ooo-build r12691 - in branches/ooo-build-2-4-1: . patches/src680



Author: thorstenb
Date: Wed May 28 21:24:46 2008
New Revision: 12691
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12691&view=rev

Log:
	* patches/src680/svg-import-filter-gfxfilter.diff: now on par with
	document svg import (text, shapes, gradients, strokes & bitmaps
	working). Incremental patch, needs the other svg patches before.
	* patches/src680/apply: added aforementioned patch to SVGImport
	section.



Modified:
   branches/ooo-build-2-4-1/ChangeLog
   branches/ooo-build-2-4-1/patches/src680/apply
   branches/ooo-build-2-4-1/patches/src680/svg-import-filter-gfxfilter.diff

Modified: branches/ooo-build-2-4-1/patches/src680/apply
==============================================================================
--- branches/ooo-build-2-4-1/patches/src680/apply	(original)
+++ branches/ooo-build-2-4-1/patches/src680/apply	Wed May 28 21:24:46 2008
@@ -1963,8 +1963,12 @@
 # Marco Cecchetti's work on importing text
 #svg-import-text.diff, jholesov
 
+# A bit less partial implementation of SVG import
+# Work in progress, but fairly usable already
 svg-import-basegfx.diff, thorsten
 svg-import-filter.diff, thorsten
+# Same as before, but adds a graphic filter for SVG
+svg-import-filter-gfxfilter.diff, thorsten
 
 [ CalcDataPilotDrillDown ]
 # Implements DataPilot cache table, result drill-down, and some extra UNO API.

Modified: branches/ooo-build-2-4-1/patches/src680/svg-import-filter-gfxfilter.diff
==============================================================================
--- branches/ooo-build-2-4-1/patches/src680/svg-import-filter-gfxfilter.diff	(original)
+++ branches/ooo-build-2-4-1/patches/src680/svg-import-filter-gfxfilter.diff	Wed May 28 21:24:46 2008
@@ -1,5 +1,5 @@
 diff -ur filter_orig/source/config/fragments/internalgraphicfilters/svg_Export.xcu filter/source/config/fragments/internalgraphicfilters/svg_Export.xcu
---- filter_orig/source/config/fragments/internalgraphicfilters/svg_Export.xcu	2005-07-20 13:19:27.000000000 +0200
+--- filter_orig/source/config/fragments/internalgraphicfilters/svg_Export.xcu	2008-05-28 02:34:02.000000000 +0200
 +++ filter/source/config/fragments/internalgraphicfilters/svg_Export.xcu	2008-05-28 02:30:15.000000000 +0200
 @@ -8,3 +8,13 @@
  		</prop>
@@ -15,9 +15,8 @@
 +		</prop>
 +		<prop oor:name="Flags"><value>IMPORT</value></prop>
 +	</node>
-Only in filter/source/config/fragments/internalgraphicfilters: svg_Export.xcu~
 diff -ur filter_orig/source/svg/exports.map filter/source/svg/exports.map
---- filter_orig/source/svg/exports.map	2008-05-28 02:27:09.000000000 +0200
+--- filter_orig/source/svg/exports.map	2008-05-28 02:34:02.000000000 +0200
 +++ filter/source/svg/exports.map	2008-05-27 23:32:34.000000000 +0200
 @@ -3,6 +3,7 @@
                  component_getImplementationEnvironment;
@@ -28,7 +27,7 @@
          local:
                  *;
 diff -ur filter_orig/source/svg/makefile.mk filter/source/svg/makefile.mk
---- filter_orig/source/svg/makefile.mk	2008-05-28 02:27:09.000000000 +0200
+--- filter_orig/source/svg/makefile.mk	2008-05-28 02:34:02.000000000 +0200
 +++ filter/source/svg/makefile.mk	2008-05-28 02:16:23.000000000 +0200
 @@ -78,6 +78,7 @@
  	$(UNOTOOLSLIB)		\
@@ -39,7 +38,7 @@
  	$(CPPULIB)			\
  	$(SALLIB)			\
 diff -ur filter_orig/source/svg/svgfilter.cxx filter/source/svg/svgfilter.cxx
---- filter_orig/source/svg/svgfilter.cxx	2008-05-28 02:27:09.000000000 +0200
+--- filter_orig/source/svg/svgfilter.cxx	2008-05-28 02:34:02.000000000 +0200
 +++ filter/source/svg/svgfilter.cxx	2008-05-27 23:32:59.000000000 +0200
 @@ -243,3 +243,11 @@
  {
@@ -54,7 +53,7 @@
 +	return importSvg( rStream, rGraphic );
 +}
 diff -ur filter_orig/source/svg/svgfilter.hxx filter/source/svg/svgfilter.hxx
