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