[Libreoffice-commits] core.git: chart2/source desktop/inc include/sfx2 sc/source sd/source sfx2/source svx/source sw/source tools/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 5 20:20:50 UTC 2021


 chart2/source/controller/main/ChartWindow.cxx |    8 ++++----
 desktop/inc/lib/init.hxx                      |    7 +++----
 include/sfx2/lokhelper.hxx                    |    3 ++-
 sc/source/ui/view/gridwin4.cxx                |   11 ++++++-----
 sc/source/ui/view/tabview.cxx                 |    2 +-
 sc/source/ui/view/tabview3.cxx                |    4 ++--
 sd/source/ui/view/sdwindow.cxx                |   11 ++++++-----
 sfx2/source/view/lokhelper.cxx                |   10 ++++++----
 svx/source/svdraw/sdrpagewindow.cxx           |    2 +-
 svx/source/svdraw/svdmrkv.cxx                 |    8 ++++----
 sw/source/uibase/docvw/edtwin.cxx             |    8 +-------
 tools/source/generic/gen.cxx                  |    8 ++------
 12 files changed, 38 insertions(+), 44 deletions(-)

New commits:
commit 417f881d20cafe88a02b64894ba4483875fb9460
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 4 11:37:34 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 5 22:20:13 2021 +0200

    improve LOK notifyInvalidation
    
    (*) tweak buffer in SfxLokHelper::notifyInvalidation to be a bit larger,
    so we avoid the cost of a resize&copy
    (*) use our optimised OString concatentation instead of going via
    std::stringstream
    (*) pass down a pointer to rectangle, instead of a string. later we will
    use this to avoid doing the stringify until later
    
    Change-Id: Ia3e3042bc919d9b9cb80e47a93704eb236438605
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119994
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120072
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index 73e642446be1..ad5afd131b96 100644
--- a/chart2/source/controller/main/ChartWindow.cxx
+++ b/chart2/source/controller/main/ChartWindow.cxx
@@ -283,11 +283,11 @@ void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
     SfxViewShell* pCurrentShell = SfxViewShell::Current();
     if ( nullptr == pCurrentShell )
         return;
-    OString sRectangle;
+    tools::Rectangle aResultRectangle;
     if (!pRectangle)
     {
         // we have to invalidate the whole chart area not the whole document
-        sRectangle = GetBoundingBox().toString();
+        aResultRectangle = GetBoundingBox();
     }
     else
     {
@@ -325,9 +325,9 @@ void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
             aRectangle = tools::Rectangle(aRectangle.TopLeft() + aOffset, aRectangle.GetSize());
         }
 
-        sRectangle = aRectangle.toString();
+        aResultRectangle = aRectangle;
     }
-    SfxLokHelper::notifyInvalidation(pCurrentShell, sRectangle);
+    SfxLokHelper::notifyInvalidation(pCurrentShell, &aResultRectangle);
 }
 
 FactoryFunction ChartWindow::GetUITestFactory() const
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index e47c92cc5c0a..e27f0563cd58 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -47,11 +47,10 @@ namespace desktop {
 
         OString toString() const
         {
-            std::stringstream ss;
-            ss << m_aRectangle.toString();
             if (m_nPart >= -1)
-                ss << ", " << m_nPart;
-            return ss.str().c_str();
+                return m_aRectangle.toString() + ", " + OString::number(m_nPart);
+            else
+                return m_aRectangle.toString();
         }
 
         /// Infinite Rectangle is both sides are
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index f10bac147933..a806f022fa19 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -15,6 +15,7 @@
 #include <vcl/event.hxx>
 #include <sfx2/dllapi.h>
 #include <sfx2/viewsh.hxx>
+#include <tools/gen.hxx>
 #include <cstddef>
 #include <rtl/string.hxx>
 #include <optional>
@@ -105,7 +106,7 @@ public:
     /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same document - if @bInvalidateAll - first invalidates all parts
     static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
-    static void notifyInvalidation(SfxViewShell const* pThisView, std::string_view rPayload);
+    static void notifyInvalidation(SfxViewShell const* pThisView, tools::Rectangle const *);
     /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it according to setOptionalFeatures() if needed.
     static void notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle, bool bMispelledWord = false, const OString& rHyperlink = "");
     /// Notifies all views with the given type and payload.
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index a6ca5defcfa6..dab88b11717f 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1543,12 +1543,13 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 
 void ScGridWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
 {
-    OString sRectangle;
+    tools::Rectangle aRectangle;
+    tools::Rectangle* pResultRectangle;
     if (!pRectangle)
-        sRectangle = "EMPTY";
+        pResultRectangle = nullptr;
     else
     {
-        tools::Rectangle aRectangle(*pRectangle);
+        aRectangle = *pRectangle;
         // When dragging shapes the map mode is disabled.
         if (IsMapModeEnabled())
         {
@@ -1557,11 +1558,11 @@ void ScGridWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
         }
         else
             aRectangle = PixelToLogic(aRectangle, MapMode(MapUnit::MapTwip));
-        sRectangle = aRectangle.toString();
+        pResultRectangle = &aRectangle;
     }
 
     ScTabViewShell* pViewShell = mrViewData.GetViewShell();
-    SfxLokHelper::notifyInvalidation(pViewShell, sRectangle);
+    SfxLokHelper::notifyInvalidation(pViewShell, pResultRectangle);
 }
 
 void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 4fb5d812c8af..be0243958779 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2587,7 +2587,7 @@ void lcl_ExtendTiledDimension(bool bColumn, const SCCOLROW nEnd, const SCCOLROW
     if ((bColumn && aNewArea.getWidth()) || (!bColumn && aNewArea.getHeight()))
     {
         rTabView.UpdateSelectionOverlay();
-        SfxLokHelper::notifyInvalidation(rViewData.GetViewShell(), aNewArea.toString());
+        SfxLokHelper::notifyInvalidation(rViewData.GetViewShell(), &aNewArea);
     }
 
     // Provide size in the payload, so clients don't have to query for that.
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 3273999128d2..6133b506c955 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -431,13 +431,13 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
     // Only invalidate if spreadsheet extended to the right
     if (aNewColArea.getWidth())
     {
-        SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewColArea.toString());
+        SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), &aNewColArea);
     }
 
     // Only invalidate if spreadsheet extended to the bottom
     if (aNewRowArea.getHeight())
     {
-        SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewRowArea.toString());
+        SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), &aNewRowArea);
     }
 
     // Provide size in the payload, so clients don't have to
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 8c0d58f50cec..bb29151b4b1e 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -1028,18 +1028,19 @@ void Window::LogicInvalidate(const ::tools::Rectangle* pRectangle)
 
     if (!comphelper::LibreOfficeKit::isActive())
         return;
-    OString sRectangle;
+    ::tools::Rectangle aRectangle;
+    ::tools::Rectangle* pResultRectangle;
     if (!pRectangle)
-        sRectangle = "EMPTY";
+        pResultRectangle = nullptr;
     else
     {
-        ::tools::Rectangle aRectangle(*pRectangle);
+        aRectangle = *pRectangle;
         if (GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
             aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
-        sRectangle = aRectangle.toString();
+        pResultRectangle = &aRectangle;
     }
     SfxViewShell& rSfxViewShell = pDrawViewShell->GetViewShellBase();
-    SfxLokHelper::notifyInvalidation(&rSfxViewShell, sRectangle);
+    SfxLokHelper::notifyInvalidation(&rSfxViewShell, pResultRectangle);
 }
 
 void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 415351d37db3..2f68b37e3bd9 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -493,14 +493,16 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
     pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, s.getStr());
 }
 