---- filter_orig/source/svg/svgfilter.hxx	2008-05-28 02:27:09.000000000 +0200
+--- filter_orig/source/svg/svgfilter.hxx	2008-05-28 02:34:02.000000000 +0200
 +++ filter/source/svg/svgfilter.hxx	2008-05-27 23:03:42.000000000 +0200
 @@ -328,4 +328,11 @@
  SAL_CALL SVGFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
@@ -69,8 +68,8 @@
 +
  #endif // SVGFILTER_HXX
 diff -ur filter_orig/source/svg/svgreader.cxx filter/source/svg/svgreader.cxx
---- filter_orig/source/svg/svgreader.cxx	2008-05-28 02:27:09.000000000 +0200
-+++ filter/source/svg/svgreader.cxx	2008-05-28 02:05:51.000000000 +0200
+--- filter_orig/source/svg/svgreader.cxx	2008-05-28 02:34:02.000000000 +0200
++++ filter/source/svg/svgreader.cxx	2008-05-28 22:12:21.000000000 +0200
 @@ -7,6 +7,7 @@
   *      Thorsten Behrens <tbehrens novell com>	   	
   *
@@ -79,13 +78,15 @@
   *
   *   The Contents of this file are made available subject to
   *   the terms of GNU Lesser General Public License Version 2.1.
-@@ -41,6 +42,15 @@
+@@ -41,6 +42,17 @@
  #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
  #include <com/sun/star/xml/dom/NodeType.hpp>
  
 +#include <comphelper/processfactory.hxx>
++#include <basegfx/polygon/b2dpolygoncutandtouch.hxx>
 +#include <basegfx/polygon/b2dpolypolygontools.hxx>
 +#include <unotools/streamwrap.hxx>
++#include <xmloff/xmluconv.hxx>
 +#include <vcl/graph.hxx>
 +#include <vcl/virdev.hxx>
 +#include <vcl/gradient.hxx>
@@ -95,7 +96,7 @@
  #include <boost/bind.hpp>
  #include <hash_set>
  #include <map>
-@@ -432,6 +442,9 @@
+@@ -432,6 +444,9 @@
          // start&end color)
          optimizeGradientStops(rState.maFillGradient);
  
@@ -105,7 +106,25 @@
          // do we have a gradient fill? then write out gradient as well
          if( rState.meFillType == GRADIENT && rState.maFillGradient.maStops.size() > 1 )
          {
-@@ -1896,4 +1909,690 @@
+@@ -1541,10 +1556,13 @@
+             for( sal_uInt32 i=0; i<rPoly.count(); ++i )
+             {                
+                 aPolys.push_back(
+-                    basegfx::tools::createAreaGeometryForPolygon(
+-                        rPoly.getB2DPolygon(i),
+-                        aState.mnStrokeWidth/2.0,
+-                        aState.meLineJoin));
++                    basegfx::tools::removeNeutralPolygons(
++                        basegfx::tools::removeAllIntersections(
++                            basegfx::tools::createAreaGeometryForPolygon(
++                                rPoly.getB2DPolygon(i),
++                                aState.mnStrokeWidth/2.0,
++                                aState.meLineJoin)),
++                            true));
+                 // TODO(F2): line ends
+             }
+ 
+@@ -1896,4 +1914,734 @@
      return sal_True;
  }
  
@@ -390,8 +409,12 @@
 +                    // <- blatant copy from svx/source/xml/xmlgrhlp.cxx
 +                    Graphic aGraphic;
 +
-+                    SvMemoryStream aSrc(const_cast<char*>(sLinkValue.c_str()), 
-+                                        sLinkValue.length(), STREAM_READ);
++                    uno::Sequence<sal_Int8> aData;
++                    SvXMLUnitConverter::decodeBase64(aData, 
++                                                     rtl::OUString::createFromAscii(sLinkValue.c_str()));
++                    SvMemoryStream aSrc(aData.getArray(), 
++                                        aData.getLength(), 
++                                        STREAM_READ);
 +                    USHORT nFormat = GRFILTER_FORMAT_DONTKNOW;
 +                    USHORT pDeterminedFormat = GRFILTER_FORMAT_DONTKNOW;
 +                    GetGrfFilter()->ImportGraphic( aGraphic, String(), aSrc ,nFormat,&pDeterminedFormat );
