summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-07 13:02:14 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-09-08 10:33:39 +0200
commit092c5f5ae9e8e1975ab1595f782fe10a2739a4d7 (patch)
treee520cfabcd212a2c3e989b5bf20cdfed239203f3
parent7280d3b62c0326554a0d2b14f218b5282562b2cf (diff)
patch SdrPageWindow in SdXImpressDocument::paintTile()
This is based on commit 424312aa99307da9f0ee60ea6e3213b2b3dc26b4 amd I don't quite understand everything that happens, because the drawing layer classes have all kinds of comments except those that would explain the purpose or usage of the classes. My understanding is that drawing layer keeps all kinds of state in Sdr* classes and when drawing it tries to find those based on the OutputDevice. But since tiled drawing uses its own VirtualDevice for the drawing, the search fails and a temporary state is used that's always setup up and cleared again. Which is wasteful, and not having the state around also means that e.g. when clicking a checkbox for impress master background, with idle painting disabled there's nothing to react to the event and cause a tile repaint. Change-Id: Ic9036680c628d67615a82dcc4f585ab827b91525 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121779 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index a246aab75b34..f5d3b51c72d4 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -58,6 +58,8 @@
#include <svx/svdundo.hxx>
#include <svx/unoapi.hxx>
#include <svx/unofill.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdrpaintwindow.hxx>
#include <editeng/flditem.hxx>
#include <editeng/fontitem.hxx>
#include <toolkit/awt/vclxdevice.hxx>
@@ -2220,6 +2222,25 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
if (!pViewSh)
return;
+ // Setup drawing layer to work properly. Since we use a custom VirtualDevice
+ // for the drawing, SdrPaintView::BeginCompleteRedraw() will call FindPaintWindow()
+ // unsuccessfully and use a temporary window that doesn't keep state. So patch
+ // the existing SdrPageWindow to use a temporary, and this way the state will be kept.
+ // Well, at least that's how I understand it based on Writer's RenderContextGuard,
+ // as the drawing layer classes lack documentation.
+ SdrPageWindow* patchedPageWindow = nullptr;
+ SdrPaintWindow* previousPaintWindow = nullptr;
+ std::unique_ptr<SdrPaintWindow> temporaryPaintWindow;
+ if(SdrView* pDrawView = pViewSh->GetDrawView())
+ {
+ if(SdrPageView* pSdrPageView = pDrawView->GetSdrPageView())
+ {
+ patchedPageWindow = pSdrPageView->FindPageWindow(*getDocWindow());
+ temporaryPaintWindow.reset(new SdrPaintWindow(*pDrawView, rDevice));
+ previousPaintWindow = patchedPageWindow->patchPaintWindow(*temporaryPaintWindow);
+ }
+ }
+
// Scaling. Must convert from pixels to twips. We know
// that VirtualDevices use a DPI of 96.
// We specifically calculate these scales first as we're still
@@ -2257,6 +2278,9 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+
+ if(patchedPageWindow != nullptr)
+ patchedPageWindow->unpatchPaintWindow(previousPaintWindow);
}
void SdXImpressDocument::selectPart(int nPart, int nSelect)