LibreOffice Module sw (master) 1
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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 .
18 */
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>
30#include "calbck.hxx"
33class SwFlyFrame;
34class SwFrame;
35class SwPageFrame;
37class SwFlyDrawObj;
38class SwRect;
39class SwDrawContact;
40struct SwPosition;
41class SdrTextObj;
42class SwContact;
50inline const SwFrameFormat *FindFrameFormat( const SdrObject *pObj )
51{ return ::FindFrameFormat( const_cast<SdrObject*>(pObj) ); }
52bool HasWrap( const SdrObject* pObj );
54void setContextWritingMode( SdrObject* pObj, SwFrame const * pAnchor );
63bool IsMarqueeTextObj( const SdrObject& rObj );
66class SAL_DLLPUBLIC_RTTI SwContact : public SdrObjUserCall, public SwClient
93 void MoveObjToLayer( const bool _bToVisible,
94 SdrObject* _pDrawObj );
97 void SetInDTOR();
98 virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
103 SwContact( SwFrameFormat *pToRegisterIn );
104 virtual ~SwContact() override;
106 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const = 0;
107 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) = 0;
109 virtual const SdrObject *GetMaster() const = 0;
110 virtual SdrObject *GetMaster() = 0;
112 SwFrameFormat *GetFormat() { return static_cast<SwFrameFormat*>(GetRegisteredIn()); }
114 { return static_cast<const SwFrameFormat*>(GetRegisteredIn()); }
116 bool IsInDTOR() const { return mbInDTOR;}
125 virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj );
134 virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj );
139 {
140 assert( GetFormat() );
142 return GetFormat()->GetAnchor();
143 }
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; }
152 const SwNode& GetAnchorNode() const
153 {
154 const SwNode* pNode = GetAnchorFormat().GetAnchorNode();
155 assert( pNode );
156 return *pNode;
157 }
160 virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const = 0;
165 sal_uInt32 GetMinOrdNum() const;
170 sal_uInt32 GetMaxOrdNum() const;
180 void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
181 sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame* pFly, SwFrame const& rAnchorFrame);
186 SwFlyDrawContact(SwFlyFrameFormat* pToRegisterIn, SdrModel& rTargetModel);
187 static SwVirtFlyDrawObj* CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFormat* pFormat, SwFrame const& rAnchorFrame);
188 virtual ~SwFlyDrawContact() override;
190 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const override;
191 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) override;
193 virtual const SdrObject* GetMaster() const override
194 { return const_cast<SwFlyDrawContact*>(this)->GetMaster(); };
195 virtual SdrObject* GetMaster() override;
200 virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj ) override;
201 virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj ) override;
204 virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const override;
211class SwDrawVirtObj final : public SdrVirtObj
213 private:
214 // data for connection to writer layout
227 virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
229 // protected destructor
230 virtual ~SwDrawVirtObj() override;
232 public:
234 SdrModel& rSdrModel,
235 SdrObject& _rNewObj,
236 SwDrawContact& _rDrawContact);
237 // copy constructor
238 SwDrawVirtObj(SdrModel& rSdrModel, SwDrawVirtObj const & rSource);
241 virtual Point GetOffset() const override;
243 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
248 const SwFrame* GetAnchorFrame() const;
253 void AddToDrawingPage(SwFrame const& rAnchorFrame);
258 bool IsConnected() const;
260 virtual void NbcSetAnchorPos(const Point& rPnt) override;
263 virtual void RecalcBoundRect() override;
264 virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const override;
265 virtual ::basegfx::B2DPolyPolygon TakeContour() const override;
266 virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
267 virtual void NbcMove(const Size& rSiz) override;
268 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
269 virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
270 virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
271 virtual void NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
272 virtual void Move(const Size& rSiz) override;
273 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) override;
274 virtual void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
275 virtual void Mirror(const Point& rRef1, const Point& rRef2) override;
276 virtual void Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
277 virtual void RecalcSnapRect() override;
278 virtual const tools::Rectangle& GetSnapRect() const override;
279 virtual void SetSnapRect(const tools::Rectangle& rRect) override;
280 virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
281 virtual const tools::Rectangle& GetLogicRect() const override;
282 virtual void SetLogicRect(const tools::Rectangle& rRect) override;
283 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
284 virtual Point GetSnapPoint(sal_uInt32 i) const override;
285 virtual Point GetPoint(sal_uInt32 i) const override;
286 virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i) override;
288 virtual bool HasTextEdit() const override;
290 virtual SdrLayerID GetLayer() const override;
291 virtual void NbcSetLayer(SdrLayerID nLayer) override;
292 virtual void SetLayer(SdrLayerID nLayer) override;
294 virtual void SetBoundRectDirty() override;
295 virtual const tools::Rectangle& GetCurrentBoundRect() const override;
296 virtual const tools::Rectangle& GetLastBoundRect() const override;
299bool CheckControlLayer( const SdrObject *pObj );
304class SAL_DLLPUBLIC_RTTI SwDrawContact final : public SwContact
306 private:
312 std::vector< rtl::Reference<SwDrawVirtObj> > maDrawVirtObjs;
329 friend class NestedUserCallHdl;
332 void InvalidateObjs_( const bool _bUpdateSortedObjsList = false );
334 SwDrawContact( const SwDrawContact& ) = delete;
337 virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
339 public:
341 SwDrawContact( SwFrameFormat *pToRegisterIn, SdrObject *pObj );
342 virtual ~SwDrawContact() override;
344 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const override;
345 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) override;
347 virtual const SdrObject* GetMaster() const override
348 { return const_cast<SwDrawContact*>(this)->GetMaster(); };
349 virtual SdrObject* GetMaster() override;
351 const SwFrame* GetAnchorFrame( const SdrObject* _pDrawObj = nullptr ) const;
352 SwFrame* GetAnchorFrame( SdrObject const * _pDrawObj = nullptr );
355 {
356 return maAnchoredDrawObj.GetPageFrame();
357 }
359 {
360 return maAnchoredDrawObj.GetPageFrame();
361 }
362 void ChkPage();
363 SwPageFrame* FindPage( const SwRect &rRect );
368 void ConnectToLayout( const SwFormatAnchor *pAnch = nullptr );
371 void InsertMasterIntoDrawPage();
373 void DisconnectFromLayout( bool _bMoveMasterToInvisibleLayer = true );
376 void DisconnectObjFromLayout( SdrObject* _pDrawObj );
383 void RemoveMasterFromDrawPage();
385 void RemoveAllVirtObjs();
389 SdrObject* GetDrawObjectByAnchorFrame( const SwFrame& _rAnchorFrame );
392 virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect) override;
393 virtual sal_Int32 GetPDFAnchorStructureElementId(SdrObject const& rObj) override;
397 void Changed_(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle* pOldBoundRect);
400 void ChangeMasterObject( SdrObject *pNewMaster );
402 SwDrawVirtObj* AddVirtObj(SwFrame const& rAnchorFrame);
404 void NotifyBackgroundOfAllVirtObjs( const tools::Rectangle* pOldBoundRect );
408 static void GetTextObjectsFromFormat( std::list<SdrTextObj*>&, SwDoc& );
409 virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const override;
414/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
helper class for method <SwDrawContact::Changed_(..)> for handling nested <SdrObjUserCall> events
Definition: dcontact.cxx:1019
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect)
virtual sal_Int32 GetPDFAnchorStructureElementId(SdrObject const &rObj)
class for the positioning of drawing objects
wrapper class for the positioning of Writer fly frames and drawing objects
SwPageFrame * GetPageFrame()
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:166
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:120
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:67
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
virtual SdrObject * GetMaster()=0
const SwNode & GetAnchorNode() const
Definition: dcontact.hxx:152
bool IsInDTOR() const
Definition: dcontact.hxx:116
virtual const SdrObject * GetMaster() const =0
bool ObjAnchoredAtPage() const
Definition: dcontact.hxx:146
bool ObjAnchoredAsChar() const
Definition: dcontact.hxx:150
bool ObjAnchoredAtFly() const
Definition: dcontact.hxx:147
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:210
const SwFrameFormat * GetFormat() const
Definition: dcontact.hxx:113
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: dcontact.cxx:421
virtual void GetAnchoredObjs(std::vector< SwAnchoredObject * > &_roAnchoredObjs) const =0
get data collection of anchored objects, handled by with contact
bool ObjAnchoredAtChar() const
Definition: dcontact.hxx:149
bool ObjAnchoredAtPara() const
Definition: dcontact.hxx:148
virtual void MoveObjToInvisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding invisible layer
Definition: dcontact.cxx:237
const SwFormatAnchor & GetAnchorFormat() const
some virtual helper methods for information about the object (Writer fly frame resp.
Definition: dcontact.hxx:138
bool mbInDTOR
boolean, indicating destruction of contact object important note: boolean has to be set at the beginn...
Definition: dcontact.hxx:71
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
virtual SwAnchoredObject * GetAnchoredObj(SdrObject *_pSdrObj)=0
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
Definition: doc.hxx:195
ContactObject for connection of formats as representatives of draw objects in SwClient and the object...
Definition: dcontact.hxx:305
bool mbDisconnectInProgress
internal flag to indicate that disconnect from layout is in progress
Definition: dcontact.hxx:320
SwDrawContact & operator=(const SwDrawContact &)=delete
SwAnchoredDrawObject maAnchoredDrawObj
anchored drawing object instance for the 'master' drawing object
Definition: dcontact.hxx:309
const SwPageFrame * GetPageFrame() const
Definition: dcontact.hxx:354
bool mbUserCallActive
Needed data for handling of nested <SdrObjUserCall> events in method <Changed_(..)>
Definition: dcontact.hxx:324
SdrUserCallType meEventTypeOfCurrentUserCall
event type, which is handled for <mpSdrObjHandledByCurrentUserCall>.
Definition: dcontact.hxx:327
SwDrawContact(const SwDrawContact &)=delete
virtual const SdrObject * GetMaster() const override
Definition: dcontact.hxx:347
bool mbMasterObjCleared
boolean indicating set 'master' drawing object has been cleared.
Definition: dcontact.hxx:316
SwPageFrame * GetPageFrame()
Definition: dcontact.hxx:358
std::vector< rtl::Reference< SwDrawVirtObj > > maDrawVirtObjs
container for 'virtual' drawing object supporting drawing objects in headers/footers.
Definition: dcontact.hxx:312
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object.
Definition: dcontact.hxx:212
virtual void SetLayer(SdrLayerID nLayer) override
Definition: dcontact.cxx:2683
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: dcontact.cxx:2516
virtual void RecalcBoundRect() override
All overridden methods which need to use the offset.
Definition: dcontact.cxx:2470
virtual void NbcSetLayer(SdrLayerID nLayer) override
Definition: dcontact.cxx:2677
virtual void SetSnapRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2600
virtual const tools::Rectangle & GetSnapRect() const override
Definition: dcontact.cxx:2592
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2636
virtual ::basegfx::B2DPolyPolygon TakeContour() const override
Definition: dcontact.cxx:2488
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: dcontact.cxx:2496
const SwFrame * GetAnchorFrame() const
Definition: dcontact.cxx:2322
virtual ~SwDrawVirtObj() override
Definition: dcontact.cxx:2313
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: dcontact.cxx:2436
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const override
Definition: dcontact.cxx:2317
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: dcontact.cxx:2534
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2610
SwAnchoredObject & AnchoredObj()
Definition: dcontact.hxx:247
virtual void RecalcSnapRect() override
Definition: dcontact.cxx:2586
virtual const tools::Rectangle & GetLogicRect() const override
Definition: dcontact.cxx:2618
virtual bool HasTextEdit() const override
Definition: dcontact.cxx:2665
SwFrame * AnchorFrame()
Definition: dcontact.cxx:2328
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:2278
virtual void Mirror(const Point &rRef1, const Point &rRef2) override
Definition: dcontact.cxx:2567
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true) override
Definition: dcontact.cxx:2545
void RemoveFromDrawingPage()
Definition: dcontact.cxx:2410
virtual Point GetPoint(sal_uInt32 i) const override
Definition: dcontact.cxx:2652
virtual void NbcSetPoint(const Point &rPnt, sal_uInt32 i) override
Definition: dcontact.cxx:2657
virtual void NbcMove(const Size &rSiz) override
Definition: dcontact.cxx:2511
SwDrawContact & mrDrawContact
writer-drawing contact object the 'virtual' drawing object is controlled by.
Definition: dcontact.hxx:222
void RemoveFromWriterLayout()
Definition: dcontact.cxx:2334
virtual void NbcSetAnchorPos(const Point &rPnt) override
Definition: dcontact.cxx:2428
SwDrawVirtObj(SdrModel &rSdrModel, SdrObject &_rNewObj, SwDrawContact &_rDrawContact)
Definition: dcontact.cxx:2283
virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const override
Definition: dcontact.cxx:2480
virtual void SetLogicRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2626
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: dcontact.cxx:2556
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: dcontact.cxx:2575
virtual const tools::Rectangle & GetLastBoundRect() const override
Definition: dcontact.cxx:2446
virtual void SetBoundRectDirty() override
Definition: dcontact.cxx:2465
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
Definition: dcontact.cxx:2420
virtual Point GetOffset() const override
access to offset
Definition: dcontact.cxx:2451
void AddToDrawingPage(SwFrame const &rAnchorFrame)
connection to drawing layer
Definition: dcontact.cxx:2344
const SwAnchoredObject & GetAnchoredObj() const
connection to writer layout
Definition: dcontact.hxx:246
virtual void Move(const Size &rSiz) override
Definition: dcontact.cxx:2540
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: dcontact.cxx:2522
virtual Point GetSnapPoint(sal_uInt32 i) const override
Definition: dcontact.cxx:2644
virtual SdrLayerID GetLayer() const override
Definition: dcontact.cxx:2672
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: dcontact.cxx:2528
SwAnchoredDrawObject maAnchoredDrawObj
anchored drawing object instance for the 'virtual' drawing object
Definition: dcontact.hxx:217
ContactObject for connection between frames (or their formats respectively) in SwClient and the drawo...
Definition: dcontact.hxx:177
rtl::Reference< SwFlyDrawObj > mpMasterObj
Definition: dcontact.hxx:179
virtual const SdrObject * GetMaster() const override
Definition: dcontact.hxx:193
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
Definition: fmtanchr.hxx:37
Style of a layout element.
Definition: frmfmt.hxx:62
Base class of the Writer layout elements.
Definition: frame.hxx:315
Base class of the Writer document model elements.
Definition: node.hxx:98
A page of the document layout.
Definition: pagefrm.hxx:59
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
bool IsMarqueeTextObj(const SdrObject &rObj)
Returns true if the SrdObject is a Marquee-Object (scrolling text)
Definition: dcontact.cxx:183
SwRect GetBoundRectOfAnchoredObj(const SdrObject *pObj)
returns the BoundRect inclusive distance of the object.
Definition: dcontact.cxx:155
SwContact * GetUserCall(const SdrObject *)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:172
void setContextWritingMode(SdrObject *pObj, SwFrame const *pAnchor)
Definition: dcontact.cxx:103
SW_DLLPUBLIC SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The other way round: Search format for given object.
Definition: dcontact.cxx:121
bool HasWrap(const SdrObject *pObj)
Definition: dcontact.cxx:140
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:683
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
const SwFrame * FindPage(const SwRect &rRect, const SwFrame *pPage)
Definition: frmtool.cxx:3751
Marks a position in the document model.
Definition: pam.hxx:37
Definition: swdllapi.h:28