From 6d7e059e8f632f35496b8528a90d6ad3dc4f6ae1 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 18 Dec 2020 08:21:02 +0100 Subject: Revert "HACK: Revert "tdf#132940 Crash in mergedlo!vcl::Region::operator="" tdf#131281 has now properly been fixed with commit 5592d5e97810e68bcc0a70b2892c4ad487a06f81 Author: Armin Le Grand (allotropia) Date: Tue Dec 15 00:52:05 2020 +0100 tdf#131281 Always draw FormControls when TiledRendering When FormControls are not in layout mode it would be necessary to have real VCL ChildWindows in the client (usually the office). While this is done in the office itself and thus the visualization of FormControls (and their usage) is guaranteed, this is currently not the case for existing clients of TiledRendering. The big solution would be an API for the TiledRendering client to get infos for FormControls and create these locally (what would allow to have these editable/interactive and in the style of the client system). As long as this is not the case, I add this fallback to render the FormControls as content to the tiles to get them visualized at all. so drop the hack that was only done to make the revert of the commit that introduced the regression tdf#132940 apply cleanly. This reverts commit 1297eab938570ef6ffd7526fb59e1b97fdb22de8. --- include/svx/sdrpagewindow.hxx | 4 ++-- svx/source/svdraw/sdrpagewindow.cxx | 33 ++++++++++++++++++++++++++------- svx/source/svdraw/svdpagv.cxx | 11 ++++++----- sw/source/core/view/viewsh.cxx | 5 +++-- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/include/svx/sdrpagewindow.hxx b/include/svx/sdrpagewindow.hxx index 80417a6729a0..f5cb98c297da 100644 --- a/include/svx/sdrpagewindow.hxx +++ b/include/svx/sdrpagewindow.hxx @@ -68,8 +68,8 @@ public: rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const; // #i72752# allow patcing SdrPaintWindow from SdrPageView::DrawLayer if needed - void patchPaintWindow(SdrPaintWindow& rPaintWindow); - void unpatchPaintWindow(); + [[nodiscard]] SdrPaintWindow* patchPaintWindow(SdrPaintWindow& rPaintWindow); + void unpatchPaintWindow(SdrPaintWindow* pPreviousPaintWindow); // the repaint method. For migration from pPaintProc, use one more parameter void PrePaint(); diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx index fb3155c0eb14..6d197dab5282 100644 --- a/svx/source/svdraw/sdrpagewindow.cxx +++ b/svx/source/svdraw/sdrpagewindow.cxx @@ -163,22 +163,41 @@ rtl::Reference< sdr::overlay::OverlayManager > const & SdrPageWindow::GetOverlay return GetPaintWindow().GetOverlayManager(); } -void SdrPageWindow::patchPaintWindow(SdrPaintWindow& rPaintWindow) +SdrPaintWindow* SdrPageWindow::patchPaintWindow(SdrPaintWindow& rPaintWindow) { - mpImpl->mpOriginalPaintWindow = mpImpl->mpPaintWindow; - mpImpl->mpPaintWindow = &rPaintWindow; - mpImpl->mpOriginalPaintWindow->setPatched(&rPaintWindow); + if (!mpImpl->mpOriginalPaintWindow) + { + // first patch + mpImpl->mpOriginalPaintWindow = mpImpl->mpPaintWindow; + mpImpl->mpPaintWindow = &rPaintWindow; + mpImpl->mpOriginalPaintWindow->setPatched(&rPaintWindow); + return mpImpl->mpOriginalPaintWindow; + } + else + { + // second or more patch + auto pPreviousPaintWindow = mpImpl->mpPaintWindow; + mpImpl->mpPaintWindow = &rPaintWindow; + mpImpl->mpOriginalPaintWindow->setPatched(&rPaintWindow); + return pPreviousPaintWindow; + } } -void SdrPageWindow::unpatchPaintWindow() +void SdrPageWindow::unpatchPaintWindow(SdrPaintWindow* pPreviousPaintWindow) { - DBG_ASSERT(mpImpl->mpOriginalPaintWindow, "SdrPageWindow::unpatchPaintWindow: paint window not patched!" ); - if (mpImpl->mpOriginalPaintWindow) + if (pPreviousPaintWindow == mpImpl->mpOriginalPaintWindow) { + // first patch mpImpl->mpPaintWindow = mpImpl->mpOriginalPaintWindow; mpImpl->mpOriginalPaintWindow->setPatched(nullptr); mpImpl->mpOriginalPaintWindow = nullptr; } + else + { + // second or more patch + mpImpl->mpPaintWindow = pPreviousPaintWindow; + mpImpl->mpOriginalPaintWindow->setPatched(pPreviousPaintWindow); + } } void SdrPageWindow::PrePaint() diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 215e37bc7c94..480182782984 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include using namespace ::com::sun::star; @@ -290,13 +291,13 @@ void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, else aTemporaryPaintWindow.SetRedrawRegion(vcl::Region(rRect)); // patch the ExistingPageWindow - pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow); - + auto pPreviousWindow = pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow); + // unpatch window when leaving the scope + const ::comphelper::ScopeGuard aGuard( + [&pPreviousWindow, &pPreparedTarget]() { pPreparedTarget->unpatchPaintWindow(pPreviousWindow); } ); + // redraw the layer pPreparedTarget->RedrawLayer(&nID, pRedirector, pPageFrame); - - // restore the ExistingPageWindow - pPreparedTarget->unpatchPaintWindow(); } else { diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index b711cf472bad..ef26275ab9fd 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1719,6 +1719,7 @@ class RenderContextGuard { std::unique_ptr m_TemporaryPaintWindow; SdrPageWindow* m_pPatchedPageWindow; + SdrPaintWindow* m_pPreviousPaintWindow = nullptr; public: RenderContextGuard(VclPtr& pRef, vcl::RenderContext* pValue, SwViewShell* pShell) @@ -1741,7 +1742,7 @@ public: if (nullptr != m_pPatchedPageWindow) { m_TemporaryPaintWindow.reset(new SdrPaintWindow(*pDrawView, *pValue)); - m_pPatchedPageWindow->patchPaintWindow(*m_TemporaryPaintWindow); + m_pPreviousPaintWindow = m_pPatchedPageWindow->patchPaintWindow(*m_TemporaryPaintWindow); } } } @@ -1752,7 +1753,7 @@ public: { if(nullptr != m_pPatchedPageWindow) { - m_pPatchedPageWindow->unpatchPaintWindow(); + m_pPatchedPageWindow->unpatchPaintWindow(m_pPreviousPaintWindow); } } }; -- cgit