Revert "reduce symbol visibility in sw"
[LibreOffice.git] / sw / inc / frmfmt.hxx
blobed2a419e7750f9ed0b22d8314de30574c2ca4b45
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_INC_FRMFMT_HXX
20 #define INCLUDED_SW_INC_FRMFMT_HXX
22 #include <memory>
23 #include <com/sun/star/text/PositionLayoutDir.hpp>
24 #include <cppuhelper/weakref.hxx>
25 #include <tools/gen.hxx>
26 namespace sw
28 template<class T> class FrameFormats;
29 class SpzFrameFormat;
31 #include "format.hxx"
32 #include "hintids.hxx"
33 #include "swdllapi.h"
34 #include <list>
35 #include "textboxhelper.hxx"
37 class Graphic;
38 class IMapObject;
39 class ImageMap;
40 class SdrObject;
41 class SwAnchoredObject;
42 class SwDrawFrameFormat;
43 class SwFlyDrawContact;
44 class SwFlyFrame;
45 class SwFlyFrameFormat;
46 class SwRect;
47 class SwRootFrame;
48 class SwTableBox;
50 namespace sw
52 class DocumentLayoutManager;
53 // This is cheating: we are not really decoupling much with this hint.
54 // SwDrawFrameFormat should probably bookkeep its SdrObject (and
55 // SwDrawFrameFormat too) as members
56 struct SW_DLLPUBLIC FindSdrObjectHint final : SfxHint
58 SdrObject*& m_rpObject;
59 FindSdrObjectHint(SdrObject*& rpObject)
60 : SfxHint(SfxHintId::SwFindSdrObject), m_rpObject(rpObject) {};
61 virtual ~FindSdrObjectHint() override;
63 template<class T> class FrameFormats;
64 class SpzFrameFormat;
66 class SwFormatsBase;
67 class SwTableFormat;
69 /// Style of a layout element.
70 class SW_DLLPUBLIC SwFrameFormat
71 : public SwFormat
73 friend class SwDoc;
74 friend class SwPageDesc; ///< Is allowed to call protected CTor.
75 friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor.
76 friend class sw::FrameFormats<SwTableFormat*>; ///< Is allowed to update the list backref.
77 friend class sw::FrameFormats<sw::SpzFrameFormat*>; ///< Is allowed to update the list backref.
78 friend class sw::FrameFormats<SwFrameFormat*>; ///< Is allowed to update the list backref.
79 friend class SwTextBoxHelper;
80 friend class SwUndoFlyBase; ///< calls SetOtherTextBoxFormat
82 css::uno::WeakReference<css::uno::XInterface> m_wXObject;
84 // DrawingLayer FillAttributes in a preprocessed form for primitive usage
85 drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes;
87 // The assigned SwFrmFmt list.
88 SwFormatsBase* m_ffList;
90 std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats;
92 struct change_name
94 change_name(const OUString &rName) : mName(rName) {}
95 void operator()(SwFormat *pFormat) { pFormat->m_aFormatName = mName; }
96 const OUString &mName;
99 protected:
100 SwFrameFormat(
101 SwAttrPool& rPool,
102 const OUString &rFormatNm,
103 SwFrameFormat *pDrvdFrame,
104 sal_uInt16 nFormatWhich = RES_FRMFMT,
105 const WhichRangesContainer& pWhichRange = aFrameFormatSetRange);
107 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
109 public:
111 const std::shared_ptr< SwTextBoxNode >& GetOtherTextBoxFormats() const { return m_pOtherTextBoxFormats; };
112 void SetOtherTextBoxFormats(const std::shared_ptr<SwTextBoxNode>& rNew) { m_pOtherTextBoxFormats = rNew; };
114 virtual ~SwFrameFormat() override;
116 SwFrameFormat(SwFrameFormat const &) = default;
117 SwFrameFormat(SwFrameFormat &&) = default;
118 SwFrameFormat & operator =(SwFrameFormat const &) = default;
119 SwFrameFormat & operator =(SwFrameFormat &&) = default;
121 /// Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
122 virtual void DelFrames();
124 /// Creates the views.
125 virtual void MakeFrames();
127 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt );
129 /** @return the IMapObject defined at format (Fly)
130 in the ImageMap at position Point.
131 rPoint - test on DocPosition.
132 pFly - optional FlyFrame, in case it is already known. */
133 IMapObject* GetIMapObject( const Point& rPoint,
134 const SwFlyFrame *pFly = nullptr ) const;
136 /** @return the real size of the frame - or an empty rectangle
137 if no layout exists.
138 If pPoint is given, look for the frame closest to it. */
139 SwRect FindLayoutRect( const bool bPrtArea = false,
140 const Point* pPoint = nullptr ) const;
142 /** @return the SdrObject, that is connected to the ContactObject.
143 Only DrawFrameFormats are connected to the "real SdrObject". FlyFrameFormats
144 are connected to a Master and all FlyFrames has the "real SdrObject".
145 "Real SdrObject" has position and a Z-order. */
146 SdrObject* FindSdrObject()
148 SdrObject* pObject(nullptr);
149 CallSwClientNotify(sw::FindSdrObjectHint(pObject));
150 return pObject;
152 const SdrObject *FindSdrObject() const
153 { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
155 SdrObject *FindRealSdrObject();
156 const SdrObject *FindRealSdrObject() const
157 { return const_cast<SwFrameFormat*>(this)->FindRealSdrObject(); }
159 bool IsLowerOf( const SwFrameFormat& rFormat ) const;
161 enum tLayoutDir
163 HORI_L2R,
164 HORI_R2L,
165 VERT_R2L
168 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const;
169 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir );
171 virtual sal_Int16 GetPositionLayoutDir() const;
172 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
174 virtual OUString GetDescription() const;
176 SAL_DLLPRIVATE css::uno::WeakReference<css::uno::XInterface> const& GetXObject() const
177 { return m_wXObject; }
178 SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject)
179 { m_wXObject = xObject; }
181 void RegisterToFormat( SwFormat& rFormat );
183 // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
184 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override;
185 virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
187 void dumpAsXml(xmlTextWriterPtr pWriter) const;
189 virtual void SetFormatName( const OUString& rNewName, bool bBroadcast=false ) override;
190 void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
191 virtual bool IsVisible() const;
194 namespace sw
196 class SW_DLLPUBLIC SpzFrameFormat: public SwFrameFormat {
197 friend ::SwDrawFrameFormat;
198 friend ::SwFlyFrameFormat;
199 SpzFrameFormat(
200 SwAttrPool& rPool,
201 const OUString& rFormatName,
202 SwFrameFormat* pDerivedFrame,
203 sal_uInt16 nFormatWhich)
204 : SwFrameFormat(rPool, rFormatName, pDerivedFrame, nFormatWhich)
206 assert(nFormatWhich == RES_DRAWFRMFMT || nFormatWhich == RES_FLYFRMFMT);
210 // The FlyFrame-Format
212 class SW_DLLPUBLIC SwFlyFrameFormat final : public sw::SpzFrameFormat
214 friend class SwDoc;
215 OUString msTitle;
216 OUString msDesc;
217 /// A tooltip has priority over an SwFormatURL and is not persisted to files.
218 OUString msTooltip;
220 /** Both not existent.
221 it stores the previous position of Prt rectangle from RequestObjectResize
222 so it can be used to move frames of non-resizable objects to align them correctly
223 when they get borders (this is done in SwWrtShell::CalcAndGetScale) */
224 Point m_aLastFlyFramePrtRectPos;
225 std::unique_ptr<SwFlyDrawContact> m_pContact;
227 SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
228 SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
230 SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
232 public:
233 virtual ~SwFlyFrameFormat() override;
235 /// Creates the views.
236 virtual void MakeFrames() override;
238 SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
240 SwAnchoredObject* GetAnchoredObj() const;
242 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
244 OUString GetObjTitle() const;
245 void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
247 const OUString & GetObjTooltip() const;
248 void SetObjTooltip(const OUString& rTooltip);
250 OUString GetObjDescription() const;
251 void SetObjDescription( const OUString& rDescription, bool bBroadcast = false );
253 bool IsDecorative() const;
254 void SetObjDecorative(bool isDecorative);
256 /** SwFlyFrameFormat::IsBackgroundTransparent
258 Override virtual method and its default implementation,
259 because format of fly frame provides transparent backgrounds.
260 Method determines, if background of fly frame is transparent.
262 @return true, if background color is transparent, but not "no fill"
263 or an existing background graphic is transparent.
265 virtual bool IsBackgroundTransparent() const override;
267 /** SwFlyFrameFormat::IsBackgroundBrushInherited
269 Method to determine, if the brush for drawing the
270 background is "inherited" from its parent/grandparent.
271 This is the case, if no background graphic is set and the background
272 color is "no fill"/"auto fill"
274 @return true, if background brush is "inherited" from parent/grandparent
276 bool IsBackgroundBrushInherited() const;
278 const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
279 void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
281 SwFlyDrawContact* GetOrCreateContact();
284 //The DrawFrame-Format
287 class SwDrawFrameFormat;
288 class SwDrawContact;
289 class SdrTextObj;
291 namespace sw
293 enum class DrawFrameFormatHintId {
294 DYING,
295 PREPPASTING,
296 PREP_INSERT_FLY,
297 PREP_DELETE_FLY,
298 PAGE_OUT_OF_BOUNDS,
299 MAKE_FRAMES,
300 DELETE_FRAMES,
301 POST_RESTORE_FLY_ANCHOR,
303 struct DrawFrameFormatHint final: SfxHint
305 DrawFrameFormatHintId m_eId;
306 DrawFrameFormatHint(DrawFrameFormatHintId eId)
307 : SfxHint(SfxHintId::SwDrawFrameFormat), m_eId(eId) {};
308 virtual ~DrawFrameFormatHint() override;
310 struct CheckDrawFrameFormatLayerHint final: SfxHint
312 bool* m_bCheckControlLayer;
313 CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer)
314 : SfxHint(SfxHintId::SwCheckDrawFrameFormatLayer),
315 m_bCheckControlLayer(bCheckControlLayer) {};
316 virtual ~CheckDrawFrameFormatLayerHint() override;
318 struct ContactChangedHint final: SfxHint
320 SdrObject** m_ppObject;
321 ContactChangedHint(SdrObject** ppObject)
322 : SfxHint(SfxHintId::SwContactChanged),
323 m_ppObject(ppObject) {};
324 virtual ~ContactChangedHint() override;
326 struct DrawFormatLayoutCopyHint final : SfxHint
328 SwDrawFrameFormat& m_rDestFormat;
329 SwDoc& m_rDestDoc;
330 DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc)
331 : SfxHint(SfxHintId::SwDrawFormatLayoutCopy),
332 m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
333 virtual ~DrawFormatLayoutCopyHint() override;
335 enum class WW8AnchorConv
337 NO_CONV,
338 CONV2PG,
339 CONV2COL_OR_PARA,
340 CONV2CHAR,
341 CONV2LINE,
342 RELTOTABLECELL
344 struct WW8AnchorConvResult final
346 WW8AnchorConv m_eHoriConv;
347 WW8AnchorConv m_eVertConv;
348 bool m_bConverted;
349 Point m_aPos;
350 WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
352 struct SW_DLLPUBLIC WW8AnchorConvHint final : SfxHint
354 WW8AnchorConvResult& m_rResult;
355 WW8AnchorConvHint(WW8AnchorConvResult& rResult)
356 : SfxHint(SfxHintId::SwWW8AnchorConv),
357 m_rResult(rResult) {};
358 virtual ~WW8AnchorConvHint() override;
360 struct RestoreFlyAnchorHint final : SfxHint
362 const Point m_aPos;
363 RestoreFlyAnchorHint(Point aPos)
364 : SfxHint(SfxHintId::SwRestoreFlyAnchor),
365 m_aPos(aPos) {};
366 virtual ~RestoreFlyAnchorHint() override;
368 struct CreatePortionHint final : SfxHint
370 SwDrawContact** m_ppContact;
371 CreatePortionHint(SwDrawContact** ppContact)
372 : SfxHint(SfxHintId::SwCreatePortion),
373 m_ppContact(ppContact) {};
374 virtual ~CreatePortionHint() override;
376 struct CollectTextObjectsHint final : SfxHint
378 std::list<SdrTextObj*>& m_rTextObjects;
379 CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects)
380 : SfxHint(SfxHintId::SwCollectTextObjects),
381 m_rTextObjects(rTextObjects) {};
382 virtual ~CollectTextObjectsHint() override;
384 struct GetZOrderHint final : SfxHint
386 sal_uInt32& m_rnZOrder;
387 GetZOrderHint(sal_uInt32& rnZOrder)
388 : SfxHint(SfxHintId::SwGetZOrder),
389 m_rnZOrder(rnZOrder) {};
390 virtual ~GetZOrderHint() override;
392 struct GetObjectConnectedHint final : SfxHint
394 bool& m_risConnected;
395 const SwRootFrame* m_pRoot;
396 GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot)
397 : SfxHint(SfxHintId::SwGetObjectConnected),
398 m_risConnected(risConnected), m_pRoot(pRoot) {};
399 virtual ~GetObjectConnectedHint() override;
403 class SW_DLLPUBLIC SwDrawFrameFormat final : public sw::SpzFrameFormat
405 friend class SwDoc;
407 mutable const SdrObject * m_pSdrObjectCached;
408 mutable OUString m_sSdrObjectCachedComment;
410 SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
411 SwDrawFrameFormat &operator=( const SwDrawFrameFormat &rCpy ) = delete;
413 SwFrameFormat::tLayoutDir meLayoutDir;
415 sal_Int16 mnPositionLayoutDir;
417 bool mbPosAttrSet;
419 SwDrawFrameFormat(SwAttrPool& rPool, const OUString& rFormatName, SwFrameFormat* pDerivedFrame)
420 : sw::SpzFrameFormat(rPool, rFormatName, pDerivedFrame, RES_DRAWFRMFMT),
421 m_pSdrObjectCached(nullptr),
422 meLayoutDir(SwFrameFormat::HORI_L2R),
423 mnPositionLayoutDir(css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor),
424 mbPosAttrSet(false)
427 public:
428 virtual ~SwDrawFrameFormat() override;
430 /** DrawObjects are removed from the arrays at the layout.
431 The DrawObjects are marked as deleted. */
432 virtual void DelFrames() override;
434 /** Register DrawObjects in the arrays at layout.
435 Reset delete marks. */
436 virtual void MakeFrames() override;
438 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
440 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
441 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
443 virtual sal_Int16 GetPositionLayoutDir() const override;
444 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
446 bool IsPosAttrSet() const { return mbPosAttrSet; }
447 void PosAttrSet() { mbPosAttrSet = true; }
449 virtual OUString GetDescription() const override;
452 namespace sw {
454 SW_DLLPUBLIC bool IsFlyFrameFormatInHeader(const SwFrameFormat& rFormat);
456 void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
460 #endif
462 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */