You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/01/03 18:18:47 UTC

svn commit: r1226879 [2/2] - in /incubator/ooo/trunk/main: chart2/source/controller/chartapiwrapper/ chart2/source/controller/inc/ chart2/source/controller/main/ chart2/source/inc/ drawinglayer/ drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/s...

Modified: incubator/ooo/trunk/main/sw/source/core/doc/notxtfrm.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/doc/notxtfrm.cxx?rev=1226879&r1=1226878&r2=1226879&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/doc/notxtfrm.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/doc/notxtfrm.cxx Tue Jan  3 17:18:46 2012
@@ -73,7 +73,7 @@
 #include <com/sun/star/embed/EmbedStates.hpp>
 
 #include <svtools/embedhlp.hxx>
-#include <svtools/chartprettypainter.hxx>
+#include <svx/charthelper.hxx>
 // --> OD 2009-03-05 #i99665#
 #include <dview.hxx>
 // <--
@@ -817,6 +817,92 @@ void lcl_correctlyAlignRect( SwRect& rAl
     }
 }
 
+bool paintUsingPrimitivesHelper(
+    OutputDevice& rOutputDevice,
+    const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
+    const basegfx::B2DRange& rSourceRange,
+    const basegfx::B2DRange& rTargetRange,
+    const sal_Int32 nLeftCrop = 0,
+    const sal_Int32 nTopCrop = 0,
+    const sal_Int32 nRightCrop = 0,
+    const sal_Int32 nBottomCrop = 0,
+    const bool bMirrorX = false,
+    const bool bMirrorY = false)
+{
+    const double fSourceWidth(rSourceRange.getWidth());
+    const double fSourceHeight(rSourceRange.getHeight());
+
+    if(rSequence.hasElements() && !basegfx::fTools::equalZero(fSourceWidth) && !basegfx::fTools::equalZero(fSourceHeight))
+    {
+        // copy target range and apply evtl. cropping
+        basegfx::B2DRange aTargetRange(rTargetRange);
+
+        if(nLeftCrop || nTopCrop || nRightCrop || nBottomCrop)
+        {
+            // calculate original TargetRange
+            const double fFactor100thmmToTwips(72.0 / 127.0);
+
+            aTargetRange = basegfx::B2DRange(
+                aTargetRange.getMinX() - (nLeftCrop * fFactor100thmmToTwips),
+                aTargetRange.getMinY() - (nTopCrop * fFactor100thmmToTwips),
+                aTargetRange.getMaxX() + (nRightCrop * fFactor100thmmToTwips),
+                aTargetRange.getMaxY() + (nBottomCrop * fFactor100thmmToTwips));
+        }
+
+        const double fTargetWidth(aTargetRange.getWidth());
+        const double fTargetHeight(aTargetRange.getHeight());
+                            
+        if(!basegfx::fTools::equalZero(fTargetWidth) && !basegfx::fTools::equalZero(fTargetHeight))
+        {
+            // map graphic range to target range. This will automatically include
+            // tme mapping from Svg 1/100th mm content to twips since the target
+            // range is twips already
+            basegfx::B2DHomMatrix aMappingTransform(
+                basegfx::tools::createTranslateB2DHomMatrix(
+                    -rSourceRange.getMinX(), 
+                    -rSourceRange.getMinY()));
+
+            aMappingTransform.scale(fTargetWidth / fSourceWidth, fTargetHeight / fSourceHeight);
+            aMappingTransform.translate(aTargetRange.getMinX(), aTargetRange.getMinY());
+
+            // apply mirrorings
+            if(bMirrorX || bMirrorY)
+            {
+                aMappingTransform.translate(-aTargetRange.getCenterX(), -aTargetRange.getCenterY());
+                aMappingTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorX ? -1.0 : 1.0);
+                aMappingTransform.translate(aTargetRange.getCenterX(), aTargetRange.getCenterY());
+            }
+
+            // Fill ViewInformation. Use MappingTransform here, so there is no need to
+            // embed the primitives to it. Use original TargetRange here so there is also
+            // no need to embed the primitives to a MaskPrimitive for cropping. This works 
+            // only in this case where the graphic object cannot be rotated, though.
+            const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
+                aMappingTransform, 
+                rOutputDevice.GetViewTransformation(), 
+                aTargetRange, 
+                0,
+                0.0, 
+                uno::Sequence< beans::PropertyValue >());
+
+            // get a primitive processor for rendering
+            drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = sdr::contact::createBaseProcessor2DFromOutputDevice(
+                rOutputDevice, 
+                aViewInformation2D);
+
+            if(pProcessor2D)
+            {
+                // render and cleanup
+                pProcessor2D->process(rSequence);
+                delete pProcessor2D;
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
 // Ausgabe der Grafik. Hier wird entweder eine QuickDraw-Bmp oder
 // eine Grafik vorausgesetzt. Ist nichts davon vorhanden, wird
 // eine Ersatzdarstellung ausgegeben.
@@ -834,7 +920,7 @@ void SwNoTxtFrm::PaintPicture( OutputDev
     const sal_Bool bPrn = pOut == rNoTNd.getIDocumentDeviceAccess()->getPrinter( false ) ||
                           pOut->GetConnectMetaFile();
 
-    const bool bIsChart = pOLENd && ChartPrettyPainter::IsChart( pOLENd->GetOLEObj().GetObject() );
+    const bool bIsChart = pOLENd && ChartHelper::IsChart( pOLENd->GetOLEObj().GetObject() );
 
     /// OD 25.09.2002 #99739# - calculate aligned rectangle from parameter <rGrfArea>.
     ///     Use aligned rectangle <aAlignedGrfArea> instead of <rGrfArea> in
@@ -953,86 +1039,24 @@ void SwNoTxtFrm::PaintPicture( OutputDev
                     if(rSvgDataPtr.get())
                     {
                         // Graphic is Svg and can be painted as primitives (vector graphic)
-                        const basegfx::B2DRange& rRange = rSvgDataPtr->getRange();
-                        const double fWidth(rRange.getWidth());
-                        const double fHeight(rRange.getHeight());
-                        const drawinglayer::primitive2d::Primitive2DSequence& rSequence = rSvgDataPtr->getPrimitive2DSequence();
-
-                        if(rSequence.hasElements() && !basegfx::fTools::equalZero(fWidth) && !basegfx::fTools::equalZero(fHeight))
-                        {
-                            // get target range
-                            const basegfx::B2DRange aTargetRange(
-                                aAlignedGrfArea.Left(), aAlignedGrfArea.Top(), 
-                                aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
-
-                            // prepare evtl. cropped range
-                            basegfx::B2DRange aCroppedTargetRange(aTargetRange);
-
-                            if(aGrfAttr.IsCropped())
-                            {
-                                // calculate original TargetRange
-                                const double fFactor100thmmToTwips(72.0 / 127.0);
-
-                                aCroppedTargetRange = basegfx::B2DRange(
-                                    aTargetRange.getMinX() - (aGrfAttr.GetLeftCrop() * fFactor100thmmToTwips),
-                                    aTargetRange.getMinY() - (aGrfAttr.GetTopCrop() * fFactor100thmmToTwips),
-                                    aTargetRange.getMaxX() + (aGrfAttr.GetRightCrop() * fFactor100thmmToTwips),
-                                    aTargetRange.getMaxY() + (aGrfAttr.GetBottomCrop() * fFactor100thmmToTwips));
-                            }
-
-                            const double fTargetWidth(aCroppedTargetRange.getWidth());
-                            const double fTargetHeight(aCroppedTargetRange.getHeight());
-                            
-                            if(!basegfx::fTools::equalZero(fTargetWidth) && !basegfx::fTools::equalZero(fTargetHeight))
-                            {
-                                // map graphic range to target range. This will automatically include
-                                // tme mapping from Svg 1/100th mm content to twips since the target
-                                // range is twips already
-                                basegfx::B2DHomMatrix aMappingTransform(
-                                    basegfx::tools::createTranslateB2DHomMatrix(
-                                        -rRange.getMinX(), 
-                                        -rRange.getMinY()));
-
-                                aMappingTransform.scale(fTargetWidth / fWidth, fTargetHeight / fHeight);
-                                aMappingTransform.translate(aCroppedTargetRange.getMinX(), aCroppedTargetRange.getMinY());
-
-                                // check for and apply mirrorings
-                                const bool bMirrorHor(aGrfAttr.GetMirrorFlags() & BMP_MIRROR_HORZ);
-                                const bool bMirrorVer(aGrfAttr.GetMirrorFlags() & BMP_MIRROR_VERT);
-
-                                if(bMirrorHor || bMirrorVer)
-                                {
-                                    aMappingTransform.translate(-aCroppedTargetRange.getCenterX(), -aCroppedTargetRange.getCenterY());
-                                    aMappingTransform.scale(bMirrorHor ? -1.0 : 1.0, bMirrorVer ? -1.0 : 1.0);
-                                    aMappingTransform.translate(aCroppedTargetRange.getCenterX(), aCroppedTargetRange.getCenterY());
-                                }
-
-                                // Fill ViewInformation. Use MappingTransform here, so there is no need to
-                                // embed the primitives to it. Use original TargetRange here so there is also
-                                // no need to embed the primitives to a MaskPrimitive for cropping. This works 
-                                // only in this case where the graphic object cannot be rotated, though.
-                                const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
-                                    aMappingTransform, 
-                                    pOut->GetViewTransformation(), 
-                                    aTargetRange, 
-                                    0,
-                                    0.0, 
-                                    com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >());
-
-                                // get a primitive processor for rendering
-                                drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = sdr::contact::createBaseProcessor2DFromOutputDevice(
-                                    *pOut, 
-                                    aViewInformation2D);
-
-                                if(pProcessor2D)
-                                {
-                                    // render and cleanup
-                                    pProcessor2D->process(rSequence);
-                                    delete pProcessor2D;
-                                    bDone = true;
-                                }
-                            }
-                        }
+                        const basegfx::B2DRange aTargetRange(
+                            aAlignedGrfArea.Left(), aAlignedGrfArea.Top(), 
+                            aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
+                        const bool bCropped(aGrfAttr.IsCropped());
+                        const bool bMirrorHor(aGrfAttr.GetMirrorFlags() & BMP_MIRROR_HORZ);
+                        const bool bMirrorVer(aGrfAttr.GetMirrorFlags() & BMP_MIRROR_VERT);
+
+                        bDone = paintUsingPrimitivesHelper(
+                            *pOut,
+                            rSvgDataPtr->getPrimitive2DSequence(),
+                            rSvgDataPtr->getRange(),
+                            aTargetRange,
+                            bCropped ? aGrfAttr.GetLeftCrop() : 0,
+                            bCropped ? aGrfAttr.GetTopCrop() : 0,
+                            bCropped ? aGrfAttr.GetRightCrop() : 0,
+                            bCropped ? aGrfAttr.GetBottomCrop() : 0,
+                            aGrfAttr.GetMirrorFlags() & BMP_MIRROR_HORZ,
+                            aGrfAttr.GetMirrorFlags() & BMP_MIRROR_VERT);
                     }
 
                     if(!bDone)
@@ -1073,22 +1097,13 @@ void SwNoTxtFrm::PaintPicture( OutputDev
 		if( bForceSwap )
 			pGrfNd->SwapOut();
 	}
-    else if( bIsChart
-        //charts must be painted resolution dependent!! #i82893#, #i75867#
-        && ChartPrettyPainter::ShouldPrettyPaintChartOnThisDevice( pOut )
-        && svt::EmbeddedObjectRef::TryRunningState( pOLENd->GetOLEObj().GetOleRef() )
-        && ChartPrettyPainter::DoPrettyPaintChart( uno::Reference< frame::XModel >(
-            pOLENd->GetOLEObj().GetOleRef()->getComponent(), uno::UNO_QUERY), pOut, aAlignedGrfArea.SVRect() ) )
+    else // bIsChart || pOLENd
     {
-        (void)(0);//all was done in if statement
-    }
-    else if( pOLENd )
-	{
         // --> OD 2009-03-05 #i99665#
         // Adjust AntiAliasing mode at output device for chart OLE
         const sal_uInt16 nFormerAntialiasingAtOutput( pOut->GetAntialiasing() );
         if ( pOLENd->IsChart() &&
-             pShell->Imp()->GetDrawView()->IsAntiAliasing() )
+                pShell->Imp()->GetDrawView()->IsAntiAliasing() )
         {
             const sal_uInt16 nAntialiasingForChartOLE =
                     nFormerAntialiasingAtOutput | ANTIALIASING_PIXELSNAPHAIRLINE;
@@ -1096,64 +1111,97 @@ void SwNoTxtFrm::PaintPicture( OutputDev
         }
         // <--
 
-        Point aPosition(aAlignedGrfArea.Pos());
-        Size aSize(aAlignedGrfArea.SSize());
+        bool bDone(false);
 
-        // Im BrowseModus gibt es nicht unbedingt einen Drucker und
-        // damit kein JobSetup, also legen wir eines an ...
-        const JobSetup* pJobSetup = pOLENd->getIDocumentDeviceAccess()->getJobsetup();
-        sal_Bool bDummyJobSetup = 0 == pJobSetup;
-        if( bDummyJobSetup )
-            pJobSetup = new JobSetup();
-
-		// #i42323#
-		// The reason for #114233# is gone, so i remove it again
-        //TODO/LATER: is it a problem that the JopSetup isn't used?
-        //xRef->DoDraw( pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), *pJobSetup );
-
-        // get hi-contrast image, but never for printing
-		Graphic* pGraphic = NULL;
-        if (pOut && !bPrn && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
-			pGraphic = pOLENd->GetHCGraphic();
-
-		// when it is not possible to get HC-representation, the original image should be used
-		if ( !pGraphic )
-           	pGraphic = pOLENd->GetGraphic();
+        if(bIsChart)
+        {
+            const uno::Reference< frame::XModel > aXModel(pOLENd->GetOLEObj().GetOleRef()->getComponent(), uno::UNO_QUERY);
 
-        if ( pGraphic && pGraphic->GetType() != GRAPHIC_NONE )
-		{
-			pGraphic->Draw( pOut, aPosition, aSize );
+            if(aXModel.is())
+            {
+                basegfx::B2DRange aSourceRange;
 
-			// shade the representation if the object is activated outplace
-			uno::Reference < embed::XEmbeddedObject > xObj = pOLENd->GetOLEObj().GetOleRef();
-			if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::ACTIVE )
-			{
-				::svt::EmbeddedObjectRef::DrawShading( Rectangle( aPosition, aSize ), pOut );
-			}
-		}
-        else
-            ::svt::EmbeddedObjectRef::DrawPaintReplacement( Rectangle( aPosition, aSize ), pOLENd->GetOLEObj().GetCurrentPersistName(), pOut );
+                const drawinglayer::primitive2d::Primitive2DSequence aSequence(
+                    ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
+                        aXModel,
+                        aSourceRange));
 
-        if( bDummyJobSetup )
-            delete pJobSetup;  // ... und raeumen wieder auf.
+                if(aSequence.hasElements() && !aSourceRange.isEmpty())
+                {
+                    const basegfx::B2DRange aTargetRange(
+                        aAlignedGrfArea.Left(), aAlignedGrfArea.Top(), 
+                        aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
+
+                    bDone = paintUsingPrimitivesHelper(
+                        *pOut,
+                        aSequence,
+                        aSourceRange,
+                        aTargetRange);
+                }
+            }
+        }
 
-        sal_Int64 nMiscStatus = pOLENd->GetOLEObj().GetOleRef()->getStatus( pOLENd->GetAspect() );
-        if ( !bPrn && pShell->ISA( SwCrsrShell ) &&
-                nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
-        {
-            const SwFlyFrm *pFly = FindFlyFrm();
-            ASSERT( pFly, "OLE not in FlyFrm" );
-            ((SwFEShell*)pShell)->ConnectObj( pOLENd->GetOLEObj().GetObject(), pFly->Prt(), pFly->Frm());
+        if(!bDone && pOLENd)
+	    {
+            Point aPosition(aAlignedGrfArea.Pos());
+            Size aSize(aAlignedGrfArea.SSize());
+
+            // Im BrowseModus gibt es nicht unbedingt einen Drucker und
+            // damit kein JobSetup, also legen wir eines an ...
+            const JobSetup* pJobSetup = pOLENd->getIDocumentDeviceAccess()->getJobsetup();
+            sal_Bool bDummyJobSetup = 0 == pJobSetup;
+            if( bDummyJobSetup )
+                pJobSetup = new JobSetup();
+
+		    // #i42323#
+		    // The reason for #114233# is gone, so i remove it again
+            //TODO/LATER: is it a problem that the JopSetup isn't used?
+            //xRef->DoDraw( pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), *pJobSetup );
+
+            // get hi-contrast image, but never for printing
+		    Graphic* pGraphic = NULL;
+            if (pOut && !bPrn && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+			    pGraphic = pOLENd->GetHCGraphic();
+
+		    // when it is not possible to get HC-representation, the original image should be used
+		    if ( !pGraphic )
+           	    pGraphic = pOLENd->GetGraphic();
+
+            if ( pGraphic && pGraphic->GetType() != GRAPHIC_NONE )
+		    {
+			    pGraphic->Draw( pOut, aPosition, aSize );
+
+			    // shade the representation if the object is activated outplace
+			    uno::Reference < embed::XEmbeddedObject > xObj = pOLENd->GetOLEObj().GetOleRef();
+			    if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::ACTIVE )
+			    {
+				    ::svt::EmbeddedObjectRef::DrawShading( Rectangle( aPosition, aSize ), pOut );
+			    }
+		    }
+            else
+                ::svt::EmbeddedObjectRef::DrawPaintReplacement( Rectangle( aPosition, aSize ), pOLENd->GetOLEObj().GetCurrentPersistName(), pOut );
+
+            if( bDummyJobSetup )
+                delete pJobSetup;  // ... und raeumen wieder auf.
+
+            sal_Int64 nMiscStatus = pOLENd->GetOLEObj().GetOleRef()->getStatus( pOLENd->GetAspect() );
+            if ( !bPrn && pShell->ISA( SwCrsrShell ) &&
+                    nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
+            {
+                const SwFlyFrm *pFly = FindFlyFrm();
+                ASSERT( pFly, "OLE not in FlyFrm" );
+                ((SwFEShell*)pShell)->ConnectObj( pOLENd->GetOLEObj().GetObject(), pFly->Prt(), pFly->Frm());
+            }
         }
 
         // --> OD 2009-03-05 #i99665#
         if ( pOLENd->IsChart() &&
-             pShell->Imp()->GetDrawView()->IsAntiAliasing() )
+                pShell->Imp()->GetDrawView()->IsAntiAliasing() )
         {
             pOut->SetAntialiasing( nFormerAntialiasingAtOutput );
         }
         // <--
-	}
+    }
 }
 
 

Modified: incubator/ooo/trunk/main/sw/source/core/layout/paintfrm.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/layout/paintfrm.cxx?rev=1226879&r1=1226878&r2=1226879&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/layout/paintfrm.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/layout/paintfrm.cxx Tue Jan  3 17:18:46 2012
@@ -90,7 +90,7 @@
 // <--
 
 #include <ndole.hxx>
-#include <svtools/chartprettypainter.hxx>
+#include <svx/charthelper.hxx>
 #include <PostItMgr.hxx>
 #include <tools/color.hxx>
 #include <vcl/svapp.hxx>
@@ -3546,7 +3546,7 @@ void SwFlyFrm::Paint(SwRect const& rRect
         if( pNoTNd )
         {
             SwOLENode* pOLENd = const_cast<SwOLENode*>(pNoTNd->GetOLENode());
-            if( pOLENd && ChartPrettyPainter::IsChart( pOLENd->GetOLEObj().GetObject() ) )
+            if( pOLENd && ChartHelper::IsChart( pOLENd->GetOLEObj().GetObject() ) )
                 bIsChart = true;
         }
     }

Modified: incubator/ooo/trunk/main/sw/source/core/unocore/unochart.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/unocore/unochart.cxx?rev=1226879&r1=1226878&r2=1226879&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/unocore/unochart.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/unocore/unochart.cxx Tue Jan  3 17:18:46 2012
@@ -34,7 +34,7 @@
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
 #include <svl/zforlist.hxx>     // SvNumberFormatter
-#include <svtools/chartprettypainter.hxx>
+#include <svx/charthelper.hxx>
 
 #include <tools/link.hxx>
 
@@ -99,7 +99,7 @@ void SwChartHelper::DoUpdateAllCharts( S
     {
         aIdx++;
         if (0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
-            ChartPrettyPainter::IsChart( pONd->GetOLEObj().GetObject() ) )
+            ChartHelper::IsChart( pONd->GetOLEObj().GetObject() ) )
         {
             // Load the object and set modified