[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 3 commits - include/svx sd/inc sd/source svx/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Wed May 27 12:08:25 UTC 2020


 include/svx/svdmrkv.hxx        |    6 +-
 sd/inc/Outliner.hxx            |   11 +++
 sd/source/ui/view/Outliner.cxx |  121 ++++++++++++++++++++---------------------
 svx/source/svdraw/svdmrkv.cxx  |   21 +++----
 4 files changed, 83 insertions(+), 76 deletions(-)

New commits:
commit a61e93f28596059baacf0a057ac78fa60343b58a
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 14:07:10 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed May 27 14:07:10 2020 +0200

    sd: move LOK search result logic to it's own method
    
    Change-Id: I67cbe4d3d63bffdab72c09b3a956f67806588348

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index 8e175983f249..79c54c032a03 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -46,6 +46,7 @@ struct SearchSelection
 {
     /// 0-based index of the page that has the selection.
     int m_nPage;
+
     /**
      * List of selection rectangles in twips -- multiple rectangles only in
      * case the selection spans over more layout lines.
@@ -359,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 e7f676f43e4e..6e982f3d25f7 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -673,6 +673,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 ();
@@ -764,55 +824,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 0878b13610a41b1e7cbc9f3b4226b05f48259439
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 13:58:00 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed May 27 13:58:00 2020 +0200

    sd: move SearchSelection constr. to the header file
    
    Change-Id: I068c1e2643e2aafeb838a2bfa1433a2495323f2f

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index c95786577b62..8e175983f249 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -52,7 +52,11 @@ struct SearchSelection
      */
     OString m_aRectangles;
 
-    SearchSelection(int nPage, const OString& rRectangles);
+    SearchSelection(int nPage, const OString& rRectangles)
+        : m_nPage(nPage)
+        , m_aRectangles(rRectangles)
+    {
+    }
 
     bool operator==(const SearchSelection& rOther) const
     {
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index e67d823e9a11..e7f676f43e4e 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -66,17 +66,6 @@ using namespace ::com::sun::star::linguistic2;
 
 class SfxStyleSheetPool;
 
-namespace sd {
-
-SearchSelection::SearchSelection(int nPage, const OString& rRectangles)
-    : m_nPage(nPage),
-    m_aRectangles(rRectangles)
-{
-}
-
-} // end of namespace sd
-
-
 class SdOutliner::Implementation
 {
 public:
commit bc0b4627b45eb7c3f699423dc75896bff7644290
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 12:54:54 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed May 27 12:54:54 2020 +0200

    svx: convert ImplMarkingOverlay and friends to use unique_ptr
    
    Change-Id: I19ba9e93f2804fded237b760a28f3ce62e4b2c5f

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..99a5bcdfefc8 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -354,10 +354,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 +401,7 @@ void SdrMarkView::BrkMarkObj()
     if(IsMarkObj())
     {
         DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
-        delete mpMarkObjOverlay;
-        mpMarkObjOverlay = nullptr;
+        mpMarkObjOverlay.reset();
     }
 }
 
@@ -413,9 +412,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 +465,7 @@ void SdrMarkView::BrkMarkPoints()
     if(IsMarkPoints())
     {
         DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
-        delete mpMarkPointsOverlay;
-        mpMarkPointsOverlay = nullptr;
+        mpMarkPointsOverlay.reset();
     }
 }
 
@@ -478,10 +476,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 +523,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