diff options
-rw-r--r-- | sc/qa/unit/data/ods/tdf103092_RotatedImage.ods | bin | 0 -> 15393 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 33 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 4 |
3 files changed, 36 insertions, 1 deletions
diff --git a/sc/qa/unit/data/ods/tdf103092_RotatedImage.ods b/sc/qa/unit/data/ods/tdf103092_RotatedImage.ods Binary files differnew file mode 100644 index 000000000000..eb966406272c --- /dev/null +++ b/sc/qa/unit/data/ods/tdf103092_RotatedImage.ods 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 ); |