summaryrefslogtreecommitdiffstats
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-09-01 09:24:48 +0200
commit5f1a61e685f4abc94a311fa3f01a2fa96c65677e (patch)
tree86b66307b59f6e8c8ccbfdf7aa83d84a9ef60e7b
parentvcl: save and load the page number when swapping the graphic (diff)
downloadcore-5f1a61e685f4abc94a311fa3f01a2fa96c65677e.tar.gz
core-5f1a61e685f4abc94a311fa3f01a2fa96c65677e.zip
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. 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> (cherry picked from commit b34e80b3a8d0b9032556d82bc2619e450802dc8c) Change-Id: Ia0f34647b30b35f4ddb84d33353990d635756905 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101761 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--sd/inc/VectorGraphicSearchContext.hxx35
-rw-r--r--sd/source/ui/inc/View.hxx6
-rw-r--r--sd/source/ui/view/Outliner.cxx58
3 files changed, 66 insertions, 33 deletions
diff --git a/sd/inc/VectorGraphicSearchContext.hxx b/sd/inc/VectorGraphicSearchContext.hxx
new file mode 100644
index 000000000000..e6f978ca273c
--- /dev/null
+++ b/sd/inc/VectorGraphicSearchContext.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <vcl/VectorGraphicSearch.hxx>
+
+namespace sd
+{
+struct VectorGraphicSearchContext
+{
+ bool mbCurrentIsVectorGraphic;
+ std::unique_ptr<VectorGraphicSearch> mpVectorGraphicSearch;
+
+ VectorGraphicSearchContext()
+ : mbCurrentIsVectorGraphic(false)
+ {
+ }
+
+ void reset()
+ {
+ mbCurrentIsVectorGraphic = false;
+ mpVectorGraphicSearch.reset();
+ }
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx
index e88424122877..dc85e22d2b26 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"
@@ -220,6 +221,8 @@ public:
void SetAuthor(const OUString& rAuthor) { m_sAuthor = rAuthor; }
const OUString& GetAuthor() { return m_sAuthor; }
+ VectorGraphicSearchContext& getVectorGraphicSearchContext() { return aVectorGraphicSearchContext; }
+
protected:
DECL_LINK( OnParagraphInsertedHdl, ::Outliner::ParagraphHdlParam, void );
DECL_LINK( OnParagraphRemovingHdl, ::Outliner::ParagraphHdlParam, void );
@@ -253,6 +256,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 34f709ce9fb5..984e939b0634 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -76,6 +76,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;
@@ -114,11 +115,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
@@ -757,9 +753,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()));
@@ -815,7 +812,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());
}
@@ -847,12 +844,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();
@@ -862,14 +859,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)
@@ -880,15 +877,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
@@ -917,7 +913,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.
@@ -1205,8 +1201,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
@@ -1240,8 +1236,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)
{
@@ -1258,7 +1253,7 @@ void SdOutliner::ProvideNextTextObject()
else if (meMode == SEARCH && isValidVectorGraphicObject(maCurrentPosition))
{
mpObj = maCurrentPosition.mxObject.get();
- mpImpl->mbCurrentIsVectorGraphic = true;
+ rVectorGraphicSearchContext.mbCurrentIsVectorGraphic = true;
}
}
@@ -1267,7 +1262,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
@@ -1280,15 +1275,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)
@@ -1303,7 +1298,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);
@@ -1313,8 +1308,7 @@ void SdOutliner::ProvideNextTextObject()
}
else
{
- mpImpl->mbCurrentIsVectorGraphic = false;
- mpImpl->mpVectorGraphicSearch.reset();
+ rVectorGraphicSearchContext.reset();
}
}
else
@@ -1342,8 +1336,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.
@@ -1954,7 +1947,6 @@ VclPtr<vcl::Window> SdOutliner::GetMessageBoxParent()
SdOutliner::Implementation::Implementation()
: meOriginalEditMode(EditMode::Page),
- mbCurrentIsVectorGraphic(false),
mbOwnOutlineView(false),
mpOutlineView(nullptr)
{