Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sw / dcontact.hxx
blob2b7a8cfac5fa28629e1da6af14803adbf61e6874
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.7 $
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 #ifndef _SVDOBJ_HXX //autogen
34 #include <bf_svx/svdobj.hxx>
35 #endif
36 // OD 14.05.2003 #108784#
37 #ifndef _SVDOVIRT_HXX
38 #include <bf_svx/svdovirt.hxx>
39 #endif
41 // OD 17.06.2003 #108784#
42 #include <list>
44 #include "calbck.hxx"
45 namespace binfilter {
47 class SfxPoolItem;
49 class SwFrmFmt;
50 class SwFlyFrmFmt;
51 class SwDrawFrmFmt;
52 class SwFlyFrm;
53 class SwFrm;
54 class SwPageFrm;
55 class SwVirtFlyDrawObj;
56 class SwFmtAnchor;
57 class SwFlyDrawObj;
58 class SwRect;
59 // OD 17.06.2003 #108784# - forward declaration for class <SwDrawVirtObj>
60 class SwDrawContact;
62 //Der Umgekehrte Weg: Sucht das Format zum angegebenen Objekt.
63 //Wenn das Object ein SwVirtFlyDrawObj ist so wird das Format von
64 //selbigem besorgt.
65 //Anderfalls ist es eben ein einfaches Zeichenobjekt. Diese hat einen
66 //UserCall und der ist Client vom gesuchten Format.
67 //Implementierung in dcontact.cxx
68 SwFrmFmt *FindFrmFmt( SdrObject *pObj );
69 inline const SwFrmFmt *FindFrmFmt( const SdrObject *pObj )
70 { return ::binfilter::FindFrmFmt( (SdrObject*)pObj ); }
71 sal_Bool HasWrap( const SdrObject* pObj );
73 //Bei Aenderungen das Objekt aus dem ContourCache entfernen.
74 //Implementierung in TxtFly.Cxx
75 void ClrContourCache( const SdrObject *pObj );
77 // liefert BoundRect inklusive Abstand
78 SwRect GetBoundRect( const SdrObject* pObj );
80 // Moves a SdrObj so that it fits to a given frame
81 void CaptureDrawObj( SdrObject& rObj, const SwRect& rFrm );
83 //Liefert den UserCall ggf. vom Gruppenobjekt
84 SdrObjUserCall* GetUserCall( const SdrObject* );
86 // liefert TRUE falls das SrdObject ein Marquee-Object (Lauftext) ist
87 FASTBOOL IsMarqueeTextObj( const SdrObject& rObj );
89 //Basisklasse fuer die folgenden KontaktObjekte (Rahmen+Zeichenobjekte)
90 class SwContact : public SdrObjUserCall, public SwClient
92 SdrObject *pMasterObj;
93 public:
94 TYPEINFO();
96 //Fuer den Reader, es wir nur die Verbindung hergestellt.
97 SwContact( SwFrmFmt *pToRegisterIn, SdrObject *pObj );
98 SwContact( SwModify *pToRegisterIn ) : SwClient( pToRegisterIn ){}
100 // OD 13.05.2003 #108784# - made methods virtual and not inline
101 virtual const SdrObject *GetMaster() const;
102 virtual SdrObject *GetMaster();
103 virtual void SetMaster( SdrObject* pNew );
105 virtual ~SwContact();
107 SwFrmFmt *GetFmt(){ return (SwFrmFmt*)GetRegisteredIn(); }
108 const SwFrmFmt *GetFmt() const
109 { return (const SwFrmFmt*)GetRegisteredIn(); }
113 //KontactObjekt fuer die Verbindung zwischen Rahmen bzw. deren Formaten
114 //im StarWriter (SwClient) und den Zeichenobjekten des Drawing (SdrObjUserCall)
116 class SwFlyDrawContact : public SwContact
118 public:
119 TYPEINFO();
121 //Legt das DrawObjekt an und meldet es beim Model an.
122 SwFlyDrawContact( SwFlyFrmFmt *pToRegisterIn, SdrModel *pMod );
123 SwFlyDrawContact( SwFrmFmt *pToRegisterIn, SdrObject *pObj ):
124 SwContact( pToRegisterIn, pObj ){}
126 SwVirtFlyDrawObj *CreateNewRef( SwFlyFrm *pFly );
128 // virtuelle Methoden von SwClient
129 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
133 // OD 16.05.2003 #108784# - new class for re-direct methods calls at a 'virtual'
134 // drawing object to its referenced object.
135 class SwDrawVirtObj : public SdrVirtObj
137 private:
138 // data for connection to writer layout
139 SwFrm* mpAnchorFrm;
140 SwPageFrm* mpPageFrm;
142 // #108784#
143 // implement a real offset for this object since the anchor pos will be
144 // needed, too.
145 Point maOffset;
147 // writer-drawing contact object the 'virtual' drawing object is controlled by.
148 // This object is also the <UserCall> of the drawing object, if it's
149 // inserted into the drawing layer.
150 SwDrawContact& mrDrawContact;
152 public:
153 TYPEINFO();
155 SwDrawVirtObj( SdrObject& _rNewObj,
156 SwDrawContact& _rDrawContact );
157 virtual ~SwDrawVirtObj();
159 // access to offset
160 void SetOffset( const Point& rNewOffset );
161 // OD 30.06.2003 #108784# - virtual!!!
162 virtual const Point GetOffset() const;
164 virtual SdrObject* Clone() const;
165 virtual void operator=( const SdrObject& rObj );
167 // connection to writer layout
168 void SetAnchorFrm( SwFrm* _pNewAnchorFrm );
169 SwFrm* GetAnchorFrm() const;
170 void SetPageFrm( SwPageFrm* _pNewPageFrm );
171 SwPageFrm* GetPageFrm() const;
172 void RemoveFromWriterLayout();
174 // connection to drawing layer
175 void AddToDrawingPage();
176 void RemoveFromDrawingPage();
178 // is 'virtual' drawing object connected to writer layout and
179 // to drawing layer.
180 bool IsConnected() const;
182 // OD 19.06.2003 #108784# - adjust the relative postion of the 'virtual'
183 // drawing object to the reference object
184 void AdjustRelativePosToReference();
186 // #108784#
187 // All overloaded methods which need to use the offset to move
188 // the object position virtually.
189 virtual void NbcSetRelativePos(const Point& rPnt);
190 virtual void NbcSetAnchorPos(const Point& rPnt);
192 // #108784#
193 // All overloaded methods which need to use the offset
194 virtual const Rectangle& GetBoundRect() const;
195 virtual void RecalcBoundRect();
196 virtual FASTBOOL Paint(ExtOutputDevice& rOut, const SdrPaintInfoRec& rInfoRec) const;
197 virtual SdrObject* CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const;
198 virtual void TakeXorPoly(XPolyPolygon& rPoly, FASTBOOL bDetail) const;
199 virtual void TakeContour(XPolyPolygon& rPoly) const;
200 virtual SdrHdl* GetHdl(USHORT nHdlNum) const;
201 virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, USHORT nPlNum) const;
202 virtual void NbcMove(const Size& rSiz);
203 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
204 virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
205 virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
206 virtual void NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear);
207 virtual void Move(const Size& rSiz);
208 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
209 virtual void Rotate(const Point& rRef, long nWink, double sn, double cs);
210 virtual void Mirror(const Point& rRef1, const Point& rRef2);
211 virtual void Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear);
212 virtual void RecalcSnapRect();
213 virtual const Rectangle& GetSnapRect() const;
214 virtual void SetSnapRect(const Rectangle& rRect);
215 virtual void NbcSetSnapRect(const Rectangle& rRect);
216 virtual const Rectangle& GetLogicRect() const;
217 virtual void SetLogicRect(const Rectangle& rRect);
218 virtual void NbcSetLogicRect(const Rectangle& rRect);
219 virtual Point GetSnapPoint(USHORT i) const;
220 virtual const Point& GetPoint(USHORT i) const;
221 virtual void NbcSetPoint(const Point& rPnt, USHORT i);
223 // #108784#
224 virtual FASTBOOL HasTextEdit() const;
226 // OD 17.06.2003 #108784# - overload 'layer' methods
227 virtual SdrLayerID GetLayer() const;
228 virtual void NbcSetLayer(SdrLayerID nLayer);
229 virtual void SetLayer(SdrLayerID nLayer);
232 // OD 26.06.2003 #108784#
233 bool CheckControlLayer( const SdrObject *pObj );
235 //KontactObjekt fuer die Verbindung von Formaten als Repraesentanten der
236 //Zeichenobjekte im StarWriter (SwClient) und den Objekten selbst im Drawing
237 //(SdrObjUserCall).
239 class SwDrawContact : public SwContact
241 private:
242 SwFrm *pAnchor;
243 SwPageFrm *pPage;
245 // OD 16.05.2003 #108784# - data structure for collecting 'virtual'
246 // drawing object supporting drawing objects in headers/footers.
247 std::list<SwDrawVirtObj*> maDrawVirtObjs;
249 // unary function used by <list> iterator to find a disconnected 'virtual'
250 // drawing object
251 struct UsedOrUnusedVirtObjPred
253 bool mbUsedPred;
254 UsedOrUnusedVirtObjPred( bool _bUsed ) : mbUsedPred( _bUsed ) {};
255 bool operator() ( const SwDrawVirtObj* _pDrawVirtObj )
257 if ( mbUsedPred )
259 return _pDrawVirtObj->IsConnected();
261 else
263 return !_pDrawVirtObj->IsConnected();
268 // unary function used by <list> iterator to find a 'virtual' drawing
269 // object anchored at a given frame
270 struct VirtObjAnchoredAtFrmPred
272 const SwFrm& mrAnchorFrm;
273 VirtObjAnchoredAtFrmPred( const SwFrm& _rAnchorFrm ) : mrAnchorFrm( _rAnchorFrm ) {};
274 bool operator() ( const SwDrawVirtObj* _pDrawVirtObj )
276 return ( _pDrawVirtObj->GetAnchorFrm() == &mrAnchorFrm );
280 // OD 16.05.2003 #108784# - method for adding/removing 'virtual' drawing object.
281 SwDrawVirtObj* CreateVirtObj();
282 void DestroyVirtObj( SwDrawVirtObj* pVirtObj );
283 void RemoveAllVirtObjs();
285 public:
286 TYPEINFO();
288 SwDrawContact( SwFrmFmt *pToRegisterIn, SdrObject *pObj );
289 virtual ~SwDrawContact();
291 const SwPageFrm *GetPage() const { return pPage; }
292 SwPageFrm *GetPage() { return pPage; }
293 const SwFrm *GetAnchor() const { return pAnchor; }
294 SwFrm *GetAnchor() { return pAnchor; }
295 void ChgAnchor( SwFrm *pNew ) { pAnchor = pNew; }
296 void ChgPage ( SwPageFrm *pNew){ pPage = pNew; }
298 void ChkPage(); //Muss immer nach SetAnchorPos() gerufen
299 //werden. Das Objekt haengt sich dann an
300 //die richtige Seite.
301 SwPageFrm* FindPage( const SwRect &rRect );
303 //Fuegt das SdrObject in die Arrays (SwPageFrm und SwFrm) des Layouts ein.
304 //Der Anker wird Anhand des Attributes SwFmtAnchor bestimmt.
305 //Das Objekt wird ggf. beim alten Anker abgemeldet.
306 void ConnectToLayout( const SwFmtAnchor *pAnch = 0 );
308 void DisconnectFromLayout( bool _bMoveMasterToInvisibleLayer = true );
309 // OD 19.06.2003 #108784# - disconnect for a dedicated drawing object -
310 // could be 'master' or 'virtual'.
311 void DisconnectObjFromLayout( SdrObject* _pDrawObj );
312 // OD 26.06.2003 #108784# - method to remove 'master' drawing object
313 // from drawing page.
314 // To be used by the undo for delete of object. Call it after method
315 // <DisconnectFromLayout( bool = true )> is already performed.
316 // Note: <DisconnectFromLayout( bool )> no longer removes the 'master'
317 // drawing object from drawing page.
318 void RemoveMasterFromDrawPage();
320 // OD 16.05.2003 #108784# - overload in order to perform work for 'virtual'
321 // drawing object
322 virtual void SetMaster( SdrObject* pNew );
323 // OD 19.06.2003 #108784# - get drawing object ('master' or 'virtual')
324 // by frame.
325 SdrObject* GetDrawObjectByAnchorFrm( const SwFrm& _rAnchorFrm );
327 // virtuelle Methoden von SwClient
328 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
330 // virtuelle Methoden von SdrObjUserCall
331 virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& rOldBoundRect);
333 // wird von Changed() und auch vom UndoDraw benutzt, uebernimmt
334 // das Notifien von Absaetzen, die ausweichen muessen
335 void _Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle* pOldBoundRect);
337 //Moved alle SW-Verbindungen zu dem neuen Master.
339 // OD 19.06.2003 #108784#
340 SwDrawVirtObj* AddVirtObj();
342 // OD 20.06.2003 #108784#
343 void CorrectRelativePosOfVirtObjs();
344 void MoveOffsetOfVirtObjs( const Size& _rMoveSize );
345 void InvalidateAnchorOfVirtObjs();
346 void NotifyBackgrdOfAllVirtObjs( const Rectangle* pOldBoundRect );
350 } //namespace binfilter
351 #endif