LCOV - code coverage report
Current view: top level - sw/source/core/frmedt - fecopy.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 788 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1818 0.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                 :            : #include <hintids.hxx>
      30                 :            : 
      31                 :            : #include <vcl/graph.hxx>
      32                 :            : #include <sot/formats.hxx>
      33                 :            : #include <sot/storage.hxx>
      34                 :            : #include <unotools/pathoptions.hxx>
      35                 :            : #include <sfx2/dispatch.hxx>
      36                 :            : #include <sfx2/viewsh.hxx>
      37                 :            : #include <svx/xexch.hxx>
      38                 :            : #include <svx/xflasit.hxx>
      39                 :            : #include <svx/xfillit0.hxx>
      40                 :            : #include <svx/xflclit.hxx>
      41                 :            : #include <editeng/brshitem.hxx>
      42                 :            : #include <svx/svdocapt.hxx>
      43                 :            : #include <svx/svdouno.hxx>
      44                 :            : #include <svx/xfillit.hxx>
      45                 :            : #include <svx/svdpage.hxx>
      46                 :            : #include <svx/svdogrp.hxx>
      47                 :            : #include <svx/xoutbmp.hxx>
      48                 :            : #include <svx/svdoole2.hxx>
      49                 :            : #include <svx/fmmodel.hxx>
      50                 :            : #include <svx/unomodel.hxx>
      51                 :            : #include <svx/svditer.hxx> // #i50824#
      52                 :            : #include <svx/svdograf.hxx>
      53                 :            : #include <unotools/streamwrap.hxx>
      54                 :            : #include <fmtanchr.hxx>
      55                 :            : #include <fmtcntnt.hxx>
      56                 :            : #include <fmtornt.hxx>
      57                 :            : #include <fmtflcnt.hxx>
      58                 :            : #include <frmfmt.hxx>
      59                 :            : #include <docary.hxx>
      60                 :            : #include <txtfrm.hxx>
      61                 :            : #include <txtflcnt.hxx>
      62                 :            : #include <fesh.hxx>
      63                 :            : #include <doc.hxx>
      64                 :            : #include <IDocumentUndoRedo.hxx>
      65                 :            : #include <rootfrm.hxx>
      66                 :            : #include <ndtxt.hxx>
      67                 :            : #include <pam.hxx>
      68                 :            : #include <tblsel.hxx>
      69                 :            : #include <swtable.hxx>
      70                 :            : #include <flyfrm.hxx>
      71                 :            : #include <pagefrm.hxx>
      72                 :            : #include <fldbas.hxx>
      73                 :            : #include <edimp.hxx>
      74                 :            : #include <swundo.hxx>
      75                 :            : #include <viewimp.hxx>
      76                 :            : #include <dview.hxx>
      77                 :            : #include <dcontact.hxx>
      78                 :            : #include <dflyobj.hxx>
      79                 :            : #include <docsh.hxx>
      80                 :            : #include <pagedesc.hxx>
      81                 :            : #include <mvsave.hxx>
      82                 :            : #include <vcl/virdev.hxx>
      83                 :            : 
      84                 :            : 
      85                 :            : using namespace ::com::sun::star;
      86                 :            : 
      87                 :            : /*************************************************************************
      88                 :            : |*
      89                 :            : |*  SwFEShell::Copy()   copy for the internal clipboard.
      90                 :            : |*      Copies all selections to the clipboard.
      91                 :            : |*
      92                 :            : |*************************************************************************/
      93                 :            : 
      94                 :          0 : sal_Bool SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt )
      95                 :            : {
      96                 :            :     OSL_ENSURE( pClpDoc, "kein Clipboard-Dokument"  );
      97                 :            : 
      98 [ #  # ][ #  # ]:          0 :     pClpDoc->GetIDocumentUndoRedo().DoUndo(false); // always false!
      99                 :            : 
     100                 :            :     // delete content if ClpDocument contains content
     101 [ #  # ][ #  # ]:          0 :     SwNodeIndex aSttIdx( pClpDoc->GetNodes().GetEndOfExtras(), 2 );
     102                 :          0 :     SwTxtNode* pTxtNd = aSttIdx.GetNode().GetTxtNode();
     103   [ #  #  #  # ]:          0 :     if( !pTxtNd || pTxtNd->GetTxt().Len() ||
         [ #  # ][ #  # ]
     104         [ #  # ]:          0 :         aSttIdx.GetIndex()+1 != pClpDoc->GetNodes().GetEndOfContent().GetIndex() )
     105                 :            :     {
     106         [ #  # ]:          0 :         pClpDoc->GetNodes().Delete( aSttIdx,
     107 [ #  # ][ #  # ]:          0 :             pClpDoc->GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
     108         [ #  # ]:          0 :         pTxtNd = pClpDoc->GetNodes().MakeTxtNode( aSttIdx,
     109         [ #  # ]:          0 :                             (SwTxtFmtColl*)pClpDoc->GetDfltTxtFmtColl() );
     110         [ #  # ]:          0 :         aSttIdx--;
     111                 :            :     }
     112                 :            : 
     113                 :            :     // also delete surrounding FlyFrames if any
     114         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < pClpDoc->GetSpzFrmFmts()->size(); ++n )
     115                 :            :     {
     116         [ #  # ]:          0 :         SwFlyFrmFmt* pFly = (SwFlyFrmFmt*)(*pClpDoc->GetSpzFrmFmts())[n];
     117         [ #  # ]:          0 :         pClpDoc->DelLayoutFmt( pFly );
     118                 :            :     }
     119         [ #  # ]:          0 :     pClpDoc->GCFieldTypes();        // delete the FieldTypes
     120                 :            : 
     121                 :            :     // if a string was passed, copy it to the clipboard-
     122                 :            :     // document. Then also the Calculator can use the internal
     123                 :            :     // clipboard
     124         [ #  # ]:          0 :     if( pNewClpTxt )
     125                 :            :     {
     126 [ #  # ][ #  # ]:          0 :         pTxtNd->InsertText( *pNewClpTxt, SwIndex( pTxtNd ) );
         [ #  # ][ #  # ]
     127                 :          0 :         return sal_True;                // das wars.
     128                 :            :     }
     129                 :            : 
     130         [ #  # ]:          0 :     pClpDoc->LockExpFlds();
     131         [ #  # ]:          0 :     pClpDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES );
     132                 :            :     sal_Bool bRet;
     133                 :            : 
     134                 :            :     // do we want to copy a FlyFrame?
     135 [ #  # ][ #  # ]:          0 :     if( IsFrmSelected() )
     136                 :            :     {
     137                 :            :         // get the FlyFormat
     138         [ #  # ]:          0 :         SwFlyFrm* pFly = FindFlyFrm();
     139         [ #  # ]:          0 :         SwFrmFmt* pFlyFmt = pFly->GetFmt();
     140 [ #  # ][ #  # ]:          0 :         SwFmtAnchor aAnchor( pFlyFmt->GetAnchor() );
     141                 :            : 
     142   [ #  #  #  #  :          0 :         if ((FLY_AT_PARA == aAnchor.GetAnchorId()) ||
             #  #  #  # ]
                 [ #  # ]
     143                 :          0 :             (FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
     144                 :          0 :             (FLY_AT_FLY  == aAnchor.GetAnchorId()) ||
     145                 :          0 :             (FLY_AS_CHAR == aAnchor.GetAnchorId()))
     146                 :            :         {
     147         [ #  # ]:          0 :             SwPosition aPos( aSttIdx );
     148         [ #  # ]:          0 :             if ( FLY_AS_CHAR == aAnchor.GetAnchorId() )
     149                 :            :             {
     150 [ #  # ][ #  # ]:          0 :                 aPos.nContent.Assign( pTxtNd, 0 );
     151                 :            :             }
     152 [ #  # ][ #  # ]:          0 :             aAnchor.SetAnchor( &aPos );
     153                 :            :         }
     154         [ #  # ]:          0 :         pFlyFmt = pClpDoc->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true );
     155                 :            : 
     156                 :            :        // assure the "RootFmt" is the first element in Spz-Array
     157                 :            :         // (if necessary Flys were copied in Flys)
     158                 :          0 :         SwFrmFmts& rSpzFrmFmts = *(SwFrmFmts*)pClpDoc->GetSpzFrmFmts();
     159 [ #  # ][ #  # ]:          0 :         if( rSpzFrmFmts[ 0 ] != pFlyFmt )
     160                 :            :         {
     161         [ #  # ]:          0 :             SwFrmFmts::iterator it = std::find( rSpzFrmFmts.begin(), rSpzFrmFmts.end(), pFlyFmt );
     162                 :            :             OSL_ENSURE( it != rSpzFrmFmts.end(), "Fly not contained in Spz-Array" );
     163                 :            : 
     164         [ #  # ]:          0 :             rSpzFrmFmts.erase( it );
     165         [ #  # ]:          0 :             rSpzFrmFmts.insert( rSpzFrmFmts.begin(), pFlyFmt );
     166                 :            :         }
     167                 :            : 
     168         [ #  # ]:          0 :         if ( FLY_AS_CHAR == aAnchor.GetAnchorId() )
     169                 :            :         {
     170                 :            :             // JP 13.02.99  Bug 61863: if a frameselection is passed to the
     171                 :            :             //              clipboard, it should be found at pasting. Therefore
     172                 :            :             //              the copied TextAttribut should be removed in the node
     173                 :            :             //              otherwise it will be recognised as TextSelektion
     174 [ #  # ][ #  # ]:          0 :             const SwIndex& rIdx = pFlyFmt->GetAnchor().GetCntntAnchor()->nContent;
     175                 :            :             SwTxtFlyCnt *const pTxtFly = static_cast<SwTxtFlyCnt *>(
     176                 :            :                 pTxtNd->GetTxtAttrForCharAt(
     177         [ #  # ]:          0 :                     rIdx.GetIndex(), RES_TXTATR_FLYCNT));
     178         [ #  # ]:          0 :             if( pTxtFly )
     179                 :            :             {
     180                 :          0 :                 ((SwFmtFlyCnt&)pTxtFly->GetFlyCnt()).SetFlyFmt( 0 );
     181         [ #  # ]:          0 :                 pTxtNd->EraseText( rIdx, 1 );
     182                 :            :             }
     183                 :            :         }
     184         [ #  # ]:          0 :         bRet = sal_True;
     185                 :            :     }
     186 [ #  # ][ #  # ]:          0 :     else if ( IsObjSelected() )
     187                 :            :     {
     188 [ #  # ][ #  # ]:          0 :         SwPosition aPos( aSttIdx, SwIndex( pTxtNd, 0 ));
         [ #  # ][ #  # ]
     189                 :          0 :         const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
     190         [ #  # ]:          0 :         for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
     191                 :            :         {
     192 [ #  # ][ #  # ]:          0 :             SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     193                 :            : 
     194 [ #  # ][ #  # ]:          0 :             if( Imp()->GetDrawView()->IsGroupEntered() ||
         [ #  # ][ #  # ]
                 [ #  # ]
     195 [ #  # ][ #  # ]:          0 :                 ( !pObj->GetUserCall() && pObj->GetUpGroup()) )
     196                 :            :             {
     197         [ #  # ]:          0 :                 SfxItemSet aSet( pClpDoc->GetAttrPool(), aFrmFmtSetRange );
     198                 :            : 
     199         [ #  # ]:          0 :                 SwFmtAnchor aAnchor( FLY_AT_PARA );
     200         [ #  # ]:          0 :                 aAnchor.SetAnchor( &aPos );
     201         [ #  # ]:          0 :                 aSet.Put( aAnchor );
     202                 :            : 
     203                 :            :                 SdrObject *const pNew =
     204         [ #  # ]:          0 :                     pClpDoc->CloneSdrObj( *pObj, sal_False, sal_True );
     205                 :            : 
     206         [ #  # ]:          0 :                 SwPaM aTemp(aPos);
     207 [ #  # ][ #  # ]:          0 :                 pClpDoc->Insert(aTemp, *pNew, &aSet, NULL);
         [ #  # ][ #  # ]
     208                 :            :             }
     209                 :            :             else
     210                 :            :             {
     211         [ #  # ]:          0 :                 SwDrawContact *pContact = (SwDrawContact*)GetUserCall( pObj );
     212                 :          0 :                 SwFrmFmt *pFmt = pContact->GetFmt();
     213 [ #  # ][ #  # ]:          0 :                 SwFmtAnchor aAnchor( pFmt->GetAnchor() );
     214   [ #  #  #  #  :          0 :                 if ((FLY_AT_PARA == aAnchor.GetAnchorId()) ||
             #  #  #  # ]
                 [ #  # ]
     215                 :          0 :                     (FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
     216                 :          0 :                     (FLY_AT_FLY  == aAnchor.GetAnchorId()) ||
     217                 :          0 :                     (FLY_AS_CHAR == aAnchor.GetAnchorId()))
     218                 :            :                 {
     219         [ #  # ]:          0 :                     aAnchor.SetAnchor( &aPos );
     220                 :            :                 }
     221                 :            : 
     222 [ #  # ][ #  # ]:          0 :                 pClpDoc->CopyLayoutFmt( *pFmt, aAnchor, true, true );
     223                 :            :             }
     224                 :            :         }
     225         [ #  # ]:          0 :         bRet = sal_True;
     226                 :            :     }
     227                 :            :     else
     228         [ #  # ]:          0 :         bRet = _CopySelToDoc( pClpDoc, 0 );     // copy the selections
     229                 :            : 
     230         [ #  # ]:          0 :     pClpDoc->SetRedlineMode_intern((RedlineMode_t)0 );
     231         [ #  # ]:          0 :     pClpDoc->UnlockExpFlds();
     232 [ #  # ][ #  # ]:          0 :     if( !pClpDoc->IsExpFldsLocked() )
     233         [ #  # ]:          0 :         pClpDoc->UpdateExpFlds(NULL, true);
     234                 :            : 
     235         [ #  # ]:          0 :     return bRet;
     236                 :            : }
     237                 :            : 
     238                 :          0 : const Point &lcl_FindBasePos( const SwFrm *pFrm, const Point &rPt )
     239                 :            : {
     240                 :          0 :     const SwFrm *pF = pFrm;
     241 [ #  # ][ #  # ]:          0 :     while ( pF && !pF->Frm().IsInside( rPt ) )
                 [ #  # ]
     242                 :            :     {
     243         [ #  # ]:          0 :         if ( pF->IsCntntFrm() )
     244                 :          0 :             pF = ((SwCntntFrm*)pF)->GetFollow();
     245                 :            :         else
     246                 :          0 :             pF = 0;
     247                 :            :     }
     248         [ #  # ]:          0 :     if ( pF )
     249                 :          0 :         return pF->Frm().Pos();
     250                 :            :     else
     251                 :          0 :         return pFrm->Frm().Pos();
     252                 :            : }
     253                 :            : 
     254                 :          0 : sal_Bool lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrm* pFly,
     255                 :            :                 const Point& rInsPt, SwFEShell& rDestShell, SwFmtAnchor& rAnchor,
     256                 :            :                 Point& rNewPos, sal_Bool bCheckFlyRecur )
     257                 :            : {
     258                 :          0 :     sal_Bool bRet = sal_True;
     259                 :          0 :     rAnchor.SetAnchor( &rPos );
     260                 :          0 :     SwCntntFrm* pTmpFrm = rNd.GetCntntNode()->getLayoutFrm( rDestShell.GetLayout(), &rInsPt, 0, sal_False );
     261                 :          0 :     SwFlyFrm *pTmpFly = pTmpFrm->FindFlyFrm();
     262 [ #  # ][ #  # ]:          0 :     if( pTmpFly && bCheckFlyRecur && pFly->IsUpperOf( *pTmpFly ) )
         [ #  # ][ #  # ]
     263                 :            :     {
     264                 :          0 :         bRet = sal_False;
     265                 :            :     }
     266         [ #  # ]:          0 :     else if ( FLY_AT_FLY == rAnchor.GetAnchorId() )
     267                 :            :     {
     268         [ #  # ]:          0 :         if( pTmpFly )
     269                 :            :         {
     270 [ #  # ][ #  # ]:          0 :             const SwNodeIndex& rIdx = *pTmpFly->GetFmt()->GetCntnt().GetCntntIdx();
     271         [ #  # ]:          0 :             SwPosition aPos( rIdx );
     272         [ #  # ]:          0 :             rAnchor.SetAnchor( &aPos );
     273         [ #  # ]:          0 :             rNewPos = pTmpFly->Frm().Pos();
     274                 :            :         }
     275                 :            :         else
     276                 :            :         {
     277                 :          0 :             rAnchor.SetType( FLY_AT_PAGE );
     278                 :          0 :             rAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) );
     279                 :          0 :             const SwFrm *pPg = pTmpFrm->FindPageFrm();
     280                 :          0 :             rNewPos = pPg->Frm().Pos();
     281                 :            :         }
     282                 :            :     }
     283                 :            :     else
     284                 :          0 :         rNewPos = ::lcl_FindBasePos( pTmpFrm, rInsPt );
     285                 :          0 :     return bRet;
     286                 :            : }
     287                 :            : 
     288                 :          0 : sal_Bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
     289                 :            :                     const Point& rInsPt, sal_Bool bIsMove, sal_Bool bSelectInsert )
     290                 :            : {
     291                 :          0 :     sal_Bool bRet = sal_True;
     292                 :            : 
     293                 :            :     // The list should be copied, because below new objects will be selected
     294         [ #  # ]:          0 :     const SdrMarkList aMrkList( Imp()->GetDrawView()->GetMarkedObjectList() );
     295                 :          0 :     sal_uLong nMarkCount = aMrkList.GetMarkCount();
     296         [ #  # ]:          0 :     if( !pDestShell->Imp()->GetDrawView() )
     297                 :            :         // should create it now
     298         [ #  # ]:          0 :         pDestShell->MakeDrawView();
     299         [ #  # ]:          0 :     else if( bSelectInsert )
     300         [ #  # ]:          0 :         pDestShell->Imp()->GetDrawView()->UnmarkAll();
     301                 :            : 
     302                 :          0 :     SdrPageView *pDestPgView = pDestShell->Imp()->GetPageView(),
     303                 :          0 :                 *pSrcPgView = Imp()->GetPageView();
     304                 :          0 :     SwDrawView *pDestDrwView = pDestShell->Imp()->GetDrawView(),
     305                 :          0 :                 *pSrcDrwView = Imp()->GetDrawView();
     306                 :          0 :     SwDoc* pDestDoc = pDestShell->GetDoc();
     307                 :            : 
     308                 :          0 :     Size aSiz( rInsPt.X() - rSttPt.X(), rInsPt.Y() - rSttPt.Y() );
     309         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i < nMarkCount; ++i )
     310                 :            :     {
     311 [ #  # ][ #  # ]:          0 :         SdrObject *pObj = aMrkList.GetMark( i )->GetMarkedSdrObj();
     312                 :            : 
     313         [ #  # ]:          0 :         SwDrawContact *pContact = (SwDrawContact*)GetUserCall( pObj );
     314                 :          0 :         SwFrmFmt *pFmt = pContact->GetFmt();
     315         [ #  # ]:          0 :         const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
     316                 :            : 
     317                 :          0 :         sal_Bool bInsWithFmt = sal_True;
     318                 :            : 
     319 [ #  # ][ #  # ]:          0 :         if( pDestDrwView->IsGroupEntered() )
     320                 :            :         {
     321                 :            :             // insert into the group, when it belongs to an entered group
     322                 :            :             // or when the object is not anchored as a character
     323         [ #  # ]:          0 :             if( pSrcDrwView->IsGroupEntered() ||
           [ #  #  #  # ]
                 [ #  # ]
     324                 :          0 :                 (FLY_AS_CHAR != rAnchor.GetAnchorId()) )
     325                 :            : 
     326                 :            :             {
     327                 :            :                 SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove &&
     328 [ #  # ][ #  # ]:          0 :                                         GetDoc() == pDestDoc, sal_False );
                 [ #  # ]
     329         [ #  # ]:          0 :                 pNew->NbcMove( aSiz );
     330         [ #  # ]:          0 :                 pDestDrwView->InsertObjectAtView( pNew, *pDestPgView );
     331                 :          0 :                 bInsWithFmt = sal_False;
     332                 :            :             }
     333                 :            :         }
     334                 :            : 
     335         [ #  # ]:          0 :         if( bInsWithFmt )
     336                 :            :         {
     337         [ #  # ]:          0 :             SwFmtAnchor aAnchor( rAnchor );
     338                 :          0 :             Point aNewAnch;
     339                 :            : 
     340 [ #  # ][ #  #  :          0 :             if ((FLY_AT_PARA == aAnchor.GetAnchorId()) ||
          #  #  #  #  #  
                      # ]
     341                 :          0 :                 (FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
     342                 :          0 :                 (FLY_AT_FLY  == aAnchor.GetAnchorId()) ||
     343                 :          0 :                 (FLY_AS_CHAR == aAnchor.GetAnchorId()))
     344                 :            :             {
     345         [ #  # ]:          0 :                 if ( this == pDestShell )
     346                 :            :                 {
     347                 :            :                     // same shell? Then request the position
     348                 :            :                     // from the passed DocumentPosition
     349 [ #  # ][ #  # ]:          0 :                     SwPosition aPos( *GetCrsr()->GetPoint() );
     350                 :          0 :                     Point aPt( rInsPt );
     351         [ #  # ]:          0 :                     aPt -= rSttPt - pObj->GetSnapRect().TopLeft();
     352                 :          0 :                     SwCrsrMoveState aState( MV_SETONLYTEXT );
     353 [ #  # ][ #  # ]:          0 :                     GetLayout()->GetCrsrOfst( &aPos, aPt, &aState );
     354                 :            :                     const SwNode *pNd;
     355         [ #  # ]:          0 :                     if( (pNd = &aPos.nNode.GetNode())->IsNoTxtNode() )
     356                 :          0 :                         bRet = sal_False;
     357                 :            :                     else
     358                 :            :                         bRet = ::lcl_SetAnchor( aPos, *pNd, 0, rInsPt,
     359 [ #  # ][ #  # ]:          0 :                                 *pDestShell, aAnchor, aNewAnch, sal_False );
     360                 :            :                 }
     361                 :            :                 else
     362                 :            :                 {
     363         [ #  # ]:          0 :                     SwPaM *pCrsr = pDestShell->GetCrsr();
     364         [ #  # ]:          0 :                     if( pCrsr->GetNode()->IsNoTxtNode() )
     365                 :          0 :                         bRet = sal_False;
     366                 :            :                     else
     367                 :          0 :                         bRet = ::lcl_SetAnchor( *pCrsr->GetPoint(),
     368                 :          0 :                                                 *pCrsr->GetNode(), 0, rInsPt,
     369                 :            :                                                 *pDestShell, aAnchor,
     370         [ #  # ]:          0 :                                                 aNewAnch, sal_False );
     371                 :            :                 }
     372                 :            :             }
     373         [ #  # ]:          0 :             else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() )
     374                 :            :             {
     375         [ #  # ]:          0 :                 aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) );
     376         [ #  # ]:          0 :                 const SwRootFrm* pTmpRoot = pDestShell->GetLayout();
     377         [ #  # ]:          0 :                 const SwFrm* pPg = pTmpRoot->GetPageAtPos( rInsPt, 0, true );
     378         [ #  # ]:          0 :                 if ( pPg )
     379                 :          0 :                     aNewAnch = pPg->Frm().Pos();
     380                 :            :             }
     381                 :            : 
     382         [ #  # ]:          0 :             if( bRet )
     383                 :            :             {
     384 [ #  # ][ #  # ]:          0 :                 if( pSrcDrwView->IsGroupEntered() ||
         [ #  # ][ #  # ]
                 [ #  # ]
     385 [ #  # ][ #  # ]:          0 :                     ( !pObj->GetUserCall() && pObj->GetUpGroup()) )
     386                 :            :                 {
     387         [ #  # ]:          0 :                     SfxItemSet aSet( pDestDoc->GetAttrPool(),aFrmFmtSetRange);
     388         [ #  # ]:          0 :                     aSet.Put( aAnchor );
     389                 :            :                     SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove &&
     390 [ #  # ][ #  # ]:          0 :                                                 GetDoc() == pDestDoc, sal_True );
                 [ #  # ]
     391         [ #  # ]:          0 :                     pFmt = pDestDoc->Insert( *pDestShell->GetCrsr(),
     392 [ #  # ][ #  # ]:          0 :                                             *pNew, &aSet, NULL );
     393                 :            :                 }
     394                 :            :                 else
     395         [ #  # ]:          0 :                     pFmt = pDestDoc->CopyLayoutFmt( *pFmt, aAnchor, true, true );
     396                 :            : 
     397                 :            :                 // Can be 0, as Draws are not allowed in Headers/Footers
     398         [ #  # ]:          0 :                 if ( pFmt )
     399                 :            :                 {
     400         [ #  # ]:          0 :                     SdrObject* pNew = pFmt->FindSdrObject();
     401         [ #  # ]:          0 :                     if ( FLY_AS_CHAR != aAnchor.GetAnchorId() )
     402                 :            :                     {
     403                 :          0 :                         Point aPos( rInsPt );
     404                 :          0 :                         aPos -= aNewAnch;
     405         [ #  # ]:          0 :                         aPos -= rSttPt - pObj->GetSnapRect().TopLeft();
     406                 :            :                         // OD 2004-04-05 #i26791# - change attributes instead of
     407                 :            :                         // direct positioning
     408 [ #  # ][ #  # ]:          0 :                         pFmt->SetFmtAttr( SwFmtHoriOrient( aPos.X(), text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
                 [ #  # ]
     409 [ #  # ][ #  # ]:          0 :                         pFmt->SetFmtAttr( SwFmtVertOrient( aPos.Y(), text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
                 [ #  # ]
     410                 :            :                         // #i47455# - notify draw frame format
     411                 :            :                         // that position attributes are already set.
     412 [ #  # ][ #  # ]:          0 :                         if ( pFmt->ISA(SwDrawFrmFmt) )
                 [ #  # ]
     413                 :            :                         {
     414                 :          0 :                             static_cast<SwDrawFrmFmt*>(pFmt)->PosAttrSet();
     415                 :            :                         }
     416                 :            :                     }
     417         [ #  # ]:          0 :                     if( bSelectInsert )
     418         [ #  # ]:          0 :                         pDestDrwView->MarkObj( pNew, pDestPgView );
     419                 :            :                 }
     420         [ #  # ]:          0 :             }
     421                 :            :         }
     422                 :            :     }
     423                 :            : 
     424 [ #  # ][ #  # ]:          0 :     if ( bIsMove && bRet )
     425                 :            :     {
     426         [ #  # ]:          0 :         if( pDestShell == this )
     427                 :            :         {
     428         [ #  # ]:          0 :             const SdrMarkList aList( pSrcDrwView->GetMarkedObjectList() );
     429         [ #  # ]:          0 :             pSrcDrwView->UnmarkAll();
     430                 :            : 
     431                 :          0 :             sal_uLong nMrkCnt = aMrkList.GetMarkCount();
     432                 :            :             sal_uInt16 i;
     433         [ #  # ]:          0 :             for ( i = 0; i < nMrkCnt; ++i )
     434                 :            :             {
     435 [ #  # ][ #  # ]:          0 :                 SdrObject *pObj = aMrkList.GetMark( i )->GetMarkedSdrObj();
     436         [ #  # ]:          0 :                 pSrcDrwView->MarkObj( pObj, pSrcPgView );
     437                 :            :             }
     438         [ #  # ]:          0 :             DelSelectedObj();
     439                 :          0 :             nMrkCnt = aList.GetMarkCount();
     440         [ #  # ]:          0 :             for ( i = 0; i < nMrkCnt; ++i )
     441                 :            :             {
     442 [ #  # ][ #  # ]:          0 :                 SdrObject *pObj = aList.GetMark( i )->GetMarkedSdrObj();
     443         [ #  # ]:          0 :                 pSrcDrwView->MarkObj( pObj, pSrcPgView );
     444         [ #  # ]:          0 :             }
     445                 :            :         }
     446                 :            :         else
     447         [ #  # ]:          0 :             DelSelectedObj();
     448                 :            :     }
     449                 :            : 
     450         [ #  # ]:          0 :     return bRet;
     451                 :            : }
     452                 :            : 
     453                 :          0 : sal_Bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
     454                 :            :                     const Point& rInsPt, sal_Bool bIsMove, sal_Bool bSelectInsert )
     455                 :            : {
     456                 :          0 :     sal_Bool bRet = sal_False;
     457                 :            : 
     458                 :            :     OSL_ENSURE( pDestShell, "Copy without DestShell." );
     459                 :            :     OSL_ENSURE( this == pDestShell || !pDestShell->IsObjSelected(),
     460                 :            :             "Dest-Shell cannot be in Obj-Mode" );
     461                 :            : 
     462         [ #  # ]:          0 :     SET_CURR_SHELL( pDestShell );
     463                 :            : 
     464         [ #  # ]:          0 :     pDestShell->StartAllAction();
     465         [ #  # ]:          0 :     pDestShell->GetDoc()->LockExpFlds();
     466                 :            : 
     467                 :            :     // Shift references
     468                 :          0 :     sal_Bool bCopyIsMove = pDoc->IsCopyIsMove();
     469         [ #  # ]:          0 :     if( bIsMove )
     470                 :            :         // set a flag in Doc, handled in TextNodes
     471                 :          0 :         pDoc->SetCopyIsMove( sal_True );
     472                 :            : 
     473         [ #  # ]:          0 :     RedlineMode_t eOldRedlMode = pDestShell->GetDoc()->GetRedlineMode();
     474         [ #  # ]:          0 :     pDestShell->GetDoc()->SetRedlineMode_intern( (RedlineMode_t)(eOldRedlMode | nsRedlineMode_t::REDLINE_DELETE_REDLINES));
     475                 :            : 
     476                 :            :     // If there are table formulas in the area, then display the table first
     477                 :            :     // so that the table formula can calculate a new value first
     478                 :            :     // (individual boxes in the area are retrieved via the layout)
     479         [ #  # ]:          0 :      SwFieldType* pTblFldTyp = pDestShell->GetDoc()->GetSysFldType( RES_TABLEFLD );
     480                 :            : 
     481 [ #  # ][ #  # ]:          0 :     if( IsFrmSelected() )
     482                 :            :     {
     483         [ #  # ]:          0 :         SwFlyFrm* pFly = FindFlyFrm();
     484         [ #  # ]:          0 :         SwFrmFmt* pFlyFmt = pFly->GetFmt();
     485 [ #  # ][ #  # ]:          0 :         SwFmtAnchor aAnchor( pFlyFmt->GetAnchor() );
     486                 :          0 :         bRet = sal_True;
     487                 :          0 :         Point aNewAnch;
     488                 :            : 
     489 [ #  # ][ #  #  :          0 :         if ((FLY_AT_PARA == aAnchor.GetAnchorId()) ||
          #  #  #  #  #  
                      # ]
     490                 :          0 :             (FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
     491                 :          0 :             (FLY_AT_FLY  == aAnchor.GetAnchorId()) ||
     492                 :          0 :             (FLY_AS_CHAR == aAnchor.GetAnchorId()))
     493                 :            :         {
     494         [ #  # ]:          0 :             if ( this == pDestShell )
     495                 :            :             {
     496                 :            :                 // same shell? Then request the position
     497                 :            :                 // from the passed DocumentPosition
     498 [ #  # ][ #  # ]:          0 :                 SwPosition aPos( *GetCrsr()->GetPoint() );
     499                 :          0 :                 Point aPt( rInsPt );
     500                 :          0 :                 aPt -= rSttPt - pFly->Frm().Pos();
     501                 :          0 :                 SwCrsrMoveState aState( MV_SETONLYTEXT );
     502 [ #  # ][ #  # ]:          0 :                 GetLayout()->GetCrsrOfst( &aPos, aPt, &aState );
     503                 :            :                 const SwNode *pNd;
     504         [ #  # ]:          0 :                 if( (pNd = &aPos.nNode.GetNode())->IsNoTxtNode() )
     505                 :          0 :                     bRet = sal_False;
     506                 :            :                 else
     507                 :            :                 {
     508                 :            :                     // do not copy in itself
     509         [ #  # ]:          0 :                     const SwNodeIndex *pTmp = pFlyFmt->GetCntnt().GetCntntIdx();
     510         [ #  # ]:          0 :                     if ( aPos.nNode > *pTmp && aPos.nNode <
           [ #  #  #  # ]
     511                 :          0 :                         pTmp->GetNode().EndOfSectionIndex() )
     512                 :            :                     {
     513                 :          0 :                         bRet = sal_False;
     514                 :            :                     }
     515                 :            :                     else
     516                 :            :                         bRet = ::lcl_SetAnchor( aPos, *pNd, pFly, rInsPt,
     517         [ #  # ]:          0 :                                         *pDestShell, aAnchor, aNewAnch, sal_True );
     518         [ #  # ]:          0 :                 }
     519                 :            :             }
     520                 :            :             else
     521                 :            :             {
     522         [ #  # ]:          0 :                 const SwPaM *pCrsr = pDestShell->GetCrsr();
     523         [ #  # ]:          0 :                 if( pCrsr->GetNode()->IsNoTxtNode() )
     524                 :          0 :                     bRet = sal_False;
     525                 :            :                 else
     526                 :          0 :                     bRet = ::lcl_SetAnchor( *pCrsr->GetPoint(), *pCrsr->GetNode(),
     527                 :            :                                             pFly, rInsPt, *pDestShell, aAnchor,
     528         [ #  # ]:          0 :                                     aNewAnch, GetDoc() == pDestShell->GetDoc());
     529                 :            :             }
     530                 :            :         }
     531         [ #  # ]:          0 :         else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() )
     532                 :            :         {
     533         [ #  # ]:          0 :             aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) );
     534         [ #  # ]:          0 :             const SwRootFrm* pTmpRoot = pDestShell->GetLayout();
     535         [ #  # ]:          0 :             const SwFrm* pPg = pTmpRoot->GetPageAtPos( rInsPt, 0, true );
     536         [ #  # ]:          0 :             if ( pPg )
     537                 :          0 :                 aNewAnch = pPg->Frm().Pos();
     538                 :            :         }
     539                 :            :         else {
     540                 :            :             OSL_ENSURE( !this, "what anchor is it?" );
     541                 :            :         }
     542                 :            : 
     543         [ #  # ]:          0 :         if( bRet )
     544                 :            :         {
     545                 :          0 :             SwFrmFmt *pOldFmt = pFlyFmt;
     546         [ #  # ]:          0 :             pFlyFmt = pDestShell->GetDoc()->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true );
     547                 :            : 
     548         [ #  # ]:          0 :             if ( FLY_AS_CHAR != aAnchor.GetAnchorId() )
     549                 :            :             {
     550                 :          0 :                 Point aPos( rInsPt );
     551                 :          0 :                 aPos -= aNewAnch;
     552                 :          0 :                 aPos -= rSttPt - pFly->Frm().Pos();
     553 [ #  # ][ #  # ]:          0 :                 pFlyFmt->SetFmtAttr( SwFmtHoriOrient( aPos.X(),text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
                 [ #  # ]
     554 [ #  # ][ #  # ]:          0 :                 pFlyFmt->SetFmtAttr( SwFmtVertOrient( aPos.Y(),text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
                 [ #  # ]
     555                 :            :             }
     556                 :            : 
     557                 :          0 :             const Point aPt( pDestShell->GetCrsrDocPos() );
     558                 :            : 
     559         [ #  # ]:          0 :             if( bIsMove )
     560         [ #  # ]:          0 :                 GetDoc()->DelLayoutFmt( pOldFmt );
     561                 :            : 
     562                 :            :             // only select if it can be shifted/copied in the same shell
     563         [ #  # ]:          0 :             if( bSelectInsert )
     564                 :            :             {
     565         [ #  # ]:          0 :                 SwFlyFrm* pFlyFrm = ((SwFlyFrmFmt*)pFlyFmt)->GetFrm( &aPt, sal_False );
     566         [ #  # ]:          0 :                 if( pFlyFrm )
     567                 :            :                 {
     568                 :            :                     //JP 12.05.98: should this be in SelectFlyFrm???
     569         [ #  # ]:          0 :                     pDestShell->Imp()->GetDrawView()->UnmarkAll();
     570         [ #  # ]:          0 :                     pDestShell->SelectFlyFrm( *pFlyFrm, sal_True );
     571                 :            :                 }
     572                 :            :             }
     573                 :            : 
     574 [ #  # ][ #  # ]:          0 :             if( this != pDestShell && !pDestShell->HasShFcs() )
                 [ #  # ]
     575         [ #  # ]:          0 :                 pDestShell->Imp()->GetDrawView()->hideMarkHandles();
     576         [ #  # ]:          0 :         }
     577                 :            :     }
     578 [ #  # ][ #  # ]:          0 :     else if ( IsObjSelected() )
     579         [ #  # ]:          0 :         bRet = CopyDrawSel( pDestShell, rSttPt, rInsPt, bIsMove, bSelectInsert );
     580         [ #  # ]:          0 :     else if( IsTableMode() )
     581                 :            :     {
     582                 :            :         // Copy parts from a table: create a table with the same
     583                 :            :         // width as the original and copy the selected boxes.
     584                 :            :         // Sizes will be corrected by percentage.
     585                 :            : 
     586                 :            :         // find boxes via the layout
     587                 :            :         const SwTableNode* pTblNd;
     588         [ #  # ]:          0 :         SwSelBoxes aBoxes;
     589         [ #  # ]:          0 :         GetTblSel( *this, aBoxes );
     590   [ #  #  #  # ]:          0 :         if( !aBoxes.empty() &&
         [ #  # ][ #  # ]
     591         [ #  # ]:          0 :             0 != (pTblNd = aBoxes[0]->GetSttNd()->FindTableNode()) )
     592                 :            :         {
     593                 :          0 :             SwPosition* pDstPos = 0;
     594         [ #  # ]:          0 :             if( this == pDestShell )
     595                 :            :             {
     596                 :            :                 // same shell? Then create new Crsr at the
     597                 :            :                 // DocumentPosition passed
     598 [ #  # ][ #  # ]:          0 :                 pDstPos = new SwPosition( *GetCrsr()->GetPoint() );
                 [ #  # ]
     599                 :          0 :                 Point aPt( rInsPt );
     600 [ #  # ][ #  # ]:          0 :                 GetLayout()->GetCrsrOfst( pDstPos, aPt );
     601         [ #  # ]:          0 :                 if( !pDstPos->nNode.GetNode().IsNoTxtNode() )
     602                 :          0 :                     bRet = sal_True;
     603                 :            :             }
     604 [ #  # ][ #  # ]:          0 :             else if( !pDestShell->GetCrsr()->GetNode()->IsNoTxtNode() )
     605                 :            :             {
     606 [ #  # ][ #  # ]:          0 :                 pDstPos = new SwPosition( *pDestShell->GetCrsr()->GetPoint() );
                 [ #  # ]
     607                 :          0 :                 bRet = sal_True;
     608                 :            :             }
     609                 :            : 
     610         [ #  # ]:          0 :             if( bRet )
     611                 :            :             {
     612         [ #  # ]:          0 :                 if( GetDoc() == pDestShell->GetDoc() )
     613         [ #  # ]:          0 :                     ParkTblCrsr();
     614                 :            : 
     615                 :            :                 bRet = pDestShell->GetDoc()->InsCopyOfTbl( *pDstPos, aBoxes,0,
     616                 :            :                                         bIsMove && this == pDestShell &&
     617                 :          0 :                                         aBoxes.size() == pTblNd->GetTable().
     618                 :          0 :                                         GetTabSortBoxes().size(),
     619         [ #  # ]:          0 :                                         this != pDestShell );
           [ #  #  #  # ]
                 [ #  # ]
     620                 :            : 
     621         [ #  # ]:          0 :                 if( this != pDestShell )
     622 [ #  # ][ #  # ]:          0 :                     *pDestShell->GetCrsr()->GetPoint() = *pDstPos;
     623                 :            : 
     624                 :            :                 // create all parked Crsr?
     625         [ #  # ]:          0 :                 if( GetDoc() == pDestShell->GetDoc() )
     626         [ #  # ]:          0 :                     GetCrsr();
     627                 :            : 
     628                 :            :                 // JP 16.04.99: Bug 64908 - Set InsPos, to assure the parked
     629                 :            :                 //              Cursor is positioned at the insert position
     630         [ #  # ]:          0 :                 if( this == pDestShell )
     631                 :          0 :                     GetCrsrDocPos() = rInsPt;
     632                 :            :             }
     633 [ #  # ][ #  # ]:          0 :             delete pDstPos;
     634                 :          0 :         }
     635                 :            :     }
     636                 :            :     else
     637                 :            :     {
     638                 :          0 :         bRet = sal_True;
     639         [ #  # ]:          0 :         if( this == pDestShell )
     640                 :            :         {
     641                 :            :             // same shell? then request the postion
     642                 :            :             // at the passed document position
     643 [ #  # ][ #  # ]:          0 :             SwPosition aPos( *GetCrsr()->GetPoint() );
     644                 :          0 :             Point aPt( rInsPt );
     645 [ #  # ][ #  # ]:          0 :             GetLayout()->GetCrsrOfst( &aPos, aPt );
     646         [ #  # ]:          0 :             bRet = !aPos.nNode.GetNode().IsNoTxtNode();
     647                 :            :         }
     648 [ #  # ][ #  # ]:          0 :         else if( pDestShell->GetCrsr()->GetNode()->IsNoTxtNode() )
     649                 :          0 :             bRet = sal_False;
     650                 :            : 
     651         [ #  # ]:          0 :         if( bRet )
     652         [ #  # ]:          0 :             bRet = 0 != SwEditShell::Copy( pDestShell );
     653                 :            :     }
     654                 :            : 
     655         [ #  # ]:          0 :     pDestShell->GetDoc()->SetRedlineMode_intern( eOldRedlMode );
     656                 :          0 :     pDoc->SetCopyIsMove( bCopyIsMove );
     657                 :            : 
     658                 :            :     // have new table formules been inserted?
     659         [ #  # ]:          0 :     if( pTblFldTyp->GetDepends() )
     660                 :            :     {
     661                 :            :         // finish old actions: the table frames are created and
     662                 :            :         // a selection can be made
     663                 :            :         sal_uInt16 nActCnt;
     664         [ #  # ]:          0 :         for( nActCnt = 0; pDestShell->ActionPend(); ++nActCnt )
     665         [ #  # ]:          0 :             pDestShell->EndAllAction();
     666                 :            : 
     667         [ #  # ]:          0 :         for( ; nActCnt; --nActCnt )
     668         [ #  # ]:          0 :             pDestShell->StartAllAction();
     669                 :            :     }
     670         [ #  # ]:          0 :     pDestShell->GetDoc()->UnlockExpFlds();
     671         [ #  # ]:          0 :     pDestShell->GetDoc()->UpdateFlds(NULL, false);
     672                 :            : 
     673         [ #  # ]:          0 :     pDestShell->EndAllAction();
     674         [ #  # ]:          0 :     return bRet;
     675                 :            : }
     676                 :            : 
     677                 :            : /*************************************************************************
     678                 :            : |*
     679                 :            : |*  SwFEShell::Paste()  Paste for  the interal clipboard.
     680                 :            : |*      Copy the content of the clipboard in the document
     681                 :            : |*
     682                 :            : |*************************************************************************/
     683                 :            : 
     684                 :            : namespace {
     685                 :            :     typedef boost::shared_ptr<SwPaM> PaMPtr;
     686                 :            :     typedef boost::shared_ptr<SwPosition> PositionPtr;
     687                 :            :     typedef std::pair< PaMPtr, PositionPtr > Insertion;
     688                 :            : }
     689                 :            : 
     690                 :          0 : sal_Bool SwFEShell::Paste( SwDoc* pClpDoc, sal_Bool bIncludingPageFrames )
     691                 :            : {
     692         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     693                 :            :     OSL_ENSURE( pClpDoc, "no clipboard document"  );
     694         [ #  # ]:          0 :     const sal_uInt16 nStartPageNumber = GetPhyPageNum();
     695                 :            :     // then till end of the nodes array
     696 [ #  # ][ #  # ]:          0 :     SwNodeIndex aIdx( pClpDoc->GetNodes().GetEndOfExtras(), 2 );
     697         [ #  # ]:          0 :     SwPaM aCpyPam( aIdx ); //DocStart
     698                 :            : 
     699                 :            :     // If there are table formulas in the area, then display the table first
     700                 :            :     // so that the table formula can calculate a new value first
     701                 :            :     // (individual boxes in the area are retrieved via the layout)
     702         [ #  # ]:          0 :      SwFieldType* pTblFldTyp = GetDoc()->GetSysFldType( RES_TABLEFLD );
     703                 :            : 
     704                 :          0 :     SwTableNode *pDestNd, *pSrcNd = aCpyPam.GetNode()->GetTableNode();
     705         [ #  # ]:          0 :     if( !pSrcNd )                               // TabellenNode ?
     706                 :            :     {                                           // nicht ueberspringen!!
     707                 :          0 :         SwCntntNode* pCNd = aCpyPam.GetNode()->GetCntntNode();
     708         [ #  # ]:          0 :         if( pCNd )
     709 [ #  # ][ #  # ]:          0 :             aCpyPam.GetPoint()->nContent.Assign( pCNd, 0 );
     710 [ #  # ][ #  # ]:          0 :         else if( !aCpyPam.Move( fnMoveForward, fnGoNode ))
     711         [ #  # ]:          0 :             aCpyPam.Move( fnMoveBackward, fnGoNode );
     712                 :            :     }
     713                 :            : 
     714         [ #  # ]:          0 :     aCpyPam.SetMark();
     715         [ #  # ]:          0 :     aCpyPam.Move( fnMoveForward, fnGoDoc );
     716                 :            : 
     717                 :          0 :     sal_Bool bRet = sal_True, bDelTbl = sal_True;
     718         [ #  # ]:          0 :     StartAllAction();
     719 [ #  # ][ #  # ]:          0 :     GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL );
     720         [ #  # ]:          0 :     GetDoc()->LockExpFlds();
     721                 :            : 
     722                 :            :     // When the clipboard content has been created by a rectangular selection
     723                 :            :     // the pasting is more sophisticated:
     724                 :            :     // every paragraph will be inserted into another position.
     725                 :            :     // The first positions are given by the actual cursor ring,
     726                 :            :     // if there are more text portions to insert than cursor in this ring,
     727                 :            :     // the additional insert positions will be created by moving the last
     728                 :            :     // cursor position into the next line (like pressing the cursor down key)
     729 [ #  # ][ #  # ]:          0 :     if( pClpDoc->IsColumnSelection() && !IsTableMode() )
                 [ #  # ]
     730                 :            :     {
     731                 :            :         // Creation of the list of insert positions
     732         [ #  # ]:          0 :         std::list< Insertion > aCopyList;
     733                 :            :         // The number of text portions of the rectangular selection
     734                 :          0 :         const sal_uInt32 nSelCount = aCpyPam.GetPoint()->nNode.GetIndex()
     735                 :          0 :                        - aCpyPam.GetMark()->nNode.GetIndex();
     736                 :          0 :         sal_uInt32 nCount = nSelCount;
     737         [ #  # ]:          0 :         SwNodeIndex aClpIdx( aIdx );
     738         [ #  # ]:          0 :         SwPaM* pStartCursor = GetCrsr();
     739                 :          0 :         SwPaM* pCurrCrsr = pStartCursor;
     740         [ #  # ]:          0 :         sal_uInt32 nCursorCount = pStartCursor->numberOf();
     741                 :            :         // If the target selection is a multi-selection, often the last and first
     742                 :            :         // cursor of the ring points to identical document positions. Then
     743                 :            :         // we should avoid double insertion of text portions...
     744 [ #  # ][ #  # ]:          0 :         while( nCursorCount > 1 && *pCurrCrsr->GetPoint() ==
                 [ #  # ]
     745 [ #  # ][ #  # ]:          0 :             *(dynamic_cast<SwPaM*>(pCurrCrsr->GetPrev())->GetPoint()) )
     746                 :            :         {
     747                 :          0 :             --nCursorCount;
     748         [ #  # ]:          0 :             pCurrCrsr = dynamic_cast<SwPaM*>(pCurrCrsr->GetNext());
     749                 :          0 :             pStartCursor = pCurrCrsr;
     750                 :            :         }
     751         [ #  # ]:          0 :         SwPosition aStartPos( *pStartCursor->GetPoint() );
     752         [ #  # ]:          0 :         SwPosition aInsertPos( aStartPos ); // first insertion position
     753                 :          0 :         bool bCompletePara = false;
     754                 :          0 :         sal_uInt16 nMove = 0;
     755         [ #  # ]:          0 :         while( nCount )
     756                 :            :         {
     757                 :          0 :             --nCount;
     758                 :            :             OSL_ENSURE( aIdx.GetNode().GetCntntNode(), "Who filled the clipboard?!" );
     759         [ #  # ]:          0 :             if( aIdx.GetNode().GetCntntNode() ) // robust
     760                 :            :             {
     761         [ #  # ]:          0 :                 Insertion aInsertion( PaMPtr( new SwPaM( aIdx ) ),
     762 [ #  # ][ #  # ]:          0 :                     PositionPtr( new SwPosition( aInsertPos ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     763         [ #  # ]:          0 :                 ++aIdx;
     764         [ #  # ]:          0 :                 aInsertion.first->SetMark();
     765         [ #  # ]:          0 :                 if( pStartCursor == pCurrCrsr->GetNext() )
     766                 :            :                 {   // Now we have to look for insertion positions...
     767         [ #  # ]:          0 :                     if( !nMove ) // Annotate the last given insert position
     768         [ #  # ]:          0 :                         aStartPos = aInsertPos;
     769         [ #  # ]:          0 :                     SwCursor aCrsr( aStartPos, 0, false);
     770                 :            :                     // Check if we find another insert position by moving
     771                 :            :                     // down the last given position
     772 [ #  # ][ #  # ]:          0 :                     if( aCrsr.UpDown( sal_False, ++nMove, 0, 0 ) )
     773         [ #  # ]:          0 :                         aInsertPos = *aCrsr.GetPoint();
     774                 :            :                     else // if there is no paragraph we have to create it
     775                 :          0 :                         bCompletePara = nCount > 0;
     776         [ #  # ]:          0 :                     nCursorCount = 0;
     777                 :            :                 }
     778                 :            :                 else // as long as we find more insert positions in the cursor ring
     779                 :            :                 {    // we'll take them
     780         [ #  # ]:          0 :                     pCurrCrsr = dynamic_cast<SwPaM*>(pCurrCrsr->GetNext());
     781         [ #  # ]:          0 :                     aInsertPos = *pCurrCrsr->GetPoint();
     782                 :          0 :                     --nCursorCount;
     783                 :            :                 }
     784                 :            :                 // If there are no more paragraphs e.g. at the end of a document,
     785                 :            :                 // we insert complete paragraphs instead of text portions
     786         [ #  # ]:          0 :                 if( bCompletePara )
     787         [ #  # ]:          0 :                     aInsertion.first->GetPoint()->nNode = aIdx;
     788                 :            :                 else
     789                 :          0 :                     aInsertion.first->GetPoint()->nContent =
     790   [ #  #  #  # ]:          0 :                         aInsertion.first->GetCntntNode()->Len();
     791 [ #  # ][ #  # ]:          0 :                 aCopyList.push_back( aInsertion );
     792                 :            :             }
     793                 :            :             // If there are no text portions left but there are some more
     794                 :            :             // cursor positions to fill we have to restart with the first
     795                 :            :             // text portion
     796 [ #  # ][ #  # ]:          0 :             if( !nCount && nCursorCount )
     797                 :            :             {
     798         [ #  # ]:          0 :                 nCount = std::min( nSelCount, nCursorCount );
     799         [ #  # ]:          0 :                 aIdx = aClpIdx; // Start of clipboard content
     800                 :            :             }
     801                 :            :         }
     802                 :          0 :         std::list< Insertion >::const_iterator pCurr = aCopyList.begin();
     803                 :          0 :         std::list< Insertion >::const_iterator pEnd = aCopyList.end();
     804         [ #  # ]:          0 :         while( pCurr != pEnd )
     805                 :            :         {
     806                 :          0 :             SwPosition& rInsPos = *pCurr->second;
     807                 :          0 :             SwPaM& rCopy = *pCurr->first;
     808         [ #  # ]:          0 :             const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().FindTableBoxStartNode();
     809         [ #  # ]:          0 :             if( pBoxNd && 2 == pBoxNd->EndOfSectionIndex() - pBoxNd->GetIndex() &&
           [ #  #  #  # ]
                 [ #  # ]
     810                 :          0 :                 rCopy.GetPoint()->nNode != rCopy.GetMark()->nNode )
     811                 :            :             {
     812                 :            :                 // if more than one node will be copied into a cell
     813                 :            :                 // the box attributes have to be removed
     814         [ #  # ]:          0 :                 GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
     815                 :            :             }
     816                 :            :             {
     817         [ #  # ]:          0 :                 SwNodeIndex aIndexBefore(rInsPos.nNode);
     818         [ #  # ]:          0 :                 aIndexBefore--;
     819         [ #  # ]:          0 :                 pClpDoc->CopyRange( rCopy, rInsPos, false );
     820                 :            :                 {
     821         [ #  # ]:          0 :                     aIndexBefore++;
     822                 :            :                     SwPaM aPaM(SwPosition(aIndexBefore),
     823 [ #  # ][ #  # ]:          0 :                                SwPosition(rInsPos.nNode));
         [ #  # ][ #  # ]
                 [ #  # ]
     824 [ #  # ][ #  # ]:          0 :                     aPaM.GetDoc()->MakeUniqueNumRules(aPaM);
     825         [ #  # ]:          0 :                 }
     826                 :            :             }
     827         [ #  # ]:          0 :             SaveTblBoxCntnt( &rInsPos );
     828                 :          0 :             ++pCurr;
     829 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     830                 :            :     }
     831                 :            :     else
     832                 :            :     {
     833 [ #  # ][ #  # ]:          0 :         FOREACHPAM_START(this)
     834                 :            : 
     835   [ #  #  #  # ]:          0 :         if( pSrcNd &&
         [ #  # ][ #  # ]
     836                 :          0 :             0 != ( pDestNd = GetDoc()->IsIdxInTbl( PCURCRSR->GetPoint()->nNode )))
     837                 :            :         {
     838         [ #  # ]:          0 :             SwPosition aDestPos( *PCURCRSR->GetPoint() );
     839                 :            : 
     840                 :          0 :             sal_Bool bParkTblCrsr = sal_False;
     841         [ #  # ]:          0 :             const SwStartNode* pSttNd =  PCURCRSR->GetNode()->FindTableBoxStartNode();
     842                 :            : 
     843                 :            :             // TABLE IN TABLE: copy table in table
     844                 :            :             // search boxes via the layout
     845         [ #  # ]:          0 :             SwSelBoxes aBoxes;
     846         [ #  # ]:          0 :             if( IsTableMode() )     // table selection?
     847                 :            :             {
     848         [ #  # ]:          0 :                 GetTblSel( *this, aBoxes );
     849         [ #  # ]:          0 :                 ParkTblCrsr();
     850                 :          0 :                 bParkTblCrsr = sal_True;
     851                 :            :             }
     852 [ #  # ][ #  # ]:          0 :             else if( !PCURCRSR->HasMark() && PCURCRSR->GetNext() == PCURCRSR &&
           [ #  #  #  # ]
                 [ #  # ]
     853         [ #  # ]:          0 :                      ( !pSrcNd->GetTable().IsTblComplex() ||
     854                 :          0 :                        pDestNd->GetTable().IsNewModel() ) )
     855                 :            :             {
     856                 :            :                 // make relative table copy
     857                 :          0 :                 SwTableBox* pBox = pDestNd->GetTable().GetTblBox(
     858         [ #  # ]:          0 :                                         pSttNd->GetIndex() );
     859                 :            :                 OSL_ENSURE( pBox, "Box steht nicht in dieser Tabelle" );
     860         [ #  # ]:          0 :                 aBoxes.insert( pBox );
     861                 :            :             }
     862                 :            : 
     863         [ #  # ]:          0 :             SwNodeIndex aNdIdx( *pDestNd->EndOfSectionNode());
     864         [ #  # ]:          0 :             if( !bParkTblCrsr )
     865                 :            :             {
     866                 :            :                 // exit first the complete table
     867                 :            :                 // ???? what about only table in a frame ?????
     868 [ #  # ][ #  # ]:          0 :                 SwCntntNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
     869 [ #  # ][ #  # ]:          0 :                 SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
         [ #  # ][ #  # ]
     870                 :            :                 // #i59539: Don't remove all redline
     871         [ #  # ]:          0 :                 SwPaM const tmpPaM(*pDestNd, *pDestNd->EndOfSectionNode());
     872 [ #  # ][ #  # ]:          0 :                 ::PaMCorrAbs(tmpPaM, aPos);
                 [ #  # ]
     873                 :            :             }
     874                 :            : 
     875                 :          0 :             bRet = GetDoc()->InsCopyOfTbl( aDestPos, aBoxes, &pSrcNd->GetTable(),
     876         [ #  # ]:          0 :                                             sal_False, sal_False );
     877                 :            : 
     878         [ #  # ]:          0 :             if( bParkTblCrsr )
     879         [ #  # ]:          0 :                 GetCrsr();
     880                 :            :             else
     881                 :            :             {
     882                 :            :                 // return to the box
     883         [ #  # ]:          0 :                 aNdIdx = *pSttNd;
     884 [ #  # ][ #  # ]:          0 :                 SwCntntNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
     885 [ #  # ][ #  # ]:          0 :                 SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
         [ #  # ][ #  # ]
     886                 :            :                 // #i59539: Don't remove all redline
     887                 :          0 :                 SwNode & rNode(PCURCRSR->GetPoint()->nNode.GetNode());
     888                 :          0 :                 SwCntntNode *const pCntntNode( rNode.GetCntntNode() );
     889                 :            :                 SwPaM const tmpPam(rNode, 0,
     890 [ #  # ][ #  # ]:          0 :                                    rNode, (pCntntNode) ? pCntntNode->Len() : 0);
                 [ #  # ]
     891 [ #  # ][ #  # ]:          0 :                 ::PaMCorrAbs(tmpPam, aPos);
                 [ #  # ]
     892                 :            :             }
     893                 :            : 
     894 [ #  # ][ #  # ]:          0 :             break;      // exit the "while-loop"
     895                 :            :         }
     896         [ #  # ]:          0 :         else if( *aCpyPam.GetPoint() == *aCpyPam.GetMark() &&
           [ #  #  #  # ]
                 [ #  # ]
     897                 :          0 :                  pClpDoc->GetSpzFrmFmts()->size() )
     898                 :            :         {
     899                 :            :             // we need a DrawView
     900         [ #  # ]:          0 :             if( !Imp()->GetDrawView() )
     901         [ #  # ]:          0 :                 MakeDrawView();
     902                 :            : 
     903         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i )
     904                 :            :             {
     905                 :          0 :                 sal_Bool bInsWithFmt = sal_True;
     906         [ #  # ]:          0 :                 const SwFrmFmt& rCpyFmt = *(*pClpDoc->GetSpzFrmFmts())[i];
     907                 :            : 
     908 [ #  # ][ #  #  :          0 :                 if( Imp()->GetDrawView()->IsGroupEntered() &&
             #  #  #  # ]
                 [ #  # ]
     909                 :          0 :                     RES_DRAWFRMFMT == rCpyFmt.Which() &&
     910         [ #  # ]:          0 :                     (FLY_AS_CHAR != rCpyFmt.GetAnchor().GetAnchorId()) )
     911                 :            :                 {
     912         [ #  # ]:          0 :                     const SdrObject* pSdrObj = rCpyFmt.FindSdrObject();
     913         [ #  # ]:          0 :                     if( pSdrObj )
     914                 :            :                     {
     915                 :            :                         SdrObject* pNew = GetDoc()->CloneSdrObj( *pSdrObj,
     916         [ #  # ]:          0 :                                                             sal_False, sal_False );
     917                 :            : 
     918                 :            :                         // Insert object sets any anchor position to 0.
     919                 :            :                         // Therefore we calculate the absolute position here
     920                 :            :                         // and after the insert the anchor of the object
     921                 :            :                         // is set to the anchor of the group object.
     922         [ #  # ]:          0 :                         Rectangle aSnapRect = pNew->GetSnapRect();
     923 [ #  # ][ #  # ]:          0 :                         if( pNew->GetAnchorPos().X() || pNew->GetAnchorPos().Y() )
         [ #  # ][ #  # ]
                 [ #  # ]
     924                 :            :                         {
     925                 :          0 :                             const Point aPoint( 0, 0 );
     926                 :            :                             // OD 2004-04-05 #i26791# - direct drawing object
     927                 :            :                             // positioning for group members
     928         [ #  # ]:          0 :                             pNew->NbcSetAnchorPos( aPoint );
     929         [ #  # ]:          0 :                             pNew->NbcSetSnapRect( aSnapRect );
     930                 :            :                         }
     931                 :            : 
     932         [ #  # ]:          0 :                         Imp()->GetDrawView()->InsertObjectAtView( pNew, *Imp()->GetPageView() );
     933                 :            : 
     934                 :          0 :                         Point aGrpAnchor( 0, 0 );
     935         [ #  # ]:          0 :                         SdrObjList* pList = pNew->GetObjList();
     936         [ #  # ]:          0 :                         if ( pList )
     937                 :            :                         {
     938                 :          0 :                             SdrObject* pOwner = pList->GetOwnerObj();
     939         [ #  # ]:          0 :                             if ( pOwner )
     940                 :            :                             {
     941 [ #  # ][ #  # ]:          0 :                                 SdrObjGroup* pThisGroup = PTR_CAST(SdrObjGroup, pOwner);
         [ #  # ][ #  # ]
     942         [ #  # ]:          0 :                                 aGrpAnchor = pThisGroup->GetAnchorPos();
     943                 :            :                             }
     944                 :            :                         }
     945                 :            : 
     946                 :            :                         // OD 2004-04-05 #i26791# - direct drawing object
     947                 :            :                         // positioning for group members
     948         [ #  # ]:          0 :                         pNew->NbcSetAnchorPos( aGrpAnchor );
     949         [ #  # ]:          0 :                         pNew->SetSnapRect( aSnapRect );
     950                 :            : 
     951                 :          0 :                         bInsWithFmt = sal_False;
     952                 :            :                     }
     953                 :            :                 }
     954                 :            : 
     955         [ #  # ]:          0 :                 if( bInsWithFmt  )
     956                 :            :                 {
     957 [ #  # ][ #  # ]:          0 :                     SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
     958   [ #  #  #  #  :          0 :                     if ((FLY_AT_PARA == aAnchor.GetAnchorId()) ||
           #  # ][ #  # ]
     959                 :          0 :                         (FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
     960                 :          0 :                         (FLY_AS_CHAR == aAnchor.GetAnchorId()))
     961                 :            :                     {
     962                 :          0 :                         SwPosition* pPos = PCURCRSR->GetPoint();
     963                 :            :                         // allow shapes (no controls) in header/footer
     964 [ #  # ][ #  # ]:          0 :                         if( RES_DRAWFRMFMT == rCpyFmt.Which() &&
         [ #  # ][ #  # ]
     965         [ #  # ]:          0 :                             GetDoc()->IsInHeaderFooter( pPos->nNode ) &&
     966 [ #  # ][ #  # ]:          0 :                             CheckControlLayer( rCpyFmt.FindSdrObject() ) )
     967                 :          0 :                             continue;
     968                 :            : 
     969         [ #  # ]:          0 :                         aAnchor.SetAnchor( pPos );
     970                 :            :                     }
     971         [ #  # ]:          0 :                     else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() )
     972                 :            :                     {
     973         [ #  # ]:          0 :                         aAnchor.SetPageNum( GetPhyPageNum() );
     974                 :            :                     }
     975         [ #  # ]:          0 :                     else if( FLY_AT_FLY == aAnchor.GetAnchorId() )
     976                 :            :                     {
     977                 :          0 :                         Point aPt;
     978                 :          0 :                         lcl_SetAnchor( *PCURCRSR->GetPoint(), *PCURCRSR->GetNode(),
     979         [ #  # ]:          0 :                                         0, aPt, *this, aAnchor, aPt, sal_False );
     980                 :            :                     }
     981                 :            : 
     982         [ #  # ]:          0 :                     SwFrmFmt * pNew = GetDoc()->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
     983                 :            : 
     984         [ #  # ]:          0 :                     if( pNew )
     985                 :            :                     {
     986         [ #  # ]:          0 :                         if( RES_FLYFRMFMT == pNew->Which() )
     987                 :            :                         {
     988                 :          0 :                             const Point aPt( GetCrsrDocPos() );
     989                 :            :                             SwFlyFrm* pFlyFrm = ((SwFlyFrmFmt*)pNew)->
     990         [ #  # ]:          0 :                                                         GetFrm( &aPt, sal_False );
     991         [ #  # ]:          0 :                             if( pFlyFrm )
     992         [ #  # ]:          0 :                                 SelectFlyFrm( *pFlyFrm, sal_True );
     993                 :            :                             // always pick the first FlyFrame only; the others
     994                 :            :                             // were copied to the clipboard via Fly in Fly
     995                 :            :                             break;
     996                 :            :                         }
     997                 :            :                         else
     998                 :            :                         {
     999                 :            :                             OSL_ENSURE( RES_DRAWFRMFMT == pNew->Which(), "Neues Format.");
    1000                 :            :                             // #i52780# - drawing object has
    1001                 :            :                             // to be made visible on paste.
    1002                 :            :                             {
    1003                 :            :                                 SwDrawContact* pContact =
    1004         [ #  # ]:          0 :                                     static_cast<SwDrawContact*>(pNew->FindContactObj());
    1005 [ #  # ][ #  # ]:          0 :                                 pContact->MoveObjToVisibleLayer( pContact->GetMaster() );
    1006                 :            :                             }
    1007         [ #  # ]:          0 :                             SdrObject *pObj = pNew->FindSdrObject();
    1008                 :          0 :                             SwDrawView  *pDV = Imp()->GetDrawView();
    1009         [ #  # ]:          0 :                             pDV->MarkObj( pObj, pDV->GetSdrPageView() );
    1010                 :            :                             // #i47455# - notify draw frame format
    1011                 :            :                             // that position attributes are already set.
    1012 [ #  # ][ #  # ]:          0 :                             if ( pNew->ISA(SwDrawFrmFmt) )
                 [ #  # ]
    1013                 :            :                             {
    1014                 :          0 :                                 static_cast<SwDrawFrmFmt*>(pNew)->PosAttrSet();
    1015                 :            :                             }
    1016                 :            :                         }
    1017         [ #  # ]:          0 :                     }
              [ #  #  # ]
    1018                 :            :                 }
    1019                 :            :             }
    1020                 :            :         }
    1021                 :            :         else
    1022                 :            :         {
    1023 [ #  # ][ #  # ]:          0 :             if( bDelTbl && IsTableMode() )
                 [ #  # ]
    1024                 :            :             {
    1025         [ #  # ]:          0 :                 SwEditShell::Delete();
    1026                 :          0 :                 bDelTbl = sal_False;
    1027                 :            :             }
    1028                 :            : 
    1029                 :          0 :             SwPosition& rInsPos = *PCURCRSR->GetPoint();
    1030                 :          0 :             const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().
    1031         [ #  # ]:          0 :                                                     FindTableBoxStartNode();
    1032         [ #  # ]:          0 :             if( pBoxNd && 2 == pBoxNd->EndOfSectionIndex() -
           [ #  #  #  # ]
                 [ #  # ]
    1033                 :          0 :                                 pBoxNd->GetIndex() &&
    1034                 :          0 :                 aCpyPam.GetPoint()->nNode != aCpyPam.GetMark()->nNode )
    1035                 :            :             {
    1036                 :            :                 // Copy more than 1 node in the current box. But
    1037                 :            :                 // then the BoxAttribute should be removed
    1038         [ #  # ]:          0 :                 GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
    1039                 :            :             }
    1040                 :            : 
    1041                 :            :             // find out if the clipboard document starts with a table
    1042 [ #  # ][ #  # ]:          0 :             bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode();
    1043         [ #  # ]:          0 :             SwPosition aInsertPosition( rInsPos );
    1044                 :            : 
    1045                 :            :             {
    1046         [ #  # ]:          0 :                 SwNodeIndex aIndexBefore(rInsPos.nNode);
    1047                 :            : 
    1048         [ #  # ]:          0 :                 aIndexBefore--;
    1049                 :            : 
    1050         [ #  # ]:          0 :                 pClpDoc->CopyRange( aCpyPam, rInsPos, false );
    1051                 :            : 
    1052                 :            :                 {
    1053         [ #  # ]:          0 :                     aIndexBefore++;
    1054                 :            :                     SwPaM aPaM(SwPosition(aIndexBefore),
    1055 [ #  # ][ #  # ]:          0 :                                SwPosition(rInsPos.nNode));
         [ #  # ][ #  # ]
                 [ #  # ]
    1056                 :            : 
    1057 [ #  # ][ #  # ]:          0 :                     aPaM.GetDoc()->MakeUniqueNumRules(aPaM);
    1058         [ #  # ]:          0 :                 }
    1059                 :            :             }
    1060                 :            : 
    1061                 :            :             // Update the rsid of each pasted text node.
    1062                 :            :             {
    1063 [ #  # ][ #  # ]:          0 :                 xub_StrLen nNodesCnt = aCpyPam.End()->nNode.GetIndex() - aCpyPam.Start()->nNode.GetIndex();
    1064         [ #  # ]:          0 :                 SwNodes &rDestNodes = GetDoc()->GetNodes();
    1065                 :          0 :                 xub_StrLen nDestStart = PCURCRSR->GetPoint()->nNode.GetIndex() - nNodesCnt;
    1066                 :            : 
    1067         [ #  # ]:          0 :                 for ( sal_uInt64 nIdx = 0; nIdx <= nNodesCnt; nIdx++ )
    1068                 :            :                 {
    1069         [ #  # ]:          0 :                     SwTxtNode *pTxtNode = rDestNodes[ nDestStart + nIdx ]->GetTxtNode();
    1070         [ #  # ]:          0 :                     if ( pTxtNode )
    1071                 :            :                     {
    1072         [ #  # ]:          0 :                         GetDoc()->UpdateParRsid( pTxtNode );
    1073                 :            :                     }
    1074                 :            :                 }
    1075                 :            :             }
    1076                 :            : 
    1077         [ #  # ]:          0 :             SaveTblBoxCntnt( &rInsPos );
    1078 [ #  # ][ #  # ]:          0 :             if(bIncludingPageFrames && bStartWithTable)
    1079                 :            :             {
    1080                 :            :                 //remove the paragraph in front of the table
    1081         [ #  # ]:          0 :                 SwPaM aPara(aInsertPosition);
    1082 [ #  # ][ #  # ]:          0 :                 GetDoc()->DelFullPara(aPara);
    1083                 :            :             }
    1084                 :            :             //additionally copy page bound frames
    1085 [ #  # ][ #  # ]:          0 :             if( bIncludingPageFrames && pClpDoc->GetSpzFrmFmts()->size() )
                 [ #  # ]
    1086                 :            :             {
    1087                 :            :                 // create a draw view if necessary
    1088         [ #  # ]:          0 :                 if( !Imp()->GetDrawView() )
    1089         [ #  # ]:          0 :                     MakeDrawView();
    1090                 :            : 
    1091         [ #  # ]:          0 :                 for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i )
    1092                 :            :                 {
    1093                 :          0 :                     sal_Bool bInsWithFmt = sal_True;
    1094         [ #  # ]:          0 :                     const SwFrmFmt& rCpyFmt = *(*pClpDoc->GetSpzFrmFmts())[i];
    1095         [ #  # ]:          0 :                     if( bInsWithFmt  )
    1096                 :            :                     {
    1097 [ #  # ][ #  # ]:          0 :                         SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
    1098         [ #  # ]:          0 :                         if ( FLY_AT_PAGE == aAnchor.GetAnchorId() )
    1099                 :            :                         {
    1100                 :          0 :                             aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 );
    1101                 :            :                         }
    1102                 :            :                         else
    1103                 :          0 :                             continue;
    1104 [ #  # ][ #  # ]:          0 :                         GetDoc()->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
                 [ #  # ]
    1105                 :            :                     }
    1106                 :            :                 }
    1107         [ #  # ]:          0 :             }
    1108                 :            :         }
    1109                 :            : 
    1110                 :          0 :         FOREACHPAM_END()
    1111                 :            :     }
    1112                 :            : 
    1113 [ #  # ][ #  # ]:          0 :     GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL );
    1114                 :            : 
    1115                 :            :     // have new table formulas been inserted?
    1116         [ #  # ]:          0 :     if( pTblFldTyp->GetDepends() )
    1117                 :            :     {
    1118                 :            :         // finish old action: table-frames have been created
    1119                 :            :         // a selection can be made now
    1120                 :            :         sal_uInt16 nActCnt;
    1121         [ #  # ]:          0 :         for( nActCnt = 0; ActionPend(); ++nActCnt )
    1122         [ #  # ]:          0 :             EndAllAction();
    1123                 :            : 
    1124         [ #  # ]:          0 :         for( ; nActCnt; --nActCnt )
    1125         [ #  # ]:          0 :             StartAllAction();
    1126                 :            :     }
    1127         [ #  # ]:          0 :     GetDoc()->UnlockExpFlds();
    1128         [ #  # ]:          0 :     GetDoc()->UpdateFlds(NULL, false);
    1129         [ #  # ]:          0 :     EndAllAction();
    1130                 :            : 
    1131 [ #  # ][ #  # ]:          0 :     return bRet;
                 [ #  # ]
    1132                 :            : }
    1133                 :            : 
    1134                 :          0 : sal_Bool SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt16 nEndPage)
    1135                 :            : {
    1136         [ #  # ]:          0 :     Push();
    1137 [ #  # ][ #  # ]:          0 :     if(!GotoPage(nStartPage))
    1138                 :            :     {
    1139         [ #  # ]:          0 :         Pop(sal_False);
    1140                 :          0 :         return sal_False;
    1141                 :            :     }
    1142         [ #  # ]:          0 :     MovePage( fnPageCurr, fnPageStart );
    1143 [ #  # ][ #  # ]:          0 :     SwPaM aCpyPam( *GetCrsr()->GetPoint() );
    1144 [ #  # ][ #  # ]:          0 :     String sStartingPageDesc = GetPageDesc( GetCurPageDesc()).GetName();
                 [ #  # ]
    1145         [ #  # ]:          0 :     SwPageDesc* pDesc = rToFill.FindPageDescByName( sStartingPageDesc, sal_True );
    1146         [ #  # ]:          0 :     if( pDesc )
    1147         [ #  # ]:          0 :         rToFill.ChgCurPageDesc( *pDesc );
    1148                 :            : 
    1149 [ #  # ][ #  # ]:          0 :     if(!GotoPage(nEndPage))
    1150                 :            :     {
    1151         [ #  # ]:          0 :         Pop(sal_False);
    1152                 :          0 :         return sal_False;
    1153                 :            :     }
    1154                 :            :     //if the page starts with a table a paragraph has to be inserted before
    1155         [ #  # ]:          0 :     SwNode* pTableNode = aCpyPam.GetNode()->FindTableNode();
    1156         [ #  # ]:          0 :     if(pTableNode)
    1157                 :            :     {
    1158                 :            :         //insert a paragraph
    1159         [ #  # ]:          0 :         StartUndo(UNDO_INSERT);
    1160         [ #  # ]:          0 :         SwNodeIndex aTblIdx(  *pTableNode, -1 );
    1161         [ #  # ]:          0 :         SwPosition aBefore(aTblIdx);
    1162 [ #  # ][ #  # ]:          0 :         if(GetDoc()->AppendTxtNode( aBefore ))
    1163                 :            :         {
    1164         [ #  # ]:          0 :             SwPaM aTmp(aBefore);
    1165 [ #  # ][ #  # ]:          0 :             aCpyPam = aTmp;
    1166                 :            :         }
    1167 [ #  # ][ #  # ]:          0 :         EndUndo(UNDO_INSERT);
                 [ #  # ]
    1168                 :            :     }
    1169                 :            : 
    1170         [ #  # ]:          0 :     MovePage( fnPageCurr, fnPageEnd );
    1171         [ #  # ]:          0 :     aCpyPam.SetMark();
    1172 [ #  # ][ #  # ]:          0 :     *aCpyPam.GetMark() = *GetCrsr()->GetPoint();
    1173                 :            : 
    1174         [ #  # ]:          0 :     SET_CURR_SHELL( this );
    1175                 :            : 
    1176         [ #  # ]:          0 :     StartAllAction();
    1177         [ #  # ]:          0 :     GetDoc()->LockExpFlds();
    1178         [ #  # ]:          0 :     SetSelection(aCpyPam);
    1179                 :            :     // copy the text of the selection
    1180         [ #  # ]:          0 :     SwEditShell::Copy(&rToFill);
    1181                 :            : 
    1182         [ #  # ]:          0 :     if(pTableNode)
    1183                 :            :     {
    1184                 :            :         //remove the inserted paragraph
    1185         [ #  # ]:          0 :         Undo();
    1186                 :            :         //remove the paragraph in the second doc, too
    1187 [ #  # ][ #  # ]:          0 :         SwNodeIndex aIdx( rToFill.GetDoc()->GetNodes().GetEndOfExtras(), 2 );
    1188         [ #  # ]:          0 :         SwPaM aPara( aIdx ); //DocStart
    1189 [ #  # ][ #  # ]:          0 :         rToFill.GetDoc()->DelFullPara(aPara);
                 [ #  # ]
    1190                 :            :     }
    1191                 :            :     // now the page bound objects
    1192                 :            :     // additionally copy page bound frames
    1193         [ #  # ]:          0 :     if( GetDoc()->GetSpzFrmFmts()->size() )
    1194                 :            :     {
    1195                 :            :         // create a draw view if necessary
    1196         [ #  # ]:          0 :         if( !rToFill.Imp()->GetDrawView() )
    1197         [ #  # ]:          0 :             rToFill.MakeDrawView();
    1198                 :            : 
    1199         [ #  # ]:          0 :         for ( sal_uInt16 i = 0; i < GetDoc()->GetSpzFrmFmts()->size(); ++i )
    1200                 :            :         {
    1201         [ #  # ]:          0 :             const SwFrmFmt& rCpyFmt = *(*GetDoc()->GetSpzFrmFmts())[i];
    1202 [ #  # ][ #  # ]:          0 :             SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
    1203   [ #  #  #  #  :          0 :             if ((FLY_AT_PAGE == aAnchor.GetAnchorId()) &&
           #  # ][ #  # ]
    1204                 :          0 :                     aAnchor.GetPageNum() >= nStartPage && aAnchor.GetPageNum() <= nEndPage)
    1205                 :            :             {
    1206                 :          0 :                 aAnchor.SetPageNum( aAnchor.GetPageNum() - nStartPage + 1);
    1207                 :            :             }
    1208                 :            :             else
    1209                 :          0 :                 continue;
    1210 [ #  # ][ #  # ]:          0 :             rToFill.GetDoc()->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
    1211         [ #  # ]:          0 :         }
    1212                 :            :     }
    1213         [ #  # ]:          0 :     GetDoc()->UnlockExpFlds();
    1214         [ #  # ]:          0 :     GetDoc()->UpdateFlds(NULL, false);
    1215         [ #  # ]:          0 :     Pop(sal_False);
    1216         [ #  # ]:          0 :     EndAllAction();
    1217                 :            : 
    1218 [ #  # ][ #  # ]:          0 :     return sal_True;
                 [ #  # ]
    1219                 :            : }
    1220                 :            : 
    1221                 :          0 : sal_Bool SwFEShell::GetDrawObjGraphic( sal_uLong nFmt, Graphic& rGrf ) const
    1222                 :            : {
    1223                 :            :     OSL_ENSURE( Imp()->HasDrawView(), "GetDrawObjGraphic without DrawView?" );
    1224                 :          0 :     const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
    1225                 :          0 :     sal_Bool bConvert = sal_True;
    1226         [ #  # ]:          0 :     if( rMrkList.GetMarkCount() )
    1227                 :            :     {
    1228   [ #  #  #  # ]:          0 :         if( rMrkList.GetMarkCount() == 1 &&
                 [ #  # ]
    1229                 :          0 :             rMrkList.GetMark( 0 )->GetMarkedSdrObj()->ISA(SwVirtFlyDrawObj) )
    1230                 :            :         {
    1231                 :            :             // select frame
    1232         [ #  # ]:          0 :             if( CNT_GRF == GetCntType() )
    1233                 :            :             {
    1234                 :          0 :                 const Graphic* pGrf( GetGraphic() );
    1235         [ #  # ]:          0 :                 if ( pGrf )
    1236                 :            :                 {
    1237         [ #  # ]:          0 :                     Graphic aGrf( *pGrf );
    1238         [ #  # ]:          0 :                     if( SOT_FORMAT_GDIMETAFILE == nFmt )
    1239                 :            :                     {
    1240 [ #  # ][ #  # ]:          0 :                         if( GRAPHIC_BITMAP != aGrf.GetType() )
    1241                 :            :                         {
    1242         [ #  # ]:          0 :                             rGrf = aGrf;
    1243                 :          0 :                             bConvert = sal_False;
    1244                 :            :                         }
    1245         [ #  # ]:          0 :                         else if( GetWin() )
    1246                 :            :                         {
    1247                 :          0 :                             Size aSz;
    1248                 :          0 :                             Point aPt;
    1249         [ #  # ]:          0 :                             GetGrfSize( aSz );
    1250                 :            : 
    1251         [ #  # ]:          0 :                             VirtualDevice aVirtDev;
    1252         [ #  # ]:          0 :                             aVirtDev.EnableOutput( sal_False );
    1253                 :            : 
    1254         [ #  # ]:          0 :                             MapMode aTmp( GetWin()->GetMapMode() );
    1255         [ #  # ]:          0 :                             aTmp.SetOrigin( aPt );
    1256         [ #  # ]:          0 :                             aVirtDev.SetMapMode( aTmp );
    1257                 :            : 
    1258         [ #  # ]:          0 :                             GDIMetaFile aMtf;
    1259         [ #  # ]:          0 :                             aMtf.Record( &aVirtDev );
    1260         [ #  # ]:          0 :                             aGrf.Draw( &aVirtDev, aPt, aSz );
    1261         [ #  # ]:          0 :                             aMtf.Stop();
    1262         [ #  # ]:          0 :                             aMtf.SetPrefMapMode( aTmp );
    1263                 :          0 :                             aMtf.SetPrefSize( aSz );
    1264 [ #  # ][ #  # ]:          0 :                             rGrf = aMtf;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1265                 :            :                         }
    1266                 :            :                     }
    1267 [ #  # ][ #  # ]:          0 :                     else if( GRAPHIC_BITMAP == aGrf.GetType() )
    1268                 :            :                     {
    1269         [ #  # ]:          0 :                         rGrf = aGrf;
    1270                 :          0 :                         bConvert = sal_False;
    1271                 :            :                     }
    1272                 :            :                     else
    1273                 :            :                     {
    1274                 :            :                         // fix(23806): not the origial size, but the current one.
    1275                 :            :                         // Otherwise it could happen that for vector graphics
    1276                 :            :                         // many MB's of memory are allocated.
    1277         [ #  # ]:          0 :                         const Size aSz( FindFlyFrm()->Prt().SSize() );
    1278         [ #  # ]:          0 :                         VirtualDevice aVirtDev( *GetWin() );
    1279                 :            : 
    1280         [ #  # ]:          0 :                         MapMode aTmp( MAP_TWIP );
    1281         [ #  # ]:          0 :                         aVirtDev.SetMapMode( aTmp );
    1282 [ #  # ][ #  # ]:          0 :                         if( aVirtDev.SetOutputSize( aSz ) )
    1283                 :            :                         {
    1284         [ #  # ]:          0 :                             aGrf.Draw( &aVirtDev, Point(), aSz );
    1285 [ #  # ][ #  # ]:          0 :                             rGrf = aVirtDev.GetBitmap( Point(), aSz );
         [ #  # ][ #  # ]
                 [ #  # ]
    1286                 :            :                         }
    1287                 :            :                         else
    1288                 :            :                         {
    1289         [ #  # ]:          0 :                             rGrf = aGrf;
    1290                 :          0 :                             bConvert = sal_False;
    1291 [ #  # ][ #  # ]:          0 :                         }
    1292         [ #  # ]:          0 :                     }
    1293                 :            :                 }
    1294                 :            :             }
    1295                 :            :         }
    1296         [ #  # ]:          0 :         else if( SOT_FORMAT_GDIMETAFILE == nFmt )
    1297 [ #  # ][ #  # ]:          0 :             rGrf = Imp()->GetDrawView()->GetAllMarkedMetaFile();
                 [ #  # ]
    1298         [ #  # ]:          0 :         else if( SOT_FORMAT_BITMAP == nFmt )
    1299 [ #  # ][ #  # ]:          0 :             rGrf = Imp()->GetDrawView()->GetAllMarkedBitmap();
                 [ #  # ]
    1300                 :            :     }
    1301                 :          0 :     return bConvert;
    1302                 :            : }
    1303                 :            : 
    1304                 :            : // #i50824#
    1305                 :            : // replace method <lcl_RemoveOleObjsFromSdrModel> by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
    1306                 :          0 : void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SdrModel* _pModel )
    1307                 :            : {
    1308         [ #  # ]:          0 :     for ( sal_uInt16 nPgNum = 0; nPgNum < _pModel->GetPageCount(); ++nPgNum )
    1309                 :            :     {
    1310                 :            :         // setup object iterator in order to iterate through all objects
    1311                 :            :         // including objects in group objects, but exclusive group objects.
    1312 [ #  # ][ #  # ]:          0 :         SdrObjListIter aIter(*(_pModel->GetPage( nPgNum )));
    1313         [ #  # ]:          0 :         while( aIter.IsMore() )
    1314                 :            :         {
    1315 [ #  # ][ #  # ]:          0 :             SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( aIter.Next() );
    1316         [ #  # ]:          0 :             if( pOle2Obj )
    1317                 :            :             {
    1318                 :            :                 // found an ole2 shape
    1319         [ #  # ]:          0 :                 SdrObjList* pObjList = pOle2Obj->GetObjList();
    1320                 :            : 
    1321                 :            :                 // get its graphic
    1322         [ #  # ]:          0 :                 Graphic aGraphic;
    1323         [ #  # ]:          0 :                 pOle2Obj->Connect();
    1324         [ #  # ]:          0 :                 Graphic* pGraphic = pOle2Obj->GetGraphic();
    1325         [ #  # ]:          0 :                 if( pGraphic )
    1326         [ #  # ]:          0 :                     aGraphic = *pGraphic;
    1327         [ #  # ]:          0 :                 pOle2Obj->Disconnect();
    1328                 :            : 
    1329                 :            :                 // create new graphic shape with the ole graphic and shape size
    1330 [ #  # ][ #  # ]:          0 :                 SdrGrafObj* pGraphicObj = new SdrGrafObj( aGraphic, pOle2Obj->GetCurrentBoundRect() );
                 [ #  # ]
    1331                 :            :                 // apply layer of ole2 shape at graphic shape
    1332 [ #  # ][ #  # ]:          0 :                 pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
    1333                 :            : 
    1334                 :            :                 // replace ole2 shape with the new graphic object and delete the ol2 shape
    1335 [ #  # ][ #  # ]:          0 :                 SdrObject* pRemovedObject = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
    1336 [ #  # ][ #  # ]:          0 :                 SdrObject::Free( pRemovedObject );
    1337                 :            :             }
    1338                 :            :         }
    1339                 :          0 :     }
    1340                 :          0 : }
    1341                 :            : 
    1342                 :          0 : void SwFEShell::Paste( SvStream& rStrm, sal_uInt16 nAction, const Point* pPt )
    1343                 :            : {
    1344         [ #  # ]:          0 :     SET_CURR_SHELL( this );
    1345         [ #  # ]:          0 :     StartAllAction();
    1346         [ #  # ]:          0 :     StartUndo();
    1347                 :            : 
    1348         [ #  # ]:          0 :     SvtPathOptions aPathOpt;
    1349                 :            :     FmFormModel* pModel = new FmFormModel( aPathOpt.GetPalettePath(),
    1350 [ #  # ][ #  # ]:          0 :                                             0, GetDoc()->GetDocShell() );
                 [ #  # ]
    1351         [ #  # ]:          0 :     pModel->GetItemPool().FreezeIdRanges();
    1352                 :            : 
    1353         [ #  # ]:          0 :     rStrm.Seek(0);
    1354                 :            : 
    1355 [ #  # ][ #  # ]:          0 :     uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rStrm ) );
                 [ #  # ]
    1356         [ #  # ]:          0 :     SvxDrawingLayerImport( pModel, xInputStream );
    1357                 :            : 
    1358         [ #  # ]:          0 :     if ( !Imp()->HasDrawView() )
    1359         [ #  # ]:          0 :         Imp()->MakeDrawView();
    1360                 :            : 
    1361         [ #  # ]:          0 :     Point aPos( pPt ? *pPt : GetCharRect().Pos() );
    1362                 :          0 :     SdrView *pView = Imp()->GetDrawView();
    1363                 :            : 
    1364                 :            :     // drop on the existing object: replace object or apply new attributes
    1365         [ #  # ]:          0 :     if( pModel->GetPageCount() > 0 &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    1366 [ #  # ][ #  # ]:          0 :         1 == pModel->GetPage(0)->GetObjCount() &&
    1367                 :          0 :         1 == pView->GetMarkedObjectList().GetMarkCount() )
    1368                 :            :     {
    1369                 :            :         // replace a marked 'virtual' drawing object
    1370                 :            :         // by its corresponding 'master' drawing object in the mark list.
    1371         [ #  # ]:          0 :         SwDrawView::ReplaceMarkedDrawVirtObjs( *pView );
    1372                 :            : 
    1373 [ #  # ][ #  # ]:          0 :         SdrObject* pClpObj = pModel->GetPage(0)->GetObj(0);
    1374 [ #  # ][ #  # ]:          0 :         SdrObject* pOldObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
    1375                 :            : 
    1376 [ #  # ][ #  # ]:          0 :         if( SW_PASTESDR_SETATTR == nAction && pOldObj->ISA(SwVirtFlyDrawObj) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1377                 :          0 :             nAction = SW_PASTESDR_REPLACE;
    1378                 :            : 
    1379      [ #  #  # ]:          0 :         switch( nAction )
    1380                 :            :         {
    1381                 :            :         case SW_PASTESDR_REPLACE:
    1382                 :            :             {
    1383                 :          0 :                 const SwFrmFmt* pFmt(0);
    1384                 :          0 :                 const SwFrm* pAnchor(0);
    1385 [ #  # ][ #  # ]:          0 :                 if( pOldObj->ISA(SwVirtFlyDrawObj) )
                 [ #  # ]
    1386                 :            :                 {
    1387         [ #  # ]:          0 :                     pFmt = FindFrmFmt( pOldObj );
    1388                 :            : 
    1389                 :          0 :                     Point aNullPt;
    1390         [ #  # ]:          0 :                     SwFlyFrm* pFlyFrm = ((SwFlyFrmFmt*)pFmt)->GetFrm( &aNullPt );
    1391         [ #  # ]:          0 :                     pAnchor = pFlyFrm->GetAnchorFrm();
    1392                 :            : 
    1393 [ #  # ][ #  # ]:          0 :                     if( pAnchor->FindFooterOrHeader() )
    1394                 :            :                     {
    1395                 :            :                         // if there is a textframe in the header/footer:
    1396                 :            :                         // do not replace but insert
    1397                 :          0 :                         nAction = SW_PASTESDR_INSERT;
    1398                 :            :                         break;
    1399                 :            :                     }
    1400                 :            :                 }
    1401                 :            : 
    1402         [ #  # ]:          0 :                 SdrObject* pNewObj = pClpObj->Clone();
    1403         [ #  # ]:          0 :                 Rectangle aOldObjRect( pOldObj->GetCurrentBoundRect() );
    1404         [ #  # ]:          0 :                 Size aOldObjSize( aOldObjRect.GetSize() );
    1405         [ #  # ]:          0 :                 Rectangle aNewRect( pNewObj->GetCurrentBoundRect() );
    1406         [ #  # ]:          0 :                 Size aNewSize( aNewRect.GetSize() );
    1407                 :            : 
    1408         [ #  # ]:          0 :                 Fraction aScaleWidth( aOldObjSize.Width(), aNewSize.Width() );
    1409         [ #  # ]:          0 :                 Fraction aScaleHeight( aOldObjSize.Height(), aNewSize.Height());
    1410         [ #  # ]:          0 :                 pNewObj->NbcResize( aNewRect.TopLeft(), aScaleWidth, aScaleHeight);
    1411                 :            : 
    1412                 :          0 :                 Point aVec = aOldObjRect.TopLeft() - aNewRect.TopLeft();
    1413         [ #  # ]:          0 :                 pNewObj->NbcMove(Size(aVec.X(), aVec.Y()));
    1414                 :            : 
    1415 [ #  # ][ #  # ]:          0 :                 if( pNewObj->ISA( SdrUnoObj ) )
                 [ #  # ]
    1416 [ #  # ][ #  # ]:          0 :                     pNewObj->SetLayer( GetDoc()->GetControlsId() );
    1417 [ #  # ][ #  # ]:          0 :                 else if( pOldObj->ISA( SdrUnoObj ) )
                 [ #  # ]
    1418 [ #  # ][ #  # ]:          0 :                     pNewObj->SetLayer( GetDoc()->GetHeavenId() );
    1419                 :            :                 else
    1420 [ #  # ][ #  # ]:          0 :                     pNewObj->SetLayer( pOldObj->GetLayer() );
    1421                 :            : 
    1422 [ #  # ][ #  # ]:          0 :                 if( pOldObj->ISA(SwVirtFlyDrawObj) )
                 [ #  # ]
    1423                 :            :                 {
    1424                 :            :                     // store attributes, then set SdrObject
    1425                 :          0 :                     SfxItemSet aFrmSet( pDoc->GetAttrPool(),
    1426         [ #  # ]:          0 :                                             RES_SURROUND, RES_ANCHOR );
    1427         [ #  # ]:          0 :                     aFrmSet.Set( pFmt->GetAttrSet() );
    1428                 :            : 
    1429                 :          0 :                     Point aNullPt;
    1430 [ #  # ][ #  # ]:          0 :                     if( pAnchor->IsTxtFrm() && ((SwTxtFrm*)pAnchor)->IsFollow() )
                 [ #  # ]
    1431                 :            :                     {
    1432                 :          0 :                         const SwTxtFrm* pTmp = (SwTxtFrm*)pAnchor;
    1433         [ #  # ]:          0 :                         do {
    1434         [ #  # ]:          0 :                             pTmp = pTmp->FindMaster();
    1435                 :            :                             OSL_ENSURE( pTmp, "Where's my Master?" );
    1436                 :          0 :                         } while( pTmp->IsFollow() );
    1437                 :          0 :                         pAnchor = pTmp;
    1438                 :            :                     }
    1439 [ #  # ][ #  # ]:          0 :                     if( pOldObj->ISA( SdrCaptionObj ))
                 [ #  # ]
    1440         [ #  # ]:          0 :                         aNullPt = ((SdrCaptionObj*)pOldObj)->GetTailPos();
    1441                 :            :                     else
    1442                 :          0 :                         aNullPt = aOldObjRect.TopLeft();
    1443                 :            : 
    1444 [ #  # ][ #  # ]:          0 :                     Point aNewAnchor = pAnchor->GetFrmAnchorPos( ::HasWrap( pOldObj ) );
    1445                 :            :                     // OD 2004-04-05 #i26791# - direct positioning of Writer
    1446                 :            :                     // fly frame object for <SwDoc::Insert(..)>
    1447         [ #  # ]:          0 :                     pNewObj->NbcSetRelativePos( aNullPt - aNewAnchor );
    1448         [ #  # ]:          0 :                     pNewObj->NbcSetAnchorPos( aNewAnchor );
    1449                 :            : 
    1450         [ #  # ]:          0 :                     pOldObj->GetOrdNum();
    1451                 :            : 
    1452         [ #  # ]:          0 :                     DelSelectedObj();
    1453                 :            : 
    1454 [ #  # ][ #  # ]:          0 :                     pFmt = GetDoc()->Insert( *GetCrsr(), *pNewObj, &aFrmSet, NULL );
                 [ #  # ]
    1455                 :            :                 }
    1456                 :            :                 else
    1457         [ #  # ]:          0 :                     pView->ReplaceObjectAtView( pOldObj, *Imp()->GetPageView(), pNewObj, sal_True );
    1458                 :            :             }
    1459                 :          0 :             break;
    1460                 :            : 
    1461                 :            :         case SW_PASTESDR_SETATTR:
    1462                 :            :             {
    1463 [ #  # ][ #  # ]:          0 :                 SfxItemSet aSet( GetAttrPool() );
    1464 [ #  # ][ #  # ]:          0 :                 aSet.Put(pClpObj->GetMergedItemSet());
    1465 [ #  # ][ #  # ]:          0 :                 pView->SetAttributes( aSet, sal_False );
    1466                 :            :             }
    1467                 :          0 :             break;
    1468                 :            : 
    1469                 :            :         default:
    1470                 :          0 :             nAction = SW_PASTESDR_INSERT;
    1471                 :          0 :             break;
    1472                 :            :         }
    1473                 :            :     }
    1474                 :            :     else
    1475                 :          0 :         nAction = SW_PASTESDR_INSERT;
    1476                 :            : 
    1477         [ #  # ]:          0 :     if( SW_PASTESDR_INSERT == nAction )
    1478                 :            :     {
    1479 [ #  # ][ #  # ]:          0 :         ::sw::DrawUndoGuard drawUndoGuard(GetDoc()->GetIDocumentUndoRedo());
    1480                 :            : 
    1481                 :          0 :         sal_Bool bDesignMode = pView->IsDesignMode();
    1482         [ #  # ]:          0 :         if( !bDesignMode )
    1483         [ #  # ]:          0 :             pView->SetDesignMode( sal_True );
    1484                 :            : 
    1485                 :            :         // #i50824#
    1486                 :            :         // method <lcl_RemoveOleObjsFromSdrModel> replaced by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
    1487         [ #  # ]:          0 :         lcl_ConvertSdrOle2ObjsToSdrGrafObjs( pModel );
    1488         [ #  # ]:          0 :         pView->Paste( *pModel, aPos );
    1489                 :            : 
    1490                 :          0 :         sal_uLong nCnt = pView->GetMarkedObjectList().GetMarkCount();
    1491         [ #  # ]:          0 :         if( nCnt )
    1492                 :            :         {
    1493                 :          0 :             const Point aNull( 0, 0 );
    1494         [ #  # ]:          0 :             for( sal_uLong i=0; i < nCnt; ++i )
    1495                 :            :             {
    1496 [ #  # ][ #  # ]:          0 :                 SdrObject *pObj = pView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
    1497         [ #  # ]:          0 :                 pObj->ImpSetAnchorPos( aNull );
    1498                 :            :             }
    1499                 :            : 
    1500         [ #  # ]:          0 :             pView->SetCurrentObj( OBJ_GRUP, SdrInventor );
    1501         [ #  # ]:          0 :             if ( nCnt > 1 )
    1502         [ #  # ]:          0 :                 pView->GroupMarked();
    1503 [ #  # ][ #  # ]:          0 :             SdrObject *pObj = pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
    1504 [ #  # ][ #  # ]:          0 :             if( pObj->ISA( SdrUnoObj ) )
                 [ #  # ]
    1505                 :            :             {
    1506 [ #  # ][ #  # ]:          0 :                 pObj->SetLayer( GetDoc()->GetControlsId() );
    1507                 :          0 :                 bDesignMode = sal_True;
    1508                 :            :             }
    1509                 :            :             else
    1510 [ #  # ][ #  # ]:          0 :                 pObj->SetLayer( GetDoc()->GetHeavenId() );
    1511         [ #  # ]:          0 :             const Rectangle &rSnap = pObj->GetSnapRect();
    1512 [ #  # ][ #  # ]:          0 :             const Size aDiff( rSnap.GetWidth()/2, rSnap.GetHeight()/2 );
    1513         [ #  # ]:          0 :             pView->MoveMarkedObj( aDiff );
    1514         [ #  # ]:          0 :             ImpEndCreate();
    1515         [ #  # ]:          0 :             if( !bDesignMode )
    1516         [ #  # ]:          0 :                 pView->SetDesignMode( sal_False );
    1517         [ #  # ]:          0 :         }
    1518                 :            :     }
    1519         [ #  # ]:          0 :     EndUndo();
    1520         [ #  # ]:          0 :     EndAllAction();
    1521 [ #  # ][ #  # ]:          0 :     delete pModel;
         [ #  # ][ #  # ]
    1522                 :          0 : }
    1523                 :            : 
    1524                 :          0 : sal_Bool SwFEShell::Paste( const Graphic &rGrf )
    1525                 :            : {
    1526         [ #  # ]:          0 :     SET_CURR_SHELL( this );
    1527                 :            :     SdrObject* pObj;
    1528                 :          0 :     SdrView *pView = Imp()->GetDrawView();
    1529                 :            : 
    1530                 :          0 :     sal_Bool bRet = 1 == pView->GetMarkedObjectList().GetMarkCount() &&
    1531 [ #  # ][ #  # ]:          0 :         (pObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj())->IsClosedObj() &&
    1532 [ #  # ][ #  # ]:          0 :         !pObj->ISA( SdrOle2Obj );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1533                 :            : 
    1534         [ #  # ]:          0 :     if( bRet )
    1535                 :            :     {
    1536 [ #  # ][ #  # ]:          0 :         XOBitmap aXOBitmap( rGrf.GetBitmap() );
                 [ #  # ]
    1537 [ #  # ][ #  # ]:          0 :         SfxItemSet aSet( GetAttrPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP );
    1538 [ #  # ][ #  # ]:          0 :         aSet.Put( XFillStyleItem( XFILL_BITMAP ));
                 [ #  # ]
    1539 [ #  # ][ #  # ]:          0 :         aSet.Put( XFillBitmapItem( aEmptyStr, aXOBitmap ));
                 [ #  # ]
    1540 [ #  # ][ #  # ]:          0 :         pView->SetAttributes( aSet, sal_False );
                 [ #  # ]
    1541                 :            :     }
    1542         [ #  # ]:          0 :     return bRet;
    1543                 :            : }
    1544                 :            : 
    1545                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10