Teach symstore more duplicated DLLs
[LibreOffice.git] / sw / inc / frmfmt.hxx
blob4bfd5268d2516fc47d108e5eb10790b115fdab9c
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 #include "format.hxx"
27 #include "hintids.hxx"
28 #include "swdllapi.h"
29 #include <list>
31 class SwFlyFrame;
32 class SwFlyDrawContact;
33 class SwAnchoredObject;
34 class Graphic;
35 class ImageMap;
36 class IMapObject;
37 class SwRect;
38 class SdrObject;
39 class SwRootFrame;
41 namespace sw
43 class DocumentLayoutManager;
44 // This is cheating: we are not really decoupling much with this hint.
45 // SwDrawFrameFormat should probably bookkeep its SdrObject (and
46 // SwDrawFrameFormat too) as members
47 struct SW_DLLPUBLIC FindSdrObjectHint final : SfxHint
49 SdrObject*& m_rpObject;
50 FindSdrObjectHint(SdrObject*& rpObject) : m_rpObject(rpObject) {};
51 virtual ~FindSdrObjectHint() override;
54 class SwFrameFormats;
56 /// Style of a layout element.
57 class SW_DLLPUBLIC SwFrameFormat
58 : public SwFormat
60 friend class SwDoc;
61 friend class SwPageDesc; ///< Is allowed to call protected CTor.
62 friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor.
63 friend class SwFrameFormats; ///< Is allowed to update the list backref.
64 friend class SwTextBoxHelper;
65 friend class SwUndoFlyBase; ///< calls SetOtherTextBoxFormat
67 css::uno::WeakReference<css::uno::XInterface> m_wXObject;
69 // DrawingLayer FillAttributes in a preprocessed form for primitive usage
70 drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes;
72 // The assigned SwFrmFmt list.
73 SwFrameFormats *m_ffList;
75 SwFrameFormat *m_pOtherTextBoxFormat;
77 struct change_name
79 change_name(const OUString &rName) : mName(rName) {}
80 void operator()(SwFormat *pFormat) { pFormat->m_aFormatName = mName; }
81 const OUString &mName;
84 protected:
85 SwFrameFormat(
86 SwAttrPool& rPool,
87 const sal_Char* pFormatNm,
88 SwFrameFormat *pDrvdFrame,
89 sal_uInt16 nFormatWhich = RES_FRMFMT,
90 const sal_uInt16* pWhichRange = nullptr);
92 SwFrameFormat(
93 SwAttrPool& rPool,
94 const OUString &rFormatNm,
95 SwFrameFormat *pDrvdFrame,
96 sal_uInt16 nFormatWhich = RES_FRMFMT,
97 const sal_uInt16* pWhichRange = nullptr);
99 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) override;
101 SwFrameFormat* GetOtherTextBoxFormat() const { return m_pOtherTextBoxFormat; }
102 void SetOtherTextBoxFormat( SwFrameFormat *pFormat );
104 public:
105 virtual ~SwFrameFormat() override;
107 SwFrameFormat(SwFrameFormat const &) = default;
108 SwFrameFormat(SwFrameFormat &&) = default;
109 SwFrameFormat & operator =(SwFrameFormat const &) = default;
110 SwFrameFormat & operator =(SwFrameFormat &&) = default;
112 /// Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
113 virtual void DelFrames();
115 /// Creates the views.
116 virtual void MakeFrames();
118 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr );
120 /** @return the IMapObject defined at format (Fly)
121 in the ImageMap at position Point.
122 rPoint - test on DocPosition.
123 pFly - optional FlyFrame, in case it is already known. */
124 IMapObject* GetIMapObject( const Point& rPoint,
125 const SwFlyFrame *pFly = nullptr ) const;
127 /** @return the real size of the frame - or an empty rectangle
128 if no layout exists.
129 If pPoint is given, look for the frame closest to it. */
130 SwRect FindLayoutRect( const bool bPrtArea = false,
131 const Point* pPoint = nullptr ) const;
133 /** @return the SdrObject, that is connected to the ContactObject.
134 Only DrawFrameFormats are connected to the "real SdrObject". FlyFrameFormats
135 are connected to a Master and all FlyFrames has the "real SdrObject".
136 "Real SdrObject" has position and a Z-order. */
137 SdrObject* FindSdrObject()
139 SdrObject* pObject(nullptr);
140 CallSwClientNotify(sw::FindSdrObjectHint(pObject));
141 return pObject;
143 const SdrObject *FindSdrObject() const
144 { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
146 SdrObject *FindRealSdrObject();
147 const SdrObject *FindRealSdrObject() const
148 { return const_cast<SwFrameFormat*>(this)->FindRealSdrObject(); }
150 bool IsLowerOf( const SwFrameFormat& rFormat ) const;
152 enum tLayoutDir
154 HORI_L2R,
155 HORI_R2L,
156 VERT_R2L
159 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const;
160 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir );
162 virtual sal_Int16 GetPositionLayoutDir() const;
163 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
165 virtual OUString GetDescription() const;
167 SAL_DLLPRIVATE css::uno::WeakReference<css::uno::XInterface> const& GetXObject() const
168 { return m_wXObject; }
169 SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject)
170 { m_wXObject = xObject; }
172 void RegisterToFormat( SwFormat& rFormat );
174 // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
175 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override;
176 virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
178 void dumpAsXml(xmlTextWriterPtr pWriter) const;
180 virtual void SetName( const OUString& rNewName, bool bBroadcast=false ) override;
183 // The FlyFrame-Format
185 class SW_DLLPUBLIC SwFlyFrameFormat final : public SwFrameFormat
187 friend class SwDoc;
188 OUString msTitle;
189 OUString msDesc;
191 /** Both not existent.
192 it stores the previous position of Prt rectangle from RequestObjectResize
193 so it can be used to move frames of non-resizable objects to align them correctly
194 when they get borders (this is done in SwWrtShell::CalcAndGetScale) */
195 Point m_aLastFlyFramePrtRectPos;
196 std::unique_ptr<SwFlyDrawContact> m_pContact;
198 SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
199 SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
201 SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
203 public:
204 virtual ~SwFlyFrameFormat() override;
206 /// Creates the views.
207 virtual void MakeFrames() override;
209 SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
211 SwAnchoredObject* GetAnchoredObj() const;
213 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr ) override;
215 virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
217 OUString GetObjTitle() const;
218 void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
219 OUString GetObjDescription() const;
220 void SetObjDescription( const OUString& rDescription, bool bBroadcast = false );
222 /** SwFlyFrameFormat::IsBackgroundTransparent
224 Override virtual method and its default implementation,
225 because format of fly frame provides transparent backgrounds.
226 Method determines, if background of fly frame is transparent.
228 @return true, if background color is transparent, but not "no fill"
229 or an existing background graphic is transparent.
231 virtual bool IsBackgroundTransparent() const override;
233 /** SwFlyFrameFormat::IsBackgroundBrushInherited
235 Method to determine, if the brush for drawing the
236 background is "inherited" from its parent/grandparent.
237 This is the case, if no background graphic is set and the background
238 color is "no fill"/"auto fill"
240 @return true, if background brush is "inherited" from parent/grandparent
242 bool IsBackgroundBrushInherited() const;
244 const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
245 void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
247 SwFlyDrawContact* GetOrCreateContact();
250 //The DrawFrame-Format
253 class SwDrawFrameFormat;
254 class SwDrawContact;
255 class SdrTextObj;
257 namespace sw
259 enum class DrawFrameFormatHintId {
260 DYING,
261 PREPPASTING,
262 PREP_INSERT_FLY,
263 PREP_DELETE_FLY,
264 PAGE_OUT_OF_BOUNDS,
265 MAKE_FRAMES,
266 DELETE_FRAMES,
267 POST_RESTORE_FLY_ANCHOR,
269 struct SW_DLLPUBLIC DrawFrameFormatHint final: SfxHint
271 DrawFrameFormatHintId const m_eId;
272 DrawFrameFormatHint(DrawFrameFormatHintId eId) : m_eId(eId) {};
273 virtual ~DrawFrameFormatHint() override;
275 struct SW_DLLPUBLIC CheckDrawFrameFormatLayerHint final: SfxHint
277 bool* m_bCheckControlLayer;
278 CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer) : m_bCheckControlLayer(bCheckControlLayer) {};
279 virtual ~CheckDrawFrameFormatLayerHint() override;
281 struct SW_DLLPUBLIC ContactChangedHint final: SfxHint
283 SdrObject** m_ppObject;
284 ContactChangedHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
285 virtual ~ContactChangedHint() override;
287 struct SW_DLLPUBLIC DrawFormatLayoutCopyHint final : SfxHint
289 SwDrawFrameFormat& m_rDestFormat;
290 SwDoc& m_rDestDoc;
291 DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc) : m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
292 virtual ~DrawFormatLayoutCopyHint() override;
294 enum class WW8AnchorConv
296 NO_CONV,
297 CONV2PG,
298 CONV2COL_OR_PARA,
299 CONV2CHAR,
300 CONV2LINE,
301 RELTOTABLECELL
303 struct WW8AnchorConvResult final
305 WW8AnchorConv m_eHoriConv;
306 WW8AnchorConv m_eVertConv;
307 bool m_bConverted;
308 Point m_aPos;
309 WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
311 struct SW_DLLPUBLIC WW8AnchorConvHint final : SfxHint
313 WW8AnchorConvResult& m_rResult;
314 WW8AnchorConvHint(WW8AnchorConvResult& rResult) : m_rResult(rResult) {};
315 virtual ~WW8AnchorConvHint() override;
317 struct SW_DLLPUBLIC RestoreFlyAnchorHint final : SfxHint
319 const Point m_aPos;
320 RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
321 virtual ~RestoreFlyAnchorHint() override;
323 struct SW_DLLPUBLIC CreatePortionHint final : SfxHint
325 SwDrawContact** m_ppContact;
326 CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
327 virtual ~CreatePortionHint() override;
329 struct SW_DLLPUBLIC CollectTextObjectsHint final : SfxHint
331 std::list<SdrTextObj*>& m_rTextObjects;
332 CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
333 virtual ~CollectTextObjectsHint() override;
335 struct SW_DLLPUBLIC GetZOrderHint final : SfxHint
337 sal_uInt32& m_rnZOrder;
338 GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
339 virtual ~GetZOrderHint() override;
341 struct SW_DLLPUBLIC GetObjectConnectedHint final : SfxHint
343 bool& m_risConnected;
344 const SwRootFrame* m_pRoot;
345 GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
346 virtual ~GetObjectConnectedHint() override;
350 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
352 friend class SwDoc;
354 mutable const SdrObject * m_pSdrObjectCached;
355 mutable OUString m_sSdrObjectCachedComment;
357 SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
358 SwDrawFrameFormat &operator=( const SwDrawFrameFormat &rCpy ) = delete;
360 SwFrameFormat::tLayoutDir meLayoutDir;
362 sal_Int16 mnPositionLayoutDir;
364 bool mbPosAttrSet;
366 protected:
367 SwDrawFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm,
368 SwFrameFormat *pDrvdFrame )
369 : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_DRAWFRMFMT ),
370 m_pSdrObjectCached(nullptr),
371 meLayoutDir( SwFrameFormat::HORI_L2R ),
373 mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
375 mbPosAttrSet( false )
378 public:
379 virtual ~SwDrawFrameFormat() override;
381 /** DrawObjects are removed from the arrays at the layout.
382 The DrawObjects are marked as deleted. */
383 virtual void DelFrames() override;
385 /** Register DrawObjects in the arrays at layout.
386 Reset delete marks. */
387 virtual void MakeFrames() override;
389 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr ) override;
391 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
392 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
394 virtual sal_Int16 GetPositionLayoutDir() const override;
395 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
397 bool IsPosAttrSet() const { return mbPosAttrSet; }
398 void PosAttrSet() { mbPosAttrSet = true; }
400 virtual OUString GetDescription() const override;
403 namespace sw {
405 SW_DLLPUBLIC bool IsFlyFrameFormatInHeader(const SwFrameFormat& rFormat);
407 void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
411 #endif
413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */