LCOV - code coverage report
Current view: top level - sw/source/core/frmedt - feshview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 61 1471 4.1 %
Date: 2012-08-25 Functions: 11 78 14.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 2382 1.4 %

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

Generated by: LCOV version 1.10