Basic compiler undetected typo
[LibreOffice.git] / sw / inc / frmfmt.hxx
blob59aee54a2f4aea9357110c9ad22c377c6deae377
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>
30 #include "textboxhelper.hxx"
32 class SwFlyFrame;
33 class SwFlyDrawContact;
34 class SwAnchoredObject;
35 class Graphic;
36 class ImageMap;
37 class IMapObject;
38 class SwRect;
39 class SdrObject;
40 class SwRootFrame;
41 class SwTableBox;
43 namespace sw
45 class DocumentLayoutManager;
46 // This is cheating: we are not really decoupling much with this hint.
47 // SwDrawFrameFormat should probably bookkeep its SdrObject (and
48 // SwDrawFrameFormat too) as members
49 struct SW_DLLPUBLIC FindSdrObjectHint final : SfxHint
51 SdrObject*& m_rpObject;
52 FindSdrObjectHint(SdrObject*& rpObject) : m_rpObject(rpObject) {};
53 virtual ~FindSdrObjectHint() override;
56 class SwFrameFormats;
58 /// Style of a layout element.
59 class SW_DLLPUBLIC SwFrameFormat
60 : public SwFormat
62 friend class SwDoc;
63 friend class SwPageDesc; ///< Is allowed to call protected CTor.
64 friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor.
65 friend class SwFrameFormats; ///< Is allowed to update the list backref.
66 friend class SwTextBoxHelper;
67 friend class SwUndoFlyBase; ///< calls SetOtherTextBoxFormat
69 css::uno::WeakReference<css::uno::XInterface> m_wXObject;
71 // DrawingLayer FillAttributes in a preprocessed form for primitive usage
72 drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes;
74 // The assigned SwFrmFmt list.
75 SwFrameFormats *m_ffList;
77 SwTextBoxNode* m_pOtherTextBoxFormat;
79 struct change_name
81 change_name(const OUString &rName) : mName(rName) {}
82 void operator()(SwFormat *pFormat) { pFormat->m_aFormatName = mName; }
83 const OUString &mName;
86 protected:
87 SwFrameFormat(
88 SwAttrPool& rPool,
89 const char* pFormatNm,
90 SwFrameFormat *pDrvdFrame,
91 sal_uInt16 nFormatWhich = RES_FRMFMT,
92 const WhichRangesContainer& pWhichRange = aFrameFormatSetRange);
94 SwFrameFormat(
95 SwAttrPool& rPool,
96 const OUString &rFormatNm,
97 SwFrameFormat *pDrvdFrame,
98 sal_uInt16 nFormatWhich = RES_FRMFMT,
99 const WhichRangesContainer& pWhichRange = aFrameFormatSetRange);
101 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
103 public:
105 SwTextBoxNode* GetOtherTextBoxFormat() const { return m_pOtherTextBoxFormat; };
106 void SetOtherTextBoxFormat(SwTextBoxNode* pNew) { m_pOtherTextBoxFormat = pNew; };
108 virtual ~SwFrameFormat() override;
110 SwFrameFormat(SwFrameFormat const &) = default;
111 SwFrameFormat(SwFrameFormat &&) = default;
112 SwFrameFormat & operator =(SwFrameFormat const &) = default;
113 SwFrameFormat & operator =(SwFrameFormat &&) = default;
115 /// Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
116 virtual void DelFrames();
118 /// Creates the views.
119 virtual void MakeFrames();
121 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt );
123 /** @return the IMapObject defined at format (Fly)
124 in the ImageMap at position Point.
125 rPoint - test on DocPosition.
126 pFly - optional FlyFrame, in case it is already known. */
127 IMapObject* GetIMapObject( const Point& rPoint,
128 const SwFlyFrame *pFly = nullptr ) const;
130 /** @return the real size of the frame - or an empty rectangle
131 if no layout exists.
132 If pPoint is given, look for the frame closest to it. */
133 SwRect FindLayoutRect( const bool bPrtArea = false,
134 const Point* pPoint = nullptr ) const;
136 /** @return the SdrObject, that is connected to the ContactObject.
137 Only DrawFrameFormats are connected to the "real SdrObject". FlyFrameFormats
138 are connected to a Master and all FlyFrames has the "real SdrObject".
139 "Real SdrObject" has position and a Z-order. */
140 SdrObject* FindSdrObject()
142 SdrObject* pObject(nullptr);
143 CallSwClientNotify(sw::FindSdrObjectHint(pObject));
144 return pObject;
146 const SdrObject *FindSdrObject() const
147 { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
149 SdrObject *FindRealSdrObject();
150 const SdrObject *FindRealSdrObject() const
151 { return const_cast<SwFrameFormat*>(this)->FindRealSdrObject(); }
153 bool IsLowerOf( const SwFrameFormat& rFormat ) const;
155 enum tLayoutDir
157 HORI_L2R,
158 HORI_R2L,
159 VERT_R2L
162 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const;
163 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir );
165 virtual sal_Int16 GetPositionLayoutDir() const;
166 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
168 virtual OUString GetDescription() const;
170 SAL_DLLPRIVATE css::uno::WeakReference<css::uno::XInterface> const& GetXObject() const
171 { return m_wXObject; }
172 SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject)
173 { m_wXObject = xObject; }
175 void RegisterToFormat( SwFormat& rFormat );
177 // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
178 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override;
179 virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
181 void dumpAsXml(xmlTextWriterPtr pWriter) const;
183 virtual void SetName( const OUString& rNewName, bool bBroadcast=false ) override;
184 void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
187 // The FlyFrame-Format
189 class SW_DLLPUBLIC SwFlyFrameFormat final : public SwFrameFormat
191 friend class SwDoc;
192 OUString msTitle;
193 OUString msDesc;
195 /** Both not existent.
196 it stores the previous position of Prt rectangle from RequestObjectResize
197 so it can be used to move frames of non-resizable objects to align them correctly
198 when they get borders (this is done in SwWrtShell::CalcAndGetScale) */
199 Point m_aLastFlyFramePrtRectPos;
200 std::unique_ptr<SwFlyDrawContact> m_pContact;
202 SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
203 SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
205 SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
207 public:
208 virtual ~SwFlyFrameFormat() override;
210 /// Creates the views.
211 virtual void MakeFrames() override;
213 SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
215 SwAnchoredObject* GetAnchoredObj() const;
217 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
219 virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
221 OUString GetObjTitle() const;
222 void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
223 OUString GetObjDescription() const;
224 void SetObjDescription( const OUString& rDescription, bool bBroadcast = false );
226 /** SwFlyFrameFormat::IsBackgroundTransparent
228 Override virtual method and its default implementation,
229 because format of fly frame provides transparent backgrounds.
230 Method determines, if background of fly frame is transparent.
232 @return true, if background color is transparent, but not "no fill"
233 or an existing background graphic is transparent.
235 virtual bool IsBackgroundTransparent() const override;
237 /** SwFlyFrameFormat::IsBackgroundBrushInherited
239 Method to determine, if the brush for drawing the
240 background is "inherited" from its parent/grandparent.
241 This is the case, if no background graphic is set and the background
242 color is "no fill"/"auto fill"
244 @return true, if background brush is "inherited" from parent/grandparent
246 bool IsBackgroundBrushInherited() const;
248 const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
249 void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
251 SwFlyDrawContact* GetOrCreateContact();
254 //The DrawFrame-Format
257 class SwDrawFrameFormat;
258 class SwDrawContact;
259 class SdrTextObj;
261 namespace sw
263 enum class DrawFrameFormatHintId {
264 DYING,
265 PREPPASTING,
266 PREP_INSERT_FLY,
267 PREP_DELETE_FLY,
268 PAGE_OUT_OF_BOUNDS,
269 MAKE_FRAMES,
270 DELETE_FRAMES,
271 POST_RESTORE_FLY_ANCHOR,
273 struct DrawFrameFormatHint final: SfxHint
275 DrawFrameFormatHintId m_eId;
276 DrawFrameFormatHint(DrawFrameFormatHintId eId) : m_eId(eId) {};
277 virtual ~DrawFrameFormatHint() override;
279 struct CheckDrawFrameFormatLayerHint final: SfxHint
281 bool* m_bCheckControlLayer;
282 CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer) : m_bCheckControlLayer(bCheckControlLayer) {};
283 virtual ~CheckDrawFrameFormatLayerHint() override;
285 struct ContactChangedHint final: SfxHint
287 SdrObject** m_ppObject;
288 ContactChangedHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
289 virtual ~ContactChangedHint() override;
291 struct DrawFormatLayoutCopyHint final : SfxHint
293 SwDrawFrameFormat& m_rDestFormat;
294 SwDoc& m_rDestDoc;
295 DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc) : m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
296 virtual ~DrawFormatLayoutCopyHint() override;
298 enum class WW8AnchorConv
300 NO_CONV,
301 CONV2PG,
302 CONV2COL_OR_PARA,
303 CONV2CHAR,
304 CONV2LINE,
305 RELTOTABLECELL
307 struct WW8AnchorConvResult final
309 WW8AnchorConv m_eHoriConv;
310 WW8AnchorConv m_eVertConv;
311 bool m_bConverted;
312 Point m_aPos;
313 WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
315 struct SW_DLLPUBLIC WW8AnchorConvHint final : SfxHint
317 WW8AnchorConvResult& m_rResult;
318 WW8AnchorConvHint(WW8AnchorConvResult& rResult) : m_rResult(rResult) {};
319 virtual ~WW8AnchorConvHint() override;
321 struct RestoreFlyAnchorHint final : SfxHint
323 const Point m_aPos;
324 RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
325 virtual ~RestoreFlyAnchorHint() override;
327 struct CreatePortionHint final : SfxHint
329 SwDrawContact** m_ppContact;
330 CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
331 virtual ~CreatePortionHint() override;
333 struct CollectTextObjectsHint final : SfxHint
335 std::list<SdrTextObj*>& m_rTextObjects;
336 CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
337 virtual ~CollectTextObjectsHint() override;
339 struct GetZOrderHint final : SfxHint
341 sal_uInt32& m_rnZOrder;
342 GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
343 virtual ~GetZOrderHint() override;
345 struct GetObjectConnectedHint final : SfxHint
347 bool& m_risConnected;
348 const SwRootFrame* m_pRoot;
349 GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
350 virtual ~GetObjectConnectedHint() override;
354 class SW_DLLPUBLIC SwDrawFrameFormat final : public SwFrameFormat
356 friend class SwDoc;
358 mutable const SdrObject * m_pSdrObjectCached;
359 mutable OUString m_sSdrObjectCachedComment;
361 SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
362 SwDrawFrameFormat &operator=( const SwDrawFrameFormat &rCpy ) = delete;
364 SwFrameFormat::tLayoutDir meLayoutDir;
366 sal_Int16 mnPositionLayoutDir;
368 bool mbPosAttrSet;
370 SwDrawFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm,
371 SwFrameFormat *pDrvdFrame )
372 : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_DRAWFRMFMT ),
373 m_pSdrObjectCached(nullptr),
374 meLayoutDir( SwFrameFormat::HORI_L2R ),
376 mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
378 mbPosAttrSet( false )
381 public:
382 virtual ~SwDrawFrameFormat() override;
384 /** DrawObjects are removed from the arrays at the layout.
385 The DrawObjects are marked as deleted. */
386 virtual void DelFrames() override;
388 /** Register DrawObjects in the arrays at layout.
389 Reset delete marks. */
390 virtual void MakeFrames() override;
392 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
394 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
395 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
397 virtual sal_Int16 GetPositionLayoutDir() const override;
398 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
400 bool IsPosAttrSet() const { return mbPosAttrSet; }
401 void PosAttrSet() { mbPosAttrSet = true; }
403 virtual OUString GetDescription() const override;
406 namespace sw {
408 SW_DLLPUBLIC bool IsFlyFrameFormatInHeader(const SwFrameFormat& rFormat);
410 void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
414 #endif
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */