Kaydet (Commit) 3fb24e63 authored tarafından Thorsten Behrens's avatar Thorsten Behrens

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).
üst d3c189fa
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/drawing/HomogenMatrix.hpp> #include <com/sun/star/drawing/HomogenMatrix.hpp>
#include <tools/mapunit.hxx> #include <tools/mapunit.hxx>
#include <xmloff/xmlimp.hxx>
#include <vector> #include <vector>
...@@ -46,6 +45,8 @@ ...@@ -46,6 +45,8 @@
struct ImpSdXMLExpTransObj2DBase; struct ImpSdXMLExpTransObj2DBase;
struct ImpSdXMLExpTransObj3DBase; struct ImpSdXMLExpTransObj3DBase;
class SvXMLUnitConverter; class SvXMLUnitConverter;
class SvXMLImport;
class SvXMLExport;
namespace basegfx namespace basegfx
{ {
...@@ -160,14 +161,14 @@ class SdXMLImExSvgDElement ...@@ -160,14 +161,14 @@ class SdXMLImExSvgDElement
const SdXMLImExViewBox& mrViewBox; const SdXMLImExViewBox& mrViewBox;
bool mbIsClosed; bool mbIsClosed;
bool mbIsCurve; bool mbIsCurve;
bool mbRelative;
sal_Int32 mnLastX; sal_Int32 mnLastX;
sal_Int32 mnLastY; sal_Int32 mnLastY;
com::sun::star::drawing::PolyPolygonBezierCoords maPoly; com::sun::star::drawing::PolyPolygonBezierCoords maPoly;
public: public:
SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox); SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox, const SvXMLExport& rExport);
SdXMLImExSvgDElement(const rtl::OUString& rNew, SdXMLImExSvgDElement(const rtl::OUString& rNew,
const SdXMLImExViewBox& rViewBox, const SdXMLImExViewBox& rViewBox,
const com::sun::star::awt::Point& rObjectPos, const com::sun::star::awt::Point& rObjectPos,
...@@ -179,7 +180,7 @@ public: ...@@ -179,7 +180,7 @@ public:
com::sun::star::drawing::FlagSequence* pFlags, com::sun::star::drawing::FlagSequence* pFlags,
const com::sun::star::awt::Point& rObjectPos, const com::sun::star::awt::Point& rObjectPos,
const com::sun::star::awt::Size& rObjectSize, const com::sun::star::awt::Size& rObjectSize,
bool bClosed = false, bool bRelative = true); bool bClosed = false);
const rtl::OUString& GetExportString() const { return msString; } const rtl::OUString& GetExportString() const { return msString; }
bool IsClosed() const { return mbIsClosed; } bool IsClosed() const { return mbIsClosed; }
......
...@@ -999,7 +999,7 @@ void XMLShapeExport::ImpExportPolygonShape( ...@@ -999,7 +999,7 @@ void XMLShapeExport::ImpExportPolygonShape(
if(pOuterSequence && pOuterFlags) if(pOuterSequence && pOuterFlags)
{ {
// prepare svx:d element export // prepare svx:d element export
SdXMLImExSvgDElement aSvgDElement(aViewBox); SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport());
for(sal_Int32 a(0L); a < nOuterCnt; a++) for(sal_Int32 a(0L); a < nOuterCnt; a++)
{ {
...@@ -1066,7 +1066,7 @@ void XMLShapeExport::ImpExportPolygonShape( ...@@ -1066,7 +1066,7 @@ void XMLShapeExport::ImpExportPolygonShape(
if(pOuterSequence) if(pOuterSequence)
{ {
// prepare svx:d element export // prepare svx:d element export
SdXMLImExSvgDElement aSvgDElement(aViewBox); SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport());
for(sal_Int32 a(0L); a < nOuterCnt; a++) for(sal_Int32 a(0L); a < nOuterCnt; a++)
{ {
...@@ -1432,7 +1432,7 @@ void XMLShapeExport::ImpExportConnectorShape( ...@@ -1432,7 +1432,7 @@ void XMLShapeExport::ImpExportConnectorShape(
awt::Point aPoint( 0, 0 ); awt::Point aPoint( 0, 0 );
awt::Size aSize( 1, 1 ); awt::Size aSize( 1, 1 );
SdXMLImExViewBox aViewBox( 0, 0, 1, 1 ); SdXMLImExViewBox aViewBox( 0, 0, 1, 1 );
SdXMLImExSvgDElement aSvgDElement(aViewBox); SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport());
for(sal_Int32 a(0L); a < nOuterCnt; a++) for(sal_Int32 a(0L); a < nOuterCnt; a++)
{ {
......
...@@ -263,7 +263,7 @@ void XMLShapeExport::ImpExport3DShape( ...@@ -263,7 +263,7 @@ void XMLShapeExport::ImpExport3DShape(
aViewBox.GetExportString()); aViewBox.GetExportString());
// prepare svx:d element export // prepare svx:d element export
SdXMLImExSvgDElement aSvgDElement(aViewBox); SdXMLImExSvgDElement aSvgDElement(aViewBox, GetExport());
pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray(); pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray();
pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray();
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <sax/tools/converter.hxx> #include <sax/tools/converter.hxx>
#include <xmloff/xmluconv.hxx> #include <xmloff/xmluconv.hxx>
#include <xmloff/xmlexp.hxx>
#include <xmloff/xmlimp.hxx>
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <basegfx/vector/b2dvector.hxx> #include <basegfx/vector/b2dvector.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrix.hxx>
...@@ -1469,10 +1471,17 @@ SdXMLImExPointsElement::SdXMLImExPointsElement(const OUString& rNew, ...@@ -1469,10 +1471,17 @@ SdXMLImExPointsElement::SdXMLImExPointsElement(const OUString& rNew,
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
SdXMLImExSvgDElement::SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox) SdXMLImExSvgDElement::SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox,
const SvXMLExport& rExport)
: mrViewBox( rViewBox ), : mrViewBox( rViewBox ),
mbIsClosed( false ), mbIsClosed( false ),
mbIsCurve( 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 ), mnLastX( 0L ),
mnLastY( 0L ), mnLastY( 0L ),
maPoly() maPoly()
...@@ -1535,7 +1544,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1535,7 +1544,7 @@ void SdXMLImExSvgDElement::AddPolygon(
drawing::FlagSequence* pFlags, drawing::FlagSequence* pFlags,
const awt::Point& rObjectPos, const awt::Point& rObjectPos,
const awt::Size& rObjectSize, const awt::Size& rObjectSize,
bool bClosed, bool bRelative) bool bClosed)
{ {
// Leaving the export stuff for the while, should eventually also // Leaving the export stuff for the while, should eventually also
// consolidated with basegfx svg support // consolidated with basegfx svg support
...@@ -1722,7 +1731,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1722,7 +1731,7 @@ void SdXMLImExSvgDElement::AddPolygon(
if(bPrevPointIsSymmetric) if(bPrevPointIsSymmetric)
{ {
// write a shorthand/smooth quadratic curveto entry (T) // write a shorthand/smooth quadratic curveto entry (T)
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('t')) if(aLastCommand != sal_Unicode('t'))
aNewString += OUString(sal_Unicode('t')); aNewString += OUString(sal_Unicode('t'));
...@@ -1752,7 +1761,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1752,7 +1761,7 @@ void SdXMLImExSvgDElement::AddPolygon(
mrViewBox, bScale, bTranslate); mrViewBox, bScale, bTranslate);
// write a quadratic curveto entry (Q) // write a quadratic curveto entry (Q)
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('q')) if(aLastCommand != sal_Unicode('q'))
aNewString += OUString(sal_Unicode('q')); aNewString += OUString(sal_Unicode('q'));
...@@ -1814,7 +1823,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1814,7 +1823,7 @@ void SdXMLImExSvgDElement::AddPolygon(
if(bPrevPointIsSmooth) if(bPrevPointIsSmooth)
{ {
// write a shorthand/smooth quadratic curveto entry (T) // write a shorthand/smooth quadratic curveto entry (T)
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('t')) if(aLastCommand != sal_Unicode('t'))
aNewString += rtl::OUString(static_cast<sal_Unicode>('t')); aNewString += rtl::OUString(static_cast<sal_Unicode>('t'));
...@@ -1844,7 +1853,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1844,7 +1853,7 @@ void SdXMLImExSvgDElement::AddPolygon(
mrViewBox, bScale, bTranslate); mrViewBox, bScale, bTranslate);
// write a quadratic curveto entry (Q) // write a quadratic curveto entry (Q)
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('q')) if(aLastCommand != sal_Unicode('q'))
aNewString += rtl::OUString(static_cast<sal_Unicode>('q')); aNewString += rtl::OUString(static_cast<sal_Unicode>('q'));
...@@ -1903,7 +1912,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1903,7 +1912,7 @@ void SdXMLImExSvgDElement::AddPolygon(
if(bPrevPointIsSymmetric) if(bPrevPointIsSymmetric)
{ {
// write a shorthand/smooth curveto entry (S) // write a shorthand/smooth curveto entry (S)
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('s')) if(aLastCommand != sal_Unicode('s'))
aNewString += rtl::OUString(static_cast<sal_Unicode>('s')); aNewString += rtl::OUString(static_cast<sal_Unicode>('s'));
...@@ -1937,7 +1946,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1937,7 +1946,7 @@ void SdXMLImExSvgDElement::AddPolygon(
mrViewBox, bScale, bTranslate); mrViewBox, bScale, bTranslate);
// write a curveto entry (C) // write a curveto entry (C)
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('c')) if(aLastCommand != sal_Unicode('c'))
aNewString += rtl::OUString(static_cast<sal_Unicode>('c')); aNewString += rtl::OUString(static_cast<sal_Unicode>('c'));
...@@ -1993,7 +2002,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -1993,7 +2002,7 @@ void SdXMLImExSvgDElement::AddPolygon(
// write as normal point // write as normal point
if(mnLastX == nX) if(mnLastX == nX)
{ {
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('v')) if(aLastCommand != sal_Unicode('v'))
aNewString += rtl::OUString(static_cast<sal_Unicode>('v')); aNewString += rtl::OUString(static_cast<sal_Unicode>('v'));
...@@ -2014,7 +2023,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -2014,7 +2023,7 @@ void SdXMLImExSvgDElement::AddPolygon(
} }
else if(mnLastY == nY) else if(mnLastY == nY)
{ {
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('h')) if(aLastCommand != sal_Unicode('h'))
aNewString += rtl::OUString(static_cast<sal_Unicode>('h')); aNewString += rtl::OUString(static_cast<sal_Unicode>('h'));
...@@ -2035,7 +2044,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -2035,7 +2044,7 @@ void SdXMLImExSvgDElement::AddPolygon(
} }
else else
{ {
if(bRelative) if(mbRelative)
{ {
if(aLastCommand != sal_Unicode('l')) if(aLastCommand != sal_Unicode('l'))
aNewString += rtl::OUString(static_cast<sal_Unicode>('l')); aNewString += rtl::OUString(static_cast<sal_Unicode>('l'));
...@@ -2060,7 +2069,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -2060,7 +2069,7 @@ void SdXMLImExSvgDElement::AddPolygon(
else else
{ {
// write as start point // write as start point
if(bRelative) if(mbRelative)
{ {
aNewString += rtl::OUString(static_cast<sal_Unicode>('m')); aNewString += rtl::OUString(static_cast<sal_Unicode>('m'));
...@@ -2099,7 +2108,7 @@ void SdXMLImExSvgDElement::AddPolygon( ...@@ -2099,7 +2108,7 @@ void SdXMLImExSvgDElement::AddPolygon(
// close path if closed poly // close path if closed poly
if(bClosed) if(bClosed)
{ {
if(bRelative) if(mbRelative)
aNewString += rtl::OUString(static_cast<sal_Unicode>('z')); aNewString += rtl::OUString(static_cast<sal_Unicode>('z'));
else else
aNewString += rtl::OUString(static_cast<sal_Unicode>('Z')); aNewString += rtl::OUString(static_cast<sal_Unicode>('Z'));
...@@ -2126,6 +2135,7 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, ...@@ -2126,6 +2135,7 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew,
mrViewBox( rViewBox ), mrViewBox( rViewBox ),
mbIsClosed( false ), mbIsClosed( false ),
mbIsCurve( false ), mbIsCurve( false ),
mbRelative( true ),
mnLastX( 0L ), mnLastX( 0L ),
mnLastY( 0L ), mnLastY( 0L ),
maPoly() maPoly()
......
...@@ -253,7 +253,7 @@ sal_Bool XMLMarkerStyleExport::exportXML( ...@@ -253,7 +253,7 @@ sal_Bool XMLMarkerStyleExport::exportXML(
// Pathdata // Pathdata
pOuterSequence = aBezier.Coordinates.getArray(); pOuterSequence = aBezier.Coordinates.getArray();
drawing::FlagSequence* pOuterFlags = aBezier.Flags.getArray(); drawing::FlagSequence* pOuterFlags = aBezier.Flags.getArray();
SdXMLImExSvgDElement aSvgDElement(aViewBox); SdXMLImExSvgDElement aSvgDElement(aViewBox, rExport);
for (a = 0; a < nOuterCnt; a++) for (a = 0; a < nOuterCnt; a++)
{ {
......
...@@ -3019,7 +3019,7 @@ void XMLTextParagraphExport::exportContour( ...@@ -3019,7 +3019,7 @@ void XMLTextParagraphExport::exportContour(
if(pOuterSequence) if(pOuterSequence)
{ {
// prepare svx:d element export // prepare svx:d element export
SdXMLImExSvgDElement aSvgDElement( aViewBox ); SdXMLImExSvgDElement aSvgDElement( aViewBox, GetExport() );
for(sal_Int32 a(0L); a < nOuterCnt; a++) for(sal_Int32 a(0L); a < nOuterCnt; a++)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment