summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-14 14:20:40 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-14 16:00:08 +0100
commit8cdc1e85f60bdb8340ef7a001222b777b194fab3 (patch)
tree5002999bfb7e7fc590e279918c8153f208fac534
parent70c946d1682d019e12cd447fdf4d6a523b899ba4 (diff)
editeng: handle SdrModel::isTiledSearching()
Given that the edit/outliner views can come and go, avoid the lifecycle problems with just passing a pointer to the sdr model to editeng, and then it'll always have the up to date "are we searching" information. editeng can't depend on svx, so provide an interface class SdrModel can implement. (cherry picked from commit 7b5d20983dfbfb458898eeab54828ba5fef5841f) Conflicts: editeng/source/editeng/editview.cxx editeng/source/editeng/impedit.cxx include/editeng/outliner.hxx sd/qa/unit/tiledrendering/tiledrendering.cxx svx/source/svdraw/svdedxv.cxx sw/inc/PostItMgr.hxx sw/source/uibase/docvw/PostItMgr.cxx sw/source/uibase/docvw/SidebarWin.cxx Change-Id: I3b98011593b00ac0fab05b6b9c591dd20d94c579
-rw-r--r--editeng/source/editeng/editview.cxx4
-rw-r--r--editeng/source/editeng/impedit.cxx17
-rw-r--r--editeng/source/editeng/impedit.hxx4
-rw-r--r--editeng/source/outliner/outlvw.cxx8
-rw-r--r--include/editeng/editview.hxx3
-rw-r--r--include/editeng/outliner.hxx11
-rw-r--r--include/svx/svdmodel.hxx3
-rw-r--r--sc/source/ui/app/inputhdl.cxx2
-rw-r--r--sc/source/ui/view/viewdata.cxx3
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx27
-rw-r--r--svx/source/svdraw/svdedxv.cxx2
-rw-r--r--sw/inc/PostItMgr.hxx3
-rw-r--r--sw/source/core/view/viewsh.cxx2
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx4
-rw-r--r--sw/source/uibase/docvw/SidebarWin.cxx2
15 files changed, 76 insertions, 19 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 66a49ed925de..2a418b5c3cd7 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -592,9 +592,9 @@ bool EditView::isTiledRendering()
return pImpEditView->isTiledRendering();
}
-void EditView::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData)
+void EditView::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData, OutlinerSearchable *pSearchable)
{
- pImpEditView->registerLibreOfficeKitCallback(pCallback, pLibreOfficeKitData);
+ pImpEditView->registerLibreOfficeKitCallback(pCallback, pLibreOfficeKitData, pSearchable);
}
void EditView::SetControlWord( EVControlBits nWord )
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 7ee1a2bc0ba2..5ac794a3fb2f 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -26,6 +26,7 @@
#include <impedit.hxx>
#include <editeng/editeng.hxx>
#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
#include <tools/poly.hxx>
#include <editeng/unolingu.hxx>
#include <com/sun/star/linguistic2/XDictionaryEntry.hpp>
@@ -81,6 +82,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
mbTiledRendering = false;
mpLibreOfficeKitCallback = 0;
mpLibreOfficeKitData = 0;
+ mpLibreOfficeKitSearchable = 0;
nScrollDiffX = 0;
nExtraCursorFlags = 0;
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
@@ -128,14 +130,27 @@ bool ImpEditView::isTiledRendering() const
return mbTiledRendering;
}
-void ImpEditView::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
+void ImpEditView::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData, OutlinerSearchable* pSearchable)
{
mpLibreOfficeKitCallback = pCallback;
mpLibreOfficeKitData = pData;
+ mpLibreOfficeKitSearchable = pSearchable;
}
void ImpEditView::libreOfficeKitCallback(int nType, const char* pPayload) const
{
+ if (mpLibreOfficeKitSearchable && mpLibreOfficeKitSearchable->isTiledSearching())
+ {
+ switch (nType)
+ {
+ case LOK_CALLBACK_TEXT_SELECTION:
+ case LOK_CALLBACK_TEXT_SELECTION_START:
+ case LOK_CALLBACK_TEXT_SELECTION_END:
+ case LOK_CALLBACK_GRAPHIC_SELECTION:
+ return;
+ }
+ }
+
if (mpLibreOfficeKitCallback)
mpLibreOfficeKitCallback(nType, pPayload, mpLibreOfficeKitData);
}
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 7b24e6e790b7..a44e3356e44f 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -78,6 +78,7 @@
class EditView;
class EditEngine;
+class OutlinerSearchable;
class SvxSearchItem;
class SvxLRSpaceItem;
@@ -223,6 +224,7 @@ private:
bool mbTiledRendering;
LibreOfficeKitCallback mpLibreOfficeKitCallback;
void* mpLibreOfficeKitData;
+ OutlinerSearchable* mpLibreOfficeKitSearchable;
EditEngine* pEditEngine;
VclPtr<vcl::Window> pOutWin;
Pointer* pPointer;
@@ -375,7 +377,7 @@ public:
void setTiledRendering(bool bTiledRendering);
bool isTiledRendering() const;
/// @see vcl::ITiledRenderable::registerCallback().
- void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
+ void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData, OutlinerSearchable* pSearchable);
/// Invokes the registered callback, if there are any.
void libreOfficeKitCallback(int nType, const char* pPayload) const;
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 329b5f3c0ed4..6b918f410084 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1430,9 +1430,9 @@ void OutlinerView::setTiledRendering(bool bTiledRendering)
pEditView->setTiledRendering(bTiledRendering);
}
-void OutlinerView::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData)
+void OutlinerView::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData, OutlinerSearchable* pSearchable)
{
- pEditView->registerLibreOfficeKitCallback(pCallback, pLibreOfficeKitData);
+ pEditView->registerLibreOfficeKitCallback(pCallback, pLibreOfficeKitData, pSearchable);
}
Color OutlinerView::GetBackgroundColor()
@@ -1460,7 +1460,9 @@ Selection OutlinerView::GetSurroundingTextSelection() const
return pEditView->GetSurroundingTextSelection();
}
-
+OutlinerSearchable::~OutlinerSearchable()
+{
+}
// ===== some code for thesaurus sub menu within context menu
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 41146fac63a5..d3a1c04d6e5a 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -36,6 +36,7 @@
class EditEngine;
class ImpEditEngine;
class ImpEditView;
+class OutlinerSearchable;
class SvxSearchItem;
class SvxFieldItem;
namespace vcl { class Window; }
@@ -178,7 +179,7 @@ public:
void setTiledRendering(bool bTiledRendering);
bool isTiledRendering();
/// @see vcl::ITiledRenderable::registerCallback().
- void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
+ void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData, OutlinerSearchable *pSearchable);
void SetControlWord( EVControlBits nWord );
EVControlBits GetControlWord() const;
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index dddb221ec9cc..c6c078f9fc6e 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -72,6 +72,7 @@ class SvxLRSpaceItem;
class EditEngine;
class SvKeyValueIterator;
class SvxForbiddenCharactersTable;
+class OutlinerSearchable;
namespace svl
{
@@ -274,7 +275,7 @@ public:
/// Set if we are doing tiled rendering.
void setTiledRendering(bool bTiledRendering);
/// @see vcl::ITiledRenderable::registerCallback().
- void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
+ void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData, OutlinerSearchable* pSearchable);
SfxItemSet GetAttribs();
@@ -374,6 +375,14 @@ public:
Selection GetSurroundingTextSelection() const;
};
+/// Interface class to know if we do tiled searching.
+class EDITENG_DLLPUBLIC OutlinerSearchable
+{
+public:
+ virtual ~OutlinerSearchable();
+
+ virtual bool isTiledSearching() const = 0;
+};
// some thesaurus functionality to avoid code duplication in different projects...
bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView );
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 99bdf72c03ba..d007da426b2e 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <cppuhelper/weakref.hxx>
#include <editeng/forbiddencharacterstable.hxx>
+#include <editeng/outliner.hxx>
#include <rtl/ustring.hxx>
#include <tools/link.hxx>
#include <tools/weakbase.hxx>
@@ -149,7 +150,7 @@ public:
struct SdrModelImpl;
-class SVX_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase< SdrModel >
+class SVX_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase< SdrModel >, public OutlinerSearchable
{
protected:
DateTime aReadDate; // date of the incoming stream
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index fa2225e257bc..6c00497a3e2c 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1727,7 +1727,7 @@ void ScInputHandler::UpdateActiveView()
if (rDoc.GetDrawLayer()->isTiledRendering())
{
ScDrawLayer *pDrawLayer = pDocShell->GetDocument().GetDrawLayer();
- pTableView->registerLibreOfficeKitCallback(pDrawLayer->getLibreOfficeKitCallback(), pDrawLayer->getLibreOfficeKitData());
+ pTableView->registerLibreOfficeKitCallback(pDrawLayer->getLibreOfficeKitCallback(), pDrawLayer->getLibreOfficeKitData(), pDrawLayer);
pTableView->setTiledRendering(true);
}
}
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 04d11f3d0d57..85fc81a31b37 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -938,7 +938,8 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
if (pDoc->GetDrawLayer() && pDoc->GetDrawLayer()->isTiledRendering())
{
pEditView[eWhich]->registerLibreOfficeKitCallback(pDoc->GetDrawLayer()->getLibreOfficeKitCallback(),
- pDoc->GetDrawLayer()->getLibreOfficeKitData());
+ pDoc->GetDrawLayer()->getLibreOfficeKitData(),
+ pDoc->GetDrawLayer());
pEditView[eWhich]->setTiledRendering(true);
}
}
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index b7150d58aa7b..264f492f142f 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -35,6 +35,7 @@
#include <ViewShell.hxx>
#include <sdpage.hxx>
#include <unomodel.hxx>
+#include <comphelper/lok.hxx>
using namespace css;
@@ -60,6 +61,7 @@ public:
void testSearch();
void testSearchAll();
void testSearchAllSelections();
+ void testSearchAllNotifications();
#endif
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -74,6 +76,7 @@ public:
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchAll);
//CPPUNIT_TEST(testSearchAllSelections);
+ CPPUNIT_TEST(testSearchAllNotifications);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -92,13 +95,17 @@ private:
sal_Int32 m_nPart;
std::vector<OString> m_aSearchResultSelection;
std::vector<int> m_aSearchResultPart;
+ int m_nSelectionBeforeSearchResult;
+ int m_nSelectionAfterSearchResult;
#endif
};
SdTiledRenderingTest::SdTiledRenderingTest()
#if !defined(WNT) && !defined(MACOSX)
: m_bFound(true),
- m_nPart(0)
+ m_nPart(0),
+ m_nSelectionBeforeSearchResult(0),
+ m_nSelectionAfterSearchResult(0)
#endif
{
}
@@ -183,6 +190,10 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
lcl_convertRectangle(rString, aRectangle);
m_aSelection.push_back(aRectangle);
}
+ if (m_aSearchResultSelection.empty())
+ ++m_nSelectionBeforeSearchResult;
+ else
+ ++m_nSelectionAfterSearchResult;
}
break;
case LOK_CALLBACK_SEARCH_NOT_FOUND:
@@ -456,6 +467,20 @@ void SdTiledRenderingTest::testSearchAllSelections()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSelection.size());
}
+void SdTiledRenderingTest::testSearchAllNotifications()
+{
+ comphelper::LibreOfficeKit::setActive();
+ SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+ pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this);
+
+ lcl_search("third", /*bFindAll=*/true);
+ // Make sure that we get no notifications about selection changes during search.
+ CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult);
+ // But we do get the selection of the first hit.
+ CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0);
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 7d517e2c4003..75247218cb96 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -460,7 +460,7 @@ OutlinerView* SdrObjEditView::ImpMakeOutlinerView(vcl::Window* pWin, bool /*bNoP
pOutlView->SetControlWord(nStat);
pOutlView->SetBackgroundColor( aBackground );
pOutlView->setTiledRendering(GetModel()->isTiledRendering());
- pOutlView->registerLibreOfficeKitCallback(GetModel()->getLibreOfficeKitCallback(), GetModel()->getLibreOfficeKitData());
+ pOutlView->registerLibreOfficeKitCallback(GetModel()->getLibreOfficeKitCallback(), GetModel()->getLibreOfficeKitData(), GetModel());
if (pText!=NULL)
{
pOutlView->SetAnchorMode((EVAnchorMode)(pText->GetOutlinerViewAnchorMode()));
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index fb69d29386ac..b0c77057798a 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -63,6 +63,7 @@ class SwSidebarItem;
class SwFrm;
namespace vcl { class Window; }
struct ImplSVEvent;
+class OutlinerSearchable;
#define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
#define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
@@ -294,7 +295,7 @@ class SwPostItMgr: public SfxListener
void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage);
void PaintTile(OutputDevice& rRenderContext, const Rectangle& rRect);
/// Informs already created annotations about a newly registered LOK callback.
- void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData);
+ void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData, OutlinerSearchable* pSearchable);
};
#endif
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index a660c96a6345..c6ee06a6abea 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -121,7 +121,7 @@ void SwViewShell::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallbac
{
getIDocumentDrawModelAccess()->GetDrawModel()->registerLibreOfficeKitCallback(pCallback, pData);
if (SwPostItMgr* pPostItMgr = GetPostItMgr())
- pPostItMgr->registerLibreOfficeKitCallback(pCallback, pData);
+ pPostItMgr->registerLibreOfficeKitCallback(pCallback, pData, getIDocumentDrawModelAccess()->GetDrawModel());
}
void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload) const
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index e0ea88fd86b4..b50724738e35 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -881,7 +881,7 @@ void SwPostItMgr::PaintTile(OutputDevice& rRenderContext, const Rectangle& /*rRe
}
}
-void SwPostItMgr::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
+void SwPostItMgr::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData, OutlinerSearchable* pSearchable)
{
for (SwSidebarItem* pItem : mvPostItFields)
{
@@ -890,7 +890,7 @@ void SwPostItMgr::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallbac
continue;
pPostIt->GetOutlinerView()->setTiledRendering(mpWrtShell->isTiledRendering());
- pPostIt->GetOutlinerView()->registerLibreOfficeKitCallback(pCallback, pData);
+ pPostIt->GetOutlinerView()->registerLibreOfficeKitCallback(pCallback, pData, pSearchable);
}
}
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index 78733b648972..a66f9486ac27 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -619,7 +619,7 @@ void SwSidebarWin::InitControls()
void* pData = 0;
pDrawModel->getLibreOfficeKitCallback(pCallback, pData);
mpOutlinerView->setTiledRendering(mrView.GetWrtShellPtr()->isTiledRendering());
- mpOutlinerView->registerLibreOfficeKitCallback(pCallback, pData);
+ mpOutlinerView->registerLibreOfficeKitCallback(pCallback, pData, pDrawModel);
}
//create Scrollbars