LCOV - code coverage report
Current view: top level - sw/source/core/frmedt - fefly1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 75 995 7.5 %
Date: 2012-08-25 Functions: 6 47 12.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 56 1876 3.0 %

           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 <hintids.hxx>
      31                 :            : #include <svl/itemiter.hxx>
      32                 :            : #include <svtools/imapobj.hxx>
      33                 :            : #include <svtools/soerr.hxx>
      34                 :            : #include <editeng/protitem.hxx>
      35                 :            : #include <svx/svdogrp.hxx>
      36                 :            : #include <svx/svdouno.hxx>
      37                 :            : #include <svx/fmglob.hxx>
      38                 :            : #include <com/sun/star/form/FormButtonType.hpp>
      39                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      40                 :            : #include <fmtanchr.hxx>
      41                 :            : #include <txtflcnt.hxx>
      42                 :            : #include <fmtcntnt.hxx>
      43                 :            : #include <fmtornt.hxx>
      44                 :            : #include <fmtflcnt.hxx>
      45                 :            : #include <fmturl.hxx>
      46                 :            : #include <fmtclds.hxx>
      47                 :            : #include <fmtfsize.hxx>
      48                 :            : #include <docary.hxx>
      49                 :            : #include <fesh.hxx>
      50                 :            : #include <rootfrm.hxx>
      51                 :            : #include <pagefrm.hxx>
      52                 :            : #include <cntfrm.hxx>
      53                 :            : #include <txtfrm.hxx>
      54                 :            : #include <viewimp.hxx>
      55                 :            : #include <viscrs.hxx>
      56                 :            : #include <doc.hxx>
      57                 :            : #include <IDocumentUndoRedo.hxx>
      58                 :            : #include <dview.hxx>
      59                 :            : #include <dflyobj.hxx>
      60                 :            : #include <dcontact.hxx>
      61                 :            : #include <frmfmt.hxx>
      62                 :            : #include <flyfrm.hxx>
      63                 :            : #include <ndtxt.hxx>
      64                 :            : #include <edimp.hxx>
      65                 :            : #include <swtable.hxx>
      66                 :            : #include <mvsave.hxx>       // storage structures for Move/Delete
      67                 :            : #include <ndgrf.hxx>
      68                 :            : #include <flyfrms.hxx>
      69                 :            : #include <flypos.hxx>
      70                 :            : #include <fldbas.hxx>
      71                 :            : #include <fmtfld.hxx>
      72                 :            : #include <swundo.hxx>
      73                 :            : #include <frame.hxx>
      74                 :            : #include <notxtfrm.hxx>
      75                 :            : #include <HandleAnchorNodeChg.hxx>
      76                 :            : #include <frmatr.hxx>
      77                 :            : #include <fmtsrnd.hxx> // #i89920#
      78                 :            : #include <ndole.hxx>
      79                 :            : #include <editeng/opaqitem.hxx>
      80                 :            : 
      81                 :            : using ::rtl::OUString;
      82                 :            : using namespace ::com::sun::star;
      83                 :            : 
      84                 :            : // To register Flys in Flys in ...
      85                 :            : // as defined in layout/frmtool.cxx
      86                 :            : void RegistFlys( SwPageFrm*, const SwLayoutFrm* );
      87                 :            : 
      88                 :            : /***********************************************************************
      89                 :            : #*  Class       :  SwDoc
      90                 :            : #*  Methode     :  UseSpzLayoutFmt
      91                 :            : #*  Description :  based on the request, changes to the specific layouts
      92                 :            : #*                 will be made, to fit to the format
      93                 :            : #***********************************************************************/
      94                 :            : 
      95                 :          0 : sal_Bool lcl_SetNewFlyPos( const SwNode& rNode, SwFmtAnchor& rAnchor,
      96                 :            :                         const Point& rPt )
      97                 :            : {
      98                 :          0 :     sal_Bool bRet = sal_False;
      99                 :          0 :     const SwStartNode* pStNode = rNode.FindFlyStartNode();
     100         [ #  # ]:          0 :     if( pStNode )
     101                 :            :     {
     102         [ #  # ]:          0 :         SwPosition aPos( *pStNode );
     103         [ #  # ]:          0 :         rAnchor.SetAnchor( &aPos );
     104         [ #  # ]:          0 :         bRet = sal_True;
     105                 :            :     }
     106                 :            :     else
     107                 :            :     {
     108                 :          0 :         const SwCntntNode *pCntNd = rNode.GetCntntNode();
     109         [ #  # ]:          0 :         const SwCntntFrm* pCFrm = pCntNd ? pCntNd->getLayoutFrm( pCntNd->GetDoc()->GetCurrentLayout(), &rPt, 0, sal_False ) : 0;
     110         [ #  # ]:          0 :         const SwPageFrm *pPg = pCFrm ? pCFrm->FindPageFrm() : 0;
     111                 :            : 
     112         [ #  # ]:          0 :         rAnchor.SetPageNum( pPg ? pPg->GetPhyPageNum() : 1 );
     113                 :          0 :         rAnchor.SetType( FLY_AT_PAGE );
     114                 :            :     }
     115                 :          0 :     return bRet;
     116                 :            : }
     117                 :            : 
     118                 :         10 : sal_Bool lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm,
     119                 :            :                         SfxItemSet& rSet )
     120                 :            : {
     121                 :         10 :     sal_Bool bRet = sal_True;
     122 [ +  - ][ +  - ]:         10 :     SwFmtAnchor aNewAnch( (SwFmtAnchor&)rSet.Get( RES_ANCHOR ) );
     123                 :         10 :     RndStdIds nNew = aNewAnch.GetAnchorId();
     124                 :            :     const SwFrm *pNewAnch;
     125                 :            : 
     126                 :            :     //determine new anchor
     127                 :         10 :     Point aTmpPnt( rPt );
     128   [ +  -  +  - ]:         10 :     switch( nNew )
     129                 :            :     {
     130                 :            :     case FLY_AS_CHAR:  // also include this?
     131                 :            :     case FLY_AT_PARA:
     132                 :            :     case FLY_AT_CHAR: // LAYER_IMPL
     133                 :            :         {
     134                 :            :             // starting from the upper-left corner of the Fly,
     135                 :            :             // search nearest CntntFrm
     136                 :          8 :             const SwFrm* pFrm = rFrm.IsFlyFrm() ? ((SwFlyFrm&)rFrm).GetAnchorFrm()
     137 [ +  - ][ +  - ]:          8 :                                                 : &rFrm;
     138         [ +  - ]:          8 :             pNewAnch = ::FindAnchor( pFrm, aTmpPnt );
     139 [ +  - ][ -  + ]:          8 :             if( pNewAnch->IsProtected() )
     140                 :            :             {
     141                 :          0 :                 bRet = sal_False;
     142                 :            :                 break;
     143                 :            :             }
     144                 :            : 
     145         [ +  - ]:          8 :             SwPosition aPos( *((SwCntntFrm*)pNewAnch)->GetNode() );
     146 [ +  - ][ +  + ]:          8 :             if ((FLY_AT_CHAR == nNew) || (FLY_AS_CHAR == nNew))
     147                 :            :             {
     148                 :            :                 // textnode should be found, as only in those
     149                 :            :                 // a content bound frame can be anchored
     150                 :          4 :                 SwCrsrMoveState aState( MV_SETONLYTEXT );
     151                 :          4 :                 aTmpPnt.X() -= 1;                   // do not land in the fly!
     152 [ -  + ][ +  - ]:          4 :                 if( !pNewAnch->GetCrsrOfst( &aPos, aTmpPnt, &aState ) )
     153                 :            :                 {
     154                 :          0 :                     SwCntntNode* pCNd = ((SwCntntFrm*)pNewAnch)->GetNode();
     155         [ #  # ]:          0 :                     if( pNewAnch->Frm().Bottom() < aTmpPnt.Y() )
     156         [ #  # ]:          0 :                         pCNd->MakeStartIndex( &aPos.nContent );
     157                 :            :                     else
     158         [ #  # ]:          4 :                         pCNd->MakeEndIndex( &aPos.nContent );
     159                 :            :                 }
     160                 :            :             }
     161 [ +  - ][ +  - ]:          8 :             aNewAnch.SetAnchor( &aPos );
     162                 :            :         }
     163                 :          8 :         break;
     164                 :            : 
     165                 :            :     case FLY_AT_FLY: // LAYER_IMPL
     166                 :            :         {
     167                 :            :             // starting from the upper-left corner of the Fly
     168                 :            :             // search nearest SwFlyFrm
     169                 :          0 :             SwCrsrMoveState aState( MV_SETONLYTEXT );
     170 [ #  # ][ #  # ]:          0 :             SwPosition aPos( rDoc.GetNodes() );
         [ #  # ][ #  # ]
     171                 :          0 :             aTmpPnt.X() -= 1;                   // do not land in the fly!
     172 [ #  # ][ #  # ]:          0 :             rDoc.GetCurrentLayout()->GetCrsrOfst( &aPos, aTmpPnt, &aState );    //swmod 071108//swmod 071225
     173                 :            :             pNewAnch = ::FindAnchor(
     174         [ #  # ]:          0 :                 aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( rFrm.getRootFrm(), 0, 0, sal_False ),
     175 [ #  # ][ #  # ]:          0 :                 aTmpPnt )->FindFlyFrm();
     176                 :            : 
     177 [ #  # ][ #  # ]:          0 :             if( pNewAnch && &rFrm != pNewAnch && !pNewAnch->IsProtected() )
         [ #  # ][ #  # ]
                 [ #  # ]
     178                 :            :             {
     179 [ #  # ][ #  # ]:          0 :                 aPos.nNode = *((SwFlyFrm*)pNewAnch)->GetFmt()->GetCntnt().
     180         [ #  # ]:          0 :                                 GetCntntIdx();
     181         [ #  # ]:          0 :                 aNewAnch.SetAnchor( &aPos );
     182                 :            :                 break;
     183 [ #  # ][ #  # ]:          0 :             }
     184                 :            :         }
     185                 :            : 
     186                 :          0 :         aNewAnch.SetType( nNew = FLY_AT_PAGE );
     187                 :            :         // no break
     188                 :            : 
     189                 :            :     case FLY_AT_PAGE:
     190         [ +  - ]:          2 :         pNewAnch = rFrm.FindPageFrm();
     191         [ +  - ]:          2 :         aNewAnch.SetPageNum( pNewAnch->GetPhyPageNum() );
     192                 :          2 :         break;
     193                 :            : 
     194                 :            :     default:
     195                 :            :         OSL_ENSURE( !&rDoc, "Falsche ID fuer neuen Anker." );
     196                 :            :     }
     197                 :            : 
     198         [ +  - ]:         10 :     rSet.Put( aNewAnch );
     199         [ +  - ]:         10 :     return bRet;
     200                 :            : }
     201                 :            : 
     202                 :            : //
     203                 :            : //! also used in unoframe.cxx
     204                 :            : //
     205                 :         14 : sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet )
     206                 :            : {
     207                 :         14 :     const SwFrmFmt& rFmt = *rFly.GetFmt();
     208                 :         14 :     const SwFmtAnchor &rOldAnch = rFmt.GetAnchor();
     209                 :         14 :     const RndStdIds nOld = rOldAnch.GetAnchorId();
     210                 :            : 
     211                 :         14 :     RndStdIds nNew = ((SwFmtAnchor&)rSet.Get( RES_ANCHOR )).GetAnchorId();
     212                 :            : 
     213         [ +  + ]:         14 :     if( nOld == nNew )
     214                 :          4 :         return sal_False;
     215                 :            : 
     216                 :         10 :     SwDoc* pDoc = (SwDoc*)rFmt.GetDoc();
     217                 :            : 
     218                 :            : #if OSL_DEBUG_LEVEL > 0
     219                 :            :     OSL_ENSURE( !(nNew == FLY_AT_PAGE &&
     220                 :            :         (FLY_AT_PARA==nOld || FLY_AT_CHAR==nOld || FLY_AS_CHAR==nOld ) &&
     221                 :            :         pDoc->IsInHeaderFooter( rOldAnch.GetCntntAnchor()->nNode )),
     222                 :            :             "forbidden anchor change in Head/Foot." );
     223                 :            : #endif
     224                 :            : 
     225                 :         14 :     return ::lcl_FindAnchorPos( *pDoc, rFly.Frm().Pos(), rFly, rSet );
     226                 :            : }
     227                 :            : 
     228                 :          0 : void SwFEShell::SelectFlyFrm( SwFlyFrm& rFrm, sal_Bool bNew )
     229                 :            : {
     230         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     231                 :            : 
     232                 :            :     // The frame is new, thus select it.
     233                 :            :     // !! Always select the frame, if it's not selected.
     234                 :            :     // - it could be a new "old" one because the anchor was changed
     235                 :            :     // - "old" frames have had to be selected previously otherwise they could
     236                 :            :     //   not have been changed
     237                 :            :     // The frames should not be selected by the document position, because
     238                 :            :     // it should have been selected!
     239                 :          0 :     SwViewImp *pImpl = Imp();
     240 [ #  # ][ #  # ]:          0 :     if( GetWin() && (bNew || !pImpl->GetDrawView()->AreObjectsMarked()) )
         [ #  # ][ #  # ]
     241                 :            :     {
     242                 :            :         OSL_ENSURE( rFrm.IsFlyFrm(), "SelectFlyFrm will einen Fly" );
     243                 :            : 
     244                 :            :        // nothing to be done if the Fly already was selected
     245 [ #  # ][ #  # ]:          0 :         if ( FindFlyFrm() == &rFrm )
     246                 :          0 :             return;
     247                 :            : 
     248                 :            :         // assure the anchor is drawn
     249 [ #  # ][ #  # ]:          0 :         if( rFrm.IsFlyInCntFrm() && rFrm.GetAnchorFrm() )
         [ #  # ][ #  # ]
     250         [ #  # ]:          0 :              rFrm.GetAnchorFrm()->SetCompletePaint();
     251                 :            : 
     252         [ #  # ]:          0 :         if( pImpl->GetDrawView()->AreObjectsMarked() )
     253         [ #  # ]:          0 :             pImpl->GetDrawView()->UnmarkAll();
     254                 :            : 
     255         [ #  # ]:          0 :         pImpl->GetDrawView()->MarkObj( rFrm.GetVirtDrawObj(),
     256         [ #  # ]:          0 :                                       pImpl->GetPageView(), sal_False, sal_False );
     257         [ #  # ]:          0 :         KillPams();
     258         [ #  # ]:          0 :         ClearMark();
     259         [ #  # ]:          0 :         SelFlyGrabCrsr();
     260 [ #  # ][ #  # ]:          0 :     }
     261                 :            : }
     262                 :            : 
     263                 :            : /*************************************************************************
     264                 :            : |*
     265                 :            : |*  SwFEShell::FindFlyFrm()
     266                 :            : |*
     267                 :            : |*  Description        returns a Fly if one is selected
     268                 :            : |*
     269                 :            : *************************************************************************/
     270                 :            : 
     271                 :       3811 : SwFlyFrm *SwFEShell::FindFlyFrm() const
     272                 :            : {
     273         [ +  - ]:       3811 :     if ( Imp()->HasDrawView() )
     274                 :            :     {
     275                 :            :         // A Fly is only accessible if it is selected
     276                 :       3811 :         const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
     277         [ +  - ]:       3811 :         if( rMrkList.GetMarkCount() != 1 )
     278                 :       3811 :             return 0;
     279                 :            : 
     280                 :          0 :         SdrObject *pO = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     281 [ #  # ][ #  # ]:          0 :         return ( pO && pO->ISA(SwVirtFlyDrawObj) ) ? ((SwVirtFlyDrawObj*)pO)->GetFlyFrm() : 0;
     282                 :            :     }
     283                 :       3811 :     return 0;
     284                 :            : }
     285                 :            : 
     286                 :            : /*************************************************************************
     287                 :            : |*
     288                 :            : |*  SwFEShell::IsFlyInFly()
     289                 :            : |*
     290                 :            : |*  Description        Returns sal_True, if the current Fly could be anchored
     291                 :            : |*                     to another one (so it is inside)
     292                 :            : |*
     293                 :            : *************************************************************************/
     294                 :            : 
     295                 :          0 : const SwFrmFmt* SwFEShell::IsFlyInFly()
     296                 :            : {
     297         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     298                 :            : 
     299         [ #  # ]:          0 :     if ( !Imp()->HasDrawView() )
     300                 :          0 :         return NULL;
     301                 :            : 
     302                 :          0 :     const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
     303         [ #  # ]:          0 :     if ( !rMrkList.GetMarkCount() )
     304                 :            :     {
     305         [ #  # ]:          0 :         SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
     306         [ #  # ]:          0 :         if( !pCntnt )
     307                 :          0 :             return NULL;
     308         [ #  # ]:          0 :         SwFlyFrm *pFly = pCntnt->FindFlyFrm();
     309         [ #  # ]:          0 :         if ( !pFly )
     310                 :          0 :             return NULL;
     311         [ #  # ]:          0 :         return pFly->GetFmt();
     312                 :            :     }
     313 [ #  # ][ #  # ]:          0 :     else if ( rMrkList.GetMarkCount() != 1 ||
                 [ #  # ]
     314 [ #  # ][ #  # ]:          0 :          !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) )
                 [ #  # ]
     315                 :          0 :         return NULL;
     316                 :            : 
     317 [ #  # ][ #  # ]:          0 :     SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     318                 :            : 
     319         [ #  # ]:          0 :     SwFrmFmt *pFmt = FindFrmFmt( pObj );
     320 [ #  # ][ #  # ]:          0 :     if( pFmt && FLY_AT_FLY == pFmt->GetAnchor().GetAnchorId() )
         [ #  # ][ #  # ]
     321                 :            :     {
     322 [ #  # ][ #  # ]:          0 :         const SwFrm* pFly = pObj->ISA(SwVirtFlyDrawObj) ?
     323                 :          0 :             ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetAnchorFrm() :
     324   [ #  #  #  # ]:          0 :             ((SwDrawContact*)GetUserCall(pObj))->GetAnchorFrm( pObj );
         [ #  # ][ #  # ]
     325                 :            :         OSL_ENSURE( pFly, "IsFlyInFly: Where's my anchor?" );
     326                 :            :         OSL_ENSURE( pFly->IsFlyFrm(), "IsFlyInFly: Funny anchor!" );
     327         [ #  # ]:          0 :         return ((SwFlyFrm*)pFly)->GetFmt();
     328                 :            :     }
     329                 :            : 
     330         [ #  # ]:          0 :     Point aTmpPos = pObj->GetCurrentBoundRect().TopLeft();
     331                 :            : 
     332                 :            :     SwFrm *pTxtFrm;
     333                 :            :     {
     334                 :          0 :         SwCrsrMoveState aState( MV_SETONLYTEXT );
     335 [ #  # ][ #  # ]:          0 :         SwNodeIndex aSwNodeIndex( GetDoc()->GetNodes() );
     336         [ #  # ]:          0 :         SwPosition aPos( aSwNodeIndex );
     337                 :          0 :         Point aPoint( aTmpPos );
     338                 :          0 :         aPoint.X() -= 1;                    //do not land in the fly!!
     339 [ #  # ][ #  # ]:          0 :         GetLayout()->GetCrsrOfst( &aPos, aPoint, &aState );
     340                 :            :         // determine text frame by left-top-corner of object
     341 [ #  # ][ #  # ]:          0 :         pTxtFrm = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(), &aTmpPos, 0, sal_False );
         [ #  # ][ #  # ]
     342                 :            :     }
     343         [ #  # ]:          0 :     const SwFrm *pTmp = ::FindAnchor( pTxtFrm, aTmpPos );
     344         [ #  # ]:          0 :     const SwFlyFrm *pFly = pTmp->FindFlyFrm();
     345         [ #  # ]:          0 :     if( pFly )
     346         [ #  # ]:          0 :         return pFly->GetFmt();
     347         [ #  # ]:          0 :     return NULL;
     348                 :            : }
     349                 :            : 
     350                 :            : /*************************************************************************
     351                 :            : |*
     352                 :            : |*  SwFEShell::SetFlyPos
     353                 :            : |*
     354                 :            : *************************************************************************/
     355                 :            : 
     356                 :          0 : void SwFEShell::SetFlyPos( const Point& rAbsPos )
     357                 :            : {
     358         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     359                 :            : 
     360                 :            :     // Determine reference point in document coordinates
     361         [ #  # ]:          0 :     SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
     362         [ #  # ]:          0 :     if( !pCntnt )
     363                 :            :         return;
     364         [ #  # ]:          0 :     SwFlyFrm *pFly = pCntnt->FindFlyFrm();
     365         [ #  # ]:          0 :     if ( !pFly )
     366                 :            :         return;
     367                 :            : 
     368                 :            :     //SwSaveHdl aSaveX( Imp() );
     369                 :            : 
     370                 :            :     // Set an anchor starting from the absolute position for paragraph bound Flys
     371                 :            :     // Anchor and new RelPos will be calculated and set by the Fly
     372         [ #  # ]:          0 :     if ( pFly->IsFlyAtCntFrm() )
     373         [ #  # ]:          0 :         ((SwFlyAtCntFrm*)pFly)->SetAbsPos( rAbsPos );
     374                 :            :     else
     375                 :            :     {
     376         [ #  # ]:          0 :             const SwFrm *pAnch = pFly->GetAnchorFrm();
     377                 :          0 :             Point aOrient( pAnch->Frm().Pos() );
     378                 :            : 
     379         [ #  # ]:          0 :         if ( pFly->IsFlyInCntFrm() )
     380                 :          0 :             aOrient.X() = rAbsPos.X();
     381                 :            : 
     382                 :            :         // calculate RelPos.
     383                 :          0 :         aOrient.X() = rAbsPos.X() - aOrient.X();
     384                 :          0 :         aOrient.Y() = rAbsPos.Y() - aOrient.Y();
     385         [ #  # ]:          0 :         pFly->ChgRelPos( aOrient );
     386                 :            :     }
     387 [ #  # ][ #  # ]:          0 :     CallChgLnk();       // call the AttrChangeNotify on the UI-side.
                 [ #  # ]
     388                 :            : }
     389                 :            : 
     390                 :            : /*************************************************************************
     391                 :            : |*
     392                 :            : |*  SwFEShell::FindAnchorPos
     393                 :            : |*
     394                 :            : *************************************************************************/
     395                 :            : 
     396                 :          0 : Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt )
     397                 :            : {
     398                 :          0 :     Point aRet;
     399                 :            : 
     400         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     401                 :            : 
     402         [ #  # ]:          0 :     if ( !Imp()->HasDrawView() )
     403                 :            :         return aRet;
     404                 :            : 
     405                 :          0 :     const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
     406 [ #  # ][ #  # ]:          0 :     if ( rMrkList.GetMarkCount() != 1 ||
                 [ #  # ]
     407 [ #  # ][ #  # ]:          0 :          !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) )
                 [ #  # ]
     408                 :            :         return aRet;
     409                 :            : 
     410 [ #  # ][ #  # ]:          0 :     SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     411                 :            :     // #i28701#
     412 [ #  # ][ #  # ]:          0 :     SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
     413         [ #  # ]:          0 :     SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
     414         [ #  # ]:          0 :     RndStdIds nAnchorId = rFmt.GetAnchor().GetAnchorId();
     415                 :            : 
     416         [ #  # ]:          0 :     if ( FLY_AS_CHAR == nAnchorId )
     417                 :            :         return aRet;
     418                 :            : 
     419 [ #  # ][ #  # ]:          0 :     sal_Bool bFlyFrame = pObj->ISA(SwVirtFlyDrawObj);
     420                 :            : 
     421                 :          0 :     SwFlyFrm* pFly = 0L;
     422                 :            :     const SwFrm* pOldAnch;
     423                 :          0 :     const SwFrm* pFooterOrHeader = NULL;
     424                 :            : 
     425         [ #  # ]:          0 :     if( bFlyFrame )
     426                 :            :     {
     427                 :            :         // Calculate reference point in document coordinates
     428         [ #  # ]:          0 :         SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
     429         [ #  # ]:          0 :         if( !pCntnt )
     430                 :            :             return aRet;
     431         [ #  # ]:          0 :         pFly = pCntnt->FindFlyFrm();
     432         [ #  # ]:          0 :         if ( !pFly )
     433                 :            :             return aRet;
     434         [ #  # ]:          0 :         pOldAnch = pFly->GetAnchorFrm();
     435         [ #  # ]:          0 :         if( !pOldAnch )
     436                 :            :             return aRet;
     437         [ #  # ]:          0 :         if ( FLY_AT_PAGE != nAnchorId )
     438                 :            :         {
     439         [ #  # ]:          0 :             pFooterOrHeader = pCntnt->FindFooterOrHeader();
     440                 :            :         }
     441                 :            :     }
     442                 :            :     // set <pFooterOrHeader> also for drawing
     443                 :            :     // objects, but not for control objects.
     444                 :            :     // Necessary for moving 'anchor symbol' at the user interface inside header/footer.
     445 [ #  # ][ #  # ]:          0 :     else if ( !::CheckControlLayer( pObj ) )
     446                 :            :     {
     447         [ #  # ]:          0 :         SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
     448         [ #  # ]:          0 :         if( !pCntnt )
     449                 :            :             return aRet;
     450         [ #  # ]:          0 :         pFooterOrHeader = pCntnt->FindFooterOrHeader();
     451                 :            :     }
     452                 :            : 
     453                 :            :     // Search nearest SwFlyFrm starting from the upper-left corner
     454                 :            :     // of the fly
     455                 :            :     SwCntntFrm *pTxtFrm;
     456                 :            :     {
     457                 :          0 :         SwCrsrMoveState aState( MV_SETONLYTEXT );
     458 [ #  # ][ #  # ]:          0 :         SwPosition aPos( GetDoc()->GetNodes().GetEndOfExtras() );
     459                 :          0 :         Point aTmpPnt( rAbsPos );
     460 [ #  # ][ #  # ]:          0 :         GetLayout()->GetCrsrOfst( &aPos, aTmpPnt, &aState );
     461 [ #  # ][ #  # ]:          0 :         pTxtFrm = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(),0,&aPos,sal_False );
                 [ #  # ]
     462                 :            :     }
     463                 :            :     const SwFrm *pNewAnch;
     464         [ #  # ]:          0 :     if( pTxtFrm )
     465                 :            :     {
     466         [ #  # ]:          0 :         if ( FLY_AT_PAGE == nAnchorId )
     467                 :            :         {
     468         [ #  # ]:          0 :             pNewAnch = pTxtFrm->FindPageFrm();
     469                 :            :         }
     470                 :            :         else
     471                 :            :         {
     472         [ #  # ]:          0 :             pNewAnch = ::FindAnchor( pTxtFrm, rAbsPos );
     473                 :            : 
     474         [ #  # ]:          0 :             if( FLY_AT_FLY == nAnchorId ) // LAYER_IMPL
     475                 :            :             {
     476         [ #  # ]:          0 :                 pNewAnch = pNewAnch->FindFlyFrm();
     477                 :            :             }
     478                 :            :         }
     479                 :            :     }
     480                 :            :     else
     481                 :          0 :         pNewAnch = 0;
     482                 :            : 
     483 [ #  # ][ #  # ]:          0 :     if( pNewAnch && !pNewAnch->IsProtected() )
         [ #  # ][ #  # ]
     484                 :            :     {
     485 [ #  # ][ #  # ]:          0 :         const SwFlyFrm* pCheck = bFlyFrame ? pNewAnch->FindFlyFrm() : 0;
     486                 :            :         // If we land inside the frame, make sure
     487                 :            :         // that the frame does not land inside its own content
     488         [ #  # ]:          0 :         while( pCheck )
     489                 :            :         {
     490         [ #  # ]:          0 :             if( pCheck == pFly )
     491                 :          0 :                 break;
     492         [ #  # ]:          0 :             const SwFrm *pTmp = pCheck->GetAnchorFrm();
     493 [ #  # ][ #  # ]:          0 :             pCheck = pTmp ? pTmp->FindFlyFrm() : NULL;
     494                 :            :         }
     495                 :            : 
     496                 :            :         // Do not switch from header/footer to another area,
     497                 :            :         // do not switch to a header/footer
     498 [ #  # ][ #  # ]:          0 :         if( !pCheck &&
                 [ #  # ]
     499         [ #  # ]:          0 :             pFooterOrHeader == pNewAnch->FindFooterOrHeader() )
     500                 :            :         {
     501 [ #  # ][ #  # ]:          0 :             aRet = pNewAnch->GetFrmAnchorPos( ::HasWrap( pObj ) );
     502                 :            : 
     503 [ #  # ][ #  # ]:          0 :             if ( bMoveIt || (nAnchorId == FLY_AT_CHAR) )
     504                 :            :             {
     505 [ #  # ][ #  # ]:          0 :                 SwFmtAnchor aAnch( rFmt.GetAnchor() );
     506   [ #  #  #  #  :          0 :                 switch ( nAnchorId )
                      # ]
     507                 :            :                 {
     508                 :            :                     case FLY_AT_PARA:
     509                 :            :                     {
     510         [ #  # ]:          0 :                         SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
     511         [ #  # ]:          0 :                         pPos->nNode = *pTxtFrm->GetNode();
     512         [ #  # ]:          0 :                         pPos->nContent.Assign(0,0);
     513                 :          0 :                         break;
     514                 :            :                     }
     515                 :            :                     case FLY_AT_PAGE:
     516                 :            :                     {
     517                 :            :                         aAnch.SetPageNum( ((const SwPageFrm*)pNewAnch)->
     518                 :          0 :                                           GetPhyPageNum() );
     519                 :          0 :                         break;
     520                 :            :                     }
     521                 :            :                     case FLY_AT_FLY:
     522                 :            :                     {
     523         [ #  # ]:          0 :                         SwPosition aPos( *((SwFlyFrm*)pNewAnch)->GetFmt()->
     524 [ #  # ][ #  # ]:          0 :                                                   GetCntnt().GetCntntIdx() );
     525         [ #  # ]:          0 :                         aAnch.SetAnchor( &aPos );
     526         [ #  # ]:          0 :                         break;
     527                 :            :                     }
     528                 :            :                     case FLY_AT_CHAR:
     529                 :            :                     {
     530         [ #  # ]:          0 :                         SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
     531                 :          0 :                         Point aTmpPnt( rAbsPos );
     532 [ #  # ][ #  # ]:          0 :                         if( pTxtFrm->GetCrsrOfst( pPos, aTmpPnt, NULL ) )
     533                 :            :                         {
     534                 :          0 :                             SwRect aTmpRect;
     535         [ #  # ]:          0 :                             pTxtFrm->GetCharRect( aTmpRect, *pPos );
     536                 :          0 :                             aRet = aTmpRect.Pos();
     537                 :            :                         }
     538                 :            :                         else
     539                 :            :                         {
     540         [ #  # ]:          0 :                             pPos->nNode = *pTxtFrm->GetNode();
     541         [ #  # ]:          0 :                             pPos->nContent.Assign(0,0);
     542                 :            :                         }
     543                 :            :                         break;
     544                 :            :                     }
     545                 :            :                     default:
     546                 :          0 :                         break;
     547                 :            :                 }
     548         [ #  # ]:          0 :                 if( bMoveIt )
     549                 :            :                 {
     550         [ #  # ]:          0 :                     StartAllAction();
     551                 :            :                     // --> handle change of anchor node:
     552                 :            :                     // if count of the anchor frame also change, the fly frames have to be
     553                 :            :                     // re-created. Thus, delete all fly frames except the <this> before the
     554                 :            :                     // anchor attribute is change and re-create them afterwards.
     555                 :            :                     {
     556                 :          0 :                         SwHandleAnchorNodeChg* pHandleAnchorNodeChg( 0L );
     557         [ #  # ]:          0 :                         SwFlyFrmFmt* pFlyFrmFmt( dynamic_cast<SwFlyFrmFmt*>(&rFmt) );
     558         [ #  # ]:          0 :                         if ( pFlyFrmFmt )
     559                 :            :                         {
     560                 :            :                             pHandleAnchorNodeChg =
     561 [ #  # ][ #  # ]:          0 :                                 new SwHandleAnchorNodeChg( *pFlyFrmFmt, aAnch );
     562                 :            :                         }
     563         [ #  # ]:          0 :                         rFmt.GetDoc()->SetAttr( aAnch, rFmt );
     564 [ #  # ][ #  # ]:          0 :                         delete pHandleAnchorNodeChg;
     565                 :            :                     }
     566                 :            :                     // #i28701# - no call of method
     567                 :            :                     // <CheckCharRectAndTopOfLine()> for to-character anchored
     568                 :            :                     // Writer fly frame needed. This method call can cause a
     569                 :            :                     // format of the anchor frame, which is no longer intended.
     570                 :            :                     // Instead clear the anchor character rectangle and
     571                 :            :                     // the top of line values for all to-character anchored objects.
     572         [ #  # ]:          0 :                     pAnchoredObj->ClearCharRectAndTopOfLine();
     573         [ #  # ]:          0 :                     EndAllAction();
     574         [ #  # ]:          0 :                 }
     575                 :            :             }
     576                 :            : 
     577                 :          0 :             SwRect aTmpRect( aRet, rAbsPos );
     578 [ #  # ][ #  # ]:          0 :             if( aTmpRect.HasArea() )
     579         [ #  # ]:          0 :                 MakeVisible( aTmpRect );
     580                 :            : #if OSL_DEBUG_LEVEL > 0
     581                 :            :             //TODO: That doesn't seem to be intended
     582                 :            :             if( Color(COL_TRANSPARENT) != GetOut()->GetLineColor() )
     583                 :            :             {
     584                 :            :                 OSL_FAIL( "Hey, Joe: Where's my Null Pen?" );
     585                 :            :                 GetOut()->SetLineColor( Color(COL_TRANSPARENT) );
     586                 :            :             }
     587                 :            : #endif
     588                 :            :         }
     589                 :            :     }
     590                 :            : 
     591         [ #  # ]:          0 :     return aRet;
     592                 :            : }
     593                 :            : 
     594                 :            : /***********************************************************************
     595                 :            : #*  Class       :  SwFEShell
     596                 :            : #*  Methode     :  NewFlyFrm
     597                 :            : #*  Description :
     598                 :            : #***********************************************************************/
     599                 :            : 
     600                 :          0 : const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchValid,
     601                 :            :                            SwFrmFmt *pParent )
     602                 :            : {
     603         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     604         [ #  # ]:          0 :     StartAllAction();
     605                 :            : 
     606         [ #  # ]:          0 :     SwPaM* pCrsr = GetCrsr();
     607                 :          0 :     const Point aPt( GetCrsrDocPos() );
     608                 :            : 
     609         [ #  # ]:          0 :     SwSelBoxes aBoxes;
     610                 :          0 :     sal_Bool bMoveCntnt = sal_True;
     611         [ #  # ]:          0 :     if( IsTableMode() )
     612                 :            :     {
     613         [ #  # ]:          0 :         GetTblSel( *this, aBoxes );
     614         [ #  # ]:          0 :         if( !aBoxes.empty() )
     615                 :            :         {
     616                 :            :             // Crsr should be removed from the removal area.
     617                 :            :             // Always put it after/on the table; via the
     618                 :            :             // document position they will be set to the old
     619                 :            :             // position
     620 [ #  # ][ #  # ]:          0 :             ParkCrsr( SwNodeIndex( *aBoxes[0]->GetSttNd() ));
         [ #  # ][ #  # ]
     621                 :            : 
     622                 :            :             // #i127787# pCurCrsr will be deleted in ParkCrsr,
     623                 :            :             // we better get the current pCurCrsr instead of working with the
     624                 :            :             // deleted one:
     625         [ #  # ]:          0 :             pCrsr = GetCrsr();
     626                 :            :         }
     627                 :            :         else
     628                 :          0 :             bMoveCntnt = sal_False;
     629                 :            :     }
     630 [ #  # ][ #  # ]:          0 :     else if( !pCrsr->HasMark() && pCrsr->GetNext() == pCrsr )
                 [ #  # ]
     631                 :          0 :         bMoveCntnt = sal_False;
     632                 :            : 
     633         [ #  # ]:          0 :     const SwPosition& rPos = *pCrsr->Start();
     634                 :            : 
     635         [ #  # ]:          0 :     SwFmtAnchor& rAnch = (SwFmtAnchor&)rSet.Get( RES_ANCHOR );
     636                 :          0 :     RndStdIds eRndId = rAnch.GetAnchorId();
     637      [ #  #  # ]:          0 :     switch( eRndId )
     638                 :            :     {
     639                 :            :     case FLY_AT_PAGE:
     640         [ #  # ]:          0 :         if( !rAnch.GetPageNum() )       //HotFix: Bug in UpdateByExample
     641                 :          0 :             rAnch.SetPageNum( 1 );
     642                 :          0 :         break;
     643                 :            : 
     644                 :            :     case FLY_AT_FLY:
     645                 :            :     case FLY_AT_PARA:
     646                 :            :     case FLY_AT_CHAR:
     647                 :            :     case FLY_AS_CHAR:
     648         [ #  # ]:          0 :         if( !bAnchValid )
     649                 :            :         {
     650         [ #  # ]:          0 :             if( FLY_AT_FLY != eRndId )
     651                 :            :             {
     652         [ #  # ]:          0 :                 rAnch.SetAnchor( &rPos );
     653                 :            :             }
     654 [ #  # ][ #  # ]:          0 :             else if( lcl_SetNewFlyPos( rPos.nNode.GetNode(), rAnch, aPt ) )
     655                 :            :             {
     656                 :          0 :                 eRndId = FLY_AT_PAGE;
     657                 :            :             }
     658                 :            :         }
     659                 :          0 :         break;
     660                 :            : 
     661                 :            :     default:
     662                 :            :         OSL_ENSURE( !this, "What is the purpose of this Fly?" );
     663                 :          0 :         break;
     664                 :            :     }
     665                 :            : 
     666                 :            :     SwFlyFrmFmt *pRet;
     667         [ #  # ]:          0 :     if( bMoveCntnt )
     668                 :            :     {
     669 [ #  # ][ #  # ]:          0 :         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSLAYFMT, NULL );
     670                 :          0 :         SwFmtAnchor* pOldAnchor = 0;
     671                 :          0 :         sal_Bool bHOriChgd = sal_False, bVOriChgd = sal_False;
     672         [ #  # ]:          0 :         SwFmtVertOrient aOldV;
     673         [ #  # ]:          0 :         SwFmtHoriOrient aOldH;
     674                 :            : 
     675         [ #  # ]:          0 :         if ( FLY_AT_PAGE != eRndId )
     676                 :            :         {
     677                 :            :            // First as with page link. Paragraph/character link on if
     678                 :            :             // everything was shifted. Then the position is valid!
     679                 :            :             // JP 13.05.98: if necessary also convert the horizontal/vertical
     680                 :            :             //              orientation, to prevent correction during re-anchoring
     681 [ #  # ][ #  # ]:          0 :             pOldAnchor = new SwFmtAnchor( rAnch );
     682 [ #  # ][ #  # ]:          0 :             const_cast<SfxItemSet&>(rSet).Put( SwFmtAnchor( FLY_AT_PAGE, 1 ) );
                 [ #  # ]
     683                 :            : 
     684                 :            :             const SfxPoolItem* pItem;
     685         [ #  # ]:          0 :             if( SFX_ITEM_SET == rSet.GetItemState( RES_HORI_ORIENT, sal_False, &pItem )
           [ #  #  #  # ]
                 [ #  # ]
     686                 :          0 :                 && text::HoriOrientation::NONE == ((SwFmtHoriOrient*)pItem)->GetHoriOrient() )
     687                 :            :             {
     688                 :          0 :                 bHOriChgd = sal_True;
     689                 :          0 :                 aOldH = *((SwFmtHoriOrient*)pItem);
     690 [ #  # ][ #  # ]:          0 :                 ((SfxItemSet&)rSet).Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT ) );
                 [ #  # ]
     691                 :            :             }
     692         [ #  # ]:          0 :             if( SFX_ITEM_SET == rSet.GetItemState( RES_VERT_ORIENT, sal_False, &pItem )
           [ #  #  #  # ]
                 [ #  # ]
     693                 :          0 :                 && text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient() )
     694                 :            :             {
     695                 :          0 :                 bVOriChgd = sal_True;
     696                 :          0 :                 aOldV = *((SwFmtVertOrient*)pItem);
     697 [ #  # ][ #  # ]:          0 :                 ((SfxItemSet&)rSet).Put( SwFmtVertOrient( 0, text::VertOrientation::TOP ) );
                 [ #  # ]
     698                 :            :             }
     699                 :            :         }
     700                 :            : 
     701         [ #  # ]:          0 :         pRet = GetDoc()->MakeFlyAndMove( *pCrsr, rSet, &aBoxes, pParent );
     702                 :            : 
     703         [ #  # ]:          0 :         KillPams();
     704                 :            : 
     705         [ #  # ]:          0 :         if( pOldAnchor )
     706                 :            :         {
     707         [ #  # ]:          0 :             if( pRet )
     708                 :            :             {
     709                 :            :                 // calculate new position
     710                 :            :                 // JP 24.03.97: also go via page links
     711                 :            :                 //              chaos::anchor should not lie in the shifted area
     712         [ #  # ]:          0 :                 pRet->DelFrms();
     713                 :            : 
     714 [ #  # ][ #  # ]:          0 :                 const SwFrm* pAnch = ::FindAnchor( GetLayout(), aPt, sal_False );
     715         [ #  # ]:          0 :                 SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() );
     716         [ #  # ]:          0 :                 if ( FLY_AS_CHAR == eRndId )
     717                 :            :                 {
     718 [ #  # ][ #  # ]:          0 :                     aPos.nContent.Assign( ((SwCntntFrm*)pAnch)->GetNode(), 0 );
     719                 :            :                 }
     720         [ #  # ]:          0 :                 pOldAnchor->SetAnchor( &aPos );
     721                 :            : 
     722                 :            :                 // shifting of table selection is not Undo-capable. therefore
     723                 :            :                 // changing the anchors should not be recorded
     724                 :            :                 bool const bDoesUndo =
     725 [ #  # ][ #  # ]:          0 :                     GetDoc()->GetIDocumentUndoRedo().DoesUndo();
     726                 :          0 :                 SwUndoId nLastUndoId(UNDO_EMPTY);
     727 [ #  # ][ #  # ]:          0 :                 if (bDoesUndo &&
                 [ #  # ]
     728         [ #  # ]:          0 :                     GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0,
     729         [ #  # ]:          0 :                         & nLastUndoId))
     730                 :            :                 {
     731         [ #  # ]:          0 :                     if (UNDO_INSLAYFMT == nLastUndoId)
     732                 :            :                     {
     733 [ #  # ][ #  # ]:          0 :                         GetDoc()->GetIDocumentUndoRedo().DoUndo(false);
     734                 :            :                     }
     735                 :            :                 }
     736                 :            : 
     737         [ #  # ]:          0 :                 ((SfxItemSet&)rSet).Put( *pOldAnchor );
     738                 :            : 
     739         [ #  # ]:          0 :                 if( bHOriChgd )
     740         [ #  # ]:          0 :                     ((SfxItemSet&)rSet).Put( aOldH );
     741         [ #  # ]:          0 :                 if( bVOriChgd )
     742         [ #  # ]:          0 :                     ((SfxItemSet&)rSet).Put( aOldV );
     743                 :            : 
     744         [ #  # ]:          0 :                 GetDoc()->SetFlyFrmAttr( *pRet, (SfxItemSet&)rSet );
     745 [ #  # ][ #  # ]:          0 :                 GetDoc()->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
                 [ #  # ]
     746                 :            :             }
     747 [ #  # ][ #  # ]:          0 :             delete pOldAnchor;
     748                 :            :         }
     749 [ #  # ][ #  # ]:          0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_INSLAYFMT, NULL );
         [ #  # ][ #  # ]
     750                 :            :     }
     751                 :            :     else
     752                 :            :         /* If called from a shell try to propagate an
     753                 :            :             existing adjust item from rPos to the content node of the
     754                 :            :             new frame. */
     755         [ #  # ]:          0 :         pRet = GetDoc()->MakeFlySection( eRndId, &rPos, &rSet, pParent, sal_True );
     756                 :            : 
     757         [ #  # ]:          0 :     if( pRet )
     758                 :            :     {
     759         [ #  # ]:          0 :         SwFlyFrm* pFrm = pRet->GetFrm( &aPt );
     760         [ #  # ]:          0 :         if( pFrm )
     761         [ #  # ]:          0 :             SelectFlyFrm( *pFrm, sal_True );
     762                 :            :         else
     763                 :            :         {
     764         [ #  # ]:          0 :             GetLayout()->SetAssertFlyPages();
     765                 :          0 :             pRet = 0;
     766                 :            :         }
     767                 :            :     }
     768         [ #  # ]:          0 :     EndAllActionAndCall();
     769                 :            : 
     770         [ #  # ]:          0 :     return pRet;
     771                 :            : }
     772                 :            : 
     773                 :            : /***********************************************************************
     774                 :            : #*  Class       :  SwFEShell
     775                 :            : #*  Methode     :  Insert
     776                 :            : #***********************************************************************/
     777                 :            : 
     778                 :          0 : void SwFEShell::Insert( const String& rGrfName, const String& rFltName,
     779                 :            :                         const Graphic* pGraphic,
     780                 :            :                         const SfxItemSet* pFlyAttrSet,
     781                 :            :                         const SfxItemSet* pGrfAttrSet,
     782                 :            :                         SwFrmFmt* pFrmFmt )
     783                 :            : {
     784                 :          0 :     SwFlyFrmFmt* pFmt = 0;
     785         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     786         [ #  # ]:          0 :     StartAllAction();
     787 [ #  # ][ #  # ]:          0 :     SwShellCrsr *pStartCursor = dynamic_cast<SwShellCrsr*>(this->GetSwCrsr());
     788                 :          0 :     SwShellCrsr *pCursor = pStartCursor;
     789 [ #  # ][ #  # ]:          0 :     do {
     790                 :            : 
     791                 :            :         // Has the anchor not been set or been set incompletely?
     792         [ #  # ]:          0 :         if( pFlyAttrSet )
     793                 :            :         {
     794                 :            :             const SfxPoolItem* pItem;
     795         [ #  # ]:          0 :             if( SFX_ITEM_SET == pFlyAttrSet->GetItemState( RES_ANCHOR, sal_False,
     796         [ #  # ]:          0 :                     &pItem ) )
     797                 :            :             {
     798                 :          0 :                 SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem;
     799   [ #  #  #  # ]:          0 :                 switch( pAnchor->GetAnchorId())
     800                 :            :                 {
     801                 :            :                 case FLY_AT_PARA:
     802                 :            :                 case FLY_AT_CHAR: // LAYER_IMPL
     803                 :            :                 case FLY_AS_CHAR:
     804 [ #  # ][ #  # ]:          0 :                     if( !pAnchor->GetCntntAnchor() )
     805                 :            :                     {
     806         [ #  # ]:          0 :                         pAnchor->SetAnchor( pCursor->GetPoint() );
     807                 :            :                     }
     808                 :          0 :                     break;
     809                 :            :                 case FLY_AT_FLY:
     810 [ #  # ][ #  # ]:          0 :                     if( !pAnchor->GetCntntAnchor() )
     811                 :            :                     {
     812                 :          0 :                         lcl_SetNewFlyPos( *pCursor->GetNode(),
     813         [ #  # ]:          0 :                                 *pAnchor, GetCrsrDocPos() );
     814                 :            :                     }
     815                 :          0 :                     break;
     816                 :            :                 case FLY_AT_PAGE:
     817         [ #  # ]:          0 :                     if( !pAnchor->GetPageNum() )
     818                 :            :                     {
     819                 :            :                         pAnchor->SetPageNum( pCursor->GetPageNum(
     820         [ #  # ]:          0 :                                 sal_True, &pCursor->GetPtPos() ) );
     821                 :            :                     }
     822                 :          0 :                     break;
     823                 :            :                 default :
     824                 :          0 :                     break;
     825                 :            :                 }
     826                 :            :             }
     827                 :            :         }
     828                 :          0 :         pFmt = GetDoc()->Insert(*pCursor, rGrfName,
     829                 :            :                                 rFltName, pGraphic,
     830                 :            :                                 pFlyAttrSet,
     831         [ #  # ]:          0 :                                 pGrfAttrSet, pFrmFmt );
     832                 :            :         OSL_ENSURE( pFmt, "Doc->Insert(notxt) failed." );
     833                 :            : 
     834                 :          0 :     } while( (pCursor = dynamic_cast<SwShellCrsr*>(pCursor->GetNext()))
     835                 :            :              != pStartCursor );
     836                 :            : 
     837         [ #  # ]:          0 :     EndAllAction();
     838                 :            : 
     839         [ #  # ]:          0 :     if( pFmt )
     840                 :            :     {
     841                 :          0 :         const Point aPt( GetCrsrDocPos() );
     842         [ #  # ]:          0 :         SwFlyFrm* pFrm = pFmt->GetFrm( &aPt );
     843                 :            : 
     844                 :            :         // fdo#36681: Invalidate the content and layout to refresh the picture anchoring
     845                 :            :         // properly
     846         [ #  # ]:          0 :         SwPageFrm* pPageFrm = pFrm->FindPageFrmOfAnchor();
     847                 :          0 :         pPageFrm->InvalidateFlyLayout();
     848                 :          0 :         pPageFrm->InvalidateCntnt();
     849                 :            : 
     850         [ #  # ]:          0 :         if( pFrm )
     851         [ #  # ]:          0 :             SelectFlyFrm( *pFrm, sal_True );
     852                 :            :         else
     853         [ #  # ]:          0 :             GetLayout()->SetAssertFlyPages();
     854         [ #  # ]:          0 :     }
     855                 :          0 : }
     856                 :            : 
     857                 :          0 : SwFlyFrmFmt* SwFEShell::InsertObject( const svt::EmbeddedObjectRef&  xObj,
     858                 :            :                         const SfxItemSet* pFlyAttrSet,
     859                 :            :                         const SfxItemSet* pGrfAttrSet,
     860                 :            :                         SwFrmFmt* pFrmFmt )
     861                 :            : {
     862                 :          0 :     SwFlyFrmFmt* pFmt = 0;
     863         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     864         [ #  # ]:          0 :     StartAllAction();
     865 [ #  # ][ #  # ]:          0 :         FOREACHPAM_START( this )
     866                 :          0 :             pFmt = GetDoc()->Insert(*PCURCRSR, xObj,
     867         [ #  # ]:          0 :                                     pFlyAttrSet, pGrfAttrSet, pFrmFmt );
     868                 :            :             OSL_ENSURE( pFmt, "Doc->Insert(notxt) failed." );
     869                 :            : 
     870                 :          0 :         FOREACHPAM_END()
     871         [ #  # ]:          0 :     EndAllAction();
     872                 :            : 
     873         [ #  # ]:          0 :     if( pFmt )
     874                 :            :     {
     875                 :          0 :         const Point aPt( GetCrsrDocPos() );
     876         [ #  # ]:          0 :         SwFlyFrm* pFrm = pFmt->GetFrm( &aPt );
     877                 :            : 
     878         [ #  # ]:          0 :         if( pFrm )
     879         [ #  # ]:          0 :             SelectFlyFrm( *pFrm, sal_True );
     880                 :            :         else
     881         [ #  # ]:          0 :             GetLayout()->SetAssertFlyPages();
     882                 :            :     }
     883                 :            : 
     884         [ #  # ]:          0 :     return pFmt;
     885                 :            : }
     886                 :            : 
     887                 :            : 
     888                 :          0 : void SwFEShell::InsertDrawObj( SdrObject& rDrawObj,
     889                 :            :                                const Point& rInsertPosition )
     890                 :            : {
     891         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     892                 :            : 
     893         [ #  # ]:          0 :     SfxItemSet rFlyAttrSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange );
     894 [ #  # ][ #  # ]:          0 :     rFlyAttrSet.Put( SwFmtAnchor( FLY_AT_PARA ));
                 [ #  # ]
     895                 :            :     // #i89920#
     896 [ #  # ][ #  # ]:          0 :     rFlyAttrSet.Put( SwFmtSurround( SURROUND_THROUGHT ) );
                 [ #  # ]
     897 [ #  # ][ #  # ]:          0 :     rDrawObj.SetLayer( getIDocumentDrawModelAccess()->GetHeavenId() );
                 [ #  # ]
     898                 :            : 
     899                 :            :     // find anchor position
     900 [ #  # ][ #  # ]:          0 :     SwPaM aPam( pDoc->GetNodes() );
         [ #  # ][ #  # ]
     901                 :            :     {
     902                 :          0 :         SwCrsrMoveState aState( MV_SETONLYTEXT );
     903                 :          0 :         Point aTmpPt( rInsertPosition );
     904 [ #  # ][ #  # ]:          0 :         GetLayout()->GetCrsrOfst( aPam.GetPoint(), aTmpPt, &aState );
     905 [ #  # ][ #  # ]:          0 :         const SwFrm* pFrm = aPam.GetCntntNode()->getLayoutFrm( GetLayout(), 0, 0, sal_False );
     906                 :          0 :         const Point aRelPos( rInsertPosition.X() - pFrm->Frm().Left(),
     907                 :          0 :                              rInsertPosition.Y() - pFrm->Frm().Top() );
     908         [ #  # ]:          0 :         rDrawObj.SetRelativePos( aRelPos );
     909         [ #  # ]:          0 :         ::lcl_FindAnchorPos( *GetDoc(), rInsertPosition, *pFrm, rFlyAttrSet );
     910                 :            :     }
     911                 :            :     // insert drawing object into the document creating a new <SwDrawFrmFmt> instance
     912         [ #  # ]:          0 :     SwDrawFrmFmt* pFmt = GetDoc()->Insert( aPam, rDrawObj, &rFlyAttrSet, 0 );
     913                 :            : 
     914                 :            :     // move object to visible layer
     915         [ #  # ]:          0 :     SwContact* pContact = static_cast<SwContact*>(rDrawObj.GetUserCall());
     916         [ #  # ]:          0 :     if ( pContact )
     917                 :            :     {
     918         [ #  # ]:          0 :         pContact->MoveObjToVisibleLayer( &rDrawObj );
     919                 :            :     }
     920                 :            : 
     921         [ #  # ]:          0 :     if ( pFmt )
     922                 :            :     {
     923                 :            :         // select drawing object
     924                 :          0 :         Imp()->GetDrawView()->MarkObj( &rDrawObj, Imp()->GetPageView(),
     925         [ #  # ]:          0 :                                        sal_False, sal_False );
     926                 :            :     }
     927                 :            :     else
     928                 :            :     {
     929         [ #  # ]:          0 :         GetLayout()->SetAssertFlyPages();
     930 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
     931                 :          0 : }
     932                 :            : 
     933                 :            : /***********************************************************************
     934                 :            : #*  Class       :  SwFEShell
     935                 :            : #*  Methode     :  GetPageObjs
     936                 :            : #***********************************************************************/
     937                 :            : 
     938                 :          0 : void SwFEShell::GetPageObjs( std::vector<SwFrmFmt*>& rFillArr )
     939                 :            : {
     940                 :          0 :     rFillArr.clear();
     941                 :            : 
     942         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->size(); ++n )
     943                 :            :     {
     944                 :          0 :         SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n];
     945 [ #  # ][ #  # ]:          0 :         if (FLY_AT_PAGE == pFmt->GetAnchor().GetAnchorId())
     946                 :            :         {
     947         [ #  # ]:          0 :             rFillArr.push_back( pFmt );
     948                 :            :         }
     949                 :            :     }
     950                 :          0 : }
     951                 :            : 
     952                 :            : /***********************************************************************
     953                 :            : #*  Class       :  SwFEShell
     954                 :            : #*  Methode     :  SetPageFlysNewPage
     955                 :            : #***********************************************************************/
     956                 :            : 
     957                 :          0 : void SwFEShell::SetPageObjsNewPage( std::vector<SwFrmFmt*>& rFillArr, int nOffset )
     958                 :            : {
     959 [ #  # ][ #  # ]:          0 :     if( rFillArr.empty() || !nOffset )
                 [ #  # ]
     960                 :          0 :         return;
     961                 :            : 
     962                 :          0 :     StartAllAction();
     963                 :          0 :     StartUndo();
     964                 :            : 
     965                 :            :     long nNewPage;
     966                 :          0 :     SwRootFrm* pTmpRootFrm = GetLayout();//swmod 080317
     967                 :          0 :     sal_uInt16 nMaxPage = pTmpRootFrm->GetPageNum();
     968                 :          0 :     sal_Bool bTmpAssert = sal_False;
     969         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < rFillArr.size(); ++n )
     970                 :            :     {
     971                 :          0 :         SwFrmFmt* pFmt = rFillArr[n];
     972         [ #  # ]:          0 :         if( pDoc->GetSpzFrmFmts()->Contains( pFmt ))
     973                 :            :         {
     974                 :            :             // FlyFmt is still valid, therefore process
     975                 :            : 
     976 [ #  # ][ #  # ]:          0 :             SwFmtAnchor aNewAnchor( pFmt->GetAnchor() );
     977   [ #  #  #  # ]:          0 :             if ((FLY_AT_PAGE != aNewAnchor.GetAnchorId()) ||
                 [ #  # ]
     978                 :          0 :                 0 >= ( nNewPage = aNewAnchor.GetPageNum() + nOffset ) )
     979                 :            :                 // chaos::Anchor has been changed or invalid page number,
     980                 :            :                 // therefore: do not change!
     981                 :          0 :                 continue;
     982                 :            : 
     983         [ #  # ]:          0 :             if( sal_uInt16(nNewPage) > nMaxPage )
     984                 :            :             {
     985         [ #  # ]:          0 :                 if ( RES_DRAWFRMFMT == pFmt->Which() )
     986                 :            :                 {
     987         [ #  # ]:          0 :                     SwContact *pCon = pFmt->FindContactObj();
     988         [ #  # ]:          0 :                     if( pCon )
     989         [ #  # ]:          0 :                         ((SwDrawContact*)pCon)->DisconnectFromLayout();
     990                 :            :                 }
     991                 :            :                 else
     992         [ #  # ]:          0 :                     pFmt->DelFrms();
     993                 :          0 :                 bTmpAssert = sal_True;
     994                 :            :             }
     995                 :          0 :             aNewAnchor.SetPageNum( sal_uInt16(nNewPage) );
     996 [ #  # ][ #  # ]:          0 :             pDoc->SetAttr( aNewAnchor, *pFmt );
                 [ #  # ]
     997                 :            :         }
     998                 :            :     }
     999                 :            : 
    1000         [ #  # ]:          0 :     if( bTmpAssert )
    1001                 :          0 :         pTmpRootFrm->SetAssertFlyPages();
    1002                 :            : 
    1003                 :          0 :     EndUndo();
    1004                 :          0 :     EndAllAction();
    1005                 :            : }
    1006                 :            : 
    1007                 :            : /***********************************************************************
    1008                 :            : #*  Class       :  SwFEShell
    1009                 :            : #*  Methode     :  GetFlyFrmAttr
    1010                 :            : #*  Description :  all attributes in the "baskets" will be filled
    1011                 :            : #*                 with the attributes of the current FlyFrms.
    1012                 :            : #*                 Attributes which cannot be filled due to being at the wrong place
    1013                 :            : #*                 or which are ambiguous (multiple selections) will be removed.
    1014                 :            : #*
    1015                 :            : #***********************************************************************/
    1016                 :            : 
    1017                 :          0 : sal_Bool SwFEShell::GetFlyFrmAttr( SfxItemSet &rSet ) const
    1018                 :            : {
    1019         [ #  # ]:          0 :     SwFlyFrm *pFly = FindFlyFrm();
    1020         [ #  # ]:          0 :     if ( !pFly )
    1021                 :            :     {
    1022         [ #  # ]:          0 :         SwFrm* pCurrFrm( GetCurrFrm() );
    1023         [ #  # ]:          0 :         if ( !pCurrFrm )
    1024                 :            :         {
    1025                 :            :             OSL_FAIL( "<SwFEShell::GetFlyFrmAttr(..)> - missing current frame. This is a serious defect, please inform OD." );
    1026                 :          0 :             return sal_False;
    1027                 :            :         }
    1028 [ #  # ][ #  # ]:          0 :         pFly = GetCurrFrm()->FindFlyFrm();
    1029         [ #  # ]:          0 :         if ( !pFly )
    1030                 :            :         {
    1031                 :            :             OSL_ENSURE( !this, "GetFlyFrmAttr, no Fly selected." );
    1032                 :          0 :             return sal_False;
    1033                 :            :         }
    1034                 :            :     }
    1035                 :            : 
    1036         [ #  # ]:          0 :     SET_CURR_SHELL( (ViewShell*)this );
    1037                 :            : 
    1038 [ #  # ][ #  # ]:          0 :     if( !rSet.Set( pFly->GetFmt()->GetAttrSet(), sal_True ) )
                 [ #  # ]
    1039                 :          0 :         return sal_False;
    1040                 :            : 
    1041                 :            :     // now examine all attributes. Remove forbidden attributes, then
    1042                 :            :     // get all remaining attributes and enter them
    1043                 :            :     const SfxPoolItem* pItem;
    1044 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, sal_False, &pItem ) )
    1045                 :            :     {
    1046                 :          0 :         SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem;
    1047                 :          0 :         RndStdIds eType = pAnchor->GetAnchorId();
    1048                 :            : 
    1049         [ #  # ]:          0 :         if ( FLY_AT_PAGE != eType )
    1050                 :            :         {
    1051                 :            :             // OD 12.11.2003 #i22341# - content anchor of anchor item is needed.
    1052                 :            :             // Thus, don't overwrite anchor item by default contructed anchor item.
    1053         [ #  # ]:          0 :             if ( FLY_AS_CHAR == eType )
    1054                 :            :             {
    1055         [ #  # ]:          0 :                 rSet.ClearItem( RES_OPAQUE );
    1056         [ #  # ]:          0 :                 rSet.ClearItem( RES_SURROUND );
    1057                 :            :             }
    1058                 :            :         }
    1059                 :            :     }
    1060         [ #  # ]:          0 :     rSet.SetParent( pFly->GetFmt()->GetAttrSet().GetParent() );
    1061                 :            :     // attributes must be removed
    1062         [ #  # ]:          0 :     rSet.ClearItem( RES_FILL_ORDER );
    1063         [ #  # ]:          0 :     rSet.ClearItem( RES_CNTNT );
    1064                 :            :     //MA: remove first (Template by example etc.)
    1065         [ #  # ]:          0 :     rSet.ClearItem( RES_CHAIN );
    1066         [ #  # ]:          0 :     return sal_True;
    1067                 :            : }
    1068                 :            : /***********************************************************************
    1069                 :            : #*  Class       :  SwFEShell
    1070                 :            : #*  Methode     :  SetFlyFrmAttr
    1071                 :            : #*  Description :  Attributes of the current fly will change.
    1072                 :            : #***********************************************************************/
    1073                 :            : 
    1074                 :          0 : sal_Bool SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet )
    1075                 :            : {
    1076         [ #  # ]:          0 :     SET_CURR_SHELL( this );
    1077                 :          0 :     sal_Bool bRet = sal_False;
    1078                 :            : 
    1079         [ #  # ]:          0 :     if( rSet.Count() )
    1080                 :            :     {
    1081         [ #  # ]:          0 :         SwFlyFrm *pFly = FindFlyFrm();
    1082         [ #  # ]:          0 :         if( !pFly )
    1083                 :            :         {
    1084                 :            :             OSL_ENSURE( GetCurrFrm(), "Crsr in parking zone" );
    1085 [ #  # ][ #  # ]:          0 :             pFly = GetCurrFrm()->FindFlyFrm();
    1086                 :            :             OSL_ENSURE( pFly, "SetFlyFrmAttr, no Fly selected." );
    1087                 :            :         }
    1088         [ #  # ]:          0 :         if( pFly )
    1089                 :            :         {
    1090         [ #  # ]:          0 :             StartAllAction();
    1091                 :          0 :             const Point aPt( pFly->Frm().Pos() );
    1092                 :            : 
    1093 [ #  # ][ #  # ]:          0 :             if( SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, sal_False ))
    1094         [ #  # ]:          0 :                 ::lcl_ChkAndSetNewAnchor( *pFly, rSet );
    1095         [ #  # ]:          0 :             SwFlyFrmFmt* pFlyFmt = (SwFlyFrmFmt*)pFly->GetFmt();
    1096                 :            : 
    1097 [ #  # ][ #  # ]:          0 :             if( GetDoc()->SetFlyFrmAttr( *pFlyFmt, rSet ))
    1098                 :            :             {
    1099                 :          0 :                 bRet = sal_True;
    1100         [ #  # ]:          0 :                 SwFlyFrm* pFrm = pFlyFmt->GetFrm( &aPt );
    1101         [ #  # ]:          0 :                 if( pFrm )
    1102         [ #  # ]:          0 :                     SelectFlyFrm( *pFrm, sal_True );
    1103                 :            :                 else
    1104         [ #  # ]:          0 :                     GetLayout()->SetAssertFlyPages();
    1105                 :            :             }
    1106                 :            : 
    1107         [ #  # ]:          0 :             EndAllActionAndCall();
    1108                 :            :         }
    1109                 :            :     }
    1110         [ #  # ]:          0 :     return bRet;
    1111                 :            : }
    1112                 :            : 
    1113                 :          0 : sal_Bool SwFEShell::SetDrawingAttr( SfxItemSet& rSet )
    1114                 :            : {
    1115                 :          0 :     sal_Bool bRet = sal_False;
    1116         [ #  # ]:          0 :     SET_CURR_SHELL( this );
    1117   [ #  #  #  # ]:          0 :     if ( !rSet.Count() ||
                 [ #  # ]
    1118                 :          0 :             !Imp()->HasDrawView() )
    1119                 :          0 :         return bRet;
    1120                 :            : 
    1121                 :          0 :     const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
    1122         [ #  # ]:          0 :     if ( rMrkList.GetMarkCount() != 1 )
    1123                 :          0 :         return bRet;
    1124                 :            : 
    1125         [ #  # ]:          0 :     StartUndo();
    1126 [ #  # ][ #  # ]:          0 :     SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
    1127         [ #  # ]:          0 :     SwFrmFmt *pFmt = FindFrmFmt( pObj );
    1128         [ #  # ]:          0 :     StartAllAction();
    1129 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, sal_False ))
    1130                 :            :     {
    1131         [ #  # ]:          0 :         RndStdIds nNew = ((SwFmtAnchor&)rSet.Get( RES_ANCHOR )).GetAnchorId();
    1132 [ #  # ][ #  # ]:          0 :         if ( nNew != pFmt->GetAnchor().GetAnchorId() )
    1133                 :            :         {
    1134         [ #  # ]:          0 :             ChgAnchor( nNew );
    1135                 :            :             // #i26791# - clear anchor attribute in item set,
    1136                 :            :             // because method <ChgAnchor(..)> takes care of it.
    1137         [ #  # ]:          0 :             rSet.ClearItem( RES_ANCHOR );
    1138                 :            :         }
    1139                 :            :     }
    1140                 :            : 
    1141 [ #  # ][ #  # ]:          0 :     if( GetDoc()->SetFlyFrmAttr( *pFmt, rSet ))
    1142                 :            :     {
    1143                 :          0 :         bRet = sal_True;
    1144                 :          0 :         Point aTmp;
    1145         [ #  # ]:          0 :         SelectObj( aTmp, 0, pObj );
    1146                 :            :     }
    1147         [ #  # ]:          0 :     EndAllActionAndCall();
    1148         [ #  # ]:          0 :     EndUndo();
    1149         [ #  # ]:          0 :     return bRet;
    1150                 :            : }
    1151                 :            : 
    1152                 :            : 
    1153                 :            : /***********************************************************************
    1154                 :            : #*  Class       :  SwFEShell
    1155                 :            : #*  Methode     :  ResetFlyFrmAttr
    1156                 :            : #*  Description :  Reset requested attributes or the ones contained in
    1157                 :            : #*                 the set.
    1158                 :            : #***********************************************************************/
    1159                 :            : 
    1160                 :          0 : sal_Bool SwFEShell::ResetFlyFrmAttr( sal_uInt16 nWhich, const SfxItemSet* pSet )
    1161                 :            : {
    1162                 :          0 :     sal_Bool bRet = sal_False;
    1163                 :            : 
    1164 [ #  # ][ #  # ]:          0 :     if( RES_ANCHOR != nWhich && RES_CHAIN != nWhich && RES_CNTNT != nWhich )
                 [ #  # ]
    1165                 :            :     {
    1166         [ #  # ]:          0 :         SET_CURR_SHELL( this );
    1167                 :            : 
    1168         [ #  # ]:          0 :         SwFlyFrm *pFly = FindFlyFrm();
    1169         [ #  # ]:          0 :         if( !pFly )
    1170                 :            :         {
    1171                 :            :             OSL_ENSURE( GetCurrFrm(), "Crsr in parking zone" );
    1172 [ #  # ][ #  # ]:          0 :             pFly = GetCurrFrm()->FindFlyFrm();
    1173                 :            :             OSL_ENSURE( pFly, "SetFlyFrmAttr, no Fly selected." );
    1174                 :            :         }
    1175                 :            : 
    1176         [ #  # ]:          0 :         if( pFly )
    1177                 :            :         {
    1178         [ #  # ]:          0 :             StartAllAction();
    1179                 :            : 
    1180         [ #  # ]:          0 :             if( pSet )
    1181                 :            :             {
    1182         [ #  # ]:          0 :                 SfxItemIter aIter( *pSet );
    1183                 :          0 :                 const SfxPoolItem* pItem = aIter.FirstItem();
    1184         [ #  # ]:          0 :                 while( pItem )
    1185                 :            :                 {
    1186 [ #  # ][ #  # ]:          0 :                     if( !IsInvalidItem( pItem ) &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1187                 :            :                         RES_ANCHOR != ( nWhich = pItem->Which() ) &&
    1188                 :            :                         RES_CHAIN != nWhich && RES_CNTNT != nWhich )
    1189 [ #  # ][ #  # ]:          0 :                         pFly->GetFmt()->ResetFmtAttr( nWhich );
    1190         [ #  # ]:          0 :                     pItem = aIter.NextItem();
    1191         [ #  # ]:          0 :                 }
    1192                 :            :             }
    1193                 :            :             else
    1194 [ #  # ][ #  # ]:          0 :                 pFly->GetFmt()->ResetFmtAttr( nWhich );
    1195                 :            : 
    1196                 :          0 :             bRet = sal_True;
    1197         [ #  # ]:          0 :             EndAllActionAndCall();
    1198         [ #  # ]:          0 :             GetDoc()->SetModified();
    1199         [ #  # ]:          0 :         }
    1200                 :            :     }
    1201                 :          0 :     return bRet;
    1202                 :            : }
    1203                 :            : 
    1204                 :            : /***********************************************************************
    1205                 :            : #*  Class       :  SwFEShell
    1206                 :            : #*  Methode     :  GetCurFrmFmt
    1207                 :            : #*  Description :  Returns frame-format if frame, otherwise 0
    1208                 :            : #***********************************************************************/
    1209                 :            : 
    1210                 :       3659 : SwFrmFmt* SwFEShell::GetCurFrmFmt() const
    1211                 :            : {
    1212                 :       3659 :     SwFrmFmt* pRet = 0;
    1213                 :       3659 :     SwLayoutFrm *pFly = FindFlyFrm();
    1214 [ #  # ][ -  + ]:       3659 :     if( pFly && ( pRet = (SwFrmFmt*)pFly->GetFmt()->DerivedFrom() ) ==
                 [ -  + ]
    1215                 :          0 :                                             GetDoc()->GetDfltFrmFmt() )
    1216                 :          0 :         pRet = 0;
    1217                 :       3659 :     return pRet;
    1218                 :            : }
    1219                 :            : 
    1220                 :            : /******************************************************************************
    1221                 :            :  *  Methode     :   void SwFEShell::SetFrmFmt(SwFrmFmt *pNewFmt)
    1222                 :            :  *  Description :
    1223                 :            :  ******************************************************************************/
    1224                 :            : 
    1225                 :          0 : void SwFEShell::SetFrmFmt( SwFrmFmt *pNewFmt, sal_Bool bKeepOrient, Point* pDocPos )
    1226                 :            : {
    1227                 :          0 :     SwFlyFrm *pFly = 0;
    1228         [ #  # ]:          0 :     if(pDocPos)
    1229                 :            :     {
    1230                 :          0 :         const SwFrmFmt* pFmt = GetFmtFromObj( *pDocPos );
    1231                 :            : 
    1232 [ #  # ][ #  # ]:          0 :         if(PTR_CAST(SwFlyFrmFmt, pFmt))
         [ #  # ][ #  # ]
    1233                 :          0 :             pFly = ((SwFlyFrmFmt*)pFmt)->GetFrm();
    1234                 :            :     }
    1235                 :            :     else
    1236                 :          0 :         pFly = FindFlyFrm();
    1237                 :            :     OSL_ENSURE( pFly, "SetFrmFmt: no frame" );
    1238         [ #  # ]:          0 :     if( pFly )
    1239                 :            :     {
    1240         [ #  # ]:          0 :         StartAllAction();
    1241         [ #  # ]:          0 :         SET_CURR_SHELL( this );
    1242                 :            : 
    1243         [ #  # ]:          0 :         SwFlyFrmFmt* pFlyFmt = (SwFlyFrmFmt*)pFly->GetFmt();
    1244                 :          0 :         const Point aPt( pFly->Frm().Pos() );
    1245                 :            : 
    1246                 :          0 :         SfxItemSet* pSet = 0;
    1247                 :            :         const SfxPoolItem* pItem;
    1248 [ #  # ][ #  # ]:          0 :         if( SFX_ITEM_SET == pNewFmt->GetItemState( RES_ANCHOR, sal_False, &pItem ))
    1249                 :            :         {
    1250 [ #  # ][ #  # ]:          0 :             pSet = new SfxItemSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange );
    1251         [ #  # ]:          0 :             pSet->Put( *pItem );
    1252 [ #  # ][ #  # ]:          0 :             if( !::lcl_ChkAndSetNewAnchor( *pFly, *pSet ))
    1253 [ #  # ][ #  # ]:          0 :                 delete pSet, pSet = 0;
    1254                 :            :         }
    1255                 :            : 
    1256 [ #  # ][ #  # ]:          0 :         if( GetDoc()->SetFrmFmtToFly( *pFlyFmt, *pNewFmt, pSet, bKeepOrient ))
    1257                 :            :         {
    1258         [ #  # ]:          0 :             SwFlyFrm* pFrm = pFlyFmt->GetFrm( &aPt );
    1259         [ #  # ]:          0 :             if( pFrm )
    1260         [ #  # ]:          0 :                 SelectFlyFrm( *pFrm, sal_True );
    1261                 :            :             else
    1262         [ #  # ]:          0 :                 GetLayout()->SetAssertFlyPages();
    1263                 :            :         }
    1264 [ #  # ][ #  # ]:          0 :         delete pSet;
    1265                 :            : 
    1266 [ #  # ][ #  # ]:          0 :         EndAllActionAndCall();
    1267                 :            :     }
    1268                 :          0 : }
    1269                 :            : 
    1270                 :            : /*************************************************************************
    1271                 :            : |*
    1272                 :            : |*  SwFEShell::GetFlyFrmFmt()
    1273                 :            : |*
    1274                 :            : *************************************************************************/
    1275                 :            : 
    1276                 :          0 : const SwFrmFmt* SwFEShell::GetFlyFrmFmt() const
    1277                 :            : {
    1278                 :          0 :     const SwFlyFrm* pFly = FindFlyFrm();
    1279         [ #  # ]:          0 :     if ( !pFly )
    1280                 :            :     {
    1281                 :          0 :         SwFrm* pCurrFrm = GetCurrFrm();
    1282         [ #  # ]:          0 :         pFly = pCurrFrm ? pCurrFrm->FindFlyFrm() : 0;
    1283                 :            :     }
    1284         [ #  # ]:          0 :     if( pFly )
    1285                 :          0 :         return pFly->GetFmt();
    1286                 :          0 :     return 0;
    1287                 :            : }
    1288                 :            : 
    1289                 :          0 : SwFrmFmt* SwFEShell::GetFlyFrmFmt()
    1290                 :            : {
    1291                 :          0 :     SwFlyFrm* pFly = FindFlyFrm();
    1292         [ #  # ]:          0 :     if ( !pFly )
    1293                 :            :     {
    1294                 :          0 :         SwFrm* pCurrFrm = GetCurrFrm();
    1295         [ #  # ]:          0 :         pFly = pCurrFrm ? pCurrFrm->FindFlyFrm() : 0;
    1296                 :            :     }
    1297         [ #  # ]:          0 :     if( pFly )
    1298                 :          0 :         return pFly->GetFmt();
    1299                 :          0 :     return 0;
    1300                 :            : }
    1301                 :            : 
    1302                 :            : /*************************************************************************
    1303                 :            : |*
    1304                 :            : |*  SwFEShell::GetFlyRect()
    1305                 :            : |*
    1306                 :            : *************************************************************************/
    1307                 :            : 
    1308                 :          0 : SwRect SwFEShell::GetFlyRect() const
    1309                 :            : {
    1310                 :          0 :     SwCntntFrm *pCntnt = GetCurrFrm( sal_False );
    1311         [ #  # ]:          0 :     SwFlyFrm *pFly = pCntnt ? pCntnt->FindFlyFrm() : 0;
    1312         [ #  # ]:          0 :     if ( !pFly )
    1313                 :            :     {
    1314                 :          0 :         SwRect aRect;
    1315                 :          0 :         return aRect;
    1316                 :            :     }
    1317                 :            :     else
    1318                 :          0 :         return pFly->Frm();
    1319                 :            : }
    1320                 :            : 
    1321                 :            : /*************************************************************************
    1322                 :            : |*
    1323                 :            : |*  SwFEShell::GetObjRect()
    1324                 :            : |*
    1325                 :            : *************************************************************************/
    1326                 :            : 
    1327                 :          0 : SwRect SwFEShell::GetObjRect() const
    1328                 :            : {
    1329         [ #  # ]:          0 :     if( Imp()->HasDrawView() )
    1330                 :          0 :         return Imp()->GetDrawView()->GetAllMarkedRect();
    1331                 :            :     else
    1332                 :            :     {
    1333                 :          0 :         SwRect aRect;
    1334                 :          0 :         return aRect;
    1335                 :            :     }
    1336                 :            : }
    1337                 :            : 
    1338                 :          0 : void SwFEShell::SetObjRect( const SwRect& rRect )
    1339                 :            : {
    1340         [ #  # ]:          0 :     if ( Imp()->HasDrawView() )
    1341                 :            :     {
    1342         [ #  # ]:          0 :         Imp()->GetDrawView()->SetAllMarkedRect( rRect.SVRect() );
    1343                 :          0 :         CallChgLnk();   // call AttrChangeNotify on the UI-side.
    1344                 :            :     }
    1345                 :          0 : }
    1346                 :            : 
    1347                 :            : /***********************************************************************
    1348                 :            : #*  Class       :  SwFEShell
    1349                 :            : #*  Methode     :  RequestObjectResize()
    1350                 :            : #***********************************************************************/
    1351                 :            : 
    1352                 :          6 : Size SwFEShell::RequestObjectResize( const SwRect &rRect, const uno::Reference < embed::XEmbeddedObject >& xObj )
    1353                 :            : {
    1354                 :          6 :     Size aResult;
    1355                 :            : 
    1356         [ +  - ]:          6 :     SwFlyFrm *pFly = FindFlyFrm( xObj );
    1357         [ -  + ]:          6 :     if ( !pFly )
    1358                 :            :     {
    1359                 :          0 :         aResult = rRect.SSize();
    1360                 :            :         return aResult;
    1361                 :            :     }
    1362                 :            : 
    1363                 :          6 :     aResult = pFly->Prt().SSize();
    1364                 :            : 
    1365 [ +  - ][ +  - ]:          6 :     sal_Bool bPosProt = pFly->GetFmt()->GetProtect().IsPosProtected();
    1366 [ +  - ][ +  - ]:          6 :     sal_Bool bSizeProt = pFly->GetFmt()->GetProtect().IsSizeProtected();
    1367                 :            : 
    1368         [ +  - ]:          6 :     StartAllAction();
    1369                 :            : 
    1370                 :            :     // MA we do not allow to clip the Fly, as the OLE server can
    1371                 :            :     // request various wishes. Clipping is done via the formatting.
    1372                 :            :     // Correct display is done by scaling.
    1373                 :            :     // Scaling is done by SwNoTxtFrm::Format by calling
    1374                 :            :     // SwWrtShell::CalcAndSetScale()
    1375 [ +  + ][ +  - ]:          6 :     if ( rRect.SSize() != pFly->Prt().SSize() && !bSizeProt )
                 [ +  + ]
    1376                 :            :     {
    1377                 :          2 :          Size aSz( rRect.SSize() );
    1378                 :            : 
    1379                 :            :         //JP 28.02.2001: Task 74707 - ask for fly in fly with automatic size
    1380                 :            :         //
    1381                 :            :         const SwFrm* pAnchor;
    1382                 :            :         const SwTxtNode* pTNd;
    1383                 :            :         const SwpHints* pHts;
    1384 [ +  - ][ +  - ]:          2 :         const SwFmtFrmSize& rFrmSz = pFly->GetFmt()->GetFrmSize();
    1385   [ -  +  #  # ]:          2 :         if( bCheckForOLEInCaption &&
         [ #  # ][ #  #  
          #  #  #  #  #  
             #  #  #  #  
              # ][ #  # ]
                 [ -  + ]
    1386                 :          0 :             0 != rFrmSz.GetWidthPercent() &&
    1387                 :          0 :             0 != (pAnchor = pFly->GetAnchorFrm()) &&
    1388                 :          0 :             pAnchor->IsTxtFrm() &&
    1389                 :          0 :             !pAnchor->GetNext() && !pAnchor->GetPrev() &&
    1390                 :          0 :             pAnchor->GetUpper()->IsFlyFrm() &&
    1391                 :          0 :             0 != ( pTNd = ((SwTxtFrm*)pAnchor)->GetNode()->GetTxtNode()) &&
    1392                 :            :             0 != ( pHts = pTNd->GetpSwpHints() ))
    1393                 :            :         {
    1394                 :            :             // search for a sequence field:
    1395                 :            :             const SfxPoolItem* pItem;
    1396         [ #  # ]:          0 :             for( sal_uInt16 n = 0, nEnd = pHts->Count(); n < nEnd; ++n )
    1397 [ #  # ][ #  # ]:          0 :                 if( RES_TXTATR_FIELD == ( pItem =
                 [ #  # ]
    1398         [ #  # ]:          0 :                             &(*pHts)[ n ]->GetAttr())->Which() &&
    1399         [ #  # ]:          0 :                     TYP_SEQFLD == ((SwFmtFld*)pItem)->GetFld()->GetTypeId() )
    1400                 :            :                 {
    1401                 :            :                     // sequence field found
    1402                 :          0 :                     SwFlyFrm* pChgFly = (SwFlyFrm*)pAnchor->GetUpper();
    1403                 :            :                     // calculate the changed size:
    1404                 :            :                     // width must change, height can change
    1405                 :          0 :                     Size aNewSz( aSz.Width() + pChgFly->Frm().Width() -
    1406                 :          0 :                                    pFly->Prt().Width(), aSz.Height() );
    1407                 :            : 
    1408         [ #  # ]:          0 :                     SwFrmFmt *pFmt = pChgFly->GetFmt();
    1409 [ #  # ][ #  # ]:          0 :                     SwFmtFrmSize aFrmSz( pFmt->GetFrmSize() );
    1410                 :          0 :                     aFrmSz.SetWidth( aNewSz.Width() );
    1411         [ #  # ]:          0 :                     if( ATT_MIN_SIZE != aFrmSz.GetHeightSizeType() )
    1412                 :            :                     {
    1413                 :          0 :                         aNewSz.Height() += pChgFly->Frm().Height() -
    1414                 :          0 :                                                pFly->Prt().Height();
    1415         [ #  # ]:          0 :                         if( Abs( aNewSz.Height() - pChgFly->Frm().Height()) > 1 )
    1416                 :          0 :                             aFrmSz.SetHeight( aNewSz.Height() );
    1417                 :            :                     }
    1418                 :            :                     // via Doc for the Undo!
    1419         [ #  # ]:          0 :                     pFmt->GetDoc()->SetAttr( aFrmSz, *pFmt );
    1420         [ #  # ]:          0 :                     break;
    1421                 :            :                 }
    1422                 :            :         }
    1423                 :            : 
    1424                 :            :         // set the new Size at the fly themself
    1425 [ +  - ][ +  - ]:          2 :         if ( pFly->Prt().Height() > 0 && pFly->Prt().Width() > 0 )
                 [ +  - ]
    1426                 :            :         {
    1427                 :          2 :             aSz.Width() += pFly->Frm().Width() - pFly->Prt().Width();
    1428                 :          2 :             aSz.Height()+= pFly->Frm().Height()- pFly->Prt().Height();
    1429                 :            :         }
    1430         [ +  - ]:          2 :         aResult = pFly->ChgSize( aSz );
    1431                 :            : 
    1432                 :            :         // if the object changes, the contour is outside the object
    1433                 :            :         OSL_ENSURE( pFly->Lower()->IsNoTxtFrm(), "Request without NoTxt" );
    1434                 :          2 :         SwNoTxtNode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetNoTxtNode();
    1435                 :            :         OSL_ENSURE( pNd, "Request without Node" );
    1436         [ +  - ]:          2 :         pNd->SetContour( 0 );
    1437         [ +  - ]:          2 :         ClrContourCache();
    1438                 :            :     }
    1439                 :            : 
    1440                 :            :     // if only the size is to be adjusted, a position is transported with
    1441                 :            :     // allocated values
    1442                 :          6 :     Point aPt( pFly->Prt().Pos() );
    1443                 :          6 :     aPt += pFly->Frm().Pos();
    1444 [ #  # ][ #  # ]:          6 :     if ( rRect.Top() != LONG_MIN && rRect.Pos() != aPt && !bPosProt )
         [ -  + ][ -  + ]
    1445                 :            :     {
    1446                 :          0 :         aPt = rRect.Pos();
    1447                 :          0 :         aPt.X() -= pFly->Prt().Left();
    1448                 :          0 :         aPt.Y() -= pFly->Prt().Top();
    1449                 :            : 
    1450                 :            :         // in case of paragraph-bound Flys, starting from the new position,
    1451                 :            :         // a new anchor is to be set. The anchor and the new RelPos are
    1452                 :            :         // calculated by the Fly and set
    1453         [ #  # ]:          0 :         if( pFly->IsFlyAtCntFrm() )
    1454         [ #  # ]:          0 :             ((SwFlyAtCntFrm*)pFly)->SetAbsPos( aPt );
    1455                 :            :         else
    1456                 :            :         {
    1457         [ #  # ]:          0 :             const SwFrmFmt *pFmt = pFly->GetFmt();
    1458         [ #  # ]:          0 :             const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
    1459         [ #  # ]:          0 :             const SwFmtHoriOrient &rHori = pFmt->GetHoriOrient();
    1460                 :          0 :             const long lXDiff = aPt.X() - pFly->Frm().Left();
    1461                 :          0 :             const long lYDiff = aPt.Y() - pFly->Frm().Top();
    1462                 :          0 :             const Point aTmp( rHori.GetPos() + lXDiff,
    1463                 :          0 :                               rVert.GetPos() + lYDiff );
    1464         [ #  # ]:          0 :             pFly->ChgRelPos( aTmp );
    1465                 :            :         }
    1466                 :            :     }
    1467                 :            : 
    1468         [ +  - ]:          6 :     SwFlyFrmFmt *pFlyFrmFmt = pFly->GetFmt();
    1469                 :            :     OSL_ENSURE( pFlyFrmFmt, "fly frame format missing!" );
    1470         [ +  - ]:          6 :     if ( pFlyFrmFmt )
    1471                 :          6 :         pFlyFrmFmt->SetLastFlyFrmPrtRectPos( pFly->Prt().Pos() ); //stores the value of last Prt rect
    1472                 :            : 
    1473         [ +  - ]:          6 :     EndAllAction();
    1474                 :            : 
    1475                 :            :     return aResult;
    1476                 :            : }
    1477                 :            : 
    1478                 :            : 
    1479                 :            : /***********************************************************************
    1480                 :            : #*  Class       :  SwFEShell
    1481                 :            : #*  Methode     :  WizzardFindCurFrmFmt
    1482                 :            : #***********************************************************************/
    1483                 :            : 
    1484                 :          0 : SwFrmFmt* SwFEShell::WizzardGetFly()
    1485                 :            : {
    1486                 :            :     // do not search the Fly via the layout. Now we can delete a frame
    1487                 :            :     // without a valid layout. ( e.g. for the wizards )
    1488                 :          0 :     SwFrmFmts& rSpzArr = *pDoc->GetSpzFrmFmts();
    1489                 :          0 :     sal_uInt16 nCnt = rSpzArr.size();
    1490         [ #  # ]:          0 :     if( nCnt )
    1491                 :            :     {
    1492                 :          0 :         SwNodeIndex& rCrsrNd = GetCrsr()->GetPoint()->nNode;
    1493         [ #  # ]:          0 :         if( rCrsrNd.GetIndex() > pDoc->GetNodes().GetEndOfExtras().GetIndex() )
    1494                 :            :             // Cursor is in the body area!
    1495                 :          0 :             return 0;
    1496                 :            : 
    1497         [ #  # ]:          0 :         for( sal_uInt16 n = 0; n < nCnt; ++n )
    1498                 :            :         {
    1499                 :          0 :             SwFrmFmt* pFmt = rSpzArr[ n ];
    1500                 :          0 :             const SwNodeIndex* pIdx = pFmt->GetCntnt( sal_False ).GetCntntIdx();
    1501                 :            :             SwStartNode* pSttNd;
    1502 [ #  # ][ #  #  :          0 :             if( pIdx &&
          #  #  #  #  #  
                      # ]
    1503                 :          0 :                 0 != ( pSttNd = pIdx->GetNode().GetStartNode() ) &&
    1504                 :          0 :                 pSttNd->GetIndex() < rCrsrNd.GetIndex() &&
    1505                 :          0 :                 rCrsrNd.GetIndex() < pSttNd->EndOfSectionIndex() )
    1506                 :            :             {
    1507                 :            :                 // found: return immediately
    1508                 :          0 :                 return pFmt;
    1509                 :            :             }
    1510                 :            :         }
    1511                 :            :     }
    1512                 :          0 :     return 0;
    1513                 :            : }
    1514                 :            : 
    1515                 :          0 : void SwFEShell::SetFlyName( const String& rName )
    1516                 :            : {
    1517                 :          0 :     SwLayoutFrm *pFly = FindFlyFrm();
    1518         [ #  # ]:          0 :     if( pFly )
    1519                 :          0 :         GetDoc()->SetFlyName( *(SwFlyFrmFmt*)pFly->GetFmt(), rName );
    1520                 :            :     else {
    1521                 :            :         OSL_ENSURE( !this, "no FlyFrame selected" );
    1522                 :            :     }
    1523                 :          0 : }
    1524                 :            : 
    1525                 :          0 : const String& SwFEShell::GetFlyName() const
    1526                 :            : {
    1527                 :          0 :     SwLayoutFrm *pFly = FindFlyFrm();
    1528         [ #  # ]:          0 :     if( pFly )
    1529                 :          0 :         return pFly->GetFmt()->GetName();
    1530                 :            : 
    1531                 :            :     OSL_ENSURE( !this, "no FlyFrame selected" );
    1532                 :          0 :     return aEmptyStr;
    1533                 :            : }
    1534                 :            : 
    1535                 :            : 
    1536                 :          0 : const uno::Reference < embed::XEmbeddedObject > SwFEShell::GetOleRef() const
    1537                 :            : {
    1538                 :          0 :     uno::Reference < embed::XEmbeddedObject > xObj;
    1539         [ #  # ]:          0 :     SwFlyFrm * pFly = FindFlyFrm();
    1540 [ #  # ][ #  # ]:          0 :     if (pFly && pFly->Lower() && pFly->Lower()->IsNoTxtFrm())
         [ #  # ][ #  # ]
    1541                 :            :     {
    1542                 :          0 :         SwOLENode *pNd = ((SwNoTxtFrm*)pFly->Lower())->GetNode()->GetOLENode();
    1543         [ #  # ]:          0 :         if (pNd)
    1544 [ #  # ][ #  # ]:          0 :             xObj = pNd->GetOLEObj().GetOleRef();
    1545                 :            :     }
    1546                 :          0 :     return xObj;
    1547                 :            : }
    1548                 :            : 
    1549                 :            : 
    1550                 :          0 : String SwFEShell::GetUniqueGrfName() const
    1551                 :            : {
    1552                 :          0 :     return GetDoc()->GetUniqueGrfName();
    1553                 :            : }
    1554                 :            : 
    1555                 :          0 : const SwFrmFmt* SwFEShell::IsURLGrfAtPos( const Point& rPt, String* pURL,
    1556                 :            :                                         String *pTargetFrameName,
    1557                 :            :                                         String *pDescription ) const
    1558                 :            : {
    1559         [ #  # ]:          0 :     if( !Imp()->HasDrawView() )
    1560                 :          0 :         return 0;
    1561                 :            : 
    1562                 :            :     SdrObject* pObj;
    1563                 :            :     SdrPageView* pPV;
    1564                 :          0 :     const SwFrmFmt* pRet = 0;
    1565                 :          0 :     SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
    1566                 :            : 
    1567                 :          0 :     sal_uInt16 nOld = pDView->GetHitTolerancePixel();
    1568         [ #  # ]:          0 :     pDView->SetHitTolerancePixel( 2 );
    1569                 :            : 
    1570 [ #  # ][ #  # ]:          0 :     if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV,SDRSEARCH_PICKMACRO ) &&
         [ #  # ][ #  # ]
    1571 [ #  # ][ #  # ]:          0 :         pObj->ISA(SwVirtFlyDrawObj) )
    1572                 :            :     {
    1573                 :          0 :         SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
    1574 [ #  # ][ #  # ]:          0 :         const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
    1575 [ #  # ][ #  # ]:          0 :         if( rURL.GetURL().Len() || rURL.GetMap() )
                 [ #  # ]
    1576                 :            :         {
    1577                 :          0 :             sal_Bool bSetTargetFrameName = pTargetFrameName != 0;
    1578                 :          0 :             sal_Bool bSetDescription = pDescription != 0;
    1579         [ #  # ]:          0 :             if ( rURL.GetMap() )
    1580                 :            :             {
    1581 [ #  # ][ #  # ]:          0 :                 IMapObject *pObject = pFly->GetFmt()->GetIMapObject( rPt, pFly );
    1582 [ #  # ][ #  # ]:          0 :                 if ( pObject && pObject->GetURL().Len() )
                 [ #  # ]
    1583                 :            :                 {
    1584         [ #  # ]:          0 :                     if( pURL )
    1585         [ #  # ]:          0 :                         *pURL = pObject->GetURL();
    1586 [ #  # ][ #  # ]:          0 :                     if ( bSetTargetFrameName && pObject->GetTarget().Len() )
                 [ #  # ]
    1587                 :            :                     {
    1588                 :          0 :                         bSetTargetFrameName = sal_False;
    1589         [ #  # ]:          0 :                         *pTargetFrameName = pObject->GetTarget();
    1590                 :            :                     }
    1591         [ #  # ]:          0 :                     if ( bSetDescription )
    1592                 :            :                     {
    1593                 :          0 :                         bSetDescription = sal_False;
    1594         [ #  # ]:          0 :                         *pDescription = pObject->GetAltText();
    1595                 :            :                     }
    1596         [ #  # ]:          0 :                     pRet = pFly->GetFmt();
    1597                 :            :                 }
    1598                 :            :             }
    1599                 :            :             else
    1600                 :            :             {
    1601         [ #  # ]:          0 :                 if( pURL )
    1602                 :            :                 {
    1603         [ #  # ]:          0 :                     *pURL = rURL.GetURL();
    1604         [ #  # ]:          0 :                     if( rURL.IsServerMap() )
    1605                 :            :                     {
    1606                 :            :                        // append the relative pixel position !!
    1607                 :          0 :                         Point aPt( rPt );
    1608                 :          0 :                         aPt -= pFly->Frm().Pos();
    1609                 :            :                         // without MapMode-Offset, without Offset, o ... !!!!!
    1610                 :            :                         aPt = GetOut()->LogicToPixel(
    1611 [ #  # ][ #  # ]:          0 :                                 aPt, MapMode( MAP_TWIP ) );
                 [ #  # ]
    1612 [ #  # ][ #  # ]:          0 :                         ((( *pURL += '?' ) += String::CreateFromInt32( aPt.X() ))
         [ #  # ][ #  # ]
    1613 [ #  # ][ #  # ]:          0 :                                   += ',' ) += String::CreateFromInt32(aPt.Y() );
         [ #  # ][ #  # ]
    1614                 :            :                     }
    1615                 :            :                 }
    1616         [ #  # ]:          0 :                 pRet = pFly->GetFmt();
    1617                 :            :             }
    1618         [ #  # ]:          0 :             if ( bSetTargetFrameName )
    1619         [ #  # ]:          0 :                 *pTargetFrameName = rURL.GetTargetFrameName();
    1620         [ #  # ]:          0 :             if ( bSetDescription )
    1621 [ #  # ][ #  # ]:          0 :                 *pDescription = pFly->GetFmt()->GetName();
    1622                 :            :         }
    1623                 :            :     }
    1624         [ #  # ]:          0 :     pDView->SetHitTolerancePixel( nOld );
    1625                 :          0 :     return pRet;
    1626                 :            : }
    1627                 :            : 
    1628                 :          0 : const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt,
    1629                 :            :                                        String &rName, sal_Bool &rbLink ) const
    1630                 :            : {
    1631         [ #  # ]:          0 :     if( !Imp()->HasDrawView() )
    1632                 :          0 :         return 0;
    1633                 :            : 
    1634                 :            :     SdrObject* pObj;
    1635                 :            :     SdrPageView* pPV;
    1636                 :          0 :     SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
    1637                 :            : 
    1638 [ #  # ][ #  # ]:          0 :     if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV ) && pObj->ISA(SwVirtFlyDrawObj) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1639                 :            :     {
    1640                 :          0 :         SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
    1641 [ #  # ][ #  # ]:          0 :         if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
                 [ #  # ]
    1642                 :            :         {
    1643                 :          0 :             SwGrfNode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetGrfNode();
    1644         [ #  # ]:          0 :             if ( pNd )
    1645                 :            :             {
    1646         [ #  # ]:          0 :                 if ( pNd->IsGrfLink() )
    1647                 :            :                 {
    1648                 :            :                     // halfway ready graphic?
    1649 [ #  # ][ #  # ]:          0 :                     ::sfx2::SvLinkSource* pLnkObj = pNd->GetLink()->GetObj();
    1650 [ #  # ][ #  # ]:          0 :                     if( pLnkObj && pLnkObj->IsPending() )
         [ #  # ][ #  # ]
    1651                 :          0 :                         return 0;
    1652                 :          0 :                     rbLink = sal_True;
    1653                 :            :                 }
    1654                 :            : 
    1655         [ #  # ]:          0 :                 pNd->GetFileFilterNms( &rName, 0 );
    1656         [ #  # ]:          0 :                 if ( !rName.Len() )
    1657 [ #  # ][ #  # ]:          0 :                     rName = pFly->GetFmt()->GetName();
    1658         [ #  # ]:          0 :                 pNd->SwapIn( sal_True );
    1659         [ #  # ]:          0 :                 return &pNd->GetGrf();
    1660                 :            :             }
    1661                 :            :         }
    1662                 :            :     }
    1663                 :          0 :     return 0;
    1664                 :            : }
    1665                 :            : 
    1666                 :            : 
    1667                 :          0 : const SwFrmFmt* SwFEShell::GetFmtFromObj( const Point& rPt, SwRect** pRectToFill ) const
    1668                 :            : {
    1669                 :          0 :     SwFrmFmt* pRet = 0;
    1670                 :            : 
    1671         [ #  # ]:          0 :     if( Imp()->HasDrawView() )
    1672                 :            :     {
    1673                 :            :         SdrObject* pObj;
    1674                 :            :         SdrPageView* pPView;
    1675                 :            : 
    1676                 :          0 :         SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
    1677                 :            : 
    1678                 :          0 :         sal_uInt16 nOld = pDView->GetHitTolerancePixel();
    1679                 :            :         // tolerance for Drawing-SS
    1680 [ #  # ][ #  # ]:          0 :         pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
    1681                 :            : 
    1682 [ #  # ][ #  # ]:          0 :         if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) )
    1683                 :            :         {
    1684                 :            :            // first check it:
    1685 [ #  # ][ #  # ]:          0 :             if ( pObj->ISA(SwVirtFlyDrawObj) )
                 [ #  # ]
    1686         [ #  # ]:          0 :                 pRet = ((SwVirtFlyDrawObj*)pObj)->GetFmt();
    1687 [ #  # ][ #  # ]:          0 :             else if ( pObj->GetUserCall() ) //not for group objects
    1688         [ #  # ]:          0 :                 pRet = ((SwDrawContact*)pObj->GetUserCall())->GetFmt();
    1689 [ #  # ][ #  # ]:          0 :             if(pRet && pRectToFill)
    1690 [ #  # ][ #  # ]:          0 :                 **pRectToFill = pObj->GetCurrentBoundRect();
    1691                 :            :         }
    1692         [ #  # ]:          0 :         pDView->SetHitTolerancePixel( nOld );
    1693                 :            :     }
    1694                 :          0 :     return pRet;
    1695                 :            : }
    1696                 :            : 
    1697                 :            : // returns a format too, if the point is over the text of any fly
    1698                 :          0 : const SwFrmFmt* SwFEShell::GetFmtFromAnyObj( const Point& rPt ) const
    1699                 :            : {
    1700                 :          0 :     const SwFrmFmt* pRet = GetFmtFromObj( rPt );
    1701 [ #  # ][ #  # ]:          0 :     if( !pRet || RES_FLYFRMFMT == pRet->Which() )
                 [ #  # ]
    1702                 :            :     {
    1703 [ #  # ][ #  # ]:          0 :         SwPosition aPos( *GetCrsr()->GetPoint() );
    1704                 :          0 :         Point aPt( rPt );
    1705 [ #  # ][ #  # ]:          0 :         GetLayout()->GetCrsrOfst( &aPos, aPt );
    1706                 :          0 :         SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
    1707 [ #  # ][ #  # ]:          0 :         SwFrm* pFrm = pNd->getLayoutFrm( GetLayout(), &rPt, 0, sal_False )->FindFlyFrm();
                 [ #  # ]
    1708 [ #  # ][ #  # ]:          0 :         pRet = pFrm ? ((SwLayoutFrm*)pFrm)->GetFmt() : 0;
                 [ #  # ]
    1709                 :            :     }
    1710                 :          0 :     return pRet;
    1711                 :            : }
    1712                 :            : 
    1713                 :          0 : ObjCntType SwFEShell::GetObjCntType( const SdrObject& rObj ) const
    1714                 :            : {
    1715                 :          0 :     ObjCntType eType = OBJCNT_NONE;
    1716                 :            : 
    1717                 :            :     // investigate 'master' drawing object, if method
    1718                 :            :     // is called for a 'virtual' drawing object.
    1719                 :            :     const SdrObject* pInvestigatedObj;
    1720         [ #  # ]:          0 :     if ( rObj.ISA(SwDrawVirtObj) )
    1721                 :            :     {
    1722                 :          0 :         const SwDrawVirtObj* pDrawVirtObj = static_cast<const SwDrawVirtObj*>(&rObj);
    1723                 :          0 :         pInvestigatedObj = &(pDrawVirtObj->GetReferencedObj());
    1724                 :            :     }
    1725                 :            :     else
    1726                 :            :     {
    1727                 :          0 :         pInvestigatedObj = &rObj;
    1728                 :            :     }
    1729                 :            : 
    1730         [ #  # ]:          0 :     if( FmFormInventor == pInvestigatedObj->GetObjInventor() )
    1731                 :            :     {
    1732                 :          0 :         eType = OBJCNT_CONTROL;
    1733                 :            :         uno::Reference< awt::XControlModel >  xModel =
    1734         [ #  # ]:          0 :                 ((SdrUnoObj&)(*pInvestigatedObj)).GetUnoControlModel();
    1735         [ #  # ]:          0 :         if( xModel.is() )
    1736                 :            :         {
    1737                 :          0 :             uno::Any aVal;
    1738         [ #  # ]:          0 :             OUString sName(RTL_CONSTASCII_USTRINGPARAM("ButtonType"));
    1739         [ #  # ]:          0 :             uno::Reference< beans::XPropertySet >  xSet(xModel, uno::UNO_QUERY);
    1740                 :            : 
    1741 [ #  # ][ #  # ]:          0 :             uno::Reference< beans::XPropertySetInfo >  xInfo = xSet->getPropertySetInfo();
    1742 [ #  # ][ #  # ]:          0 :             if(xInfo->hasPropertyByName( sName ))
                 [ #  # ]
    1743                 :            :             {
    1744 [ #  # ][ #  # ]:          0 :                 beans::Property xProperty = xInfo->getPropertyByName( sName );
    1745 [ #  # ][ #  # ]:          0 :                 aVal = xSet->getPropertyValue( sName );
    1746 [ #  # ][ #  # ]:          0 :                 if( aVal.getValue() && form::FormButtonType_URL == *((form::FormButtonType*)aVal.getValue()) )
                 [ #  # ]
    1747                 :          0 :                     eType = OBJCNT_URLBUTTON;
    1748                 :          0 :             }
    1749                 :          0 :         }
    1750                 :            :     }
    1751         [ #  # ]:          0 :     else if( pInvestigatedObj->ISA(SwVirtFlyDrawObj) )
    1752                 :            :     {
    1753                 :          0 :         SwFlyFrm *pFly = ((SwVirtFlyDrawObj&)(*pInvestigatedObj)).GetFlyFrm();
    1754 [ #  # ][ #  # ]:          0 :         if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
                 [ #  # ]
    1755                 :            :         {
    1756         [ #  # ]:          0 :             if ( ((SwCntntFrm*)pFly->Lower())->GetNode()->GetGrfNode() )
    1757                 :          0 :                 eType = OBJCNT_GRF;
    1758                 :            :             else
    1759                 :          0 :                 eType = OBJCNT_OLE;
    1760                 :            :         }
    1761                 :            :         else
    1762                 :          0 :             eType = OBJCNT_FLY;
    1763                 :            :     }
    1764         [ #  # ]:          0 :     else if ( pInvestigatedObj->ISA( SdrObjGroup ) )
    1765                 :            :     {
    1766         [ #  # ]:          0 :         SwDrawContact* pDrawContact( dynamic_cast<SwDrawContact*>(GetUserCall( pInvestigatedObj ) ) );
    1767         [ #  # ]:          0 :         if ( !pDrawContact )
    1768                 :            :         {
    1769                 :            :             OSL_FAIL( "<SwFEShell::GetObjCntType(..)> - missing draw contact object" );
    1770                 :          0 :             eType = OBJCNT_NONE;
    1771                 :            :         }
    1772                 :            :         else
    1773                 :            :         {
    1774                 :          0 :             SwFrmFmt* pFrmFmt( pDrawContact->GetFmt() );
    1775         [ #  # ]:          0 :             if ( !pFrmFmt )
    1776                 :            :             {
    1777                 :            :                 OSL_FAIL( "<SwFEShell::GetObjCntType(..)> - missing frame format" );
    1778                 :          0 :                 eType = OBJCNT_NONE;
    1779                 :            :             }
    1780         [ #  # ]:          0 :             else if ( FLY_AS_CHAR != pFrmFmt->GetAnchor().GetAnchorId() )
    1781                 :            :             {
    1782                 :          0 :                 eType = OBJCNT_GROUPOBJ;
    1783                 :            :             }
    1784                 :            :         }
    1785                 :            :     }
    1786                 :            :     else
    1787                 :          0 :         eType = OBJCNT_SIMPLE;
    1788                 :          0 :     return eType;
    1789                 :            : }
    1790                 :            : 
    1791                 :          0 : ObjCntType SwFEShell::GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const
    1792                 :            : {
    1793                 :          0 :     ObjCntType eType = OBJCNT_NONE;
    1794                 :            : 
    1795         [ #  # ]:          0 :     if( Imp()->HasDrawView() )
    1796                 :            :     {
    1797                 :            :         SdrObject* pObj;
    1798                 :            :         SdrPageView* pPView;
    1799                 :            : 
    1800                 :          0 :         SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView();
    1801                 :            : 
    1802                 :          0 :         sal_uInt16 nOld = pDView->GetHitTolerancePixel();
    1803                 :            :         // tolerance for Drawing-SS
    1804 [ #  # ][ #  # ]:          0 :         pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
    1805                 :            : 
    1806 [ #  # ][ #  # ]:          0 :         if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) )
    1807         [ #  # ]:          0 :             eType = GetObjCntType( *(rpObj = pObj) );
    1808                 :            : 
    1809         [ #  # ]:          0 :         pDView->SetHitTolerancePixel( nOld );
    1810                 :            :     }
    1811                 :          0 :     return eType;
    1812                 :            : }
    1813                 :            : 
    1814                 :       5622 : ObjCntType SwFEShell::GetObjCntTypeOfSelection( SdrObject** ppObj ) const
    1815                 :            : {
    1816                 :       5622 :     ObjCntType eType = OBJCNT_NONE;
    1817                 :            : 
    1818         [ +  - ]:       5622 :     if( Imp()->HasDrawView() )
    1819                 :            :     {
    1820                 :       5622 :         const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
    1821         [ -  + ]:       5622 :         for( sal_uInt32 i = 0, nE = rMrkList.GetMarkCount(); i < nE; ++i )
    1822                 :            :         {
    1823                 :          0 :             SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
    1824         [ #  # ]:          0 :             if( !pObj )
    1825                 :          0 :                 continue;
    1826                 :          0 :             ObjCntType eTmp = GetObjCntType( *pObj );
    1827         [ #  # ]:          0 :             if( !i )
    1828                 :            :             {
    1829                 :          0 :                 eType = eTmp;
    1830         [ #  # ]:          0 :                 if( ppObj ) *ppObj = pObj;
    1831                 :            :             }
    1832         [ #  # ]:          0 :             else if( eTmp != eType )
    1833                 :            :             {
    1834                 :          0 :                 eType = OBJCNT_DONTCARE;
    1835                 :            :                 // once DontCare, always DontCare!
    1836                 :          0 :                 break;
    1837                 :            :             }
    1838                 :            :         }
    1839                 :            :     }
    1840                 :       5622 :     return eType;
    1841                 :            : }
    1842                 :            : 
    1843                 :            : 
    1844                 :          0 : sal_Bool SwFEShell::ReplaceSdrObj( const String& rGrfName, const String& rFltName,
    1845                 :            :                                 const Graphic* pGrf )
    1846                 :            : {
    1847         [ #  # ]:          0 :     SET_CURR_SHELL( this );
    1848                 :            : 
    1849                 :          0 :     sal_Bool bRet = sal_False;
    1850                 :            :     const SdrMarkList *pMrkList;
    1851   [ #  #  #  # ]:          0 :     if( Imp()->HasDrawView() &&  1 ==
                 [ #  # ]
    1852                 :          0 :         ( pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList())->GetMarkCount() )
    1853                 :            :     {
    1854 [ #  # ][ #  # ]:          0 :         SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
    1855         [ #  # ]:          0 :         SwFrmFmt *pFmt = FindFrmFmt( pObj );
    1856                 :            : 
    1857                 :            :         // store attributes, then set the graphic
    1858                 :          0 :         SfxItemSet aFrmSet( pDoc->GetAttrPool(),
    1859         [ #  # ]:          0 :                             pFmt->GetAttrSet().GetRanges() );
    1860         [ #  # ]:          0 :         aFrmSet.Set( pFmt->GetAttrSet() );
    1861                 :            : 
    1862                 :            :         // set size and position?
    1863 [ #  # ][ #  # ]:          0 :         if( !pObj->ISA(SwVirtFlyDrawObj) )
                 [ #  # ]
    1864                 :            :         {
    1865                 :            :             // then let's do it:
    1866         [ #  # ]:          0 :             const Rectangle &rBound = pObj->GetSnapRect();
    1867         [ #  # ]:          0 :             Point aRelPos( pObj->GetRelativePos() );
    1868                 :            : 
    1869                 :          0 :             const long nWidth = rBound.Right()  - rBound.Left();
    1870                 :          0 :             const long nHeight= rBound.Bottom() - rBound.Top();
    1871                 :            :             aFrmSet.Put( SwFmtFrmSize( ATT_MIN_SIZE,
    1872                 :            :                                 Max( nWidth,  long(MINFLY) ),
    1873 [ #  # ][ #  # ]:          0 :                                 Max( nHeight, long(MINFLY) )));
                 [ #  # ]
    1874                 :            : 
    1875 [ #  # ][ #  # ]:          0 :             if( SFX_ITEM_SET != aFrmSet.GetItemState( RES_HORI_ORIENT ))
    1876 [ #  # ][ #  # ]:          0 :                 aFrmSet.Put( SwFmtHoriOrient( aRelPos.X(), text::HoriOrientation::NONE, text::RelOrientation::FRAME ));
                 [ #  # ]
    1877                 :            : 
    1878 [ #  # ][ #  # ]:          0 :             if( SFX_ITEM_SET != aFrmSet.GetItemState( RES_VERT_ORIENT ))
    1879 [ #  # ][ #  # ]:          0 :                 aFrmSet.Put( SwFmtVertOrient( aRelPos.Y(), text::VertOrientation::NONE, text::RelOrientation::FRAME ));
                 [ #  # ]
    1880                 :            : 
    1881                 :            :         }
    1882                 :            : 
    1883         [ #  # ]:          0 :         pObj->GetOrdNum();
    1884                 :            : 
    1885         [ #  # ]:          0 :         StartAllAction();
    1886         [ #  # ]:          0 :         StartUndo();
    1887                 :            : 
    1888                 :            :         // delete "Sdr-Object", insert the graphic instead
    1889         [ #  # ]:          0 :         DelSelectedObj();
    1890                 :            : 
    1891 [ #  # ][ #  # ]:          0 :         pFmt = GetDoc()->Insert( *GetCrsr(), rGrfName, rFltName, pGrf, &aFrmSet, NULL, NULL );
    1892                 :            : 
    1893         [ #  # ]:          0 :         EndUndo();
    1894         [ #  # ]:          0 :         EndAllAction();
    1895         [ #  # ]:          0 :         bRet = sal_True;
    1896                 :            :     }
    1897         [ #  # ]:          0 :     return bRet;
    1898                 :            : }
    1899                 :            : 
    1900                 :          0 : static sal_uInt16 SwFmtGetPageNum(const SwFlyFrmFmt * pFmt)
    1901                 :            : {
    1902                 :            :     OSL_ENSURE(pFmt != NULL, "invalid argument");
    1903                 :            : 
    1904                 :          0 :     SwFlyFrm * pFrm = pFmt->GetFrm();
    1905                 :            : 
    1906                 :            :     sal_uInt16 aResult;
    1907                 :            : 
    1908         [ #  # ]:          0 :     if (pFrm != NULL)
    1909                 :          0 :         aResult = pFrm->GetPhyPageNum();
    1910                 :            :     else
    1911                 :          0 :         aResult = pFmt->GetAnchor().GetPageNum();
    1912                 :            : 
    1913                 :          0 :     return aResult;
    1914                 :            : }
    1915                 :            : 
    1916                 :            : #include <fmtcnct.hxx>
    1917                 :            : 
    1918                 :          0 : void SwFEShell::GetConnectableFrmFmts(SwFrmFmt & rFmt,
    1919                 :            :                                       const String & rReference,
    1920                 :            :                                       sal_Bool bSuccessors,
    1921                 :            :                                       ::std::vector< String > & aPrevPageVec,
    1922                 :            :                                       ::std::vector< String > & aThisPageVec,
    1923                 :            :                                       ::std::vector< String > & aNextPageVec,
    1924                 :            :                                       ::std::vector< String > & aRestVec)
    1925                 :            : {
    1926         [ #  # ]:          0 :     StartAction();
    1927                 :            : 
    1928 [ #  # ][ #  # ]:          0 :     SwFmtChain rChain = rFmt.GetChain();
    1929                 :          0 :     SwFrmFmt * pOldChainNext = (SwFrmFmt *) rChain.GetNext();
    1930                 :          0 :     SwFrmFmt * pOldChainPrev = (SwFrmFmt *) rChain.GetPrev();
    1931                 :            : 
    1932         [ #  # ]:          0 :     if (pOldChainNext)
    1933         [ #  # ]:          0 :         pDoc->Unchain(rFmt);
    1934                 :            : 
    1935         [ #  # ]:          0 :     if (pOldChainPrev)
    1936         [ #  # ]:          0 :         pDoc->Unchain(*pOldChainPrev);
    1937                 :            : 
    1938         [ #  # ]:          0 :     sal_uInt16 nCnt = pDoc->GetFlyCount(FLYCNTTYPE_FRM);
    1939                 :            : 
    1940                 :            :     /* potential successors resp. predecessors */
    1941         [ #  # ]:          0 :     ::std::vector< const SwFrmFmt * > aTmpSpzArray;
    1942                 :            : 
    1943         [ #  # ]:          0 :     pDoc->FindFlyByName(rReference);
    1944                 :            : 
    1945         [ #  # ]:          0 :     for (sal_uInt16 n = 0; n < nCnt; n++)
    1946                 :            :     {
    1947         [ #  # ]:          0 :         const SwFrmFmt & rFmt1 = *(pDoc->GetFlyNum(n, FLYCNTTYPE_FRM));
    1948                 :            : 
    1949                 :            :         /*
    1950                 :            :            pFmt is a potential successor of rFmt if it is chainable after
    1951                 :            :            rFmt.
    1952                 :            : 
    1953                 :            :            pFmt is a potential predecessor of rFmt if rFmt is chainable
    1954                 :            :            after pFmt.
    1955                 :            :         */
    1956                 :            : 
    1957                 :            :         int nChainState;
    1958                 :            : 
    1959         [ #  # ]:          0 :         if (bSuccessors)
    1960         [ #  # ]:          0 :             nChainState = pDoc->Chainable(rFmt, rFmt1);
    1961                 :            :         else
    1962         [ #  # ]:          0 :             nChainState = pDoc->Chainable(rFmt1, rFmt);
    1963                 :            : 
    1964         [ #  # ]:          0 :         if (nChainState == SW_CHAIN_OK)
    1965                 :            :         {
    1966         [ #  # ]:          0 :             aTmpSpzArray.push_back(&rFmt1);
    1967                 :            : 
    1968                 :            :         }
    1969                 :            : 
    1970                 :            :     }
    1971                 :            : 
    1972         [ #  # ]:          0 :     if  (aTmpSpzArray.size() > 0)
    1973                 :            :     {
    1974                 :          0 :         aPrevPageVec.clear();
    1975                 :          0 :         aThisPageVec.clear();
    1976                 :          0 :         aNextPageVec.clear();
    1977                 :          0 :         aRestVec.clear();
    1978                 :            : 
    1979                 :            :         /* number of page rFmt resides on */
    1980         [ #  # ]:          0 :         sal_uInt16 nPageNum = SwFmtGetPageNum((SwFlyFrmFmt *) &rFmt);
    1981                 :            : 
    1982                 :          0 :         ::std::vector< const SwFrmFmt * >::const_iterator aIt;
    1983                 :            : 
    1984 [ #  # ][ #  # ]:          0 :         for (aIt = aTmpSpzArray.begin(); aIt != aTmpSpzArray.end(); ++aIt)
         [ #  # ][ #  # ]
    1985                 :            :         {
    1986 [ #  # ][ #  # ]:          0 :             String  aString = (*aIt)->GetName();
    1987                 :            : 
    1988                 :            :             /* rFmt is not a vaild successor or predecessor of
    1989                 :            :                itself */
    1990 [ #  # ][ #  # ]:          0 :             if (aString != rReference && aString != rFmt.GetName())
         [ #  # ][ #  # ]
                 [ #  # ]
    1991                 :            :             {
    1992                 :            :                 sal_uInt16 nNum1 =
    1993 [ #  # ][ #  # ]:          0 :                     SwFmtGetPageNum((SwFlyFrmFmt *) *aIt);
    1994                 :            : 
    1995         [ #  # ]:          0 :                 if (nNum1 == nPageNum -1)
    1996         [ #  # ]:          0 :                     aPrevPageVec.push_back(aString);
    1997         [ #  # ]:          0 :                 else if (nNum1 == nPageNum)
    1998         [ #  # ]:          0 :                     aThisPageVec.push_back(aString);
    1999         [ #  # ]:          0 :                 else if (nNum1 == nPageNum + 1)
    2000         [ #  # ]:          0 :                     aNextPageVec.push_back(aString);
    2001                 :            :                 else
    2002         [ #  # ]:          0 :                     aRestVec.push_back(aString);
    2003                 :            :             }
    2004         [ #  # ]:          0 :         }
    2005                 :            : 
    2006                 :            :     }
    2007                 :            : 
    2008         [ #  # ]:          0 :     if (pOldChainNext)
    2009         [ #  # ]:          0 :         pDoc->Chain(rFmt, *pOldChainNext);
    2010                 :            : 
    2011         [ #  # ]:          0 :     if (pOldChainPrev)
    2012         [ #  # ]:          0 :         pDoc->Chain(*pOldChainPrev, rFmt);
    2013                 :            : 
    2014 [ #  # ][ #  # ]:          0 :     EndAction();
    2015                 :          0 : }
    2016                 :            : 
    2017                 :            : // #i73249#
    2018                 :          0 : const String SwFEShell::GetObjTitle() const
    2019                 :            : {
    2020                 :          0 :     String aTitle;
    2021                 :            : 
    2022         [ #  # ]:          0 :     if ( Imp()->HasDrawView() )
    2023                 :            :     {
    2024                 :          0 :         const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
    2025         [ #  # ]:          0 :         if ( pMrkList->GetMarkCount() == 1 )
    2026                 :            :         {
    2027 [ #  # ][ #  # ]:          0 :             const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
    2028         [ #  # ]:          0 :             const SwFrmFmt* pFmt = FindFrmFmt( pObj );
    2029         [ #  # ]:          0 :             if ( pFmt->Which() == RES_FLYFRMFMT )
    2030                 :            :             {
    2031 [ #  # ][ #  # ]:          0 :                 aTitle = dynamic_cast<const SwFlyFrmFmt*>(pFmt)->GetObjTitle();
         [ #  # ][ #  # ]
    2032                 :            :             }
    2033                 :            :             else
    2034                 :            :             {
    2035 [ #  # ][ #  # ]:          0 :                 aTitle = pObj->GetTitle();
    2036                 :            :             }
    2037                 :            :         }
    2038                 :            :     }
    2039                 :            : 
    2040                 :          0 :     return aTitle;
    2041                 :            : }
    2042                 :            : 
    2043                 :          0 : void SwFEShell::SetObjTitle( const String& rTitle )
    2044                 :            : {
    2045         [ #  # ]:          0 :     if ( Imp()->HasDrawView() )
    2046                 :            :     {
    2047                 :          0 :         const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
    2048         [ #  # ]:          0 :         if ( pMrkList->GetMarkCount() == 1 )
    2049                 :            :         {
    2050                 :          0 :             SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
    2051                 :          0 :             SwFrmFmt* pFmt = FindFrmFmt( pObj );
    2052         [ #  # ]:          0 :             if ( pFmt->Which() == RES_FLYFRMFMT )
    2053                 :            :             {
    2054                 :            :                 GetDoc()->SetFlyFrmTitle( *(dynamic_cast<SwFlyFrmFmt*>(pFmt)),
    2055         [ #  # ]:          0 :                                           rTitle );
    2056                 :            :             }
    2057                 :            :             else
    2058                 :            :             {
    2059         [ #  # ]:          0 :                 pObj->SetTitle( rTitle );
    2060                 :            :             }
    2061                 :            :         }
    2062                 :            :     }
    2063                 :          0 : }
    2064                 :            : 
    2065                 :          0 : const String SwFEShell::GetObjDescription() const
    2066                 :            : {
    2067                 :          0 :     String aDescription;
    2068                 :            : 
    2069         [ #  # ]:          0 :     if ( Imp()->HasDrawView() )
    2070                 :            :     {
    2071                 :          0 :         const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
    2072         [ #  # ]:          0 :         if ( pMrkList->GetMarkCount() == 1 )
    2073                 :            :         {
    2074 [ #  # ][ #  # ]:          0 :             const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
    2075         [ #  # ]:          0 :             const SwFrmFmt* pFmt = FindFrmFmt( pObj );
    2076         [ #  # ]:          0 :             if ( pFmt->Which() == RES_FLYFRMFMT )
    2077                 :            :             {
    2078 [ #  # ][ #  # ]:          0 :                 aDescription = dynamic_cast<const SwFlyFrmFmt*>(pFmt)->GetObjDescription();
         [ #  # ][ #  # ]
    2079                 :            :             }
    2080                 :            :             else
    2081                 :            :             {
    2082 [ #  # ][ #  # ]:          0 :                 aDescription = pObj->GetDescription();
    2083                 :            :             }
    2084                 :            :         }
    2085                 :            :     }
    2086                 :            : 
    2087                 :          0 :     return aDescription;
    2088                 :            : }
    2089                 :            : 
    2090                 :          0 : void SwFEShell::SetObjDescription( const String& rDescription )
    2091                 :            : {
    2092         [ #  # ]:          0 :     if ( Imp()->HasDrawView() )
    2093                 :            :     {
    2094                 :          0 :         const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
    2095         [ #  # ]:          0 :         if ( pMrkList->GetMarkCount() == 1 )
    2096                 :            :         {
    2097                 :          0 :             SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
    2098                 :          0 :             SwFrmFmt* pFmt = FindFrmFmt( pObj );
    2099         [ #  # ]:          0 :             if ( pFmt->Which() == RES_FLYFRMFMT )
    2100                 :            :             {
    2101                 :            :                 GetDoc()->SetFlyFrmDescription( *(dynamic_cast<SwFlyFrmFmt*>(pFmt)),
    2102         [ #  # ]:          0 :                                                 rDescription );
    2103                 :            :             }
    2104                 :            :             else
    2105                 :            :             {
    2106         [ #  # ]:          0 :                 pObj->SetDescription( rDescription );
    2107                 :            :             }
    2108                 :            :         }
    2109                 :            :     }
    2110                 :          0 : }
    2111                 :            : 
    2112                 :            : 
    2113                 :          0 : void SwFEShell::AlignFormulaToBaseline( const uno::Reference < embed::XEmbeddedObject >& xObj, SwFlyFrm * pFly )
    2114                 :            : {
    2115                 :            : #if OSL_DEBUG_LEVEL > 0
    2116                 :            :     SvGlobalName aCLSID( xObj->getClassID() );
    2117                 :            :     const bool bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
    2118                 :            :     OSL_ENSURE( bStarMath, "AlignFormulaToBaseline should only be called for Math objects" );
    2119                 :            : 
    2120                 :            :     if ( !bStarMath )
    2121                 :            :         return;
    2122                 :            : #endif
    2123                 :            : 
    2124         [ #  # ]:          0 :     if (!pFly)
    2125                 :          0 :         pFly = FindFlyFrm( xObj );
    2126                 :            :     OSL_ENSURE( pFly , "No fly frame!" );
    2127         [ #  # ]:          0 :     SwFrmFmt * pFrmFmt = pFly ? pFly->GetFmt() : 0;
    2128                 :            : 
    2129                 :            :     // baseline to baseline alignment should only be applied to formulas anchored as char
    2130 [ #  # ][ #  # ]:          0 :     if ( pFly && pFrmFmt && FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
         [ #  # ][ #  # ]
    2131                 :            :     {
    2132                 :            :         // get baseline from Math object
    2133                 :          0 :         uno::Any aBaseline;
    2134 [ #  # ][ #  # ]:          0 :         if( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
    2135                 :            :         {
    2136 [ #  # ][ #  # ]:          0 :             uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
                 [ #  # ]
    2137         [ #  # ]:          0 :             if ( xSet.is() )
    2138                 :            :             {
    2139                 :            :                 try
    2140                 :            :                 {
    2141 [ #  # ][ #  # ]:          0 :                     aBaseline = xSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BaseLine") ) );
         [ #  # ][ #  # ]
    2142                 :            :                 }
    2143         [ #  # ]:          0 :                 catch ( uno::Exception& )
    2144                 :            :                 {
    2145                 :            :                     OSL_FAIL( "Baseline could not be retrieved from Starmath!" );
    2146                 :            :                 }
    2147                 :          0 :             }
    2148                 :            :         }
    2149                 :            : 
    2150         [ #  # ]:          0 :         sal_Int32 nBaseline = ::comphelper::getINT32(aBaseline);
    2151         [ #  # ]:          0 :         const MapMode aSourceMapMode( MAP_100TH_MM );
    2152         [ #  # ]:          0 :         const MapMode aTargetMapMode( MAP_TWIP );
    2153         [ #  # ]:          0 :         nBaseline = OutputDevice::LogicToLogic( nBaseline, aSourceMapMode.GetMapUnit(), aTargetMapMode.GetMapUnit() );
    2154                 :            : 
    2155                 :            :         OSL_ENSURE( nBaseline > 0, "Wrong value of Baseline while retrieving from Starmath!" );
    2156                 :            :         //nBaseline must be moved by aPrt position
    2157         [ #  # ]:          0 :         const SwFlyFrmFmt *pFlyFrmFmt = pFly->GetFmt();
    2158                 :            :         OSL_ENSURE( pFlyFrmFmt, "fly frame format missing!" );
    2159         [ #  # ]:          0 :         if ( pFlyFrmFmt )
    2160                 :          0 :             nBaseline += pFlyFrmFmt->GetLastFlyFrmPrtRectPos().Y();
    2161                 :            : 
    2162         [ #  # ]:          0 :         const SwFmtVertOrient &rVert = pFrmFmt->GetVertOrient();
    2163         [ #  # ]:          0 :         SwFmtVertOrient aVert( rVert );
    2164                 :          0 :         aVert.SetPos( -nBaseline );
    2165                 :          0 :         aVert.SetVertOrient( com::sun::star::text::VertOrientation::NONE );
    2166                 :            : 
    2167                 :          0 :         pFrmFmt->LockModify();
    2168         [ #  # ]:          0 :         pFrmFmt->SetFmtAttr( aVert );
    2169                 :          0 :         pFrmFmt->UnlockModify();
    2170 [ #  # ][ #  # ]:          0 :         pFly->InvalidatePos();
         [ #  # ][ #  # ]
    2171                 :            :     }
    2172                 :          0 : }
    2173                 :            : 
    2174                 :            : 
    2175                 :          0 : void SwFEShell::AlignAllFormulasToBaseline()
    2176                 :            : {
    2177         [ #  # ]:          0 :     StartAllAction();
    2178                 :            : 
    2179                 :            :     SwStartNode *pStNd;
    2180 [ #  # ][ #  # ]:          0 :     SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
    2181         [ #  # ]:          0 :     while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
    2182                 :            :     {
    2183         [ #  # ]:          0 :         ++aIdx;
    2184         [ #  # ]:          0 :         SwOLENode *pOleNode = dynamic_cast< SwOLENode * >( &aIdx.GetNode() );
    2185         [ #  # ]:          0 :         if ( pOleNode )
    2186                 :            :         {
    2187         [ #  # ]:          0 :             const uno::Reference < embed::XEmbeddedObject > & xObj( pOleNode->GetOLEObj().GetOleRef() );
    2188         [ #  # ]:          0 :             if (xObj.is())
    2189                 :            :             {
    2190 [ #  # ][ #  # ]:          0 :                 SvGlobalName aCLSID( xObj->getClassID() );
         [ #  # ][ #  # ]
    2191 [ #  # ][ #  # ]:          0 :                 if ( SotExchange::IsMath( aCLSID ) )
    2192 [ #  # ][ #  # ]:          0 :                     AlignFormulaToBaseline( xObj );
    2193                 :          0 :             }
    2194                 :            :         }
    2195                 :            : 
    2196         [ #  # ]:          0 :         aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
    2197                 :            :     }
    2198                 :            : 
    2199 [ #  # ][ #  # ]:          0 :     EndAllAction();
    2200                 :          0 : }
    2201                 :            : 
    2202                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10