Anonymous avatar Anonymous committed 1517793 Merge

merged

Comments (0)

Files changed (1)

sw/source/core/draw/dflyobj.cxx

 |*
 *************************************************************************/
 
+// --> 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();
     // 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() );
 		    }
 	    }
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.