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 
77  std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats;
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  const std::shared_ptr< SwTextBoxNode >& GetOtherTextBoxFormats() const { return m_pOtherTextBoxFormats; };
106  void SetOtherTextBoxFormats(const std::shared_ptr<SwTextBoxNode>& rNew) { m_pOtherTextBoxFormats = rNew; };
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;
195  OUString msTooltip;
196 
202  std::unique_ptr<SwFlyDrawContact> m_pContact;
203 
204  SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
205  SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
206 
207  SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
208 
209 public:
210  virtual ~SwFlyFrameFormat() override;
211 
213  virtual void MakeFrames() override;
214 
215  SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
216 
217  SwAnchoredObject* GetAnchoredObj() const;
218 
219  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
220 
221  virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
222 
223  OUString GetObjTitle() const;
224  void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
225 
226  const OUString & GetObjTooltip() const;
227  void SetObjTooltip(const OUString& rTooltip);
228 
229  OUString GetObjDescription() const;
230  void SetObjDescription( const OUString& rDescription, bool bBroadcast = false );
231 
241  virtual bool IsBackgroundTransparent() const override;
242 
252  bool IsBackgroundBrushInherited() const;
253 
254  const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
255  void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
256 
257  SwFlyDrawContact* GetOrCreateContact();
258 };
259 
260 //The DrawFrame-Format
261 
262 
263 class SwDrawFrameFormat;
264 class SwDrawContact;
265 class SdrTextObj;
266 
267 namespace sw
268 {
270  DYING,
271  PREPPASTING,
275  MAKE_FRAMES,
278  };
280  {
283  virtual ~DrawFrameFormatHint() override;
284  };
286  {
288  CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer) : m_bCheckControlLayer(bCheckControlLayer) {};
289  virtual ~CheckDrawFrameFormatLayerHint() override;
290  };
292  {
294  ContactChangedHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
295  virtual ~ContactChangedHint() override;
296  };
298  {
301  DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc) : m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
302  virtual ~DrawFormatLayoutCopyHint() override;
303  };
304  enum class WW8AnchorConv
305  {
306  NO_CONV,
307  CONV2PG,
309  CONV2CHAR,
310  CONV2LINE,
312  };
313  struct WW8AnchorConvResult final
314  {
319  WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
320  };
322  {
324  WW8AnchorConvHint(WW8AnchorConvResult& rResult) : m_rResult(rResult) {};
325  virtual ~WW8AnchorConvHint() override;
326  };
328  {
329  const Point m_aPos;
330  RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
331  virtual ~RestoreFlyAnchorHint() override;
332  };
333  struct CreatePortionHint final : SfxHint
334  {
336  CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
337  virtual ~CreatePortionHint() override;
338  };
340  {
341  std::list<SdrTextObj*>& m_rTextObjects;
342  CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
343  virtual ~CollectTextObjectsHint() override;
344  };
345  struct GetZOrderHint final : SfxHint
346  {
347  sal_uInt32& m_rnZOrder;
348  GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
349  virtual ~GetZOrderHint() override;
350  };
352  {
355  GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
356  virtual ~GetObjectConnectedHint() override;
357  };
358 }
359 
361 {
362  friend class SwDoc;
363 
364  mutable const SdrObject * m_pSdrObjectCached;
365  mutable OUString m_sSdrObjectCachedComment;
366 
367  SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
368  SwDrawFrameFormat &operator=( const SwDrawFrameFormat &rCpy ) = delete;
369 
371 
373 
375 
376  SwDrawFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm,
377  SwFrameFormat *pDrvdFrame )
378  : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_DRAWFRMFMT ),
379  m_pSdrObjectCached(nullptr),
380  meLayoutDir( SwFrameFormat::HORI_L2R ),
381 
382  mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
383 
384  mbPosAttrSet( false )
385  {}
386 
387 public:
388  virtual ~SwDrawFrameFormat() override;
389 
392  virtual void DelFrames() override;
393 
396  virtual void MakeFrames() override;
397 
398  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
399 
400  virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
401  virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
402 
403  virtual sal_Int16 GetPositionLayoutDir() const override;
404  virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
405 
406  bool IsPosAttrSet() const { return mbPosAttrSet; }
407  void PosAttrSet() { mbPosAttrSet = true; }
408 
409  virtual OUString GetDescription() const override;
410 };
411 
412 namespace sw {
413 
415 
416 void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
417 
418 }
419 
420 #endif
421 
422 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~DrawFormatLayoutCopyHint() override
Definition: atrfrm.cxx:3442
SwFrameFormats * m_ffList
Definition: frmfmt.hxx:75
WW8AnchorConv
Definition: frmfmt.hxx:304
sal_Int16 mnPositionLayoutDir
Definition: frmfmt.hxx:372
CreatePortionHint(SwDrawContact **ppContact)
Definition: frmfmt.hxx:336
virtual ~CheckDrawFrameFormatLayerHint() override
Definition: atrfrm.cxx:3440
OUString msDesc
Definition: frmfmt.hxx:193
SdrObject ** m_ppObject
Definition: frmfmt.hxx:293
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:170
virtual ~GetZOrderHint() override
Definition: atrfrm.cxx:3448
ContactChangedHint(SdrObject **ppObject)
Definition: frmfmt.hxx:294
OUString m_aFormatName
Definition: format.hxx:50
virtual OUString GetDescription() const
Definition: atrfrm.cxx:2852
Definition: doc.hxx:187
void PosAttrSet()
Definition: frmfmt.hxx:407
change_name(const OUString &rName)
Definition: frmfmt.hxx:81
void SetLastFlyFramePrtRectPos(const Point &rPoint)
Definition: frmfmt.hxx:255
bool IsPosAttrSet() const
Definition: frmfmt.hxx:406
DrawFrameFormatHint(DrawFrameFormatHintId eId)
Definition: frmfmt.hxx:282
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:3445
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:161
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 >)
CollectTextObjectsHint(std::list< SdrTextObj * > &rTextObjects)
Definition: frmfmt.hxx:342
GetZOrderHint(sal_uInt32 &rnZOrder)
Definition: frmfmt.hxx:348
WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv)
Definition: frmfmt.hxx:319
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:299
virtual ~RestoreFlyAnchorHint() override
Definition: atrfrm.cxx:3444
WW8AnchorConv m_eVertConv
Definition: frmfmt.hxx:316
RestoreFlyAnchorHint(Point aPos)
Definition: frmfmt.hxx:330
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:41
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: format.cxx:225
virtual ~CollectTextObjectsHint() override
Definition: atrfrm.cxx:3447
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:103
void MakeFrames(SwDoc *pDoc, const SwNodeIndex &rSttIdx, const SwNodeIndex &rEndIdx)
Definition: frmtool.cxx:2014
Specific frame formats (frames, DrawObjects).
GetObjectConnectedHint(bool &risConnected, const SwRootFrame *pRoot)
Definition: frmfmt.hxx:355
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
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:7590
friend class SwFrameFormat
Definition: format.hxx:48
virtual SwFrameFormat::tLayoutDir GetLayoutDir() const
Definition: atrfrm.cxx:2832
DrawFormatLayoutCopyHint(SwDrawFrameFormat &rDestFormat, SwDoc &rDestDoc)
Definition: frmfmt.hxx:301
Point m_aLastFlyFramePrtRectPos
Both not existent.
Definition: frmfmt.hxx:201
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:144
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2695
SwDrawContact ** m_ppContact
Definition: frmfmt.hxx:335
WW8AnchorConvHint(WW8AnchorConvResult &rResult)
Definition: frmfmt.hxx:324
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::list< SdrTextObj * > & m_rTextObjects
Definition: frmfmt.hxx:341
virtual ~DrawFrameFormatHint() override
Definition: atrfrm.cxx:3439
const SdrObject * m_pSdrObjectCached
Definition: frmfmt.hxx:364
const SwRootFrame * m_pRoot
Definition: frmfmt.hxx:354
SwDrawFrameFormat(SwAttrPool &rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame)
Definition: frmfmt.hxx:376
bool IsFlyFrameFormatInHeader(const SwFrameFormat &rFormat)
Definition: atrfrm.cxx:3616
sal_uInt32 & m_rnZOrder
Definition: frmfmt.hxx:347
virtual ~GetObjectConnectedHint() override
Definition: atrfrm.cxx:3449
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:753
WW8AnchorConvResult & m_rResult
Definition: frmfmt.hxx:323
virtual void GetDescription(OUString &rName) override
virtual sal_Int16 GetPositionLayoutDir() const
Definition: atrfrm.cxx:2843
std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats
Definition: frmfmt.hxx:77
void SetOtherTextBoxFormats(const std::shared_ptr< SwTextBoxNode > &rNew)
Definition: frmfmt.hxx:106
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2706
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:418
const OUString & mName
Definition: frmfmt.hxx:83
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:325
SwFrameFormat & operator=(SwFrameFormat const &)=default
CheckDrawFrameFormatLayerHint(bool *bCheckControlLayer)
Definition: frmfmt.hxx:288
const SdrObject * FindSdrObject() const
Definition: frmfmt.hxx:146
std::unique_ptr< SwFlyDrawContact > m_pContact
Definition: frmfmt.hxx:202
struct _xmlTextWriter * xmlTextWriterPtr
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:254
DrawFrameFormatHintId
Definition: frmfmt.hxx:269
SwFrameFormat::tLayoutDir meLayoutDir
Definition: frmfmt.hxx:370
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes
Definition: frmfmt.hxx:72
virtual bool IsBackgroundTransparent() const
SwFormat::IsBackgroundTransparent.
Definition: format.cxx:704
WW8AnchorConv m_eHoriConv
Definition: frmfmt.hxx:315
virtual bool supportsFullDrawingLayerFillAttributeSet() const
Definition: format.cxx:362
virtual ~ContactChangedHint() override
Definition: atrfrm.cxx:3441
const std::shared_ptr< SwTextBoxNode > & GetOtherTextBoxFormats() const
Definition: frmfmt.hxx:105
const SdrObject * FindRealSdrObject() const
Definition: frmfmt.hxx:150
OUString msTooltip
A tooltip has priority over an SwFormatURL and is not persisted to files.
Definition: frmfmt.hxx:195
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir)
Definition: atrfrm.cxx:2847
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:140
virtual void SetLayoutDir(const SwFrameFormat::tLayoutDir _eLayoutDir)
Definition: atrfrm.cxx:2837
DrawFrameFormatHintId m_eId
Definition: frmfmt.hxx:281
OUString m_sSdrObjectCachedComment
Definition: frmfmt.hxx:365
bool m_bDetectedRangeSegmentation false
void CheckAnchoredFlyConsistency(SwDoc const &rDoc)
Definition: atrfrm.cxx:3641
css::uno::WeakReference< css::uno::XInterface > m_wXObject
Definition: frmfmt.hxx:69