diff options
author | Thorsten Behrens <tbehrens@suse.com> | 2012-06-05 05:03:06 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2012-06-05 05:11:42 +0200 |
commit | 3fb24e6307e0ec3e09b1e48e9a4ce5f6787d2cc9 (patch) | |
tree | 54bc1974bf6a255948793302bd3ae53c21a50ca5 | |
parent | d3c189fa742f0b21f99a8f3b1ebafe71c130d8d5 (diff) |
Fix fdo#50704 Default to absolute svg:d paths for ODF1.2 compat-mode
This writes out absolute paths, to side-step buggy odf consumers'
wrong handling of the 'z' statement (i.e. they ignore it for current
positions).
-rw-r--r-- | xmloff/inc/xexptran.hxx | 9 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport2.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport3.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/draw/xexptran.cxx | 36 | ||||
-rw-r--r-- | xmloff/source/style/MarkerStyle.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 2 |
6 files changed, 34 insertions, 23 deletions
diff --git a/xmloff/inc/xexptran.hxx b/xmloff/inc/xexptran.hxx index 86883cfc7e4e..b38860a6a466 100644 --- a/xmloff/inc/xexptran.hxx +++ b/xmloff/inc/xexptran.hxx @@ -36,7 +36,6 @@ #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/drawing/HomogenMatrix.hpp> #include <tools/mapunit.hxx> -#include <xmloff/xmlimp.hxx> #include <vector> @@ -46,6 +45,8 @@ struct ImpSdXMLExpTransObj2DBase; struct ImpSdXMLExpTransObj3DBase; class SvXMLUnitConverter; +class SvXMLImport; +class SvXMLExport; namespace basegfx { @@ -160,14 +161,14 @@ class SdXMLImExSvgDElement const SdXMLImExViewBox& mrViewBox; bool mbIsClosed; bool mbIsCurve; - + bool mbRelative; sal_Int32 mnLastX; sal_Int32 mnLastY; com::sun::star::drawing::PolyPolygonBezierCoords maPoly; public: - SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox); + SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox, const SvXMLExport& rExport); SdXMLImExSvgDElement(const rtl::OUString& rNew, const SdXMLImExViewBox& rViewBox, const com::sun::star::awt::Point& rObjectPos, @@ -179,7 +180,7 @@ public: com::sun::star::drawing::FlagSequence* pFlags, const com::sun::star::awt::Point& rObjectPos, const com::sun::star::awt::Size& rObjectSize, - bool bClosed = false, bool bRelative = true); + bool bClosed = false); const rtl::OUString& GetExportString() const { return msString; } bool IsClosed() const { return mbIsClosed; } diff --git a/xmloff/source/draw/shapeexport2.cxx b/xmloff/source/draw/shapeexport2.cxx index 43d9711458f0..00856c83572a 100644 --- a/xmloff/source/draw/shapeexport2.cxx +++ b/xmloff/source/draw/shapeexport2.cxx @@ -999,7 +999,7 @@ void XMLShapeExport::ImpExportPolygonShape( if(pOuterSequence && pOuterFlags) { // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); + SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport()); for(sal_Int32 a(0L); a < nOuterCnt; a++) { @@ -1066,7 +1066,7 @@ void XMLShapeExport::ImpExportPolygonShape( if(pOuterSequence) { // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); + SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport()); for(sal_Int32 a(0L); a < nOuterCnt; a++) { @@ -1432,7 +1432,7 @@ void XMLShapeExport::ImpExportConnectorShape( awt::Point aPoint( 0, 0 ); awt::Size aSize( 1, 1 ); SdXMLImExViewBox aViewBox( 0, 0, 1, 1 ); - SdXMLImExSvgDElement aSvgDElement(aViewBox); + SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport()); for(sal_Int32 a(0L); a < nOuterCnt; a++) { diff --git a/xmloff/source/draw/shapeexport3.cxx b/xmloff/source/draw/shapeexport3.cxx index 7e111d60a210..888f4b603c3c 100644 --- a/xmloff/source/draw/shapeexport3.cxx +++ b/xmloff/source/draw/shapeexport3.cxx @@ -263,7 +263,7 @@ void XMLShapeExport::ImpExport3DShape( aViewBox.GetExportString()); // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); + SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport()); pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray(); pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx index 050409667707..545e0a42ae87 100644 --- a/xmloff/source/draw/xexptran.cxx +++ b/xmloff/source/draw/xexptran.cxx @@ -31,6 +31,8 @@ #include <rtl/ustrbuf.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmluconv.hxx> +#include <xmloff/xmlexp.hxx> +#include <xmloff/xmlimp.hxx> #include <tools/gen.hxx> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> @@ -1469,10 +1471,17 @@ SdXMLImExPointsElement::SdXMLImExPointsElement(const OUString& rNew, ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -SdXMLImExSvgDElement::SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox) +SdXMLImExSvgDElement::SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox, + const SvXMLExport& rExport) : mrViewBox( rViewBox ), mbIsClosed( false ), mbIsCurve( false ), + // fdo#47406 - handle writing svg:d path slightly different for + // old odf versions and ODF1.2 compat mode - since ~all the legacy + // ODF ecosystem interprets relative svg:d paths incorrectly, + // write out absolute paths in those cases. + mbRelative( rExport.getDefaultVersion() >= SvtSaveOptions::ODFVER_012 && + rExport.getDefaultVersion() != SvtSaveOptions::ODFVER_012_EXT_COMPAT ), mnLastX( 0L ), mnLastY( 0L ), maPoly() @@ -1535,7 +1544,7 @@ void SdXMLImExSvgDElement::AddPolygon( drawing::FlagSequence* pFlags, const awt::Point& rObjectPos, const awt::Size& rObjectSize, - bool bClosed, bool bRelative) + bool bClosed) { // Leaving the export stuff for the while, should eventually also // consolidated with basegfx svg support @@ -1722,7 +1731,7 @@ void SdXMLImExSvgDElement::AddPolygon( if(bPrevPointIsSymmetric) { // write a shorthand/smooth quadratic curveto entry (T) - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('t')) aNewString += OUString(sal_Unicode('t')); @@ -1752,7 +1761,7 @@ void SdXMLImExSvgDElement::AddPolygon( mrViewBox, bScale, bTranslate); // write a quadratic curveto entry (Q) - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('q')) aNewString += OUString(sal_Unicode('q')); @@ -1814,7 +1823,7 @@ void SdXMLImExSvgDElement::AddPolygon( if(bPrevPointIsSmooth) { // write a shorthand/smooth quadratic curveto entry (T) - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('t')) aNewString += rtl::OUString(static_cast<sal_Unicode>('t')); @@ -1844,7 +1853,7 @@ void SdXMLImExSvgDElement::AddPolygon( mrViewBox, bScale, bTranslate); // write a quadratic curveto entry (Q) - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('q')) aNewString += rtl::OUString(static_cast<sal_Unicode>('q')); @@ -1903,7 +1912,7 @@ void SdXMLImExSvgDElement::AddPolygon( if(bPrevPointIsSymmetric) { // write a shorthand/smooth curveto entry (S) - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('s')) aNewString += rtl::OUString(static_cast<sal_Unicode>('s')); @@ -1937,7 +1946,7 @@ void SdXMLImExSvgDElement::AddPolygon( mrViewBox, bScale, bTranslate); // write a curveto entry (C) - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('c')) aNewString += rtl::OUString(static_cast<sal_Unicode>('c')); @@ -1993,7 +2002,7 @@ void SdXMLImExSvgDElement::AddPolygon( // write as normal point if(mnLastX == nX) { - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('v')) aNewString += rtl::OUString(static_cast<sal_Unicode>('v')); @@ -2014,7 +2023,7 @@ void SdXMLImExSvgDElement::AddPolygon( } else if(mnLastY == nY) { - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('h')) aNewString += rtl::OUString(static_cast<sal_Unicode>('h')); @@ -2035,7 +2044,7 @@ void SdXMLImExSvgDElement::AddPolygon( } else { - if(bRelative) + if(mbRelative) { if(aLastCommand != sal_Unicode('l')) aNewString += rtl::OUString(static_cast<sal_Unicode>('l')); @@ -2060,7 +2069,7 @@ void SdXMLImExSvgDElement::AddPolygon( else { // write as start point - if(bRelative) + if(mbRelative) { aNewString += rtl::OUString(static_cast<sal_Unicode>('m')); @@ -2099,7 +2108,7 @@ void SdXMLImExSvgDElement::AddPolygon( // close path if closed poly if(bClosed) { - if(bRelative) + if(mbRelative) aNewString += rtl::OUString(static_cast<sal_Unicode>('z')); else aNewString += rtl::OUString(static_cast<sal_Unicode>('Z')); @@ -2126,6 +2135,7 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, mrViewBox( rViewBox ), mbIsClosed( false ), mbIsCurve( false ), + mbRelative( true ), mnLastX( 0L ), mnLastY( 0L ), maPoly() diff --git a/xmloff/source/style/MarkerStyle.cxx b/xmloff/source/style/MarkerStyle.cxx index 4e51a57f02d0..5c0c0ec0b368 100644 --- a/xmloff/source/style/MarkerStyle.cxx +++ b/xmloff/source/style/MarkerStyle.cxx @@ -253,7 +253,7 @@ sal_Bool XMLMarkerStyleExport::exportXML( // Pathdata pOuterSequence = aBezier.Coordinates.getArray(); drawing::FlagSequence* pOuterFlags = aBezier.Flags.getArray(); - SdXMLImExSvgDElement aSvgDElement(aViewBox); + SdXMLImExSvgDElement aSvgDElement(aViewBox, rExport); for (a = 0; a < nOuterCnt; a++) { diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 99f3230ef720..e7b370b561bb 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3019,7 +3019,7 @@ void XMLTextParagraphExport::exportContour( if(pOuterSequence) { // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement( aViewBox ); + SdXMLImExSvgDElement aSvgDElement( aViewBox, GetExport() ); for(sal_Int32 a(0L); a < nOuterCnt; a++) { |