sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 13 ++++++++++ sw/source/core/layout/anchoreddrawobject.cxx | 3 ++ writerfilter/source/dmapper/GraphicImport.cxx | 8 ++++++ 4 files changed, 24 insertions(+)
New commits: commit ff4740980c7a7fa5162da94c0d31d41e25f5d1e3 Author: Szabolcs Toth <szabolcs...@gmail.com> AuthorDate: Fri Jun 5 12:06:22 2020 +0200 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Mon Jul 27 23:04:42 2020 +0200 tdf#133670 DOCX import: fix shape width relative to right margin using UNO API RelativeWidthRelation and the associated lo-ext attribute for OpenDocument export. See commit 43d7f4e3640c5e370fd1204739c2b0c7eb5f40e4 (offapi: document the 4 new properties which are no longer read-only). Co-authored-by: Balázs Regényi Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95582 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 330ed8120e9881656716d70d87b9f49f861f0bfa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97067 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> (cherry picked from commit 718683ab1582849ea43797e404c6453ce2fbd424) Change-Id: Ic5d25701d46cdace6502ec55dbc0e5f0ebd7742b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99536 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx b/sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx new file mode 100644 index 000000000000..68f24370a31e Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 93a65a57fc45..c9833e045f0a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1231,6 +1231,19 @@ DECLARE_OOXMLEXPORT_TEST(testDocxTablePosition, "floating-table-position.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", "4611"); } +DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorWidthFromRightMargin, "tdf133670_testRelativeAnchorWidthFromRightMargin.docx") +{ + // TODO: Fix export. + if (mbExported) + return; + + // tdf#133670 The width was set relative from right margin, but this was handled relative from page width. + xmlDocPtr pXmlDoc = parseLayoutDump(); + const sal_Int32 nAnchoredWidth + = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "width").toInt32(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2408), nAnchoredWidth); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 95ad5bc155b4..4b9b119b7d0f 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -633,6 +633,9 @@ SwRect SwAnchoredDrawObject::GetObjBoundRect() const // E.g.: (left margin = 8 && relative size = 150%) -> width of some shape = 12. else if (GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::PAGE_LEFT) nWidth = GetPageFrame()->GetLeftMargin(); + // Same as the left margin above. + else if (GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::PAGE_RIGHT) + nWidth = GetPageFrame()->GetRightMargin(); else nWidth = GetPageFrame( )->GetBoundRect( GetPageFrame()->getRootFrame()->GetCurrShell()->GetOut() ).SVRect().GetWidth(); nTargetWidth = nWidth * (*GetDrawObj( )->GetRelativeWidth()); diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 04b2b124aae6..062c00d5f58e 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -948,6 +948,14 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::PAGE_LEFT)); } break; + case NS_ooxml::LN_ST_SizeRelFromH_rightMargin: + if (m_xShape.is()) + { + // Same as the left margin above. + uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::PAGE_RIGHT)); + } + break; case NS_ooxml::LN_ST_SizeRelFromH_page: if (m_xShape.is()) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits