[Libreoffice-commits] core.git: 2 commits - include/svx sd/inc sd/source svx/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 2 06:13:23 UTC 2020


 include/svx/svdmrkv.hxx        |    6 +-
 sd/inc/Outliner.hxx            |    4 +
 sd/source/ui/view/Outliner.cxx |  110 ++++++++++++++++++++++-------------------
 svx/source/svdraw/svdmrkv.cxx  |   24 +++-----
 4 files changed, 77 insertions(+), 67 deletions(-)

New commits:
commit e9dbdc9fc6ff943650e6e18986ed1cce913971ef
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 14:07:10 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 2 08:12:57 2020 +0200

    sd: move LOK search result logic to it's own method
    
    Change-Id: I67cbe4d3d63bffdab72c09b3a956f67806588348
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95306
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index 3a73b9339f09..79c54c032a03 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -360,6 +360,10 @@ private:
     */
     bool SearchAndReplaceOnce(std::vector<::sd::SearchSelection>* pSelections = nullptr);
 
+    void sendLOKSearchResultCallback(std::shared_ptr<sd::ViewShell>& pViewShell,
+                                     OutlinerView* pOutlinerView,
+                                     std::vector<sd::SearchSelection>* pSelections);
+
     /** Detect changes of the document or view and react accordingly.  Such
         changes may occur because different calls to
         <member>SearchAndReplace()</member> there usually is user
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 86e8e9fc9bee..0aebe2838e4c 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -662,6 +662,66 @@ bool SdOutliner::SearchAndReplaceAll()
     return bRet;
 }
 
+void SdOutliner::sendLOKSearchResultCallback(std::shared_ptr<sd::ViewShell> & pViewShell,
+                                             OutlinerView* pOutlinerView,
+                                             std::vector<sd::SearchSelection>* pSelections)
+{
+    std::vector<::tools::Rectangle> aLogicRects;
+    pOutlinerView->GetSelectionRectangles(aLogicRects);
+
+    // convert to twips if in 100thmm (seems as if LibreOfficeKit is based on twips?). Do this
+    // here where we have the only place needing this, *not* in ImpEditView::GetSelectionRectangles
+    // which makes that method unusable for others
+    if (pOutlinerView->GetWindow() && MapUnit::Map100thMM == pOutlinerView->GetWindow()->GetMapMode().GetMapUnit())
+    {
+        for (tools::Rectangle& rRectangle : aLogicRects)
+        {
+            rRectangle = OutputDevice::LogicToLogic(rRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+        }
+    }
+
+    std::vector<OString> aLogicRectStrings;
+    std::transform(aLogicRects.begin(), aLogicRects.end(), std::back_inserter(aLogicRectStrings),
+        [](const ::tools::Rectangle& rRectangle)
+    {
+        return rRectangle.toString();
+    });
+
+    OString sRectangles = comphelper::string::join("; ", aLogicRectStrings);
+
+    if (!pSelections)
+    {
+        // notify LibreOfficeKit about changed page
+        OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
+        SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
+        rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
+
+        // also about search result selections
+        boost::property_tree::ptree aTree;
+        aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
+        aTree.put("highlightAll", false);
+
+        boost::property_tree::ptree aChildren;
+        boost::property_tree::ptree aChild;
+        aChild.put("part", OString::number(maCurrentPosition.mnPageIndex).getStr());
+        aChild.put("rectangles", sRectangles.getStr());
+        aChildren.push_back(std::make_pair("", aChild));
+        aTree.add_child("searchResultSelection", aChildren);
+
+        std::stringstream aStream;
+        boost::property_tree::write_json(aStream, aTree);
+        aPayload = aStream.str().c_str();
+        rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
+    }
+    else
+    {
+        sd::SearchSelection aSelection(maCurrentPosition.mnPageIndex, sRectangles);
+        bool bDuplicate = !pSelections->empty() && pSelections->back() == aSelection;
+        if (!bDuplicate)
+            pSelections->push_back(aSelection);
+    }
+}
+
 bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelections)
 {
     DetectChange ();
@@ -753,55 +813,7 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti
 
     if (pViewShell && comphelper::LibreOfficeKit::isActive() && mbStringFound)
     {
-        std::vector<::tools::Rectangle> aLogicRects;
-        pOutlinerView->GetSelectionRectangles(aLogicRects);
-
-        // convert to twips if in 100thmm (seems as if LibreOfficeKit is based on twips?). Do this
-        // here where we have the only place needing this, *not* in ImpEditView::GetSelectionRectangles
-        // which makes that method unusable for others
-        if (pOutlinerView->GetWindow() && MapUnit::Map100thMM == pOutlinerView->GetWindow()->GetMapMode().GetMapUnit())
-        {
-            for (tools::Rectangle& rRectangle : aLogicRects)
-            {
-                rRectangle = OutputDevice::LogicToLogic(rRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
-            }
-        }
-
-        std::vector<OString> aLogicRectStrings;
-        std::transform(aLogicRects.begin(), aLogicRects.end(), std::back_inserter(aLogicRectStrings), [](const ::tools::Rectangle& rRectangle) { return rRectangle.toString(); });
-        OString sRectangles = comphelper::string::join("; ", aLogicRectStrings);
-
-        if (!pSelections)
-        {
-            // notify LibreOfficeKit about changed page
-            OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
-            SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
-            rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
-
-            // also about search result selections
-            boost::property_tree::ptree aTree;
-            aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
-            aTree.put("highlightAll", false);
-
-            boost::property_tree::ptree aChildren;
-            boost::property_tree::ptree aChild;
-            aChild.put("part", OString::number(maCurrentPosition.mnPageIndex).getStr());
-            aChild.put("rectangles", sRectangles.getStr());
-            aChildren.push_back(std::make_pair("", aChild));
-            aTree.add_child("searchResultSelection", aChildren);
-
-            std::stringstream aStream;
-            boost::property_tree::write_json(aStream, aTree);
-            aPayload = aStream.str().c_str();
-            rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
-        }
-        else
-        {
-            sd::SearchSelection aSelection(maCurrentPosition.mnPageIndex, sRectangles);
-            bool bDuplicate = !pSelections->empty() && pSelections->back() == aSelection;
-            if (!bDuplicate)
-                pSelections->push_back(aSelection);
-        }
+        sendLOKSearchResultCallback(pViewShell, pOutlinerView, pSelections);
     }
 
     return mbEndOfSearch;
commit a6c0dc079700d662e14d422d18c6c3a9c2c3b7af
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 12:54:54 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 2 08:12:40 2020 +0200

    svx: convert ImplMarkingOverlay and friends to use unique_ptr
    
    Change-Id: I19ba9e93f2804fded237b760a28f3ce62e4b2c5f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95305
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index 49d39f06fb8d..9ccf77ef2784 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -90,9 +90,9 @@ class SVXCORE_DLLPUBLIC SdrMarkView : public SdrSnapView
     friend class                SdrPageView;
 
     // #114409#-3 Migrate selections
-    ImplMarkingOverlay*                                 mpMarkObjOverlay;
-    ImplMarkingOverlay*                                 mpMarkPointsOverlay;
-    ImplMarkingOverlay*                                 mpMarkGluePointsOverlay;
+    std::unique_ptr<ImplMarkingOverlay> mpMarkObjOverlay;
+    std::unique_ptr<ImplMarkingOverlay> mpMarkPointsOverlay;
+    std::unique_ptr<ImplMarkingOverlay> mpMarkGluePointsOverlay;
 
 protected:
     SdrObject*                  mpMarkedObj;       // If not just one object ( i.e. More than one object ) is marked.
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 3e28a3956391..988f33183a40 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -156,9 +156,6 @@ SdrMarkView::SdrMarkView(
     SdrModel& rSdrModel,
     OutputDevice* pOut)
 :   SdrSnapView(rSdrModel, pOut),
-    mpMarkObjOverlay(nullptr),
-    mpMarkPointsOverlay(nullptr),
-    mpMarkGluePointsOverlay(nullptr),
     maHdlList(this)
 {
     ImpClearVars();
@@ -354,10 +351,10 @@ void SdrMarkView::BegMarkObj(const Point& rPnt, bool bUnmark)
 {
     BrkAction();
 
-    DBG_ASSERT(nullptr == mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkObjOverlay (!)");
+    DBG_ASSERT(!mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkObjOverlay (!)");
 
     basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
-    mpMarkObjOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+    mpMarkObjOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, bUnmark));
 
     maDragStat.Reset(rPnt);
     maDragStat.NextPoint();
@@ -401,8 +398,7 @@ void SdrMarkView::BrkMarkObj()
     if(IsMarkObj())
     {
         DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
-        delete mpMarkObjOverlay;
-        mpMarkObjOverlay = nullptr;
+        mpMarkObjOverlay.reset();
     }
 }
 
@@ -413,9 +409,9 @@ bool SdrMarkView::BegMarkPoints(const Point& rPnt, bool bUnmark)
     {
         BrkAction();
 
-        DBG_ASSERT(nullptr == mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkPointsOverlay (!)");
+        DBG_ASSERT(!mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkPointsOverlay (!)");
         basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
-        mpMarkPointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+        mpMarkPointsOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, bUnmark));
 
         maDragStat.Reset(rPnt);
         maDragStat.NextPoint();
@@ -466,8 +462,7 @@ void SdrMarkView::BrkMarkPoints()
     if(IsMarkPoints())
     {
         DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
-        delete mpMarkPointsOverlay;
-        mpMarkPointsOverlay = nullptr;
+        mpMarkPointsOverlay.reset();
     }
 }
 
@@ -478,10 +473,10 @@ bool SdrMarkView::BegMarkGluePoints(const Point& rPnt, bool bUnmark)
     {
         BrkAction();
 
-        DBG_ASSERT(nullptr == mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
+        DBG_ASSERT(!mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
 
         basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
-        mpMarkGluePointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+        mpMarkGluePointsOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, bUnmark));
         maDragStat.Reset(rPnt);
         maDragStat.NextPoint();
         maDragStat.SetMinMove(mnMinMovLog);
@@ -525,8 +520,7 @@ void SdrMarkView::BrkMarkGluePoints()
     if(IsMarkGluePoints())
     {
         DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
-        delete mpMarkGluePointsOverlay;
-        mpMarkGluePointsOverlay = nullptr;
+        mpMarkGluePointsOverlay.reset();
     }
 }
 


More information about the Libreoffice-commits mailing list