summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-04-12 18:39:36 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2018-05-07 12:38:30 +0200
commitc7b4fb269034ec87700481d389f60ca181060c8c (patch)
tree5b8fc86152c4f11f89e1b87f7c866001b92aff57
parent90d298ba863210ac2ad140c7bf8e426fc39b10ca (diff)
tdf#116976 DOCX import: fix rel size of shape after bitmap
We have a queue of these odd relative sizes (which are not XML attributes but text inside the XML element), if the bitmap doesn't pop the queue, the following shape won't get its size. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport11.cxx Change-Id: I1602208c9509d8889bf0be254f3b25fb25fafca2 Reviewed-on: https://gerrit.libreoffice.org/52984 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit cba1897f3c063f8a535898bfd16a516c8de9ac21) Reviewed-on: https://gerrit.libreoffice.org/53739 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf116976.docxbin0 -> 14983 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx7
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx10
3 files changed, 15 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf116976.docx b/sw/qa/extras/ooxmlexport/data/tdf116976.docx
new file mode 100644
index 000000000000..70492a4af2f3
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf116976.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 8ffe76e77f55..dd3b9759cf4b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -716,6 +716,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf116410, "tdf116410.docx")
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx")
+{
+ // This was 0, reltive size of shape after bitmap was ignored.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(40),
+ getProperty<sal_Int16>(getShape(1), "RelativeWidth"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index e9826192143c..d6745f2dc162 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1080,10 +1080,12 @@ void GraphicImport::lcl_sprm(Sprm& rSprm)
break;
case NS_ooxml::LN_CT_SizeRelH_pctWidth:
case NS_ooxml::LN_CT_SizeRelV_pctHeight:
- if (m_xShape.is() && !m_pImpl->m_rPositivePercentages.empty())
+ if (m_pImpl->m_rPositivePercentages.empty())
+ break;
+
+ if (m_xShape.is())
{
sal_Int16 nPositivePercentage = rtl::math::round(m_pImpl->m_rPositivePercentages.front().toDouble() / oox::drawingml::PER_PERCENT);
- m_pImpl->m_rPositivePercentages.pop();
if (nPositivePercentage)
{
@@ -1092,6 +1094,10 @@ void GraphicImport::lcl_sprm(Sprm& rSprm)
xPropertySet->setPropertyValue(aProperty, uno::makeAny(nPositivePercentage));
}
}
+
+ // Make sure the token is consumed even if xShape is an empty
+ // reference.
+ m_pImpl->m_rPositivePercentages.pop();
break;
case NS_ooxml::LN_EG_WrapType_wrapNone: // 90944; - doesn't contain attributes
//depending on the behindDoc attribute text wraps through behind or in front of the object