Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9CDAF9BA0 for ; Tue, 6 Dec 2011 17:54:21 +0000 (UTC) Received: (qmail 85012 invoked by uid 500); 6 Dec 2011 17:54:21 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 84981 invoked by uid 500); 6 Dec 2011 17:54:21 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 84974 invoked by uid 99); 6 Dec 2011 17:54:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 17:54:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 17:54:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D18042388860; Tue, 6 Dec 2011 17:53:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: ooo-commits@incubator.apache.org From: alg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111206175355.D18042388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 +#include + 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 #include #include +#include // ----------- // - 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 );