update dev300-m57
[ooovba.git] / sw / inc / dcontact.hxx
blob8860f0e38f7b4656c4c4bef85fd816ee1940ceef
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dcontact.hxx,v $
10 * $Revision: 1.26.210.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _DCONTACT_HXX
31 #define _DCONTACT_HXX
33 #include <svx/svdobj.hxx>
34 // OD 14.05.2003 #108784#
35 #include <svx/svdovirt.hxx>
36 // OD 2004-01-16 #110582#
37 #include <swtypes.hxx>
38 #include <fmtanchr.hxx>
39 #include <frmfmt.hxx>
41 // OD 17.06.2003 #108784#
42 #include <list>
44 #include "calbck.hxx"
46 class SfxPoolItem;
47 class SwFrmFmt;
48 class SwFlyFrmFmt;
49 class SwFlyFrm;
50 class SwFrm;
51 class SwPageFrm;
52 class SwVirtFlyDrawObj;
53 class SwFmtAnchor;
54 class SwFlyDrawObj;
55 class SwRect;
56 // OD 17.06.2003 #108784# - forward declaration for class <SwDrawVirtObj>
57 class SwDrawContact;
58 // OD 2004-01-16 #110582#
59 struct SwPosition;
60 class SwIndex;
61 // OD 2004-03-25 #i26791#
62 #include <anchoreddrawobject.hxx>
64 //Der Umgekehrte Weg: Sucht das Format zum angegebenen Objekt.
65 //Wenn das Object ein SwVirtFlyDrawObj ist so wird das Format von
66 //selbigem besorgt.
67 //Anderfalls ist es eben ein einfaches Zeichenobjekt. Diese hat einen
68 //UserCall und der ist Client vom gesuchten Format.
69 //Implementierung in dcontact.cxx
70 SW_DLLPUBLIC SwFrmFmt *FindFrmFmt( SdrObject *pObj );
71 inline const SwFrmFmt *FindFrmFmt( const SdrObject *pObj )
72 { return ::FindFrmFmt( (SdrObject*)pObj ); }
73 sal_Bool HasWrap( const SdrObject* pObj );
75 void setContextWritingMode( SdrObject* pObj, SwFrm* pAnchor );
77 //Bei Aenderungen das Objekt aus dem ContourCache entfernen.
78 //Implementierung in TxtFly.Cxx
79 void ClrContourCache( const SdrObject *pObj );
81 // liefert BoundRect inklusive Abstand
82 // --> OD 2006-08-15 #i68520# - change naming
83 SwRect GetBoundRectOfAnchoredObj( const SdrObject* pObj );
84 // <--
86 //Liefert den UserCall ggf. vom Gruppenobjekt
87 // OD 2004-03-31 #i26791# - change return type
88 SwContact* GetUserCall( const SdrObject* );
90 // liefert TRUE falls das SrdObject ein Marquee-Object (Lauftext) ist
91 BOOL IsMarqueeTextObj( const SdrObject& rObj );
93 //Basisklasse fuer die folgenden KontaktObjekte (Rahmen+Zeichenobjekte)
94 class SwContact : public SdrObjUserCall, public SwClient
96 // OD 05.09.2003 #112039# - boolean, indicating destruction of contact object
97 // important note: boolean has to be set at the beginning of each destructor
98 // in the subclasses using method <SetInDTOR()>.
99 bool mbInDTOR;
101 /** method to move object to visible/invisible layer
103 OD 21.08.2003 #i18447#
104 Implementation for the public method <MoveObjToVisibleLayer(..)>
105 and <MoveObjToInvisibleLayer(..)>
106 If object is in invisble respectively visible layer, its moved to
107 the corresponding visible respectively invisible layers.
108 For group object the members are individually moved to the corresponding
109 layer, because <SdrObjGroup::GetLayer()> does return 0, if members
110 aren't on the same layer as the group object, and
111 <SdrObjGroup::SetLayer(..)|NbcSetLayer(..)> sets also the layer of
112 the members.
113 OD 2004-01-15 #110582# - moved from subclass <SwDrawContact>
115 @author OD
117 @param _bToVisible
118 input parameter - boolean indicating, if object has to be moved to
119 visible (== true) or invisible (== false) layer.
121 @param _pDrawObj
122 input parameter, which will be changed - drawing object, which will
123 change its layer.
125 void _MoveObjToLayer( const bool _bToVisible,
126 SdrObject* _pDrawObj );
128 protected:
129 // OD 05.09.2003 #112039# - accessor to set member <mbInDTOR>
130 void SetInDTOR();
132 public:
133 TYPEINFO();
135 //Fuer den Reader, es wir nur die Verbindung hergestellt.
136 SwContact( SwFrmFmt *pToRegisterIn );
137 virtual ~SwContact();
139 // OD 2004-03-29 #i26791#
140 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const = 0;
141 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj ) = 0;
143 // OD 13.05.2003 #108784# - made methods virtual and not inline
144 // OD 2004-04-01 #i26791# - made methods pure virtual
145 virtual const SdrObject *GetMaster() const = 0;
146 virtual SdrObject *GetMaster() = 0;
147 virtual void SetMaster( SdrObject* _pNewMaster ) = 0;
149 SwFrmFmt *GetFmt(){ return (SwFrmFmt*)GetRegisteredIn(); }
150 const SwFrmFmt *GetFmt() const
151 { return (const SwFrmFmt*)GetRegisteredIn(); }
153 // OD 05.09.2003 #112039# - accessor for member <mbInDTOR>
154 bool IsInDTOR() const;
156 /** method to move drawing object to corresponding visible layer
158 OD 21.08.2003 #i18447#
159 uses method <_MoveObjToLayer(..)>
160 OD 2004-01-15 #110582# - moved from subclass <SwDrawContact> and made virtual
162 @author OD
164 @param _pDrawObj
165 drawing object, which will be moved to the visible layer
167 virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj );
169 /** method to move drawing object to corresponding invisible layer
171 OD 21.08.2003 #i18447#
172 uses method <_MoveObjToLayer(..)>
173 OD 2004-01-15 #110582# - moved from subclass <SwDrawContact> and made virtual.
175 @author OD
177 @param _pDrawObj
178 drawing object, which will be moved to the visible layer
180 virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj );
182 // -------------------------------------------------------------------------
183 // OD 2004-01-16 #110582# - some virtual helper methods for information
184 // about the object (Writer fly frame resp. drawing object)
185 const SwFmtAnchor& GetAnchorFmt() const
187 ASSERT( GetFmt(),
188 "<SwContact::GetAnchorFmt()> - no frame format -> crash" );
190 return GetFmt()->GetAnchor();
193 RndStdIds GetAnchorId() const { return GetAnchorFmt().GetAnchorId(); }
194 bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_PAGE; }
195 bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; }
196 bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_CNTNT; }
197 bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AUTO_CNTNT; }
198 bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_IN_CNTNT; }
200 const SwPosition& GetCntntAnchor() const
202 ASSERT( GetAnchorFmt().GetCntntAnchor(),
203 "<SwContact::GetCntntAnchor()> - no content anchor -> crash" );
205 return *(GetAnchorFmt().GetCntntAnchor());
208 const SwIndex& GetCntntAnchorIndex() const;
210 // -------------------------------------------------------------------------
212 /** get data collection of anchored objects, handled by with contact
214 OD 2004-08-23 #110810#
216 @author
218 virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const = 0;
220 /** get minimum order number of anchored objects handled by with contact
222 OD 2004-08-24 #110810#
224 @author
226 sal_uInt32 GetMinOrdNum() const;
228 /** get maximum order number of anchored objects handled by with contact
230 OD 2004-08-24 #110810#
232 @author
234 sal_uInt32 GetMaxOrdNum() const;
237 //KontactObjekt fuer die Verbindung zwischen Rahmen bzw. deren Formaten
238 //im StarWriter (SwClient) und den Zeichenobjekten des Drawing (SdrObjUserCall)
240 class SW_DLLPUBLIC SwFlyDrawContact : public SwContact
242 private:
243 // OD 2004-04-01 #i26791#
244 SwFlyDrawObj* mpMasterObj;
246 /** method to determine new order number for new instance of <SwVirtFlyDrawObj>
248 OD 2004-08-16 #i27030#
249 Used in method <CreateNewRef(..)>.
251 @author OD
253 sal_uInt32 _GetOrdNumForNewRef( const SwFlyFrm* pFlyFrm );
255 public:
256 TYPEINFO();
258 //Legt das DrawObjekt an und meldet es beim Model an.
259 SwFlyDrawContact( SwFlyFrmFmt* pToRegisterIn, SdrModel* pMod );
260 virtual ~SwFlyDrawContact();
262 // OD 2004-03-29 #i26791#
263 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const;
264 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj );
266 // OD 2004-04-01 #i26791#
267 virtual const SdrObject* GetMaster() const;
268 virtual SdrObject* GetMaster();
269 virtual void SetMaster( SdrObject* _pNewMaster );
271 SwVirtFlyDrawObj* CreateNewRef( SwFlyFrm* pFly );
273 // virtuelle Methoden von SwClient
274 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
276 // OD 2004-01-16 #110582# - override methods to control Writer fly frames,
277 // which are linked, and to assure that all objects anchored at/inside the
278 // Writer fly frame are also made visible/invisible.
279 virtual void MoveObjToVisibleLayer( SdrObject* _pDrawObj );
280 virtual void MoveObjToInvisibleLayer( SdrObject* _pDrawObj );
282 /** get data collection of anchored objects handled by with contact
284 OD 2004-08-23 #110810#
286 @author
288 virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const;
291 // OD 16.05.2003 #108784# - new class for re-direct methods calls at a 'virtual'
292 // drawing object to its referenced object.
293 class SwDrawVirtObj : public SdrVirtObj
295 private:
296 // data for connection to writer layout
297 // OD 2004-03-25 #i26791# - anchored drawing object instance for the
298 // 'virtual' drawing object
299 SwAnchoredDrawObject maAnchoredDrawObj;
301 // writer-drawing contact object the 'virtual' drawing object is controlled by.
302 // This object is also the <UserCall> of the drawing object, if it's
303 // inserted into the drawing layer.
304 SwDrawContact& mrDrawContact;
306 using SdrVirtObj::GetPlusHdl;
308 private:
309 // AW: Need own sdr::contact::ViewContact since AnchorPos from parent is
310 // not used but something own (top left of new SnapRect minus top left
311 // of original SnapRect)
312 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
314 public:
315 TYPEINFO();
317 SwDrawVirtObj( SdrObject& _rNewObj,
318 SwDrawContact& _rDrawContact );
319 virtual ~SwDrawVirtObj();
321 // access to offset
322 // OD 30.06.2003 #108784# - virtual!!!
323 virtual const Point GetOffset() const;
325 virtual SdrObject* Clone() const;
326 virtual void operator=( const SdrObject& rObj );
328 // connection to writer layout
329 // OD 2004-03-29 #i26791#
330 const SwAnchoredObject* GetAnchoredObj() const;
331 SwAnchoredObject* AnchoredObj();
332 const SwFrm* GetAnchorFrm() const;
333 SwFrm* AnchorFrm();
334 void RemoveFromWriterLayout();
336 // connection to drawing layer
337 void AddToDrawingPage();
338 void RemoveFromDrawingPage();
340 // is 'virtual' drawing object connected to writer layout and
341 // to drawing layer.
342 bool IsConnected() const;
344 virtual void NbcSetAnchorPos(const Point& rPnt);
346 // #108784#
347 // All overloaded methods which need to use the offset
348 virtual void RecalcBoundRect();
349 virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const;
350 virtual ::basegfx::B2DPolyPolygon TakeContour() const;
351 virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const;
352 virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, USHORT nPlNum) const;
353 virtual void NbcMove(const Size& rSiz);
354 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
355 virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
356 virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
357 virtual void NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear);
358 virtual void Move(const Size& rSiz);
359 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
360 virtual void Rotate(const Point& rRef, long nWink, double sn, double cs);
361 virtual void Mirror(const Point& rRef1, const Point& rRef2);
362 virtual void Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear);
363 virtual void RecalcSnapRect();
364 virtual const Rectangle& GetSnapRect() const;
365 virtual void SetSnapRect(const Rectangle& rRect);
366 virtual void NbcSetSnapRect(const Rectangle& rRect);
367 virtual const Rectangle& GetLogicRect() const;
368 virtual void SetLogicRect(const Rectangle& rRect);
369 virtual void NbcSetLogicRect(const Rectangle& rRect);
370 virtual Point GetSnapPoint(sal_uInt32 i) const;
371 virtual Point GetPoint(sal_uInt32 i) const;
372 virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i);
374 // #108784#
375 virtual FASTBOOL HasTextEdit() const;
377 // OD 17.06.2003 #108784# - overload 'layer' methods
378 virtual SdrLayerID GetLayer() const;
379 virtual void NbcSetLayer(SdrLayerID nLayer);
380 virtual void SetLayer(SdrLayerID nLayer);
382 // FullDrag support
383 virtual bool supportsFullDrag() const;
384 virtual SdrObject* getFullDragClone() const;
386 // #i97197#
387 virtual void SetBoundRectDirty();
388 virtual const Rectangle& GetCurrentBoundRect() const;
389 virtual const Rectangle& GetLastBoundRect() const;
392 // OD 26.06.2003 #108784#
393 bool CheckControlLayer( const SdrObject *pObj );
395 //KontactObjekt fuer die Verbindung von Formaten als Repraesentanten der
396 //Zeichenobjekte im StarWriter (SwClient) und den Objekten selbst im Drawing
397 //(SdrObjUserCall).
399 // --> OD 2006-01-18 #129959#
400 class NestedUserCallHdl;
401 // <--
403 class SwDrawContact : public SwContact
405 private:
406 // OD 2004-03-25 #i26791# - anchored drawing object instance for the
407 // 'master' drawing object
408 SwAnchoredDrawObject maAnchoredDrawObj;
410 // OD 16.05.2003 #108784# - data structure for collecting 'virtual'
411 // drawing object supporting drawing objects in headers/footers.
412 std::list<SwDrawVirtObj*> maDrawVirtObjs;
414 // OD 2004-04-01 #i26791# - boolean indicating set 'master' drawing
415 // object has been cleared.
416 bool mbMasterObjCleared : 1;
418 // OD 10.10.2003 #112299# - internal flag to indicate that disconnect
419 // from layout is in progress
420 bool mbDisconnectInProgress : 1;
422 // --> OD 2006-01-18 #129959#
423 // Needed data for handling of nested <SdrObjUserCall> events in
424 // method <_Changed(..)>
425 bool mbUserCallActive : 1;
426 // event type, which is handled for <mpSdrObjHandledByCurrentUserCall>.
427 // Note: value only valid, if <mbUserCallActive> is TRUE.
428 SdrUserCallType meEventTypeOfCurrentUserCall;
430 friend class NestedUserCallHdl;
431 // <--
433 // unary function used by <list> iterator to find a disconnected 'virtual'
434 // drawing object
435 struct UsedOrUnusedVirtObjPred
437 bool mbUsedPred;
438 UsedOrUnusedVirtObjPred( bool _bUsed ) : mbUsedPred( _bUsed ) {};
439 bool operator() ( const SwDrawVirtObj* _pDrawVirtObj )
441 if ( mbUsedPred )
443 return _pDrawVirtObj->IsConnected();
445 else
447 return !_pDrawVirtObj->IsConnected();
452 // unary function used by <list> iterator to find a 'virtual' drawing
453 // object anchored at a given frame
454 struct VirtObjAnchoredAtFrmPred
456 const SwFrm* mpAnchorFrm;
457 VirtObjAnchoredAtFrmPred( const SwFrm& _rAnchorFrm );
458 bool operator() ( const SwDrawVirtObj* _pDrawVirtObj );
461 // OD 16.05.2003 #108784# - method for adding/removing 'virtual' drawing object.
462 SwDrawVirtObj* CreateVirtObj();
463 void DestroyVirtObj( SwDrawVirtObj* pVirtObj );
464 void RemoveAllVirtObjs();
466 // OD 2004-03-31 #i26791#
467 void _InvalidateObjs( const bool _bUpdateSortedObjsList = false );
469 // --> OD 2006-01-23 #124157#
470 // no copy-constructor and no assignment operator
471 SwDrawContact( const SwDrawContact& );
472 SwDrawContact& operator=( const SwDrawContact& );
473 // <--
474 public:
475 TYPEINFO();
477 SwDrawContact( SwFrmFmt *pToRegisterIn, SdrObject *pObj );
478 virtual ~SwDrawContact();
480 // OD 2004-03-29 #i26791#
481 // --> OD 2005-01-06 #i30669# - no default value for parameter <_pSdrObj>
482 virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const;
483 virtual SwAnchoredObject* GetAnchoredObj( SdrObject* _pSdrObj );
484 // <--
486 // OD 2004-04-01 #i26791#
487 virtual const SdrObject* GetMaster() const;
488 virtual SdrObject* GetMaster();
489 virtual void SetMaster( SdrObject* _pNewMaster );
491 // OD 2004-03-29 #i26791#
492 const SwFrm* GetAnchorFrm( const SdrObject* _pDrawObj = 0L ) const;
493 SwFrm* GetAnchorFrm( SdrObject* _pDrawObj = 0L );
495 // --> OD 2004-06-30 #i28701# - page frame is now stored at member <maAnchoredDrawObj>
496 inline const SwPageFrm* GetPageFrm() const
498 return maAnchoredDrawObj.GetPageFrm();
500 inline SwPageFrm* GetPageFrm()
502 return maAnchoredDrawObj.GetPageFrm();
504 void SetPageFrm( SwPageFrm* _pNewPageFrm )
506 return maAnchoredDrawObj.SetPageFrm( _pNewPageFrm );
508 // <--
509 void ChkPage();
510 SwPageFrm* FindPage( const SwRect &rRect );
512 //Fuegt das SdrObject in die Arrays (SwPageFrm und SwFrm) des Layouts ein.
513 //Der Anker wird Anhand des Attributes SwFmtAnchor bestimmt.
514 //Das Objekt wird ggf. beim alten Anker abgemeldet.
515 void ConnectToLayout( const SwFmtAnchor *pAnch = 0 );
516 // OD 27.06.2003 #108784# - method to insert 'master' drawing object
517 // into drawing page
518 void InsertMasterIntoDrawPage();
520 void DisconnectFromLayout( bool _bMoveMasterToInvisibleLayer = true );
521 // OD 19.06.2003 #108784# - disconnect for a dedicated drawing object -
522 // could be 'master' or 'virtual'.
523 void DisconnectObjFromLayout( SdrObject* _pDrawObj );
524 // OD 26.06.2003 #108784# - method to remove 'master' drawing object
525 // from drawing page.
526 // To be used by the undo for delete of object. Call it after method
527 // <DisconnectFromLayout( bool = true )> is already performed.
528 // Note: <DisconnectFromLayout( bool )> no longer removes the 'master'
529 // drawing object from drawing page.
530 void RemoveMasterFromDrawPage();
532 // OD 19.06.2003 #108784# - get drawing object ('master' or 'virtual')
533 // by frame.
534 SdrObject* GetDrawObjectByAnchorFrm( const SwFrm& _rAnchorFrm );
536 // virtuelle Methoden von SwClient
537 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
539 // virtuelle Methoden von SdrObjUserCall
540 virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& rOldBoundRect);
542 // wird von Changed() und auch vom UndoDraw benutzt, uebernimmt
543 // das Notifien von Absaetzen, die ausweichen muessen
544 void _Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle* pOldBoundRect);
546 //Moved alle SW-Verbindungen zu dem neuen Master.
547 void ChangeMasterObject( SdrObject *pNewMaster );
549 // OD 19.06.2003 #108784#
550 SwDrawVirtObj* AddVirtObj();
552 // OD 20.06.2003 #108784#
553 void NotifyBackgrdOfAllVirtObjs( const Rectangle* pOldBoundRect );
555 /** get data collection of anchored objects, handled by with contact
557 OD 2004-08-23 #110810#
559 @author
561 virtual void GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const;
564 #endif