diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-05-10 16:31:43 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-05-10 16:44:57 +0200 |
commit | 7a6ebd9e527aaa1dc379e789f3379bc21753b5d8 (patch) | |
tree | 6f449d8dd1a0fe94e34784108c5af10041d14f2e /svx | |
parent | b9ad7c21f3646d532bee8235b028ae6be705e792 (diff) |
make it possible to update the region passed to BeginDrawLayers() (bnc#683550)
Writer needs this, as it changes the region during painting.
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/svdpntv.hxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdpntv.cxx | 106 |
2 files changed, 69 insertions, 41 deletions
diff --git a/svx/inc/svx/svdpntv.hxx b/svx/inc/svx/svdpntv.hxx index cb9c97e70a..b300cf9f93 100644 --- a/svx/inc/svx/svdpntv.hxx +++ b/svx/inc/svx/svdpntv.hxx @@ -400,6 +400,8 @@ public: // #i74769# Interface change to use common BeginCompleteRedraw/EndCompleteRedraw // #i76114# bDisableIntersect disables intersecting rReg with the Window's paint region SdrPaintWindow* BeginDrawLayers(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect = false); + // used when the region passed to BeginDrawLayers needs to be changed + void UpdateDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect = false); void EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer); protected: @@ -412,6 +414,8 @@ protected: // used to paint the form layer after the PreRender device is flushed (painted) to the window. void ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const; + Region OptimizeDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect); + public: sal_Bool IsPageVisible() const { return bPageVisible; } // Seite (weisse Flaeche) malen oder nicht sal_Bool IsPageBorderVisible() const { return bPageBorderVisible; } // Seite (weisse Flaeche) malen oder nicht diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index cbbd76874b..4e1990e568 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -964,47 +964,7 @@ SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const Region& if(pKnownTarget) { - // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region - // rReg may be made more granular (fine) with using it. Normally, rReg - // does come from Window::Paint() anyways and thus is based on a single - // rectangle which was derived from exactly that repaint region - Region aOptimizedRepaintRegion(rReg); - - // #i76114# Intersecting the region with the Window's paint region is disabled - // for print preview in Calc, because the intersection can be empty (if the paint - // region is outside of the table area of the page), and then no clip region - // would be set. - if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect) - { - Window* pWindow = (Window*)pOut; - - if(pWindow->IsInPaint()) - { - if(!pWindow->GetPaintRegion().IsEmpty()) - { - aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion()); - -#ifdef DBG_UTIL - // #i74769# test-paint repaint region - static bool bDoPaintForVisualControl(false); - if(bDoPaintForVisualControl) - { - RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects()); - Rectangle aRegionRectangle; - - while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle)) - { - pWindow->SetLineColor(COL_LIGHTGREEN); - pWindow->SetFillColor(); - pWindow->DrawRect(aRegionRectangle); - } - - aOptimizedRepaintRegion.EndEnumRects(aRegionHandle); - } -#endif - } - } - } + Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, bDisableIntersect ); // prepare redraw pKnownTarget->PrepareRedraw(aOptimizedRepaintRegion); @@ -1029,6 +989,70 @@ void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLa } } +void SdrPaintView::UpdateDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect) +{ + SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut); + OSL_ENSURE(pPaintWindow, "SdrPaintView::UpdateDrawLayersRegion: No SdrPaintWindow (!)"); + + if(mpPageView) + { + SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow); + + if(pKnownTarget) + { + Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, bDisableIntersect ); + pKnownTarget->GetPaintWindow().SetRedrawRegion(aOptimizedRepaintRegion); + mpPageView->setPreparedPageWindow(pKnownTarget); // already set actually + } + } +} + +Region SdrPaintView::OptimizeDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect) +{ + // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region + // rReg may be made more granular (fine) with using it. Normally, rReg + // does come from Window::Paint() anyways and thus is based on a single + // rectangle which was derived from exactly that repaint region + Region aOptimizedRepaintRegion(rReg); + + // #i76114# Intersecting the region with the Window's paint region is disabled + // for print preview in Calc, because the intersection can be empty (if the paint + // region is outside of the table area of the page), and then no clip region + // would be set. + if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect) + { + Window* pWindow = (Window*)pOut; + + if(pWindow->IsInPaint()) + { + if(!pWindow->GetPaintRegion().IsEmpty()) + { + aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion()); + +#ifdef DBG_UTIL + // #i74769# test-paint repaint region + static bool bDoPaintForVisualControl(false); + if(bDoPaintForVisualControl) + { + RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects()); + Rectangle aRegionRectangle; + + while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle)) + { + pWindow->SetLineColor(COL_LIGHTGREEN); + pWindow->SetFillColor(); + pWindow->DrawRect(aRegionRectangle); + } + + aOptimizedRepaintRegion.EndEnumRects(aRegionHandle); + } +#endif + } + } + } + return aOptimizedRepaintRegion; +} + //////////////////////////////////////////////////////////////////////////////////////////////////// void SdrPaintView::ImpTextEditDrawing(SdrPaintWindow& rPaintWindow) const |