-void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, std::string_view rPayload)
+void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, tools::Rectangle const* pRect)
 {
-    OStringBuffer aBuf(32);
-
     if (DisableCallbacks::disabled())
         return;
 
-    aBuf.append(rPayload);
+    OStringBuffer aBuf(64);
+    if (pRect)
+        aBuf.append(pRect->toString());
+    else
+        aBuf.append("EMPTY");
     if (comphelper::LibreOfficeKit::isPartInInvalidation())
     {
         aBuf.append(", ");
diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx
index 108ca6bff18b..d82f234f3cd4 100644
--- a/svx/source/svdraw/sdrpagewindow.cxx
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -465,7 +465,7 @@ void SdrPageWindow::InvalidatePageWindow(const basegfx::B2DRange& rRange)
         const tools::Rectangle aRectTwips = OutputDevice::LogicToLogic(aRect100thMM, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
 
         if (SfxViewShell* pViewShell = SfxViewShell::Current())
-            SfxLokHelper::notifyInvalidation(pViewShell, aRectTwips.toString());
+            SfxLokHelper::notifyInvalidation(pViewShell, &aRectTwips);
     }
 }
 
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 41778c8af6cf..c89abea36b37 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -234,9 +234,9 @@ void SdrMarkView::ModelHasChanged()
 
     //TODO: Is MarkedObjRect valid at this point?
     tools::Rectangle aSelection(GetMarkedObjRect());
-    OString sSelection;
+    tools::Rectangle* pResultSelection;
     if (aSelection.IsEmpty())
-        sSelection = "EMPTY";
+        pResultSelection = nullptr;
     else
     {
         sal_uInt32 nTotalPaintWindows = this->PaintWindowCount();
@@ -266,11 +266,11 @@ void SdrMarkView::ModelHasChanged()
             }
         }
 
-        sSelection = aSelection.toString();
+        pResultSelection = &aSelection;
     }
 
     if(SfxViewShell* pViewShell = GetSfxViewShell())
-        SfxLokHelper::notifyInvalidation(pViewShell, sSelection);
+        SfxLokHelper::notifyInvalidation(pViewShell, pResultSelection);
 }
 
 
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 5a27274f380a..3a3b64defb26 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6496,13 +6496,7 @@ bool SwEditWin::DeleteSurroundingText(const Selection& rSelection)
 
 void SwEditWin::LogicInvalidate(const tools::Rectangle* pRectangle)
 {
-    OString sRectangle;
-    if (!pRectangle)
-        sRectangle = "EMPTY";
-    else
-        sRectangle = pRectangle->toString();
-
-    SfxLokHelper::notifyInvalidation(&m_rView, sRectangle);
+    SfxLokHelper::notifyInvalidation(&m_rView, pRectangle);
 }
 
 void SwEditWin::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 34c9fbdfd649..1740f4b306f1 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -29,12 +29,10 @@
 
 OString Pair::toString() const
 {
-    std::stringstream ss;
     // Note that this is not just used for debugging output but the
     // format is parsed by external code (passed in callbacks to
     // LibreOfficeKit clients). So don't change.
-    ss << A() << ", " << B();
-    return ss.str().c_str();
+    return OString::number(A()) + ", " + OString::number(B());
 }
 
 tools::Rectangle tools::Rectangle::Justify( const Point& rLT, const Point& rRB )
@@ -192,12 +190,10 @@ bool tools::Rectangle::IsOver( const tools::Rectangle& rRect ) const
 
 OString tools::Rectangle::toString() const
 {
-    std::stringstream ss;
     // Note that this is not just used for debugging output but the
     // format is parsed by external code (passed in callbacks to
     // LibreOfficeKit clients). So don't change.
-    ss << getX() << ", " << getY() << ", " << getWidth() << ", " << getHeight();
-    return ss.str().c_str();
+    return OString::number(getX()) + ", " + OString::number(getY()) + ", " + OString::number(getWidth()) + ", " + OString::number(getHeight());
 }
 
 void tools::Rectangle::expand(tools::Long nExpandBy)


More information about the Libreoffice-commits mailing list