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 14:45:09 +0100
commit7b5d20983dfbfb458898eeab54828ba5fef5841f (patch)
treeb067a0fbdb143073e17a44e20cc0384193be550c
parentb9565ef0a73c235cd1e14fce9031db6e9237c524 (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. 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.hxx12
-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.cxx26
-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, 75 insertions, 20 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index d9d31483df5f..f936d4e7a0b1 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -588,9 +588,9 @@ void EditView::setTiledRendering(bool bTiledRendering)
pImpEditView->setTiledRendering(bTiledRendering);
}
-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 f14d57c2ecf1..0fc72ff5372c 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 = nullptr;
mpLibreOfficeKitData = nullptr;
+ mpLibreOfficeKitSearchable = nullptr;
nScrollDiffX = 0;
nExtraCursorFlags = 0;
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
@@ -123,14 +125,27 @@ void ImpEditView::setTiledRendering(bool bTiledRendering)
mbTiledRendering = bTiledRendering;
}
-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 84163cce9359..5f180cd83d09 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -79,6 +79,7 @@
class EditView;
class EditEngine;
+class OutlinerSearchable;
class SvxSearchItem;
class SvxLRSpaceItem;
@@ -224,6 +225,7 @@ private:
bool mbTiledRendering;
LibreOfficeKitCallback mpLibreOfficeKitCallback;
void* mpLibreOfficeKitData;
+ OutlinerSearchable* mpLibreOfficeKitSearchable;
EditEngine* pEditEngine;
VclPtr<vcl::Window> pOutWin;
Pointer* pPointer;
@@ -370,7 +372,7 @@ public:
void setTiledRendering(bool bTiledRendering);
/// @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 9de935e268e1..d624eb6fa689 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1436,9 +1436,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()
@@ -1466,7 +1466,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 33adc6e9a475..21343f50a63b 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -35,6 +35,7 @@
class EditEngine;
class ImpEditEngine;
class ImpEditView;
+class OutlinerSearchable;
class SvxSearchItem;
class SvxFieldItem;
namespace vcl { class Window; }
@@ -183,7 +184,7 @@ public:
void setTiledRendering(bool bTiledRendering);
/// @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 b2c018e926ee..6ea221e6edd8 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -72,7 +72,7 @@ class SvKeyValueIterator;
class SvxForbiddenCharactersTable;
class OverflowingText;
class NonOverflowingText;
-
+class OutlinerSearchable;
namespace svl
{
@@ -276,7 +276,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();
@@ -378,6 +378,14 @@ public:
void SetEndCutPasteLinkHdl(const Link<LinkParamNone*,void> &rLink) { aEndCutPasteLink = rLink; }
};
+/// 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 49eab630274b..fc60a8954b27 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>
@@ -148,7 +149,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:
std::vector<SdrPage*> maMaPag; // master pages
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 65fd839da6e9..a4cf3efbfe5c 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1722,7 +1722,7 @@ void ScInputHandler::UpdateActiveView()
if (comphelper::LibreOfficeKit::isActive())
{
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 fdf86d44faaa..95b9573b0d29 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -941,7 +941,8 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
if (pDoc->GetDrawLayer() && comphelper::LibreOfficeKit::isActive())
{
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 13b4223a2444..296964d2c15d 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -54,6 +54,7 @@ public:
void testSearch();
void testSearchAll();
void testSearchAllSelections();
+ void testSearchAllNotifications();
#endif
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -68,6 +69,7 @@ public:
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchAll);
CPPUNIT_TEST(testSearchAllSelections);
+ CPPUNIT_TEST(testSearchAllNotifications);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -86,13 +88,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
{
}
@@ -177,6 +183,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:
@@ -458,6 +468,20 @@ void SdTiledRenderingTest::testSearchAllSelections()
comphelper::LibreOfficeKit::setActive(false);
}
+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 9c9b2449ced6..5c2dc63ec873 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -462,7 +462,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!=nullptr)
{
pOutlView->SetAnchorMode((EVAnchorMode)(pText->GetOutlinerViewAnchorMode()));
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index 11276b982646..b4f96a675347 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -62,6 +62,7 @@ class SwSidebarItem;
class SwFrame;
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)
@@ -290,7 +291,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 50087dc495de..a543016dc63b 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -119,7 +119,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 c4d0f6a4e87e..86be22085bfb 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(comphelper::LibreOfficeKit::isActive());
- 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 6f73a63b0272..57374acb05aa 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -619,7 +619,7 @@ void SwSidebarWin::InitControls()
void* pData = nullptr;
pDrawModel->getLibreOfficeKitCallback(pCallback, pData);
mpOutlinerView->setTiledRendering(comphelper::LibreOfficeKit::isActive());
- mpOutlinerView->registerLibreOfficeKitCallback(pCallback, pData);
+ mpOutlinerView->registerLibreOfficeKitCallback(pCallback, pData, pDrawModel);
}
//create Scrollbars