@@ -446,11 +469,15 @@
 +                    }
 +                    // -> blatant copy from svx/source/xml/xmlgrhlp.cxx
 +
++                    const Rectangle aBounds(
++                        Point(basegfx::fround(x),
++                              basegfx::fround(y)),
++                        Size(basegfx::fround(width),
++                             basegfx::fround(height)));
 +                    aGraphic.Draw(&mrOutDev,
-+                                  Point(basegfx::fround(x),
-+                                        basegfx::fround(y)),
-+                                  Size(basegfx::fround(width),
-+                                       basegfx::fround(height)));
++                                  aBounds.TopLeft(),
++                                  aBounds.GetSize());
++                    maBounds.Union(aBounds);
 +                }
 +                break;
 +            }
@@ -518,6 +545,7 @@
 +                        aFont.SetOrientation(basegfx::fround(fRotate*1800.0/M_PI));
 +                }
 +
++                // TODO(F2): update bounds
 +                mrOutDev.SetFont(aFont);
 +                mrOutDev.DrawText(Point(basegfx::fround(x),
 +                                        basegfx::fround(y)),
@@ -566,9 +594,11 @@
 +    {
 +        // we might need to split up polypolygon into multiple path
 +        // shapes (e.g. when emulating line stroking)
-+        std::vector<basegfx::B2DPolyPolygon> aPolys(1,rPoly);
 +        State aState = maCurrState;
 +		
++        basegfx::B2DPolyPolygon aPoly(rPoly);
++        aPoly.transform(aState.maCTM);
++
 +        OSL_TRACE("the CTM is now #2: %f %f %f %f %f %f", 
 +                  maCurrState.maCTM.get(0,0),
 +                  maCurrState.maCTM.get(0,1),
@@ -577,35 +607,16 @@
 +                  maCurrState.maCTM.get(1,1),
 +                  maCurrState.maCTM.get(1,2));        
 +
-+		if( aState.maDashArray.size() ||
-+            aState.mnStrokeWidth != 1.0 )
-+        {
-+            // vcl thick lines are severly borked - generate filled polygon instead
-+            aPolys.clear();
-+            for( sal_uInt32 i=0; i<rPoly.count(); ++i )
-+            {                
-+                aPolys.push_back(
-+                    basegfx::tools::createAreaGeometryForPolygon(
-+                        rPoly.getB2DPolygon(i),
-+                        aState.mnStrokeWidth/2.0,
-+                        aState.meLineJoin));
-+                // TODO(F2): line ends
-+            }
-+
-+            State aEmulatedStrokeState( aState );
-+            aEmulatedStrokeState.meFillType = aState.meStrokeType;
-+            aEmulatedStrokeState.mnFillOpacity = aState.mnStrokeOpacity;
-+            aEmulatedStrokeState.maFillColor = aState.maStrokeColor;
-+            aEmulatedStrokeState.maFillGradient = aState.maStrokeGradient;
-+            aEmulatedStrokeState.meFillRule = EVEN_ODD;
-+            aEmulatedStrokeState.meStrokeType = NONE;
-+
-+            aState = aEmulatedStrokeState;
-+        }
++        const basegfx::B2DRange aBounds=basegfx::tools::getRange(aPoly);
++        maBounds.Union(
++            Rectangle(
++                basegfx::fround(aBounds.getMinX()),
++                basegfx::fround(aBounds.getMinY()),
++                basegfx::fround(aBounds.getMaxX()),
++                basegfx::fround(aBounds.getMaxY())));
 +
-+        std::for_each(aPolys.begin(),aPolys.end(),
-+                      boost::bind(&basegfx::B2DPolyPolygon::transform,
-+                                  _1,boost::cref(aState.maCTM)));
++        // fill first
++        mrOutDev.SetLineColor();
 +
 +        // do we have a gradient fill?
 +        if( aState.meFillType == GRADIENT && aState.maFillGradient.maStops.size() > 1 )
@@ -641,28 +652,28 @@
 +            {
 +                ::Gradient aTransparencyGradient=aGradient;
 +
-+                // modulate gradient opacity with overall fill opacity
-+                aTransparencyGradient.SetEndColor(
-+                    basegfx::fround(mrGradientStopVector[
-+                                        aState.maFillGradient.maStops[0]].maStopColor.a*
-+                                    aState.mnFillOpacity*100.0));
-+                aTransparencyGradient.SetStartColor(
++                const BYTE	cTransStart( 255-
 +                    basegfx::fround(mrGradientStopVector[
 +                                        aState.maFillGradient.maStops[1]].maStopColor.a*
-+                                    aState.mnFillOpacity*100.0));
++                                    aState.mnFillOpacity*255.0));
++                const Color aTransStart( cTransStart, cTransStart, cTransStart );
++
++                const BYTE	cTransEnd( 255-
++                    basegfx::fround(mrGradientStopVector[
++                                        aState.maFillGradient.maStops[0]].maStopColor.a*
++                                    aState.mnFillOpacity*255.0));
++                const Color aTransEnd( cTransEnd, cTransEnd, cTransEnd );
++
++                // modulate gradient opacity with overall fill opacity
++                aTransparencyGradient.SetStartColor(aTransStart);
++                aTransparencyGradient.SetEndColor(aTransEnd);
 +
 +                VirtualDevice	aVDev;
 +                GDIMetaFile		aMtf;
 +
 +                aVDev.EnableOutput( FALSE );
 +                aMtf.Record( &aVDev );
-+                basegfx::B2DRange aBounds;
-+                // TODO(P3): limit bounds to actual polygon bbox
-+                for( sal_uInt32 i=0; i<aPolys.size(); ++i )
-+                {
-+                    aBounds.expand(basegfx::tools::getRange(aPolys[i]));
-+                    aVDev.DrawGradient(::PolyPolygon(aPolys[i]),aGradient);
-+                }
++                aVDev.DrawGradient(::PolyPolygon(aPoly),aGradient);
 +
 +                aMtf.Stop();
 +                aMtf.WindStart();
@@ -677,8 +688,7 @@
 +            }
 +            else
 +            {
-+                for( sal_uInt32 i=0; i<aPolys.size(); ++i )
-+                    mrOutDev.DrawGradient(::PolyPolygon(aPolys[i]),aGradient);
++                mrOutDev.DrawGradient(::PolyPolygon(aPoly),aGradient);
 +            }
 +        }
 +        else
