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: swdtflvr.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"
38 #include <com/sun/star/embed/XVisualObject.hpp>
39 #include <com/sun/star/embed/XTransactedObject.hpp>
40 #include <com/sun/star/embed/Aspects.hpp>
41 #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
42 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
44 #include <svtools/embedtransfer.hxx>
45 #include <svtools/insdlg.hxx>
46 #include <unotools/tempfile.hxx>
47 #include <comphelper/storagehelper.hxx>
48 #include <comphelper/processfactory.hxx>
49 #include <unotools/ucbstreamhelper.hxx>
50 #include <sot/filelist.hxx>
51 #include <svx/svxdlg.hxx>
52 #include <toolkit/helper/vclunohelper.hxx>
53 #include <osl/endian.h>
54 #include <sfx2/linkmgr.hxx>
55 #include <tools/urlobj.hxx>
57 #include <vcl/wrkwin.hxx>
60 #include <vcl/msgbox.hxx>
62 #include <sfx2/dispatch.hxx>
63 #include <svtools/stritem.hxx>
64 #include <svtools/imap.hxx>
65 #include <sot/storage.hxx>
67 #include <vcl/graph.hxx>
69 #include <svtools/urihelper.hxx>
70 #include <svx/svdmodel.hxx>
71 #include <svx/xexch.hxx>
72 #include <svx/xmlexchg.hxx>
73 #include <svx/dbaexchange.hxx>
74 #include <svx/clipfmtitem.hxx>
75 #include <sfx2/mieclip.hxx>
76 #include <svx/svdetc.hxx>
77 #include <svx/xoutbmp.hxx>
78 #include <svtools/urlbmk.hxx>
79 #include <svtools/htmlout.hxx>
80 #include <svx/hlnkitem.hxx>
81 #include <svtools/inetimg.hxx>
82 #include <svx/paperinf.hxx>
83 #include <svx/fmview.hxx>
84 #include <svx/impgrf.hxx>
85 #include <svx/scripttypeitem.hxx>
86 #include <sfx2/docfilt.hxx>
87 #include <svtools/imapobj.hxx>
88 #include <sfx2/docfile.hxx>
89 #include <unotools/transliterationwrapper.hxx>
90 #include <unotools/streamwrap.hxx>
92 #include <svx/unomodel.hxx>
94 #include <fmtinfmt.hxx>
95 #include <fmtfsize.hxx>
96 #include <swdtflvr.hxx>
97 #include <shellio.hxx>
100 #include <pagedesc.hxx>
102 #include <docary.hxx>
103 #include <section.hxx>
105 #include <edtwin.hxx>
106 #include <navicont.hxx>
107 #include <swcont.hxx>
109 #include <swmodule.hxx>
117 #include <wdocsh.hxx>
119 #include <fldbas.hxx> //DDE
120 #include <swundo.hxx> // fuer Undo-Ids
123 #include <swwait.hxx>
124 #include <viewopt.hxx>
125 #include <swunodef.hxx>
126 #include <vcl/sound.hxx>
128 #include <SwCapObjType.hxx>
133 #include <dochdl.hrc>
136 #include <comcore.hrc> // #111827#
138 #include <sot/stg.hxx>
141 #include <svx/svditer.hxx>
144 #include <svx/eeitem.hxx>
147 #include <svx/fhgtitem.hxx>
150 #include <svx/svdpage.hxx>
151 #include <avmedia/mediawindow.hxx>
154 #include <swcrsr.hxx>
155 #include <SwRewriter.hxx>
156 #include <undobj.hxx>
158 #include <globals.hrc>
160 #include <vos/mutex.hxx>
161 #include <vcl/svapp.hxx>
162 #include <swserv.hxx>
164 extern BOOL bFrmDrag
;
165 extern BOOL bDDINetAttr
;
166 extern BOOL bExecuteDrag
;
169 #define OLESIZE 11905 - 2 * lMinBorder, 6 * MM50
171 #define SWTRANSFER_OBJECTTYPE_DRAWMODEL 0x00000001
172 #define SWTRANSFER_OBJECTTYPE_HTML 0x00000002
173 #define SWTRANSFER_OBJECTTYPE_RTF 0x00000004
174 #define SWTRANSFER_OBJECTTYPE_STRING 0x00000008
175 #define SWTRANSFER_OBJECTTYPE_SWOLE 0x00000010
176 #define SWTRANSFER_OBJECTTYPE_DDE 0x00000020
178 #define SWTRANSFER_GRAPHIC_INSERTED 0x00000040
180 using namespace ::svx
;
181 using ::rtl::OUString
;
182 using namespace ::com::sun::star
;
183 using namespace ::com::sun::star::uno
;
184 using namespace ::com::sun::star::datatransfer
;
185 using namespace nsTransferBufferType
;
187 #define DDE_TXT_ENCODING gsl_getSystemTextEncoding()
189 //---------------------------------------------
190 // this struct conforms to the Microsoft
191 // OBJECTDESCRIPTOR -> see oleidl.h
193 //---------------------------------------------
195 struct OleObjectDescriptor
199 sal_uInt32 dwDrawAspect
;
203 sal_uInt32 dwFullUserTypeName
;
204 sal_uInt32 dwSrcOfCopy
;
207 class SwTrnsfrDdeLink
: public ::sfx2::SvBaseLink
210 ::sfx2::SvLinkSourceRef refObj
;
211 SwTransferable
& rTrnsfr
;
212 SwDocShell
* pDocShell
;
214 BOOL bDelBookmrk
: 1;
215 BOOL bInDisconnect
: 1;
219 using sfx2::SvBaseLink::Disconnect
;
222 virtual ~SwTrnsfrDdeLink();
225 SwTrnsfrDdeLink( SwTransferable
& rTrans
, SwWrtShell
& rSh
);
227 virtual void DataChanged( const String
& rMimeType
,
228 const uno::Any
& rValue
);
229 virtual void Closed();
231 BOOL
WriteData( SvStream
& rStrm
);
233 void Disconnect( BOOL bRemoveDataAdvise
);
236 // helper class for Action and Undo enclosing
237 class SwTrnsfrActionAndUndo
242 SwTrnsfrActionAndUndo( SwWrtShell
*pS
, SwUndoId nId
,
243 const SwRewriter
* pRewriter
= 0,
244 BOOL bDelSel
= FALSE
)
245 : pSh( pS
), eUndoId( nId
)
247 pSh
->StartUndo( eUndoId
, pRewriter
);
250 pSh
->StartAllAction();
252 ~SwTrnsfrActionAndUndo()
254 pSh
->EndUndo( eUndoId
);
260 // -----------------------------------------------------------------------
262 SwTransferable::SwTransferable( SwWrtShell
& rSh
)
272 eBufferType( TRNSFR_NONE
)
274 rSh
.GetView().AddTransferable(*this);
275 SwDocShell
* pDShell
= rSh
.GetDoc()->GetDocShell();
278 pDShell
->FillTransferableObjectDescriptor( aObjDesc
);
279 if( pDShell
->GetMedium() )
281 const INetURLObject
& rURLObj
= pDShell
->GetMedium()->GetURLObject();
282 aObjDesc
.maDisplayName
= URIHelper::removePassword(
283 rURLObj
.GetMainURL( INetURLObject::NO_DECODE
),
284 INetURLObject::WAS_ENCODED
,
285 INetURLObject::DECODE_UNAMBIGUOUS
);
288 PrepareOLE( aObjDesc
);
292 // -----------------------------------------------------------------------
294 SwTransferable::~SwTransferable()
296 Application::GetSolarMutex().acquire();
298 // der DDELink braucht noch die WrtShell!
299 if( refDdeLink
.Is() )
301 ((SwTrnsfrDdeLink
*)&refDdeLink
)->Disconnect( TRUE
);
307 // dvo 2002-05-30, #99239#: release reference to the document so that
308 // aDocShellRef will delete it (if aDocShellRef is set). Otherwise, the OLE
309 // nodes keep references to their sub-storage when the storage is already
313 //JP 22.04.95: erst schliessen, dann kann die Ref. auch gecleared werden,
314 // so das die DocShell auch tatsaechlich geloescht wird!
315 if( aDocShellRef
.Is() )
317 SfxObjectShell
* pObj
= aDocShellRef
;
318 SwDocShell
* pDocSh
= (SwDocShell
*)pObj
;
321 aDocShellRef
.Clear();
323 SwModule
* pMod
= SW_MOD();
326 if ( pMod
->pClipboard
== this )
327 pMod
->pClipboard
= 0;
328 else if ( pMod
->pDragDrop
== this )
330 else if ( pMod
->pXSelection
== this )
331 pMod
->pXSelection
= 0;
341 eBufferType
= TRNSFR_NONE
;
343 Application::GetSolarMutex().release();
346 // -----------------------------------------------------------------------
348 void SwTransferable::ObjectReleased()
350 SwModule
*pMod
= SW_MOD();
351 if( this == pMod
->pClipboard
)
352 pMod
->pClipboard
= 0;
353 else if( this == pMod
->pDragDrop
)
355 else if( this == pMod
->pXSelection
)
356 pMod
->pXSelection
= 0;
359 // -----------------------------------------------------------------------
361 void SwTransferable::AddSupportedFormats()
363 // only need if we are the current XSelection Object
364 SwModule
*pMod
= SW_MOD();
365 if( this == pMod
->pXSelection
)
367 SetDataForDragAndDrop( Point( 0,0) );
371 // -----------------------------------------------------------------------
373 void SwTransferable::InitOle( SfxObjectShell
* pDoc
, SwDoc
& rDoc
)
375 //OleVisArea einstellen. Linke obere Ecke der Seite und Groesse
376 //der RealSize in Twips.
377 const Size
aSz( OLESIZE
);
378 SwRect
aVis( Point( DOCUMENTBORDER
, DOCUMENTBORDER
), aSz
);
379 pDoc
->SetVisArea( aVis
.SVRect() );
380 rDoc
.set(IDocumentSettingAccess::BROWSE_MODE
, true );
383 // -----------------------------------------------------------------------
385 uno::Reference
< embed::XEmbeddedObject
> SwTransferable::FindOLEObj( sal_Int64
& nAspect
) const
387 uno::Reference
< embed::XEmbeddedObject
> xObj
;
390 SwClientIter
aIter( *(SwModify
*)pClpDocFac
->GetDoc()->
391 GetDfltGrfFmtColl() );
392 for( SwCntntNode
* pNd
= (SwCntntNode
*)aIter
.First( TYPE( SwCntntNode
) );
393 pNd
; pNd
= (SwCntntNode
*)aIter
.Next() )
394 if( ND_OLENODE
== pNd
->GetNodeType() )
396 xObj
= ((SwOLENode
*)pNd
)->GetOLEObj().GetOleRef();
397 nAspect
= ((SwOLENode
*)pNd
)->GetAspect();
404 // -----------------------------------------------------------------------
406 Graphic
* SwTransferable::FindOLEReplacementGraphic() const
410 SwClientIter
aIter( *(SwModify
*)pClpDocFac
->GetDoc()->
411 GetDfltGrfFmtColl() );
412 for( SwCntntNode
* pNd
= (SwCntntNode
*)aIter
.First( TYPE( SwCntntNode
) );
413 pNd
; pNd
= (SwCntntNode
*)aIter
.Next() )
414 if( ND_OLENODE
== pNd
->GetNodeType() )
416 return ((SwOLENode
*)pNd
)->GetGraphic();
424 // -----------------------------------------------------------------------
426 void SwTransferable::RemoveDDELinkFormat( const Window
& rWin
)
428 RemoveFormat( SOT_FORMATSTR_ID_LINK
);
429 CopyToClipboard( (Window
*)&rWin
);
432 // -----------------------------------------------------------------------
434 sal_Bool
SwTransferable::GetData( const DATA_FLAVOR
& rFlavor
)
436 sal_uInt32 nFormat
= SotExchange::GetFormat( rFlavor
);
438 // we can only fullfil the request if
439 // 1) we have data for this format
440 // 2) we have either a clipboard document (pClpDocFac), or
441 // we have a SwWrtShell (so we can generate a new clipboard document)
442 if( !HasFormat( nFormat
) || ( pClpDocFac
== NULL
&& pWrtShell
== NULL
) )
447 SelectionType nSelectionType
= pWrtShell
->GetSelectionType();
449 // SEL_GRF kommt vom ContentType der editsh
450 if( (nsSelectionType::SEL_GRF
| nsSelectionType::SEL_DRW_FORM
) & nSelectionType
)
452 pClpGraphic
= new Graphic
;
453 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_GDIMETAFILE
, *pClpGraphic
))
454 pOrigGrf
= pClpGraphic
;
455 pClpBitmap
= new Graphic
;
456 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_BITMAP
, *pClpBitmap
))
457 pOrigGrf
= pClpBitmap
;
459 // ist es ein URL-Button ?
461 if( pWrtShell
->GetURLFromButton( sURL
, sDesc
) )
463 pBkmk
= new INetBookmark( sURL
, sDesc
);
464 eBufferType
= TRNSFR_INETFLD
;
468 pClpDocFac
= new SwDocFac
;
469 SwDoc
* pTmpDoc
= pClpDocFac
->GetDoc();
471 pTmpDoc
->SetRefForDocShell( boost::addressof(aDocShellRef
) );
472 pTmpDoc
->LockExpFlds(); // nie die Felder updaten - Text so belassen
473 pWrtShell
->Copy( pTmpDoc
);
475 // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
476 if( aDocShellRef
.Is() )
477 SwTransferable::InitOle( aDocShellRef
, *pTmpDoc
);
478 pTmpDoc
->SetRefForDocShell( 0 );
480 if( nSelectionType
& nsSelectionType::SEL_TXT
&& !pWrtShell
->HasMark() )
482 SwContentAtPos
aCntntAtPos( SwContentAtPos::SW_INETATTR
);
484 Point
aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
486 BOOL bSelect
= bExecuteDrag
&&
487 pWrtShell
->GetView().GetDocShell() &&
488 !pWrtShell
->GetView().GetDocShell()->IsReadOnly();
489 if( pWrtShell
->GetContentAtPos( aPos
, aCntntAtPos
, bSelect
) )
491 pBkmk
= new INetBookmark(
492 ((SwFmtINetFmt
*)aCntntAtPos
.aFnd
.pAttr
)->GetValue(),
494 eBufferType
= TRNSFR_INETFLD
;
496 pWrtShell
->SelectTxtAttr( RES_TXTATR_INETFMT
);
499 if( pWrtShell
->IsFrmSelected() )
501 SfxItemSet
aSet( pWrtShell
->GetAttrPool(), RES_URL
, RES_URL
);
502 pWrtShell
->GetFlyFrmAttr( aSet
);
503 const SwFmtURL
& rURL
= (SwFmtURL
&)aSet
.Get( RES_URL
);
505 pImageMap
= new ImageMap( *rURL
.GetMap() );
506 else if( rURL
.GetURL().Len() )
507 pTargetURL
= new INetImage( aEmptyStr
, rURL
.GetURL(),
508 rURL
.GetTargetFrameName(),
513 sal_Bool bOK
= sal_False
;
514 if( TRNSFR_OLE
== eBufferType
)
516 //TODO/MBA: testing - is this the "single OLE object" case?!
517 // aus dem ClipDoc das OLE-Object besorgen und von dem die Daten
519 sal_Int64 nAspect
= embed::Aspects::MSOLE_CONTENT
; // will be set in the next statement
520 uno::Reference
< embed::XEmbeddedObject
> xObj
= FindOLEObj( nAspect
);
521 Graphic
* pOLEGraph
= FindOLEReplacementGraphic();
524 TransferableDataHelper
aD( new SvEmbedTransferHelper( xObj
, pOLEGraph
, nAspect
) );
525 uno::Any
aAny( aD
.GetAny( rFlavor
));
526 if( aAny
.hasValue() )
527 bOK
= SetAny( aAny
, rFlavor
);
530 // the following solution will be used in the case when the object can not generate the image
531 // TODO/LATER: in future the transferhelper must probably be created based on object and the replacement stream
532 if ( nFormat
== SOT_FORMAT_GDIMETAFILE
)
534 pOLEGraph
= FindOLEReplacementGraphic();
536 bOK
= SetGDIMetaFile( pOLEGraph
->GetGDIMetaFile(), rFlavor
);
543 case SOT_FORMATSTR_ID_LINK
:
544 if( refDdeLink
.Is() )
545 bOK
= SetObject( &refDdeLink
,
546 SWTRANSFER_OBJECTTYPE_DDE
, rFlavor
);
549 case SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
:
550 case SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR
:
551 bOK
= SetTransferableObjectDescriptor( aObjDesc
, rFlavor
);
554 case SOT_FORMATSTR_ID_DRAWING
:
556 SwDoc
*pDoc
= pClpDocFac
->GetDoc();
557 ASSERT( pDoc
, "Document not found" );
558 bOK
= SetObject( pDoc
->GetDrawModel(),
559 SWTRANSFER_OBJECTTYPE_DRAWMODEL
, rFlavor
);
563 case SOT_FORMAT_STRING
:
565 SwDoc
* pDoc
= pClpDocFac
->GetDoc();
566 ASSERT( pDoc
, "Document not found" );
567 pDoc
->SetClipBoard( true );
568 bOK
= SetObject( pDoc
,
569 SWTRANSFER_OBJECTTYPE_STRING
, rFlavor
);
573 bOK
= SetObject( pClpDocFac
->GetDoc(),
574 SWTRANSFER_OBJECTTYPE_RTF
, rFlavor
);
577 case SOT_FORMATSTR_ID_HTML
:
578 bOK
= SetObject( pClpDocFac
->GetDoc(),
579 SWTRANSFER_OBJECTTYPE_HTML
, rFlavor
);
582 case SOT_FORMATSTR_ID_SVXB
:
583 if( eBufferType
& TRNSFR_GRAPHIC
&& pOrigGrf
)
584 bOK
= SetGraphic( *pOrigGrf
, rFlavor
);
587 case SOT_FORMAT_GDIMETAFILE
:
588 if( eBufferType
& TRNSFR_GRAPHIC
)
589 bOK
= SetGDIMetaFile( pClpGraphic
->GetGDIMetaFile(), rFlavor
);
591 case SOT_FORMAT_BITMAP
:
592 // #126398# Neither pClpBitmap nor pClpGraphic are necessarily set
593 if( (eBufferType
& TRNSFR_GRAPHIC
) && (pClpBitmap
!= 0 || pClpGraphic
!= 0))
594 bOK
= SetBitmap( (pClpBitmap
? pClpBitmap
595 : pClpGraphic
)->GetBitmap(),
599 case SOT_FORMATSTR_ID_SVIM
:
601 bOK
= SetImageMap( *pImageMap
, rFlavor
);
604 case SOT_FORMATSTR_ID_INET_IMAGE
:
606 bOK
= SetINetImage( *pTargetURL
, rFlavor
);
609 case SOT_FORMATSTR_ID_SOLK
:
610 case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
:
611 case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
:
612 case SOT_FORMATSTR_ID_FILECONTENT
:
613 case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
:
614 case SOT_FORMAT_FILE
:
615 if( (TRNSFR_INETFLD
& eBufferType
) && pBkmk
)
616 bOK
= SetINetBookmark( *pBkmk
, rFlavor
);
619 case SOT_FORMATSTR_ID_EMBED_SOURCE
:
621 if( !aDocShellRef
.Is() )
623 SwDoc
*pDoc
= pClpDocFac
->GetDoc();
624 SwDocShell
* pNewDocSh
= new SwDocShell( pDoc
,
625 SFX_CREATE_MODE_EMBEDDED
);
626 aDocShellRef
= pNewDocSh
;
627 aDocShellRef
->DoInitNew( NULL
);
628 SwTransferable::InitOle( aDocShellRef
, *pDoc
);
630 bOK
= SetObject( &aDocShellRef
, SWTRANSFER_OBJECTTYPE_SWOLE
,
638 // -----------------------------------------------------------------------
640 sal_Bool
SwTransferable::WriteObject( SotStorageStreamRef
& xStream
,
641 void* pObject
, sal_uInt32 nObjectType
,
642 const DATA_FLAVOR
& /*rFlavor*/ )
644 sal_Bool bRet
= sal_False
;
647 switch( nObjectType
)
649 case SWTRANSFER_OBJECTTYPE_DRAWMODEL
:
651 //JP 28.02.2001: dont change the sequence of commands - Bug 8
652 SdrModel
*pModel
= (SdrModel
*)pObject
;
653 xStream
->SetBufferSize( 16348 );
656 // for the changed pool defaults from drawing layer pool set those
657 // attributes as hard attributes to preserve them for saving
658 const SfxItemPool
& rItemPool
= pModel
->GetItemPool();
659 const SvxFontHeightItem
& rDefaultFontHeight
= (const SvxFontHeightItem
&)rItemPool
.GetDefaultItem(EE_CHAR_FONTHEIGHT
);
661 // SW should have no MasterPages
662 DBG_ASSERT(0L == pModel
->GetMasterPageCount(), "SW with MasterPages (!)");
664 for(sal_uInt16
a(0); a
< pModel
->GetPageCount(); a
++)
666 const SdrPage
* pPage
= pModel
->GetPage(a
);
667 SdrObjListIter
aIter(*pPage
, IM_DEEPNOGROUPS
);
669 while(aIter
.IsMore())
671 SdrObject
* pObj
= aIter
.Next();
672 const SvxFontHeightItem
& rItem
= (const SvxFontHeightItem
&)pObj
->GetMergedItem(EE_CHAR_FONTHEIGHT
);
674 if(rItem
.GetHeight() == rDefaultFontHeight
.GetHeight())
676 pObj
->SetMergedItem(rDefaultFontHeight
);
682 uno::Reference
<io::XOutputStream
> xDocOut( new utl::OOutputStreamWrapper( *xStream
) );
683 if( SvxDrawingLayerExport( pModel
, xDocOut
) )
687 bRet
= ERRCODE_NONE
== xStream
->GetError();
691 case SWTRANSFER_OBJECTTYPE_SWOLE
:
693 SfxObjectShell
* pEmbObj
= (SfxObjectShell
*) pObject
;
696 ::utl::TempFile aTempFile
;
697 aTempFile
.EnableKillingFile();
698 uno::Reference
< embed::XStorage
> xWorkStore
=
699 ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile
.GetURL(), embed::ElementModes::READWRITE
);
701 // write document storage
702 pEmbObj
->SetupStorage( xWorkStore
, SOFFICE_FILEFORMAT_CURRENT
, sal_False
);
703 // mba: no BaseURL for clipboard
704 SfxMedium
aMedium( xWorkStore
, String() );
705 bRet
= pEmbObj
->DoSaveObjectAs( aMedium
, FALSE
);
706 pEmbObj
->DoSaveCompleted();
708 uno::Reference
< embed::XTransactedObject
> xTransact( xWorkStore
, uno::UNO_QUERY
);
709 if ( xTransact
.is() )
712 SvStream
* pSrcStm
= ::utl::UcbStreamHelper::CreateStream( aTempFile
.GetURL(), STREAM_READ
);
715 xStream
->SetBufferSize( 0xff00 );
716 *xStream
<< *pSrcStm
;
722 xWorkStore
->dispose();
723 xWorkStore
= uno::Reference
< embed::XStorage
>();
726 catch ( uno::Exception
& )
729 bRet
= ( xStream
->GetError() == ERRCODE_NONE
);
734 case SWTRANSFER_OBJECTTYPE_DDE
:
736 xStream
->SetBufferSize( 1024 );
737 SwTrnsfrDdeLink
* pDdeLnk
= (SwTrnsfrDdeLink
*)pObject
;
738 if( pDdeLnk
->WriteData( *xStream
) )
741 bRet
= ERRCODE_NONE
== xStream
->GetError();
746 case SWTRANSFER_OBJECTTYPE_HTML
:
747 GetHTMLWriter( aEmptyStr
, String(), xWrt
);
750 case SWTRANSFER_OBJECTTYPE_RTF
:
751 GetRTFWriter( aEmptyStr
, String(), xWrt
);
754 case SWTRANSFER_OBJECTTYPE_STRING
:
755 GetASCWriter( aEmptyStr
, String(), xWrt
);
758 SwAsciiOptions aAOpt
;
759 aAOpt
.SetCharSet( RTL_TEXTENCODING_UTF8
);
760 xWrt
->SetAsciiOptions( aAOpt
);
762 // #102841# no start char for clipboard
763 xWrt
->bUCS2_WithStartChar
= FALSE
;
770 SwDoc
* pDoc
= (SwDoc
*)pObject
;
771 xWrt
->bWriteClipboardDoc
= TRUE
;
772 xWrt
->bWriteOnlyFirstTable
= 0 != (TRNSFR_TABELLE
& eBufferType
);
773 xWrt
->SetShowProgress( FALSE
);
774 SwWriter
aWrt( *xStream
, *pDoc
);
775 if( !IsError( aWrt
.Write( xWrt
)) )
777 *xStream
<< '\0'; // terminate with a zero
786 // -----------------------------------------------------------------------
788 int SwTransferable::Cut()
790 int nRet
= Copy( TRUE
);
796 // -----------------------------------------------------------------------
798 void SwTransferable::DeleteSelection()
802 // Selektionsart vor Action-Klammerung erfragen
803 const int nSelection
= pWrtShell
->GetSelectionType();
804 pWrtShell
->StartUndo( UNDO_DELETE
);
805 if( ( nsSelectionType::SEL_TXT
| nsSelectionType::SEL_TBL
) & nSelection
)
806 pWrtShell
->IntelligentCut( nSelection
);
807 pWrtShell
->DelRight();
808 pWrtShell
->EndUndo( UNDO_DELETE
);
811 // -----------------------------------------------------------------------
813 int SwTransferable::PrepareForCopy( BOOL bIsCut
)
820 const int nSelection
= pWrtShell
->GetSelectionType();
821 if( nSelection
== nsSelectionType::SEL_GRF
)
823 pClpGraphic
= new Graphic
;
824 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_GDIMETAFILE
, *pClpGraphic
))
825 pOrigGrf
= pClpGraphic
;
826 pClpBitmap
= new Graphic
;
827 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_BITMAP
, *pClpBitmap
))
828 pOrigGrf
= pClpBitmap
;
830 pClpDocFac
= new SwDocFac
;
831 pWrtShell
->Copy( pClpDocFac
->GetDoc() );
833 if (pOrigGrf
&& !pOrigGrf
->GetBitmap().IsEmpty())
834 AddFormat( SOT_FORMATSTR_ID_SVXB
);
836 PrepareOLE( aObjDesc
);
837 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
839 // --> OD 2005-02-09 #119353# - robust
840 const Graphic
* pGrf
= pWrtShell
->GetGraphic();
841 if( pGrf
&& pGrf
->IsSupportedGraphic() )
844 AddFormat( FORMAT_GDIMETAFILE
);
845 AddFormat( FORMAT_BITMAP
);
847 eBufferType
= TRNSFR_GRAPHIC
;
848 pWrtShell
->GetGrfNms( &sGrfNm
, 0 );
850 else if ( nSelection
== nsSelectionType::SEL_OLE
)
852 pClpDocFac
= new SwDocFac
;
853 SwDoc
*pDoc
= pClpDocFac
->GetDoc();
854 aDocShellRef
= new SwDocShell( pDoc
, SFX_CREATE_MODE_EMBEDDED
);
855 aDocShellRef
->DoInitNew( NULL
);
856 pWrtShell
->Copy( pDoc
);
858 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
860 PrepareOLE( aObjDesc
);
861 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
863 AddFormat( FORMAT_GDIMETAFILE
);
864 eBufferType
= TRNSFR_OLE
;
866 //Gibt es ueberhaupt etwas zum bereitstellen?
867 else if ( pWrtShell
->IsSelection() || pWrtShell
->IsFrmSelected() ||
868 pWrtShell
->IsObjSelected() )
871 if( pWrtShell
->ShouldWait() )
872 pWait
= new SwWait( *pWrtShell
->GetView().GetDocShell(), TRUE
);
874 pClpDocFac
= new SwDocFac
;
876 // zusaetzlichen Cursor erzeugen, damit eine Gleichbehandlung
877 // von Tastatur- und Mausselektion moeglich ist.
878 // Im AddMode wird bei Tastaturselektion der neue Cursor erst
879 // beim Bewegen des Cursors nach Selektionsende erzeugt.
880 if( pWrtShell
->IsAddMode() && pWrtShell
->SwCrsrShell::HasSelection() )
881 pWrtShell
->CreateCrsr();
883 SwDoc
* pTmpDoc
= pClpDocFac
->GetDoc();
884 pTmpDoc
->SetClipBoard( true );
886 pTmpDoc
->SetRefForDocShell( boost::addressof(aDocShellRef
) );
887 pTmpDoc
->LockExpFlds(); // nie die Felder updaten - Text so belassen
888 pWrtShell
->Copy( pTmpDoc
);
891 IDocumentMarkAccess
* const pMarkAccess
= pTmpDoc
->getIDocumentMarkAccess();
892 ::std::vector
< ::sw::mark::IMark
* > vDdeMarks
;
893 // find all DDE-Bookmarks
894 for(IDocumentMarkAccess::const_iterator_t ppMark
= pMarkAccess
->getMarksBegin();
895 ppMark
!= pMarkAccess
->getMarksEnd();
898 if(IDocumentMarkAccess::DDE_BOOKMARK
== IDocumentMarkAccess::GetType(**ppMark
))
899 vDdeMarks
.push_back(ppMark
->get());
901 // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
902 for(::std::vector
< ::sw::mark::IMark
* >::iterator ppMark
= vDdeMarks
.begin();
903 ppMark
!= vDdeMarks
.end();
905 pMarkAccess
->deleteMark(*ppMark
);
908 // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
909 if( aDocShellRef
.Is() )
910 SwTransferable::InitOle( aDocShellRef
, *pTmpDoc
);
911 pTmpDoc
->SetRefForDocShell( 0 );
913 if( pWrtShell
->IsObjSelected() )
914 eBufferType
= TRNSFR_DRAWING
;
917 eBufferType
= TRNSFR_DOCUMENT
;
918 if (pWrtShell
->IntelligentCut(nSelection
, FALSE
) != SwWrtShell::NO_WORD
)
919 eBufferType
= (TransferBufferType
)(TRNSFR_DOCUMENT_WORD
| eBufferType
);
922 int bDDELink
= pWrtShell
->IsSelection();
923 if( nSelection
& nsSelectionType::SEL_TBL_CELLS
)
925 eBufferType
= (TransferBufferType
)(TRNSFR_TABELLE
| eBufferType
);
926 bDDELink
= pWrtShell
->HasWholeTabSelection();
929 //Wenn's einer braucht OLE'n wir ihm was.
930 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
932 //RTF vor das Metafile von OLE stellen, weil mit weniger verlusten
934 if( !pWrtShell
->IsObjSelected() )
936 AddFormat( FORMAT_RTF
);
937 AddFormat( SOT_FORMATSTR_ID_HTML
);
939 if( pWrtShell
->IsSelection() )
940 AddFormat( FORMAT_STRING
);
942 if( nSelection
& ( nsSelectionType::SEL_DRW
| nsSelectionType::SEL_DRW_FORM
))
944 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
945 if ( nSelection
& nsSelectionType::SEL_DRW
)
947 AddFormat( FORMAT_GDIMETAFILE
);
948 AddFormat( FORMAT_BITMAP
);
950 eBufferType
= (TransferBufferType
)( TRNSFR_GRAPHIC
| eBufferType
);
952 pClpGraphic
= new Graphic
;
953 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_GDIMETAFILE
, *pClpGraphic
))
954 pOrigGrf
= pClpGraphic
;
955 pClpBitmap
= new Graphic
;
956 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_BITMAP
, *pClpBitmap
))
957 pOrigGrf
= pClpBitmap
;
959 // ist es ein URL-Button ?
961 if( pWrtShell
->GetURLFromButton( sURL
, sDesc
) )
963 AddFormat( FORMAT_STRING
);
964 AddFormat( SOT_FORMATSTR_ID_SOLK
);
965 AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
);
966 AddFormat( SOT_FORMATSTR_ID_FILECONTENT
);
967 AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
);
968 AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
);
969 eBufferType
= (TransferBufferType
)( TRNSFR_INETFLD
| eBufferType
);
974 // beim Cut hat DDE-Link keinen Sinn!!
976 if( !bIsCut
&& bDDELink
&&
977 0 != ( pDShell
= pWrtShell
->GetDoc()->GetDocShell()) &&
978 SFX_CREATE_MODE_STANDARD
== pDShell
->GetCreateMode() )
980 AddFormat( SOT_FORMATSTR_ID_LINK
);
981 refDdeLink
= new SwTrnsfrDdeLink( *this, *pWrtShell
);
984 //ObjectDescriptor wurde bereits aus der alten DocShell gefuellt.
985 //Jetzt noch anpassen. Dadurch kann im GetData die erste Anfrage
986 //auch noch mit delayed rendering beantwortet werden.
987 aObjDesc
.mbCanLink
= FALSE
;
989 aObjDesc
.maSize
= OutputDevice::LogicToLogic( aSz
, MAP_TWIP
, MAP_100TH_MM
);
991 PrepareOLE( aObjDesc
);
992 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
999 if( pWrtShell
->IsFrmSelected() )
1001 SfxItemSet
aSet( pWrtShell
->GetAttrPool(), RES_URL
, RES_URL
);
1002 pWrtShell
->GetFlyFrmAttr( aSet
);
1003 const SwFmtURL
& rURL
= (SwFmtURL
&)aSet
.Get( RES_URL
);
1006 pImageMap
= new ImageMap( *rURL
.GetMap() );
1007 AddFormat( SOT_FORMATSTR_ID_SVIM
);
1009 else if( rURL
.GetURL().Len() )
1011 pTargetURL
= new INetImage( sGrfNm
, rURL
.GetURL(),
1012 rURL
.GetTargetFrameName(),
1013 aEmptyStr
, Size() );
1014 AddFormat( SOT_FORMATSTR_ID_INET_IMAGE
);
1021 int SwTransferable::Copy( BOOL bIsCut
)
1023 int nRet
= PrepareForCopy( bIsCut
);
1026 SW_MOD()->pClipboard
= this;
1027 CopyToClipboard( &pWrtShell
->GetView().GetEditWin() );
1032 // -----------------------------------------------------------------------
1034 int SwTransferable::CalculateAndCopy()
1038 SwWait
aWait( *pWrtShell
->GetView().GetDocShell(), TRUE
);
1040 String
aStr( pWrtShell
->Calculate() );
1042 pClpDocFac
= new SwDocFac
;
1043 pWrtShell
->Copy( pClpDocFac
->GetDoc(), &aStr
);
1044 eBufferType
= TRNSFR_DOCUMENT
;
1045 AddFormat( FORMAT_STRING
);
1047 SW_MOD()->pClipboard
= this;
1048 CopyToClipboard( &pWrtShell
->GetView().GetEditWin() );
1053 // -----------------------------------------------------------------------
1055 int SwTransferable::CopyGlossary( SwTextBlocks
& rGlossary
,
1056 const String
& rStr
)
1060 SwWait
aWait( *pWrtShell
->GetView().GetDocShell(), TRUE
);
1062 pClpDocFac
= new SwDocFac
;
1063 SwDoc
* pCDoc
= pClpDocFac
->GetDoc();
1065 SwNodes
& rNds
= pCDoc
->GetNodes();
1066 SwNodeIndex
aNodeIdx( *rNds
.GetEndOfContent().StartOfSectionNode() );
1067 SwCntntNode
* pCNd
= rNds
.GoNext( &aNodeIdx
); // gehe zum 1. ContentNode
1068 SwPaM
aPam( *pCNd
);
1070 pCDoc
->SetRefForDocShell( boost::addressof(aDocShellRef
) );
1071 pCDoc
->LockExpFlds(); // nie die Felder updaten - Text so belassen
1073 pCDoc
->InsertGlossary( rGlossary
, rStr
, aPam
, 0 );
1075 // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
1076 if( aDocShellRef
.Is() )
1077 SwTransferable::InitOle( aDocShellRef
, *pCDoc
);
1078 pCDoc
->SetRefForDocShell( 0 );
1080 eBufferType
= TRNSFR_DOCUMENT
;
1082 //Wenn's einer braucht OLE'n wir ihm was.
1083 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
1084 AddFormat( FORMAT_RTF
);
1085 AddFormat( SOT_FORMATSTR_ID_HTML
);
1086 AddFormat( FORMAT_STRING
);
1088 //ObjectDescriptor wurde bereits aus der alten DocShell gefuellt.
1089 //Jetzt noch anpassen. Dadurch kann im GetData die erste Anfrage
1090 //auch noch mit delayed rendering beantwortet werden.
1091 aObjDesc
.mbCanLink
= FALSE
;
1092 Size
aSz( OLESIZE
);
1093 aObjDesc
.maSize
= OutputDevice::LogicToLogic( aSz
, MAP_TWIP
, MAP_100TH_MM
);
1095 PrepareOLE( aObjDesc
);
1096 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
1098 SW_MOD()->pClipboard
= this;
1099 CopyToClipboard( &pWrtShell
->GetView().GetEditWin() );
1104 static inline uno::Reference
< XTransferable
> * lcl_getTransferPointer ( uno::Reference
< XTransferable
> &xRef
)
1108 // -----------------------------------------------------------------------
1110 BOOL
SwTransferable::IsPaste( const SwWrtShell
& rSh
,
1111 const TransferableDataHelper
& rData
)
1113 // Check the common case first: We can always paste our own data!
1114 // #106503#: If _only_ the internal format can be pasted, this check will
1115 // yield 'true', while the one below would give a (wrong) result 'false'.
1116 bool bIsPaste
= ( SW_MOD()->pClipboard
!= NULL
);
1118 // if it's not our own data, we need to have a closer look:
1121 // determine the proper paste action, and return true if we find one
1122 uno::Reference
<XTransferable
> xTransferable( rData
.GetXTransferable() );
1123 uno::Reference
<XUnoTunnel
> xTunnel( xTransferable
, UNO_QUERY
);
1126 sal_Int64 nHandle
= xTunnel
->getSomething( getUnoTunnelId() );
1131 USHORT nDestination
= SwTransferable::GetSotDestination( rSh
);
1132 USHORT nSourceOptions
=
1133 (( EXCHG_DEST_DOC_TEXTFRAME
== nDestination
||
1134 EXCHG_DEST_SWDOC_FREE_AREA
== nDestination
||
1135 EXCHG_DEST_DOC_TEXTFRAME_WEB
== nDestination
||
1136 EXCHG_DEST_SWDOC_FREE_AREA_WEB
== nDestination
)
1137 ? EXCHG_IN_ACTION_COPY
1138 : EXCHG_IN_ACTION_MOVE
);
1140 ULONG nFormat
; // output param for GetExchangeAction
1141 USHORT nEventAction
; // output param for GetExchangeAction
1142 USHORT nAction
= SotExchange::GetExchangeAction(
1143 rData
.GetDataFlavorExVector(),
1145 nSourceOptions
, /* ?? */
1146 EXCHG_IN_ACTION_DEFAULT
, /* ?? */
1147 nFormat
, nEventAction
, 0,
1148 lcl_getTransferPointer ( xTransferable
) );
1150 // if we find a suitable action, we can paste!
1151 bIsPaste
= (EXCHG_INOUT_ACTION_NONE
!= nAction
);
1157 // -----------------------------------------------------------------------
1159 int SwTransferable::Paste( SwWrtShell
& rSh
, TransferableDataHelper
& rData
)
1161 USHORT nEventAction
, nAction
=0,
1162 nDestination
= SwTransferable::GetSotDestination( rSh
);
1165 if( SW_MOD()->pClipboard
)
1166 nAction
= EXCHG_OUT_ACTION_INSERT_PRIVATE
;
1169 uno::Reference
<XUnoTunnel
> xTunnel( rData
.GetTransferable(), UNO_QUERY
);
1172 sal_Int64 nHandle
= xTunnel
->getSomething( getUnoTunnelId() );
1174 nAction
= EXCHG_OUT_ACTION_INSERT_PRIVATE
;
1179 USHORT nSourceOptions
=
1180 (( EXCHG_DEST_DOC_TEXTFRAME
== nDestination
||
1181 EXCHG_DEST_SWDOC_FREE_AREA
== nDestination
||
1182 EXCHG_DEST_DOC_TEXTFRAME_WEB
== nDestination
||
1183 EXCHG_DEST_SWDOC_FREE_AREA_WEB
== nDestination
)
1184 ? EXCHG_IN_ACTION_COPY
1185 : EXCHG_IN_ACTION_MOVE
);
1186 uno::Reference
<XTransferable
> xTransferable( rData
.GetXTransferable() );
1187 nAction
= SotExchange::GetExchangeAction(
1188 rData
.GetDataFlavorExVector(),
1190 nSourceOptions
, /* ?? */
1191 EXCHG_IN_ACTION_DEFAULT
, /* ?? */
1192 nFormat
, nEventAction
, 0,
1193 lcl_getTransferPointer ( xTransferable
) );
1197 // special case for tables from draw application
1198 if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ
== (nAction
& EXCHG_ACTION_MASK
) )
1200 if( rData
.HasFormat( SOT_FORMAT_RTF
) )
1202 nAction
= EXCHG_OUT_ACTION_INSERT_STRING
| (nAction
& !EXCHG_ACTION_MASK
);
1203 nFormat
= SOT_FORMAT_RTF
;
1207 return EXCHG_INOUT_ACTION_NONE
!= nAction
&&
1208 SwTransferable::PasteData( rData
, rSh
, nAction
, nFormat
,
1209 nDestination
, FALSE
, FALSE
);
1212 // -----------------------------------------------------------------------
1214 int SwTransferable::PasteData( TransferableDataHelper
& rData
,
1215 SwWrtShell
& rSh
, USHORT nAction
, ULONG nFormat
,
1216 USHORT nDestination
, BOOL bIsPasteFmt
,
1217 sal_Bool bIsDefault
,
1218 const Point
* pPt
, sal_Int8 nDropAction
,
1219 BOOL bPasteSelection
)
1221 SwWait
aWait( *rSh
.GetView().
1222 GetDocShell(), FALSE
);
1223 SwTrnsfrActionAndUndo
* pAction
= 0;
1224 SwModule
* pMod
= SW_MOD();
1227 bool bCallAutoCaption
= false;
1232 if( bPasteSelection
? !pMod
->pXSelection
: !pMod
->pDragDrop
)
1234 switch( nDestination
)
1236 case EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP
:
1237 case EXCHG_DEST_DOC_LNKD_GRAPHOBJ
:
1238 case EXCHG_DEST_DOC_GRAPH_W_IMAP
:
1239 case EXCHG_DEST_DOC_GRAPHOBJ
:
1240 case EXCHG_DEST_DOC_OLEOBJ
:
1241 case EXCHG_DEST_DOC_DRAWOBJ
:
1242 case EXCHG_DEST_DOC_URLBUTTON
:
1243 case EXCHG_DEST_DOC_GROUPOBJ
:
1244 // Rahmen/Objecte selektieren
1245 SwTransferable::SetSelInShell( rSh
, TRUE
, pPt
);
1248 // case EXCHG_DEST_DOC_TEXTFRAME:
1249 // case EXCHG_DEST_SWDOC_FREE_AREA:
1250 // case EXCHG_DEST_DOC_URLFIELD:
1252 SwTransferable::SetSelInShell( rSh
, FALSE
, pPt
);
1257 else if( ( !pMod
->pClipboard
|| bIsPasteFmt
) &&
1258 !rSh
.IsTableMode() && rSh
.HasSelection() )
1260 // dann die Selektionen loeschen
1262 //Selektierten Inhalt loeschen,
1263 // - nicht bei Tabellen-Selektion
1264 // - nicht bei ReRead einer Grafik/DDEDaten
1265 // - nicht bei D&D, fuer die richtige Selektion wurde im
1266 // Drop-Handler gesorgt
1267 BOOL bDelSel
= FALSE
;
1268 switch( nDestination
)
1270 case EXCHG_DEST_DOC_TEXTFRAME
:
1271 case EXCHG_DEST_SWDOC_FREE_AREA
:
1272 case EXCHG_DEST_DOC_TEXTFRAME_WEB
:
1273 case EXCHG_DEST_SWDOC_FREE_AREA_WEB
:
1279 // --> FME 2004-10-19 #i34830#
1280 pAction
= new SwTrnsfrActionAndUndo( &rSh
, UNDO_PASTE_CLIPBOARD
, NULL
,
1285 SwTransferable
*pTrans
=0, *pTunneledTrans
=0;
1286 uno::Reference
<XUnoTunnel
> xTunnel( rData
.GetTransferable(), UNO_QUERY
);
1289 sal_Int64 nHandle
= xTunnel
->getSomething( getUnoTunnelId() );
1291 pTunneledTrans
= (SwTransferable
*) (sal_IntPtr
) nHandle
;
1294 if( pPt
&& ( bPasteSelection
? 0 != ( pTrans
= pMod
->pXSelection
)
1295 : 0 != ( pTrans
= pMod
->pDragDrop
) ))
1297 // then internal Drag & Drop or XSelection
1298 nRet
= pTrans
->PrivateDrop( rSh
, *pPt
, DND_ACTION_MOVE
== nDropAction
,
1301 else if( !pPt
&& ( pTunneledTrans
|| 0 != ( pTunneledTrans
= pMod
->pClipboard
) ) &&
1302 EXCHG_OUT_ACTION_INSERT_PRIVATE
== nAction
)
1304 // then internal paste
1305 nRet
= pTunneledTrans
->PrivatePaste( rSh
);
1307 else if( EXCHG_INOUT_ACTION_NONE
!= nAction
)
1312 pAction
= new SwTrnsfrActionAndUndo( &rSh
, UNDO_PASTE_CLIPBOARD
);
1315 // im Drag&Drop duerfen keine MessageBoxen angezeigt werden
1316 BOOL bMsg
= 0 == pPt
;
1317 BYTE nActionFlags
= static_cast< BYTE
>(( nAction
>> 8 ) & 0xFF);
1319 USHORT nClearedAction
= ( nAction
& EXCHG_ACTION_MASK
);
1320 // Selektionen loeschen
1322 switch( nClearedAction
)
1324 case EXCHG_OUT_ACTION_INSERT_PRIVATE
:
1325 ASSERT( pPt
, "EXCHG_OUT_ACTION_INSERT_PRIVATE: was soll hier passieren?" );
1328 case EXCHG_OUT_ACTION_MOVE_PRIVATE
:
1329 ASSERT( pPt
, "EXCHG_OUT_ACTION_MOVE_PRIVATE: was soll hier passieren?" );
1333 case EXCHG_IN_ACTION_MOVE
:
1334 case EXCHG_IN_ACTION_COPY
:
1335 case EXCHG_IN_ACTION_LINK
:
1336 case EXCHG_OUT_ACTION_INSERT_HTML
:
1337 case EXCHG_OUT_ACTION_INSERT_STRING
:
1338 case EXCHG_OUT_ACTION_INSERT_IMAGEMAP
:
1339 case EXCHG_OUT_ACTION_REPLACE_IMAGEMAP
:
1341 // dann muss ueber das Format gegangen werden
1344 case SOT_FORMATSTR_ID_DRAWING
:
1345 nRet
= SwTransferable::_PasteSdrFormat( rData
, rSh
,
1346 SW_PASTESDR_INSERT
, pPt
,
1350 case SOT_FORMATSTR_ID_HTML
:
1351 case SOT_FORMATSTR_ID_HTML_SIMPLE
:
1352 case SOT_FORMATSTR_ID_HTML_NO_COMMENT
:
1353 case SOT_FORMAT_RTF
:
1354 case SOT_FORMAT_STRING
:
1355 nRet
= SwTransferable::_PasteFileContent( rData
, rSh
,
1359 case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
:
1362 if( rData
.GetINetBookmark( nFormat
, aBkmk
) )
1364 SwFmtINetFmt
aFmt( aBkmk
.GetURL(), aEmptyStr
);
1365 rSh
.InsertURL( aFmt
, aBkmk
.GetDescription() );
1371 case SOT_FORMATSTR_ID_SD_OLE
:
1372 nRet
= SwTransferable::_PasteOLE( rData
, rSh
, nFormat
,
1373 nActionFlags
, bMsg
);
1376 case SOT_FORMATSTR_ID_SVIM
:
1377 nRet
= SwTransferable::_PasteImageMap( rData
, rSh
);
1380 case SOT_FORMATSTR_ID_SVXB
:
1381 case SOT_FORMAT_BITMAP
:
1382 case SOT_FORMAT_GDIMETAFILE
:
1383 nRet
= SwTransferable::_PasteGrf( rData
, rSh
, nFormat
,
1384 SW_PASTESDR_INSERT
,pPt
,
1385 nActionFlags
, bMsg
);
1388 case SOT_FORMATSTR_ID_XFORMS
:
1389 case SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE
:
1390 case SOT_FORMATSTR_ID_SBA_DATAEXCHANGE
:
1391 case SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE
:
1392 nRet
= SwTransferable::_PasteDBData( rData
, rSh
, nFormat
,
1393 EXCHG_IN_ACTION_LINK
== nClearedAction
,
1397 case SOT_FORMAT_FILE
:
1398 nRet
= SwTransferable::_PasteFileName( rData
, rSh
, nFormat
,
1399 ( EXCHG_IN_ACTION_MOVE
== nClearedAction
1400 ? SW_PASTESDR_REPLACE
1401 : EXCHG_IN_ACTION_LINK
== nClearedAction
1402 ? SW_PASTESDR_SETATTR
1403 : SW_PASTESDR_INSERT
),
1404 pPt
, nActionFlags
, bMsg
);
1407 case SOT_FORMAT_FILE_LIST
:
1408 // dann nur als Grafiken einfuegen
1409 nRet
= SwTransferable::_PasteFileList( rData
, rSh
,
1410 EXCHG_IN_ACTION_LINK
== nClearedAction
,
1414 case SOT_FORMATSTR_ID_SONLK
:
1417 NaviContentBookmark aBkmk
;
1418 if( aBkmk
.Paste( rData
) )
1422 switch(aBkmk
.GetDefaultDragType())
1424 case REGION_MODE_NONE
: nClearedAction
= EXCHG_IN_ACTION_COPY
; break;
1425 case REGION_MODE_EMBEDDED
: nClearedAction
= EXCHG_IN_ACTION_MOVE
; break;
1426 case REGION_MODE_LINK
: nClearedAction
= EXCHG_IN_ACTION_LINK
; break;
1429 rSh
.NavigatorPaste( aBkmk
, nClearedAction
);
1435 case SOT_FORMATSTR_ID_INET_IMAGE
:
1436 case SOT_FORMATSTR_ID_NETSCAPE_IMAGE
:
1437 nRet
= SwTransferable::_PasteTargetURL( rData
, rSh
,
1443 ASSERT( pPt
, "unbekanntes Format" );
1447 case EXCHG_OUT_ACTION_INSERT_FILE
:
1448 nRet
= SwTransferable::_PasteFileName( rData
, rSh
, nFormat
,
1449 SW_PASTESDR_INSERT
, pPt
,
1450 nActionFlags
, bMsg
);
1451 if( nRet
& SWTRANSFER_GRAPHIC_INSERTED
)
1452 bCallAutoCaption
= true;
1455 case EXCHG_OUT_ACTION_INSERT_OLE
:
1456 nRet
= SwTransferable::_PasteOLE( rData
, rSh
, nFormat
,
1457 nActionFlags
,bMsg
);
1460 case EXCHG_OUT_ACTION_INSERT_DDE
:
1462 BOOL bReRead
= 0 != CNT_HasGrf( rSh
.GetCntType() );
1463 nRet
= SwTransferable::_PasteDDE( rData
, rSh
, bReRead
, bMsg
);
1467 case EXCHG_OUT_ACTION_INSERT_HYPERLINK
:
1470 if( SOT_FORMAT_FILE
== nFormat
)
1472 if( rData
.GetString( nFormat
, sURL
) && sURL
.Len() )
1474 SwTransferable::_CheckForURLOrLNKFile( rData
, sURL
, &sDesc
);
1483 if( rData
.GetINetBookmark( nFormat
, aBkmk
) )
1485 sURL
= aBkmk
.GetURL();
1486 sDesc
= aBkmk
.GetDescription();
1493 SwFmtINetFmt
aFmt( sURL
, aEmptyStr
);
1494 rSh
.InsertURL( aFmt
, sDesc
);
1499 case EXCHG_OUT_ACTION_GET_ATTRIBUTES
:
1502 case SOT_FORMATSTR_ID_DRAWING
:
1503 nRet
= SwTransferable::_PasteSdrFormat( rData
, rSh
,
1504 SW_PASTESDR_SETATTR
, pPt
,
1507 case SOT_FORMATSTR_ID_SVXB
:
1508 case SOT_FORMAT_GDIMETAFILE
:
1509 case SOT_FORMAT_BITMAP
:
1510 case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
:
1511 case SOT_FORMAT_FILE
:
1512 case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
:
1513 case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
:
1514 nRet
= SwTransferable::_PasteGrf( rData
, rSh
, nFormat
,
1515 SW_PASTESDR_SETATTR
, pPt
,
1516 nActionFlags
, bMsg
);
1519 ASSERT( FALSE
, "unbekanntes Format" );
1524 case EXCHG_OUT_ACTION_INSERT_DRAWOBJ
:
1525 nRet
= SwTransferable::_PasteSdrFormat( rData
, rSh
,
1526 SW_PASTESDR_INSERT
, pPt
,
1529 case EXCHG_OUT_ACTION_INSERT_SVXB
:
1530 case EXCHG_OUT_ACTION_INSERT_GDIMETAFILE
:
1531 case EXCHG_OUT_ACTION_INSERT_BITMAP
:
1532 case EXCHG_OUT_ACTION_INSERT_GRAPH
:
1533 nRet
= SwTransferable::_PasteGrf( rData
, rSh
, nFormat
,
1534 SW_PASTESDR_INSERT
, pPt
,
1535 nActionFlags
, bMsg
);
1538 case EXCHG_OUT_ACTION_REPLACE_DRAWOBJ
:
1539 nRet
= SwTransferable::_PasteSdrFormat( rData
, rSh
,
1540 SW_PASTESDR_REPLACE
, pPt
,
1544 case EXCHG_OUT_ACTION_REPLACE_SVXB
:
1545 case EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE
:
1546 case EXCHG_OUT_ACTION_REPLACE_BITMAP
:
1547 case EXCHG_OUT_ACTION_REPLACE_GRAPH
:
1548 nRet
= SwTransferable::_PasteGrf( rData
, rSh
, nFormat
,
1549 SW_PASTESDR_REPLACE
,pPt
,
1550 nActionFlags
, bMsg
);
1553 case EXCHG_OUT_ACTION_INSERT_INTERACTIVE
:
1554 nRet
= SwTransferable::_PasteAsHyperlink( rData
, rSh
, nFormat
);
1558 ASSERT( FALSE
, "unbekannte Action" );
1562 if( !bPasteSelection
&& rSh
.IsFrmSelected() )
1564 rSh
.EnterSelFrmMode();
1565 //force ::SelectShell
1566 rSh
.GetView().StopShellTimer();
1571 if( bCallAutoCaption
)
1572 rSh
.GetView().AutoCaption( GRAPHIC_CAP
);
1577 // -----------------------------------------------------------------------
1579 USHORT
SwTransferable::GetSotDestination( const SwWrtShell
& rSh
,
1582 USHORT nRet
= EXCHG_INOUT_ACTION_NONE
;
1587 SdrObject
*pObj
= 0;
1588 eOType
= rSh
.GetObjCntType( *pPt
, pObj
);
1591 eOType
= rSh
.GetObjCntTypeOfSelection();
1600 bIMap
= 0 != rSh
.GetFmtFromObj( *pPt
)->GetURL().GetMap();
1602 rSh
.GetGrfAtPos( *pPt
, aDummy
, bLink
);
1606 bIMap
= 0 != rSh
.GetFlyFrmFmt()->GetURL().GetMap();
1608 rSh
.GetGrfNms( &aDummy
, 0 );
1609 bLink
= 0 != aDummy
.Len();
1612 if( bLink
&& bIMap
)
1613 nRet
= EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP
;
1615 nRet
= EXCHG_DEST_DOC_LNKD_GRAPHOBJ
;
1617 nRet
= EXCHG_DEST_DOC_GRAPH_W_IMAP
;
1619 nRet
= EXCHG_DEST_DOC_GRAPHOBJ
;
1624 if( rSh
.GetView().GetDocShell()->ISA(SwWebDocShell
) )
1625 nRet
= EXCHG_DEST_DOC_TEXTFRAME_WEB
;
1627 nRet
= EXCHG_DEST_DOC_TEXTFRAME
;
1629 case OBJCNT_OLE
: nRet
= EXCHG_DEST_DOC_OLEOBJ
; break;
1631 case OBJCNT_CONTROL
: /* no Action avail */
1632 case OBJCNT_SIMPLE
: nRet
= EXCHG_DEST_DOC_DRAWOBJ
; break;
1633 case OBJCNT_URLBUTTON
: nRet
= EXCHG_DEST_DOC_URLBUTTON
; break;
1634 case OBJCNT_GROUPOBJ
: nRet
= EXCHG_DEST_DOC_GROUPOBJ
; break;
1636 // was mmchen wir bei Mehrfachselektion???
1637 // case OBJCNT_DONTCARE:
1641 JP 13.07.98: Bug 52637: es wird ein URL-Feld erkannt also werden nur die
1642 Inhalte zugelassen. Das ist aber bestimmt nicht das
1644 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
1645 SfxItemSet aSet( (SfxItemPool&)rSh.GetAttrPool(),
1646 RES_TXTATR_INETFMT, RES_TXTATR_INETFMT );
1647 if( pPt ? ((SwWrtShell&)rSh).GetContentAtPos( *pPt, aCntntAtPos, FALSE )
1648 : (rSh.GetAttr( aSet ) && aSet.Count()) )
1649 nRet = EXCHG_DEST_DOC_URLFIELD;
1652 if( rSh
.GetView().GetDocShell()->ISA(SwWebDocShell
) )
1653 nRet
= EXCHG_DEST_SWDOC_FREE_AREA_WEB
;
1655 nRet
= EXCHG_DEST_SWDOC_FREE_AREA
;
1662 // -----------------------------------------------------------------------
1664 int SwTransferable::_PasteFileContent( TransferableDataHelper
& rData
,
1665 SwWrtShell
& rSh
, ULONG nFmt
, BOOL bMsg
)
1667 USHORT nResId
= MSG_CLPBRD_FORMAT_ERROR
;
1670 MSE40HTMLClipFormatObj aMSE40ClpObj
;
1672 SotStorageStreamRef xStrm
;
1673 SvStream
* pStream
= 0;
1675 rtl::OUString sData
;
1678 case SOT_FORMAT_STRING
:
1681 if( rData
.GetString( nFmt
, sData
) )
1683 pStream
= new SvMemoryStream( (void*)sData
.getStr(),
1684 sData
.getLength() * sizeof( sal_Unicode
),
1686 #ifdef OSL_BIGENDIAN
1687 pStream
->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN
);
1689 pStream
->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN
);
1692 SwAsciiOptions aAOpt
;
1693 aAOpt
.SetCharSet( RTL_TEXTENCODING_UCS2
);
1694 pRead
->GetReaderOpt().SetASCIIOpts( aAOpt
);
1698 // no break - because then test if we get a stream
1701 if( rData
.GetSotStorageStream( nFmt
, xStrm
) )
1703 if( ( SOT_FORMATSTR_ID_HTML_SIMPLE
== nFmt
) ||
1704 ( SOT_FORMATSTR_ID_HTML_NO_COMMENT
== nFmt
) )
1706 pStream
= aMSE40ClpObj
.IsValid( *xStrm
);
1708 pRead
->SetReadUTF8( TRUE
);
1709 //pRead->SetBaseURL( aMSE40ClpObj.GetBaseURL() );
1712 ( nFmt
== SOT_FORMATSTR_ID_HTML_NO_COMMENT
);
1713 pRead
->SetIgnoreHTMLComments( bNoComments
);
1718 if( SOT_FORMAT_RTF
== nFmt
)
1719 pRead
= SwReaderWriter::GetReader( READER_WRITER_RTF
);
1723 pRead
->SetReadUTF8( TRUE
);
1730 if( pStream
&& pRead
)
1732 Link
aOldLink( rSh
.GetChgLnk() );
1733 rSh
.SetChgLnk( Link() );
1735 SwReader
aReader( *pStream
, aEmptyStr
, String(), *rSh
.GetCrsr() );
1736 if( IsError( aReader
.Read( *pRead
)) )
1737 nResId
= ERR_CLPBRD_READ
;
1739 nResId
= 0, nRet
= 1;
1741 rSh
.SetChgLnk( aOldLink
);
1746 nResId
= MSG_CLPBRD_FORMAT_ERROR
;
1748 // Exist a SvMemoryStream? (data in the OUString and xStrm is empty)
1749 if( pStream
&& !xStrm
.Is() )
1752 if( bMsg
&& nResId
)
1754 InfoBox( 0, SW_RES( nResId
)).Execute();
1759 // -----------------------------------------------------------------------
1761 int SwTransferable::_PasteOLE( TransferableDataHelper
& rData
, SwWrtShell
& rSh
,
1762 ULONG nFmt
, BYTE nActionFlags
, BOOL bMsg
)
1765 TransferableObjectDescriptor aObjDesc
;
1766 uno::Reference
< io::XInputStream
> xStrm
;
1767 uno::Reference
< embed::XStorage
> xStore
;
1770 // Get the preferred format
1771 SotFormatStringId nId
;
1772 if( rData
.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ
) )
1773 nId
= SOT_FORMATSTR_ID_EMBEDDED_OBJ
;
1774 else if( rData
.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
) &&
1775 rData
.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
))
1776 nId
= SOT_FORMATSTR_ID_EMBED_SOURCE
;
1780 if( nId
&& rData
.GetInputStream( nId
, xStrm
) && xStrm
.is() )
1782 // if there is an embedded object, first try if it's a writer object
1783 // this will be inserted into the document by using a Reader
1786 xStore
= comphelper::OStorageHelper::GetStorageFromInputStream( xStrm
);
1787 switch( SotStorage::GetFormatID( xStore
) )
1789 case SOT_FORMATSTR_ID_STARWRITER_60
:
1790 case SOT_FORMATSTR_ID_STARWRITERWEB_60
:
1791 case SOT_FORMATSTR_ID_STARWRITERGLOB_60
:
1792 case SOT_FORMATSTR_ID_STARWRITER_8
:
1793 case SOT_FORMATSTR_ID_STARWRITERWEB_8
:
1794 case SOT_FORMATSTR_ID_STARWRITERGLOB_8
:
1800 uno::Reference
< lang::XComponent
> xComp( xStore
, uno::UNO_QUERY
);
1804 catch ( uno::Exception
& )
1811 catch ( uno::Exception
& )
1813 // it wasn't a storage, but maybe it's a useful stream
1821 SwPaM
&rPAM
= *rSh
.GetCrsr();
1822 SwReader
aReader( xStore
, aEmptyStr
, rPAM
);
1823 if( !IsError( aReader
.Read( *pRead
)) )
1826 InfoBox( 0, SW_RES(ERR_CLPBRD_READ
) ).Execute();
1830 // temporary storage until the object is inserted
1831 uno::Reference
< embed::XStorage
> xTmpStor
;
1832 uno::Reference
< embed::XEmbeddedObject
> xObj
;
1833 ::rtl::OUString aName
;
1834 comphelper::EmbeddedObjectContainer aCnt
;
1838 if ( !rData
.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
, aObjDesc
) )
1840 DBG_ASSERT( !xStrm
.is(), "An object without descriptor in clipboard!");
1845 if( rData
.HasFormat( nFmt
= SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE
) && rData
.GetTransferableObjectDescriptor( nFmt
, aObjDesc
) )
1847 if ( !rData
.GetInputStream( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
, xStrm
) )
1848 rData
.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
, xStrm
);
1852 // This is MSOLE object that should be created by direct using of system clipboard
1855 xTmpStor
= ::comphelper::OStorageHelper::GetTemporaryStorage();
1856 uno::Reference
< embed::XEmbedObjectClipboardCreator
> xClipboardCreator(
1857 ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(
1858 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
1859 uno::UNO_QUERY_THROW
);
1861 embed::InsertedObjectInfo aInfo
= xClipboardCreator
->createInstanceInitFromClipboard(
1863 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
1864 uno::Sequence
< beans::PropertyValue
>() );
1866 // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
1867 // for example whether the object should be an iconified one
1868 xObj
= aInfo
.Object
;
1870 catch( uno::Exception
& )
1876 if ( xStrm
.is() && !xObj
.is() )
1877 xObj
= aCnt
.InsertEmbeddedObject( xStrm
, aName
);
1881 svt::EmbeddedObjectRef
xObjRef( xObj
, aObjDesc
.mnViewAspect
);
1883 // try to get the replacement image from the clipboard
1885 ULONG nGrFormat
= 0;
1887 // (wg. Selection Manager bei Trustet Solaris)
1890 if( rData.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
1891 nGrFormat = SOT_FORMATSTR_ID_SVXB;
1892 else if( rData.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
1893 nGrFormat = SOT_FORMAT_GDIMETAFILE;
1894 else if( rData.GetGraphic( FORMAT_BITMAP, aGraphic ) )
1895 nGrFormat = SOT_FORMAT_BITMAP;
1899 // insert replacement image ( if there is one ) into the object helper
1902 datatransfer::DataFlavor aDataFlavor
;
1903 SotExchange::GetFormatDataFlavor( nGrFormat
, aDataFlavor
);
1904 xObjRef
.SetGraphic( aGraphic
, aDataFlavor
.MimeType
);
1906 else if ( aObjDesc
.mnViewAspect
== embed::Aspects::MSOLE_ICON
)
1908 // it is important to have an icon, let an empty graphic be used
1909 // if no other graphic is provided
1910 // TODO/LATER: in future a default bitmap could be used
1911 ::rtl::OUString aMimeType
;
1912 MapMode
aMapMode( MAP_100TH_MM
);
1913 aGraphic
.SetPrefSize( Size( 2500, 2500 ) );
1914 aGraphic
.SetPrefMapMode( aMapMode
);
1915 xObjRef
.SetGraphic( aGraphic
, aMimeType
);
1918 //Size einstellen. Ist ein Hack wg. Auslieferung, die Size sollte
1919 //an das InsertOle uebergeben werden!!!!!!!!!!
1921 if ( aObjDesc
.mnViewAspect
== embed::Aspects::MSOLE_ICON
)
1923 if( aObjDesc
.maSize
.Width() && aObjDesc
.maSize
.Height() )
1924 aSize
= aObjDesc
.maSize
;
1927 MapMode
aMapMode( MAP_100TH_MM
);
1928 aSize
= xObjRef
.GetSize( &aMapMode
);
1931 else if( aObjDesc
.maSize
.Width() && aObjDesc
.maSize
.Height() )
1933 aSize
= Size( aObjDesc
.maSize
); //immer 100TH_MM
1934 MapUnit aUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( aObjDesc
.mnViewAspect
) );
1935 aSize
= OutputDevice::LogicToLogic( aSize
, MAP_100TH_MM
, aUnit
);
1939 aSz
= xObj
->getVisualAreaSize( aObjDesc
.mnViewAspect
);
1941 catch( embed::NoVisualAreaSizeException
& )
1943 // in this case the provided size is used
1946 if ( aSz
.Width
!= aSize
.Width() || aSz
.Height
!= aSize
.Height() )
1948 aSz
.Width
= aSize
.Width();
1949 aSz
.Height
= aSize
.Height();
1950 xObj
->setVisualAreaSize( aObjDesc
.mnViewAspect
, aSz
);
1955 // the descriptor contains the wrong object size
1956 // the following call will let the MSOLE objects cache the size if it is possible
1957 // it should be done while the object is running
1960 xObj
->getVisualAreaSize( aObjDesc
.mnViewAspect
);
1962 catch( uno::Exception
& )
1968 rSh
.InsertOleObject( xObjRef
);
1971 if( nRet
&& ( nActionFlags
&
1972 ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL
>> 8) ))
1973 SwTransferable::_PasteTargetURL( rData
, rSh
, 0, 0, FALSE
);
1975 // let the object be unloaded if possible
1976 SwOLEObj::UnloadObject( xObj
, rSh
.GetDoc(), embed::Aspects::MSOLE_CONTENT
);
1982 // -----------------------------------------------------------------------
1985 // -----------------------------------------------------------------------
1987 int SwTransferable::_PasteTargetURL( TransferableDataHelper
& rData
,
1988 SwWrtShell
& rSh
, USHORT nAction
,
1989 const Point
* pPt
, BOOL bInsertGRF
)
1993 if( ( rData
.HasFormat( SOT_FORMATSTR_ID_INET_IMAGE
) &&
1994 rData
.GetINetImage( SOT_FORMATSTR_ID_INET_IMAGE
, aINetImg
)) ||
1995 ( rData
.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_IMAGE
) &&
1996 rData
.GetINetImage( SOT_FORMATSTR_ID_NETSCAPE_IMAGE
, aINetImg
)) )
1998 if( aINetImg
.GetImageURL().Len() && bInsertGRF
)
2000 String
sURL( aINetImg
.GetImageURL() );
2001 SwTransferable::_CheckForURLOrLNKFile( rData
, sURL
);
2003 //!!! auf FileSystem abpruefen - nur dann ist es sinnvoll die
2004 // Grafiken zu testen !!!!
2006 GraphicFilter
*pFlt
= ::GetGrfFilter();
2007 nRet
= GRFILTER_OK
== ::LoadGraphic( sURL
, aEmptyStr
, aGrf
, pFlt
);
2012 case SW_PASTESDR_INSERT
:
2013 SwTransferable::SetSelInShell( rSh
, FALSE
, pPt
);
2014 rSh
.Insert( sURL
, aEmptyStr
, aGrf
);
2017 case SW_PASTESDR_REPLACE
:
2018 if( rSh
.IsObjSelected() )
2020 rSh
.ReplaceSdrObj( sURL
, aEmptyStr
, &aGrf
);
2021 Point
aPt( pPt
? *pPt
: rSh
.GetCrsrDocPos() );
2022 SwTransferable::SetSelInShell( rSh
, TRUE
, &aPt
);
2025 rSh
.ReRead( sURL
, aEmptyStr
, &aGrf
);
2028 case SW_PASTESDR_SETATTR
:
2029 if( rSh
.IsObjSelected() )
2031 else if( OBJCNT_GRF
== rSh
.GetObjCntTypeOfSelection() )
2032 rSh
.ReRead( sURL
, aEmptyStr
, &aGrf
);
2035 SwTransferable::SetSelInShell( rSh
, FALSE
, pPt
);
2036 rSh
.Insert( sURL
, aEmptyStr
, aGrf
);
2050 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
2051 rSh
.GetFlyFrmAttr( aSet
);
2052 SwFmtURL
aURL( (SwFmtURL
&)aSet
.Get( RES_URL
) );
2054 if( aURL
.GetURL() != aINetImg
.GetTargetURL() ||
2055 aURL
.GetTargetFrameName() != aINetImg
.GetTargetFrame() )
2057 aURL
.SetURL( aINetImg
.GetTargetURL(), FALSE
);
2058 aURL
.SetTargetFrameName( aINetImg
.GetTargetFrame() );
2060 rSh
.SetFlyFrmAttr( aSet
);
2067 // -----------------------------------------------------------------------
2069 void SwTransferable::SetSelInShell( SwWrtShell
& rSh
, BOOL bSelectFrm
,
2074 // Rahmen/Objecte selektieren
2075 if( pPt
&& !rSh
.GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
2077 rSh
.GetView().NoRotate();
2078 if( rSh
.SelectObj( *pPt
))
2081 rSh
.EnterSelFrmMode( pPt
);
2088 if( rSh
.IsFrmSelected() || rSh
.IsObjSelected() )
2091 rSh
.LeaveSelFrmMode();
2092 rSh
.GetView().GetEditWin().StopInsFrm();
2095 else if( rSh
.GetView().GetDrawFuncPtr() )
2096 rSh
.GetView().GetEditWin().StopInsFrm();
2100 rSh
.SwCrsrShell::SetCrsr( *pPt
, TRUE
);
2104 // -----------------------------------------------------------------------
2106 int SwTransferable::_PasteDDE( TransferableDataHelper
& rData
,
2107 SwWrtShell
& rWrtShell
, BOOL bReReadGrf
,
2110 // Daten aus dem Clipboardformat
2111 String aApp
, aTopic
, aItem
;
2114 SotStorageStreamRef xStrm
;
2115 if( !rData
.GetSotStorageStream( SOT_FORMATSTR_ID_LINK
, xStrm
))
2117 ASSERT( !&rWrtShell
, "DDE Data not found." );
2119 } //sinnvollen Fehler melden!!
2121 rtl_TextEncoding eEncoding
= DDE_TXT_ENCODING
;
2122 xStrm
->ReadCString( aApp
, eEncoding
);
2123 xStrm
->ReadCString( aTopic
, eEncoding
);
2124 xStrm
->ReadCString( aItem
, eEncoding
);
2128 sfx2::MakeLnkName( aCmd
, &aApp
, aTopic
, aItem
);
2130 // wollen wir jetzt eine Grafik einlesen ?
2132 if( !rData
.HasFormat( FORMAT_RTF
) &&
2133 !rData
.HasFormat( SOT_FORMATSTR_ID_HTML
) &&
2134 !rData
.HasFormat( FORMAT_STRING
) &&
2135 (rData
.HasFormat( nFormat
= FORMAT_GDIMETAFILE
) ||
2136 rData
.HasFormat( nFormat
= FORMAT_BITMAP
)) )
2139 int nRet
= rData
.GetGraphic( nFormat
, aGrf
);
2142 String
sLnkTyp( String::CreateFromAscii(
2143 RTL_CONSTASCII_STRINGPARAM( "DDE" )));
2145 rWrtShell
.ReRead( aCmd
, sLnkTyp
, &aGrf
);
2147 rWrtShell
.Insert( aCmd
, sLnkTyp
, aGrf
);
2152 SwFieldType
* pTyp
= 0;
2155 BOOL bAlreadyThere
= FALSE
, bDoublePaste
= FALSE
;
2156 USHORT nSize
= rWrtShell
.GetFldTypeCount();
2157 const ::utl::TransliterationWrapper
& rColl
= ::GetAppCmpStrIgnore();
2161 aName
+= String::CreateFromInt32( i
);
2162 for( j
= INIT_FLDTYPES
; j
< nSize
; j
++ )
2164 pTyp
= rWrtShell
.GetFldType( j
);
2165 if( RES_DDEFLD
== pTyp
->Which() )
2167 String
sTmp( ((SwDDEFieldType
*)pTyp
)->GetCmd() );
2168 if( rColl
.isEqual( sTmp
, aCmd
) &&
2169 sfx2::LINKUPDATE_ALWAYS
== ((SwDDEFieldType
*)pTyp
)->GetType() )
2171 aName
= pTyp
->GetName();
2172 bDoublePaste
= TRUE
;
2175 else if( rColl
.isEqual( aName
, pTyp
->GetName() ) )
2180 bAlreadyThere
= FALSE
;
2183 bAlreadyThere
= TRUE
;
2187 while( bAlreadyThere
&& !bDoublePaste
);
2191 SwDDEFieldType
aType( aName
, aCmd
, sfx2::LINKUPDATE_ALWAYS
);
2192 pTyp
= rWrtShell
.InsertFldType( aType
);
2196 SwDDEFieldType
* pDDETyp
= (SwDDEFieldType
*)pTyp
;
2199 if( rData
.GetString( FORMAT_STRING
, aExpand
))
2201 do { // middle checked loop
2203 // Wenn die Daten von einer Tabellenkalkulation kommen
2204 // fuegen wir eine DDE-Tabelle ein
2205 if( ( rData
.HasFormat( SOT_FORMATSTR_ID_SYLK
) ||
2206 rData
.HasFormat( SOT_FORMATSTR_ID_SYLK_BIGCAPS
) ) &&
2208 ( 1 < aExpand
.GetTokenCount( '\n' ) ||
2209 aExpand
.GetTokenCount( '\t' )) )
2211 String
sTmp( aExpand
);
2212 xub_StrLen nRows
= sTmp
.GetTokenCount( '\n' );
2215 sTmp
= sTmp
.GetToken( 0, '\n' );
2216 xub_StrLen nCols
= sTmp
.GetTokenCount( '\t' );
2218 // mindestens eine Spalte & Zeile muss vorhanden sein
2219 if( !nRows
|| !nCols
)
2222 InfoBox(0, SW_RESSTR(STR_NO_TABLE
)).Execute();
2227 rWrtShell
.InsertDDETable(
2228 SwInsertTableOptions( tabopts::HEADLINE_NO_BORDER
, 1 ), // TODO MULTIHEADER
2229 pDDETyp
, nRows
, nCols
);
2231 else if( 1 < aExpand
.GetTokenCount( '\n' ) )
2233 // mehrere Absaetze -> eine geschuetzte Section einfuegen
2234 if( rWrtShell
.HasSelection() )
2235 rWrtShell
.DelRight();
2237 SwSection
aSect( DDE_LINK_SECTION
, aName
);
2238 aSect
.SetLinkFileName( aCmd
);
2240 rWrtShell
.InsertSection( aSect
);
2242 pDDETyp
= 0; // FeldTypen wieder entfernen
2247 SwDDEField
aSwDDEField( pDDETyp
);
2248 rWrtShell
.Insert( aSwDDEField
);
2254 pDDETyp
= 0; // FeldTypen wieder entfernen
2256 if( !pDDETyp
&& !bDoublePaste
)
2258 // FeldTyp wieder entfernen - Fehler aufgetreten!
2259 for( j
= nSize
; j
>= INIT_FLDTYPES
; --j
)
2260 if( pTyp
== rWrtShell
.GetFldType( j
) )
2262 rWrtShell
.RemoveFldType( j
);
2270 // -----------------------------------------------------------------------
2272 int SwTransferable::_PasteSdrFormat( TransferableDataHelper
& rData
,
2273 SwWrtShell
& rSh
, USHORT nAction
,
2274 const Point
* pPt
, BYTE nActionFlags
)
2277 SotStorageStreamRef xStrm
;
2278 if( rData
.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING
, xStrm
))
2280 xStrm
->SetVersion( SOFFICE_FILEFORMAT_50
);
2281 rSh
.Paste( *xStrm
, nAction
, pPt
);
2284 if( nRet
&& ( nActionFlags
&
2285 ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL
>> 8) ))
2286 SwTransferable::_PasteTargetURL( rData
, rSh
, 0, 0, FALSE
);
2291 // -----------------------------------------------------------------------
2293 int SwTransferable::_PasteGrf( TransferableDataHelper
& rData
, SwWrtShell
& rSh
,
2294 ULONG nFmt
, USHORT nAction
, const Point
* pPt
,
2295 BYTE nActionFlags
, BOOL
/*bMsg*/ )
2301 BOOL bCheckForGrf
= FALSE
, bCheckForImageMap
= FALSE
;
2305 case SOT_FORMAT_BITMAP
:
2306 case SOT_FORMAT_GDIMETAFILE
:
2307 nRet
= rData
.GetGraphic( nFmt
, aGrf
);
2310 case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
:
2311 case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
:
2312 case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
:
2313 if( 0 != ( nRet
= rData
.GetINetBookmark( nFmt
, aBkmk
) ))
2315 /* if( SW_PASTESDR_SETATTR != nAction )
2317 INetURLObject aURL( aBkmk.GetURL() );
2318 bCheckForGrf = INET_PROT_FILE == aURL.GetProtocol();
2319 nRet = 0 != bCheckForGrf;
2322 if( SW_PASTESDR_SETATTR
== nAction
)
2323 nFmt
= SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
;
2325 bCheckForGrf
= TRUE
;
2329 case SOT_FORMAT_FILE
:
2332 if( 0 != ( nRet
= rData
.GetString( nFmt
, sTxt
) ) )
2335 SwTransferable::_CheckForURLOrLNKFile( rData
, sTxt
, &sDesc
);
2337 aBkmk
= INetBookmark(
2338 URIHelper::SmartRel2Abs(INetURLObject(), sTxt
, Link(), false ),
2340 bCheckForGrf
= TRUE
;
2341 bCheckForImageMap
= SW_PASTESDR_REPLACE
== nAction
;
2347 nRet
= rData
.GetGraphic( nFmt
, aGrf
);
2353 //!!! auf FileSystem abpruefen - nur dann ist es sinnvoll die
2354 // Grafiken zu testen !!!!
2355 GraphicFilter
*pFlt
= ::GetGrfFilter();
2356 nRet
= GRFILTER_OK
== ::LoadGraphic( aBkmk
.GetURL(), aEmptyStr
,
2358 if( !nRet
&& SW_PASTESDR_SETATTR
== nAction
&&
2359 SOT_FORMAT_FILE
== nFmt
&&
2360 // Bug 63031 - nur bei Rahmenselektion
2361 rSh
.IsFrmSelected() )
2363 // dann als Hyperlink hinter die Grafik setzen
2364 nFmt
= SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
;
2372 if( rSh
.GetView().GetDocShell()->ISA(SwWebDocShell
) )
2373 sURL
= aBkmk
.GetURL();
2377 case SW_PASTESDR_INSERT
:
2378 SwTransferable::SetSelInShell( rSh
, FALSE
, pPt
);
2379 rSh
.Insert( sURL
, aEmptyStr
, aGrf
);
2382 case SW_PASTESDR_REPLACE
:
2383 if( rSh
.IsObjSelected() )
2385 rSh
.ReplaceSdrObj( sURL
, aEmptyStr
, &aGrf
);
2386 Point
aPt( pPt
? *pPt
: rSh
.GetCrsrDocPos() );
2387 SwTransferable::SetSelInShell( rSh
, TRUE
, &aPt
);
2390 rSh
.ReRead( sURL
, aEmptyStr
, &aGrf
);
2393 case SW_PASTESDR_SETATTR
:
2394 if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
== nFmt
)
2396 if( rSh
.IsFrmSelected() )
2398 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
2399 rSh
.GetFlyFrmAttr( aSet
);
2400 SwFmtURL
aURL( (SwFmtURL
&)aSet
.Get( RES_URL
) );
2401 aURL
.SetURL( aBkmk
.GetURL(), FALSE
);
2403 rSh
.SetFlyFrmAttr( aSet
);
2406 else if( rSh
.IsObjSelected() )
2408 else if( OBJCNT_GRF
== rSh
.GetObjCntTypeOfSelection() )
2409 rSh
.ReRead( sURL
, aEmptyStr
, &aGrf
);
2412 SwTransferable::SetSelInShell( rSh
, FALSE
, pPt
);
2413 rSh
.Insert( aBkmk
.GetURL(), aEmptyStr
, aGrf
);
2425 (( EXCHG_OUT_ACTION_FLAG_INSERT_IMAGEMAP
|
2426 EXCHG_OUT_ACTION_FLAG_REPLACE_IMAGEMAP
) >> 8) )
2427 SwTransferable::_PasteImageMap( rData
, rSh
);
2430 ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL
>> 8) )
2431 SwTransferable::_PasteTargetURL( rData
, rSh
, 0, 0, FALSE
);
2433 else if( bCheckForImageMap
)
2435 // oder sollte das File ein ImageMap-File sein?
2437 SfxMedium
aMed( INetURLObject(aBkmk
.GetURL()).GetFull(),
2438 STREAM_STD_READ
, FALSE
);
2439 SvStream
* pStream
= aMed
.GetInStream();
2440 if( pStream
!= NULL
&&
2441 !pStream
->GetError() &&
2442 // mba: no BaseURL for clipboard functionality
2443 aMap
.Read( *pStream
, IMAP_FORMAT_DETECT
, String() ) == IMAP_ERR_OK
&&
2444 aMap
.GetIMapObjectCount() )
2446 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
2447 rSh
.GetFlyFrmAttr( aSet
);
2448 SwFmtURL
aURL( (SwFmtURL
&)aSet
.Get( RES_URL
) );
2449 aURL
.SetMap( &aMap
);
2451 rSh
.SetFlyFrmAttr( aSet
);
2459 // -----------------------------------------------------------------------
2461 int SwTransferable::_PasteImageMap( TransferableDataHelper
& rData
,
2465 if( rData
.HasFormat( SOT_FORMATSTR_ID_SVIM
))
2467 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
2468 rSh
.GetFlyFrmAttr( aSet
);
2469 SwFmtURL
aURL( (SwFmtURL
&)aSet
.Get( RES_URL
) );
2470 const ImageMap
* pOld
= aURL
.GetMap();
2472 // setzen oder ersetzen ist hier die Frage
2474 if( rData
.GetImageMap( SOT_FORMATSTR_ID_SVIM
, aImageMap
) &&
2475 ( !pOld
|| aImageMap
!= *pOld
))
2477 aURL
.SetMap( &aImageMap
);
2479 rSh
.SetFlyFrmAttr( aSet
);
2486 // -----------------------------------------------------------------------
2488 int SwTransferable::_PasteAsHyperlink( TransferableDataHelper
& rData
,
2489 SwWrtShell
& rSh
, ULONG nFmt
)
2493 if( rData
.GetString( nFmt
, sFile
) && sFile
.Len() )
2496 SwTransferable::_CheckForURLOrLNKFile( rData
, sFile
, &sDesc
);
2498 //#41801# ersteinmal die URL absolut machen
2500 aURL
.SetSmartProtocol( INET_PROT_FILE
);
2501 aURL
.SetSmartURL( sFile
);
2502 sFile
= aURL
.GetMainURL( INetURLObject::NO_DECODE
);
2504 switch( rSh
.GetObjCntTypeOfSelection() )
2510 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
2511 rSh
.GetFlyFrmAttr( aSet
);
2512 SwFmtURL
aURL2( (SwFmtURL
&)aSet
.Get( RES_URL
) );
2513 aURL2
.SetURL( sFile
, FALSE
);
2514 if( !aURL2
.GetName().Len() )
2515 aURL2
.SetName( sFile
);
2517 rSh
.SetFlyFrmAttr( aSet
);
2523 rSh
.InsertURL( SwFmtINetFmt( sFile
, aEmptyStr
),
2524 sDesc
.Len() ? sDesc
: sFile
);
2532 // -----------------------------------------------------------------------
2534 int SwTransferable::_PasteFileName( TransferableDataHelper
& rData
,
2535 SwWrtShell
& rSh
, ULONG nFmt
,
2536 USHORT nAction
, const Point
* pPt
,
2537 BYTE nActionFlags
, BOOL bMsg
)
2539 int nRet
= SwTransferable::_PasteGrf( rData
, rSh
, nFmt
, nAction
,
2540 pPt
, nActionFlags
, bMsg
);
2542 nRet
|= SWTRANSFER_GRAPHIC_INSERTED
;
2545 String sFile
, sDesc
;
2546 if( rData
.GetString( nFmt
, sFile
) && sFile
.Len() )
2548 INetURLObject aMediaURL
;
2550 aMediaURL
.SetSmartURL( sFile
);
2551 const String
aMediaURLStr( aMediaURL
.GetMainURL( INetURLObject::NO_DECODE
) );
2553 if( ::avmedia::MediaWindow::isMediaURL( aMediaURLStr
) )
2555 const SfxStringItem
aMediaURLItem( SID_INSERT_AVMEDIA
, aMediaURLStr
);
2556 rSh
.GetView().GetViewFrame()->GetDispatcher()->Execute(
2557 SID_INSERT_AVMEDIA
, SFX_CALLMODE_SYNCHRON
,
2558 &aMediaURLItem
, 0L );
2562 BOOL bIsURLFile
= SwTransferable::_CheckForURLOrLNKFile( rData
, sFile
, &sDesc
);
2564 //Eigenes FileFormat? -->Einfuegen, nicht fuer StarWriter/Web
2565 String sFileURL
= URIHelper::SmartRel2Abs(INetURLObject(), sFile
, Link(), false );
2566 const SfxFilter
* pFlt
= SW_PASTESDR_SETATTR
== nAction
2567 ? 0 : SwIoSystem::GetFileFilter(
2568 sFileURL
, aEmptyStr
);
2569 if( pFlt
&& !rSh
.GetView().GetDocShell()->ISA(SwWebDocShell
)
2571 JP 02.07.98: warum nur fuer die Formate ??
2572 && ( pFlt->GetUserData() == FILTER_SW5 ||
2573 pFlt->GetUserData() == FILTER_SW4 ||
2574 pFlt->GetUserData() == FILTER_SW3 ||
2575 pFlt->GetUserData() == FILTER_SWG )
2579 // und dann per PostUser Event den Bereich-Einfuegen-Dialog hochreissen
2580 SwSection
* pSect
= new SwSection( FILE_LINK_SECTION
,
2581 rSh
.GetDoc()->GetUniqueSectionName() );
2582 pSect
->SetLinkFileName( sFileURL
);
2583 pSect
->SetProtect( TRUE
);
2585 Application::PostUserEvent( STATIC_LINK( &rSh
, SwWrtShell
,
2586 InsertRegionDialog
), pSect
);
2589 else if( SW_PASTESDR_SETATTR
== nAction
||
2590 ( bIsURLFile
&& SW_PASTESDR_INSERT
== nAction
))
2592 //Fremde Files koennen wir immerhin noch als Links
2595 //#41801# ersteinmal die URL absolut machen
2597 aURL
.SetSmartProtocol( INET_PROT_FILE
);
2598 aURL
.SetSmartURL( sFile
);
2599 sFile
= aURL
.GetMainURL( INetURLObject::NO_DECODE
);
2601 switch( rSh
.GetObjCntTypeOfSelection() )
2607 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
2608 rSh
.GetFlyFrmAttr( aSet
);
2609 SwFmtURL
aURL2( (SwFmtURL
&)aSet
.Get( RES_URL
) );
2610 aURL2
.SetURL( sFile
, FALSE
);
2611 if( !aURL2
.GetName().Len() )
2612 aURL2
.SetName( sFile
);
2614 rSh
.SetFlyFrmAttr( aSet
);
2620 rSh
.InsertURL( SwFmtINetFmt( sFile
, aEmptyStr
),
2621 sDesc
.Len() ? sDesc
: sFile
);
2632 // -----------------------------------------------------------------------
2634 int SwTransferable::_PasteDBData( TransferableDataHelper
& rData
,
2635 SwWrtShell
& rSh
, ULONG nFmt
, BOOL bLink
,
2636 const Point
* pDragPt
, BOOL bMsg
)
2640 if( rData
.GetString( nFmt
, sTxt
) && sTxt
.Len() )
2642 USHORT nWh
= SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE
== nFmt
2644 : SOT_FORMATSTR_ID_SBA_DATAEXCHANGE
== nFmt
2646 ? FN_QRY_MERGE_FIELD
2650 : FN_QRY_INSERT_FIELD
);
2651 DataFlavorExVector
& rVector
= rData
.GetDataFlavorExVector();
2652 sal_Bool bHaveColumnDescriptor
= OColumnTransferable::canExtractColumnDescriptor(rVector
, CTF_COLUMN_DESCRIPTOR
| CTF_CONTROL_EXCHANGE
);
2653 if ( SOT_FORMATSTR_ID_XFORMS
== nFmt
)
2657 FmFormView
* pFmView
= PTR_CAST( FmFormView
, rSh
.GetDrawView() );
2659 const OXFormsDescriptor
&rDesc
= OXFormsTransferable::extractDescriptor(rData
);
2660 if(0 != (pObj
= pFmView
->CreateXFormsControl(rDesc
)))
2661 rSh
.SwFEShell::Insert( *pObj
, 0, 0, pDragPt
);
2666 SfxUsrAnyItem
* pConnectionItem
= 0;
2667 SfxUsrAnyItem
* pCursorItem
= 0;
2668 SfxUsrAnyItem
* pColumnItem
= 0;
2669 SfxUsrAnyItem
* pSourceItem
= 0;
2670 SfxUsrAnyItem
* pCommandItem
= 0;
2671 SfxUsrAnyItem
* pCommandTypeItem
= 0;
2672 SfxUsrAnyItem
* pColumnNameItem
= 0;
2673 SfxUsrAnyItem
* pSelectionItem
= 0;
2675 BOOL bDataAvailable
= TRUE
;
2676 ODataAccessDescriptor aDesc
;
2677 if(bHaveColumnDescriptor
)
2678 aDesc
= OColumnTransferable::extractColumnDescriptor(rData
);
2679 else if(ODataAccessObjectTransferable::canExtractObjectDescriptor(rVector
) )
2680 aDesc
= ODataAccessObjectTransferable::extractObjectDescriptor(rData
);
2682 bDataAvailable
= FALSE
;
2684 if ( bDataAvailable
)
2686 pConnectionItem
= new SfxUsrAnyItem(FN_DB_CONNECTION_ANY
, aDesc
[daConnection
]);
2687 pColumnItem
= new SfxUsrAnyItem(FN_DB_COLUMN_ANY
, aDesc
[daColumnObject
]);
2688 pSourceItem
= new SfxUsrAnyItem(FN_DB_DATA_SOURCE_ANY
, makeAny(aDesc
.getDataSource()));
2689 pCommandItem
= new SfxUsrAnyItem(FN_DB_DATA_COMMAND_ANY
, aDesc
[daCommand
]);
2690 pCommandTypeItem
= new SfxUsrAnyItem(FN_DB_DATA_COMMAND_TYPE_ANY
, aDesc
[daCommandType
]);
2691 pColumnNameItem
= new SfxUsrAnyItem(FN_DB_DATA_COLUMN_NAME_ANY
, aDesc
[daColumnName
]);
2692 pSelectionItem
= new SfxUsrAnyItem(FN_DB_DATA_SELECTION_ANY
, aDesc
[daSelection
]);
2693 pCursorItem
= new SfxUsrAnyItem(FN_DB_DATA_CURSOR_ANY
, aDesc
[daCursor
]);
2696 SwView
& rView
= rSh
.GetView();
2697 //force ::SelectShell
2698 rView
.StopShellTimer();
2700 SfxStringItem
aDataDesc( nWh
, sTxt
);
2701 rView
.GetViewFrame()->GetDispatcher()->Execute(
2702 nWh
, SFX_CALLMODE_ASYNCHRON
, &aDataDesc
,
2703 pConnectionItem
, pColumnItem
,
2704 pSourceItem
, pCommandItem
, pCommandTypeItem
,
2705 pColumnNameItem
, pSelectionItem
, pCursorItem
,0L);
2706 delete pConnectionItem
;
2709 delete pCommandItem
;
2710 delete pCommandTypeItem
;
2711 delete pColumnNameItem
;
2718 FmFormView
* pFmView
= PTR_CAST( FmFormView
, rSh
.GetDrawView() );
2719 if (pFmView
&& bHaveColumnDescriptor
)
2721 if ( 0 != (pObj
= pFmView
->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData
) ) ) )
2722 rSh
.SwFEShell::Insert( *pObj
, 0, 0, pDragPt
);
2729 InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR
)).Execute();
2734 // -----------------------------------------------------------------------
2736 int SwTransferable::_PasteFileList( TransferableDataHelper
& rData
,
2737 SwWrtShell
& rSh
, BOOL bLink
,
2738 const Point
* pPt
, BOOL bMsg
)
2742 if( rData
.GetFileList( SOT_FORMAT_FILE_LIST
, aFileList
) &&
2745 USHORT nAct
= bLink
? SW_PASTESDR_SETATTR
: SW_PASTESDR_INSERT
;
2747 // iterate over the filelist
2748 for( ULONG n
= 0, nEnd
= aFileList
.Count(); n
< nEnd
; ++n
)
2750 TransferDataContainer
* pHlp
= new TransferDataContainer
;
2751 pHlp
->CopyString( FORMAT_FILE
, aFileList
.GetFile( n
));
2752 TransferableDataHelper
aData( pHlp
);
2754 if( SwTransferable::_PasteFileName( aData
, rSh
, SOT_FORMAT_FILE
, nAct
,
2759 sFlyNm
= rSh
.GetFlyName();
2760 SwTransferable::SetSelInShell( rSh
, FALSE
, pPt
);
2766 rSh
.GotoFly( sFlyNm
);
2770 InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR
)).Execute();
2775 // -----------------------------------------------------------------------
2777 BOOL
SwTransferable::_CheckForURLOrLNKFile( TransferableDataHelper
& rData
,
2778 String
& rFileName
, String
* pTitle
)
2780 BOOL bIsURLFile
= FALSE
;
2782 if( rData
.GetINetBookmark( SOT_FORMATSTR_ID_SOLK
, aBkmk
) )
2784 rFileName
= aBkmk
.GetURL();
2786 *pTitle
= aBkmk
.GetDescription();
2791 xub_StrLen nLen
= rFileName
.Len();
2792 if( 4 < nLen
&& '.' == rFileName
.GetChar( nLen
- 4 ))
2794 String
sExt( rFileName
.Copy( nLen
- 3 ));
2795 if( sExt
.EqualsIgnoreCaseAscii( "url" ))
2797 ASSERT( !&rFileName
, "how do we read today .URL - Files?" );
2804 // -----------------------------------------------------------------------
2806 BOOL
SwTransferable::IsPasteSpecial( const SwWrtShell
& rWrtShell
,
2807 const TransferableDataHelper
& rData
)
2809 // we can paste-special if there's an entry in the paste-special-format list
2810 SvxClipboardFmtItem
aClipboardFmtItem(0);
2811 FillClipFmtItem( rWrtShell
, rData
, aClipboardFmtItem
);
2812 return aClipboardFmtItem
.Count() > 0;
2815 // -----------------------------------------------------------------------
2817 int SwTransferable::PasteFormat( SwWrtShell
& rSh
,
2818 TransferableDataHelper
& rData
,
2821 SwWait
aWait( *rSh
.GetView().GetDocShell(), FALSE
);
2824 ULONG nPrivateFmt
= FORMAT_PRIVATE
;
2825 SwTransferable
*pClipboard
= SW_MOD()->pClipboard
;
2827 ((TRNSFR_DOCUMENT
|TRNSFR_GRAPHIC
|TRNSFR_OLE
) & pClipboard
->eBufferType
))
2828 nPrivateFmt
= SOT_FORMATSTR_ID_EMBED_SOURCE
;
2830 if( pClipboard
&& nPrivateFmt
== nFormat
)
2831 nRet
= pClipboard
->PrivatePaste( rSh
);
2832 else if( rData
.HasFormat( nFormat
) )
2834 uno::Reference
<XTransferable
> xTransferable( rData
.GetXTransferable() );
2835 USHORT nEventAction
,
2836 nDestination
= SwTransferable::GetSotDestination( rSh
),
2838 (( EXCHG_DEST_DOC_TEXTFRAME
== nDestination
||
2839 EXCHG_DEST_SWDOC_FREE_AREA
== nDestination
||
2840 EXCHG_DEST_DOC_TEXTFRAME_WEB
== nDestination
||
2841 EXCHG_DEST_SWDOC_FREE_AREA_WEB
== nDestination
)
2842 ? EXCHG_IN_ACTION_COPY
2843 : EXCHG_IN_ACTION_MOVE
),
2844 nAction
= SotExchange::GetExchangeAction(
2845 rData
.GetDataFlavorExVector(),
2847 nSourceOptions
, /* ?? */
2848 EXCHG_IN_ACTION_DEFAULT
, /* ?? */
2849 nFormat
, nEventAction
, nFormat
,
2850 lcl_getTransferPointer ( xTransferable
) );
2852 if( EXCHG_INOUT_ACTION_NONE
!= nAction
)
2853 nRet
= SwTransferable::PasteData( rData
, rSh
, nAction
, nFormat
,
2854 nDestination
, TRUE
, FALSE
);
2859 // -----------------------------------------------------------------------
2861 int SwTransferable::_TestAllowedFormat( const TransferableDataHelper
& rData
,
2862 ULONG nFormat
, USHORT nDestination
)
2864 USHORT nAction
= EXCHG_INOUT_ACTION_NONE
, nEventAction
;
2865 if( rData
.HasFormat( nFormat
)) {
2866 uno::Reference
<XTransferable
> xTransferable( rData
.GetXTransferable() );
2867 nAction
= SotExchange::GetExchangeAction(
2868 rData
.GetDataFlavorExVector(),
2869 nDestination
, EXCHG_IN_ACTION_COPY
,
2870 EXCHG_IN_ACTION_COPY
, nFormat
,
2871 nEventAction
, nFormat
,
2872 lcl_getTransferPointer ( xTransferable
) );
2874 return EXCHG_INOUT_ACTION_NONE
!= nAction
;
2877 // -----------------------------------------------------------------------
2880 * the list of formats which will be offered to the user in the 'Paste
2881 * Special...' dialog and the paste button menu
2883 static USHORT aPasteSpecialIds
[] =
2885 SOT_FORMATSTR_ID_HTML
,
2886 SOT_FORMATSTR_ID_HTML_SIMPLE
,
2887 SOT_FORMATSTR_ID_HTML_NO_COMMENT
,
2890 SOT_FORMATSTR_ID_SONLK
,
2891 SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
,
2892 SOT_FORMATSTR_ID_DRAWING
,
2893 SOT_FORMATSTR_ID_SVXB
,
2896 SOT_FORMATSTR_ID_SVIM
,
2897 SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
,
2902 int SwTransferable::PasteUnformatted( SwWrtShell
& rSh
, TransferableDataHelper
& rData
)
2904 // Plain text == unformatted
2905 return SwTransferable::PasteFormat( rSh
, rData
, SOT_FORMAT_STRING
);
2908 // -----------------------------------------------------------------------
2910 int SwTransferable::PasteSpecial( SwWrtShell
& rSh
, TransferableDataHelper
& rData
, ULONG
& rFormatUsed
)
2913 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
2914 SfxAbstractPasteDialog
* pDlg
= pFact
->CreatePasteDialog( &rSh
.GetView().GetEditWin() );
2916 DataFlavorExVector
aFormats( rData
.GetDataFlavorExVector() );
2917 TransferableObjectDescriptor aDesc
;
2919 USHORT nDest
= SwTransferable::GetSotDestination( rSh
);
2921 SwTransferable
*pClipboard
= SW_MOD()->pClipboard
;
2924 aDesc
= pClipboard
->aObjDesc
;
2926 if( pClipboard
->eBufferType
& TRNSFR_DOCUMENT
)
2927 nResId
= STR_PRIVATETEXT
;
2928 else if( pClipboard
->eBufferType
& TRNSFR_GRAPHIC
)
2929 nResId
= STR_PRIVATEGRAPHIC
;
2930 else if( pClipboard
->eBufferType
== TRNSFR_OLE
)
2931 nResId
= STR_PRIVATEOLE
;
2937 if( STR_PRIVATEOLE
== nResId
|| STR_PRIVATEGRAPHIC
== nResId
)
2939 // add SOT_FORMATSTR_ID_EMBED_SOURCE to the formats. This
2940 // format display then the private format name.
2941 DataFlavorEx aFlavorEx
;
2942 aFlavorEx
.mnSotId
= SOT_FORMATSTR_ID_EMBED_SOURCE
;
2943 aFormats
.insert( aFormats
.begin(), aFlavorEx
);
2945 pDlg
->SetObjName( pClipboard
->aObjDesc
.maClassName
,
2947 pDlg
->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE
, aEmptyStr
);
2952 if( rData
.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
) )
2953 rData
.GetTransferableObjectDescriptor(
2954 SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
, aDesc
);
2956 if( SwTransferable::_TestAllowedFormat( rData
, SOT_FORMATSTR_ID_EMBED_SOURCE
, nDest
))
2957 pDlg
->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE
, aEmptyStr
);
2958 if( SwTransferable::_TestAllowedFormat( rData
, SOT_FORMATSTR_ID_LINK_SOURCE
, nDest
))
2959 pDlg
->Insert( SOT_FORMATSTR_ID_LINK_SOURCE
, aEmptyStr
);
2962 if( SwTransferable::_TestAllowedFormat( rData
, SOT_FORMATSTR_ID_LINK
, nDest
))
2963 pDlg
->Insert( SOT_FORMATSTR_ID_LINK
, SW_RES(STR_DDEFORMAT
) );
2965 for( USHORT
* pIds
= aPasteSpecialIds
; *pIds
; ++pIds
)
2966 if( SwTransferable::_TestAllowedFormat( rData
, *pIds
, nDest
))
2967 pDlg
->Insert( *pIds
, aEmptyStr
);
2969 ULONG nFormat
= pDlg
->GetFormat( rData
.GetTransferable() );
2972 nRet
= SwTransferable::PasteFormat( rSh
, rData
, nFormat
);
2975 rFormatUsed
= nFormat
;
2982 void SwTransferable::FillClipFmtItem( const SwWrtShell
& rSh
,
2983 const TransferableDataHelper
& rData
,
2984 SvxClipboardFmtItem
& rToFill
)
2986 USHORT nDest
= SwTransferable::GetSotDestination( rSh
);
2987 SwTransferable
*pClipboard
= SW_MOD()->pClipboard
;
2991 if( pClipboard
->eBufferType
& TRNSFR_DOCUMENT
)
2992 nResId
= STR_PRIVATETEXT
;
2993 else if( pClipboard
->eBufferType
& TRNSFR_GRAPHIC
)
2994 nResId
= STR_PRIVATEGRAPHIC
;
2995 else if( pClipboard
->eBufferType
== TRNSFR_OLE
)
2996 nResId
= STR_PRIVATEOLE
;
3001 rToFill
.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
,
3006 TransferableObjectDescriptor aDesc
;
3007 if( rData
.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
) )
3008 ((TransferableDataHelper
&)rData
).GetTransferableObjectDescriptor(
3009 SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
, aDesc
);
3011 if( SwTransferable::_TestAllowedFormat( rData
, SOT_FORMATSTR_ID_EMBED_SOURCE
, nDest
))
3012 rToFill
.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
,
3014 if( SwTransferable::_TestAllowedFormat( rData
, SOT_FORMATSTR_ID_LINK_SOURCE
, nDest
))
3015 rToFill
.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK_SOURCE
);
3017 SotFormatStringId nFormat
;
3018 if ( rData
.HasFormat(nFormat
= SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
) || rData
.HasFormat(nFormat
= SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
) )
3020 String sName
,sSource
;
3021 if ( SvPasteObjectHelper::GetEmbeddedName(rData
,sName
,sSource
,nFormat
) )
3022 rToFill
.AddClipbrdFormat( nFormat
, sName
);
3026 if( SwTransferable::_TestAllowedFormat( rData
, SOT_FORMATSTR_ID_LINK
, nDest
))
3027 rToFill
.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK
, SW_RES(STR_DDEFORMAT
) );
3029 for( USHORT
* pIds
= aPasteSpecialIds
; *pIds
; ++pIds
)
3030 if( SwTransferable::_TestAllowedFormat( rData
, *pIds
, nDest
))
3031 rToFill
.AddClipbrdFormat( *pIds
, aEmptyStr
);
3034 void SwTransferable::SetDataForDragAndDrop( const Point
& rSttPos
)
3039 const int nSelection
= pWrtShell
->GetSelectionType();
3040 if( nsSelectionType::SEL_GRF
== nSelection
)
3042 AddFormat( SOT_FORMATSTR_ID_SVXB
);
3043 // --> OD 2005-02-09 #119353# - robust
3044 const Graphic
* pGrf
= pWrtShell
->GetGraphic();
3045 if ( pGrf
&& pGrf
->IsSupportedGraphic() )
3048 AddFormat( FORMAT_GDIMETAFILE
);
3049 AddFormat( FORMAT_BITMAP
);
3051 eBufferType
= TRNSFR_GRAPHIC
;
3052 pWrtShell
->GetGrfNms( &sGrfNm
, 0 );
3054 else if( nsSelectionType::SEL_OLE
== nSelection
)
3056 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
3057 PrepareOLE( aObjDesc
);
3058 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
3059 AddFormat( FORMAT_GDIMETAFILE
);
3060 eBufferType
= TRNSFR_OLE
;
3062 //Gibt es ueberhaupt etwas zum bereitstellen?
3063 else if ( pWrtShell
->IsSelection() || pWrtShell
->IsFrmSelected() ||
3064 pWrtShell
->IsObjSelected() )
3066 if( pWrtShell
->IsObjSelected() )
3067 eBufferType
= TRNSFR_DRAWING
;
3070 eBufferType
= TRNSFR_DOCUMENT
;
3071 if( SwWrtShell::NO_WORD
!=
3072 pWrtShell
->IntelligentCut( nSelection
, FALSE
))
3073 eBufferType
= TransferBufferType( TRNSFR_DOCUMENT_WORD
3077 if( nSelection
& nsSelectionType::SEL_TBL_CELLS
)
3078 eBufferType
= (TransferBufferType
)(TRNSFR_TABELLE
| eBufferType
);
3080 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
3082 //RTF vor das Metafile von OLE stellen, weil mit weniger verlusten
3084 if( !pWrtShell
->IsObjSelected() )
3086 AddFormat( FORMAT_RTF
);
3087 AddFormat( SOT_FORMATSTR_ID_HTML
);
3089 if( pWrtShell
->IsSelection() )
3090 AddFormat( FORMAT_STRING
);
3092 if( nSelection
& ( nsSelectionType::SEL_DRW
| nsSelectionType::SEL_DRW_FORM
))
3094 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
3095 if ( nSelection
& nsSelectionType::SEL_DRW
)
3097 AddFormat( FORMAT_GDIMETAFILE
);
3098 AddFormat( FORMAT_BITMAP
);
3100 eBufferType
= (TransferBufferType
)( TRNSFR_GRAPHIC
| eBufferType
);
3102 pClpGraphic
= new Graphic
;
3103 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_GDIMETAFILE
, *pClpGraphic
))
3104 pOrigGrf
= pClpGraphic
;
3105 pClpBitmap
= new Graphic
;
3106 if( !pWrtShell
->GetDrawObjGraphic( FORMAT_BITMAP
, *pClpBitmap
))
3107 pOrigGrf
= pClpBitmap
;
3109 // ist es ein URL-Button ?
3111 if( pWrtShell
->GetURLFromButton( sURL
, sDesc
) )
3113 AddFormat( FORMAT_STRING
);
3114 AddFormat( SOT_FORMATSTR_ID_SOLK
);
3115 AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
);
3116 AddFormat( SOT_FORMATSTR_ID_FILECONTENT
);
3117 AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
);
3118 AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
);
3119 eBufferType
= (TransferBufferType
)( TRNSFR_INETFLD
| eBufferType
);
3123 //ObjectDescriptor wurde bereits aus der alten DocShell gefuellt.
3124 //Jetzt noch anpassen. Dadurch kann im GetData die erste Anfrage
3125 //auch noch mit delayed rendering beantwortet werden.
3126 aObjDesc
.mbCanLink
= FALSE
;
3127 aObjDesc
.maDragStartPos
= rSttPos
;
3128 aObjDesc
.maSize
= OutputDevice::LogicToLogic( Size( OLESIZE
),
3129 MAP_TWIP
, MAP_100TH_MM
);
3130 PrepareOLE( aObjDesc
);
3131 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
3133 else if( nSelection
& nsSelectionType::SEL_TXT
&& !pWrtShell
->HasMark() )
3135 // ist nur ein Feld - Selektiert?
3136 SwContentAtPos
aCntntAtPos( SwContentAtPos::SW_INETATTR
);
3137 Point
aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
3139 if( pWrtShell
->GetContentAtPos( aPos
, aCntntAtPos
) )
3141 AddFormat( FORMAT_STRING
);
3142 AddFormat( SOT_FORMATSTR_ID_SOLK
);
3143 AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
);
3144 AddFormat( SOT_FORMATSTR_ID_FILECONTENT
);
3145 AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
);
3146 AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
);
3147 eBufferType
= TRNSFR_INETFLD
;
3151 if( pWrtShell
->IsFrmSelected() )
3153 SfxItemSet
aSet( pWrtShell
->GetAttrPool(), RES_URL
, RES_URL
);
3154 pWrtShell
->GetFlyFrmAttr( aSet
);
3155 const SwFmtURL
& rURL
= (SwFmtURL
&)aSet
.Get( RES_URL
);
3158 pImageMap
= new ImageMap( *rURL
.GetMap() );
3159 AddFormat( SOT_FORMATSTR_ID_SVIM
);
3161 else if( rURL
.GetURL().Len() )
3163 pTargetURL
= new INetImage( sGrfNm
, rURL
.GetURL(),
3164 rURL
.GetTargetFrameName(),
3165 aEmptyStr
, Size() );
3166 AddFormat( SOT_FORMATSTR_ID_INET_IMAGE
);
3171 void SwTransferable::StartDrag( Window
* pWin
, const Point
& rPos
)
3175 bOldIdle
= pWrtShell
->GetViewOptions()->IsIdle();
3178 ((SwViewOption
*)pWrtShell
->GetViewOptions())->SetIdle( FALSE
);
3180 if( pWrtShell
->IsSelFrmMode() )
3181 pWrtShell
->ShowCrsr();
3183 SW_MOD()->pDragDrop
= this;
3185 SetDataForDragAndDrop( rPos
);
3187 sal_Int8 nDragOptions
= DND_ACTION_COPYMOVE
| DND_ACTION_LINK
;
3188 SwDocShell
* pDShell
= pWrtShell
->GetView().GetDocShell();
3189 if( ( pDShell
&& pDShell
->IsReadOnly() ) || pWrtShell
->HasReadonlySel() )
3190 nDragOptions
&= ~DND_ACTION_MOVE
;
3192 TransferableHelper::StartDrag( pWin
, nDragOptions
);
3195 void SwTransferable::DragFinished( sal_Int8 nAction
)
3197 //Und noch die letzten Nacharbeiten damit alle Stati stimmen.
3198 if( DND_ACTION_MOVE
== nAction
)
3202 //Es wurde auserhalb des Writers gedroped. Wir muessen noch
3205 pWrtShell
->StartAllAction();
3206 pWrtShell
->StartUndo( UNDO_UI_DRAG_AND_MOVE
);
3207 if ( pWrtShell
->IsTableMode() )
3208 pWrtShell
->DeleteTblSel();
3211 if ( !(pWrtShell
->IsSelFrmMode() || pWrtShell
->IsObjSelected()) )
3212 //SmartCut, eines der Blanks mitnehmen.
3213 pWrtShell
->IntelligentCut( pWrtShell
->GetSelectionType(), TRUE
);
3214 pWrtShell
->DelRight();
3216 pWrtShell
->EndUndo( UNDO_UI_DRAG_AND_MOVE
);
3217 pWrtShell
->EndAllAction();
3221 const int nSelection
= pWrtShell
->GetSelectionType();
3222 if( ( nsSelectionType::SEL_FRM
| nsSelectionType::SEL_GRF
|
3223 nsSelectionType::SEL_OLE
| nsSelectionType::SEL_DRW
) & nSelection
)
3225 pWrtShell
->EnterSelFrmMode();
3229 pWrtShell
->GetView().GetEditWin().DragFinished();
3231 if( pWrtShell
->IsSelFrmMode() )
3232 pWrtShell
->HideCrsr();
3234 pWrtShell
->ShowCrsr();
3235 //!! else if( DND_ACTION_NONE != nAction )
3236 //!! pWrtShell->ShowCrsr();
3239 //!! //Muss wohl sein weil gescrollt wurde und ?...?
3240 //!! pWrtShell->StartAction();
3241 //!! pWrtShell->EndAction();
3244 ((SwViewOption
*)pWrtShell
->GetViewOptions())->SetIdle( bOldIdle
);
3250 int SwTransferable::PrivatePaste( SwWrtShell
& rShell
)
3252 // erst den SelectionType erfragen, dann Action-Klammerung !!!!
3253 // (sonst wird nicht in eine TabellenSelektion gepastet!!!)
3254 ASSERT( !rShell
.ActionPend(), "Paste darf nie eine Actionklammerung haben" );
3256 return sal_False
; // the return value of the SwFEShell::Paste also is BOOL!
3258 const int nSelection
= rShell
.GetSelectionType();
3261 SwRewriter aRewriter
;
3263 SwTrnsfrActionAndUndo
aAction( &rShell
, UNDO_PASTE_CLIPBOARD
);
3265 bool bKillPaMs
= false;
3267 //Selektierten Inhalt loeschen, nicht bei Tabellen-Selektion und
3268 //Tabelle im Clipboard
3269 if( rShell
.HasSelection() && !( nSelection
& nsSelectionType::SEL_TBL_CELLS
))
3272 rShell
.SetRetainSelection( true );
3274 // war ein Fly selektiert, so muss jetzt fuer eine gueltige
3275 // Cursor-Position gesorgt werden! (geparkter Cursor!)
3276 if( ( nsSelectionType::SEL_FRM
| nsSelectionType::SEL_GRF
|
3277 nsSelectionType::SEL_OLE
| nsSelectionType::SEL_DRW
|
3278 nsSelectionType::SEL_DRW_FORM
) & nSelection
)
3280 // den Cursor wieder positionieren
3281 Point
aPt( rShell
.GetCharRect().Pos() );
3282 rShell
.SwCrsrShell::SetCrsr( aPt
, TRUE
);
3284 rShell
.SetRetainSelection( false );
3287 BOOL bInWrd
= FALSE
, bEndWrd
= FALSE
, bSttWrd
= FALSE
,
3288 bSmart
= 0 != (TRNSFR_DOCUMENT_WORD
& eBufferType
);
3291 // #108491# Why not for other Scripts? If TRNSFR_DOCUMENT_WORD is set, we have
3292 // a word in the buffer, word in this context means 'something with spaces at
3293 // beginning and end'. In this case we definitely want these spaces to be inserted
3295 // if( SCRIPTTYPE_LATIN != rShell.GetScriptType() )
3299 bInWrd
= rShell
.IsInWrd();
3300 bEndWrd
= rShell
.IsEndWrd();
3301 bSmart
= bInWrd
|| bEndWrd
;
3304 bSttWrd
= rShell
.IsSttWrd();
3305 if( bSmart
&& !bSttWrd
&& (bInWrd
|| bEndWrd
) )
3306 rShell
.SwEditShell::Insert(' ');
3311 int nRet
= rShell
.Paste( pClpDocFac
->GetDoc() );
3316 // Wenn Smart Paste dann Leerzeichen einfuegen
3317 if( nRet
&& bSmart
&& ((bInWrd
&& !bEndWrd
)|| bSttWrd
) )
3318 rShell
.SwEditShell::Insert(' ');
3323 int SwTransferable::PrivateDrop( SwWrtShell
& rSh
, const Point
& rDragPt
,
3324 BOOL bMove
, BOOL bIsXSelection
)
3327 BOOL bInWrd
= FALSE
;
3328 BOOL bEndWrd
= FALSE
;
3329 BOOL bSttWrd
= FALSE
;
3330 BOOL bSttPara
= FALSE
;
3331 BOOL bTblSel
= FALSE
;
3332 BOOL bFrmSel
= FALSE
;
3334 SwWrtShell
& rSrcSh
= *GetShell();
3338 if( TRNSFR_INETFLD
== eBufferType
)
3340 if( rSh
.GetFmtFromObj( rDragPt
) )
3343 if( (TRNSFR_INETFLD
& eBufferType
) && pBkmk
)
3346 // Zielgrafik selektieren
3347 if( rSh
.SelectObj( rDragPt
) )
3350 rSh
.EnterSelFrmMode( &rDragPt
);
3354 const int nSelection
= rSh
.GetSelectionType();
3356 // Draw-Objekte erstmal noch nicht beruecksichtigen
3357 if( nsSelectionType::SEL_GRF
& nSelection
)
3359 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_URL
, RES_URL
);
3360 rSh
.GetFlyFrmAttr( aSet
);
3361 SwFmtURL
aURL( (SwFmtURL
&)aSet
.Get( RES_URL
) );
3362 aURL
.SetURL( aTmp
.GetURL(), FALSE
);
3364 rSh
.SetFlyFrmAttr( aSet
);
3368 if( nsSelectionType::SEL_DRW
& nSelection
)
3370 rSh
.LeaveSelFrmMode();
3378 if( &rSh
!= &rSrcSh
&& (nsSelectionType::SEL_GRF
& rSh
.GetSelectionType()) &&
3379 TRNSFR_GRAPHIC
== eBufferType
)
3381 // ReRead auf die Grafik
3382 String sGrfNm
, sFltNm
;
3383 rSrcSh
.GetGrfNms( &sGrfNm
, &sFltNm
);
3384 rSh
.ReRead( sGrfNm
, sFltNm
, rSrcSh
.GetGraphic() );
3388 //Nicht in Selektionen oder selektierten Rahmen
3389 if( rSh
.ChgCurrPam( rDragPt
) ||
3390 ( rSh
.IsSelFrmMode() && rSh
.IsInsideSelectedObj( rDragPt
)) )
3393 if( rSrcSh
.IsTableMode() )
3395 else if( rSrcSh
.IsSelFrmMode() || rSrcSh
.IsObjSelected() )
3397 // keine positionsgeschuetzten Objecte verschieben!
3398 if( bMove
&& rSrcSh
.IsSelObjProtected( FLYPROTECT_POS
) )
3404 const int nSel
= rSrcSh
.GetSelectionType();
3406 SwUndoId eUndoId
= bMove
? UNDO_UI_DRAG_AND_MOVE
: UNDO_UI_DRAG_AND_COPY
;
3409 SwRewriter aRewriter
;
3411 aRewriter
.AddRule(UNDO_ARG1
, rSrcSh
.GetSelDescr());
3413 if(rSrcSh
.GetDoc() != rSh
.GetDoc())
3414 rSrcSh
.StartUndo( eUndoId
, &aRewriter
);
3415 rSh
.StartUndo( eUndoId
, &aRewriter
);
3418 rSrcSh
.StartAction();
3420 if( &rSrcSh
!= &rSh
)
3423 rSh
.SwCrsrShell::SetCrsr( rDragPt
, TRUE
);
3424 cWord
= rSrcSh
.IntelligentCut( nSel
, FALSE
);
3426 else if( !bTblSel
&& !bFrmSel
)
3428 if( !rSh
.IsAddMode() )
3430 // --> OD 2008-03-19 #i87233#
3431 if ( rSh
.IsBlockMode() )
3433 // preserve order of cursors for block mode
3437 rSh
.SwCrsrShell::CreateCrsr();
3439 rSh
.SwCrsrShell::SetCrsr( rDragPt
, TRUE
, false );
3441 cWord
= rSh
.IntelligentCut( rSh
.GetSelectionType(), FALSE
);
3445 bInWrd
= rSh
.IsInWrd();
3446 bEndWrd
= rSh
.IsEndWrd();
3447 bSttWrd
= !bEndWrd
&& rSh
.IsSttWrd();
3448 bSttPara
= rSh
.IsSttPara();
3450 Point
aSttPt( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY() );
3452 //JP 05.03.96: INetFelder erstmal selektieren !
3453 if( TRNSFR_INETFLD
== eBufferType
)
3455 if( &rSrcSh
== &rSh
)
3458 rSh
.SwCrsrShell::SetCrsr( aSttPt
, TRUE
);
3459 rSh
.SelectTxtAttr( RES_TXTATR_INETFMT
);
3460 if( rSh
.ChgCurrPam( rDragPt
) )
3462 // nicht in sich selbst kopieren/verschieben
3464 rSh
.EndUndo( eUndoId
);
3473 rSrcSh
.SwCrsrShell::SetCrsr( aSttPt
, TRUE
);
3474 rSrcSh
.SelectTxtAttr( RES_TXTATR_INETFMT
);
3477 // ist am Einfuege Punkt ein URL-Attribut? Dann das ersetzen,
3478 // also einfach eine Selektion aufspannen?
3479 rSh
.DelINetAttrWithText();
3483 if ( rSrcSh
.IsSelFrmMode() )
3485 //Hack: Spezialbehandlung austricksen
3486 aSttPt
-= aSttPt
- rSrcSh
.GetObjRect().Pos();
3489 BOOL bRet
= rSrcSh
.SwFEShell::Copy( &rSh
, aSttPt
, rDragPt
, bMove
,
3492 if( !bIsXSelection
)
3495 if ( bRet
&& bMove
&& !bFrmSel
)
3499 /* #109590# delete table contents not cells */
3504 //SmartCut, eines der Blank mitnehmen.
3505 rSh
.SwCrsrShell::DestroyCrsr();
3506 if ( cWord
== SwWrtShell::WORD_SPACE_BEFORE
)
3507 rSh
.ExtendSelection( FALSE
);
3508 else if ( cWord
== SwWrtShell::WORD_SPACE_AFTER
)
3509 rSh
.ExtendSelection();
3514 rSrcSh
.Pop( FALSE
);
3516 /* #109590# after dragging a table selection inside one shell
3517 set cursor to the drop position. */
3518 if( &rSh
== &rSrcSh
&& ( bTblSel
|| rSh
.IsBlockMode() ) )
3520 rSrcSh
.SwCrsrShell::SetCrsr(rDragPt
);
3521 rSrcSh
.GetSwCrsr()->SetMark();
3525 if( bRet
&& !bTblSel
&& !bFrmSel
)
3527 if( (bInWrd
|| bEndWrd
) &&
3528 (cWord
== SwWrtShell::WORD_SPACE_AFTER
||
3529 cWord
== SwWrtShell::WORD_SPACE_BEFORE
) )
3531 if ( bSttWrd
|| (bInWrd
&& !bEndWrd
))
3532 rSh
.SwEditShell::Insert(' ', bIsXSelection
);
3533 if ( !bSttWrd
|| (bInWrd
&& !bSttPara
) )
3537 rSh
.SwEditShell::Insert(' ', bIsXSelection
);
3544 if( &rSrcSh
== &rSh
&& !rSh
.IsAddMode() )
3546 rSh
.SwCrsrShell::DestroyCrsr();
3552 rSh
.SwCrsrShell::ClearMark();
3557 if( rSh
.IsAddMode() )
3558 rSh
.SwCrsrShell::CreateCrsr();
3561 // Selektionsmodus einschalten
3568 if( bRet
&& bMove
&& bFrmSel
)
3569 rSrcSh
.LeaveSelFrmMode();
3571 if( rSrcSh
.GetDoc() != rSh
.GetDoc() )
3572 rSrcSh
.EndUndo( eUndoId
);
3573 rSh
.EndUndo( eUndoId
);
3575 // Shell in den richtigen Status versetzen
3576 if( &rSrcSh
!= &rSh
&& ( rSh
.IsFrmSelected() || rSh
.IsObjSelected() ))
3577 rSh
.EnterSelFrmMode();
3584 // Interfaces for Selection
3585 void SwTransferable::CreateSelection( SwWrtShell
& rSh
,
3586 const ViewShell
* _pCreatorView
)
3588 SwModule
*pMod
= SW_MOD();
3589 SwTransferable
* pNew
= new SwTransferable( rSh
);
3592 pNew
->pCreatorView
= _pCreatorView
;
3595 datatransfer::XTransferable
> xRef( pNew
);
3596 pMod
->pXSelection
= pNew
;
3597 pNew
->CopyToSelection( rSh
.GetWin() );
3600 void SwTransferable::ClearSelection( SwWrtShell
& rSh
,
3601 const ViewShell
* _pCreatorView
)
3603 SwModule
*pMod
= SW_MOD();
3604 if( pMod
->pXSelection
&&
3605 ((!pMod
->pXSelection
->pWrtShell
) || (pMod
->pXSelection
->pWrtShell
== &rSh
)) &&
3607 (!_pCreatorView
|| (pMod
->pXSelection
->pCreatorView
== _pCreatorView
)) )
3609 TransferableHelper::ClearSelection( rSh
.GetWin() );
3612 /* -----------------3/31/2003 11:46AM----------------
3614 --------------------------------------------------*/
3615 const Sequence
< sal_Int8
>& SwTransferable::getUnoTunnelId()
3617 static Sequence
< sal_Int8
> aSeq
;
3618 if( !aSeq
.getLength() )
3620 static osl::Mutex aCreateMutex
;
3621 osl::Guard
< osl::Mutex
> aGuard( aCreateMutex
);
3623 rtl_createUuid( reinterpret_cast< sal_uInt8
* >( aSeq
.getArray() ), 0, sal_True
);
3627 /* -----------------3/31/2003 11:46AM----------------
3629 --------------------------------------------------*/
3630 sal_Int64
SwTransferable::getSomething( const Sequence
< sal_Int8
>& rId
) throw( RuntimeException
)
3633 if( ( rId
.getLength() == 16 ) &&
3634 ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
3636 nRet
= sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>( this ) );
3639 nRet
= TransferableHelper::getSomething(rId
);
3645 // -----------------------------------------------------------------------
3647 SwTrnsfrDdeLink::SwTrnsfrDdeLink( SwTransferable
& rTrans
, SwWrtShell
& rSh
)
3648 : rTrnsfr( rTrans
), pDocShell( 0 ),
3649 bDelBookmrk( FALSE
), bInDisconnect( FALSE
)
3651 // hier kommen wir nur bei Tabellen- oder Text-Selection an
3652 const int nSelection
= rSh
.GetSelectionType();
3653 if( nsSelectionType::SEL_TBL_CELLS
& nSelection
)
3655 SwFrmFmt
* pFmt
= rSh
.GetTableFmt();
3657 sName
= pFmt
->GetName();
3661 // creating a temp. bookmark without undo
3662 BOOL bUndo
= rSh
.DoesUndo();
3663 rSh
.DoUndo( FALSE
);
3664 BOOL bIsModified
= rSh
.IsModified();
3666 ::sw::mark::IMark
* pMark
= rSh
.SetBookmark(
3670 IDocumentMarkAccess::DDE_BOOKMARK
);
3673 sName
= pMark
->GetName();
3676 rSh
.ResetModified();
3680 rSh
.DoUndo( bUndo
);
3684 0 != ( pDocShell
= rSh
.GetDoc()->GetDocShell() ) )
3686 // dann erzeugen wir uns mal unseren "Server" und connecten uns
3688 refObj
= pDocShell
->DdeCreateLinkSource( sName
);
3691 refObj
->AddConnectAdvise( this );
3692 refObj
->AddDataAdvise( this,
3693 // SotExchange::GetFormatMimeType( FORMAT_RTF ),
3695 ADVISEMODE_NODATA
| ADVISEMODE_ONLYONCE
);
3696 nOldTimeOut
= refObj
->GetUpdateTimeout();
3697 refObj
->SetUpdateTimeout( 0 );
3702 // -----------------------------------------------------------------------
3704 SwTrnsfrDdeLink::~SwTrnsfrDdeLink()
3710 // -----------------------------------------------------------------------
3712 void SwTrnsfrDdeLink::DataChanged( const String
& ,
3715 // tja das wars dann mit dem Link
3716 if( !bInDisconnect
)
3718 if( FindDocShell() && pDocShell
->GetView() )
3719 rTrnsfr
.RemoveDDELinkFormat( pDocShell
->GetView()->GetEditWin() );
3720 Disconnect( FALSE
);
3724 // -----------------------------------------------------------------------
3726 BOOL
SwTrnsfrDdeLink::WriteData( SvStream
& rStrm
)
3728 if( !refObj
.Is() || !FindDocShell() )
3731 rtl_TextEncoding eEncoding
= DDE_TXT_ENCODING
;
3732 const ByteString
aAppNm( GetpApp()->GetAppName(), eEncoding
);
3733 const ByteString
aTopic( pDocShell
->GetTitle( SFX_TITLE_FULLNAME
),
3735 const ByteString
aName( sName
, eEncoding
);
3737 sal_Char
* pMem
= new char[ aAppNm
.Len() + aTopic
.Len() + aName
.Len() + 4 ];
3739 xub_StrLen nLen
= aAppNm
.Len();
3740 memcpy( pMem
, aAppNm
.GetBuffer(), nLen
);
3742 memcpy( pMem
+ nLen
, aTopic
.GetBuffer(), aTopic
.Len() );
3743 nLen
= nLen
+ aTopic
.Len();
3745 memcpy( pMem
+ nLen
, aName
.GetBuffer(), aName
.Len() );
3746 nLen
= nLen
+ aName
.Len();
3750 rStrm
.Write( pMem
, nLen
);
3755 // // er wird das erstemal abgeholt, also ins Undo mitaufnehmen
3759 IDocumentMarkAccess
* const pMarkAccess
= pDocShell
->GetDoc()->getIDocumentMarkAccess();
3760 IDocumentMarkAccess::const_iterator_t ppMark
= pMarkAccess
->findMark(sName
);
3761 if(ppMark
!= pMarkAccess
->getMarksEnd()
3762 && IDocumentMarkAccess::GetType(**ppMark
) != IDocumentMarkAccess::BOOKMARK
)
3764 // the mark is still a DdeBookmark
3765 // we replace it with a Bookmark, so it will get saved etc.
3766 ::sw::mark::IMark
* const pMark
= ppMark
->get();
3767 SwServerObject
* const pServerObject
= dynamic_cast<SwServerObject
*>(&refObj
);
3769 // collecting state of old mark
3770 SwPaM
aPaM(pMark
->GetMarkStart());
3771 *aPaM
.GetPoint() = pMark
->GetMarkStart();
3772 if(pMark
->IsExpanded())
3775 *aPaM
.GetMark() = pMark
->GetMarkEnd();
3777 ::rtl::OUString sMarkName
= pMark
->GetName();
3780 pServerObject
->SetNoServer(); // this removes the connection between SwServerObject and mark
3781 // N.B. ppMark was not loaded from file and cannot have xml:id
3782 pMarkAccess
->deleteMark(ppMark
);
3784 // recreate as Bookmark
3785 ::sw::mark::IMark
* const pNewMark
= pMarkAccess
->makeMark(
3788 IDocumentMarkAccess::BOOKMARK
);
3789 pServerObject
->SetDdeBookmark(*pNewMark
);
3792 bDelBookmrk
= false;
3796 // -----------------------------------------------------------------------
3798 void SwTrnsfrDdeLink::Disconnect( BOOL bRemoveDataAdvise
)
3800 //JP 29.01.96 Bug 24432:
3801 // kein DataChanged mehr entgegen nehmen, wenn man
3802 // sich schon im Disconnet befindet!
3803 // (DTOR vom Bookmark verschickt einen DataChanged!)
3804 BOOL bOldDisconnect
= bInDisconnect
;
3805 bInDisconnect
= TRUE
;
3807 // den nicht verwendeten Bookmark wieder zerstoeren (ohne Undo!)?
3808 if( bDelBookmrk
&& refObj
.Is() && FindDocShell() )
3810 SwDoc
* pDoc
= pDocShell
->GetDoc();
3811 BOOL bUndo
= pDoc
->DoesUndo();
3812 pDoc
->DoUndo( FALSE
);
3814 // --> OD, CD, OS 2005-11-25 #i58448#
3815 Link
aSavedOle2Link( pDoc
->GetOle2Link() );
3816 pDoc
->SetOle2Link( Link() );
3818 BOOL bIsModified
= pDoc
->IsModified();
3820 IDocumentMarkAccess
* const pMarkAccess
= pDoc
->getIDocumentMarkAccess();
3821 pMarkAccess
->deleteMark(pMarkAccess
->findMark(sName
));
3824 pDoc
->ResetModified();
3825 // --> OD, CD, OS 2005-11-25 #i58448#
3826 pDoc
->SetOle2Link( aSavedOle2Link
);
3829 pDoc
->DoUndo( bUndo
);
3830 bDelBookmrk
= FALSE
;
3835 refObj
->SetUpdateTimeout( nOldTimeOut
);
3836 refObj
->RemoveConnectAdvise( this );
3837 if( bRemoveDataAdvise
)
3838 // in einem DataChanged darf das SelectionObject NIE geloescht
3839 // werden; wird schon von der Basisklasse erledigt
3840 // (ADVISEMODE_ONLYONCE!!!!)
3841 // Im normalen Disconnet aber schon!
3842 refObj
->RemoveAllDataAdvise( this );
3845 bInDisconnect
= bOldDisconnect
;
3848 // -----------------------------------------------------------------------
3850 BOOL
SwTrnsfrDdeLink::FindDocShell()
3852 TypeId
aType( TYPE( SwDocShell
) );
3853 SfxObjectShell
* pTmpSh
= SfxObjectShell::GetFirst( &aType
);
3856 if( pTmpSh
== pDocShell
) // die wollen wir haben
3858 if( pDocShell
->GetDoc() )
3860 break; // das Doc ist nicht mehr vorhanden, also raus!
3862 pTmpSh
= SfxObjectShell::GetNext( *pTmpSh
, &aType
);
3869 // -----------------------------------------------------------------------
3871 void SwTrnsfrDdeLink::Closed()
3873 if( !bInDisconnect
&& refObj
.Is() )
3875 refObj
->RemoveAllDataAdvise( this );
3876 refObj
->RemoveConnectAdvise( this );