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 
41 namespace sw
42 {
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
48  {
50  FindSdrObjectHint(SdrObject*& rpObject) : m_rpObject(rpObject) {};
51  virtual ~FindSdrObjectHint() override;
52  };
53 }
54 class SwFrameFormats;
55 
58  : public SwFormat
59 {
60  friend class SwDoc;
61  friend class SwPageDesc;
62  friend class ::sw::DocumentLayoutManager;
63  friend class SwFrameFormats;
64  friend class SwTextBoxHelper;
65  friend class SwUndoFlyBase;
66 
67  css::uno::WeakReference<css::uno::XInterface> m_wXObject;
68 
69  // DrawingLayer FillAttributes in a preprocessed form for primitive usage
71 
72  // The assigned SwFrmFmt list.
74 
76 
77  struct change_name
78  {
79  change_name(const OUString &rName) : mName(rName) {}
80  void operator()(SwFormat *pFormat) { pFormat->m_aFormatName = mName; }
81  const OUString &mName;
82  };
83 
84 protected:
86  SwAttrPool& rPool,
87  const sal_Char* pFormatNm,
88  SwFrameFormat *pDrvdFrame,
89  sal_uInt16 nFormatWhich = RES_FRMFMT,
90  const sal_uInt16* pWhichRange = nullptr);
91 
93  SwAttrPool& rPool,
94  const OUString &rFormatNm,
95  SwFrameFormat *pDrvdFrame,
96  sal_uInt16 nFormatWhich = RES_FRMFMT,
97  const sal_uInt16* pWhichRange = nullptr);
98 
99  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) override;
100 
101  SwFrameFormat* GetOtherTextBoxFormat() const { return m_pOtherTextBoxFormat; }
102  void SetOtherTextBoxFormat( SwFrameFormat *pFormat );
103 
104 public:
105  virtual ~SwFrameFormat() override;
106 
107  SwFrameFormat(SwFrameFormat const &) = default;
108  SwFrameFormat(SwFrameFormat &&) = default;
109  SwFrameFormat & operator =(SwFrameFormat const &) = default;
110  SwFrameFormat & operator =(SwFrameFormat &&) = default;
111 
113  virtual void DelFrames();
114 
116  virtual void MakeFrames();
117 
118  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr );
119 
124  IMapObject* GetIMapObject( const Point& rPoint,
125  const SwFlyFrame *pFly = nullptr ) const;
126 
130  SwRect FindLayoutRect( const bool bPrtArea = false,
131  const Point* pPoint = nullptr ) const;
132 
138  {
139  SdrObject* pObject(nullptr);
141  return pObject;
142  }
143  const SdrObject *FindSdrObject() const
144  { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
145 
146  SdrObject *FindRealSdrObject();
148  { return const_cast<SwFrameFormat*>(this)->FindRealSdrObject(); }
149 
150  bool IsLowerOf( const SwFrameFormat& rFormat ) const;
151 
153  {
156  VERT_R2L
157  };
158 
159  virtual SwFrameFormat::tLayoutDir GetLayoutDir() const;
160  virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir );
161 
162  virtual sal_Int16 GetPositionLayoutDir() const;
163  virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
164 
165  virtual OUString GetDescription() const;
166 
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; }
171 
172  void RegisterToFormat( SwFormat& rFormat );
173 
174  // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
176  virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
177 
178  void dumpAsXml(xmlTextWriterPtr pWriter) const;
179 
180  virtual void SetName( const OUString& rNewName, bool bBroadcast=false ) override;
181 };
182 
183 // The FlyFrame-Format
184 
186 {
187  friend class SwDoc;
188  OUString msTitle;
189  OUString msDesc;
190 
196  std::unique_ptr<SwFlyDrawContact> m_pContact;
197 
198  SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
199  SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
200 
201  SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
202 
203 public:
204  virtual ~SwFlyFrameFormat() override;
205 
207  virtual void MakeFrames() override;
208 
209  SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
210 
211  SwAnchoredObject* GetAnchoredObj() const;
212 
213  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr ) override;
214 
215  virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
216 
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 );
221 
231  virtual bool IsBackgroundTransparent() const override;
232 
242  bool IsBackgroundBrushInherited() const;
243 
244  const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
245  void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
246 
247  SwFlyDrawContact* GetOrCreateContact();
248 };
249 
250 //The DrawFrame-Format
251 
252 
253 class SwDrawFrameFormat;
254 class SwDrawContact;
255 class SdrTextObj;
256 
257 namespace sw
258 {
260  DYING,
261  PREPPASTING,
265  MAKE_FRAMES,
268  };
270  {
273  virtual ~DrawFrameFormatHint() override;
274  };
276  {
278  CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer) : m_bCheckControlLayer(bCheckControlLayer) {};
279  virtual ~CheckDrawFrameFormatLayerHint() override;
280  };
282  {
284  ContactChangedHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
285  virtual ~ContactChangedHint() override;
286  };
288  {
291  DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc) : m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
292  virtual ~DrawFormatLayoutCopyHint() override;
293  };
294  enum class WW8AnchorConv
295  {
296  NO_CONV,
297  CONV2PG,
299  CONV2CHAR,
300  CONV2LINE,
302  };
303  struct WW8AnchorConvResult final
304  {
309  WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
310  };
312  {
314  WW8AnchorConvHint(WW8AnchorConvResult& rResult) : m_rResult(rResult) {};
315  virtual ~WW8AnchorConvHint() override;
316  };
318  {
319  const Point m_aPos;
320  RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
321  virtual ~RestoreFlyAnchorHint() override;
322  };
324  {
326  CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
327  virtual ~CreatePortionHint() override;
328  };
330  {
331  std::list<SdrTextObj*>& m_rTextObjects;
332  CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
333  virtual ~CollectTextObjectsHint() override;
334  };
336  {
337  sal_uInt32& m_rnZOrder;
338  GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
339  virtual ~GetZOrderHint() override;
340  };
342  {
345  GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
346  virtual ~GetObjectConnectedHint() override;
347  };
348 }
349 
351 {
352  friend class SwDoc;
353 
354  mutable const SdrObject * m_pSdrObjectCached;
355  mutable OUString m_sSdrObjectCachedComment;
356 
357  SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
358  SwDrawFrameFormat &operator=( const SwDrawFrameFormat &rCpy ) = delete;
359 
361 
363 
365 
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 ),
372 
373  mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
374 
375  mbPosAttrSet( false )
376  {}
377 
378 public:
379  virtual ~SwDrawFrameFormat() override;
380 
383  virtual void DelFrames() override;
384 
387  virtual void MakeFrames() override;
388 
389  virtual Graphic MakeGraphic( ImageMap* pMap = nullptr ) override;
390 
391  virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
392  virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
393 
394  virtual sal_Int16 GetPositionLayoutDir() const override;
395  virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
396 
397  bool IsPosAttrSet() const { return mbPosAttrSet; }
398  void PosAttrSet() { mbPosAttrSet = true; }
399 
400  virtual OUString GetDescription() const override;
401 };
402 
403 namespace sw {
404 
406 
407 void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
408 
409 }
410 
411 #endif
412 
413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwFrameFormats * m_ffList
Definition: frmfmt.hxx:73
WW8AnchorConv
Definition: frmfmt.hxx:294
#define RES_FRMFMT
Definition: hintids.hxx:273
sal_Int16 mnPositionLayoutDir
Definition: frmfmt.hxx:362
DrawFrameFormatHintId const m_eId
Definition: frmfmt.hxx:271
CreatePortionHint(SwDrawContact **ppContact)
Definition: frmfmt.hxx:326
OUString msDesc
Definition: frmfmt.hxx:189
SdrObject ** m_ppObject
Definition: frmfmt.hxx:283
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:167
ContactChangedHint(SdrObject **ppObject)
Definition: frmfmt.hxx:284
OUString m_aFormatName
Definition: format.hxx:47
virtual OUString GetDescription() const
Definition: atrfrm.cxx:2774
Definition: doc.hxx:185
void PosAttrSet()
Definition: frmfmt.hxx:398
change_name(const OUString &rName)
Definition: frmfmt.hxx:79
void SetLastFlyFramePrtRectPos(const Point &rPoint)
Definition: frmfmt.hxx:245
bool IsPosAttrSet() const
Definition: frmfmt.hxx:397
DrawFrameFormatHint(DrawFrameFormatHintId eId)
Definition: frmfmt.hxx:272
A TextBox is a TextFrame, that is tied to a drawinglayer shape.
FindSdrObjectHint(SdrObject *&rpObject)
Definition: frmfmt.hxx:50
Dialog to specify the properties of drop-down form field.
Definition: accfrmobj.cxx:40
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:206
CollectTextObjectsHint(std::list< SdrTextObj * > &rTextObjects)
Definition: frmfmt.hxx:332
GetZOrderHint(sal_uInt32 &rnZOrder)
Definition: frmfmt.hxx:338
WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv)
Definition: frmfmt.hxx:309
SdrObject *& m_rpObject
Definition: frmfmt.hxx:49
wrapper class for the positioning of Writer fly frames and drawing objects
SwDrawFrameFormat & m_rDestFormat
Definition: frmfmt.hxx:289
WW8AnchorConv m_eVertConv
Definition: frmfmt.hxx:306
char sal_Char
RestoreFlyAnchorHint(Point aPos)
Definition: frmfmt.hxx:320
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:38
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::uno::XInterface > const &xObject)
Definition: frmfmt.hxx:169
SwFormat & operator=(const SwFormat &)
Definition: format.cxx:105
void MakeFrames(SwDoc *pDoc, const SwNodeIndex &rSttIdx, const SwNodeIndex &rEndIdx)
Definition: frmtool.cxx:1767
Specific frame formats (frames, DrawObjects).
Definition: docary.hxx:201
GetObjectConnectedHint(bool &risConnected, const SwRootFrame *pRoot)
Definition: frmfmt.hxx:345
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
struct _xmlTextWriter * xmlTextWriterPtr
Style of a layout element.
Definition: frmfmt.hxx:57
SwFrameFormat * GetOtherTextBoxFormat() const
Definition: frmfmt.hxx:101
friend class SwFrameFormat
Definition: format.hxx:45
virtual SwFrameFormat::tLayoutDir GetLayoutDir() const
Definition: atrfrm.cxx:2754
DrawFormatLayoutCopyHint(SwDrawFrameFormat &rDestFormat, SwDoc &rDestDoc)
Definition: frmfmt.hxx:291
Point m_aLastFlyFramePrtRectPos
Both not existent.
Definition: frmfmt.hxx:195
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:153
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2617
SwDrawContact ** m_ppContact
Definition: frmfmt.hxx:325
SwFrameFormat * m_pOtherTextBoxFormat
Definition: frmfmt.hxx:75
WW8AnchorConvHint(WW8AnchorConvResult &rResult)
Definition: frmfmt.hxx:314
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::list< SdrTextObj * > & m_rTextObjects
Definition: frmfmt.hxx:331
const SdrObject * m_pSdrObjectCached
Definition: frmfmt.hxx:354
const SwRootFrame * m_pRoot
Definition: frmfmt.hxx:344
SwDrawFrameFormat(SwAttrPool &rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame)
Definition: frmfmt.hxx:367
bool IsFlyFrameFormatInHeader(const SwFrameFormat &rFormat)
Definition: atrfrm.cxx:3455
sal_uInt32 & m_rnZOrder
Definition: frmfmt.hxx:337
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
OUString msTitle
Definition: frmfmt.hxx:188
#define RES_DRAWFRMFMT
Definition: hintids.hxx:277
void operator()(SwFormat *pFormat)
Definition: frmfmt.hxx:80
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: format.cxx:800
WW8AnchorConvResult & m_rResult
Definition: frmfmt.hxx:313
virtual sal_Int16 GetPositionLayoutDir() const
Definition: atrfrm.cxx:2765
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2628
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNewValue) override
Definition: format.cxx:246
const OUString & mName
Definition: frmfmt.hxx:81
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:376
SwFrameFormat & operator=(SwFrameFormat const &)=default
def text(shape, st)
CheckDrawFrameFormatLayerHint(bool *bCheckControlLayer)
Definition: frmfmt.hxx:278
const SdrObject * FindSdrObject() const
Definition: frmfmt.hxx:143
std::unique_ptr< SwFlyDrawContact > m_pContact
Definition: frmfmt.hxx:196
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:244
virtual Graphic MakeGraphic(ImageMap *pMap=nullptr)
Definition: paintfrm.cxx:7317
DrawFrameFormatHintId
Definition: frmfmt.hxx:259
SwFrameFormat::tLayoutDir meLayoutDir
Definition: frmfmt.hxx:360
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes
Definition: frmfmt.hxx:70
virtual bool IsBackgroundTransparent() const
SwFormat::IsBackgroundTransparent.
Definition: format.cxx:751
WW8AnchorConv m_eHoriConv
Definition: frmfmt.hxx:305
virtual bool supportsFullDrawingLayerFillAttributeSet() const
Definition: format.cxx:374
const SdrObject * FindRealSdrObject() const
Definition: frmfmt.hxx:147
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir)
Definition: atrfrm.cxx:2769
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:137
virtual void SetLayoutDir(const SwFrameFormat::tLayoutDir _eLayoutDir)
Definition: atrfrm.cxx:2759
OUString m_sSdrObjectCachedComment
Definition: frmfmt.hxx:355
void CheckAnchoredFlyConsistency(SwDoc const &rDoc)
Definition: atrfrm.cxx:3480
css::uno::WeakReference< css::uno::XInterface > m_wXObject
Definition: frmfmt.hxx:67