[Libreoffice-commits] core.git: sc/qa sc/source
Regina Henschel (via logerrit)
logerrit at kemper.freedesktop.org
Mon Nov 18 13:23:48 UTC 2019
sc/qa/unit/data/ods/tdf103092_RotatedImage.ods |binary
sc/qa/unit/subsequent_export-test.cxx | 33 +++++++++++++++++++++++++
sc/source/filter/xml/xmlexprt.cxx | 4 ++-
3 files changed, 36 insertions(+), 1 deletion(-)
New commits:
commit 58ee73068fa881950e42cca22ed17cf5829b8d14
Author: Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Sat Nov 16 21:55:05 2019 +0100
Commit: Regina Henschel <rb.henschel at t-online.de>
CommitDate: Mon Nov 18 14:22:42 2019 +0100
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.
Change-Id: I433c7534be21655887863005f14836d2b733cf1f
Reviewed-on: https://gerrit.libreoffice.org/83004
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
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
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf103092_RotatedImage.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index dcd395784949..e9ad4b5eade4 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;
@@ -226,6 +228,7 @@ public:
void testCommentTextHAlignment();
void testXltxExport();
+ void testRotatedImageODS();
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
@@ -355,6 +358,7 @@ public:
CPPUNIT_TEST(testCommentTextHAlignment);
CPPUNIT_TEST(testXltxExport);
+ CPPUNIT_TEST(testRotatedImageODS);
CPPUNIT_TEST_SUITE_END();
@@ -4522,6 +4526,35 @@ void ScExportTest::testCommentTextHAlignment()
assertXPathContent(pVmlDrawing, "/xml/v:shape/xx:ClientData/xx:TextHAlign", "Center");
}
+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);
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index fc12af17c4b1..a1fdf72f53b1 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 );
More information about the Libreoffice-commits
mailing list