Kaydet (Commit) b396bc04 authored tarafından Marco Cecchetti's avatar Marco Cecchetti Kaydeden (comit) Jan Holesovsky

Calc: safer life cycle handling for OutputDevice in SdrPaintWindow

Change-Id: I5469332c4ef98bce8cd9c2caff5bf61dbf102b23
Reviewed-on: https://gerrit.libreoffice.org/33220Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst a332bb9a
......@@ -46,7 +46,7 @@ PaintTransparentChildren(vcl::Window & rWindow, Rectangle const& rPixelRect);
class SdrPreRenderDevice
{
// The original OutputDevice
OutputDevice& mrOutputDevice;
VclPtr<OutputDevice> mpOutputDevice;
// The VirtualDevice for PreRendering
VclPtr<VirtualDevice> mpPreRenderDevice;
......@@ -65,7 +65,7 @@ class SVX_DLLPUBLIC SdrPaintWindow
{
private:
// the OutputDevice this window represents
OutputDevice& mrOutputDevice;
VclPtr<OutputDevice> mpOutputDevice;
/// In case mrOutputDevice is a buffer for a vcl::Window, this is the window.
VclPtr<vcl::Window> mpWindow;
......@@ -95,7 +95,7 @@ public:
// data read accesses
SdrPaintView& GetPaintView() const { return mrPaintView; }
OutputDevice& GetOutputDevice() const { return mrOutputDevice; }
OutputDevice& GetOutputDevice() const { return *mpOutputDevice.get(); }
vcl::Window* GetWindow() const { return mpWindow; }
// OVERLAYMANAGER
......@@ -108,13 +108,13 @@ public:
Rectangle GetVisibleArea() const;
// Is OutDev a printer?
bool OutputToPrinter() const { return (OUTDEV_PRINTER == mrOutputDevice.GetOutDevType()); }
bool OutputToPrinter() const { return (OUTDEV_PRINTER == mpOutputDevice->GetOutDevType()); }
// Is OutDev a window?
bool OutputToWindow() const { return (OUTDEV_WINDOW == mrOutputDevice.GetOutDevType()); }
bool OutputToWindow() const { return (OUTDEV_WINDOW == mpOutputDevice->GetOutDevType()); }
// Is OutDev a VirtualDevice?
bool OutputToVirtualDevice() const { return (OUTDEV_VIRDEV == mrOutputDevice.GetOutDevType()); }
bool OutputToVirtualDevice() const { return (OUTDEV_VIRDEV == mpOutputDevice->GetOutDevType()); }
// Is OutDev a recording MetaFile?
bool OutputToRecordingMetaFile() const;
......@@ -134,7 +134,7 @@ public:
void setTemporaryTarget(bool bNew) { mbTemporaryTarget = bNew; }
// #i72889# get target output device, take into account output buffering
OutputDevice& GetTargetOutputDevice() { if(mpPreRenderDevice) return mpPreRenderDevice->GetPreRenderDevice(); else return mrOutputDevice; }
OutputDevice& GetTargetOutputDevice() { if(mpPreRenderDevice) return mpPreRenderDevice->GetPreRenderDevice(); else return *mpOutputDevice.get(); }
};
// typedefs for a list of SdrPaintWindows
......
......@@ -108,7 +108,7 @@ void CandidateMgr::PaintTransparentChildren(vcl::Window & rWindow, Rectangle con
}
SdrPreRenderDevice::SdrPreRenderDevice(OutputDevice& rOriginal)
: mrOutputDevice(rOriginal),
: mpOutputDevice(&rOriginal),
mpPreRenderDevice(VclPtr<VirtualDevice>::Create())
{
}
......@@ -121,33 +121,33 @@ SdrPreRenderDevice::~SdrPreRenderDevice()
void SdrPreRenderDevice::PreparePreRenderDevice()
{
// compare size of mpPreRenderDevice with size of visible area
if(mpPreRenderDevice->GetOutputSizePixel() != mrOutputDevice.GetOutputSizePixel())
if(mpPreRenderDevice->GetOutputSizePixel() != mpOutputDevice->GetOutputSizePixel())
{
mpPreRenderDevice->SetOutputSizePixel(mrOutputDevice.GetOutputSizePixel());
mpPreRenderDevice->SetOutputSizePixel(mpOutputDevice->GetOutputSizePixel());
}
// Also compare the MapModes for zoom/scroll changes
if(mpPreRenderDevice->GetMapMode() != mrOutputDevice.GetMapMode())
if(mpPreRenderDevice->GetMapMode() != mpOutputDevice->GetMapMode())
{
mpPreRenderDevice->SetMapMode(mrOutputDevice.GetMapMode());
mpPreRenderDevice->SetMapMode(mpOutputDevice->GetMapMode());
}
// #i29186#
mpPreRenderDevice->SetDrawMode(mrOutputDevice.GetDrawMode());
mpPreRenderDevice->SetSettings(mrOutputDevice.GetSettings());
mpPreRenderDevice->SetDrawMode(mpOutputDevice->GetDrawMode());
mpPreRenderDevice->SetSettings(mpOutputDevice->GetSettings());
}
void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegion)
{
// region to pixels
const vcl::Region aRegionPixel(mrOutputDevice.LogicToPixel(rExpandedRegion));
const vcl::Region aRegionPixel(mpOutputDevice->LogicToPixel(rExpandedRegion));
//RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects());
//Rectangle aRegionRectanglePixel;
// MapModes off
bool bMapModeWasEnabledDest(mrOutputDevice.IsMapModeEnabled());
bool bMapModeWasEnabledDest(mpOutputDevice->IsMapModeEnabled());
bool bMapModeWasEnabledSource(mpPreRenderDevice->IsMapModeEnabled());
mrOutputDevice.EnableMapMode(false);
mpOutputDevice->EnableMapMode(false);
mpPreRenderDevice->EnableMapMode(false);
RectangleVector aRectangles;
......@@ -159,7 +159,7 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio
const Point aTopLeft(aRectIter->TopLeft());
const Size aSize(aRectIter->GetSize());
mrOutputDevice.DrawOutDev(
mpOutputDevice->DrawOutDev(
aTopLeft, aSize,
aTopLeft, aSize,
*mpPreRenderDevice.get());
......@@ -175,14 +175,14 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio
int nB = comphelper::rng::uniform_int_distribution(0, 0x7F-1);
const Color aColor(((((nR|0x80)<<8L)|(nG|0x80))<<8L)|(nB|0x80));
mrOutputDevice.SetLineColor(aColor);
mrOutputDevice.SetFillColor();
mrOutputDevice.DrawRect(*aRectIter);
mpOutputDevice->SetLineColor(aColor);
mpOutputDevice->SetFillColor();
mpOutputDevice->DrawRect(*aRectIter);
}
#endif
}
mrOutputDevice.EnableMapMode(bMapModeWasEnabledDest);
mpOutputDevice->EnableMapMode(bMapModeWasEnabledDest);
mpPreRenderDevice->EnableMapMode(bMapModeWasEnabledSource);
}
......@@ -242,7 +242,7 @@ void SdrPaintWindow::impCreateOverlayManager()
}
SdrPaintWindow::SdrPaintWindow(SdrPaintView& rNewPaintView, OutputDevice& rOut, vcl::Window* pWindow)
: mrOutputDevice(rOut),
: mpOutputDevice(&rOut),
mpWindow(pWindow),
mrPaintView(rNewPaintView),
mpPreRenderDevice(nullptr),
......@@ -276,7 +276,7 @@ Rectangle SdrPaintWindow::GetVisibleArea() const
bool SdrPaintWindow::OutputToRecordingMetaFile() const
{
GDIMetaFile* pMetaFile = mrOutputDevice.GetConnectMetaFile();
GDIMetaFile* pMetaFile = mpOutputDevice->GetConnectMetaFile();
return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
}
......@@ -292,7 +292,7 @@ void SdrPaintWindow::PreparePreRenderDevice()
{
if(!mpPreRenderDevice)
{
mpPreRenderDevice = new SdrPreRenderDevice(mrOutputDevice);
mpPreRenderDevice = new SdrPreRenderDevice(*mpOutputDevice.get());
}
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment