xref: /AOO41X/main/sw/source/core/frmedt/feshview.cxx (revision 2a0ce83467c220e5a9a9ec91c89b222d844b1788)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/embed/EmbedMisc.hpp>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "hintids.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <svx/sdrobjectfilter.hxx>
32cdf0e10cSrcweir #include <svx/svditer.hxx>
33cdf0e10cSrcweir #include <svx/svdobj.hxx>
34cdf0e10cSrcweir #include <svx/svdouno.hxx>
35cdf0e10cSrcweir #include <svx/svdoole2.hxx>
36cdf0e10cSrcweir #include <svx/svdogrp.hxx>
37cdf0e10cSrcweir #include <svx/svdocirc.hxx>
38cdf0e10cSrcweir #include <svx/svdopath.hxx>
39cdf0e10cSrcweir #include <svx/sxciaitm.hxx>
40cdf0e10cSrcweir #include <svx/xfillit.hxx>
41cdf0e10cSrcweir #include <svx/svdocapt.hxx>
42cdf0e10cSrcweir #include <sfx2/app.hxx>
43cdf0e10cSrcweir #include <editeng/boxitem.hxx>
44cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
45cdf0e10cSrcweir #include <editeng/protitem.hxx>
46cdf0e10cSrcweir #include <svx/svdpage.hxx>
47cdf0e10cSrcweir #include <svx/svdpagv.hxx>
48cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
49cdf0e10cSrcweir #include <cmdid.h>
50cdf0e10cSrcweir #include <poolfmt.hrc>      // fuer InitFldTypes
51cdf0e10cSrcweir #include <frmfmt.hxx>
52cdf0e10cSrcweir #include <frmatr.hxx>
53cdf0e10cSrcweir #include <fmtfsize.hxx>
54cdf0e10cSrcweir #include <fmtanchr.hxx>
55cdf0e10cSrcweir #include <fmtornt.hxx>
56cdf0e10cSrcweir #include <fmtsrnd.hxx>
57cdf0e10cSrcweir #include <fmtcntnt.hxx>
58cdf0e10cSrcweir #include <fmtflcnt.hxx>
59cdf0e10cSrcweir #include <fmtcnct.hxx>
60cdf0e10cSrcweir #include <docary.hxx>
61cdf0e10cSrcweir #include <tblsel.hxx>
62cdf0e10cSrcweir #include <swtable.hxx>
63cdf0e10cSrcweir #include <flyfrms.hxx>
64cdf0e10cSrcweir #include "fesh.hxx"
65cdf0e10cSrcweir #include "rootfrm.hxx"
66cdf0e10cSrcweir #include "pagefrm.hxx"
67cdf0e10cSrcweir #include "sectfrm.hxx"
68cdf0e10cSrcweir #include "doc.hxx"
69cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
70cdf0e10cSrcweir #include "dview.hxx"
71cdf0e10cSrcweir #include "dflyobj.hxx"
72cdf0e10cSrcweir #include "dcontact.hxx"
73cdf0e10cSrcweir #include "viewimp.hxx"
74cdf0e10cSrcweir #include "flyfrm.hxx"
75cdf0e10cSrcweir #include "pam.hxx"
76cdf0e10cSrcweir #include "ndole.hxx"
77cdf0e10cSrcweir #include "ndgrf.hxx"
78cdf0e10cSrcweir #include "ndtxt.hxx"
79cdf0e10cSrcweir #include "viewopt.hxx"					// fuer GetHTMLMode
80cdf0e10cSrcweir #include "swundo.hxx"
81cdf0e10cSrcweir #include "notxtfrm.hxx"
82cdf0e10cSrcweir #include "txtfrm.hxx"
83cdf0e10cSrcweir #include "txatbase.hxx"
84cdf0e10cSrcweir #include "mdiexp.hxx"					// fuer Update der Statuszeile bei drag
85cdf0e10cSrcweir #include <sortedobjs.hxx>
86cdf0e10cSrcweir #include <HandleAnchorNodeChg.hxx>
87cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
88cdf0e10cSrcweir #include <switerator.hxx>
89cdf0e10cSrcweir 
90cdf0e10cSrcweir #define SCROLLVAL 75
91cdf0e10cSrcweir 
92cdf0e10cSrcweir using namespace com::sun::star;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //Tattergrenze fuer Drawing-SS
95cdf0e10cSrcweir #define MINMOVE ((sal_uInt16)GetOut()->PixelToLogic(Size(Imp()->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width())
96cdf0e10cSrcweir 
GetFlyFromMarked(const SdrMarkList * pLst,ViewShell * pSh)97cdf0e10cSrcweir SwFlyFrm *GetFlyFromMarked( const SdrMarkList *pLst, ViewShell *pSh )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	if ( !pLst )
100cdf0e10cSrcweir 		pLst = pSh->HasDrawView() ? &pSh->Imp()->GetDrawView()->GetMarkedObjectList():0;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	if ( pLst && pLst->GetMarkCount() == 1 )
103cdf0e10cSrcweir 	{
104cdf0e10cSrcweir 		SdrObject *pO = pLst->GetMark( 0 )->GetMarkedSdrObj();
105cdf0e10cSrcweir 		if ( pO && pO->ISA(SwVirtFlyDrawObj) )
106cdf0e10cSrcweir 			return ((SwVirtFlyDrawObj*)pO)->GetFlyFrm();
107cdf0e10cSrcweir 	}
108cdf0e10cSrcweir 	return 0;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
lcl_GrabCursor(SwFEShell * pSh,SwFlyFrm * pOldSelFly)111cdf0e10cSrcweir void lcl_GrabCursor( SwFEShell* pSh, SwFlyFrm* pOldSelFly)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	const SwFrmFmt *pFlyFmt = pSh->SelFlyGrabCrsr();
114cdf0e10cSrcweir 	if( pFlyFmt && !pSh->ActionPend() &&
115cdf0e10cSrcweir 						(!pOldSelFly || pOldSelFly->GetFmt() != pFlyFmt) )
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		// dann das evt. gesetzte Macro rufen
118cdf0e10cSrcweir 		pSh->GetFlyMacroLnk().Call( (void*)pFlyFmt );
119cdf0e10cSrcweir extern sal_Bool bNoInterrupt;		// in swapp.cxx
120cdf0e10cSrcweir 		// wir in dem Makro ein Dialog gestartet, dann kommt das
121cdf0e10cSrcweir 		// MouseButtonUp zu diesem und nicht zu uns. Dadurch ist
122cdf0e10cSrcweir 		// Flag bei uns immer gesetzt und schaltet nie die auf die
123cdf0e10cSrcweir 		// entsp. Shell um !!!!!!!
124cdf0e10cSrcweir 		bNoInterrupt = sal_False;
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 	else if( !pFlyFmt || RES_DRAWFRMFMT == pFlyFmt->Which() )
127cdf0e10cSrcweir     {
128cdf0e10cSrcweir         // --> OD 2007-07-25 #136039#
129cdf0e10cSrcweir         // assure consistent cursor
130cdf0e10cSrcweir         pSh->KillPams();
131cdf0e10cSrcweir         pSh->ClearMark();
132cdf0e10cSrcweir         // <--
133cdf0e10cSrcweir 		pSh->SetCrsr( pSh->Imp()->GetDrawView()->GetAllMarkedRect().TopLeft(), sal_True);
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /*************************************************************************
138cdf0e10cSrcweir |*
139cdf0e10cSrcweir |*	SwFEShell::SelectObj()
140cdf0e10cSrcweir *************************************************************************/
141cdf0e10cSrcweir 
SelectObj(const Point & rPt,sal_uInt8 nFlag,SdrObject * pObj)142cdf0e10cSrcweir sal_Bool SwFEShell::SelectObj( const Point& rPt, sal_uInt8 nFlag, SdrObject *pObj )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	SwDrawView *pDView = Imp()->GetDrawView();
145cdf0e10cSrcweir     if(!pDView)
146cdf0e10cSrcweir         return sal_False;
147cdf0e10cSrcweir     SET_CURR_SHELL( this );
148cdf0e10cSrcweir 	StartAction();			//Aktion ist Notwendig, damit nicht mehrere
149cdf0e10cSrcweir 							//AttrChgdNotify (etwa durch Unmark->MarkListHasChgd)
150cdf0e10cSrcweir 							//durchkommen
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	const SdrMarkList &rMrkList = pDView->GetMarkedObjectList();
153cdf0e10cSrcweir 	const sal_Bool bHadSelection = rMrkList.GetMarkCount() ? sal_True : sal_False;
154cdf0e10cSrcweir     const sal_Bool bAddSelect = 0 != (SW_ADD_SELECT & nFlag);
155cdf0e10cSrcweir     const sal_Bool bEnterGroup = 0 != (SW_ENTER_GROUP & nFlag);
156cdf0e10cSrcweir 	SwFlyFrm* pOldSelFly = 0;
157cdf0e10cSrcweir 	const Point aOldPos( pDView->GetAllMarkedRect().TopLeft() );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	if( bHadSelection )
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir 		//Unmark rufen wenn !bAddSelect oder wenn ein Fly selektiert ist.
162cdf0e10cSrcweir         sal_Bool bUnmark = !bAddSelect;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 		if ( rMrkList.GetMarkCount() == 1 )
165cdf0e10cSrcweir 		{
166cdf0e10cSrcweir 			//Wenn ein Fly selektiert ist, so muss er erst deselektiert werden.
167cdf0e10cSrcweir 			pOldSelFly = ::GetFlyFromMarked( &rMrkList, this );
168cdf0e10cSrcweir 			if ( pOldSelFly )
169cdf0e10cSrcweir 			{
170cdf0e10cSrcweir 				const sal_uInt16 nType = GetCntType();
171cdf0e10cSrcweir                 if( nType != CNT_TXT || (SW_LEAVE_FRAME & nFlag) ||
172cdf0e10cSrcweir 					( pOldSelFly->GetFmt()->GetProtect().IsCntntProtected()
173cdf0e10cSrcweir 					 && !IsReadOnlyAvailable() ))
174cdf0e10cSrcweir 				{
175cdf0e10cSrcweir 					//Wenn ein Fly deselektiert wird, der Grafik, Ole o.ae.
176cdf0e10cSrcweir 					//enthaelt, so muss der Crsr aus diesem entfernt werden.
177cdf0e10cSrcweir 					//Desgleichen wenn ein Fly mit geschuetztem Inhalt deselektiert
178cdf0e10cSrcweir 					//wird. Der Einfachheit halber wire der Crsr 'grad so neben die
179cdf0e10cSrcweir 					//linke obere Ecke gesetzt.
180cdf0e10cSrcweir 					Point aPt( pOldSelFly->Frm().Pos() );
181cdf0e10cSrcweir 					aPt.X() -= 1;
182cdf0e10cSrcweir 					sal_Bool bUnLockView = !IsViewLocked();
183cdf0e10cSrcweir 					LockView( sal_True );
184cdf0e10cSrcweir 					SetCrsr( aPt, sal_True );
185cdf0e10cSrcweir 					if( bUnLockView )
186cdf0e10cSrcweir 						LockView( sal_False );
187cdf0e10cSrcweir 				}
188cdf0e10cSrcweir 				if ( nType & CNT_GRF &&
189cdf0e10cSrcweir 					 ((SwNoTxtFrm*)pOldSelFly->Lower())->HasAnimation() )
190cdf0e10cSrcweir 				{
191cdf0e10cSrcweir 					GetWin()->Invalidate( pOldSelFly->Frm().SVRect() );
192cdf0e10cSrcweir 				}
193cdf0e10cSrcweir 				bUnmark = sal_True;
194cdf0e10cSrcweir 			}
195cdf0e10cSrcweir 		}
196cdf0e10cSrcweir 		if ( bUnmark )
197cdf0e10cSrcweir 			pDView->UnmarkAll();
198cdf0e10cSrcweir 	}
199cdf0e10cSrcweir 	else
200cdf0e10cSrcweir 	{
201cdf0e10cSrcweir 		KillPams();
202cdf0e10cSrcweir 		ClearMark();
203cdf0e10cSrcweir 	}
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	if ( pObj )
206cdf0e10cSrcweir 	{
207cdf0e10cSrcweir 		ASSERT( !bEnterGroup, "SW_ENTER_GROUP is not supported" );
208cdf0e10cSrcweir 		pDView->MarkObj( pObj, Imp()->GetPageView() );
209cdf0e10cSrcweir 	}
210cdf0e10cSrcweir 	else
211cdf0e10cSrcweir 	{
212cdf0e10cSrcweir 		pDView->MarkObj( rPt, MINMOVE, bAddSelect, bEnterGroup );
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	const sal_Bool bRet = 0 != rMrkList.GetMarkCount();
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	if ( rMrkList.GetMarkCount() > 1 )
218cdf0e10cSrcweir 	{
219cdf0e10cSrcweir 		//Ganz dumm ist es, wenn Zeichenobjekte Selektiert waren und
220cdf0e10cSrcweir 		//nun ein Fly hinzuselektiert wird.
221cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
222cdf0e10cSrcweir 		{
223cdf0e10cSrcweir             SdrObject *pTmpObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
224cdf0e10cSrcweir             sal_Bool bForget = pTmpObj->ISA(SwVirtFlyDrawObj);
225cdf0e10cSrcweir 			if( bForget )
226cdf0e10cSrcweir 			{
227cdf0e10cSrcweir 				pDView->UnmarkAll();
228cdf0e10cSrcweir                 pDView->MarkObj( pTmpObj, Imp()->GetPageView(), bAddSelect, bEnterGroup );
229cdf0e10cSrcweir 				break;
230cdf0e10cSrcweir 			}
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	if ( bRet )
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		::lcl_GrabCursor(this, pOldSelFly);
237cdf0e10cSrcweir 		if ( GetCntType() & CNT_GRF )
238cdf0e10cSrcweir 		{
239cdf0e10cSrcweir 			const SwFlyFrm *pTmp = GetFlyFromMarked( &rMrkList, this );
240cdf0e10cSrcweir 			ASSERT( pTmp, "Graphic without Fly" );
241cdf0e10cSrcweir 			if ( ((SwNoTxtFrm*)pTmp->Lower())->HasAnimation() )
242cdf0e10cSrcweir 				((SwNoTxtFrm*)pTmp->Lower())->StopAnimation( GetOut() );
243cdf0e10cSrcweir 		}
244cdf0e10cSrcweir 	}
245cdf0e10cSrcweir 	else if ( !pOldSelFly && bHadSelection )
246cdf0e10cSrcweir 		SetCrsr( aOldPos, sal_True);
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 	if( bRet || !bHadSelection )
249cdf0e10cSrcweir 		CallChgLnk();
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	// update der Statuszeile
252cdf0e10cSrcweir 	::FrameNotify( this, bRet ? FLY_DRAG_START : FLY_DRAG_END );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	EndAction();
255cdf0e10cSrcweir 	return bRet;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir /*************************************************************************
259cdf0e10cSrcweir |*
260cdf0e10cSrcweir |*  sal_Bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
261cdf0e10cSrcweir |*
262cdf0e10cSrcweir |*  Description: MoveAnchor( nDir ) looked for an another Anchor for
263cdf0e10cSrcweir |*  the selected drawing object (or fly frame) in the given direction.
264cdf0e10cSrcweir |*  An object "as character" doesn't moves anyway.
265cdf0e10cSrcweir |*  A page bounded object could move to the previous/next page with up/down,
266cdf0e10cSrcweir |*  an object bounded "at paragraph" moves to the previous/next paragraph, too.
267cdf0e10cSrcweir |*  An object bounded "at character" moves to the previous/next paragraph
268cdf0e10cSrcweir |*  with up/down and to the previous/next character with left/right.
269cdf0e10cSrcweir |*  If the anchor for at paragraph/character bounded objects has vertical or
270cdf0e10cSrcweir |*  right_to_left text direction, the directions for up/down/left/right will
271cdf0e10cSrcweir |*  interpreted accordingly.
272cdf0e10cSrcweir |*  An object bounded "at fly" takes the center of the actual anchor and looks
273cdf0e10cSrcweir |*  for the nearest fly frame in the given direction.
274cdf0e10cSrcweir |*
275cdf0e10cSrcweir *************************************************************************/
276cdf0e10cSrcweir 
277cdf0e10cSrcweir #define LESS_X( aPt1, aPt2, bOld ) ( aPt1.X() < aPt2.X() || \
278cdf0e10cSrcweir         ( aPt1.X() == aPt2.X() && ( aPt1.Y() < aPt2.Y() || \
279cdf0e10cSrcweir         ( aPt1.Y() == aPt2.Y() && bOld ) ) ) )
280cdf0e10cSrcweir #define LESS_Y( aPt1, aPt2, bOld ) ( aPt1.Y() < aPt2.Y() || \
281cdf0e10cSrcweir         ( aPt1.Y() == aPt2.Y() && ( aPt1.X() < aPt2.X() || \
282cdf0e10cSrcweir         ( aPt1.X() == aPt2.X() && bOld ) ) ) )
283cdf0e10cSrcweir 
MoveAnchor(sal_uInt16 nDir)284cdf0e10cSrcweir sal_Bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	const SdrMarkList* pMrkList;
287cdf0e10cSrcweir 	if( !Imp()->GetDrawView() ||
288cdf0e10cSrcweir 		0 == (pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList()) ||
289cdf0e10cSrcweir         1 != pMrkList->GetMarkCount())
290cdf0e10cSrcweir         return sal_False;
291cdf0e10cSrcweir     SwFrm* pOld;
292cdf0e10cSrcweir     SwFlyFrm* pFly = NULL;
293cdf0e10cSrcweir     SdrObject *pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
294cdf0e10cSrcweir     if( pObj->ISA(SwVirtFlyDrawObj) )
295cdf0e10cSrcweir     {
296cdf0e10cSrcweir         pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
297cdf0e10cSrcweir         pOld = pFly->AnchorFrm();
298cdf0e10cSrcweir     }
299cdf0e10cSrcweir     else
300cdf0e10cSrcweir         pOld = ((SwDrawContact*)GetUserCall(pObj))->GetAnchorFrm( pObj );
301cdf0e10cSrcweir     sal_Bool bRet = sal_False;
302cdf0e10cSrcweir     if( pOld )
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         SwFrm* pNew = pOld;
305cdf0e10cSrcweir         // --> OD 2004-07-16 #i28701#
306cdf0e10cSrcweir         SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
307cdf0e10cSrcweir         SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
308cdf0e10cSrcweir         SwFmtAnchor aAnch( rFmt.GetAnchor() );
309cdf0e10cSrcweir         RndStdIds nAnchorId = aAnch.GetAnchorId();
310cdf0e10cSrcweir         if ( FLY_AS_CHAR == nAnchorId )
311cdf0e10cSrcweir             return sal_False;
312cdf0e10cSrcweir         if( pOld->IsVertical() )
313cdf0e10cSrcweir         {
314cdf0e10cSrcweir             if( pOld->IsTxtFrm() )
315cdf0e10cSrcweir             {
316cdf0e10cSrcweir                 switch( nDir ) {
317cdf0e10cSrcweir                     case SW_MOVE_UP: nDir = SW_MOVE_LEFT; break;
318cdf0e10cSrcweir                     case SW_MOVE_DOWN: nDir = SW_MOVE_RIGHT; break;
319cdf0e10cSrcweir                     case SW_MOVE_LEFT: nDir = SW_MOVE_DOWN; break;
320cdf0e10cSrcweir                     case SW_MOVE_RIGHT: nDir = SW_MOVE_UP; break;
321cdf0e10cSrcweir                 }
322cdf0e10cSrcweir                 if( pOld->IsRightToLeft() )
323cdf0e10cSrcweir                 {
324cdf0e10cSrcweir                     if( nDir == SW_MOVE_LEFT )
325cdf0e10cSrcweir                         nDir = SW_MOVE_RIGHT;
326cdf0e10cSrcweir                     else if( nDir == SW_MOVE_RIGHT )
327cdf0e10cSrcweir                         nDir = SW_MOVE_LEFT;
328cdf0e10cSrcweir                 }
329cdf0e10cSrcweir             }
330cdf0e10cSrcweir         }
331cdf0e10cSrcweir         switch ( nAnchorId ) {
332cdf0e10cSrcweir             case FLY_AT_PAGE:
333cdf0e10cSrcweir             {
334cdf0e10cSrcweir                 ASSERT( pOld->IsPageFrm(), "Wrong anchor, page exspected." );
335cdf0e10cSrcweir                 if( SW_MOVE_UP == nDir )
336cdf0e10cSrcweir                     pNew = pOld->GetPrev();
337cdf0e10cSrcweir                 else if( SW_MOVE_DOWN == nDir )
338cdf0e10cSrcweir                     pNew = pOld->GetNext();
339cdf0e10cSrcweir                 if( pNew && pNew != pOld )
340cdf0e10cSrcweir                 {
341cdf0e10cSrcweir                     aAnch.SetPageNum( ((SwPageFrm*)pNew)->GetPhyPageNum() );
342cdf0e10cSrcweir                     bRet = sal_True;
343cdf0e10cSrcweir                 }
344cdf0e10cSrcweir                 break;
345cdf0e10cSrcweir             }
346cdf0e10cSrcweir             case FLY_AT_CHAR:
347cdf0e10cSrcweir             {
348cdf0e10cSrcweir                 ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." );
349cdf0e10cSrcweir                 if( SW_MOVE_LEFT == nDir || SW_MOVE_RIGHT == nDir )
350cdf0e10cSrcweir                 {
351cdf0e10cSrcweir                     SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
352cdf0e10cSrcweir                     SwTxtNode* pTxtNd = ((SwTxtFrm*)pOld)->GetTxtNode();
353cdf0e10cSrcweir                     xub_StrLen nAct = pPos->nContent.GetIndex();
354cdf0e10cSrcweir                     if( SW_MOVE_LEFT == nDir )
355cdf0e10cSrcweir                     {
356cdf0e10cSrcweir                         bRet = sal_True;
357cdf0e10cSrcweir                         if( nAct )
358cdf0e10cSrcweir                         {
359cdf0e10cSrcweir                             --nAct;
360cdf0e10cSrcweir                             pPos->nContent.Assign( pTxtNd, nAct );
361cdf0e10cSrcweir                         }
362cdf0e10cSrcweir                         else
363cdf0e10cSrcweir                             nDir = SW_MOVE_UP;
364cdf0e10cSrcweir                     }
365cdf0e10cSrcweir                     else
366cdf0e10cSrcweir                     {
367cdf0e10cSrcweir                         xub_StrLen nMax =
368cdf0e10cSrcweir                             ((SwTxtFrm*)pOld)->GetTxtNode()->GetTxt().Len();
369cdf0e10cSrcweir                         if( nAct < nMax )
370cdf0e10cSrcweir                         {
371cdf0e10cSrcweir                             ++nAct;
372cdf0e10cSrcweir                             bRet = sal_True;
373cdf0e10cSrcweir                             pPos->nContent.Assign( pTxtNd, nAct );
374cdf0e10cSrcweir                         }
375cdf0e10cSrcweir                         else
376cdf0e10cSrcweir                             nDir = SW_MOVE_DOWN;
377cdf0e10cSrcweir                     }
378cdf0e10cSrcweir                 }
379cdf0e10cSrcweir             } // no break!
380cdf0e10cSrcweir             case FLY_AT_PARA:
381cdf0e10cSrcweir             {
382cdf0e10cSrcweir                 ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." );
383cdf0e10cSrcweir                 if( SW_MOVE_UP == nDir )
384cdf0e10cSrcweir                     pNew = pOld->FindPrev();
385cdf0e10cSrcweir                 else if( SW_MOVE_DOWN == nDir )
386cdf0e10cSrcweir                     pNew = pOld->FindNext();
387cdf0e10cSrcweir                 if( pNew && pNew != pOld && pNew->IsCntntFrm() )
388cdf0e10cSrcweir                 {
389cdf0e10cSrcweir                     SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
390cdf0e10cSrcweir                     SwTxtNode* pTxtNd = ((SwTxtFrm*)pNew)->GetTxtNode();
391cdf0e10cSrcweir                     pPos->nNode = *pTxtNd;
392cdf0e10cSrcweir                     xub_StrLen nTmp = 0;
393cdf0e10cSrcweir                     if( bRet )
394cdf0e10cSrcweir                     {
395cdf0e10cSrcweir                         nTmp = ((SwTxtFrm*)pNew)->GetTxtNode()->GetTxt().Len();
396cdf0e10cSrcweir                         if( nTmp )
397cdf0e10cSrcweir                             --nTmp;
398cdf0e10cSrcweir                     }
399cdf0e10cSrcweir                     pPos->nContent.Assign( pTxtNd, nTmp );
400cdf0e10cSrcweir                     bRet = sal_True;
401cdf0e10cSrcweir                 }
402cdf0e10cSrcweir                 else if( SW_MOVE_UP == nDir || SW_MOVE_DOWN == nDir )
403cdf0e10cSrcweir                     bRet = sal_False;
404cdf0e10cSrcweir                 break;
405cdf0e10cSrcweir             }
406cdf0e10cSrcweir             case FLY_AT_FLY:
407cdf0e10cSrcweir             {
408cdf0e10cSrcweir                 ASSERT( pOld->IsFlyFrm(), "Wrong anchor, fly frame exspected.");
409cdf0e10cSrcweir                 SwPageFrm* pPage = pOld->FindPageFrm();
410cdf0e10cSrcweir                 ASSERT( pPage, "Where's my page?" );
411cdf0e10cSrcweir                 SwFlyFrm* pNewFly = NULL;
412cdf0e10cSrcweir                 if( pPage->GetSortedObjs() )
413cdf0e10cSrcweir                 {
414cdf0e10cSrcweir                     int i;
415cdf0e10cSrcweir                     sal_Bool bOld = sal_False;
416cdf0e10cSrcweir                     Point aCenter( pOld->Frm().Left() + pOld->Frm().Width()/2,
417cdf0e10cSrcweir                                    pOld->Frm().Top() + pOld->Frm().Height()/2 );
418cdf0e10cSrcweir                     Point aBest;
419cdf0e10cSrcweir                     for( i = 0; (sal_uInt16)i<pPage->GetSortedObjs()->Count(); ++i )
420cdf0e10cSrcweir                     {
421cdf0e10cSrcweir                         SwAnchoredObject* pAnchObj =
422cdf0e10cSrcweir                                                 (*pPage->GetSortedObjs())[i];
423cdf0e10cSrcweir                         if( pAnchObj->ISA(SwFlyFrm) )
424cdf0e10cSrcweir                         {
425cdf0e10cSrcweir                             SwFlyFrm* pTmp = static_cast<SwFlyFrm*>(pAnchObj);
426cdf0e10cSrcweir                             if( pTmp == pOld )
427cdf0e10cSrcweir                                 bOld = sal_True;
428cdf0e10cSrcweir                             else
429cdf0e10cSrcweir                             {
430cdf0e10cSrcweir                                 const SwFlyFrm* pCheck = pFly ? pTmp : 0;
431cdf0e10cSrcweir                                 while( pCheck )
432cdf0e10cSrcweir                                 {
433cdf0e10cSrcweir                                     if( pCheck == pFly )
434cdf0e10cSrcweir                                         break;
435cdf0e10cSrcweir                                     const SwFrm *pNxt = pCheck->GetAnchorFrm();
436cdf0e10cSrcweir                                     pCheck = pNxt ? pNxt->FindFlyFrm() : NULL;
437cdf0e10cSrcweir                                 }
438cdf0e10cSrcweir                                 if( pCheck || pTmp->IsProtected() )
439cdf0e10cSrcweir                                     continue;
440cdf0e10cSrcweir                                 Point aNew( pTmp->Frm().Left() +
441cdf0e10cSrcweir                                             pTmp->Frm().Width()/2,
442cdf0e10cSrcweir                                             pTmp->Frm().Top() +
443cdf0e10cSrcweir                                             pTmp->Frm().Height()/2 );
444cdf0e10cSrcweir                                 sal_Bool bAccept = sal_False;
445cdf0e10cSrcweir                                 switch( nDir ) {
446cdf0e10cSrcweir                                     case SW_MOVE_RIGHT:
447cdf0e10cSrcweir                                     {
448cdf0e10cSrcweir                                         bAccept = LESS_X( aCenter, aNew, bOld )
449cdf0e10cSrcweir                                              && ( !pNewFly ||
450cdf0e10cSrcweir                                              LESS_X( aNew, aBest, sal_False ) );
451cdf0e10cSrcweir                                         break;
452cdf0e10cSrcweir                                     }
453cdf0e10cSrcweir                                     case SW_MOVE_LEFT:
454cdf0e10cSrcweir                                     {
455cdf0e10cSrcweir                                         bAccept = LESS_X( aNew, aCenter, !bOld )
456cdf0e10cSrcweir                                              && ( !pNewFly ||
457cdf0e10cSrcweir                                              LESS_X( aBest, aNew, sal_True ) );
458cdf0e10cSrcweir                                         break;
459cdf0e10cSrcweir                                     }
460cdf0e10cSrcweir                                     case SW_MOVE_UP:
461cdf0e10cSrcweir                                     {
462cdf0e10cSrcweir                                         bAccept = LESS_Y( aNew, aCenter, !bOld )
463cdf0e10cSrcweir                                              && ( !pNewFly ||
464cdf0e10cSrcweir                                              LESS_Y( aBest, aNew, sal_True ) );
465cdf0e10cSrcweir                                         break;
466cdf0e10cSrcweir                                     }
467cdf0e10cSrcweir                                     case SW_MOVE_DOWN:
468cdf0e10cSrcweir                                     {
469cdf0e10cSrcweir                                         bAccept = LESS_Y( aCenter, aNew, bOld )
470cdf0e10cSrcweir                                              && ( !pNewFly ||
471cdf0e10cSrcweir                                              LESS_Y( aNew, aBest, sal_False ) );
472cdf0e10cSrcweir                                         break;
473cdf0e10cSrcweir                                     }
474cdf0e10cSrcweir                                 }
475cdf0e10cSrcweir                                 if( bAccept )
476cdf0e10cSrcweir                                 {
477cdf0e10cSrcweir                                     pNewFly = pTmp;
478cdf0e10cSrcweir                                     aBest = aNew;
479cdf0e10cSrcweir                                 }
480cdf0e10cSrcweir                             }
481cdf0e10cSrcweir                         }
482cdf0e10cSrcweir                     }
483cdf0e10cSrcweir                 }
484cdf0e10cSrcweir 
485cdf0e10cSrcweir                 if( pNewFly )
486cdf0e10cSrcweir                 {
487cdf0e10cSrcweir                     SwPosition aPos( *pNewFly->GetFmt()->
488cdf0e10cSrcweir                                         GetCntnt().GetCntntIdx());
489cdf0e10cSrcweir                     aAnch.SetAnchor( &aPos );
490cdf0e10cSrcweir                     bRet = sal_True;
491cdf0e10cSrcweir                 }
492cdf0e10cSrcweir                 break;
493cdf0e10cSrcweir             }
494cdf0e10cSrcweir             default: break;
495cdf0e10cSrcweir         }
496cdf0e10cSrcweir         if( bRet )
497cdf0e10cSrcweir         {
498cdf0e10cSrcweir             StartAllAction();
499cdf0e10cSrcweir             // --> OD 2006-02-28 #125892#
500cdf0e10cSrcweir             // handle change of anchor node:
501cdf0e10cSrcweir             // if count of the anchor frame also change, the fly frames have to be
502cdf0e10cSrcweir             // re-created. Thus, delete all fly frames except the <this> before the
503cdf0e10cSrcweir             // anchor attribute is change and re-create them afterwards.
504cdf0e10cSrcweir             {
505cdf0e10cSrcweir                 SwHandleAnchorNodeChg* pHandleAnchorNodeChg( 0L );
506cdf0e10cSrcweir                 SwFlyFrmFmt* pFlyFrmFmt( dynamic_cast<SwFlyFrmFmt*>(&rFmt) );
507cdf0e10cSrcweir                 if ( pFlyFrmFmt )
508cdf0e10cSrcweir                 {
509cdf0e10cSrcweir                     pHandleAnchorNodeChg =
510cdf0e10cSrcweir                         new SwHandleAnchorNodeChg( *pFlyFrmFmt, aAnch );
511cdf0e10cSrcweir                 }
512cdf0e10cSrcweir                 rFmt.GetDoc()->SetAttr( aAnch, rFmt );
513cdf0e10cSrcweir                 delete pHandleAnchorNodeChg;
514cdf0e10cSrcweir             }
515cdf0e10cSrcweir             // <--
516cdf0e10cSrcweir             // --> OD 2004-06-24 #i28701# - no call of method
517cdf0e10cSrcweir             // <CheckCharRectAndTopOfLine()> for to-character anchored
518cdf0e10cSrcweir             // Writer fly frame needed. This method call can cause a
519cdf0e10cSrcweir             // format of the anchor frame, which is no longer intended.
520cdf0e10cSrcweir                     // Instead clear the anchor character rectangle and
521cdf0e10cSrcweir                     // the top of line values for all to-character anchored objects.
522cdf0e10cSrcweir             pAnchoredObj->ClearCharRectAndTopOfLine();
523cdf0e10cSrcweir             EndAllAction();
524cdf0e10cSrcweir         }
525cdf0e10cSrcweir     }
526cdf0e10cSrcweir     return bRet;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir /*************************************************************************
530cdf0e10cSrcweir |*
531cdf0e10cSrcweir |*	SwFEShell::GetSelFrmType()
532cdf0e10cSrcweir |*
533cdf0e10cSrcweir *************************************************************************/
534cdf0e10cSrcweir 
_GetMarkList() const535cdf0e10cSrcweir const SdrMarkList* SwFEShell::_GetMarkList() const
536cdf0e10cSrcweir {
537cdf0e10cSrcweir     const SdrMarkList* pMarkList = NULL;
538cdf0e10cSrcweir     if( Imp()->GetDrawView() != NULL )
539cdf0e10cSrcweir         pMarkList = &Imp()->GetDrawView()->GetMarkedObjectList();
540cdf0e10cSrcweir     return pMarkList;
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
GetSelFrmType() const543cdf0e10cSrcweir sal_uInt16 SwFEShell::GetSelFrmType() const
544cdf0e10cSrcweir {
545cdf0e10cSrcweir     sal_uInt16 eType;
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     // get marked frame list, and check if anything is selected
548cdf0e10cSrcweir     const SdrMarkList* pMarkList = _GetMarkList();
549cdf0e10cSrcweir     if( pMarkList == NULL  ||  pMarkList->GetMarkCount() == 0 )
550cdf0e10cSrcweir         eType = FRMTYPE_NONE;
551cdf0e10cSrcweir     else
552cdf0e10cSrcweir     {
553cdf0e10cSrcweir         // obtain marked item as fly frame; if no fly frame, it must
554cdf0e10cSrcweir         // be a draw object
555cdf0e10cSrcweir         const SwFlyFrm* pFly = ::GetFlyFromMarked(pMarkList, (ViewShell*)this);
556cdf0e10cSrcweir         if ( pFly != NULL )
557cdf0e10cSrcweir         {
558cdf0e10cSrcweir             if( pFly->IsFlyLayFrm() )
559cdf0e10cSrcweir                 eType = FRMTYPE_FLY_FREE;
560cdf0e10cSrcweir             else if( pFly->IsFlyAtCntFrm() )
561cdf0e10cSrcweir                 eType = FRMTYPE_FLY_ATCNT;
562cdf0e10cSrcweir             else
563cdf0e10cSrcweir             {
564cdf0e10cSrcweir                 ASSERT( pFly->IsFlyInCntFrm(), "Neuer Rahmentyp?" );
565cdf0e10cSrcweir                 eType = FRMTYPE_FLY_INCNT;
566cdf0e10cSrcweir             }
567cdf0e10cSrcweir         }
568cdf0e10cSrcweir         else
569cdf0e10cSrcweir             eType = FRMTYPE_DRAWOBJ;
570cdf0e10cSrcweir     }
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     return eType;
573cdf0e10cSrcweir }
574cdf0e10cSrcweir 
575cdf0e10cSrcweir // #108784# does the draw selection contain a control?
IsSelContainsControl() const576cdf0e10cSrcweir bool SwFEShell::IsSelContainsControl() const
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     bool bRet = false;
579cdf0e10cSrcweir 
580cdf0e10cSrcweir     // basically, copy the mechanism from GetSelFrmType(), but call
581cdf0e10cSrcweir     // CheckControl... if you get a drawing object
582cdf0e10cSrcweir     const SdrMarkList* pMarkList = _GetMarkList();
583cdf0e10cSrcweir     if( pMarkList != NULL  &&  pMarkList->GetMarkCount() == 1 )
584cdf0e10cSrcweir     {
585cdf0e10cSrcweir         // if we have one marked object, get the SdrObject and check
586cdf0e10cSrcweir         // whether it contains a control
587cdf0e10cSrcweir         const SdrObject* pSdrObject = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
588cdf0e10cSrcweir         bRet = pSdrObject && ::CheckControlLayer( pSdrObject );
589cdf0e10cSrcweir     }
590cdf0e10cSrcweir     return bRet;
591cdf0e10cSrcweir }
592cdf0e10cSrcweir 
593cdf0e10cSrcweir /*************************************************************************
594cdf0e10cSrcweir |*
595cdf0e10cSrcweir |*	SwFEShell::Scroll()
596cdf0e10cSrcweir |*
597cdf0e10cSrcweir *************************************************************************/
598cdf0e10cSrcweir 
ScrollTo(const Point & rPt)599cdf0e10cSrcweir void SwFEShell::ScrollTo( const Point &rPt )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir 	const SwRect aRect( rPt, rPt );
602cdf0e10cSrcweir 	if ( IsScrollMDI( this, aRect ) &&
603cdf0e10cSrcweir 		 (!Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() ||
604cdf0e10cSrcweir 		  Imp()->IsDragPossible( rPt )) )
605cdf0e10cSrcweir 	{
606cdf0e10cSrcweir 		//SwSaveHdl aSave( Imp() );
607cdf0e10cSrcweir 		ScrollMDI( this, aRect, SCROLLVAL, SCROLLVAL );
608cdf0e10cSrcweir 	}
609cdf0e10cSrcweir }
610cdf0e10cSrcweir 
611cdf0e10cSrcweir /*************************************************************************
612cdf0e10cSrcweir |*
613cdf0e10cSrcweir |*	SwFEShell::SetDragMode()
614cdf0e10cSrcweir |*
615cdf0e10cSrcweir *************************************************************************/
616cdf0e10cSrcweir 
SetDragMode(sal_uInt16 eDragMode)617cdf0e10cSrcweir void SwFEShell::SetDragMode( sal_uInt16 eDragMode )
618cdf0e10cSrcweir {
619cdf0e10cSrcweir 	if ( Imp()->HasDrawView() )
620cdf0e10cSrcweir 		Imp()->GetDrawView()->SetDragMode( (SdrDragMode)eDragMode );
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir /*************************************************************************
624cdf0e10cSrcweir |*
625cdf0e10cSrcweir |*	SwFEShell::BeginDrag()
626cdf0e10cSrcweir |*
627cdf0e10cSrcweir *************************************************************************/
628cdf0e10cSrcweir 
BeginDrag(const Point * pPt,sal_Bool)629cdf0e10cSrcweir long SwFEShell::BeginDrag( const Point* pPt, sal_Bool )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir 	SdrView *pView = Imp()->GetDrawView();
632cdf0e10cSrcweir 	if ( pView && pView->AreObjectsMarked() )
633cdf0e10cSrcweir 	{
634cdf0e10cSrcweir 		delete pChainFrom; delete pChainTo; pChainFrom = pChainTo = 0;
635cdf0e10cSrcweir 		SdrHdl* pHdl = pView->PickHandle( *pPt );
636cdf0e10cSrcweir 		pView->BegDragObj( *pPt, 0 /*GetWin()*/, pHdl );
637cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG );
638cdf0e10cSrcweir 		return 1;
639cdf0e10cSrcweir 	}
640cdf0e10cSrcweir 	return 0;
641cdf0e10cSrcweir }
642cdf0e10cSrcweir /*************************************************************************
643cdf0e10cSrcweir |*
644cdf0e10cSrcweir |*	SwFEShell::Drag()
645cdf0e10cSrcweir |*
646cdf0e10cSrcweir *************************************************************************/
647cdf0e10cSrcweir 
Drag(const Point * pPt,sal_Bool)648cdf0e10cSrcweir long SwFEShell::Drag( const Point *pPt, sal_Bool )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "Drag without DrawView?" );
651cdf0e10cSrcweir 	if ( Imp()->GetDrawView()->IsDragObj() )
652cdf0e10cSrcweir 	{
653cdf0e10cSrcweir 		ScrollTo( *pPt );
654cdf0e10cSrcweir 		Imp()->GetDrawView()->MovDragObj( *pPt );
655cdf0e10cSrcweir 		Imp()->GetDrawView()->ShowDragAnchor();
656cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG );
657cdf0e10cSrcweir 		return 1;
658cdf0e10cSrcweir 	}
659cdf0e10cSrcweir 	return 0;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir 
662cdf0e10cSrcweir /*************************************************************************
663cdf0e10cSrcweir |*
664cdf0e10cSrcweir |*	SwFEShell::EndDrag()
665cdf0e10cSrcweir |*
666cdf0e10cSrcweir *************************************************************************/
667cdf0e10cSrcweir 
EndDrag(const Point *,sal_Bool)668cdf0e10cSrcweir long SwFEShell::EndDrag( const Point *, sal_Bool )
669cdf0e10cSrcweir {
670cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "EndDrag without DrawView?" );
671cdf0e10cSrcweir 	SdrView *pView = Imp()->GetDrawView();
672cdf0e10cSrcweir 	if ( pView->IsDragObj() )
673cdf0e10cSrcweir 	{
674cdf0e10cSrcweir 		//Start-/EndActions nur an der ViewShell aufsetzen
675cdf0e10cSrcweir 		ViewShell *pSh = this;
676cdf0e10cSrcweir 		do {
677cdf0e10cSrcweir 			pSh->StartAction();
678cdf0e10cSrcweir 		} while ( this != (pSh = (ViewShell*)pSh->GetNext()) );
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 		StartUndo( UNDO_START );
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 		//#50778# Bug im Draging: Im StartAction wird ein HideShowXor gerufen.
683cdf0e10cSrcweir 		//Im EndDragObj() wird dies unsinniger und faelschlicherweise wieder
684cdf0e10cSrcweir 		//Rueckgaengig gemacht. Um Konsistenz herzustellen muessen wir das
685cdf0e10cSrcweir 		//Xor also wieder zur Anzeige bringen.
686cdf0e10cSrcweir 
687cdf0e10cSrcweir         // Reanimation from the hack #50778 to fix bug #97057
688cdf0e10cSrcweir         // May be not the best solution, but the one with lowest risc at the moment.
689cdf0e10cSrcweir         //pView->ShowShownXor( GetOut() );
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 		pView->EndDragObj();
692cdf0e10cSrcweir 		// DrawUndo-Action auf FlyFrames werden nicht gespeichert
693cdf0e10cSrcweir 		//				Die Fly aendern das Flag
694cdf0e10cSrcweir         GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
695cdf0e10cSrcweir 		ChgAnchor( 0, sal_True );
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 		EndUndo( UNDO_END );
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 		do {
700cdf0e10cSrcweir 			pSh->EndAction();
701cdf0e10cSrcweir 			if( pSh->IsA( TYPE( SwCrsrShell ) ) )
702cdf0e10cSrcweir 				((SwCrsrShell*)pSh)->CallChgLnk();
703cdf0e10cSrcweir 		} while ( this != (pSh = (ViewShell*)pSh->GetNext()) );
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 		GetDoc()->SetModified();
706cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG );
707cdf0e10cSrcweir 		return 1;
708cdf0e10cSrcweir 	}
709cdf0e10cSrcweir 	return 0;
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir /*************************************************************************
713cdf0e10cSrcweir |*
714cdf0e10cSrcweir |*	SwFEShell::BreakDrag()
715cdf0e10cSrcweir |*
716cdf0e10cSrcweir *************************************************************************/
717cdf0e10cSrcweir 
BreakDrag()718cdf0e10cSrcweir void SwFEShell::BreakDrag()
719cdf0e10cSrcweir {
720cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "BreakDrag without DrawView?" );
721cdf0e10cSrcweir 	if ( Imp()->GetDrawView()->IsDragObj() )
722cdf0e10cSrcweir 		Imp()->GetDrawView()->BrkDragObj();
723cdf0e10cSrcweir 	SetChainMarker();
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir /*************************************************************************
727cdf0e10cSrcweir |*
728cdf0e10cSrcweir |*	SwFEShell::SelFlyGrabCrsr()
729cdf0e10cSrcweir |*
730cdf0e10cSrcweir |* 	Beschreibung		Wenn ein Fly selektiert ist, zieht er den Crsr in
731cdf0e10cSrcweir |* 						den ersten CntntFrm
732cdf0e10cSrcweir *************************************************************************/
733cdf0e10cSrcweir 
SelFlyGrabCrsr()734cdf0e10cSrcweir const SwFrmFmt* SwFEShell::SelFlyGrabCrsr()
735cdf0e10cSrcweir {
736cdf0e10cSrcweir 	if ( Imp()->HasDrawView() )
737cdf0e10cSrcweir 	{
738cdf0e10cSrcweir 		const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
739cdf0e10cSrcweir 		SwFlyFrm *pFly = ::GetFlyFromMarked( &rMrkList, this );
740cdf0e10cSrcweir 
741cdf0e10cSrcweir 		if( pFly )
742cdf0e10cSrcweir 		{
743cdf0e10cSrcweir 			SwCntntFrm *pCFrm = pFly->ContainsCntnt();
744cdf0e10cSrcweir 			if ( pCFrm )
745cdf0e10cSrcweir 			{
746cdf0e10cSrcweir 				SwCntntNode	*pCNode = pCFrm->GetNode();
747cdf0e10cSrcweir                 // --> OD 2007-07-25 #126039#
748cdf0e10cSrcweir                 // assure, that the cursor is consistent.
749cdf0e10cSrcweir                 KillPams();
750cdf0e10cSrcweir                 ClearMark();
751cdf0e10cSrcweir                 // <--
752cdf0e10cSrcweir 				SwPaM		*pCrsr	= GetCrsr();
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 				pCrsr->GetPoint()->nNode = *pCNode;
755cdf0e10cSrcweir 				pCrsr->GetPoint()->nContent.Assign( pCNode, 0 );
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 				SwRect& rChrRect = (SwRect&)GetCharRect();
758cdf0e10cSrcweir 				rChrRect = pFly->Prt();
759cdf0e10cSrcweir 				rChrRect.Pos() += pFly->Frm().Pos();
760cdf0e10cSrcweir 				GetCrsrDocPos() = rChrRect.Pos();
761cdf0e10cSrcweir 			}
762cdf0e10cSrcweir 			return pFly->GetFmt();
763cdf0e10cSrcweir 		}
764cdf0e10cSrcweir 	}
765cdf0e10cSrcweir 	return 0;
766cdf0e10cSrcweir }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 
769cdf0e10cSrcweir /*************************************************************************
770cdf0e10cSrcweir |*
771cdf0e10cSrcweir |*	SwFEShell::SelectionToTop(), SelectionToBottom()
772cdf0e10cSrcweir |*
773cdf0e10cSrcweir |* 	Beschreibung		Selektion nach oben/unten (Z-Order)
774cdf0e10cSrcweir |*
775cdf0e10cSrcweir *************************************************************************/
776cdf0e10cSrcweir 
lcl_NotifyNeighbours(const SdrMarkList * pLst)777cdf0e10cSrcweir void lcl_NotifyNeighbours( const SdrMarkList *pLst )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir 	//Die Regeln fuer die Ausweichmanoever haben sich veraendert.
780cdf0e10cSrcweir 	//1. Die Umgebung des Fly und aller innenliegenden muss benachrichtigt
781cdf0e10cSrcweir 	//	 werden.
782cdf0e10cSrcweir 	//2. Der Inhalt des Rahmen selbst muss benachrichtigt werden.
783cdf0e10cSrcweir 	//3. Rahmen die dem Rahmen ausweichen bzw. wichen muessen benachrichtigt werden.
784cdf0e10cSrcweir 	//4. Auch Zeichenobjekte koennen Rahmen verdraengen
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 	for( sal_uInt16 j = 0; j < pLst->GetMarkCount(); ++j )
787cdf0e10cSrcweir 	{
788cdf0e10cSrcweir 		SwPageFrm *pPage;
789cdf0e10cSrcweir 		sal_Bool bCheckNeighbours = sal_False;
790cdf0e10cSrcweir         sal_Int16 aHori = text::HoriOrientation::NONE;
791cdf0e10cSrcweir 		SwRect aRect;
792cdf0e10cSrcweir 		SdrObject *pO = pLst->GetMark( 0 )->GetMarkedSdrObj();
793cdf0e10cSrcweir 		if ( pO->ISA(SwVirtFlyDrawObj) )
794cdf0e10cSrcweir 		{
795cdf0e10cSrcweir 			SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pO)->GetFlyFrm();
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 			const SwFmtHoriOrient &rHori = pFly->GetFmt()->GetHoriOrient();
798cdf0e10cSrcweir 			aHori = rHori.GetHoriOrient();
799cdf0e10cSrcweir             if( text::HoriOrientation::NONE != aHori && text::HoriOrientation::CENTER != aHori &&
800cdf0e10cSrcweir 				pFly->IsFlyAtCntFrm() )
801cdf0e10cSrcweir 			{
802cdf0e10cSrcweir 				bCheckNeighbours = sal_True;
803cdf0e10cSrcweir 				pFly->InvalidatePos();
804cdf0e10cSrcweir 				pFly->Frm().Pos().Y() += 1;
805cdf0e10cSrcweir 			}
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 			pPage = pFly->FindPageFrm();
808cdf0e10cSrcweir 			aRect = pFly->Frm();
809cdf0e10cSrcweir 		}
810cdf0e10cSrcweir 		else
811cdf0e10cSrcweir 		{
812cdf0e10cSrcweir             SwFrm* pAnch = ( (SwDrawContact*)GetUserCall(pO) )->GetAnchorFrm( pO );
813cdf0e10cSrcweir 			if( !pAnch )
814cdf0e10cSrcweir 				continue;
815cdf0e10cSrcweir 			pPage = pAnch->FindPageFrm();
816cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520# - naming changed
817cdf0e10cSrcweir             aRect = GetBoundRectOfAnchoredObj( pO );
818cdf0e10cSrcweir             // <--
819cdf0e10cSrcweir 		}
820cdf0e10cSrcweir 
821cdf0e10cSrcweir         sal_uInt32 nCount = pPage->GetSortedObjs() ? pPage->GetSortedObjs()->Count() : 0;
822cdf0e10cSrcweir         for ( sal_uInt32 i = 0; i < nCount; ++i )
823cdf0e10cSrcweir 		{
824cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pPage->GetSortedObjs())[i];
825cdf0e10cSrcweir             if ( !pAnchoredObj->ISA(SwFlyFrm) )
826cdf0e10cSrcweir 				continue;
827cdf0e10cSrcweir 
828cdf0e10cSrcweir             SwFlyFrm* pAct = static_cast<SwFlyFrm*>(pAnchoredObj);
829cdf0e10cSrcweir 			SwRect aTmpCalcPnt( pAct->Prt() );
830cdf0e10cSrcweir 			aTmpCalcPnt += pAct->Frm().Pos();
831cdf0e10cSrcweir 			if ( aRect.IsOver( aTmpCalcPnt ) )
832cdf0e10cSrcweir 			{
833cdf0e10cSrcweir 				SwCntntFrm *pCnt = pAct->ContainsCntnt();
834cdf0e10cSrcweir 				while ( pCnt )
835cdf0e10cSrcweir 				{
836cdf0e10cSrcweir 					aTmpCalcPnt = pCnt->Prt();
837cdf0e10cSrcweir 					aTmpCalcPnt += pCnt->Frm().Pos();
838cdf0e10cSrcweir 					if ( aRect.IsOver( aTmpCalcPnt ) )
839cdf0e10cSrcweir 						((SwFrm*)pCnt)->Prepare( PREP_FLY_ATTR_CHG );
840cdf0e10cSrcweir 					pCnt = pCnt->GetNextCntntFrm();
841cdf0e10cSrcweir 				}
842cdf0e10cSrcweir 			}
843cdf0e10cSrcweir 			if ( bCheckNeighbours && pAct->IsFlyAtCntFrm() )
844cdf0e10cSrcweir 			{
845cdf0e10cSrcweir 				const SwFmtHoriOrient &rH = pAct->GetFmt()->GetHoriOrient();
846cdf0e10cSrcweir 				if ( rH.GetHoriOrient() == aHori &&
847cdf0e10cSrcweir 					 pAct->Frm().Top()	  <= aRect.Bottom() &&
848cdf0e10cSrcweir 					 pAct->Frm().Bottom() >= aRect.Top() )
849cdf0e10cSrcweir 				{
850cdf0e10cSrcweir 					pAct->InvalidatePos();
851cdf0e10cSrcweir 					pAct->Frm().Pos().Y() += 1;
852cdf0e10cSrcweir 				}
853cdf0e10cSrcweir 			}
854cdf0e10cSrcweir 		}
855cdf0e10cSrcweir 	}
856cdf0e10cSrcweir }
857cdf0e10cSrcweir 
SelectionToTop(sal_Bool bTop)858cdf0e10cSrcweir void SwFEShell::SelectionToTop( sal_Bool bTop )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "SelectionToTop without DrawView?" );
861cdf0e10cSrcweir 	const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
862cdf0e10cSrcweir 	ASSERT( rMrkList.GetMarkCount(), "Kein Object Selektiert." );
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 	SwFlyFrm *pFly = ::GetFlyFromMarked( &rMrkList, this );
865cdf0e10cSrcweir 	if ( pFly && pFly->IsFlyInCntFrm() )
866cdf0e10cSrcweir 		return;
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 	StartAllAction();
869cdf0e10cSrcweir 	if ( bTop )
870cdf0e10cSrcweir 		Imp()->GetDrawView()->PutMarkedToTop();
871cdf0e10cSrcweir 	else
872cdf0e10cSrcweir 		Imp()->GetDrawView()->MovMarkedToTop();
873cdf0e10cSrcweir 	::lcl_NotifyNeighbours( &rMrkList );
874cdf0e10cSrcweir 	GetDoc()->SetModified();
875cdf0e10cSrcweir 	EndAllAction();
876cdf0e10cSrcweir }
877cdf0e10cSrcweir 
SelectionToBottom(sal_Bool bBottom)878cdf0e10cSrcweir void SwFEShell::SelectionToBottom( sal_Bool bBottom )
879cdf0e10cSrcweir {
880cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "SelectionToBottom without DrawView?" );
881cdf0e10cSrcweir 	const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
882cdf0e10cSrcweir 	ASSERT( rMrkList.GetMarkCount(), "Kein Object Selektiert." );
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 	SwFlyFrm *pFly = ::GetFlyFromMarked( &rMrkList, this );
885cdf0e10cSrcweir 	if ( pFly && pFly->IsFlyInCntFrm() )
886cdf0e10cSrcweir 		return;
887cdf0e10cSrcweir 
888cdf0e10cSrcweir 	StartAllAction();
889cdf0e10cSrcweir 	if ( bBottom )
890cdf0e10cSrcweir 		Imp()->GetDrawView()->PutMarkedToBtm();
891cdf0e10cSrcweir 	else
892cdf0e10cSrcweir 		Imp()->GetDrawView()->MovMarkedToBtm();
893cdf0e10cSrcweir 	::lcl_NotifyNeighbours( &rMrkList );
894cdf0e10cSrcweir 	GetDoc()->SetModified();
895cdf0e10cSrcweir 	EndAllAction();
896cdf0e10cSrcweir }
897cdf0e10cSrcweir 
898cdf0e10cSrcweir /*************************************************************************
899cdf0e10cSrcweir |*
900cdf0e10cSrcweir |*	SwFEShell::GetLayerId()
901cdf0e10cSrcweir |*
902cdf0e10cSrcweir |*	Beschreibung		Objekt ueber/unter dem Dokument?
903cdf0e10cSrcweir |*						2 Controls, 1 Heaven, 0 Hell, -1 Uneindeutig
904cdf0e10cSrcweir *************************************************************************/
905cdf0e10cSrcweir 
GetLayerId() const906cdf0e10cSrcweir short SwFEShell::GetLayerId() const
907cdf0e10cSrcweir {
908cdf0e10cSrcweir 	short nRet = SHRT_MAX;
909cdf0e10cSrcweir 	if ( Imp()->HasDrawView() )
910cdf0e10cSrcweir 	{
911cdf0e10cSrcweir 		const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
912cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
913cdf0e10cSrcweir 		{
914cdf0e10cSrcweir 			const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
915cdf0e10cSrcweir             if( !pObj )
916cdf0e10cSrcweir                 continue;
917cdf0e10cSrcweir 			if ( nRet == SHRT_MAX )
918cdf0e10cSrcweir 				nRet = pObj->GetLayer();
919cdf0e10cSrcweir 			else if ( nRet != pObj->GetLayer() )
920cdf0e10cSrcweir 			{
921cdf0e10cSrcweir 				nRet = -1;
922cdf0e10cSrcweir 				break;
923cdf0e10cSrcweir 			}
924cdf0e10cSrcweir 		}
925cdf0e10cSrcweir 	}
926cdf0e10cSrcweir 	if ( nRet == SHRT_MAX )
927cdf0e10cSrcweir 		nRet = -1;
928cdf0e10cSrcweir 	return nRet;
929cdf0e10cSrcweir }
930cdf0e10cSrcweir 
931cdf0e10cSrcweir /*************************************************************************
932cdf0e10cSrcweir |*
933cdf0e10cSrcweir |*	SwFEShell::SelectionToHeaven(), SelectionToHell()
934cdf0e10cSrcweir |*
935cdf0e10cSrcweir |*	Beschreibung		Objekt ueber/unter dem Dokument
936cdf0e10cSrcweir |*
937cdf0e10cSrcweir *************************************************************************/
938cdf0e10cSrcweir // OD 25.06.2003 #108784#
939cdf0e10cSrcweir // Note: only visible objects can be marked. Thus, objects with invisible
940cdf0e10cSrcweir //       layer IDs have not to be considered.
941cdf0e10cSrcweir //       If <SwFEShell> exists, layout exists!!
ChangeOpaque(SdrLayerID nLayerId)942cdf0e10cSrcweir void SwFEShell::ChangeOpaque( SdrLayerID nLayerId )
943cdf0e10cSrcweir {
944cdf0e10cSrcweir 	if ( Imp()->HasDrawView() )
945cdf0e10cSrcweir 	{
946cdf0e10cSrcweir 		const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
947cdf0e10cSrcweir         const IDocumentDrawModelAccess* pIDDMA = getIDocumentDrawModelAccess();
948cdf0e10cSrcweir         // OD 25.06.2003 #108784# - correct type of <nControls>
949cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
950cdf0e10cSrcweir 		{
951cdf0e10cSrcweir             SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
952cdf0e10cSrcweir             if( !pObj )
953cdf0e10cSrcweir                 continue;
954cdf0e10cSrcweir             // OD 21.08.2003 #i18447# - no change of layer for controls
955cdf0e10cSrcweir             // or group objects containing controls.
956cdf0e10cSrcweir             // --> OD 2010-09-14 #i113730#
957cdf0e10cSrcweir             // consider that a member of a drawing group has been selected.
958cdf0e10cSrcweir             const SwContact* pContact = ::GetUserCall( pObj );
959cdf0e10cSrcweir             ASSERT( pContact && pContact->GetMaster(), "<SwFEShell::ChangeOpaque(..)> - missing contact or missing master object at contact!" );
960cdf0e10cSrcweir             const bool bControlObj = ( pContact && pContact->GetMaster() )
961cdf0e10cSrcweir                                      ? ::CheckControlLayer( pContact->GetMaster() )
962cdf0e10cSrcweir                                      : ::CheckControlLayer( pObj );
963cdf0e10cSrcweir             // <--
964cdf0e10cSrcweir             if ( !bControlObj && pObj->GetLayer() != nLayerId )
965cdf0e10cSrcweir 			{
966cdf0e10cSrcweir 				pObj->SetLayer( nLayerId );
967cdf0e10cSrcweir 				InvalidateWindows( SwRect( pObj->GetCurrentBoundRect() ) );
968cdf0e10cSrcweir 				if ( pObj->ISA(SwVirtFlyDrawObj) )
969cdf0e10cSrcweir 				{
970cdf0e10cSrcweir 					SwFmt *pFmt = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetFmt();
971cdf0e10cSrcweir 					SvxOpaqueItem aOpa( pFmt->GetOpaque() );
972cdf0e10cSrcweir                     aOpa.SetValue(  nLayerId == pIDDMA->GetHellId() );
973cdf0e10cSrcweir                     pFmt->SetFmtAttr( aOpa );
974cdf0e10cSrcweir 				}
975cdf0e10cSrcweir 			}
976cdf0e10cSrcweir 		}
977cdf0e10cSrcweir 		GetDoc()->SetModified();
978cdf0e10cSrcweir 	}
979cdf0e10cSrcweir }
980cdf0e10cSrcweir 
SelectionToHeaven()981cdf0e10cSrcweir void SwFEShell::SelectionToHeaven()
982cdf0e10cSrcweir {
983cdf0e10cSrcweir     ChangeOpaque( getIDocumentDrawModelAccess()->GetHeavenId() );
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
SelectionToHell()986cdf0e10cSrcweir void SwFEShell::SelectionToHell()
987cdf0e10cSrcweir {
988cdf0e10cSrcweir     ChangeOpaque( getIDocumentDrawModelAccess()->GetHellId() );
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir /*************************************************************************
992cdf0e10cSrcweir |*
993cdf0e10cSrcweir |*	SwFEShell::IsObjSelected(), IsFrmSelected()
994cdf0e10cSrcweir |*
995cdf0e10cSrcweir *************************************************************************/
996cdf0e10cSrcweir 
IsObjSelected() const997cdf0e10cSrcweir sal_uInt16 SwFEShell::IsObjSelected() const
998cdf0e10cSrcweir {
999cdf0e10cSrcweir 	if ( IsFrmSelected() || !Imp()->HasDrawView() )
1000cdf0e10cSrcweir 		return 0;
1001cdf0e10cSrcweir 	else
1002cdf0e10cSrcweir 		return sal_uInt16( Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() );
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir 
IsFrmSelected() const1005cdf0e10cSrcweir sal_Bool SwFEShell::IsFrmSelected() const
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir 	if ( !Imp()->HasDrawView() )
1008cdf0e10cSrcweir 		return sal_False;
1009cdf0e10cSrcweir 	else
1010cdf0e10cSrcweir 		return 0 != ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
1011cdf0e10cSrcweir 										(ViewShell*)this );
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir 
IsObjSelected(const SdrObject & rObj) const1014cdf0e10cSrcweir sal_Bool SwFEShell::IsObjSelected( const SdrObject& rObj ) const
1015cdf0e10cSrcweir {
1016cdf0e10cSrcweir 	if ( IsFrmSelected() || !Imp()->HasDrawView() )
1017cdf0e10cSrcweir 		return sal_False;
1018cdf0e10cSrcweir 	else
1019cdf0e10cSrcweir 		return Imp()->GetDrawView()
1020cdf0e10cSrcweir 					->IsObjMarked( const_cast< SdrObject * >( &rObj ) );
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir 
IsObjSameLevelWithMarked(const SdrObject * pObj) const1023ca62e2c2SSteve Yin sal_Bool SwFEShell::IsObjSameLevelWithMarked(const SdrObject* pObj) const
1024ca62e2c2SSteve Yin {
1025ca62e2c2SSteve Yin 	if (pObj)
1026ca62e2c2SSteve Yin 	{
1027ca62e2c2SSteve Yin 		const SdrMarkList& aMarkList = Imp()->GetDrawView()->GetMarkedObjectList();
1028ca62e2c2SSteve Yin 		if (aMarkList.GetMarkCount() == 0)
1029ca62e2c2SSteve Yin 		{
1030ca62e2c2SSteve Yin 			return sal_True;
1031ca62e2c2SSteve Yin 		}
1032ca62e2c2SSteve Yin 		SdrMark* pM=aMarkList.GetMark(0);
1033ca62e2c2SSteve Yin 		if (pM)
1034ca62e2c2SSteve Yin 		{
1035ca62e2c2SSteve Yin 			SdrObject* pMarkObj = pM->GetMarkedSdrObj();
1036ca62e2c2SSteve Yin 			if (pMarkObj && pMarkObj->GetUpGroup() == pObj->GetUpGroup())
1037ca62e2c2SSteve Yin 				return sal_True;
1038ca62e2c2SSteve Yin 		}
1039ca62e2c2SSteve Yin 	}
1040ca62e2c2SSteve Yin 	return sal_False;
1041ca62e2c2SSteve Yin }
1042cdf0e10cSrcweir /*************************************************************************
1043cdf0e10cSrcweir |*
1044cdf0e10cSrcweir |*	SwFEShell::EndTextEdit()
1045cdf0e10cSrcweir |*
1046cdf0e10cSrcweir *************************************************************************/
1047cdf0e10cSrcweir 
EndTextEdit()1048cdf0e10cSrcweir void SwFEShell::EndTextEdit()
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir 	//Beenden des TextEditModus. Wenn gewuenscht (default wenn das Objekt
1051cdf0e10cSrcweir 	//keinen Text mehr enthaelt und keine Attribute traegt) wird das
1052cdf0e10cSrcweir 	//Objekt gel�scht. Alle anderen markierten Objekte bleiben erhalten.
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView() && Imp()->GetDrawView()->IsTextEdit(),
1055cdf0e10cSrcweir 			"EndTextEdit an no Object" );
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 	StartAllAction();
1058cdf0e10cSrcweir 	SdrView *pView = Imp()->GetDrawView();
1059cdf0e10cSrcweir 	SdrObject *pObj = pView->GetTextEditObject();
1060cdf0e10cSrcweir 	SdrObjUserCall* pUserCall;
1061cdf0e10cSrcweir 	if( 0 != ( pUserCall = GetUserCall(pObj) ) )
1062cdf0e10cSrcweir 	{
1063cdf0e10cSrcweir         SdrObject *pTmp = ((SwContact*)pUserCall)->GetMaster();
1064cdf0e10cSrcweir         if( !pTmp )
1065cdf0e10cSrcweir             pTmp = pObj;
1066cdf0e10cSrcweir         pUserCall->Changed( *pTmp, SDRUSERCALL_RESIZE, pTmp->GetLastBoundRect() );
1067cdf0e10cSrcweir 	}
1068cdf0e10cSrcweir 	if ( !pObj->GetUpGroup() )
1069cdf0e10cSrcweir 	{
1070cdf0e10cSrcweir 		if ( SDRENDTEXTEDIT_SHOULDBEDELETED == pView->SdrEndTextEdit(sal_True) )
1071cdf0e10cSrcweir 		{
1072cdf0e10cSrcweir 			if ( pView->GetMarkedObjectList().GetMarkCount() > 1 )
1073cdf0e10cSrcweir 			{
1074cdf0e10cSrcweir 				{
1075cdf0e10cSrcweir 					SdrMarkList aSave( pView->GetMarkedObjectList() );
1076cdf0e10cSrcweir 					aSave.DeleteMark( aSave.FindObject( pObj ) );
1077cdf0e10cSrcweir 					if ( aSave.GetMarkCount() )
1078cdf0e10cSrcweir 					{
1079cdf0e10cSrcweir 						pView->UnmarkAll();
1080cdf0e10cSrcweir 						pView->MarkObj( pObj, Imp()->GetPageView() );
1081cdf0e10cSrcweir 					}
1082cdf0e10cSrcweir 					DelSelectedObj();
1083cdf0e10cSrcweir 					if ( aSave.GetMarkCount() )
1084cdf0e10cSrcweir 					{
1085cdf0e10cSrcweir 						for ( sal_uInt16 i = 0; i < aSave.GetMarkCount(); ++i )
1086cdf0e10cSrcweir 							pView->MarkObj( aSave.GetMark( i )->GetMarkedSdrObj(),
1087cdf0e10cSrcweir 											Imp()->GetPageView() );
1088cdf0e10cSrcweir 					}
1089cdf0e10cSrcweir 				}
1090cdf0e10cSrcweir 			}
1091cdf0e10cSrcweir 			else
1092cdf0e10cSrcweir 				DelSelectedObj();
1093cdf0e10cSrcweir 		}
1094cdf0e10cSrcweir 	}
1095cdf0e10cSrcweir 	else
1096cdf0e10cSrcweir 		pView->SdrEndTextEdit();
1097cdf0e10cSrcweir 	EndAllAction();
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir /*************************************************************************
1101cdf0e10cSrcweir |*
1102cdf0e10cSrcweir |*	SwFEShell::IsInsideSelectedObj()
1103cdf0e10cSrcweir |*
1104cdf0e10cSrcweir *************************************************************************/
1105cdf0e10cSrcweir 
IsInsideSelectedObj(const Point & rPt)1106cdf0e10cSrcweir int SwFEShell::IsInsideSelectedObj( const Point &rPt )
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir 	if( Imp()->HasDrawView() )
1109cdf0e10cSrcweir 	{
1110cdf0e10cSrcweir 		SwDrawView *pDView = Imp()->GetDrawView();
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir 		if( pDView->GetMarkedObjectList().GetMarkCount() &&
1113cdf0e10cSrcweir 			pDView->IsMarkedObjHit( rPt ) )
1114cdf0e10cSrcweir 		{
1115cdf0e10cSrcweir 			return SDRHIT_OBJECT;
1116cdf0e10cSrcweir 		}
1117cdf0e10cSrcweir 	}
1118cdf0e10cSrcweir 	return SDRHIT_NONE;
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir /*************************************************************************
1122cdf0e10cSrcweir |*
1123cdf0e10cSrcweir |*	SwFEShell::IsObjSelectable()
1124cdf0e10cSrcweir |*
1125cdf0e10cSrcweir *************************************************************************/
1126cdf0e10cSrcweir 
IsObjSelectable(const Point & rPt)1127cdf0e10cSrcweir bool SwFEShell::IsObjSelectable( const Point& rPt )
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir 	SET_CURR_SHELL(this);
1130cdf0e10cSrcweir #ifdef OLD
1131cdf0e10cSrcweir 	if( Imp()->HasDrawView() )
1132cdf0e10cSrcweir 		return Imp()->GetDrawView()->PickSomething( rPt, MINMOVE );
1133cdf0e10cSrcweir 	return 0;
1134cdf0e10cSrcweir #else
1135cdf0e10cSrcweir 	SwDrawView *pDView = Imp()->GetDrawView();
1136cdf0e10cSrcweir     bool bRet = false;
1137cdf0e10cSrcweir 	if( pDView )
1138cdf0e10cSrcweir 	{
1139cdf0e10cSrcweir 		SdrObject* pObj;
1140cdf0e10cSrcweir 		SdrPageView* pPV;
1141cdf0e10cSrcweir 		sal_uInt16 nOld = pDView->GetHitTolerancePixel();
1142cdf0e10cSrcweir 		pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir         bRet = 0 != pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMARKABLE );
1145cdf0e10cSrcweir 		pDView->SetHitTolerancePixel( nOld );
1146cdf0e10cSrcweir 	}
1147cdf0e10cSrcweir     return bRet;
1148cdf0e10cSrcweir #endif
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir // #107513#
1152cdf0e10cSrcweir // Test if there is a object at that position and if it should be selected.
ShouldObjectBeSelected(const Point & rPt)1153cdf0e10cSrcweir sal_Bool SwFEShell::ShouldObjectBeSelected(const Point& rPt)
1154cdf0e10cSrcweir {
1155cdf0e10cSrcweir 	SET_CURR_SHELL(this);
1156cdf0e10cSrcweir 	SwDrawView *pDrawView = Imp()->GetDrawView();
1157cdf0e10cSrcweir 	sal_Bool bRet(sal_False);
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir 	if(pDrawView)
1160cdf0e10cSrcweir 	{
1161cdf0e10cSrcweir 		SdrObject* pObj;
1162cdf0e10cSrcweir 		SdrPageView* pPV;
1163cdf0e10cSrcweir 		sal_uInt16 nOld(pDrawView->GetHitTolerancePixel());
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 		pDrawView->SetHitTolerancePixel(pDrawView->GetMarkHdlSizePixel()/2);
1166cdf0e10cSrcweir 		bRet = pDrawView->PickObj(rPt, pDrawView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMARKABLE);
1167cdf0e10cSrcweir 		pDrawView->SetHitTolerancePixel(nOld);
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir         if ( bRet && pObj )
1170cdf0e10cSrcweir 		{
1171cdf0e10cSrcweir             const IDocumentDrawModelAccess* pIDDMA = getIDocumentDrawModelAccess();
1172cdf0e10cSrcweir             // --> OD 2009-12-30 #i89920#
1173cdf0e10cSrcweir             // Do not select object in background which is overlapping this text
1174cdf0e10cSrcweir             // at the given position.
1175cdf0e10cSrcweir             bool bObjInBackground( false );
1176cdf0e10cSrcweir             {
1177cdf0e10cSrcweir                 if ( pObj->GetLayer() == pIDDMA->GetHellId() )
1178cdf0e10cSrcweir                 {
1179cdf0e10cSrcweir                     const SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
1180cdf0e10cSrcweir                     const SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
1181cdf0e10cSrcweir                     const SwFmtSurround& rSurround = rFmt.GetSurround();
1182cdf0e10cSrcweir                     if ( rSurround.GetSurround() == SURROUND_THROUGHT )
1183cdf0e10cSrcweir                     {
1184cdf0e10cSrcweir                         bObjInBackground = true;
1185cdf0e10cSrcweir                     }
1186cdf0e10cSrcweir                 }
1187cdf0e10cSrcweir             }
1188cdf0e10cSrcweir             if ( bObjInBackground )
1189cdf0e10cSrcweir             {
1190cdf0e10cSrcweir                 const SwPageFrm* pPageFrm = GetLayout()->GetPageAtPos( rPt );
1191cdf0e10cSrcweir                 if( pPageFrm )
1192cdf0e10cSrcweir                 {
1193cdf0e10cSrcweir                     const SwCntntFrm* pCntntFrm( pPageFrm->ContainsCntnt() );
1194cdf0e10cSrcweir                     while ( pCntntFrm )
1195cdf0e10cSrcweir                     {
1196cdf0e10cSrcweir                         if ( pCntntFrm->UnionFrm().IsInside( rPt ) )
1197cdf0e10cSrcweir                         {
1198cdf0e10cSrcweir                             const SwTxtFrm* pTxtFrm =
1199cdf0e10cSrcweir                                     dynamic_cast<const SwTxtFrm*>(pCntntFrm);
1200cdf0e10cSrcweir                             if ( pTxtFrm )
1201cdf0e10cSrcweir                             {
1202cdf0e10cSrcweir                                 SwPosition* pPos =
1203cdf0e10cSrcweir                                     new SwPosition( *(pTxtFrm->GetTxtNode()) );
1204cdf0e10cSrcweir                                 Point aTmpPt( rPt );
1205cdf0e10cSrcweir                                 if ( pTxtFrm->GetKeyCrsrOfst( pPos, aTmpPt ) )
1206cdf0e10cSrcweir                                 {
1207cdf0e10cSrcweir                                     SwRect aCursorCharRect;
1208cdf0e10cSrcweir                                     if ( pTxtFrm->GetCharRect( aCursorCharRect, *pPos ) )
1209cdf0e10cSrcweir                                     {
1210cdf0e10cSrcweir                                         if ( aCursorCharRect.IsOver( SwRect( pObj->GetLastBoundRect() ) ) )
1211cdf0e10cSrcweir                                         {
1212cdf0e10cSrcweir                                             bRet = sal_False;
1213cdf0e10cSrcweir                                         }
1214cdf0e10cSrcweir                                     }
1215cdf0e10cSrcweir                                 }
1216cdf0e10cSrcweir                             }
1217cdf0e10cSrcweir                             else
1218cdf0e10cSrcweir                             {
1219cdf0e10cSrcweir                                 bRet = sal_False;
1220cdf0e10cSrcweir                             }
1221cdf0e10cSrcweir                             break;
1222cdf0e10cSrcweir                         }
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir                         pCntntFrm = pCntntFrm->GetNextCntntFrm();
1225cdf0e10cSrcweir                     }
1226cdf0e10cSrcweir                 }
1227cdf0e10cSrcweir             }
1228cdf0e10cSrcweir             // <--
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir             if ( bRet )
1231cdf0e10cSrcweir             {
1232cdf0e10cSrcweir                 const SdrPage* pPage = pIDDMA->GetDrawModel()->GetPage(0);
1233cdf0e10cSrcweir                 for(sal_uInt32 a(pObj->GetOrdNum() + 1); bRet && a < pPage->GetObjCount(); a++)
1234cdf0e10cSrcweir                 {
1235cdf0e10cSrcweir                     SdrObject *pCandidate = pPage->GetObj(a);
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir                     if (pCandidate->ISA(SwVirtFlyDrawObj) &&
1238cdf0e10cSrcweir                        ( (SwVirtFlyDrawObj*)pCandidate)->GetCurrentBoundRect().IsInside(rPt) )
1239cdf0e10cSrcweir                     {
1240cdf0e10cSrcweir                         bRet = sal_False;
1241cdf0e10cSrcweir                     }
1242cdf0e10cSrcweir                 }
1243cdf0e10cSrcweir             }
1244cdf0e10cSrcweir 		}
1245cdf0e10cSrcweir 	}
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 	return bRet;
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir /*************************************************************************
1251cdf0e10cSrcweir |*
1252cdf0e10cSrcweir |*	SwFEShell::GotoObj()
1253cdf0e10cSrcweir |*
1254cdf0e10cSrcweir |* 	Beschreibung		Wenn ein Obj selektiert ist, gehen wir von dessen
1255cdf0e10cSrcweir |* 		TopLeft aus, andernfalls von der Mitte des aktuellen CharRects.
1256cdf0e10cSrcweir |*
1257cdf0e10cSrcweir *************************************************************************/
1258cdf0e10cSrcweir /* ------------------------------------
1259cdf0e10cSrcweir  * Beinhaltet das Objekt ein Control oder Gruppen,
1260cdf0e10cSrcweir  * die nur aus Controls bestehen
1261cdf0e10cSrcweir  * --------------------------------------------------*/
lcl_IsControlGroup(const SdrObject * pObj)1262cdf0e10cSrcweir sal_Bool lcl_IsControlGroup( const SdrObject *pObj )
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1265cdf0e10cSrcweir 	if(pObj->ISA(SdrUnoObj))
1266cdf0e10cSrcweir 		bRet = sal_True;
1267cdf0e10cSrcweir 	else if( pObj->ISA( SdrObjGroup ) )
1268cdf0e10cSrcweir 	{
1269cdf0e10cSrcweir 		bRet = sal_True;
1270cdf0e10cSrcweir 		const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
1271cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < pLst->GetObjCount(); ++i )
1272cdf0e10cSrcweir 			if( !::lcl_IsControlGroup( pLst->GetObj( i ) ) )
1273cdf0e10cSrcweir 				return sal_False;
1274cdf0e10cSrcweir 	}
1275cdf0e10cSrcweir 	return bRet;
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir namespace
1279cdf0e10cSrcweir {
1280cdf0e10cSrcweir     class MarkableObjectsOnly : public ::svx::ISdrObjectFilter
1281cdf0e10cSrcweir     {
1282cdf0e10cSrcweir     public:
MarkableObjectsOnly(SdrPageView * i_pPV)1283cdf0e10cSrcweir         MarkableObjectsOnly( SdrPageView* i_pPV )
1284cdf0e10cSrcweir             :m_pPV( i_pPV )
1285cdf0e10cSrcweir         {
1286cdf0e10cSrcweir         }
1287cdf0e10cSrcweir 
includeObject(const SdrObject & i_rObject) const1288cdf0e10cSrcweir         virtual bool    includeObject( const SdrObject& i_rObject ) const
1289cdf0e10cSrcweir         {
1290cdf0e10cSrcweir             return m_pPV && m_pPV->GetView().IsObjMarkable( const_cast< SdrObject* >( &i_rObject ), m_pPV );
1291cdf0e10cSrcweir         }
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir     private:
1294cdf0e10cSrcweir         SdrPageView*    m_pPV;
1295cdf0e10cSrcweir     };
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir 
GetBestObject(sal_Bool bNext,sal_uInt16 eType,sal_Bool bFlat,const::svx::ISdrObjectFilter * pFilter)1298cdf0e10cSrcweir const SdrObject* SwFEShell::GetBestObject( sal_Bool bNext, sal_uInt16 /*GOTOOBJ_...*/ eType, sal_Bool bFlat, const ::svx::ISdrObjectFilter* pFilter )
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir 	if( !Imp()->HasDrawView() )
1301cdf0e10cSrcweir 		return NULL;
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir 	const SdrObject	*pBest	= 0,
1304cdf0e10cSrcweir 					*pTop	= 0;
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir 	const long nTmp = bNext ? LONG_MAX : 0;
1307cdf0e10cSrcweir 	Point aBestPos( nTmp, nTmp );
1308cdf0e10cSrcweir 	Point aTopPos(	nTmp, nTmp );
1309cdf0e10cSrcweir 	Point aCurPos;
1310cdf0e10cSrcweir 	Point aPos;
1311cdf0e10cSrcweir     sal_Bool bNoDraw = 0 == (GOTOOBJ_DRAW_ANY & eType);
1312cdf0e10cSrcweir     sal_Bool bNoFly = 0 == (GOTOOBJ_FLY_ANY & eType);
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir     if( !bNoFly && bNoDraw )
1315cdf0e10cSrcweir     {
1316cdf0e10cSrcweir         SwFlyFrm *pFly = GetCurrFrm( sal_False )->FindFlyFrm();
1317cdf0e10cSrcweir         if( pFly )
1318cdf0e10cSrcweir             pBest = pFly->GetVirtDrawObj();
1319cdf0e10cSrcweir     }
1320cdf0e10cSrcweir 	const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1321cdf0e10cSrcweir     SdrPageView* pPV = Imp()->GetDrawView()->GetSdrPageView();
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir     MarkableObjectsOnly aDefaultFilter( pPV );
1324cdf0e10cSrcweir     if ( !pFilter )
1325cdf0e10cSrcweir         pFilter = &aDefaultFilter;
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir     if( !pBest || rMrkList.GetMarkCount() == 1 )
1328cdf0e10cSrcweir     {
1329cdf0e10cSrcweir         // Ausgangspunkt bestimmen.
1330cdf0e10cSrcweir         SdrObjList* pList = NULL;
1331cdf0e10cSrcweir         if ( rMrkList.GetMarkCount() )
1332cdf0e10cSrcweir         {
1333cdf0e10cSrcweir             const SdrObject* pStartObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
1334cdf0e10cSrcweir             if( pStartObj->ISA(SwVirtFlyDrawObj) )
1335cdf0e10cSrcweir                 aPos = ((SwVirtFlyDrawObj*)pStartObj)->GetFlyFrm()->Frm().Pos();
1336cdf0e10cSrcweir             else
1337cdf0e10cSrcweir                 aPos = pStartObj->GetSnapRect().TopLeft();
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir             // If an object inside a group is selected, we want to
1340cdf0e10cSrcweir             // iterate over the group members.
1341cdf0e10cSrcweir             if ( ! pStartObj->GetUserCall() )
1342cdf0e10cSrcweir                 pList = pStartObj->GetObjList();
1343cdf0e10cSrcweir         }
1344cdf0e10cSrcweir         else
1345cdf0e10cSrcweir         {
1346cdf0e10cSrcweir             // If no object is selected, we check if we just entered a group.
1347cdf0e10cSrcweir             // In this case we want to iterate over the group members.
1348cdf0e10cSrcweir             aPos = GetCharRect().Center();
1349cdf0e10cSrcweir             const SdrObject* pStartObj = pPV ? pPV->GetAktGroup() : 0;
1350cdf0e10cSrcweir             if ( pStartObj && pStartObj->ISA( SdrObjGroup ) )
1351cdf0e10cSrcweir                 pList = pStartObj->GetSubList();
1352cdf0e10cSrcweir         }
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir         if ( ! pList )
1355cdf0e10cSrcweir         {
1356cdf0e10cSrcweir             // Here we are if
1357cdf0e10cSrcweir             // A  No object has been selected and no group has been entered or
1358cdf0e10cSrcweir             // B  An object has been selected and it is not inside a group
1359cdf0e10cSrcweir             pList = getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 );
1360cdf0e10cSrcweir         }
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir         ASSERT( pList, "No object list to iterate" )
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir         SdrObjListIter aObjIter( *pList, bFlat ? IM_FLAT : IM_DEEPNOGROUPS );
1366cdf0e10cSrcweir         while ( aObjIter.IsMore() )
1367cdf0e10cSrcweir         {
1368cdf0e10cSrcweir             SdrObject* pObj = aObjIter.Next();
1369cdf0e10cSrcweir             sal_Bool bFlyFrm = pObj->ISA(SwVirtFlyDrawObj);
1370cdf0e10cSrcweir             if( ( bNoFly && bFlyFrm ) ||
1371cdf0e10cSrcweir                 ( bNoDraw && !bFlyFrm ) ||
1372cdf0e10cSrcweir                 ( eType == GOTOOBJ_DRAW_SIMPLE && lcl_IsControlGroup( pObj ) ) ||
1373cdf0e10cSrcweir                 ( eType == GOTOOBJ_DRAW_CONTROL && !lcl_IsControlGroup( pObj ) ) ||
1374cdf0e10cSrcweir                 ( pFilter && !pFilter->includeObject( *pObj ) ) )
1375cdf0e10cSrcweir                 continue;
1376cdf0e10cSrcweir             if( bFlyFrm )
1377cdf0e10cSrcweir             {
1378cdf0e10cSrcweir                 SwVirtFlyDrawObj *pO = (SwVirtFlyDrawObj*)pObj;
1379cdf0e10cSrcweir                 SwFlyFrm *pFly = pO->GetFlyFrm();
1380cdf0e10cSrcweir                 if( GOTOOBJ_FLY_ANY != ( GOTOOBJ_FLY_ANY & eType ) )
1381cdf0e10cSrcweir                 {
1382cdf0e10cSrcweir                     switch ( eType )
1383cdf0e10cSrcweir                     {
1384cdf0e10cSrcweir                         case GOTOOBJ_FLY_FRM:
1385cdf0e10cSrcweir                             if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
1386cdf0e10cSrcweir                                 continue;
1387cdf0e10cSrcweir                         break;
1388cdf0e10cSrcweir                         case GOTOOBJ_FLY_GRF:
1389cdf0e10cSrcweir                             if ( pFly->Lower() &&
1390cdf0e10cSrcweir                                 (pFly->Lower()->IsLayoutFrm() ||
1391cdf0e10cSrcweir                                 !((SwCntntFrm*)pFly->Lower())->GetNode()->GetGrfNode()))
1392cdf0e10cSrcweir                                 continue;
1393cdf0e10cSrcweir                         break;
1394cdf0e10cSrcweir                         case GOTOOBJ_FLY_OLE:
1395cdf0e10cSrcweir                             if ( pFly->Lower() &&
1396cdf0e10cSrcweir                                 (pFly->Lower()->IsLayoutFrm() ||
1397cdf0e10cSrcweir                                 !((SwCntntFrm*)pFly->Lower())->GetNode()->GetOLENode()))
1398cdf0e10cSrcweir                                 continue;
1399cdf0e10cSrcweir                         break;
1400cdf0e10cSrcweir                     }
1401cdf0e10cSrcweir                 }
1402cdf0e10cSrcweir                 aCurPos = pFly->Frm().Pos();
1403cdf0e10cSrcweir             }
1404cdf0e10cSrcweir             else
1405cdf0e10cSrcweir                 aCurPos = pObj->GetCurrentBoundRect().TopLeft();
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir             // Sonderfall wenn ein anderes Obj auf selber Y steht.
1408cdf0e10cSrcweir             if( aCurPos != aPos &&          // nur wenn ich es nicht selber bin
1409cdf0e10cSrcweir                 aCurPos.Y() == aPos.Y() &&  // ist die Y Position gleich
1410cdf0e10cSrcweir                 (bNext? (aCurPos.X() > aPos.X()) :  // liegt neben mir
1411cdf0e10cSrcweir                         (aCurPos.X() < aPos.X())) ) // " reverse
1412cdf0e10cSrcweir             {
1413cdf0e10cSrcweir                 aBestPos = Point( nTmp, nTmp );
1414cdf0e10cSrcweir                 SdrObjListIter aTmpIter( *pList, bFlat ? IM_FLAT : IM_DEEPNOGROUPS );
1415cdf0e10cSrcweir                 while ( aTmpIter.IsMore() )
1416cdf0e10cSrcweir                 {
1417cdf0e10cSrcweir                     SdrObject* pTmpObj = aTmpIter.Next();
1418cdf0e10cSrcweir                     bFlyFrm = pTmpObj->ISA(SwVirtFlyDrawObj);
1419cdf0e10cSrcweir                     if( ( bNoFly && bFlyFrm ) || ( bNoDraw && !bFlyFrm ) )
1420cdf0e10cSrcweir                         continue;
1421cdf0e10cSrcweir                     if( bFlyFrm )
1422cdf0e10cSrcweir                     {
1423cdf0e10cSrcweir                         SwVirtFlyDrawObj *pO = (SwVirtFlyDrawObj*)pTmpObj;
1424cdf0e10cSrcweir                         aCurPos = pO->GetFlyFrm()->Frm().Pos();
1425cdf0e10cSrcweir                     }
1426cdf0e10cSrcweir                     else
1427cdf0e10cSrcweir                         aCurPos = pTmpObj->GetCurrentBoundRect().TopLeft();
1428cdf0e10cSrcweir 
1429cdf0e10cSrcweir                     if( aCurPos != aPos && aCurPos.Y() == aPos.Y() &&
1430cdf0e10cSrcweir                         (bNext? (aCurPos.X() > aPos.X()) :  // liegt neben mir
1431cdf0e10cSrcweir                                 (aCurPos.X() < aPos.X())) &&    // " reverse
1432cdf0e10cSrcweir                         (bNext? (aCurPos.X() < aBestPos.X()) :  // besser als Beste
1433cdf0e10cSrcweir                                 (aCurPos.X() > aBestPos.X())) ) // " reverse
1434cdf0e10cSrcweir                     {
1435cdf0e10cSrcweir                         aBestPos = aCurPos;
1436cdf0e10cSrcweir                         pBest = pTmpObj;
1437cdf0e10cSrcweir                     }
1438cdf0e10cSrcweir                 }
1439cdf0e10cSrcweir                 break;
1440cdf0e10cSrcweir             }
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir             if( (
1443cdf0e10cSrcweir                 (bNext? (aPos.Y() < aCurPos.Y()) :          // nur unter mir
1444cdf0e10cSrcweir                         (aPos.Y() > aCurPos.Y())) &&        // " reverse
1445cdf0e10cSrcweir                 (bNext? (aBestPos.Y() > aCurPos.Y()) :      // naeher drunter
1446cdf0e10cSrcweir                         (aBestPos.Y() < aCurPos.Y()))
1447cdf0e10cSrcweir                     ) ||    // " reverse
1448cdf0e10cSrcweir                         (aBestPos.Y() == aCurPos.Y() &&
1449cdf0e10cSrcweir                 (bNext? (aBestPos.X() > aCurPos.X()) :      // weiter links
1450cdf0e10cSrcweir                         (aBestPos.X() < aCurPos.X()))))     // " reverse
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir             {
1453cdf0e10cSrcweir                 aBestPos = aCurPos;
1454cdf0e10cSrcweir                 pBest = pObj;
1455cdf0e10cSrcweir             }
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir             if( (bNext? (aTopPos.Y() > aCurPos.Y()) :       // hoeher als Beste
1458cdf0e10cSrcweir                         (aTopPos.Y() < aCurPos.Y())) ||     // " reverse
1459cdf0e10cSrcweir                         (aTopPos.Y() == aCurPos.Y() &&
1460cdf0e10cSrcweir                 (bNext? (aTopPos.X() > aCurPos.X()) :       // weiter links
1461cdf0e10cSrcweir                         (aTopPos.X() < aCurPos.X()))))      // " reverse
1462cdf0e10cSrcweir             {
1463cdf0e10cSrcweir                 aTopPos = aCurPos;
1464cdf0e10cSrcweir                 pTop = pObj;
1465cdf0e10cSrcweir             }
1466cdf0e10cSrcweir         }
1467cdf0e10cSrcweir         // leider nichts gefunden
1468cdf0e10cSrcweir         if( (bNext? (aBestPos.X() == LONG_MAX) : (aBestPos.X() == 0)) )
1469cdf0e10cSrcweir             pBest = pTop;
1470cdf0e10cSrcweir     }
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir     return pBest;
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir 
GotoObj(sal_Bool bNext,sal_uInt16 eType)1475cdf0e10cSrcweir sal_Bool SwFEShell::GotoObj( sal_Bool bNext, sal_uInt16 /*GOTOOBJ_...*/ eType )
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir     const SdrObject* pBest = GetBestObject( bNext, eType );
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir 	if ( !pBest )
1480cdf0e10cSrcweir         return sal_False;
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir     sal_Bool bFlyFrm = pBest->ISA(SwVirtFlyDrawObj);
1483cdf0e10cSrcweir     if( bFlyFrm )
1484cdf0e10cSrcweir     {
1485cdf0e10cSrcweir         SwVirtFlyDrawObj *pO = (SwVirtFlyDrawObj*)pBest;
1486cdf0e10cSrcweir         const SwRect& rFrm = pO->GetFlyFrm()->Frm();
1487cdf0e10cSrcweir         SelectObj( rFrm.Pos(), 0, (SdrObject*)pBest );
1488cdf0e10cSrcweir         if( !ActionPend() )
1489cdf0e10cSrcweir             MakeVisible( rFrm );
1490cdf0e10cSrcweir     }
1491cdf0e10cSrcweir     else
1492cdf0e10cSrcweir     {
1493cdf0e10cSrcweir         SelectObj( Point(), 0, (SdrObject*)pBest );
1494cdf0e10cSrcweir         if( !ActionPend() )
1495cdf0e10cSrcweir             MakeVisible( pBest->GetCurrentBoundRect() );
1496cdf0e10cSrcweir     }
1497cdf0e10cSrcweir 	CallChgLnk();
1498cdf0e10cSrcweir     return sal_True;
1499cdf0e10cSrcweir }
1500cdf0e10cSrcweir 
1501cdf0e10cSrcweir /*************************************************************************
1502cdf0e10cSrcweir |*
1503cdf0e10cSrcweir |*	SwFEShell::BeginCreate()
1504cdf0e10cSrcweir |*
1505cdf0e10cSrcweir *************************************************************************/
1506cdf0e10cSrcweir 
BeginCreate(sal_uInt16 eSdrObjectKind,const Point & rPos)1507cdf0e10cSrcweir sal_Bool SwFEShell::BeginCreate( sal_uInt16 /*SdrObjKind ?*/  eSdrObjectKind, const Point &rPos )
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir 	if ( !Imp()->HasDrawView() )
1512cdf0e10cSrcweir 		Imp()->MakeDrawView();
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir 	if ( GetPageNumber( rPos ) )
1515cdf0e10cSrcweir 	{
1516cdf0e10cSrcweir 		Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind );
1517cdf0e10cSrcweir 		if ( eSdrObjectKind == OBJ_CAPTION )
1518cdf0e10cSrcweir 			bRet = Imp()->GetDrawView()->BegCreateCaptionObj(
1519cdf0e10cSrcweir 						rPos, Size( lMinBorder - MINFLY, lMinBorder - MINFLY ),
1520cdf0e10cSrcweir 						GetOut() );
1521cdf0e10cSrcweir 		else
1522cdf0e10cSrcweir 			bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1523cdf0e10cSrcweir 	}
1524cdf0e10cSrcweir 	if ( bRet )
1525cdf0e10cSrcweir     {
1526cdf0e10cSrcweir         ::FrameNotify( this, FLY_DRAG_START );
1527cdf0e10cSrcweir     }
1528cdf0e10cSrcweir 	return bRet;
1529cdf0e10cSrcweir }
1530cdf0e10cSrcweir 
BeginCreate(sal_uInt16 eSdrObjectKind,sal_uInt32 eObjInventor,const Point & rPos)1531cdf0e10cSrcweir sal_Bool SwFEShell::BeginCreate( sal_uInt16 /*SdrObjKind ?*/  eSdrObjectKind, sal_uInt32 eObjInventor,
1532cdf0e10cSrcweir 							 const Point &rPos )
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir 	if ( !Imp()->HasDrawView() )
1537cdf0e10cSrcweir 		Imp()->MakeDrawView();
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir 	if ( GetPageNumber( rPos ) )
1540cdf0e10cSrcweir 	{
1541cdf0e10cSrcweir 		Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind, eObjInventor );
1542cdf0e10cSrcweir 		bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1543cdf0e10cSrcweir 	}
1544cdf0e10cSrcweir 	if ( bRet )
1545cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG_START );
1546cdf0e10cSrcweir 	return bRet;
1547cdf0e10cSrcweir }
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir /*************************************************************************
1550cdf0e10cSrcweir |*
1551cdf0e10cSrcweir |*	SwFEShell::MoveCreate()
1552cdf0e10cSrcweir |*
1553cdf0e10cSrcweir *************************************************************************/
1554cdf0e10cSrcweir 
MoveCreate(const Point & rPos)1555cdf0e10cSrcweir void SwFEShell::MoveCreate( const Point &rPos )
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "MoveCreate without DrawView?" );
1558cdf0e10cSrcweir 	if ( GetPageNumber( rPos ) )
1559cdf0e10cSrcweir 	{
1560cdf0e10cSrcweir 		ScrollTo( rPos );
1561cdf0e10cSrcweir 		Imp()->GetDrawView()->MovCreateObj( rPos );
1562cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG );
1563cdf0e10cSrcweir 	}
1564cdf0e10cSrcweir }
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir /*************************************************************************
1567cdf0e10cSrcweir |*
1568cdf0e10cSrcweir |*	SwFEShell::EndCreate(), ImpEndCreate()
1569cdf0e10cSrcweir |*
1570cdf0e10cSrcweir *************************************************************************/
1571cdf0e10cSrcweir 
EndCreate(sal_uInt16 eSdrCreateCmd)1572cdf0e10cSrcweir sal_Bool SwFEShell::EndCreate( sal_uInt16 eSdrCreateCmd )
1573cdf0e10cSrcweir {
1574cdf0e10cSrcweir 	// Damit das Undo-Object aus der DrawEngine nicht bei uns
1575cdf0e10cSrcweir 	// gespeichert wird, (wir erzeugen ein eigenes Undo-Object!) hier kurz
1576cdf0e10cSrcweir 	// das Undo abschalten
1577cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "EndCreate without DrawView?" );
1578cdf0e10cSrcweir 	if( !Imp()->GetDrawView()->IsGroupEntered() )
1579cdf0e10cSrcweir     {
1580cdf0e10cSrcweir         GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
1581cdf0e10cSrcweir     }
1582cdf0e10cSrcweir 	sal_Bool bCreate = Imp()->GetDrawView()->EndCreateObj(
1583cdf0e10cSrcweir 									SdrCreateCmd( eSdrCreateCmd ) );
1584cdf0e10cSrcweir     GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir 	if ( !bCreate )
1587cdf0e10cSrcweir 	{
1588cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG_END );
1589cdf0e10cSrcweir 		return sal_False;
1590cdf0e10cSrcweir 	}
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir 	if ( (SdrCreateCmd)eSdrCreateCmd == SDRCREATE_NEXTPOINT )
1593cdf0e10cSrcweir 	{
1594cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG );
1595cdf0e10cSrcweir 		return sal_True;
1596cdf0e10cSrcweir 	}
1597cdf0e10cSrcweir 	return ImpEndCreate();
1598cdf0e10cSrcweir }
1599cdf0e10cSrcweir 
1600cdf0e10cSrcweir 
ImpEndCreate()1601cdf0e10cSrcweir sal_Bool SwFEShell::ImpEndCreate()
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir 	ASSERT( Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1,
1604cdf0e10cSrcweir 			"Neues Object nicht selektiert." );
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir 	SdrObject& rSdrObj = *Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir 	if( rSdrObj.GetSnapRect().IsEmpty() )
1609cdf0e10cSrcweir 	{
1610cdf0e10cSrcweir 		// das Object vergessen wir lieber, fuerht nur
1611cdf0e10cSrcweir 		//				zu Problemen
1612cdf0e10cSrcweir 		Imp()->GetDrawView()->DeleteMarked();
1613cdf0e10cSrcweir 		Imp()->GetDrawView()->UnmarkAll();
1614cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG_END );
1615cdf0e10cSrcweir 		return sal_False;
1616cdf0e10cSrcweir 	}
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir 	if( rSdrObj.GetUpGroup() )
1619cdf0e10cSrcweir 	{
1620cdf0e10cSrcweir         Point aTmpPos( rSdrObj.GetSnapRect().TopLeft() );
1621cdf0e10cSrcweir         Point aNewAnchor( rSdrObj.GetUpGroup()->GetAnchorPos() );
1622cdf0e10cSrcweir         // OD 2004-04-05 #i26791# - direct object positioning for group members
1623cdf0e10cSrcweir         rSdrObj.NbcSetRelativePos( aTmpPos - aNewAnchor );
1624cdf0e10cSrcweir         rSdrObj.NbcSetAnchorPos( aNewAnchor );
1625cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG );
1626cdf0e10cSrcweir 		return sal_True;
1627cdf0e10cSrcweir 	}
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir 	LockPaint();
1630cdf0e10cSrcweir 	StartAllAction();
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir 	Imp()->GetDrawView()->UnmarkAll();
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir     const Rectangle &rBound = rSdrObj.GetSnapRect();
1635cdf0e10cSrcweir     Point aPt( rBound.TopRight() );
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir 	//Fremde Identifier sollen in den Default laufen.
1638cdf0e10cSrcweir 	//Ueberschneidungen sind moeglich!!
1639cdf0e10cSrcweir 	sal_uInt16 nIdent = SdrInventor == rSdrObj.GetObjInventor()
1640cdf0e10cSrcweir 						? rSdrObj.GetObjIdentifier()
1641cdf0e10cSrcweir 						: 0xFFFF;
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir 	//Default fuer Controls ist Zeichengebunden, Absatzgebunden sonst.
1644cdf0e10cSrcweir 	SwFmtAnchor aAnch;
1645cdf0e10cSrcweir 	const SwFrm *pAnch = 0;
1646cdf0e10cSrcweir 	sal_Bool bCharBound = sal_False;
1647cdf0e10cSrcweir 	if( rSdrObj.ISA( SdrUnoObj ) )
1648cdf0e10cSrcweir 	{
1649cdf0e10cSrcweir 		SwPosition aPos( GetDoc()->GetNodes() );
1650cdf0e10cSrcweir 		SwCrsrMoveState aState( MV_SETONLYTEXT );
1651cdf0e10cSrcweir 		Point aPoint( aPt.X(), aPt.Y() + rBound.GetHeight()/2 );
1652cdf0e10cSrcweir         GetLayout()->GetCrsrOfst( &aPos, aPoint, &aState );	//swmod 080317
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir 		//Zeichenbindung ist im ReadnOnly-Inhalt nicht erlaubt
1655cdf0e10cSrcweir 		if( !aPos.nNode.GetNode().IsProtect() )
1656cdf0e10cSrcweir 		{
1657cdf0e10cSrcweir 			pAnch = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(), &aPoint, &aPos );
1658cdf0e10cSrcweir 			SwRect aTmp;
1659cdf0e10cSrcweir 			pAnch->GetCharRect( aTmp, aPos );
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir 			//Der Crsr darf nicht zu weit entfernt sein.
1662cdf0e10cSrcweir 			bCharBound = sal_True;
1663cdf0e10cSrcweir 			Rectangle aRect( aTmp.SVRect() );
1664cdf0e10cSrcweir 			aRect.Left()  -= MM50*2;
1665cdf0e10cSrcweir 			aRect.Top()   -= MM50*2;
1666cdf0e10cSrcweir 			aRect.Right() += MM50*2;
1667cdf0e10cSrcweir 			aRect.Bottom()+= MM50*2;
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir 			if( !aRect.IsOver( rBound ) && !::GetHtmlMode( GetDoc()->GetDocShell() ))
1670cdf0e10cSrcweir 				bCharBound = sal_False;
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir 				//Bindung in Kopf-/Fusszeilen ist ebenfalls nicht erlaubt.
1673cdf0e10cSrcweir 			if( bCharBound )
1674cdf0e10cSrcweir 				bCharBound = !GetDoc()->IsInHeaderFooter( aPos.nNode );
1675cdf0e10cSrcweir 
1676cdf0e10cSrcweir 			if( bCharBound )
1677cdf0e10cSrcweir 			{
1678cdf0e10cSrcweir                 aAnch.SetType( FLY_AS_CHAR );
1679cdf0e10cSrcweir 				aAnch.SetAnchor( &aPos );
1680cdf0e10cSrcweir 			}
1681cdf0e10cSrcweir 		}
1682cdf0e10cSrcweir 	}
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir 	if( !bCharBound )
1685cdf0e10cSrcweir 	{
1686cdf0e10cSrcweir         // OD 16.05.2003 #108784# - allow native drawing objects in header/footer.
1687cdf0e10cSrcweir         // Thus, set <bBodyOnly> to <false> for these objects using value
1688cdf0e10cSrcweir         // of <nIdent> - value <0xFFFF> indicates control objects, which aren't
1689cdf0e10cSrcweir         // allowed in header/footer.
1690cdf0e10cSrcweir         //bool bBodyOnly = OBJ_NONE != nIdent;
1691cdf0e10cSrcweir         bool bBodyOnly = 0xFFFF == nIdent;
1692cdf0e10cSrcweir         bool bAtPage = false;
1693cdf0e10cSrcweir         const SwFrm* pPage = 0;
1694cdf0e10cSrcweir 		SwCrsrMoveState aState( MV_SETONLYTEXT );
1695cdf0e10cSrcweir 		Point aPoint( aPt );
1696cdf0e10cSrcweir 		SwPosition aPos( GetDoc()->GetNodes() );
1697cdf0e10cSrcweir 		GetLayout()->GetCrsrOfst( &aPos, aPoint, &aState );
1698cdf0e10cSrcweir 
1699cdf0e10cSrcweir 		//nicht in ReadnOnly-Inhalt setzen
1700cdf0e10cSrcweir 		if( aPos.nNode.GetNode().IsProtect() )
1701cdf0e10cSrcweir 			// dann darf er nur seitengebunden sein. Oder sollte man
1702cdf0e10cSrcweir 			// die naechste nicht READONLY Position suchen?
1703cdf0e10cSrcweir             bAtPage = true;
1704cdf0e10cSrcweir 
1705cdf0e10cSrcweir 		pAnch = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(), &aPoint, 0, sal_False );
1706cdf0e10cSrcweir 
1707cdf0e10cSrcweir 		if( !bAtPage )
1708cdf0e10cSrcweir 		{
1709cdf0e10cSrcweir 			const SwFlyFrm *pTmp = pAnch->FindFlyFrm();
1710cdf0e10cSrcweir 			if( pTmp )
1711cdf0e10cSrcweir 			{
1712cdf0e10cSrcweir 				const SwFrm* pTmpFrm = pAnch;
1713cdf0e10cSrcweir 				SwRect aBound( rBound );
1714cdf0e10cSrcweir 				while( pTmp )
1715cdf0e10cSrcweir 				{
1716cdf0e10cSrcweir 					if( pTmp->Frm().IsInside( aBound ) )
1717cdf0e10cSrcweir 					{
1718cdf0e10cSrcweir 						if( !bBodyOnly || !pTmp->FindFooterOrHeader() )
1719cdf0e10cSrcweir 							pPage = pTmpFrm;
1720cdf0e10cSrcweir 						break;
1721cdf0e10cSrcweir 					}
1722cdf0e10cSrcweir                     pTmp = pTmp->GetAnchorFrm()
1723cdf0e10cSrcweir                                 ? pTmp->GetAnchorFrm()->FindFlyFrm()
1724cdf0e10cSrcweir 								: 0;
1725cdf0e10cSrcweir 					pTmpFrm = pTmp;
1726cdf0e10cSrcweir 				}
1727cdf0e10cSrcweir 			}
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir 			if( !pPage )
1730cdf0e10cSrcweir 				pPage = pAnch->FindPageFrm();
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir 			// immer ueber FindAnchor gehen, damit der Frame immer an den
1733cdf0e10cSrcweir 			// davorgehen gebunden wird. Beim GetCrsOfst kann man auch zum
1734cdf0e10cSrcweir 			// nachfolgenden kommen. DAS IST FALSCH
1735cdf0e10cSrcweir             pAnch = ::FindAnchor( pPage, aPt, bBodyOnly );
1736cdf0e10cSrcweir 			aPos.nNode = *((SwCntntFrm*)pAnch)->GetNode();
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir 			//nicht in ReadnOnly-Inhalt setzen
1739cdf0e10cSrcweir 			if( aPos.nNode.GetNode().IsProtect() )
1740cdf0e10cSrcweir 				// dann darf er nur seitengebunden sein. Oder sollte man
1741cdf0e10cSrcweir 				// die naechste nicht READONLY Position suchen?
1742cdf0e10cSrcweir                 bAtPage = true;
1743cdf0e10cSrcweir 			else
1744cdf0e10cSrcweir 			{
1745cdf0e10cSrcweir                 aAnch.SetType( FLY_AT_PARA );
1746cdf0e10cSrcweir 				aAnch.SetAnchor( &aPos );
1747cdf0e10cSrcweir 			}
1748cdf0e10cSrcweir 		}
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir 		if( bAtPage )
1751cdf0e10cSrcweir 		{
1752cdf0e10cSrcweir 			pPage = pAnch->FindPageFrm();
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir             aAnch.SetType( FLY_AT_PAGE );
1755cdf0e10cSrcweir 			aAnch.SetPageNum( pPage->GetPhyPageNum() );
1756cdf0e10cSrcweir 			pAnch = pPage;		// die Page wird jetzt zum Anker
1757cdf0e10cSrcweir 		}
1758cdf0e10cSrcweir 	}
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir 	SfxItemSet aSet( GetDoc()->GetAttrPool(), RES_FRM_SIZE, RES_FRM_SIZE,
1761cdf0e10cSrcweir 											RES_SURROUND, RES_ANCHOR, 0 );
1762cdf0e10cSrcweir 	aSet.Put( aAnch );
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir     // OD 2004-03-30 #i26791# - determine relative object position
1765cdf0e10cSrcweir     SwTwips nXOffset;
1766cdf0e10cSrcweir     SwTwips nYOffset = rBound.Top() - pAnch->Frm().Top();
1767cdf0e10cSrcweir     {
1768cdf0e10cSrcweir         if( pAnch->IsVertical() )
1769cdf0e10cSrcweir         {
1770cdf0e10cSrcweir             nXOffset = nYOffset;
1771cdf0e10cSrcweir             nYOffset = pAnch->Frm().Left()+pAnch->Frm().Width()-rBound.Right();
1772cdf0e10cSrcweir         }
1773cdf0e10cSrcweir         else if( pAnch->IsRightToLeft() )
1774cdf0e10cSrcweir             nXOffset = pAnch->Frm().Left()+pAnch->Frm().Width()-rBound.Right();
1775cdf0e10cSrcweir         else
1776cdf0e10cSrcweir             nXOffset = rBound.Left() - pAnch->Frm().Left();
1777cdf0e10cSrcweir         if( pAnch->IsTxtFrm() && ((SwTxtFrm*)pAnch)->IsFollow() )
1778cdf0e10cSrcweir         {
1779cdf0e10cSrcweir             SwTxtFrm* pTmp = (SwTxtFrm*)pAnch;
1780cdf0e10cSrcweir             do {
1781cdf0e10cSrcweir                 pTmp = pTmp->FindMaster();
1782cdf0e10cSrcweir                 ASSERT( pTmp, "Where's my Master?" );
1783cdf0e10cSrcweir                 // OD 2004-03-30 #i26791# - correction: add frame area height
1784cdf0e10cSrcweir                 // of master frames.
1785cdf0e10cSrcweir                 nYOffset += pTmp->IsVertical() ?
1786cdf0e10cSrcweir                             pTmp->Frm().Width() : pTmp->Frm().Height();
1787cdf0e10cSrcweir             } while ( pTmp->IsFollow() );
1788cdf0e10cSrcweir         }
1789cdf0e10cSrcweir     }
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir 	if( OBJ_NONE == nIdent )
1792cdf0e10cSrcweir 	{
1793cdf0e10cSrcweir 		//Bei OBJ_NONE wird ein Fly eingefuegt.
1794cdf0e10cSrcweir 		const long nWidth = rBound.Right()	- rBound.Left();
1795cdf0e10cSrcweir 		const long nHeight=	rBound.Bottom() - rBound.Top();
1796cdf0e10cSrcweir 		aSet.Put( SwFmtFrmSize( ATT_MIN_SIZE, Max( nWidth,	long(MINFLY) ),
1797cdf0e10cSrcweir 											  Max( nHeight, long(MINFLY) )));
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir         SwFmtHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
1800cdf0e10cSrcweir         SwFmtVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
1801cdf0e10cSrcweir 		aSet.Put( SwFmtSurround( SURROUND_PARALLEL ) );
1802cdf0e10cSrcweir 		aSet.Put( aHori );
1803cdf0e10cSrcweir 		aSet.Put( aVert );
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir 		//Schnell noch das Rechteck merken
1806cdf0e10cSrcweir 		const SwRect aFlyRect( rBound );
1807cdf0e10cSrcweir 
1808cdf0e10cSrcweir 		//Erzeugtes Object wegwerfen, so kann der Fly am elegentesten
1809cdf0e10cSrcweir 		//ueber vorhandene SS erzeugt werden.
1810cdf0e10cSrcweir         GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); // see above
1811cdf0e10cSrcweir         // --> OD 2005-08-08 #i52858# - method name changed
1812cdf0e10cSrcweir         SdrPage *pPg = getIDocumentDrawModelAccess()->GetOrCreateDrawModel()->GetPage( 0 );
1813cdf0e10cSrcweir         // <--
1814cdf0e10cSrcweir 		if( !pPg )
1815cdf0e10cSrcweir 		{
1816cdf0e10cSrcweir             SdrModel* pTmpSdrModel = getIDocumentDrawModelAccess()->GetDrawModel();
1817cdf0e10cSrcweir             pPg = pTmpSdrModel->AllocPage( sal_False );
1818cdf0e10cSrcweir             pTmpSdrModel->InsertPage( pPg );
1819cdf0e10cSrcweir 		}
1820cdf0e10cSrcweir 		pPg->RecalcObjOrdNums();
1821cdf0e10cSrcweir         SdrObject* pRemovedObject = pPg->RemoveObject( rSdrObj.GetOrdNumDirect() );
1822cdf0e10cSrcweir         SdrObject::Free( pRemovedObject );
1823cdf0e10cSrcweir         GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir 		SwFlyFrm* pFlyFrm;
1826cdf0e10cSrcweir 		if( NewFlyFrm( aSet, sal_True ) &&
1827cdf0e10cSrcweir 			::GetHtmlMode( GetDoc()->GetDocShell() ) &&
1828cdf0e10cSrcweir 			0 != ( pFlyFrm = FindFlyFrm() ))
1829cdf0e10cSrcweir 		{
1830cdf0e10cSrcweir 			SfxItemSet aHtmlSet( GetDoc()->GetAttrPool(), RES_VERT_ORIENT, RES_HORI_ORIENT );
1831cdf0e10cSrcweir 			//Horizontale Ausrichtung:
1832cdf0e10cSrcweir 			const sal_Bool bLeftFrm = aFlyRect.Left() <
1833cdf0e10cSrcweir 									  pAnch->Frm().Left() + pAnch->Prt().Left(),
1834cdf0e10cSrcweir 						   bLeftPrt = aFlyRect.Left() + aFlyRect.Width() <
1835cdf0e10cSrcweir 									  pAnch->Frm().Left() + pAnch->Prt().Width()/2;
1836cdf0e10cSrcweir 			if( bLeftFrm || bLeftPrt )
1837cdf0e10cSrcweir 			{
1838cdf0e10cSrcweir                 aHori.SetHoriOrient( text::HoriOrientation::LEFT );
1839cdf0e10cSrcweir                 aHori.SetRelationOrient( bLeftFrm ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
1840cdf0e10cSrcweir 			}
1841cdf0e10cSrcweir 			else
1842cdf0e10cSrcweir 			{
1843cdf0e10cSrcweir 				const sal_Bool bRightFrm = aFlyRect.Left() >
1844cdf0e10cSrcweir 										   pAnch->Frm().Left() + pAnch->Prt().Width();
1845cdf0e10cSrcweir                 aHori.SetHoriOrient( text::HoriOrientation::RIGHT );
1846cdf0e10cSrcweir                 aHori.SetRelationOrient( bRightFrm ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
1847cdf0e10cSrcweir 			}
1848cdf0e10cSrcweir 			aHtmlSet.Put( aHori );
1849cdf0e10cSrcweir             aVert.SetVertOrient( text::VertOrientation::TOP );
1850cdf0e10cSrcweir             aVert.SetRelationOrient( text::RelOrientation::PRINT_AREA );
1851cdf0e10cSrcweir 			aHtmlSet.Put( aVert );
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir 			GetDoc()->SetAttr( aHtmlSet, *pFlyFrm->GetFmt() );
1854cdf0e10cSrcweir 		}
1855cdf0e10cSrcweir 	}
1856cdf0e10cSrcweir 	else
1857cdf0e10cSrcweir 	{
1858cdf0e10cSrcweir 		Point aRelNullPt;
1859cdf0e10cSrcweir 		if( OBJ_CAPTION == nIdent )
1860cdf0e10cSrcweir 			aRelNullPt = ((SdrCaptionObj&)rSdrObj).GetTailPos();
1861cdf0e10cSrcweir 		else
1862cdf0e10cSrcweir 			aRelNullPt = rBound.TopLeft();
1863cdf0e10cSrcweir 
1864cdf0e10cSrcweir 		aSet.Put( aAnch );
1865cdf0e10cSrcweir 		aSet.Put( SwFmtSurround( SURROUND_THROUGHT ) );
1866cdf0e10cSrcweir         // OD 2004-03-30 #i26791# - set horizontal position
1867cdf0e10cSrcweir         SwFmtHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
1868cdf0e10cSrcweir         aSet.Put( aHori );
1869cdf0e10cSrcweir         // OD 2004-03-30 #i26791# - set vertical position
1870cdf0e10cSrcweir         if( pAnch->IsTxtFrm() && ((SwTxtFrm*)pAnch)->IsFollow() )
1871cdf0e10cSrcweir         {
1872cdf0e10cSrcweir             SwTxtFrm* pTmp = (SwTxtFrm*)pAnch;
1873cdf0e10cSrcweir             do {
1874cdf0e10cSrcweir                 pTmp = pTmp->FindMaster();
1875cdf0e10cSrcweir                 ASSERT( pTmp, "Where's my Master?" );
1876cdf0e10cSrcweir                 nYOffset += pTmp->IsVertical() ?
1877cdf0e10cSrcweir                             pTmp->Prt().Width() : pTmp->Prt().Height();
1878cdf0e10cSrcweir             } while ( pTmp->IsFollow() );
1879cdf0e10cSrcweir         }
1880cdf0e10cSrcweir         SwFmtVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
1881cdf0e10cSrcweir         aSet.Put( aVert );
1882cdf0e10cSrcweir         SwDrawFrmFmt* pFmt = (SwDrawFrmFmt*)getIDocumentLayoutAccess()->MakeLayoutFmt( RND_DRAW_OBJECT, &aSet );
1883cdf0e10cSrcweir         // --> OD 2004-10-25 #i36010# - set layout direction of the position
1884cdf0e10cSrcweir         pFmt->SetPositionLayoutDir(
1885cdf0e10cSrcweir             text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
1886cdf0e10cSrcweir         // <--
1887cdf0e10cSrcweir         // --> OD 2005-03-11 #i44344#, #i44681# - positioning attributes already set
1888cdf0e10cSrcweir         pFmt->PosAttrSet();
1889cdf0e10cSrcweir         // <--
1890cdf0e10cSrcweir 
1891cdf0e10cSrcweir 		SwDrawContact *pContact = new SwDrawContact( pFmt, &rSdrObj );
1892cdf0e10cSrcweir         // --> OD 2004-11-22 #i35635#
1893cdf0e10cSrcweir         pContact->MoveObjToVisibleLayer( &rSdrObj );
1894cdf0e10cSrcweir         // <--
1895cdf0e10cSrcweir 		if( bCharBound )
1896cdf0e10cSrcweir 		{
1897cdf0e10cSrcweir             ASSERT( aAnch.GetAnchorId() == FLY_AS_CHAR, "wrong AnchorType" );
1898cdf0e10cSrcweir 			SwTxtNode *pNd = aAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode();
1899cdf0e10cSrcweir             SwFmtFlyCnt aFmt( pFmt );
1900cdf0e10cSrcweir             pNd->InsertItem(aFmt,
1901cdf0e10cSrcweir 							aAnch.GetCntntAnchor()->nContent.GetIndex(), 0 );
1902cdf0e10cSrcweir             SwFmtVertOrient aVertical( pFmt->GetVertOrient() );
1903cdf0e10cSrcweir             aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER );
1904cdf0e10cSrcweir             pFmt->SetFmtAttr( aVertical );
1905cdf0e10cSrcweir 		}
1906cdf0e10cSrcweir 		if( pAnch->IsTxtFrm() && ((SwTxtFrm*)pAnch)->IsFollow() )
1907cdf0e10cSrcweir 		{
1908cdf0e10cSrcweir 			SwTxtFrm* pTmp = (SwTxtFrm*)pAnch;
1909cdf0e10cSrcweir 			do {
1910cdf0e10cSrcweir 				pTmp = pTmp->FindMaster();
1911cdf0e10cSrcweir 				ASSERT( pTmp, "Where's my Master?" );
1912cdf0e10cSrcweir 			} while( pTmp->IsFollow() );
1913cdf0e10cSrcweir 			pAnch = pTmp;
1914cdf0e10cSrcweir 		}
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir 		pContact->ConnectToLayout();
1917cdf0e10cSrcweir 
1918cdf0e10cSrcweir         // OD 25.06.2003 #108784# - mark object at frame the object is inserted at.
1919cdf0e10cSrcweir         {
1920cdf0e10cSrcweir             SdrObject* pMarkObj = pContact->GetDrawObjectByAnchorFrm( *pAnch );
1921cdf0e10cSrcweir             if ( pMarkObj )
1922cdf0e10cSrcweir             {
1923cdf0e10cSrcweir                 Imp()->GetDrawView()->MarkObj( pMarkObj, Imp()->GetPageView(),
1924cdf0e10cSrcweir                                                 sal_False, sal_False );
1925cdf0e10cSrcweir             }
1926cdf0e10cSrcweir             else
1927cdf0e10cSrcweir             {
1928cdf0e10cSrcweir                 Imp()->GetDrawView()->MarkObj( &rSdrObj, Imp()->GetPageView(),
1929cdf0e10cSrcweir                                                 sal_False, sal_False );
1930cdf0e10cSrcweir             }
1931cdf0e10cSrcweir         }
1932cdf0e10cSrcweir 	}
1933cdf0e10cSrcweir 
1934cdf0e10cSrcweir 	GetDoc()->SetModified();
1935cdf0e10cSrcweir 
1936cdf0e10cSrcweir 	KillPams();
1937cdf0e10cSrcweir 	EndAllActionAndCall();
1938cdf0e10cSrcweir 	UnlockPaint();
1939cdf0e10cSrcweir 	return sal_True;
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir 
1942cdf0e10cSrcweir 
1943cdf0e10cSrcweir /*************************************************************************
1944cdf0e10cSrcweir |*
1945cdf0e10cSrcweir |*	SwFEShell::BreakCreate()
1946cdf0e10cSrcweir |*
1947cdf0e10cSrcweir *************************************************************************/
1948cdf0e10cSrcweir 
BreakCreate()1949cdf0e10cSrcweir void SwFEShell::BreakCreate()
1950cdf0e10cSrcweir {
1951cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "BreakCreate without DrawView?" );
1952cdf0e10cSrcweir 	Imp()->GetDrawView()->BrkCreateObj();
1953cdf0e10cSrcweir 	::FrameNotify( this, FLY_DRAG_END );
1954cdf0e10cSrcweir }
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir /*************************************************************************
1957cdf0e10cSrcweir |*
1958cdf0e10cSrcweir |*	SwFEShell::IsDrawCreate()
1959cdf0e10cSrcweir |*
1960cdf0e10cSrcweir *************************************************************************/
1961cdf0e10cSrcweir 
IsDrawCreate() const1962cdf0e10cSrcweir sal_Bool SwFEShell::IsDrawCreate() const
1963cdf0e10cSrcweir {
1964cdf0e10cSrcweir 	return Imp()->HasDrawView() ? Imp()->GetDrawView()->IsCreateObj() : sal_False;
1965cdf0e10cSrcweir }
1966cdf0e10cSrcweir 
1967cdf0e10cSrcweir /*************************************************************************
1968cdf0e10cSrcweir |*
1969cdf0e10cSrcweir |*	SwFEShell::BeginMark()
1970cdf0e10cSrcweir |*
1971cdf0e10cSrcweir *************************************************************************/
1972cdf0e10cSrcweir 
BeginMark(const Point & rPos)1973cdf0e10cSrcweir sal_Bool SwFEShell::BeginMark( const Point &rPos )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir 	if ( !Imp()->HasDrawView() )
1976cdf0e10cSrcweir 		Imp()->MakeDrawView();
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir 	if ( GetPageNumber( rPos ) )
1979cdf0e10cSrcweir 	{
1980cdf0e10cSrcweir 		SwDrawView* pDView = Imp()->GetDrawView();
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir 		if (pDView->HasMarkablePoints())
1983cdf0e10cSrcweir 			return pDView->BegMarkPoints( rPos );
1984cdf0e10cSrcweir 		else
1985cdf0e10cSrcweir 			return pDView->BegMarkObj( rPos );
1986cdf0e10cSrcweir 	}
1987cdf0e10cSrcweir 	else
1988cdf0e10cSrcweir 		return sal_False;
1989cdf0e10cSrcweir }
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir /*************************************************************************
1992cdf0e10cSrcweir |*
1993cdf0e10cSrcweir |*	SwFEShell::MoveMark()
1994cdf0e10cSrcweir |*
1995cdf0e10cSrcweir *************************************************************************/
1996cdf0e10cSrcweir 
MoveMark(const Point & rPos)1997cdf0e10cSrcweir void SwFEShell::MoveMark( const Point &rPos )
1998cdf0e10cSrcweir {
1999cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "MoveMark without DrawView?" );
2000cdf0e10cSrcweir 
2001cdf0e10cSrcweir 	if ( GetPageNumber( rPos ) )
2002cdf0e10cSrcweir 	{
2003cdf0e10cSrcweir 		ScrollTo( rPos );
2004cdf0e10cSrcweir 		SwDrawView* pDView = Imp()->GetDrawView();
2005cdf0e10cSrcweir //		Imp()->GetDrawView()->MovMarkObj( rPos );
2006cdf0e10cSrcweir 
2007cdf0e10cSrcweir 		if (pDView->IsInsObjPoint())
2008cdf0e10cSrcweir 			pDView->MovInsObjPoint( rPos );
2009cdf0e10cSrcweir 		else if (pDView->IsMarkPoints())
2010cdf0e10cSrcweir 			pDView->MovMarkPoints( rPos );
2011cdf0e10cSrcweir 		else
2012cdf0e10cSrcweir 			pDView->MovAction( rPos );
2013cdf0e10cSrcweir 	}
2014cdf0e10cSrcweir }
2015cdf0e10cSrcweir 
2016cdf0e10cSrcweir /*************************************************************************
2017cdf0e10cSrcweir |*
2018cdf0e10cSrcweir |*	SwFEShell::EndMark()
2019cdf0e10cSrcweir |*
2020cdf0e10cSrcweir *************************************************************************/
2021cdf0e10cSrcweir 
EndMark()2022cdf0e10cSrcweir sal_Bool SwFEShell::EndMark()
2023cdf0e10cSrcweir {
2024cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2025cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "EndMark without DrawView?" );
2026cdf0e10cSrcweir 
2027cdf0e10cSrcweir 	if (Imp()->GetDrawView()->IsMarkObj())
2028cdf0e10cSrcweir 	{
2029cdf0e10cSrcweir 		bRet = Imp()->GetDrawView()->EndMarkObj();
2030cdf0e10cSrcweir 
2031cdf0e10cSrcweir 		if ( bRet )
2032cdf0e10cSrcweir 		{
2033cdf0e10cSrcweir 			sal_Bool bShowHdl = sal_False;
2034cdf0e10cSrcweir 			SwDrawView* pDView = Imp()->GetDrawView();
2035cdf0e10cSrcweir 			//Rahmen werden auf diese Art nicht Selektiert, es sein denn es
2036cdf0e10cSrcweir 			//ist nur ein Rahmen.
2037cdf0e10cSrcweir 			SdrMarkList &rMrkList = (SdrMarkList&)pDView->GetMarkedObjectList();
2038cdf0e10cSrcweir 			SwFlyFrm* pOldSelFly = ::GetFlyFromMarked( &rMrkList, this );
2039cdf0e10cSrcweir 
2040cdf0e10cSrcweir 			if ( rMrkList.GetMarkCount() > 1 )
2041cdf0e10cSrcweir 				for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
2042cdf0e10cSrcweir 				{
2043cdf0e10cSrcweir 					SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2044cdf0e10cSrcweir 					if( pObj->ISA(SwVirtFlyDrawObj) )
2045cdf0e10cSrcweir 					{
2046cdf0e10cSrcweir 						if ( !bShowHdl )
2047cdf0e10cSrcweir 						{
2048cdf0e10cSrcweir 							//HMHpDView->HideMarkHdl();
2049cdf0e10cSrcweir 							bShowHdl = sal_True;
2050cdf0e10cSrcweir 						}
2051cdf0e10cSrcweir 						rMrkList.DeleteMark( i );
2052cdf0e10cSrcweir 						--i;	//keinen auslassen.
2053cdf0e10cSrcweir 					}
2054cdf0e10cSrcweir 				}
2055cdf0e10cSrcweir 
2056cdf0e10cSrcweir 			if( bShowHdl )
2057cdf0e10cSrcweir 			{
2058cdf0e10cSrcweir 				pDView->MarkListHasChanged();
2059cdf0e10cSrcweir 				pDView->AdjustMarkHdl();
2060cdf0e10cSrcweir 				//HMHpDView->ShowMarkHdl();
2061cdf0e10cSrcweir 			}
2062cdf0e10cSrcweir 
2063cdf0e10cSrcweir 			if ( rMrkList.GetMarkCount() )
2064cdf0e10cSrcweir 				::lcl_GrabCursor(this, pOldSelFly);
2065cdf0e10cSrcweir 			else
2066cdf0e10cSrcweir 				bRet = sal_False;
2067cdf0e10cSrcweir 		}
2068cdf0e10cSrcweir 		if ( bRet )
2069cdf0e10cSrcweir 			::FrameNotify( this, FLY_DRAG_START );
2070cdf0e10cSrcweir 	}
2071cdf0e10cSrcweir 	else
2072cdf0e10cSrcweir 	{
2073cdf0e10cSrcweir 		if (Imp()->GetDrawView()->IsMarkPoints())
2074cdf0e10cSrcweir 			bRet = Imp()->GetDrawView()->EndMarkPoints();
2075cdf0e10cSrcweir 	}
2076cdf0e10cSrcweir 
2077cdf0e10cSrcweir 	SetChainMarker();
2078cdf0e10cSrcweir 	return bRet;
2079cdf0e10cSrcweir }
2080cdf0e10cSrcweir 
2081cdf0e10cSrcweir /*************************************************************************
2082cdf0e10cSrcweir |*
2083cdf0e10cSrcweir |*	SwFEShell::BreakSelect()
2084cdf0e10cSrcweir |*
2085cdf0e10cSrcweir *************************************************************************/
2086cdf0e10cSrcweir 
BreakMark()2087cdf0e10cSrcweir void SwFEShell::BreakMark()
2088cdf0e10cSrcweir {
2089cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "BreakMark without DrawView?" );
2090cdf0e10cSrcweir 	Imp()->GetDrawView()->BrkMarkObj();
2091cdf0e10cSrcweir }
2092cdf0e10cSrcweir 
2093cdf0e10cSrcweir /*************************************************************************
2094cdf0e10cSrcweir |*
2095cdf0e10cSrcweir |*	SwFEShell::GetAnchorId()
2096cdf0e10cSrcweir |*
2097cdf0e10cSrcweir *************************************************************************/
2098cdf0e10cSrcweir 
GetAnchorId() const2099cdf0e10cSrcweir short SwFEShell::GetAnchorId() const
2100cdf0e10cSrcweir {
2101cdf0e10cSrcweir 	short nRet = SHRT_MAX;
2102cdf0e10cSrcweir 	if ( Imp()->HasDrawView() )
2103cdf0e10cSrcweir 	{
2104cdf0e10cSrcweir 		const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2105cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
2106cdf0e10cSrcweir 		{
2107cdf0e10cSrcweir 			SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2108cdf0e10cSrcweir 			if ( pObj->ISA(SwVirtFlyDrawObj) )
2109cdf0e10cSrcweir 			{
2110cdf0e10cSrcweir 				nRet = -1;
2111cdf0e10cSrcweir 				break;
2112cdf0e10cSrcweir 			}
2113cdf0e10cSrcweir 			SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
2114cdf0e10cSrcweir 			short nId = static_cast<short>(pContact->GetFmt()->GetAnchor().GetAnchorId());
2115cdf0e10cSrcweir 			if ( nRet == SHRT_MAX )
2116cdf0e10cSrcweir 				nRet = nId;
2117cdf0e10cSrcweir 			else if ( nRet != nId )
2118cdf0e10cSrcweir 			{
2119cdf0e10cSrcweir 				nRet = -1;
2120cdf0e10cSrcweir 				break;
2121cdf0e10cSrcweir 			}
2122cdf0e10cSrcweir 		}
2123cdf0e10cSrcweir 	}
2124cdf0e10cSrcweir 	if ( nRet == SHRT_MAX )
2125cdf0e10cSrcweir 		nRet = -1;
2126cdf0e10cSrcweir 	return nRet;
2127cdf0e10cSrcweir }
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir /*************************************************************************
2130cdf0e10cSrcweir |*
2131cdf0e10cSrcweir |*	SwFEShell::ChgAnchor()
2132cdf0e10cSrcweir |*
2133cdf0e10cSrcweir *************************************************************************/
2134cdf0e10cSrcweir 
ChgAnchor(int eAnchorId,sal_Bool bSameOnly,sal_Bool bPosCorr)2135cdf0e10cSrcweir void SwFEShell::ChgAnchor( int eAnchorId, sal_Bool bSameOnly, sal_Bool bPosCorr )
2136cdf0e10cSrcweir {
2137cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "ChgAnchor without DrawView?" );
2138cdf0e10cSrcweir 	const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2139cdf0e10cSrcweir 	if( rMrkList.GetMarkCount() &&
2140cdf0e10cSrcweir 		!rMrkList.GetMark( 0 )->GetMarkedSdrObj()->GetUpGroup() )
2141cdf0e10cSrcweir 	{
2142cdf0e10cSrcweir 		StartAllAction();
2143cdf0e10cSrcweir 
2144cdf0e10cSrcweir         if( GetDoc()->ChgAnchor( rMrkList, (RndStdIds)eAnchorId, bSameOnly, bPosCorr ))
2145cdf0e10cSrcweir 			Imp()->GetDrawView()->UnmarkAll();
2146cdf0e10cSrcweir 
2147cdf0e10cSrcweir 		EndAllAction();
2148cdf0e10cSrcweir 
2149cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG );
2150cdf0e10cSrcweir 	}
2151cdf0e10cSrcweir }
2152cdf0e10cSrcweir 
2153cdf0e10cSrcweir /*************************************************************************
2154cdf0e10cSrcweir |*
2155cdf0e10cSrcweir |*	SwFEShell::DelSelectedObj()
2156cdf0e10cSrcweir |*
2157cdf0e10cSrcweir *************************************************************************/
2158cdf0e10cSrcweir 
DelSelectedObj()2159cdf0e10cSrcweir void SwFEShell::DelSelectedObj()
2160cdf0e10cSrcweir {
2161cdf0e10cSrcweir 	ASSERT( Imp()->HasDrawView(), "DelSelectedObj(), no DrawView available" );
2162cdf0e10cSrcweir 	if ( Imp()->HasDrawView() )
2163cdf0e10cSrcweir 	{
2164cdf0e10cSrcweir 		StartAllAction();
2165cdf0e10cSrcweir 		Imp()->GetDrawView()->DeleteMarked();
2166cdf0e10cSrcweir 		EndAllAction();
2167cdf0e10cSrcweir 		::FrameNotify( this, FLY_DRAG_END );
2168cdf0e10cSrcweir 	}
2169cdf0e10cSrcweir }
2170cdf0e10cSrcweir 
2171cdf0e10cSrcweir /*************************************************************************
2172cdf0e10cSrcweir |*
2173cdf0e10cSrcweir |*	SwFEShell::GetObjSize(), GetAnchorObjDiff()
2174cdf0e10cSrcweir |*
2175cdf0e10cSrcweir |*	Beschreibung		Fuer die Statuszeile zum Erfragen der aktuellen
2176cdf0e10cSrcweir |*						Verhaeltnisse
2177cdf0e10cSrcweir |*
2178cdf0e10cSrcweir *************************************************************************/
2179cdf0e10cSrcweir 
GetObjSize() const2180cdf0e10cSrcweir Size SwFEShell::GetObjSize() const
2181cdf0e10cSrcweir {
2182cdf0e10cSrcweir 	Rectangle aRect;
2183cdf0e10cSrcweir 	if ( Imp()->HasDrawView() )
2184cdf0e10cSrcweir 	{
2185cdf0e10cSrcweir 		if ( Imp()->GetDrawView()->IsAction() )
2186cdf0e10cSrcweir 			Imp()->GetDrawView()->TakeActionRect( aRect );
2187cdf0e10cSrcweir 		else
2188cdf0e10cSrcweir 			aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2189cdf0e10cSrcweir 	}
2190cdf0e10cSrcweir 	return aRect.GetSize();
2191cdf0e10cSrcweir }
2192cdf0e10cSrcweir 
GetAnchorObjDiff() const2193cdf0e10cSrcweir Point SwFEShell::GetAnchorObjDiff() const
2194cdf0e10cSrcweir {
2195cdf0e10cSrcweir 	const SdrView *pView = Imp()->GetDrawView();
2196cdf0e10cSrcweir 	ASSERT( pView, "GetAnchorObjDiff without DrawView?" );
2197cdf0e10cSrcweir 
2198cdf0e10cSrcweir 	Rectangle aRect;
2199cdf0e10cSrcweir 	if ( Imp()->GetDrawView()->IsAction() )
2200cdf0e10cSrcweir 		Imp()->GetDrawView()->TakeActionRect( aRect );
2201cdf0e10cSrcweir 	else
2202cdf0e10cSrcweir 		aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2203cdf0e10cSrcweir 
2204cdf0e10cSrcweir 	Point aRet( aRect.TopLeft() );
2205cdf0e10cSrcweir 
2206cdf0e10cSrcweir 	if ( IsFrmSelected() )
2207cdf0e10cSrcweir 	{
2208cdf0e10cSrcweir 		SwFlyFrm *pFly = FindFlyFrm();
2209cdf0e10cSrcweir         aRet -= pFly->GetAnchorFrm()->Frm().Pos();
2210cdf0e10cSrcweir 	}
2211cdf0e10cSrcweir 	else
2212cdf0e10cSrcweir 	{
2213cdf0e10cSrcweir 		const SdrObject *pObj = pView->GetMarkedObjectList().GetMarkCount() == 1 ?
2214cdf0e10cSrcweir 								pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() : 0;
2215cdf0e10cSrcweir 		if ( pObj )
2216cdf0e10cSrcweir 			aRet -= pObj->GetAnchorPos();
2217cdf0e10cSrcweir 	}
2218cdf0e10cSrcweir 
2219cdf0e10cSrcweir 	return aRet;
2220cdf0e10cSrcweir }
2221cdf0e10cSrcweir 
GetObjAbsPos() const2222cdf0e10cSrcweir Point SwFEShell::GetObjAbsPos() const
2223cdf0e10cSrcweir {
2224cdf0e10cSrcweir 	ASSERT( Imp()->GetDrawView(), "GetObjAbsPos() without DrawView?" );
2225cdf0e10cSrcweir 	return Imp()->GetDrawView()->GetDragStat().GetActionRect().TopLeft();
2226cdf0e10cSrcweir }
2227cdf0e10cSrcweir 
2228cdf0e10cSrcweir 
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir /*************************************************************************
2231cdf0e10cSrcweir |*
2232cdf0e10cSrcweir |*	SwFEShell::IsGroupSelected()
2233cdf0e10cSrcweir |*
2234cdf0e10cSrcweir *************************************************************************/
2235cdf0e10cSrcweir 
IsGroupSelected()2236cdf0e10cSrcweir sal_Bool SwFEShell::IsGroupSelected()
2237cdf0e10cSrcweir {
2238cdf0e10cSrcweir 	if ( IsObjSelected() )
2239cdf0e10cSrcweir 	{
2240cdf0e10cSrcweir 		const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2241cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
2242cdf0e10cSrcweir 		{
2243cdf0e10cSrcweir 			SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2244cdf0e10cSrcweir             // OD 30.06.2003 #108784# - consider 'virtual' drawing objects.
2245cdf0e10cSrcweir             // Thus, use corresponding method instead of checking type.
2246cdf0e10cSrcweir             if ( pObj->IsGroupObject() &&
2247cdf0e10cSrcweir                  // --> FME 2004-12-08 #i38505# No ungroup allowed for 3d objects
2248cdf0e10cSrcweir                  !pObj->Is3DObj() &&
2249cdf0e10cSrcweir                  // <--
2250cdf0e10cSrcweir                  FLY_AS_CHAR != ((SwDrawContact*)GetUserCall(pObj))->
2251cdf0e10cSrcweir                                       GetFmt()->GetAnchor().GetAnchorId() )
2252cdf0e10cSrcweir             {
2253cdf0e10cSrcweir 				return sal_True;
2254cdf0e10cSrcweir             }
2255cdf0e10cSrcweir 		}
2256cdf0e10cSrcweir 	}
2257cdf0e10cSrcweir 	return sal_False;
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir 
2260cdf0e10cSrcweir // OD 27.06.2003 #108784# - change return type.
2261cdf0e10cSrcweir // OD 27.06.2003 #108784# - adjustments for drawing objects in header/footer:
2262cdf0e10cSrcweir //      allow group, only if all selected objects are in the same header/footer
2263cdf0e10cSrcweir //      or not in header/footer.
IsGroupAllowed() const2264cdf0e10cSrcweir bool SwFEShell::IsGroupAllowed() const
2265cdf0e10cSrcweir {
2266cdf0e10cSrcweir     bool bIsGroupAllowed = false;
2267cdf0e10cSrcweir 	if ( IsObjSelected() > 1 )
2268cdf0e10cSrcweir 	{
2269cdf0e10cSrcweir         bIsGroupAllowed = true;
2270cdf0e10cSrcweir         const SdrObject* pUpGroup = 0L;
2271cdf0e10cSrcweir         const SwFrm* pHeaderFooterFrm = 0L;
2272cdf0e10cSrcweir 		const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2273cdf0e10cSrcweir         for ( sal_uInt16 i = 0; bIsGroupAllowed && i < rMrkList.GetMarkCount(); ++i )
2274cdf0e10cSrcweir 		{
2275cdf0e10cSrcweir             const SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2276cdf0e10cSrcweir             if ( i )
2277cdf0e10cSrcweir                 bIsGroupAllowed = pObj->GetUpGroup() == pUpGroup;
2278cdf0e10cSrcweir 			else
2279cdf0e10cSrcweir 				pUpGroup = pObj->GetUpGroup();
2280cdf0e10cSrcweir 
2281cdf0e10cSrcweir             if ( bIsGroupAllowed )
2282cdf0e10cSrcweir             {
2283cdf0e10cSrcweir                 SwFrmFmt* pFrmFmt( ::FindFrmFmt( const_cast<SdrObject*>(pObj) ) );
2284cdf0e10cSrcweir                 if ( !pFrmFmt )
2285cdf0e10cSrcweir                 {
2286cdf0e10cSrcweir                     ASSERT( false,
2287cdf0e10cSrcweir                             "<SwFEShell::IsGroupAllowed()> - missing frame format" );
2288cdf0e10cSrcweir                     bIsGroupAllowed = false;
2289cdf0e10cSrcweir                 }
2290cdf0e10cSrcweir                 else if ( FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
2291cdf0e10cSrcweir                 {
2292cdf0e10cSrcweir                     bIsGroupAllowed = false;
2293cdf0e10cSrcweir                 }
2294cdf0e10cSrcweir             }
2295cdf0e10cSrcweir 
2296cdf0e10cSrcweir             // OD 27.06.2003 #108784# - check, if all selected objects are in the
2297cdf0e10cSrcweir             // same header/footer or not in header/footer.
2298cdf0e10cSrcweir             if ( bIsGroupAllowed )
2299cdf0e10cSrcweir             {
2300cdf0e10cSrcweir                 const SwFrm* pAnchorFrm = 0L;
2301cdf0e10cSrcweir                 if ( pObj->ISA(SwVirtFlyDrawObj) )
2302cdf0e10cSrcweir                 {
2303cdf0e10cSrcweir                     const SwFlyFrm* pFlyFrm =
2304cdf0e10cSrcweir                             static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrm();
2305cdf0e10cSrcweir                     if ( pFlyFrm )
2306cdf0e10cSrcweir                     {
2307cdf0e10cSrcweir                         pAnchorFrm = pFlyFrm->GetAnchorFrm();
2308cdf0e10cSrcweir                     }
2309cdf0e10cSrcweir                 }
2310cdf0e10cSrcweir                 else
2311cdf0e10cSrcweir                 {
2312cdf0e10cSrcweir                     SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall( pObj ));
2313cdf0e10cSrcweir                     if ( pDrawContact )
2314cdf0e10cSrcweir                     {
2315cdf0e10cSrcweir                         pAnchorFrm = pDrawContact->GetAnchorFrm( pObj );
2316cdf0e10cSrcweir                     }
2317cdf0e10cSrcweir                 }
2318cdf0e10cSrcweir                 if ( pAnchorFrm )
2319cdf0e10cSrcweir                 {
2320cdf0e10cSrcweir                     if ( i )
2321cdf0e10cSrcweir                     {
2322cdf0e10cSrcweir                         bIsGroupAllowed =
2323cdf0e10cSrcweir                             ( pAnchorFrm->FindFooterOrHeader() == pHeaderFooterFrm );
2324cdf0e10cSrcweir                     }
2325cdf0e10cSrcweir                     else
2326cdf0e10cSrcweir                     {
2327cdf0e10cSrcweir                         pHeaderFooterFrm = pAnchorFrm->FindFooterOrHeader();
2328cdf0e10cSrcweir                     }
2329cdf0e10cSrcweir                 }
2330cdf0e10cSrcweir             }
2331cdf0e10cSrcweir 
2332cdf0e10cSrcweir 		}
2333cdf0e10cSrcweir 	}
2334cdf0e10cSrcweir 
2335cdf0e10cSrcweir     return bIsGroupAllowed;
2336cdf0e10cSrcweir }
2337cdf0e10cSrcweir 
2338cdf0e10cSrcweir /*************************************************************************
2339cdf0e10cSrcweir |*
2340cdf0e10cSrcweir |*	SwFEShell::GroupSelection()
2341cdf0e10cSrcweir |*
2342cdf0e10cSrcweir |*	Beschreibung		Die Gruppe bekommt den Anker und das Contactobjekt
2343cdf0e10cSrcweir |* 						des ersten in der Selektion
2344cdf0e10cSrcweir |*
2345cdf0e10cSrcweir *************************************************************************/
2346cdf0e10cSrcweir 
GroupSelection()2347cdf0e10cSrcweir void SwFEShell::GroupSelection()
2348cdf0e10cSrcweir {
2349cdf0e10cSrcweir 	if ( IsGroupAllowed() )
2350cdf0e10cSrcweir 	{
2351cdf0e10cSrcweir 		StartAllAction();
2352cdf0e10cSrcweir 		StartUndo( UNDO_START );
2353cdf0e10cSrcweir 
2354cdf0e10cSrcweir 		GetDoc()->GroupSelection( *Imp()->GetDrawView() );
2355cdf0e10cSrcweir 
2356cdf0e10cSrcweir 		EndUndo( UNDO_END );
2357cdf0e10cSrcweir 		EndAllAction();
2358cdf0e10cSrcweir 	}
2359cdf0e10cSrcweir }
2360cdf0e10cSrcweir 
2361cdf0e10cSrcweir /*************************************************************************
2362cdf0e10cSrcweir |*
2363cdf0e10cSrcweir |*	SwFEShell::UnGroupSelection()
2364cdf0e10cSrcweir |*
2365cdf0e10cSrcweir |*	Beschreibung		Die Einzelobjekte bekommen eine Kopie vom Anker und
2366cdf0e10cSrcweir |* 						Contactobjekt der Gruppe.
2367cdf0e10cSrcweir |*
2368cdf0e10cSrcweir *************************************************************************/
2369cdf0e10cSrcweir 
UnGroupSelection()2370cdf0e10cSrcweir void SwFEShell::UnGroupSelection()
2371cdf0e10cSrcweir {
2372cdf0e10cSrcweir 	if ( IsGroupSelected() )
2373cdf0e10cSrcweir 	{
2374cdf0e10cSrcweir 		StartAllAction();
2375cdf0e10cSrcweir 		StartUndo( UNDO_START );
2376cdf0e10cSrcweir 
2377cdf0e10cSrcweir 		GetDoc()->UnGroupSelection( *Imp()->GetDrawView() );
2378cdf0e10cSrcweir 
2379cdf0e10cSrcweir 		EndUndo( UNDO_END );
2380cdf0e10cSrcweir 		EndAllAction();
2381cdf0e10cSrcweir 	}
2382cdf0e10cSrcweir }
2383cdf0e10cSrcweir 
2384cdf0e10cSrcweir /*************************************************************************
2385cdf0e10cSrcweir |*
2386cdf0e10cSrcweir |*	SwFEShell::MirrorSelection()
2387cdf0e10cSrcweir |*
2388cdf0e10cSrcweir *************************************************************************/
2389cdf0e10cSrcweir 
MirrorSelection(sal_Bool bHorizontal)2390cdf0e10cSrcweir void SwFEShell::MirrorSelection( sal_Bool bHorizontal )
2391cdf0e10cSrcweir {
2392cdf0e10cSrcweir 	SdrView *pView = Imp()->GetDrawView();
2393cdf0e10cSrcweir 	if ( IsObjSelected() && pView->IsMirrorAllowed() )
2394cdf0e10cSrcweir 	{
2395cdf0e10cSrcweir 		if ( bHorizontal )
2396cdf0e10cSrcweir 			pView->MirrorAllMarkedHorizontal();
2397cdf0e10cSrcweir 		else
2398cdf0e10cSrcweir 			pView->MirrorAllMarkedVertical();
2399cdf0e10cSrcweir 	}
2400cdf0e10cSrcweir }
2401cdf0e10cSrcweir 
2402cdf0e10cSrcweir // springe zum benannten Rahmen (Grafik/OLE)
2403cdf0e10cSrcweir 
GotoFly(const String & rName,FlyCntType eType,sal_Bool bSelFrm)2404cdf0e10cSrcweir sal_Bool SwFEShell::GotoFly( const String& rName, FlyCntType eType, sal_Bool bSelFrm )
2405cdf0e10cSrcweir {
2406cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2407cdf0e10cSrcweir static sal_uInt8 __READONLY_DATA aChkArr[ 4 ] = {
2408cdf0e10cSrcweir 			 /* FLYCNTTYPE_ALL */ 	0,
2409cdf0e10cSrcweir 			 /* FLYCNTTYPE_FRM */	ND_TEXTNODE,
2410cdf0e10cSrcweir 			 /* FLYCNTTYPE_GRF */	ND_GRFNODE,
2411cdf0e10cSrcweir 			 /* FLYCNTTYPE_OLE */	ND_OLENODE
2412cdf0e10cSrcweir 			};
2413cdf0e10cSrcweir 
2414cdf0e10cSrcweir 	const SwFlyFrmFmt* pFlyFmt = pDoc->FindFlyByName( rName, aChkArr[ eType]);
2415cdf0e10cSrcweir 	if( pFlyFmt )
2416cdf0e10cSrcweir 	{
2417cdf0e10cSrcweir 		SET_CURR_SHELL( this );
2418cdf0e10cSrcweir 
2419cdf0e10cSrcweir 		SwFlyFrm* pFrm = SwIterator<SwFlyFrm,SwFmt>::FirstElement( *pFlyFmt );
2420cdf0e10cSrcweir 		if( pFrm )
2421cdf0e10cSrcweir 		{
2422cdf0e10cSrcweir 			if( bSelFrm )
2423cdf0e10cSrcweir 			{
2424cdf0e10cSrcweir                 SelectObj( pFrm->Frm().Pos(), 0, pFrm->GetVirtDrawObj() );
2425cdf0e10cSrcweir 				if( !ActionPend() )
2426cdf0e10cSrcweir 					MakeVisible( pFrm->Frm() );
2427cdf0e10cSrcweir 			}
2428cdf0e10cSrcweir 			else
2429cdf0e10cSrcweir 			{
2430cdf0e10cSrcweir                 // --> OD 2004-06-11 #i28701# - no format here
2431cdf0e10cSrcweir //                pFrm->GetAnchorFrm()->Calc();
2432cdf0e10cSrcweir 				SwCntntFrm *pCFrm = pFrm->ContainsCntnt();
2433cdf0e10cSrcweir 				if ( pCFrm )
2434cdf0e10cSrcweir 				{
2435cdf0e10cSrcweir 					SwCntntNode	*pCNode = pCFrm->GetNode();
2436cdf0e10cSrcweir 					ClearMark();
2437cdf0e10cSrcweir 					SwPaM* pCrsr = GetCrsr();
2438cdf0e10cSrcweir 
2439cdf0e10cSrcweir 					pCrsr->GetPoint()->nNode = *pCNode;
2440cdf0e10cSrcweir 					pCrsr->GetPoint()->nContent.Assign( pCNode, 0 );
2441cdf0e10cSrcweir 
2442cdf0e10cSrcweir 					SwRect& rChrRect = (SwRect&)GetCharRect();
2443cdf0e10cSrcweir 					rChrRect = pFrm->Prt();
2444cdf0e10cSrcweir 					rChrRect.Pos() += pFrm->Frm().Pos();
2445cdf0e10cSrcweir 					GetCrsrDocPos() = rChrRect.Pos();
2446cdf0e10cSrcweir 				}
2447cdf0e10cSrcweir 			}
2448cdf0e10cSrcweir 			bRet = sal_True;
2449cdf0e10cSrcweir 		}
2450cdf0e10cSrcweir 	}
2451cdf0e10cSrcweir 	return bRet;
2452cdf0e10cSrcweir }
2453cdf0e10cSrcweir 
GetFlyCount(FlyCntType eType) const2454cdf0e10cSrcweir sal_uInt16 SwFEShell::GetFlyCount( FlyCntType eType ) const
2455cdf0e10cSrcweir {
2456cdf0e10cSrcweir 	return GetDoc()->GetFlyCount(eType);
2457cdf0e10cSrcweir }
2458cdf0e10cSrcweir 
2459cdf0e10cSrcweir 
GetFlyNum(sal_uInt16 nIdx,FlyCntType eType) const2460cdf0e10cSrcweir const SwFrmFmt*  SwFEShell::GetFlyNum(sal_uInt16 nIdx, FlyCntType eType ) const
2461cdf0e10cSrcweir {
2462cdf0e10cSrcweir 	return GetDoc()->GetFlyNum(nIdx, eType );
2463cdf0e10cSrcweir }
2464cdf0e10cSrcweir 
2465*2a0ce834SOliver-Rainer Wittmann 
2466cdf0e10cSrcweir // zeige das akt. selektierte "Object" an
MakeSelVisible()2467cdf0e10cSrcweir void SwFEShell::MakeSelVisible()
2468cdf0e10cSrcweir {
2469cdf0e10cSrcweir     if ( Imp()->HasDrawView() &&
2470cdf0e10cSrcweir          Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )
2471cdf0e10cSrcweir     {
2472*2a0ce834SOliver-Rainer Wittmann         GetCurrFrm(); // just to trigger formatting in case the selected object is not formatted.
2473cdf0e10cSrcweir         MakeVisible( Imp()->GetDrawView()->GetAllMarkedRect() );
2474cdf0e10cSrcweir     }
2475cdf0e10cSrcweir     else
2476cdf0e10cSrcweir         SwCrsrShell::MakeSelVisible();
2477cdf0e10cSrcweir }
2478cdf0e10cSrcweir 
2479cdf0e10cSrcweir 
2480cdf0e10cSrcweir //Welcher Schutz ist am selektierten Objekt gesetzt?
IsSelObjProtected(sal_uInt16 eType) const2481cdf0e10cSrcweir sal_uInt8 SwFEShell::IsSelObjProtected( sal_uInt16 eType ) const
2482cdf0e10cSrcweir {
2483cdf0e10cSrcweir 	int nChk = 0;
2484cdf0e10cSrcweir 	const bool bParent = (eType & FLYPROTECT_PARENT);
2485cdf0e10cSrcweir 	if( Imp()->HasDrawView() )
2486cdf0e10cSrcweir 	{
2487cdf0e10cSrcweir 		const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2488cdf0e10cSrcweir 		for( sal_uLong i = rMrkList.GetMarkCount(); i; )
2489cdf0e10cSrcweir 		{
2490cdf0e10cSrcweir 			SdrObject *pObj = rMrkList.GetMark( --i )->GetMarkedSdrObj();
2491cdf0e10cSrcweir 			if( !bParent )
2492cdf0e10cSrcweir 			{
2493cdf0e10cSrcweir 				nChk |= ( pObj->IsMoveProtect()	? FLYPROTECT_POS : 0 ) |
2494cdf0e10cSrcweir 						( pObj->IsResizeProtect()? FLYPROTECT_SIZE : 0 );
2495cdf0e10cSrcweir 
2496cdf0e10cSrcweir 				if( pObj->ISA(SwVirtFlyDrawObj) )
2497cdf0e10cSrcweir 				{
2498cdf0e10cSrcweir 					SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
2499cdf0e10cSrcweir 					if ( (FLYPROTECT_CONTENT & eType) && pFly->GetFmt()->GetProtect().IsCntntProtected() )
2500cdf0e10cSrcweir 						nChk |= FLYPROTECT_CONTENT;
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir 					if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
2503cdf0e10cSrcweir 					{
2504cdf0e10cSrcweir 						SwOLENode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetOLENode();
2505cdf0e10cSrcweir                         uno::Reference < embed::XEmbeddedObject > xObj( pNd ? pNd->GetOLEObj().GetOleRef() : 0 );
2506cdf0e10cSrcweir 						if ( xObj.is() )
2507cdf0e10cSrcweir 						{
2508cdf0e10cSrcweir                             // TODO/LATER: use correct aspect
2509cdf0e10cSrcweir                             const bool bNeverResize = (embed::EmbedMisc::EMBED_NEVERRESIZE & xObj->getStatus( embed::Aspects::MSOLE_CONTENT ));
25100c259c9fSOliver-Rainer Wittmann                             if ( ( (FLYPROTECT_CONTENT & eType) || (FLYPROTECT_SIZE & eType) ) && bNeverResize )
2511cdf0e10cSrcweir                             {
2512cdf0e10cSrcweir                                 nChk |= FLYPROTECT_SIZE;
2513cdf0e10cSrcweir                                 nChk |= FLYPROTECT_FIXED;
2514cdf0e10cSrcweir                             }
2515cdf0e10cSrcweir 
2516cdf0e10cSrcweir                             // set FLYPROTECT_POS if it is a Math object anchored 'as char' and baseline alignment is activated
2517cdf0e10cSrcweir                             const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
2518cdf0e10cSrcweir                                     && FLY_AS_CHAR == pFly->GetFmt()->GetAnchor().GetAnchorId()
2519cdf0e10cSrcweir                                     && pDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
2520cdf0e10cSrcweir                             if ((FLYPROTECT_POS & eType) && bProtectMathPos)
2521cdf0e10cSrcweir                                 nChk |= FLYPROTECT_POS;
2522cdf0e10cSrcweir 						}
2523cdf0e10cSrcweir 					}
2524cdf0e10cSrcweir 				}
2525cdf0e10cSrcweir 				nChk &= eType;
2526cdf0e10cSrcweir 				if( nChk == eType )
2527cdf0e10cSrcweir 					return static_cast<sal_uInt8>(eType);
2528cdf0e10cSrcweir 			}
2529cdf0e10cSrcweir             const SwFrm* pAnch;
2530cdf0e10cSrcweir 			if( pObj->ISA(SwVirtFlyDrawObj) )
2531cdf0e10cSrcweir                 pAnch = ( (SwVirtFlyDrawObj*)pObj )->GetFlyFrm()->GetAnchorFrm();
2532cdf0e10cSrcweir 			else
2533cdf0e10cSrcweir 			{
2534cdf0e10cSrcweir 				SwDrawContact* pTmp = (SwDrawContact*)GetUserCall(pObj);
2535cdf0e10cSrcweir                 pAnch = pTmp ? pTmp->GetAnchorFrm( pObj ) : NULL;
2536cdf0e10cSrcweir 			}
2537cdf0e10cSrcweir 			if( pAnch && pAnch->IsProtected() )
2538cdf0e10cSrcweir 				return static_cast<sal_uInt8>(eType);
2539cdf0e10cSrcweir 		}
2540cdf0e10cSrcweir 	}
2541cdf0e10cSrcweir 	return static_cast<sal_uInt8>(nChk);
2542cdf0e10cSrcweir }
2543cdf0e10cSrcweir 
GetObjAttr(SfxItemSet & rSet) const2544cdf0e10cSrcweir sal_Bool SwFEShell::GetObjAttr( SfxItemSet &rSet ) const
2545cdf0e10cSrcweir {
2546cdf0e10cSrcweir 	if ( !IsObjSelected() )
2547cdf0e10cSrcweir 		return sal_False;
2548cdf0e10cSrcweir 
2549cdf0e10cSrcweir 	const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2550cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
2551cdf0e10cSrcweir 	{
2552cdf0e10cSrcweir 		SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2553cdf0e10cSrcweir 		SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
2554cdf0e10cSrcweir         // --> OD 2007-07-24 #143008# - make code robust
2555cdf0e10cSrcweir         ASSERT( pContact, "<SwFEShell::GetObjAttr(..)> - missing <pContact> - please inform OD." );
2556cdf0e10cSrcweir         if ( pContact )
2557cdf0e10cSrcweir         {
2558cdf0e10cSrcweir             if ( i )
2559cdf0e10cSrcweir                 rSet.MergeValues( pContact->GetFmt()->GetAttrSet() );
2560cdf0e10cSrcweir             else
2561cdf0e10cSrcweir                 rSet.Put( pContact->GetFmt()->GetAttrSet() );
2562cdf0e10cSrcweir         }
2563cdf0e10cSrcweir         // <--
2564cdf0e10cSrcweir 	}
2565cdf0e10cSrcweir 	return sal_True;
2566cdf0e10cSrcweir }
2567cdf0e10cSrcweir 
SetObjAttr(const SfxItemSet & rSet)2568cdf0e10cSrcweir sal_Bool SwFEShell::SetObjAttr( const SfxItemSet& rSet )
2569cdf0e10cSrcweir {
2570cdf0e10cSrcweir 	SET_CURR_SHELL( this );
2571cdf0e10cSrcweir 
2572cdf0e10cSrcweir 	if ( !rSet.Count() )
2573cdf0e10cSrcweir 	{	ASSERT( !this, "SetObjAttr, empty set." );
2574cdf0e10cSrcweir 		return sal_False;
2575cdf0e10cSrcweir 	}
2576cdf0e10cSrcweir 
2577cdf0e10cSrcweir 	StartAllAction();
2578cdf0e10cSrcweir 	StartUndo( UNDO_INSATTR );
2579cdf0e10cSrcweir 
2580cdf0e10cSrcweir 	const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2581cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
2582cdf0e10cSrcweir 	{
2583cdf0e10cSrcweir 		SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2584cdf0e10cSrcweir 		SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
2585cdf0e10cSrcweir 		GetDoc()->SetAttr( rSet, *pContact->GetFmt() );
2586cdf0e10cSrcweir 	}
2587cdf0e10cSrcweir 
2588cdf0e10cSrcweir 	EndUndo( UNDO_INSATTR );
2589cdf0e10cSrcweir 	EndAllActionAndCall();
2590cdf0e10cSrcweir 	GetDoc()->SetModified();
2591cdf0e10cSrcweir 	return sal_True;
2592cdf0e10cSrcweir }
2593cdf0e10cSrcweir 
IsAlignPossible() const2594cdf0e10cSrcweir sal_Bool SwFEShell::IsAlignPossible() const
2595cdf0e10cSrcweir {
2596cdf0e10cSrcweir 	sal_uInt16 nCnt;
2597cdf0e10cSrcweir 	if ( 0 < (nCnt = IsObjSelected()) )
2598cdf0e10cSrcweir 	{
2599cdf0e10cSrcweir 		sal_Bool bRet = sal_True;
2600cdf0e10cSrcweir 		if ( nCnt == 1 )
2601cdf0e10cSrcweir 		{
2602cdf0e10cSrcweir 			SdrObject *pO = Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
2603cdf0e10cSrcweir 			SwDrawContact *pC = (SwDrawContact*)GetUserCall(pO);
2604cdf0e10cSrcweir             //only as character bound drawings can be aligned
2605cdf0e10cSrcweir             bRet = (pC->GetFmt()->GetAnchor().GetAnchorId() == FLY_AS_CHAR);
2606cdf0e10cSrcweir 		}
2607cdf0e10cSrcweir 		if ( bRet )
2608cdf0e10cSrcweir 			return Imp()->GetDrawView()->IsAlignPossible();
2609cdf0e10cSrcweir 	}
2610cdf0e10cSrcweir 	return sal_False;
2611cdf0e10cSrcweir }
2612cdf0e10cSrcweir 
2613cdf0e10cSrcweir 
2614cdf0e10cSrcweir //Temporaerer Fix bis SS von JOE da ist
CheckUnboundObjects()2615cdf0e10cSrcweir void SwFEShell::CheckUnboundObjects()
2616cdf0e10cSrcweir {
2617cdf0e10cSrcweir 	SET_CURR_SHELL( this );
2618cdf0e10cSrcweir 
2619cdf0e10cSrcweir 	const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2620cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
2621cdf0e10cSrcweir 	{
2622cdf0e10cSrcweir 		SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2623cdf0e10cSrcweir 		if ( !GetUserCall(pObj) )
2624cdf0e10cSrcweir 		{
2625cdf0e10cSrcweir 			const Rectangle &rBound = pObj->GetSnapRect();
2626cdf0e10cSrcweir 			const Point aPt( rBound.TopLeft() );
2627cdf0e10cSrcweir 			const SwFrm *pPage = GetLayout()->Lower();
2628cdf0e10cSrcweir 			const SwFrm *pLast = pPage;
2629cdf0e10cSrcweir 			while ( pPage && !pPage->Frm().IsInside( aPt ) )
2630cdf0e10cSrcweir 			{
2631cdf0e10cSrcweir 				if ( aPt.Y() > pPage->Frm().Bottom() )
2632cdf0e10cSrcweir 					pLast = pPage;
2633cdf0e10cSrcweir 				pPage = pPage->GetNext();
2634cdf0e10cSrcweir 			}
2635cdf0e10cSrcweir 			if ( !pPage )
2636cdf0e10cSrcweir 				pPage = pLast;
2637cdf0e10cSrcweir 			ASSERT( pPage, "Page not found." );
2638cdf0e10cSrcweir 
2639cdf0e10cSrcweir 			//Fremde Identifier sollen in den Default laufen.
2640cdf0e10cSrcweir 			//Ueberschneidungen sind moeglich!!
2641cdf0e10cSrcweir 			sal_uInt16 nIdent =
2642cdf0e10cSrcweir 					Imp()->GetDrawView()->GetCurrentObjInventor() == SdrInventor ?
2643cdf0e10cSrcweir 							Imp()->GetDrawView()->GetCurrentObjIdentifier() : 0xFFFF;
2644cdf0e10cSrcweir 
2645cdf0e10cSrcweir 			SwFmtAnchor aAnch;
2646cdf0e10cSrcweir 			const SwFrm *pAnch = 0;
2647cdf0e10cSrcweir 			{
2648cdf0e10cSrcweir 			pAnch = ::FindAnchor( pPage, aPt, sal_True );
2649cdf0e10cSrcweir 			SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() );
2650cdf0e10cSrcweir             aAnch.SetType( FLY_AT_PARA );
2651cdf0e10cSrcweir 			aAnch.SetAnchor( &aPos );
2652cdf0e10cSrcweir 			((SwRect&)GetCharRect()).Pos() = aPt;
2653cdf0e10cSrcweir 			}
2654cdf0e10cSrcweir 
2655cdf0e10cSrcweir 			//Erst hier die Action, damit das GetCharRect aktuelle Werte liefert.
2656cdf0e10cSrcweir 			StartAllAction();
2657cdf0e10cSrcweir 
2658cdf0e10cSrcweir 			SfxItemSet aSet( GetAttrPool(), RES_FRM_SIZE, RES_FRM_SIZE,
2659cdf0e10cSrcweir 											RES_SURROUND, RES_ANCHOR, 0 );
2660cdf0e10cSrcweir 			aSet.Put( aAnch );
2661cdf0e10cSrcweir 
2662cdf0e10cSrcweir 			Point aRelNullPt;
2663cdf0e10cSrcweir 
2664cdf0e10cSrcweir 			if( OBJ_CAPTION == nIdent )
2665cdf0e10cSrcweir 				aRelNullPt = ((SdrCaptionObj*)pObj)->GetTailPos();
2666cdf0e10cSrcweir 			else
2667cdf0e10cSrcweir 				aRelNullPt = rBound.TopLeft();
2668cdf0e10cSrcweir 
2669cdf0e10cSrcweir 			aSet.Put( aAnch );
2670cdf0e10cSrcweir 			aSet.Put( SwFmtSurround( SURROUND_THROUGHT ) );
2671cdf0e10cSrcweir             SwFrmFmt* pFmt = getIDocumentLayoutAccess()->MakeLayoutFmt( RND_DRAW_OBJECT, &aSet );
2672cdf0e10cSrcweir 
2673cdf0e10cSrcweir 			SwDrawContact *pContact = new SwDrawContact(
2674cdf0e10cSrcweir 											(SwDrawFrmFmt*)pFmt, pObj );
2675cdf0e10cSrcweir 
2676cdf0e10cSrcweir             // --> OD 2004-11-22 #i35635#
2677cdf0e10cSrcweir             pContact->MoveObjToVisibleLayer( pObj );
2678cdf0e10cSrcweir             // <--
2679cdf0e10cSrcweir             pContact->ConnectToLayout();
2680cdf0e10cSrcweir 
2681cdf0e10cSrcweir 			EndAllAction();
2682cdf0e10cSrcweir 		}
2683cdf0e10cSrcweir 	}
2684cdf0e10cSrcweir }
2685cdf0e10cSrcweir 
SetCalcFieldValueHdl(Outliner * pOutliner)2686cdf0e10cSrcweir void SwFEShell::SetCalcFieldValueHdl(Outliner* pOutliner)
2687cdf0e10cSrcweir {
2688cdf0e10cSrcweir 	GetDoc()->SetCalcFieldValueHdl(pOutliner);
2689cdf0e10cSrcweir }
2690cdf0e10cSrcweir 
2691cdf0e10cSrcweir 
2692cdf0e10cSrcweir 
Chainable(SwRect & rRect,const SwFrmFmt & rSource,const Point & rPt) const2693cdf0e10cSrcweir int SwFEShell::Chainable( SwRect &rRect, const SwFrmFmt &rSource,
2694cdf0e10cSrcweir 							const Point &rPt ) const
2695cdf0e10cSrcweir {
2696cdf0e10cSrcweir 	rRect.Clear();
2697cdf0e10cSrcweir 
2698cdf0e10cSrcweir 	//Die Source darf noch keinen Follow haben.
2699cdf0e10cSrcweir 	const SwFmtChain &rChain = rSource.GetChain();
2700cdf0e10cSrcweir 	if ( rChain.GetNext() )
2701cdf0e10cSrcweir 		return SW_CHAIN_SOURCE_CHAINED;
2702cdf0e10cSrcweir 
2703cdf0e10cSrcweir 	if( Imp()->HasDrawView() )
2704cdf0e10cSrcweir 	{
2705cdf0e10cSrcweir 		SdrObject* pObj;
2706cdf0e10cSrcweir 		SdrPageView* pPView;
2707cdf0e10cSrcweir 		SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
2708cdf0e10cSrcweir 		const sal_uInt16 nOld = pDView->GetHitTolerancePixel();
2709cdf0e10cSrcweir 		pDView->SetHitTolerancePixel( 0 );
2710cdf0e10cSrcweir 		if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) &&
2711cdf0e10cSrcweir 			pObj->ISA(SwVirtFlyDrawObj) )
2712cdf0e10cSrcweir 		{
2713cdf0e10cSrcweir 			SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
2714cdf0e10cSrcweir 			rRect = pFly->Frm();
2715cdf0e10cSrcweir 
2716cdf0e10cSrcweir 			//Ziel darf natuerlich nicht gleich Source sein und es
2717cdf0e10cSrcweir 			//darf keine geschlossene Kette entstehen.
2718cdf0e10cSrcweir 			SwFrmFmt *pFmt = pFly->GetFmt();
2719cdf0e10cSrcweir 			return GetDoc()->Chainable(rSource, *pFmt);
2720cdf0e10cSrcweir 		}
2721cdf0e10cSrcweir 		pDView->SetHitTolerancePixel( nOld );
2722cdf0e10cSrcweir 	}
2723cdf0e10cSrcweir 	return SW_CHAIN_NOT_FOUND;
2724cdf0e10cSrcweir }
2725cdf0e10cSrcweir 
Chain(SwFrmFmt & rSource,const SwFrmFmt & rDest)2726cdf0e10cSrcweir int SwFEShell::Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest )
2727cdf0e10cSrcweir {
2728cdf0e10cSrcweir     return GetDoc()->Chain(rSource, rDest);
2729cdf0e10cSrcweir }
2730cdf0e10cSrcweir 
Chain(SwFrmFmt & rSource,const Point & rPt)2731cdf0e10cSrcweir int SwFEShell::Chain( SwFrmFmt &rSource, const Point &rPt )
2732cdf0e10cSrcweir {
2733cdf0e10cSrcweir 	SwRect aDummy;
2734cdf0e10cSrcweir 	int nErr = Chainable( aDummy, rSource, rPt );
2735cdf0e10cSrcweir 	if ( !nErr )
2736cdf0e10cSrcweir 	{
2737cdf0e10cSrcweir 		StartAllAction();
2738cdf0e10cSrcweir 		SdrObject* pObj;
2739cdf0e10cSrcweir 		SdrPageView* pPView;
2740cdf0e10cSrcweir 		SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
2741cdf0e10cSrcweir 		const sal_uInt16 nOld = pDView->GetHitTolerancePixel();
2742cdf0e10cSrcweir 		pDView->SetHitTolerancePixel( 0 );
2743cdf0e10cSrcweir 		pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE );
2744cdf0e10cSrcweir 		pDView->SetHitTolerancePixel( nOld );
2745cdf0e10cSrcweir 		SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
2746cdf0e10cSrcweir 
2747cdf0e10cSrcweir 		SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)pFly->GetFmt();
2748cdf0e10cSrcweir 		GetDoc()->Chain(rSource, *pFmt);
2749cdf0e10cSrcweir 		EndAllAction();
2750cdf0e10cSrcweir 		SetChainMarker();
2751cdf0e10cSrcweir 	}
2752cdf0e10cSrcweir 	return nErr;
2753cdf0e10cSrcweir }
2754cdf0e10cSrcweir 
Unchain(SwFrmFmt & rFmt)2755cdf0e10cSrcweir void SwFEShell::Unchain( SwFrmFmt &rFmt )
2756cdf0e10cSrcweir {
2757cdf0e10cSrcweir 	StartAllAction();
2758cdf0e10cSrcweir 	GetDoc()->Unchain(rFmt);
2759cdf0e10cSrcweir 	EndAllAction();
2760cdf0e10cSrcweir }
2761cdf0e10cSrcweir 
2762cdf0e10cSrcweir 
HideChainMarker()2763cdf0e10cSrcweir void SwFEShell::HideChainMarker()
2764cdf0e10cSrcweir {
2765cdf0e10cSrcweir 	if ( pChainFrom )
2766cdf0e10cSrcweir 	{
2767cdf0e10cSrcweir 		delete pChainFrom;
2768cdf0e10cSrcweir 		pChainFrom = 0L;
2769cdf0e10cSrcweir 	}
2770cdf0e10cSrcweir 	if ( pChainTo )
2771cdf0e10cSrcweir 	{
2772cdf0e10cSrcweir 		delete pChainTo;
2773cdf0e10cSrcweir 		pChainTo = 0L;
2774cdf0e10cSrcweir 	}
2775cdf0e10cSrcweir }
2776cdf0e10cSrcweir 
SetChainMarker()2777cdf0e10cSrcweir void SwFEShell::SetChainMarker()
2778cdf0e10cSrcweir {
2779cdf0e10cSrcweir 	sal_Bool bDelFrom = sal_True,
2780cdf0e10cSrcweir 			 bDelTo	  = sal_True;
2781cdf0e10cSrcweir 	if ( IsFrmSelected() )
2782cdf0e10cSrcweir 	{
2783cdf0e10cSrcweir 		SwFlyFrm *pFly = FindFlyFrm();
2784cdf0e10cSrcweir 
2785cdf0e10cSrcweir 		if ( pFly->GetPrevLink() )
2786cdf0e10cSrcweir 		{
2787cdf0e10cSrcweir 			bDelFrom = sal_False;
2788cdf0e10cSrcweir 			const SwFrm *pPre = pFly->GetPrevLink();
2789cdf0e10cSrcweir 
2790cdf0e10cSrcweir 			Point aStart( pPre->Frm().Right(), pPre->Frm().Bottom());
2791cdf0e10cSrcweir 			Point aEnd(pFly->Frm().Pos());
2792cdf0e10cSrcweir 
2793cdf0e10cSrcweir 			if ( !pChainFrom )
2794cdf0e10cSrcweir 			{
2795cdf0e10cSrcweir 				pChainFrom = new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd );
2796cdf0e10cSrcweir 			}
2797cdf0e10cSrcweir 		}
2798cdf0e10cSrcweir 		if ( pFly->GetNextLink() )
2799cdf0e10cSrcweir 		{
2800cdf0e10cSrcweir 			bDelTo = sal_False;
2801cdf0e10cSrcweir 			const SwFlyFrm *pNxt = pFly->GetNextLink();
2802cdf0e10cSrcweir 
2803cdf0e10cSrcweir 			Point aStart( pFly->Frm().Right(), pFly->Frm().Bottom());
2804cdf0e10cSrcweir 			Point aEnd(pNxt->Frm().Pos());
2805cdf0e10cSrcweir 
2806cdf0e10cSrcweir 			if ( !pChainTo )
2807cdf0e10cSrcweir 			{
2808cdf0e10cSrcweir 				pChainTo = new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd );
2809cdf0e10cSrcweir 			}
2810cdf0e10cSrcweir 		}
2811cdf0e10cSrcweir 	}
2812cdf0e10cSrcweir 
2813cdf0e10cSrcweir 	if ( bDelFrom )
2814cdf0e10cSrcweir 	{
2815cdf0e10cSrcweir 		delete pChainFrom, pChainFrom = 0;
2816cdf0e10cSrcweir 	}
2817cdf0e10cSrcweir 
2818cdf0e10cSrcweir 	if ( bDelTo )
2819cdf0e10cSrcweir 	{
2820cdf0e10cSrcweir 		delete pChainTo,   pChainTo = 0;
2821cdf0e10cSrcweir 	}
2822cdf0e10cSrcweir }
2823cdf0e10cSrcweir 
GetSectionWidth(SwFmt & rFmt) const2824cdf0e10cSrcweir long SwFEShell::GetSectionWidth( SwFmt& rFmt ) const
2825cdf0e10cSrcweir {
2826cdf0e10cSrcweir 	SwFrm *pFrm = GetCurrFrm();
2827cdf0e10cSrcweir 	// Steht der Cursor z.Z. in einem SectionFrm?
2828cdf0e10cSrcweir 	if( pFrm && pFrm->IsInSct() )
2829cdf0e10cSrcweir 	{
2830cdf0e10cSrcweir 		SwSectionFrm* pSect = pFrm->FindSctFrm();
2831cdf0e10cSrcweir 		do
2832cdf0e10cSrcweir 		{
2833cdf0e10cSrcweir 			// Ist es der Gewuenschte?
2834cdf0e10cSrcweir 			if( pSect->KnowsFormat( rFmt ) )
2835cdf0e10cSrcweir 				return pSect->Frm().Width();
2836cdf0e10cSrcweir 			// fuer geschachtelte Bereiche
2837cdf0e10cSrcweir 			pSect = pSect->GetUpper()->FindSctFrm();
2838cdf0e10cSrcweir 		}
2839cdf0e10cSrcweir 		while( pSect );
2840cdf0e10cSrcweir 	}
2841cdf0e10cSrcweir 	SwIterator<SwSectionFrm,SwFmt> aIter( rFmt );
2842d816a317SMichael Stahl     for ( SwSectionFrm* pSct = aIter.First(); pSct; pSct = aIter.Next() )
2843d816a317SMichael Stahl     {
2844cdf0e10cSrcweir         if( !pSct->IsFollow() )
2845d816a317SMichael Stahl         {
2846cdf0e10cSrcweir             return pSct->Frm().Width();
2847d816a317SMichael Stahl         }
2848d816a317SMichael Stahl     }
2849cdf0e10cSrcweir 	return 0;
2850cdf0e10cSrcweir }
2851cdf0e10cSrcweir 
CreateDefaultShape(sal_uInt16 eSdrObjectKind,const Rectangle & rRect,sal_uInt16 nSlotId)2852cdf0e10cSrcweir void SwFEShell::CreateDefaultShape( sal_uInt16 /*SdrObjKind ?*/ eSdrObjectKind, const Rectangle& rRect,
2853cdf0e10cSrcweir                 sal_uInt16 nSlotId)
2854cdf0e10cSrcweir {
2855cdf0e10cSrcweir     SdrView* pDrawView = GetDrawView();
2856cdf0e10cSrcweir     SdrModel* pDrawModel = pDrawView->GetModel();
2857cdf0e10cSrcweir     SdrObject* pObj = SdrObjFactory::MakeNewObject(
2858cdf0e10cSrcweir         SdrInventor, eSdrObjectKind,
2859cdf0e10cSrcweir         0L, pDrawModel);
2860cdf0e10cSrcweir 
2861cdf0e10cSrcweir 	if(pObj)
2862cdf0e10cSrcweir 	{
2863cdf0e10cSrcweir         Rectangle aRect(rRect);
2864cdf0e10cSrcweir         if(OBJ_CARC == eSdrObjectKind || OBJ_CCUT == eSdrObjectKind)
2865cdf0e10cSrcweir         {
2866cdf0e10cSrcweir             // force quadratic
2867cdf0e10cSrcweir             if(aRect.GetWidth() > aRect.GetHeight())
2868cdf0e10cSrcweir             {
2869cdf0e10cSrcweir                 aRect = Rectangle(
2870cdf0e10cSrcweir                     Point(aRect.Left() + ((aRect.GetWidth() - aRect.GetHeight()) / 2), aRect.Top()),
2871cdf0e10cSrcweir                     Size(aRect.GetHeight(), aRect.GetHeight()));
2872cdf0e10cSrcweir             }
2873cdf0e10cSrcweir             else
2874cdf0e10cSrcweir             {
2875cdf0e10cSrcweir                 aRect = Rectangle(
2876cdf0e10cSrcweir                     Point(aRect.Left(), aRect.Top() + ((aRect.GetHeight() - aRect.GetWidth()) / 2)),
2877cdf0e10cSrcweir                     Size(aRect.GetWidth(), aRect.GetWidth()));
2878cdf0e10cSrcweir             }
2879cdf0e10cSrcweir         }
2880cdf0e10cSrcweir         pObj->SetLogicRect(aRect);
2881cdf0e10cSrcweir 
2882cdf0e10cSrcweir         if(pObj->ISA(SdrCircObj))
2883cdf0e10cSrcweir 		{
2884cdf0e10cSrcweir             SfxItemSet aAttr(pDrawModel->GetItemPool());
2885cdf0e10cSrcweir 			aAttr.Put(SdrCircStartAngleItem(9000));
2886cdf0e10cSrcweir 			aAttr.Put(SdrCircEndAngleItem(0));
2887cdf0e10cSrcweir 			pObj->SetMergedItemSet(aAttr);
2888cdf0e10cSrcweir         }
2889cdf0e10cSrcweir         else if(pObj->ISA(SdrPathObj))
2890cdf0e10cSrcweir 		{
2891cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aPoly;
2892cdf0e10cSrcweir 
2893cdf0e10cSrcweir             switch(eSdrObjectKind)
2894cdf0e10cSrcweir 			{
2895cdf0e10cSrcweir                 case OBJ_PATHLINE:
2896cdf0e10cSrcweir 				{
2897cdf0e10cSrcweir 					basegfx::B2DPolygon aInnerPoly;
2898cdf0e10cSrcweir 
2899cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
2900cdf0e10cSrcweir 
2901cdf0e10cSrcweir 					const basegfx::B2DPoint aCenterBottom(aRect.Center().X(), aRect.Bottom());
2902cdf0e10cSrcweir 					aInnerPoly.appendBezierSegment(
2903cdf0e10cSrcweir 						aCenterBottom,
2904cdf0e10cSrcweir 						aCenterBottom,
2905cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Center().X(), aRect.Center().Y()));
2906cdf0e10cSrcweir 
2907cdf0e10cSrcweir 					const basegfx::B2DPoint aCenterTop(aRect.Center().X(), aRect.Top());
2908cdf0e10cSrcweir 					aInnerPoly.appendBezierSegment(
2909cdf0e10cSrcweir 						aCenterTop,
2910cdf0e10cSrcweir 						aCenterTop,
2911cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Right(), aRect.Top()));
2912cdf0e10cSrcweir 
2913cdf0e10cSrcweir 					aInnerPoly.setClosed(true);
2914cdf0e10cSrcweir 					aPoly.append(aInnerPoly);
2915cdf0e10cSrcweir                 }
2916cdf0e10cSrcweir                 break;
2917cdf0e10cSrcweir                 case OBJ_FREELINE:
2918cdf0e10cSrcweir 				{
2919cdf0e10cSrcweir 					basegfx::B2DPolygon aInnerPoly;
2920cdf0e10cSrcweir 
2921cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
2922cdf0e10cSrcweir 
2923cdf0e10cSrcweir 					aInnerPoly.appendBezierSegment(
2924cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Left(), aRect.Top()),
2925cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Center().X(), aRect.Top()),
2926cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Center().X(), aRect.Center().Y()));
2927cdf0e10cSrcweir 
2928cdf0e10cSrcweir 					aInnerPoly.appendBezierSegment(
2929cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Center().X(), aRect.Bottom()),
2930cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Right(), aRect.Bottom()),
2931cdf0e10cSrcweir 						basegfx::B2DPoint(aRect.Right(), aRect.Top()));
2932cdf0e10cSrcweir 
2933cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
2934cdf0e10cSrcweir 					aInnerPoly.setClosed(true);
2935cdf0e10cSrcweir 					aPoly.append(aInnerPoly);
2936cdf0e10cSrcweir                 }
2937cdf0e10cSrcweir                 break;
2938cdf0e10cSrcweir                 case OBJ_POLY:
2939cdf0e10cSrcweir                 case OBJ_PLIN:
2940cdf0e10cSrcweir 				{
2941cdf0e10cSrcweir 					basegfx::B2DPolygon aInnerPoly;
2942cdf0e10cSrcweir                     sal_Int32 nWdt(aRect.GetWidth());
2943cdf0e10cSrcweir                     sal_Int32 nHgt(aRect.GetHeight());
2944cdf0e10cSrcweir 
2945cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
2946cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 30) / 100, aRect.Top() + (nHgt * 70) / 100));
2947cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top() + (nHgt * 15) / 100));
2948cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 65) / 100, aRect.Top()));
2949cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + nWdt, aRect.Top() + (nHgt * 30) / 100));
2950cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 50) / 100));
2951cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 75) / 100));
2952cdf0e10cSrcweir 					aInnerPoly.append(basegfx::B2DPoint(aRect.Bottom(), aRect.Right()));
2953cdf0e10cSrcweir 
2954cdf0e10cSrcweir                     if(OBJ_PLIN == eSdrObjectKind)
2955cdf0e10cSrcweir 					{
2956cdf0e10cSrcweir 						aInnerPoly.append(basegfx::B2DPoint(aRect.Center().X(), aRect.Bottom()));
2957cdf0e10cSrcweir 					}
2958cdf0e10cSrcweir 					else
2959cdf0e10cSrcweir 					{
2960cdf0e10cSrcweir 						aInnerPoly.setClosed(true);
2961cdf0e10cSrcweir 					}
2962cdf0e10cSrcweir 
2963cdf0e10cSrcweir 					aPoly.append(aInnerPoly);
2964cdf0e10cSrcweir                 }
2965cdf0e10cSrcweir                 break;
2966cdf0e10cSrcweir                 case OBJ_LINE :
2967cdf0e10cSrcweir                 {
2968cdf0e10cSrcweir 					sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
2969cdf0e10cSrcweir 					basegfx::B2DPolygon aTempPoly;
2970cdf0e10cSrcweir 					aTempPoly.append(basegfx::B2DPoint(aRect.TopLeft().X(), nYMiddle));
2971cdf0e10cSrcweir 					aTempPoly.append(basegfx::B2DPoint(aRect.BottomRight().X(), nYMiddle));
2972cdf0e10cSrcweir 					aPoly.append(aTempPoly);
2973cdf0e10cSrcweir                 }
2974cdf0e10cSrcweir                 break;
2975cdf0e10cSrcweir 			}
2976cdf0e10cSrcweir 
2977cdf0e10cSrcweir 			((SdrPathObj*)pObj)->SetPathPoly(aPoly);
2978cdf0e10cSrcweir 		}
2979cdf0e10cSrcweir         else if(pObj->ISA(SdrCaptionObj))
2980cdf0e10cSrcweir         {
2981cdf0e10cSrcweir             sal_Bool bVerticalText = ( SID_DRAW_TEXT_VERTICAL == nSlotId ||
2982cdf0e10cSrcweir                                             SID_DRAW_CAPTION_VERTICAL == nSlotId );
2983cdf0e10cSrcweir             ((SdrTextObj*)pObj)->SetVerticalWriting(bVerticalText);
2984cdf0e10cSrcweir             if(bVerticalText)
2985cdf0e10cSrcweir             {
2986cdf0e10cSrcweir                 SfxItemSet aSet(pObj->GetMergedItemSet());
2987cdf0e10cSrcweir                 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
2988cdf0e10cSrcweir                 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
2989cdf0e10cSrcweir                 pObj->SetMergedItemSet(aSet);
2990cdf0e10cSrcweir             }
2991cdf0e10cSrcweir 
2992cdf0e10cSrcweir             ((SdrCaptionObj*)pObj)->SetLogicRect(aRect);
2993cdf0e10cSrcweir             ((SdrCaptionObj*)pObj)->SetTailPos(
2994cdf0e10cSrcweir                 aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
2995cdf0e10cSrcweir         }
2996cdf0e10cSrcweir         else if(pObj->ISA(SdrTextObj))
2997cdf0e10cSrcweir         {
2998cdf0e10cSrcweir             SdrTextObj* pText = (SdrTextObj*)pObj;
2999cdf0e10cSrcweir             pText->SetLogicRect(aRect);
3000cdf0e10cSrcweir 
3001cdf0e10cSrcweir             sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotId);
3002cdf0e10cSrcweir             sal_Bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nSlotId);
3003cdf0e10cSrcweir 
3004cdf0e10cSrcweir 			pText->SetVerticalWriting(bVertical);
3005cdf0e10cSrcweir 
3006cdf0e10cSrcweir 			if(bVertical)
3007cdf0e10cSrcweir 			{
3008cdf0e10cSrcweir                 SfxItemSet aSet(pDrawModel->GetItemPool());
3009cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
3010cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
3011cdf0e10cSrcweir 				aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
3012cdf0e10cSrcweir 				aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
3013cdf0e10cSrcweir 				pText->SetMergedItemSet(aSet);
3014cdf0e10cSrcweir 			}
3015cdf0e10cSrcweir 
3016cdf0e10cSrcweir 			if(bMarquee)
3017cdf0e10cSrcweir 			{
3018cdf0e10cSrcweir                 SfxItemSet aSet(pDrawModel->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
3019cdf0e10cSrcweir 				aSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
3020cdf0e10cSrcweir 				aSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
3021cdf0e10cSrcweir 				aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
3022cdf0e10cSrcweir 				aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
3023cdf0e10cSrcweir 				aSet.Put( SdrTextAniCountItem( 1 ) );
3024cdf0e10cSrcweir                 aSet.Put( SdrTextAniAmountItem( (sal_Int16)GetWin()->PixelToLogic(Size(2,1)).Width()) );
3025cdf0e10cSrcweir 				pObj->SetMergedItemSetAndBroadcast(aSet);
3026cdf0e10cSrcweir 			}
3027cdf0e10cSrcweir         }
3028cdf0e10cSrcweir         SdrPageView* pPageView = pDrawView->GetSdrPageView();
3029cdf0e10cSrcweir         pDrawView->InsertObjectAtView(pObj, *pPageView);
3030cdf0e10cSrcweir     }
3031cdf0e10cSrcweir     ImpEndCreate();
3032cdf0e10cSrcweir }
3033cdf0e10cSrcweir 
3034cdf0e10cSrcweir /** SwFEShell::GetShapeBackgrd
3035cdf0e10cSrcweir 
3036cdf0e10cSrcweir     OD 02.09.2002 for #102450#:
3037cdf0e10cSrcweir     method determines background color of the page the selected drawing
3038cdf0e10cSrcweir     object is on and returns this color.
3039cdf0e10cSrcweir     If no color is found, because no drawing object is selected or ...,
3040cdf0e10cSrcweir     color COL_BLACK (default color on constructing object of class Color)
3041cdf0e10cSrcweir     is returned.
3042cdf0e10cSrcweir 
3043cdf0e10cSrcweir     @author OD
3044cdf0e10cSrcweir 
3045cdf0e10cSrcweir     @returns an object of class Color
3046cdf0e10cSrcweir */
GetShapeBackgrd() const3047cdf0e10cSrcweir const Color SwFEShell::GetShapeBackgrd() const
3048cdf0e10cSrcweir {
3049cdf0e10cSrcweir     Color aRetColor;
3050cdf0e10cSrcweir 
3051cdf0e10cSrcweir     // check, if a draw view exists
3052cdf0e10cSrcweir     ASSERT( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackgrd - no draw view!");
3053cdf0e10cSrcweir     if( Imp()->GetDrawView() )
3054cdf0e10cSrcweir     {
3055cdf0e10cSrcweir         // determine list of selected objects
3056cdf0e10cSrcweir         const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3057cdf0e10cSrcweir         // check, if exactly one object is selected.
3058cdf0e10cSrcweir         ASSERT( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackgrd - no selected object!");
3059cdf0e10cSrcweir         if ( pMrkList->GetMarkCount() == 1)
3060cdf0e10cSrcweir         {
3061cdf0e10cSrcweir             // get selected object
3062cdf0e10cSrcweir             const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3063cdf0e10cSrcweir             // check, if selected object is a shape (drawing object)
3064cdf0e10cSrcweir             ASSERT( !pSdrObj->ISA(SwVirtFlyDrawObj), "wrong usage of SwFEShell::GetShapeBackgrd - selected object is not a drawing object!");
3065cdf0e10cSrcweir             if ( !pSdrObj->ISA(SwVirtFlyDrawObj) )
3066cdf0e10cSrcweir             {
3067cdf0e10cSrcweir                 // determine page frame of the frame the shape is anchored.
3068cdf0e10cSrcweir                 const SwFrm* pAnchorFrm =
3069cdf0e10cSrcweir                         static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrm( pSdrObj );
3070cdf0e10cSrcweir                 ASSERT( pAnchorFrm, "inconsistent modell - no anchor at shape!");
3071cdf0e10cSrcweir                 if ( pAnchorFrm )
3072cdf0e10cSrcweir                 {
3073cdf0e10cSrcweir                     const SwPageFrm* pPageFrm = pAnchorFrm->FindPageFrm();
3074cdf0e10cSrcweir                     ASSERT( pPageFrm, "inconsistent modell - no page!");
3075cdf0e10cSrcweir                     if ( pPageFrm )
3076cdf0e10cSrcweir                     {
3077cdf0e10cSrcweir                         aRetColor = pPageFrm->GetDrawBackgrdColor();
3078cdf0e10cSrcweir                     }
3079cdf0e10cSrcweir                 }
3080cdf0e10cSrcweir             }
3081cdf0e10cSrcweir         }
3082cdf0e10cSrcweir     }
3083cdf0e10cSrcweir 
3084cdf0e10cSrcweir     return aRetColor;
3085cdf0e10cSrcweir }
3086cdf0e10cSrcweir 
3087cdf0e10cSrcweir /** Is default horizontal text direction for selected drawing object right-to-left
3088cdf0e10cSrcweir 
3089cdf0e10cSrcweir     OD 09.12.2002 #103045#
3090cdf0e10cSrcweir     Because drawing objects only painted for each page only, the default
3091cdf0e10cSrcweir     horizontal text direction of a drawing object is given by the corresponding
3092cdf0e10cSrcweir     page property.
3093cdf0e10cSrcweir 
3094cdf0e10cSrcweir     @author OD
3095cdf0e10cSrcweir 
3096cdf0e10cSrcweir     @returns boolean, indicating, if the horizontal text direction of the
3097cdf0e10cSrcweir     page, the selected drawing object is on, is right-to-left.
3098cdf0e10cSrcweir */
IsShapeDefaultHoriTextDirR2L() const3099cdf0e10cSrcweir bool SwFEShell::IsShapeDefaultHoriTextDirR2L() const
3100cdf0e10cSrcweir {
3101cdf0e10cSrcweir     bool bRet = false;
3102cdf0e10cSrcweir 
3103cdf0e10cSrcweir     // check, if a draw view exists
3104cdf0e10cSrcweir     ASSERT( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackgrd - no draw view!");
3105cdf0e10cSrcweir     if( Imp()->GetDrawView() )
3106cdf0e10cSrcweir     {
3107cdf0e10cSrcweir         // determine list of selected objects
3108cdf0e10cSrcweir         const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3109cdf0e10cSrcweir         // check, if exactly one object is selected.
3110cdf0e10cSrcweir         ASSERT( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackgrd - no selected object!");
3111cdf0e10cSrcweir         if ( pMrkList->GetMarkCount() == 1)
3112cdf0e10cSrcweir         {
3113cdf0e10cSrcweir             // get selected object
3114cdf0e10cSrcweir             const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3115cdf0e10cSrcweir             // check, if selected object is a shape (drawing object)
3116cdf0e10cSrcweir             ASSERT( !pSdrObj->ISA(SwVirtFlyDrawObj), "wrong usage of SwFEShell::GetShapeBackgrd - selected object is not a drawing object!");
3117cdf0e10cSrcweir             if ( !pSdrObj->ISA(SwVirtFlyDrawObj) )
3118cdf0e10cSrcweir             {
3119cdf0e10cSrcweir                 // determine page frame of the frame the shape is anchored.
3120cdf0e10cSrcweir                 const SwFrm* pAnchorFrm =
3121cdf0e10cSrcweir                         static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrm( pSdrObj );
3122cdf0e10cSrcweir                 ASSERT( pAnchorFrm, "inconsistent modell - no anchor at shape!");
3123cdf0e10cSrcweir                 if ( pAnchorFrm )
3124cdf0e10cSrcweir                 {
3125cdf0e10cSrcweir                     const SwPageFrm* pPageFrm = pAnchorFrm->FindPageFrm();
3126cdf0e10cSrcweir                     ASSERT( pPageFrm, "inconsistent modell - no page!");
3127cdf0e10cSrcweir                     if ( pPageFrm )
3128cdf0e10cSrcweir                     {
3129cdf0e10cSrcweir                         bRet = pPageFrm->IsRightToLeft() ? true : false;
3130cdf0e10cSrcweir                     }
3131cdf0e10cSrcweir                 }
3132cdf0e10cSrcweir             }
3133cdf0e10cSrcweir         }
3134cdf0e10cSrcweir     }
3135cdf0e10cSrcweir 
3136cdf0e10cSrcweir     return bRet;
3137cdf0e10cSrcweir }
3138cdf0e10cSrcweir 
GetRelativePagePosition(const Point & rDocPos)3139cdf0e10cSrcweir Point SwFEShell::GetRelativePagePosition(const Point& rDocPos)
3140cdf0e10cSrcweir {
3141cdf0e10cSrcweir     Point aRet(-1, -1);
3142cdf0e10cSrcweir     const SwFrm *pPage = GetLayout()->Lower();
3143cdf0e10cSrcweir     while ( pPage && !pPage->Frm().IsInside( rDocPos ) )
3144cdf0e10cSrcweir     {
3145cdf0e10cSrcweir         pPage = pPage->GetNext();
3146cdf0e10cSrcweir     }
3147cdf0e10cSrcweir     if(pPage)
3148cdf0e10cSrcweir     {
3149cdf0e10cSrcweir         aRet = rDocPos - pPage->Frm().TopLeft();
3150cdf0e10cSrcweir     }
3151cdf0e10cSrcweir     return aRet;
3152cdf0e10cSrcweir }
3153cdf0e10cSrcweir 
3154