[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sc/qa sc/source

Regina Henschel (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 21 19:28:54 UTC 2019


 sc/qa/unit/data/ods/tdf103092_RotatedImage.ods |binary
 sc/qa/unit/subsequent_export-test.cxx          |   34 +++++++++++++++++++++++++
 sc/source/filter/xml/xmlexprt.cxx              |    4 ++
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit e8997a95f8f06a32d32124c55897138ac0fe840d
Author:     Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Sat Nov 16 21:55:05 2019 +0100
Commit:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Thu Nov 21 20:27:47 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.
    
    Reviewed-on: https://gerrit.libreoffice.org/83004
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
    (cherry picked from commit 58ee73068fa881950e42cca22ed17cf5829b8d14)
    Reviewed-on: https://gerrit.libreoffice.org/83099
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    
    Change-Id: I433c7534be21655887863005f14836d2b733cf1f
    Reviewed-on: https://gerrit.libreoffice.org/83126
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

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 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 );


More information about the Libreoffice-commits mailing list