[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 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
Wed Aug 4 16:24:12 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/SidebarScrollBar.cxx | 3 +--
sw/source/uibase/docvw/SidebarTxtControl.cxx | 3 +--
sw/source/uibase/docvw/edtwin.cxx | 8 +-------
tools/source/generic/gen.cxx | 8 ++------
14 files changed, 40 insertions(+), 48 deletions(-)
New commits:
commit 5a76932c9f53bd35a83f3f956d4cbd693b88bfee
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: Wed Aug 4 18:23:34 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>
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index 0971fd079ca1..4c9e59542af3 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 1a927280e24b..17c0be8b2824 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 9c91a1724844..b552d959c487 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 <boost/optional.hpp>
@@ -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 dce3d4a6d5d4..c3cfe1f60a54 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1499,12 +1499,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())
{
@@ -1513,11 +1514,11 @@ void ScGridWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
}
else
aRectangle = PixelToLogic(aRectangle, MapMode(MapUnit::MapTwip));
- sRectangle = aRectangle.toString();
+ pResultRectangle = &aRectangle;
}
ScTabViewShell* pViewShell = pViewData->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 1f924ddaf8f9..0c23821cd26d 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2588,7 +2588,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 92bc95326f9c..072207a0c6cd 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -412,13 +412,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 118f1545b186..a6ce2c02b2b3 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -1009,18 +1009,19 @@ void Window::LogicInvalidate(const ::tools::Rectangle* pRectangle)
if (!pDrawViewShell || pDrawViewShell->IsInSwitchPage())
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 04ea9b8a25f5..1641811af86d 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 b85ab66a9e12..775f35510c3a 100644
--- a/svx/source/svdraw/sdrpagewindow.cxx
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -449,7 +449,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 738faec6175f..caf9321b41dd 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -251,9 +251,9 @@ void SdrMarkView::ModelHasChanged()
{
//TODO: Is MarkedObjRect valid at this point?
tools::Rectangle aSelection(GetMarkedObjRect());
- OString sSelection;
+ tools::Rectangle* pResultRect;
if (aSelection.IsEmpty())
- sSelection = "EMPTY";
+ pResultRect = nullptr;
else
{
sal_uInt32 nTotalPaintWindows = this->PaintWindowCount();
@@ -282,11 +282,11 @@ void SdrMarkView::ModelHasChanged()
}
}
- sSelection = aSelection.toString();
+ pResultRect = &aSelection;
}
if(SfxViewShell* pViewShell = GetSfxViewShell())
- SfxLokHelper::notifyInvalidation(pViewShell, sSelection);
+ SfxLokHelper::notifyInvalidation(pViewShell, pResultRect);
}
}
diff --git a/sw/source/uibase/docvw/SidebarScrollBar.cxx b/sw/source/uibase/docvw/SidebarScrollBar.cxx
index 9b57616ba89f..ee118f29b496 100644
--- a/sw/source/uibase/docvw/SidebarScrollBar.cxx
+++ b/sw/source/uibase/docvw/SidebarScrollBar.cxx
@@ -54,9 +54,8 @@ void SidebarScrollBar::LogicInvalidate(const tools::Rectangle* pRectangle)
rParent.Pop();
aRectangle.Move(aOffset.getX(), aOffset.getY());
- OString sRectangle = aRectangle.toString();
SwWrtShell& rWrtShell = m_rView.GetWrtShell();
- SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), sRectangle);
+ SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), &aRectangle);
}
void SidebarScrollBar::MouseButtonUp(const MouseEvent& /*rMouseEvent*/)
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx
index bdbb0e2804e4..9598b607bff1 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.cxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx
@@ -214,9 +214,8 @@ void SidebarTextControl::LogicInvalidate(const tools::Rectangle* pRectangle)
rParent.Pop();
aRectangle.Move(aOffset.getX(), aOffset.getY());
- OString sRectangle = aRectangle.toString();
SwWrtShell& rWrtShell = mrDocView.GetWrtShell();
- SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), sRectangle);
+ SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), &aRectangle);
}
void SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt )
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index facc9e95bda0..4f4cd8a6b754 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6356,13 +6356,7 @@ Selection SwEditWin::GetSurroundingTextSelection() const
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 7c182818c460..d7360af6419c 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());
}
void tools::Rectangle::SetSize( const Size& rSize )
@@ -185,12 +183,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(long nExpandBy)
More information about the Libreoffice-commits
mailing list