summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docxbin0 -> 14864 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport3.cxx14
-rw-r--r--sw/source/core/layout/anchoreddrawobject.cxx13
3 files changed, 23 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docx b/sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docx
new file mode 100644
index 000000000000..2f1c5560c17a
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 336e99b26507..4c6428321792 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1155,6 +1155,20 @@ DECLARE_OOXMLEXPORT_TEST(testShapeLineWidth, "tdf92526_ShapeLineWidth.odt")
"/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln", "w", "0");
}
+DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorWidthFromLeftMargin, "tdf132976_testRelativeAnchorWidthFromLeftMargin.docx")
+{
+ // TODO: Fix export.
+ if (mbExported)
+ return;
+
+ // tdf#132976 The size of the width of this shape should come from the size of the left margin.
+ // It was set to the size of the width of the entire page before.
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ const sal_Int32 nAnchoredWidth
+ = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "width").toInt32();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1133), 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 5f60d769a44a..4789ae807239 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -632,13 +632,18 @@ SwRect SwAnchoredDrawObject::GetObjBoundRect() const
long nTargetWidth = aCurrObjRect.GetWidth( );
if ( GetDrawObj( )->GetRelativeWidth( ) )
{
- tools::Rectangle aPageRect;
+ long nWidth = 0;
if (GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::FRAME)
// Exclude margins.
- aPageRect = GetPageFrame()->getFramePrintArea().SVRect();
+ nWidth = GetPageFrame()->getFramePrintArea().SVRect().GetWidth();
+ // Here we handle the relative size of the width of some shape.
+ // The size of the shape's width is going to be relative to the size of the left margin.
+ // E.g.: (left margin = 8 && relative size = 150%) -> width of some shape = 12.
+ else if (GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::PAGE_LEFT)
+ nWidth = GetPageFrame()->GetLeftMargin();
else
- aPageRect = GetPageFrame( )->GetBoundRect( GetPageFrame()->getRootFrame()->GetCurrShell()->GetOut() ).SVRect();
- nTargetWidth = aPageRect.GetWidth( ) * (*GetDrawObj( )->GetRelativeWidth());
+ nWidth = GetPageFrame( )->GetBoundRect( GetPageFrame()->getRootFrame()->GetCurrShell()->GetOut() ).SVRect().GetWidth();
+ nTargetWidth = nWidth * (*GetDrawObj( )->GetRelativeWidth());
}
long nTargetHeight = aCurrObjRect.GetHeight( );