xref: /AOO41X/main/sw/source/core/draw/dcontact.cxx (revision d3e0dd8eb215533c15e891ee35bd141abe9397ee)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include "hintids.hxx"
27cdf0e10cSrcweir #include <editeng/protitem.hxx>
28cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
29cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
30cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
31cdf0e10cSrcweir #include <svx/svdpage.hxx>
32cdf0e10cSrcweir #include <svx/svditer.hxx>
33cdf0e10cSrcweir #include <svx/fmglob.hxx>
34cdf0e10cSrcweir #include <svx/svdogrp.hxx>
35cdf0e10cSrcweir #include <svx/svdotext.hxx>
36cdf0e10cSrcweir #include <svx/svdmodel.hxx>
37cdf0e10cSrcweir #include <svx/svdpagv.hxx>
38cdf0e10cSrcweir #include <svx/svdviter.hxx>
39cdf0e10cSrcweir #include <svx/svdview.hxx>
40cdf0e10cSrcweir #include <svx/shapepropertynotifier.hxx>
41cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
42cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
43cdf0e10cSrcweir #include <fmtornt.hxx>
44cdf0e10cSrcweir #include <viewimp.hxx>
45cdf0e10cSrcweir #include <fmtsrnd.hxx>
46cdf0e10cSrcweir #include <fmtanchr.hxx>
47cdf0e10cSrcweir #include <node.hxx>
48cdf0e10cSrcweir #include <fmtcntnt.hxx>
49cdf0e10cSrcweir #include <pagefrm.hxx>
50cdf0e10cSrcweir #include <rootfrm.hxx>
51cdf0e10cSrcweir #include <frmtool.hxx>	// Notify_Background
52cdf0e10cSrcweir #include <flyfrm.hxx>
53cdf0e10cSrcweir #include <frmfmt.hxx>
54cdf0e10cSrcweir #include <dflyobj.hxx>
55cdf0e10cSrcweir #include <dcontact.hxx>
56cdf0e10cSrcweir #include <unodraw.hxx>
57cdf0e10cSrcweir #include <IDocumentDrawModelAccess.hxx>
58cdf0e10cSrcweir #include <doc.hxx>
59cdf0e10cSrcweir #include <hints.hxx>
60cdf0e10cSrcweir #include <txtfrm.hxx>
61cdf0e10cSrcweir #include <editsh.hxx>
62cdf0e10cSrcweir #include <docary.hxx>
63cdf0e10cSrcweir #include <flyfrms.hxx>
64cdf0e10cSrcweir #include <sortedobjs.hxx>
65cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
66cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
67cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofvirtobj.hxx>
68cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
69cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
70cdf0e10cSrcweir #include <com/sun/star/text/WritingMode2.hpp>
71cdf0e10cSrcweir #include <switerator.hxx>
72cdf0e10cSrcweir #include <algorithm>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir using namespace ::com::sun::star;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
TYPEINIT1(SwContact,SwClient)77cdf0e10cSrcweir TYPEINIT1( SwContact, SwClient )
78cdf0e10cSrcweir TYPEINIT1( SwFlyDrawContact, SwContact )
79cdf0e10cSrcweir TYPEINIT1( SwDrawContact, SwContact )
80cdf0e10cSrcweir 
81cdf0e10cSrcweir void setContextWritingMode( SdrObject* pObj, SwFrm* pAnchor )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     if( pObj && pAnchor )
84cdf0e10cSrcweir     {
85cdf0e10cSrcweir         short nWritingDirection = text::WritingMode2::LR_TB;
86cdf0e10cSrcweir         if( pAnchor->IsVertical() )
87cdf0e10cSrcweir         {
88cdf0e10cSrcweir             nWritingDirection = text::WritingMode2::TB_RL;
89cdf0e10cSrcweir         } else if( pAnchor->IsRightToLeft() )
90cdf0e10cSrcweir         {
91cdf0e10cSrcweir             nWritingDirection = text::WritingMode2::RL_TB;
92cdf0e10cSrcweir         }
93cdf0e10cSrcweir         pObj->SetContextWritingMode( nWritingDirection );
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir //Der Umgekehrte Weg: Sucht das Format zum angegebenen Objekt.
99cdf0e10cSrcweir //Wenn das Object ein SwVirtFlyDrawObj ist so wird das Format von
100cdf0e10cSrcweir //selbigem besorgt.
101cdf0e10cSrcweir //Anderfalls ist es eben ein einfaches Zeichenobjekt. Diese hat einen
102cdf0e10cSrcweir //UserCall und der ist Client vom gesuchten Format.
103cdf0e10cSrcweir 
FindFrmFmt(SdrObject * pObj)104cdf0e10cSrcweir SwFrmFmt *FindFrmFmt( SdrObject *pObj )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     SwFrmFmt* pRetval = 0L;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	if ( pObj->ISA(SwVirtFlyDrawObj) )
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir        pRetval = ((SwVirtFlyDrawObj*)pObj)->GetFmt();
111cdf0e10cSrcweir 	}
112cdf0e10cSrcweir 	else
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir         SwDrawContact* pContact = static_cast<SwDrawContact*>(GetUserCall( pObj ));
115cdf0e10cSrcweir         if ( pContact )
116cdf0e10cSrcweir 		{
117cdf0e10cSrcweir 			pRetval = pContact->GetFmt();
118cdf0e10cSrcweir 		}
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir /* SJ: after prior consultation with OD we decided to remove this Assertion
121cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
122cdf0e10cSrcweir     ASSERT( pRetval,
123cdf0e10cSrcweir             "<::FindFrmFmt(..)> - no frame format found for given object. Please inform OD." );
124cdf0e10cSrcweir #endif
125cdf0e10cSrcweir */
126cdf0e10cSrcweir     return pRetval;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
HasWrap(const SdrObject * pObj)129cdf0e10cSrcweir sal_Bool HasWrap( const SdrObject* pObj )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     if ( pObj )
132cdf0e10cSrcweir     {
133cdf0e10cSrcweir         const SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
134cdf0e10cSrcweir         if ( pFmt )
135cdf0e10cSrcweir         {
136cdf0e10cSrcweir             return SURROUND_THROUGHT != pFmt->GetSurround().GetSurround();
137cdf0e10cSrcweir         }
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     return sal_False;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir /*****************************************************************************
144cdf0e10cSrcweir  *
145cdf0e10cSrcweir  * GetBoundRect liefert das BoundRect _inklusive_ Abstand des Objekts.
146cdf0e10cSrcweir  *
147cdf0e10cSrcweir  *****************************************************************************/
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // --> OD 2006-08-15 #i68520# - change naming
GetBoundRectOfAnchoredObj(const SdrObject * pObj)150cdf0e10cSrcweir SwRect GetBoundRectOfAnchoredObj( const SdrObject* pObj )
151cdf0e10cSrcweir // <--
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	SwRect aRet( pObj->GetCurrentBoundRect() );
154cdf0e10cSrcweir     // --> OD 2006-08-10 #i68520# - call cache of <SwAnchoredObject>
155cdf0e10cSrcweir     SwContact* pContact( GetUserCall( pObj ) );
156cdf0e10cSrcweir     if ( pContact )
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         const SwAnchoredObject* pAnchoredObj( pContact->GetAnchoredObj( pObj ) );
159cdf0e10cSrcweir         if ( pAnchoredObj )
160cdf0e10cSrcweir         {
161cdf0e10cSrcweir             aRet = pAnchoredObj->GetObjRectWithSpaces();
162cdf0e10cSrcweir         }
163cdf0e10cSrcweir     }
164cdf0e10cSrcweir     // <--
165cdf0e10cSrcweir 	return aRet;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir //Liefert den UserCall ggf. vom Gruppenobjekt
169cdf0e10cSrcweir // OD 2004-03-31 #i26791# - change return type
GetUserCall(const SdrObject * pObj)170cdf0e10cSrcweir SwContact* GetUserCall( const SdrObject* pObj )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir     SdrObject *pTmp;
173cdf0e10cSrcweir 	while ( !pObj->GetUserCall() && 0 != (pTmp = pObj->GetUpGroup()) )
174cdf0e10cSrcweir 		pObj = pTmp;
175cdf0e10cSrcweir     ASSERT( !pObj->GetUserCall() || pObj->GetUserCall()->ISA(SwContact),
176cdf0e10cSrcweir             "<::GetUserCall(..)> - wrong type of found object user call." );
177cdf0e10cSrcweir     return static_cast<SwContact*>(pObj->GetUserCall());
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir // liefert sal_True falls das SrdObject ein Marquee-Object (Lauftext) ist
IsMarqueeTextObj(const SdrObject & rObj)181cdf0e10cSrcweir sal_Bool IsMarqueeTextObj( const SdrObject& rObj )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	SdrTextAniKind eTKind;
184cdf0e10cSrcweir 	return SdrInventor == rObj.GetObjInventor() &&
185cdf0e10cSrcweir 		OBJ_TEXT == rObj.GetObjIdentifier() &&
186cdf0e10cSrcweir 		( SDRTEXTANI_SCROLL == ( eTKind = ((SdrTextObj&)rObj).GetTextAniKind())
187cdf0e10cSrcweir 		 || SDRTEXTANI_ALTERNATE == eTKind || SDRTEXTANI_SLIDE == eTKind );
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir /*************************************************************************
191cdf0e10cSrcweir |*
192cdf0e10cSrcweir |*	SwContact, Ctor und Dtor
193cdf0e10cSrcweir |*
194cdf0e10cSrcweir |*	Ersterstellung		AMA 27.Sep.96 18:13
195cdf0e10cSrcweir |*	Letzte Aenderung	AMA 27.Sep.96
196cdf0e10cSrcweir |*
197cdf0e10cSrcweir |*************************************************************************/
198cdf0e10cSrcweir 
SwContact(SwFrmFmt * pToRegisterIn)199cdf0e10cSrcweir SwContact::SwContact( SwFrmFmt *pToRegisterIn ) :
200cdf0e10cSrcweir 	SwClient( pToRegisterIn ),
201cdf0e10cSrcweir     // OD 05.09.2003 #112039# - init member <mbInDTOR>
202cdf0e10cSrcweir     mbInDTOR( false )
203cdf0e10cSrcweir {}
204cdf0e10cSrcweir 
~SwContact()205cdf0e10cSrcweir SwContact::~SwContact()
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     // OD 05.09.2003 #112039# - set <mbInDTOR>
208cdf0e10cSrcweir     SetInDTOR();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir // OD 05.09.2003 #112039# - accessor for member <mbInDTOR>
IsInDTOR() const212cdf0e10cSrcweir bool SwContact::IsInDTOR() const
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     return mbInDTOR;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir // OD 05.09.2003 #112039# - accessor to set member <mbInDTOR>
SetInDTOR()218cdf0e10cSrcweir void SwContact::SetInDTOR()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     mbInDTOR = true;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir /** method to move drawing object to corresponding visible layer
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     OD 21.08.2003 #i18447#
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     @author OD
228cdf0e10cSrcweir */
MoveObjToVisibleLayer(SdrObject * _pDrawObj)229cdf0e10cSrcweir void SwContact::MoveObjToVisibleLayer( SdrObject* _pDrawObj )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir     // --> OD 2005-06-08 #i46297# - notify background about the arriving of
232cdf0e10cSrcweir     // the object and invalidate its position.
233cdf0e10cSrcweir     const bool bNotify( !GetFmt()->getIDocumentDrawModelAccess()->IsVisibleLayerId( _pDrawObj->GetLayer() ) );
234cdf0e10cSrcweir     // <--
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     _MoveObjToLayer( true, _pDrawObj );
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     // --> OD 2005-05-23 #i46297#
239cdf0e10cSrcweir     if ( bNotify )
240cdf0e10cSrcweir     {
241cdf0e10cSrcweir         SwAnchoredObject* pAnchoredObj = GetAnchoredObj( _pDrawObj );
242cdf0e10cSrcweir         ASSERT( pAnchoredObj,
243cdf0e10cSrcweir                 "<SwContact::MoveObjToInvisibleLayer(..)> - missing anchored object" );
244cdf0e10cSrcweir         if ( pAnchoredObj )
245cdf0e10cSrcweir         {
246cdf0e10cSrcweir             ::setContextWritingMode( _pDrawObj, pAnchoredObj->GetAnchorFrmContainingAnchPos() );
247cdf0e10cSrcweir             // Note: as-character anchored objects aren't registered at a page frame and
248cdf0e10cSrcweir             //       a notification of its background isn't needed.
249cdf0e10cSrcweir             if ( pAnchoredObj->GetPageFrm() )
250cdf0e10cSrcweir             {
251cdf0e10cSrcweir                 ::Notify_Background( _pDrawObj, pAnchoredObj->GetPageFrm(),
252cdf0e10cSrcweir                                      pAnchoredObj->GetObjRect(), PREP_FLY_ARRIVE, sal_True );
253cdf0e10cSrcweir             }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir             pAnchoredObj->InvalidateObjPos();
256cdf0e10cSrcweir         }
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir     // <--
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir /** method to move drawing object to corresponding invisible layer
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     OD 21.08.2003 #i18447#
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     @author OD
266cdf0e10cSrcweir */
MoveObjToInvisibleLayer(SdrObject * _pDrawObj)267cdf0e10cSrcweir void SwContact::MoveObjToInvisibleLayer( SdrObject* _pDrawObj )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     // --> OD 2005-06-08 #i46297# - notify background about the leaving of the object.
270cdf0e10cSrcweir     const bool bNotify( GetFmt()->getIDocumentDrawModelAccess()->IsVisibleLayerId( _pDrawObj->GetLayer() ) );
271cdf0e10cSrcweir     // <--
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     _MoveObjToLayer( false, _pDrawObj );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir     // --> OD 2005-05-19 #i46297#
276cdf0e10cSrcweir     if ( bNotify )
277cdf0e10cSrcweir     {
278cdf0e10cSrcweir         SwAnchoredObject* pAnchoredObj = GetAnchoredObj( _pDrawObj );
279cdf0e10cSrcweir         ASSERT( pAnchoredObj,
280cdf0e10cSrcweir                 "<SwContact::MoveObjToInvisibleLayer(..)> - missing anchored object" );
281cdf0e10cSrcweir         // Note: as-character anchored objects aren't registered at a page frame and
282cdf0e10cSrcweir         //       a notification of its background isn't needed.
283cdf0e10cSrcweir         if ( pAnchoredObj && pAnchoredObj->GetPageFrm() )
284cdf0e10cSrcweir         {
285cdf0e10cSrcweir             ::Notify_Background( _pDrawObj, pAnchoredObj->GetPageFrm(),
286cdf0e10cSrcweir                                  pAnchoredObj->GetObjRect(), PREP_FLY_LEAVE, sal_True );
287cdf0e10cSrcweir         }
288cdf0e10cSrcweir     }
289cdf0e10cSrcweir     // <--
290cdf0e10cSrcweir }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir /** method to move object to visible/invisible layer
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     OD 21.08.2003 #i18447#
295cdf0e10cSrcweir     implementation for the public method <MoveObjToVisibleLayer(..)>
296cdf0e10cSrcweir     and <MoveObjToInvisibleLayer(..)>
297cdf0e10cSrcweir 
298cdf0e10cSrcweir     @author OD
299cdf0e10cSrcweir */
_MoveObjToLayer(const bool _bToVisible,SdrObject * _pDrawObj)300cdf0e10cSrcweir void SwContact::_MoveObjToLayer( const bool _bToVisible,
301cdf0e10cSrcweir                                  SdrObject* _pDrawObj )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     if ( !_pDrawObj )
304cdf0e10cSrcweir     {
305cdf0e10cSrcweir         ASSERT( false, "SwDrawContact::_MoveObjToLayer(..) - no drawing object!" );
306cdf0e10cSrcweir         return;
307cdf0e10cSrcweir     }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir     if ( !GetRegisteredIn() )
310cdf0e10cSrcweir     {
311cdf0e10cSrcweir         ASSERT( false, "SwDrawContact::_MoveObjToLayer(..) - no drawing frame format!" );
312cdf0e10cSrcweir         return;
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     const IDocumentDrawModelAccess* pIDDMA = static_cast<SwFrmFmt*>(GetRegisteredInNonConst())->getIDocumentDrawModelAccess();
316cdf0e10cSrcweir     if ( !pIDDMA )
317cdf0e10cSrcweir     {
318cdf0e10cSrcweir         ASSERT( false, "SwDrawContact::_MoveObjToLayer(..) - no writer document!" );
319cdf0e10cSrcweir         return;
320cdf0e10cSrcweir     }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir     SdrLayerID nToHellLayerId =
323cdf0e10cSrcweir         _bToVisible ? pIDDMA->GetHellId() : pIDDMA->GetInvisibleHellId();
324cdf0e10cSrcweir     SdrLayerID nToHeavenLayerId =
325cdf0e10cSrcweir         _bToVisible ? pIDDMA->GetHeavenId() : pIDDMA->GetInvisibleHeavenId();
326cdf0e10cSrcweir     SdrLayerID nToControlLayerId =
327cdf0e10cSrcweir         _bToVisible ? pIDDMA->GetControlsId() : pIDDMA->GetInvisibleControlsId();
328cdf0e10cSrcweir     SdrLayerID nFromHellLayerId =
329cdf0e10cSrcweir         _bToVisible ? pIDDMA->GetInvisibleHellId() : pIDDMA->GetHellId();
330cdf0e10cSrcweir     SdrLayerID nFromHeavenLayerId =
331cdf0e10cSrcweir         _bToVisible ? pIDDMA->GetInvisibleHeavenId() : pIDDMA->GetHeavenId();
332cdf0e10cSrcweir     SdrLayerID nFromControlLayerId =
333cdf0e10cSrcweir         _bToVisible ? pIDDMA->GetInvisibleControlsId() : pIDDMA->GetControlsId();
334cdf0e10cSrcweir 
335cdf0e10cSrcweir     if ( _pDrawObj->ISA( SdrObjGroup ) )
336cdf0e10cSrcweir     {
337cdf0e10cSrcweir         // determine layer for group object
338cdf0e10cSrcweir         {
339cdf0e10cSrcweir             // proposed layer of a group object is the hell layer
340cdf0e10cSrcweir             SdrLayerID nNewLayerId = nToHellLayerId;
341cdf0e10cSrcweir             if ( ::CheckControlLayer( _pDrawObj ) )
342cdf0e10cSrcweir             {
343cdf0e10cSrcweir                 // it has to be the control layer, if one of the member
344cdf0e10cSrcweir                 // is a control
345cdf0e10cSrcweir                 nNewLayerId = nToControlLayerId;
346cdf0e10cSrcweir             }
347cdf0e10cSrcweir             else if ( _pDrawObj->GetLayer() == pIDDMA->GetHeavenId() ||
348cdf0e10cSrcweir                       _pDrawObj->GetLayer() == pIDDMA->GetInvisibleHeavenId() )
349cdf0e10cSrcweir             {
350cdf0e10cSrcweir                 // it has to be the heaven layer, if method <GetLayer()> reveals
351cdf0e10cSrcweir                 // a heaven layer
352cdf0e10cSrcweir                 nNewLayerId = nToHeavenLayerId;
353cdf0e10cSrcweir             }
354cdf0e10cSrcweir             // set layer at group object, but do *not* broadcast and
355cdf0e10cSrcweir             // no propagation to the members.
356cdf0e10cSrcweir             // Thus, call <NbcSetLayer(..)> at super class
357cdf0e10cSrcweir             _pDrawObj->SdrObject::NbcSetLayer( nNewLayerId );
358cdf0e10cSrcweir         }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         // call method recursively for group object members
361cdf0e10cSrcweir         const SdrObjList* pLst =
362cdf0e10cSrcweir                 static_cast<SdrObjGroup*>(_pDrawObj)->GetSubList();
363cdf0e10cSrcweir         if ( pLst )
364cdf0e10cSrcweir         {
365cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pLst->GetObjCount(); ++i )
366cdf0e10cSrcweir             {
367cdf0e10cSrcweir                 _MoveObjToLayer( _bToVisible, pLst->GetObj( i ) );
368cdf0e10cSrcweir             }
369cdf0e10cSrcweir         }
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir     else
372cdf0e10cSrcweir     {
373cdf0e10cSrcweir         const SdrLayerID nLayerIdOfObj = _pDrawObj->GetLayer();
374cdf0e10cSrcweir         if ( nLayerIdOfObj == nFromHellLayerId )
375cdf0e10cSrcweir         {
376cdf0e10cSrcweir             _pDrawObj->SetLayer( nToHellLayerId );
377cdf0e10cSrcweir         }
378cdf0e10cSrcweir         else if ( nLayerIdOfObj == nFromHeavenLayerId )
379cdf0e10cSrcweir         {
380cdf0e10cSrcweir             _pDrawObj->SetLayer( nToHeavenLayerId );
381cdf0e10cSrcweir         }
382cdf0e10cSrcweir         else if ( nLayerIdOfObj == nFromControlLayerId )
383cdf0e10cSrcweir         {
384cdf0e10cSrcweir             _pDrawObj->SetLayer( nToControlLayerId );
385cdf0e10cSrcweir         }
386cdf0e10cSrcweir     }
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir // -------------------------------------------------------------------------
390cdf0e10cSrcweir // OD 2004-01-16 #110582# - some virtual helper methods for information
391cdf0e10cSrcweir // about the object (Writer fly frame resp. drawing object)
392cdf0e10cSrcweir 
GetCntntAnchorIndex() const393cdf0e10cSrcweir const SwIndex& SwContact::GetCntntAnchorIndex() const
394cdf0e10cSrcweir {
395cdf0e10cSrcweir     return GetCntntAnchor().nContent;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir 
398cdf0e10cSrcweir /** get minimum order number of anchored objects handled by with contact
399cdf0e10cSrcweir 
400cdf0e10cSrcweir     OD 2004-08-24 #110810#
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     @author
403cdf0e10cSrcweir */
GetMinOrdNum() const404cdf0e10cSrcweir sal_uInt32 SwContact::GetMinOrdNum() const
405cdf0e10cSrcweir {
406cdf0e10cSrcweir     sal_uInt32 nMinOrdNum( SAL_MAX_UINT32 );
407cdf0e10cSrcweir 
408cdf0e10cSrcweir     std::list< SwAnchoredObject* > aObjs;
409cdf0e10cSrcweir     GetAnchoredObjs( aObjs );
410cdf0e10cSrcweir 
411cdf0e10cSrcweir     while ( !aObjs.empty() )
412cdf0e10cSrcweir     {
413cdf0e10cSrcweir         sal_uInt32 nTmpOrdNum = aObjs.back()->GetDrawObj()->GetOrdNum();
414cdf0e10cSrcweir 
415cdf0e10cSrcweir         if ( nTmpOrdNum < nMinOrdNum )
416cdf0e10cSrcweir         {
417cdf0e10cSrcweir             nMinOrdNum = nTmpOrdNum;
418cdf0e10cSrcweir         }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir         aObjs.pop_back();
421cdf0e10cSrcweir     }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     ASSERT( nMinOrdNum != SAL_MAX_UINT32,
424cdf0e10cSrcweir             "<SwContact::GetMinOrdNum()> - no order number found." );
425cdf0e10cSrcweir     return nMinOrdNum;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir /** get maximum order number of anchored objects handled by with contact
429cdf0e10cSrcweir 
430cdf0e10cSrcweir     OD 2004-08-24 #110810#
431cdf0e10cSrcweir 
432cdf0e10cSrcweir     @author
433cdf0e10cSrcweir */
GetMaxOrdNum() const434cdf0e10cSrcweir sal_uInt32 SwContact::GetMaxOrdNum() const
435cdf0e10cSrcweir {
436cdf0e10cSrcweir     sal_uInt32 nMaxOrdNum( 0L );
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     std::list< SwAnchoredObject* > aObjs;
439cdf0e10cSrcweir     GetAnchoredObjs( aObjs );
440cdf0e10cSrcweir 
441cdf0e10cSrcweir     while ( !aObjs.empty() )
442cdf0e10cSrcweir     {
443cdf0e10cSrcweir         sal_uInt32 nTmpOrdNum = aObjs.back()->GetDrawObj()->GetOrdNum();
444cdf0e10cSrcweir 
445cdf0e10cSrcweir         if ( nTmpOrdNum > nMaxOrdNum )
446cdf0e10cSrcweir         {
447cdf0e10cSrcweir             nMaxOrdNum = nTmpOrdNum;
448cdf0e10cSrcweir         }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir         aObjs.pop_back();
451cdf0e10cSrcweir     }
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     return nMaxOrdNum;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir // -------------------------------------------------------------------------
456cdf0e10cSrcweir 
457cdf0e10cSrcweir /*************************************************************************
458cdf0e10cSrcweir |*
459cdf0e10cSrcweir |*	SwFlyDrawContact, Ctor und Dtor
460cdf0e10cSrcweir |*
461cdf0e10cSrcweir |*	Ersterstellung		OK 23.11.94 18:13
462cdf0e10cSrcweir |*	Letzte Aenderung	MA 06. Apr. 95
463cdf0e10cSrcweir |*
464cdf0e10cSrcweir |*************************************************************************/
465cdf0e10cSrcweir 
SwFlyDrawContact(SwFlyFrmFmt * pToRegisterIn,SdrModel *)466cdf0e10cSrcweir SwFlyDrawContact::SwFlyDrawContact( SwFlyFrmFmt *pToRegisterIn, SdrModel * ) :
467cdf0e10cSrcweir 	SwContact( pToRegisterIn )
468cdf0e10cSrcweir {
469cdf0e10cSrcweir     // OD 2004-04-01 #i26791# - class <SwFlyDrawContact> contains the 'master'
470cdf0e10cSrcweir     // drawing object of type <SwFlyDrawObj> on its own.
471cdf0e10cSrcweir     mpMasterObj = new SwFlyDrawObj;
472cdf0e10cSrcweir     mpMasterObj->SetOrdNum( 0xFFFFFFFE );
473cdf0e10cSrcweir     mpMasterObj->SetUserCall( this );
474cdf0e10cSrcweir }
475cdf0e10cSrcweir 
~SwFlyDrawContact()476cdf0e10cSrcweir SwFlyDrawContact::~SwFlyDrawContact()
477cdf0e10cSrcweir {
478cdf0e10cSrcweir     if ( mpMasterObj )
479cdf0e10cSrcweir     {
480cdf0e10cSrcweir         mpMasterObj->SetUserCall( 0 );
481cdf0e10cSrcweir         if ( mpMasterObj->GetPage() )
482cdf0e10cSrcweir             mpMasterObj->GetPage()->RemoveObject( mpMasterObj->GetOrdNum() );
483cdf0e10cSrcweir         delete mpMasterObj;
484cdf0e10cSrcweir     }
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir // OD 2004-03-29 #i26791#
GetAnchoredObj(const SdrObject * _pSdrObj) const488cdf0e10cSrcweir const SwAnchoredObject* SwFlyDrawContact::GetAnchoredObj( const SdrObject* _pSdrObj ) const
489cdf0e10cSrcweir {
490cdf0e10cSrcweir     ASSERT( _pSdrObj,
491cdf0e10cSrcweir             "<SwFlyDrawContact::GetAnchoredObj(..)> - no object provided" );
492cdf0e10cSrcweir     ASSERT( _pSdrObj->ISA(SwVirtFlyDrawObj),
493cdf0e10cSrcweir             "<SwFlyDrawContact::GetAnchoredObj(..)> - wrong object type object provided" );
494cdf0e10cSrcweir     ASSERT( GetUserCall( _pSdrObj ) == const_cast<SwFlyDrawContact*>(this),
495cdf0e10cSrcweir             "<SwFlyDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" );
496cdf0e10cSrcweir 
497cdf0e10cSrcweir     const SwAnchoredObject* pRetAnchoredObj = 0L;
498cdf0e10cSrcweir 
499cdf0e10cSrcweir     if ( _pSdrObj && _pSdrObj->ISA(SwVirtFlyDrawObj) )
500cdf0e10cSrcweir     {
501cdf0e10cSrcweir         pRetAnchoredObj = static_cast<const SwVirtFlyDrawObj*>(_pSdrObj)->GetFlyFrm();
502cdf0e10cSrcweir     }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir     return pRetAnchoredObj;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
GetAnchoredObj(SdrObject * _pSdrObj)507cdf0e10cSrcweir SwAnchoredObject* SwFlyDrawContact::GetAnchoredObj( SdrObject* _pSdrObj )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir     ASSERT( _pSdrObj,
510cdf0e10cSrcweir             "<SwFlyDrawContact::GetAnchoredObj(..)> - no object provided" );
511cdf0e10cSrcweir     ASSERT( _pSdrObj->ISA(SwVirtFlyDrawObj),
512cdf0e10cSrcweir             "<SwFlyDrawContact::GetAnchoredObj(..)> - wrong object type provided" );
513cdf0e10cSrcweir     ASSERT( GetUserCall( _pSdrObj ) == this,
514cdf0e10cSrcweir             "<SwFlyDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" );
515cdf0e10cSrcweir 
516cdf0e10cSrcweir     SwAnchoredObject* pRetAnchoredObj = 0L;
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     if ( _pSdrObj && _pSdrObj->ISA(SwVirtFlyDrawObj) )
519cdf0e10cSrcweir     {
520cdf0e10cSrcweir         pRetAnchoredObj = static_cast<SwVirtFlyDrawObj*>(_pSdrObj)->GetFlyFrm();
521cdf0e10cSrcweir     }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir     return pRetAnchoredObj;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
GetMaster() const526cdf0e10cSrcweir const SdrObject* SwFlyDrawContact::GetMaster() const
527cdf0e10cSrcweir {
528cdf0e10cSrcweir     return mpMasterObj;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
GetMaster()531cdf0e10cSrcweir SdrObject* SwFlyDrawContact::GetMaster()
532cdf0e10cSrcweir {
533cdf0e10cSrcweir     return mpMasterObj;
534cdf0e10cSrcweir }
535cdf0e10cSrcweir 
SetMaster(SdrObject * _pNewMaster)536cdf0e10cSrcweir void SwFlyDrawContact::SetMaster( SdrObject* _pNewMaster )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir     ASSERT( _pNewMaster->ISA(SwFlyDrawObj),
539cdf0e10cSrcweir             "<SwFlyDrawContact::SetMaster(..)> - wrong type of new master object" );
540cdf0e10cSrcweir     mpMasterObj = static_cast<SwFlyDrawObj *>(_pNewMaster);
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir /*************************************************************************
544cdf0e10cSrcweir |*
545cdf0e10cSrcweir |*	SwFlyDrawContact::Modify()
546cdf0e10cSrcweir |*
547cdf0e10cSrcweir |*	Ersterstellung		OK 08.11.94 10:21
548cdf0e10cSrcweir |*	Letzte Aenderung	MA 06. Dec. 94
549cdf0e10cSrcweir |*
550cdf0e10cSrcweir |*************************************************************************/
551cdf0e10cSrcweir 
Modify(const SfxPoolItem *,const SfxPoolItem *)552cdf0e10cSrcweir void SwFlyDrawContact::Modify( const SfxPoolItem*, const SfxPoolItem * )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir // OD 2004-01-16 #110582# - override method to control Writer fly frames,
557cdf0e10cSrcweir // which are linked, and to assure that all objects anchored at/inside the
558cdf0e10cSrcweir // Writer fly frame are also made visible.
MoveObjToVisibleLayer(SdrObject * _pDrawObj)559cdf0e10cSrcweir void SwFlyDrawContact::MoveObjToVisibleLayer( SdrObject* _pDrawObj )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir     ASSERT( _pDrawObj->ISA(SwVirtFlyDrawObj),
562cdf0e10cSrcweir             "<SwFlyDrawContact::MoveObjToVisibleLayer(..)> - wrong SdrObject type -> crash" );
563cdf0e10cSrcweir 
564cdf0e10cSrcweir     if ( GetFmt()->getIDocumentDrawModelAccess()->IsVisibleLayerId( _pDrawObj->GetLayer() ) )
565cdf0e10cSrcweir     {
566cdf0e10cSrcweir         // nothing to do
567cdf0e10cSrcweir         return;
568cdf0e10cSrcweir     }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir     SwFlyFrm* pFlyFrm = static_cast<SwVirtFlyDrawObj*>(_pDrawObj)->GetFlyFrm();
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     // --> OD 2005-03-09 #i44464# - consider, that Writer fly frame content
573cdf0e10cSrcweir     // already exists - (e.g. WW8 document is inserted into a existing document).
574cdf0e10cSrcweir     if ( !pFlyFrm->Lower() )
575cdf0e10cSrcweir     {
576cdf0e10cSrcweir         pFlyFrm->InsertColumns();
577cdf0e10cSrcweir         pFlyFrm->Chain( pFlyFrm->AnchorFrm() );
578cdf0e10cSrcweir         pFlyFrm->InsertCnt();
579cdf0e10cSrcweir     }
580cdf0e10cSrcweir     if ( pFlyFrm->GetDrawObjs() )
581cdf0e10cSrcweir     {
582cdf0e10cSrcweir         for ( sal_uInt8 i = 0; i < pFlyFrm->GetDrawObjs()->Count(); ++i)
583cdf0e10cSrcweir         {
584cdf0e10cSrcweir             // --> OD 2004-07-01 #i28701# - consider type of objects in sorted object list.
585cdf0e10cSrcweir             SdrObject* pObj = (*pFlyFrm->GetDrawObjs())[i]->DrawObj();
586cdf0e10cSrcweir             SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
587cdf0e10cSrcweir             pContact->MoveObjToVisibleLayer( pObj );
588cdf0e10cSrcweir         }
589cdf0e10cSrcweir     }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir     // make fly frame visible
592cdf0e10cSrcweir     SwContact::MoveObjToVisibleLayer( _pDrawObj );
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir // OD 2004-01-16 #110582# - override method to control Writer fly frames,
596cdf0e10cSrcweir // which are linked, and to assure that all objects anchored at/inside the
597cdf0e10cSrcweir // Writer fly frame are also made invisible.
MoveObjToInvisibleLayer(SdrObject * _pDrawObj)598cdf0e10cSrcweir void SwFlyDrawContact::MoveObjToInvisibleLayer( SdrObject* _pDrawObj )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir     ASSERT( _pDrawObj->ISA(SwVirtFlyDrawObj),
601cdf0e10cSrcweir             "<SwFlyDrawContact::MoveObjToInvisibleLayer(..)> - wrong SdrObject type -> crash" );
602cdf0e10cSrcweir 
603cdf0e10cSrcweir     if ( !GetFmt()->getIDocumentDrawModelAccess()->IsVisibleLayerId( _pDrawObj->GetLayer() ) )
604cdf0e10cSrcweir     {
605cdf0e10cSrcweir         // nothing to do
606cdf0e10cSrcweir         return;
607cdf0e10cSrcweir     }
608cdf0e10cSrcweir 
609cdf0e10cSrcweir     SwFlyFrm* pFlyFrm = static_cast<SwVirtFlyDrawObj*>(_pDrawObj)->GetFlyFrm();
610cdf0e10cSrcweir 
611cdf0e10cSrcweir     pFlyFrm->Unchain();
612cdf0e10cSrcweir     pFlyFrm->DeleteCnt();
613cdf0e10cSrcweir     if ( pFlyFrm->GetDrawObjs() )
614cdf0e10cSrcweir     {
615cdf0e10cSrcweir         for ( sal_uInt8 i = 0; i < pFlyFrm->GetDrawObjs()->Count(); ++i)
616cdf0e10cSrcweir         {
617cdf0e10cSrcweir             // --> OD 2004-07-01 #i28701# - consider type of objects in sorted object list.
618cdf0e10cSrcweir             SdrObject* pObj = (*pFlyFrm->GetDrawObjs())[i]->DrawObj();
619cdf0e10cSrcweir             SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
620cdf0e10cSrcweir             pContact->MoveObjToInvisibleLayer( pObj );
621cdf0e10cSrcweir         }
622cdf0e10cSrcweir     }
623cdf0e10cSrcweir 
624cdf0e10cSrcweir     // make fly frame invisible
625cdf0e10cSrcweir     SwContact::MoveObjToInvisibleLayer( _pDrawObj );
626cdf0e10cSrcweir }
627cdf0e10cSrcweir 
628cdf0e10cSrcweir /** get data collection of anchored objects, handled by with contact
629cdf0e10cSrcweir 
630cdf0e10cSrcweir     OD 2004-08-23 #110810#
631cdf0e10cSrcweir 
632cdf0e10cSrcweir     @author
633cdf0e10cSrcweir */
GetAnchoredObjs(std::list<SwAnchoredObject * > & _roAnchoredObjs) const634cdf0e10cSrcweir void SwFlyDrawContact::GetAnchoredObjs( std::list<SwAnchoredObject*>& _roAnchoredObjs ) const
635cdf0e10cSrcweir {
636cdf0e10cSrcweir     const SwFrmFmt* pFmt = GetFmt();
637cdf0e10cSrcweir     SwFlyFrm::GetAnchoredObjects( _roAnchoredObjs, *pFmt );
638cdf0e10cSrcweir }
639cdf0e10cSrcweir 
640cdf0e10cSrcweir /*************************************************************************
641cdf0e10cSrcweir |*
642cdf0e10cSrcweir |*	SwDrawContact, Ctor+Dtor
643cdf0e10cSrcweir |*
644cdf0e10cSrcweir |*	Ersterstellung		MA 09. Jan. 95
645cdf0e10cSrcweir |*	Letzte Aenderung	MA 22. Jul. 98
646cdf0e10cSrcweir |*
647cdf0e10cSrcweir |*************************************************************************/
CheckControlLayer(const SdrObject * pObj)648cdf0e10cSrcweir bool CheckControlLayer( const SdrObject *pObj )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir 	if ( FmFormInventor == pObj->GetObjInventor() )
651cdf0e10cSrcweir         return true;
652cdf0e10cSrcweir 	if ( pObj->ISA( SdrObjGroup ) )
653cdf0e10cSrcweir 	{
654cdf0e10cSrcweir 		const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
655cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < pLst->GetObjCount(); ++i )
656cdf0e10cSrcweir         {
657cdf0e10cSrcweir             if ( ::CheckControlLayer( pLst->GetObj( i ) ) )
658cdf0e10cSrcweir             {
659cdf0e10cSrcweir                 // OD 21.08.2003 #i18447# - return correct value ;-)
660cdf0e10cSrcweir                 return true;
661cdf0e10cSrcweir             }
662cdf0e10cSrcweir         }
663cdf0e10cSrcweir 	}
664cdf0e10cSrcweir     return false;
665cdf0e10cSrcweir }
666cdf0e10cSrcweir 
SwDrawContact(SwFrmFmt * pToRegisterIn,SdrObject * pObj)667cdf0e10cSrcweir SwDrawContact::SwDrawContact( SwFrmFmt* pToRegisterIn, SdrObject* pObj ) :
668cdf0e10cSrcweir     SwContact( pToRegisterIn ),
669cdf0e10cSrcweir     maAnchoredDrawObj(),
670cdf0e10cSrcweir     mbMasterObjCleared( false ),
671cdf0e10cSrcweir     // OD 10.10.2003 #112299#
672cdf0e10cSrcweir     mbDisconnectInProgress( false ),
673cdf0e10cSrcweir     // --> OD 2006-01-18 #129959#
674cdf0e10cSrcweir     mbUserCallActive( false ),
675cdf0e10cSrcweir     // Note: value of <meEventTypeOfCurrentUserCall> isn't of relevance, because
676cdf0e10cSrcweir     //       <mbUserCallActive> is sal_False.
677cdf0e10cSrcweir     meEventTypeOfCurrentUserCall( SDRUSERCALL_MOVEONLY )
678cdf0e10cSrcweir     // <--
679cdf0e10cSrcweir {
680cdf0e10cSrcweir     // clear list containing 'virtual' drawing objects.
681cdf0e10cSrcweir     maDrawVirtObjs.clear();
682cdf0e10cSrcweir 
683cdf0e10cSrcweir     // --> OD 2004-09-22 #i33909# - assure, that drawing object is inserted
684cdf0e10cSrcweir     // in the drawing page.
685cdf0e10cSrcweir     if ( !pObj->IsInserted() )
686cdf0e10cSrcweir     {
687cdf0e10cSrcweir         pToRegisterIn->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage(0)->
688cdf0e10cSrcweir                                 InsertObject( pObj, pObj->GetOrdNumDirect() );
689cdf0e10cSrcweir     }
690cdf0e10cSrcweir     // <--
691cdf0e10cSrcweir 
692cdf0e10cSrcweir     //Controls muessen immer im Control-Layer liegen. Das gilt auch fuer
693cdf0e10cSrcweir 	//Gruppenobjekte, wenn diese Controls enthalten.
694cdf0e10cSrcweir     if ( ::CheckControlLayer( pObj ) )
695cdf0e10cSrcweir     {
696cdf0e10cSrcweir         // OD 25.06.2003 #108784# - set layer of object to corresponding invisible layer.
697cdf0e10cSrcweir         pObj->SetLayer( pToRegisterIn->getIDocumentDrawModelAccess()->GetInvisibleControlsId() );
698cdf0e10cSrcweir     }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     // OD 2004-03-29 #i26791#
701cdf0e10cSrcweir     pObj->SetUserCall( this );
702cdf0e10cSrcweir     maAnchoredDrawObj.SetDrawObj( *pObj );
703cdf0e10cSrcweir 
704cdf0e10cSrcweir     // if there already exists an SwXShape for the object, ensure it knows about us, and the SdrObject
705cdf0e10cSrcweir     // FS 2009-04-07 #i99056#
706cdf0e10cSrcweir     SwXShape::AddExistingShapeToFmt( *pObj );
707cdf0e10cSrcweir }
708cdf0e10cSrcweir 
~SwDrawContact()709cdf0e10cSrcweir SwDrawContact::~SwDrawContact()
710cdf0e10cSrcweir {
711cdf0e10cSrcweir     // OD 05.09.2003 #112039# - set <mbInDTOR>
712cdf0e10cSrcweir     SetInDTOR();
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     DisconnectFromLayout();
715cdf0e10cSrcweir 
716cdf0e10cSrcweir     // OD 25.06.2003 #108784# - remove 'master' from drawing page
717cdf0e10cSrcweir     RemoveMasterFromDrawPage();
718cdf0e10cSrcweir 
719cdf0e10cSrcweir     // remove and destroy 'virtual' drawing objects.
720cdf0e10cSrcweir     RemoveAllVirtObjs();
721cdf0e10cSrcweir 
722cdf0e10cSrcweir     if ( !mbMasterObjCleared )
723cdf0e10cSrcweir     {
724cdf0e10cSrcweir         SdrObject* pObject = const_cast< SdrObject* >( maAnchoredDrawObj.GetDrawObj() );
725cdf0e10cSrcweir         SdrObject::Free( pObject );
726cdf0e10cSrcweir     }
727cdf0e10cSrcweir }
728cdf0e10cSrcweir 
GetTextObjectsFromFmt(std::list<SdrTextObj * > & rTextObjects,SwDoc * pDoc)729cdf0e10cSrcweir void SwDrawContact::GetTextObjectsFromFmt( std::list<SdrTextObj*>& rTextObjects, SwDoc* pDoc )
730cdf0e10cSrcweir {
731cdf0e10cSrcweir     for( sal_Int32 n=0; n<pDoc->GetSpzFrmFmts()->Count(); n++ )
732cdf0e10cSrcweir     {
733cdf0e10cSrcweir         SwFrmFmt* pFly = (*pDoc->GetSpzFrmFmts())[n];
734cdf0e10cSrcweir         if( pFly->IsA( TYPE(SwDrawFrmFmt) ) )
735cdf0e10cSrcweir         {
736cdf0e10cSrcweir             std::list<SdrTextObj*> aTextObjs;
737cdf0e10cSrcweir             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFrmFmt>::FirstElement(*pFly);
738cdf0e10cSrcweir             if( pContact )
739cdf0e10cSrcweir             {
740cdf0e10cSrcweir                 SdrObject* pSdrO = pContact->GetMaster();
741cdf0e10cSrcweir                 if ( pSdrO )
742cdf0e10cSrcweir                 {
743cdf0e10cSrcweir                     if ( pSdrO->IsA( TYPE(SdrObjGroup) ) )
744cdf0e10cSrcweir                     {
745cdf0e10cSrcweir                         SdrObjListIter aListIter( *pSdrO, IM_DEEPNOGROUPS );
746cdf0e10cSrcweir                         //iterate inside of a grouped object
747cdf0e10cSrcweir                         while( aListIter.IsMore() )
748cdf0e10cSrcweir                         {
749cdf0e10cSrcweir                             SdrObject* pSdrOElement = aListIter.Next();
750cdf0e10cSrcweir                             if( pSdrOElement && pSdrOElement->IsA( TYPE(SdrTextObj) ) &&
751cdf0e10cSrcweir                                 static_cast<SdrTextObj*>( pSdrOElement)->HasText() )
752cdf0e10cSrcweir                             {
753cdf0e10cSrcweir                                 rTextObjects.push_back((SdrTextObj*) pSdrOElement);
754cdf0e10cSrcweir                             }
755cdf0e10cSrcweir                         }
756cdf0e10cSrcweir                     }
757cdf0e10cSrcweir                     else if( pSdrO->IsA( TYPE(SdrTextObj) ) &&
758cdf0e10cSrcweir                             static_cast<SdrTextObj*>( pSdrO )->HasText() )
759cdf0e10cSrcweir                     {
760cdf0e10cSrcweir                         rTextObjects.push_back((SdrTextObj*) pSdrO);
761cdf0e10cSrcweir                     }
762cdf0e10cSrcweir                 }
763cdf0e10cSrcweir             }
764cdf0e10cSrcweir         }
765cdf0e10cSrcweir     }
766cdf0e10cSrcweir }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir // OD 2004-03-29 #i26791#
GetAnchoredObj(const SdrObject * _pSdrObj) const769cdf0e10cSrcweir const SwAnchoredObject* SwDrawContact::GetAnchoredObj( const SdrObject* _pSdrObj ) const
770cdf0e10cSrcweir {
771cdf0e10cSrcweir     // handle default parameter value
772cdf0e10cSrcweir     if ( !_pSdrObj )
773cdf0e10cSrcweir     {
774cdf0e10cSrcweir         _pSdrObj = GetMaster();
775cdf0e10cSrcweir     }
776cdf0e10cSrcweir 
777cdf0e10cSrcweir     ASSERT( _pSdrObj,
778cdf0e10cSrcweir             "<SwDrawContact::GetAnchoredObj(..)> - no object provided" );
779cdf0e10cSrcweir     ASSERT( _pSdrObj->ISA(SwDrawVirtObj) ||
780cdf0e10cSrcweir             ( !_pSdrObj->ISA(SdrVirtObj) && !_pSdrObj->ISA(SwDrawVirtObj) ),
781cdf0e10cSrcweir             "<SwDrawContact::GetAnchoredObj(..)> - wrong object type object provided" );
782cdf0e10cSrcweir     ASSERT( GetUserCall( _pSdrObj ) == const_cast<SwDrawContact*>(this) ||
783cdf0e10cSrcweir             _pSdrObj == GetMaster(),
784cdf0e10cSrcweir             "<SwDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" );
785cdf0e10cSrcweir 
786cdf0e10cSrcweir     const SwAnchoredObject* pRetAnchoredObj = 0L;
787cdf0e10cSrcweir 
788cdf0e10cSrcweir     if ( _pSdrObj )
789cdf0e10cSrcweir     {
790cdf0e10cSrcweir         if ( _pSdrObj->ISA(SwDrawVirtObj) )
791cdf0e10cSrcweir         {
792cdf0e10cSrcweir             pRetAnchoredObj = static_cast<const SwDrawVirtObj*>(_pSdrObj)->GetAnchoredObj();
793cdf0e10cSrcweir         }
794cdf0e10cSrcweir         else if ( !_pSdrObj->ISA(SdrVirtObj) && !_pSdrObj->ISA(SwDrawVirtObj) )
795cdf0e10cSrcweir         {
796cdf0e10cSrcweir             pRetAnchoredObj = &maAnchoredDrawObj;
797cdf0e10cSrcweir         }
798cdf0e10cSrcweir     }
799cdf0e10cSrcweir 
800cdf0e10cSrcweir     return pRetAnchoredObj;
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
GetAnchoredObj(SdrObject * _pSdrObj)803cdf0e10cSrcweir SwAnchoredObject* SwDrawContact::GetAnchoredObj( SdrObject* _pSdrObj )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir     // handle default parameter value
806cdf0e10cSrcweir     if ( !_pSdrObj )
807cdf0e10cSrcweir     {
808cdf0e10cSrcweir         _pSdrObj = GetMaster();
809cdf0e10cSrcweir     }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir     ASSERT( _pSdrObj,
812cdf0e10cSrcweir             "<SwDrawContact::GetAnchoredObj(..)> - no object provided" );
813cdf0e10cSrcweir     ASSERT( _pSdrObj->ISA(SwDrawVirtObj) ||
814cdf0e10cSrcweir             ( !_pSdrObj->ISA(SdrVirtObj) && !_pSdrObj->ISA(SwDrawVirtObj) ),
815cdf0e10cSrcweir             "<SwDrawContact::GetAnchoredObj(..)> - wrong object type object provided" );
816cdf0e10cSrcweir     ASSERT( GetUserCall( _pSdrObj ) == this || _pSdrObj == GetMaster(),
817cdf0e10cSrcweir             "<SwDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" );
818cdf0e10cSrcweir 
819cdf0e10cSrcweir     SwAnchoredObject* pRetAnchoredObj = 0L;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir     if ( _pSdrObj )
822cdf0e10cSrcweir     {
823cdf0e10cSrcweir         if ( _pSdrObj->ISA(SwDrawVirtObj) )
824cdf0e10cSrcweir         {
825cdf0e10cSrcweir             pRetAnchoredObj = static_cast<SwDrawVirtObj*>(_pSdrObj)->AnchoredObj();
826cdf0e10cSrcweir         }
827cdf0e10cSrcweir         else if ( !_pSdrObj->ISA(SdrVirtObj) && !_pSdrObj->ISA(SwDrawVirtObj) )
828cdf0e10cSrcweir         {
829cdf0e10cSrcweir             pRetAnchoredObj = &maAnchoredDrawObj;
830cdf0e10cSrcweir         }
831cdf0e10cSrcweir     }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     return pRetAnchoredObj;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
GetMaster() const836cdf0e10cSrcweir const SdrObject* SwDrawContact::GetMaster() const
837cdf0e10cSrcweir {
838cdf0e10cSrcweir     return !mbMasterObjCleared
839cdf0e10cSrcweir            ? maAnchoredDrawObj.GetDrawObj()
840cdf0e10cSrcweir            : 0L;
841cdf0e10cSrcweir }
842cdf0e10cSrcweir 
GetMaster()843cdf0e10cSrcweir SdrObject* SwDrawContact::GetMaster()
844cdf0e10cSrcweir {
845cdf0e10cSrcweir     return !mbMasterObjCleared
846cdf0e10cSrcweir            ? maAnchoredDrawObj.DrawObj()
847cdf0e10cSrcweir            : 0L;
848cdf0e10cSrcweir }
849cdf0e10cSrcweir 
850cdf0e10cSrcweir // OD 16.05.2003 #108784# - overload <SwContact::SetMaster(..)> in order to
851cdf0e10cSrcweir // assert, if the 'master' drawing object is replaced.
852cdf0e10cSrcweir // OD 10.07.2003 #110742# - replace of master object correctly handled, if
853cdf0e10cSrcweir // handled by method <SwDrawContact::ChangeMasterObject(..)>. Thus, assert
854cdf0e10cSrcweir // only, if a debug level is given.
SetMaster(SdrObject * _pNewMaster)855cdf0e10cSrcweir void SwDrawContact::SetMaster( SdrObject* _pNewMaster )
856cdf0e10cSrcweir {
857cdf0e10cSrcweir     if ( _pNewMaster )
858cdf0e10cSrcweir     {
859cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
860cdf0e10cSrcweir         ASSERT( false, "debug notification - master replaced!" );
861cdf0e10cSrcweir #endif
862cdf0e10cSrcweir         maAnchoredDrawObj.SetDrawObj( *_pNewMaster );
863cdf0e10cSrcweir     }
864cdf0e10cSrcweir     else
865cdf0e10cSrcweir     {
866cdf0e10cSrcweir         mbMasterObjCleared = true;
867cdf0e10cSrcweir     }
868cdf0e10cSrcweir }
869cdf0e10cSrcweir 
GetAnchorFrm(const SdrObject * _pDrawObj) const870cdf0e10cSrcweir const SwFrm* SwDrawContact::GetAnchorFrm( const SdrObject* _pDrawObj ) const
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     const SwFrm* pAnchorFrm = 0L;
873cdf0e10cSrcweir     if ( !_pDrawObj ||
874cdf0e10cSrcweir          _pDrawObj == GetMaster() ||
875cdf0e10cSrcweir          ( !_pDrawObj->GetUserCall() &&
876cdf0e10cSrcweir            GetUserCall( _pDrawObj ) == static_cast<const SwContact* const>(this) ) )
877cdf0e10cSrcweir     {
878cdf0e10cSrcweir         pAnchorFrm = maAnchoredDrawObj.GetAnchorFrm();
879cdf0e10cSrcweir     }
880cdf0e10cSrcweir     else if ( _pDrawObj->ISA(SwDrawVirtObj) )
881cdf0e10cSrcweir     {
882cdf0e10cSrcweir         pAnchorFrm = static_cast<const SwDrawVirtObj*>(_pDrawObj)->GetAnchorFrm();
883cdf0e10cSrcweir     }
884cdf0e10cSrcweir     else
885cdf0e10cSrcweir     {
886cdf0e10cSrcweir         ASSERT( false,
887cdf0e10cSrcweir                 "<SwDrawContact::GetAnchorFrm(..)> - unknown drawing object." )
888cdf0e10cSrcweir     }
889cdf0e10cSrcweir 
890cdf0e10cSrcweir     return pAnchorFrm;
891cdf0e10cSrcweir }
GetAnchorFrm(SdrObject * _pDrawObj)892cdf0e10cSrcweir SwFrm* SwDrawContact::GetAnchorFrm( SdrObject* _pDrawObj )
893cdf0e10cSrcweir {
894cdf0e10cSrcweir     SwFrm* pAnchorFrm = 0L;
895cdf0e10cSrcweir     if ( !_pDrawObj ||
896cdf0e10cSrcweir          _pDrawObj == GetMaster() ||
897cdf0e10cSrcweir          ( !_pDrawObj->GetUserCall() &&
898cdf0e10cSrcweir            GetUserCall( _pDrawObj ) == this ) )
899cdf0e10cSrcweir     {
900cdf0e10cSrcweir         pAnchorFrm = maAnchoredDrawObj.AnchorFrm();
901cdf0e10cSrcweir     }
902cdf0e10cSrcweir     else
903cdf0e10cSrcweir     {
904cdf0e10cSrcweir         ASSERT( _pDrawObj->ISA(SwDrawVirtObj),
905cdf0e10cSrcweir                 "<SwDrawContact::GetAnchorFrm(..)> - unknown drawing object." )
906cdf0e10cSrcweir         pAnchorFrm = static_cast<SwDrawVirtObj*>(_pDrawObj)->AnchorFrm();
907cdf0e10cSrcweir     }
908cdf0e10cSrcweir 
909cdf0e10cSrcweir     return pAnchorFrm;
910cdf0e10cSrcweir }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir // OD 23.06.2003 #108784# - method to create a new 'virtual' drawing object.
CreateVirtObj()913cdf0e10cSrcweir SwDrawVirtObj* SwDrawContact::CreateVirtObj()
914cdf0e10cSrcweir {
915cdf0e10cSrcweir     // determine 'master'
916cdf0e10cSrcweir     SdrObject* pOrgMasterSdrObj = GetMaster();
917cdf0e10cSrcweir 
918cdf0e10cSrcweir     // create 'virtual' drawing object
919cdf0e10cSrcweir     SwDrawVirtObj* pNewDrawVirtObj = new SwDrawVirtObj ( *(pOrgMasterSdrObj), *(this) );
920cdf0e10cSrcweir 
921cdf0e10cSrcweir     // add new 'virtual' drawing object managing data structure
922cdf0e10cSrcweir     maDrawVirtObjs.push_back( pNewDrawVirtObj );
923cdf0e10cSrcweir 
924cdf0e10cSrcweir     return pNewDrawVirtObj;
925cdf0e10cSrcweir }
926cdf0e10cSrcweir 
927cdf0e10cSrcweir // OD 23.06.2003 #108784# - destroys a given 'virtual' drawing object.
928cdf0e10cSrcweir // side effect: 'virtual' drawing object is removed from data structure
929cdf0e10cSrcweir //              <maDrawVirtObjs>.
DestroyVirtObj(SwDrawVirtObj * _pVirtObj)930cdf0e10cSrcweir void SwDrawContact::DestroyVirtObj( SwDrawVirtObj* _pVirtObj )
931cdf0e10cSrcweir {
932cdf0e10cSrcweir     if ( _pVirtObj )
933cdf0e10cSrcweir     {
934cdf0e10cSrcweir         delete _pVirtObj;
935cdf0e10cSrcweir         _pVirtObj = 0;
936cdf0e10cSrcweir     }
937cdf0e10cSrcweir }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir // OD 16.05.2003 #108784# - add a 'virtual' drawing object to drawing page.
940cdf0e10cSrcweir // Use an already created one, which isn't used, or create a new one.
AddVirtObj()941cdf0e10cSrcweir SwDrawVirtObj* SwDrawContact::AddVirtObj()
942cdf0e10cSrcweir {
943cdf0e10cSrcweir     SwDrawVirtObj* pAddedDrawVirtObj = 0L;
944cdf0e10cSrcweir 
945cdf0e10cSrcweir     // check, if a disconnected 'virtual' drawing object exist and use it
946cdf0e10cSrcweir     std::list<SwDrawVirtObj*>::const_iterator aFoundVirtObjIter =
947cdf0e10cSrcweir             std::find_if( maDrawVirtObjs.begin(), maDrawVirtObjs.end(),
948cdf0e10cSrcweir                           UsedOrUnusedVirtObjPred( false ) );
949cdf0e10cSrcweir 
950cdf0e10cSrcweir     if ( aFoundVirtObjIter != maDrawVirtObjs.end() )
951cdf0e10cSrcweir     {
952cdf0e10cSrcweir         // use already created, disconnected 'virtual' drawing object
953cdf0e10cSrcweir         pAddedDrawVirtObj = (*aFoundVirtObjIter);
954cdf0e10cSrcweir     }
955cdf0e10cSrcweir     else
956cdf0e10cSrcweir     {
957cdf0e10cSrcweir         // create new 'virtual' drawing object.
958cdf0e10cSrcweir         pAddedDrawVirtObj = CreateVirtObj();
959cdf0e10cSrcweir     }
960cdf0e10cSrcweir     pAddedDrawVirtObj->AddToDrawingPage();
961cdf0e10cSrcweir 
962cdf0e10cSrcweir     return pAddedDrawVirtObj;
963cdf0e10cSrcweir }
964cdf0e10cSrcweir 
965cdf0e10cSrcweir // OD 16.05.2003 #108784# - remove 'virtual' drawing objects and destroy them.
RemoveAllVirtObjs()966cdf0e10cSrcweir void SwDrawContact::RemoveAllVirtObjs()
967cdf0e10cSrcweir {
968cdf0e10cSrcweir     for ( std::list<SwDrawVirtObj*>::iterator aDrawVirtObjsIter = maDrawVirtObjs.begin();
969cdf0e10cSrcweir           aDrawVirtObjsIter != maDrawVirtObjs.end();
970cdf0e10cSrcweir           ++aDrawVirtObjsIter )
971cdf0e10cSrcweir     {
972cdf0e10cSrcweir         // remove and destroy 'virtual object'
973cdf0e10cSrcweir         SwDrawVirtObj* pDrawVirtObj = (*aDrawVirtObjsIter);
974cdf0e10cSrcweir         pDrawVirtObj->RemoveFromWriterLayout();
975cdf0e10cSrcweir         pDrawVirtObj->RemoveFromDrawingPage();
976cdf0e10cSrcweir         DestroyVirtObj( pDrawVirtObj );
977cdf0e10cSrcweir     }
978cdf0e10cSrcweir     maDrawVirtObjs.clear();
979cdf0e10cSrcweir }
980cdf0e10cSrcweir 
VirtObjAnchoredAtFrmPred(const SwFrm & _rAnchorFrm)981cdf0e10cSrcweir SwDrawContact::VirtObjAnchoredAtFrmPred::VirtObjAnchoredAtFrmPred(
982cdf0e10cSrcweir                                                 const SwFrm& _rAnchorFrm )
983cdf0e10cSrcweir     : mpAnchorFrm( &_rAnchorFrm )
984cdf0e10cSrcweir {
985cdf0e10cSrcweir     if ( mpAnchorFrm->IsCntntFrm() )
986cdf0e10cSrcweir     {
987cdf0e10cSrcweir         const SwCntntFrm* pTmpFrm =
988cdf0e10cSrcweir                             static_cast<const SwCntntFrm*>( mpAnchorFrm );
989cdf0e10cSrcweir         while ( pTmpFrm->IsFollow() )
990cdf0e10cSrcweir         {
991cdf0e10cSrcweir             pTmpFrm = pTmpFrm->FindMaster();
992cdf0e10cSrcweir         }
993cdf0e10cSrcweir         mpAnchorFrm = pTmpFrm;
994cdf0e10cSrcweir     }
995cdf0e10cSrcweir }
996cdf0e10cSrcweir 
997cdf0e10cSrcweir // OD 2004-04-14 #i26791# - compare with master frame
operator ()(const SwDrawVirtObj * _pDrawVirtObj)998cdf0e10cSrcweir bool SwDrawContact::VirtObjAnchoredAtFrmPred::operator() ( const SwDrawVirtObj* _pDrawVirtObj )
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir     const SwFrm* pObjAnchorFrm = _pDrawVirtObj->GetAnchorFrm();
1001cdf0e10cSrcweir     if ( pObjAnchorFrm && pObjAnchorFrm->IsCntntFrm() )
1002cdf0e10cSrcweir     {
1003cdf0e10cSrcweir         const SwCntntFrm* pTmpFrm =
1004cdf0e10cSrcweir                             static_cast<const SwCntntFrm*>( pObjAnchorFrm );
1005cdf0e10cSrcweir         while ( pTmpFrm->IsFollow() )
1006cdf0e10cSrcweir         {
1007cdf0e10cSrcweir             pTmpFrm = pTmpFrm->FindMaster();
1008cdf0e10cSrcweir         }
1009cdf0e10cSrcweir         pObjAnchorFrm = pTmpFrm;
1010cdf0e10cSrcweir     }
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir     return ( pObjAnchorFrm == mpAnchorFrm );
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir // OD 19.06.2003 #108784# - get drawing object ('master' or 'virtual') by frame.
GetDrawObjectByAnchorFrm(const SwFrm & _rAnchorFrm)1016cdf0e10cSrcweir SdrObject* SwDrawContact::GetDrawObjectByAnchorFrm( const SwFrm& _rAnchorFrm )
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir     SdrObject* pRetDrawObj = 0L;
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir     // OD 2004-04-14 #i26791# - compare master frames instead of direct frames
1021cdf0e10cSrcweir     const SwFrm* pProposedAnchorFrm = &_rAnchorFrm;
1022cdf0e10cSrcweir     if ( pProposedAnchorFrm->IsCntntFrm() )
1023cdf0e10cSrcweir     {
1024cdf0e10cSrcweir         const SwCntntFrm* pTmpFrm =
1025cdf0e10cSrcweir                             static_cast<const SwCntntFrm*>( pProposedAnchorFrm );
1026cdf0e10cSrcweir         while ( pTmpFrm->IsFollow() )
1027cdf0e10cSrcweir         {
1028cdf0e10cSrcweir             pTmpFrm = pTmpFrm->FindMaster();
1029cdf0e10cSrcweir         }
1030cdf0e10cSrcweir         pProposedAnchorFrm = pTmpFrm;
1031cdf0e10cSrcweir     }
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir     const SwFrm* pMasterObjAnchorFrm = GetAnchorFrm();
1034cdf0e10cSrcweir     if ( pMasterObjAnchorFrm && pMasterObjAnchorFrm->IsCntntFrm() )
1035cdf0e10cSrcweir     {
1036cdf0e10cSrcweir         const SwCntntFrm* pTmpFrm =
1037cdf0e10cSrcweir                             static_cast<const SwCntntFrm*>( pMasterObjAnchorFrm );
1038cdf0e10cSrcweir         while ( pTmpFrm->IsFollow() )
1039cdf0e10cSrcweir         {
1040cdf0e10cSrcweir             pTmpFrm = pTmpFrm->FindMaster();
1041cdf0e10cSrcweir         }
1042cdf0e10cSrcweir         pMasterObjAnchorFrm = pTmpFrm;
1043cdf0e10cSrcweir     }
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir     if ( pMasterObjAnchorFrm && pMasterObjAnchorFrm == pProposedAnchorFrm )
1046cdf0e10cSrcweir     {
1047cdf0e10cSrcweir         pRetDrawObj = GetMaster();
1048cdf0e10cSrcweir     }
1049cdf0e10cSrcweir     else
1050cdf0e10cSrcweir     {
1051cdf0e10cSrcweir         std::list<SwDrawVirtObj*>::const_iterator aFoundVirtObjIter =
1052cdf0e10cSrcweir                 std::find_if( maDrawVirtObjs.begin(), maDrawVirtObjs.end(),
1053cdf0e10cSrcweir                               VirtObjAnchoredAtFrmPred( *pProposedAnchorFrm ) );
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir         if ( aFoundVirtObjIter != maDrawVirtObjs.end() )
1056cdf0e10cSrcweir         {
1057cdf0e10cSrcweir             pRetDrawObj = (*aFoundVirtObjIter);
1058cdf0e10cSrcweir         }
1059cdf0e10cSrcweir     }
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir     return pRetDrawObj;
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir /*************************************************************************
1065cdf0e10cSrcweir |*
1066cdf0e10cSrcweir |*	SwDrawContact::Changed
1067cdf0e10cSrcweir |*
1068cdf0e10cSrcweir |*	Ersterstellung		MA 09. Jan. 95
1069cdf0e10cSrcweir |*	Letzte Aenderung	MA 29. May. 96
1070cdf0e10cSrcweir |*
1071cdf0e10cSrcweir |*************************************************************************/
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir // OD 03.07.2003 #108784#
NotifyBackgrdOfAllVirtObjs(const Rectangle * pOldBoundRect)1074cdf0e10cSrcweir void SwDrawContact::NotifyBackgrdOfAllVirtObjs( const Rectangle* pOldBoundRect )
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir     for ( std::list<SwDrawVirtObj*>::iterator aDrawVirtObjIter = maDrawVirtObjs.begin();
1077cdf0e10cSrcweir           aDrawVirtObjIter != maDrawVirtObjs.end();
1078cdf0e10cSrcweir           ++aDrawVirtObjIter )
1079cdf0e10cSrcweir     {
1080cdf0e10cSrcweir         SwDrawVirtObj* pDrawVirtObj = (*aDrawVirtObjIter);
1081cdf0e10cSrcweir         if ( pDrawVirtObj->GetAnchorFrm() )
1082cdf0e10cSrcweir         {
1083cdf0e10cSrcweir             // --> OD 2004-10-21 #i34640# - determine correct page frame
1084cdf0e10cSrcweir             SwPageFrm* pPage = pDrawVirtObj->AnchoredObj()->FindPageFrmOfAnchor();
1085cdf0e10cSrcweir             // <--
1086cdf0e10cSrcweir             if( pOldBoundRect && pPage )
1087cdf0e10cSrcweir             {
1088cdf0e10cSrcweir                 SwRect aOldRect( *pOldBoundRect );
1089cdf0e10cSrcweir                 aOldRect.Pos() += pDrawVirtObj->GetOffset();
1090cdf0e10cSrcweir                 if( aOldRect.HasArea() )
1091cdf0e10cSrcweir                     ::Notify_Background( pDrawVirtObj, pPage,
1092cdf0e10cSrcweir                                          aOldRect, PREP_FLY_LEAVE,sal_True);
1093cdf0e10cSrcweir             }
1094cdf0e10cSrcweir             // --> OD 2004-10-21 #i34640# - include spacing for wrapping
1095cdf0e10cSrcweir             SwRect aRect( pDrawVirtObj->GetAnchoredObj()->GetObjRectWithSpaces() );
1096cdf0e10cSrcweir             // <--
1097cdf0e10cSrcweir             if( aRect.HasArea() )
1098cdf0e10cSrcweir             {
1099cdf0e10cSrcweir                 // --> OD 2004-10-21 #i34640# - simplify
1100cdf0e10cSrcweir                 SwPageFrm* pPg = (SwPageFrm*)::FindPage( aRect, pPage );
1101cdf0e10cSrcweir                 // <--
1102cdf0e10cSrcweir                 if ( pPg )
1103cdf0e10cSrcweir                     ::Notify_Background( pDrawVirtObj, pPg, aRect,
1104cdf0e10cSrcweir                                          PREP_FLY_ARRIVE, sal_True );
1105cdf0e10cSrcweir             }
1106cdf0e10cSrcweir             ::ClrContourCache( pDrawVirtObj );
1107cdf0e10cSrcweir         }
1108cdf0e10cSrcweir     }
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir // OD 2004-04-08 #i26791# - local method to notify the background for a drawing object
lcl_NotifyBackgroundOfObj(SwDrawContact & _rDrawContact,const SdrObject & _rObj,const Rectangle * _pOldObjRect)1112cdf0e10cSrcweir void lcl_NotifyBackgroundOfObj( SwDrawContact& _rDrawContact,
1113cdf0e10cSrcweir                                 const SdrObject& _rObj,
1114cdf0e10cSrcweir                                 const Rectangle* _pOldObjRect )
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir     // --> OD 2004-10-21 #i34640#
1117cdf0e10cSrcweir     SwAnchoredObject* pAnchoredObj =
1118cdf0e10cSrcweir         const_cast<SwAnchoredObject*>(_rDrawContact.GetAnchoredObj( &_rObj ));
1119cdf0e10cSrcweir     if ( pAnchoredObj && pAnchoredObj->GetAnchorFrm() )
1120cdf0e10cSrcweir     // <--
1121cdf0e10cSrcweir     {
1122cdf0e10cSrcweir         // --> OD 2004-10-21 #i34640# - determine correct page frame
1123cdf0e10cSrcweir         SwPageFrm* pPageFrm = pAnchoredObj->FindPageFrmOfAnchor();
1124cdf0e10cSrcweir         // <--
1125cdf0e10cSrcweir         if( _pOldObjRect && pPageFrm )
1126cdf0e10cSrcweir         {
1127cdf0e10cSrcweir             SwRect aOldRect( *_pOldObjRect );
1128cdf0e10cSrcweir             if( aOldRect.HasArea() )
1129cdf0e10cSrcweir             {
1130cdf0e10cSrcweir                 // --> OD 2004-10-21 #i34640# - determine correct page frame
1131cdf0e10cSrcweir                 SwPageFrm* pOldPageFrm = (SwPageFrm*)::FindPage( aOldRect, pPageFrm );
1132cdf0e10cSrcweir                 // <--
1133cdf0e10cSrcweir                 ::Notify_Background( &_rObj, pOldPageFrm, aOldRect,
1134cdf0e10cSrcweir                                      PREP_FLY_LEAVE, sal_True);
1135cdf0e10cSrcweir             }
1136cdf0e10cSrcweir         }
1137cdf0e10cSrcweir         // --> OD 2004-10-21 #i34640# - include spacing for wrapping
1138cdf0e10cSrcweir         SwRect aNewRect( pAnchoredObj->GetObjRectWithSpaces() );
1139cdf0e10cSrcweir         // <--
1140cdf0e10cSrcweir         if( aNewRect.HasArea() && pPageFrm )
1141cdf0e10cSrcweir         {
1142cdf0e10cSrcweir             pPageFrm = (SwPageFrm*)::FindPage( aNewRect, pPageFrm );
1143cdf0e10cSrcweir             ::Notify_Background( &_rObj, pPageFrm, aNewRect,
1144cdf0e10cSrcweir                                  PREP_FLY_ARRIVE, sal_True );
1145cdf0e10cSrcweir         }
1146cdf0e10cSrcweir         ClrContourCache( &_rObj );
1147cdf0e10cSrcweir     }
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
Changed(const SdrObject & rObj,SdrUserCallType eType,const Rectangle & rOldBoundRect)1150cdf0e10cSrcweir void SwDrawContact::Changed( const SdrObject& rObj,
1151cdf0e10cSrcweir                              SdrUserCallType eType,
1152cdf0e10cSrcweir                              const Rectangle& rOldBoundRect )
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir     // OD 2004-06-01 #i26791# - no event handling, if existing <ViewShell>
1155cdf0e10cSrcweir     // is in contruction
1156cdf0e10cSrcweir     SwDoc* pDoc = GetFmt()->GetDoc();
1157cdf0e10cSrcweir     if ( pDoc->GetCurrentViewShell() &&
1158cdf0e10cSrcweir          pDoc->GetCurrentViewShell()->IsInConstructor() )
1159cdf0e10cSrcweir     {
1160cdf0e10cSrcweir         return;
1161cdf0e10cSrcweir     }
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir     // --> OD 2005-03-08 #i44339#
1164cdf0e10cSrcweir     // no event handling, if document is in destruction.
1165cdf0e10cSrcweir     // Exception: It's the SDRUSERCALL_DELETE event
1166cdf0e10cSrcweir     if ( pDoc->IsInDtor() && eType != SDRUSERCALL_DELETE )
1167cdf0e10cSrcweir     {
1168cdf0e10cSrcweir         return;
1169cdf0e10cSrcweir     }
1170cdf0e10cSrcweir     // <--
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir     //Action aufsetzen, aber nicht wenn gerade irgendwo eine Action laeuft.
1173cdf0e10cSrcweir 	ViewShell *pSh = 0, *pOrg;
1174cdf0e10cSrcweir 	SwRootFrm *pTmpRoot = pDoc->GetCurrentLayout();//swmod 080317
1175cdf0e10cSrcweir 	if ( pTmpRoot && pTmpRoot->IsCallbackActionEnabled() )
1176cdf0e10cSrcweir 	{
1177cdf0e10cSrcweir 		pDoc->GetEditShell( &pOrg );
1178cdf0e10cSrcweir 		pSh = pOrg;
1179cdf0e10cSrcweir 		if ( pSh )
1180cdf0e10cSrcweir 			do
1181cdf0e10cSrcweir 			{   if ( pSh->Imp()->IsAction() || pSh->Imp()->IsIdleAction() )
1182cdf0e10cSrcweir 					pSh = 0;
1183cdf0e10cSrcweir 				else
1184cdf0e10cSrcweir 					pSh = (ViewShell*)pSh->GetNext();
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir 			} while ( pSh && pSh != pOrg );
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 		if ( pSh )
1189cdf0e10cSrcweir 			pTmpRoot->StartAllAction();
1190cdf0e10cSrcweir 	}
1191cdf0e10cSrcweir 	SdrObjUserCall::Changed( rObj, eType, rOldBoundRect );
1192cdf0e10cSrcweir     _Changed( rObj, eType, &rOldBoundRect );    //Achtung, ggf. Suizid!
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 	if ( pSh )
1195cdf0e10cSrcweir 		pTmpRoot->EndAllAction();
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir // --> OD 2006-01-18 #129959#
1199cdf0e10cSrcweir // helper class for method <SwDrawContact::_Changed(..)> for handling nested
1200cdf0e10cSrcweir // <SdrObjUserCall> events
1201cdf0e10cSrcweir class NestedUserCallHdl
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir     private:
1204cdf0e10cSrcweir         SwDrawContact* mpDrawContact;
1205cdf0e10cSrcweir         bool mbParentUserCallActive;
1206cdf0e10cSrcweir         SdrUserCallType meParentUserCallEventType;
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir     public:
NestedUserCallHdl(SwDrawContact * _pDrawContact,SdrUserCallType _eEventType)1209cdf0e10cSrcweir         NestedUserCallHdl( SwDrawContact* _pDrawContact,
1210cdf0e10cSrcweir                            SdrUserCallType _eEventType )
1211cdf0e10cSrcweir             : mpDrawContact( _pDrawContact ),
1212cdf0e10cSrcweir               mbParentUserCallActive( _pDrawContact->mbUserCallActive ),
1213cdf0e10cSrcweir               meParentUserCallEventType( _pDrawContact->meEventTypeOfCurrentUserCall )
1214cdf0e10cSrcweir         {
1215cdf0e10cSrcweir             mpDrawContact->mbUserCallActive = true;
1216cdf0e10cSrcweir             mpDrawContact->meEventTypeOfCurrentUserCall = _eEventType;
1217cdf0e10cSrcweir         }
1218cdf0e10cSrcweir 
~NestedUserCallHdl()1219cdf0e10cSrcweir         ~NestedUserCallHdl()
1220cdf0e10cSrcweir         {
1221cdf0e10cSrcweir             if ( mpDrawContact )
1222cdf0e10cSrcweir             {
1223cdf0e10cSrcweir                 mpDrawContact->mbUserCallActive = mbParentUserCallActive;
1224cdf0e10cSrcweir                 mpDrawContact->meEventTypeOfCurrentUserCall = meParentUserCallEventType;
1225cdf0e10cSrcweir             }
1226cdf0e10cSrcweir         }
1227cdf0e10cSrcweir 
DrawContactDeleted()1228cdf0e10cSrcweir         void DrawContactDeleted()
1229cdf0e10cSrcweir         {
1230cdf0e10cSrcweir             mpDrawContact = 0;
1231cdf0e10cSrcweir         }
1232cdf0e10cSrcweir 
IsNestedUserCall()1233cdf0e10cSrcweir         bool IsNestedUserCall()
1234cdf0e10cSrcweir         {
1235cdf0e10cSrcweir             return mbParentUserCallActive;
1236cdf0e10cSrcweir         }
1237cdf0e10cSrcweir 
AssertNestedUserCall()1238cdf0e10cSrcweir         void AssertNestedUserCall()
1239cdf0e10cSrcweir         {
1240cdf0e10cSrcweir             if ( IsNestedUserCall() )
1241cdf0e10cSrcweir             {
1242cdf0e10cSrcweir                 bool bTmpAssert( true );
1243cdf0e10cSrcweir                 // Currently its known, that a nested event SDRUSERCALL_RESIZE
1244cdf0e10cSrcweir                 // could occur during parent user call SDRUSERCALL_INSERTED,
1245cdf0e10cSrcweir                 // SDRUSERCALL_DELETE and SDRUSERCALL_RESIZE for edge objects.
1246cdf0e10cSrcweir                 // Also possible are nested SDRUSERCALL_CHILD_RESIZE events for
1247cdf0e10cSrcweir                 // edge objects
1248cdf0e10cSrcweir                 // Thus, assert all other combinations
1249cdf0e10cSrcweir                 if ( ( meParentUserCallEventType == SDRUSERCALL_INSERTED ||
1250cdf0e10cSrcweir                        meParentUserCallEventType == SDRUSERCALL_DELETE ||
1251cdf0e10cSrcweir                        meParentUserCallEventType == SDRUSERCALL_RESIZE ) &&
1252cdf0e10cSrcweir                      mpDrawContact->meEventTypeOfCurrentUserCall == SDRUSERCALL_RESIZE )
1253cdf0e10cSrcweir                 {
1254cdf0e10cSrcweir                     bTmpAssert = false;
1255cdf0e10cSrcweir                 }
1256cdf0e10cSrcweir                 else if ( meParentUserCallEventType == SDRUSERCALL_CHILD_RESIZE &&
1257cdf0e10cSrcweir                           mpDrawContact->meEventTypeOfCurrentUserCall == SDRUSERCALL_CHILD_RESIZE )
1258cdf0e10cSrcweir                 {
1259cdf0e10cSrcweir                     bTmpAssert = false;
1260cdf0e10cSrcweir                 }
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir                 if ( bTmpAssert )
1263cdf0e10cSrcweir                 {
1264cdf0e10cSrcweir                     ASSERT( false,
1265cdf0e10cSrcweir                             "<SwDrawContact::_Changed(..)> - unknown nested <UserCall> event. This is serious, please inform OD." );
1266cdf0e10cSrcweir                 }
1267cdf0e10cSrcweir             }
1268cdf0e10cSrcweir         }
1269cdf0e10cSrcweir };
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir // <--
1272cdf0e10cSrcweir //
1273cdf0e10cSrcweir // !!!ACHTUNG!!! The object may commit suicide!!!
1274cdf0e10cSrcweir //
_Changed(const SdrObject & rObj,SdrUserCallType eType,const Rectangle * pOldBoundRect)1275cdf0e10cSrcweir void SwDrawContact::_Changed( const SdrObject& rObj,
1276cdf0e10cSrcweir                               SdrUserCallType eType,
1277cdf0e10cSrcweir                               const Rectangle* pOldBoundRect )
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir     // --> OD 2006-01-18 #129959#
1280cdf0e10cSrcweir     // suppress handling of nested <SdrObjUserCall> events
1281cdf0e10cSrcweir     NestedUserCallHdl aNestedUserCallHdl( this, eType );
1282cdf0e10cSrcweir     if ( aNestedUserCallHdl.IsNestedUserCall() )
1283cdf0e10cSrcweir     {
1284cdf0e10cSrcweir         aNestedUserCallHdl.AssertNestedUserCall();
1285cdf0e10cSrcweir         return;
1286cdf0e10cSrcweir     }
1287cdf0e10cSrcweir     // <--
1288cdf0e10cSrcweir     // OD 05.08.2002 #100843# - do *not* notify, if document is destructing
1289cdf0e10cSrcweir     // --> OD 2004-10-21 #i35912# - do *not* notify for as-character anchored
1290cdf0e10cSrcweir     // drawing objects.
1291cdf0e10cSrcweir     // --> OD 2004-11-11 #i35007#
1292cdf0e10cSrcweir     // improvement: determine as-character anchored object flag only once.
1293cdf0e10cSrcweir     const bool bAnchoredAsChar = ObjAnchoredAsChar();
1294cdf0e10cSrcweir     // <--
1295cdf0e10cSrcweir     const bool bNotify = !(GetFmt()->GetDoc()->IsInDtor()) &&
1296cdf0e10cSrcweir                          ( SURROUND_THROUGHT != GetFmt()->GetSurround().GetSurround() ) &&
1297cdf0e10cSrcweir                          !bAnchoredAsChar;
1298cdf0e10cSrcweir     // <--
1299cdf0e10cSrcweir 	switch( eType )
1300cdf0e10cSrcweir 	{
1301cdf0e10cSrcweir 		case SDRUSERCALL_DELETE:
1302cdf0e10cSrcweir 			{
1303cdf0e10cSrcweir                 if ( bNotify )
1304cdf0e10cSrcweir                 {
1305cdf0e10cSrcweir                     lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1306cdf0e10cSrcweir                     // --> OD 2004-10-27 #i36181# - background of 'virtual'
1307cdf0e10cSrcweir                     // drawing objects have also been notified.
1308cdf0e10cSrcweir                     NotifyBackgrdOfAllVirtObjs( pOldBoundRect );
1309cdf0e10cSrcweir                     // <--
1310cdf0e10cSrcweir                 }
1311cdf0e10cSrcweir                 DisconnectFromLayout( false );
1312cdf0e10cSrcweir 				SetMaster( NULL );
1313cdf0e10cSrcweir 				delete this;
1314cdf0e10cSrcweir                 // --> FME 2006-07-12 #i65784# Prevent memory corruption
1315cdf0e10cSrcweir                 aNestedUserCallHdl.DrawContactDeleted();
1316cdf0e10cSrcweir                 // <--
1317cdf0e10cSrcweir 				break;
1318cdf0e10cSrcweir 			}
1319cdf0e10cSrcweir 		case SDRUSERCALL_INSERTED:
1320cdf0e10cSrcweir 			{
1321cdf0e10cSrcweir                 // OD 10.10.2003 #112299#
1322cdf0e10cSrcweir                 if ( mbDisconnectInProgress )
1323cdf0e10cSrcweir                 {
1324cdf0e10cSrcweir                     ASSERT( false,
1325cdf0e10cSrcweir                             "<SwDrawContact::_Changed(..)> - Insert event during disconnection from layout is invalid." );
1326cdf0e10cSrcweir                 }
1327cdf0e10cSrcweir                 else
1328cdf0e10cSrcweir                 {
1329cdf0e10cSrcweir                     ConnectToLayout();
1330cdf0e10cSrcweir                     if ( bNotify )
1331cdf0e10cSrcweir                     {
1332cdf0e10cSrcweir                         lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1333cdf0e10cSrcweir                     }
1334cdf0e10cSrcweir                 }
1335cdf0e10cSrcweir 				break;
1336cdf0e10cSrcweir 			}
1337cdf0e10cSrcweir 		case SDRUSERCALL_REMOVED:
1338cdf0e10cSrcweir 			{
1339cdf0e10cSrcweir                 if ( bNotify )
1340cdf0e10cSrcweir                 {
1341cdf0e10cSrcweir                     lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1342cdf0e10cSrcweir                 }
1343cdf0e10cSrcweir                 DisconnectFromLayout( false );
1344cdf0e10cSrcweir 				break;
1345cdf0e10cSrcweir 			}
1346cdf0e10cSrcweir         case SDRUSERCALL_CHILD_INSERTED :
1347cdf0e10cSrcweir         case SDRUSERCALL_CHILD_REMOVED :
1348cdf0e10cSrcweir         {
1349cdf0e10cSrcweir             // --> AW, OD 2010-09-13 #i113730#
1350cdf0e10cSrcweir             // force layer of controls for group objects containing control objects
1351cdf0e10cSrcweir             if(dynamic_cast< SdrObjGroup* >(maAnchoredDrawObj.DrawObj()))
1352cdf0e10cSrcweir             {
1353cdf0e10cSrcweir                 if(::CheckControlLayer(maAnchoredDrawObj.DrawObj()))
1354cdf0e10cSrcweir                 {
1355cdf0e10cSrcweir                     const IDocumentDrawModelAccess* pIDDMA = static_cast<SwFrmFmt*>(GetRegisteredInNonConst())->getIDocumentDrawModelAccess();
1356cdf0e10cSrcweir                     const SdrLayerID aCurrentLayer(maAnchoredDrawObj.DrawObj()->GetLayer());
1357cdf0e10cSrcweir                     const SdrLayerID aControlLayerID(pIDDMA->GetControlsId());
1358cdf0e10cSrcweir                     const SdrLayerID aInvisibleControlLayerID(pIDDMA->GetInvisibleControlsId());
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir                     if(aCurrentLayer != aControlLayerID && aCurrentLayer != aInvisibleControlLayerID)
1361cdf0e10cSrcweir                     {
1362cdf0e10cSrcweir                         if ( aCurrentLayer == pIDDMA->GetInvisibleHellId() ||
1363cdf0e10cSrcweir                              aCurrentLayer == pIDDMA->GetInvisibleHeavenId() )
1364cdf0e10cSrcweir                         {
1365cdf0e10cSrcweir                             maAnchoredDrawObj.DrawObj()->SetLayer(aInvisibleControlLayerID);
1366cdf0e10cSrcweir                         }
1367cdf0e10cSrcweir                         else
1368cdf0e10cSrcweir                         {
1369cdf0e10cSrcweir                             maAnchoredDrawObj.DrawObj()->SetLayer(aControlLayerID);
1370cdf0e10cSrcweir                         }
1371cdf0e10cSrcweir                     }
1372cdf0e10cSrcweir                 }
1373cdf0e10cSrcweir             }
1374cdf0e10cSrcweir             // fallthrough intended here
1375cdf0e10cSrcweir             // <--
1376cdf0e10cSrcweir         }
1377cdf0e10cSrcweir         case SDRUSERCALL_MOVEONLY:
1378cdf0e10cSrcweir 		case SDRUSERCALL_RESIZE:
1379cdf0e10cSrcweir 		case SDRUSERCALL_CHILD_MOVEONLY :
1380cdf0e10cSrcweir 		case SDRUSERCALL_CHILD_RESIZE :
1381cdf0e10cSrcweir 		case SDRUSERCALL_CHILD_CHGATTR :
1382cdf0e10cSrcweir 		case SDRUSERCALL_CHILD_DELETE :
1383cdf0e10cSrcweir 		case SDRUSERCALL_CHILD_COPY :
1384cdf0e10cSrcweir         {
1385cdf0e10cSrcweir             // --> OD 2004-08-04 #i31698# - improvement:
1386cdf0e10cSrcweir             // get instance <SwAnchoredDrawObject> only once
1387cdf0e10cSrcweir             const SwAnchoredDrawObject* pAnchoredDrawObj =
1388cdf0e10cSrcweir                 static_cast<const SwAnchoredDrawObject*>( GetAnchoredObj( &rObj ) );
1389cdf0e10cSrcweir             // <--
1390cdf0e10cSrcweir             // OD 2004-04-06 #i26791# - adjust positioning and alignment attributes,
1391cdf0e10cSrcweir             // if positioning of drawing object isn't in progress.
1392cdf0e10cSrcweir             // --> OD 2005-08-15 #i53320# - no adjust of positioning attributes,
1393cdf0e10cSrcweir             // if drawing object isn't positioned.
1394cdf0e10cSrcweir             if ( !pAnchoredDrawObj->IsPositioningInProgress() &&
1395cdf0e10cSrcweir                  !pAnchoredDrawObj->NotYetPositioned() )
1396cdf0e10cSrcweir             // <--
1397cdf0e10cSrcweir             {
1398cdf0e10cSrcweir                 // --> OD 2004-09-29 #i34748# - If no last object rectangle is
1399cdf0e10cSrcweir                 // provided by the anchored object, use parameter <pOldBoundRect>.
1400cdf0e10cSrcweir                 const Rectangle& aOldObjRect = pAnchoredDrawObj->GetLastObjRect()
1401cdf0e10cSrcweir                                                ? *(pAnchoredDrawObj->GetLastObjRect())
1402cdf0e10cSrcweir                                                : *(pOldBoundRect);
1403cdf0e10cSrcweir                 // <--
1404cdf0e10cSrcweir                 // --> OD 2008-02-18 #i79400#
1405cdf0e10cSrcweir                 // always invalidate object rectangle inclusive spaces
1406cdf0e10cSrcweir                 pAnchoredDrawObj->InvalidateObjRectWithSpaces();
1407cdf0e10cSrcweir                 // <--
1408cdf0e10cSrcweir                 // --> OD 2005-01-28 #i41324# - notify background before
1409cdf0e10cSrcweir                 // adjusting position
1410cdf0e10cSrcweir                 if ( bNotify )
1411cdf0e10cSrcweir                 {
1412cdf0e10cSrcweir                     // --> OD 2004-07-20 #i31573# - correction: Only invalidate
1413cdf0e10cSrcweir                     // background of given drawing object.
1414cdf0e10cSrcweir                     lcl_NotifyBackgroundOfObj( *this, rObj, &aOldObjRect );
1415cdf0e10cSrcweir                 }
1416cdf0e10cSrcweir                 // <--
1417cdf0e10cSrcweir                 // --> OD 2004-08-04 #i31698# - determine layout direction
1418cdf0e10cSrcweir                 // via draw frame format.
1419cdf0e10cSrcweir                 SwFrmFmt::tLayoutDir eLayoutDir =
1420cdf0e10cSrcweir                                 pAnchoredDrawObj->GetFrmFmt().GetLayoutDir();
1421cdf0e10cSrcweir                 // <--
1422cdf0e10cSrcweir                 // use geometry of drawing object
1423cdf0e10cSrcweir                 SwRect aObjRect( rObj.GetSnapRect() );
1424cdf0e10cSrcweir                 // If drawing object is a member of a group, the adjustment
1425cdf0e10cSrcweir                 // of the positioning and the alignment attributes has to
1426cdf0e10cSrcweir                 // be done for the top group object.
1427cdf0e10cSrcweir                 if ( rObj.GetUpGroup() )
1428cdf0e10cSrcweir                 {
1429cdf0e10cSrcweir                     const SdrObject* pGroupObj = rObj.GetUpGroup();
1430cdf0e10cSrcweir                     while ( pGroupObj->GetUpGroup() )
1431cdf0e10cSrcweir                     {
1432cdf0e10cSrcweir                         pGroupObj = pGroupObj->GetUpGroup();
1433cdf0e10cSrcweir                     }
1434cdf0e10cSrcweir                     // use geometry of drawing object
1435cdf0e10cSrcweir                     aObjRect = pGroupObj->GetSnapRect();
1436cdf0e10cSrcweir                 }
1437cdf0e10cSrcweir                 SwTwips nXPosDiff(0L);
1438cdf0e10cSrcweir                 SwTwips nYPosDiff(0L);
1439cdf0e10cSrcweir                 switch ( eLayoutDir )
1440cdf0e10cSrcweir                 {
1441cdf0e10cSrcweir                     case SwFrmFmt::HORI_L2R:
1442cdf0e10cSrcweir                     {
1443cdf0e10cSrcweir                         nXPosDiff = aObjRect.Left() - aOldObjRect.Left();
1444cdf0e10cSrcweir                         nYPosDiff = aObjRect.Top() - aOldObjRect.Top();
1445cdf0e10cSrcweir                     }
1446cdf0e10cSrcweir                     break;
1447cdf0e10cSrcweir                     case SwFrmFmt::HORI_R2L:
1448cdf0e10cSrcweir                     {
1449cdf0e10cSrcweir                         nXPosDiff = aOldObjRect.Right() - aObjRect.Right();
1450cdf0e10cSrcweir                         nYPosDiff = aObjRect.Top() - aOldObjRect.Top();
1451cdf0e10cSrcweir                     }
1452cdf0e10cSrcweir                     break;
1453cdf0e10cSrcweir                     case SwFrmFmt::VERT_R2L:
1454cdf0e10cSrcweir                     {
1455cdf0e10cSrcweir                         nXPosDiff = aObjRect.Top() - aOldObjRect.Top();
1456cdf0e10cSrcweir                         nYPosDiff = aOldObjRect.Right() - aObjRect.Right();
1457cdf0e10cSrcweir                     }
1458cdf0e10cSrcweir                     break;
1459cdf0e10cSrcweir                     default:
1460cdf0e10cSrcweir                     {
1461cdf0e10cSrcweir                         ASSERT( false,
1462cdf0e10cSrcweir                                 "<SwDrawContact::_Changed(..)> - unsupported layout direction" );
1463cdf0e10cSrcweir                     }
1464cdf0e10cSrcweir                 }
1465cdf0e10cSrcweir                 SfxItemSet aSet( GetFmt()->GetDoc()->GetAttrPool(),
1466cdf0e10cSrcweir                                  RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
1467cdf0e10cSrcweir                 const SwFmtVertOrient& rVert = GetFmt()->GetVertOrient();
1468cdf0e10cSrcweir                 if ( nYPosDiff != 0 )
1469cdf0e10cSrcweir                 {
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir                     if ( rVert.GetRelationOrient() == text::RelOrientation::CHAR ||
1472cdf0e10cSrcweir                          rVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
1473cdf0e10cSrcweir                     {
1474cdf0e10cSrcweir                         nYPosDiff = -nYPosDiff;
1475cdf0e10cSrcweir                     }
1476cdf0e10cSrcweir                     aSet.Put( SwFmtVertOrient( rVert.GetPos()+nYPosDiff,
1477cdf0e10cSrcweir                                                text::VertOrientation::NONE,
1478cdf0e10cSrcweir                                                rVert.GetRelationOrient() ) );
1479cdf0e10cSrcweir                 }
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir                 const SwFmtHoriOrient& rHori = GetFmt()->GetHoriOrient();
1482cdf0e10cSrcweir                 if ( !bAnchoredAsChar && nXPosDiff != 0 )
1483cdf0e10cSrcweir                 {
1484cdf0e10cSrcweir                     aSet.Put( SwFmtHoriOrient( rHori.GetPos()+nXPosDiff,
1485cdf0e10cSrcweir                                                text::HoriOrientation::NONE,
1486cdf0e10cSrcweir                                                rHori.GetRelationOrient() ) );
1487cdf0e10cSrcweir                 }
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir                 if ( nYPosDiff ||
1490cdf0e10cSrcweir                      ( !bAnchoredAsChar && nXPosDiff != 0 ) )
1491cdf0e10cSrcweir                 {
1492cdf0e10cSrcweir                     GetFmt()->GetDoc()->SetFlyFrmAttr( *(GetFmt()), aSet );
1493cdf0e10cSrcweir                     // keep new object rectangle, to avoid multiple
1494cdf0e10cSrcweir                     // changes of the attributes by multiple event from
1495cdf0e10cSrcweir                     // the drawing layer - e.g. group objects and its members
1496cdf0e10cSrcweir                     // --> OD 2004-09-29 #i34748# - use new method
1497cdf0e10cSrcweir                     // <SwAnchoredDrawObject::SetLastObjRect(..)>.
1498cdf0e10cSrcweir                     const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj)
1499cdf0e10cSrcweir                                     ->SetLastObjRect( aObjRect.SVRect() );
1500cdf0e10cSrcweir                 }
1501cdf0e10cSrcweir                 else if ( aObjRect.SSize() != aOldObjRect.GetSize() )
1502cdf0e10cSrcweir                 {
1503cdf0e10cSrcweir                     _InvalidateObjs();
1504cdf0e10cSrcweir                     // --> OD 2004-11-11 #i35007# - notify anchor frame
1505cdf0e10cSrcweir                     // of as-character anchored object
1506cdf0e10cSrcweir                     if ( bAnchoredAsChar )
1507cdf0e10cSrcweir                     {
1508371e7ce6SJian Hong Cheng                         //-->Modified for i119654,2012.6.8
1509d4302b39SOliver-Rainer Wittmann                         SwFrm* pAnchorFrame = pAnchoredDrawObj
1510d4302b39SOliver-Rainer Wittmann                                               ? const_cast<SwAnchoredDrawObject*>( pAnchoredDrawObj )->AnchorFrm()
1511d4302b39SOliver-Rainer Wittmann                                               : NULL;
1512d4302b39SOliver-Rainer Wittmann                         if ( pAnchorFrame )
1513d4302b39SOliver-Rainer Wittmann                         {
1514371e7ce6SJian Hong Cheng                             pAnchorFrame->Prepare( PREP_FLY_ATTR_CHG, GetFmt() );
1515d4302b39SOliver-Rainer Wittmann                         }
1516371e7ce6SJian Hong Cheng                         //<--
1517cdf0e10cSrcweir                     }
1518cdf0e10cSrcweir                     // <--
1519cdf0e10cSrcweir                 }
1520cdf0e10cSrcweir             }
1521cdf0e10cSrcweir             // --> OD 2006-01-18 #129959#
1522cdf0e10cSrcweir             // It reveals that the following code causes several defects -
1523cdf0e10cSrcweir             // on copying or on ungrouping a group shape containing edge objects.
1524cdf0e10cSrcweir             // Testing fix for #i53320# also reveal that the following code
1525cdf0e10cSrcweir             // isn't necessary.
1526cdf0e10cSrcweir //            // --> OD 2005-08-15 #i53320# - reset positioning attributes,
1527cdf0e10cSrcweir //            // if anchored drawing object isn't yet positioned.
1528cdf0e10cSrcweir //            else if ( pAnchoredDrawObj->NotYetPositioned() &&
1529cdf0e10cSrcweir //                      static_cast<const SwDrawFrmFmt&>(pAnchoredDrawObj->GetFrmFmt()).IsPosAttrSet() )
1530cdf0e10cSrcweir //            {
1531cdf0e10cSrcweir //                const_cast<SwDrawFrmFmt&>(
1532cdf0e10cSrcweir //                    static_cast<const SwDrawFrmFmt&>(pAnchoredDrawObj->GetFrmFmt()))
1533cdf0e10cSrcweir //                        .ResetPosAttr();
1534cdf0e10cSrcweir //            }
1535cdf0e10cSrcweir //            // <--
1536cdf0e10cSrcweir             // <--
1537cdf0e10cSrcweir         }
1538cdf0e10cSrcweir         break;
1539cdf0e10cSrcweir 		case SDRUSERCALL_CHGATTR:
1540cdf0e10cSrcweir             if ( bNotify )
1541cdf0e10cSrcweir             {
1542cdf0e10cSrcweir                 lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1543cdf0e10cSrcweir             }
1544cdf0e10cSrcweir 			break;
1545cdf0e10cSrcweir         default:
1546cdf0e10cSrcweir             break;
1547cdf0e10cSrcweir 	}
1548cdf0e10cSrcweir }
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir namespace
1551cdf0e10cSrcweir {
lcl_getAnchorFmt(const SfxPoolItem & _rItem)1552cdf0e10cSrcweir     static const SwFmtAnchor* lcl_getAnchorFmt( const SfxPoolItem& _rItem )
1553cdf0e10cSrcweir     {
1554cdf0e10cSrcweir 	    sal_uInt16 nWhich = _rItem.Which();
1555cdf0e10cSrcweir         const SwFmtAnchor* pAnchorFmt = NULL;
1556cdf0e10cSrcweir         if ( RES_ATTRSET_CHG == nWhich )
1557cdf0e10cSrcweir 	    {
1558cdf0e10cSrcweir             static_cast<const SwAttrSetChg&>(_rItem).GetChgSet()->
1559cdf0e10cSrcweir                 GetItemState( RES_ANCHOR, sal_False, (const SfxPoolItem**)&pAnchorFmt );
1560cdf0e10cSrcweir 	    }
1561cdf0e10cSrcweir         else if ( RES_ANCHOR == nWhich )
1562cdf0e10cSrcweir         {
1563cdf0e10cSrcweir             pAnchorFmt = &static_cast<const SwFmtAnchor&>(_rItem);
1564cdf0e10cSrcweir         }
1565cdf0e10cSrcweir         return pAnchorFmt;
1566cdf0e10cSrcweir     }
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir /*************************************************************************
1570cdf0e10cSrcweir |*
1571cdf0e10cSrcweir |*	SwDrawContact::Modify()
1572cdf0e10cSrcweir |*
1573cdf0e10cSrcweir |*	Ersterstellung		MA 09. Jan. 95
1574cdf0e10cSrcweir |*	Letzte Aenderung	MA 03. Dec. 95
1575cdf0e10cSrcweir |*
1576cdf0e10cSrcweir |*************************************************************************/
1577cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)1578cdf0e10cSrcweir void SwDrawContact::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
1579cdf0e10cSrcweir {
1580cdf0e10cSrcweir     // OD 10.10.2003 #112299#
1581cdf0e10cSrcweir     ASSERT( !mbDisconnectInProgress,
1582cdf0e10cSrcweir             "<SwDrawContact::Modify(..)> called during disconnection.");
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir 	sal_uInt16 nWhich = pNew ? pNew->Which() : 0;
1585cdf0e10cSrcweir     const SwFmtAnchor* pNewAnchorFmt = pNew ? lcl_getAnchorFmt( *pNew ) : NULL;
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir     if ( pNewAnchorFmt )
1588cdf0e10cSrcweir 	{
1589cdf0e10cSrcweir 		// JP 10.04.95: nicht auf ein Reset Anchor reagieren !!!!!
1590cdf0e10cSrcweir         if ( SFX_ITEM_SET ==
1591cdf0e10cSrcweir                 GetFmt()->GetAttrSet().GetItemState( RES_ANCHOR, sal_False ) )
1592cdf0e10cSrcweir 		{
1593cdf0e10cSrcweir             // OD 10.10.2003 #112299# - no connect to layout during disconnection
1594cdf0e10cSrcweir             if ( !mbDisconnectInProgress )
1595cdf0e10cSrcweir             {
1596cdf0e10cSrcweir                 // determine old object retangle of 'master' drawing object
1597cdf0e10cSrcweir                 // for notification
1598cdf0e10cSrcweir                 const Rectangle* pOldRect = 0L;
1599cdf0e10cSrcweir                 Rectangle aOldRect;
1600cdf0e10cSrcweir                 if ( GetAnchorFrm() )
1601cdf0e10cSrcweir                 {
1602cdf0e10cSrcweir                     // --> OD 2004-10-27 #i36181# - include spacing in object
1603cdf0e10cSrcweir                     // rectangle for notification.
1604cdf0e10cSrcweir                     aOldRect = maAnchoredDrawObj.GetObjRectWithSpaces().SVRect();
1605cdf0e10cSrcweir                     pOldRect = &aOldRect;
1606cdf0e10cSrcweir                     // <--
1607cdf0e10cSrcweir                 }
1608cdf0e10cSrcweir                 // re-connect to layout due to anchor format change
1609cdf0e10cSrcweir                 ConnectToLayout( pNewAnchorFmt );
1610cdf0e10cSrcweir                 // notify background of drawing objects
1611cdf0e10cSrcweir                 lcl_NotifyBackgroundOfObj( *this, *GetMaster(), pOldRect );
1612cdf0e10cSrcweir                 NotifyBackgrdOfAllVirtObjs( pOldRect );
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir                 const SwFmtAnchor* pOldAnchorFmt = pOld ? lcl_getAnchorFmt( *pOld ) : NULL;
1615cdf0e10cSrcweir                 if ( !pOldAnchorFmt || ( pOldAnchorFmt->GetAnchorId() != pNewAnchorFmt->GetAnchorId() ) )
1616cdf0e10cSrcweir                 {
1617cdf0e10cSrcweir                     ASSERT( maAnchoredDrawObj.DrawObj(), "SwDrawContact::Modify: no draw object here?" );
1618cdf0e10cSrcweir                     if ( maAnchoredDrawObj.DrawObj() )
1619cdf0e10cSrcweir                     {
1620cdf0e10cSrcweir                         // --> OD 2009-07-10 #i102752#
1621cdf0e10cSrcweir                         // assure that a ShapePropertyChangeNotifier exists
1622cdf0e10cSrcweir                         maAnchoredDrawObj.DrawObj()->notifyShapePropertyChange( ::svx::eTextShapeAnchorType );
1623cdf0e10cSrcweir                         // <--
1624cdf0e10cSrcweir                     }
1625cdf0e10cSrcweir                 }
1626cdf0e10cSrcweir             }
1627cdf0e10cSrcweir 		}
1628cdf0e10cSrcweir 		else
1629cdf0e10cSrcweir 			DisconnectFromLayout();
1630cdf0e10cSrcweir 	}
1631cdf0e10cSrcweir     // --> OD 2006-03-17 #i62875# - revised fix for issue #124157#
1632cdf0e10cSrcweir     // no further notification, if not connected to Writer layout
1633cdf0e10cSrcweir     else if ( maAnchoredDrawObj.GetAnchorFrm() &&
1634cdf0e10cSrcweir               maAnchoredDrawObj.GetDrawObj()->GetUserCall() )
1635cdf0e10cSrcweir     {
1636cdf0e10cSrcweir         // --> OD 2004-07-01 #i28701# - on change of wrapping style, hell|heaven layer,
1637cdf0e10cSrcweir         // or wrapping style influence an update of the <SwSortedObjs> list,
1638cdf0e10cSrcweir         // the drawing object is registered in, has to be performed. This is triggered
1639cdf0e10cSrcweir         // by the 1st parameter of method call <_InvalidateObjs(..)>.
1640cdf0e10cSrcweir         if ( RES_SURROUND == nWhich ||
1641cdf0e10cSrcweir              RES_OPAQUE == nWhich ||
1642cdf0e10cSrcweir              RES_WRAP_INFLUENCE_ON_OBJPOS == nWhich ||
1643cdf0e10cSrcweir              ( RES_ATTRSET_CHG == nWhich &&
1644cdf0e10cSrcweir                ( SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1645cdf0e10cSrcweir                            RES_SURROUND, sal_False ) ||
1646cdf0e10cSrcweir                  SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1647cdf0e10cSrcweir                            RES_OPAQUE, sal_False ) ||
1648cdf0e10cSrcweir                  SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1649cdf0e10cSrcweir                            RES_WRAP_INFLUENCE_ON_OBJPOS, sal_False ) ) ) )
1650cdf0e10cSrcweir         {
1651cdf0e10cSrcweir             lcl_NotifyBackgroundOfObj( *this, *GetMaster(), 0L );
1652cdf0e10cSrcweir             NotifyBackgrdOfAllVirtObjs( 0L );
1653cdf0e10cSrcweir             _InvalidateObjs( true );
1654cdf0e10cSrcweir         }
1655cdf0e10cSrcweir         else if ( RES_UL_SPACE == nWhich || RES_LR_SPACE == nWhich ||
1656cdf0e10cSrcweir                   RES_HORI_ORIENT == nWhich || RES_VERT_ORIENT == nWhich ||
1657cdf0e10cSrcweir                   // --> OD 2004-07-01 #i28701# - add attribute 'Follow text flow'
1658cdf0e10cSrcweir                   RES_FOLLOW_TEXT_FLOW == nWhich ||
1659cdf0e10cSrcweir                   ( RES_ATTRSET_CHG == nWhich &&
1660cdf0e10cSrcweir                     ( SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1661cdf0e10cSrcweir                                 RES_LR_SPACE, sal_False ) ||
1662cdf0e10cSrcweir                       SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1663cdf0e10cSrcweir                                 RES_UL_SPACE, sal_False ) ||
1664cdf0e10cSrcweir                       SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1665cdf0e10cSrcweir                                 RES_HORI_ORIENT, sal_False ) ||
1666cdf0e10cSrcweir                       SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1667cdf0e10cSrcweir                                 RES_VERT_ORIENT, sal_False ) ||
1668cdf0e10cSrcweir                       SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
1669cdf0e10cSrcweir                                 RES_FOLLOW_TEXT_FLOW, sal_False ) ) ) )
1670cdf0e10cSrcweir         {
1671cdf0e10cSrcweir             lcl_NotifyBackgroundOfObj( *this, *GetMaster(), 0L );
1672cdf0e10cSrcweir             NotifyBackgrdOfAllVirtObjs( 0L );
1673cdf0e10cSrcweir             _InvalidateObjs();
1674cdf0e10cSrcweir         }
1675cdf0e10cSrcweir         // --> OD 2004-10-26 #i35443#
1676cdf0e10cSrcweir         else if ( RES_ATTRSET_CHG == nWhich )
1677cdf0e10cSrcweir         {
1678cdf0e10cSrcweir             lcl_NotifyBackgroundOfObj( *this, *GetMaster(), 0L );
1679cdf0e10cSrcweir             NotifyBackgrdOfAllVirtObjs( 0L );
1680cdf0e10cSrcweir             _InvalidateObjs();
1681cdf0e10cSrcweir         }
1682cdf0e10cSrcweir         // <--
1683cdf0e10cSrcweir         else if ( RES_REMOVE_UNO_OBJECT == nWhich )
1684cdf0e10cSrcweir         {
1685cdf0e10cSrcweir             // nothing to do
1686cdf0e10cSrcweir         }
1687cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1688cdf0e10cSrcweir         else
1689cdf0e10cSrcweir         {
1690cdf0e10cSrcweir             ASSERT( false,
1691cdf0e10cSrcweir                     "<SwDrawContact::Modify(..)> - unhandled attribute? - please inform od@openoffice.org" );
1692cdf0e10cSrcweir         }
1693cdf0e10cSrcweir #endif
1694cdf0e10cSrcweir     }
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir     // --> OD 2005-07-18 #i51474#
1697cdf0e10cSrcweir     GetAnchoredObj( 0L )->ResetLayoutProcessBools();
1698cdf0e10cSrcweir     // <--
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir // OD 2004-03-31 #i26791#
1702cdf0e10cSrcweir // --> OD 2004-07-01 #i28701# - added parameter <_bUpdateSortedObjsList>
_InvalidateObjs(const bool _bUpdateSortedObjsList)1703cdf0e10cSrcweir void SwDrawContact::_InvalidateObjs( const bool _bUpdateSortedObjsList )
1704cdf0e10cSrcweir {
1705cdf0e10cSrcweir     // invalidate position of existing 'virtual' drawing objects
1706cdf0e10cSrcweir     for ( std::list<SwDrawVirtObj*>::iterator aDisconnectIter = maDrawVirtObjs.begin();
1707cdf0e10cSrcweir           aDisconnectIter != maDrawVirtObjs.end();
1708cdf0e10cSrcweir           ++aDisconnectIter )
1709cdf0e10cSrcweir     {
1710cdf0e10cSrcweir         SwDrawVirtObj* pDrawVirtObj = (*aDisconnectIter);
1711cdf0e10cSrcweir         // --> OD 2004-08-23 #i33313# - invalidation only for connected
1712cdf0e10cSrcweir         // 'virtual' drawing objects
1713cdf0e10cSrcweir         if ( pDrawVirtObj->IsConnected() )
1714cdf0e10cSrcweir         {
1715cdf0e10cSrcweir             pDrawVirtObj->AnchoredObj()->InvalidateObjPos();
1716cdf0e10cSrcweir             // --> OD 2004-07-01 #i28701#
1717cdf0e10cSrcweir             if ( _bUpdateSortedObjsList )
1718cdf0e10cSrcweir             {
1719cdf0e10cSrcweir                 pDrawVirtObj->AnchoredObj()->UpdateObjInSortedList();
1720cdf0e10cSrcweir             }
1721cdf0e10cSrcweir             // <--
1722cdf0e10cSrcweir         }
1723cdf0e10cSrcweir         // <--
1724cdf0e10cSrcweir     }
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir     // invalidate position of 'master' drawing object
1727cdf0e10cSrcweir     SwAnchoredObject* pAnchoredObj = GetAnchoredObj( 0L );
1728cdf0e10cSrcweir     pAnchoredObj->InvalidateObjPos();
1729cdf0e10cSrcweir     // --> OD 2004-07-01 #i28701#
1730cdf0e10cSrcweir     if ( _bUpdateSortedObjsList )
1731cdf0e10cSrcweir     {
1732cdf0e10cSrcweir         pAnchoredObj->UpdateObjInSortedList();
1733cdf0e10cSrcweir     }
1734cdf0e10cSrcweir     // <--
1735cdf0e10cSrcweir }
1736cdf0e10cSrcweir 
1737cdf0e10cSrcweir /*************************************************************************
1738cdf0e10cSrcweir |*
1739cdf0e10cSrcweir |*	SwDrawContact::DisconnectFromLayout()
1740cdf0e10cSrcweir |*
1741cdf0e10cSrcweir |*	Ersterstellung		MA 09. Jan. 95
1742cdf0e10cSrcweir |*	Letzte Aenderung	MA 25. Mar. 99
1743cdf0e10cSrcweir |*
1744cdf0e10cSrcweir |*************************************************************************/
1745cdf0e10cSrcweir 
DisconnectFromLayout(bool _bMoveMasterToInvisibleLayer)1746cdf0e10cSrcweir void SwDrawContact::DisconnectFromLayout( bool _bMoveMasterToInvisibleLayer )
1747cdf0e10cSrcweir {
1748cdf0e10cSrcweir     // OD 10.10.2003 #112299#
1749cdf0e10cSrcweir     mbDisconnectInProgress = true;
1750cdf0e10cSrcweir 
1751cdf0e10cSrcweir     // --> OD 2004-10-27 #i36181# - notify background of drawing object
1752cdf0e10cSrcweir     if ( _bMoveMasterToInvisibleLayer &&
1753cdf0e10cSrcweir          !(GetFmt()->GetDoc()->IsInDtor()) &&
1754cdf0e10cSrcweir          GetAnchorFrm() )
1755cdf0e10cSrcweir     {
1756cdf0e10cSrcweir         const Rectangle aOldRect( maAnchoredDrawObj.GetObjRectWithSpaces().SVRect() );
1757cdf0e10cSrcweir         lcl_NotifyBackgroundOfObj( *this, *GetMaster(), &aOldRect );
1758cdf0e10cSrcweir         NotifyBackgrdOfAllVirtObjs( &aOldRect );
1759cdf0e10cSrcweir     }
1760cdf0e10cSrcweir     // <--
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir     // OD 16.05.2003 #108784# - remove 'virtual' drawing objects from writer
1763cdf0e10cSrcweir     // layout and from drawing page
1764cdf0e10cSrcweir     for ( std::list<SwDrawVirtObj*>::iterator aDisconnectIter = maDrawVirtObjs.begin();
1765cdf0e10cSrcweir           aDisconnectIter != maDrawVirtObjs.end();
1766cdf0e10cSrcweir           ++aDisconnectIter )
1767cdf0e10cSrcweir     {
1768cdf0e10cSrcweir         SwDrawVirtObj* pDrawVirtObj = (*aDisconnectIter);
1769cdf0e10cSrcweir         pDrawVirtObj->RemoveFromWriterLayout();
1770cdf0e10cSrcweir         pDrawVirtObj->RemoveFromDrawingPage();
1771cdf0e10cSrcweir     }
1772cdf0e10cSrcweir 
1773cdf0e10cSrcweir     if ( maAnchoredDrawObj.GetAnchorFrm() )
1774cdf0e10cSrcweir     {
1775cdf0e10cSrcweir         maAnchoredDrawObj.AnchorFrm()->RemoveDrawObj( maAnchoredDrawObj );
1776cdf0e10cSrcweir     }
1777cdf0e10cSrcweir 
1778cdf0e10cSrcweir     if ( _bMoveMasterToInvisibleLayer && GetMaster() && GetMaster()->IsInserted() )
1779cdf0e10cSrcweir 	{
1780cdf0e10cSrcweir 		SdrViewIter aIter( GetMaster() );
1781cdf0e10cSrcweir 		for( SdrView* pView = aIter.FirstView(); pView;
1782cdf0e10cSrcweir 					pView = aIter.NextView() )
1783cdf0e10cSrcweir         {
1784cdf0e10cSrcweir 			pView->MarkObj( GetMaster(), pView->GetSdrPageView(), sal_True );
1785cdf0e10cSrcweir         }
1786cdf0e10cSrcweir 
1787cdf0e10cSrcweir         // OD 25.06.2003 #108784# - Instead of removing 'master' object from
1788cdf0e10cSrcweir         // drawing page, move the 'master' drawing object into the corresponding
1789cdf0e10cSrcweir         // invisible layer.
1790cdf0e10cSrcweir         {
1791cdf0e10cSrcweir             //((SwFrmFmt*)GetRegisteredIn())->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage(0)->
1792cdf0e10cSrcweir             //                            RemoveObject( GetMaster()->GetOrdNum() );
1793cdf0e10cSrcweir             // OD 21.08.2003 #i18447# - in order to consider group object correct
1794cdf0e10cSrcweir             // use new method <SwDrawContact::MoveObjToInvisibleLayer(..)>
1795cdf0e10cSrcweir             MoveObjToInvisibleLayer( GetMaster() );
1796cdf0e10cSrcweir         }
1797cdf0e10cSrcweir 	}
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir     // OD 10.10.2003 #112299#
1800cdf0e10cSrcweir     mbDisconnectInProgress = false;
1801cdf0e10cSrcweir }
1802cdf0e10cSrcweir 
1803cdf0e10cSrcweir // OD 26.06.2003 #108784# - method to remove 'master' drawing object
1804cdf0e10cSrcweir // from drawing page.
RemoveMasterFromDrawPage()1805cdf0e10cSrcweir void SwDrawContact::RemoveMasterFromDrawPage()
1806cdf0e10cSrcweir {
1807cdf0e10cSrcweir     if ( GetMaster() )
1808cdf0e10cSrcweir     {
1809cdf0e10cSrcweir         GetMaster()->SetUserCall( 0 );
1810cdf0e10cSrcweir         if ( GetMaster()->IsInserted() )
1811cdf0e10cSrcweir         {
1812cdf0e10cSrcweir             ((SwFrmFmt*)GetRegisteredIn())->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage(0)->
1813cdf0e10cSrcweir                                         RemoveObject( GetMaster()->GetOrdNum() );
1814cdf0e10cSrcweir         }
1815cdf0e10cSrcweir     }
1816cdf0e10cSrcweir }
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir // OD 19.06.2003 #108784# - disconnect for a dedicated drawing object -
1819cdf0e10cSrcweir // could be 'master' or 'virtual'.
1820cdf0e10cSrcweir // a 'master' drawing object will disconnect a 'virtual' drawing object
1821cdf0e10cSrcweir // in order to take its place.
1822cdf0e10cSrcweir // OD 13.10.2003 #i19919# - no special case, if drawing object isn't in
1823cdf0e10cSrcweir // page header/footer, in order to get drawing objects in repeating table headers
1824cdf0e10cSrcweir // also working.
DisconnectObjFromLayout(SdrObject * _pDrawObj)1825cdf0e10cSrcweir void SwDrawContact::DisconnectObjFromLayout( SdrObject* _pDrawObj )
1826cdf0e10cSrcweir {
1827cdf0e10cSrcweir     if ( _pDrawObj->ISA(SwDrawVirtObj) )
1828cdf0e10cSrcweir     {
1829cdf0e10cSrcweir         SwDrawVirtObj* pDrawVirtObj = static_cast<SwDrawVirtObj*>(_pDrawObj);
1830cdf0e10cSrcweir         pDrawVirtObj->RemoveFromWriterLayout();
1831cdf0e10cSrcweir         pDrawVirtObj->RemoveFromDrawingPage();
1832cdf0e10cSrcweir     }
1833cdf0e10cSrcweir     else
1834cdf0e10cSrcweir     {
1835cdf0e10cSrcweir         std::list<SwDrawVirtObj*>::const_iterator aFoundVirtObjIter =
1836cdf0e10cSrcweir                 std::find_if( maDrawVirtObjs.begin(), maDrawVirtObjs.end(),
1837cdf0e10cSrcweir                               UsedOrUnusedVirtObjPred( true ) );
1838cdf0e10cSrcweir         if ( aFoundVirtObjIter != maDrawVirtObjs.end() )
1839cdf0e10cSrcweir         {
1840cdf0e10cSrcweir             // replace found 'virtual' drawing object by 'master' drawing
1841cdf0e10cSrcweir             // object and disconnect the 'virtual' one
1842cdf0e10cSrcweir             SwDrawVirtObj* pDrawVirtObj = (*aFoundVirtObjIter);
1843cdf0e10cSrcweir             SwFrm* pNewAnchorFrmOfMaster = pDrawVirtObj->AnchorFrm();
1844cdf0e10cSrcweir             // disconnect 'virtual' drawing object
1845cdf0e10cSrcweir             pDrawVirtObj->RemoveFromWriterLayout();
1846cdf0e10cSrcweir             pDrawVirtObj->RemoveFromDrawingPage();
1847cdf0e10cSrcweir             // disconnect 'master' drawing object from current frame
1848cdf0e10cSrcweir             GetAnchorFrm()->RemoveDrawObj( maAnchoredDrawObj );
1849cdf0e10cSrcweir             // re-connect 'master' drawing object to frame of found 'virtual'
1850cdf0e10cSrcweir             // drawing object.
1851cdf0e10cSrcweir             pNewAnchorFrmOfMaster->AppendDrawObj( maAnchoredDrawObj );
1852cdf0e10cSrcweir         }
1853cdf0e10cSrcweir         else
1854cdf0e10cSrcweir         {
1855cdf0e10cSrcweir             // no connected 'virtual' drawing object found. Thus, disconnect
1856cdf0e10cSrcweir             // completely from layout.
1857cdf0e10cSrcweir             DisconnectFromLayout();
1858cdf0e10cSrcweir         }
1859cdf0e10cSrcweir     }
1860cdf0e10cSrcweir }
1861cdf0e10cSrcweir 
1862cdf0e10cSrcweir /*************************************************************************
1863cdf0e10cSrcweir |*
1864cdf0e10cSrcweir |*	SwDrawContact::ConnectToLayout()
1865cdf0e10cSrcweir |*
1866cdf0e10cSrcweir |*	Ersterstellung		MA 09. Jan. 95
1867cdf0e10cSrcweir |*	Letzte Aenderung	MA 25. Mar. 99
1868cdf0e10cSrcweir |*
1869cdf0e10cSrcweir |*************************************************************************/
lcl_GetFlyInCntntAnchor(SwTxtFrm * _pProposedAnchorFrm,const xub_StrLen _nTxtOfs)1870cdf0e10cSrcweir SwTxtFrm* lcl_GetFlyInCntntAnchor( SwTxtFrm* _pProposedAnchorFrm,
1871cdf0e10cSrcweir                                    const xub_StrLen _nTxtOfs )
1872cdf0e10cSrcweir {
1873cdf0e10cSrcweir     SwTxtFrm* pAct = _pProposedAnchorFrm;
1874cdf0e10cSrcweir     SwTxtFrm* pTmp;
1875cdf0e10cSrcweir     do
1876cdf0e10cSrcweir     {
1877cdf0e10cSrcweir         pTmp = pAct;
1878cdf0e10cSrcweir         pAct = pTmp->GetFollow();
1879cdf0e10cSrcweir     }
1880cdf0e10cSrcweir     while( pAct && _nTxtOfs >= pAct->GetOfst() );
1881cdf0e10cSrcweir     return pTmp;
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir 
ConnectToLayout(const SwFmtAnchor * pAnch)1884cdf0e10cSrcweir void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch )
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir     // OD 10.10.2003 #112299# - *no* connect to layout during disconnection from
1887cdf0e10cSrcweir     // layout.
1888cdf0e10cSrcweir     if ( mbDisconnectInProgress )
1889cdf0e10cSrcweir     {
1890cdf0e10cSrcweir         ASSERT( false,
1891cdf0e10cSrcweir                 "<SwDrawContact::ConnectToLayout(..)> called during disconnection.");
1892cdf0e10cSrcweir         return;
1893cdf0e10cSrcweir     }
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir     // --> OD 2004-09-22 #i33909# - *no* connect to layout, if 'master' drawing
1896cdf0e10cSrcweir     // object isn't inserted in the drawing page
1897cdf0e10cSrcweir     if ( !GetMaster()->IsInserted() )
1898cdf0e10cSrcweir     {
1899cdf0e10cSrcweir         ASSERT( false, "<SwDrawContact::ConnectToLayout(..)> - master drawing object not inserted -> no connect to layout. Please inform od@openoffice.org" );
1900cdf0e10cSrcweir         return;
1901cdf0e10cSrcweir     }
1902cdf0e10cSrcweir     // <--
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir     SwFrmFmt* pDrawFrmFmt = (SwFrmFmt*)GetRegisteredIn();
1905cdf0e10cSrcweir 
1906cdf0e10cSrcweir     if( !pDrawFrmFmt->getIDocumentLayoutAccess()->GetCurrentViewShell() )
1907cdf0e10cSrcweir 		return;
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir     // OD 16.05.2003 #108784# - remove 'virtual' drawing objects from writer
1910cdf0e10cSrcweir     // layout and from drawing page, and remove 'master' drawing object from
1911cdf0e10cSrcweir     // writer layout - 'master' object will remain in drawing page.
1912cdf0e10cSrcweir     DisconnectFromLayout( false );
1913cdf0e10cSrcweir 
1914cdf0e10cSrcweir 	if ( !pAnch )
1915cdf0e10cSrcweir     {
1916cdf0e10cSrcweir         pAnch = &(pDrawFrmFmt->GetAnchor());
1917cdf0e10cSrcweir     }
1918cdf0e10cSrcweir 
1919cdf0e10cSrcweir 	switch ( pAnch->GetAnchorId() )
1920cdf0e10cSrcweir 	{
1921cdf0e10cSrcweir         case FLY_AT_PAGE:
1922cdf0e10cSrcweir                 {
1923cdf0e10cSrcweir                 sal_uInt16 nPgNum = pAnch->GetPageNum();
1924cdf0e10cSrcweir                 ViewShell *pShell = pDrawFrmFmt->getIDocumentLayoutAccess()->GetCurrentViewShell();
1925cdf0e10cSrcweir                 if( !pShell )
1926cdf0e10cSrcweir                     break;
1927cdf0e10cSrcweir                 SwRootFrm* pRoot = pShell->GetLayout();
1928cdf0e10cSrcweir                 SwPageFrm *pPage = static_cast<SwPageFrm*>(pRoot->Lower());
1929cdf0e10cSrcweir 
1930cdf0e10cSrcweir                 for ( sal_uInt16 i = 1; i < nPgNum && pPage; ++i )
1931cdf0e10cSrcweir                 {
1932cdf0e10cSrcweir                     pPage = static_cast<SwPageFrm*>(pPage->GetNext());
1933cdf0e10cSrcweir                 }
1934cdf0e10cSrcweir 
1935cdf0e10cSrcweir                 if ( pPage )
1936cdf0e10cSrcweir                 {
1937cdf0e10cSrcweir                     pPage->AppendDrawObj( maAnchoredDrawObj );
1938cdf0e10cSrcweir                 }
1939cdf0e10cSrcweir                 else
1940cdf0e10cSrcweir                     //Sieht doof aus, ist aber erlaubt (vlg. SwFEShell::SetPageObjsNewPage)
1941cdf0e10cSrcweir                     pRoot->SetAssertFlyPages();
1942cdf0e10cSrcweir                 }
1943cdf0e10cSrcweir                 break;
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir         case FLY_AT_CHAR:
1946cdf0e10cSrcweir         case FLY_AT_PARA:
1947cdf0e10cSrcweir         case FLY_AT_FLY:
1948cdf0e10cSrcweir         case FLY_AS_CHAR:
1949cdf0e10cSrcweir             {
1950cdf0e10cSrcweir                 if ( pAnch->GetAnchorId() == FLY_AS_CHAR )
1951cdf0e10cSrcweir                 {
1952cdf0e10cSrcweir                     ClrContourCache( GetMaster() );
1953cdf0e10cSrcweir                 }
1954cdf0e10cSrcweir                 // OD 16.05.2003 #108784# - support drawing objects in header/footer,
1955cdf0e10cSrcweir                 // but not control objects:
1956cdf0e10cSrcweir                 // anchor at first found frame the 'master' object and
1957cdf0e10cSrcweir                 // at the following frames 'virtual' drawing objects.
1958cdf0e10cSrcweir                 // Note: method is similar to <SwFlyFrmFmt::MakeFrms(..)>
1959cdf0e10cSrcweir                 SwModify *pModify = 0;
1960cdf0e10cSrcweir                 if( pAnch->GetCntntAnchor() )
1961cdf0e10cSrcweir                 {
1962cdf0e10cSrcweir                     if ( pAnch->GetAnchorId() == FLY_AT_FLY )
1963cdf0e10cSrcweir                     {
1964cdf0e10cSrcweir                         SwNodeIndex aIdx( pAnch->GetCntntAnchor()->nNode );
1965cdf0e10cSrcweir                         SwCntntNode* pCNd = pDrawFrmFmt->GetDoc()->GetNodes().GoNext( &aIdx );
1966cdf0e10cSrcweir                         if ( SwIterator<SwFrm,SwCntntNode>::FirstElement( *pCNd ) )
1967cdf0e10cSrcweir                             pModify = pCNd;
1968cdf0e10cSrcweir                         else
1969cdf0e10cSrcweir                         {
1970cdf0e10cSrcweir                             const SwNodeIndex& rIdx = pAnch->GetCntntAnchor()->nNode;
1971cdf0e10cSrcweir                             SwSpzFrmFmts& rFmts = *(pDrawFrmFmt->GetDoc()->GetSpzFrmFmts());
1972cdf0e10cSrcweir                             for( sal_uInt16 i = 0; i < rFmts.Count(); ++i )
1973cdf0e10cSrcweir                             {
1974cdf0e10cSrcweir                                 SwFrmFmt* pFlyFmt = rFmts[i];
1975cdf0e10cSrcweir                                 if( pFlyFmt->GetCntnt().GetCntntIdx() &&
1976cdf0e10cSrcweir                                     rIdx == *(pFlyFmt->GetCntnt().GetCntntIdx()) )
1977cdf0e10cSrcweir                                 {
1978cdf0e10cSrcweir                                     pModify = pFlyFmt;
1979cdf0e10cSrcweir                                     break;
1980cdf0e10cSrcweir                                 }
1981cdf0e10cSrcweir                             }
1982cdf0e10cSrcweir                         }
1983cdf0e10cSrcweir                         // --> OD 2004-06-15 #i29199# - It is possible, that
1984cdf0e10cSrcweir                         // the anchor doesn't exist - E.g., reordering the
1985cdf0e10cSrcweir                         // sub-documents in a master document.
1986cdf0e10cSrcweir                         // Note: The anchor will be inserted later.
1987cdf0e10cSrcweir                         if ( !pModify )
1988cdf0e10cSrcweir                         {
1989cdf0e10cSrcweir                             // break to end of the current switch case.
1990cdf0e10cSrcweir                             break;
1991cdf0e10cSrcweir                         }
1992cdf0e10cSrcweir                     }
1993cdf0e10cSrcweir                     else
1994cdf0e10cSrcweir                     {
1995cdf0e10cSrcweir                         pModify = pAnch->GetCntntAnchor()->nNode.GetNode().GetCntntNode();
1996cdf0e10cSrcweir                     }
1997cdf0e10cSrcweir                 }
1998cdf0e10cSrcweir                 SwIterator<SwFrm,SwModify> aIter( *pModify );
1999cdf0e10cSrcweir                 SwFrm* pAnchorFrmOfMaster = 0;
2000cdf0e10cSrcweir                 for( SwFrm *pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
2001cdf0e10cSrcweir                 {
2002cdf0e10cSrcweir                     // append drawing object, if
2003cdf0e10cSrcweir                     // (1) proposed anchor frame isn't a follow and
2004cdf0e10cSrcweir                     // (2) drawing object isn't a control object to be anchored
2005cdf0e10cSrcweir                     //     in header/footer.
2006cdf0e10cSrcweir                     const bool bAdd = ( !pFrm->IsCntntFrm() ||
2007cdf0e10cSrcweir                                         !((SwCntntFrm*)pFrm)->IsFollow() ) &&
2008cdf0e10cSrcweir                                       ( !::CheckControlLayer( GetMaster() ) ||
2009cdf0e10cSrcweir                                         !pFrm->FindFooterOrHeader() );
2010cdf0e10cSrcweir 
2011cdf0e10cSrcweir                     if( bAdd )
2012cdf0e10cSrcweir                     {
2013cdf0e10cSrcweir                         if ( FLY_AT_FLY == pAnch->GetAnchorId() && !pFrm->IsFlyFrm() )
2014cdf0e10cSrcweir                         {
2015cdf0e10cSrcweir                             pFrm = pFrm->FindFlyFrm();
2016cdf0e10cSrcweir                             ASSERT( pFrm,
2017cdf0e10cSrcweir                                     "<SwDrawContact::ConnectToLayout(..)> - missing fly frame -> crash." );
2018cdf0e10cSrcweir                         }
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir                         // OD 2004-01-20 #110582# - find correct follow for
2021cdf0e10cSrcweir                         // as character anchored objects.
2022cdf0e10cSrcweir                         if ((pAnch->GetAnchorId() == FLY_AS_CHAR) &&
2023cdf0e10cSrcweir                              pFrm->IsTxtFrm() )
2024cdf0e10cSrcweir                         {
2025cdf0e10cSrcweir                             pFrm = lcl_GetFlyInCntntAnchor(
2026cdf0e10cSrcweir                                         static_cast<SwTxtFrm*>(pFrm),
2027cdf0e10cSrcweir                                         pAnch->GetCntntAnchor()->nContent.GetIndex() );
2028cdf0e10cSrcweir                         }
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir                         if ( !pAnchorFrmOfMaster )
2031cdf0e10cSrcweir                         {
2032cdf0e10cSrcweir                             // append 'master' drawing object
2033cdf0e10cSrcweir                             pAnchorFrmOfMaster = pFrm;
2034cdf0e10cSrcweir                             pFrm->AppendDrawObj( maAnchoredDrawObj );
2035cdf0e10cSrcweir                         }
2036cdf0e10cSrcweir                         else
2037cdf0e10cSrcweir                         {
2038cdf0e10cSrcweir                             // append 'virtual' drawing object
2039cdf0e10cSrcweir                             SwDrawVirtObj* pDrawVirtObj = AddVirtObj();
2040cdf0e10cSrcweir                             if ( pAnch->GetAnchorId() == FLY_AS_CHAR )
2041cdf0e10cSrcweir                             {
2042cdf0e10cSrcweir                                 ClrContourCache( pDrawVirtObj );
2043cdf0e10cSrcweir                             }
2044cdf0e10cSrcweir                             pFrm->AppendDrawObj( *(pDrawVirtObj->AnchoredObj()) );
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir 							// for repaint, use new ActionChanged()
2047cdf0e10cSrcweir                             // pDrawVirtObj->SendRepaintBroadcast();
2048cdf0e10cSrcweir                             pDrawVirtObj->ActionChanged();
2049cdf0e10cSrcweir                         }
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir                         if ( pAnch->GetAnchorId() == FLY_AS_CHAR )
2052cdf0e10cSrcweir                         {
2053cdf0e10cSrcweir                             pFrm->InvalidatePrt();
2054cdf0e10cSrcweir                         }
2055cdf0e10cSrcweir                     }
2056cdf0e10cSrcweir                 }
2057cdf0e10cSrcweir 			}
2058cdf0e10cSrcweir 			break;
2059cdf0e10cSrcweir         default:
2060cdf0e10cSrcweir             ASSERT( sal_False, "Unknown Anchor." )
2061cdf0e10cSrcweir             break;
2062cdf0e10cSrcweir     }
2063cdf0e10cSrcweir     if ( GetAnchorFrm() )
2064cdf0e10cSrcweir 	{
2065cdf0e10cSrcweir         ::setContextWritingMode( maAnchoredDrawObj.DrawObj(), GetAnchorFrm() );
2066cdf0e10cSrcweir         // OD 2004-04-01 #i26791# - invalidate objects instead of direct positioning
2067cdf0e10cSrcweir         _InvalidateObjs();
2068cdf0e10cSrcweir 	}
2069cdf0e10cSrcweir }
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir // OD 27.06.2003 #108784# - insert 'master' drawing object into drawing page
InsertMasterIntoDrawPage()2072cdf0e10cSrcweir void SwDrawContact::InsertMasterIntoDrawPage()
2073cdf0e10cSrcweir {
2074cdf0e10cSrcweir     if ( !GetMaster()->IsInserted() )
2075cdf0e10cSrcweir     {
2076cdf0e10cSrcweir         GetFmt()->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage(0)
2077cdf0e10cSrcweir                 ->InsertObject( GetMaster(), GetMaster()->GetOrdNumDirect() );
2078cdf0e10cSrcweir     }
2079cdf0e10cSrcweir     GetMaster()->SetUserCall( this );
2080cdf0e10cSrcweir }
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir /*************************************************************************
2083cdf0e10cSrcweir |*
2084cdf0e10cSrcweir |*	SwDrawContact::FindPage(), ChkPage()
2085cdf0e10cSrcweir |*
2086cdf0e10cSrcweir |*	Ersterstellung		MA 21. Mar. 95
2087cdf0e10cSrcweir |*	Letzte Aenderung	MA 19. Jul. 96
2088cdf0e10cSrcweir |*
2089cdf0e10cSrcweir |*************************************************************************/
2090cdf0e10cSrcweir 
FindPage(const SwRect & rRect)2091cdf0e10cSrcweir SwPageFrm* SwDrawContact::FindPage( const SwRect &rRect )
2092cdf0e10cSrcweir {
2093cdf0e10cSrcweir     // --> OD 2004-07-01 #i28701# - use method <GetPageFrm()>
2094cdf0e10cSrcweir     SwPageFrm* pPg = GetPageFrm();
2095cdf0e10cSrcweir     if ( !pPg && GetAnchorFrm() )
2096cdf0e10cSrcweir         pPg = GetAnchorFrm()->FindPageFrm();
2097cdf0e10cSrcweir 	if ( pPg )
2098cdf0e10cSrcweir 		pPg = (SwPageFrm*)::FindPage( rRect, pPg );
2099cdf0e10cSrcweir 	return pPg;
2100cdf0e10cSrcweir }
2101cdf0e10cSrcweir 
ChkPage()2102cdf0e10cSrcweir void SwDrawContact::ChkPage()
2103cdf0e10cSrcweir {
2104cdf0e10cSrcweir     // OD 10.10.2003 #112299#
2105cdf0e10cSrcweir     if ( mbDisconnectInProgress )
2106cdf0e10cSrcweir     {
2107cdf0e10cSrcweir         ASSERT( false,
2108cdf0e10cSrcweir                 "<SwDrawContact::ChkPage()> called during disconnection." );
2109cdf0e10cSrcweir         return;
2110cdf0e10cSrcweir     }
2111cdf0e10cSrcweir 
2112cdf0e10cSrcweir     // --> OD 2004-07-01 #i28701#
2113cdf0e10cSrcweir     SwPageFrm* pPg = ( maAnchoredDrawObj.GetAnchorFrm() &&
2114cdf0e10cSrcweir                        maAnchoredDrawObj.GetAnchorFrm()->IsPageFrm() )
2115cdf0e10cSrcweir                      ? GetPageFrm()
2116cdf0e10cSrcweir                      : FindPage( GetMaster()->GetCurrentBoundRect() );
2117cdf0e10cSrcweir     if ( GetPageFrm() != pPg )
2118cdf0e10cSrcweir 	{
2119cdf0e10cSrcweir         // OD 27.06.2003 #108784# - if drawing object is anchor in header/footer
2120cdf0e10cSrcweir         // a change of the page is a dramatic change. Thus, completely re-connect
2121cdf0e10cSrcweir         // to the layout
2122cdf0e10cSrcweir         if ( maAnchoredDrawObj.GetAnchorFrm() &&
2123cdf0e10cSrcweir              maAnchoredDrawObj.GetAnchorFrm()->FindFooterOrHeader() )
2124cdf0e10cSrcweir         {
2125cdf0e10cSrcweir             ConnectToLayout();
2126cdf0e10cSrcweir         }
2127cdf0e10cSrcweir         else
2128cdf0e10cSrcweir         {
2129cdf0e10cSrcweir             // --> OD 2004-07-01 #i28701# - use methods <GetPageFrm()> and <SetPageFrm>
2130cdf0e10cSrcweir             if ( GetPageFrm() )
2131cdf0e10cSrcweir                 GetPageFrm()->RemoveDrawObjFromPage( maAnchoredDrawObj );
2132cdf0e10cSrcweir             pPg->AppendDrawObjToPage( maAnchoredDrawObj );
2133cdf0e10cSrcweir             SetPageFrm( pPg );
2134cdf0e10cSrcweir         }
2135cdf0e10cSrcweir 	}
2136cdf0e10cSrcweir }
2137cdf0e10cSrcweir 
2138cdf0e10cSrcweir /*************************************************************************
2139cdf0e10cSrcweir |*
2140cdf0e10cSrcweir |*	SwDrawContact::ChangeMasterObject()
2141cdf0e10cSrcweir |*
2142cdf0e10cSrcweir |*	Ersterstellung		MA 07. Aug. 95
2143cdf0e10cSrcweir |*	Letzte Aenderung	MA 20. Apr. 99
2144cdf0e10cSrcweir |*
2145cdf0e10cSrcweir |*************************************************************************/
2146cdf0e10cSrcweir // OD 10.07.2003 #110742# - Important note:
2147cdf0e10cSrcweir // method is called by method <SwDPage::ReplaceObject(..)>, which called its
2148cdf0e10cSrcweir // corresponding superclass method <FmFormPage::ReplaceObject(..)>.
2149cdf0e10cSrcweir // Note: 'master' drawing object *has* to be connected to layout triggered
2150cdf0e10cSrcweir //       by the caller of this, if method is called.
ChangeMasterObject(SdrObject * pNewMaster)2151cdf0e10cSrcweir void SwDrawContact::ChangeMasterObject( SdrObject *pNewMaster )
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir     DisconnectFromLayout( false );
2154cdf0e10cSrcweir     // OD 10.07.2003 #110742# - consider 'virtual' drawing objects
2155cdf0e10cSrcweir     RemoveAllVirtObjs();
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir     GetMaster()->SetUserCall( 0 );
2158cdf0e10cSrcweir 	SetMaster( pNewMaster );
2159cdf0e10cSrcweir 	GetMaster()->SetUserCall( this );
2160cdf0e10cSrcweir 
2161cdf0e10cSrcweir     _InvalidateObjs();
2162cdf0e10cSrcweir }
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir /** get data collection of anchored objects, handled by with contact
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir     OD 2004-08-23 #110810#
2167cdf0e10cSrcweir 
2168cdf0e10cSrcweir     @author
2169cdf0e10cSrcweir */
GetAnchoredObjs(std::list<SwAnchoredObject * > & _roAnchoredObjs) const2170cdf0e10cSrcweir void SwDrawContact::GetAnchoredObjs( std::list<SwAnchoredObject*>& _roAnchoredObjs ) const
2171cdf0e10cSrcweir {
2172cdf0e10cSrcweir     _roAnchoredObjs.push_back( const_cast<SwAnchoredDrawObject*>(&maAnchoredDrawObj) );
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir     for ( std::list<SwDrawVirtObj*>::const_iterator aDrawVirtObjsIter = maDrawVirtObjs.begin();
2175cdf0e10cSrcweir           aDrawVirtObjsIter != maDrawVirtObjs.end();
2176cdf0e10cSrcweir           ++aDrawVirtObjsIter )
2177cdf0e10cSrcweir     {
2178cdf0e10cSrcweir         _roAnchoredObjs.push_back( (*aDrawVirtObjsIter)->AnchoredObj() );
2179cdf0e10cSrcweir     }
2180cdf0e10cSrcweir }
2181cdf0e10cSrcweir 
2182cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////
2183cdf0e10cSrcweir // AW: own sdr::contact::ViewContact (VC) sdr::contact::ViewObjectContact (VOC) needed
2184cdf0e10cSrcweir // since offset is defined different from SdrVirtObj's sdr::contact::ViewContactOfVirtObj.
2185cdf0e10cSrcweir // For paint, that offset is used by setting at the OutputDevice; for primitives this is
2186cdf0e10cSrcweir // not possible since we have no OutputDevice, but define the geometry itself.
2187cdf0e10cSrcweir 
2188cdf0e10cSrcweir namespace sdr
2189cdf0e10cSrcweir {
2190cdf0e10cSrcweir 	namespace contact
2191cdf0e10cSrcweir 	{
2192cdf0e10cSrcweir         class VOCOfDrawVirtObj : public ViewObjectContactOfSdrObj
2193cdf0e10cSrcweir 		{
2194cdf0e10cSrcweir 		protected:
2195cdf0e10cSrcweir 			// This method is responsible for creating the graphical visualisation data which is
2196cdf0e10cSrcweir 			// stored/cached in the local primitive. Default gets view-independent Primitive
2197cdf0e10cSrcweir 			// from the ViewContact using ViewContact::getViewIndependentPrimitive2DSequence(), takes care of
2198cdf0e10cSrcweir 			// visibility, handles glue and ghosted.
2199cdf0e10cSrcweir 			// This method will not handle included hierarchies and not check geometric visibility.
2200cdf0e10cSrcweir 			virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const;
2201cdf0e10cSrcweir 
2202cdf0e10cSrcweir         public:
VOCOfDrawVirtObj(ObjectContact & rObjectContact,ViewContact & rViewContact)2203cdf0e10cSrcweir 			VOCOfDrawVirtObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
2204cdf0e10cSrcweir             :   ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
2205cdf0e10cSrcweir             {
2206cdf0e10cSrcweir             }
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir 			virtual ~VOCOfDrawVirtObj();
2209cdf0e10cSrcweir 		};
2210cdf0e10cSrcweir 
2211cdf0e10cSrcweir 		class VCOfDrawVirtObj : public ViewContactOfVirtObj
2212cdf0e10cSrcweir 		{
2213cdf0e10cSrcweir         protected:
2214cdf0e10cSrcweir 			// Create a Object-Specific ViewObjectContact, set ViewContact and
2215cdf0e10cSrcweir 			// ObjectContact. Always needs to return something. Default is to create
2216cdf0e10cSrcweir 			// a standard ViewObjectContact containing the given ObjectContact and *this
2217cdf0e10cSrcweir 			virtual ViewObjectContact& CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact);
2218cdf0e10cSrcweir 
2219cdf0e10cSrcweir         public:
2220cdf0e10cSrcweir 			// basic constructor, used from SdrObject.
VCOfDrawVirtObj(SwDrawVirtObj & rObj)2221cdf0e10cSrcweir             VCOfDrawVirtObj(SwDrawVirtObj& rObj)
2222cdf0e10cSrcweir             :   ViewContactOfVirtObj(rObj)
2223cdf0e10cSrcweir             {
2224cdf0e10cSrcweir             }
2225cdf0e10cSrcweir 			virtual ~VCOfDrawVirtObj();
2226cdf0e10cSrcweir 
2227cdf0e10cSrcweir             // access to SwDrawVirtObj
GetSwDrawVirtObj() const2228cdf0e10cSrcweir             SwDrawVirtObj& GetSwDrawVirtObj() const
2229cdf0e10cSrcweir             {
2230cdf0e10cSrcweir 			    return (SwDrawVirtObj&)mrObject;
2231cdf0e10cSrcweir             }
2232cdf0e10cSrcweir 		};
2233cdf0e10cSrcweir 	} // end of namespace contact
2234cdf0e10cSrcweir } // end of namespace sdr
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir namespace sdr
2237cdf0e10cSrcweir {
2238cdf0e10cSrcweir 	namespace contact
2239cdf0e10cSrcweir 	{
2240cdf0e10cSrcweir         // recursively collect primitive data from given VOC with given offset
impAddPrimitivesFromGroup(const ViewObjectContact & rVOC,const basegfx::B2DHomMatrix & rOffsetMatrix,const DisplayInfo & rDisplayInfo,drawinglayer::primitive2d::Primitive2DSequence & rxTarget)2241cdf0e10cSrcweir         void impAddPrimitivesFromGroup(const ViewObjectContact& rVOC, const basegfx::B2DHomMatrix& rOffsetMatrix, const DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DSequence& rxTarget)
2242cdf0e10cSrcweir         {
2243cdf0e10cSrcweir 			const sal_uInt32 nSubHierarchyCount(rVOC.GetViewContact().GetObjectCount());
2244cdf0e10cSrcweir 
2245cdf0e10cSrcweir 			for(sal_uInt32 a(0L); a < nSubHierarchyCount; a++)
2246cdf0e10cSrcweir 			{
2247cdf0e10cSrcweir 				const ViewObjectContact& rCandidate(rVOC.GetViewContact().GetViewContact(a).GetViewObjectContact(rVOC.GetObjectContact()));
2248cdf0e10cSrcweir 
2249cdf0e10cSrcweir                 if(rCandidate.GetViewContact().GetObjectCount())
2250cdf0e10cSrcweir                 {
2251cdf0e10cSrcweir                     // is a group object itself, call resursively
2252cdf0e10cSrcweir                     impAddPrimitivesFromGroup(rCandidate, rOffsetMatrix, rDisplayInfo, rxTarget);
2253cdf0e10cSrcweir                 }
2254cdf0e10cSrcweir                 else
2255cdf0e10cSrcweir                 {
2256cdf0e10cSrcweir                     // single object, add primitives; check model-view visibility
2257cdf0e10cSrcweir 			        if(rCandidate.isPrimitiveVisible(rDisplayInfo))
2258cdf0e10cSrcweir 			        {
2259cdf0e10cSrcweir                         drawinglayer::primitive2d::Primitive2DSequence aNewSequence(rCandidate.getPrimitive2DSequence(rDisplayInfo));
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir 				        if(aNewSequence.hasElements())
2262cdf0e10cSrcweir 				        {
2263cdf0e10cSrcweir 					        // get ranges
2264cdf0e10cSrcweir 					        const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(rCandidate.GetObjectContact().getViewInformation2D());
2265cdf0e10cSrcweir 					        const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
2266cdf0e10cSrcweir 					        basegfx::B2DRange aObjectRange(rCandidate.getObjectRange());
2267cdf0e10cSrcweir 
2268cdf0e10cSrcweir                             // correct with virtual object's offset
2269cdf0e10cSrcweir                             aObjectRange.transform(rOffsetMatrix);
2270cdf0e10cSrcweir 
2271cdf0e10cSrcweir 					        // check geometrical visibility (with offset)
2272cdf0e10cSrcweir 					        if(!aViewRange.overlaps(aObjectRange))
2273cdf0e10cSrcweir 					        {
2274cdf0e10cSrcweir 						        // not visible, release
2275cdf0e10cSrcweir 						        aNewSequence.realloc(0);
2276cdf0e10cSrcweir 					        }
2277cdf0e10cSrcweir 				        }
2278cdf0e10cSrcweir 
2279cdf0e10cSrcweir 				        if(aNewSequence.hasElements())
2280cdf0e10cSrcweir 				        {
2281cdf0e10cSrcweir                             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rxTarget, aNewSequence);
2282cdf0e10cSrcweir                         }
2283cdf0e10cSrcweir                     }
2284cdf0e10cSrcweir                 }
2285cdf0e10cSrcweir 			}
2286cdf0e10cSrcweir         }
2287cdf0e10cSrcweir 
createPrimitive2DSequence(const DisplayInfo & rDisplayInfo) const2288cdf0e10cSrcweir         drawinglayer::primitive2d::Primitive2DSequence VOCOfDrawVirtObj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
2289cdf0e10cSrcweir         {
2290cdf0e10cSrcweir #ifdef DBG_UTIL
2291cdf0e10cSrcweir 			// #i101734#
2292cdf0e10cSrcweir 			static bool bCheckOtherThanTranslate(false);
2293cdf0e10cSrcweir 			static double fShearX(0.0);
2294cdf0e10cSrcweir 			static double fRotation(0.0);
2295cdf0e10cSrcweir 			static double fScaleX(0.0);
2296cdf0e10cSrcweir 			static double fScaleY(0.0);
2297cdf0e10cSrcweir #endif
2298cdf0e10cSrcweir 
2299cdf0e10cSrcweir 			const VCOfDrawVirtObj& rVC = static_cast< const VCOfDrawVirtObj& >(GetViewContact());
2300cdf0e10cSrcweir             const SdrObject& rReferencedObject = rVC.GetSwDrawVirtObj().GetReferencedObj();
2301cdf0e10cSrcweir 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
2302cdf0e10cSrcweir 
2303cdf0e10cSrcweir 		    // create offset transformation
2304cdf0e10cSrcweir 		    basegfx::B2DHomMatrix aOffsetMatrix;
2305cdf0e10cSrcweir             const Point aLocalOffset(rVC.GetSwDrawVirtObj().GetOffset());
2306cdf0e10cSrcweir 
2307cdf0e10cSrcweir 		    if(aLocalOffset.X() || aLocalOffset.Y())
2308cdf0e10cSrcweir 		    {
2309cdf0e10cSrcweir #ifdef DBG_UTIL
2310cdf0e10cSrcweir 				// #i101734# added debug code to check more complex transformations
2311cdf0e10cSrcweir 				// than just a translation
2312cdf0e10cSrcweir 				if(bCheckOtherThanTranslate)
2313cdf0e10cSrcweir 				{
2314cdf0e10cSrcweir 					aOffsetMatrix.scale(fScaleX, fScaleY);
2315cdf0e10cSrcweir 					aOffsetMatrix.shearX(tan(fShearX * F_PI180));
2316cdf0e10cSrcweir 					aOffsetMatrix.rotate(fRotation * F_PI180);
2317cdf0e10cSrcweir 				}
2318cdf0e10cSrcweir #endif
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir 			    aOffsetMatrix.set(0, 2, aLocalOffset.X());
2321cdf0e10cSrcweir 			    aOffsetMatrix.set(1, 2, aLocalOffset.Y());
2322cdf0e10cSrcweir 
2323cdf0e10cSrcweir 		    }
2324cdf0e10cSrcweir 
2325cdf0e10cSrcweir             if(rReferencedObject.ISA(SdrObjGroup))
2326cdf0e10cSrcweir             {
2327cdf0e10cSrcweir                 // group object. Since the VOC/OC/VC hierarchy does not represent the
2328cdf0e10cSrcweir                 // hierarchy virtual objects when they have group objects
2329cdf0e10cSrcweir                 // (ViewContactOfVirtObj::GetObjectCount() returns null for that purpose)
2330cdf0e10cSrcweir                 // to avoid multiple usages of VOCs (which would not work), the primitives
2331cdf0e10cSrcweir                 // for the sub-hierarchy need to be collected here
2332cdf0e10cSrcweir 
2333cdf0e10cSrcweir                 // Get the VOC of the referenced object (the Group) and fetch primitives from it
2334cdf0e10cSrcweir                 const ViewObjectContact& rVOCOfRefObj = rReferencedObject.GetViewContact().GetViewObjectContact(GetObjectContact());
2335cdf0e10cSrcweir                 impAddPrimitivesFromGroup(rVOCOfRefObj, aOffsetMatrix, rDisplayInfo, xRetval);
2336cdf0e10cSrcweir             }
2337cdf0e10cSrcweir             else
2338cdf0e10cSrcweir             {
2339cdf0e10cSrcweir 			    // single object, use method from referenced object to get the Primitive2DSequence
2340cdf0e10cSrcweir 			    xRetval = rReferencedObject.GetViewContact().getViewIndependentPrimitive2DSequence();
2341cdf0e10cSrcweir             }
2342cdf0e10cSrcweir 
2343cdf0e10cSrcweir             if(xRetval.hasElements())
2344cdf0e10cSrcweir 		    {
2345cdf0e10cSrcweir 			    // create transform primitive
2346cdf0e10cSrcweir 			    const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::TransformPrimitive2D(aOffsetMatrix, xRetval));
2347cdf0e10cSrcweir                 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
2348cdf0e10cSrcweir 		    }
2349cdf0e10cSrcweir 
2350cdf0e10cSrcweir             return xRetval;
2351cdf0e10cSrcweir         }
2352cdf0e10cSrcweir 
~VOCOfDrawVirtObj()2353cdf0e10cSrcweir         VOCOfDrawVirtObj::~VOCOfDrawVirtObj()
2354cdf0e10cSrcweir         {
2355cdf0e10cSrcweir         }
2356cdf0e10cSrcweir 
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)2357cdf0e10cSrcweir 		ViewObjectContact& VCOfDrawVirtObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
2358cdf0e10cSrcweir         {
2359cdf0e10cSrcweir 			return *(new VOCOfDrawVirtObj(rObjectContact, *this));
2360cdf0e10cSrcweir         }
2361cdf0e10cSrcweir 
~VCOfDrawVirtObj()2362cdf0e10cSrcweir         VCOfDrawVirtObj::~VCOfDrawVirtObj()
2363cdf0e10cSrcweir         {
2364cdf0e10cSrcweir         }
2365cdf0e10cSrcweir 	} // end of namespace contact
2366cdf0e10cSrcweir } // end of namespace sdr
2367cdf0e10cSrcweir 
2368cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////
2369cdf0e10cSrcweir 
2370cdf0e10cSrcweir // =============================================================================
2371cdf0e10cSrcweir /** implementation of class <SwDrawVirtObj>
2372cdf0e10cSrcweir 
2373cdf0e10cSrcweir     OD 14.05.2003 #108784#
2374cdf0e10cSrcweir 
2375cdf0e10cSrcweir     @author OD
2376cdf0e10cSrcweir */
2377cdf0e10cSrcweir 
2378cdf0e10cSrcweir TYPEINIT1(SwDrawVirtObj,SdrVirtObj);
2379cdf0e10cSrcweir 
CreateObjectSpecificViewContact()2380cdf0e10cSrcweir sdr::contact::ViewContact* SwDrawVirtObj::CreateObjectSpecificViewContact()
2381cdf0e10cSrcweir {
2382cdf0e10cSrcweir 	return new sdr::contact::VCOfDrawVirtObj(*this);
2383cdf0e10cSrcweir }
2384cdf0e10cSrcweir 
2385cdf0e10cSrcweir // #108784#
2386cdf0e10cSrcweir // implemetation of SwDrawVirtObj
SwDrawVirtObj(SdrObject & _rNewObj,SwDrawContact & _rDrawContact)2387cdf0e10cSrcweir SwDrawVirtObj::SwDrawVirtObj( SdrObject&        _rNewObj,
2388cdf0e10cSrcweir                               SwDrawContact&    _rDrawContact )
2389cdf0e10cSrcweir     : SdrVirtObj( _rNewObj ),
2390cdf0e10cSrcweir       // OD 2004-03-29 #i26791# - init new member <maAnchoredDrawObj>
2391cdf0e10cSrcweir       maAnchoredDrawObj(),
2392cdf0e10cSrcweir       mrDrawContact( _rDrawContact )
2393cdf0e10cSrcweir {
2394cdf0e10cSrcweir     // OD 2004-03-29 #i26791#
2395cdf0e10cSrcweir     maAnchoredDrawObj.SetDrawObj( *this );
2396cdf0e10cSrcweir     // --> OD 2004-11-17 #i35635# - set initial position out of sight
2397cdf0e10cSrcweir     NbcMove( Size( -RECT_EMPTY, -RECT_EMPTY ) );
2398cdf0e10cSrcweir     // <--
2399cdf0e10cSrcweir }
2400cdf0e10cSrcweir 
~SwDrawVirtObj()2401cdf0e10cSrcweir SwDrawVirtObj::~SwDrawVirtObj()
2402cdf0e10cSrcweir {}
2403cdf0e10cSrcweir 
operator =(const SdrObject & rObj)2404cdf0e10cSrcweir void SwDrawVirtObj::operator=( const SdrObject& rObj )
2405cdf0e10cSrcweir {
2406cdf0e10cSrcweir 	SdrVirtObj::operator=(rObj);
2407cdf0e10cSrcweir     // Note: Members <maAnchoredDrawObj> and <mrDrawContact>
2408cdf0e10cSrcweir     //       haven't to be considered.
2409cdf0e10cSrcweir }
2410cdf0e10cSrcweir 
Clone() const2411cdf0e10cSrcweir SdrObject* SwDrawVirtObj::Clone() const
2412cdf0e10cSrcweir {
2413cdf0e10cSrcweir     SwDrawVirtObj* pObj = new SwDrawVirtObj( rRefObj, mrDrawContact );
2414cdf0e10cSrcweir 
2415cdf0e10cSrcweir     if ( pObj )
2416cdf0e10cSrcweir     {
2417cdf0e10cSrcweir         pObj->operator=(static_cast<const SdrObject&>(*this));
2418cdf0e10cSrcweir         // Note: Member <maAnchoredDrawObj> hasn't to be considered.
2419cdf0e10cSrcweir     }
2420cdf0e10cSrcweir 
2421cdf0e10cSrcweir     return pObj;
2422cdf0e10cSrcweir }
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir // --------------------------------------------------------------------
2425cdf0e10cSrcweir // connection to writer layout: <GetAnchoredObj()>, <SetAnchorFrm(..)>,
2426cdf0e10cSrcweir // <GetAnchorFrm()>, <SetPageFrm(..)>, <GetPageFrm()> and <RemoveFromWriterLayout()>
2427cdf0e10cSrcweir // --------------------------------------------------------------------
GetAnchoredObj() const2428cdf0e10cSrcweir const SwAnchoredObject* SwDrawVirtObj::GetAnchoredObj() const
2429cdf0e10cSrcweir {
2430cdf0e10cSrcweir     return &maAnchoredDrawObj;
2431cdf0e10cSrcweir }
2432cdf0e10cSrcweir 
AnchoredObj()2433cdf0e10cSrcweir SwAnchoredObject* SwDrawVirtObj::AnchoredObj()
2434cdf0e10cSrcweir {
2435cdf0e10cSrcweir     return &maAnchoredDrawObj;
2436cdf0e10cSrcweir }
2437cdf0e10cSrcweir 
GetAnchorFrm() const2438cdf0e10cSrcweir const SwFrm* SwDrawVirtObj::GetAnchorFrm() const
2439cdf0e10cSrcweir {
2440cdf0e10cSrcweir     // OD 2004-03-29 #i26791# - use new member <maAnchoredDrawObj>
2441cdf0e10cSrcweir     return maAnchoredDrawObj.GetAnchorFrm();
2442cdf0e10cSrcweir }
2443cdf0e10cSrcweir 
AnchorFrm()2444cdf0e10cSrcweir SwFrm* SwDrawVirtObj::AnchorFrm()
2445cdf0e10cSrcweir {
2446cdf0e10cSrcweir     // OD 2004-03-29 #i26791# - use new member <maAnchoredDrawObj>
2447cdf0e10cSrcweir     return maAnchoredDrawObj.AnchorFrm();
2448cdf0e10cSrcweir }
2449cdf0e10cSrcweir 
RemoveFromWriterLayout()2450cdf0e10cSrcweir void SwDrawVirtObj::RemoveFromWriterLayout()
2451cdf0e10cSrcweir {
2452cdf0e10cSrcweir     // remove contact object from frame for 'virtual' drawing object
2453cdf0e10cSrcweir     // OD 2004-03-29 #i26791# - use new member <maAnchoredDrawObj>
2454cdf0e10cSrcweir     if ( maAnchoredDrawObj.GetAnchorFrm() )
2455cdf0e10cSrcweir     {
2456cdf0e10cSrcweir         maAnchoredDrawObj.AnchorFrm()->RemoveDrawObj( maAnchoredDrawObj );
2457cdf0e10cSrcweir     }
2458cdf0e10cSrcweir }
2459cdf0e10cSrcweir 
2460cdf0e10cSrcweir // --------------------------------------------------------------------
2461cdf0e10cSrcweir // connection to writer layout: <AddToDrawingPage()>, <RemoveFromDrawingPage()>
2462cdf0e10cSrcweir // --------------------------------------------------------------------
AddToDrawingPage()2463cdf0e10cSrcweir void SwDrawVirtObj::AddToDrawingPage()
2464cdf0e10cSrcweir {
2465cdf0e10cSrcweir     // determine 'master'
2466cdf0e10cSrcweir     SdrObject* pOrgMasterSdrObj = mrDrawContact.GetMaster();
2467cdf0e10cSrcweir 
2468cdf0e10cSrcweir     // insert 'virtual' drawing object into page, set layer and user call.
2469cdf0e10cSrcweir     SdrPage* pDrawPg;
2470cdf0e10cSrcweir     // --> OD 2004-08-16 #i27030# - apply order number of referenced object
2471cdf0e10cSrcweir     if ( 0 != ( pDrawPg = pOrgMasterSdrObj->GetPage() ) )
2472cdf0e10cSrcweir     {
2473cdf0e10cSrcweir         // --> OD 2004-08-16 #i27030# - apply order number of referenced object
2474cdf0e10cSrcweir         pDrawPg->InsertObject( this, GetReferencedObj().GetOrdNum() );
2475cdf0e10cSrcweir     }
2476cdf0e10cSrcweir     else
2477cdf0e10cSrcweir     {
2478cdf0e10cSrcweir         pDrawPg = GetPage();
2479cdf0e10cSrcweir         if ( pDrawPg )
2480cdf0e10cSrcweir         {
2481cdf0e10cSrcweir             pDrawPg->SetObjectOrdNum( GetOrdNumDirect(),
2482cdf0e10cSrcweir                                       GetReferencedObj().GetOrdNum() );
2483cdf0e10cSrcweir         }
2484cdf0e10cSrcweir         else
2485cdf0e10cSrcweir         {
2486cdf0e10cSrcweir             SetOrdNum( GetReferencedObj().GetOrdNum() );
2487cdf0e10cSrcweir         }
2488cdf0e10cSrcweir     }
2489cdf0e10cSrcweir     // <--
2490cdf0e10cSrcweir     SetUserCall( &mrDrawContact );
2491cdf0e10cSrcweir }
2492cdf0e10cSrcweir 
RemoveFromDrawingPage()2493cdf0e10cSrcweir void SwDrawVirtObj::RemoveFromDrawingPage()
2494cdf0e10cSrcweir {
2495cdf0e10cSrcweir     SetUserCall( 0 );
2496cdf0e10cSrcweir     if ( GetPage() )
2497cdf0e10cSrcweir     {
2498cdf0e10cSrcweir         GetPage()->RemoveObject( GetOrdNum() );
2499cdf0e10cSrcweir     }
2500cdf0e10cSrcweir }
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir // is 'virtual' drawing object connected to writer layout and to drawing layer.
IsConnected() const2503cdf0e10cSrcweir bool SwDrawVirtObj::IsConnected() const
2504cdf0e10cSrcweir {
2505cdf0e10cSrcweir     bool bRetVal = GetAnchorFrm() &&
2506cdf0e10cSrcweir                    ( GetPage() && GetUserCall() );
2507cdf0e10cSrcweir 
2508cdf0e10cSrcweir     return bRetVal;
2509cdf0e10cSrcweir }
2510cdf0e10cSrcweir 
NbcSetAnchorPos(const Point & rPnt)2511cdf0e10cSrcweir void SwDrawVirtObj::NbcSetAnchorPos(const Point& rPnt)
2512cdf0e10cSrcweir {
2513cdf0e10cSrcweir     SdrObject::NbcSetAnchorPos( rPnt );
2514cdf0e10cSrcweir }
2515cdf0e10cSrcweir 
2516cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2517cdf0e10cSrcweir // #i97197#
2518cdf0e10cSrcweir // the methods relevant for positioning
2519cdf0e10cSrcweir 
GetCurrentBoundRect() const2520cdf0e10cSrcweir const Rectangle& SwDrawVirtObj::GetCurrentBoundRect() const
2521cdf0e10cSrcweir {
2522cdf0e10cSrcweir     if(aOutRect.IsEmpty())
2523cdf0e10cSrcweir     {
2524cdf0e10cSrcweir         const_cast<SwDrawVirtObj*>(this)->RecalcBoundRect();
2525cdf0e10cSrcweir     }
2526cdf0e10cSrcweir 
2527cdf0e10cSrcweir     return aOutRect;
2528cdf0e10cSrcweir }
2529cdf0e10cSrcweir 
GetLastBoundRect() const2530cdf0e10cSrcweir const Rectangle& SwDrawVirtObj::GetLastBoundRect() const
2531cdf0e10cSrcweir {
2532cdf0e10cSrcweir 	return aOutRect;
2533cdf0e10cSrcweir }
2534cdf0e10cSrcweir 
GetOffset() const2535cdf0e10cSrcweir const Point SwDrawVirtObj::GetOffset() const
2536cdf0e10cSrcweir {
2537cdf0e10cSrcweir     // do NOT use IsEmpty() here, there is already a useful offset
2538cdf0e10cSrcweir     // in the position
2539cdf0e10cSrcweir     if(aOutRect == Rectangle())
2540cdf0e10cSrcweir     {
2541cdf0e10cSrcweir         return Point();
2542cdf0e10cSrcweir     }
2543cdf0e10cSrcweir     else
2544cdf0e10cSrcweir     {
2545cdf0e10cSrcweir         return aOutRect.TopLeft() - GetReferencedObj().GetCurrentBoundRect().TopLeft();
2546cdf0e10cSrcweir     }
2547cdf0e10cSrcweir }
2548cdf0e10cSrcweir 
SetBoundRectDirty()2549cdf0e10cSrcweir void SwDrawVirtObj::SetBoundRectDirty()
2550cdf0e10cSrcweir {
2551cdf0e10cSrcweir     // do nothing to not lose model information in aOutRect
2552cdf0e10cSrcweir }
2553cdf0e10cSrcweir 
RecalcBoundRect()2554cdf0e10cSrcweir void SwDrawVirtObj::RecalcBoundRect()
2555cdf0e10cSrcweir {
2556cdf0e10cSrcweir     // OD 2004-04-05 #i26791# - switch order of calling <GetOffset()> and
2557cdf0e10cSrcweir     // <ReferencedObj().GetCurrentBoundRect()>, because <GetOffset()> calculates
2558cdf0e10cSrcweir     // its value by the 'BoundRect' of the referenced object.
2559cdf0e10cSrcweir     //aOutRect = rRefObj.GetCurrentBoundRect();
2560cdf0e10cSrcweir     //aOutRect += GetOffset();
2561cdf0e10cSrcweir 
2562cdf0e10cSrcweir     const Point aOffset(GetOffset());
2563cdf0e10cSrcweir     aOutRect = ReferencedObj().GetCurrentBoundRect() + aOffset;
2564cdf0e10cSrcweir }
2565cdf0e10cSrcweir 
TakeXorPoly() const2566cdf0e10cSrcweir basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const
2567cdf0e10cSrcweir {
2568cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aRetval(rRefObj.TakeXorPoly());
2569cdf0e10cSrcweir 	aRetval.transform(basegfx::tools::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y()));
2570cdf0e10cSrcweir 
2571cdf0e10cSrcweir 	return aRetval;
2572cdf0e10cSrcweir }
2573cdf0e10cSrcweir 
TakeContour() const2574cdf0e10cSrcweir basegfx::B2DPolyPolygon SwDrawVirtObj::TakeContour() const
2575cdf0e10cSrcweir {
2576cdf0e10cSrcweir     basegfx::B2DPolyPolygon aRetval(rRefObj.TakeContour());
2577cdf0e10cSrcweir 	aRetval.transform(basegfx::tools::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y()));
2578cdf0e10cSrcweir 
2579cdf0e10cSrcweir 	return aRetval;
2580cdf0e10cSrcweir }
2581cdf0e10cSrcweir 
GetHdl(sal_uInt32 nHdlNum) const2582cdf0e10cSrcweir SdrHdl* SwDrawVirtObj::GetHdl(sal_uInt32 nHdlNum) const
2583cdf0e10cSrcweir {
2584cdf0e10cSrcweir 	SdrHdl* pHdl = rRefObj.GetHdl(nHdlNum);
2585*eefa0d2bSArmin Le Grand 
2586*eefa0d2bSArmin Le Grand     if(pHdl)
2587*eefa0d2bSArmin Le Grand     {
2588cdf0e10cSrcweir         Point aP(pHdl->GetPos() + GetOffset());
2589cdf0e10cSrcweir         pHdl->SetPos(aP);
2590*eefa0d2bSArmin Le Grand     }
2591*eefa0d2bSArmin Le Grand     else
2592*eefa0d2bSArmin Le Grand     {
2593*eefa0d2bSArmin Le Grand         OSL_ENSURE(false, "Got no SdrHdl(!)");
2594*eefa0d2bSArmin Le Grand     }
2595cdf0e10cSrcweir 
2596cdf0e10cSrcweir 	return pHdl;
2597cdf0e10cSrcweir }
2598cdf0e10cSrcweir 
GetPlusHdl(const SdrHdl & rHdl,sal_uInt16 nPlNum) const2599cdf0e10cSrcweir SdrHdl* SwDrawVirtObj::GetPlusHdl(const SdrHdl& rHdl, sal_uInt16 nPlNum) const
2600cdf0e10cSrcweir {
2601cdf0e10cSrcweir 	SdrHdl* pHdl = rRefObj.GetPlusHdl(rHdl, nPlNum);
2602*eefa0d2bSArmin Le Grand 
2603*eefa0d2bSArmin Le Grand     if(pHdl)
2604*eefa0d2bSArmin Le Grand     {
2605cdf0e10cSrcweir         pHdl->SetPos(pHdl->GetPos() + GetOffset());
2606*eefa0d2bSArmin Le Grand     }
2607*eefa0d2bSArmin Le Grand     else
2608*eefa0d2bSArmin Le Grand     {
2609*eefa0d2bSArmin Le Grand         OSL_ENSURE(false, "Got no SdrHdl(!)");
2610*eefa0d2bSArmin Le Grand     }
2611cdf0e10cSrcweir 
2612cdf0e10cSrcweir 	return pHdl;
2613cdf0e10cSrcweir }
2614cdf0e10cSrcweir 
NbcMove(const Size & rSiz)2615cdf0e10cSrcweir void SwDrawVirtObj::NbcMove(const Size& rSiz)
2616cdf0e10cSrcweir {
2617cdf0e10cSrcweir     SdrObject::NbcMove( rSiz );
2618cdf0e10cSrcweir }
2619cdf0e10cSrcweir 
NbcResize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)2620cdf0e10cSrcweir void SwDrawVirtObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
2621cdf0e10cSrcweir {
2622cdf0e10cSrcweir     rRefObj.NbcResize(rRef - GetOffset(), xFact, yFact);
2623cdf0e10cSrcweir 	SetRectsDirty();
2624cdf0e10cSrcweir }
2625cdf0e10cSrcweir 
NbcRotate(const Point & rRef,long nWink,double sn,double cs)2626cdf0e10cSrcweir void SwDrawVirtObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
2627cdf0e10cSrcweir {
2628cdf0e10cSrcweir     rRefObj.NbcRotate(rRef - GetOffset(), nWink, sn, cs);
2629cdf0e10cSrcweir 	SetRectsDirty();
2630cdf0e10cSrcweir }
2631cdf0e10cSrcweir 
NbcMirror(const Point & rRef1,const Point & rRef2)2632cdf0e10cSrcweir void SwDrawVirtObj::NbcMirror(const Point& rRef1, const Point& rRef2)
2633cdf0e10cSrcweir {
2634cdf0e10cSrcweir     rRefObj.NbcMirror(rRef1 - GetOffset(), rRef2 - GetOffset());
2635cdf0e10cSrcweir 	SetRectsDirty();
2636cdf0e10cSrcweir }
2637cdf0e10cSrcweir 
NbcShear(const Point & rRef,long nWink,double tn,FASTBOOL bVShear)2638cdf0e10cSrcweir void SwDrawVirtObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
2639cdf0e10cSrcweir {
2640cdf0e10cSrcweir     rRefObj.NbcShear(rRef - GetOffset(), nWink, tn, bVShear);
2641cdf0e10cSrcweir 	SetRectsDirty();
2642cdf0e10cSrcweir }
2643cdf0e10cSrcweir 
Move(const Size & rSiz)2644cdf0e10cSrcweir void SwDrawVirtObj::Move(const Size& rSiz)
2645cdf0e10cSrcweir {
2646cdf0e10cSrcweir     SdrObject::Move( rSiz );
2647cdf0e10cSrcweir //    Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
2648cdf0e10cSrcweir //    rRefObj.Move( rSiz );
2649cdf0e10cSrcweir //    SetRectsDirty();
2650cdf0e10cSrcweir //    SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
2651cdf0e10cSrcweir }
2652cdf0e10cSrcweir 
Resize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)2653cdf0e10cSrcweir void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
2654cdf0e10cSrcweir {
2655cdf0e10cSrcweir 	if(xFact.GetNumerator() != xFact.GetDenominator() || yFact.GetNumerator() != yFact.GetDenominator())
2656cdf0e10cSrcweir 	{
2657cdf0e10cSrcweir 		Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
2658cdf0e10cSrcweir         rRefObj.Resize(rRef - GetOffset(), xFact, yFact);
2659cdf0e10cSrcweir 		SetRectsDirty();
2660cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
2661cdf0e10cSrcweir 	}
2662cdf0e10cSrcweir }
2663cdf0e10cSrcweir 
Rotate(const Point & rRef,long nWink,double sn,double cs)2664cdf0e10cSrcweir void SwDrawVirtObj::Rotate(const Point& rRef, long nWink, double sn, double cs)
2665cdf0e10cSrcweir {
2666cdf0e10cSrcweir 	if(nWink)
2667cdf0e10cSrcweir 	{
2668cdf0e10cSrcweir 		Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
2669cdf0e10cSrcweir         rRefObj.Rotate(rRef - GetOffset(), nWink, sn, cs);
2670cdf0e10cSrcweir 		SetRectsDirty();
2671cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
2672cdf0e10cSrcweir 	}
2673cdf0e10cSrcweir }
2674cdf0e10cSrcweir 
Mirror(const Point & rRef1,const Point & rRef2)2675cdf0e10cSrcweir void SwDrawVirtObj::Mirror(const Point& rRef1, const Point& rRef2)
2676cdf0e10cSrcweir {
2677cdf0e10cSrcweir 	Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
2678cdf0e10cSrcweir     rRefObj.Mirror(rRef1 - GetOffset(), rRef2 - GetOffset());
2679cdf0e10cSrcweir 	SetRectsDirty();
2680cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
2681cdf0e10cSrcweir }
2682cdf0e10cSrcweir 
Shear(const Point & rRef,long nWink,double tn,FASTBOOL bVShear)2683cdf0e10cSrcweir void SwDrawVirtObj::Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
2684cdf0e10cSrcweir {
2685cdf0e10cSrcweir 	if(nWink)
2686cdf0e10cSrcweir 	{
2687cdf0e10cSrcweir 		Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
2688cdf0e10cSrcweir         rRefObj.Shear(rRef - GetOffset(), nWink, tn, bVShear);
2689cdf0e10cSrcweir 		SetRectsDirty();
2690cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
2691cdf0e10cSrcweir 	}
2692cdf0e10cSrcweir }
2693cdf0e10cSrcweir 
RecalcSnapRect()2694cdf0e10cSrcweir void SwDrawVirtObj::RecalcSnapRect()
2695cdf0e10cSrcweir {
2696cdf0e10cSrcweir     aSnapRect = rRefObj.GetSnapRect();
2697cdf0e10cSrcweir     aSnapRect += GetOffset();
2698cdf0e10cSrcweir }
2699cdf0e10cSrcweir 
GetSnapRect() const2700cdf0e10cSrcweir const Rectangle& SwDrawVirtObj::GetSnapRect() const
2701cdf0e10cSrcweir {
2702cdf0e10cSrcweir     ((SwDrawVirtObj*)this)->aSnapRect = rRefObj.GetSnapRect();
2703cdf0e10cSrcweir     ((SwDrawVirtObj*)this)->aSnapRect += GetOffset();
2704cdf0e10cSrcweir 
2705cdf0e10cSrcweir     return aSnapRect;
2706cdf0e10cSrcweir }
2707cdf0e10cSrcweir 
SetSnapRect(const Rectangle & rRect)2708cdf0e10cSrcweir void SwDrawVirtObj::SetSnapRect(const Rectangle& rRect)
2709cdf0e10cSrcweir {
2710cdf0e10cSrcweir 	Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
2711cdf0e10cSrcweir 	Rectangle aR(rRect);
2712cdf0e10cSrcweir     aR -= GetOffset();
2713cdf0e10cSrcweir 	rRefObj.SetSnapRect(aR);
2714cdf0e10cSrcweir 	SetRectsDirty();
2715cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
2716cdf0e10cSrcweir }
2717cdf0e10cSrcweir 
NbcSetSnapRect(const Rectangle & rRect)2718cdf0e10cSrcweir void SwDrawVirtObj::NbcSetSnapRect(const Rectangle& rRect)
2719cdf0e10cSrcweir {
2720cdf0e10cSrcweir 	Rectangle aR(rRect);
2721cdf0e10cSrcweir     aR -= GetOffset();
2722cdf0e10cSrcweir 	SetRectsDirty();
2723cdf0e10cSrcweir 	rRefObj.NbcSetSnapRect(aR);
2724cdf0e10cSrcweir }
2725cdf0e10cSrcweir 
GetLogicRect() const2726cdf0e10cSrcweir const Rectangle& SwDrawVirtObj::GetLogicRect() const
2727cdf0e10cSrcweir {
2728cdf0e10cSrcweir 	((SwDrawVirtObj*)this)->aSnapRect = rRefObj.GetLogicRect();
2729cdf0e10cSrcweir     ((SwDrawVirtObj*)this)->aSnapRect += GetOffset();
2730cdf0e10cSrcweir 
2731cdf0e10cSrcweir 	return aSnapRect;
2732cdf0e10cSrcweir }
2733cdf0e10cSrcweir 
SetLogicRect(const Rectangle & rRect)2734cdf0e10cSrcweir void SwDrawVirtObj::SetLogicRect(const Rectangle& rRect)
2735cdf0e10cSrcweir {
2736cdf0e10cSrcweir 	Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect();
2737cdf0e10cSrcweir 	Rectangle aR(rRect);
2738cdf0e10cSrcweir     aR -= GetOffset();
2739cdf0e10cSrcweir 	rRefObj.SetLogicRect(aR);
2740cdf0e10cSrcweir 	SetRectsDirty();
2741cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
2742cdf0e10cSrcweir }
2743cdf0e10cSrcweir 
NbcSetLogicRect(const Rectangle & rRect)2744cdf0e10cSrcweir void SwDrawVirtObj::NbcSetLogicRect(const Rectangle& rRect)
2745cdf0e10cSrcweir {
2746cdf0e10cSrcweir 	Rectangle aR(rRect);
2747cdf0e10cSrcweir     aR -= GetOffset();
2748cdf0e10cSrcweir 	rRefObj.NbcSetLogicRect(aR);
2749cdf0e10cSrcweir 	SetRectsDirty();
2750cdf0e10cSrcweir }
2751cdf0e10cSrcweir 
GetSnapPoint(sal_uInt32 i) const2752cdf0e10cSrcweir Point SwDrawVirtObj::GetSnapPoint(sal_uInt32 i) const
2753cdf0e10cSrcweir {
2754cdf0e10cSrcweir 	Point aP(rRefObj.GetSnapPoint(i));
2755cdf0e10cSrcweir     aP += GetOffset();
2756cdf0e10cSrcweir 
2757cdf0e10cSrcweir 	return aP;
2758cdf0e10cSrcweir }
2759cdf0e10cSrcweir 
GetPoint(sal_uInt32 i) const2760cdf0e10cSrcweir Point SwDrawVirtObj::GetPoint(sal_uInt32 i) const
2761cdf0e10cSrcweir {
2762cdf0e10cSrcweir 	return Point(rRefObj.GetPoint(i) + GetOffset());
2763cdf0e10cSrcweir }
2764cdf0e10cSrcweir 
NbcSetPoint(const Point & rPnt,sal_uInt32 i)2765cdf0e10cSrcweir void SwDrawVirtObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
2766cdf0e10cSrcweir {
2767cdf0e10cSrcweir 	Point aP(rPnt);
2768cdf0e10cSrcweir     aP -= GetOffset();
2769cdf0e10cSrcweir 	rRefObj.SetPoint(aP, i);
2770cdf0e10cSrcweir 	SetRectsDirty();
2771cdf0e10cSrcweir }
2772cdf0e10cSrcweir 
2773cdf0e10cSrcweir // #108784#
HasTextEdit() const2774cdf0e10cSrcweir FASTBOOL SwDrawVirtObj::HasTextEdit() const
2775cdf0e10cSrcweir {
2776cdf0e10cSrcweir 	return rRefObj.HasTextEdit();
2777cdf0e10cSrcweir }
2778cdf0e10cSrcweir 
2779cdf0e10cSrcweir // OD 18.06.2003 #108784# - overloaded 'layer' methods for 'virtual' drawing
2780cdf0e10cSrcweir // object to assure, that layer of 'virtual' object is the layer of the referenced
2781cdf0e10cSrcweir // object.
GetLayer() const2782cdf0e10cSrcweir SdrLayerID SwDrawVirtObj::GetLayer() const
2783cdf0e10cSrcweir {
2784cdf0e10cSrcweir     return GetReferencedObj().GetLayer();
2785cdf0e10cSrcweir }
2786cdf0e10cSrcweir 
NbcSetLayer(SdrLayerID nLayer)2787cdf0e10cSrcweir void SwDrawVirtObj::NbcSetLayer(SdrLayerID nLayer)
2788cdf0e10cSrcweir {
2789cdf0e10cSrcweir     ReferencedObj().NbcSetLayer( nLayer );
2790cdf0e10cSrcweir     SdrVirtObj::NbcSetLayer( ReferencedObj().GetLayer() );
2791cdf0e10cSrcweir }
2792cdf0e10cSrcweir 
SetLayer(SdrLayerID nLayer)2793cdf0e10cSrcweir void SwDrawVirtObj::SetLayer(SdrLayerID nLayer)
2794cdf0e10cSrcweir {
2795cdf0e10cSrcweir     ReferencedObj().SetLayer( nLayer );
2796cdf0e10cSrcweir     SdrVirtObj::NbcSetLayer( ReferencedObj().GetLayer() );
2797cdf0e10cSrcweir }
2798cdf0e10cSrcweir 
supportsFullDrag() const2799cdf0e10cSrcweir bool SwDrawVirtObj::supportsFullDrag() const
2800cdf0e10cSrcweir {
2801cdf0e10cSrcweir     // call parent
2802cdf0e10cSrcweir     return SdrVirtObj::supportsFullDrag();
2803cdf0e10cSrcweir }
2804cdf0e10cSrcweir 
getFullDragClone() const2805cdf0e10cSrcweir SdrObject* SwDrawVirtObj::getFullDragClone() const
2806cdf0e10cSrcweir {
2807cdf0e10cSrcweir     // call parent
2808cdf0e10cSrcweir     return SdrVirtObj::getFullDragClone();
2809cdf0e10cSrcweir }
2810cdf0e10cSrcweir 
2811cdf0e10cSrcweir // eof
2812cdf0e10cSrcweir 
2813