@@ -688,18 +698,79 @@
 +            else
 +                mrOutDev.SetFillColor(getVclColor(aState.maFillColor));
 +
-+            if( aState.meStrokeType == NONE )
-+                mrOutDev.SetLineColor();
++            if( aState.mnFillOpacity != 1.0 )
++                mrOutDev.DrawTransparent(::PolyPolygon(aPoly),
++                                         basegfx::fround(
++                                             (1.0-aState.mnFillOpacity)*100.0));
 +            else
-+                mrOutDev.SetLineColor(getVclColor(aState.maStrokeColor));
++                mrOutDev.DrawPolyPolygon(::PolyPolygon(aPoly));
++        }
++
++        // Stroking now
++        mrOutDev.SetFillColor();
++
++        if( aState.meStrokeType != NONE &&
++            (aState.maDashArray.size() ||
++             aState.mnStrokeWidth != 1.0) )
++        {
++            // vcl thick lines are severly borked - generate filled
++            // polygon instead
++            std::vector<basegfx::B2DPolyPolygon> aPolys;
++            aPoly=basegfx::tools::adaptiveSubdivideByAngle(aPoly);
++            if( !aState.maDashArray.empty() )
++                aPoly=basegfx::tools::applyLineDashing(aPoly,
++                                                       aState.maDashArray);
++            for( sal_uInt32 i=0; i<aPoly.count(); ++i )
++            {                
++                // ugly. convert to integer-based tools polygon
++                // first, and only _then_ remove intersections (we
++                // might get new ones from the rounding)
++                aPolys.push_back(
++                    basegfx::tools::removeNeutralPolygons(
++                        basegfx::tools::removeAllIntersections(
++                            ::PolyPolygon(
++                                basegfx::tools::createAreaGeometryForPolygon(
++                                    aPoly.getB2DPolygon(i),
++                                    aState.mnStrokeWidth/2.0,
++                                    aState.meLineJoin)).getB2DPolyPolygon()),
++                        true));
++                // TODO(F2): line ends
++            }
++
++            mrOutDev.SetLineColor();
++            mrOutDev.SetFillColor(getVclColor(aState.maStrokeColor));
 +
 +            for( sal_uInt32 i=0; i<aPolys.size(); ++i )
-+                if( maCurrState.mnFillOpacity != 1.0 )
++            {
++                if( aState.mnStrokeOpacity != 1.0 )
 +                    mrOutDev.DrawTransparent(::PolyPolygon(aPolys[i]),
 +                                             basegfx::fround(
-+                                                 maCurrState.mnFillOpacity*100.0));
++                                                 (1.0-aState.mnStrokeOpacity)*100.0));
 +                else
 +                    mrOutDev.DrawPolyPolygon(::PolyPolygon(aPolys[i]));
