summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-04-13 15:09:53 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2018-05-07 12:38:40 +0200
commit3ead159607641f91bf220c574e7fd87c95d2e834 (patch)
treec6dc39746600c35e1a9c6f635c1b6a76e00e24bc
parentc7b4fb269034ec87700481d389f60ca181060c8c (diff)
tdf#116985 sw: fix geometry of textbox of shape with relative size
Relative size of shapes are calculated by the layout, so the normal doc model-level synchronization between the shape and its textbox was not enough. (cherry picked from commit c8b976ac64c9cac360f7c4fd9844fcfac7ba25a8) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport11.cxx Change-Id: Ia6f460132efaf03a7ba3a023cf751f6fff74404d Reviewed-on: https://gerrit.libreoffice.org/52985 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 2b39c6821929041d0806125720c56525df40c455) Reviewed-on: https://gerrit.libreoffice.org/53740 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/tdf116985.docxbin0 -> 13508 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx10
-rw-r--r--sw/source/core/layout/anchoreddrawobject.cxx17
3 files changed, 26 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf116985.docx b/sw/qa/extras/ooxmlexport/data/tdf116985.docx
new file mode 100644
index 000000000000..2a8e2023884d
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf116985.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index dd3b9759cf4b..d4443761dd90 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -723,6 +723,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx")
getProperty<sal_Int16>(getShape(1), "RelativeWidth"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf116985, "tdf116985.docx")
+{
+ // Body frame width is 10800, 40% is the requested relative width, with 144
+ // spacing to text on the left/right side. So ideal width would be 4032,
+ // was 3431. Allow one pixel tolerance, though.
+ sal_Int32 nWidth
+ = parseDump("/root/page[1]/body/txt[1]/anchored/fly/infos/bounds", "width").toInt32();
+ CPPUNIT_ASSERT(nWidth > 4000);
+}
+
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 9d450f9a26f7..8bdf1dbf587f 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -32,6 +32,8 @@
#include <IDocumentState.hxx>
#include <txtfly.hxx>
#include <viewimp.hxx>
+#include <textboxhelper.hxx>
+#include <unomid.h>
using namespace ::com::sun::star;
@@ -661,9 +663,22 @@ const SwRect SwAnchoredDrawObject::GetObjBoundRect() const
bool bEnableSetModified = pDoc->getIDocumentState().IsEnableSetModified();
pDoc->getIDocumentState().SetEnableSetModified(false);
- const_cast< SdrObject* >( GetDrawObj() )->Resize( aCurrObjRect.TopLeft(),
+ auto pObject = const_cast<SdrObject*>(GetDrawObj());
+ pObject->Resize( aCurrObjRect.TopLeft(),
Fraction( nTargetWidth, aCurrObjRect.GetWidth() ),
Fraction( nTargetHeight, aCurrObjRect.GetHeight() ), false );
+
+ if (SwFrameFormat* pFrameFormat = FindFrameFormat(pObject))
+ {
+ if (SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT))
+ {
+ // Shape has relative size and also a textbox, update its text area as well.
+ uno::Reference<drawing::XShape> xShape(pObject->getUnoShape(), uno::UNO_QUERY);
+ SwTextBoxHelper::syncProperty(pFrameFormat, RES_FRM_SIZE, MID_FRMSIZE_SIZE,
+ uno::makeAny(xShape->getSize()));
+ }
+ }
+
pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified);
}
}