diff options
author | Attila Bakos (NISZ) <bakos.attilakaroly@nisz.hu> | 2021-04-01 17:08:58 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-04-19 10:44:28 +0200 |
commit | cb965f2cf6d68c284ccbd8a9635abfdfcc0538ca (patch) | |
tree | 211234a77440fc026faedc6c4af41a5724557c8a /sw/inc | |
parent | 531993161d6fe8065436191666cc88d7c4c20749 (diff) |
and regressions by refactoring SwTextBoxHelper.
tdf#141550 was a DOCX import regression from
commit ff321dd36554d25f0817903becf4598065e0a194
(tdf#140828 sw textbox: fix AS_CHAR regression),
resulting bad horizontal position of the frame of
the textbox.
tdf#141557 was a regression resulting crash
by changing text box anchoring "To Paragraph".
tdf#140975 was an implementation error, resulting
broken textbox by changing box anchoring to
"As Character".
In the SwTextBoxHelper class there were many
repeating code parts for textbox positioning.
Now these parts have been replaced with
the calls of several new functions:
1) getShapeFormat() returns with the SwFrameFormat
of the UNO XShape;
2) setWrapThrough() only sets the surround
of the textframe (used in the code frequently);
3) changeAnchor() sets the anchor of the textframe
according to the anchor of the shape;
4) doTextFramePositioning() sets the position of the
textbox according to the shape (used in the code
frequently);
5) isAnchorTypeDifferent() shows difference of the
anchor types of the shape and the textframe. Also it
handles the situation of anchoring "As Character";
6) isTextBoxHasValidTextFrame() checks if the shape
is a part of a textbox or not.
Every function returns with true on success, otherwise
gives information to the log. All of them can be called
with ShapeFormat or UNO XShape.
The goal of this to make the possibility to advance this
class for further functions – rotation, grouped
textboxes etc. – without code copying.
Change-Id: I4441cab87931f161d0ace4983646d6d2a68a7321
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113463
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/textboxhelper.hxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 51261a8f77a3..21a1c5a97d83 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -81,9 +81,48 @@ public: /// Similar to syncProperty(), but used by the internal API (e.g. for UI purposes). static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& rSet); + /// Returns the SwFrameFormat* of the given UNO-XShape if exists otherwise nullptr. + static SwFrameFormat* getShapeFormat(css::uno::Reference<css::drawing::XShape> xShape); + /// Copy shape attributes to the text frame static void updateTextBoxMargin(SdrObject* pObj); + /// Sets the surround to through for the textframe of the given shape, + /// not to interfere with the layout. Returns true on success. + static bool setWrapThrough(SwFrameFormat* pShape); + + /// Sets the surround to through for the textframe of the given shape, + /// not to interfere with the layout. Returns true on success. + static bool setWrapThrough(css::uno::Reference<css::drawing::XShape> xShape); + + /// Sets the anchor of the associated textframe of the given shape, and + /// returns true on success. + static bool changeAnchor(SwFrameFormat* pShape); + + /// Sets the anchor of the associated textframe of the given shape, and + /// returns true on success. + static bool changeAnchor(css::uno::Reference<css::drawing::XShape> xShape); + + /// Does the positioning for the associated textframe of the shape, and + /// returns true on success. + static bool doTextBoxPositioning(SwFrameFormat* pShape); + + /// Does the positioning for the associated textframe of the shape, and + /// returns true on success. + static bool doTextBoxPositioning(css::uno::Reference<css::drawing::XShape> xShape); + + /// Returns true if the anchor different for the given shape, and the + /// associated textframe of the given shape. + /// Note: In case of AS_CHAR anchor the anchor type must be different, + /// because if not, layout breaks, but this situation also handled by + /// this function, and returns true in that case too. + static std::optional<bool> isAnchorTypeDifferent(SwFrameFormat* pShape); + + /// Returns true if the given shape has a valid textframe. + static bool isTextBoxShapeHasValidTextFrame(SwFrameFormat* pShape); + /// Returns true if the given shape has a valid textframe. + static bool isTextBoxShapeHasValidTextFrame(css::uno::Reference<css::drawing::XShape> xShape); + /** * If we have an associated TextFrame, then return that. * |