diff --git a/sw/qa/extras/ooxmlexport/data/dml-rectangle-relsize.docx b/sw/qa/extras/ooxmlexport/data/dml-rectangle-relsize.docx new file mode 100644 index 000000000000..391d737bf124 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/dml-rectangle-relsize.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 1de987d48112..cecb7fa19d95 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2808,6 +2808,13 @@ DECLARE_OOXMLEXPORT_TEST(testDMLCustomGeometry, "dml-customgeometry-cubicbezier. } } +DECLARE_OOXMLEXPORT_TEST(testDmlRectangleRelsize, "dml-rectangle-relsize.docx") +{ + // This was around 19560, as we did not read wp14:pctHeight for + // drawinglayer shapes and the fallback data was invalid. + CPPUNIT_ASSERT(21000 < getShape(1)->getSize().Height); +} + DECLARE_OOXMLEXPORT_TEST(testGradientFillPreservation, "gradient-fill-preservation.docx") { xmlDocPtr pXmlDocument = parseExport("word/document.xml"); diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 380227205157..f88690bde9b8 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -642,7 +642,7 @@ const SwRect SwAnchoredDrawObject::GetObjRect() const const SwRect SwAnchoredDrawObject::GetObjBoundRect() const { // Resize objects with relative width or height - if ( GetDrawObj( )->GetRelativeWidth( ) || GetDrawObj()->GetRelativeHeight( ) ) + if ( GetPageFrm( ) && ( GetDrawObj( )->GetRelativeWidth( ) || GetDrawObj()->GetRelativeHeight( ) ) ) { Rectangle aPageRect = GetPageFrm( )->GetBoundRect( ).SVRect(); Rectangle aCurrObjRect = GetDrawObj()->GetCurrentBoundRect(); diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 7eec0312bc40..9528cd543ef3 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -951,16 +952,12 @@ 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 = rtl::math::round(m_pImpl->m_rPositivePercentages.front().toDouble() / 1000); + sal_Int16 nPositivePercentage = rtl::math::round(m_pImpl->m_rPositivePercentages.front().toDouble() / oox::drawingml::PER_PERCENT); m_pImpl->m_rPositivePercentages.pop(); - uno::Reference xServiceInfo(m_xShape, uno::UNO_QUERY_THROW); - if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) - { - uno::Reference xPropertySet(m_xShape, uno::UNO_QUERY); - OUString aProperty = nSprmId == NS_ooxml::LN_CT_SizeRelH_pctWidth ? OUString("RelativeWidth") : OUString("RelativeHeight"); - xPropertySet->setPropertyValue(aProperty, uno::makeAny(nPositivePercentage)); - } + uno::Reference xPropertySet(m_xShape, uno::UNO_QUERY); + OUString aProperty = nSprmId == NS_ooxml::LN_CT_SizeRelH_pctWidth ? OUString("RelativeWidth") : OUString("RelativeHeight"); + xPropertySet->setPropertyValue(aProperty, uno::makeAny(nPositivePercentage)); } break; case 0x271b: