LibreOffice Module sw (master)  1
frmfmt.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  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_SW_INC_FRMFMT_HXX
20 #define INCLUDED_SW_INC_FRMFMT_HXX
21 
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"
31 
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;
42 
43 namespace sw
44 {
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
50  {
52  FindSdrObjectHint(SdrObject*& rpObject) : m_rpObject(rpObject) {};
53  virtual ~FindSdrObjectHint() override;
54  };
55 }
56 class SwFrameFormats;
57 
60  : public SwFormat
61 {
62  friend class SwDoc;
63  friend class SwPageDesc;
64  friend class ::sw::DocumentLayoutManager;
65  friend class SwFrameFormats;
66  friend class SwTextBoxHelper;
67  friend class SwUndoFlyBase;
68 
69  css::uno::WeakReference<css::uno::XInterface> m_wXObject;
70 
71  // DrawingLayer FillAttributes in a preprocessed form for primitive usage
73 
74  // The assigned SwFrmFmt list.
76 
78 
79  struct change_name
80  {
81  change_name(const OUString &rName) : mName(rName) {}
82  void operator()(SwFormat *pFormat) { pFormat->m_aFormatName = mName; }
83  const OUString &mName;
84  };
85 
86 protected:
88  SwAttrPool& rPool,
89  const char* pFormatNm,
90  SwFrameFormat *pDrvdFrame,
91  sal_uInt16 nFormatWhich = RES_FRMFMT,
92  const WhichRangesContainer& pWhichRange = aFrameFormatSetRange);
93 
95  SwAttrPool& rPool,
96  const OUString &rFormatNm,
97  SwFrameFormat *pDrvdFrame,
98  sal_uInt16 nFormatWhich = RES_FRMFMT,
99  const WhichRangesContainer& pWhichRange = aFrameFormatSetRange);
100 
101  virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
102 
103 public:
104 
105  SwTextBoxNode* GetOtherTextBoxFormat() const { return m_pOtherTextBoxFormat; };
106  void SetOtherTextBoxFormat(SwTextBoxNode* pNew) { m_pOtherTextBoxFormat = pNew; };
107 
108  virtual ~SwFrameFormat() override;
109 
110  SwFrameFormat(SwFrameFormat const &) = default;
111  SwFrameFormat(SwFrameFormat &&) = default;
112  SwFrameFormat & operator =(SwFrameFormat const &) = default;
113  SwFrameFormat & operator =(SwFrameFormat &&) = default;
114 
116  virtual void DelFrames();
117 
119  virtual void MakeFrames();
120 
121  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt );
122 
127  IMapObject* GetIMapObject( const Point& rPoint,
128  const SwFlyFrame *pFly = nullptr ) const;
129 
133  SwRect FindLayoutRect( const bool bPrtArea = false,
134  const Point* pPoint = nullptr ) const;
135 
141  {
142  SdrObject* pObject(nullptr);
144  return pObject;
145  }
146  const SdrObject *FindSdrObject() const
147  { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
148 
149  SdrObject *FindRealSdrObject();
151  { return const_cast<SwFrameFormat*>(this)->FindRealSdrObject(); }
152 
153  bool IsLowerOf( const SwFrameFormat& rFormat ) const;
154 
156  {
159  VERT_R2L
160  };
161 
162  virtual SwFrameFormat::tLayoutDir GetLayoutDir() const;
163  virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir );
164 
165  virtual sal_Int16 GetPositionLayoutDir() const;
166  virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
167 
168  virtual OUString GetDescription() const;
169 
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; }
174 
175  void RegisterToFormat( SwFormat& rFormat );
176 
177  // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
179  virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
180 
181  void dumpAsXml(xmlTextWriterPtr pWriter) const;
182 
183  virtual void SetName( const OUString& rNewName, bool bBroadcast=false ) override;
184  void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
185 };
186 
187 // The FlyFrame-Format
188 
190 {
191  friend class SwDoc;
192  OUString msTitle;
193  OUString msDesc;
194 
200  std::unique_ptr<SwFlyDrawContact> m_pContact;
201 
202  SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
203  SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
204 
205  SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
206 
207 public:
208  virtual ~SwFlyFrameFormat() override;
209 
211  virtual void MakeFrames() override;
212 
213  SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
214 
215  SwAnchoredObject* GetAnchoredObj() const;
216 
217  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
218 
219  virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
220 
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 );
225 
235  virtual bool IsBackgroundTransparent() const override;
236 
246  bool IsBackgroundBrushInherited() const;
247 
248  const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
249  void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
250 
251  SwFlyDrawContact* GetOrCreateContact();
252 };
253 
254 //The DrawFrame-Format
255 
256 
257 class SwDrawFrameFormat;
258 class SwDrawContact;
259 class SdrTextObj;
260 
261 namespace sw
262 {
264  DYING,
265  PREPPASTING,
269  MAKE_FRAMES,
272  };
274  {
277  virtual ~DrawFrameFormatHint() override;
278  };
280  {
282  CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer) : m_bCheckControlLayer(bCheckControlLayer) {};
283  virtual ~CheckDrawFrameFormatLayerHint() override;
284  };
286  {
288  ContactChangedHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
289  virtual ~ContactChangedHint() override;
290  };
292  {
295  DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc) : m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
296  virtual ~DrawFormatLayoutCopyHint() override;
297  };
298  enum class WW8AnchorConv
299  {
300  NO_CONV,
301  CONV2PG,
303  CONV2CHAR,
304  CONV2LINE,
306  };
307  struct WW8AnchorConvResult final
308  {
313  WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
314  };
316  {
318  WW8AnchorConvHint(WW8AnchorConvResult& rResult) : m_rResult(rResult) {};
319  virtual ~WW8AnchorConvHint() override;
320  };
322  {
323  const Point m_aPos;
324  RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
325  virtual ~RestoreFlyAnchorHint() override;
326  };
327  struct CreatePortionHint final : SfxHint
328  {
330  CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
331  virtual ~CreatePortionHint() override;
332  };
334  {
335  std::list<SdrTextObj*>& m_rTextObjects;
336  CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
337  virtual ~CollectTextObjectsHint() override;
338  };
339  struct GetZOrderHint final : SfxHint
340  {
341  sal_uInt32& m_rnZOrder;
342  GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
343  virtual ~GetZOrderHint() override;
344  };
346  {
349  GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
350  virtual ~GetObjectConnectedHint() override;
351  };
352 }
353 
355 {
356  friend class SwDoc;
357 
358  mutable const SdrObject * m_pSdrObjectCached;
359  mutable OUString m_sSdrObjectCachedComment;
360 
361  SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
362  SwDrawFrameFormat &operator=( const SwDrawFrameFormat &rCpy ) = delete;
363 
365 
367 
369 
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 ),
375 
376  mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
377 
378  mbPosAttrSet( false )
379  {}
380 
381 public:
382  virtual ~SwDrawFrameFormat() override;
383 
386  virtual void DelFrames() override;
387 
390  virtual void MakeFrames() override;
391 
392  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
393 
394  virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
395  virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
396 
397  virtual sal_Int16 GetPositionLayoutDir() const override;
398  virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
399 
400  bool IsPosAttrSet() const { return mbPosAttrSet; }
401  void PosAttrSet() { mbPosAttrSet = true; }
402 
403  virtual OUString GetDescription() const override;
404 };
405 
406 namespace sw {
407 
409 
410 void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
411 
412 }
413 
414 #endif
415 
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~DrawFormatLayoutCopyHint() override
Definition: atrfrm.cxx:3438
SwFrameFormats * m_ffList
Definition: frmfmt.hxx:75
WW8AnchorConv
Definition: frmfmt.hxx:298
sal_Int16 mnPositionLayoutDir
Definition: frmfmt.hxx:366
CreatePortionHint(SwDrawContact **ppContact)
Definition: frmfmt.hxx:330
virtual ~CheckDrawFrameFormatLayerHint() override
Definition: atrfrm.cxx:3436
OUString msDesc
Definition: frmfmt.hxx:193
SdrObject ** m_ppObject
Definition: frmfmt.hxx:287
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:170
virtual ~GetZOrderHint() override
Definition: atrfrm.cxx:3444
ContactChangedHint(SdrObject **ppObject)
Definition: frmfmt.hxx:288
OUString m_aFormatName
Definition: format.hxx:50
virtual OUString GetDescription() const
Definition: atrfrm.cxx:2861
Definition: doc.hxx:188
Textboxes are basically textframe + shape pairs.
void PosAttrSet()
Definition: frmfmt.hxx:401
change_name(const OUString &rName)
Definition: frmfmt.hxx:81
void SetLastFlyFramePrtRectPos(const Point &rPoint)
Definition: frmfmt.hxx:249
void SetOtherTextBoxFormat(SwTextBoxNode *pNew)
Definition: frmfmt.hxx:106
bool IsPosAttrSet() const
Definition: frmfmt.hxx:400
DrawFrameFormatHint(DrawFrameFormatHintId eId)
Definition: frmfmt.hxx:276
A TextBox is a TextFrame, that is tied to a drawinglayer shape.
FindSdrObjectHint(SdrObject *&rpObject)
Definition: frmfmt.hxx:52
Dialog to specify the properties of date form field.
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
EmbeddedObjectRef * pObject
virtual ~CreatePortionHint() override
Definition: atrfrm.cxx:3441
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:162
WhichRangesContainer const aFrameFormatSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
SwTextBoxNode * m_pOtherTextBoxFormat
Definition: frmfmt.hxx:77
CollectTextObjectsHint(std::list< SdrTextObj * > &rTextObjects)
Definition: frmfmt.hxx:336
GetZOrderHint(sal_uInt32 &rnZOrder)
Definition: frmfmt.hxx:342
WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv)
Definition: frmfmt.hxx:313
SdrObject *& m_rpObject
Definition: frmfmt.hxx:51
wrapper class for the positioning of Writer fly frames and drawing objects
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
SwDrawFrameFormat & m_rDestFormat
Definition: frmfmt.hxx:293
virtual ~RestoreFlyAnchorHint() override
Definition: atrfrm.cxx:3440
WW8AnchorConv m_eVertConv
Definition: frmfmt.hxx:310
RestoreFlyAnchorHint(Point aPos)
Definition: frmfmt.hxx:324
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:41
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: format.cxx:227
virtual ~CollectTextObjectsHint() override
Definition: atrfrm.cxx:3443
constexpr TypedWhichId< SwFrameFormat > RES_FRMFMT(155)
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::uno::XInterface > const &xObject)
Definition: frmfmt.hxx:172
SwFormat & operator=(const SwFormat &)
Definition: format.cxx:105
void MakeFrames(SwDoc *pDoc, const SwNodeIndex &rSttIdx, const SwNodeIndex &rEndIdx)
Definition: frmtool.cxx:1984
Specific frame formats (frames, DrawObjects).
GetObjectConnectedHint(bool &risConnected, const SwRootFrame *pRoot)
Definition: frmfmt.hxx:349
Base class for various Writer styles.
Definition: format.hxx:46
ContactObject for connection between frames (or their formats respectively) in SwClient and the drawo...
Definition: dcontact.hxx:175
exports com.sun.star. text
struct _xmlTextWriter * xmlTextWriterPtr
Style of a layout element.
Definition: frmfmt.hxx:59
virtual Graphic MakeGraphic(ImageMap *pMap=nullptr, const sal_uInt32 nMaximumQuadraticPixels=500000, const std::optional< Size > &rTargetDPI=std::nullopt)
Definition: paintfrm.cxx:7466
friend class SwFrameFormat
Definition: format.hxx:48
virtual SwFrameFormat::tLayoutDir GetLayoutDir() const
Definition: atrfrm.cxx:2841
DrawFormatLayoutCopyHint(SwDrawFrameFormat &rDestFormat, SwDoc &rDestDoc)
Definition: frmfmt.hxx:295
Point m_aLastFlyFramePrtRectPos
Both not existent.
Definition: frmfmt.hxx:199
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:146
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2704
SwDrawContact ** m_ppContact
Definition: frmfmt.hxx:329
WW8AnchorConvHint(WW8AnchorConvResult &rResult)
Definition: frmfmt.hxx:318
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::list< SdrTextObj * > & m_rTextObjects
Definition: frmfmt.hxx:335
virtual ~DrawFrameFormatHint() override
Definition: atrfrm.cxx:3435
const SdrObject * m_pSdrObjectCached
Definition: frmfmt.hxx:358
const SwRootFrame * m_pRoot
Definition: frmfmt.hxx:348
SwDrawFrameFormat(SwAttrPool &rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame)
Definition: frmfmt.hxx:370
bool IsFlyFrameFormatInHeader(const SwFrameFormat &rFormat)
Definition: atrfrm.cxx:3612
sal_uInt32 & m_rnZOrder
Definition: frmfmt.hxx:341
virtual ~GetObjectConnectedHint() override
Definition: atrfrm.cxx:3445
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
OUString msTitle
Definition: frmfmt.hxx:192
void operator()(SwFormat *pFormat)
Definition: frmfmt.hxx:82
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: format.cxx:758
WW8AnchorConvResult & m_rResult
Definition: frmfmt.hxx:317
virtual sal_Int16 GetPositionLayoutDir() const
Definition: atrfrm.cxx:2852
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2715
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:405
const OUString & mName
Definition: frmfmt.hxx:83
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:326
SwFrameFormat & operator=(SwFrameFormat const &)=default
CheckDrawFrameFormatLayerHint(bool *bCheckControlLayer)
Definition: frmfmt.hxx:282
const SdrObject * FindSdrObject() const
Definition: frmfmt.hxx:146
std::unique_ptr< SwFlyDrawContact > m_pContact
Definition: frmfmt.hxx:200
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:248
DrawFrameFormatHintId
Definition: frmfmt.hxx:263
SwFrameFormat::tLayoutDir meLayoutDir
Definition: frmfmt.hxx:364
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes
Definition: frmfmt.hxx:72
virtual bool IsBackgroundTransparent() const
SwFormat::IsBackgroundTransparent.
Definition: format.cxx:709
WW8AnchorConv m_eHoriConv
Definition: frmfmt.hxx:309
virtual bool supportsFullDrawingLayerFillAttributeSet() const
Definition: format.cxx:364
virtual ~ContactChangedHint() override
Definition: atrfrm.cxx:3437
const SdrObject * FindRealSdrObject() const
Definition: frmfmt.hxx:150
SwTextBoxNode * GetOtherTextBoxFormat() const
Definition: frmfmt.hxx:105
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir)
Definition: atrfrm.cxx:2856
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:140
virtual void SetLayoutDir(const SwFrameFormat::tLayoutDir _eLayoutDir)
Definition: atrfrm.cxx:2846
DrawFrameFormatHintId m_eId
Definition: frmfmt.hxx:275
OUString m_sSdrObjectCachedComment
Definition: frmfmt.hxx:359
void CheckAnchoredFlyConsistency(SwDoc const &rDoc)
Definition: atrfrm.cxx:3637
css::uno::WeakReference< css::uno::XInterface > m_wXObject
Definition: frmfmt.hxx:69