incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1211055 - in /incubator/ooo/branches/alg/svgreplacement/main: svx/source/svdraw/svdograf.cxx svx/source/svdraw/svdorect.cxx vcl/source/gdi/gdimtf.cxx
Date Tue, 06 Dec 2011 17:53:55 GMT
Author: alg
Date: Tue Dec  6 17:53:55 2011
New Revision: 1211055

URL: http://svn.apache.org/viewvc?rev=1211055&view=rev
Log:
svg: Adapted DoConvertToPolyObj for Svg-using SdrGraphObjs to make most processings work,
e.g. conversions and logical operations. Also fixed a bottleneck in CRC number calculation
for MetaFiles

Modified:
    incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdograf.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdorect.cxx
    incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx

Modified: incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdograf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdograf.cxx?rev=1211055&r1=1211054&r2=1211055&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdograf.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdograf.cxx Tue Dec
 6 17:53:55 2011
@@ -1091,11 +1091,67 @@ const GDIMetaFile* SdrGrafObj::GetGDIMet
 
 // -----------------------------------------------------------------------------
 
+#include <drawinglayer/processor2d/vclmetafileprocessor2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
 SdrObject* SdrGrafObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
 {
 	SdrObject* pRetval = NULL;
+    GraphicType aGraphicType(GetGraphicType());
+    GDIMetaFile aMtf;
+
+    if(GRAPHIC_BITMAP == aGraphicType)
+    {
+        const Graphic& rGraphic = GetGraphic();
+
+        if(rGraphic.getSvgData().get())
+        {
+            // Embedded Svg
+            // There is currently no helper to create SdrObjects from primitives (even if
I'm thinking
+            // about writing one for some time). To get the roundtrip to SdrObjects it is
necessary to
+            // use the old converter path over the MetaFile mechanism. Create Metafile from
Svg 
+            // primitives here pretty directly
+            VirtualDevice aOut;
+            Size aDummySize(2, 2);
+
+            aOut.SetOutputSizePixel(aDummySize);
+            aOut.EnableOutput(false);
+            aMtf.Clear();
+            aMtf.Record(&aOut);
+
+            // map to (0,0,objectsize)
+            const basegfx::B2DRange& rRange = rGraphic.getSvgData()->getRange();
+            basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createTranslateB2DHomMatrix(-rRange.getMinX(),
-rRange.getMinY()));
+
+            aObjectMatrix.scale(
+                aRect.getWidth() / (basegfx::fTools::equalZero(rRange.getWidth()) ? 1.0 :
rRange.getWidth()),
+                aRect.getHeight() / (basegfx::fTools::equalZero(rRange.getHeight()) ? 1.0
: rRange.getHeight()));
+
+            const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
+                aObjectMatrix,
+                basegfx::B2DHomMatrix(),
+                basegfx::B2DRange(),
+                0,
+                0.0,
+                com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >());
+            drawinglayer::processor2d::VclMetafileProcessor2D aProcessor(aViewInformation2D,
aOut);
+
+            aProcessor.process(rGraphic.getSvgData()->getPrimitive2DSequence());
+            
+            aMtf.Stop();
+            aMtf.WindStart();
+            aMtf.SetPrefMapMode(rGraphic.GetPrefMapMode());
+            aMtf.SetPrefSize(rGraphic.GetPrefSize());
+
+            aGraphicType = GRAPHIC_GDIMETAFILE;
+        }
+    }
+    else if(GRAPHIC_GDIMETAFILE == aGraphicType)
+    {
+        aMtf = GetTransformedGraphic(SDRGRAFOBJ_TRANSFORMATTR_COLOR|SDRGRAFOBJ_TRANSFORMATTR_MIRROR).GetGDIMetaFile();
+    }
 
-	switch( GetGraphicType() )
+	switch(aGraphicType)
 	{
 		case GRAPHIC_GDIMETAFILE:
 		{
@@ -1105,14 +1161,12 @@ SdrObject* SdrGrafObj::DoConvertToPolyOb
 			aFilter.SetLayer(GetLayer());
 
 			SdrObjGroup* pGrp = new SdrObjGroup();
-			sal_uInt32 nInsAnz = aFilter.DoImport(GetTransformedGraphic(
-                SDRGRAFOBJ_TRANSFORMATTR_COLOR|SDRGRAFOBJ_TRANSFORMATTR_MIRROR).GetGDIMetaFile(),

-                *pGrp->GetSubList(), 0);
+			sal_uInt32 nInsAnz = aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0);
 
             if(nInsAnz)
 			{
                 {
-                    // copy transformation
+                        // copy transformation
                 	GeoStat aGeoStat(GetGeoStat());
 
 	                if(aGeoStat.nShearWink) 

Modified: incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdorect.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdorect.cxx?rev=1211055&r1=1211054&r2=1211055&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdorect.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svx/source/svdraw/svdorect.cxx Tue Dec
 6 17:53:55 2011
@@ -591,7 +591,10 @@ SdrObject* SdrRectObj::DoConvertToPolyOb
     aPolyPolygon.removeDoublePoints();
 	SdrObject* pRet = 0L;
 	
-	if(!IsTextFrame() || HasFill() || HasLine()) 
+    // small correction: Do not create something when no fill and no line. To
+    // be sure to not damage something with non-text frames, do this only
+    // when used with bAddText==false from other converters
+	if((bAddText && !IsTextFrame()) || HasFill() || HasLine()) 
 	{
 		pRet = ImpConvertMakeObj(aPolyPolygon, sal_True, bBezier);
 	}

Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx?rev=1211055&r1=1211054&r2=1211055&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/gdimtf.cxx Tue Dec  6 17:53:55
2011
@@ -37,6 +37,7 @@
 #include <vcl/virdev.hxx>
 #include <vcl/gdimtf.hxx>
 #include <vcl/graphictools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
 
 // -----------
 // - Defines -
@@ -2713,6 +2714,73 @@ sal_uLong GDIMetaFile::GetChecksum() con
 			}
 			break;
 
+            case META_CLIPREGION_ACTION :
+            {
+                MetaClipRegionAction* pAct = dynamic_cast< MetaClipRegionAction* >(pAction);
+                const Region& rRegion = pAct->GetRegion();
+
+                if(rRegion.HasPolyPolygon())
+                {
+                    // It has shown that this is a possible bottleneck for checksum calculation.
+                    // In worst case a very expensive RegionHandle representation gets created.
+                    // In this case it's cheaper to use the PolyPolygon
+                    const basegfx::B2DPolyPolygon aPolyPolygon(rRegion.GetB2DPolyPolygon());
+                    const sal_uInt32 nPolyCount(aPolyPolygon.count());
+                    SVBT64 aSVBT64;
+
+                    for(sal_uInt32 a(0); a < nPolyCount; a++)
+                    {
+                        const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(a));
+                        const sal_uInt32 nPointCount(aPolygon.count());
+                        const bool bControl(aPolygon.areControlPointsUsed());
+                        
+                        for(sal_uInt32 b(0); b < nPointCount; b++)
+                        {
+                            const basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(b));
+
+                            DoubleToSVBT64(aPoint.getX(), aSVBT64);
+                            nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+                            DoubleToSVBT64(aPoint.getY(), aSVBT64);
+                            nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+
+                            if(bControl)
+                            {
+                                if(aPolygon.isPrevControlPointUsed(b))
+                                {
+                                    const basegfx::B2DPoint aCtrl(aPolygon.getPrevControlPoint(b));
+
+                                    DoubleToSVBT64(aCtrl.getX(), aSVBT64);
+                                    nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+                                    DoubleToSVBT64(aCtrl.getY(), aSVBT64);
+                                    nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+                                }
+
+                                if(aPolygon.isNextControlPointUsed(b))
+                                {
+                                    const basegfx::B2DPoint aCtrl(aPolygon.getNextControlPoint(b));
+
+                                    DoubleToSVBT64(aCtrl.getX(), aSVBT64);
+                                    nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+                                    DoubleToSVBT64(aCtrl.getY(), aSVBT64);
+                                    nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+                                }
+                            }
+                        }
+                    }
+
+                    SVBT8 aSVBT8;
+                    ByteToSVBT8((sal_uInt8)pAct->IsClipping(), aSVBT8);
+                    nCrc = rtl_crc32(nCrc, aSVBT8, 1);
+                }
+                else
+                {
+                    pAction->Write( aMemStm, &aWriteData );
+                    nCrc = rtl_crc32( nCrc, aMemStm.GetData(), aMemStm.Tell() );
+                    aMemStm.Seek( 0 );
+                }
+            }
+            break;
+
 			default:
 			{
 				pAction->Write( aMemStm, &aWriteData );



Mime
View raw message