[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 5 commits - sd/source sd/uiconfig sw/qa sw/source
Jan Holesovsky
kendy at collabora.com
Wed Jun 3 04:25:45 PDT 2015
sd/source/ui/app/sdstring.src | 4
sd/source/ui/app/strings.src | 8 -
sd/source/ui/inc/sdstring.hrc | 1
sd/source/ui/inc/strings.hrc | 2
sd/source/ui/view/Outliner.cxx | 114 ++++++++++--------------
sd/uiconfig/sdraw/toolbar/findbar.xml | 2
sd/uiconfig/simpress/toolbar/findbar.xml | 2
sw/qa/extras/tiledrendering/data/2-pages.odt |binary
sw/qa/extras/tiledrendering/data/search.odt |binary
sw/qa/extras/tiledrendering/tiledrendering.cxx | 118 +++++++++++++++++++++++++
sw/source/uibase/uiview/viewsrch.cxx | 15 ++-
11 files changed, 186 insertions(+), 80 deletions(-)
New commits:
commit 630b0303d33d2eca6530fdf46631fae17ba80313
Author: Jan Holesovsky <kendy at collabora.com>
Date: Thu May 28 18:23:25 2015 +0200
fdo#74132: Do not interrupt search in Impress and Draw.
Apparently this was forgotten; Writer and Calc already support this.
Change-Id: I1a187b54294cb84a1b48ef8e855cc75df3f75dd7
Reviewed-on: https://gerrit.libreoffice.org/15953
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
Tested-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
diff --git a/sd/source/ui/app/sdstring.src b/sd/source/ui/app/sdstring.src
index 2198a1a..6751765 100644
--- a/sd/source/ui/app/sdstring.src
+++ b/sd/source/ui/app/sdstring.src
@@ -18,10 +18,6 @@
*/
#include "sdstring.hrc"
-String STR_SAR_NOT_FOUND
-{
- Text [ en-US ] = "Search key not found.";
-};
String STR_SAR_WRAP_FORWARD
{
diff --git a/sd/source/ui/app/strings.src b/sd/source/ui/app/strings.src
index ed790cf..6308c02 100644
--- a/sd/source/ui/app/strings.src
+++ b/sd/source/ui/app/strings.src
@@ -459,10 +459,6 @@ String STR_OBJECTS
{
Text [ en-US ] = "Objects" ;
};
-String STR_END_SEARCHING
-{
- Text [ en-US ] = "The document search is finished." ;
-};
String STR_END_SPELLING
{
Text [ en-US ] = "Spellcheck of entire document has been completed." ;
@@ -507,10 +503,6 @@ String STR_UNDO_SET_PRESLAYOUT
{
Text [ en-US ] = "Apply presentation layout" ;
};
-String STR_STRING_NOTFOUND
-{
- Text [ en-US ] = "Search key not found." ;
-};
String STR_PLAY
{
Text [ en-US ] = "~Play" ;
diff --git a/sd/source/ui/inc/sdstring.hrc b/sd/source/ui/inc/sdstring.hrc
index 9d11d16..abf2acf 100644
--- a/sd/source/ui/inc/sdstring.hrc
+++ b/sd/source/ui/inc/sdstring.hrc
@@ -20,7 +20,6 @@
#define SID_SD_STRING_START RID_APP_START+300
// Texts for search and replace info and question boxes.
-#define STR_SAR_NOT_FOUND SID_SD_STRING_START+23
#define STR_SAR_WRAP_FORWARD SID_SD_STRING_START+24
#define STR_SAR_WRAP_BACKWARD SID_SD_STRING_START+25
#define STR_SAR_WRAP_FORWARD_DRAW SID_SD_STRING_START+26
diff --git a/sd/source/ui/inc/strings.hrc b/sd/source/ui/inc/strings.hrc
index a5da566..ca3f496a 100644
--- a/sd/source/ui/inc/strings.hrc
+++ b/sd/source/ui/inc/strings.hrc
@@ -200,7 +200,6 @@
#define STR_IMPORT_GRFILTER_TOOBIG (RID_APP_START+340)
#define STR_OBJECTS (RID_APP_START+341)
-#define STR_END_SEARCHING (RID_APP_START+342)
#define STR_END_SPELLING (RID_APP_START+343)
#define STR_NOLANGUAGE (RID_APP_START+344)
#define STR_ASK_FOR_CONVERT_TO_BEZIER (RID_APP_START+347)
@@ -210,7 +209,6 @@
#define STR_UNDO_INSERT_FILE (RID_APP_START+352)
#define STR_UNDO_INSERT_SPECCHAR (RID_APP_START+353)
#define STR_UNDO_SET_PRESLAYOUT (RID_APP_START+354)
-#define STR_STRING_NOTFOUND (RID_APP_START+355)
#define STR_PLAY (RID_APP_START+356)
#define STR_STOP (RID_APP_START+357)
#define STR_UNDO_ORIGINALSIZE (RID_APP_START+359)
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index ba96512..e073118 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -439,6 +439,9 @@ bool Outliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem)
{
bool bEndOfSearch = true;
+ // clear the search toolbar entry
+ SvxSearchDialogWrapper::SetSearchLabel(SL_Empty);
+
mpDrawDocument->GetDocSh()->SetWaitCursor( true );
if (mbPrepareSpellingPending)
PrepareSpelling();
@@ -718,8 +721,7 @@ bool Outliner::SearchAndReplaceOnce()
mpDrawDocument->GetDocSh()->SetWaitCursor( false );
// notify LibreOfficeKit about changed page
- if (pViewShell && pViewShell->GetDoc()->isTiledRendering() &&
- mbStringFound && pViewShell->ISA(DrawViewShell))
+ if (pViewShell && pViewShell->GetDoc()->isTiledRendering() && mbStringFound)
{
OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
@@ -1040,86 +1042,73 @@ void Outliner::EndOfSearch()
void Outliner::ShowEndOfSearchDialog()
{
- OUString aString;
+ mbWholeDocumentProcessed = true;
+
if (meMode == SEARCH)
{
- if (mbStringFound)
- aString = SD_RESSTR(STR_END_SEARCHING);
- else
+ if (!mbStringFound)
{
- aString = SD_RESSTR(STR_STRING_NOTFOUND);
+ SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
mpDrawDocument->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_NOT_FOUND,
- mpSearchItem->GetSearchString().toUtf8().getStr());
-
+ mpSearchItem->GetSearchString().toUtf8().getStr());
}
+
+ // don't do anything else for search
+ return;
}
+
+ OUString aString;
+ if (mpView->AreObjectsMarked())
+ aString = SD_RESSTR(STR_END_SPELLING_OBJ);
else
- {
- if (mpView->AreObjectsMarked())
- aString = SD_RESSTR(STR_END_SPELLING_OBJ);
- else
- aString = SD_RESSTR(STR_END_SPELLING);
- }
+ aString = SD_RESSTR(STR_END_SPELLING);
// Show the message in an info box that is modal with respect to the
// whole application.
ScopedVclPtrInstance< MessageDialog > aInfoBox(nullptr, aString, VCL_MESSAGE_INFO);
-
ShowModalMessageBox (*aInfoBox.get());
-
- mbWholeDocumentProcessed = true;
}
bool Outliner::ShowWrapArroundDialog()
{
- bool bDoWrapArround = false;
-
// Determine whether to show the dialog.
- bool bShowDialog = false;
- if (mpSearchItem != NULL)
+ if (mpSearchItem)
{
// When searching display the dialog only for single find&replace.
- const SvxSearchCmd nCommand (mpSearchItem->GetCommand());
- bShowDialog = (nCommand==SvxSearchCmd::REPLACE)
- || (nCommand==SvxSearchCmd::FIND);
- }
- else
- // Spell checking needs the dialog, too.
- bShowDialog = (meMode == SPELL);
-
- boost::shared_ptr<ViewShell> pViewShell(mpWeakViewShell.lock());
- if (pViewShell && pViewShell->GetDoc()->isTiledRendering())
- {
- // Wrap around without asking anything.
- bShowDialog = false;
- bDoWrapArround = true;
- }
+ const SvxSearchCmd nCommand(mpSearchItem->GetCommand());
+ if (nCommand == SvxSearchCmd::REPLACE || nCommand == SvxSearchCmd::FIND)
+ {
+ if (mbDirectionIsForward)
+ SvxSearchDialogWrapper::SetSearchLabel(SL_End);
+ else
+ SvxSearchDialogWrapper::SetSearchLabel(SL_Start);
- if (bShowDialog)
- {
- // The question text depends on the search direction.
- bool bImpress = mpDrawDocument!=NULL
- && mpDrawDocument->GetDocumentType() == DOCUMENT_TYPE_IMPRESS;
- sal_uInt16 nStringId;
- if (mbDirectionIsForward)
- nStringId = bImpress
- ? STR_SAR_WRAP_FORWARD
- : STR_SAR_WRAP_FORWARD_DRAW;
+ return true;
+ }
else
- nStringId = bImpress
- ? STR_SAR_WRAP_BACKWARD
- : STR_SAR_WRAP_BACKWARD_DRAW;
-
- // Pop up question box that asks the user whether to wrap around.
- // The dialog is made modal with respect to the whole application.
- ScopedVclPtrInstance<QueryBox> aQuestionBox (
- nullptr, WB_YES_NO | WB_DEF_YES, SD_RESSTR(nStringId));
- aQuestionBox->SetImage (QueryBox::GetStandardImage());
- sal_uInt16 nBoxResult = ShowModalMessageBox(*aQuestionBox.get());
- bDoWrapArround = (nBoxResult == RET_YES);
+ return false;
}
- return bDoWrapArround;
+ // show dialog only for spelling
+ if (meMode != SPELL)
+ return false;
+
+ // The question text depends on the search direction.
+ bool bImpress = mpDrawDocument && mpDrawDocument->GetDocumentType() == DOCUMENT_TYPE_IMPRESS;
+
+ sal_uInt16 nStringId;
+ if (mbDirectionIsForward)
+ nStringId = bImpress ? STR_SAR_WRAP_FORWARD : STR_SAR_WRAP_FORWARD_DRAW;
+ else
+ nStringId = bImpress ? STR_SAR_WRAP_BACKWARD : STR_SAR_WRAP_BACKWARD_DRAW;
+
+ // Pop up question box that asks the user whether to wrap around.
+ // The dialog is made modal with respect to the whole application.
+ ScopedVclPtrInstance<QueryBox> aQuestionBox(nullptr, WB_YES_NO | WB_DEF_YES, SD_RESSTR(nStringId));
+ aQuestionBox->SetImage(QueryBox::GetStandardImage());
+ sal_uInt16 nBoxResult = ShowModalMessageBox(*aQuestionBox.get());
+
+ return (nBoxResult == RET_YES);
}
bool Outliner::IsValidTextObject (const ::sd::outliner::IteratorPosition& rPosition)
@@ -1375,16 +1364,15 @@ bool Outliner::HandleFailedSearch()
// that there is no match.
if (HasNoPreviousMatch ())
{
- // No match found in the whole presentation. Tell the user.
- ScopedVclPtrInstance< InfoBox > aInfoBox(nullptr, SD_RESSTR(STR_SAR_NOT_FOUND));
- ShowModalMessageBox (*aInfoBox.get());
+ // No match found in the whole presentation.
+ SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
}
else
{
// No further matches found. Ask the user whether to wrap
// around and start again.
- bContinueSearch = ShowWrapArroundDialog ();
+ bContinueSearch = ShowWrapArroundDialog();
}
}
diff --git a/sd/uiconfig/sdraw/toolbar/findbar.xml b/sd/uiconfig/sdraw/toolbar/findbar.xml
index 4e8ec6b..807ffbf 100644
--- a/sd/uiconfig/sdraw/toolbar/findbar.xml
+++ b/sd/uiconfig/sdraw/toolbar/findbar.xml
@@ -26,4 +26,6 @@
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
+ <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:SearchLabel"/>
</toolbar:toolbar>
diff --git a/sd/uiconfig/simpress/toolbar/findbar.xml b/sd/uiconfig/simpress/toolbar/findbar.xml
index 4e8ec6b..807ffbf 100644
--- a/sd/uiconfig/simpress/toolbar/findbar.xml
+++ b/sd/uiconfig/simpress/toolbar/findbar.xml
@@ -26,4 +26,6 @@
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
+ <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:SearchLabel"/>
</toolbar:toolbar>
commit b6a895d8d03e6dd46e12e4d70361f4003c902cce
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jun 3 09:03:48 2015 +0200
SwView::SearchAndWrap: fix WrapAround search in fly frames
First, SttDoc() / EndDoc() is the implementation of Ctrl-Home, i.e. it
goes to the start of the current text (like a fly frame), not to the
start of the whole document. When wrapping around, we want the later.
Second, if the normal search have two passes, first searching in the
body text, then searching in the special sections, then the wrap-around
search should do the same.
Change-Id: I0b7466c80476f6fb45174be19215a5d68374d047
(cherry picked from commit c88802829832a315550cb7e19e17030dc4c2bd77)
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index ba8237e..b139b16 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -26,6 +26,7 @@ static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
class SwTiledRenderingTest : public SwModelTestBase
{
public:
+ SwTiledRenderingTest();
void testRegisterCallback();
void testPostKeyEvent();
void testPostMouseEvent();
@@ -35,6 +36,7 @@ public:
void testSearch();
void testSearchViewArea();
void testSearchTextFrame();
+ void testSearchTextFrameWrapAround();
void testDocumentSizeChanged();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
@@ -47,6 +49,7 @@ public:
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchViewArea);
CPPUNIT_TEST(testSearchTextFrame);
+ CPPUNIT_TEST(testSearchTextFrameWrapAround);
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST_SUITE_END();
@@ -57,8 +60,14 @@ private:
Rectangle m_aInvalidation;
Size m_aDocumentSize;
OString m_aTextSelection;
+ bool m_bFound;
};
+SwTiledRenderingTest::SwTiledRenderingTest()
+ : m_bFound(true)
+{
+}
+
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
{
load(DATA_DIRECTORY, pName);
@@ -106,6 +115,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
m_aTextSelection = pPayload;
}
break;
+ case LOK_CALLBACK_SEARCH_NOT_FOUND:
+ {
+ m_bFound = false;
+ }
+ break;
}
}
@@ -342,6 +356,24 @@ void SwTiledRenderingTest::testSearchTextFrame()
#endif
}
+void SwTiledRenderingTest::testSearchTextFrameWrapAround()
+{
+#if !defined(WNT) && !defined(MACOSX)
+ SwXTextDocument* pXTextDocument = createDoc("search.odt");
+ pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
+ {"SearchItem.Backward", uno::makeAny(false)},
+ }));
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+ CPPUNIT_ASSERT(m_bFound);
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+ // This failed, i.e. the second time 'not found' was reported, instead of wrapping around.
+ CPPUNIT_ASSERT(m_bFound);
+#endif
+}
+
void SwTiledRenderingTest::testDocumentSizeChanged()
{
#if !defined(WNT) && !defined(MACOSX)
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index dbd792b..94b987a 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -554,13 +554,24 @@ bool SwView::SearchAndWrap(bool bApi)
if (bHasSrchInOther)
{
m_pWrtShell->ClearMark();
+ // Select the start or the end of the entire document
if (bSrchBkwrd)
- m_pWrtShell->EndDoc();
+ m_pWrtShell->SttEndDoc(false);
else
- m_pWrtShell->SttDoc();
+ m_pWrtShell->SttEndDoc(true);
}
m_bFound = bool(FUNC_Search( aOpts ));
+
+ // If WrapAround found no matches in the body text, search in the special
+ // sections, too.
+ if (!m_bFound && !m_pSrchItem->GetSelection() && !m_bExtra)
+ {
+ m_bExtra = true;
+ if (FUNC_Search(aOpts))
+ m_bFound = true;
+ }
+
m_pWrtShell->EndAllAction();
pWait.reset();
#if HAVE_FEATURE_DESKTOP
commit ffac19f7fe42826df423448e94d8628b0c3f47ac
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jun 2 15:26:56 2015 +0200
CppunitTest_sw_tiledrendering: add TextFrame search testcase
Fails without commit 2d17cd6b03a214393755ddfed5ba50a18f0cd774 (sw:
LOK_CALLBACK_TEXT_SELECTION should be the union of all selections,
2015-06-02).
Change-Id: I1d45eabf53dadd24051ff46acbf4bbfb85fb60a9
(cherry picked from commit 3f3ea9fadd6dc643fbd12e99075a23d59ff73207)
diff --git a/sw/qa/extras/tiledrendering/data/search.odt b/sw/qa/extras/tiledrendering/data/search.odt
index 9d98145..76ab2e1 100644
Binary files a/sw/qa/extras/tiledrendering/data/search.odt and b/sw/qa/extras/tiledrendering/data/search.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index c8d4b92..ba8237e 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -34,6 +34,7 @@ public:
void testResetSelection();
void testSearch();
void testSearchViewArea();
+ void testSearchTextFrame();
void testDocumentSizeChanged();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
@@ -45,6 +46,7 @@ public:
CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchViewArea);
+ CPPUNIT_TEST(testSearchTextFrame);
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST_SUITE_END();
@@ -54,6 +56,7 @@ private:
void callbackImpl(int nType, const char* pPayload);
Rectangle m_aInvalidation;
Size m_aDocumentSize;
+ OString m_aTextSelection;
};
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
@@ -98,6 +101,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
m_aDocumentSize.setHeight(aSeq[1].toInt32());
}
break;
+ case LOK_CALLBACK_TEXT_SELECTION:
+ {
+ m_aTextSelection = pPayload;
+ }
+ break;
}
}
@@ -318,6 +326,22 @@ void SwTiledRenderingTest::testSearchViewArea()
#endif
}
+void SwTiledRenderingTest::testSearchTextFrame()
+{
+#if !defined(WNT) && !defined(MACOSX)
+ SwXTextDocument* pXTextDocument = createDoc("search.odt");
+ pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
+ {"SearchItem.Backward", uno::makeAny(false)},
+ }));
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+ // This was empty: nothing was highlighted after searching for 'TextFrame'.
+ CPPUNIT_ASSERT(!m_aTextSelection.isEmpty());
+#endif
+}
+
void SwTiledRenderingTest::testDocumentSizeChanged()
{
#if !defined(WNT) && !defined(MACOSX)
commit 53f4074107bdcf4938cc92e6d6c5d48208e8f88e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jun 1 17:01:21 2015 +0200
CppunitTest_sw_tiledrendering: add search start point testcase
Fails without the sw/source hunk of commit
1dc60bc9e99304c58007bfd5a964ff3f78480106 (SvxSearchItem: add
m_nStartPoint{X,Y}, 2015-05-28).
Change-Id: I7b13294760a8a3c9c413a4a11582bc2a14d3d499
(cherry picked from commit 54619b4fa1cc477c92d0fa48cafffefe1b15a8fe)
diff --git a/sw/qa/extras/tiledrendering/data/search.odt b/sw/qa/extras/tiledrendering/data/search.odt
index 5fb02fa..9d98145 100644
Binary files a/sw/qa/extras/tiledrendering/data/search.odt and b/sw/qa/extras/tiledrendering/data/search.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index a6dbe60..c8d4b92 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -33,6 +33,7 @@ public:
void testSetGraphicSelection();
void testResetSelection();
void testSearch();
+ void testSearchViewArea();
void testDocumentSizeChanged();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
@@ -43,6 +44,7 @@ public:
CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch);
+ CPPUNIT_TEST(testSearchViewArea);
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST_SUITE_END();
@@ -289,6 +291,33 @@ void SwTiledRenderingTest::testSearch()
#endif
}
+void SwTiledRenderingTest::testSearchViewArea()
+{
+#if !defined(WNT) && !defined(MACOSX)
+ SwXTextDocument* pXTextDocument = createDoc("search.odt");
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ // Go to the second page, 1-based.
+ pWrtShell->GotoPage(2, false);
+ SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
+ // Get the ~top left corner of the second page.
+ Point aPoint = pShellCrsr->GetSttPos();
+
+ // Go back to the first page, search while the cursor is there, but the
+ // visible area is the second page.
+ pWrtShell->GotoPage(1, false);
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"SearchItem.SearchString", uno::makeAny(OUString("Heading"))},
+ {"SearchItem.Backward", uno::makeAny(false)},
+ {"SearchItem.SearchStartPointX", uno::makeAny(static_cast<sal_Int32>(aPoint.getX()))},
+ {"SearchItem.SearchStartPointY", uno::makeAny(static_cast<sal_Int32>(aPoint.getY()))}
+ }));
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+ // This was just "Heading", i.e. SwView::SearchAndWrap() did not search from only the top of the second page.
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading on second page"), pShellCrsr->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
+#endif
+}
+
void SwTiledRenderingTest::testDocumentSizeChanged()
{
#if !defined(WNT) && !defined(MACOSX)
commit 368903eedd638c1f2bf7a26360d8d8b09013ca3e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri May 29 12:05:32 2015 +0200
LOK: add DOCUMENT_SIZE_CHANGED testcase
This failed without the SwViewShell::SizeChgNotify() hunk of commit
63a40c45018ad2e6f4a660a520a5907beb1d7801 (LOK: change PAGE_COUNT to a
more generic DOCUMENT_SIZE, 2015-05-27).
Change-Id: Id230420f60d1a6f3caf822f7e23ffca010919196
(cherry picked from commit 560c3fdca41843c29ea33c1e9c14429537f4e4b6)
diff --git a/sw/qa/extras/tiledrendering/data/2-pages.odt b/sw/qa/extras/tiledrendering/data/2-pages.odt
new file mode 100644
index 0000000..04953e5
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/2-pages.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 4d6cc99..a6dbe60 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -33,6 +33,7 @@ public:
void testSetGraphicSelection();
void testResetSelection();
void testSearch();
+ void testDocumentSizeChanged();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -42,6 +43,7 @@ public:
CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch);
+ CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST_SUITE_END();
private:
@@ -49,6 +51,7 @@ private:
static void callback(int nType, const char* pPayload, void* pData);
void callbackImpl(int nType, const char* pPayload);
Rectangle m_aInvalidation;
+ Size m_aDocumentSize;
};
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
@@ -75,6 +78,8 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
if (m_aInvalidation.IsEmpty())
{
uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
+ if (OString("EMPTY") == pPayload)
+ return;
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
m_aInvalidation.setX(aSeq[0].toInt32());
m_aInvalidation.setY(aSeq[1].toInt32());
@@ -83,6 +88,14 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
}
}
break;
+ case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
+ {
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aSeq.getLength());
+ m_aDocumentSize.setWidth(aSeq[0].toInt32());
+ m_aDocumentSize.setHeight(aSeq[1].toInt32());
+ }
+ break;
}
}
@@ -276,6 +289,26 @@ void SwTiledRenderingTest::testSearch()
#endif
}
+void SwTiledRenderingTest::testDocumentSizeChanged()
+{
+#if !defined(WNT) && !defined(MACOSX)
+ // Get the current document size.
+ SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
+ pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pXTextDocument->initializeForTiledRendering();
+ Size aSize = pXTextDocument->getDocumentSize();
+
+ // Delete the second page and see how the size changes.
+ pWrtShell->Down(false);
+ pWrtShell->DelLeft();
+ // Document width should not change, this was 0.
+ CPPUNIT_ASSERT_EQUAL(aSize.getWidth(), m_aDocumentSize.getWidth());
+ // Document height should be smaller now.
+ CPPUNIT_ASSERT(aSize.getHeight() > m_aDocumentSize.getHeight());
+#endif
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list