summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-08-16 12:06:30 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-08-19 10:36:40 +0200
commitb34e80b3a8d0b9032556d82bc2619e450802dc8c (patch)
treeca12c1e7452d799d5cae5f3bd90711f85add83b7 /sd/source
parentd6b4a0a9a3fed1ba07125d7e9517f0a663fc4018 (diff)
move vector graphic search to View, so it works in multiple views
VectorGraphicSearch was instantiated for the Outline, which is the same for every view. The problem with this is that when we have multiple views, the search would interfere with each other, which is especially distracting in online when multiple users connect to the same document and try searching. This adds VectorGraphicSearchContext class, that is added to the View, which makes the search view dependent and multiple instances of VectorGraphicSearch are created, each one for its own view. Change-Id: Ia0f34647b30b35f4ddb84d33353990d635756905 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100837 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 74e2f2178fd8a0ad29c5dbcefb22a9778a75ae82) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100884 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sd/source')
-rw-r--r--sd/source/ui/inc/View.hxx6
-rw-r--r--sd/source/ui/view/Outliner.cxx59
2 files changed, 31 insertions, 34 deletions
diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx
index 5aba1fb326d9..d7da6fc2df12 100644
--- a/sd/source/ui/inc/View.hxx
+++ b/sd/source/ui/inc/View.hxx
@@ -27,6 +27,7 @@
#include <svx/fmview.hxx>
#include <svx/svdpage.hxx>
#include <vcl/idle.hxx>
+#include <VectorGraphicSearchContext.hxx>
#include "smarttag.hxx"
@@ -217,6 +218,8 @@ public:
void SetAuthor(const OUString& rAuthor) { m_sAuthor = rAuthor; }
const OUString& GetAuthor() const { return m_sAuthor; }
+ VectorGraphicSearchContext& getVectorGraphicSearchContext() { return aVectorGraphicSearchContext; }
+
protected:
DECL_LINK( OnParagraphInsertedHdl, ::Outliner::ParagraphHdlParam, void );
DECL_LINK( OnParagraphRemovingHdl, ::Outliner::ParagraphHdlParam, void );
@@ -250,6 +253,9 @@ protected:
private:
::std::unique_ptr<ViewClipboard> mpClipboard;
OutlinerMasterViewFilter maMasterViewFilter;
+
+ VectorGraphicSearchContext aVectorGraphicSearchContext;
+
OUString m_sAuthor;
};
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 9b777d3a1dad..7f6a1853d753 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -21,7 +21,6 @@
#include <boost/property_tree/json_parser.hpp>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/VectorGraphicSearch.hxx>
#include <svl/srchitem.hxx>
#include <svl/intitem.hxx>
@@ -61,6 +60,7 @@
#include <comphelper/string.hxx>
#include <comphelper/lok.hxx>
#include <comphelper/scopeguard.hxx>
+#include <VectorGraphicSearchContext.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -99,11 +99,6 @@ public:
*/
void ReleaseOutlinerView();
- /** Search in vector graphic
- */
- bool mbCurrentIsVectorGraphic;
- std::unique_ptr<VectorGraphicSearch> mpVectorGraphicSearch;
-
private:
/** Flag that specifies whether we own the outline view pointed to by
<member>mpOutlineView</member> and thus have to
@@ -729,9 +724,10 @@ void SdOutliner::sendLOKSearchResultCallback(std::shared_ptr<sd::ViewShell> & pV
std::vector<sd::SearchSelection>* pSelections)
{
std::vector<::tools::Rectangle> aLogicRects;
- if (mpImpl->mbCurrentIsVectorGraphic)
+ auto& rVectorGraphicSearchContext = pViewShell->GetView()->getVectorGraphicSearchContext();
+ if (rVectorGraphicSearchContext.mbCurrentIsVectorGraphic)
{
- basegfx::B2DRectangle aSelectionHMM = getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+ basegfx::B2DRectangle aSelectionHMM = getPDFSelection(rVectorGraphicSearchContext.mpVectorGraphicSearch, mpObj);
tools::Rectangle aSelection(Point(aSelectionHMM.getMinX(), aSelectionHMM.getMinY()),
Size(aSelectionHMM.getWidth(), aSelectionHMM.getHeight()));
@@ -787,7 +783,7 @@ void SdOutliner::sendLOKSearchResultCallback(std::shared_ptr<sd::ViewShell> & pV
aPayload = aStream.str().c_str();
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
- if (mpImpl->mbCurrentIsVectorGraphic)
+ if (rVectorGraphicSearchContext.mbCurrentIsVectorGraphic)
{
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangles.getStr());
}
@@ -819,12 +815,12 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti
mpView = pViewShell->GetView();
mpWindow = pViewShell->GetActiveWindow();
pOutlinerView->SetWindow(mpWindow);
-
+ auto& rVectorGraphicSearchContext = mpView->getVectorGraphicSearchContext();
if (nullptr != dynamic_cast<const sd::DrawViewShell*>(pViewShell.get()))
{
sal_uLong nMatchCount = 0;
- if (mpImpl->mbCurrentIsVectorGraphic)
+ if (rVectorGraphicSearchContext.mbCurrentIsVectorGraphic)
{
OUString const & rString = mpSearchItem->GetSearchString();
bool bBackwards = mpSearchItem->GetBackward();
@@ -834,14 +830,14 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti
aOptions.mbMatchCase = mpSearchItem->GetExact();
aOptions.mbMatchWholeWord = mpSearchItem->GetWordOnly();
- bool bResult = mpImpl->mpVectorGraphicSearch->search(rString, aOptions);
+ bool bResult = rVectorGraphicSearchContext.mpVectorGraphicSearch->search(rString, aOptions);
if (bResult)
{
if (bBackwards)
- bResult = mpImpl->mpVectorGraphicSearch->previous();
+ bResult = rVectorGraphicSearchContext.mpVectorGraphicSearch->previous();
else
- bResult = mpImpl->mpVectorGraphicSearch->next();
+ bResult = rVectorGraphicSearchContext.mpVectorGraphicSearch->next();
}
if (bResult)
@@ -852,15 +848,14 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti
mpView->UnmarkAllObj(pPageView);
std::vector<basegfx::B2DRectangle> aSubSelections;
- basegfx::B2DRectangle aSubSelection = getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+ basegfx::B2DRectangle aSubSelection = getPDFSelection(rVectorGraphicSearchContext.mpVectorGraphicSearch, mpObj);
if (!aSubSelection.isEmpty())
aSubSelections.push_back(aSubSelection);
mpView->MarkObj(mpObj, pPageView, false, false, aSubSelections);
}
else
{
- mpImpl->mbCurrentIsVectorGraphic = false;
- mpImpl->mpVectorGraphicSearch.reset();
+ rVectorGraphicSearchContext.reset();
}
}
else
@@ -889,7 +884,7 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti
{
ProvideNextTextObject ();
- if (!mbEndOfSearch && !mpImpl->mbCurrentIsVectorGraphic)
+ if (!mbEndOfSearch && !rVectorGraphicSearchContext.mbCurrentIsVectorGraphic)
{
// Remember the current position as the last one with a
// text object.
@@ -1177,8 +1172,8 @@ void SdOutliner::ProvideNextTextObject()
mbFoundObject = false;
// reset the vector search
- mpImpl->mbCurrentIsVectorGraphic = false;
- mpImpl->mpVectorGraphicSearch.reset();
+ auto& rVectorGraphicSearchContext = mpView->getVectorGraphicSearchContext();
+ rVectorGraphicSearchContext.reset();
mpView->UnmarkAllObj (mpView->GetSdrPageView());
try
@@ -1212,8 +1207,7 @@ void SdOutliner::ProvideNextTextObject()
// LOK: do not descent to notes or master pages when searching
bool bForbiddenPage = comphelper::LibreOfficeKit::isActive() && (maCurrentPosition.mePageKind != PageKind::Standard || maCurrentPosition.meEditMode != EditMode::Page);
- mpImpl->mbCurrentIsVectorGraphic = false;
- mpImpl->mpVectorGraphicSearch.reset();
+ rVectorGraphicSearchContext.reset();
if (!bForbiddenPage)
{
@@ -1230,7 +1224,7 @@ void SdOutliner::ProvideNextTextObject()
else if (meMode == SEARCH && isValidVectorGraphicObject(maCurrentPosition))
{
mpObj = maCurrentPosition.mxObject.get();
- mpImpl->mbCurrentIsVectorGraphic = true;
+ rVectorGraphicSearchContext.mbCurrentIsVectorGraphic = true;
}
}
@@ -1239,7 +1233,7 @@ void SdOutliner::ProvideNextTextObject()
if (mpObj)
{
- if (mpImpl->mbCurrentIsVectorGraphic)
+ if (rVectorGraphicSearchContext.mbCurrentIsVectorGraphic)
{
// We know here the object is a SdrGrafObj and that it
// contains a vector graphic
@@ -1252,15 +1246,15 @@ void SdOutliner::ProvideNextTextObject()
aOptions.mbMatchCase = mpSearchItem->GetExact();
aOptions.mbMatchWholeWord = mpSearchItem->GetWordOnly();
- mpImpl->mpVectorGraphicSearch = std::make_unique<VectorGraphicSearch>(pGraphicObject->GetGraphic());
+ rVectorGraphicSearchContext.mpVectorGraphicSearch = std::make_unique<VectorGraphicSearch>(pGraphicObject->GetGraphic());
- bool bResult = mpImpl->mpVectorGraphicSearch->search(rString, aOptions);
+ bool bResult = rVectorGraphicSearchContext.mpVectorGraphicSearch->search(rString, aOptions);
if (bResult)
{
if (bBackwards)
- bResult = mpImpl->mpVectorGraphicSearch->previous();
+ bResult = rVectorGraphicSearchContext.mpVectorGraphicSearch->previous();
else
- bResult = mpImpl->mpVectorGraphicSearch->next();
+ bResult = rVectorGraphicSearchContext.mpVectorGraphicSearch->next();
}
if (bResult)
@@ -1275,7 +1269,7 @@ void SdOutliner::ProvideNextTextObject()
mpView->UnmarkAllObj(pPageView);
std::vector<basegfx::B2DRectangle> aSubSelections;
- basegfx::B2DRectangle aSubSelection = getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+ basegfx::B2DRectangle aSubSelection = getPDFSelection(rVectorGraphicSearchContext.mpVectorGraphicSearch, mpObj);
if (!aSubSelection.isEmpty())
aSubSelections.push_back(aSubSelection);
@@ -1285,8 +1279,7 @@ void SdOutliner::ProvideNextTextObject()
}
else
{
- mpImpl->mbCurrentIsVectorGraphic = false;
- mpImpl->mpVectorGraphicSearch.reset();
+ rVectorGraphicSearchContext.reset();
}
}
else
@@ -1314,8 +1307,7 @@ void SdOutliner::ProvideNextTextObject()
}
else
{
- mpImpl->mbCurrentIsVectorGraphic = false;
- mpImpl->mpVectorGraphicSearch.reset();
+ rVectorGraphicSearchContext.reset();
if (meMode == SEARCH)
// Instead of doing a full-blown SetObject(), which would do the same -- but would also possibly switch pages.
@@ -1934,7 +1926,6 @@ weld::Window* SdOutliner::GetMessageBoxParent()
SdOutliner::Implementation::Implementation()
: meOriginalEditMode(EditMode::Page),
- mbCurrentIsVectorGraphic(false),
mbOwnOutlineView(false),
mpOutlineView(nullptr)
{