fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sw / inc / dcontact.hxx
blobeb02ac54bd9c10c4061ed6cb0be99a05fbc59c72
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _DCONTACT_HXX
20 #define _DCONTACT_HXX
22 #include <svx/svdobj.hxx>
23 #include <svx/svdovirt.hxx>
24 #include <swtypes.hxx>
25 #include <fmtanchr.hxx>
26 #include <frmfmt.hxx>
27 #include <list>
29 #include "calbck.hxx"
30 #include <anchoreddrawobject.hxx>
32 class SfxPoolItem;
33 class SwFrmFmt;
34 class SwFlyFrmFmt;
35 class SwFlyFrm;
36 class SwFrm;
37 class SwPageFrm;
38 class SwVirtFlyDrawObj;
39 class SwFmtAnchor;
40 class SwFlyDrawObj;
41 class SwRect;
42 class SwDrawContact;
43 struct SwPosition;
44 class SwIndex;
45 class SdrTextObj;
47 /** The other way round: Search format for given object.
48 If object is a SwVirtFlyDrawObj the format will be obtained from it.
49 If not it is a simple DrawObject. It has a UserCall which
50 is client of the format we are looking for.
51 Implementation in dcontact.cxx. */
52 SW_DLLPUBLIC SwFrmFmt *FindFrmFmt( SdrObject *pObj );
53 inline const SwFrmFmt *FindFrmFmt( const SdrObject *pObj )
54 { return ::FindFrmFmt( (SdrObject*)pObj ); }
55 sal_Bool HasWrap( const SdrObject* pObj );
57 void setContextWritingMode( SdrObject* pObj, SwFrm* pAnchor );
59 /** When changes occur remove object from ContourCache.
60 Implementation in TxtFly.cxx. */
61 void ClrContourCache( const SdrObject *pObj );
63 /// @return BoundRect plus distance.
64 SwRect GetBoundRectOfAnchoredObj( const SdrObject* pObj );
66 /// @return UserCall of goup object (if applicable).
67 SwContact* GetUserCall( const SdrObject* );
69 /// @return TRUE if the SrdObject is a Marquee object.
70 sal_Bool IsMarqueeTextObj( const SdrObject& rObj );
72 /// Base class for the following contact objects (frame + draw objects).
73 class SwContact : public SdrObjUserCall, public SwClient
75 /** boolean, indicating destruction of contact object
76 important note: boolean has to be set at the beginning of each destructor
77 in the subclasses using method <SetInDTOR()>. */
78 bool mbInDTOR;
80 /** method to move object to visible/invisible layer
82 Implementation for the public method <MoveObjToVisibleLayer(..)>
83 and <MoveObjToInvisibleLayer(..)>
84 If object is in invisble respectively visible layer, its moved to
85 the corresponding visible respectively invisible layers.
86 For group object the members are individually moved to the corresponding
87 layer, because <SdrObjGroup::GetLayer()> does return 0, if members
88 aren't on the same layer as the group object, and
89 <SdrObjGroup::SetLayer(..)|NbcSetLayer(..)> sets also the layer of
90 the members.
92 @author OD
94 @param _bToVisible
95 input parameter - boolean indicating, if object has to be moved to
96 visible (== true) or invisible (== false) layer.
98 @param _pDrawObj
99 input parameter, which will be changed - drawing object, which will
100 change its layer.
102 void _MoveObjToLayer( const bool _bToVisible,
103 SdrObject* _pDrawObj );
105 protected:
106 void SetInDTOR();
108 public:
109 TYPEINFO();
111 /// For reader. Only the connection is created.
112 SwContact( SwFrmFmt *pToRegisterIn );
113 virtual ~SwContact();
115 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const = 0;
116 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) = 0;
118 virtual const SdrObject *GetMaster() const = 0;
119 virtual SdrObject *GetMaster() = 0;
120 virtual void SetMaster( SdrObject* _pNewMaster ) = 0;
122 SwFrmFmt *GetFmt(){ return (SwFrmFmt*)GetRegisteredIn(); }
123 const SwFrmFmt *GetFmt() const
124 { return (const SwFrmFmt*)GetRegisteredIn(); }
126 bool IsInDTOR() const;
128 /** method to move drawing object to corresponding visible layer
130 uses method <_MoveObjToLayer(..)>
132 @author OD
134 @param _pDrawObj
135 drawing object, which will be moved to the visible layer
137 virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj );
139 /** method to move drawing object to corresponding invisible layer
141 uses method <_MoveObjToLayer(..)>
143 @author OD
145 @param _pDrawObj
146 drawing object, which will be moved to the visible layer
148 virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj );
150 // -------------------------------------------------------------------------
151 /** some virtual helper methods for information
152 about the object (Writer fly frame resp. drawing object) */
153 const SwFmtAnchor& GetAnchorFmt() const
155 OSL_ENSURE( GetFmt(),
156 "<SwContact::GetAnchorFmt()> - no frame format -> crash" );
158 return GetFmt()->GetAnchor();
161 RndStdIds GetAnchorId() const { return GetAnchorFmt().GetAnchorId(); }
162 bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_AT_PAGE; }
163 bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; }
164 bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_PARA; }
165 bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AT_CHAR; }
166 bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_AS_CHAR; }
168 const SwPosition& GetCntntAnchor() const
170 OSL_ENSURE( GetAnchorFmt().GetCntntAnchor(),
171 "<SwContact::GetCntntAnchor()> - no content anchor -> crash" );
173 return *(GetAnchorFmt().GetCntntAnchor());
176 const SwIndex& GetCntntAnchorIndex() const;
178 // -------------------------------------------------------------------------
180 /** get data collection of anchored objects, handled by with contact
183 virtual void GetAnchoredObjs( std::list<SwAnchoredObject*>& _roAnchoredObjs ) const = 0;
185 /** get minimum order number of anchored objects handled by with contact
188 sal_uInt32 GetMinOrdNum() const;
190 /** get maximum order number of anchored objects handled by with contact
193 sal_uInt32 GetMaxOrdNum() const;
196 /** ContactObject for connection between frames (or their formats respectively)
197 in SwClient and the drawobjects of Drawing (DsrObjUserCall). */
199 class SW_DLLPUBLIC SwFlyDrawContact : public SwContact
201 private:
202 SwFlyDrawObj* mpMasterObj;
204 protected:
205 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
207 public:
208 TYPEINFO();
210 /// Creates DrawObject and registers it with the Model.
211 SwFlyDrawContact( SwFlyFrmFmt* pToRegisterIn, SdrModel* pMod );
212 virtual ~SwFlyDrawContact();
214 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const;
215 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj );
217 virtual const SdrObject* GetMaster() const;
218 virtual SdrObject* GetMaster();
219 virtual void SetMaster( SdrObject* _pNewMaster );
221 /** override methods to control Writer fly frames,
222 which are linked, and to assure that all objects anchored at/inside the
223 Writer fly frame are also made visible/invisible. */
224 virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj );
225 virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj );
227 /** get data collection of anchored objects handled by with contact
229 virtual void GetAnchoredObjs( std::list<SwAnchoredObject*>& _roAnchoredObjs ) const;
232 /** new class for re-direct methods calls at a 'virtual'
233 drawing object to its referenced object. */
234 class SwDrawVirtObj : public SdrVirtObj
236 private:
237 // data for connection to writer layout
238 /** anchored drawing object instance for the
239 'virtual' drawing object */
240 SwAnchoredDrawObject maAnchoredDrawObj;
242 /** writer-drawing contact object the 'virtual' drawing object is controlled by.
243 This object is also the <UserCall> of the drawing object, if it's
244 inserted into the drawing layer. */
245 SwDrawContact& mrDrawContact;
247 using SdrVirtObj::GetPlusHdl;
249 protected:
250 /** AW: Need own sdr::contact::ViewContact since AnchorPos from parent is
251 not used but something own (top left of new SnapRect minus top left
252 of original SnapRect) */
253 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
255 public:
256 TYPEINFO();
258 SwDrawVirtObj( SdrObject& _rNewObj,
259 SwDrawContact& _rDrawContact );
260 virtual ~SwDrawVirtObj();
262 /// access to offset
263 virtual const Point GetOffset() const;
265 virtual SwDrawVirtObj* Clone() const;
266 SwDrawVirtObj& operator= (const SwDrawVirtObj& rObj);
268 /// connection to writer layout
269 const SwAnchoredObject* GetAnchoredObj() const;
270 SwAnchoredObject* AnchoredObj();
271 const SwFrm* GetAnchorFrm() const;
272 SwFrm* AnchorFrm();
273 void RemoveFromWriterLayout();
275 /// connection to drawing layer
276 void AddToDrawingPage();
277 void RemoveFromDrawingPage();
279 /** is 'virtual' drawing object connected to writer layout and
280 / to drawing layer. */
281 bool IsConnected() const;
283 virtual void NbcSetAnchorPos(const Point& rPnt);
285 /// All overloaded methods which need to use the offset
286 virtual void RecalcBoundRect();
287 virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const;
288 virtual ::basegfx::B2DPolyPolygon TakeContour() const;
289 virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const;
290 virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt16 nPlNum) const;
291 virtual void NbcMove(const Size& rSiz);
292 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
293 virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
294 virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
295 virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear);
296 virtual void Move(const Size& rSiz);
297 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true);
298 virtual void Rotate(const Point& rRef, long nWink, double sn, double cs);
299 virtual void Mirror(const Point& rRef1, const Point& rRef2);
300 virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear);
301 virtual void RecalcSnapRect();
302 virtual const Rectangle& GetSnapRect() const;
303 virtual void SetSnapRect(const Rectangle& rRect);
304 virtual void NbcSetSnapRect(const Rectangle& rRect);
305 virtual const Rectangle& GetLogicRect() const;
306 virtual void SetLogicRect(const Rectangle& rRect);
307 virtual void NbcSetLogicRect(const Rectangle& rRect);
308 virtual Point GetSnapPoint(sal_uInt32 i) const;
309 virtual Point GetPoint(sal_uInt32 i) const;
310 virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i);
312 virtual bool HasTextEdit() const;
314 virtual SdrLayerID GetLayer() const;
315 virtual void NbcSetLayer(SdrLayerID nLayer);
316 virtual void SetLayer(SdrLayerID nLayer);
318 /// FullDrag support
319 virtual bool supportsFullDrag() const;
320 virtual SdrObject* getFullDragClone() const;
322 virtual void SetBoundRectDirty();
323 virtual const Rectangle& GetCurrentBoundRect() const;
324 virtual const Rectangle& GetLastBoundRect() const;
327 bool CheckControlLayer( const SdrObject *pObj );
330 /** ContactObject for connection of formats as representatives of draw objects
331 in SwClient and the objects themselves in Drawing (SDrObjUserCall). */
332 class NestedUserCallHdl;
334 class SwDrawContact : public SwContact
336 private:
337 /** anchored drawing object instance for the
338 'master' drawing object */
339 SwAnchoredDrawObject maAnchoredDrawObj;
341 /** data structure for collecting 'virtual'
342 drawing object supporting drawing objects in headers/footers. */
343 std::list<SwDrawVirtObj*> maDrawVirtObjs;
345 /** boolean indicating set 'master' drawing
346 object has been cleared. */
347 bool mbMasterObjCleared : 1;
349 /** internal flag to indicate that disconnect
350 from layout is in progress */
351 bool mbDisconnectInProgress : 1;
353 /** Needed data for handling of nested <SdrObjUserCall> events in
354 method <_Changed(..)> */
355 bool mbUserCallActive : 1;
356 /** event type, which is handled for <mpSdrObjHandledByCurrentUserCall>.
357 Note: value only valid, if <mbUserCallActive> is sal_True. */
358 SdrUserCallType meEventTypeOfCurrentUserCall;
360 friend class NestedUserCallHdl;
362 /** unary function used by <list> iterator to find a disconnected 'virtual'
363 drawing object */
364 struct UsedOrUnusedVirtObjPred
366 bool mbUsedPred;
367 UsedOrUnusedVirtObjPred( bool _bUsed ) : mbUsedPred( _bUsed ) {};
368 bool operator() ( const SwDrawVirtObj* _pDrawVirtObj )
370 if ( mbUsedPred )
372 return _pDrawVirtObj->IsConnected();
374 else
376 return !_pDrawVirtObj->IsConnected();
381 /** unary function used by <list> iterator to find a 'virtual' drawing
382 object anchored at a given frame */
383 struct VirtObjAnchoredAtFrmPred
385 const SwFrm* mpAnchorFrm;
386 VirtObjAnchoredAtFrmPred( const SwFrm& _rAnchorFrm );
387 bool operator() ( const SwDrawVirtObj* _pDrawVirtObj );
390 /// method for adding/removing 'virtual' drawing object.
391 SwDrawVirtObj* CreateVirtObj();
392 void DestroyVirtObj( SwDrawVirtObj* pVirtObj );
393 void RemoveAllVirtObjs();
395 void _InvalidateObjs( const bool _bUpdateSortedObjsList = false );
397 /// no copy-constructor and no assignment operator
398 SwDrawContact( const SwDrawContact& );
399 SwDrawContact& operator=( const SwDrawContact& );
401 protected:
402 /// virtuelle Methoden von SwClient
403 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
405 public:
406 TYPEINFO();
408 SwDrawContact( SwFrmFmt *pToRegisterIn, SdrObject *pObj );
409 virtual ~SwDrawContact();
411 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const;
412 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj );
414 virtual const SdrObject* GetMaster() const;
415 virtual SdrObject* GetMaster();
416 virtual void SetMaster( SdrObject* _pNewMaster );
418 const SwFrm* GetAnchorFrm( const SdrObject* _pDrawObj = 0L ) const;
419 SwFrm* GetAnchorFrm( SdrObject* _pDrawObj = 0L );
421 inline const SwPageFrm* GetPageFrm() const
423 return maAnchoredDrawObj.GetPageFrm();
425 inline SwPageFrm* GetPageFrm()
427 return maAnchoredDrawObj.GetPageFrm();
429 void SetPageFrm( SwPageFrm* _pNewPageFrm )
431 return maAnchoredDrawObj.SetPageFrm( _pNewPageFrm );
433 void ChkPage();
434 SwPageFrm* FindPage( const SwRect &rRect );
436 /** Inserts SdrObject in the arrays of the layout ((SwPageFrm and SwFrm).
437 The anchor is determined according to the attribute SwFmtAnchor.
438 If required the object gets unregistered with the old anchor. */
439 void ConnectToLayout( const SwFmtAnchor *pAnch = 0 );
440 /** method to insert 'master' drawing object
441 into drawing page */
442 void InsertMasterIntoDrawPage();
444 void DisconnectFromLayout( bool _bMoveMasterToInvisibleLayer = true );
445 /** disconnect for a dedicated drawing object -
446 could be 'master' or 'virtual'. */
447 void DisconnectObjFromLayout( SdrObject* _pDrawObj );
448 /** method to remove 'master' drawing object
449 from drawing page.
450 To be used by the undo for delete of object. Call it after method
451 <DisconnectFromLayout( bool = true )> is already performed.
452 Note: <DisconnectFromLayout( bool )> no longer removes the 'master'
453 drawing object from drawing page. */
454 void RemoveMasterFromDrawPage();
456 /** get drawing object ('master' or 'virtual')
457 by frame. */
458 SdrObject* GetDrawObjectByAnchorFrm( const SwFrm& _rAnchorFrm );
460 /// Virtual methods of SdrObjUserCall.
461 virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& rOldBoundRect);
463 /** Used by Changed() and by UndoDraw.
464 Notifies paragraphs that have to get out of the way. */
465 void _Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle* pOldBoundRect);
467 /// Moves all SW-connections to new Master)
468 void ChangeMasterObject( SdrObject *pNewMaster );
470 SwDrawVirtObj* AddVirtObj();
472 void NotifyBackgrdOfAllVirtObjs( const Rectangle* pOldBoundRect );
474 /** get data collection of anchored objects, handled by with contact
477 static void GetTextObjectsFromFmt( std::list<SdrTextObj*>&, SwDoc* );
478 virtual void GetAnchoredObjs( std::list<SwAnchoredObject*>& _roAnchoredObjs ) const;
481 #endif
483 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */