Kaydet (Commit) fb61289c authored tarafından Miklos Vajna's avatar Miklos Vajna

Add SwTiledRenderingTest::testGetTextSelection() testcase.

Fails without commit 193b907b
(SwXTextDocument::getTextSelection: fix missing editeng forward,
2015-06-18).

Change-Id: I5fdab128471c12901f930b6b4ab4e2304dd3fe64
Reviewed-on: https://gerrit.libreoffice.org/16359Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
(cherry picked from commit bcace9ac)
üst 55ff3174
...@@ -15,16 +15,16 @@ namespace comphelper ...@@ -15,16 +15,16 @@ namespace comphelper
namespace LibreOfficeKit namespace LibreOfficeKit
{ {
static bool bActive(false); static bool g_bActive(false);
void setActive() void setActive(bool bActive)
{ {
bActive = true; g_bActive = bActive;
} }
bool isActive() bool isActive()
{ {
return bActive; return g_bActive;
} }
static void (*pStatusIndicatorCallback)(void *data, statusIndicatorCallbackType type, int percent)(nullptr); static void (*pStatusIndicatorCallback)(void *data, statusIndicatorCallbackType type, int percent)(nullptr);
......
...@@ -24,7 +24,7 @@ namespace LibreOfficeKit ...@@ -24,7 +24,7 @@ namespace LibreOfficeKit
// Functions to be called only from the LibreOfficeKit implementation in desktop, not from other // Functions to be called only from the LibreOfficeKit implementation in desktop, not from other
// places in LibreOffice code. // places in LibreOffice code.
COMPHELPER_DLLPUBLIC void setActive(); COMPHELPER_DLLPUBLIC void setActive(bool bActive = true);
enum class statusIndicatorCallbackType { Start, SetValue, Finish }; enum class statusIndicatorCallbackType { Start, SetValue, Finish };
......
<?xml version="1.0" encoding="UTF-8"?>
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
<office:body>
<office:text>
<text:sequence-decls>
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
</text:sequence-decls>
<text:p><draw:custom-shape text:anchor-type="paragraph" draw:z-index="0" svg:width="4.883cm" svg:height="3.225cm" svg:x="2.602cm" svg:y="1.178cm">
<text:p>Shape text</text:p>
<draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:glue-points="10800 0 3163 3163 0 10800 3163 18437 10800 21600 18437 18437 21600 10800 18437 3163" draw:text-areas="3163 3163 18437 18437" draw:type="ellipse" draw:enhanced-path="U 10800 10800 10800 10800 0 360 Z N"/>
</draw:custom-shape>Hello.</text:p>
</office:text>
</office:body>
</office:document>
...@@ -12,9 +12,12 @@ ...@@ -12,9 +12,12 @@
#include <comphelper/dispatchcommand.hxx> #include <comphelper/dispatchcommand.hxx>
#include <comphelper/propertysequence.hxx> #include <comphelper/propertysequence.hxx>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <comphelper/lok.hxx>
#include <svx/svdpage.hxx> #include <svx/svdpage.hxx>
#include <svx/svdview.hxx> #include <svx/svdview.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <editeng/editview.hxx>
#include <editeng/outliner.hxx>
#include <crsskip.hxx> #include <crsskip.hxx>
#include <drawdoc.hxx> #include <drawdoc.hxx>
#include <ndtxt.hxx> #include <ndtxt.hxx>
...@@ -31,6 +34,7 @@ public: ...@@ -31,6 +34,7 @@ public:
void testPostKeyEvent(); void testPostKeyEvent();
void testPostMouseEvent(); void testPostMouseEvent();
void testSetTextSelection(); void testSetTextSelection();
void testGetTextSelection();
void testSetGraphicSelection(); void testSetGraphicSelection();
void testResetSelection(); void testResetSelection();
void testSearch(); void testSearch();
...@@ -44,6 +48,7 @@ public: ...@@ -44,6 +48,7 @@ public:
CPPUNIT_TEST(testPostKeyEvent); CPPUNIT_TEST(testPostKeyEvent);
CPPUNIT_TEST(testPostMouseEvent); CPPUNIT_TEST(testPostMouseEvent);
CPPUNIT_TEST(testSetTextSelection); CPPUNIT_TEST(testSetTextSelection);
CPPUNIT_TEST(testGetTextSelection);
CPPUNIT_TEST(testSetGraphicSelection); CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch); CPPUNIT_TEST(testSearch);
...@@ -211,6 +216,34 @@ void SwTiledRenderingTest::testSetTextSelection() ...@@ -211,6 +216,34 @@ void SwTiledRenderingTest::testSetTextSelection()
CPPUNIT_ASSERT_EQUAL(OUString("Aaa b"), pShellCrsr->GetText()); CPPUNIT_ASSERT_EQUAL(OUString("Aaa b"), pShellCrsr->GetText());
} }
void SwTiledRenderingTest::testGetTextSelection()
{
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("shape-with-text.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
// Move the cursor into the first word.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false);
// Create a selection by on the word.
pWrtShell->SelWrd();
// Make sure that we selected text from the body text.
CPPUNIT_ASSERT_EQUAL(OString("Hello"), pXTextDocument->getTextSelection("text/plain;charset=utf-8"));
// Now select some shape text and check again.
SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
SdrObject* pObject = pPage->GetObj(0);
SdrView* pView = pWrtShell->GetDrawView();
pView->SdrBeginTextEdit(pObject);
CPPUNIT_ASSERT(pView->GetTextEditObject());
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
ESelection aWordSelection(0, 0, 0, 5);
rEditView.SetSelection(aWordSelection);
CPPUNIT_ASSERT_EQUAL(OString("Shape"), pXTextDocument->getTextSelection("text/plain;charset=utf-8"));
comphelper::LibreOfficeKit::setActive(false);
}
void SwTiledRenderingTest::testSetGraphicSelection() void SwTiledRenderingTest::testSetGraphicSelection()
{ {
SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment