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
This commit is contained in:
Miklos Vajna
2014-06-27 13:47:11 +02:00
parent 4f33a0961d
commit c00d81612e

View File

@@ -41,6 +41,7 @@
#include <ndole.hxx>
#include <swtable.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdoashp.hxx>
#include "layouter.hxx"
#include "pagefrm.hxx"
#include "rootfrm.hxx"
@@ -59,6 +60,7 @@
#include <vcl/svapp.hxx>
#include "switerator.hxx"
#include <IDocumentSettingAccess.hxx>
#include <textboxhelper.hxx>
using namespace ::com::sun::star;
@@ -1275,6 +1277,21 @@ void SwFlyFrm::Format( const SwBorderAttrs *pAttrs )
InvalidateObjRectWithSpaces();
}
mbValidSize = true;
std::map<SwFrmFmt*, SwFrmFmt*> 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
{