summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-05-18 18:43:51 +0200
committerJan Holesovsky <kendy@collabora.com>2021-01-07 16:32:55 +0100
commitbdb3d5d7a9e8c9c7fd465ee249c6ba89c68e3add (patch)
tree983b7e29ac86ee3a8e8546d4766cdccd5981ac4f /xmloff
parent4181f01c032c8aa8ac018956a4da58168ce6fa50 (diff)
tdf#89475 xmloff: ODF import/export: continue fixing draw:angle
Continue what commit aadda5d17f6e422da143ea774f759bfc5f629c5b started wrt. unit-less draw:angle attributes in ODF >= 1.2: * ODF 1.3 files don't ever have unit-less draw:angle interpreted as 10th of degree * import unit-less draw:angle as degree, except if it's ODF 1.0/1.1 or it's ODF 1.2 written by OOo/LO < 7.0, then 10th of degree * export draw:angle with "deg", which LO 4.4 and newer can read; except if exporting ODF 1.0/1.1 or ODF 1.2 Extended (compatibility mode), then 10th of degree (unit-less) The only problem with this is that if you store a file as ODF 1.2 Extended (compatibility mode) and load it with LO 7.0 it will interpret the angle wrong, but nothing's perfect... Change-Id: I3771e6571afd40e44b6f7890dacf18c28841610f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94443 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/style/GradientStyle.cxx11
-rw-r--r--xmloff/source/style/TransGradientStyle.cxx11
2 files changed, 18 insertions, 4 deletions
diff --git a/xmloff/source/style/GradientStyle.cxx b/xmloff/source/style/GradientStyle.cxx
index a58eff4fc42f..d2b84fef3d80 100644
--- a/xmloff/source/style/GradientStyle.cxx
+++ b/xmloff/source/style/GradientStyle.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/awt/Gradient.hpp>
#include <sax/tools/converter.hxx>
+#include <comphelper/documentconstants.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmluconv.hxx>
@@ -158,8 +159,14 @@ void XMLGradientStyleImport::importXML(
break;
case XML_TOK_GRADIENT_ANGLE:
{
+ auto const cmp12(rImport.GetODFVersion().compareTo(ODFVER_012_TEXT));
bool const bSuccess =
- ::sax::Converter::convertAngle(aGradient.Angle, rStrValue);
+ ::sax::Converter::convertAngle(aGradient.Angle, rStrValue,
+ // tdf#89475 try to detect borked OOo angles
+ (cmp12 < 0) || (cmp12 == 0
+ && (rImport.isGeneratorVersionOlderThan(SvXMLImport::AOO_4x, SvXMLImport::LO_7x)
+ // also for AOO 4.x, assume there won't ever be a 4.2
+ || rImport.getGeneratorVersion() == SvXMLImport::AOO_4x)));
SAL_INFO_IF(!bSuccess, "xmloff.style", "failed to import draw:angle");
}
break;
@@ -258,7 +265,7 @@ void XMLGradientStyleExport::exportXML(
// Angle
if( aGradient.Style != awt::GradientStyle_RADIAL )
{
- ::sax::Converter::convertAngle(aOut, aGradient.Angle);
+ ::sax::Converter::convertAngle(aOut, aGradient.Angle, rExport.getSaneDefaultVersion());
aStrValue = aOut.makeStringAndClear();
rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_GRADIENT_ANGLE, aStrValue );
}
diff --git a/xmloff/source/style/TransGradientStyle.cxx b/xmloff/source/style/TransGradientStyle.cxx
index 55e7a7358f79..f0049fc2a06b 100644
--- a/xmloff/source/style/TransGradientStyle.cxx
+++ b/xmloff/source/style/TransGradientStyle.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/awt/Gradient.hpp>
#include <sax/tools/converter.hxx>
+#include <comphelper/documentconstants.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmluconv.hxx>
@@ -169,8 +170,14 @@ void XMLTransGradientStyleImport::importXML(
break;
case XML_TOK_GRADIENT_ANGLE:
{
+ auto const cmp12(rImport.GetODFVersion().compareTo(ODFVER_012_TEXT));
bool const bSuccess =
- ::sax::Converter::convertAngle(aGradient.Angle, rStrValue);
+ ::sax::Converter::convertAngle(aGradient.Angle, rStrValue,
+ // tdf#89475 try to detect borked OOo angles
+ (cmp12 < 0) || (cmp12 == 0
+ && (rImport.isGeneratorVersionOlderThan(SvXMLImport::AOO_4x, SvXMLImport::LO_7x)
+ // also for AOO 4.x, assume there won't ever be a 4.2
+ || rImport.getGeneratorVersion() == SvXMLImport::AOO_4x)));
SAL_INFO_IF(!bSuccess, "xmloff.style", "failed to import draw:angle");
}
break;
@@ -263,7 +270,7 @@ void XMLTransGradientStyleExport::exportXML(
// Angle
if( aGradient.Style != awt::GradientStyle_RADIAL )
{
- ::sax::Converter::convertAngle(aOut, aGradient.Angle);
+ ::sax::Converter::convertAngle(aOut, aGradient.Angle, rExport.getSaneDefaultVersion());
aStrValue = aOut.makeStringAndClear();
rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_GRADIENT_ANGLE, aStrValue );
}