LibreOffice Module sw (master)  1
textboxhelper.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_SW_INC_TEXTBOXHELPER_HXX
11 #define INCLUDED_SW_INC_TEXTBOXHELPER_HXX
12 
13 #include <map>
14 #include <optional>
15 #include <set>
16 #include <vector>
17 
18 #include <com/sun/star/uno/Any.h>
19 #include <com/sun/star/uno/Type.h>
20 #include <com/sun/star/text/TextContentAnchorType.hpp>
21 #include <svx/swframetypes.hxx>
22 
23 #include "swdllapi.h"
24 
25 class SdrPage;
26 class SdrObject;
27 class SfxItemSet;
28 class SwFrameFormat;
29 class SwFrameFormats;
30 class SwFormatContent;
31 class SwDoc;
32 namespace tools
33 {
34 class Rectangle;
35 }
36 class ZSortFly;
38 {
39 class XShape;
40 }
41 namespace com::sun::star::text
42 {
43 class XTextFrame;
44 }
45 
53 {
54 public:
56  using SavedLink = std::map<const SwFrameFormat*, const SwFrameFormat*>;
58  using SavedContent = std::map<const SwFrameFormat*, SwFormatContent>;
61  static void create(SwFrameFormat* pShape, bool bCopyText = false);
63  static void destroy(SwFrameFormat* pShape);
65  static css::uno::Any queryInterface(const SwFrameFormat* pShape, const css::uno::Type& rType);
66 
68  static void syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID,
69  const css::uno::Any& rValue);
71  static void syncProperty(SwFrameFormat* pShape, std::u16string_view rPropertyName,
72  const css::uno::Any& rValue);
74  static void getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID,
75  css::uno::Any& rValue);
77  static css::uno::Any getProperty(SwFrameFormat const* pShape, OUString sPropName);
78 
80  static css::text::TextContentAnchorType mapAnchorType(const RndStdIds& rAnchorID);
81 
83  static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& rSet);
84 
86  static void updateTextBoxMargin(SdrObject* pObj);
87 
90  static bool setWrapThrough(SwFrameFormat* pShape);
91 
94  static bool changeAnchor(SwFrameFormat* pShape);
95 
98  static bool doTextBoxPositioning(SwFrameFormat* pShape);
99 
105  static std::optional<bool> isAnchorTypeDifferent(SwFrameFormat* pShape);
106 
108  static bool isTextBoxShapeHasValidTextFrame(SwFrameFormat* pShape);
109 
110  // Returns true on success. Synchronize z-order of the text frame of the given textbox
111  // by setting it one level higher than the z-order of the shape of the textbox.
112  static bool DoTextBoxZOrderCorrection(SwFrameFormat* pShape);
113 
122  static SwFrameFormat* getOtherTextBoxFormat(const SwFrameFormat* pFormat, sal_uInt16 nType);
124  static SwFrameFormat*
125  getOtherTextBoxFormat(css::uno::Reference<css::drawing::XShape> const& xShape);
127  static css::uno::Reference<css::text::XTextFrame>
128  getUnoTextFrame(css::uno::Reference<css::drawing::XShape> const& xShape);
130  static tools::Rectangle getTextRectangle(SwFrameFormat* pShape, bool bAbsolute = true);
131 
141  static bool isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType);
142 
144  static bool hasTextFrame(const SdrObject* pObj);
145 
147  static sal_Int32 getCount(const SwDoc& rDoc);
149  static sal_Int32 getCount(SdrPage const* pPage);
153  static css::uno::Any getByIndex(SdrPage const* pPage, sal_Int32 nIndex);
155  static sal_Int32 getOrdNum(const SdrObject* pObject);
157  static void getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough);
158 
160  static void saveLinks(const SwFrameFormats& rFormats,
161  std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks);
163  static void restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrameFormat*>& rNew,
164  SavedLink& rSavedLinks);
165 };
166 
167 #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
168 
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:187
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
A TextBox is a TextFrame, that is tied to a drawinglayer shape.
std::map< const SwFrameFormat *, const SwFrameFormat * > SavedLink
Maps a draw format to a fly format.
Reference< deployment::XPackageRegistry > create(Reference< deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, Reference< XComponentContext > const &xComponentContext)
OUString getProperty(uno::Reference< beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)
Specific frame formats (frames, DrawObjects).
Style of a layout element.
Definition: frmfmt.hxx:58
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
Helper to copy paragraph-bound Flys.
Definition: mvsave.hxx:161
std::map< const SwFrameFormat *, SwFormatContent > SavedContent
Maps a draw format to content.
unsigned char sal_uInt8
RndStdIds
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)