[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - 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 Sep 16 17:01:49 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 712c5d7090abea828aff57f199879a7897211680
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 4 11:37:34 2021 +0200
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Sep 16 19:01:07 2021 +0200
improve LOK notifyInvalidation
(*) tweak buffer in SfxLokHelper::notifyInvalidation to be a bit larger,
so we avoid the cost of a resize©
(*) 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>
(cherry picked from commit 417f881d20cafe88a02b64894ba4483875fb9460)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122123
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index 6ab1fae77b99..f8fcb1f0aa34 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 84d9d5299fd4..3d95d4f602b4 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -46,11 +46,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 07baf8a20a3c..390b024757cf 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>
@@ -107,7 +108,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, const OString& 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 ce6c70b44c01..926e2407a0db 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1503,12 +1503,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())
{
@@ -1517,11 +1518,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 70e781d5e30c..f1aa58eabaf3 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2586,7 +2586,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 ec257e9d8b5f..bd34fd5d7520 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -429,13 +429,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 eceb4254a1fe..6e9ecc64b2ad 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -1025,18 +1025,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 364490a479ac..03a7c45dcae7 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -506,14 +506,16 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, s.getStr());
}
-void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& 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 c3230b12285d..ccb133d10af9 100644
--- a/svx/source/svdraw/sdrpagewindow.cxx
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -464,7 +464,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 bab58248fa9d..6ca400399f5c 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -232,9 +232,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();
@@ -263,11 +263,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 d28e67b9d8f9..a09a1cc9cc68 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6547,13 +6547,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 78025c459d07..e16d85698c0e 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 )
@@ -194,12 +192,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