diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-15 15:58:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-16 09:54:58 +0200 |
commit | a399853f864ace2d4bd7e9a3a3b3eeb8a2379e4a (patch) | |
tree | c39ff3adad7060656ff7623cebd63e88bc60f0d4 | |
parent | bb34fed5b4cec43811a733e197137c2ac05f47c4 (diff) |
refactor to move overlay creation to SdrPaintView
Change-Id: Idbb734a44289d7ecead84f3c4ac2bc1ebc44ef40
Reviewed-on: https://gerrit.libreoffice.org/72381
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/svx/svdpntv.hxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/sdrpaintwindow.cxx | 92 |
2 files changed, 51 insertions, 44 deletions
diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx index 429e9b96f020..43bcd34e234f 100644 --- a/include/svx/svdpntv.hxx +++ b/include/svx/svdpntv.hxx @@ -43,6 +43,7 @@ class SdrPageWindow; namespace com { namespace sun { namespace star { namespace awt { class XControlContainer; }}}} +namespace sdr { namespace overlay { class OverlayManager; } } class SdrPage; class SdrView; @@ -220,6 +221,8 @@ public: bool IsPagePaintingAllowed() const { return mbPagePaintingAllowed;} void SetPagePaintingAllowed(bool bNew); + rtl::Reference<sdr::overlay::OverlayManager> CreateOverlayManager(OutputDevice& rDevice) const; + protected: svtools::ColorConfig maColorConfig; Color maGridColor; diff --git a/svx/source/svdraw/sdrpaintwindow.cxx b/svx/source/svdraw/sdrpaintwindow.cxx index 711da48c53b7..060437fa77a1 100644 --- a/svx/source/svdraw/sdrpaintwindow.cxx +++ b/svx/source/svdraw/sdrpaintwindow.cxx @@ -168,59 +168,63 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio mpPreRenderDevice->EnableMapMode(bMapModeWasEnabledSource); } - -void SdrPaintWindow::impCreateOverlayManager() +rtl::Reference<sdr::overlay::OverlayManager> SdrPaintView::CreateOverlayManager(OutputDevice& rOutputDevice) const { - // not yet one created? - if(!mxOverlayManager.is()) + rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager; + // is it a window? + if (OUTDEV_WINDOW == rOutputDevice.GetOutDevType()) { - // is it a window? - if(OUTDEV_WINDOW == GetOutputDevice().GetOutDevType()) + vcl::Window& rWindow = dynamic_cast<vcl::Window&>(rOutputDevice); + // decide which OverlayManager to use + if (IsBufferedOverlayAllowed() && !rWindow.SupportsDoubleBuffering()) { - vcl::Window& rWindow = dynamic_cast<vcl::Window&>(GetOutputDevice()); - // decide which OverlayManager to use - if(GetPaintView().IsBufferedOverlayAllowed() && !rWindow.SupportsDoubleBuffering()) - { - // buffered OverlayManager, buffers its background and refreshes from there - // for pure overlay changes (no system redraw). The 3rd parameter specifies - // whether that refresh itself will use a 2nd vdev to avoid flickering. - // Also hand over the old OverlayManager if existent; this means to take over - // the registered OverlayObjects from it - mxOverlayManager = sdr::overlay::OverlayManagerBuffered::create(GetOutputDevice()); - } - else - { - // unbuffered OverlayManager, just invalidates places where changes - // take place - // Also hand over the old OverlayManager if existent; this means to take over - // the registered OverlayObjects from it - mxOverlayManager = sdr::overlay::OverlayManager::create(GetOutputDevice()); - } + // buffered OverlayManager, buffers its background and refreshes from there + // for pure overlay changes (no system redraw). The 3rd parameter specifies + // whether that refresh itself will use a 2nd vdev to avoid flickering. + // Also hand over the old OverlayManager if existent; this means to take over + // the registered OverlayObjects from it + xOverlayManager = sdr::overlay::OverlayManagerBuffered::create(rOutputDevice); + } + else + { + // unbuffered OverlayManager, just invalidates places where changes + // take place + // Also hand over the old OverlayManager if existent; this means to take over + // the registered OverlayObjects from it + xOverlayManager = sdr::overlay::OverlayManager::create(rOutputDevice); + } - OSL_ENSURE(mxOverlayManager.is(), "SdrPaintWindow::SdrPaintWindow: Could not allocate an overlayManager (!)"); + OSL_ENSURE(xOverlayManager.is(), "SdrPaintWindow::SdrPaintWindow: Could not allocate an overlayManager (!)"); - // Request a repaint so that the buffered overlay manager fills - // its buffer properly. This is a workaround for missing buffer - // updates. - if (!comphelper::LibreOfficeKit::isActive()) - { - rWindow.Invalidate(); - } + // Request a repaint so that the buffered overlay manager fills + // its buffer properly. This is a workaround for missing buffer + // updates. + if (!comphelper::LibreOfficeKit::isActive()) + { + rWindow.Invalidate(); + } - Color aColA(GetPaintView().getOptionsDrawinglayer().GetStripeColorA()); - Color aColB(GetPaintView().getOptionsDrawinglayer().GetStripeColorB()); + Color aColA(getOptionsDrawinglayer().GetStripeColorA()); + Color aColB(getOptionsDrawinglayer().GetStripeColorB()); - if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) - { - aColA = aColB = Application::GetSettings().GetStyleSettings().GetHighlightColor(); - aColB.Invert(); - } - - mxOverlayManager->setStripeColorA(aColA); - mxOverlayManager->setStripeColorB(aColB); - mxOverlayManager->setStripeLengthPixel(GetPaintView().getOptionsDrawinglayer().GetStripeLength()); + if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + aColA = aColB = Application::GetSettings().GetStyleSettings().GetHighlightColor(); + aColB.Invert(); } + + xOverlayManager->setStripeColorA(aColA); + xOverlayManager->setStripeColorB(aColB); + xOverlayManager->setStripeLengthPixel(getOptionsDrawinglayer().GetStripeLength()); } + return xOverlayManager; +} + +void SdrPaintWindow::impCreateOverlayManager() +{ + // not yet one created? + if(!mxOverlayManager.is()) + mxOverlayManager = GetPaintView().CreateOverlayManager(GetOutputDevice()); } SdrPaintWindow::SdrPaintWindow(SdrPaintView& rNewPaintView, OutputDevice& rOut, vcl::Window* pWindow) |