LibreOffice Module sw (master)  1
dcontact.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_DCONTACT_HXX
20 #define INCLUDED_SW_INC_DCONTACT_HXX
21 
22 #include <svx/svdobj.hxx>
23 #include <svx/svdovirt.hxx>
24 #include "fmtanchr.hxx"
25 #include "frmfmt.hxx"
26 #include <list>
27 #include <vector>
28 #include <memory>
29 
30 #include "calbck.hxx"
31 #include "anchoreddrawobject.hxx"
32 
33 class SwFlyFrame;
34 class SwFrame;
35 class SwPageFrame;
36 class SwVirtFlyDrawObj;
37 class SwFlyDrawObj;
38 class SwRect;
39 class SwDrawContact;
40 struct SwPosition;
41 class SdrTextObj;
42 class SwContact;
43 
50 inline const SwFrameFormat *FindFrameFormat( const SdrObject *pObj )
51 { return ::FindFrameFormat( const_cast<SdrObject*>(pObj) ); }
52 bool HasWrap( const SdrObject* pObj );
53 
54 void setContextWritingMode( SdrObject* pObj, SwFrame const * pAnchor );
55 
58 
61 
63 bool IsMarqueeTextObj( const SdrObject& rObj );
64 
67 {
71  bool mbInDTOR;
72 
93  void MoveObjToLayer( const bool _bToVisible,
94  SdrObject* _pDrawObj );
95 
96 protected:
97  void SetInDTOR();
98  virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
99 
100 public:
101 
103  SwContact( SwFrameFormat *pToRegisterIn );
104  virtual ~SwContact() override;
105 
106  virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const = 0;
107  virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) = 0;
108 
109  virtual const SdrObject *GetMaster() const = 0;
110  virtual SdrObject *GetMaster() = 0;
111 
112  SwFrameFormat *GetFormat() { return static_cast<SwFrameFormat*>(GetRegisteredIn()); }
113  const SwFrameFormat *GetFormat() const
114  { return static_cast<const SwFrameFormat*>(GetRegisteredIn()); }
115 
116  bool IsInDTOR() const { return mbInDTOR;}
117 
125  virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj );
126 
134  virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj );
135 
139  {
140  assert( GetFormat() );
141 
142  return GetFormat()->GetAnchor();
143  }
144 
145  RndStdIds GetAnchorId() const { return GetAnchorFormat().GetAnchorId(); }
146  bool ObjAnchoredAtPage() const { return GetAnchorId() == RndStdIds::FLY_AT_PAGE; }
147  bool ObjAnchoredAtFly() const { return GetAnchorId() == RndStdIds::FLY_AT_FLY; }
148  bool ObjAnchoredAtPara() const { return GetAnchorId() == RndStdIds::FLY_AT_PARA; }
149  bool ObjAnchoredAtChar() const { return GetAnchorId() == RndStdIds::FLY_AT_CHAR; }
150  bool ObjAnchoredAsChar() const { return GetAnchorId() == RndStdIds::FLY_AS_CHAR; }
151 
153  {
154  assert( GetAnchorFormat().GetContentAnchor() );
155  return *(GetAnchorFormat().GetContentAnchor());
156  }
157 
159  virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const = 0;
160 
164  sal_uInt32 GetMinOrdNum() const;
165 
169  sal_uInt32 GetMaxOrdNum() const;
170 };
171 
176 {
177 private:
178  typedef std::unique_ptr< SwFlyDrawObj, SdrObjectFreeOp > SwFlyDrawObjPtr;
179 
180  SwFlyDrawObjPtr mpMasterObj;
181  void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
182  sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame* pFly);
183 
184 public:
185 
187  SwFlyDrawContact(SwFlyFrameFormat* pToRegisterIn, SdrModel& rTargetModel);
188  static SwVirtFlyDrawObj* CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFormat* pFormat);
189  virtual ~SwFlyDrawContact() override;
190 
191  virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const override;
192  virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) override;
193 
194  virtual const SdrObject* GetMaster() const override
195  { return const_cast<SwFlyDrawContact*>(this)->GetMaster(); };
196  virtual SdrObject* GetMaster() override;
197 
201  virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj ) override;
202  virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj ) override;
203 
205  virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const override;
206 };
207 
210 class SwDrawVirtObj : public SdrVirtObj
211 {
212  private:
213  // data for connection to writer layout
217 
222 
223  protected:
227  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
228 
229  // protected destructor
230  virtual ~SwDrawVirtObj() override;
231 
232  public:
234  SdrModel& rSdrModel,
235  SdrObject& _rNewObj,
236  SwDrawContact& _rDrawContact);
237 
239  virtual const Point GetOffset() const override;
240 
241  virtual SwDrawVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override;
242  SwDrawVirtObj& operator= (const SwDrawVirtObj& rObj);
243 
247  const SwFrame* GetAnchorFrame() const;
248  SwFrame* AnchorFrame();
249  void RemoveFromWriterLayout();
250 
252  void AddToDrawingPage();
253  void RemoveFromDrawingPage();
254 
257  bool IsConnected() const;
258 
259  virtual void NbcSetAnchorPos(const Point& rPnt) override;
260 
262  virtual void RecalcBoundRect() override;
263  virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const override;
264  virtual ::basegfx::B2DPolyPolygon TakeContour() const override;
265  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
266  virtual void NbcMove(const Size& rSiz) override;
267  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
268  virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) override;
269  virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
270  virtual void NbcShear(const Point& rRef, long nAngle, double tn, bool bVShear) override;
271  virtual void Move(const Size& rSiz) override;
272  virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) override;
273  virtual void Rotate(const Point& rRef, long nAngle, double sn, double cs) override;
274  virtual void Mirror(const Point& rRef1, const Point& rRef2) override;
275  virtual void Shear(const Point& rRef, long nAngle, double tn, bool bVShear) override;
276  virtual void RecalcSnapRect() override;
277  virtual const tools::Rectangle& GetSnapRect() const override;
278  virtual void SetSnapRect(const tools::Rectangle& rRect) override;
279  virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
280  virtual const tools::Rectangle& GetLogicRect() const override;
281  virtual void SetLogicRect(const tools::Rectangle& rRect) override;
282  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
283  virtual Point GetSnapPoint(sal_uInt32 i) const override;
284  virtual Point GetPoint(sal_uInt32 i) const override;
285  virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i) override;
286 
287  virtual bool HasTextEdit() const override;
288 
289  virtual SdrLayerID GetLayer() const override;
290  virtual void NbcSetLayer(SdrLayerID nLayer) override;
291  virtual void SetLayer(SdrLayerID nLayer) override;
292 
293  virtual void SetBoundRectDirty() override;
294  virtual const tools::Rectangle& GetCurrentBoundRect() const override;
295  virtual const tools::Rectangle& GetLastBoundRect() const override;
296 };
297 
298 bool CheckControlLayer( const SdrObject *pObj );
299 
303 typedef std::unique_ptr< SwDrawVirtObj, SdrObjectFreeOp > SwDrawVirtObjPtr;
304 
305 class SAL_DLLPUBLIC_RTTI SwDrawContact final : public SwContact
306 {
307  private:
311 
313  std::vector< SwDrawVirtObjPtr > maDrawVirtObjs;
314 
317  bool mbMasterObjCleared : 1;
318 
321  bool mbDisconnectInProgress : 1;
322 
325  bool mbUserCallActive : 1;
329 
330  friend class NestedUserCallHdl;
331 
332 
333  void RemoveAllVirtObjs();
334 
335  void InvalidateObjs_( const bool _bUpdateSortedObjsList = false );
336 
337  SwDrawContact( const SwDrawContact& ) = delete;
338  SwDrawContact& operator=( const SwDrawContact& ) = delete;
339 
340  virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
341 
342  public:
343 
344  SwDrawContact( SwFrameFormat *pToRegisterIn, SdrObject *pObj );
345  virtual ~SwDrawContact() override;
346 
347  virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const override;
348  virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) override;
349 
350  virtual const SdrObject* GetMaster() const override
351  { return const_cast<SwDrawContact*>(this)->GetMaster(); };
352  virtual SdrObject* GetMaster() override;
353 
354  const SwFrame* GetAnchorFrame( const SdrObject* _pDrawObj = nullptr ) const;
355  SwFrame* GetAnchorFrame( SdrObject const * _pDrawObj = nullptr );
356 
357  const SwPageFrame* GetPageFrame() const
358  {
359  return maAnchoredDrawObj.GetPageFrame();
360  }
362  {
363  return maAnchoredDrawObj.GetPageFrame();
364  }
365  void ChkPage();
366  SwPageFrame* FindPage( const SwRect &rRect );
367 
371  void ConnectToLayout( const SwFormatAnchor *pAnch = nullptr );
374  void InsertMasterIntoDrawPage();
375 
376  void DisconnectFromLayout( bool _bMoveMasterToInvisibleLayer = true );
379  void DisconnectObjFromLayout( SdrObject* _pDrawObj );
386  void RemoveMasterFromDrawPage();
387 
390  SdrObject* GetDrawObjectByAnchorFrame( const SwFrame& _rAnchorFrame );
391 
393  virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect) override;
394 
397  void Changed_(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle* pOldBoundRect);
398 
400  void ChangeMasterObject( SdrObject *pNewMaster );
401 
402  SwDrawVirtObj* AddVirtObj();
403 
404  void NotifyBackgrdOfAllVirtObjs( const tools::Rectangle* pOldBoundRect );
405 
408  static void GetTextObjectsFromFormat( std::list<SdrTextObj*>&, SwDoc* );
409  virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const override;
410 };
411 
412 #endif
413 
414 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwFrame * AnchorFrame()
Definition: dcontact.cxx:2210
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:295
SwFlyDrawObjPtr mpMasterObj
Definition: dcontact.hxx:180
SwAnchoredDrawObject maAnchoredDrawObj
anchored drawing object instance for the 'virtual' drawing object
Definition: dcontact.hxx:216
Marks a position in the document model.
Definition: pam.hxx:35
class for the positioning of drawing objects
virtual SwDrawVirtObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: dcontact.cxx:2191
std::unique_ptr< SwDrawVirtObj, SdrObjectFreeOp > SwDrawVirtObjPtr
ContactObject for connection of formats as representatives of draw objects in SwClient and the object...
Definition: dcontact.hxx:303
const SwFrame * FindPage(const SwRect &rRect, const SwFrame *pPage)
Definition: frmtool.cxx:3412
helper class for method for handling nested events ...
Definition: dcontact.cxx:1000
SdrUserCallType
virtual ~SwDrawVirtObj() override
Definition: dcontact.cxx:2179
Definition: doc.hxx:185
SwDrawVirtObj(SdrModel &rSdrModel, SdrObject &_rNewObj, SwDrawContact &_rDrawContact)
Definition: dcontact.cxx:2164
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: dcontact.cxx:2341
virtual void Move(const Size &rSiz) override
Definition: dcontact.cxx:2385
SdrUserCallType meEventTypeOfCurrentUserCall
event type, which is handled for .
Definition: dcontact.hxx:328
virtual void NbcMove(const Size &rSiz) override
Definition: dcontact.cxx:2356
bool IsInDTOR() const
Definition: dcontact.hxx:116
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:108
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwDrawContact & mrDrawContact
writer-drawing contact object the 'virtual' drawing object is controlled by.
Definition: dcontact.hxx:221
bool IsMarqueeTextObj(const SdrObject &rObj)
Returns true if the SrdObject is a Marquee-Object (scrolling text)
Definition: dcontact.cxx:187
virtual bool HasTextEdit() const override
Definition: dcontact.cxx:2510
wrapper class for the positioning of Writer fly frames and drawing objects
SwDrawVirtObj & operator=(const SwDrawVirtObj &rObj)
Definition: dcontact.cxx:2183
virtual const tools::Rectangle & GetLogicRect() const override
Definition: dcontact.cxx:2463
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: dcontact.cxx:424
bool HasWrap(const SdrObject *pObj)
Definition: dcontact.cxx:144
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: dcontact.cxx:2373
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:213
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect)
bool mbInDTOR
boolean, indicating destruction of contact object important note: boolean has to be set at the beginn...
Definition: dcontact.hxx:71
ContactObject for connection between frames (or their formats respectively) in SwClient and the drawo...
Definition: dcontact.hxx:175
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
AW: Need own sdr::contact::ViewContact since AnchorPos from parent is not used but something own (top...
Definition: dcontact.cxx:2159
void AddToDrawingPage()
connection to drawing layer
Definition: dcontact.cxx:2226
Style of a layout element.
Definition: frmfmt.hxx:57
std::unique_ptr< SwFlyDrawObj, SdrObjectFreeOp > SwFlyDrawObjPtr
Definition: dcontact.hxx:178
SwContact * GetUserCall(const SdrObject *)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:176
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: dcontact.cxx:2281
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2481
SW_DLLPUBLIC SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The other way round: Search format for given object.
Definition: dcontact.cxx:125
virtual SdrLayerID GetLayer() const override
Definition: dcontact.cxx:2517
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
virtual void SetBoundRectDirty() override
Definition: dcontact.cxx:2310
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
FlyAnchors.
Definition: fmtanchr.hxx:34
virtual void NbcShear(const Point &rRef, long nAngle, double tn, bool bVShear) override
Definition: dcontact.cxx:2379
SwPageFrame * GetPageFrame()
Definition: dcontact.hxx:361
bool ObjAnchoredAtPage() const
Definition: dcontact.hxx:146
virtual const SdrObject * GetMaster() const override
Definition: dcontact.hxx:350
const SwFrameFormat * GetFormat() const
Definition: dcontact.hxx:113
virtual const tools::Rectangle & GetLastBoundRect() const override
Definition: dcontact.cxx:2291
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
A page of the document layout.
Definition: pagefrm.hxx:40
virtual const Point GetOffset() const override
access to offset
Definition: dcontact.cxx:2296
virtual const SdrObject * GetMaster() const =0
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2455
virtual void RecalcBoundRect() override
All overridden methods which need to use the offset.
Definition: dcontact.cxx:2315
virtual void RecalcSnapRect() override
Definition: dcontact.cxx:2431
virtual void SetLogicRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2471
virtual Point GetSnapPoint(sal_uInt32 i) const override
Definition: dcontact.cxx:2489
virtual void SetLayer(SdrLayerID nLayer) override
Definition: dcontact.cxx:2528
virtual const tools::Rectangle & GetSnapRect() const override
Definition: dcontact.cxx:2437
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
virtual void Shear(const Point &rRef, long nAngle, double tn, bool bVShear) override
Definition: dcontact.cxx:2420
SwPageFrame * GetPageFrame()
virtual void Mirror(const Point &rRef1, const Point &rRef2) override
Definition: dcontact.cxx:2412
virtual void NbcSetLayer(SdrLayerID nLayer) override
Definition: dcontact.cxx:2522
const SwAnchoredObject & GetAnchoredObj() const
connection to writer layout
Definition: dcontact.hxx:245
const SwPageFrame * GetPageFrame() const
Definition: dcontact.hxx:357
virtual void NbcRotate(const Point &rRef, long nAngle, double sn, double cs) override
Definition: dcontact.cxx:2367
void RemoveFromDrawingPage()
Definition: dcontact.cxx:2255
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
Definition: dcontact.hxx:210
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true) override
Definition: dcontact.cxx:2390
bool ObjAnchoredAtFly() const
Definition: dcontact.hxx:147
bool ObjAnchoredAsChar() const
Definition: dcontact.hxx:150
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: dcontact.cxx:2361
WriterListener & operator=(WriterListener const &)=delete
std::vector< SwDrawVirtObjPtr > maDrawVirtObjs
container for 'virtual' drawing object supporting drawing objects in headers/footers.
Definition: dcontact.hxx:313
virtual void GetAnchoredObjs(std::vector< SwAnchoredObject * > &_roAnchoredObjs) const =0
get data collection of anchored objects, handled by with contact
virtual void MoveObjToInvisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding invisible layer
Definition: dcontact.cxx:240
virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const override
Definition: dcontact.cxx:2325
virtual ::basegfx::B2DPolyPolygon TakeContour() const override
Definition: dcontact.cxx:2333
void RemoveFromWriterLayout()
Definition: dcontact.cxx:2216
const SwFrame * GetAnchorFrame() const
Definition: dcontact.cxx:2204
RndStdIds
virtual void SetSnapRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2445
virtual void Rotate(const Point &rRef, long nAngle, double sn, double cs) override
Definition: dcontact.cxx:2401
virtual void NbcSetAnchorPos(const Point &rPnt) override
Definition: dcontact.cxx:2273
SwAnchoredDrawObject maAnchoredDrawObj
anchored drawing object instance for the 'master' drawing object
Definition: dcontact.hxx:310
virtual void NbcSetPoint(const Point &rPnt, sal_uInt32 i) override
Definition: dcontact.cxx:2502
void setContextWritingMode(SdrObject *pObj, SwFrame const *pAnchor)
Definition: dcontact.cxx:107
const SwFormatAnchor & GetAnchorFormat() const
some virtual helper methods for information about the object (Writer fly frame resp.
Definition: dcontact.hxx:138
SwRect GetBoundRectOfAnchoredObj(const SdrObject *pObj)
returns the BoundRect inclusive distance of the object.
Definition: dcontact.cxx:159
const SwPosition & GetContentAnchor() const
Definition: dcontact.hxx:152
bool ObjAnchoredAtPara() const
Definition: dcontact.hxx:148
virtual Point GetPoint(sal_uInt32 i) const override
Definition: dcontact.cxx:2497
bool ObjAnchoredAtChar() const
Definition: dcontact.hxx:149
SwAnchoredObject & AnchoredObj()
Definition: dcontact.hxx:246
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
Definition: dcontact.cxx:2265
virtual const SdrObject * GetMaster() const override
Definition: dcontact.hxx:194
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:662