[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 30 06:57:24 PST 2014


 sw/qa/extras/ooxmlimport/data/rel-size-round.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx          |    6 ++++++
 writerfilter/source/dmapper/GraphicImport.cxx     |    3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 1af6cf096ade2276b364aff8d465f8782f77db53
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 30 15:37:37 2014 +0100

    DOCX import: round wp14:pctWidth/Height
    
    sw core supports integers only ATM, so at least let e.g. 9.8 be 10, not
    9.
    
    Change-Id: I94842d7190bfa264f0fa0331d7418c411ef191d9

diff --git a/sw/qa/extras/ooxmlimport/data/rel-size-round.docx b/sw/qa/extras/ooxmlimport/data/rel-size-round.docx
new file mode 100755
index 0000000..ccd076a
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/rel-size-round.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index bfcaa26..c2f3c95 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1748,6 +1748,12 @@ DECLARE_OOXMLIMPORT_TEST(testPageRelSize, "pagerelsize.docx")
     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testRelSizeRound, "rel-size-round.docx")
+{
+    // This was 9: 9.8 was imported as 9 instead of being rounded to 10.
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 2f7cfd0..e615ddf 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -43,6 +43,7 @@
 
 #include <cppuhelper/implbase1.hxx>
 #include <rtl/ustrbuf.hxx>
+#include <rtl/math.hxx>
 
 #include <dmapper/DomainMapper.hxx>
 #include <ooxml/resourceids.hxx>
@@ -936,7 +937,7 @@ void GraphicImport::lcl_sprm(Sprm & rSprm)
         case NS_ooxml::LN_CT_SizeRelV_pctHeight:
             if (m_xShape.is() && !m_pImpl->m_rPositivePercentages.empty())
             {
-                sal_Int16 nPositivePercentage = m_pImpl->m_rPositivePercentages.front().toInt32() / 1000;
+                sal_Int16 nPositivePercentage = rtl::math::round(m_pImpl->m_rPositivePercentages.front().toDouble() / 1000);
                 m_pImpl->m_rPositivePercentages.pop();
 
                 uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW);


More information about the Libreoffice-commits mailing list