diff options
author | Oliver-Rainer Wittmann <od@openoffice.org> | 2011-03-23 10:24:41 +0100 |
---|---|---|
committer | Oliver-Rainer Wittmann <od@openoffice.org> | 2011-03-23 10:24:41 +0100 |
commit | 222aa143f18508f514c4ba2d32c82d1ae3334d1c (patch) | |
tree | 3c0322ecdcea398214f9050d0c6121efc4d1fec6 /sw | |
parent | 2042bfa6e98f275047cddb39fd3d5b0592f642e4 (diff) |
os151: #i102707# - method <SwVirtFlyDrawObj::wrap_DoPaintObject()> - restoration of map mode only if needed and special handling during meta file creation
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/draw/dflyobj.cxx | 66 |
1 files changed, 55 insertions, 11 deletions
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 73616b18fc36..1fac4a1634a7 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -473,6 +473,52 @@ SwFrmFmt *SwVirtFlyDrawObj::GetFmt() |* *************************************************************************/ +// --> OD #i102707# +namespace +{ + class RestoreMapMode + { + public: + explicit RestoreMapMode( ViewShell* pViewShell ) + : mbMapModeRestored( false ) + , mpOutDev( pViewShell->GetOut() ) + { + if ( pViewShell->getPrePostMapMode() != mpOutDev->GetMapMode() ) + { + mpOutDev->Push(PUSH_MAPMODE); + + GDIMetaFile* pMetaFile = mpOutDev->GetConnectMetaFile(); + if ( pMetaFile && + pMetaFile->IsRecord() && !pMetaFile->IsPause() ) + { + ASSERT( false, + "MapMode restoration during meta file creation is somehow suspect - using <SetRelativeMapMode(..)>, but not sure, if correct." ) + mpOutDev->SetRelativeMapMode( pViewShell->getPrePostMapMode() ); + } + else + { + mpOutDev->SetMapMode( pViewShell->getPrePostMapMode() ); + } + + mbMapModeRestored = true; + } + }; + + ~RestoreMapMode() + { + if ( mbMapModeRestored ) + { + mpOutDev->Pop(); + } + }; + + private: + bool mbMapModeRestored; + OutputDevice* mpOutDev; + }; +} +// <-- + void SwVirtFlyDrawObj::wrap_DoPaintObject() const { ViewShell* pShell = pFlyFrm->getRootFrm()->GetCurrShell(); @@ -482,31 +528,29 @@ void SwVirtFlyDrawObj::wrap_DoPaintObject() const // but no paints. IsPaintInProgress() depends on SW repaint, so, as long // as SW paints self and calls DrawLayer() for Heaven and Hell, this will // be correct - if(pShell && pShell->IsDrawingLayerPaintInProgress()) + if ( pShell && pShell->IsDrawingLayerPaintInProgress() ) { sal_Bool bDrawObject(sal_True); - if(!SwFlyFrm::IsPaint((SdrObject*)this, pShell)) + if ( !SwFlyFrm::IsPaint( (SdrObject*)this, pShell ) ) { bDrawObject = sal_False; } - if(bDrawObject) + if ( bDrawObject ) { - if(!pFlyFrm->IsFlyInCntFrm()) + if ( !pFlyFrm->IsFlyInCntFrm() ) { // it is also necessary to restore the VCL MapMode from ViewInformation since e.g. // the VCL PixelRenderer resets it at the used OutputDevice. Unfortunately, this // excludes shears and rotates which are not expressable in MapMode. - OutputDevice* pOut = pShell->GetOut(); - - pOut->Push(PUSH_MAPMODE); - pOut->SetMapMode(pShell->getPrePostMapMode()); + // OD #i102707# + // new helper class to restore MapMode - restoration, only if + // needed and consideration of paint for meta file creation . + RestoreMapMode aRestoreMapModeIfNeeded( pShell ); // paint the FlyFrame (use standard VCL-Paint) - pFlyFrm->Paint(GetFlyFrm()->Frm()); - - pOut->Pop(); + pFlyFrm->Paint( GetFlyFrm()->Frm() ); } } } |