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