desktop/qa/desktop_lib/test_desktop_lib.cxx | 8 ++++ editeng/source/editeng/impedit3.cxx | 5 ++ sd/qa/unit/tiledrendering/data/search-all.odp |binary sd/qa/unit/tiledrendering/tiledrendering.cxx | 40 +++++++++++++++++++- sd/source/ui/view/Outliner.cxx | 51 ++++++++++++++++++++++++-- vcl/source/outdev/bitmap.cxx | 11 +++-- 6 files changed, 106 insertions(+), 9 deletions(-)
New commits: commit 67dd4613f0dd0508383ba0606621b628789e0d4e Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Oct 16 11:24:11 2015 +0200 sd tiled rendering: emit CALLBACK_TEXT_SELECTION on multiple search results (cherry picked from commit d8bc93ef118c75f48685d5f6d121ad7eabf2a80c) Conflicts: sd/source/ui/view/Outliner.cxx Change-Id: Ib6be973bf7c911907c793571b84021dc317dcc80 diff --git a/sd/qa/unit/tiledrendering/data/search-all.odp b/sd/qa/unit/tiledrendering/data/search-all.odp index 0fd069c..46ddaf4 100644 Binary files a/sd/qa/unit/tiledrendering/data/search-all.odp and b/sd/qa/unit/tiledrendering/data/search-all.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 0af3bf9..830911d 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -53,6 +53,7 @@ public: void testResetSelection(); void testSearch(); void testSearchAll(); + void testSearchAllSelections(); #endif CPPUNIT_TEST_SUITE(SdTiledRenderingTest); @@ -66,6 +67,7 @@ public: CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testSearch); CPPUNIT_TEST(testSearchAll); + CPPUNIT_TEST(testSearchAllSelections); #endif CPPUNIT_TEST_SUITE_END(); @@ -436,6 +438,18 @@ void SdTiledRenderingTest::testSearchAll() CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart); } +void SdTiledRenderingTest::testSearchAllSelections() +{ + SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); + pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + + lcl_search("third", /*bFindAll=*/true); + // Make sure this is found on the 3rd slide. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), m_nPart); + // This was 1: only the first match was highlighted. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSelection.size()); +} + #endif CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index ab7fc9c..e4c508a 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -611,6 +611,7 @@ bool Outliner::SearchAndReplaceAll() return true; } + std::vector<SearchSelection> aSelections; if (pViewShell->ISA(OutlineViewShell)) { // Put the cursor to the beginning/end of the outliner. @@ -633,7 +634,6 @@ bool Outliner::SearchAndReplaceAll() // Search/replace until the end of the document is reached. bool bFoundMatch; - std::vector<SearchSelection> aSelections; do { bFoundMatch = ! SearchAndReplaceOnce(&aSelections); @@ -679,6 +679,19 @@ bool Outliner::SearchAndReplaceAll() // Find-all, tiled rendering and we have at least one match. OString aPayload = OString::number(mnStartPageIndex); pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr()); + + // Emit a selection callback here: + // 1) The original one is no longer valid, as we there was a SET_PART in between + // 2) The underlying editeng will only talk about the first match till + // it doesn't support multi-selection. + std::vector<OString> aRectangles; + for (const SearchSelection& rSelection : aSelections) + { + if (rSelection.m_nPage == mnStartPageIndex) + aRectangles.push_back(rSelection.m_aRectangles); + } + OString sRectangles = comphelper::string::join("; ", aRectangles); + pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangles.getStr()); } mnStartPageIndex = (sal_uInt16)-1; commit bedb5bf0902a5728f088cce8862738c4709bc135 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Oct 16 09:45:52 2015 +0200 editeng tiled rendering: avoid selections callbacks in Paint() Given that we emit selection callbacks on each logical operations (set selection, deselect all, etc) already, it's not necessary to emit callbacks in DrawSelection() when it's called from Paint(). Change-Id: I6781c71ee2f292de2a1c7d129fc49b514aca2be1 (cherry picked from commit c8bfca547d822a75ddfdd33903deae3fb6488789) diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index fb071e0..0f38709 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -3851,7 +3851,10 @@ void ImpEditEngine::Paint( ImpEditView* pView, const Rectangle& rRect, OutputDev else pTarget->SetClipRegion(); - pView->DrawSelection(pView->GetEditSelection(), 0, pTarget); + // In case of tiled rendering pass a region to DrawSelection(), so that + // selection callbacks are not emitted during every repaint. + vcl::Region aRegion; + pView->DrawSelection(pView->GetEditSelection(), pView->isTiledRendering() ? &aRegion : 0, pTarget); } } commit ca8ca3c1a6bec44e41174dea340961ba00a1e976 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 15 17:18:28 2015 +0200 vcl: aAlphaBitmap.ImplGetImpBitmap() seen as 0 Change-Id: I3f34f0315045d33ff6e498e24c0dacb0aabb0ff9 (cherry picked from commit 293dd731e9815c06ba8eca1fb83d86276103c820) diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index c3cc748..df8723b 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -298,6 +298,14 @@ void DesktopLOKTest::testPaintTile() // 256. pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); + // This crashed in OutputDevice::DrawDeviceAlphaBitmap(). + nCanvasWidth = 200; + nCanvasHeight = 200; + nTileWidth = 4000; + nTileHeight = 4000; + aBuffer.resize(nCanvasWidth * nCanvasHeight * 4); + pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); + closeDoc(); } diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 2ae0236..1ca0418 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -670,11 +670,14 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r if (mpAlphaVDev) { Bitmap aAlphaBitmap( mpAlphaVDev->GetBitmap( aRelPt, aOutSz ) ); - SalBitmap* pSalAlphaBmp2 = aAlphaBitmap.ImplGetImpBitmap()->ImplGetSalBitmap(); - if (mpGraphics->BlendAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, *pSalAlphaBmp2, this)) + if (aAlphaBitmap.ImplGetImpBitmap()) { - mpAlphaVDev->BlendBitmap(aTR, rAlpha); - return; + SalBitmap* pSalAlphaBmp2 = aAlphaBitmap.ImplGetImpBitmap()->ImplGetSalBitmap(); + if (mpGraphics->BlendAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, *pSalAlphaBmp2, this)) + { + mpAlphaVDev->BlendBitmap(aTR, rAlpha); + return; + } } } else commit 66f33819810e50ee39d468789edd4b6839d28d12 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 15 16:56:14 2015 +0200 sd tiled rendering: implement CALLBACK_SET_PART for find-all Change-Id: I607b3719e0f508f9ae24db7482323847aa8e2491 (cherry picked from commit 6a35a75a6bb2753f40edf59f360130e452b3c7f0) diff --git a/sd/qa/unit/tiledrendering/data/search-all.odp b/sd/qa/unit/tiledrendering/data/search-all.odp index cb3cb31..0fd069c 100644 Binary files a/sd/qa/unit/tiledrendering/data/search-all.odp and b/sd/qa/unit/tiledrendering/data/search-all.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 586263e..0af3bf9 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -421,12 +421,19 @@ void SdTiledRenderingTest::testSearch() void SdTiledRenderingTest::testSearchAll() { SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); + pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); lcl_search("match", /*bFindAll=*/true); OString aUsedFormat; // This was empty: find-all did not highlight the first match. CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat)); + + // We're on the first slide, search for something on the second slide and make sure we get a SET_PART. + m_nPart = 0; + lcl_search("second", /*bFindAll=*/true); + // This was 0: no SET_PART was emitted. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart); } #endif diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index 581d9d2..ab7fc9c 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -673,6 +673,14 @@ bool Outliner::SearchAndReplaceAll() } RestoreStartPosition (); + + if (mpSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL && pViewShell->GetDoc()->isTiledRendering() && !bRet) + { + // Find-all, tiled rendering and we have at least one match. + OString aPayload = OString::number(mnStartPageIndex); + pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr()); + } + mnStartPageIndex = (sal_uInt16)-1; return bRet; commit d1a3aae419c63fe93a280cf265716b857a02858f Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 15 15:20:23 2015 +0200 sd tiled rendering: let find-all at least select the first match physically The LOK API can describe a multi-selection, so find-all can signal all matches, editeng can have a single selection only. Instead of having no selections after a find-all, select the first match, so e.g. copy works. Change-Id: I0eab2565916f0c3cce5d77279c0d927ad4b7054c (cherry picked from commit cd4976988cf3acb4f1a23f1df7fcc2bfec0f3da0) diff --git a/sd/qa/unit/tiledrendering/data/search-all.odp b/sd/qa/unit/tiledrendering/data/search-all.odp new file mode 100644 index 0000000..cb3cb31 Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/search-all.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 33c3683..586263e 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -23,6 +23,7 @@ #include <editeng/outliner.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> +#include <svl/srchitem.hxx> #include <DrawDocShell.hxx> #include <ViewShell.hxx> @@ -51,6 +52,7 @@ public: void testSetGraphicSelection(); void testResetSelection(); void testSearch(); + void testSearchAll(); #endif CPPUNIT_TEST_SUITE(SdTiledRenderingTest); @@ -63,6 +65,7 @@ public: CPPUNIT_TEST(testSetGraphicSelection); CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testSearch); + CPPUNIT_TEST(testSearchAll); #endif CPPUNIT_TEST_SUITE_END(); @@ -371,12 +374,13 @@ void SdTiledRenderingTest::testResetSelection() CPPUNIT_ASSERT(!pView->GetTextEditObject()); } -static void lcl_search(const OUString& rKey) +static void lcl_search(const OUString& rKey, bool bFindAll = false) { uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"SearchItem.SearchString", uno::makeAny(rKey)}, - {"SearchItem.Backward", uno::makeAny(false)} + {"SearchItem.Backward", uno::makeAny(false)}, + {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(bFindAll ? SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND))}, })); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); } @@ -414,6 +418,17 @@ void SdTiledRenderingTest::testSearch() CPPUNIT_ASSERT_EQUAL(false, m_bFound); } +void SdTiledRenderingTest::testSearchAll() +{ + SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); + + lcl_search("match", /*bFindAll=*/true); + + OString aUsedFormat; + // This was empty: find-all did not highlight the first match. + CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat)); +} + #endif CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index 13daf03..581d9d2 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -599,6 +599,7 @@ void Outliner::Initialize (bool bDirectionIsForward) bool Outliner::SearchAndReplaceAll() { + bool bRet = true; // Save the current position to be restored after having replaced all // matches. RememberStartPosition (); @@ -636,6 +637,16 @@ bool Outliner::SearchAndReplaceAll() do { bFoundMatch = ! SearchAndReplaceOnce(&aSelections); + if (mpSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL && pViewShell->GetDoc()->isTiledRendering() && bFoundMatch && aSelections.size() == 1) + { + // Without this, RememberStartPosition() will think it already has a remembered position. + mnStartPageIndex = (sal_uInt16)-1; + + RememberStartPosition(); + + // So when RestoreStartPosition() restores the first match, then spellchecker doesn't kill the selection. + bRet = false; + } } while (bFoundMatch); @@ -664,7 +675,7 @@ bool Outliner::SearchAndReplaceAll() RestoreStartPosition (); mnStartPageIndex = (sal_uInt16)-1; - return true; + return bRet; } bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections) commit 05bb293c72b19bc6a1e20abb4275ab11fed2faf7 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 15 15:03:46 2015 +0200 sd search: restore start selection if nothing was found For one, if sd::Outliner::RememberStartPosition() cares about storing the current selection in the DrawViewShell case in maStartSelection, then sd::Outliner::RestoreStartPosition() should probably restore it. For another, sd::Outliner::StartSearchAndReplace() returned true in the "nothing was found" case, which restarted the spellchecking, which killed the selection. If the selection has been restored already, then at least don't kill it in the find case: find is read-only, so no need to restart the spellchecker. Change-Id: Idd886d449a9cfb164887fc6b1fde27b5e63e272b (cherry picked from commit aa8f218079e2d311927d8aaf64b03b234453fb11) diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index b5d394c..13daf03 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -504,7 +504,12 @@ bool Outliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem) bEndOfSearch = SearchAndReplaceOnce (); // restore start position if nothing was found if(!mbStringFound) + { RestoreStartPosition (); + // Nothing was changed, no need to restart the spellchecker. + if (nCommand == SvxSearchCmd::FIND) + bEndOfSearch = false; + } mnStartPageIndex = (sal_uInt16)-1; } @@ -962,7 +967,17 @@ void Outliner::RestoreStartPosition() ::boost::dynamic_pointer_cast<DrawViewShell>(pViewShell)); SetViewMode (meStartViewMode); if (pDrawViewShell.get() != NULL) + { SetPage (meStartEditMode, mnStartPageIndex); + mpObj = mpStartEditedObject; + if (mpObj) + { + PutTextIntoOutliner(); + EnterEditMode(false); + if (OutlinerView* pOutlinerView = mpImpl->GetOutlinerView()) + pOutlinerView->SetSelection(maStartSelection); + } + } } else if (pViewShell->ISA(OutlineViewShell)) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits