summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2019-11-16 21:55:05 +0100
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2019-11-21 20:27:47 +0100
commite8997a95f8f06a32d32124c55897138ac0fe840d (patch)
treef21e0b527fc1a3a0a2c75a0ecff4fd30b2cc1b13
parentf5b74048d460de005335cb74f5c072410bf66b51 (diff)
tdf#103092 export uses MeasureUnit not FieldUnit
ctor of SvXMLExport expects a util::MeasureUnit, but getMetric() from XGlobalSheetSettings returns a FieldUnit. The conversion was missing. So FieldUnit::MM (=1) was treated as MeasureUnit::MM_10TH (=1). But that one has no unit string, so the 'translate' transformation got numbers without unit, which then were wrongly interpreted. Reviewed-on: https://gerrit.libreoffice.org/83004 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de> (cherry picked from commit 58ee73068fa881950e42cca22ed17cf5829b8d14) Reviewed-on: https://gerrit.libreoffice.org/83099 Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Change-Id: I433c7534be21655887863005f14836d2b733cf1f Reviewed-on: https://gerrit.libreoffice.org/83126 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--sc/qa/unit/data/ods/tdf103092_RotatedImage.odsbin0 -> 15393 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx34
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx4
3 files changed, 37 insertions, 1 deletions
diff --git a/sc/qa/unit/data/ods/tdf103092_RotatedImage.ods b/sc/qa/unit/data/ods/tdf103092_RotatedImage.ods
new file mode 100644
index 000000000000..eb966406272c
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf103092_RotatedImage.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 06eaf398407f..e8d4978259b4 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -63,12 +63,14 @@
#include <comphelper/scopeguard.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <tools/datetime.hxx>
+#include <tools/fldunit.hxx>
#include <svl/zformat.hxx>
#include <test/xmltesttools.hxx>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/GraphicType.hpp>
+#include <com/sun/star/sheet/GlobalSheetSettings.hpp>
#include <comphelper/storagehelper.hxx>
using namespace ::com::sun::star;
@@ -228,6 +230,7 @@ public:
void testTdf126177XLSX();
void testXltxExport();
+ void testRotatedImageODS();
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
@@ -359,6 +362,7 @@ public:
CPPUNIT_TEST(testTdf126177XLSX);
CPPUNIT_TEST(testXltxExport);
+ CPPUNIT_TEST(testRotatedImageODS);
CPPUNIT_TEST_SUITE_END();
@@ -4456,6 +4460,36 @@ void ScExportTest::testTdf126177XLSX()
assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External");
}
+void ScExportTest::testRotatedImageODS()
+{
+ // Error was, that the length values in shapes were not
+ // written in the given unit into the file.
+ css::uno::Reference<css::sheet::XGlobalSheetSettings> xGlobalSheetSettings
+ = css::sheet::GlobalSheetSettings::create(comphelper::getProcessComponentContext());
+ xGlobalSheetSettings->setMetric(static_cast<sal_Int16>(FieldUnit::MM));
+
+ ScDocShellRef xDocSh = loadDoc("tdf103092_RotatedImage.", FORMAT_ODS, true);
+ CPPUNIT_ASSERT(xDocSh.is());
+
+ std::shared_ptr<utl::TempFile> pTemp = saveAs(xDocSh.get(), FORMAT_ODS);
+ CPPUNIT_ASSERT(pTemp);
+ const xmlDocPtr pXmlDoc = XPathHelper::parseExport(pTemp, m_xSFactory, "content.xml");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ const OString sPathStart = "/office:document-content/office:body/office:spreadsheet/"
+ "table:table/table:shapes/draw:frame";
+ const OUString sTransform = getXPath(pXmlDoc, sPathStart, "transform");
+ // Attribute transform has the structure skew (...) rotate (...) translate (x y)
+ // parts are separated by blank
+ OUString sTranslate(sTransform.copy(sTransform.lastIndexOf('(')));
+ sTranslate = sTranslate.copy(1, sTranslate.getLength()-2); // remove '(' and ')'
+ const OUString sX(sTranslate.getToken(0, ' '));
+ const OUString sY(sTranslate.getToken(1, ' '));
+ CPPUNIT_ASSERT(sX.endsWith("mm") && sY.endsWith("mm"));
+
+ xDocSh->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 06917c278589..28f85c97fd75 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -103,6 +103,7 @@
#include <xmloff/ProgressBarHelper.hxx>
#include <sax/tools/converter.hxx>
+#include <tools/fldunit.hxx>
#include <rtl/ustring.hxx>
@@ -326,7 +327,8 @@ sal_Int16 ScXMLExport::GetMeasureUnit()
{
css::uno::Reference<css::sheet::XGlobalSheetSettings> xProperties =
css::sheet::GlobalSheetSettings::create( comphelper::getProcessComponentContext() );
- return xProperties->getMetric();
+ const FieldUnit eFieldUnit = static_cast<FieldUnit>(xProperties->getMetric());
+ return SvXMLUnitConverter::GetMeasureUnit(eFieldUnit);
}
static const OUStringLiteral gsLayerID( SC_LAYERID );