summaryrefslogtreecommitdiff
path: root/filter/source/svg/svgwriter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/svg/svgwriter.cxx')
-rw-r--r--filter/source/svg/svgwriter.cxx179
1 files changed, 132 insertions, 47 deletions
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 2e7316b8ebcc..cf1602fdbc0b 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -1,31 +1,21 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
+/*
+ * This file is part of the LibreOffice project.
*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
- * Copyright 2008 by Sun Microsystems, Inc.
+ * This file incorporates work covered by the following license notice:
*
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
#include "svgfilter.hxx"
#include "svgfontexport.hxx"
@@ -97,6 +87,8 @@ static const char aXMLAttrGradientUnits[] = "gradientUnits";
static const char aXMLAttrPatternUnits[] = "patternUnits";
static const char aXMLAttrOffset[] = "offset";
static const char aXMLAttrStopColor[] = "stop-color";
+static const char aXMLAttrStrokeLinejoin[] = "stroke-linejoin";
+static const char aXMLAttrStrokeLinecap[] = "stroke-linecap";
#define NSPREFIX "ooo:"
@@ -2033,6 +2025,7 @@ PolyPolygon& SVGActionWriter::ImplMap( const PolyPolygon& rPolyPoly, PolyPolygon
aPathData += ::rtl::OUString::valueOf( aPolyPoint.Y() );
sal_Char nCurrentMode = 0;
+ const bool bClose(!bLine || rPoly[0] == rPoly[nSize - 1]);
while( n < nSize )
{
aPathData += aBlank;
@@ -2066,7 +2059,7 @@ PolyPolygon& SVGActionWriter::ImplMap( const PolyPolygon& rPolyPoly, PolyPolygon
}
}
- if( !bLine )
+ if(bClose)
aPathData += B2UCONST( " Z" );
if( i < ( nCount - 1 ) )
@@ -2218,6 +2211,51 @@ void SVGActionWriter::ImplWriteShape( const SVGShapeDescriptor& rShape, sal_Bool
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeWidth, ::rtl::OUString::valueOf( nStrokeWidth ) );
}
+ // support for LineJoin
+ switch(rShape.maLineJoin)
+ {
+ default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE
+ case basegfx::B2DLINEJOIN_MITER:
+ {
+ // miter is Svg default, so no need to write until the exporter might write styles.
+ // If this happens, activate here
+ // mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, ::rtl::OUString::createFromAscii("miter"));
+ break;
+ }
+ case basegfx::B2DLINEJOIN_BEVEL:
+ {
+ mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, ::rtl::OUString::createFromAscii("bevel"));
+ break;
+ }
+ case basegfx::B2DLINEJOIN_ROUND:
+ {
+ mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, ::rtl::OUString::createFromAscii("round"));
+ break;
+ }
+ }
+
+ // support for LineCap
+ switch(rShape.maLineCap)
+ {
+ default: /* com::sun::star::drawing::LineCap_BUTT */
+ {
+ // butt is Svg default, so no need to write until the exporter might write styles.
+ // If this happens, activate here
+ // mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, ::rtl::OUString::createFromAscii("butt"));
+ break;
+ }
+ case com::sun::star::drawing::LineCap_ROUND:
+ {
+ mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, ::rtl::OUString::createFromAscii("round"));
+ break;
+ }
+ case com::sun::star::drawing::LineCap_SQUARE:
+ {
+ mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, ::rtl::OUString::createFromAscii("square"));
+ break;
+ }
+ }
+
if( rShape.maDashArray.size() )
{
const ::rtl::OUString aComma( B2UCONST( "," ) );
@@ -2787,7 +2825,10 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText,
}
if( bCont )
+ {
+ // #118796# do NOT access pDXArray, it may be zero (!)
nX = aPos.X() + pDX[ nCurPos - 1 ];
+ }
}
}
}
@@ -2901,6 +2942,10 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
const Reference< XShape >* pxShape,
const GDIMetaFile* pTextEmbeddedBitmapMtf )
{
+ // need a counter fo rthe actions written per shape to avoid double ID
+ // generation
+ sal_Int32 nEntryCount(0);
+
if( mnInnerMtfCount )
nWriteFlags |= SVGWRITER_NO_SHAPE_COMMENTS;
@@ -3279,7 +3324,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
mapCurShape.reset( new SVGShapeDescriptor );
if( pElementId )
- mapCurShape->maId = *pElementId;
+ {
+ mapCurShape->maId = *pElementId + B2UCONST("_") + ::rtl::OUString::valueOf(nEntryCount++);
+ }
mapCurShape->maShapePolyPoly = aShapePolyPoly;
mapCurShape->maShapeFillColor = aFill.getFillColor();
@@ -3345,14 +3392,30 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
if( bSkip )
{
- if( !mapCurShape.get() )
+ Polygon aPoly;
+
+ aStroke.getPath(aPoly);
+
+ if(mapCurShape.get())
{
- Polygon aPoly;
+ if(1 != mapCurShape->maShapePolyPoly.Count()
+ || !mapCurShape->maShapePolyPoly[0].IsEqual(aPoly))
+ {
+ // this path action is not covering the same path than the already existing
+ // fill polypolygon, so write out the fill polygon
+ ImplWriteShape( *mapCurShape );
+ mapCurShape.reset();
+ }
+ }
+ if( !mapCurShape.get() )
+ {
mapCurShape.reset( new SVGShapeDescriptor );
if( pElementId )
- mapCurShape->maId = *pElementId;
+ {
+ mapCurShape->maId = *pElementId + B2UCONST("_") + ::rtl::OUString::valueOf(nEntryCount++);
+ }
aStroke.getPath( aPoly );
mapCurShape->maShapePolyPoly = aPoly;
@@ -3364,6 +3427,46 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
aStroke.getDashArray( mapCurShape->maDashArray );
}
+ // support for LineJoin
+ switch(aStroke.getJoinType())
+ {
+ default: /* SvtGraphicStroke::joinMiter, SvtGraphicStroke::joinNone */
+ {
+ mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_MITER;
+ break;
+ }
+ case SvtGraphicStroke::joinRound:
+ {
+ mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_ROUND;
+ break;
+ }
+ case SvtGraphicStroke::joinBevel:
+ {
+ mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_BEVEL;
+ break;
+ }
+ }
+
+ // support for LineCap
+ switch(aStroke.getCapType())
+ {
+ default: /* SvtGraphicStroke::capButt */
+ {
+ mapCurShape->maLineCap = com::sun::star::drawing::LineCap_BUTT;
+ break;
+ }
+ case SvtGraphicStroke::capRound:
+ {
+ mapCurShape->maLineCap = com::sun::star::drawing::LineCap_ROUND;
+ break;
+ }
+ case SvtGraphicStroke::capSquare:
+ {
+ mapCurShape->maLineCap = com::sun::star::drawing::LineCap_SQUARE;
+ break;
+ }
+ }
+
// write open shape in every case
if( mapCurShape.get() )
{
@@ -3682,24 +3785,6 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
}
break;
- case( META_RENDERGRAPHIC_ACTION ):
- {
- if( nWriteFlags & SVGWRITER_WRITE_FILL )
- {
- // TODO KA: try to embed the native data in case the RenderGraphic
- // contains valid SVG data (MimeType "image/svg+xml")
- // => incorporate 'use' or 'image' element (KA 01/2011)
- const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pAction;
- const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() );
- const Point aPointPixel;
- const Size aSizePixel( mpVDev->LogicToPixel( pA->GetSize() ) );
- const BitmapEx aBmpEx( aRasterizer.Rasterize( aSizePixel ) );
-
- ImplWriteBmp( aBmpEx, pA->GetPoint(), pA->GetSize(), aPointPixel, aBmpEx.GetSizePixel() );
- }
- }
- break;
-
case( META_CLIPREGION_ACTION ):
case( META_ISECTRECTCLIPREGION_ACTION ):
case( META_ISECTREGIONCLIPREGION_ACTION ):