diff options
author | Szabolcs Toth <szabolcs450@gmail.com> | 2020-06-05 12:06:22 +0200 |
---|---|---|
committer | Adolfo Jayme Barrientos <fitojb@ubuntu.com> | 2020-06-26 12:55:09 +0200 |
commit | 718683ab1582849ea43797e404c6453ce2fbd424 (patch) | |
tree | 5775548d80909722a3b1d797acf92b50012ca402 /sw | |
parent | 461634632d796fc719e941d925021ae48a210e59 (diff) |
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
Change-Id: Ic5d25701d46cdace6502ec55dbc0e5f0ebd7742b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95582
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 330ed8120e9881656716d70d87b9f49f861f0bfa)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97067
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx | bin | 0 -> 14953 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/layout/anchoreddrawobject.cxx | 3 |
3 files changed, 16 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx b/sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx Binary files differnew file mode 100644 index 000000000000..68f24370a31e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf133670_testRelativeAnchorWidthFromRightMargin.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 5289dec3dfc5..791d32e26435 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1229,6 +1229,19 @@ DECLARE_OOXMLEXPORT_TEST(testUnderlineColorGroupedShapes, "tdf132491_UnderlineCo "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[3]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u", "color"); } +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. + xmlDocUniquePtr 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 4789ae807239..ae7ecf1ea295 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -641,6 +641,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()); |