From c00d81612e128b74c23c95e011b482dc3918fca4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 27 Jun 2014 13:47:11 +0200 Subject: [PATCH] SwFlyFrm::Format: inform our custom shape about size changes if needed This adds support for the following scenario: - Shape has no editeng text, but a textbox - Shape has automatic size - User edits the fly frame (serving as the textbox of the draw shape) and expects that both the shape and the textbox gets resized accordingly Note that this way we can signal our size request for the textbox, and the custom shape takes care of resizing the shape in a way, so that after the resize, the text area counted from the custom shape geometry will be exactly what we requested. (I.e. just asking the shape to have the same size as the fly would work for rectangle, but not e.g. for triangles.) Change-Id: I1e7efd00db52cf28481f6821ea6949f748b855e7 --- sw/source/core/layout/fly.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 306875bc1053..c87d0cb67b7b 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include "layouter.hxx" #include "pagefrm.hxx" #include "rootfrm.hxx" @@ -59,6 +60,7 @@ #include #include "switerator.hxx" #include +#include using namespace ::com::sun::star; @@ -1275,6 +1277,21 @@ void SwFlyFrm::Format( const SwBorderAttrs *pAttrs ) InvalidateObjRectWithSpaces(); } mbValidSize = true; + + std::map aShapes = SwTextBoxHelper::findShapes(GetFmt()->GetDoc()); + if (aShapes.find(GetFmt()) != aShapes.end()) + { + // This fly is a textbox of a draw shape. + SdrObject* pShape = aShapes[GetFmt()]->FindSdrObject(); + if (SdrObjCustomShape* pCustomShape = PTR_CAST(SdrObjCustomShape, pShape)) + { + // The shape is a customshape: then inform it about the calculated fly size. + Size aSize((Frm().*fnRect->fnGetWidth)(), (Frm().*fnRect->fnGetHeight)()); + pCustomShape->SuggestTextFrameSize(aSize); + // Do the calculations normally done after touching editeng text of the shape. + pCustomShape->NbcSetOutlinerParaObjectForText(0, 0); + } + } } else {