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 
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;
40 class SwTableBox;
41 
42 namespace sw
43 {
44  class DocumentLayoutManager;
45  // This is cheating: we are not really decoupling much with this hint.
46  // SwDrawFrameFormat should probably bookkeep its SdrObject (and
47  // SwDrawFrameFormat too) as members
49  {
51  FindSdrObjectHint(SdrObject*& rpObject) : m_rpObject(rpObject) {};
52  virtual ~FindSdrObjectHint() override;
53  };
54 }
55 class SwFrameFormats;
56 
59  : public SwFormat
60 {
61  friend class SwDoc;
62  friend class SwPageDesc;
63  friend class ::sw::DocumentLayoutManager;
64  friend class SwFrameFormats;
65  friend class SwTextBoxHelper;
66  friend class SwUndoFlyBase;
67 
68  css::uno::WeakReference<css::uno::XInterface> m_wXObject;
69 
70  // DrawingLayer FillAttributes in a preprocessed form for primitive usage
72 
73  // The assigned SwFrmFmt list.
75 
77 
78  struct change_name
79  {
80  change_name(const OUString &rName) : mName(rName) {}
81  void operator()(SwFormat *pFormat) { pFormat->m_aFormatName = mName; }
82  const OUString &mName;
83  };
84 
85 protected:
87  SwAttrPool& rPool,
88  const char* pFormatNm,
89  SwFrameFormat *pDrvdFrame,
90  sal_uInt16 nFormatWhich = RES_FRMFMT,
91  const sal_uInt16* pWhichRange = nullptr);
92 
94  SwAttrPool& rPool,
95  const OUString &rFormatNm,
96  SwFrameFormat *pDrvdFrame,
97  sal_uInt16 nFormatWhich = RES_FRMFMT,
98  const sal_uInt16* pWhichRange = nullptr);
99 
100  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) override;
101 
102  SwFrameFormat* GetOtherTextBoxFormat() const { return m_pOtherTextBoxFormat; }
103  void SetOtherTextBoxFormat( SwFrameFormat *pFormat );
104 
105 public:
106  virtual ~SwFrameFormat() override;
107 
108  SwFrameFormat(SwFrameFormat const &) = default;
109  SwFrameFormat(SwFrameFormat &&) = default;
110  SwFrameFormat & operator =(SwFrameFormat const &) = default;
111  SwFrameFormat & operator =(SwFrameFormat &&) = default;
112 
114  virtual void DelFrames();
115 
117  virtual void MakeFrames();
118 
119  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr );
120 
125  IMapObject* GetIMapObject( const Point& rPoint,
126  const SwFlyFrame *pFly = nullptr ) const;
127 
131  SwRect FindLayoutRect( const bool bPrtArea = false,
132  const Point* pPoint = nullptr ) const;
133 
139  {
140  SdrObject* pObject(nullptr);
142  return pObject;
143  }
144  const SdrObject *FindSdrObject() const
145  { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
146 
147  SdrObject *FindRealSdrObject();
149  { return const_cast<SwFrameFormat*>(this)->FindRealSdrObject(); }
150 
151  bool IsLowerOf( const SwFrameFormat& rFormat ) const;
152 
154  {
157  VERT_R2L
158  };
159 
160  virtual SwFrameFormat::tLayoutDir GetLayoutDir() const;
161  virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir );
162 
163  virtual sal_Int16 GetPositionLayoutDir() const;
164  virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
165 
166  virtual OUString GetDescription() const;
167 
168  SAL_DLLPRIVATE css::uno::WeakReference<css::uno::XInterface> const& GetXObject() const
169  { return m_wXObject; }
170  SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject)
171  { m_wXObject = xObject; }
172 
173  void RegisterToFormat( SwFormat& rFormat );
174 
175  // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
177  virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
178 
179  void dumpAsXml(xmlTextWriterPtr pWriter) const;
180 
181  virtual void SetName( const OUString& rNewName, bool bBroadcast=false ) override;
182  void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
183 };
184 
185 // The FlyFrame-Format
186 
188 {
189  friend class SwDoc;
190  OUString msTitle;
191  OUString msDesc;
192 
198  std::unique_ptr<SwFlyDrawContact> m_pContact;
199 
200  SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
201  SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
202 
203  SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
204 
205 public:
206  virtual ~SwFlyFrameFormat() override;
207 
209  virtual void MakeFrames() override;
210 
211  SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
212 
213  SwAnchoredObject* GetAnchoredObj() const;
214 
215  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr ) override;
216 
217  virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
218 
219  OUString GetObjTitle() const;
220  void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
221  OUString GetObjDescription() const;
222  void SetObjDescription( const OUString& rDescription, bool bBroadcast = false );
223 
233  virtual bool IsBackgroundTransparent() const override;
234 
244  bool IsBackgroundBrushInherited() const;
245 
246  const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
247  void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
248 
249  SwFlyDrawContact* GetOrCreateContact();
250 };
251 
252 //The DrawFrame-Format
253 
254 
255 class SwDrawFrameFormat;
256 class SwDrawContact;
257 class SdrTextObj;
258 
259 namespace sw
260 {
262  DYING,
263  PREPPASTING,
267  MAKE_FRAMES,
270  };
272  {
275  virtual ~DrawFrameFormatHint() override;
276  };
278  {
280  CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer) : m_bCheckControlLayer(bCheckControlLayer) {};
281  virtual ~CheckDrawFrameFormatLayerHint() override;
282  };
284  {
286  ContactChangedHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
287  virtual ~ContactChangedHint() override;
288  };
290  {
293  DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc) : m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
294  virtual ~DrawFormatLayoutCopyHint() override;
295  };
296  enum class WW8AnchorConv
297  {
298  NO_CONV,
299  CONV2PG,
301  CONV2CHAR,
302  CONV2LINE,
304  };
305  struct WW8AnchorConvResult final
306  {
311  WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
312  };
314  {
316  WW8AnchorConvHint(WW8AnchorConvResult& rResult) : m_rResult(rResult) {};
317  virtual ~WW8AnchorConvHint() override;
318  };
320  {
321  const Point m_aPos;
322  RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
323  virtual ~RestoreFlyAnchorHint() override;
324  };
325  struct CreatePortionHint final : SfxHint
326  {
328  CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
329  virtual ~CreatePortionHint() override;
330  };
332  {
333  std::list<SdrTextObj*>& m_rTextObjects;
334  CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
335  virtual ~CollectTextObjectsHint() override;
336  };
337  struct GetZOrderHint final : SfxHint
338  {
339  sal_uInt32& m_rnZOrder;
340  GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
341  virtual ~GetZOrderHint() override;
342  };
344  {
347  GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
348  virtual ~GetObjectConnectedHint() override;
349  };
350 }
351 
353 {
354  friend class SwDoc;
355 
356  mutable const SdrObject * m_pSdrObjectCached;
357  mutable OUString m_sSdrObjectCachedComment;
358 
359  SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
360  SwDrawFrameFormat &operator=( const SwDrawFrameFormat &rCpy ) = delete;
361 
363 
365 
367 
368 protected:
369  SwDrawFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm,
370  SwFrameFormat *pDrvdFrame )
371  : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_DRAWFRMFMT ),
372  m_pSdrObjectCached(nullptr),
373  meLayoutDir( SwFrameFormat::HORI_L2R ),
374 
375  mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
376 
377  mbPosAttrSet( false )
378  {}
379 
380 public:
381  virtual ~SwDrawFrameFormat() override;
382 
385  virtual void DelFrames() override;
386 
389  virtual void MakeFrames() override;
390 
391  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr ) override;
392 
393  virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
394  virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
395 
396  virtual sal_Int16 GetPositionLayoutDir() const override;
397  virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
398 
399  bool IsPosAttrSet() const { return mbPosAttrSet; }
400  void PosAttrSet() { mbPosAttrSet = true; }
401 
402  virtual OUString GetDescription() const override;
403 };
404 
405 namespace sw {
406 
408 
409 void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
410 
411 }
412 
413 #endif
414 
415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~DrawFormatLayoutCopyHint() override
Definition: atrfrm.cxx:3404
SwFrameFormats * m_ffList
Definition: frmfmt.hxx:74
WW8AnchorConv
Definition: frmfmt.hxx:296
sal_Int16 mnPositionLayoutDir
Definition: frmfmt.hxx:364
CreatePortionHint(SwDrawContact **ppContact)
Definition: frmfmt.hxx:328
virtual ~CheckDrawFrameFormatLayerHint() override
Definition: atrfrm.cxx:3402
OUString msDesc
Definition: frmfmt.hxx:191
SdrObject ** m_ppObject
Definition: frmfmt.hxx:285
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:168
virtual ~GetZOrderHint() override
Definition: atrfrm.cxx:3410
ContactChangedHint(SdrObject **ppObject)
Definition: frmfmt.hxx:286
OUString m_aFormatName
Definition: format.hxx:47
virtual OUString GetDescription() const
Definition: atrfrm.cxx:2827
Definition: doc.hxx:186
void PosAttrSet()
Definition: frmfmt.hxx:400
change_name(const OUString &rName)
Definition: frmfmt.hxx:80
void SetLastFlyFramePrtRectPos(const Point &rPoint)
Definition: frmfmt.hxx:247
bool IsPosAttrSet() const
Definition: frmfmt.hxx:399
DrawFrameFormatHint(DrawFrameFormatHintId eId)
Definition: frmfmt.hxx:274
A TextBox is a TextFrame, that is tied to a drawinglayer shape.
FindSdrObjectHint(SdrObject *&rpObject)
Definition: frmfmt.hxx:51
Dialog to specify the properties of date form field.
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
EmbeddedObjectRef * pObject
virtual ~CreatePortionHint() override
Definition: atrfrm.cxx:3407
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:188
CollectTextObjectsHint(std::list< SdrTextObj * > &rTextObjects)
Definition: frmfmt.hxx:334
GetZOrderHint(sal_uInt32 &rnZOrder)
Definition: frmfmt.hxx:340
WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv)
Definition: frmfmt.hxx:311
SdrObject *& m_rpObject
Definition: frmfmt.hxx:50
wrapper class for the positioning of Writer fly frames and drawing objects
SwDrawFrameFormat & m_rDestFormat
Definition: frmfmt.hxx:291
virtual ~RestoreFlyAnchorHint() override
Definition: atrfrm.cxx:3406
WW8AnchorConv m_eVertConv
Definition: frmfmt.hxx:308
RestoreFlyAnchorHint(Point aPos)
Definition: frmfmt.hxx:322
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:38
virtual ~CollectTextObjectsHint() override
Definition: atrfrm.cxx:3409
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::uno::XInterface > const &xObject)
Definition: frmfmt.hxx:170
SwFormat & operator=(const SwFormat &)
Definition: format.cxx:103
void MakeFrames(SwDoc *pDoc, const SwNodeIndex &rSttIdx, const SwNodeIndex &rEndIdx)
Definition: frmtool.cxx:1936
constexpr TypedWhichId< SwFrameFormat > RES_FRMFMT(153)
Specific frame formats (frames, DrawObjects).
GetObjectConnectedHint(bool &risConnected, const SwRootFrame *pRoot)
Definition: frmfmt.hxx:347
Base class for various Writer styles.
Definition: format.hxx:43
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:58
SwFrameFormat * GetOtherTextBoxFormat() const
Definition: frmfmt.hxx:102
friend class SwFrameFormat
Definition: format.hxx:45
virtual SwFrameFormat::tLayoutDir GetLayoutDir() const
Definition: atrfrm.cxx:2807
DrawFormatLayoutCopyHint(SwDrawFrameFormat &rDestFormat, SwDoc &rDestDoc)
Definition: frmfmt.hxx:293
Point m_aLastFlyFramePrtRectPos
Both not existent.
Definition: frmfmt.hxx:197
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:149
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2670
SwDrawContact ** m_ppContact
Definition: frmfmt.hxx:327
SwFrameFormat * m_pOtherTextBoxFormat
Definition: frmfmt.hxx:76
WW8AnchorConvHint(WW8AnchorConvResult &rResult)
Definition: frmfmt.hxx:316
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::list< SdrTextObj * > & m_rTextObjects
Definition: frmfmt.hxx:333
virtual ~DrawFrameFormatHint() override
Definition: atrfrm.cxx:3401
const SdrObject * m_pSdrObjectCached
Definition: frmfmt.hxx:356
const SwRootFrame * m_pRoot
Definition: frmfmt.hxx:346
SwDrawFrameFormat(SwAttrPool &rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame)
Definition: frmfmt.hxx:369
bool IsFlyFrameFormatInHeader(const SwFrameFormat &rFormat)
Definition: atrfrm.cxx:3578
sal_uInt32 & m_rnZOrder
Definition: frmfmt.hxx:339
virtual ~GetObjectConnectedHint() override
Definition: atrfrm.cxx:3411
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
OUString msTitle
Definition: frmfmt.hxx:190
void operator()(SwFormat *pFormat)
Definition: frmfmt.hxx:81
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: format.cxx:777
WW8AnchorConvResult & m_rResult
Definition: frmfmt.hxx:315
virtual sal_Int16 GetPositionLayoutDir() const
Definition: atrfrm.cxx:2818
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2681
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNewValue) override
Definition: format.cxx:244
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:393
const OUString & mName
Definition: frmfmt.hxx:82
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:370
SwFrameFormat & operator=(SwFrameFormat const &)=default
CheckDrawFrameFormatLayerHint(bool *bCheckControlLayer)
Definition: frmfmt.hxx:280
const SdrObject * FindSdrObject() const
Definition: frmfmt.hxx:144
std::unique_ptr< SwFlyDrawContact > m_pContact
Definition: frmfmt.hxx:198
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:246
virtual Graphic MakeGraphic(ImageMap *pMap=nullptr)
Definition: paintfrm.cxx:7362
DrawFrameFormatHintId
Definition: frmfmt.hxx:261
SwFrameFormat::tLayoutDir meLayoutDir
Definition: frmfmt.hxx:362
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes
Definition: frmfmt.hxx:71
virtual bool IsBackgroundTransparent() const
SwFormat::IsBackgroundTransparent.
Definition: format.cxx:728
WW8AnchorConv m_eHoriConv
Definition: frmfmt.hxx:307
virtual bool supportsFullDrawingLayerFillAttributeSet() const
Definition: format.cxx:375
virtual ~ContactChangedHint() override
Definition: atrfrm.cxx:3403
const SdrObject * FindRealSdrObject() const
Definition: frmfmt.hxx:148
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir)
Definition: atrfrm.cxx:2822
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:138
virtual void SetLayoutDir(const SwFrameFormat::tLayoutDir _eLayoutDir)
Definition: atrfrm.cxx:2812
DrawFrameFormatHintId m_eId
Definition: frmfmt.hxx:273
OUString m_sSdrObjectCachedComment
Definition: frmfmt.hxx:357
void CheckAnchoredFlyConsistency(SwDoc const &rDoc)
Definition: atrfrm.cxx:3603
css::uno::WeakReference< css::uno::XInterface > m_wXObject
Definition: frmfmt.hxx:68