++
++                const basegfx::B2DRange aStrokeBounds=basegfx::tools::getRange(aPolys[i]);
++                maBounds.Union(
++                    Rectangle(
++                        basegfx::fround(aStrokeBounds.getMinX()),
++                        basegfx::fround(aStrokeBounds.getMinY()),
++                        basegfx::fround(aStrokeBounds.getMaxX()),
++                        basegfx::fround(aStrokeBounds.getMaxY())));
++            }
++        }
++        else
++        {
++            if( aState.meStrokeType == NONE )
++                mrOutDev.SetLineColor();
++            else
++                mrOutDev.SetLineColor(getVclColor(aState.maStrokeColor));
++
++            if( aState.mnStrokeOpacity != 1.0 )
++                mrOutDev.DrawTransparent(::PolyPolygon(aPoly),
++                                         basegfx::fround(
++                                             (1.0-aState.mnStrokeOpacity)*100.0));
++            else
++                mrOutDev.DrawPolyPolygon(::PolyPolygon(aPoly));
 +        }
 +    }
 +
@@ -710,20 +781,9 @@
 +    OutputDevice&                               mrOutDev;
 +    const std::vector< Gradient >&             mrGradientVector;
 +    const std::vector< GradientStop >&         mrGradientStopVector;
++    Rectangle                                   maBounds;
 +};
 +
-+/// Write out shapes from DOM tree
-+static void renderShapes( StatePool&                                        rStatePool,
-+                          StateMap&                                         rStateMap,
-+                          const uno::Reference<xml::dom::XElement>          xElem,
-+                          OutputDevice&                                     rOutDev,
-+                          const std::vector< Gradient >&                    rGradientVector,
-+                          const std::vector< GradientStop >&                rGradientStopVector)
-+{
-+    ShapeRenderingVisitor aVisitor(rStatePool,rStateMap,rOutDev,rGradientVector,rGradientStopVector);
-+    visitElements(aVisitor, xElem);
-+}
-+
  } // namespace svgi
 +
 +bool importSvg(SvStream & rStream, Graphic & rGraphic )
@@ -765,12 +825,10 @@
 +#endif
 +
 +    // render all shapes to mtf
-+    svgi::renderShapes(aStatePool,
-+                       aStateMap,
-+                       xDocElem,
-+                       aVDev,
-+                       aVisitor.maGradientVector,
-+                       aVisitor.maGradientStopVector);
++    svgi::ShapeRenderingVisitor aRenderer(aStatePool,aStateMap,aVDev,
++                                         aVisitor.maGradientVector,
++                                         aVisitor.maGradientStopVector);
++    svgi::visitElements(aRenderer, xDocElem);
 +
 +    aMtf.Stop();
 +
@@ -786,9 +844,14 @@
 +	if (!xDocElem->hasAttribute(USTR("height")))
 +		xDocElem->setAttribute(USTR("height"), USTR("297mm"));
 +		
-+    aMtf.SetPrefSize( Size( basegfx::fround(svgi::convLength(xDocElem->getAttribute(USTR("width")))), 
-+                            basegfx::fround(svgi::convLength(xDocElem->getAttribute(USTR("height")))) ));
-+
++    aMtf.SetPrefSize( 
++        Size( 
++            std::max(
++                sal_Int32(aRenderer.maBounds.Right()),
++                basegfx::fround(svgi::convLength(xDocElem->getAttribute(USTR("width"))))), 
++            std::max(
++                sal_Int32(aRenderer.maBounds.Bottom()),
++                basegfx::fround(svgi::convLength(xDocElem->getAttribute(USTR("height"))))) ));
 +
 +    rGraphic = aMtf;
 +    
@@ -797,7 +860,7 @@
 +
 +
 diff -ur filter_orig/source/svg/test/makefile.mk filter/source/svg/test/makefile.mk
---- filter_orig/source/svg/test/makefile.mk	2008-05-28 02:27:09.000000000 +0200
+--- filter_orig/source/svg/test/makefile.mk	2008-05-28 02:34:02.000000000 +0200
 +++ filter/source/svg/test/makefile.mk	2008-05-28 02:18:07.000000000 +0200
 @@ -40,6 +40,7 @@
  	$(UNOTOOLSLIB)		\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]