xref: /aoo41x/main/sw/source/core/draw/dview.cxx (revision 8218eba2)
1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist  *
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
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
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.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include "hintids.hxx"
26cdf0e10cSrcweir #include <editeng/protitem.hxx>
27cdf0e10cSrcweir #include <svx/svdpagv.hxx>
28cdf0e10cSrcweir #include <svx/fmmodel.hxx>
29cdf0e10cSrcweir #include <sot/exchange.hxx>
30*8218eba2SArmin Le Grand #include <svx/sdrundomanager.hxx>
31*8218eba2SArmin Le Grand #include <editeng/outliner.hxx>
32*8218eba2SArmin Le Grand #include <com/sun/star/embed/EmbedMisc.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "swtypes.hxx"
35cdf0e10cSrcweir #include "pagefrm.hxx"
36cdf0e10cSrcweir #include "rootfrm.hxx"
37cdf0e10cSrcweir #include "cntfrm.hxx"
38cdf0e10cSrcweir #include "flyfrm.hxx"
39cdf0e10cSrcweir #include "frmfmt.hxx"
40cdf0e10cSrcweir #include "dflyobj.hxx"
41cdf0e10cSrcweir #include "dcontact.hxx"
42cdf0e10cSrcweir #include "frmatr.hxx"
43cdf0e10cSrcweir #include "viewsh.hxx"
44cdf0e10cSrcweir #include "viewimp.hxx"
45cdf0e10cSrcweir #include "dview.hxx"
46cdf0e10cSrcweir #include "dpage.hxx"
47cdf0e10cSrcweir #include "doc.hxx"
48cdf0e10cSrcweir #include "mdiexp.hxx"
49cdf0e10cSrcweir #include <ndole.hxx>
50cdf0e10cSrcweir #include <fmtanchr.hxx>
51cdf0e10cSrcweir #include "shellres.hxx"
52cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
53cdf0e10cSrcweir #include <vector>
54cdf0e10cSrcweir #include <sortedobjs.hxx>
55cdf0e10cSrcweir #include <flyfrms.hxx>
56*8218eba2SArmin Le Grand #include <UndoManager.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using namespace com::sun::star;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir class SwSdrHdl : public SdrHdl
61cdf0e10cSrcweir {
62cdf0e10cSrcweir public:
SwSdrHdl(const Point & rPnt,bool bTopRight)63cdf0e10cSrcweir     SwSdrHdl(const Point& rPnt, bool bTopRight ) :
64cdf0e10cSrcweir         SdrHdl( rPnt, bTopRight ? HDL_ANCHOR_TR : HDL_ANCHOR ) {}
65cdf0e10cSrcweir     virtual sal_Bool IsFocusHdl() const;
66cdf0e10cSrcweir };
67cdf0e10cSrcweir 
IsFocusHdl() const68cdf0e10cSrcweir sal_Bool SwSdrHdl::IsFocusHdl() const
69cdf0e10cSrcweir {
70cdf0e10cSrcweir     if( HDL_ANCHOR == eKind || HDL_ANCHOR_TR == eKind )
71cdf0e10cSrcweir         return sal_True;
72cdf0e10cSrcweir     return SdrHdl::IsFocusHdl();
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
lcl_FindAnchor(const SdrObject * pObj,sal_Bool bAll)75cdf0e10cSrcweir const SwFrm *lcl_FindAnchor( const SdrObject *pObj, sal_Bool bAll )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	const SwVirtFlyDrawObj *pVirt = pObj->ISA(SwVirtFlyDrawObj) ?
78cdf0e10cSrcweir 											(SwVirtFlyDrawObj*)pObj : 0;
79cdf0e10cSrcweir 	if ( pVirt )
80cdf0e10cSrcweir 	{
81cdf0e10cSrcweir 		if ( bAll || !pVirt->GetFlyFrm()->IsFlyInCntFrm() )
82cdf0e10cSrcweir             return pVirt->GetFlyFrm()->GetAnchorFrm();
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 	else
85cdf0e10cSrcweir 	{
86cdf0e10cSrcweir         const SwDrawContact *pCont = (const SwDrawContact*)GetUserCall(pObj);
87cdf0e10cSrcweir 		if ( pCont )
88cdf0e10cSrcweir             return pCont->GetAnchorFrm( pObj );
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 	return 0;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir /*************************************************************************
94cdf0e10cSrcweir |*
95cdf0e10cSrcweir |*	SwDrawView::Ctor
96cdf0e10cSrcweir |*
97cdf0e10cSrcweir |*	Ersterstellung		OK 18.11.94
98cdf0e10cSrcweir |*	Letzte Aenderung	MA 22. Jul. 96
99cdf0e10cSrcweir |*
100cdf0e10cSrcweir *************************************************************************/
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
SwDrawView(SwViewImp & rI,SdrModel * pMd,OutputDevice * pOutDev)104cdf0e10cSrcweir SwDrawView::SwDrawView( SwViewImp &rI, SdrModel *pMd, OutputDevice *pOutDev) :
105cdf0e10cSrcweir 	FmFormView( (FmFormModel*)pMd, pOutDev ),
106cdf0e10cSrcweir 	rImp( rI )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	SetPageVisible( sal_False );
109cdf0e10cSrcweir 	SetBordVisible( sal_False );
110cdf0e10cSrcweir 	SetGridVisible( sal_False );
111cdf0e10cSrcweir 	SetHlplVisible( sal_False );
112cdf0e10cSrcweir 	SetGlueVisible( sal_False );
113cdf0e10cSrcweir 	SetFrameDragSingles( sal_True );
114cdf0e10cSrcweir 	SetVirtualObjectBundling( sal_True );
115cdf0e10cSrcweir 	SetSwapAsynchron( sal_True );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	EnableExtendedKeyInputDispatcher( sal_False );
118cdf0e10cSrcweir 	EnableExtendedMouseEventDispatcher( sal_False );
119cdf0e10cSrcweir 	EnableExtendedCommandEventDispatcher( sal_False );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	SetHitTolerancePixel( GetMarkHdlSizePixel()/2 );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	SetPrintPreview( rI.GetShell()->IsPreView() );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	// #i73602# Use default from the configuration
126cdf0e10cSrcweir 	SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Writer());
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	// #i74769#, #i75172# Use default from the configuration
129cdf0e10cSrcweir 	SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Writer());
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir // --> OD 2009-03-05 #i99665#
IsAntiAliasing() const133cdf0e10cSrcweir sal_Bool SwDrawView::IsAntiAliasing() const
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     return getOptionsDrawinglayer().IsAntiAliasing();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir // <--
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
140cdf0e10cSrcweir 
impLocalHitCorrection(SdrObject * pRetval,const Point & rPnt,sal_uInt16 nTol,const SdrMarkList & rMrkList)141cdf0e10cSrcweir SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt16 nTol, const SdrMarkList &rMrkList)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     if(!nTol)
144cdf0e10cSrcweir     {
145cdf0e10cSrcweir         // the old method forced back to outer bounds test when nTol == 0, so
146cdf0e10cSrcweir         // do not try to correct when nTol is not set (used from HelpContent)
147cdf0e10cSrcweir     }
148cdf0e10cSrcweir     else
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir         // rebuild logic from former SwVirtFlyDrawObj::CheckSdrObjectHit. This is needed since
151cdf0e10cSrcweir         // the SdrObject-specific CheckHit implementations are now replaced with primitives and
152cdf0e10cSrcweir         // 'tricks' like in the old implementation (e.g. using a view from a model-data class to
153cdf0e10cSrcweir         // detect if object is selected) are no longer valid.
154cdf0e10cSrcweir         // The standard primitive hit-test for SwVirtFlyDrawObj now is the outer bound. The old
155cdf0e10cSrcweir         // implementation reduced this excluding the inner bound when the object was not selected.
156cdf0e10cSrcweir         SwVirtFlyDrawObj* pSwVirtFlyDrawObj = dynamic_cast< SwVirtFlyDrawObj* >(pRetval);
157cdf0e10cSrcweir 
158cdf0e10cSrcweir         if(pSwVirtFlyDrawObj)
159cdf0e10cSrcweir         {
160cdf0e10cSrcweir             if(pSwVirtFlyDrawObj->GetFlyFrm()->Lower() && pSwVirtFlyDrawObj->GetFlyFrm()->Lower()->IsNoTxtFrm())
161cdf0e10cSrcweir 			{
162cdf0e10cSrcweir                 // the old method used IsNoTxtFrm (should be for SW's own OLE and
163cdf0e10cSrcweir                 // graphic's) to accept hit only based on outer bounds; nothing to do
164cdf0e10cSrcweir             }
165cdf0e10cSrcweir             else
166cdf0e10cSrcweir             {
167cdf0e10cSrcweir                 // check if the object is selected in this view
168cdf0e10cSrcweir                 const sal_uInt32 nMarkCount(rMrkList.GetMarkCount());
169cdf0e10cSrcweir                 bool bSelected(false);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir                 for(sal_uInt32 a(0); !bSelected && a < nMarkCount; a++)
172cdf0e10cSrcweir                 {
173cdf0e10cSrcweir                     if(pSwVirtFlyDrawObj == rMrkList.GetMark(a)->GetMarkedSdrObj())
174cdf0e10cSrcweir                     {
175cdf0e10cSrcweir                         bSelected = true;
176cdf0e10cSrcweir                     }
177cdf0e10cSrcweir                 }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir                 if(!bSelected)
180cdf0e10cSrcweir                 {
181cdf0e10cSrcweir                     // when not selected, the object is not hit when hit position is inside
182cdf0e10cSrcweir                     // inner range. Get and shrink inner range
183cdf0e10cSrcweir                     basegfx::B2DRange aInnerBound(pSwVirtFlyDrawObj->getInnerBound());
184cdf0e10cSrcweir 
185cdf0e10cSrcweir                     aInnerBound.grow(-1.0 * nTol);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                     if(aInnerBound.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
188cdf0e10cSrcweir                     {
189cdf0e10cSrcweir                         // exclude this hit
190cdf0e10cSrcweir                         pRetval = 0;
191cdf0e10cSrcweir                     }
192cdf0e10cSrcweir                 }
193cdf0e10cSrcweir             }
194cdf0e10cSrcweir         }
195cdf0e10cSrcweir     }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     return pRetval;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
CheckSingleSdrObjectHit(const Point & rPnt,sal_uInt16 nTol,SdrObject * pObj,SdrPageView * pPV,sal_uLong nOptions,const SetOfByte * pMVisLay) const200cdf0e10cSrcweir SdrObject* SwDrawView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     // call parent
203cdf0e10cSrcweir     SdrObject* pRetval = FmFormView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     if(pRetval)
206cdf0e10cSrcweir     {
207cdf0e10cSrcweir         // overloaded to allow extra handling when picking SwVirtFlyDrawObj's
208cdf0e10cSrcweir         pRetval = impLocalHitCorrection(pRetval, rPnt, nTol, GetMarkedObjectList());
209cdf0e10cSrcweir     }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     return pRetval;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir /*************************************************************************
215cdf0e10cSrcweir |*
216cdf0e10cSrcweir |*	SwDrawView::AddCustomHdl()
217cdf0e10cSrcweir |*
218cdf0e10cSrcweir |*  Gets called every time the handles need to be build
219cdf0e10cSrcweir |*
220cdf0e10cSrcweir |*	Ersterstellung		AW 06. Sep. 99
221cdf0e10cSrcweir |*	Letzte Aenderung	AW 06. Sep. 99
222cdf0e10cSrcweir |*
223cdf0e10cSrcweir *************************************************************************/
224cdf0e10cSrcweir 
AddCustomHdl()225cdf0e10cSrcweir void SwDrawView::AddCustomHdl()
226cdf0e10cSrcweir {
227cdf0e10cSrcweir 	const SdrMarkList &rMrkList = GetMarkedObjectList();
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	if(rMrkList.GetMarkCount() != 1 || !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()))
230cdf0e10cSrcweir 		return;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	SdrObject *pObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
233cdf0e10cSrcweir     // --> OD 2006-11-06 #130889# - make code robust
234cdf0e10cSrcweir //    const SwFmtAnchor &rAnchor = ::FindFrmFmt(pObj)->GetAnchor();
235cdf0e10cSrcweir     SwFrmFmt* pFrmFmt( ::FindFrmFmt( pObj ) );
236cdf0e10cSrcweir     if ( !pFrmFmt )
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         ASSERT( false, "<SwDrawView::AddCustomHdl()> - missing frame format!" );
239cdf0e10cSrcweir         return;
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir     const SwFmtAnchor &rAnchor = pFrmFmt->GetAnchor();
242cdf0e10cSrcweir     // <--
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     if (FLY_AS_CHAR == rAnchor.GetAnchorId())
245cdf0e10cSrcweir 		return;
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	const SwFrm* pAnch;
248cdf0e10cSrcweir 	if(0 == (pAnch = CalcAnchor()))
249cdf0e10cSrcweir 		return;
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     Point aPos(aAnchorPoint);
252cdf0e10cSrcweir 
253cdf0e10cSrcweir     if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
254cdf0e10cSrcweir 	{
255cdf0e10cSrcweir         // --> OD 2004-06-24 #i28701# - use last character rectangle saved at object
256cdf0e10cSrcweir         // in order to avoid a format of the anchor frame
257cdf0e10cSrcweir         SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
258cdf0e10cSrcweir         SwRect aAutoPos = pAnchoredObj->GetLastCharRect();
259cdf0e10cSrcweir         if ( aAutoPos.Height() )
260cdf0e10cSrcweir         {
261cdf0e10cSrcweir             aPos = aAutoPos.Pos();
262cdf0e10cSrcweir         }
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 	// add anchor handle:
266cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
267cdf0e10cSrcweir     aHdl.AddHdl( new SwSdrHdl( aPos, ( pAnch->IsVertical() && !pAnch->IsVertLR() ) ||
268cdf0e10cSrcweir                                      pAnch->IsRightToLeft() ) );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir /*************************************************************************
272cdf0e10cSrcweir |*
273cdf0e10cSrcweir |*	SwDrawView::GetMaxToTopObj(), _GetMaxToTopObj()
274cdf0e10cSrcweir |*
275cdf0e10cSrcweir |*	Ersterstellung		MA 13. Jan. 95
276cdf0e10cSrcweir |*	Letzte Aenderung	MA 18. Mar. 97
277cdf0e10cSrcweir |*
278cdf0e10cSrcweir *************************************************************************/
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 
GetMaxToTopObj(SdrObject * pObj) const281cdf0e10cSrcweir SdrObject* SwDrawView::GetMaxToTopObj( SdrObject* pObj ) const
282cdf0e10cSrcweir {
283cdf0e10cSrcweir 	if ( GetUserCall(pObj) )
284cdf0e10cSrcweir 	{
285cdf0e10cSrcweir 		const SwFrm *pAnch = ::lcl_FindAnchor( pObj, sal_False );
286cdf0e10cSrcweir 		if ( pAnch )
287cdf0e10cSrcweir 		{
288cdf0e10cSrcweir 			//Das oberste Obj innerhalb des Ankers darf nicht ueberholt
289cdf0e10cSrcweir 			//werden.
290cdf0e10cSrcweir 			const SwFlyFrm *pFly = pAnch->FindFlyFrm();
291cdf0e10cSrcweir 			if ( pFly )
292cdf0e10cSrcweir 			{
293cdf0e10cSrcweir 				const SwPageFrm *pPage = pFly->FindPageFrm();
294cdf0e10cSrcweir 				if ( pPage->GetSortedObjs() )
295cdf0e10cSrcweir 				{
296cdf0e10cSrcweir 					sal_uInt32 nOrdNum = 0;
297cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; i < pPage->GetSortedObjs()->Count(); ++i )
298cdf0e10cSrcweir 					{
299cdf0e10cSrcweir                         const SdrObject *pO =
300cdf0e10cSrcweir                                     (*pPage->GetSortedObjs())[i]->GetDrawObj();
301cdf0e10cSrcweir 
302cdf0e10cSrcweir                         if ( pO->GetOrdNumDirect() > nOrdNum )
303cdf0e10cSrcweir 						{
304cdf0e10cSrcweir                             const SwFrm *pTmpAnch = ::lcl_FindAnchor( pO, sal_False );
305cdf0e10cSrcweir                             if ( pFly->IsAnLower( pTmpAnch ) )
306cdf0e10cSrcweir 							{
307cdf0e10cSrcweir 								nOrdNum = pO->GetOrdNumDirect();
308cdf0e10cSrcweir 							}
309cdf0e10cSrcweir 						}
310cdf0e10cSrcweir 					}
311cdf0e10cSrcweir 					if ( nOrdNum )
312cdf0e10cSrcweir 					{
313cdf0e10cSrcweir                         SdrPage *pTmpPage = GetModel()->GetPage( 0 );
314cdf0e10cSrcweir 						++nOrdNum;
315cdf0e10cSrcweir                         if ( nOrdNum < pTmpPage->GetObjCount() )
316cdf0e10cSrcweir 						{
317cdf0e10cSrcweir                             return pTmpPage->GetObj( nOrdNum );
318cdf0e10cSrcweir 						}
319cdf0e10cSrcweir 					}
320cdf0e10cSrcweir 				}
321cdf0e10cSrcweir 			}
322cdf0e10cSrcweir 		}
323cdf0e10cSrcweir 	}
324cdf0e10cSrcweir 	return 0;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir /*************************************************************************
328cdf0e10cSrcweir |*
329cdf0e10cSrcweir |*	SwDrawView::GetMaxToBtmObj()
330cdf0e10cSrcweir |*
331cdf0e10cSrcweir |*	Ersterstellung		MA 13. Jan. 95
332cdf0e10cSrcweir |*	Letzte Aenderung	MA 05. Sep. 96
333cdf0e10cSrcweir |*
334cdf0e10cSrcweir *************************************************************************/
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 
GetMaxToBtmObj(SdrObject * pObj) const337cdf0e10cSrcweir SdrObject* SwDrawView::GetMaxToBtmObj(SdrObject* pObj) const
338cdf0e10cSrcweir {
339cdf0e10cSrcweir 	if ( GetUserCall(pObj) )
340cdf0e10cSrcweir 	{
341cdf0e10cSrcweir 		const SwFrm *pAnch = ::lcl_FindAnchor( pObj, sal_False );
342cdf0e10cSrcweir 		if ( pAnch )
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 			//Der Fly des Ankers darf nicht "unterflogen" werden.
345cdf0e10cSrcweir 			const SwFlyFrm *pFly = pAnch->FindFlyFrm();
346cdf0e10cSrcweir 			if ( pFly )
347cdf0e10cSrcweir 			{
348cdf0e10cSrcweir 				SdrObject *pRet = (SdrObject*)pFly->GetVirtDrawObj();
349cdf0e10cSrcweir 				return pRet != pObj ? pRet : 0;
350cdf0e10cSrcweir 			}
351cdf0e10cSrcweir 		}
352cdf0e10cSrcweir 	}
353cdf0e10cSrcweir 	return 0;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir /*************************************************************************
357cdf0e10cSrcweir |*
358cdf0e10cSrcweir |*	SwDrawView::ObjOrderChanged()
359cdf0e10cSrcweir |*
360cdf0e10cSrcweir |*	Ersterstellung		MA 31. Jul. 95
361cdf0e10cSrcweir |*	Letzte Aenderung	MA 18. Mar. 97
362cdf0e10cSrcweir |*
363cdf0e10cSrcweir *************************************************************************/
364cdf0e10cSrcweir 
lcl_IsChild(SdrObject * pParent,SdrObject * pChild)365cdf0e10cSrcweir inline sal_Bool lcl_IsChild( SdrObject *pParent, SdrObject *pChild )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir 	if ( pParent->ISA(SwVirtFlyDrawObj) )
368cdf0e10cSrcweir 	{
369cdf0e10cSrcweir 		const SwFrm *pAnch = lcl_FindAnchor( pChild, sal_False );
370cdf0e10cSrcweir 		if ( pAnch && ((SwVirtFlyDrawObj*)pParent)->GetFlyFrm()->IsAnLower( pAnch ))
371cdf0e10cSrcweir 		{
372cdf0e10cSrcweir 			return sal_True;
373cdf0e10cSrcweir 		}
374cdf0e10cSrcweir 	}
375cdf0e10cSrcweir 	return sal_False;
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
lcl_FindParent(SdrObject * pObj)378cdf0e10cSrcweir inline SdrObject *lcl_FindParent( SdrObject *pObj )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	const SwFrm *pAnch = lcl_FindAnchor( pObj, sal_False );
381cdf0e10cSrcweir 	if ( pAnch && pAnch->IsInFly() )
382cdf0e10cSrcweir 		return (SdrObject*)pAnch->FindFlyFrm()->GetVirtDrawObj();
383cdf0e10cSrcweir 	return 0;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir /** determine maximal order number for a 'child' object of given 'parent' object
387cdf0e10cSrcweir 
388cdf0e10cSrcweir     OD 2004-08-20 #110810#
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     @author OD
391cdf0e10cSrcweir */
_GetMaxChildOrdNum(const SwFlyFrm & _rParentObj,const SdrObject * _pExclChildObj) const392cdf0e10cSrcweir sal_uInt32 SwDrawView::_GetMaxChildOrdNum( const SwFlyFrm& _rParentObj,
393cdf0e10cSrcweir                                            const SdrObject* _pExclChildObj ) const
394cdf0e10cSrcweir {
395cdf0e10cSrcweir     sal_uInt32 nMaxChildOrdNum = _rParentObj.GetDrawObj()->GetOrdNum();
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     const SdrPage* pDrawPage = _rParentObj.GetDrawObj()->GetPage();
398cdf0e10cSrcweir     ASSERT( pDrawPage,
399cdf0e10cSrcweir             "<SwDrawView::_GetMaxChildOrdNum(..) - missing drawing page at parent object - crash!" );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     sal_uInt32 nObjCount = pDrawPage->GetObjCount();
402cdf0e10cSrcweir     for ( sal_uInt32 i = nObjCount-1; i > _rParentObj.GetDrawObj()->GetOrdNum() ; --i )
403cdf0e10cSrcweir     {
404cdf0e10cSrcweir         const SdrObject* pObj = pDrawPage->GetObj( i );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir         // Don't consider 'child' object <_pExclChildObj>
407cdf0e10cSrcweir         if ( pObj == _pExclChildObj )
408cdf0e10cSrcweir         {
409cdf0e10cSrcweir             continue;
410cdf0e10cSrcweir         }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir         if ( pObj->GetOrdNum() > nMaxChildOrdNum &&
413cdf0e10cSrcweir              _rParentObj.IsAnLower( lcl_FindAnchor( pObj, sal_True ) ) )
414cdf0e10cSrcweir         {
415cdf0e10cSrcweir             nMaxChildOrdNum = pObj->GetOrdNum();
416cdf0e10cSrcweir             break;
417cdf0e10cSrcweir         }
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir     return nMaxChildOrdNum;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir /** method to move 'repeated' objects of the given moved object to the
424cdf0e10cSrcweir     according level
425cdf0e10cSrcweir 
426cdf0e10cSrcweir     OD 2004-08-23 #110810#
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     @author OD
429cdf0e10cSrcweir */
_MoveRepeatedObjs(const SwAnchoredObject & _rMovedAnchoredObj,const std::vector<SdrObject * > & _rMovedChildObjs) const430cdf0e10cSrcweir void SwDrawView::_MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj,
431cdf0e10cSrcweir                                     const std::vector<SdrObject*>& _rMovedChildObjs ) const
432cdf0e10cSrcweir {
433cdf0e10cSrcweir     // determine 'repeated' objects of already moved object <_rMovedAnchoredObj>
434cdf0e10cSrcweir     std::list<SwAnchoredObject*> aAnchoredObjs;
435cdf0e10cSrcweir     {
436cdf0e10cSrcweir         const SwContact* pContact = ::GetUserCall( _rMovedAnchoredObj.GetDrawObj() );
437cdf0e10cSrcweir         ASSERT( pContact,
438cdf0e10cSrcweir                 "SwDrawView::_MoveRepeatedObjs(..) - missing contact object -> crash." );
439cdf0e10cSrcweir         pContact->GetAnchoredObjs( aAnchoredObjs );
440cdf0e10cSrcweir     }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir     // check, if 'repeated' objects exists.
443cdf0e10cSrcweir     if ( aAnchoredObjs.size() > 1 )
444cdf0e10cSrcweir     {
445cdf0e10cSrcweir         SdrPage* pDrawPage = GetModel()->GetPage( 0 );
446cdf0e10cSrcweir 
447cdf0e10cSrcweir         // move 'repeated' ones to the same order number as the already moved one.
448cdf0e10cSrcweir         sal_uInt32 nNewPos = _rMovedAnchoredObj.GetDrawObj()->GetOrdNum();
449cdf0e10cSrcweir         while ( !aAnchoredObjs.empty() )
450cdf0e10cSrcweir         {
451cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
452cdf0e10cSrcweir             if ( pAnchoredObj != &_rMovedAnchoredObj )
453cdf0e10cSrcweir             {
454cdf0e10cSrcweir                 pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
455cdf0e10cSrcweir                                             nNewPos );
456cdf0e10cSrcweir                 pDrawPage->RecalcObjOrdNums();
457cdf0e10cSrcweir                 // adjustments for accessibility API
458cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
459cdf0e10cSrcweir                 {
460cdf0e10cSrcweir                     const SwFlyFrm *pTmpFlyFrm = static_cast<SwFlyFrm*>(pAnchoredObj);
461cdf0e10cSrcweir                     rImp.DisposeAccessibleFrm( pTmpFlyFrm );
462cdf0e10cSrcweir                     rImp.AddAccessibleFrm( pTmpFlyFrm );
463cdf0e10cSrcweir                 }
464cdf0e10cSrcweir                 else
465cdf0e10cSrcweir                 {
466cdf0e10cSrcweir                     rImp.DisposeAccessibleObj( pAnchoredObj->GetDrawObj() );
467cdf0e10cSrcweir                     rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
468cdf0e10cSrcweir                 }
469cdf0e10cSrcweir             }
470cdf0e10cSrcweir             aAnchoredObjs.pop_back();
471cdf0e10cSrcweir         }
472cdf0e10cSrcweir 
473cdf0e10cSrcweir         // move 'repeated' ones of 'child' objects
474cdf0e10cSrcweir         for ( std::vector<SdrObject*>::const_iterator aObjIter = _rMovedChildObjs.begin();
475cdf0e10cSrcweir               aObjIter != _rMovedChildObjs.end(); ++aObjIter )
476cdf0e10cSrcweir         {
477cdf0e10cSrcweir             SdrObject* pChildObj = (*aObjIter);
478cdf0e10cSrcweir             {
479cdf0e10cSrcweir                 const SwContact* pContact = ::GetUserCall( pChildObj );
480cdf0e10cSrcweir                 ASSERT( pContact,
481cdf0e10cSrcweir                         "SwDrawView::_MoveRepeatedObjs(..) - missing contact object -> crash." );
482cdf0e10cSrcweir                 pContact->GetAnchoredObjs( aAnchoredObjs );
483cdf0e10cSrcweir             }
484cdf0e10cSrcweir             // move 'repeated' ones to the same order number as the already moved one.
485cdf0e10cSrcweir             const sal_uInt32 nTmpNewPos = pChildObj->GetOrdNum();
486cdf0e10cSrcweir             while ( !aAnchoredObjs.empty() )
487cdf0e10cSrcweir             {
488cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
489cdf0e10cSrcweir                 if ( pAnchoredObj->GetDrawObj() != pChildObj )
490cdf0e10cSrcweir                 {
491cdf0e10cSrcweir                     pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
492cdf0e10cSrcweir                                                 nTmpNewPos );
493cdf0e10cSrcweir                     pDrawPage->RecalcObjOrdNums();
494cdf0e10cSrcweir                     // adjustments for accessibility API
495cdf0e10cSrcweir                     if ( pAnchoredObj->ISA(SwFlyFrm) )
496cdf0e10cSrcweir                     {
497cdf0e10cSrcweir                         const SwFlyFrm *pTmpFlyFrm = static_cast<SwFlyFrm*>(pAnchoredObj);
498cdf0e10cSrcweir                         rImp.DisposeAccessibleFrm( pTmpFlyFrm );
499cdf0e10cSrcweir                         rImp.AddAccessibleFrm( pTmpFlyFrm );
500cdf0e10cSrcweir                     }
501cdf0e10cSrcweir                     else
502cdf0e10cSrcweir                     {
503cdf0e10cSrcweir                         rImp.DisposeAccessibleObj( pAnchoredObj->GetDrawObj() );
504cdf0e10cSrcweir                         rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
505cdf0e10cSrcweir                     }
506cdf0e10cSrcweir                 }
507cdf0e10cSrcweir                 aAnchoredObjs.pop_back();
508cdf0e10cSrcweir             }
509cdf0e10cSrcweir         }
510cdf0e10cSrcweir     }
511cdf0e10cSrcweir }
512cdf0e10cSrcweir 
513cdf0e10cSrcweir // --> OD 2004-08-20 #110810# - adjustment and re-factoring of method
ObjOrderChanged(SdrObject * pObj,sal_uLong nOldPos,sal_uLong nNewPos)514cdf0e10cSrcweir void SwDrawView::ObjOrderChanged( SdrObject* pObj, sal_uLong nOldPos,
515cdf0e10cSrcweir 										  sal_uLong nNewPos )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir     // --> OD 2004-08-17 #110810# - nothing to do for group members
518cdf0e10cSrcweir     if ( pObj->GetUpGroup() )
519cdf0e10cSrcweir     {
520cdf0e10cSrcweir         return;
521cdf0e10cSrcweir     }
522cdf0e10cSrcweir     // <--
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     // determine drawing page and assure that the order numbers are correct.
525cdf0e10cSrcweir     SdrPage* pDrawPage = GetModel()->GetPage( 0 );
526cdf0e10cSrcweir     if ( pDrawPage->IsObjOrdNumsDirty() )
527cdf0e10cSrcweir         pDrawPage->RecalcObjOrdNums();
528cdf0e10cSrcweir     const sal_uInt32 nObjCount = pDrawPage->GetObjCount();
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     SwAnchoredObject* pMovedAnchoredObj =
531cdf0e10cSrcweir                                 ::GetUserCall( pObj )->GetAnchoredObj( pObj );
532cdf0e10cSrcweir     const SwFlyFrm* pParentAnchoredObj =
533cdf0e10cSrcweir                                 pMovedAnchoredObj->GetAnchorFrm()->FindFlyFrm();
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     const bool bMovedForward = nOldPos < nNewPos;
536cdf0e10cSrcweir 
537cdf0e10cSrcweir     // assure for a 'child' object, that it doesn't exceed the limits of its 'parent'
538cdf0e10cSrcweir     if ( pParentAnchoredObj )
539cdf0e10cSrcweir     {
540cdf0e10cSrcweir         if ( bMovedForward )
541cdf0e10cSrcweir         {
542cdf0e10cSrcweir             sal_uInt32 nMaxChildOrdNumWithoutMoved =
543cdf0e10cSrcweir                     _GetMaxChildOrdNum( *pParentAnchoredObj, pMovedAnchoredObj->GetDrawObj() );
544cdf0e10cSrcweir             if ( nNewPos > nMaxChildOrdNumWithoutMoved+1 )
545cdf0e10cSrcweir             {
546cdf0e10cSrcweir                 // set position to the top of the 'child' object group
547cdf0e10cSrcweir                 pDrawPage->SetObjectOrdNum( nNewPos, nMaxChildOrdNumWithoutMoved+1 );
548cdf0e10cSrcweir                 nNewPos = nMaxChildOrdNumWithoutMoved+1;
549cdf0e10cSrcweir             }
550cdf0e10cSrcweir         }
551cdf0e10cSrcweir         else
552cdf0e10cSrcweir         {
553cdf0e10cSrcweir             const sal_uInt32 nParentOrdNum = pParentAnchoredObj->GetDrawObj()->GetOrdNum();
554cdf0e10cSrcweir             if ( nNewPos < nParentOrdNum )
555cdf0e10cSrcweir             {
556cdf0e10cSrcweir                 // set position to the bottom of the 'child' object group
557cdf0e10cSrcweir                 pDrawPage->SetObjectOrdNum( nNewPos, nParentOrdNum );
558cdf0e10cSrcweir                 nNewPos = nParentOrdNum;
559cdf0e10cSrcweir             }
560cdf0e10cSrcweir         }
561cdf0e10cSrcweir         if ( pDrawPage->IsObjOrdNumsDirty() )
562cdf0e10cSrcweir             pDrawPage->RecalcObjOrdNums();
563cdf0e10cSrcweir     }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     // Assure, that object isn't positioned between 'repeated' ones
566cdf0e10cSrcweir     if ( ( bMovedForward && nNewPos < nObjCount - 1 ) ||
567cdf0e10cSrcweir          ( !bMovedForward && nNewPos > 0 ) )
568cdf0e10cSrcweir     {
569cdf0e10cSrcweir         const SdrObject* pTmpObj =
570cdf0e10cSrcweir                 pDrawPage->GetObj( bMovedForward ? nNewPos - 1 : nNewPos + 1 );
571cdf0e10cSrcweir         if ( pTmpObj )
572cdf0e10cSrcweir         {
573cdf0e10cSrcweir             sal_uInt32 nTmpNewPos( nNewPos );
574cdf0e10cSrcweir             if ( bMovedForward )
575cdf0e10cSrcweir             {
576cdf0e10cSrcweir                 // move before the top 'repeated' object
577cdf0e10cSrcweir                 const sal_uInt32 nTmpMaxOrdNum =
578cdf0e10cSrcweir                                     ::GetUserCall( pTmpObj )->GetMaxOrdNum();
579cdf0e10cSrcweir                 if ( nTmpMaxOrdNum > nNewPos )
580cdf0e10cSrcweir                     nTmpNewPos = nTmpMaxOrdNum;
581cdf0e10cSrcweir             }
582cdf0e10cSrcweir             else
583cdf0e10cSrcweir             {
584cdf0e10cSrcweir                 // move behind the bottom 'repeated' object
585cdf0e10cSrcweir                 const sal_uInt32 nTmpMinOrdNum =
586cdf0e10cSrcweir                                     ::GetUserCall( pTmpObj )->GetMinOrdNum();
587cdf0e10cSrcweir                 if ( nTmpMinOrdNum < nNewPos )
588cdf0e10cSrcweir                     nTmpNewPos = nTmpMinOrdNum;
589cdf0e10cSrcweir             }
590cdf0e10cSrcweir             if ( nTmpNewPos != nNewPos )
591cdf0e10cSrcweir             {
592cdf0e10cSrcweir                 pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
593cdf0e10cSrcweir                 nNewPos = nTmpNewPos;
594cdf0e10cSrcweir                 pDrawPage->RecalcObjOrdNums();
595cdf0e10cSrcweir             }
596cdf0e10cSrcweir         }
597cdf0e10cSrcweir     }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     // On move forward, assure that object is moved before its own childs.
600cdf0e10cSrcweir     // Only Writer fly frames can have childs.
601cdf0e10cSrcweir     if ( pMovedAnchoredObj->ISA(SwFlyFrm) &&
602cdf0e10cSrcweir          bMovedForward && nNewPos < nObjCount - 1 )
603cdf0e10cSrcweir     {
604cdf0e10cSrcweir         sal_uInt32 nMaxChildOrdNum =
605cdf0e10cSrcweir                     _GetMaxChildOrdNum( *(static_cast<const SwFlyFrm*>(pMovedAnchoredObj)) );
606cdf0e10cSrcweir         if ( nNewPos < nMaxChildOrdNum )
607cdf0e10cSrcweir         {
608cdf0e10cSrcweir             // determine position before the object before its top 'child' object
609cdf0e10cSrcweir             const SdrObject* pTmpObj = pDrawPage->GetObj( nMaxChildOrdNum );
610cdf0e10cSrcweir             sal_uInt32 nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum() + 1;
611cdf0e10cSrcweir             if ( nTmpNewPos >= nObjCount )
612cdf0e10cSrcweir             {
613cdf0e10cSrcweir                 --nTmpNewPos;
614cdf0e10cSrcweir             }
615cdf0e10cSrcweir             // assure, that determined position isn't between 'repeated' objects
616cdf0e10cSrcweir             pTmpObj = pDrawPage->GetObj( nTmpNewPos );
617cdf0e10cSrcweir             nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum();
618cdf0e10cSrcweir             // apply new position
619cdf0e10cSrcweir             pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
620cdf0e10cSrcweir             nNewPos = nTmpNewPos;
621cdf0e10cSrcweir             pDrawPage->RecalcObjOrdNums();
622cdf0e10cSrcweir         }
623cdf0e10cSrcweir     }
624cdf0e10cSrcweir 
625cdf0e10cSrcweir     // Assure, that object isn't positioned between nested objects
626cdf0e10cSrcweir     if ( ( bMovedForward && nNewPos < nObjCount - 1 ) ||
627cdf0e10cSrcweir          ( !bMovedForward && nNewPos > 0 ) )
628cdf0e10cSrcweir     {
629cdf0e10cSrcweir         sal_uInt32 nTmpNewPos( nNewPos );
630cdf0e10cSrcweir         const SwFrmFmt* pParentFrmFmt =
631cdf0e10cSrcweir                 pParentAnchoredObj ? &(pParentAnchoredObj->GetFrmFmt()) : 0L;
632cdf0e10cSrcweir         const SdrObject* pTmpObj = pDrawPage->GetObj( nNewPos + 1 );
633cdf0e10cSrcweir         while ( pTmpObj )
634cdf0e10cSrcweir         {
635cdf0e10cSrcweir             // --> OD 2004-12-07 #i38563# - assure, that anchor frame exists.
636cdf0e10cSrcweir             // If object is anchored inside a invisible part of the document
637cdf0e10cSrcweir             // (e.g. page header, whose page style isn't applied, or hidden
638cdf0e10cSrcweir             // section), no anchor frame exists.
639cdf0e10cSrcweir             const SwFrm* pTmpAnchorFrm = lcl_FindAnchor( pTmpObj, sal_True );
640cdf0e10cSrcweir             const SwFlyFrm* pTmpParentObj = pTmpAnchorFrm
641cdf0e10cSrcweir                                             ? pTmpAnchorFrm->FindFlyFrm() : 0L;
642cdf0e10cSrcweir             // <--
643cdf0e10cSrcweir             if ( pTmpParentObj &&
644cdf0e10cSrcweir                  &(pTmpParentObj->GetFrmFmt()) != pParentFrmFmt )
645cdf0e10cSrcweir             {
646cdf0e10cSrcweir                 if ( bMovedForward )
647cdf0e10cSrcweir                 {
648cdf0e10cSrcweir                     nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum();
649cdf0e10cSrcweir                     pTmpObj = pDrawPage->GetObj( nTmpNewPos + 1 );
650cdf0e10cSrcweir                 }
651cdf0e10cSrcweir                 else
652cdf0e10cSrcweir                 {
653cdf0e10cSrcweir                     nTmpNewPos = ::GetUserCall( pTmpParentObj->GetDrawObj() )
654cdf0e10cSrcweir                                                             ->GetMinOrdNum();
655cdf0e10cSrcweir                     pTmpObj = pTmpParentObj->GetDrawObj();
656cdf0e10cSrcweir                 }
657cdf0e10cSrcweir             }
658cdf0e10cSrcweir             else
659cdf0e10cSrcweir                 break;
660cdf0e10cSrcweir         }
661cdf0e10cSrcweir         if ( nTmpNewPos != nNewPos )
662cdf0e10cSrcweir         {
663cdf0e10cSrcweir             pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
664cdf0e10cSrcweir             nNewPos = nTmpNewPos;
665cdf0e10cSrcweir             pDrawPage->RecalcObjOrdNums();
666cdf0e10cSrcweir         }
667cdf0e10cSrcweir     }
668cdf0e10cSrcweir 
669cdf0e10cSrcweir     // setup collection of moved 'child' objects to move its 'repeated' objects.
670cdf0e10cSrcweir     std::vector< SdrObject* > aMovedChildObjs;
671cdf0e10cSrcweir 
672cdf0e10cSrcweir     // move 'childs' accordingly
673cdf0e10cSrcweir     if ( pMovedAnchoredObj->ISA(SwFlyFrm) )
674cdf0e10cSrcweir     {
675cdf0e10cSrcweir         const SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pMovedAnchoredObj);
676cdf0e10cSrcweir 
677cdf0e10cSrcweir         // adjustments for accessibility API
678cdf0e10cSrcweir         rImp.DisposeAccessibleFrm( pFlyFrm );
679cdf0e10cSrcweir         rImp.AddAccessibleFrm( pFlyFrm );
680cdf0e10cSrcweir 
681cdf0e10cSrcweir         const sal_uInt32 nChildNewPos = bMovedForward ? nNewPos : nNewPos+1;
682cdf0e10cSrcweir         sal_uInt32 i = bMovedForward ? nOldPos : nObjCount-1;
683cdf0e10cSrcweir         do
684cdf0e10cSrcweir         {
685cdf0e10cSrcweir             SdrObject* pTmpObj = pDrawPage->GetObj( i );
686cdf0e10cSrcweir             if ( pTmpObj == pObj )
687cdf0e10cSrcweir                 break;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir             // --> OD 2004-12-07 #i38563# - assure, that anchor frame exists.
690cdf0e10cSrcweir             // If object is anchored inside a invisible part of the document
691cdf0e10cSrcweir             // (e.g. page header, whose page style isn't applied, or hidden
692cdf0e10cSrcweir             // section), no anchor frame exists.
693cdf0e10cSrcweir             const SwFrm* pTmpAnchorFrm = lcl_FindAnchor( pTmpObj, sal_True );
694cdf0e10cSrcweir             const SwFlyFrm* pTmpParentObj = pTmpAnchorFrm
695cdf0e10cSrcweir                                             ? pTmpAnchorFrm->FindFlyFrm() : 0L;
696cdf0e10cSrcweir             // <--
697cdf0e10cSrcweir             if ( pTmpParentObj &&
698cdf0e10cSrcweir                  ( ( pTmpParentObj == pFlyFrm ) ||
699cdf0e10cSrcweir                    ( pFlyFrm->IsUpperOf( *pTmpParentObj ) ) ) )
700cdf0e10cSrcweir             {
701cdf0e10cSrcweir                 // move child object.,
702cdf0e10cSrcweir                 pDrawPage->SetObjectOrdNum( i, nChildNewPos );
703cdf0e10cSrcweir                 pDrawPage->RecalcObjOrdNums();
704cdf0e10cSrcweir                 // collect 'child' object
705cdf0e10cSrcweir                 aMovedChildObjs.push_back( pTmpObj );
706cdf0e10cSrcweir                 // adjustments for accessibility API
707cdf0e10cSrcweir                 if ( pTmpObj->ISA(SwVirtFlyDrawObj) )
708cdf0e10cSrcweir                 {
709cdf0e10cSrcweir                     const SwFlyFrm *pTmpFlyFrm =
710cdf0e10cSrcweir                         static_cast<SwVirtFlyDrawObj*>(pTmpObj)->GetFlyFrm();
711cdf0e10cSrcweir                     rImp.DisposeAccessibleFrm( pTmpFlyFrm );
712cdf0e10cSrcweir                     rImp.AddAccessibleFrm( pTmpFlyFrm );
713cdf0e10cSrcweir                 }
714cdf0e10cSrcweir                 else
715cdf0e10cSrcweir                 {
716cdf0e10cSrcweir                     rImp.DisposeAccessibleObj( pTmpObj );
717cdf0e10cSrcweir                     rImp.AddAccessibleObj( pTmpObj );
718cdf0e10cSrcweir                 }
719cdf0e10cSrcweir             }
720cdf0e10cSrcweir             else
721cdf0e10cSrcweir             {
722cdf0e10cSrcweir                 // adjust loop counter
723cdf0e10cSrcweir                 if ( bMovedForward )
724cdf0e10cSrcweir                     ++i;
725cdf0e10cSrcweir                 else if ( !bMovedForward && i > 0 )
726cdf0e10cSrcweir                     --i;
727cdf0e10cSrcweir             }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir         } while ( ( bMovedForward && i < ( nObjCount - aMovedChildObjs.size() ) ) ||
730cdf0e10cSrcweir                   ( !bMovedForward && i > ( nNewPos + aMovedChildObjs.size() ) ) );
731cdf0e10cSrcweir     }
732cdf0e10cSrcweir 	else
733cdf0e10cSrcweir 	{
734cdf0e10cSrcweir         // adjustments for accessibility API
735cdf0e10cSrcweir 		rImp.DisposeAccessibleObj( pObj );
736cdf0e10cSrcweir 		rImp.AddAccessibleObj( pObj );
737cdf0e10cSrcweir 	}
738cdf0e10cSrcweir 
739cdf0e10cSrcweir     _MoveRepeatedObjs( *pMovedAnchoredObj, aMovedChildObjs );
740cdf0e10cSrcweir }
741cdf0e10cSrcweir // <--
742cdf0e10cSrcweir 
743cdf0e10cSrcweir /*************************************************************************
744cdf0e10cSrcweir |*
745cdf0e10cSrcweir |*	SwDrawView::TakeDragLimit()
746cdf0e10cSrcweir |*
747cdf0e10cSrcweir |*	Ersterstellung		AMA 26. Apr. 96
748cdf0e10cSrcweir |*	Letzte Aenderung	MA 03. May. 96
749cdf0e10cSrcweir |*
750cdf0e10cSrcweir *************************************************************************/
751cdf0e10cSrcweir 
752cdf0e10cSrcweir 
TakeDragLimit(SdrDragMode eMode,Rectangle & rRect) const753cdf0e10cSrcweir sal_Bool SwDrawView::TakeDragLimit( SdrDragMode eMode,
754cdf0e10cSrcweir 											Rectangle& rRect ) const
755cdf0e10cSrcweir {
756cdf0e10cSrcweir 	const SdrMarkList &rMrkList = GetMarkedObjectList();
757cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
758cdf0e10cSrcweir 	if( 1 == rMrkList.GetMarkCount() )
759cdf0e10cSrcweir 	{
760cdf0e10cSrcweir 		const SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
761cdf0e10cSrcweir 		SwRect aRect;
762cdf0e10cSrcweir 		if( ::CalcClipRect( pObj, aRect, eMode == SDRDRAG_MOVE ) )
763cdf0e10cSrcweir 		{
764cdf0e10cSrcweir 			rRect = aRect.SVRect();
765cdf0e10cSrcweir 		 	bRet = sal_True;
766cdf0e10cSrcweir 		}
767cdf0e10cSrcweir 	}
768cdf0e10cSrcweir 	return bRet;
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir /*************************************************************************
772cdf0e10cSrcweir |*
773cdf0e10cSrcweir |*	SwDrawView::CalcAnchor()
774cdf0e10cSrcweir |*
775cdf0e10cSrcweir |*	Ersterstellung		MA 13. Jan. 95
776cdf0e10cSrcweir |*	Letzte Aenderung	MA 08. Nov. 96
777cdf0e10cSrcweir |*
778cdf0e10cSrcweir *************************************************************************/
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 
CalcAnchor()781cdf0e10cSrcweir const SwFrm* SwDrawView::CalcAnchor()
782cdf0e10cSrcweir {
783cdf0e10cSrcweir 	const SdrMarkList &rMrkList = GetMarkedObjectList();
784cdf0e10cSrcweir 	if ( rMrkList.GetMarkCount() != 1 )
785cdf0e10cSrcweir 		return NULL;
786cdf0e10cSrcweir 
787cdf0e10cSrcweir     SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 	//Fuer Absatzgebundene Objekte suchen, andernfalls einfach nur
790cdf0e10cSrcweir 	//der aktuelle Anker. Nur suchen wenn wir gerade draggen.
791cdf0e10cSrcweir     const SwFrm* pAnch;
792cdf0e10cSrcweir     Rectangle aMyRect;
793cdf0e10cSrcweir 	const sal_Bool bFly = pObj->ISA(SwVirtFlyDrawObj);
794cdf0e10cSrcweir 	if ( bFly )
795cdf0e10cSrcweir 	{
796cdf0e10cSrcweir         pAnch = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetAnchorFrm();
797cdf0e10cSrcweir         aMyRect = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->Frm().SVRect();
798cdf0e10cSrcweir 	}
799cdf0e10cSrcweir 	else
800cdf0e10cSrcweir 	{
801cdf0e10cSrcweir         SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
802cdf0e10cSrcweir         // OD 17.06.2003 #108784# - determine correct anchor position for
803cdf0e10cSrcweir         // 'virtual' drawing objects.
804cdf0e10cSrcweir         // OD 2004-03-25 #i26791#
805cdf0e10cSrcweir         pAnch = pC->GetAnchorFrm( pObj );
806cdf0e10cSrcweir 		if( !pAnch )
807cdf0e10cSrcweir 		{
808cdf0e10cSrcweir 			pC->ConnectToLayout();
809cdf0e10cSrcweir             // OD 17.06.2003 #108784# - determine correct anchor position for
810cdf0e10cSrcweir             // 'virtual' drawing objects.
811cdf0e10cSrcweir             // OD 2004-03-25 #i26791#
812cdf0e10cSrcweir             pAnch = pC->GetAnchorFrm( pObj );
813cdf0e10cSrcweir 		}
814cdf0e10cSrcweir         aMyRect = pObj->GetSnapRect();
815cdf0e10cSrcweir 	}
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 	//Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
818cdf0e10cSrcweir     const sal_Bool bTopRight = pAnch && ( ( pAnch->IsVertical() &&
819cdf0e10cSrcweir     										!pAnch->IsVertLR() ) ||
820cdf0e10cSrcweir                                          	pAnch->IsRightToLeft() );
821cdf0e10cSrcweir     const Point aMyPt = bTopRight ? aMyRect.TopRight() : aMyRect.TopLeft();
822cdf0e10cSrcweir 
823cdf0e10cSrcweir     Point aPt;
824cdf0e10cSrcweir     if ( IsAction() )
825cdf0e10cSrcweir     {
826cdf0e10cSrcweir         if ( !TakeDragObjAnchorPos( aPt, bTopRight ) )
827cdf0e10cSrcweir             return NULL;
828cdf0e10cSrcweir     }
829cdf0e10cSrcweir     else
830cdf0e10cSrcweir     {
831cdf0e10cSrcweir         Rectangle aRect = pObj->GetSnapRect();
832cdf0e10cSrcweir         aPt = bTopRight ? aRect.TopRight() : aRect.TopLeft();
833cdf0e10cSrcweir     }
834cdf0e10cSrcweir 
835cdf0e10cSrcweir     if ( aPt != aMyPt )
836cdf0e10cSrcweir 	{
837cdf0e10cSrcweir 		if ( pAnch->IsCntntFrm() )
838cdf0e10cSrcweir         {
839cdf0e10cSrcweir             // OD 26.06.2003 #108784# - allow drawing objects in header/footer,
840cdf0e10cSrcweir             // but exclude control objects.
841cdf0e10cSrcweir             bool bBodyOnly = CheckControlLayer( pObj );
842cdf0e10cSrcweir             pAnch = ::FindAnchor( (SwCntntFrm*)pAnch, aPt, bBodyOnly );
843cdf0e10cSrcweir         }
844cdf0e10cSrcweir 		else if ( !bFly )
845cdf0e10cSrcweir         {
846cdf0e10cSrcweir             const SwRect aRect( aPt.X(), aPt.Y(), 1, 1 );
847cdf0e10cSrcweir 
848cdf0e10cSrcweir             SwDrawContact* pContact = (SwDrawContact*)GetUserCall(pObj);
849cdf0e10cSrcweir             if ( pContact->GetAnchorFrm( pObj ) &&
850cdf0e10cSrcweir                  pContact->GetAnchorFrm( pObj )->IsPageFrm() )
851cdf0e10cSrcweir                 pAnch = pContact->GetPageFrm();
852cdf0e10cSrcweir 			else
853cdf0e10cSrcweir 				pAnch = pContact->FindPage( aRect );
854cdf0e10cSrcweir 		}
855cdf0e10cSrcweir 	}
856cdf0e10cSrcweir 	if( pAnch && !pAnch->IsProtected() )
857cdf0e10cSrcweir         aAnchorPoint = pAnch->GetFrmAnchorPos( ::HasWrap( pObj ) );
858cdf0e10cSrcweir 	else
859cdf0e10cSrcweir 		pAnch = 0;
860cdf0e10cSrcweir 	return pAnch;
861cdf0e10cSrcweir }
862cdf0e10cSrcweir 
863cdf0e10cSrcweir /*************************************************************************
864cdf0e10cSrcweir |*
865cdf0e10cSrcweir |*	SwDrawView::ShowDragXor(), HideDragXor()
866cdf0e10cSrcweir |*
867cdf0e10cSrcweir |*	Ersterstellung		MA 17. Jan. 95
868cdf0e10cSrcweir |*	Letzte Aenderung	MA 27. Jan. 95
869cdf0e10cSrcweir |*
870cdf0e10cSrcweir *************************************************************************/
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 
ShowDragAnchor()873cdf0e10cSrcweir void SwDrawView::ShowDragAnchor()
874cdf0e10cSrcweir {
875cdf0e10cSrcweir 	SdrHdl* pHdl = aHdl.GetHdl(HDL_ANCHOR);
876cdf0e10cSrcweir 	if ( ! pHdl )
877cdf0e10cSrcweir 		pHdl = aHdl.GetHdl(HDL_ANCHOR_TR);
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 	if(pHdl)
880cdf0e10cSrcweir 	{
881cdf0e10cSrcweir 		CalcAnchor();
882cdf0e10cSrcweir 		pHdl->SetPos(aAnchorPoint);
883cdf0e10cSrcweir 		//OLMRefreshAllIAOManagers();
884cdf0e10cSrcweir 	}
885cdf0e10cSrcweir }
886cdf0e10cSrcweir 
887cdf0e10cSrcweir /*************************************************************************
888cdf0e10cSrcweir |*
889cdf0e10cSrcweir |*	SwDrawView::MarkListHasChanged()
890cdf0e10cSrcweir |*
891cdf0e10cSrcweir |*	Ersterstellung		OM 02. Feb. 95
892cdf0e10cSrcweir |*	Letzte Aenderung	OM 07. Jul. 95
893cdf0e10cSrcweir |*
894cdf0e10cSrcweir *************************************************************************/
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 
MarkListHasChanged()897cdf0e10cSrcweir void SwDrawView::MarkListHasChanged()
898cdf0e10cSrcweir {
899cdf0e10cSrcweir     Imp().GetShell()->DrawSelChanged();
900cdf0e10cSrcweir 	FmFormView::MarkListHasChanged();
901cdf0e10cSrcweir }
902cdf0e10cSrcweir 
903cdf0e10cSrcweir // #i7672#
ModelHasChanged()904cdf0e10cSrcweir void SwDrawView::ModelHasChanged()
905cdf0e10cSrcweir {
906cdf0e10cSrcweir 	// The ModelHasChanged() call in DrawingLayer also updates
907cdf0e10cSrcweir 	// a eventually active text edit view (OutlinerView). This also leads
908cdf0e10cSrcweir 	// to newly setting the background color for that edit view. Thus,
909cdf0e10cSrcweir 	// this method rescues the current background color if a OutlinerView
910cdf0e10cSrcweir 	// exists and re-establishes it then. To be more safe, the OutlinerView
911cdf0e10cSrcweir 	// will be fetched again (maybe textedit has ended).
912cdf0e10cSrcweir 	OutlinerView* pView = GetTextEditOutlinerView();
913cdf0e10cSrcweir 	Color aBackColor;
914cdf0e10cSrcweir 	sal_Bool bColorWasSaved(sal_False);
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 	if(pView)
917cdf0e10cSrcweir 	{
918cdf0e10cSrcweir 		aBackColor = pView->GetBackgroundColor();
919cdf0e10cSrcweir 		bColorWasSaved = sal_True;
920cdf0e10cSrcweir 	}
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 	// call parent
923cdf0e10cSrcweir 	FmFormView::ModelHasChanged();
924cdf0e10cSrcweir 
925cdf0e10cSrcweir 	if(bColorWasSaved)
926cdf0e10cSrcweir 	{
927cdf0e10cSrcweir 		pView = GetTextEditOutlinerView();
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 		if(pView)
930cdf0e10cSrcweir 		{
931cdf0e10cSrcweir 			pView->SetBackgroundColor(aBackColor);
932cdf0e10cSrcweir 		}
933cdf0e10cSrcweir 	}
934cdf0e10cSrcweir }
935cdf0e10cSrcweir 
MakeVisible(const Rectangle & rRect,Window &)936cdf0e10cSrcweir void SwDrawView::MakeVisible( const Rectangle &rRect, Window & )
937cdf0e10cSrcweir {
938cdf0e10cSrcweir     ASSERT( rImp.GetShell()->GetWin(), "MakeVisible, unknown Window");
939cdf0e10cSrcweir 	rImp.GetShell()->MakeVisible( SwRect( rRect ) );
940cdf0e10cSrcweir }
941cdf0e10cSrcweir 
CheckPossibilities()942cdf0e10cSrcweir void SwDrawView::CheckPossibilities()
943cdf0e10cSrcweir {
944cdf0e10cSrcweir 	FmFormView::CheckPossibilities();
945cdf0e10cSrcweir 
946cdf0e10cSrcweir 	//Zusaetzlich zu den bestehenden Flags der Objekte selbst, die von der
947cdf0e10cSrcweir 	//DrawingEngine ausgewertet werden, koennen weitere Umstaende zu einem
948cdf0e10cSrcweir 	//Schutz fuehren.
949cdf0e10cSrcweir 	//Objekte, die in Rahmen verankert sind, muessen genau dann geschuetzt
950cdf0e10cSrcweir 	//sein, wenn der Inhalt des Rahmens geschuetzt ist.
951cdf0e10cSrcweir 	//OLE-Objekte konnen selbst einen Resize-Schutz wuenschen (StarMath)
952cdf0e10cSrcweir 
953cdf0e10cSrcweir 	const SdrMarkList &rMrkList = GetMarkedObjectList();
954cdf0e10cSrcweir 	sal_Bool bProtect = sal_False,
955cdf0e10cSrcweir 			 bSzProtect = sal_False;
956cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; !bProtect && i < rMrkList.GetMarkCount(); ++i )
957cdf0e10cSrcweir 	{
958cdf0e10cSrcweir 		const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
959cdf0e10cSrcweir 		const SwFrm *pFrm = NULL;
960cdf0e10cSrcweir 		if ( pObj->ISA(SwVirtFlyDrawObj) )
961cdf0e10cSrcweir 		{
962cdf0e10cSrcweir 			const SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
963cdf0e10cSrcweir 			if ( pFly  )
964cdf0e10cSrcweir 			{
965cdf0e10cSrcweir                 pFrm = pFly->GetAnchorFrm();
966cdf0e10cSrcweir 				if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
967cdf0e10cSrcweir 				{
968cdf0e10cSrcweir 					SwOLENode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetOLENode();
969cdf0e10cSrcweir 					if ( pNd )
970cdf0e10cSrcweir 					{
971cdf0e10cSrcweir                         uno::Reference < embed::XEmbeddedObject > xObj = pNd->GetOLEObj().GetOleRef();
972cdf0e10cSrcweir                         if ( xObj.is() )
973cdf0e10cSrcweir 						{
974cdf0e10cSrcweir                             // --> OD 2004-08-16 #110810# - improvement for
975cdf0e10cSrcweir                             // the future, when more than one Writer fly frame
976cdf0e10cSrcweir                             // can be selected.
977cdf0e10cSrcweir 
978cdf0e10cSrcweir                             // TODO/LATER: retrieve Aspect - from where?!
979cdf0e10cSrcweir                             bSzProtect |= ( embed::EmbedMisc::EMBED_NEVERRESIZE & xObj->getStatus( embed::Aspects::MSOLE_CONTENT ) ) ? sal_True : sal_False;
980cdf0e10cSrcweir 
981cdf0e10cSrcweir                             // <--
982cdf0e10cSrcweir 
983cdf0e10cSrcweir                             // #i972: protect position if it is a Math object anchored 'as char' and baseline alignment is activated
984cdf0e10cSrcweir                         	SwDoc* pDoc = Imp().GetShell()->GetDoc();
985cdf0e10cSrcweir                             const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
986cdf0e10cSrcweir                                     && FLY_AS_CHAR == pFly->GetFmt()->GetAnchor().GetAnchorId()
987cdf0e10cSrcweir                                     && pDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
988cdf0e10cSrcweir                             if (bProtectMathPos)
989cdf0e10cSrcweir                                 bMoveProtect = true;
990cdf0e10cSrcweir                         }
991cdf0e10cSrcweir 					}
992cdf0e10cSrcweir 				}
993cdf0e10cSrcweir 			}
994cdf0e10cSrcweir 		}
995cdf0e10cSrcweir 		else
996cdf0e10cSrcweir 		{
997cdf0e10cSrcweir 			SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
998cdf0e10cSrcweir             if ( pC )
999cdf0e10cSrcweir                 pFrm = pC->GetAnchorFrm( pObj );
1000cdf0e10cSrcweir 		}
1001cdf0e10cSrcweir 		if ( pFrm )
1002cdf0e10cSrcweir 			bProtect = pFrm->IsProtected(); //Rahmen, Bereiche usw.
1003cdf0e10cSrcweir         {
1004cdf0e10cSrcweir             SwFrmFmt* pFrmFmt( ::FindFrmFmt( const_cast<SdrObject*>(pObj) ) );
1005cdf0e10cSrcweir             if ( !pFrmFmt )
1006cdf0e10cSrcweir             {
1007cdf0e10cSrcweir                 ASSERT( false,
1008cdf0e10cSrcweir                         "<SwDrawView::CheckPossibilities()> - missing frame format" );
1009cdf0e10cSrcweir                 bProtect = sal_True;
1010cdf0e10cSrcweir             }
1011cdf0e10cSrcweir             else if ((FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) &&
1012cdf0e10cSrcweir                       rMrkList.GetMarkCount() > 1 )
1013cdf0e10cSrcweir             {
1014cdf0e10cSrcweir                 bProtect = sal_True;
1015cdf0e10cSrcweir             }
1016cdf0e10cSrcweir         }
1017cdf0e10cSrcweir 	}
1018cdf0e10cSrcweir 	bMoveProtect	|= bProtect;
1019cdf0e10cSrcweir 	bResizeProtect	|= bProtect | bSzProtect;
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir /** replace marked <SwDrawVirtObj>-objects by its reference object for delete
1023cdf0e10cSrcweir     marked objects.
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir     OD 18.06.2003 #108784#
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir     @author OD
1028cdf0e10cSrcweir */
ReplaceMarkedDrawVirtObjs(SdrMarkView & _rMarkView)1029cdf0e10cSrcweir void SwDrawView::ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir     SdrPageView* pDrawPageView = _rMarkView.GetSdrPageView();
1032cdf0e10cSrcweir     const SdrMarkList& rMarkList = _rMarkView.GetMarkedObjectList();
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir     if( rMarkList.GetMarkCount() )
1035cdf0e10cSrcweir     {
1036cdf0e10cSrcweir         // collect marked objects in a local data structure
1037cdf0e10cSrcweir         std::vector<SdrObject*> aMarkedObjs;
1038cdf0e10cSrcweir         for( sal_uInt32 i = 0; i < rMarkList.GetMarkCount(); ++i )
1039cdf0e10cSrcweir         {
1040cdf0e10cSrcweir             SdrObject* pMarkedObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
1041cdf0e10cSrcweir             aMarkedObjs.push_back( pMarkedObj );
1042cdf0e10cSrcweir         }
1043cdf0e10cSrcweir         // unmark all objects
1044cdf0e10cSrcweir         _rMarkView.UnmarkAllObj();
1045cdf0e10cSrcweir         // re-mark objects, but for marked <SwDrawVirtObj>-objects marked its
1046cdf0e10cSrcweir         // reference object.
1047cdf0e10cSrcweir         while ( !aMarkedObjs.empty() )
1048cdf0e10cSrcweir         {
1049cdf0e10cSrcweir             SdrObject* pMarkObj = aMarkedObjs.back();
1050cdf0e10cSrcweir             if ( pMarkObj->ISA(SwDrawVirtObj) )
1051cdf0e10cSrcweir             {
1052cdf0e10cSrcweir                 SdrObject* pRefObj = &(static_cast<SwDrawVirtObj*>(pMarkObj)->ReferencedObj());
1053cdf0e10cSrcweir                 if ( !_rMarkView.IsObjMarked( pRefObj )  )
1054cdf0e10cSrcweir                 {
1055cdf0e10cSrcweir                     _rMarkView.MarkObj( pRefObj, pDrawPageView );
1056cdf0e10cSrcweir                 }
1057cdf0e10cSrcweir             }
1058cdf0e10cSrcweir             else
1059cdf0e10cSrcweir             {
1060cdf0e10cSrcweir                 _rMarkView.MarkObj( pMarkObj, pDrawPageView );
1061cdf0e10cSrcweir             }
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir             aMarkedObjs.pop_back();
1064cdf0e10cSrcweir         }
1065cdf0e10cSrcweir         // sort marked list in order to assure consistent state in drawing layer
1066cdf0e10cSrcweir         _rMarkView.SortMarkedObjects();
1067cdf0e10cSrcweir     }
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir 
DeleteMarked()1070cdf0e10cSrcweir void SwDrawView::DeleteMarked()
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir 	SwDoc* pDoc = Imp().GetShell()->GetDoc();
1073cdf0e10cSrcweir 	SwRootFrm *pTmpRoot = pDoc->GetCurrentLayout();//swmod 080317
1074cdf0e10cSrcweir     if ( pTmpRoot )
1075cdf0e10cSrcweir 		pTmpRoot->StartAllAction();
1076cdf0e10cSrcweir     pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
1077cdf0e10cSrcweir     // OD 18.06.2003 #108784# - replace marked <SwDrawVirtObj>-objects by its
1078cdf0e10cSrcweir     // reference objects.
1079cdf0e10cSrcweir     {
1080cdf0e10cSrcweir         SdrPageView* pDrawPageView = rImp.GetPageView();
1081cdf0e10cSrcweir         if ( pDrawPageView )
1082cdf0e10cSrcweir         {
1083cdf0e10cSrcweir             SdrMarkView* pMarkView = PTR_CAST( SdrMarkView, &(pDrawPageView->GetView()) );
1084cdf0e10cSrcweir             if ( pMarkView )
1085cdf0e10cSrcweir             {
1086cdf0e10cSrcweir                 ReplaceMarkedDrawVirtObjs( *pMarkView );
1087cdf0e10cSrcweir             }
1088cdf0e10cSrcweir         }
1089cdf0e10cSrcweir     }
1090cdf0e10cSrcweir     if ( pDoc->DeleteSelection( *this ) )
1091cdf0e10cSrcweir 	{
1092cdf0e10cSrcweir 		FmFormView::DeleteMarked();
1093cdf0e10cSrcweir 		::FrameNotify( Imp().GetShell(), FLY_DRAG_END );
1094cdf0e10cSrcweir 	}
1095cdf0e10cSrcweir     pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
1096cdf0e10cSrcweir 	if( pTmpRoot )
1097cdf0e10cSrcweir 		pTmpRoot->EndAllAction();	//swmod 080218
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir 
1100*8218eba2SArmin Le Grand // support enhanced text edit for draw objects
getSdrUndoManagerForEnhancedTextEdit() const1101*8218eba2SArmin Le Grand SdrUndoManager* SwDrawView::getSdrUndoManagerForEnhancedTextEdit() const
1102*8218eba2SArmin Le Grand {
1103*8218eba2SArmin Le Grand 	SwDoc* pDoc = Imp().GetShell()->GetDoc();
1104*8218eba2SArmin Le Grand 
1105*8218eba2SArmin Le Grand     return pDoc ? dynamic_cast< SdrUndoManager* >(&(pDoc->GetUndoManager())) : 0;
1106*8218eba2SArmin Le Grand }
1107*8218eba2SArmin Le Grand 
1108*8218eba2SArmin Le Grand // eof
1109