1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fecopy.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
38 #define NEEDED_BY_FESHVIEW
42 #include <vcl/graph.hxx>
44 #include <sot/formats.hxx>
45 #include <sot/storage.hxx>
46 #include <svtools/pathoptions.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include <sfx2/viewsh.hxx>
49 #include <svx/xexch.hxx>
50 #include <svx/xflasit.hxx>
51 #include <svx/xfillit0.hxx>
52 #include <svx/xflclit.hxx>
53 #include <svx/brshitem.hxx>
54 #include <svx/svdocapt.hxx>
55 #include <svx/svdouno.hxx>
56 #include <svx/xfillit.hxx>
57 #include <svx/svdpage.hxx>
58 #include <svx/svdogrp.hxx>
59 #include <svx/xoutbmp.hxx>
60 #include <svx/svdoole2.hxx>
61 #ifndef _FM_FMMODEL_HXX
62 #include <svx/fmmodel.hxx>
64 #include <svx/unomodel.hxx>
65 // --> OD 2005-08-03 #i50824#
66 #include <svx/svditer.hxx>
68 // --> OD 2006-03-01 #b6382898#
69 #include <svx/svdograf.hxx>
71 #include <unotools/streamwrap.hxx>
72 #include <fmtanchr.hxx>
73 #include <fmtcntnt.hxx>
74 #include <fmtornt.hxx>
75 #include <fmtflcnt.hxx>
79 #include <txtflcnt.hxx>
82 #include <rootfrm.hxx>
86 #include <swtable.hxx>
88 #include <pagefrm.hxx>
92 #include <viewimp.hxx>
94 #include <dcontact.hxx>
95 #include <dflyobj.hxx>
99 #include <pagedesc.hxx>
100 #include <mvsave.hxx>
101 #include <vcl/virdev.hxx>
104 using namespace ::com::sun::star
;
106 /*************************************************************************
108 |* SwFEShell::Copy() Copy fuer das Interne Clipboard.
109 |* Kopiert alle Selektionen in das Clipboard.
111 |* Ersterstellung JP ??
112 |* Letzte Aenderung MA 22. Feb. 95
114 |*************************************************************************/
116 BOOL
SwFEShell::Copy( SwDoc
* pClpDoc
, const String
* pNewClpTxt
)
118 ASSERT( pClpDoc
, "kein Clipboard-Dokument" );
120 pClpDoc
->DoUndo( FALSE
); // immer auf FALSE !!
122 // steht noch Inhalt im ClpDocument, dann muss dieser geloescht werden
123 SwNodeIndex
aSttIdx( pClpDoc
->GetNodes().GetEndOfExtras(), 2 );
124 SwTxtNode
* pTxtNd
= aSttIdx
.GetNode().GetTxtNode();
125 if( !pTxtNd
|| pTxtNd
->GetTxt().Len() ||
126 aSttIdx
.GetIndex()+1 != pClpDoc
->GetNodes().GetEndOfContent().GetIndex() )
128 pClpDoc
->GetNodes().Delete( aSttIdx
,
129 pClpDoc
->GetNodes().GetEndOfContent().GetIndex() - aSttIdx
.GetIndex() );
130 pTxtNd
= pClpDoc
->GetNodes().MakeTxtNode( aSttIdx
,
131 (SwTxtFmtColl
*)pClpDoc
->GetDfltTxtFmtColl() );
135 // stehen noch FlyFrames rum, loesche auch diese
136 for( USHORT n
= 0; n
< pClpDoc
->GetSpzFrmFmts()->Count(); ++n
)
138 SwFlyFrmFmt
* pFly
= (SwFlyFrmFmt
*)(*pClpDoc
->GetSpzFrmFmts())[n
];
139 pClpDoc
->DelLayoutFmt( pFly
);
141 pClpDoc
->GCFieldTypes(); // loesche die FieldTypes
143 // wurde ein String uebergeben, so kopiere diesen in das Clipboard-
144 // Dokument. Somit kann auch der Calculator das interne Clipboard
148 pTxtNd
->Insert( *pNewClpTxt
, SwIndex( pTxtNd
) );
149 return TRUE
; // das wars.
152 pClpDoc
->LockExpFlds();
153 pClpDoc
->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES
);
156 // soll ein FlyFrame kopiert werden ?
157 if( IsFrmSelected() )
159 // hole das FlyFormat
160 SwFlyFrm
* pFly
= FindFlyFrm();
161 SwFrmFmt
* pFlyFmt
= pFly
->GetFmt();
162 SwFmtAnchor
aAnchor( pFlyFmt
->GetAnchor() );
164 if ( FLY_AT_CNTNT
== aAnchor
.GetAnchorId() ||
165 FLY_AUTO_CNTNT
== aAnchor
.GetAnchorId() ||
166 FLY_AT_FLY
== aAnchor
.GetAnchorId() ||
167 FLY_IN_CNTNT
== aAnchor
.GetAnchorId() )
169 SwPosition
aPos( aSttIdx
);
170 if( FLY_IN_CNTNT
== aAnchor
.GetAnchorId() )
171 aPos
.nContent
.Assign( pTxtNd
, 0 );
172 aAnchor
.SetAnchor( &aPos
);
174 pFlyFmt
= pClpDoc
->CopyLayoutFmt( *pFlyFmt
, aAnchor
, true, true );
176 // sorge dafuer das das "RootFmt" als erstes im SpzArray-steht
177 // (Es wurden ggf. Flys in Flys kopiert.
178 SwSpzFrmFmts
& rSpzFrmFmts
= *(SwSpzFrmFmts
*)pClpDoc
->GetSpzFrmFmts();
179 if( rSpzFrmFmts
[ 0 ] != pFlyFmt
)
181 USHORT nPos
= rSpzFrmFmts
.GetPos( pFlyFmt
);
182 ASSERT( nPos
!= USHRT_MAX
, "Fly steht nicht im Spz-Array" );
184 rSpzFrmFmts
.Remove( nPos
);
185 rSpzFrmFmts
.Insert( pFlyFmt
, 0 );
188 if( FLY_IN_CNTNT
== aAnchor
.GetAnchorId() )
190 // JP 13.02.99 Bug 61863: wenn eine Rahmenselektion ins Clipboard
191 // gestellt wird, so muss beim Pasten auch wieder
192 // eine solche vorgefunden werden. Also muss im Node
193 // das kopierte TextAttribut wieder entfernt werden,
194 // sonst wird es als TextSelektion erkannt
195 const SwIndex
& rIdx
= pFlyFmt
->GetAnchor().GetCntntAnchor()->nContent
;
196 SwTxtFlyCnt
* pTxtFly
= (SwTxtFlyCnt
*)pTxtNd
->GetTxtAttr(
197 rIdx
, RES_TXTATR_FLYCNT
);
200 ((SwFmtFlyCnt
&)pTxtFly
->GetFlyCnt()).SetFlyFmt( 0 );
201 pTxtNd
->Erase( rIdx
, 1 );
206 else if ( IsObjSelected() )
208 SwPosition
aPos( aSttIdx
, SwIndex( pTxtNd
, 0 ));
209 const SdrMarkList
&rMrkList
= Imp()->GetDrawView()->GetMarkedObjectList();
210 for ( USHORT i
= 0; i
< rMrkList
.GetMarkCount(); ++i
)
212 SdrObject
*pObj
= rMrkList
.GetMark( i
)->GetMarkedSdrObj();
214 if( Imp()->GetDrawView()->IsGroupEntered() ||
215 ( !pObj
->GetUserCall() && pObj
->GetUpGroup()) )
217 SfxItemSet
aSet( pClpDoc
->GetAttrPool(), aFrmFmtSetRange
);
219 SwFmtAnchor
aAnchor( FLY_AT_CNTNT
);
220 aAnchor
.SetAnchor( &aPos
);
223 SdrObject
* pNew
= pClpDoc
->CloneSdrObj( *pObj
, FALSE
, TRUE
);
226 pClpDoc
->Insert(aTemp
, *pNew
, &aSet
, NULL
);
230 SwDrawContact
*pContact
= (SwDrawContact
*)GetUserCall( pObj
);
231 SwFrmFmt
*pFmt
= pContact
->GetFmt();
232 SwFmtAnchor
aAnchor( pFmt
->GetAnchor() );
233 if ( FLY_AT_CNTNT
== aAnchor
.GetAnchorId() ||
234 FLY_AUTO_CNTNT
== aAnchor
.GetAnchorId() ||
235 FLY_AT_FLY
== aAnchor
.GetAnchorId() ||
236 FLY_IN_CNTNT
== aAnchor
.GetAnchorId() )
238 aAnchor
.SetAnchor( &aPos
);
241 pClpDoc
->CopyLayoutFmt( *pFmt
, aAnchor
, true, true );
247 bRet
= _CopySelToDoc( pClpDoc
, 0 ); // kopiere die Selectionen
249 pClpDoc
->SetRedlineMode_intern((RedlineMode_t
)0 );
250 pClpDoc
->UnlockExpFlds();
251 if( !pClpDoc
->IsExpFldsLocked() )
252 pClpDoc
->UpdateExpFlds(NULL
, true);
257 const Point
&lcl_FindBasePos( const SwFrm
*pFrm
, const Point
&rPt
)
259 const SwFrm
*pF
= pFrm
;
260 while ( pF
&& !pF
->Frm().IsInside( rPt
) )
262 if ( pF
->IsCntntFrm() )
263 pF
= ((SwCntntFrm
*)pF
)->GetFollow();
268 return pF
->Frm().Pos();
270 return pFrm
->Frm().Pos();
273 BOOL
lcl_SetAnchor( const SwPosition
& rPos
, const SwNode
& rNd
, SwFlyFrm
* pFly
,
274 const Point
& rInsPt
, SwFEShell
& rDestShell
, SwFmtAnchor
& rAnchor
,
275 Point
& rNewPos
, BOOL bCheckFlyRecur
)
278 rAnchor
.SetAnchor( &rPos
);
279 SwCntntFrm
* pTmpFrm
= rNd
.GetCntntNode()->GetFrm( &rInsPt
, 0, FALSE
);
280 SwFlyFrm
*pTmpFly
= pTmpFrm
->FindFlyFrm();
281 if( pTmpFly
&& bCheckFlyRecur
&& pFly
->IsUpperOf( *pTmpFly
) )
283 else if ( FLY_AT_FLY
== rAnchor
.GetAnchorId() )
287 const SwNodeIndex
& rIdx
= *pTmpFly
->GetFmt()->GetCntnt().GetCntntIdx();
288 SwPosition
aPos( rIdx
);
289 rAnchor
.SetAnchor( &aPos
);
290 rNewPos
= pTmpFly
->Frm().Pos();
294 rAnchor
.SetType( FLY_PAGE
);
295 rAnchor
.SetPageNum( rDestShell
.GetPageNumber( rInsPt
) );
296 const SwFrm
*pPg
= pTmpFrm
->FindPageFrm();
297 rNewPos
= pPg
->Frm().Pos();
301 rNewPos
= ::lcl_FindBasePos( pTmpFrm
, rInsPt
);
305 BOOL
SwFEShell::CopyDrawSel( SwFEShell
* pDestShell
, const Point
& rSttPt
,
306 const Point
& rInsPt
, BOOL bIsMove
, BOOL bSelectInsert
)
310 //Die Liste muss kopiert werden, weil unten die neuen Objekte
312 const SdrMarkList
aMrkList( Imp()->GetDrawView()->GetMarkedObjectList() );
313 ULONG nMarkCount
= aMrkList
.GetMarkCount();
314 if( !pDestShell
->Imp()->GetDrawView() )
315 // sollte mal eine erzeugt werden
316 pDestShell
->MakeDrawView();
317 else if( bSelectInsert
)
318 pDestShell
->Imp()->GetDrawView()->UnmarkAll();
320 SdrPageView
*pDestPgView
= pDestShell
->Imp()->GetPageView(),
321 *pSrcPgView
= Imp()->GetPageView();
322 SwDrawView
*pDestDrwView
= pDestShell
->Imp()->GetDrawView(),
323 *pSrcDrwView
= Imp()->GetDrawView();
324 SwDoc
* pDestDoc
= pDestShell
->GetDoc();
326 Size
aSiz( rInsPt
.X() - rSttPt
.X(), rInsPt
.Y() - rSttPt
.Y() );
327 for( USHORT i
= 0; i
< nMarkCount
; ++i
)
329 SdrObject
*pObj
= aMrkList
.GetMark( i
)->GetMarkedSdrObj();
331 SwDrawContact
*pContact
= (SwDrawContact
*)GetUserCall( pObj
);
332 SwFrmFmt
*pFmt
= pContact
->GetFmt();
333 const SwFmtAnchor
& rAnchor
= pFmt
->GetAnchor();
335 BOOL bInsWithFmt
= TRUE
;
337 if( pDestDrwView
->IsGroupEntered() )
339 // in die Gruppe einfuegen, wenns aus einer betretenen Gruppe
340 // kommt oder das Object nicht zeichengebunden ist
341 if( pSrcDrwView
->IsGroupEntered() ||
342 FLY_IN_CNTNT
!= rAnchor
.GetAnchorId() )
345 SdrObject
* pNew
= pDestDoc
->CloneSdrObj( *pObj
, bIsMove
&&
346 GetDoc() == pDestDoc
, FALSE
);
347 pNew
->NbcMove( aSiz
);
348 pDestDrwView
->InsertObjectAtView( pNew
, *pDestPgView
);
355 SwFmtAnchor
aAnchor( rAnchor
);
358 if ( FLY_AT_CNTNT
== aAnchor
.GetAnchorId() ||
359 FLY_AUTO_CNTNT
== aAnchor
.GetAnchorId() ||
360 FLY_AT_FLY
== aAnchor
.GetAnchorId() ||
361 FLY_IN_CNTNT
== aAnchor
.GetAnchorId() )
363 if ( this == pDestShell
)
365 //gleiche Shell? Dann erfrage die Position an der
366 //uebergebenen DokumentPosition
367 SwPosition
aPos( *GetCrsr()->GetPoint() );
369 aPt
-= rSttPt
- pObj
->GetSnapRect().TopLeft();
370 SwCrsrMoveState
aState( MV_SETONLYTEXT
);
371 GetLayout()->GetCrsrOfst( &aPos
, aPt
, &aState
);
373 if( (pNd
= &aPos
.nNode
.GetNode())->IsNoTxtNode() )
376 bRet
= ::lcl_SetAnchor( aPos
, *pNd
, 0, rInsPt
,
377 *pDestShell
, aAnchor
, aNewAnch
, FALSE
);
381 SwPaM
*pCrsr
= pDestShell
->GetCrsr();
382 if( pCrsr
->GetNode()->IsNoTxtNode() )
385 bRet
= ::lcl_SetAnchor( *pCrsr
->GetPoint(),
386 *pCrsr
->GetNode(), 0, rInsPt
,
387 *pDestShell
, aAnchor
,
391 else if( FLY_PAGE
== aAnchor
.GetAnchorId() )
393 aAnchor
.SetPageNum( pDestShell
->GetPageNumber( rInsPt
) );
394 const SwRootFrm
* pTmpRoot
= pDestShell
->GetLayout();
395 const SwFrm
* pPg
= pTmpRoot
->GetPageAtPos( rInsPt
, 0, true );
397 aNewAnch
= pPg
->Frm().Pos();
402 if( pSrcDrwView
->IsGroupEntered() ||
403 ( !pObj
->GetUserCall() && pObj
->GetUpGroup()) )
405 SfxItemSet
aSet( pDestDoc
->GetAttrPool(),aFrmFmtSetRange
);
407 SdrObject
* pNew
= pDestDoc
->CloneSdrObj( *pObj
, bIsMove
&&
408 GetDoc() == pDestDoc
, TRUE
);
409 pFmt
= pDestDoc
->Insert( *pDestShell
->GetCrsr(),
410 *pNew
, &aSet
, NULL
);
413 pFmt
= pDestDoc
->CopyLayoutFmt( *pFmt
, aAnchor
, true, true );
415 //Kann 0 sein, weil Draws in Kopf-/Fusszeilen nicht erlaubt sind.
418 SdrObject
* pNew
= pFmt
->FindSdrObject();
419 if( FLY_IN_CNTNT
!= aAnchor
.GetAnchorId() )
421 Point
aPos( rInsPt
);
423 aPos
-= rSttPt
- pObj
->GetSnapRect().TopLeft();
424 // OD 2004-04-05 #i26791# - change attributes instead of
425 // direct positioning
426 pFmt
->SetFmtAttr( SwFmtHoriOrient( aPos
.X(), text::HoriOrientation::NONE
, text::RelOrientation::FRAME
) );
427 pFmt
->SetFmtAttr( SwFmtVertOrient( aPos
.Y(), text::VertOrientation::NONE
, text::RelOrientation::FRAME
) );
428 // --> OD 2005-04-15 #i47455# - notify draw frame format
429 // that position attributes are already set.
430 if ( pFmt
->ISA(SwDrawFrmFmt
) )
432 static_cast<SwDrawFrmFmt
*>(pFmt
)->PosAttrSet();
437 pDestDrwView
->MarkObj( pNew
, pDestPgView
);
443 if ( bIsMove
&& bRet
)
445 if( pDestShell
== this )
447 const SdrMarkList
aList( pSrcDrwView
->GetMarkedObjectList() );
448 pSrcDrwView
->UnmarkAll();
450 ULONG nMrkCnt
= aMrkList
.GetMarkCount();
452 for ( i
= 0; i
< nMrkCnt
; ++i
)
454 SdrObject
*pObj
= aMrkList
.GetMark( i
)->GetMarkedSdrObj();
455 pSrcDrwView
->MarkObj( pObj
, pSrcPgView
);
458 nMrkCnt
= aList
.GetMarkCount();
459 for ( i
= 0; i
< nMrkCnt
; ++i
)
461 SdrObject
*pObj
= aList
.GetMark( i
)->GetMarkedSdrObj();
462 pSrcDrwView
->MarkObj( pObj
, pSrcPgView
);
472 BOOL
SwFEShell::Copy( SwFEShell
* pDestShell
, const Point
& rSttPt
,
473 const Point
& rInsPt
, BOOL bIsMove
, BOOL bSelectInsert
)
477 ASSERT( pDestShell
, "Copy ohne DestShell." );
478 ASSERT( this == pDestShell
|| !pDestShell
->IsObjSelected(),
479 "Dest-Shell darf nie im Obj-Modus sein" );
481 SET_CURR_SHELL( pDestShell
);
483 pDestShell
->StartAllAction();
484 pDestShell
->GetDoc()->LockExpFlds();
486 // Referenzen sollen verschoben werden.
487 BOOL bCopyIsMove
= pDoc
->IsCopyIsMove();
489 // am Doc ein Flag setzen, damit in den TextNodes
490 pDoc
->SetCopyIsMove( TRUE
);
492 RedlineMode_t eOldRedlMode
= pDestShell
->GetDoc()->GetRedlineMode();
493 pDestShell
->GetDoc()->SetRedlineMode_intern( (RedlineMode_t
)(eOldRedlMode
| nsRedlineMode_t::REDLINE_DELETE_REDLINES
));
495 // sind Tabellen-Formeln im Bereich, dann muss erst die Tabelle
496 // angezeigt werden, damit die Tabellen-Formel den neuen Wert errechnen
497 // kann (bei Bereichen wird sich ueber das Layout die einzelnen Boxen
499 SwFieldType
* pTblFldTyp
= pDestShell
->GetDoc()->GetSysFldType( RES_TABLEFLD
);
501 if( IsFrmSelected() )
503 SwFlyFrm
* pFly
= FindFlyFrm();
504 SwFrmFmt
* pFlyFmt
= pFly
->GetFmt();
505 SwFmtAnchor
aAnchor( pFlyFmt
->GetAnchor() );
509 if ( FLY_AT_CNTNT
== aAnchor
.GetAnchorId() ||
510 FLY_AUTO_CNTNT
== aAnchor
.GetAnchorId() ||
511 FLY_AT_FLY
== aAnchor
.GetAnchorId() ||
512 FLY_IN_CNTNT
== aAnchor
.GetAnchorId() )
514 if ( this == pDestShell
)
516 // gleiche Shell? Dann erfrage die Position an der
517 // uebergebenen DokumentPosition
518 SwPosition
aPos( *GetCrsr()->GetPoint() );
520 aPt
-= rSttPt
- pFly
->Frm().Pos();
521 SwCrsrMoveState
aState( MV_SETONLYTEXT
);
522 GetLayout()->GetCrsrOfst( &aPos
, aPt
, &aState
);
524 if( (pNd
= &aPos
.nNode
.GetNode())->IsNoTxtNode() )
527 { //Nicht in sich selbst kopieren
528 const SwNodeIndex
*pTmp
= pFlyFmt
->GetCntnt().GetCntntIdx();
529 if ( aPos
.nNode
> *pTmp
&& aPos
.nNode
<
530 pTmp
->GetNode().EndOfSectionIndex() )
535 bRet
= ::lcl_SetAnchor( aPos
, *pNd
, pFly
, rInsPt
,
536 *pDestShell
, aAnchor
, aNewAnch
, TRUE
);
541 const SwPaM
*pCrsr
= pDestShell
->GetCrsr();
542 if( pCrsr
->GetNode()->IsNoTxtNode() )
545 bRet
= ::lcl_SetAnchor( *pCrsr
->GetPoint(), *pCrsr
->GetNode(),
546 pFly
, rInsPt
, *pDestShell
, aAnchor
,
547 aNewAnch
, GetDoc() == pDestShell
->GetDoc());
550 else if( FLY_PAGE
== aAnchor
.GetAnchorId() )
552 aAnchor
.SetPageNum( pDestShell
->GetPageNumber( rInsPt
) );
553 const SwRootFrm
* pTmpRoot
= pDestShell
->GetLayout();
554 const SwFrm
* pPg
= pTmpRoot
->GetPageAtPos( rInsPt
, 0, true );
556 aNewAnch
= pPg
->Frm().Pos();
559 ASSERT( !this, "was fuer ein Anchor ist es denn?" );
564 SwFrmFmt
*pOldFmt
= pFlyFmt
;
565 pFlyFmt
= pDestShell
->GetDoc()->CopyLayoutFmt( *pFlyFmt
, aAnchor
, true, true );
567 if( FLY_IN_CNTNT
!= aAnchor
.GetAnchorId() )
569 Point
aPos( rInsPt
);
571 aPos
-= rSttPt
- pFly
->Frm().Pos();
572 pFlyFmt
->SetFmtAttr( SwFmtHoriOrient( aPos
.X(),text::HoriOrientation::NONE
, text::RelOrientation::FRAME
) );
573 pFlyFmt
->SetFmtAttr( SwFmtVertOrient( aPos
.Y(),text::VertOrientation::NONE
, text::RelOrientation::FRAME
) );
576 const Point
aPt( pDestShell
->GetCrsrDocPos() );
579 GetDoc()->DelLayoutFmt( pOldFmt
);
581 // nur selektieren wenn es in der gleichen Shell verschoben/
585 SwFlyFrm
* pFlyFrm
= ((SwFlyFrmFmt
*)pFlyFmt
)->GetFrm( &aPt
, FALSE
);
588 //JP 12.05.98: sollte das nicht im SelectFlyFrm stehen???
589 pDestShell
->Imp()->GetDrawView()->UnmarkAll();
590 pDestShell
->SelectFlyFrm( *pFlyFrm
, TRUE
);
594 if( this != pDestShell
&& !pDestShell
->HasShFcs() )
595 pDestShell
->Imp()->GetDrawView()->hideMarkHandles();
598 else if ( IsObjSelected() )
599 bRet
= CopyDrawSel( pDestShell
, rSttPt
, rInsPt
, bIsMove
, bSelectInsert
);
600 else if( IsTableMode() )
602 // kopiere Teile aus einer Tabelle: lege eine Tabelle mit der Breite
603 // von der Originalen an und kopiere die selectierten Boxen.
604 // Die Groessen werden prozentual korrigiert.
606 // lasse ueber das Layout die Boxen suchen
607 const SwTableNode
* pTblNd
;
609 GetTblSel( *this, aBoxes
);
610 if( aBoxes
.Count() &&
611 0 != (pTblNd
= aBoxes
[0]->GetSttNd()->FindTableNode()) )
613 SwPosition
* pDstPos
= 0;
614 if( this == pDestShell
)
616 // gleiche Shell? Dann erzeuge einen Crsr an der
617 // uebergebenen DokumentPosition
618 pDstPos
= new SwPosition( *GetCrsr()->GetPoint() );
620 GetLayout()->GetCrsrOfst( pDstPos
, aPt
);
621 if( !pDstPos
->nNode
.GetNode().IsNoTxtNode() )
624 else if( !pDestShell
->GetCrsr()->GetNode()->IsNoTxtNode() )
626 pDstPos
= new SwPosition( *pDestShell
->GetCrsr()->GetPoint() );
632 if( GetDoc() == pDestShell
->GetDoc() )
635 bRet
= pDestShell
->GetDoc()->InsCopyOfTbl( *pDstPos
, aBoxes
,0,
636 bIsMove
&& this == pDestShell
&&
637 aBoxes
.Count() == pTblNd
->GetTable().
638 GetTabSortBoxes().Count(),
639 this != pDestShell
);
641 if( this != pDestShell
)
642 *pDestShell
->GetCrsr()->GetPoint() = *pDstPos
;
644 // wieder alle geparkten Crsr erzeugen?
645 if( GetDoc() == pDestShell
->GetDoc() )
648 // JP 16.04.99: Bug 64908 - InsPos setzen, damit der geparkte
649 // Cursor auf die EinfuegePos. positioniert wird
650 if( this == pDestShell
)
651 GetCrsrDocPos() = rInsPt
;
659 if( this == pDestShell
)
661 // gleiche Shell? Dann erfrage die Position an der
662 // uebergebenen DokumentPosition
663 SwPosition
aPos( *GetCrsr()->GetPoint() );
665 GetLayout()->GetCrsrOfst( &aPos
, aPt
);
666 bRet
= !aPos
.nNode
.GetNode().IsNoTxtNode();
668 else if( pDestShell
->GetCrsr()->GetNode()->IsNoTxtNode() )
672 bRet
= 0 != SwEditShell::Copy( pDestShell
);
675 pDestShell
->GetDoc()->SetRedlineMode_intern( eOldRedlMode
);
676 pDoc
->SetCopyIsMove( bCopyIsMove
);
678 // wurden neue Tabellenformeln eingefuegt ?
679 if( pTblFldTyp
->GetDepends() )
681 // alte Actions beenden; die Tabellen-Frames werden angelegt und
682 // eine SSelection kann erzeugt werden
684 for( nActCnt
= 0; pDestShell
->ActionPend(); ++nActCnt
)
685 pDestShell
->EndAllAction();
687 for( ; nActCnt
; --nActCnt
)
688 pDestShell
->StartAllAction();
690 pDestShell
->GetDoc()->UnlockExpFlds();
691 pDestShell
->GetDoc()->UpdateFlds(NULL
, false);
693 pDestShell
->EndAllAction();
697 /*************************************************************************
699 |* SwFEShell::Paste() Paste fuer das Interne Clipboard.
700 |* Kopiert den Inhalt vom Clipboard in das Dokument.
702 |* Ersterstellung JP ??
703 |* Letzte Aenderung MA 22. Feb. 95
705 |*************************************************************************/
708 typedef boost::shared_ptr
<SwPaM
> PaMPtr
;
709 typedef boost::shared_ptr
<SwPosition
> PositionPtr
;
710 typedef std::pair
< PaMPtr
, PositionPtr
> Insertion
;
713 BOOL
SwFEShell::Paste( SwDoc
* pClpDoc
, BOOL bIncludingPageFrames
)
715 SET_CURR_SHELL( this );
716 ASSERT( pClpDoc
, "kein Clipboard-Dokument" );
717 const USHORT nStartPageNumber
= GetPhyPageNum();
718 // dann bis zum Ende vom Nodes Array
719 SwNodeIndex
aIdx( pClpDoc
->GetNodes().GetEndOfExtras(), 2 );
720 SwPaM
aCpyPam( aIdx
); //DocStart
722 // sind Tabellen-Formeln im Bereich, dann muss erst die Tabelle
723 // angezeigt werden, damit die Tabellen-Formel den neuen Wert errechnen
724 // kann (bei Bereichen wird sich ueber das Layout die einzelnen Boxen
726 SwFieldType
* pTblFldTyp
= GetDoc()->GetSysFldType( RES_TABLEFLD
);
728 SwTableNode
*pDestNd
, *pSrcNd
= aCpyPam
.GetNode()->GetTableNode();
729 if( !pSrcNd
) // TabellenNode ?
730 { // nicht ueberspringen!!
731 SwCntntNode
* pCNd
= aCpyPam
.GetNode()->GetCntntNode();
733 aCpyPam
.GetPoint()->nContent
.Assign( pCNd
, 0 );
734 else if( !aCpyPam
.Move( fnMoveForward
, fnGoNode
))
735 aCpyPam
.Move( fnMoveBackward
, fnGoNode
);
739 aCpyPam
.Move( fnMoveForward
, fnGoDoc
);
741 BOOL bRet
= TRUE
, bDelTbl
= TRUE
;
743 GetDoc()->StartUndo( UNDO_INSGLOSSARY
, NULL
);
744 GetDoc()->LockExpFlds();
746 // When the clipboard content has been created by a rectangular selection
747 // the pasting is more sophisticated:
748 // every paragraph will be inserted into another position.
749 // The first positions are given by the actual cursor ring,
750 // if there are more text portions to insert than cursor in this ring,
751 // the additional insert positions will be created by moving the last
752 // cursor position into the next line (like pressing the cursor down key)
753 if( pClpDoc
->IsColumnSelection() && !IsTableMode() )
755 // Creation of the list of insert positions
756 std::list
< Insertion
> aCopyList
;
757 // The number of text portions of the rectangular selection
758 const sal_uInt32 nSelCount
= aCpyPam
.GetPoint()->nNode
.GetIndex()
759 - aCpyPam
.GetMark()->nNode
.GetIndex();
760 sal_uInt32 nCount
= nSelCount
;
761 SwNodeIndex
aClpIdx( aIdx
);
762 SwPaM
* pStartCursor
= GetCrsr();
763 SwPaM
* pCurrCrsr
= pStartCursor
;
764 sal_uInt32 nCursorCount
= pStartCursor
->numberOf();
765 // If the target selection is a multi-selection, often the last and first
766 // cursor of the ring points to identical document positions. Then
767 // we should avoid double insertion of text portions...
768 while( nCursorCount
> 1 && *pCurrCrsr
->GetPoint() ==
769 *(dynamic_cast<SwPaM
*>(pCurrCrsr
->GetPrev())->GetPoint()) )
772 pCurrCrsr
= dynamic_cast<SwPaM
*>(pCurrCrsr
->GetNext());
773 pStartCursor
= pCurrCrsr
;
775 SwPosition
aStartPos( *pStartCursor
->GetPoint() );
776 SwPosition
aInsertPos( aStartPos
); // first insertion position
777 bool bCompletePara
= false;
782 ASSERT( aIdx
.GetNode().GetCntntNode(), "Who filled the clipboard?!" )
783 if( aIdx
.GetNode().GetCntntNode() ) // robust
785 Insertion
aInsertion( PaMPtr( new SwPaM( aIdx
) ),
786 PositionPtr( new SwPosition( aInsertPos
) ) );
788 aInsertion
.first
->SetMark();
789 if( pStartCursor
== pCurrCrsr
->GetNext() )
790 { // Now we have to look for insertion positions...
791 if( !nMove
) // Annotate the last given insert position
792 aStartPos
= aInsertPos
;
793 SwCursor
aCrsr( aStartPos
, 0, false);
794 // Check if we find another insert position by moving
795 // down the last given position
796 if( aCrsr
.UpDown( FALSE
, ++nMove
, 0, 0 ) )
797 aInsertPos
= *aCrsr
.GetPoint();
798 else // if there is no paragraph we have to create it
799 bCompletePara
= nCount
> 0;
802 else // as long as we find more insert positions in the cursor ring
804 pCurrCrsr
= dynamic_cast<SwPaM
*>(pCurrCrsr
->GetNext());
805 aInsertPos
= *pCurrCrsr
->GetPoint();
808 // If there are no more paragraphs e.g. at the end of a document,
809 // we insert complete paragraphs instead of text portions
811 aInsertion
.first
->GetPoint()->nNode
= aIdx
;
813 aInsertion
.first
->GetPoint()->nContent
=
814 aInsertion
.first
->GetCntntNode()->Len();
815 aCopyList
.push_back( aInsertion
);
817 // If there are no text portions left but there are some more
818 // cursor positions to fill we have to restart with the first
820 if( !nCount
&& nCursorCount
)
822 nCount
= std::min( nSelCount
, nCursorCount
);
823 aIdx
= aClpIdx
; // Start of clipboard content
826 std::list
< Insertion
>::const_iterator pCurr
= aCopyList
.begin();
827 std::list
< Insertion
>::const_iterator pEnd
= aCopyList
.end();
828 while( pCurr
!= pEnd
)
830 SwPosition
& rInsPos
= *pCurr
->second
;
831 SwPaM
& rCopy
= *pCurr
->first
;
832 const SwStartNode
* pBoxNd
= rInsPos
.nNode
.GetNode().FindTableBoxStartNode();
833 if( pBoxNd
&& 2 == pBoxNd
->EndOfSectionIndex() - pBoxNd
->GetIndex() &&
834 rCopy
.GetPoint()->nNode
!= rCopy
.GetMark()->nNode
)
836 // if more than one node will be copied into a cell
837 // the box attributes have to be removed
838 GetDoc()->ClearBoxNumAttrs( rInsPos
.nNode
);
841 SwNodeIndex
aIndexBefore(rInsPos
.nNode
);
843 pClpDoc
->Copy( rCopy
, rInsPos
, false );
846 SwPaM
aPaM(SwPosition(aIndexBefore
, 0),
847 SwPosition(rInsPos
.nNode
, 0));
848 aPaM
.GetDoc()->MakeUniqueNumRules(aPaM
);
851 SaveTblBoxCntnt( &rInsPos
);
857 FOREACHPAM_START(this)
860 0 != ( pDestNd
= GetDoc()->IsIdxInTbl( PCURCRSR
->GetPoint()->nNode
)))
862 SwPosition
aDestPos( *PCURCRSR
->GetPoint() );
864 BOOL bParkTblCrsr
= FALSE
;
865 const SwStartNode
* pSttNd
= PCURCRSR
->GetNode()->FindTableBoxStartNode();
867 // TABLE IN TABLE: Tabelle in Tabelle kopieren
868 // lasse ueber das Layout die Boxen suchen
870 if( IsTableMode() ) // Tabellen-Selecktion ??
872 GetTblSel( *this, aBoxes
);
876 else if( !PCURCRSR
->HasMark() && PCURCRSR
->GetNext() == PCURCRSR
&&
877 ( !pSrcNd
->GetTable().IsTblComplex() ||
878 pDestNd
->GetTable().IsNewModel() ) )
880 // dann die Tabelle "relativ" kopieren
881 SwTableBox
* pBox
= pDestNd
->GetTable().GetTblBox(
882 pSttNd
->GetIndex() );
883 ASSERT( pBox
, "Box steht nicht in dieser Tabelle" );
884 aBoxes
.Insert( pBox
);
887 SwNodeIndex
aNdIdx( *pDestNd
->EndOfSectionNode());
890 // erstmal aus der gesamten Tabelle raus
891 // ????? was ist mit Tabelle alleine im Rahmen ???????
892 SwCntntNode
* pCNd
= GetDoc()->GetNodes().GoNext( &aNdIdx
);
893 SwPosition
aPos( aNdIdx
, SwIndex( pCNd
, 0 ));
894 // #i59539: Don't remove all redline
895 ::PaMCorrAbs( SwNodeIndex( *pDestNd
),
896 SwNodeIndex( *pDestNd
->EndOfSectionNode() ),
900 bRet
= GetDoc()->InsCopyOfTbl( aDestPos
, aBoxes
, &pSrcNd
->GetTable(),
907 // und wieder in die Box zurueck
909 SwCntntNode
* pCNd
= GetDoc()->GetNodes().GoNext( &aNdIdx
);
910 SwPosition
aPos( aNdIdx
, SwIndex( pCNd
, 0 ));
911 // #i59539: Don't remove all redline
912 ::PaMCorrAbs( PCURCRSR
->GetPoint()->nNode
, aPos
);
915 break; // aus der "while"-Schleife heraus
917 else if( *aCpyPam
.GetPoint() == *aCpyPam
.GetMark() &&
918 pClpDoc
->GetSpzFrmFmts()->Count() )
920 // so langsam sollte mal eine DrawView erzeugt werden
921 if( !Imp()->GetDrawView() )
924 for ( USHORT i
= 0; i
< pClpDoc
->GetSpzFrmFmts()->Count(); ++i
)
926 BOOL bInsWithFmt
= TRUE
;
927 const SwFrmFmt
& rCpyFmt
= *(*pClpDoc
->GetSpzFrmFmts())[i
];
929 if( Imp()->GetDrawView()->IsGroupEntered() &&
930 RES_DRAWFRMFMT
== rCpyFmt
.Which() &&
931 FLY_IN_CNTNT
!= rCpyFmt
.GetAnchor().GetAnchorId() )
933 const SdrObject
* pSdrObj
= rCpyFmt
.FindSdrObject();
936 SdrObject
* pNew
= GetDoc()->CloneSdrObj( *pSdrObj
,
939 // Insert object sets any anchor position to 0.
940 // Therefore we calculate the absolute position here
941 // and after the insert the anchor of the object
942 // is set to the anchor of the group object.
943 Rectangle aSnapRect
= pNew
->GetSnapRect();
944 if( pNew
->GetAnchorPos().X() || pNew
->GetAnchorPos().Y() )
946 const Point
aPoint( 0, 0 );
947 // OD 2004-04-05 #i26791# - direct drawing object
948 // positioning for group members
949 pNew
->NbcSetAnchorPos( aPoint
);
950 pNew
->NbcSetSnapRect( aSnapRect
);
953 Imp()->GetDrawView()->InsertObjectAtView( pNew
, *Imp()->GetPageView() );
955 Point
aGrpAnchor( 0, 0 );
956 SdrObjList
* pList
= pNew
->GetObjList();
959 SdrObject
* pOwner
= pList
->GetOwnerObj();
962 SdrObjGroup
* pThisGroup
= PTR_CAST(SdrObjGroup
, pOwner
);
963 aGrpAnchor
= pThisGroup
->GetAnchorPos();
967 // OD 2004-04-05 #i26791# - direct drawing object
968 // positioning for group members
969 pNew
->NbcSetAnchorPos( aGrpAnchor
);
970 pNew
->SetSnapRect( aSnapRect
);
978 SwFmtAnchor
aAnchor( rCpyFmt
.GetAnchor() );
979 if( FLY_AT_CNTNT
== aAnchor
.GetAnchorId() ||
980 FLY_AUTO_CNTNT
== aAnchor
.GetAnchorId() ||
981 FLY_IN_CNTNT
== aAnchor
.GetAnchorId() )
983 SwPosition
* pPos
= PCURCRSR
->GetPoint();
984 // #108784# allow shapes (no controls) in header/footer
985 if( RES_DRAWFRMFMT
== rCpyFmt
.Which() &&
986 GetDoc()->IsInHeaderFooter( pPos
->nNode
) &&
987 CheckControlLayer( rCpyFmt
.FindSdrObject() ) )
990 aAnchor
.SetAnchor( pPos
);
992 else if( FLY_PAGE
== aAnchor
.GetAnchorId() )
994 aAnchor
.SetPageNum( GetPhyPageNum() );
996 else if( FLY_AT_FLY
== aAnchor
.GetAnchorId() )
999 lcl_SetAnchor( *PCURCRSR
->GetPoint(), *PCURCRSR
->GetNode(),
1000 0, aPt
, *this, aAnchor
, aPt
, FALSE
);
1003 SwFrmFmt
* pNew
= GetDoc()->CopyLayoutFmt( rCpyFmt
, aAnchor
, true, true );
1007 if( RES_FLYFRMFMT
== pNew
->Which() )
1009 const Point
aPt( GetCrsrDocPos() );
1010 SwFlyFrm
* pFlyFrm
= ((SwFlyFrmFmt
*)pNew
)->
1011 GetFrm( &aPt
, FALSE
);
1013 SelectFlyFrm( *pFlyFrm
, TRUE
);
1014 // immer nur den ersten Fly-Frame nehmen; die anderen
1015 // wurden ueber Fly in Fly ins ClipBoard kopiert !
1020 ASSERT( RES_DRAWFRMFMT
== pNew
->Which(), "Neues Format.");
1021 // --> OD 2005-09-01 #i52780# - drawing object has
1022 // to be made visible on paste.
1024 SwDrawContact
* pContact
=
1025 static_cast<SwDrawContact
*>(pNew
->FindContactObj());
1026 pContact
->MoveObjToVisibleLayer( pContact
->GetMaster() );
1029 SdrObject
*pObj
= pNew
->FindSdrObject();
1030 SwDrawView
*pDV
= Imp()->GetDrawView();
1031 pDV
->MarkObj( pObj
, pDV
->GetSdrPageView() );
1032 // --> OD 2005-04-15 #i47455# - notify draw frame format
1033 // that position attributes are already set.
1034 if ( pNew
->ISA(SwDrawFrmFmt
) )
1036 static_cast<SwDrawFrmFmt
*>(pNew
)->PosAttrSet();
1046 if( bDelTbl
&& IsTableMode() )
1048 SwEditShell::Delete();
1052 SwPosition
& rInsPos
= *PCURCRSR
->GetPoint();
1053 const SwStartNode
* pBoxNd
= rInsPos
.nNode
.GetNode().
1054 FindTableBoxStartNode();
1055 if( pBoxNd
&& 2 == pBoxNd
->EndOfSectionIndex() -
1056 pBoxNd
->GetIndex() &&
1057 aCpyPam
.GetPoint()->nNode
!= aCpyPam
.GetMark()->nNode
)
1059 // es wird mehr als 1 Node in die akt. Box kopiert. Dann
1060 // muessen die BoxAttribute aber entfernt werden.
1061 GetDoc()->ClearBoxNumAttrs( rInsPos
.nNode
);
1063 //find out if the clipboard document starts with a table
1064 bool bStartWithTable
= 0 != aCpyPam
.Start()->nNode
.GetNode().FindTableNode();
1065 SwPosition
aInsertPosition( rInsPos
);
1068 SwNodeIndex
aIndexBefore(rInsPos
.nNode
);
1072 pClpDoc
->Copy( aCpyPam
, rInsPos
, false );
1076 SwPaM
aPaM(SwPosition(aIndexBefore
, 0),
1077 SwPosition(rInsPos
.nNode
, 0));
1079 aPaM
.GetDoc()->MakeUniqueNumRules(aPaM
);
1083 SaveTblBoxCntnt( &rInsPos
);
1084 if(bIncludingPageFrames
&& bStartWithTable
)
1086 //remove the paragraph in front of the table
1087 SwPaM
aPara(aInsertPosition
);
1088 GetDoc()->DelFullPara(aPara
);
1090 //additionally copy page bound frames
1091 if( bIncludingPageFrames
&& pClpDoc
->GetSpzFrmFmts()->Count() )
1093 // create a draw view if necessary
1094 if( !Imp()->GetDrawView() )
1097 for ( USHORT i
= 0; i
< pClpDoc
->GetSpzFrmFmts()->Count(); ++i
)
1099 BOOL bInsWithFmt
= TRUE
;
1100 const SwFrmFmt
& rCpyFmt
= *(*pClpDoc
->GetSpzFrmFmts())[i
];
1103 SwFmtAnchor
aAnchor( rCpyFmt
.GetAnchor() );
1104 if( FLY_PAGE
== aAnchor
.GetAnchorId() )
1106 aAnchor
.SetPageNum( aAnchor
.GetPageNum() + nStartPageNumber
- 1 );
1110 GetDoc()->CopyLayoutFmt( rCpyFmt
, aAnchor
, true, true );
1119 GetDoc()->EndUndo( UNDO_INSGLOSSARY
, NULL
);
1121 // wurden neue Tabellenformeln eingefuegt ?
1122 if( pTblFldTyp
->GetDepends() )
1124 // alte Actions beenden; die Tabellen-Frames werden angelegt und
1125 // eine Selection kann erzeugt werden
1127 for( nActCnt
= 0; ActionPend(); ++nActCnt
)
1130 for( ; nActCnt
; --nActCnt
)
1133 GetDoc()->UnlockExpFlds();
1134 GetDoc()->UpdateFlds(NULL
, false);
1140 /*-- 14.06.2004 13:31:17---------------------------------------------------
1142 -----------------------------------------------------------------------*/
1143 BOOL
SwFEShell::PastePages( SwFEShell
& rToFill
, USHORT nStartPage
, USHORT nEndPage
)
1146 if(!GotoPage(nStartPage
))
1151 MovePage( fnPageCurr
, fnPageStart
);
1152 SwPaM
aCpyPam( *GetCrsr()->GetPoint() );
1153 String sStartingPageDesc
= GetPageDesc( GetCurPageDesc()).GetName();
1154 SwPageDesc
* pDesc
= rToFill
.FindPageDescByName( sStartingPageDesc
, TRUE
);
1156 rToFill
.ChgCurPageDesc( *pDesc
);
1158 if(!GotoPage(nEndPage
))
1163 //if the page starts with a table a paragraph has to be inserted before
1164 SwNode
* pTableNode
= aCpyPam
.GetNode()->FindTableNode();
1167 //insert a paragraph
1168 StartUndo(UNDO_INSERT
);
1169 SwNodeIndex
aTblIdx( *pTableNode
, -1 );
1170 SwPosition
aBefore(aTblIdx
);
1171 if(GetDoc()->AppendTxtNode( aBefore
))
1173 SwPaM
aTmp(aBefore
);
1176 EndUndo(UNDO_INSERT
);
1179 MovePage( fnPageCurr
, fnPageEnd
);
1181 *aCpyPam
.GetMark() = *GetCrsr()->GetPoint();
1183 SET_CURR_SHELL( this );
1186 GetDoc()->LockExpFlds();
1187 SetSelection(aCpyPam
);
1188 // copy the text of the selection
1189 SwEditShell::Copy(&rToFill
);
1193 //remove the inserted paragraph
1195 //remove the paragraph in the second doc, too
1196 SwNodeIndex
aIdx( rToFill
.GetDoc()->GetNodes().GetEndOfExtras(), 2 );
1197 SwPaM
aPara( aIdx
); //DocStart
1198 rToFill
.GetDoc()->DelFullPara(aPara
);
1200 // now the page bound objects
1201 //additionally copy page bound frames
1202 if( GetDoc()->GetSpzFrmFmts()->Count() )
1204 // create a draw view if necessary
1205 if( !rToFill
.Imp()->GetDrawView() )
1206 rToFill
.MakeDrawView();
1208 for ( USHORT i
= 0; i
< GetDoc()->GetSpzFrmFmts()->Count(); ++i
)
1210 const SwFrmFmt
& rCpyFmt
= *(*GetDoc()->GetSpzFrmFmts())[i
];
1211 SwFmtAnchor
aAnchor( rCpyFmt
.GetAnchor() );
1212 if( FLY_PAGE
== aAnchor
.GetAnchorId() &&
1213 aAnchor
.GetPageNum() >= nStartPage
&& aAnchor
.GetPageNum() <= nEndPage
)
1215 aAnchor
.SetPageNum( aAnchor
.GetPageNum() - nStartPage
+ 1);
1219 rToFill
.GetDoc()->CopyLayoutFmt( rCpyFmt
, aAnchor
, true, true );
1222 GetDoc()->UnlockExpFlds();
1223 GetDoc()->UpdateFlds(NULL
, false);
1230 BOOL
SwFEShell::GetDrawObjGraphic( ULONG nFmt
, Graphic
& rGrf
) const
1232 ASSERT( Imp()->HasDrawView(), "GetDrawObjGraphic without DrawView?" );
1233 const SdrMarkList
&rMrkList
= Imp()->GetDrawView()->GetMarkedObjectList();
1234 BOOL bConvert
= TRUE
;
1235 if( rMrkList
.GetMarkCount() )
1237 if( rMrkList
.GetMarkCount() == 1 &&
1238 rMrkList
.GetMark( 0 )->GetMarkedSdrObj()->ISA(SwVirtFlyDrawObj
) )
1240 // Rahmen selektiert
1241 if( CNT_GRF
== GetCntType() )
1243 // --> OD 2005-02-09 #119353# - robust
1244 const Graphic
* pGrf( GetGraphic() );
1247 Graphic
aGrf( *pGrf
);
1248 if( SOT_FORMAT_GDIMETAFILE
== nFmt
)
1250 if( GRAPHIC_BITMAP
!= aGrf
.GetType() )
1261 VirtualDevice aVirtDev
;
1262 aVirtDev
.EnableOutput( FALSE
);
1264 MapMode
aTmp( GetWin()->GetMapMode() );
1265 aTmp
.SetOrigin( aPt
);
1266 aVirtDev
.SetMapMode( aTmp
);
1269 aMtf
.Record( &aVirtDev
);
1270 aGrf
.Draw( &aVirtDev
, aPt
, aSz
);
1272 aMtf
.SetPrefMapMode( aTmp
);
1273 aMtf
.SetPrefSize( aSz
);
1277 else if( GRAPHIC_BITMAP
== aGrf
.GetType() )
1284 //fix(23806): Nicht die Originalgroesse, sondern die
1285 //aktuelle. Anderfalls kann es passieren, dass z.B. bei
1286 //Vektorgrafiken mal eben zig MB angefordert werden.
1287 const Size
aSz( FindFlyFrm()->Prt().SSize() );
1288 VirtualDevice
aVirtDev( *GetWin() );
1290 MapMode
aTmp( MAP_TWIP
);
1291 aVirtDev
.SetMapMode( aTmp
);
1292 if( aVirtDev
.SetOutputSize( aSz
) )
1294 aGrf
.Draw( &aVirtDev
, Point(), aSz
);
1295 rGrf
= aVirtDev
.GetBitmap( Point(), aSz
);
1307 else if( SOT_FORMAT_GDIMETAFILE
== nFmt
)
1308 rGrf
= Imp()->GetDrawView()->GetAllMarkedMetaFile();
1309 else if( SOT_FORMAT_BITMAP
== nFmt
)
1310 rGrf
= Imp()->GetDrawView()->GetAllMarkedBitmap();
1315 // --> OD 2005-08-03 #i50824#
1316 // --> OD 2006-03-01 #b6382898#
1317 // replace method <lcl_RemoveOleObjsFromSdrModel> by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1318 void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SdrModel
* _pModel
)
1320 for ( sal_uInt16 nPgNum
= 0; nPgNum
< _pModel
->GetPageCount(); ++nPgNum
)
1322 // setup object iterator in order to iterate through all objects
1323 // including objects in group objects, but exclusive group objects.
1324 SdrObjListIter
aIter(*(_pModel
->GetPage( nPgNum
)));
1325 while( aIter
.IsMore() )
1327 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( aIter
.Next() );
1330 // found an ole2 shape
1331 SdrObjList
* pObjList
= pOle2Obj
->GetObjList();
1335 pOle2Obj
->Connect();
1336 Graphic
* pGraphic
= pOle2Obj
->GetGraphic();
1338 aGraphic
= *pGraphic
;
1339 pOle2Obj
->Disconnect();
1341 // create new graphic shape with the ole graphic and shape size
1342 SdrGrafObj
* pGraphicObj
= new SdrGrafObj( aGraphic
, pOle2Obj
->GetCurrentBoundRect() );
1343 // apply layer of ole2 shape at graphic shape
1344 pGraphicObj
->SetLayer( pOle2Obj
->GetLayer() );
1346 // replace ole2 shape with the new graphic object and delete the ol2 shape
1347 SdrObject
* pRemovedObject
= pObjList
->ReplaceObject( pGraphicObj
, pOle2Obj
->GetOrdNum() );
1348 SdrObject::Free( pRemovedObject
);
1354 void SwFEShell::Paste( SvStream
& rStrm
, USHORT nAction
, const Point
* pPt
)
1356 SET_CURR_SHELL( this );
1360 SvtPathOptions aPathOpt
;
1361 FmFormModel
* pModel
= new FmFormModel( aPathOpt
.GetPalettePath(),
1362 0, GetDoc()->GetDocShell() );
1363 pModel
->GetItemPool().FreezeIdRanges();
1367 uno::Reference
< io::XInputStream
> xInputStream( new utl::OInputStreamWrapper( rStrm
) );
1368 SvxDrawingLayerImport( pModel
, xInputStream
);
1370 if ( !Imp()->HasDrawView() )
1371 Imp()->MakeDrawView();
1373 Point
aPos( pPt
? *pPt
: GetCharRect().Pos() );
1374 SdrView
*pView
= Imp()->GetDrawView();
1376 //Drop auf bestehendes Objekt: Objekt ersetzen oder neu Attributieren.
1377 if( pModel
->GetPageCount() > 0 &&
1378 1 == pModel
->GetPage(0)->GetObjCount() &&
1379 1 == pView
->GetMarkedObjectList().GetMarkCount() )
1381 // OD 10.07.2003 #110742# - replace a marked 'virtual' drawing object
1382 // by its corresponding 'master' drawing object in the mark list.
1383 SwDrawView::ReplaceMarkedDrawVirtObjs( *pView
);
1385 SdrObject
* pClpObj
= pModel
->GetPage(0)->GetObj(0);
1386 SdrObject
* pOldObj
= pView
->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
1388 if( SW_PASTESDR_SETATTR
== nAction
&& pOldObj
->ISA(SwVirtFlyDrawObj
) )
1389 nAction
= SW_PASTESDR_REPLACE
;
1393 case SW_PASTESDR_REPLACE
:
1395 const SwFrmFmt
* pFmt(0);
1396 const SwFrm
* pAnchor(0);
1397 if( pOldObj
->ISA(SwVirtFlyDrawObj
) )
1399 pFmt
= FindFrmFmt( pOldObj
);
1402 SwFlyFrm
* pFlyFrm
= ((SwFlyFrmFmt
*)pFmt
)->GetFrm( &aNullPt
);
1403 pAnchor
= pFlyFrm
->GetAnchorFrm();
1405 if( pAnchor
->FindFooterOrHeader() )
1407 // wenn TextRahmen in der Kopf/Fusszeile steht, dann
1408 // nicht ersetzen, sondern nur einfuegen
1409 nAction
= SW_PASTESDR_INSERT
;
1414 SdrObject
* pNewObj
= pClpObj
->Clone();
1415 Rectangle
aOldObjRect( pOldObj
->GetCurrentBoundRect() );
1416 Size
aOldObjSize( aOldObjRect
.GetSize() );
1417 Rectangle
aNewRect( pNewObj
->GetCurrentBoundRect() );
1418 Size
aNewSize( aNewRect
.GetSize() );
1420 Fraction
aScaleWidth( aOldObjSize
.Width(), aNewSize
.Width() );
1421 Fraction
aScaleHeight( aOldObjSize
.Height(), aNewSize
.Height());
1422 pNewObj
->NbcResize( aNewRect
.TopLeft(), aScaleWidth
, aScaleHeight
);
1424 Point aVec
= aOldObjRect
.TopLeft() - aNewRect
.TopLeft();
1425 pNewObj
->NbcMove(Size(aVec
.X(), aVec
.Y()));
1427 if( pNewObj
->ISA( SdrUnoObj
) )
1428 pNewObj
->SetLayer( GetDoc()->GetControlsId() );
1429 else if( pOldObj
->ISA( SdrUnoObj
) )
1430 pNewObj
->SetLayer( GetDoc()->GetHeavenId() );
1432 pNewObj
->SetLayer( pOldObj
->GetLayer() );
1434 if( pOldObj
->ISA(SwVirtFlyDrawObj
) )
1436 // Attribute sichern und dam SdrObject setzen
1437 SfxItemSet
aFrmSet( pDoc
->GetAttrPool(),
1438 RES_SURROUND
, RES_ANCHOR
);
1439 aFrmSet
.Set( pFmt
->GetAttrSet() );
1442 if( pAnchor
->IsTxtFrm() && ((SwTxtFrm
*)pAnchor
)->IsFollow() )
1444 const SwTxtFrm
* pTmp
= (SwTxtFrm
*)pAnchor
;
1446 pTmp
= pTmp
->FindMaster();
1447 ASSERT( pTmp
, "Where's my Master?" );
1448 } while( pTmp
->IsFollow() );
1451 if( pOldObj
->ISA( SdrCaptionObj
))
1452 aNullPt
= ((SdrCaptionObj
*)pOldObj
)->GetTailPos();
1454 aNullPt
= aOldObjRect
.TopLeft();
1456 Point aNewAnchor
= pAnchor
->GetFrmAnchorPos( ::HasWrap( pOldObj
) );
1457 // OD 2004-04-05 #i26791# - direct positioning of Writer
1458 // fly frame object for <SwDoc::Insert(..)>
1459 pNewObj
->NbcSetRelativePos( aNullPt
- aNewAnchor
);
1460 pNewObj
->NbcSetAnchorPos( aNewAnchor
);
1462 pOldObj
->GetOrdNum();
1466 pFmt
= GetDoc()->Insert( *GetCrsr(), *pNewObj
, &aFrmSet
, NULL
);
1469 pView
->ReplaceObjectAtView( pOldObj
, *Imp()->GetPageView(), pNewObj
, TRUE
);
1473 case SW_PASTESDR_SETATTR
:
1475 SfxItemSet
aSet( GetAttrPool() );
1476 aSet
.Put(pClpObj
->GetMergedItemSet());
1477 pView
->SetAttributes( aSet
, FALSE
);
1482 nAction
= SW_PASTESDR_INSERT
;
1487 nAction
= SW_PASTESDR_INSERT
;
1489 if( SW_PASTESDR_INSERT
== nAction
)
1491 GetDoc()->SetNoDrawUndoObj( TRUE
);
1493 sal_Bool bDesignMode
= pView
->IsDesignMode();
1495 pView
->SetDesignMode( sal_True
);
1497 // --> OD 2005-08-03 #i50824#
1498 // --> OD 2006-03-01 #b6382898#
1499 // method <lcl_RemoveOleObjsFromSdrModel> replaced by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1500 lcl_ConvertSdrOle2ObjsToSdrGrafObjs( pModel
);
1502 pView
->Paste( *pModel
, aPos
);
1504 ULONG nCnt
= pView
->GetMarkedObjectList().GetMarkCount();
1507 const Point
aNull( 0, 0 );
1508 for( ULONG i
=0; i
< nCnt
; ++i
)
1510 SdrObject
*pObj
= pView
->GetMarkedObjectList().GetMark(i
)->GetMarkedSdrObj();
1511 pObj
->ImpSetAnchorPos( aNull
);
1514 pView
->SetCurrentObj( OBJ_GRUP
, SdrInventor
);
1516 pView
->GroupMarked();
1517 SdrObject
*pObj
= pView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1518 if( pObj
->ISA( SdrUnoObj
) )
1520 pObj
->SetLayer( GetDoc()->GetControlsId() );
1521 bDesignMode
= sal_True
;
1524 pObj
->SetLayer( GetDoc()->GetHeavenId() );
1525 const Rectangle
&rSnap
= pObj
->GetSnapRect();
1526 const Size
aDiff( rSnap
.GetWidth()/2, rSnap
.GetHeight()/2 );
1527 pView
->MoveMarkedObj( aDiff
);
1530 pView
->SetDesignMode( sal_False
);
1532 GetDoc()->SetNoDrawUndoObj( FALSE
);
1539 BOOL
SwFEShell::Paste( const Graphic
&rGrf
)
1541 SET_CURR_SHELL( this );
1543 SdrView
*pView
= Imp()->GetDrawView();
1545 BOOL bRet
= 1 == pView
->GetMarkedObjectList().GetMarkCount() &&
1546 (pObj
= pView
->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj())->IsClosedObj() &&
1547 !pObj
->ISA( SdrOle2Obj
);
1551 XOBitmap
aXOBitmap( rGrf
.GetBitmap() );
1552 SfxItemSet
aSet( GetAttrPool(), XATTR_FILLSTYLE
, XATTR_FILLBITMAP
);
1553 aSet
.Put( XFillStyleItem( XFILL_BITMAP
));
1554 aSet
.Put( XFillBitmapItem( aEmptyStr
, aXOBitmap
));
1555 pView
->SetAttributes( aSet
, FALSE
);