xref: /aoo41x/main/sw/source/ui/dochdl/swdtflvr.cxx (revision b0b7a757)
1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifdef PRECOMPILED
27cdf0e10cSrcweir #include "ui_pch.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/embed/XVisualObject.hpp>
32cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp>
33cdf0e10cSrcweir #include <com/sun/star/embed/Aspects.hpp>
34cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
35cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <svtools/embedtransfer.hxx>
38cdf0e10cSrcweir #include <svtools/insdlg.hxx>
39cdf0e10cSrcweir #include <unotools/tempfile.hxx>
40cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
41cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
42cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
43cdf0e10cSrcweir #include <sot/filelist.hxx>
44cdf0e10cSrcweir #include <svx/svxdlg.hxx>
45cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
46cdf0e10cSrcweir #include <osl/endian.h>
47cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
48cdf0e10cSrcweir #include <tools/urlobj.hxx>
49cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
50cdf0e10cSrcweir #include <vcl/msgbox.hxx>
51cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
52cdf0e10cSrcweir #include <svl/stritem.hxx>
53cdf0e10cSrcweir #include <svtools/imap.hxx>
54cdf0e10cSrcweir #include <sot/storage.hxx>
55cdf0e10cSrcweir #include <vcl/graph.hxx>
56cdf0e10cSrcweir #include <svl/urihelper.hxx>
57cdf0e10cSrcweir #include <svx/svdmodel.hxx>
58cdf0e10cSrcweir #include <svx/xexch.hxx>
59cdf0e10cSrcweir #include <svx/xmlexchg.hxx>
60cdf0e10cSrcweir #include <svx/dbaexchange.hxx>
61cdf0e10cSrcweir #include <svx/clipfmtitem.hxx>
62cdf0e10cSrcweir #include <sfx2/mieclip.hxx>
63cdf0e10cSrcweir #include <svx/svdetc.hxx>
64cdf0e10cSrcweir #include <svx/xoutbmp.hxx>
65cdf0e10cSrcweir #include <svl/urlbmk.hxx>
66cdf0e10cSrcweir #include <svtools/htmlout.hxx>
67cdf0e10cSrcweir #include <svx/hlnkitem.hxx>
68cdf0e10cSrcweir #include <svtools/inetimg.hxx>
69cdf0e10cSrcweir #include <editeng/paperinf.hxx>
70cdf0e10cSrcweir #include <svx/fmview.hxx>
71cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
72cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
73cdf0e10cSrcweir #include <svtools/imapobj.hxx>
74cdf0e10cSrcweir #include <sfx2/docfile.hxx>
75cdf0e10cSrcweir #include <unotools/transliterationwrapper.hxx>
76cdf0e10cSrcweir #include <unotools/streamwrap.hxx>
77cdf0e10cSrcweir #include <svtools/filter.hxx>
78cdf0e10cSrcweir 
79cdf0e10cSrcweir #include <svx/unomodel.hxx>
80cdf0e10cSrcweir #include <fmturl.hxx>
81cdf0e10cSrcweir #include <fmtinfmt.hxx>
82cdf0e10cSrcweir #include <fmtfsize.hxx>
83cdf0e10cSrcweir #include <swdtflvr.hxx>
84cdf0e10cSrcweir #include <shellio.hxx>
85cdf0e10cSrcweir #include <ddefld.hxx>
86cdf0e10cSrcweir #include <doc.hxx>
87cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
88cdf0e10cSrcweir #include <pagedesc.hxx>
89cdf0e10cSrcweir #include <IMark.hxx>
90*b0b7a757SOliver-Rainer Wittmann #include <bookmrk.hxx>
91cdf0e10cSrcweir #include <docary.hxx>
92cdf0e10cSrcweir #include <section.hxx>
93cdf0e10cSrcweir #include <ndtxt.hxx>
94cdf0e10cSrcweir #include <edtwin.hxx>
95cdf0e10cSrcweir #include <navicont.hxx>
96cdf0e10cSrcweir #include <swcont.hxx>
97cdf0e10cSrcweir #include <wrtsh.hxx>
98cdf0e10cSrcweir #include <swmodule.hxx>
99cdf0e10cSrcweir #include <view.hxx>
100cdf0e10cSrcweir #include <docsh.hxx>
101cdf0e10cSrcweir #include <wdocsh.hxx>
102cdf0e10cSrcweir #include <fldbas.hxx>		//DDE
103cdf0e10cSrcweir #include <swundo.hxx>		// fuer Undo-Ids
104cdf0e10cSrcweir #include <pam.hxx>
105cdf0e10cSrcweir #include <ndole.hxx>
106cdf0e10cSrcweir #include <swwait.hxx>
107cdf0e10cSrcweir #include <viewopt.hxx>
108cdf0e10cSrcweir #include <swunodef.hxx>
109cdf0e10cSrcweir #include <vcl/sound.hxx>
110cdf0e10cSrcweir #include <swerror.h>
111cdf0e10cSrcweir #include <SwCapObjType.hxx>
112cdf0e10cSrcweir #include <cmdid.h>
113cdf0e10cSrcweir #include <dochdl.hrc>
114cdf0e10cSrcweir #include <comcore.hrc> // #111827#
115cdf0e10cSrcweir #include <sot/stg.hxx>
116cdf0e10cSrcweir #include <svx/svditer.hxx>
117cdf0e10cSrcweir #include <editeng/eeitem.hxx>
118cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
119cdf0e10cSrcweir #include <svx/svdpage.hxx>
120cdf0e10cSrcweir #include <avmedia/mediawindow.hxx>
121cdf0e10cSrcweir #include <swcrsr.hxx>
122cdf0e10cSrcweir #include <SwRewriter.hxx>
123cdf0e10cSrcweir #include <globals.hrc>
124cdf0e10cSrcweir #include <vos/mutex.hxx>
125cdf0e10cSrcweir #include <vcl/svapp.hxx>
126cdf0e10cSrcweir #include <swserv.hxx>
127cdf0e10cSrcweir #include <switerator.hxx>
128cdf0e10cSrcweir 
129cdf0e10cSrcweir extern sal_Bool bFrmDrag;
130cdf0e10cSrcweir extern sal_Bool bDDINetAttr;
131cdf0e10cSrcweir extern sal_Bool bExecuteDrag;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
134cdf0e10cSrcweir #define OLESIZE	11905 - 2 * lMinBorder, 6 * MM50
135cdf0e10cSrcweir 
136cdf0e10cSrcweir #define SWTRANSFER_OBJECTTYPE_DRAWMODEL			0x00000001
137cdf0e10cSrcweir #define SWTRANSFER_OBJECTTYPE_HTML              0x00000002
138cdf0e10cSrcweir #define SWTRANSFER_OBJECTTYPE_RTF				0x00000004
139cdf0e10cSrcweir #define SWTRANSFER_OBJECTTYPE_STRING			0x00000008
140cdf0e10cSrcweir #define SWTRANSFER_OBJECTTYPE_SWOLE				0x00000010
141cdf0e10cSrcweir #define SWTRANSFER_OBJECTTYPE_DDE				0x00000020
142cdf0e10cSrcweir 
143cdf0e10cSrcweir #define SWTRANSFER_GRAPHIC_INSERTED             0x00000040
144cdf0e10cSrcweir 
145cdf0e10cSrcweir using namespace ::svx;
146cdf0e10cSrcweir using ::rtl::OUString;
147cdf0e10cSrcweir using namespace ::com::sun::star;
148cdf0e10cSrcweir using namespace ::com::sun::star::uno;
149cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer;
150cdf0e10cSrcweir using namespace nsTransferBufferType;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir #define DDE_TXT_ENCODING 	gsl_getSystemTextEncoding()
153cdf0e10cSrcweir 
154cdf0e10cSrcweir class SwTrnsfrDdeLink : public ::sfx2::SvBaseLink
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	String sName;
157cdf0e10cSrcweir     ::sfx2::SvLinkSourceRef refObj;
158cdf0e10cSrcweir 	SwTransferable& rTrnsfr;
159cdf0e10cSrcweir 	SwDocShell* pDocShell;
160cdf0e10cSrcweir 	sal_uLong nOldTimeOut;
161cdf0e10cSrcweir 	sal_Bool bDelBookmrk : 1;
162cdf0e10cSrcweir 	sal_Bool bInDisconnect : 1;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	sal_Bool FindDocShell();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     using sfx2::SvBaseLink::Disconnect;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir protected:
169cdf0e10cSrcweir 	virtual ~SwTrnsfrDdeLink();
170cdf0e10cSrcweir 
171cdf0e10cSrcweir public:
172cdf0e10cSrcweir 	SwTrnsfrDdeLink( SwTransferable& rTrans, SwWrtShell& rSh );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	virtual void DataChanged( const String& rMimeType,
175cdf0e10cSrcweir                               const uno::Any & rValue );
176cdf0e10cSrcweir 	virtual void Closed();
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	sal_Bool WriteData( SvStream& rStrm );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	void Disconnect( sal_Bool bRemoveDataAdvise );
181cdf0e10cSrcweir };
182cdf0e10cSrcweir 
183cdf0e10cSrcweir // helper class for Action and Undo enclosing
184cdf0e10cSrcweir class SwTrnsfrActionAndUndo
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 	SwWrtShell *pSh;
187cdf0e10cSrcweir     SwUndoId eUndoId;
188cdf0e10cSrcweir public:
189cdf0e10cSrcweir     SwTrnsfrActionAndUndo( SwWrtShell *pS, SwUndoId nId,
190cdf0e10cSrcweir                            const SwRewriter * pRewriter = 0,
191cdf0e10cSrcweir                            sal_Bool bDelSel = sal_False)
192cdf0e10cSrcweir         : pSh( pS ), eUndoId( nId )
193cdf0e10cSrcweir 	{
194cdf0e10cSrcweir         pSh->StartUndo( eUndoId, pRewriter );
195cdf0e10cSrcweir 		if( bDelSel )
196cdf0e10cSrcweir 			pSh->DelRight();
197cdf0e10cSrcweir 		pSh->StartAllAction();
198cdf0e10cSrcweir 	}
199cdf0e10cSrcweir 	~SwTrnsfrActionAndUndo()
200cdf0e10cSrcweir 	{
201cdf0e10cSrcweir         pSh->EndUndo();
202cdf0e10cSrcweir 		pSh->EndAllAction();
203cdf0e10cSrcweir 	}
204cdf0e10cSrcweir };
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 
207cdf0e10cSrcweir // -----------------------------------------------------------------------
208cdf0e10cSrcweir 
209cdf0e10cSrcweir SwTransferable::SwTransferable( SwWrtShell& rSh )
210cdf0e10cSrcweir 	: pWrtShell( &rSh ),
211cdf0e10cSrcweir 	pCreatorView( 0 ),
212cdf0e10cSrcweir 	pClpDocFac( 0 ),
213cdf0e10cSrcweir 	pClpGraphic( 0 ),
214cdf0e10cSrcweir 	pClpBitmap( 0 ),
215cdf0e10cSrcweir 	pOrigGrf( 0 ),
216cdf0e10cSrcweir 	pBkmk( 0 ),
217cdf0e10cSrcweir 	pImageMap( 0 ),
218cdf0e10cSrcweir 	pTargetURL( 0 ),
219cdf0e10cSrcweir 	eBufferType( TRNSFR_NONE )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir     rSh.GetView().AddTransferable(*this);
222cdf0e10cSrcweir     SwDocShell* pDShell = rSh.GetDoc()->GetDocShell();
223cdf0e10cSrcweir 	if( pDShell )
224cdf0e10cSrcweir 	{
225cdf0e10cSrcweir 		pDShell->FillTransferableObjectDescriptor( aObjDesc );
226cdf0e10cSrcweir 		if( pDShell->GetMedium() )
227cdf0e10cSrcweir 		{
228cdf0e10cSrcweir 			const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject();
229cdf0e10cSrcweir 			aObjDesc.maDisplayName = URIHelper::removePassword(
230cdf0e10cSrcweir 								rURLObj.GetMainURL( INetURLObject::NO_DECODE ),
231cdf0e10cSrcweir 								INetURLObject::WAS_ENCODED,
232cdf0e10cSrcweir 			   					INetURLObject::DECODE_UNAMBIGUOUS );
233cdf0e10cSrcweir 		}
234cdf0e10cSrcweir 
235cdf0e10cSrcweir         PrepareOLE( aObjDesc );
236cdf0e10cSrcweir 	}
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir // -----------------------------------------------------------------------
240cdf0e10cSrcweir 
241cdf0e10cSrcweir SwTransferable::~SwTransferable()
242cdf0e10cSrcweir {
243cdf0e10cSrcweir     Application::GetSolarMutex().acquire();
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	// der DDELink braucht noch die WrtShell!
246cdf0e10cSrcweir 	if( refDdeLink.Is() )
247cdf0e10cSrcweir 	{
248cdf0e10cSrcweir 		((SwTrnsfrDdeLink*)&refDdeLink)->Disconnect( sal_True );
249cdf0e10cSrcweir 		refDdeLink.Clear();
250cdf0e10cSrcweir 	}
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	pWrtShell = 0;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     // dvo 2002-05-30, #99239#: release reference to the document so that
255cdf0e10cSrcweir     // aDocShellRef will delete it (if aDocShellRef is set). Otherwise, the OLE
256cdf0e10cSrcweir     // nodes keep references to their sub-storage when the storage is already
257cdf0e10cSrcweir     // dead.
258cdf0e10cSrcweir 	delete pClpDocFac;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	//JP 22.04.95: erst schliessen, dann kann die Ref. auch gecleared werden,
261cdf0e10cSrcweir 	//				so das die DocShell auch tatsaechlich geloescht wird!
262cdf0e10cSrcweir 	if( aDocShellRef.Is() )
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir         SfxObjectShell * pObj = aDocShellRef;
265cdf0e10cSrcweir 		SwDocShell* pDocSh = (SwDocShell*)pObj;
266cdf0e10cSrcweir 		pDocSh->DoClose();
267cdf0e10cSrcweir 	}
268cdf0e10cSrcweir 	aDocShellRef.Clear();
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	SwModule* pMod = SW_MOD();
271cdf0e10cSrcweir     if(pMod)
272cdf0e10cSrcweir     {
273cdf0e10cSrcweir         if ( pMod->pDragDrop == this )
274cdf0e10cSrcweir             pMod->pDragDrop = 0;
275cdf0e10cSrcweir         else if ( pMod->pXSelection == this )
276cdf0e10cSrcweir             pMod->pXSelection = 0;
277cdf0e10cSrcweir     }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 	delete pClpGraphic;
280cdf0e10cSrcweir 	delete pClpBitmap;
281cdf0e10cSrcweir 	delete pImageMap;
282cdf0e10cSrcweir 	delete pTargetURL;
283cdf0e10cSrcweir 	delete pBkmk;
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	eBufferType = TRNSFR_NONE;
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     Application::GetSolarMutex().release();
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir // -----------------------------------------------------------------------
292cdf0e10cSrcweir 
293cdf0e10cSrcweir static SwDoc * lcl_GetDoc(SwDocFac & rDocFac)
294cdf0e10cSrcweir {
295cdf0e10cSrcweir     SwDoc *const pDoc = rDocFac.GetDoc();
296cdf0e10cSrcweir     ASSERT( pDoc, "Document not found" );
297cdf0e10cSrcweir     if (pDoc)
298cdf0e10cSrcweir     {
299cdf0e10cSrcweir         pDoc->SetClipBoard( true );
300cdf0e10cSrcweir     }
301cdf0e10cSrcweir     return pDoc;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir // -----------------------------------------------------------------------
305cdf0e10cSrcweir 
306cdf0e10cSrcweir void SwTransferable::ObjectReleased()
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	SwModule *pMod = SW_MOD();
309cdf0e10cSrcweir 	if( this == pMod->pDragDrop )
310cdf0e10cSrcweir 		pMod->pDragDrop = 0;
311cdf0e10cSrcweir 	else if( this == pMod->pXSelection )
312cdf0e10cSrcweir 		pMod->pXSelection = 0;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir // -----------------------------------------------------------------------
316cdf0e10cSrcweir 
317cdf0e10cSrcweir void SwTransferable::AddSupportedFormats()
318cdf0e10cSrcweir {
319cdf0e10cSrcweir 	// only need if we are the current XSelection Object
320cdf0e10cSrcweir 	SwModule *pMod = SW_MOD();
321cdf0e10cSrcweir 	if( this == pMod->pXSelection )
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir 		SetDataForDragAndDrop( Point( 0,0) );
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir // -----------------------------------------------------------------------
328cdf0e10cSrcweir 
329cdf0e10cSrcweir void SwTransferable::InitOle( SfxObjectShell* pDoc, SwDoc& rDoc )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir 	//OleVisArea einstellen. Linke obere Ecke der Seite und Groesse
332cdf0e10cSrcweir 	//der RealSize in Twips.
333cdf0e10cSrcweir 	const Size aSz( OLESIZE );
334cdf0e10cSrcweir 	SwRect aVis( Point( DOCUMENTBORDER, DOCUMENTBORDER ), aSz );
335cdf0e10cSrcweir     pDoc->SetVisArea( aVis.SVRect() );
336cdf0e10cSrcweir 	rDoc.set(IDocumentSettingAccess::BROWSE_MODE, true );
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir // -----------------------------------------------------------------------
340cdf0e10cSrcweir 
341cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > SwTransferable::FindOLEObj( sal_Int64& nAspect ) const
342cdf0e10cSrcweir {
343cdf0e10cSrcweir     uno::Reference < embed::XEmbeddedObject > xObj;
344cdf0e10cSrcweir 	if( pClpDocFac )
345cdf0e10cSrcweir 	{
346cdf0e10cSrcweir 		SwIterator<SwCntntNode,SwFmtColl> aIter( *pClpDocFac->GetDoc()->GetDfltGrfFmtColl() );
347cdf0e10cSrcweir 		for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
348cdf0e10cSrcweir 			if( ND_OLENODE == pNd->GetNodeType() )
349cdf0e10cSrcweir 			{
350cdf0e10cSrcweir                 xObj = ((SwOLENode*)pNd)->GetOLEObj().GetOleRef();
351cdf0e10cSrcweir 				nAspect = ((SwOLENode*)pNd)->GetAspect();
352cdf0e10cSrcweir 				break;
353cdf0e10cSrcweir 			}
354cdf0e10cSrcweir 	}
355cdf0e10cSrcweir     return xObj;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir // -----------------------------------------------------------------------
359cdf0e10cSrcweir 
360cdf0e10cSrcweir Graphic* SwTransferable::FindOLEReplacementGraphic() const
361cdf0e10cSrcweir {
362cdf0e10cSrcweir 	if( pClpDocFac )
363cdf0e10cSrcweir 	{
364cdf0e10cSrcweir 		SwIterator<SwCntntNode,SwFmtColl> aIter( *pClpDocFac->GetDoc()->GetDfltGrfFmtColl() );
365cdf0e10cSrcweir 		for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
366cdf0e10cSrcweir 			if( ND_OLENODE == pNd->GetNodeType() )
367cdf0e10cSrcweir 			{
368cdf0e10cSrcweir                 return ((SwOLENode*)pNd)->GetGraphic();
369cdf0e10cSrcweir 			}
370cdf0e10cSrcweir 	}
371cdf0e10cSrcweir 
372cdf0e10cSrcweir     return NULL;
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 
376cdf0e10cSrcweir // -----------------------------------------------------------------------
377cdf0e10cSrcweir 
378cdf0e10cSrcweir void SwTransferable::RemoveDDELinkFormat( const Window& rWin )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	RemoveFormat( SOT_FORMATSTR_ID_LINK );
381cdf0e10cSrcweir 	CopyToClipboard( (Window*)&rWin );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir // -----------------------------------------------------------------------
385cdf0e10cSrcweir 
386cdf0e10cSrcweir sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir 	sal_uInt32	nFormat = SotExchange::GetFormat( rFlavor );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     // we can only fullfil the request if
391cdf0e10cSrcweir     // 1) we have data for this format
392cdf0e10cSrcweir     // 2) we have either a clipboard document (pClpDocFac), or
393cdf0e10cSrcweir     //    we have a SwWrtShell (so we can generate a new clipboard document)
394cdf0e10cSrcweir     if( !HasFormat( nFormat ) || ( pClpDocFac == NULL && pWrtShell == NULL ) )
395cdf0e10cSrcweir 		return sal_False;
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 	if( !pClpDocFac )
398cdf0e10cSrcweir 	{
399cdf0e10cSrcweir         SelectionType nSelectionType = pWrtShell->GetSelectionType();
400cdf0e10cSrcweir 
4011cd65da9SArmin Le Grand         // when pending we will not get the correct type, but nsSelectionType::SEL_TXT
4021cd65da9SArmin Le Grand         // as fallback. This *happens* durning D&D, so we need to check if we are in
4031cd65da9SArmin Le Grand         // the fallback and just try to get a graphic
4041cd65da9SArmin Le Grand         const bool bPending(pWrtShell->BasicActionPend());
4051cd65da9SArmin Le Grand 
4061cd65da9SArmin Le Grand         // SEL_GRF kommt vom ContentType der editsh
4071cd65da9SArmin Le Grand 		if(bPending || ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_DRW_FORM) & nSelectionType))
408cdf0e10cSrcweir 		{
409cdf0e10cSrcweir 			pClpGraphic = new Graphic;
410cdf0e10cSrcweir 			if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
411cdf0e10cSrcweir 				pOrigGrf = pClpGraphic;
412cdf0e10cSrcweir 			pClpBitmap = new Graphic;
413cdf0e10cSrcweir 			if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
414cdf0e10cSrcweir 				pOrigGrf = pClpBitmap;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 			// ist es ein URL-Button ?
417cdf0e10cSrcweir 			String sURL, sDesc;
418cdf0e10cSrcweir 			if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
419cdf0e10cSrcweir 			{
420cdf0e10cSrcweir 				pBkmk = new INetBookmark( sURL, sDesc );
421cdf0e10cSrcweir 				eBufferType = TRNSFR_INETFLD;
422cdf0e10cSrcweir 			}
423cdf0e10cSrcweir 		}
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 		pClpDocFac = new SwDocFac;
426cdf0e10cSrcweir         SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 		pTmpDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
429cdf0e10cSrcweir 		pWrtShell->Copy( pTmpDoc );
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 		// es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
432cdf0e10cSrcweir         aDocShellRef = pTmpDoc->GetTmpDocShell();
433cdf0e10cSrcweir 		if( aDocShellRef.Is() )
434cdf0e10cSrcweir 			SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
435cdf0e10cSrcweir 		pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 		if( nSelectionType & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() )
438cdf0e10cSrcweir 		{
439cdf0e10cSrcweir 			SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 			Point aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 			sal_Bool bSelect = bExecuteDrag &&
444cdf0e10cSrcweir 							pWrtShell->GetView().GetDocShell() &&
445cdf0e10cSrcweir 							!pWrtShell->GetView().GetDocShell()->IsReadOnly();
446cdf0e10cSrcweir 			if( pWrtShell->GetContentAtPos( aPos, aCntntAtPos, bSelect ) )
447cdf0e10cSrcweir 			{
448cdf0e10cSrcweir 				pBkmk = new INetBookmark(
449cdf0e10cSrcweir 						((SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr)->GetValue(),
450cdf0e10cSrcweir 						aCntntAtPos.sStr );
451cdf0e10cSrcweir 				eBufferType = TRNSFR_INETFLD;
452cdf0e10cSrcweir 				if( bSelect )
453cdf0e10cSrcweir 					pWrtShell->SelectTxtAttr( RES_TXTATR_INETFMT );
454cdf0e10cSrcweir 			}
455cdf0e10cSrcweir 		}
456cdf0e10cSrcweir 		if( pWrtShell->IsFrmSelected() )
457cdf0e10cSrcweir 		{
458cdf0e10cSrcweir 		 	SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
459cdf0e10cSrcweir 			pWrtShell->GetFlyFrmAttr( aSet );
460cdf0e10cSrcweir 			const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
461cdf0e10cSrcweir 			if( rURL.GetMap() )
462cdf0e10cSrcweir 				pImageMap = new ImageMap( *rURL.GetMap() );
463cdf0e10cSrcweir 			else if( rURL.GetURL().Len() )
464cdf0e10cSrcweir 				pTargetURL = new INetImage( aEmptyStr, rURL.GetURL(),
465cdf0e10cSrcweir 											rURL.GetTargetFrameName(),
466cdf0e10cSrcweir 											aEmptyStr, Size() );
467cdf0e10cSrcweir 		}
468cdf0e10cSrcweir 	}
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 	sal_Bool	bOK = sal_False;
471cdf0e10cSrcweir 	if( TRNSFR_OLE == eBufferType )
472cdf0e10cSrcweir 	{
473cdf0e10cSrcweir         //TODO/MBA: testing - is this the "single OLE object" case?!
474cdf0e10cSrcweir 		// aus dem ClipDoc das OLE-Object besorgen und von dem die Daten
475cdf0e10cSrcweir 		// besorgen.
476cdf0e10cSrcweir 		sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; // will be set in the next statement
477cdf0e10cSrcweir         uno::Reference < embed::XEmbeddedObject > xObj = FindOLEObj( nAspect );
478cdf0e10cSrcweir 		Graphic* pOLEGraph = FindOLEReplacementGraphic();
479cdf0e10cSrcweir         if( xObj.is() )
480cdf0e10cSrcweir 		{
481cdf0e10cSrcweir             TransferableDataHelper aD( new SvEmbedTransferHelper( xObj, pOLEGraph, nAspect ) );
482cdf0e10cSrcweir             uno::Any aAny( aD.GetAny( rFlavor ));
483cdf0e10cSrcweir 			if( aAny.hasValue() )
484cdf0e10cSrcweir 				bOK = SetAny( aAny, rFlavor );
485cdf0e10cSrcweir 		}
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 		// the following solution will be used in the case when the object can not generate the image
488cdf0e10cSrcweir 		// TODO/LATER: in future the transferhelper must probably be created based on object and the replacement stream
489cdf0e10cSrcweir 		if ( nFormat == SOT_FORMAT_GDIMETAFILE )
490cdf0e10cSrcweir 		{
491cdf0e10cSrcweir 			pOLEGraph = FindOLEReplacementGraphic();
492cdf0e10cSrcweir 			if ( pOLEGraph )
493cdf0e10cSrcweir 				bOK = SetGDIMetaFile( pOLEGraph->GetGDIMetaFile(), rFlavor );
494cdf0e10cSrcweir 		}
495cdf0e10cSrcweir 	}
496cdf0e10cSrcweir 	else
497cdf0e10cSrcweir 	{
498cdf0e10cSrcweir 		switch( nFormat )
499cdf0e10cSrcweir 		{
500cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_LINK:
501cdf0e10cSrcweir 			if( refDdeLink.Is() )
502cdf0e10cSrcweir 				bOK = SetObject( &refDdeLink,
503cdf0e10cSrcweir 									SWTRANSFER_OBJECTTYPE_DDE, rFlavor );
504cdf0e10cSrcweir 			break;
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_OBJECTDESCRIPTOR:
507cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR:
508cdf0e10cSrcweir 			bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor );
509cdf0e10cSrcweir 			break;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_DRAWING:
512cdf0e10cSrcweir 			{
513cdf0e10cSrcweir                 SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
514cdf0e10cSrcweir 				bOK = SetObject( pDoc->GetDrawModel(),
515cdf0e10cSrcweir 								SWTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
516cdf0e10cSrcweir 			}
517cdf0e10cSrcweir 			break;
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 		case SOT_FORMAT_STRING:
520cdf0e10cSrcweir         {
521cdf0e10cSrcweir             SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
522cdf0e10cSrcweir             bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_STRING, rFlavor );
523cdf0e10cSrcweir         }
524cdf0e10cSrcweir         break;
525cdf0e10cSrcweir 		case SOT_FORMAT_RTF:
526cdf0e10cSrcweir         {
527cdf0e10cSrcweir             SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
528cdf0e10cSrcweir             bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_RTF, rFlavor );
529cdf0e10cSrcweir         }
530cdf0e10cSrcweir 			break;
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_HTML:
533cdf0e10cSrcweir         {
534cdf0e10cSrcweir             SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
535cdf0e10cSrcweir             bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_HTML, rFlavor );
536cdf0e10cSrcweir         }
537cdf0e10cSrcweir 			break;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_SVXB:
540cdf0e10cSrcweir 			if( eBufferType & TRNSFR_GRAPHIC && pOrigGrf )
541cdf0e10cSrcweir 				bOK = SetGraphic( *pOrigGrf, rFlavor );
542cdf0e10cSrcweir 			break;
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 		case SOT_FORMAT_GDIMETAFILE:
545cdf0e10cSrcweir 			if( eBufferType & TRNSFR_GRAPHIC )
546cdf0e10cSrcweir 				bOK = SetGDIMetaFile( pClpGraphic->GetGDIMetaFile(), rFlavor );
547cdf0e10cSrcweir 			break;
548cdf0e10cSrcweir 		case SOT_FORMAT_BITMAP:
54945fd3b9aSArmin Le Grand         case SOT_FORMATSTR_ID_PNG:
550cdf0e10cSrcweir             // #126398#  Neither pClpBitmap nor pClpGraphic are necessarily set
551cdf0e10cSrcweir             if( (eBufferType & TRNSFR_GRAPHIC) && (pClpBitmap != 0 || pClpGraphic != 0))
55245fd3b9aSArmin Le Grand 				bOK = SetBitmapEx( (pClpBitmap ? pClpBitmap : pClpGraphic)->GetBitmapEx(), rFlavor );
553cdf0e10cSrcweir 			break;
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_SVIM:
556cdf0e10cSrcweir 			if( pImageMap )
557cdf0e10cSrcweir 				bOK = SetImageMap( *pImageMap, rFlavor );
558cdf0e10cSrcweir 			break;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_INET_IMAGE:
561cdf0e10cSrcweir 			if( pTargetURL )
562cdf0e10cSrcweir 				bOK = SetINetImage( *pTargetURL, rFlavor );
563cdf0e10cSrcweir 			break;
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_SOLK:
566cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
567cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
568cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_FILECONTENT:
569cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
570cdf0e10cSrcweir 		case SOT_FORMAT_FILE:
571cdf0e10cSrcweir 			if( (TRNSFR_INETFLD & eBufferType) && pBkmk )
572cdf0e10cSrcweir 				bOK = SetINetBookmark( *pBkmk, rFlavor );
573cdf0e10cSrcweir 			break;
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 		case SOT_FORMATSTR_ID_EMBED_SOURCE:
576cdf0e10cSrcweir //		default:
577cdf0e10cSrcweir 			if( !aDocShellRef.Is() )
578cdf0e10cSrcweir 			{
579cdf0e10cSrcweir                 SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
580cdf0e10cSrcweir 				SwDocShell* pNewDocSh = new SwDocShell( pDoc,
581cdf0e10cSrcweir 										 SFX_CREATE_MODE_EMBEDDED );
582cdf0e10cSrcweir 				aDocShellRef = pNewDocSh;
583cdf0e10cSrcweir 				aDocShellRef->DoInitNew( NULL );
584cdf0e10cSrcweir 				SwTransferable::InitOle( aDocShellRef, *pDoc );
585cdf0e10cSrcweir 			}
586cdf0e10cSrcweir 			bOK = SetObject( &aDocShellRef, SWTRANSFER_OBJECTTYPE_SWOLE,
587cdf0e10cSrcweir 							rFlavor );
588cdf0e10cSrcweir 			break;
589cdf0e10cSrcweir 		}
590cdf0e10cSrcweir 	}
591cdf0e10cSrcweir 	return bOK;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir 
594cdf0e10cSrcweir // -----------------------------------------------------------------------
595cdf0e10cSrcweir 
596cdf0e10cSrcweir sal_Bool SwTransferable::WriteObject( SotStorageStreamRef& xStream,
597cdf0e10cSrcweir 									void* pObject, sal_uInt32 nObjectType,
598cdf0e10cSrcweir 									const DATA_FLAVOR& /*rFlavor*/ )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
601cdf0e10cSrcweir 	WriterRef xWrt;
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 	switch( nObjectType )
604cdf0e10cSrcweir 	{
605cdf0e10cSrcweir 	case SWTRANSFER_OBJECTTYPE_DRAWMODEL:
606cdf0e10cSrcweir 		{
607cdf0e10cSrcweir 			//JP 28.02.2001: dont change the sequence of commands - Bug 8
608cdf0e10cSrcweir 			SdrModel *pModel = (SdrModel*)pObject;
609cdf0e10cSrcweir 			xStream->SetBufferSize( 16348 );
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 			// #108584#
612cdf0e10cSrcweir 			// for the changed pool defaults from drawing layer pool set those
613cdf0e10cSrcweir 			// attributes as hard attributes to preserve them for saving
614cdf0e10cSrcweir 			const SfxItemPool& rItemPool = pModel->GetItemPool();
615cdf0e10cSrcweir 			const SvxFontHeightItem& rDefaultFontHeight = (const SvxFontHeightItem&)rItemPool.GetDefaultItem(EE_CHAR_FONTHEIGHT);
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 			// SW should have no MasterPages
618cdf0e10cSrcweir 			DBG_ASSERT(0L == pModel->GetMasterPageCount(), "SW with MasterPages (!)");
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 			for(sal_uInt16 a(0); a < pModel->GetPageCount(); a++)
621cdf0e10cSrcweir 			{
622cdf0e10cSrcweir 				const SdrPage* pPage = pModel->GetPage(a);
623cdf0e10cSrcweir 				SdrObjListIter aIter(*pPage, IM_DEEPNOGROUPS);
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 				while(aIter.IsMore())
626cdf0e10cSrcweir 				{
627cdf0e10cSrcweir 					SdrObject* pObj = aIter.Next();
628cdf0e10cSrcweir 					const SvxFontHeightItem& rItem = (const SvxFontHeightItem&)pObj->GetMergedItem(EE_CHAR_FONTHEIGHT);
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 					if(rItem.GetHeight() == rDefaultFontHeight.GetHeight())
631cdf0e10cSrcweir 					{
632cdf0e10cSrcweir 						pObj->SetMergedItem(rDefaultFontHeight);
633cdf0e10cSrcweir 					}
634cdf0e10cSrcweir 				}
635cdf0e10cSrcweir 			}
636cdf0e10cSrcweir 
637cdf0e10cSrcweir 			{
638cdf0e10cSrcweir                 uno::Reference<io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *xStream ) );
639cdf0e10cSrcweir 				if( SvxDrawingLayerExport( pModel, xDocOut ) )
640cdf0e10cSrcweir 					xStream->Commit();
641cdf0e10cSrcweir 			}
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 			bRet = ERRCODE_NONE == xStream->GetError();
644cdf0e10cSrcweir 		}
645cdf0e10cSrcweir 		break;
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 	case SWTRANSFER_OBJECTTYPE_SWOLE:
648cdf0e10cSrcweir 		{
649cdf0e10cSrcweir             SfxObjectShell*   pEmbObj = (SfxObjectShell*) pObject;
650cdf0e10cSrcweir             try
651cdf0e10cSrcweir             {
652cdf0e10cSrcweir                 ::utl::TempFile     aTempFile;
653cdf0e10cSrcweir                 aTempFile.EnableKillingFile();
654cdf0e10cSrcweir                 uno::Reference< embed::XStorage > xWorkStore =
655cdf0e10cSrcweir                     ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir                 // write document storage
658cdf0e10cSrcweir                 pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False );
659cdf0e10cSrcweir                 // mba: no BaseURL for clipboard
660cdf0e10cSrcweir                 SfxMedium aMedium( xWorkStore, String() );
661cdf0e10cSrcweir                 bRet = pEmbObj->DoSaveObjectAs( aMedium, sal_False );
662cdf0e10cSrcweir                 pEmbObj->DoSaveCompleted();
663cdf0e10cSrcweir 
664cdf0e10cSrcweir                 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
665cdf0e10cSrcweir                 if ( xTransact.is() )
666cdf0e10cSrcweir                     xTransact->commit();
667cdf0e10cSrcweir 
668cdf0e10cSrcweir                 SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
669cdf0e10cSrcweir                 if( pSrcStm )
670cdf0e10cSrcweir                 {
671cdf0e10cSrcweir                     xStream->SetBufferSize( 0xff00 );
672cdf0e10cSrcweir                     *xStream << *pSrcStm;
673cdf0e10cSrcweir                     delete pSrcStm;
674cdf0e10cSrcweir                 }
675cdf0e10cSrcweir 
676cdf0e10cSrcweir                 bRet = sal_True;
677cdf0e10cSrcweir 
678cdf0e10cSrcweir                 xWorkStore->dispose();
679cdf0e10cSrcweir                 xWorkStore = uno::Reference < embed::XStorage >();
680cdf0e10cSrcweir                 xStream->Commit();
681cdf0e10cSrcweir             }
682cdf0e10cSrcweir             catch ( uno::Exception& )
683cdf0e10cSrcweir             {}
684cdf0e10cSrcweir 
685cdf0e10cSrcweir             bRet = ( xStream->GetError() == ERRCODE_NONE );
686cdf0e10cSrcweir 		}
687cdf0e10cSrcweir 		break;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 
690cdf0e10cSrcweir 	case SWTRANSFER_OBJECTTYPE_DDE:
691cdf0e10cSrcweir 		{
692cdf0e10cSrcweir 			xStream->SetBufferSize( 1024 );
693cdf0e10cSrcweir 			SwTrnsfrDdeLink* pDdeLnk = (SwTrnsfrDdeLink*)pObject;
694cdf0e10cSrcweir 			if( pDdeLnk->WriteData( *xStream ) )
695cdf0e10cSrcweir 			{
696cdf0e10cSrcweir 				xStream->Commit();
697cdf0e10cSrcweir 				bRet = ERRCODE_NONE == xStream->GetError();
698cdf0e10cSrcweir 			}
699cdf0e10cSrcweir 		}
700cdf0e10cSrcweir 		break;
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 	case SWTRANSFER_OBJECTTYPE_HTML:
703cdf0e10cSrcweir         GetHTMLWriter( aEmptyStr, String(), xWrt );
704cdf0e10cSrcweir 		break;
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 	case SWTRANSFER_OBJECTTYPE_RTF:
707cdf0e10cSrcweir         GetRTFWriter( aEmptyStr, String(), xWrt );
708cdf0e10cSrcweir 		break;
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 	case SWTRANSFER_OBJECTTYPE_STRING:
711cdf0e10cSrcweir         GetASCWriter( aEmptyStr, String(), xWrt );
712cdf0e10cSrcweir 		if( xWrt.Is() )
713cdf0e10cSrcweir 		{
714cdf0e10cSrcweir 			SwAsciiOptions aAOpt;
715cdf0e10cSrcweir 			aAOpt.SetCharSet( RTL_TEXTENCODING_UTF8 );
716cdf0e10cSrcweir 			xWrt->SetAsciiOptions( aAOpt );
717cdf0e10cSrcweir 
718cdf0e10cSrcweir             // #102841# no start char for clipboard
719cdf0e10cSrcweir             xWrt->bUCS2_WithStartChar = sal_False;
720cdf0e10cSrcweir 		}
721cdf0e10cSrcweir 		break;
722cdf0e10cSrcweir 	}
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 	if( xWrt.Is() )
725cdf0e10cSrcweir 	{
726cdf0e10cSrcweir 		SwDoc* pDoc = (SwDoc*)pObject;
727cdf0e10cSrcweir 		xWrt->bWriteClipboardDoc = sal_True;
728cdf0e10cSrcweir 		xWrt->bWriteOnlyFirstTable = 0 != (TRNSFR_TABELLE & eBufferType);
729cdf0e10cSrcweir 		xWrt->SetShowProgress( sal_False );
730cdf0e10cSrcweir 		SwWriter aWrt( *xStream, *pDoc );
731cdf0e10cSrcweir 		if( !IsError( aWrt.Write( xWrt )) )
732cdf0e10cSrcweir 		{
733cdf0e10cSrcweir 			*xStream << '\0'; 				// terminate with a zero
734cdf0e10cSrcweir 			xStream->Commit();
735cdf0e10cSrcweir 			bRet = sal_True;
736cdf0e10cSrcweir 		}
737cdf0e10cSrcweir 	}
738cdf0e10cSrcweir 
739cdf0e10cSrcweir 	return bRet;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir 
742cdf0e10cSrcweir // -----------------------------------------------------------------------
743cdf0e10cSrcweir 
744cdf0e10cSrcweir int SwTransferable::Cut()
745cdf0e10cSrcweir {
746cdf0e10cSrcweir 	int nRet = Copy( sal_True );
747cdf0e10cSrcweir 	if( nRet )
748cdf0e10cSrcweir 		DeleteSelection();
749cdf0e10cSrcweir 	return nRet;
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir // -----------------------------------------------------------------------
753cdf0e10cSrcweir 
754cdf0e10cSrcweir void SwTransferable::DeleteSelection()
755cdf0e10cSrcweir {
756cdf0e10cSrcweir     if(!pWrtShell)
757cdf0e10cSrcweir         return;
758cdf0e10cSrcweir     // Selektionsart vor Action-Klammerung erfragen
759cdf0e10cSrcweir 	const int nSelection = pWrtShell->GetSelectionType();
760cdf0e10cSrcweir 	pWrtShell->StartUndo( UNDO_DELETE );
761cdf0e10cSrcweir 	if( ( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL ) & nSelection )
762cdf0e10cSrcweir 		pWrtShell->IntelligentCut( nSelection );
763cdf0e10cSrcweir 	pWrtShell->DelRight();
764cdf0e10cSrcweir 	pWrtShell->EndUndo( UNDO_DELETE );
765cdf0e10cSrcweir }
766cdf0e10cSrcweir 
767cdf0e10cSrcweir // -----------------------------------------------------------------------
768cdf0e10cSrcweir 
769cdf0e10cSrcweir int SwTransferable::PrepareForCopy( sal_Bool bIsCut )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir 	int nRet = 1;
772cdf0e10cSrcweir     if(!pWrtShell)
773cdf0e10cSrcweir         return 0;;
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 	String sGrfNm;
776cdf0e10cSrcweir 	const int nSelection = pWrtShell->GetSelectionType();
777cdf0e10cSrcweir 	if( nSelection == nsSelectionType::SEL_GRF )
778cdf0e10cSrcweir 	{
779cdf0e10cSrcweir 		pClpGraphic = new Graphic;
780cdf0e10cSrcweir 		if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
781cdf0e10cSrcweir 			pOrigGrf = pClpGraphic;
782cdf0e10cSrcweir 		pClpBitmap = new Graphic;
783cdf0e10cSrcweir 		if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
784cdf0e10cSrcweir 			pOrigGrf = pClpBitmap;
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 		pClpDocFac = new SwDocFac;
787cdf0e10cSrcweir         SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
788cdf0e10cSrcweir         pWrtShell->Copy( pDoc );
789cdf0e10cSrcweir 
790cdf0e10cSrcweir         if (pOrigGrf && !pOrigGrf->GetBitmap().IsEmpty())
791cdf0e10cSrcweir 		  AddFormat( SOT_FORMATSTR_ID_SVXB );
792cdf0e10cSrcweir 
793cdf0e10cSrcweir         PrepareOLE( aObjDesc );
794cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
795cdf0e10cSrcweir 
796cdf0e10cSrcweir         // --> OD 2005-02-09 #119353# - robust
797cdf0e10cSrcweir         const Graphic* pGrf = pWrtShell->GetGraphic();
798cdf0e10cSrcweir         if( pGrf && pGrf->IsSupportedGraphic() )
799cdf0e10cSrcweir         // <--
800cdf0e10cSrcweir 		{
801cdf0e10cSrcweir 			AddFormat( FORMAT_GDIMETAFILE );
80245fd3b9aSArmin Le Grand             AddFormat( SOT_FORMATSTR_ID_PNG );
803cdf0e10cSrcweir 			AddFormat( FORMAT_BITMAP );
804cdf0e10cSrcweir 		}
805cdf0e10cSrcweir 		eBufferType = TRNSFR_GRAPHIC;
806cdf0e10cSrcweir 		pWrtShell->GetGrfNms( &sGrfNm, 0 );
807cdf0e10cSrcweir 	}
808cdf0e10cSrcweir 	else if ( nSelection == nsSelectionType::SEL_OLE )
809cdf0e10cSrcweir 	{
810cdf0e10cSrcweir         pClpDocFac = new SwDocFac;
811cdf0e10cSrcweir         SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
812cdf0e10cSrcweir 		aDocShellRef = new SwDocShell( pDoc, SFX_CREATE_MODE_EMBEDDED);
813cdf0e10cSrcweir 		aDocShellRef->DoInitNew( NULL );
814cdf0e10cSrcweir 		pWrtShell->Copy( pDoc );
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
817cdf0e10cSrcweir 
818cdf0e10cSrcweir         // --> OD #i98753#
819cdf0e10cSrcweir         // set size of embedded object at the object description structure
820cdf0e10cSrcweir         aObjDesc.maSize = OutputDevice::LogicToLogic( pWrtShell->GetObjSize(), MAP_TWIP, MAP_100TH_MM );
821cdf0e10cSrcweir         // <--
822cdf0e10cSrcweir         PrepareOLE( aObjDesc );
823cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
824cdf0e10cSrcweir 
825cdf0e10cSrcweir         AddFormat( FORMAT_GDIMETAFILE );
826cdf0e10cSrcweir 		eBufferType = TRNSFR_OLE;
827cdf0e10cSrcweir 	}
828cdf0e10cSrcweir 	//Gibt es ueberhaupt etwas zum bereitstellen?
829cdf0e10cSrcweir 	else if ( pWrtShell->IsSelection() || pWrtShell->IsFrmSelected() ||
830cdf0e10cSrcweir 			  pWrtShell->IsObjSelected() )
831cdf0e10cSrcweir 	{
832cdf0e10cSrcweir 		SwWait *pWait = 0;
833cdf0e10cSrcweir 		if( pWrtShell->ShouldWait() )
834cdf0e10cSrcweir 			pWait = new SwWait( *pWrtShell->GetView().GetDocShell(), sal_True );
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 		pClpDocFac = new SwDocFac;
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 		// zusaetzlichen Cursor erzeugen, damit eine Gleichbehandlung
839cdf0e10cSrcweir 		// von Tastatur- und Mausselektion moeglich ist.
840cdf0e10cSrcweir 		// Im AddMode wird bei Tastaturselektion der neue Cursor erst
841cdf0e10cSrcweir 		// beim Bewegen des Cursors nach Selektionsende erzeugt.
842cdf0e10cSrcweir 		if( pWrtShell->IsAddMode() && pWrtShell->SwCrsrShell::HasSelection() )
843cdf0e10cSrcweir 			pWrtShell->CreateCrsr();
844cdf0e10cSrcweir 
845cdf0e10cSrcweir         SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 		pTmpDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
848cdf0e10cSrcweir 		pWrtShell->Copy( pTmpDoc );
849cdf0e10cSrcweir 
850cdf0e10cSrcweir         {
851cdf0e10cSrcweir             IDocumentMarkAccess* const pMarkAccess = pTmpDoc->getIDocumentMarkAccess();
852cdf0e10cSrcweir             ::std::vector< ::sw::mark::IMark* > vDdeMarks;
853cdf0e10cSrcweir             // find all DDE-Bookmarks
854cdf0e10cSrcweir             for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
855cdf0e10cSrcweir                 ppMark != pMarkAccess->getMarksEnd();
856cdf0e10cSrcweir                 ppMark++)
857cdf0e10cSrcweir             {
858cdf0e10cSrcweir                 if(IDocumentMarkAccess::DDE_BOOKMARK == IDocumentMarkAccess::GetType(**ppMark))
859cdf0e10cSrcweir                     vDdeMarks.push_back(ppMark->get());
860cdf0e10cSrcweir             }
861cdf0e10cSrcweir             // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
862cdf0e10cSrcweir             for(::std::vector< ::sw::mark::IMark* >::iterator ppMark = vDdeMarks.begin();
863cdf0e10cSrcweir                 ppMark != vDdeMarks.end();
864cdf0e10cSrcweir                 ppMark++)
865cdf0e10cSrcweir                 pMarkAccess->deleteMark(*ppMark);
866cdf0e10cSrcweir         }
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 		// es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
869cdf0e10cSrcweir         aDocShellRef = pTmpDoc->GetTmpDocShell();
870cdf0e10cSrcweir 		if( aDocShellRef.Is() )
871cdf0e10cSrcweir 			SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
872cdf0e10cSrcweir 		pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
873cdf0e10cSrcweir 
874cdf0e10cSrcweir 		if( pWrtShell->IsObjSelected() )
875cdf0e10cSrcweir 			eBufferType = TRNSFR_DRAWING;
876cdf0e10cSrcweir 		else
877cdf0e10cSrcweir 		{
878cdf0e10cSrcweir 			eBufferType = TRNSFR_DOCUMENT;
879cdf0e10cSrcweir 			if (pWrtShell->IntelligentCut(nSelection, sal_False) != SwWrtShell::NO_WORD)
880cdf0e10cSrcweir 				eBufferType = (TransferBufferType)(TRNSFR_DOCUMENT_WORD | eBufferType);
881cdf0e10cSrcweir 		}
882cdf0e10cSrcweir 
883cdf0e10cSrcweir 		int bDDELink = pWrtShell->IsSelection();
884cdf0e10cSrcweir 		if( nSelection & nsSelectionType::SEL_TBL_CELLS )
885cdf0e10cSrcweir 		{
886cdf0e10cSrcweir 			eBufferType = (TransferBufferType)(TRNSFR_TABELLE | eBufferType);
887cdf0e10cSrcweir 			bDDELink = pWrtShell->HasWholeTabSelection();
888cdf0e10cSrcweir 		}
889cdf0e10cSrcweir 
890cdf0e10cSrcweir 		//Wenn's einer braucht OLE'n wir ihm was.
891cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 		//RTF vor das Metafile von OLE stellen, weil mit weniger verlusten
894cdf0e10cSrcweir 		//behaftet.
895cdf0e10cSrcweir 		if( !pWrtShell->IsObjSelected() )
896cdf0e10cSrcweir 		{
897cdf0e10cSrcweir 			AddFormat( FORMAT_RTF );
898cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_HTML );
899cdf0e10cSrcweir 		}
900cdf0e10cSrcweir 		if( pWrtShell->IsSelection() )
901cdf0e10cSrcweir 			AddFormat( FORMAT_STRING );
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 		if( nSelection & ( nsSelectionType::SEL_DRW | nsSelectionType::SEL_DRW_FORM ))
904cdf0e10cSrcweir 		{
905cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_DRAWING );
906cdf0e10cSrcweir 			if ( nSelection & nsSelectionType::SEL_DRW )
907cdf0e10cSrcweir 			{
908cdf0e10cSrcweir 				AddFormat( FORMAT_GDIMETAFILE );
90945fd3b9aSArmin Le Grand                 AddFormat( SOT_FORMATSTR_ID_PNG );
910cdf0e10cSrcweir 				AddFormat( FORMAT_BITMAP );
911cdf0e10cSrcweir 			}
912cdf0e10cSrcweir 			eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 			pClpGraphic = new Graphic;
915cdf0e10cSrcweir 			if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
916cdf0e10cSrcweir 				pOrigGrf = pClpGraphic;
917cdf0e10cSrcweir 			pClpBitmap = new Graphic;
918cdf0e10cSrcweir 			if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
919cdf0e10cSrcweir 				pOrigGrf = pClpBitmap;
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 			// ist es ein URL-Button ?
922cdf0e10cSrcweir 			String sURL, sDesc;
923cdf0e10cSrcweir 			if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
924cdf0e10cSrcweir 			{
925cdf0e10cSrcweir 				AddFormat( FORMAT_STRING );
926cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_SOLK );
927cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
928cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
929cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
930cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
931cdf0e10cSrcweir 				eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
932cdf0e10cSrcweir 				nRet = sal_True;
933cdf0e10cSrcweir 			}
934cdf0e10cSrcweir 		}
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 		// beim Cut hat DDE-Link keinen Sinn!!
937cdf0e10cSrcweir 		SwDocShell* pDShell;
938cdf0e10cSrcweir 		if( !bIsCut && bDDELink &&
939cdf0e10cSrcweir 			0 != ( pDShell = pWrtShell->GetDoc()->GetDocShell()) &&
940cdf0e10cSrcweir 			SFX_CREATE_MODE_STANDARD == pDShell->GetCreateMode() )
941cdf0e10cSrcweir 		{
942cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_LINK );
943cdf0e10cSrcweir 			refDdeLink = new SwTrnsfrDdeLink( *this, *pWrtShell );
944cdf0e10cSrcweir 		}
945cdf0e10cSrcweir 
946cdf0e10cSrcweir 		//ObjectDescriptor wurde bereits aus der alten DocShell gefuellt.
947cdf0e10cSrcweir 		//Jetzt noch anpassen. Dadurch kann im GetData die erste Anfrage
948cdf0e10cSrcweir 		//auch noch mit delayed rendering beantwortet werden.
949cdf0e10cSrcweir 		aObjDesc.mbCanLink = sal_False;
950cdf0e10cSrcweir 		Size aSz( OLESIZE );
951cdf0e10cSrcweir 		aObjDesc.maSize = OutputDevice::LogicToLogic( aSz, MAP_TWIP, MAP_100TH_MM );
952cdf0e10cSrcweir 
953cdf0e10cSrcweir         PrepareOLE( aObjDesc );
954cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 		delete pWait;
957cdf0e10cSrcweir 	}
958cdf0e10cSrcweir 	else
959cdf0e10cSrcweir 		nRet = 0;
960cdf0e10cSrcweir 
961cdf0e10cSrcweir 	if( pWrtShell->IsFrmSelected() )
962cdf0e10cSrcweir 	{
963cdf0e10cSrcweir 		SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
964cdf0e10cSrcweir 		pWrtShell->GetFlyFrmAttr( aSet );
965cdf0e10cSrcweir 		const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
966cdf0e10cSrcweir 		if( rURL.GetMap() )
967cdf0e10cSrcweir 		{
968cdf0e10cSrcweir 			pImageMap = new ImageMap( *rURL.GetMap() );
969cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_SVIM );
970cdf0e10cSrcweir 		}
971cdf0e10cSrcweir 		else if( rURL.GetURL().Len() )
972cdf0e10cSrcweir 		{
973cdf0e10cSrcweir 			pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
974cdf0e10cSrcweir 										rURL.GetTargetFrameName(),
975cdf0e10cSrcweir 										aEmptyStr, Size() );
976cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_INET_IMAGE );
977cdf0e10cSrcweir 		}
978cdf0e10cSrcweir 	}
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 	return nRet;
981cdf0e10cSrcweir }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir int SwTransferable::Copy( sal_Bool bIsCut )
984cdf0e10cSrcweir {
985cdf0e10cSrcweir     int nRet = PrepareForCopy( bIsCut );
986cdf0e10cSrcweir     if ( nRet )
987cdf0e10cSrcweir     {
988cdf0e10cSrcweir         CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
989cdf0e10cSrcweir     }
990cdf0e10cSrcweir 	return nRet;
991cdf0e10cSrcweir }
992cdf0e10cSrcweir 
993cdf0e10cSrcweir // -----------------------------------------------------------------------
994cdf0e10cSrcweir 
995cdf0e10cSrcweir int SwTransferable::CalculateAndCopy()
996cdf0e10cSrcweir {
997cdf0e10cSrcweir     if(!pWrtShell)
998cdf0e10cSrcweir         return 0;
999cdf0e10cSrcweir     SwWait aWait( *pWrtShell->GetView().GetDocShell(), sal_True );
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 	String aStr( pWrtShell->Calculate() );
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 	pClpDocFac = new SwDocFac;
1004cdf0e10cSrcweir     SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
1005cdf0e10cSrcweir     pWrtShell->Copy(pDoc, & aStr);
1006cdf0e10cSrcweir 	eBufferType = TRNSFR_DOCUMENT;
1007cdf0e10cSrcweir 	AddFormat( FORMAT_STRING );
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 	CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir 	return 1;
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir // -----------------------------------------------------------------------
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary,
1017cdf0e10cSrcweir 									const String& rStr )
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir     if(!pWrtShell)
1020cdf0e10cSrcweir         return 0;
1021cdf0e10cSrcweir     SwWait aWait( *pWrtShell->GetView().GetDocShell(), sal_True );
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 	pClpDocFac = new SwDocFac;
1024cdf0e10cSrcweir     SwDoc *const pCDoc = lcl_GetDoc(*pClpDocFac);
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir 	SwNodes& rNds = pCDoc->GetNodes();
1027cdf0e10cSrcweir 	SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() );
1028cdf0e10cSrcweir 	SwCntntNode* pCNd = rNds.GoNext( &aNodeIdx ); // gehe zum 1. ContentNode
1029cdf0e10cSrcweir 	SwPaM aPam( *pCNd );
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir 	pCDoc->LockExpFlds(); 	// nie die Felder updaten - Text so belassen
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir 	pCDoc->InsertGlossary( rGlossary, rStr, aPam, 0 );
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir 	// es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
1036cdf0e10cSrcweir     aDocShellRef = pCDoc->GetTmpDocShell();
1037cdf0e10cSrcweir 	if( aDocShellRef.Is() )
1038cdf0e10cSrcweir 		SwTransferable::InitOle( aDocShellRef, *pCDoc );
1039cdf0e10cSrcweir     pCDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 	eBufferType = TRNSFR_DOCUMENT;
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 	//Wenn's einer braucht OLE'n wir ihm was.
1044cdf0e10cSrcweir 	AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
1045cdf0e10cSrcweir     AddFormat( FORMAT_RTF );
1046cdf0e10cSrcweir 	AddFormat( SOT_FORMATSTR_ID_HTML );
1047cdf0e10cSrcweir 	AddFormat( FORMAT_STRING );
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 	//ObjectDescriptor wurde bereits aus der alten DocShell gefuellt.
1050cdf0e10cSrcweir 	//Jetzt noch anpassen. Dadurch kann im GetData die erste Anfrage
1051cdf0e10cSrcweir 	//auch noch mit delayed rendering beantwortet werden.
1052cdf0e10cSrcweir 	aObjDesc.mbCanLink = sal_False;
1053cdf0e10cSrcweir 	Size aSz( OLESIZE );
1054cdf0e10cSrcweir 	aObjDesc.maSize = OutputDevice::LogicToLogic( aSz, MAP_TWIP, MAP_100TH_MM );
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir     PrepareOLE( aObjDesc );
1057cdf0e10cSrcweir     AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir 	CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir 	return 1;
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir static inline uno::Reference < XTransferable > * lcl_getTransferPointer ( uno::Reference < XTransferable > &xRef )
1065cdf0e10cSrcweir {
1066cdf0e10cSrcweir 	return &xRef;
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir // -----------------------------------------------------------------------
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir sal_Bool SwTransferable::IsPaste( const SwWrtShell& rSh,
1071cdf0e10cSrcweir 							  const TransferableDataHelper& rData )
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir     // Check the common case first: We can always paste our own data!
1074cdf0e10cSrcweir     // #106503#: If _only_ the internal format can be pasted, this check will
1075cdf0e10cSrcweir     // yield 'true', while the one below would give a (wrong) result 'false'.
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir     bool bIsPaste = ( GetSwTransferable( rData ) != NULL );
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir     // if it's not our own data, we need to have a closer look:
1080cdf0e10cSrcweir     if( ! bIsPaste )
1081cdf0e10cSrcweir     {
1082cdf0e10cSrcweir         // determine the proper paste action, and return true if we find one
1083cdf0e10cSrcweir         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir         sal_uInt16 nDestination = SwTransferable::GetSotDestination( rSh );
1086cdf0e10cSrcweir         sal_uInt16 nSourceOptions =
1087cdf0e10cSrcweir 					(( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
1088cdf0e10cSrcweir 					   EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
1089cdf0e10cSrcweir 					   EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
1090cdf0e10cSrcweir 					   EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
1091cdf0e10cSrcweir 									? EXCHG_IN_ACTION_COPY
1092cdf0e10cSrcweir                      : EXCHG_IN_ACTION_MOVE);
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir         sal_uLong nFormat;          // output param for GetExchangeAction
1095cdf0e10cSrcweir         sal_uInt16 nEventAction;    // output param for GetExchangeAction
1096cdf0e10cSrcweir         sal_uInt16 nAction = SotExchange::GetExchangeAction(
1097cdf0e10cSrcweir 								rData.GetDataFlavorExVector(),
1098cdf0e10cSrcweir 								nDestination,
1099cdf0e10cSrcweir 								nSourceOptions,  			/* ?? */
1100cdf0e10cSrcweir 								EXCHG_IN_ACTION_DEFAULT,    /* ?? */
1101cdf0e10cSrcweir 								nFormat, nEventAction, 0,
1102cdf0e10cSrcweir 								lcl_getTransferPointer ( xTransferable ) );
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir         // if we find a suitable action, we can paste!
1105cdf0e10cSrcweir         bIsPaste = (EXCHG_INOUT_ACTION_NONE != nAction);
1106cdf0e10cSrcweir     }
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 	return bIsPaste;
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir // -----------------------------------------------------------------------
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir int SwTransferable::Paste( SwWrtShell& rSh, TransferableDataHelper& rData )
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir     sal_uInt16 nEventAction, nAction=0,
1116cdf0e10cSrcweir 		   nDestination = SwTransferable::GetSotDestination( rSh );
1117cdf0e10cSrcweir     sal_uLong nFormat = 0;
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 	if( GetSwTransferable( rData ) )
1120cdf0e10cSrcweir 	{
1121cdf0e10cSrcweir 		nAction = EXCHG_OUT_ACTION_INSERT_PRIVATE;
1122cdf0e10cSrcweir 	}
1123cdf0e10cSrcweir 	else
1124cdf0e10cSrcweir 	{
1125cdf0e10cSrcweir         sal_uInt16 nSourceOptions =
1126cdf0e10cSrcweir                     (( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
1127cdf0e10cSrcweir                     EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
1128cdf0e10cSrcweir                     EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
1129cdf0e10cSrcweir                     EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
1130cdf0e10cSrcweir                                     ? EXCHG_IN_ACTION_COPY
1131cdf0e10cSrcweir                                     : EXCHG_IN_ACTION_MOVE);
1132cdf0e10cSrcweir         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
1133cdf0e10cSrcweir         nAction = SotExchange::GetExchangeAction(
1134cdf0e10cSrcweir                                     rData.GetDataFlavorExVector(),
1135cdf0e10cSrcweir                                     nDestination,
1136cdf0e10cSrcweir                                     nSourceOptions,             /* ?? */
1137cdf0e10cSrcweir                                     EXCHG_IN_ACTION_DEFAULT,    /* ?? */
1138cdf0e10cSrcweir                                     nFormat, nEventAction, 0,
1139cdf0e10cSrcweir                                     lcl_getTransferPointer ( xTransferable ) );
1140cdf0e10cSrcweir 	}
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir 	// special case for tables from draw application
1143cdf0e10cSrcweir 	if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == (nAction & EXCHG_ACTION_MASK) )
1144cdf0e10cSrcweir 	{
1145cdf0e10cSrcweir 		if( rData.HasFormat( SOT_FORMAT_RTF ) )
1146cdf0e10cSrcweir 		{
1147cdf0e10cSrcweir 			nAction = EXCHG_OUT_ACTION_INSERT_STRING | (nAction & !EXCHG_ACTION_MASK);
1148cdf0e10cSrcweir 			nFormat = SOT_FORMAT_RTF;
1149cdf0e10cSrcweir 		}
1150cdf0e10cSrcweir 	}
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir 	return EXCHG_INOUT_ACTION_NONE != nAction &&
1153cdf0e10cSrcweir 			SwTransferable::PasteData( rData, rSh, nAction, nFormat,
1154cdf0e10cSrcweir                                         nDestination, sal_False, sal_False );
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir 
1157cdf0e10cSrcweir // -----------------------------------------------------------------------
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir int SwTransferable::PasteData( TransferableDataHelper& rData,
1160cdf0e10cSrcweir 							SwWrtShell& rSh, sal_uInt16 nAction, sal_uLong nFormat,
1161cdf0e10cSrcweir 							sal_uInt16 nDestination, sal_Bool bIsPasteFmt,
1162cdf0e10cSrcweir 							sal_Bool bIsDefault,
1163cdf0e10cSrcweir 							const Point* pPt, sal_Int8 nDropAction,
1164cdf0e10cSrcweir 							sal_Bool bPasteSelection )
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir 	SwWait aWait( *rSh.GetView().
1167cdf0e10cSrcweir 		GetDocShell(), sal_False );
1168cdf0e10cSrcweir 	SwTrnsfrActionAndUndo* pAction = 0;
1169cdf0e10cSrcweir 	SwModule* pMod = SW_MOD();
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 	int nRet = 0;
1172cdf0e10cSrcweir     bool bCallAutoCaption = false;
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	if( pPt )
1175cdf0e10cSrcweir 	{
1176cdf0e10cSrcweir 		// external Drop
1177cdf0e10cSrcweir 		if( bPasteSelection ? !pMod->pXSelection : !pMod->pDragDrop )
1178cdf0e10cSrcweir 		{
1179cdf0e10cSrcweir 			switch( nDestination )
1180cdf0e10cSrcweir 			{
1181cdf0e10cSrcweir 			case EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP:
1182cdf0e10cSrcweir 			case EXCHG_DEST_DOC_LNKD_GRAPHOBJ:
1183cdf0e10cSrcweir 			case EXCHG_DEST_DOC_GRAPH_W_IMAP:
1184cdf0e10cSrcweir 			case EXCHG_DEST_DOC_GRAPHOBJ:
1185cdf0e10cSrcweir 			case EXCHG_DEST_DOC_OLEOBJ:
1186cdf0e10cSrcweir 			case EXCHG_DEST_DOC_DRAWOBJ:
1187cdf0e10cSrcweir 			case EXCHG_DEST_DOC_URLBUTTON:
1188cdf0e10cSrcweir 			case EXCHG_DEST_DOC_GROUPOBJ:
1189cdf0e10cSrcweir 				// Rahmen/Objecte selektieren
1190cdf0e10cSrcweir 				SwTransferable::SetSelInShell( rSh, sal_True, pPt );
1191cdf0e10cSrcweir 				break;
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir 			// case EXCHG_DEST_DOC_TEXTFRAME:
1194cdf0e10cSrcweir 			// case EXCHG_DEST_SWDOC_FREE_AREA:
1195cdf0e10cSrcweir 			// case EXCHG_DEST_DOC_URLFIELD:
1196cdf0e10cSrcweir 			default:
1197cdf0e10cSrcweir 				SwTransferable::SetSelInShell( rSh, sal_False, pPt );
1198cdf0e10cSrcweir 				break;
1199cdf0e10cSrcweir 			}
1200cdf0e10cSrcweir 		}
1201cdf0e10cSrcweir 	}
1202cdf0e10cSrcweir 	else if( ( !GetSwTransferable( rData ) || bIsPasteFmt ) &&
1203cdf0e10cSrcweir 			!rSh.IsTableMode() && rSh.HasSelection() )
1204cdf0e10cSrcweir 	{
1205cdf0e10cSrcweir 		// dann die Selektionen loeschen
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir 		//Selektierten Inhalt loeschen,
1208cdf0e10cSrcweir 		// - nicht bei Tabellen-Selektion
1209cdf0e10cSrcweir 		// - nicht bei ReRead einer Grafik/DDEDaten
1210cdf0e10cSrcweir 		// - nicht bei D&D, fuer die richtige Selektion wurde im
1211cdf0e10cSrcweir 		//		Drop-Handler gesorgt
1212cdf0e10cSrcweir 		sal_Bool bDelSel = sal_False;
1213cdf0e10cSrcweir 		switch( nDestination )
1214cdf0e10cSrcweir 		{
1215cdf0e10cSrcweir 		case EXCHG_DEST_DOC_TEXTFRAME:
1216cdf0e10cSrcweir 		case EXCHG_DEST_SWDOC_FREE_AREA:
1217cdf0e10cSrcweir 		case EXCHG_DEST_DOC_TEXTFRAME_WEB:
1218cdf0e10cSrcweir 		case EXCHG_DEST_SWDOC_FREE_AREA_WEB:
1219cdf0e10cSrcweir 			bDelSel = sal_True;
1220cdf0e10cSrcweir 			break;
1221cdf0e10cSrcweir 		}
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 		if( bDelSel )
1224cdf0e10cSrcweir             // --> FME 2004-10-19 #i34830#
1225cdf0e10cSrcweir 			pAction = new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD, NULL,
1226cdf0e10cSrcweir                                                  sal_True );
1227cdf0e10cSrcweir             // <--
1228cdf0e10cSrcweir 	}
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir     SwTransferable *pTrans=0, *pTunneledTrans=GetSwTransferable( rData );
1231cdf0e10cSrcweir //    uno::Reference<XUnoTunnel> xTunnel( rData.GetTransferable(), UNO_QUERY );
1232cdf0e10cSrcweir //    if ( xTunnel.is() )
1233cdf0e10cSrcweir //    {
1234cdf0e10cSrcweir //        sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() );
1235cdf0e10cSrcweir //        if ( nHandle )
1236cdf0e10cSrcweir //            pTunneledTrans = (SwTransferable*) (sal_IntPtr) nHandle;
1237cdf0e10cSrcweir //    }
1238cdf0e10cSrcweir 
12391cd65da9SArmin Le Grand     // check for private drop
12401cd65da9SArmin Le Grand     bool bPrivateDrop(pPt && (bPasteSelection ? 0 != (pTrans = pMod->pXSelection) : 0 != (pTrans = pMod->pDragDrop)));
12411cd65da9SArmin Le Grand     bool bNeedToSelectBeforePaste(false);
12421cd65da9SArmin Le Grand 
12431cd65da9SArmin Le Grand     if(bPrivateDrop && DND_ACTION_LINK == nDropAction)
12441cd65da9SArmin Le Grand     {
12451cd65da9SArmin Le Grand         // internal drop on object, suppress bPrivateDrop to change internal fill
12461cd65da9SArmin Le Grand         bPrivateDrop = false;
12471cd65da9SArmin Le Grand         bNeedToSelectBeforePaste = true;
12481cd65da9SArmin Le Grand     }
12491cd65da9SArmin Le Grand 
12501cd65da9SArmin Le Grand     if(bPrivateDrop && pPt && DND_ACTION_MOVE == nDropAction)
12511cd65da9SArmin Le Grand     {
12521cd65da9SArmin Le Grand         // check if dragged over a useful target. If yes, use as content exchange
12531cd65da9SArmin Le Grand         // drop as if from external
12541cd65da9SArmin Le Grand         const SwFrmFmt* pSwFrmFmt = rSh.GetFmtFromObj(*pPt);
12551cd65da9SArmin Le Grand 
12561cd65da9SArmin Le Grand         if(pSwFrmFmt && 0 != dynamic_cast< const SwDrawFrmFmt* >(pSwFrmFmt))
12571cd65da9SArmin Le Grand         {
12581cd65da9SArmin Le Grand             bPrivateDrop = false;
12591cd65da9SArmin Le Grand             bNeedToSelectBeforePaste = true;
12601cd65da9SArmin Le Grand         }
12611cd65da9SArmin Le Grand     }
12621cd65da9SArmin Le Grand 
12631cd65da9SArmin Le Grand     if(bPrivateDrop)
1264cdf0e10cSrcweir 	{
1265cdf0e10cSrcweir 		// then internal Drag & Drop or XSelection
1266cdf0e10cSrcweir 		nRet = pTrans->PrivateDrop( rSh, *pPt, DND_ACTION_MOVE == nDropAction,
1267cdf0e10cSrcweir 									bPasteSelection );
1268cdf0e10cSrcweir 	}
1269cdf0e10cSrcweir     else if( !pPt && pTunneledTrans &&
1270cdf0e10cSrcweir 			EXCHG_OUT_ACTION_INSERT_PRIVATE == nAction )
1271cdf0e10cSrcweir 	{
1272cdf0e10cSrcweir 		// then internal paste
1273cdf0e10cSrcweir         nRet = pTunneledTrans->PrivatePaste( rSh );
1274cdf0e10cSrcweir 	}
1275cdf0e10cSrcweir 	else if( EXCHG_INOUT_ACTION_NONE != nAction )
1276cdf0e10cSrcweir 	{
1277cdf0e10cSrcweir 		if( !pAction )
1278cdf0e10cSrcweir         {
1279cdf0e10cSrcweir             // #111827#
1280cdf0e10cSrcweir 			pAction = new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD);
1281cdf0e10cSrcweir         }
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir 		// im Drag&Drop duerfen keine MessageBoxen angezeigt werden
1284cdf0e10cSrcweir 		sal_Bool bMsg = 0 == pPt;
1285cdf0e10cSrcweir         sal_uInt8 nActionFlags = static_cast< sal_uInt8 >(( nAction >> 8 ) & 0xFF);
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir 		sal_uInt16 nClearedAction = ( nAction & EXCHG_ACTION_MASK );
1288cdf0e10cSrcweir 		// Selektionen loeschen
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir 		switch( nClearedAction )
1291cdf0e10cSrcweir 		{
1292cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_PRIVATE:
1293cdf0e10cSrcweir ASSERT( pPt, "EXCHG_OUT_ACTION_INSERT_PRIVATE: was soll hier passieren?" );
1294cdf0e10cSrcweir 			break;
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_MOVE_PRIVATE:
1297cdf0e10cSrcweir ASSERT( pPt, "EXCHG_OUT_ACTION_MOVE_PRIVATE: was soll hier passieren?" );
1298cdf0e10cSrcweir 			break;
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir 		case EXCHG_IN_ACTION_MOVE:
1302cdf0e10cSrcweir 		case EXCHG_IN_ACTION_COPY:
1303cdf0e10cSrcweir 		case EXCHG_IN_ACTION_LINK:
1304cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_HTML:
1305cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_STRING:
1306cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_IMAGEMAP:
1307cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_REPLACE_IMAGEMAP:
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir 			// dann muss ueber das Format gegangen werden
1310cdf0e10cSrcweir 			switch( nFormat )
1311cdf0e10cSrcweir 			{
1312cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_DRAWING:
1313cdf0e10cSrcweir 				nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
1314cdf0e10cSrcweir 												SW_PASTESDR_INSERT, pPt,
13151cd65da9SArmin Le Grand 												nActionFlags, bNeedToSelectBeforePaste);
1316cdf0e10cSrcweir 				break;
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_HTML:
1319cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_HTML_SIMPLE:
1320cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_HTML_NO_COMMENT:
1321cdf0e10cSrcweir 			case SOT_FORMAT_RTF:
1322cdf0e10cSrcweir 			case SOT_FORMAT_STRING:
1323cdf0e10cSrcweir 				nRet = SwTransferable::_PasteFileContent( rData, rSh,
1324cdf0e10cSrcweir 															nFormat, bMsg );
1325cdf0e10cSrcweir 				break;
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
1328cdf0e10cSrcweir 				{
1329cdf0e10cSrcweir 					INetBookmark aBkmk;
1330cdf0e10cSrcweir 					if( rData.GetINetBookmark( nFormat, aBkmk ) )
1331cdf0e10cSrcweir 					{
1332cdf0e10cSrcweir 						SwFmtINetFmt aFmt( aBkmk.GetURL(), aEmptyStr );
1333cdf0e10cSrcweir 						rSh.InsertURL( aFmt, aBkmk.GetDescription() );
1334cdf0e10cSrcweir 						nRet = 1;
1335cdf0e10cSrcweir 					}
1336cdf0e10cSrcweir 				}
1337cdf0e10cSrcweir 				break;
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SD_OLE:
1340cdf0e10cSrcweir 				nRet = SwTransferable::_PasteOLE( rData, rSh, nFormat,
1341cdf0e10cSrcweir 													nActionFlags, bMsg );
1342cdf0e10cSrcweir 				break;
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SVIM:
1345cdf0e10cSrcweir 				nRet = SwTransferable::_PasteImageMap( rData, rSh );
1346cdf0e10cSrcweir 				break;
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SVXB:
1349cdf0e10cSrcweir 			case SOT_FORMAT_BITMAP:
1350cdf0e10cSrcweir 			case SOT_FORMAT_GDIMETAFILE:
1351cdf0e10cSrcweir 				nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
1352cdf0e10cSrcweir 												SW_PASTESDR_INSERT,pPt,
13531cd65da9SArmin Le Grand 												nActionFlags, nDropAction, bNeedToSelectBeforePaste);
1354cdf0e10cSrcweir 				break;
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_XFORMS:
1357cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE:
1358cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SBA_DATAEXCHANGE:
1359cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE:
1360cdf0e10cSrcweir 				nRet = SwTransferable::_PasteDBData( rData, rSh, nFormat,
1361cdf0e10cSrcweir 											EXCHG_IN_ACTION_LINK == nClearedAction,
1362cdf0e10cSrcweir 											pPt, bMsg );
1363cdf0e10cSrcweir 				break;
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir 			case SOT_FORMAT_FILE:
1366cdf0e10cSrcweir 				nRet = SwTransferable::_PasteFileName( rData, rSh, nFormat,
1367cdf0e10cSrcweir 								( EXCHG_IN_ACTION_MOVE == nClearedAction
1368cdf0e10cSrcweir 									? SW_PASTESDR_REPLACE
1369cdf0e10cSrcweir 									: EXCHG_IN_ACTION_LINK == nClearedAction
1370cdf0e10cSrcweir 										? SW_PASTESDR_SETATTR
1371cdf0e10cSrcweir 										: SW_PASTESDR_INSERT),
1372cdf0e10cSrcweir 								pPt, nActionFlags, bMsg );
1373cdf0e10cSrcweir 				break;
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 			case SOT_FORMAT_FILE_LIST:
1376cdf0e10cSrcweir 				// dann nur als Grafiken einfuegen
1377cdf0e10cSrcweir 				nRet = SwTransferable::_PasteFileList( rData, rSh,
1378cdf0e10cSrcweir 									EXCHG_IN_ACTION_LINK == nClearedAction,
1379cdf0e10cSrcweir 									pPt, bMsg );
1380cdf0e10cSrcweir 				break;
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SONLK:
1383cdf0e10cSrcweir 				if( pPt )
1384cdf0e10cSrcweir 				{
1385cdf0e10cSrcweir 					NaviContentBookmark aBkmk;
1386cdf0e10cSrcweir 					if( aBkmk.Paste( rData ) )
1387cdf0e10cSrcweir 					{
1388cdf0e10cSrcweir                         if(bIsDefault)
1389cdf0e10cSrcweir                         {
1390cdf0e10cSrcweir                             switch(aBkmk.GetDefaultDragType())
1391cdf0e10cSrcweir                             {
1392cdf0e10cSrcweir                                 case REGION_MODE_NONE: nClearedAction = EXCHG_IN_ACTION_COPY; break;
1393cdf0e10cSrcweir                                 case REGION_MODE_EMBEDDED: nClearedAction = EXCHG_IN_ACTION_MOVE; break;
1394cdf0e10cSrcweir                                 case REGION_MODE_LINK: nClearedAction = EXCHG_IN_ACTION_LINK; break;
1395cdf0e10cSrcweir                             }
1396cdf0e10cSrcweir                         }
1397cdf0e10cSrcweir                         rSh.NavigatorPaste( aBkmk, nClearedAction );
1398cdf0e10cSrcweir 						nRet = 1;
1399cdf0e10cSrcweir 					}
1400cdf0e10cSrcweir 				}
1401cdf0e10cSrcweir 				break;
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_INET_IMAGE:
1404cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_NETSCAPE_IMAGE:
1405cdf0e10cSrcweir 				nRet = SwTransferable::_PasteTargetURL( rData, rSh,
1406cdf0e10cSrcweir 														SW_PASTESDR_INSERT,
1407cdf0e10cSrcweir 														pPt, sal_True );
1408cdf0e10cSrcweir 				break;
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir 			default:
1411cdf0e10cSrcweir 				ASSERT( pPt, "unbekanntes Format" );
1412cdf0e10cSrcweir 			}
1413cdf0e10cSrcweir 			break;
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_FILE:
1416cdf0e10cSrcweir 			nRet = SwTransferable::_PasteFileName( rData, rSh, nFormat,
1417cdf0e10cSrcweir 										SW_PASTESDR_INSERT, pPt,
1418cdf0e10cSrcweir 										nActionFlags, bMsg );
1419cdf0e10cSrcweir 			if( nRet & SWTRANSFER_GRAPHIC_INSERTED )
1420cdf0e10cSrcweir                 bCallAutoCaption = true;
1421cdf0e10cSrcweir             break;
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_OLE:
1424cdf0e10cSrcweir 			nRet = SwTransferable::_PasteOLE( rData, rSh, nFormat,
1425cdf0e10cSrcweir 												nActionFlags,bMsg );
1426cdf0e10cSrcweir 			break;
1427cdf0e10cSrcweir 
1428cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_DDE:
1429cdf0e10cSrcweir 			{
1430cdf0e10cSrcweir 				sal_Bool bReRead = 0 != CNT_HasGrf( rSh.GetCntType() );
1431cdf0e10cSrcweir 				nRet = SwTransferable::_PasteDDE( rData, rSh, bReRead, bMsg );
1432cdf0e10cSrcweir 			}
1433cdf0e10cSrcweir 			break;
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_HYPERLINK:
1436cdf0e10cSrcweir 			{
1437cdf0e10cSrcweir 				String sURL, sDesc;
1438cdf0e10cSrcweir 				if( SOT_FORMAT_FILE == nFormat )
1439cdf0e10cSrcweir 				{
1440cdf0e10cSrcweir 					if( rData.GetString( nFormat, sURL ) && sURL.Len() )
1441cdf0e10cSrcweir 					{
1442cdf0e10cSrcweir 						SwTransferable::_CheckForURLOrLNKFile( rData, sURL, &sDesc );
1443cdf0e10cSrcweir 						if( !sDesc.Len() )
1444cdf0e10cSrcweir 							sDesc = sURL;
1445cdf0e10cSrcweir 						nRet = 1;
1446cdf0e10cSrcweir 					}
1447cdf0e10cSrcweir 				}
1448cdf0e10cSrcweir 				else
1449cdf0e10cSrcweir 				{
1450cdf0e10cSrcweir 					INetBookmark aBkmk;
1451cdf0e10cSrcweir 					if( rData.GetINetBookmark( nFormat, aBkmk ) )
1452cdf0e10cSrcweir 					{
1453cdf0e10cSrcweir 						sURL = aBkmk.GetURL();
1454cdf0e10cSrcweir 						sDesc = aBkmk.GetDescription();
1455cdf0e10cSrcweir 						nRet = 1;
1456cdf0e10cSrcweir 					}
1457cdf0e10cSrcweir 				}
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir 				if( nRet )
1460cdf0e10cSrcweir 				{
1461cdf0e10cSrcweir 					SwFmtINetFmt aFmt( sURL, aEmptyStr );
1462cdf0e10cSrcweir 					rSh.InsertURL( aFmt, sDesc );
1463cdf0e10cSrcweir 				}
1464cdf0e10cSrcweir 			}
1465cdf0e10cSrcweir 			break;
1466cdf0e10cSrcweir 
1467cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_GET_ATTRIBUTES:
1468cdf0e10cSrcweir 			switch( nFormat )
1469cdf0e10cSrcweir 			{
1470cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_DRAWING:
1471cdf0e10cSrcweir 				nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
1472cdf0e10cSrcweir 												SW_PASTESDR_SETATTR, pPt,
14731cd65da9SArmin Le Grand 												nActionFlags, bNeedToSelectBeforePaste);
1474cdf0e10cSrcweir 				break;
1475cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_SVXB:
1476cdf0e10cSrcweir 			case SOT_FORMAT_GDIMETAFILE:
1477cdf0e10cSrcweir 			case SOT_FORMAT_BITMAP:
1478cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
1479cdf0e10cSrcweir 			case SOT_FORMAT_FILE:
1480cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
1481cdf0e10cSrcweir 			case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
1482cdf0e10cSrcweir 				nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
1483cdf0e10cSrcweir 												SW_PASTESDR_SETATTR, pPt,
14841cd65da9SArmin Le Grand 												nActionFlags, nDropAction, bNeedToSelectBeforePaste);
1485cdf0e10cSrcweir 				break;
1486cdf0e10cSrcweir 			default:
1487cdf0e10cSrcweir 				ASSERT( sal_False, "unbekanntes Format" );
1488cdf0e10cSrcweir 			}
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir 			break;
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_DRAWOBJ:
1493cdf0e10cSrcweir 			nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
1494cdf0e10cSrcweir 												SW_PASTESDR_INSERT, pPt,
14951cd65da9SArmin Le Grand 												nActionFlags, bNeedToSelectBeforePaste);
1496cdf0e10cSrcweir 			break;
1497cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_SVXB:
1498cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_GDIMETAFILE:
1499cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_BITMAP:
1500cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_GRAPH:
1501cdf0e10cSrcweir 			nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
1502cdf0e10cSrcweir 												SW_PASTESDR_INSERT, pPt,
15031cd65da9SArmin Le Grand 												nActionFlags, nDropAction, bNeedToSelectBeforePaste);
1504cdf0e10cSrcweir 			break;
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_REPLACE_DRAWOBJ:
1507cdf0e10cSrcweir 			nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
1508cdf0e10cSrcweir 												SW_PASTESDR_REPLACE, pPt,
15091cd65da9SArmin Le Grand 												nActionFlags, bNeedToSelectBeforePaste);
1510cdf0e10cSrcweir 			break;
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_REPLACE_SVXB:
1513cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE:
1514cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_REPLACE_BITMAP:
1515cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_REPLACE_GRAPH:
1516cdf0e10cSrcweir 			nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
1517cdf0e10cSrcweir 												SW_PASTESDR_REPLACE,pPt,
15181cd65da9SArmin Le Grand 												nActionFlags, nDropAction, bNeedToSelectBeforePaste);
1519cdf0e10cSrcweir 			break;
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir 		case EXCHG_OUT_ACTION_INSERT_INTERACTIVE:
1522cdf0e10cSrcweir 			nRet = SwTransferable::_PasteAsHyperlink( rData, rSh, nFormat );
1523cdf0e10cSrcweir 			break;
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir 		default:
1526cdf0e10cSrcweir 			ASSERT( sal_False, "unbekannte Action" );
1527cdf0e10cSrcweir 		}
1528cdf0e10cSrcweir 	}
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir 	if( !bPasteSelection && rSh.IsFrmSelected() )
1531cdf0e10cSrcweir 	{
1532cdf0e10cSrcweir 		rSh.EnterSelFrmMode();
1533cdf0e10cSrcweir 		//force ::SelectShell
1534cdf0e10cSrcweir 		rSh.GetView().StopShellTimer();
1535cdf0e10cSrcweir 	}
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir 	if( pAction )
1538cdf0e10cSrcweir 		delete pAction;
1539cdf0e10cSrcweir     if( bCallAutoCaption )
1540cdf0e10cSrcweir         rSh.GetView().AutoCaption( GRAPHIC_CAP );
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir 	return nRet;
1543cdf0e10cSrcweir }
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir // -----------------------------------------------------------------------
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir sal_uInt16 SwTransferable::GetSotDestination( const SwWrtShell& rSh,
1548cdf0e10cSrcweir 											const Point* pPt )
1549cdf0e10cSrcweir {
1550cdf0e10cSrcweir 	sal_uInt16 nRet = EXCHG_INOUT_ACTION_NONE;
1551cdf0e10cSrcweir 
1552cdf0e10cSrcweir 	ObjCntType eOType;
1553cdf0e10cSrcweir 	if( pPt )
1554cdf0e10cSrcweir 	{
1555cdf0e10cSrcweir 		SdrObject *pObj = 0;
1556cdf0e10cSrcweir 		eOType = rSh.GetObjCntType( *pPt, pObj );
1557cdf0e10cSrcweir 	}
1558cdf0e10cSrcweir 	else
1559cdf0e10cSrcweir 		eOType = rSh.GetObjCntTypeOfSelection();
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir 	switch( eOType )
1562cdf0e10cSrcweir 	{
1563cdf0e10cSrcweir 	case OBJCNT_GRF:
1564cdf0e10cSrcweir 		{
1565cdf0e10cSrcweir 			sal_Bool bIMap, bLink;
1566cdf0e10cSrcweir 			if( pPt )
1567cdf0e10cSrcweir 			{
1568cdf0e10cSrcweir 				bIMap = 0 != rSh.GetFmtFromObj( *pPt )->GetURL().GetMap();
1569cdf0e10cSrcweir 				String aDummy;
1570cdf0e10cSrcweir 				rSh.GetGrfAtPos( *pPt, aDummy, bLink );
1571cdf0e10cSrcweir 			}
1572cdf0e10cSrcweir 			else
1573cdf0e10cSrcweir 			{
1574cdf0e10cSrcweir 				bIMap = 0 != rSh.GetFlyFrmFmt()->GetURL().GetMap();
1575cdf0e10cSrcweir 				String aDummy;
1576cdf0e10cSrcweir 				rSh.GetGrfNms( &aDummy, 0 );
1577cdf0e10cSrcweir 				bLink = 0 != aDummy.Len();
1578cdf0e10cSrcweir 			}
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir 			if( bLink && bIMap )
1581cdf0e10cSrcweir 				nRet = EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP;
1582cdf0e10cSrcweir 			else if( bLink )
1583cdf0e10cSrcweir 				nRet = EXCHG_DEST_DOC_LNKD_GRAPHOBJ;
1584cdf0e10cSrcweir 			else if( bIMap )
1585cdf0e10cSrcweir 				nRet = EXCHG_DEST_DOC_GRAPH_W_IMAP;
1586cdf0e10cSrcweir 			else
1587cdf0e10cSrcweir 				nRet = EXCHG_DEST_DOC_GRAPHOBJ;
1588cdf0e10cSrcweir 		}
1589cdf0e10cSrcweir 		break;
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir 	case OBJCNT_FLY:
1592cdf0e10cSrcweir 		if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
1593cdf0e10cSrcweir 			nRet = EXCHG_DEST_DOC_TEXTFRAME_WEB;
1594cdf0e10cSrcweir 		else
1595cdf0e10cSrcweir 			nRet = EXCHG_DEST_DOC_TEXTFRAME;
1596cdf0e10cSrcweir 		break;
1597cdf0e10cSrcweir 	case OBJCNT_OLE:		nRet = EXCHG_DEST_DOC_OLEOBJ;		break;
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir 	case OBJCNT_CONTROL:	/* no Action avail */
1600cdf0e10cSrcweir 	case OBJCNT_SIMPLE:		nRet = EXCHG_DEST_DOC_DRAWOBJ; 		break;
1601cdf0e10cSrcweir 	case OBJCNT_URLBUTTON:	nRet = EXCHG_DEST_DOC_URLBUTTON; 	break;
1602cdf0e10cSrcweir 	case OBJCNT_GROUPOBJ:	nRet = EXCHG_DEST_DOC_GROUPOBJ;		break;
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir // was mmchen wir bei Mehrfachselektion???
1605cdf0e10cSrcweir //	case OBJCNT_DONTCARE:
1606cdf0e10cSrcweir 	default:
1607cdf0e10cSrcweir 		{
1608cdf0e10cSrcweir /*
1609cdf0e10cSrcweir JP 13.07.98: Bug 52637: es wird ein URL-Feld erkannt also werden nur die
1610cdf0e10cSrcweir 						Inhalte zugelassen. Das ist aber bestimmt nicht das
1611cdf0e10cSrcweir 						gewollte.
1612cdf0e10cSrcweir 			SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
1613cdf0e10cSrcweir 			SfxItemSet aSet( (SfxItemPool&)rSh.GetAttrPool(),
1614cdf0e10cSrcweir 							RES_TXTATR_INETFMT, RES_TXTATR_INETFMT );
1615cdf0e10cSrcweir 			if( pPt ? ((SwWrtShell&)rSh).GetContentAtPos( *pPt, aCntntAtPos, sal_False )
1616cdf0e10cSrcweir 					 : (rSh.GetAttr( aSet ) && aSet.Count()) )
1617cdf0e10cSrcweir 				nRet = EXCHG_DEST_DOC_URLFIELD;
1618cdf0e10cSrcweir 			else
1619cdf0e10cSrcweir */
1620cdf0e10cSrcweir 			if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
1621cdf0e10cSrcweir 				nRet = EXCHG_DEST_SWDOC_FREE_AREA_WEB;
1622cdf0e10cSrcweir 			else
1623cdf0e10cSrcweir 				nRet = EXCHG_DEST_SWDOC_FREE_AREA;
1624cdf0e10cSrcweir 		}
1625cdf0e10cSrcweir 	}
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir 	return nRet;
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir // -----------------------------------------------------------------------
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir int SwTransferable::_PasteFileContent( TransferableDataHelper& rData,
1633cdf0e10cSrcweir 									SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bMsg )
1634cdf0e10cSrcweir {
1635cdf0e10cSrcweir 	sal_uInt16 nResId = MSG_CLPBRD_FORMAT_ERROR;
1636cdf0e10cSrcweir 	int nRet = 0;
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir 	MSE40HTMLClipFormatObj aMSE40ClpObj;
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir 	SotStorageStreamRef xStrm;
1641cdf0e10cSrcweir 	SvStream* pStream = 0;
1642cdf0e10cSrcweir 	SwRead pRead = 0;
1643cdf0e10cSrcweir 	rtl::OUString sData;
1644cdf0e10cSrcweir 	switch( nFmt )
1645cdf0e10cSrcweir 	{
1646cdf0e10cSrcweir 	case SOT_FORMAT_STRING:
1647cdf0e10cSrcweir 		{
1648cdf0e10cSrcweir 			pRead = ReadAscii;
1649cdf0e10cSrcweir 			if( rData.GetString( nFmt, sData ) )
1650cdf0e10cSrcweir 			{
1651cdf0e10cSrcweir 				pStream = new SvMemoryStream( (void*)sData.getStr(),
1652cdf0e10cSrcweir 							sData.getLength() * sizeof( sal_Unicode ),
1653cdf0e10cSrcweir 							STREAM_READ );
1654cdf0e10cSrcweir #ifdef OSL_BIGENDIAN
1655cdf0e10cSrcweir 				pStream->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
1656cdf0e10cSrcweir #else
1657cdf0e10cSrcweir 				pStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1658cdf0e10cSrcweir #endif
1659cdf0e10cSrcweir 
1660cdf0e10cSrcweir 				SwAsciiOptions aAOpt;
1661cdf0e10cSrcweir 				aAOpt.SetCharSet( RTL_TEXTENCODING_UCS2 );
1662cdf0e10cSrcweir 				pRead->GetReaderOpt().SetASCIIOpts( aAOpt );
1663cdf0e10cSrcweir 				break;
1664cdf0e10cSrcweir 			}
1665cdf0e10cSrcweir 		}
1666cdf0e10cSrcweir 		// no break - because then test if we get a stream
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir 	default:
1669cdf0e10cSrcweir 		if( rData.GetSotStorageStream( nFmt, xStrm ) )
1670cdf0e10cSrcweir 		{
1671cdf0e10cSrcweir 			if( ( SOT_FORMATSTR_ID_HTML_SIMPLE == nFmt ) ||
1672cdf0e10cSrcweir                 ( SOT_FORMATSTR_ID_HTML_NO_COMMENT == nFmt ) )
1673cdf0e10cSrcweir 			{
1674cdf0e10cSrcweir 				pStream = aMSE40ClpObj.IsValid( *xStrm );
1675cdf0e10cSrcweir 				pRead = ReadHTML;
1676cdf0e10cSrcweir 				pRead->SetReadUTF8( sal_True );
1677cdf0e10cSrcweir                 //pRead->SetBaseURL( aMSE40ClpObj.GetBaseURL() );
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir                 sal_Bool bNoComments =
1680cdf0e10cSrcweir                     ( nFmt == SOT_FORMATSTR_ID_HTML_NO_COMMENT );
1681cdf0e10cSrcweir                 pRead->SetIgnoreHTMLComments( bNoComments );
1682cdf0e10cSrcweir 			}
1683cdf0e10cSrcweir 			else
1684cdf0e10cSrcweir 			{
1685cdf0e10cSrcweir 				pStream = &xStrm;
1686cdf0e10cSrcweir 				if( SOT_FORMAT_RTF == nFmt )
1687cdf0e10cSrcweir 					pRead = SwReaderWriter::GetReader( READER_WRITER_RTF );
1688cdf0e10cSrcweir 				else if( !pRead )
1689cdf0e10cSrcweir                 {
1690cdf0e10cSrcweir 					pRead = ReadHTML;
1691cdf0e10cSrcweir     				pRead->SetReadUTF8( sal_True );
1692cdf0e10cSrcweir                 }
1693cdf0e10cSrcweir 			}
1694cdf0e10cSrcweir 		}
1695cdf0e10cSrcweir 		break;
1696cdf0e10cSrcweir 	}
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir 	if( pStream && pRead )
1699cdf0e10cSrcweir 	{
1700cdf0e10cSrcweir 		Link aOldLink( rSh.GetChgLnk() );
1701cdf0e10cSrcweir 		rSh.SetChgLnk( Link() );
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir         const SwPosition& rInsPos = *rSh.GetCrsr()->Start();
1704cdf0e10cSrcweir 		SwReader aReader( *pStream, aEmptyStr, String(), *rSh.GetCrsr() );
1705cdf0e10cSrcweir 		rSh.SaveTblBoxCntnt( &rInsPos );
1706cdf0e10cSrcweir 		if( IsError( aReader.Read( *pRead )) )
1707cdf0e10cSrcweir 			nResId = ERR_CLPBRD_READ;
1708cdf0e10cSrcweir 		else
1709cdf0e10cSrcweir 			nResId = 0, nRet = 1;
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir 		rSh.SetChgLnk( aOldLink );
1712cdf0e10cSrcweir 		if( nRet )
1713cdf0e10cSrcweir 			rSh.CallChgLnk();
1714cdf0e10cSrcweir 	}
1715cdf0e10cSrcweir 	else
1716cdf0e10cSrcweir 		nResId = MSG_CLPBRD_FORMAT_ERROR;
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir 	// Exist a SvMemoryStream? (data in the OUString and xStrm is empty)
1719cdf0e10cSrcweir 	if( pStream && !xStrm.Is() )
1720cdf0e10cSrcweir 		delete pStream;
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir 	if( bMsg && nResId )
1723cdf0e10cSrcweir 	{
1724cdf0e10cSrcweir 		InfoBox( 0, SW_RES( nResId )).Execute();
1725cdf0e10cSrcweir 	}
1726cdf0e10cSrcweir 	return nRet;
1727cdf0e10cSrcweir }
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir // -----------------------------------------------------------------------
1730cdf0e10cSrcweir 
1731cdf0e10cSrcweir int SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
1732cdf0e10cSrcweir 								sal_uLong nFmt, sal_uInt8 nActionFlags, sal_Bool bMsg )
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir 	int nRet = 0;
1735cdf0e10cSrcweir 	TransferableObjectDescriptor aObjDesc;
1736cdf0e10cSrcweir     uno::Reference < io::XInputStream > xStrm;
1737cdf0e10cSrcweir     uno::Reference < embed::XStorage > xStore;
1738cdf0e10cSrcweir 	Reader* pRead = 0;
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir     // Get the preferred format
1741cdf0e10cSrcweir     SotFormatStringId nId;
1742cdf0e10cSrcweir 	if( rData.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) )
1743cdf0e10cSrcweir 		nId = SOT_FORMATSTR_ID_EMBEDDED_OBJ;
1744cdf0e10cSrcweir 	else if( rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) &&
1745cdf0e10cSrcweir 			 rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ))
1746cdf0e10cSrcweir 		nId = SOT_FORMATSTR_ID_EMBED_SOURCE;
1747cdf0e10cSrcweir 	else
1748cdf0e10cSrcweir 		nId = 0;
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir     if( nId && rData.GetInputStream( nId, xStrm ) && xStrm.is() )
1751cdf0e10cSrcweir 	{
1752cdf0e10cSrcweir         // if there is an embedded object, first try if it's a writer object
1753cdf0e10cSrcweir         // this will be inserted into the document by using a Reader
1754cdf0e10cSrcweir         try
1755cdf0e10cSrcweir         {
1756cdf0e10cSrcweir             xStore = comphelper::OStorageHelper::GetStorageFromInputStream( xStrm );
1757cdf0e10cSrcweir             switch( SotStorage::GetFormatID( xStore ) )
1758cdf0e10cSrcweir             {
1759cdf0e10cSrcweir                 case SOT_FORMATSTR_ID_STARWRITER_60:
1760cdf0e10cSrcweir                 case SOT_FORMATSTR_ID_STARWRITERWEB_60:
1761cdf0e10cSrcweir                 case SOT_FORMATSTR_ID_STARWRITERGLOB_60:
1762cdf0e10cSrcweir 				case SOT_FORMATSTR_ID_STARWRITER_8:
1763cdf0e10cSrcweir 				case SOT_FORMATSTR_ID_STARWRITERWEB_8:
1764cdf0e10cSrcweir 				case SOT_FORMATSTR_ID_STARWRITERGLOB_8:
1765cdf0e10cSrcweir                     pRead = ReadXML;
1766cdf0e10cSrcweir                     break;
1767cdf0e10cSrcweir                 default:
1768cdf0e10cSrcweir                     try
1769cdf0e10cSrcweir                     {
1770cdf0e10cSrcweir                         uno::Reference < lang::XComponent > xComp( xStore, uno::UNO_QUERY );
1771cdf0e10cSrcweir                         xComp->dispose();
1772cdf0e10cSrcweir                         xStore = 0;
1773cdf0e10cSrcweir                     }
1774cdf0e10cSrcweir                     catch ( uno::Exception& )
1775cdf0e10cSrcweir                     {
1776cdf0e10cSrcweir                     }
1777cdf0e10cSrcweir 
1778cdf0e10cSrcweir                     break;
1779cdf0e10cSrcweir             }
1780cdf0e10cSrcweir         }
1781cdf0e10cSrcweir         catch ( uno::Exception& )
1782cdf0e10cSrcweir         {
1783cdf0e10cSrcweir             // it wasn't a storage, but maybe it's a useful stream
1784cdf0e10cSrcweir         }
1785cdf0e10cSrcweir 
1786cdf0e10cSrcweir         nFmt = nId;
1787cdf0e10cSrcweir 	}
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir     if( pRead )
1790cdf0e10cSrcweir 	{
1791cdf0e10cSrcweir 		SwPaM &rPAM = *rSh.GetCrsr();
1792cdf0e10cSrcweir         SwReader aReader( xStore, aEmptyStr, rPAM );
1793cdf0e10cSrcweir         if( !IsError( aReader.Read( *pRead )) )
1794cdf0e10cSrcweir             nRet = 1;
1795cdf0e10cSrcweir         else if( bMsg )
1796cdf0e10cSrcweir             InfoBox( 0, SW_RES(ERR_CLPBRD_READ) ).Execute();
1797cdf0e10cSrcweir 	}
1798cdf0e10cSrcweir     else
1799cdf0e10cSrcweir 	{
1800cdf0e10cSrcweir        	// temporary storage until the object is inserted
1801cdf0e10cSrcweir 		uno::Reference< embed::XStorage > xTmpStor;
1802cdf0e10cSrcweir         uno::Reference < embed::XEmbeddedObject > xObj;
1803cdf0e10cSrcweir         ::rtl::OUString aName;
1804cdf0e10cSrcweir        	comphelper::EmbeddedObjectContainer aCnt;
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir 		if ( xStrm.is() )
1807cdf0e10cSrcweir 		{
1808cdf0e10cSrcweir 			if ( !rData.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) )
1809cdf0e10cSrcweir 			{
1810cdf0e10cSrcweir 				DBG_ASSERT( !xStrm.is(), "An object without descriptor in clipboard!");
1811cdf0e10cSrcweir 			}
1812cdf0e10cSrcweir 		}
1813cdf0e10cSrcweir 		else
1814cdf0e10cSrcweir 		{
1815cdf0e10cSrcweir 			if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE ) && rData.GetTransferableObjectDescriptor( nFmt, aObjDesc ) )
1816cdf0e10cSrcweir  			{
1817cdf0e10cSrcweir             	if ( !rData.GetInputStream( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStrm ) )
1818cdf0e10cSrcweir                 	rData.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStrm );
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir 				if ( !xStrm.is() )
1821cdf0e10cSrcweir 				{
1822cdf0e10cSrcweir 					// This is MSOLE object that should be created by direct using of system clipboard
1823cdf0e10cSrcweir 					try
1824cdf0e10cSrcweir 					{
1825cdf0e10cSrcweir 						xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
1826cdf0e10cSrcweir 						uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator(
1827cdf0e10cSrcweir 							::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(
1828cdf0e10cSrcweir 											RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
1829cdf0e10cSrcweir 							uno::UNO_QUERY_THROW );
1830cdf0e10cSrcweir 
1831cdf0e10cSrcweir 						embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
1832cdf0e10cSrcweir 															xTmpStor,
1833cdf0e10cSrcweir 															::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
1834cdf0e10cSrcweir 															uno::Sequence< beans::PropertyValue >() );
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir 						// TODO/LATER: in future InsertedObjectInfo will be used to get container related information
1837cdf0e10cSrcweir 						// for example whether the object should be an iconified one
1838cdf0e10cSrcweir 						xObj = aInfo.Object;
1839cdf0e10cSrcweir 					}
1840cdf0e10cSrcweir 					catch( uno::Exception& )
1841cdf0e10cSrcweir 					{}
1842cdf0e10cSrcweir 				}
1843cdf0e10cSrcweir 			}
1844cdf0e10cSrcweir     	}
1845cdf0e10cSrcweir 
1846cdf0e10cSrcweir 		if ( xStrm.is() && !xObj.is() )
1847cdf0e10cSrcweir         	xObj = aCnt.InsertEmbeddedObject( xStrm, aName );
1848cdf0e10cSrcweir 
1849cdf0e10cSrcweir         if( xObj.is() )
1850cdf0e10cSrcweir 		{
1851cdf0e10cSrcweir 			svt::EmbeddedObjectRef xObjRef( xObj, aObjDesc.mnViewAspect );
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir 			// try to get the replacement image from the clipboard
1854cdf0e10cSrcweir 			Graphic aGraphic;
1855cdf0e10cSrcweir 			sal_uLong nGrFormat = 0;
1856cdf0e10cSrcweir 
1857cdf0e10cSrcweir // (wg. Selection Manager bei Trustet Solaris)
1858cdf0e10cSrcweir #ifndef SOLARIS
1859cdf0e10cSrcweir /*
1860cdf0e10cSrcweir             if( rData.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
1861cdf0e10cSrcweir 				nGrFormat = SOT_FORMATSTR_ID_SVXB;
1862cdf0e10cSrcweir 			else if( rData.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
1863cdf0e10cSrcweir 				nGrFormat = SOT_FORMAT_GDIMETAFILE;
1864cdf0e10cSrcweir 			else if( rData.GetGraphic( FORMAT_BITMAP, aGraphic ) )
1865cdf0e10cSrcweir 				nGrFormat = SOT_FORMAT_BITMAP;
1866cdf0e10cSrcweir */
1867cdf0e10cSrcweir #endif
1868cdf0e10cSrcweir 
1869cdf0e10cSrcweir 			// insert replacement image ( if there is one ) into the object helper
1870cdf0e10cSrcweir 			if ( nGrFormat )
1871cdf0e10cSrcweir 			{
1872cdf0e10cSrcweir 				datatransfer::DataFlavor aDataFlavor;
1873cdf0e10cSrcweir 				SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
1874cdf0e10cSrcweir                	xObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
1875cdf0e10cSrcweir 			}
1876cdf0e10cSrcweir 			else if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
1877cdf0e10cSrcweir 			{
1878cdf0e10cSrcweir 				// it is important to have an icon, let an empty graphic be used
1879cdf0e10cSrcweir 				// if no other graphic is provided
1880cdf0e10cSrcweir 				// TODO/LATER: in future a default bitmap could be used
1881cdf0e10cSrcweir 				::rtl::OUString aMimeType;
1882cdf0e10cSrcweir 				MapMode aMapMode( MAP_100TH_MM );
1883cdf0e10cSrcweir 				aGraphic.SetPrefSize( Size( 2500, 2500 ) );
1884cdf0e10cSrcweir 				aGraphic.SetPrefMapMode( aMapMode );
1885cdf0e10cSrcweir                	xObjRef.SetGraphic( aGraphic, aMimeType );
1886cdf0e10cSrcweir 			}
1887cdf0e10cSrcweir 
1888cdf0e10cSrcweir 			//Size einstellen. Ist ein Hack wg. Auslieferung, die Size sollte
1889cdf0e10cSrcweir 			//an das InsertOle uebergeben werden!!!!!!!!!!
1890cdf0e10cSrcweir 			Size aSize;
1891cdf0e10cSrcweir 			if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
1892cdf0e10cSrcweir 			{
1893cdf0e10cSrcweir                	if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1894cdf0e10cSrcweir 					aSize = aObjDesc.maSize;
1895cdf0e10cSrcweir 				else
1896cdf0e10cSrcweir 				{
1897cdf0e10cSrcweir 					MapMode aMapMode( MAP_100TH_MM );
1898cdf0e10cSrcweir 					aSize = xObjRef.GetSize( &aMapMode );
1899cdf0e10cSrcweir 				}
1900cdf0e10cSrcweir 			}
1901cdf0e10cSrcweir 			else if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1902cdf0e10cSrcweir 			{
1903cdf0e10cSrcweir             	aSize = Size( aObjDesc.maSize );    //immer 100TH_MM
1904cdf0e10cSrcweir                 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
1905cdf0e10cSrcweir                 aSize = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit );
1906cdf0e10cSrcweir                 awt::Size aSz;
1907cdf0e10cSrcweir 				try
1908cdf0e10cSrcweir 				{
1909cdf0e10cSrcweir 					aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
1910cdf0e10cSrcweir 				}
1911cdf0e10cSrcweir 				catch( embed::NoVisualAreaSizeException& )
1912cdf0e10cSrcweir 				{
1913cdf0e10cSrcweir 					// in this case the provided size is used
1914cdf0e10cSrcweir 				}
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir 				if ( aSz.Width != aSize.Width() || aSz.Height != aSize.Height() )
1917cdf0e10cSrcweir 				{
1918cdf0e10cSrcweir                 	aSz.Width = aSize.Width();
1919cdf0e10cSrcweir                 	aSz.Height = aSize.Height();
1920cdf0e10cSrcweir                 	xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
1921cdf0e10cSrcweir 				}
1922cdf0e10cSrcweir 			}
1923cdf0e10cSrcweir 			else
1924cdf0e10cSrcweir 			{
1925cdf0e10cSrcweir 				// the descriptor contains the wrong object size
1926cdf0e10cSrcweir 				// the following call will let the MSOLE objects cache the size if it is possible
1927cdf0e10cSrcweir 				// it should be done while the object is running
1928cdf0e10cSrcweir 				try
1929cdf0e10cSrcweir 				{
1930cdf0e10cSrcweir 					xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
1931cdf0e10cSrcweir 				}
1932cdf0e10cSrcweir 				catch( uno::Exception& )
1933cdf0e10cSrcweir 				{
1934cdf0e10cSrcweir 				}
1935cdf0e10cSrcweir 			}
1936cdf0e10cSrcweir 			//Ende mit Hack!
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir             rSh.InsertOleObject( xObjRef );
1939cdf0e10cSrcweir 			nRet = 1;
1940cdf0e10cSrcweir 
1941cdf0e10cSrcweir 			if( nRet && ( nActionFlags &
1942cdf0e10cSrcweir 				( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) ))
1943cdf0e10cSrcweir 				SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir 			// let the object be unloaded if possible
1946cdf0e10cSrcweir 			SwOLEObj::UnloadObject( xObj, rSh.GetDoc(), embed::Aspects::MSOLE_CONTENT );
1947cdf0e10cSrcweir 		}
1948cdf0e10cSrcweir 	}
1949cdf0e10cSrcweir 	return nRet;
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir 
1952cdf0e10cSrcweir // -----------------------------------------------------------------------
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir // -----------------------------------------------------------------------
1956cdf0e10cSrcweir 
1957cdf0e10cSrcweir int SwTransferable::_PasteTargetURL( TransferableDataHelper& rData,
1958cdf0e10cSrcweir 									SwWrtShell& rSh, sal_uInt16 nAction,
1959cdf0e10cSrcweir 									const Point* pPt, sal_Bool bInsertGRF )
1960cdf0e10cSrcweir {
1961cdf0e10cSrcweir 	int nRet = 0;
1962cdf0e10cSrcweir 	INetImage aINetImg;
1963cdf0e10cSrcweir 	if( ( rData.HasFormat( SOT_FORMATSTR_ID_INET_IMAGE ) &&
1964cdf0e10cSrcweir 		  rData.GetINetImage( SOT_FORMATSTR_ID_INET_IMAGE, aINetImg )) ||
1965cdf0e10cSrcweir 		( rData.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_IMAGE ) &&
1966cdf0e10cSrcweir 		  rData.GetINetImage( SOT_FORMATSTR_ID_NETSCAPE_IMAGE, aINetImg )) )
1967cdf0e10cSrcweir 	{
1968cdf0e10cSrcweir 		if( aINetImg.GetImageURL().Len() && bInsertGRF )
1969cdf0e10cSrcweir 		{
1970cdf0e10cSrcweir 			String sURL( aINetImg.GetImageURL() );
1971cdf0e10cSrcweir 			SwTransferable::_CheckForURLOrLNKFile( rData, sURL );
1972cdf0e10cSrcweir 
1973cdf0e10cSrcweir 			//!!! auf FileSystem abpruefen - nur dann ist es sinnvoll die
1974cdf0e10cSrcweir 			// Grafiken zu testen !!!!
1975cdf0e10cSrcweir 			Graphic aGrf;
1976cdf0e10cSrcweir 			GraphicFilter *pFlt = GraphicFilter::GetGraphicFilter();
1977cdf0e10cSrcweir 			nRet = GRFILTER_OK == GraphicFilter::LoadGraphic( sURL, aEmptyStr, aGrf, pFlt );
1978cdf0e10cSrcweir 			if( nRet )
1979cdf0e10cSrcweir 			{
1980cdf0e10cSrcweir 				switch( nAction )
1981cdf0e10cSrcweir 				{
1982cdf0e10cSrcweir 				case SW_PASTESDR_INSERT:
1983cdf0e10cSrcweir 					SwTransferable::SetSelInShell( rSh, sal_False, pPt );
1984cdf0e10cSrcweir 					rSh.Insert( sURL, aEmptyStr, aGrf );
1985cdf0e10cSrcweir 					break;
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir 				case SW_PASTESDR_REPLACE:
1988cdf0e10cSrcweir 					if( rSh.IsObjSelected() )
1989cdf0e10cSrcweir 					{
1990cdf0e10cSrcweir 						rSh.ReplaceSdrObj( sURL, aEmptyStr, &aGrf );
1991cdf0e10cSrcweir 						Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() );
1992cdf0e10cSrcweir 						SwTransferable::SetSelInShell( rSh, sal_True, &aPt );
1993cdf0e10cSrcweir 					}
1994cdf0e10cSrcweir 					else
1995cdf0e10cSrcweir 						rSh.ReRead( sURL, aEmptyStr, &aGrf );
1996cdf0e10cSrcweir 					break;
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir 				case SW_PASTESDR_SETATTR:
1999cdf0e10cSrcweir 					if( rSh.IsObjSelected() )
2000cdf0e10cSrcweir 						rSh.Paste( aGrf );
2001cdf0e10cSrcweir 					else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
2002cdf0e10cSrcweir 						rSh.ReRead( sURL, aEmptyStr, &aGrf );
2003cdf0e10cSrcweir 					else
2004cdf0e10cSrcweir 					{
2005cdf0e10cSrcweir 						SwTransferable::SetSelInShell( rSh, sal_False, pPt );
2006cdf0e10cSrcweir 						rSh.Insert( sURL, aEmptyStr, aGrf );
2007cdf0e10cSrcweir 					}
2008cdf0e10cSrcweir 					break;
2009cdf0e10cSrcweir 				default:
2010cdf0e10cSrcweir 					nRet = 0;
2011cdf0e10cSrcweir 				}
2012cdf0e10cSrcweir 			}
2013cdf0e10cSrcweir 		}
2014cdf0e10cSrcweir 		else
2015cdf0e10cSrcweir 			nRet = 1;
2016cdf0e10cSrcweir 	}
2017cdf0e10cSrcweir 
2018cdf0e10cSrcweir 	if( nRet )
2019cdf0e10cSrcweir 	{
2020cdf0e10cSrcweir 		SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
2021cdf0e10cSrcweir 		rSh.GetFlyFrmAttr( aSet );
2022cdf0e10cSrcweir 		SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
2023cdf0e10cSrcweir 
2024cdf0e10cSrcweir 		if( aURL.GetURL() != aINetImg.GetTargetURL() ||
2025cdf0e10cSrcweir 			aURL.GetTargetFrameName() != aINetImg.GetTargetFrame() )
2026cdf0e10cSrcweir 		{
2027cdf0e10cSrcweir 			aURL.SetURL( aINetImg.GetTargetURL(), sal_False );
2028cdf0e10cSrcweir 			aURL.SetTargetFrameName( aINetImg.GetTargetFrame() );
2029cdf0e10cSrcweir 			aSet.Put( aURL );
2030cdf0e10cSrcweir 			rSh.SetFlyFrmAttr( aSet );
2031cdf0e10cSrcweir 		}
2032cdf0e10cSrcweir 	}
2033cdf0e10cSrcweir 	return nRet;
2034cdf0e10cSrcweir }
2035cdf0e10cSrcweir 
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir // -----------------------------------------------------------------------
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir void SwTransferable::SetSelInShell( SwWrtShell& rSh, sal_Bool bSelectFrm,
2040cdf0e10cSrcweir 										const Point* pPt )
2041cdf0e10cSrcweir {
2042cdf0e10cSrcweir 	if( bSelectFrm )
2043cdf0e10cSrcweir 	{
2044cdf0e10cSrcweir 		// Rahmen/Objecte selektieren
2045cdf0e10cSrcweir         if( pPt && !rSh.GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
2046cdf0e10cSrcweir 		{
2047cdf0e10cSrcweir 			rSh.GetView().NoRotate();
2048cdf0e10cSrcweir 			if( rSh.SelectObj( *pPt ))
2049cdf0e10cSrcweir 			{
2050cdf0e10cSrcweir 				rSh.HideCrsr();
2051cdf0e10cSrcweir 				rSh.EnterSelFrmMode( pPt );
2052cdf0e10cSrcweir 				bFrmDrag = sal_True;
2053cdf0e10cSrcweir 			}
2054cdf0e10cSrcweir 		}
2055cdf0e10cSrcweir 	}
2056cdf0e10cSrcweir 	else
2057cdf0e10cSrcweir 	{
2058cdf0e10cSrcweir 		if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
2059cdf0e10cSrcweir 		{
2060cdf0e10cSrcweir 			rSh.UnSelectFrm();
2061cdf0e10cSrcweir 			rSh.LeaveSelFrmMode();
2062cdf0e10cSrcweir 			rSh.GetView().GetEditWin().StopInsFrm();
2063cdf0e10cSrcweir 			bFrmDrag = sal_False;
2064cdf0e10cSrcweir 		}
2065cdf0e10cSrcweir 		else if( rSh.GetView().GetDrawFuncPtr() )
2066cdf0e10cSrcweir 			rSh.GetView().GetEditWin().StopInsFrm();
2067cdf0e10cSrcweir 
2068cdf0e10cSrcweir 		rSh.EnterStdMode();
2069cdf0e10cSrcweir 		if( pPt )
2070cdf0e10cSrcweir 			rSh.SwCrsrShell::SetCrsr( *pPt, sal_True );
2071cdf0e10cSrcweir 	}
2072cdf0e10cSrcweir }
2073cdf0e10cSrcweir 
2074cdf0e10cSrcweir // -----------------------------------------------------------------------
2075cdf0e10cSrcweir 
2076cdf0e10cSrcweir int SwTransferable::_PasteDDE( TransferableDataHelper& rData,
2077cdf0e10cSrcweir 								SwWrtShell& rWrtShell, sal_Bool bReReadGrf,
2078cdf0e10cSrcweir 								sal_Bool bMsg )
2079cdf0e10cSrcweir {
2080cdf0e10cSrcweir 	// Daten aus dem Clipboardformat
2081cdf0e10cSrcweir 	String aApp, aTopic, aItem;
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir 	{
2084cdf0e10cSrcweir 		SotStorageStreamRef xStrm;
2085cdf0e10cSrcweir 		if( !rData.GetSotStorageStream( SOT_FORMATSTR_ID_LINK, xStrm ))
2086cdf0e10cSrcweir 		{
2087cdf0e10cSrcweir 			ASSERT( !&rWrtShell, "DDE Data not found." );
2088cdf0e10cSrcweir 			return 0;
2089cdf0e10cSrcweir 		}	//sinnvollen Fehler melden!!
2090cdf0e10cSrcweir 
2091cdf0e10cSrcweir         rtl_TextEncoding eEncoding = DDE_TXT_ENCODING;
2092cdf0e10cSrcweir         xStrm->ReadCString( aApp, eEncoding );
2093cdf0e10cSrcweir         xStrm->ReadCString( aTopic, eEncoding );
2094cdf0e10cSrcweir         xStrm->ReadCString( aItem, eEncoding );
2095cdf0e10cSrcweir 	}
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir 	String aCmd;
2098cdf0e10cSrcweir     sfx2::MakeLnkName( aCmd, &aApp, aTopic, aItem );
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir 	// wollen wir jetzt eine Grafik einlesen ?
2101cdf0e10cSrcweir 	sal_uLong nFormat;
2102cdf0e10cSrcweir 	if( !rData.HasFormat( FORMAT_RTF ) &&
2103cdf0e10cSrcweir 		!rData.HasFormat( SOT_FORMATSTR_ID_HTML ) &&
2104cdf0e10cSrcweir 		!rData.HasFormat( FORMAT_STRING ) &&
2105cdf0e10cSrcweir 		(rData.HasFormat( nFormat = FORMAT_GDIMETAFILE ) ||
2106cdf0e10cSrcweir 		 rData.HasFormat( nFormat = FORMAT_BITMAP )) )
2107cdf0e10cSrcweir 	{
2108cdf0e10cSrcweir 		Graphic aGrf;
2109cdf0e10cSrcweir 		int nRet = rData.GetGraphic( nFormat, aGrf );
2110cdf0e10cSrcweir 		if( nRet )
2111cdf0e10cSrcweir 		{
2112cdf0e10cSrcweir 			String sLnkTyp( String::CreateFromAscii(
2113cdf0e10cSrcweir 						RTL_CONSTASCII_STRINGPARAM( "DDE" )));
2114cdf0e10cSrcweir 			if ( bReReadGrf )
2115cdf0e10cSrcweir 				rWrtShell.ReRead( aCmd, sLnkTyp, &aGrf );
2116cdf0e10cSrcweir 			else
2117cdf0e10cSrcweir 				rWrtShell.Insert( aCmd, sLnkTyp, aGrf );
2118cdf0e10cSrcweir 		}
2119cdf0e10cSrcweir 		return nRet;
2120cdf0e10cSrcweir 	}
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir     SwFieldType* pTyp = 0;
2123cdf0e10cSrcweir 	sal_uInt16 i = 1,j;
2124cdf0e10cSrcweir 	String aName;
2125cdf0e10cSrcweir 	sal_Bool bAlreadyThere = sal_False, bDoublePaste = sal_False;
2126cdf0e10cSrcweir 	sal_uInt16 nSize = rWrtShell.GetFldTypeCount();
2127cdf0e10cSrcweir 	const ::utl::TransliterationWrapper& rColl = ::GetAppCmpStrIgnore();
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir 	do {
2130cdf0e10cSrcweir 		aName = aApp;
2131cdf0e10cSrcweir 		aName += String::CreateFromInt32( i );
2132cdf0e10cSrcweir 		for( j = INIT_FLDTYPES; j < nSize; j++ )
2133cdf0e10cSrcweir 		{
2134cdf0e10cSrcweir 			pTyp = rWrtShell.GetFldType( j );
2135cdf0e10cSrcweir 			if( RES_DDEFLD == pTyp->Which() )
2136cdf0e10cSrcweir 			{
2137cdf0e10cSrcweir 				String sTmp( ((SwDDEFieldType*)pTyp)->GetCmd() );
2138cdf0e10cSrcweir 				if( rColl.isEqual( sTmp, aCmd ) &&
2139cdf0e10cSrcweir                     sfx2::LINKUPDATE_ALWAYS == ((SwDDEFieldType*)pTyp)->GetType() )
2140cdf0e10cSrcweir 				{
2141cdf0e10cSrcweir 					aName = pTyp->GetName();
2142cdf0e10cSrcweir 					bDoublePaste = sal_True;
2143cdf0e10cSrcweir 					break;
2144cdf0e10cSrcweir 				}
2145cdf0e10cSrcweir 				else if( rColl.isEqual( aName, pTyp->GetName() ) )
2146cdf0e10cSrcweir 					break;
2147cdf0e10cSrcweir 			}
2148cdf0e10cSrcweir 		}
2149cdf0e10cSrcweir 		if( j == nSize )
2150cdf0e10cSrcweir 			bAlreadyThere = sal_False;
2151cdf0e10cSrcweir 		else
2152cdf0e10cSrcweir 		{
2153cdf0e10cSrcweir 			bAlreadyThere = sal_True;
2154cdf0e10cSrcweir 			i++;
2155cdf0e10cSrcweir 		}
2156cdf0e10cSrcweir 	}
2157cdf0e10cSrcweir 	while( bAlreadyThere && !bDoublePaste );
2158cdf0e10cSrcweir 
2159cdf0e10cSrcweir 	if( !bDoublePaste )
2160cdf0e10cSrcweir 	{
2161cdf0e10cSrcweir         SwDDEFieldType aType( aName, aCmd, sfx2::LINKUPDATE_ALWAYS );
2162cdf0e10cSrcweir 		pTyp = rWrtShell.InsertFldType( aType );
2163cdf0e10cSrcweir 	}
2164cdf0e10cSrcweir 
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir 	SwDDEFieldType* pDDETyp = (SwDDEFieldType*)pTyp;
2167cdf0e10cSrcweir 
2168cdf0e10cSrcweir 	String aExpand;
2169cdf0e10cSrcweir 	if( rData.GetString( FORMAT_STRING, aExpand ))
2170cdf0e10cSrcweir 	{
2171cdf0e10cSrcweir 		do {			// middle checked loop
2172cdf0e10cSrcweir 
2173cdf0e10cSrcweir 			// Wenn die Daten von einer Tabellenkalkulation kommen
2174cdf0e10cSrcweir 			// fuegen wir eine DDE-Tabelle ein
2175cdf0e10cSrcweir 			if( ( rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) ||
2176cdf0e10cSrcweir 				  rData.HasFormat( SOT_FORMATSTR_ID_SYLK_BIGCAPS ) ) &&
2177cdf0e10cSrcweir 				aExpand.Len() &&
2178cdf0e10cSrcweir 				 ( 1 < aExpand.GetTokenCount( '\n' ) ||
2179cdf0e10cSrcweir 					   aExpand.GetTokenCount( '\t' )) )
2180cdf0e10cSrcweir 			{
2181cdf0e10cSrcweir 				String sTmp( aExpand );
2182cdf0e10cSrcweir 				xub_StrLen nRows = sTmp.GetTokenCount( '\n' );
2183cdf0e10cSrcweir 				if( nRows )
2184cdf0e10cSrcweir 					--nRows;
2185cdf0e10cSrcweir 				sTmp = sTmp.GetToken( 0, '\n' );
2186cdf0e10cSrcweir 				xub_StrLen nCols = sTmp.GetTokenCount( '\t' );
2187cdf0e10cSrcweir 
2188cdf0e10cSrcweir 				// mindestens eine Spalte & Zeile muss vorhanden sein
2189cdf0e10cSrcweir 				if( !nRows || !nCols )
2190cdf0e10cSrcweir 				{
2191cdf0e10cSrcweir 					if( bMsg )
2192cdf0e10cSrcweir 						InfoBox(0, SW_RESSTR(STR_NO_TABLE)).Execute();
2193cdf0e10cSrcweir 					pDDETyp = 0;
2194cdf0e10cSrcweir 					break;
2195cdf0e10cSrcweir 				}
2196cdf0e10cSrcweir 
2197cdf0e10cSrcweir                 rWrtShell.InsertDDETable(
2198cdf0e10cSrcweir                     SwInsertTableOptions( tabopts::HEADLINE_NO_BORDER, 1 ), // TODO MULTIHEADER
2199cdf0e10cSrcweir                     pDDETyp, nRows, nCols );
2200cdf0e10cSrcweir 			}
2201cdf0e10cSrcweir 			else if( 1 < aExpand.GetTokenCount( '\n' ) )
2202cdf0e10cSrcweir 			{
2203cdf0e10cSrcweir 				// mehrere Absaetze -> eine geschuetzte Section einfuegen
2204cdf0e10cSrcweir 				if( rWrtShell.HasSelection() )
2205cdf0e10cSrcweir 					rWrtShell.DelRight();
2206cdf0e10cSrcweir 
2207cdf0e10cSrcweir                 SwSectionData aSect( DDE_LINK_SECTION, aName );
2208cdf0e10cSrcweir 				aSect.SetLinkFileName( aCmd );
2209cdf0e10cSrcweir                 aSect.SetProtectFlag(true);
2210cdf0e10cSrcweir 				rWrtShell.InsertSection( aSect );
2211cdf0e10cSrcweir 
2212cdf0e10cSrcweir 				pDDETyp = 0;				// FeldTypen wieder entfernen
2213cdf0e10cSrcweir 			}
2214cdf0e10cSrcweir 			else
2215cdf0e10cSrcweir 			{
2216cdf0e10cSrcweir 				// Einfuegen
2217cdf0e10cSrcweir 				SwDDEField aSwDDEField( pDDETyp );
2218cdf0e10cSrcweir 				rWrtShell.Insert( aSwDDEField );
2219cdf0e10cSrcweir 			}
2220cdf0e10cSrcweir 
2221cdf0e10cSrcweir 		} while( sal_False );
2222cdf0e10cSrcweir 	}
2223cdf0e10cSrcweir 	else
2224cdf0e10cSrcweir 		pDDETyp = 0;						// FeldTypen wieder entfernen
2225cdf0e10cSrcweir 
2226cdf0e10cSrcweir 	if( !pDDETyp && !bDoublePaste )
2227cdf0e10cSrcweir 	{
2228cdf0e10cSrcweir 		// FeldTyp wieder entfernen - Fehler aufgetreten!
2229cdf0e10cSrcweir 		for( j = nSize; j >= INIT_FLDTYPES; --j )
2230cdf0e10cSrcweir 			if( pTyp == rWrtShell.GetFldType( j ) )
2231cdf0e10cSrcweir 			{
2232cdf0e10cSrcweir 				rWrtShell.RemoveFldType( j );
2233cdf0e10cSrcweir 				break;
2234cdf0e10cSrcweir 			}
2235cdf0e10cSrcweir 	}
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir 	return 1;
2238cdf0e10cSrcweir }
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir // -----------------------------------------------------------------------
2241cdf0e10cSrcweir 
2242cdf0e10cSrcweir int SwTransferable::_PasteSdrFormat(  TransferableDataHelper& rData,
2243cdf0e10cSrcweir 									SwWrtShell& rSh, sal_uInt16 nAction,
22441cd65da9SArmin Le Grand 									const Point* pPt, sal_uInt8 nActionFlags, bool bNeedToSelectBeforePaste)
2245cdf0e10cSrcweir {
2246cdf0e10cSrcweir 	int nRet = 0;
2247cdf0e10cSrcweir 	SotStorageStreamRef xStrm;
2248cdf0e10cSrcweir 	if( rData.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStrm ))
2249cdf0e10cSrcweir 	{
2250cdf0e10cSrcweir 		xStrm->SetVersion( SOFFICE_FILEFORMAT_50 );
22511cd65da9SArmin Le Grand 
22521cd65da9SArmin Le Grand         if(bNeedToSelectBeforePaste && pPt)
22531cd65da9SArmin Le Grand         {
22541cd65da9SArmin Le Grand             // if this is an internal drag, need to set the target right (select it), else
22551cd65da9SArmin Le Grand             // still the source will be selected
22561cd65da9SArmin Le Grand             SwTransferable::SetSelInShell( rSh, sal_True, pPt );
22571cd65da9SArmin Le Grand         }
22581cd65da9SArmin Le Grand 
2259cdf0e10cSrcweir 		rSh.Paste( *xStrm, nAction, pPt );
2260cdf0e10cSrcweir 		nRet = 1;
2261cdf0e10cSrcweir 
2262cdf0e10cSrcweir 		if( nRet && ( nActionFlags &
2263cdf0e10cSrcweir 			( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) ))
2264cdf0e10cSrcweir 			SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
2265cdf0e10cSrcweir 	}
2266cdf0e10cSrcweir 	return nRet;
2267cdf0e10cSrcweir }
2268cdf0e10cSrcweir 
2269cdf0e10cSrcweir // -----------------------------------------------------------------------
2270cdf0e10cSrcweir 
2271cdf0e10cSrcweir int SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
2272cdf0e10cSrcweir 								sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
2273aae0c55aSPavel Janík 								sal_uInt8 nActionFlags, sal_Int8 /* nDropAction */, bool bNeedToSelectBeforePaste)
2274cdf0e10cSrcweir {
2275cdf0e10cSrcweir 	int nRet = 0;
2276cdf0e10cSrcweir 
2277cdf0e10cSrcweir 	Graphic aGrf;
2278cdf0e10cSrcweir 	INetBookmark aBkmk;
2279cdf0e10cSrcweir 	sal_Bool bCheckForGrf = sal_False, bCheckForImageMap = sal_False;
2280cdf0e10cSrcweir 
2281cdf0e10cSrcweir 	switch( nFmt )
2282cdf0e10cSrcweir 	{
2283cdf0e10cSrcweir 	case SOT_FORMAT_BITMAP:
2284cdf0e10cSrcweir 	case SOT_FORMAT_GDIMETAFILE:
2285cdf0e10cSrcweir 		nRet = rData.GetGraphic( nFmt, aGrf );
2286cdf0e10cSrcweir 		break;
2287cdf0e10cSrcweir 
22881cd65da9SArmin Le Grand     case SOT_FORMATSTR_ID_SVXB:
22891cd65da9SArmin Le Grand     {
22901cd65da9SArmin Le Grand         SotStorageStreamRef xStm;
22911cd65da9SArmin Le Grand 
22921cd65da9SArmin Le Grand         if(rData.GetSotStorageStream(SOT_FORMATSTR_ID_SVXB, xStm))
22931cd65da9SArmin Le Grand         {
22941cd65da9SArmin Le Grand             *xStm >> aGrf;
22951cd65da9SArmin Le Grand             nRet = (GRAPHIC_NONE != aGrf.GetType() && GRAPHIC_DEFAULT != aGrf.GetType());
22961cd65da9SArmin Le Grand         }
22971cd65da9SArmin Le Grand 
22981cd65da9SArmin Le Grand         break;
22991cd65da9SArmin Le Grand     }
23001cd65da9SArmin Le Grand 
2301cdf0e10cSrcweir 	case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
2302cdf0e10cSrcweir 	case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
2303cdf0e10cSrcweir 	case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
2304cdf0e10cSrcweir 		if( 0 != ( nRet = rData.GetINetBookmark( nFmt, aBkmk ) ))
2305cdf0e10cSrcweir 		{
2306cdf0e10cSrcweir /*				if( SW_PASTESDR_SETATTR != nAction )
2307cdf0e10cSrcweir 			{
2308cdf0e10cSrcweir 				INetURLObject aURL( aBkmk.GetURL() );
2309cdf0e10cSrcweir 				bCheckForGrf = INET_PROT_FILE == aURL.GetProtocol();
2310cdf0e10cSrcweir 				nRet = 0 != bCheckForGrf;
2311cdf0e10cSrcweir 			}
2312cdf0e10cSrcweir */
2313cdf0e10cSrcweir 			if( SW_PASTESDR_SETATTR == nAction )
2314cdf0e10cSrcweir 				nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
2315cdf0e10cSrcweir 			else
2316cdf0e10cSrcweir 				bCheckForGrf = sal_True;
2317cdf0e10cSrcweir 		}
2318cdf0e10cSrcweir 		break;
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir 	case SOT_FORMAT_FILE:
2321cdf0e10cSrcweir 		{
2322cdf0e10cSrcweir 			String sTxt;
2323cdf0e10cSrcweir 			if( 0 != ( nRet = rData.GetString( nFmt, sTxt ) ) )
2324cdf0e10cSrcweir 			{
2325cdf0e10cSrcweir 				String sDesc;
2326cdf0e10cSrcweir 				SwTransferable::_CheckForURLOrLNKFile( rData, sTxt, &sDesc );
2327cdf0e10cSrcweir 
2328cdf0e10cSrcweir                 aBkmk = INetBookmark(
2329cdf0e10cSrcweir                         URIHelper::SmartRel2Abs(INetURLObject(), sTxt, Link(), false ),
2330cdf0e10cSrcweir                         sDesc );
2331cdf0e10cSrcweir 				bCheckForGrf = sal_True;
2332cdf0e10cSrcweir 				bCheckForImageMap = SW_PASTESDR_REPLACE == nAction;
2333cdf0e10cSrcweir 			}
2334cdf0e10cSrcweir 		}
2335cdf0e10cSrcweir 		break;
2336cdf0e10cSrcweir 
2337cdf0e10cSrcweir 	default:
2338cdf0e10cSrcweir 		nRet = rData.GetGraphic( nFmt, aGrf );
2339cdf0e10cSrcweir 		break;
2340cdf0e10cSrcweir 	}
2341cdf0e10cSrcweir 
2342cdf0e10cSrcweir 	if( bCheckForGrf )
2343cdf0e10cSrcweir 	{
2344cdf0e10cSrcweir 		//!!! auf FileSystem abpruefen - nur dann ist es sinnvoll die
2345cdf0e10cSrcweir 		// Grafiken zu testen !!!!
2346cdf0e10cSrcweir 		GraphicFilter *pFlt = GraphicFilter::GetGraphicFilter();
2347cdf0e10cSrcweir 		nRet = GRFILTER_OK == GraphicFilter::LoadGraphic( aBkmk.GetURL(), aEmptyStr,
2348cdf0e10cSrcweir 											aGrf, pFlt );
2349cdf0e10cSrcweir 		if( !nRet && SW_PASTESDR_SETATTR == nAction &&
2350cdf0e10cSrcweir 			SOT_FORMAT_FILE == nFmt &&
2351cdf0e10cSrcweir 			// Bug 63031 - nur bei Rahmenselektion
2352cdf0e10cSrcweir 			rSh.IsFrmSelected() )
2353cdf0e10cSrcweir 		{
2354cdf0e10cSrcweir 			// dann als Hyperlink hinter die Grafik setzen
2355cdf0e10cSrcweir 			nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
2356cdf0e10cSrcweir 			nRet = sal_True;
2357cdf0e10cSrcweir 		}
2358cdf0e10cSrcweir 	}
2359cdf0e10cSrcweir 
23601cd65da9SArmin Le Grand     if(pPt && bNeedToSelectBeforePaste)
23611cd65da9SArmin Le Grand     {
23621cd65da9SArmin Le Grand         // when using internal D&Ds, still the source object is selected and
23631cd65da9SArmin Le Grand         // this is necessary to get the correct source data which is also
23641cd65da9SArmin Le Grand         // dependent from selection. After receiving the drag data it is
23651cd65da9SArmin Le Grand         // now tiime to select the correct target object
23661cd65da9SArmin Le Grand         SwTransferable::SetSelInShell( rSh, sal_True, pPt );
23671cd65da9SArmin Le Grand     }
23681cd65da9SArmin Le Grand 
2369cdf0e10cSrcweir 	if( nRet )
2370cdf0e10cSrcweir 	{
2371cdf0e10cSrcweir 		String sURL;
2372cdf0e10cSrcweir 		if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
2373cdf0e10cSrcweir 			sURL = aBkmk.GetURL();
2374cdf0e10cSrcweir 
2375cdf0e10cSrcweir 		switch( nAction )
2376cdf0e10cSrcweir 		{
2377cdf0e10cSrcweir 		case SW_PASTESDR_INSERT:
2378cdf0e10cSrcweir 			SwTransferable::SetSelInShell( rSh, sal_False, pPt );
2379cdf0e10cSrcweir 			rSh.Insert( sURL, aEmptyStr, aGrf );
2380cdf0e10cSrcweir         break;
2381cdf0e10cSrcweir 
2382cdf0e10cSrcweir 		case SW_PASTESDR_REPLACE:
2383cdf0e10cSrcweir 			if( rSh.IsObjSelected() )
2384cdf0e10cSrcweir 			{
2385cdf0e10cSrcweir 				rSh.ReplaceSdrObj( sURL, aEmptyStr, &aGrf );
2386cdf0e10cSrcweir 				Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() );
2387cdf0e10cSrcweir 				SwTransferable::SetSelInShell( rSh, sal_True, &aPt );
2388cdf0e10cSrcweir 			}
2389cdf0e10cSrcweir 			else
2390cdf0e10cSrcweir 				rSh.ReRead( sURL, aEmptyStr, &aGrf );
2391cdf0e10cSrcweir 			break;
2392cdf0e10cSrcweir 
2393cdf0e10cSrcweir 		case SW_PASTESDR_SETATTR:
2394cdf0e10cSrcweir 			if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK == nFmt )
2395cdf0e10cSrcweir 			{
2396cdf0e10cSrcweir 				if( rSh.IsFrmSelected() )
2397cdf0e10cSrcweir 				{
2398cdf0e10cSrcweir 					SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
2399cdf0e10cSrcweir 					rSh.GetFlyFrmAttr( aSet );
2400cdf0e10cSrcweir 					SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
2401cdf0e10cSrcweir 					aURL.SetURL( aBkmk.GetURL(), sal_False );
2402cdf0e10cSrcweir 					aSet.Put( aURL );
2403cdf0e10cSrcweir 					rSh.SetFlyFrmAttr( aSet );
2404cdf0e10cSrcweir 				}
2405cdf0e10cSrcweir 			}
2406cdf0e10cSrcweir 			else if( rSh.IsObjSelected() )
2407cdf0e10cSrcweir 				rSh.Paste( aGrf );
2408cdf0e10cSrcweir 			else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
2409cdf0e10cSrcweir 				rSh.ReRead( sURL, aEmptyStr, &aGrf );
2410cdf0e10cSrcweir 			else
2411cdf0e10cSrcweir 			{
2412cdf0e10cSrcweir 				SwTransferable::SetSelInShell( rSh, sal_False, pPt );
2413cdf0e10cSrcweir 				rSh.Insert( aBkmk.GetURL(), aEmptyStr, aGrf );
2414cdf0e10cSrcweir 			}
2415cdf0e10cSrcweir 			break;
2416cdf0e10cSrcweir 		default:
2417cdf0e10cSrcweir 			nRet = 0;
2418cdf0e10cSrcweir 		}
2419cdf0e10cSrcweir 	}
2420cdf0e10cSrcweir 
2421cdf0e10cSrcweir 	if( nRet )
2422cdf0e10cSrcweir 	{
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir 		if( nActionFlags &
2425cdf0e10cSrcweir 			(( EXCHG_OUT_ACTION_FLAG_INSERT_IMAGEMAP |
2426cdf0e10cSrcweir 				EXCHG_OUT_ACTION_FLAG_REPLACE_IMAGEMAP ) >> 8) )
2427cdf0e10cSrcweir 			SwTransferable::_PasteImageMap( rData, rSh );
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir 		if( nActionFlags &
2430cdf0e10cSrcweir 			( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) )
2431cdf0e10cSrcweir 			SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
2432cdf0e10cSrcweir 	}
2433cdf0e10cSrcweir 	else if( bCheckForImageMap )
2434cdf0e10cSrcweir 	{
2435cdf0e10cSrcweir 		// oder sollte das File ein ImageMap-File sein?
2436cdf0e10cSrcweir 		ImageMap aMap;
2437cdf0e10cSrcweir 		SfxMedium aMed( INetURLObject(aBkmk.GetURL()).GetFull(),
2438cdf0e10cSrcweir 							STREAM_STD_READ, sal_False );
2439cdf0e10cSrcweir         SvStream* pStream = aMed.GetInStream();
2440cdf0e10cSrcweir         if( pStream != NULL  &&
2441cdf0e10cSrcweir             !pStream->GetError()  &&
2442cdf0e10cSrcweir             // mba: no BaseURL for clipboard functionality
2443cdf0e10cSrcweir             aMap.Read( *pStream, IMAP_FORMAT_DETECT, String() ) == IMAP_ERR_OK &&
2444cdf0e10cSrcweir 			aMap.GetIMapObjectCount() )
2445cdf0e10cSrcweir 		{
2446cdf0e10cSrcweir 			SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
2447cdf0e10cSrcweir 			rSh.GetFlyFrmAttr( aSet );
2448cdf0e10cSrcweir 			SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
2449cdf0e10cSrcweir 			aURL.SetMap( &aMap );
2450cdf0e10cSrcweir 			aSet.Put( aURL );
2451cdf0e10cSrcweir 			rSh.SetFlyFrmAttr( aSet );
2452cdf0e10cSrcweir 			nRet = 1;
2453cdf0e10cSrcweir 		}
2454cdf0e10cSrcweir 	}
2455cdf0e10cSrcweir 
2456cdf0e10cSrcweir 	return nRet;
2457cdf0e10cSrcweir }
2458cdf0e10cSrcweir 
2459cdf0e10cSrcweir // -----------------------------------------------------------------------
2460cdf0e10cSrcweir 
2461cdf0e10cSrcweir int SwTransferable::_PasteImageMap( TransferableDataHelper& rData,
2462cdf0e10cSrcweir 									SwWrtShell& rSh )
2463cdf0e10cSrcweir {
2464cdf0e10cSrcweir 	int nRet = 0;
2465cdf0e10cSrcweir 	if( rData.HasFormat( SOT_FORMATSTR_ID_SVIM ))
2466cdf0e10cSrcweir 	{
2467cdf0e10cSrcweir 		SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
2468cdf0e10cSrcweir 		rSh.GetFlyFrmAttr( aSet );
2469cdf0e10cSrcweir 		SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
2470cdf0e10cSrcweir 		const ImageMap* pOld = aURL.GetMap();
2471cdf0e10cSrcweir 
2472cdf0e10cSrcweir 		// setzen oder ersetzen ist hier die Frage
2473cdf0e10cSrcweir 		ImageMap aImageMap;
2474cdf0e10cSrcweir 		if( rData.GetImageMap( SOT_FORMATSTR_ID_SVIM, aImageMap ) &&
2475cdf0e10cSrcweir 			( !pOld || aImageMap != *pOld ))
2476cdf0e10cSrcweir 		{
2477cdf0e10cSrcweir 			aURL.SetMap( &aImageMap );
2478cdf0e10cSrcweir 			aSet.Put( aURL );
2479cdf0e10cSrcweir 			rSh.SetFlyFrmAttr( aSet );
2480cdf0e10cSrcweir 		}
2481cdf0e10cSrcweir 		nRet = 1;
2482cdf0e10cSrcweir 	}
2483cdf0e10cSrcweir 	return nRet;
2484cdf0e10cSrcweir }
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir // -----------------------------------------------------------------------
2487cdf0e10cSrcweir 
2488cdf0e10cSrcweir int SwTransferable::_PasteAsHyperlink( TransferableDataHelper& rData,
2489cdf0e10cSrcweir 										SwWrtShell& rSh, sal_uLong nFmt )
2490cdf0e10cSrcweir {
2491cdf0e10cSrcweir 	int nRet = 0;
2492cdf0e10cSrcweir 	String sFile;
2493cdf0e10cSrcweir 	if( rData.GetString( nFmt, sFile ) && sFile.Len() )
2494cdf0e10cSrcweir 	{
2495cdf0e10cSrcweir 		String sDesc;
2496cdf0e10cSrcweir 		SwTransferable::_CheckForURLOrLNKFile( rData, sFile, &sDesc );
2497cdf0e10cSrcweir 
2498cdf0e10cSrcweir 		//#41801# ersteinmal die URL absolut machen
2499cdf0e10cSrcweir 		INetURLObject aURL;
2500cdf0e10cSrcweir 		aURL.SetSmartProtocol( INET_PROT_FILE );
2501cdf0e10cSrcweir 		aURL.SetSmartURL( sFile );
2502cdf0e10cSrcweir 		sFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
2503cdf0e10cSrcweir 
2504cdf0e10cSrcweir 		switch( rSh.GetObjCntTypeOfSelection() )
2505cdf0e10cSrcweir 		{
2506cdf0e10cSrcweir 		case OBJCNT_FLY:
2507cdf0e10cSrcweir 		case OBJCNT_GRF:
2508cdf0e10cSrcweir 		case OBJCNT_OLE:
2509cdf0e10cSrcweir 			{
2510cdf0e10cSrcweir 				SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
2511cdf0e10cSrcweir 				rSh.GetFlyFrmAttr( aSet );
2512cdf0e10cSrcweir 				SwFmtURL aURL2( (SwFmtURL&)aSet.Get( RES_URL ) );
2513cdf0e10cSrcweir 				aURL2.SetURL( sFile, sal_False );
2514cdf0e10cSrcweir 				if( !aURL2.GetName().Len() )
2515cdf0e10cSrcweir 					aURL2.SetName( sFile );
2516cdf0e10cSrcweir 				aSet.Put( aURL2 );
2517cdf0e10cSrcweir 				rSh.SetFlyFrmAttr( aSet );
2518cdf0e10cSrcweir 			}
2519cdf0e10cSrcweir 			break;
2520cdf0e10cSrcweir 
2521cdf0e10cSrcweir 		default:
2522cdf0e10cSrcweir 			{
2523cdf0e10cSrcweir 				rSh.InsertURL( SwFmtINetFmt( sFile, aEmptyStr ),
2524cdf0e10cSrcweir 								sDesc.Len() ? sDesc : sFile );
2525cdf0e10cSrcweir 			}
2526cdf0e10cSrcweir 		}
2527cdf0e10cSrcweir 		nRet = sal_True;
2528cdf0e10cSrcweir 	}
2529cdf0e10cSrcweir 	return nRet;
2530cdf0e10cSrcweir }
2531cdf0e10cSrcweir 
2532cdf0e10cSrcweir // -----------------------------------------------------------------------
2533cdf0e10cSrcweir 
2534cdf0e10cSrcweir int SwTransferable::_PasteFileName( TransferableDataHelper& rData,
2535cdf0e10cSrcweir 									SwWrtShell& rSh, sal_uLong nFmt,
2536cdf0e10cSrcweir 									sal_uInt16 nAction, const Point* pPt,
2537f946d29fSPavel Janík 									sal_uInt8 nActionFlags, sal_Bool /* bMsg */)
2538cdf0e10cSrcweir {
2539cdf0e10cSrcweir 	int nRet = SwTransferable::_PasteGrf( rData, rSh, nFmt, nAction,
25401cd65da9SArmin Le Grand 											pPt, nActionFlags, 0, false);
2541cdf0e10cSrcweir     if( nRet )
2542cdf0e10cSrcweir         nRet |= SWTRANSFER_GRAPHIC_INSERTED;
2543cdf0e10cSrcweir     if( !nRet )
2544cdf0e10cSrcweir     {
2545cdf0e10cSrcweir         String sFile, sDesc;
2546cdf0e10cSrcweir         if( rData.GetString( nFmt, sFile ) && sFile.Len() )
2547cdf0e10cSrcweir         {
2548cdf0e10cSrcweir             INetURLObject aMediaURL;
2549cdf0e10cSrcweir 
2550cdf0e10cSrcweir             aMediaURL.SetSmartURL( sFile );
2551cdf0e10cSrcweir             const String aMediaURLStr( aMediaURL.GetMainURL( INetURLObject::NO_DECODE ) );
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir             if( ::avmedia::MediaWindow::isMediaURL( aMediaURLStr ) )
2554cdf0e10cSrcweir             {
2555cdf0e10cSrcweir                 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aMediaURLStr );
2556cdf0e10cSrcweir                 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(
2557cdf0e10cSrcweir                                 SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON,
2558cdf0e10cSrcweir                                 &aMediaURLItem, 0L );
2559cdf0e10cSrcweir             }
2560cdf0e10cSrcweir             else
2561cdf0e10cSrcweir             {
2562cdf0e10cSrcweir                 sal_Bool bIsURLFile = SwTransferable::_CheckForURLOrLNKFile( rData, sFile, &sDesc );
2563cdf0e10cSrcweir 
2564cdf0e10cSrcweir                 //Eigenes FileFormat? -->Einfuegen, nicht fuer StarWriter/Web
2565cdf0e10cSrcweir                 String sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link(), false );
2566cdf0e10cSrcweir                 const SfxFilter* pFlt = SW_PASTESDR_SETATTR == nAction
2567cdf0e10cSrcweir                         ? 0 : SwIoSystem::GetFileFilter(
2568cdf0e10cSrcweir                         sFileURL, aEmptyStr );
2569cdf0e10cSrcweir                 if( pFlt && !rSh.GetView().GetDocShell()->ISA(SwWebDocShell)
2570cdf0e10cSrcweir     /*
2571cdf0e10cSrcweir     JP 02.07.98: warum nur fuer die Formate ??
2572cdf0e10cSrcweir                     && ( pFlt->GetUserData() == FILTER_SW5 ||
2573cdf0e10cSrcweir                     pFlt->GetUserData() == FILTER_SW4 ||
2574cdf0e10cSrcweir                     pFlt->GetUserData() == FILTER_SW3 ||
2575cdf0e10cSrcweir                     pFlt->GetUserData() == FILTER_SWG )
2576cdf0e10cSrcweir     */
2577cdf0e10cSrcweir                     )
2578cdf0e10cSrcweir                 {
2579cdf0e10cSrcweir     // und dann per PostUser Event den Bereich-Einfuegen-Dialog hochreissen
2580cdf0e10cSrcweir                     SwSectionData * pSect = new SwSectionData(
2581cdf0e10cSrcweir                                     FILE_LINK_SECTION,
2582cdf0e10cSrcweir                                     rSh.GetDoc()->GetUniqueSectionName() );
2583cdf0e10cSrcweir                     pSect->SetLinkFileName( sFileURL );
2584cdf0e10cSrcweir                     pSect->SetProtectFlag( true );
2585cdf0e10cSrcweir 
2586cdf0e10cSrcweir                     Application::PostUserEvent( STATIC_LINK( &rSh, SwWrtShell,
2587cdf0e10cSrcweir                                                 InsertRegionDialog ), pSect );
2588cdf0e10cSrcweir                     nRet = 1;
2589cdf0e10cSrcweir                     }
2590cdf0e10cSrcweir                 else if( SW_PASTESDR_SETATTR == nAction ||
2591cdf0e10cSrcweir                         ( bIsURLFile && SW_PASTESDR_INSERT == nAction ))
2592cdf0e10cSrcweir                 {
2593cdf0e10cSrcweir                     //Fremde Files koennen wir immerhin noch als Links
2594cdf0e10cSrcweir                     //Einfuegen.
2595cdf0e10cSrcweir 
2596cdf0e10cSrcweir                     //#41801# ersteinmal die URL absolut machen
2597cdf0e10cSrcweir                     INetURLObject aURL;
2598cdf0e10cSrcweir                     aURL.SetSmartProtocol( INET_PROT_FILE );
2599cdf0e10cSrcweir                     aURL.SetSmartURL( sFile );
2600cdf0e10cSrcweir                     sFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
2601cdf0e10cSrcweir 
2602cdf0e10cSrcweir                     switch( rSh.GetObjCntTypeOfSelection() )
2603cdf0e10cSrcweir                     {
2604cdf0e10cSrcweir                     case OBJCNT_FLY:
2605cdf0e10cSrcweir                     case OBJCNT_GRF:
2606cdf0e10cSrcweir                     case OBJCNT_OLE:
2607cdf0e10cSrcweir                         {
2608cdf0e10cSrcweir                             SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
2609cdf0e10cSrcweir                             rSh.GetFlyFrmAttr( aSet );
2610cdf0e10cSrcweir                             SwFmtURL aURL2( (SwFmtURL&)aSet.Get( RES_URL ) );
2611cdf0e10cSrcweir                             aURL2.SetURL( sFile, sal_False );
2612cdf0e10cSrcweir                             if( !aURL2.GetName().Len() )
2613cdf0e10cSrcweir                                 aURL2.SetName( sFile );
2614cdf0e10cSrcweir                             aSet.Put( aURL2 );
2615cdf0e10cSrcweir                             rSh.SetFlyFrmAttr( aSet );
2616cdf0e10cSrcweir                         }
2617cdf0e10cSrcweir                         break;
2618cdf0e10cSrcweir 
2619cdf0e10cSrcweir                     default:
2620cdf0e10cSrcweir                         {
2621cdf0e10cSrcweir                             rSh.InsertURL( SwFmtINetFmt( sFile, aEmptyStr ),
2622cdf0e10cSrcweir                                             sDesc.Len() ? sDesc : sFile );
2623cdf0e10cSrcweir                         }
2624cdf0e10cSrcweir                     }
2625cdf0e10cSrcweir                     nRet = sal_True;
2626cdf0e10cSrcweir                 }
2627cdf0e10cSrcweir             }
2628cdf0e10cSrcweir 		}
2629cdf0e10cSrcweir 	}
2630cdf0e10cSrcweir 	return nRet;
2631cdf0e10cSrcweir }
2632cdf0e10cSrcweir 
2633cdf0e10cSrcweir // -----------------------------------------------------------------------
2634cdf0e10cSrcweir 
2635cdf0e10cSrcweir int SwTransferable::_PasteDBData( TransferableDataHelper& rData,
2636cdf0e10cSrcweir 									SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bLink,
2637cdf0e10cSrcweir 									const Point* pDragPt, sal_Bool bMsg )
2638cdf0e10cSrcweir {
2639cdf0e10cSrcweir 	int nRet = 0;
2640cdf0e10cSrcweir 	String sTxt;
2641cdf0e10cSrcweir 	if( rData.GetString( nFmt, sTxt ) && sTxt.Len() )
2642cdf0e10cSrcweir 	{
2643cdf0e10cSrcweir 		sal_uInt16 nWh = SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE == nFmt
2644cdf0e10cSrcweir 					? 0
2645cdf0e10cSrcweir 					: SOT_FORMATSTR_ID_SBA_DATAEXCHANGE == nFmt
2646cdf0e10cSrcweir 								? (bLink
2647cdf0e10cSrcweir 									? FN_QRY_MERGE_FIELD
2648cdf0e10cSrcweir 									: FN_QRY_INSERT)
2649cdf0e10cSrcweir 								: (bLink
2650cdf0e10cSrcweir 									? 0
2651cdf0e10cSrcweir 									: FN_QRY_INSERT_FIELD );
2652cdf0e10cSrcweir         DataFlavorExVector& rVector = rData.GetDataFlavorExVector();
2653cdf0e10cSrcweir 		sal_Bool bHaveColumnDescriptor = OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR | CTF_CONTROL_EXCHANGE);
2654cdf0e10cSrcweir 		if ( SOT_FORMATSTR_ID_XFORMS == nFmt )
2655cdf0e10cSrcweir 		{
2656cdf0e10cSrcweir 			SdrObject* pObj;
2657cdf0e10cSrcweir 			rSh.MakeDrawView();
2658cdf0e10cSrcweir 			FmFormView* pFmView = PTR_CAST( FmFormView, rSh.GetDrawView() );
2659cdf0e10cSrcweir 			if(pFmView) {
2660cdf0e10cSrcweir 				const OXFormsDescriptor &rDesc = OXFormsTransferable::extractDescriptor(rData);
2661cdf0e10cSrcweir                 if(0 != (pObj = pFmView->CreateXFormsControl(rDesc)))
2662cdf0e10cSrcweir                 {
2663cdf0e10cSrcweir                     rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
2664cdf0e10cSrcweir                 }
2665cdf0e10cSrcweir 			}
2666cdf0e10cSrcweir 		}
2667cdf0e10cSrcweir 		else if( nWh )
2668cdf0e10cSrcweir 		{
2669cdf0e10cSrcweir             SfxUsrAnyItem* pConnectionItem	= 0;
2670cdf0e10cSrcweir 			SfxUsrAnyItem* pCursorItem		= 0;
2671cdf0e10cSrcweir             SfxUsrAnyItem* pColumnItem		= 0;
2672cdf0e10cSrcweir             SfxUsrAnyItem* pSourceItem		= 0;
2673cdf0e10cSrcweir             SfxUsrAnyItem* pCommandItem		= 0;
2674cdf0e10cSrcweir             SfxUsrAnyItem* pCommandTypeItem = 0;
2675cdf0e10cSrcweir             SfxUsrAnyItem* pColumnNameItem	= 0;
2676cdf0e10cSrcweir             SfxUsrAnyItem* pSelectionItem	= 0;
2677cdf0e10cSrcweir 
2678cdf0e10cSrcweir             sal_Bool bDataAvailable = sal_True;
2679cdf0e10cSrcweir 	        ODataAccessDescriptor aDesc;
2680cdf0e10cSrcweir             if(bHaveColumnDescriptor)
2681cdf0e10cSrcweir                 aDesc = OColumnTransferable::extractColumnDescriptor(rData);
2682cdf0e10cSrcweir             else if(ODataAccessObjectTransferable::canExtractObjectDescriptor(rVector) )
2683cdf0e10cSrcweir                 aDesc = ODataAccessObjectTransferable::extractObjectDescriptor(rData);
2684cdf0e10cSrcweir             else
2685cdf0e10cSrcweir                 bDataAvailable = sal_False;
2686cdf0e10cSrcweir 
2687cdf0e10cSrcweir             if ( bDataAvailable )
2688cdf0e10cSrcweir             {
2689cdf0e10cSrcweir                 pConnectionItem = new SfxUsrAnyItem(FN_DB_CONNECTION_ANY, aDesc[daConnection]);
2690cdf0e10cSrcweir                 pColumnItem = new SfxUsrAnyItem(FN_DB_COLUMN_ANY, aDesc[daColumnObject]);
2691cdf0e10cSrcweir                 pSourceItem = new SfxUsrAnyItem(FN_DB_DATA_SOURCE_ANY, makeAny(aDesc.getDataSource()));
2692cdf0e10cSrcweir                 pCommandItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_ANY, aDesc[daCommand]);
2693cdf0e10cSrcweir                 pCommandTypeItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_TYPE_ANY, aDesc[daCommandType]);
2694cdf0e10cSrcweir                 pColumnNameItem = new SfxUsrAnyItem(FN_DB_DATA_COLUMN_NAME_ANY, aDesc[daColumnName]);
2695cdf0e10cSrcweir                 pSelectionItem = new SfxUsrAnyItem(FN_DB_DATA_SELECTION_ANY, aDesc[daSelection]);
2696cdf0e10cSrcweir 				pCursorItem = new SfxUsrAnyItem(FN_DB_DATA_CURSOR_ANY, aDesc[daCursor]);
2697cdf0e10cSrcweir             }
2698cdf0e10cSrcweir 
2699cdf0e10cSrcweir             SwView& rView = rSh.GetView();
2700cdf0e10cSrcweir 			//force ::SelectShell
2701cdf0e10cSrcweir 			rView.StopShellTimer();
2702cdf0e10cSrcweir 
2703cdf0e10cSrcweir 			SfxStringItem aDataDesc( nWh, sTxt );
2704cdf0e10cSrcweir 			rView.GetViewFrame()->GetDispatcher()->Execute(
2705cdf0e10cSrcweir                                 nWh, SFX_CALLMODE_ASYNCHRON, &aDataDesc,
2706cdf0e10cSrcweir                                 pConnectionItem, pColumnItem,
2707cdf0e10cSrcweir                                 pSourceItem, pCommandItem, pCommandTypeItem,
2708cdf0e10cSrcweir                                 pColumnNameItem, pSelectionItem, pCursorItem,0L);
2709cdf0e10cSrcweir             delete pConnectionItem;
2710cdf0e10cSrcweir             delete pColumnItem;
2711cdf0e10cSrcweir             delete pSourceItem;
2712cdf0e10cSrcweir             delete pCommandItem;
2713cdf0e10cSrcweir             delete pCommandTypeItem;
2714cdf0e10cSrcweir             delete pColumnNameItem;
2715cdf0e10cSrcweir 			delete pCursorItem;
2716cdf0e10cSrcweir 		}
2717cdf0e10cSrcweir 		else
2718cdf0e10cSrcweir 		{
2719cdf0e10cSrcweir 			SdrObject* pObj;
2720cdf0e10cSrcweir 			rSh.MakeDrawView();
2721cdf0e10cSrcweir 			FmFormView* pFmView = PTR_CAST( FmFormView, rSh.GetDrawView() );
2722cdf0e10cSrcweir 			if (pFmView && bHaveColumnDescriptor)
2723cdf0e10cSrcweir 			{
2724cdf0e10cSrcweir 				if ( 0 != (pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) ) ) )
2725cdf0e10cSrcweir                     rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
2726cdf0e10cSrcweir 			}
2727cdf0e10cSrcweir 		}
2728cdf0e10cSrcweir 		nRet = 1;
2729cdf0e10cSrcweir 	}
2730cdf0e10cSrcweir 	else if( bMsg )
2731cdf0e10cSrcweir 	{
2732cdf0e10cSrcweir 		InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR)).Execute();
2733cdf0e10cSrcweir 	}
2734cdf0e10cSrcweir 	return nRet;
2735cdf0e10cSrcweir }
2736cdf0e10cSrcweir 
2737cdf0e10cSrcweir // -----------------------------------------------------------------------
2738cdf0e10cSrcweir 
2739cdf0e10cSrcweir int SwTransferable::_PasteFileList( TransferableDataHelper& rData,
2740cdf0e10cSrcweir 									SwWrtShell& rSh, sal_Bool bLink,
2741cdf0e10cSrcweir 									const Point* pPt, sal_Bool bMsg )
2742cdf0e10cSrcweir {
2743cdf0e10cSrcweir 	int nRet = 0;
2744cdf0e10cSrcweir 	FileList aFileList;
2745cdf0e10cSrcweir 	if( rData.GetFileList( SOT_FORMAT_FILE_LIST, aFileList ) &&
2746cdf0e10cSrcweir 		aFileList.Count() )
2747cdf0e10cSrcweir 	{
2748cdf0e10cSrcweir 		sal_uInt16 nAct = bLink ? SW_PASTESDR_SETATTR : SW_PASTESDR_INSERT;
2749cdf0e10cSrcweir 		String sFlyNm;
2750cdf0e10cSrcweir 		// iterate over the filelist
2751cdf0e10cSrcweir 		for( sal_uLong n = 0, nEnd = aFileList.Count(); n < nEnd; ++n )
2752cdf0e10cSrcweir 		{
2753cdf0e10cSrcweir 			TransferDataContainer* pHlp = new TransferDataContainer;
2754cdf0e10cSrcweir 			pHlp->CopyString( FORMAT_FILE, aFileList.GetFile( n ));
2755cdf0e10cSrcweir 			TransferableDataHelper aData( pHlp );
2756cdf0e10cSrcweir 
2757cdf0e10cSrcweir             if( SwTransferable::_PasteFileName( aData, rSh, SOT_FORMAT_FILE, nAct,
2758cdf0e10cSrcweir 											pPt, sal_False, bMsg ))
2759cdf0e10cSrcweir 			{
2760cdf0e10cSrcweir 				if( bLink )
2761cdf0e10cSrcweir 				{
2762cdf0e10cSrcweir 					sFlyNm = rSh.GetFlyName();
2763cdf0e10cSrcweir 					SwTransferable::SetSelInShell( rSh, sal_False, pPt );
2764cdf0e10cSrcweir 				}
2765cdf0e10cSrcweir 				nRet = 1;
2766cdf0e10cSrcweir 			}
2767cdf0e10cSrcweir 		}
2768cdf0e10cSrcweir 		if( sFlyNm.Len() )
2769cdf0e10cSrcweir 			rSh.GotoFly( sFlyNm );
2770cdf0e10cSrcweir 	}
2771cdf0e10cSrcweir 	else if( bMsg )
2772cdf0e10cSrcweir 	{
2773cdf0e10cSrcweir 		InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR)).Execute();
2774cdf0e10cSrcweir 	}
2775cdf0e10cSrcweir 	return nRet;
2776cdf0e10cSrcweir }
2777cdf0e10cSrcweir 
2778cdf0e10cSrcweir // -----------------------------------------------------------------------
2779cdf0e10cSrcweir 
2780cdf0e10cSrcweir sal_Bool SwTransferable::_CheckForURLOrLNKFile( TransferableDataHelper& rData,
2781cdf0e10cSrcweir 										String& rFileName, String* pTitle )
2782cdf0e10cSrcweir {
2783cdf0e10cSrcweir 	sal_Bool bIsURLFile = sal_False;
2784cdf0e10cSrcweir 	INetBookmark aBkmk;
2785cdf0e10cSrcweir 	if( rData.GetINetBookmark( SOT_FORMATSTR_ID_SOLK, aBkmk ) )
2786cdf0e10cSrcweir 	{
2787cdf0e10cSrcweir 		rFileName = aBkmk.GetURL();
2788cdf0e10cSrcweir 		if( pTitle )
2789cdf0e10cSrcweir 			*pTitle = aBkmk.GetDescription();
2790cdf0e10cSrcweir 		bIsURLFile = sal_True;
2791cdf0e10cSrcweir 	}
2792cdf0e10cSrcweir 	else
2793cdf0e10cSrcweir 	{
2794cdf0e10cSrcweir 		xub_StrLen nLen = rFileName.Len();
2795cdf0e10cSrcweir 		if( 4 < nLen && '.' == rFileName.GetChar( nLen - 4 ))
2796cdf0e10cSrcweir 		{
2797cdf0e10cSrcweir 			String sExt( rFileName.Copy( nLen - 3 ));
2798cdf0e10cSrcweir 			if( sExt.EqualsIgnoreCaseAscii( "url" ))
2799cdf0e10cSrcweir 			{
2800cdf0e10cSrcweir ASSERT( !&rFileName, "how do we read today .URL - Files?" );
2801cdf0e10cSrcweir 			}
2802cdf0e10cSrcweir 		}
2803cdf0e10cSrcweir 	}
2804cdf0e10cSrcweir 	return bIsURLFile;
2805cdf0e10cSrcweir }
2806cdf0e10cSrcweir 
2807cdf0e10cSrcweir // -----------------------------------------------------------------------
2808cdf0e10cSrcweir 
2809cdf0e10cSrcweir sal_Bool SwTransferable::IsPasteSpecial( const SwWrtShell& rWrtShell,
2810cdf0e10cSrcweir 									 const TransferableDataHelper& rData )
2811cdf0e10cSrcweir {
2812cdf0e10cSrcweir     // we can paste-special if there's an entry in the paste-special-format list
2813cdf0e10cSrcweir     SvxClipboardFmtItem aClipboardFmtItem(0);
2814cdf0e10cSrcweir     FillClipFmtItem( rWrtShell, rData, aClipboardFmtItem);
2815cdf0e10cSrcweir     return aClipboardFmtItem.Count() > 0;
2816cdf0e10cSrcweir }
2817cdf0e10cSrcweir 
2818cdf0e10cSrcweir // -----------------------------------------------------------------------
2819cdf0e10cSrcweir 
2820cdf0e10cSrcweir int SwTransferable::PasteFormat( SwWrtShell& rSh,
2821cdf0e10cSrcweir 									TransferableDataHelper& rData,
2822cdf0e10cSrcweir 									sal_uLong nFormat )
2823cdf0e10cSrcweir {
2824cdf0e10cSrcweir 	SwWait aWait( *rSh.GetView().GetDocShell(), sal_False );
2825cdf0e10cSrcweir 	int nRet = 0;
2826cdf0e10cSrcweir 
2827cdf0e10cSrcweir 	sal_uLong nPrivateFmt = FORMAT_PRIVATE;
2828cdf0e10cSrcweir 	SwTransferable *pClipboard = GetSwTransferable( rData );
2829cdf0e10cSrcweir 	if( pClipboard &&
2830cdf0e10cSrcweir 		((TRNSFR_DOCUMENT|TRNSFR_GRAPHIC|TRNSFR_OLE) & pClipboard->eBufferType ))
2831cdf0e10cSrcweir 		nPrivateFmt = SOT_FORMATSTR_ID_EMBED_SOURCE;
2832cdf0e10cSrcweir 
2833cdf0e10cSrcweir 	if( pClipboard && nPrivateFmt == nFormat )
2834cdf0e10cSrcweir 		nRet = pClipboard->PrivatePaste( rSh );
2835cdf0e10cSrcweir 	else if( rData.HasFormat( nFormat ) )
2836cdf0e10cSrcweir 	{
2837cdf0e10cSrcweir         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
2838cdf0e10cSrcweir 		sal_uInt16 nEventAction,
2839cdf0e10cSrcweir 			   nDestination = SwTransferable::GetSotDestination( rSh ),
2840cdf0e10cSrcweir 			   nSourceOptions =
2841cdf0e10cSrcweir 					(( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
2842cdf0e10cSrcweir 					   EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
2843cdf0e10cSrcweir 					   EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
2844cdf0e10cSrcweir 					   EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
2845cdf0e10cSrcweir 										? EXCHG_IN_ACTION_COPY
2846cdf0e10cSrcweir 										: EXCHG_IN_ACTION_MOVE),
2847cdf0e10cSrcweir 			   nAction = SotExchange::GetExchangeAction(
2848cdf0e10cSrcweir 									rData.GetDataFlavorExVector(),
2849cdf0e10cSrcweir 									nDestination,
2850cdf0e10cSrcweir 									nSourceOptions,  			/* ?? */
2851cdf0e10cSrcweir 									EXCHG_IN_ACTION_DEFAULT,    /* ?? */
2852cdf0e10cSrcweir 									nFormat, nEventAction, nFormat,
2853cdf0e10cSrcweir 									lcl_getTransferPointer ( xTransferable ) );
2854cdf0e10cSrcweir 
2855cdf0e10cSrcweir 		if( EXCHG_INOUT_ACTION_NONE != nAction )
2856cdf0e10cSrcweir 			nRet = SwTransferable::PasteData( rData, rSh, nAction, nFormat,
2857cdf0e10cSrcweir                                                 nDestination, sal_True, sal_False );
2858cdf0e10cSrcweir 	}
2859cdf0e10cSrcweir 	return nRet;
2860cdf0e10cSrcweir }
2861cdf0e10cSrcweir 
2862cdf0e10cSrcweir // -----------------------------------------------------------------------
2863cdf0e10cSrcweir 
2864cdf0e10cSrcweir int SwTransferable::_TestAllowedFormat( const TransferableDataHelper& rData,
2865cdf0e10cSrcweir 										sal_uLong nFormat, sal_uInt16 nDestination )
2866cdf0e10cSrcweir {
2867cdf0e10cSrcweir 	sal_uInt16 nAction = EXCHG_INOUT_ACTION_NONE, nEventAction;
2868cdf0e10cSrcweir 	if( rData.HasFormat( nFormat )) {
2869cdf0e10cSrcweir         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
2870cdf0e10cSrcweir 		nAction = SotExchange::GetExchangeAction(
2871cdf0e10cSrcweir 						rData.GetDataFlavorExVector(),
2872cdf0e10cSrcweir 						nDestination, EXCHG_IN_ACTION_COPY,
2873cdf0e10cSrcweir 						EXCHG_IN_ACTION_COPY, nFormat,
2874cdf0e10cSrcweir 						nEventAction, nFormat,
2875cdf0e10cSrcweir 						lcl_getTransferPointer ( xTransferable ) );
2876cdf0e10cSrcweir     }
2877cdf0e10cSrcweir 	return EXCHG_INOUT_ACTION_NONE != nAction;
2878cdf0e10cSrcweir }
2879cdf0e10cSrcweir 
2880cdf0e10cSrcweir // -----------------------------------------------------------------------
2881cdf0e10cSrcweir 
2882cdf0e10cSrcweir /**
2883cdf0e10cSrcweir  * the list of formats which will be offered to the user in the 'Paste
2884cdf0e10cSrcweir  * Special...' dialog and the paste button menu
2885cdf0e10cSrcweir  */
2886cdf0e10cSrcweir static sal_uInt16 aPasteSpecialIds[] =
2887cdf0e10cSrcweir {
2888cdf0e10cSrcweir     SOT_FORMATSTR_ID_HTML,
2889cdf0e10cSrcweir     SOT_FORMATSTR_ID_HTML_SIMPLE,
2890cdf0e10cSrcweir     SOT_FORMATSTR_ID_HTML_NO_COMMENT,
2891cdf0e10cSrcweir     FORMAT_RTF,
2892cdf0e10cSrcweir     FORMAT_STRING,
2893cdf0e10cSrcweir     SOT_FORMATSTR_ID_SONLK,
2894cdf0e10cSrcweir     SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK,
2895cdf0e10cSrcweir     SOT_FORMATSTR_ID_DRAWING,
2896cdf0e10cSrcweir     SOT_FORMATSTR_ID_SVXB,
2897cdf0e10cSrcweir     FORMAT_GDIMETAFILE,
2898cdf0e10cSrcweir     FORMAT_BITMAP,
2899cdf0e10cSrcweir     SOT_FORMATSTR_ID_SVIM,
2900cdf0e10cSrcweir     SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR,
2901cdf0e10cSrcweir     0
2902cdf0e10cSrcweir };
2903cdf0e10cSrcweir 
2904cdf0e10cSrcweir 
2905cdf0e10cSrcweir int SwTransferable::PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& rData )
2906cdf0e10cSrcweir {
2907cdf0e10cSrcweir     // Plain text == unformatted
2908cdf0e10cSrcweir 	return SwTransferable::PasteFormat( rSh, rData, SOT_FORMAT_STRING );
2909cdf0e10cSrcweir }
2910cdf0e10cSrcweir 
2911cdf0e10cSrcweir // -----------------------------------------------------------------------
2912cdf0e10cSrcweir 
2913cdf0e10cSrcweir int SwTransferable::PasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rData, sal_uLong& rFormatUsed )
2914cdf0e10cSrcweir {
2915cdf0e10cSrcweir 	int nRet = 0;
2916cdf0e10cSrcweir     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2917cdf0e10cSrcweir     SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rSh.GetView().GetEditWin() );
2918cdf0e10cSrcweir 
2919cdf0e10cSrcweir 	DataFlavorExVector aFormats( rData.GetDataFlavorExVector() );
2920cdf0e10cSrcweir 	TransferableObjectDescriptor aDesc;
2921cdf0e10cSrcweir 
2922cdf0e10cSrcweir 	sal_uInt16 nDest = SwTransferable::GetSotDestination( rSh );
2923cdf0e10cSrcweir 
2924cdf0e10cSrcweir 	SwTransferable *pClipboard = GetSwTransferable( rData );
2925cdf0e10cSrcweir 	if( pClipboard )
2926cdf0e10cSrcweir 	{
2927cdf0e10cSrcweir 		aDesc = pClipboard->aObjDesc;
2928cdf0e10cSrcweir 		sal_uInt16 nResId;
2929cdf0e10cSrcweir 		if( pClipboard->eBufferType & TRNSFR_DOCUMENT )
2930cdf0e10cSrcweir 			nResId = STR_PRIVATETEXT;
2931cdf0e10cSrcweir 		else if( pClipboard->eBufferType & TRNSFR_GRAPHIC )
2932cdf0e10cSrcweir 			nResId = STR_PRIVATEGRAPHIC;
2933cdf0e10cSrcweir 		else if( pClipboard->eBufferType == TRNSFR_OLE )
2934cdf0e10cSrcweir 			nResId = STR_PRIVATEOLE;
2935cdf0e10cSrcweir 		else
2936cdf0e10cSrcweir 			nResId = 0;
2937cdf0e10cSrcweir 
2938cdf0e10cSrcweir 		if( nResId )
2939cdf0e10cSrcweir 		{
2940cdf0e10cSrcweir 			if( STR_PRIVATEOLE == nResId || STR_PRIVATEGRAPHIC == nResId )
2941cdf0e10cSrcweir 			{
2942cdf0e10cSrcweir 				// add SOT_FORMATSTR_ID_EMBED_SOURCE to the formats. This
2943cdf0e10cSrcweir 				// format display then the private format name.
2944cdf0e10cSrcweir 				DataFlavorEx aFlavorEx;
2945cdf0e10cSrcweir 				aFlavorEx.mnSotId = SOT_FORMATSTR_ID_EMBED_SOURCE;
2946cdf0e10cSrcweir 				aFormats.insert( aFormats.begin(), aFlavorEx );
2947cdf0e10cSrcweir 			}
2948cdf0e10cSrcweir 			pDlg->SetObjName( pClipboard->aObjDesc.maClassName,
2949cdf0e10cSrcweir 								SW_RES( nResId ) );
2950cdf0e10cSrcweir 			pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyStr );
2951cdf0e10cSrcweir 		}
2952cdf0e10cSrcweir 	}
2953cdf0e10cSrcweir 	else
2954cdf0e10cSrcweir 	{
2955cdf0e10cSrcweir 		if( rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
2956cdf0e10cSrcweir 			rData.GetTransferableObjectDescriptor(
2957cdf0e10cSrcweir 								SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
2958cdf0e10cSrcweir 
2959cdf0e10cSrcweir 		if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_EMBED_SOURCE, nDest ))
2960cdf0e10cSrcweir 			pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyStr );
2961cdf0e10cSrcweir 		if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK_SOURCE, nDest ))
2962cdf0e10cSrcweir 			pDlg->Insert( SOT_FORMATSTR_ID_LINK_SOURCE, aEmptyStr );
2963cdf0e10cSrcweir 	}
2964cdf0e10cSrcweir 
2965cdf0e10cSrcweir 	if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK, nDest ))
2966cdf0e10cSrcweir 		pDlg->Insert( SOT_FORMATSTR_ID_LINK, SW_RES(STR_DDEFORMAT) );
2967cdf0e10cSrcweir 
2968cdf0e10cSrcweir 	for( sal_uInt16* pIds = aPasteSpecialIds; *pIds; ++pIds )
2969cdf0e10cSrcweir 		if( SwTransferable::_TestAllowedFormat( rData, *pIds, nDest ))
2970cdf0e10cSrcweir 			pDlg->Insert( *pIds, aEmptyStr );
2971cdf0e10cSrcweir 
2972cdf0e10cSrcweir     sal_uLong nFormat = pDlg->GetFormat( rData.GetTransferable() );
2973cdf0e10cSrcweir 
2974cdf0e10cSrcweir 	if( nFormat )
2975cdf0e10cSrcweir 		nRet = SwTransferable::PasteFormat( rSh, rData, nFormat );
2976cdf0e10cSrcweir 
2977cdf0e10cSrcweir     if ( nRet )
2978cdf0e10cSrcweir         rFormatUsed = nFormat;
2979cdf0e10cSrcweir 
2980cdf0e10cSrcweir     delete pDlg;
2981cdf0e10cSrcweir 	return nRet;
2982cdf0e10cSrcweir }
2983cdf0e10cSrcweir 
2984cdf0e10cSrcweir 
2985cdf0e10cSrcweir void SwTransferable::FillClipFmtItem( const SwWrtShell& rSh,
2986cdf0e10cSrcweir 								const TransferableDataHelper& rData,
2987cdf0e10cSrcweir 								SvxClipboardFmtItem & rToFill )
2988cdf0e10cSrcweir {
2989cdf0e10cSrcweir 	sal_uInt16 nDest = SwTransferable::GetSotDestination( rSh );
2990cdf0e10cSrcweir 
2991cdf0e10cSrcweir 	SwTransferable *pClipboard = GetSwTransferable( rData );
2992cdf0e10cSrcweir 	if( pClipboard )
2993cdf0e10cSrcweir 	{
2994cdf0e10cSrcweir 		sal_uInt16 nResId;
2995cdf0e10cSrcweir 		if( pClipboard->eBufferType & TRNSFR_DOCUMENT )
2996cdf0e10cSrcweir 			nResId = STR_PRIVATETEXT;
2997cdf0e10cSrcweir 		else if( pClipboard->eBufferType & TRNSFR_GRAPHIC )
2998cdf0e10cSrcweir 			nResId = STR_PRIVATEGRAPHIC;
2999cdf0e10cSrcweir 		else if( pClipboard->eBufferType == TRNSFR_OLE )
3000cdf0e10cSrcweir 			nResId = STR_PRIVATEOLE;
3001cdf0e10cSrcweir 		else
3002cdf0e10cSrcweir 			nResId = 0;
3003cdf0e10cSrcweir 
3004cdf0e10cSrcweir 		if( nResId )
3005cdf0e10cSrcweir 			rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE,
3006cdf0e10cSrcweir 										SW_RES( nResId ) );
3007cdf0e10cSrcweir 	}
3008cdf0e10cSrcweir 	else
3009cdf0e10cSrcweir 	{
3010cdf0e10cSrcweir 		TransferableObjectDescriptor aDesc;
3011cdf0e10cSrcweir 		if( rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
3012cdf0e10cSrcweir 			((TransferableDataHelper&)rData).GetTransferableObjectDescriptor(
3013cdf0e10cSrcweir 								SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
3014cdf0e10cSrcweir 
3015cdf0e10cSrcweir 		if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_EMBED_SOURCE, nDest ))
3016cdf0e10cSrcweir 			rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE,
3017cdf0e10cSrcweir 											aDesc.maTypeName );
3018cdf0e10cSrcweir 		if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK_SOURCE, nDest ))
3019cdf0e10cSrcweir 			rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK_SOURCE );
3020cdf0e10cSrcweir 
3021cdf0e10cSrcweir 		SotFormatStringId nFormat;
3022cdf0e10cSrcweir 		if ( rData.HasFormat(nFormat = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE) || rData.HasFormat(nFormat = SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE) )
3023cdf0e10cSrcweir 		{
3024cdf0e10cSrcweir 			String sName,sSource;
3025cdf0e10cSrcweir             if ( SvPasteObjectHelper::GetEmbeddedName(rData,sName,sSource,nFormat) )
3026cdf0e10cSrcweir 				rToFill.AddClipbrdFormat( nFormat, sName );
3027cdf0e10cSrcweir 		}
3028cdf0e10cSrcweir 	}
3029cdf0e10cSrcweir 
3030cdf0e10cSrcweir 	if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK, nDest ))
3031cdf0e10cSrcweir 		rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK, SW_RES(STR_DDEFORMAT) );
3032cdf0e10cSrcweir 
3033cdf0e10cSrcweir 	for( sal_uInt16* pIds = aPasteSpecialIds; *pIds; ++pIds )
3034cdf0e10cSrcweir 		if( SwTransferable::_TestAllowedFormat( rData, *pIds, nDest ))
3035cdf0e10cSrcweir 			rToFill.AddClipbrdFormat( *pIds, aEmptyStr );
3036cdf0e10cSrcweir }
3037cdf0e10cSrcweir 
3038cdf0e10cSrcweir void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
3039cdf0e10cSrcweir {
3040cdf0e10cSrcweir     if(!pWrtShell)
3041cdf0e10cSrcweir         return;
3042cdf0e10cSrcweir     String sGrfNm;
3043cdf0e10cSrcweir 	const int nSelection = pWrtShell->GetSelectionType();
3044cdf0e10cSrcweir 	if( nsSelectionType::SEL_GRF == nSelection)
3045cdf0e10cSrcweir 	{
3046cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_SVXB );
3047cdf0e10cSrcweir         // --> OD 2005-02-09 #119353# - robust
3048cdf0e10cSrcweir         const Graphic* pGrf = pWrtShell->GetGraphic();
3049cdf0e10cSrcweir         if ( pGrf && pGrf->IsSupportedGraphic() )
3050cdf0e10cSrcweir         // <--
3051cdf0e10cSrcweir 		{
3052cdf0e10cSrcweir 			AddFormat( FORMAT_GDIMETAFILE );
305345fd3b9aSArmin Le Grand             AddFormat( SOT_FORMATSTR_ID_PNG );
3054cdf0e10cSrcweir 			AddFormat( FORMAT_BITMAP );
3055cdf0e10cSrcweir 		}
3056cdf0e10cSrcweir 		eBufferType = TRNSFR_GRAPHIC;
3057cdf0e10cSrcweir 		pWrtShell->GetGrfNms( &sGrfNm, 0 );
3058cdf0e10cSrcweir 	}
3059cdf0e10cSrcweir 	else if( nsSelectionType::SEL_OLE == nSelection )
3060cdf0e10cSrcweir 	{
3061cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
3062cdf0e10cSrcweir         PrepareOLE( aObjDesc );
3063cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
3064cdf0e10cSrcweir 		AddFormat( FORMAT_GDIMETAFILE );
3065cdf0e10cSrcweir 		eBufferType = TRNSFR_OLE;
3066cdf0e10cSrcweir 	}
3067cdf0e10cSrcweir 	//Gibt es ueberhaupt etwas zum bereitstellen?
3068cdf0e10cSrcweir 	else if ( pWrtShell->IsSelection() || pWrtShell->IsFrmSelected() ||
3069cdf0e10cSrcweir 			  pWrtShell->IsObjSelected() )
3070cdf0e10cSrcweir 	{
3071cdf0e10cSrcweir 		if( pWrtShell->IsObjSelected() )
3072cdf0e10cSrcweir 			eBufferType = TRNSFR_DRAWING;
3073cdf0e10cSrcweir 		else
3074cdf0e10cSrcweir 		{
3075cdf0e10cSrcweir 			eBufferType = TRNSFR_DOCUMENT;
3076cdf0e10cSrcweir 			if( SwWrtShell::NO_WORD !=
3077cdf0e10cSrcweir 				pWrtShell->IntelligentCut( nSelection, sal_False ))
3078cdf0e10cSrcweir 				eBufferType = TransferBufferType( TRNSFR_DOCUMENT_WORD
3079cdf0e10cSrcweir 													| eBufferType);
3080cdf0e10cSrcweir 		}
3081cdf0e10cSrcweir 
3082cdf0e10cSrcweir 		if( nSelection & nsSelectionType::SEL_TBL_CELLS )
3083cdf0e10cSrcweir 			eBufferType = (TransferBufferType)(TRNSFR_TABELLE | eBufferType);
3084cdf0e10cSrcweir 
3085cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
3086cdf0e10cSrcweir 
3087cdf0e10cSrcweir 		//RTF vor das Metafile von OLE stellen, weil mit weniger verlusten
3088cdf0e10cSrcweir 		//behaftet.
3089cdf0e10cSrcweir 		if( !pWrtShell->IsObjSelected() )
3090cdf0e10cSrcweir 		{
3091cdf0e10cSrcweir 			AddFormat( FORMAT_RTF );
3092cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_HTML );
3093cdf0e10cSrcweir 		}
3094cdf0e10cSrcweir 		if( pWrtShell->IsSelection() )
3095cdf0e10cSrcweir 			AddFormat( FORMAT_STRING );
3096cdf0e10cSrcweir 
3097cdf0e10cSrcweir 		if( nSelection & ( nsSelectionType::SEL_DRW | nsSelectionType::SEL_DRW_FORM ))
3098cdf0e10cSrcweir 		{
3099cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_DRAWING );
3100cdf0e10cSrcweir 			if ( nSelection & nsSelectionType::SEL_DRW )
3101cdf0e10cSrcweir 			{
3102cdf0e10cSrcweir 				AddFormat( FORMAT_GDIMETAFILE );
310345fd3b9aSArmin Le Grand                 AddFormat( SOT_FORMATSTR_ID_PNG );
3104cdf0e10cSrcweir 				AddFormat( FORMAT_BITMAP );
3105cdf0e10cSrcweir 			}
3106cdf0e10cSrcweir 			eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
3107cdf0e10cSrcweir 
3108cdf0e10cSrcweir 			pClpGraphic = new Graphic;
3109cdf0e10cSrcweir 			if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
3110cdf0e10cSrcweir 				pOrigGrf = pClpGraphic;
3111cdf0e10cSrcweir 			pClpBitmap = new Graphic;
3112cdf0e10cSrcweir 			if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
3113cdf0e10cSrcweir 				pOrigGrf = pClpBitmap;
3114cdf0e10cSrcweir 
3115cdf0e10cSrcweir 			// ist es ein URL-Button ?
3116cdf0e10cSrcweir 			String sURL, sDesc;
3117cdf0e10cSrcweir 			if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
3118cdf0e10cSrcweir 			{
3119cdf0e10cSrcweir 				AddFormat( FORMAT_STRING );
3120cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_SOLK );
3121cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
3122cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
3123cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
3124cdf0e10cSrcweir  				AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
3125cdf0e10cSrcweir 				eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
3126cdf0e10cSrcweir 			}
3127cdf0e10cSrcweir 		}
3128cdf0e10cSrcweir 
3129cdf0e10cSrcweir 		//ObjectDescriptor wurde bereits aus der alten DocShell gefuellt.
3130cdf0e10cSrcweir 		//Jetzt noch anpassen. Dadurch kann im GetData die erste Anfrage
3131cdf0e10cSrcweir 		//auch noch mit delayed rendering beantwortet werden.
3132cdf0e10cSrcweir 		aObjDesc.mbCanLink = sal_False;
3133cdf0e10cSrcweir 		aObjDesc.maDragStartPos = rSttPos;
3134cdf0e10cSrcweir 		aObjDesc.maSize = OutputDevice::LogicToLogic( Size( OLESIZE ),
3135cdf0e10cSrcweir 												MAP_TWIP, MAP_100TH_MM );
3136cdf0e10cSrcweir         PrepareOLE( aObjDesc );
3137cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
3138cdf0e10cSrcweir 	}
3139cdf0e10cSrcweir 	else if( nSelection & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() )
3140cdf0e10cSrcweir 	{
3141cdf0e10cSrcweir 		// ist nur ein Feld - Selektiert?
3142cdf0e10cSrcweir 		SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
3143cdf0e10cSrcweir 		Point aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
3144cdf0e10cSrcweir 
3145cdf0e10cSrcweir 		if( pWrtShell->GetContentAtPos( aPos, aCntntAtPos ) )
3146cdf0e10cSrcweir 		{
3147cdf0e10cSrcweir 			AddFormat( FORMAT_STRING );
3148cdf0e10cSrcweir  			AddFormat( SOT_FORMATSTR_ID_SOLK );
3149cdf0e10cSrcweir  			AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
3150cdf0e10cSrcweir  			AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
3151cdf0e10cSrcweir  			AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
3152cdf0e10cSrcweir  			AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
3153cdf0e10cSrcweir 			eBufferType = TRNSFR_INETFLD;
3154cdf0e10cSrcweir 		}
3155cdf0e10cSrcweir 	}
3156cdf0e10cSrcweir 
3157cdf0e10cSrcweir 	if( pWrtShell->IsFrmSelected() )
3158cdf0e10cSrcweir 	{
3159cdf0e10cSrcweir 		SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
3160cdf0e10cSrcweir 		pWrtShell->GetFlyFrmAttr( aSet );
3161cdf0e10cSrcweir 		const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
3162cdf0e10cSrcweir 		if( rURL.GetMap() )
3163cdf0e10cSrcweir 		{
3164cdf0e10cSrcweir 			pImageMap = new ImageMap( *rURL.GetMap() );
3165cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_SVIM );
3166cdf0e10cSrcweir 		}
3167cdf0e10cSrcweir 		else if( rURL.GetURL().Len() )
3168cdf0e10cSrcweir 		{
3169cdf0e10cSrcweir 			pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
3170cdf0e10cSrcweir 										rURL.GetTargetFrameName(),
3171cdf0e10cSrcweir 										aEmptyStr, Size() );
3172cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_INET_IMAGE );
3173cdf0e10cSrcweir 		}
3174cdf0e10cSrcweir 	}
3175cdf0e10cSrcweir }
3176cdf0e10cSrcweir 
3177cdf0e10cSrcweir void SwTransferable::StartDrag( Window* pWin, const Point& rPos )
3178cdf0e10cSrcweir {
3179cdf0e10cSrcweir     if(!pWrtShell)
3180cdf0e10cSrcweir         return;
3181cdf0e10cSrcweir     bOldIdle = pWrtShell->GetViewOptions()->IsIdle();
3182cdf0e10cSrcweir 	bCleanUp = sal_True;
3183cdf0e10cSrcweir 
3184cdf0e10cSrcweir 	((SwViewOption *)pWrtShell->GetViewOptions())->SetIdle( sal_False );
3185cdf0e10cSrcweir 
3186cdf0e10cSrcweir 	if( pWrtShell->IsSelFrmMode() )
3187cdf0e10cSrcweir 		pWrtShell->ShowCrsr();
3188cdf0e10cSrcweir 
3189cdf0e10cSrcweir     SW_MOD()->pDragDrop = this;
3190cdf0e10cSrcweir 
3191cdf0e10cSrcweir 	SetDataForDragAndDrop( rPos );
3192cdf0e10cSrcweir 
3193cdf0e10cSrcweir 	sal_Int8 nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
3194cdf0e10cSrcweir 	SwDocShell* pDShell = pWrtShell->GetView().GetDocShell();
3195cdf0e10cSrcweir 	if( ( pDShell && pDShell->IsReadOnly() ) || pWrtShell->HasReadonlySel() )
3196cdf0e10cSrcweir 		nDragOptions &= ~DND_ACTION_MOVE;
3197cdf0e10cSrcweir 
3198cdf0e10cSrcweir 	TransferableHelper::StartDrag( pWin, nDragOptions );
3199cdf0e10cSrcweir }
3200cdf0e10cSrcweir 
3201cdf0e10cSrcweir void SwTransferable::DragFinished( sal_Int8 nAction )
3202cdf0e10cSrcweir {
3203cdf0e10cSrcweir 	//Und noch die letzten Nacharbeiten damit alle Stati stimmen.
3204cdf0e10cSrcweir 	if( DND_ACTION_MOVE == nAction	)
3205cdf0e10cSrcweir 	{
3206cdf0e10cSrcweir 		if( bCleanUp )
3207cdf0e10cSrcweir 		{
3208cdf0e10cSrcweir 			//Es wurde auserhalb des Writers gedroped. Wir muessen noch
3209cdf0e10cSrcweir 			//loeschen.
3210cdf0e10cSrcweir 
3211cdf0e10cSrcweir 			pWrtShell->StartAllAction();
3212cdf0e10cSrcweir             pWrtShell->StartUndo( UNDO_UI_DRAG_AND_MOVE );
3213cdf0e10cSrcweir 			if ( pWrtShell->IsTableMode() )
3214cdf0e10cSrcweir 				pWrtShell->DeleteTblSel();
3215cdf0e10cSrcweir 			else
3216cdf0e10cSrcweir 			{
3217cdf0e10cSrcweir 				if ( !(pWrtShell->IsSelFrmMode() || pWrtShell->IsObjSelected()) )
3218cdf0e10cSrcweir 					//SmartCut, eines der Blanks mitnehmen.
3219cdf0e10cSrcweir 					pWrtShell->IntelligentCut( pWrtShell->GetSelectionType(), sal_True );
3220cdf0e10cSrcweir 				pWrtShell->DelRight();
3221cdf0e10cSrcweir 			}
3222cdf0e10cSrcweir             pWrtShell->EndUndo( UNDO_UI_DRAG_AND_MOVE );
3223cdf0e10cSrcweir 			pWrtShell->EndAllAction();
3224cdf0e10cSrcweir 		}
3225cdf0e10cSrcweir 		else
3226cdf0e10cSrcweir 		{
3227cdf0e10cSrcweir 			const int nSelection = pWrtShell->GetSelectionType();
3228cdf0e10cSrcweir 			if( ( nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF |
3229cdf0e10cSrcweir 				 nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW ) & nSelection )
3230cdf0e10cSrcweir 			{
3231cdf0e10cSrcweir 				pWrtShell->EnterSelFrmMode();
3232cdf0e10cSrcweir 			}
3233cdf0e10cSrcweir 		}
3234cdf0e10cSrcweir 	}
3235cdf0e10cSrcweir 	pWrtShell->GetView().GetEditWin().DragFinished();
3236cdf0e10cSrcweir 
3237cdf0e10cSrcweir 	if( pWrtShell->IsSelFrmMode() )
3238cdf0e10cSrcweir 		pWrtShell->HideCrsr();
3239cdf0e10cSrcweir 	else
3240cdf0e10cSrcweir 		pWrtShell->ShowCrsr();
3241cdf0e10cSrcweir //!!	else if( DND_ACTION_NONE != nAction )
3242cdf0e10cSrcweir //!!		pWrtShell->ShowCrsr();
3243cdf0e10cSrcweir //!!	else
3244cdf0e10cSrcweir //!!	{
3245cdf0e10cSrcweir //!!		//Muss wohl sein weil gescrollt wurde und ?...?
3246cdf0e10cSrcweir //!!		pWrtShell->StartAction();
3247cdf0e10cSrcweir //!!		pWrtShell->EndAction();
3248cdf0e10cSrcweir //!!	}
3249cdf0e10cSrcweir 
3250cdf0e10cSrcweir 	((SwViewOption *)pWrtShell->GetViewOptions())->SetIdle( bOldIdle );
3251cdf0e10cSrcweir }
3252cdf0e10cSrcweir 
3253cdf0e10cSrcweir 
3254cdf0e10cSrcweir /*  */
3255cdf0e10cSrcweir 
3256cdf0e10cSrcweir int SwTransferable::PrivatePaste( SwWrtShell& rShell )
3257cdf0e10cSrcweir {
3258cdf0e10cSrcweir 	// erst den SelectionType erfragen, dann Action-Klammerung !!!!
3259cdf0e10cSrcweir 	// (sonst wird nicht in eine TabellenSelektion gepastet!!!)
3260cdf0e10cSrcweir 	ASSERT( !rShell.ActionPend(), "Paste darf nie eine Actionklammerung haben" );
3261cdf0e10cSrcweir 	if ( !pClpDocFac )
3262cdf0e10cSrcweir 		return sal_False; // the return value of the SwFEShell::Paste also is sal_Bool!
3263cdf0e10cSrcweir 
3264cdf0e10cSrcweir 	const int nSelection = rShell.GetSelectionType();
3265cdf0e10cSrcweir 
3266cdf0e10cSrcweir     // #111827#
3267cdf0e10cSrcweir     SwRewriter aRewriter;
3268cdf0e10cSrcweir 
3269cdf0e10cSrcweir     SwTrnsfrActionAndUndo aAction( &rShell, UNDO_PASTE_CLIPBOARD);
3270cdf0e10cSrcweir 
3271cdf0e10cSrcweir     bool bKillPaMs = false;
3272cdf0e10cSrcweir 
3273cdf0e10cSrcweir 	//Selektierten Inhalt loeschen, nicht bei Tabellen-Selektion und
3274cdf0e10cSrcweir 	//Tabelle im Clipboard
3275cdf0e10cSrcweir 	if( rShell.HasSelection() && !( nSelection & nsSelectionType::SEL_TBL_CELLS))
3276cdf0e10cSrcweir 	{
3277cdf0e10cSrcweir         bKillPaMs = true;
3278cdf0e10cSrcweir         rShell.SetRetainSelection( true );
3279cdf0e10cSrcweir 		rShell.DelRight();
3280cdf0e10cSrcweir 		// war ein Fly selektiert, so muss jetzt fuer eine gueltige
3281cdf0e10cSrcweir 		// Cursor-Position gesorgt werden! (geparkter Cursor!)
3282cdf0e10cSrcweir 		if( ( nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF |
3283cdf0e10cSrcweir 			nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW |
3284cdf0e10cSrcweir 			nsSelectionType::SEL_DRW_FORM ) & nSelection )
3285cdf0e10cSrcweir 		{
3286cdf0e10cSrcweir 			// den Cursor wieder positionieren
3287cdf0e10cSrcweir 			Point aPt( rShell.GetCharRect().Pos() );
3288cdf0e10cSrcweir 			rShell.SwCrsrShell::SetCrsr( aPt, sal_True );
3289cdf0e10cSrcweir 		}
3290cdf0e10cSrcweir         rShell.SetRetainSelection( false );
3291cdf0e10cSrcweir 	}
3292cdf0e10cSrcweir 
3293cdf0e10cSrcweir     sal_Bool bInWrd = sal_False, bEndWrd = sal_False, bSttWrd = sal_False,
3294cdf0e10cSrcweir          bSmart = 0 != (TRNSFR_DOCUMENT_WORD & eBufferType);
3295cdf0e10cSrcweir 	if( bSmart )
3296cdf0e10cSrcweir 	{
3297cdf0e10cSrcweir // #108491# Why not for other Scripts? If TRNSFR_DOCUMENT_WORD is set, we have
3298cdf0e10cSrcweir // a word in the buffer, word in this context means 'something with spaces at
3299cdf0e10cSrcweir // beginning and end'. In this case we definitely want these spaces to be inserted
3300cdf0e10cSrcweir // here.
3301cdf0e10cSrcweir //      if( SCRIPTTYPE_LATIN != rShell.GetScriptType() )
3302cdf0e10cSrcweir //          bSmart = sal_False;
3303cdf0e10cSrcweir //      else
3304cdf0e10cSrcweir //      {
3305cdf0e10cSrcweir 			bInWrd = rShell.IsInWrd();
3306cdf0e10cSrcweir 		 	bEndWrd = rShell.IsEndWrd();
3307cdf0e10cSrcweir 			bSmart = bInWrd || bEndWrd;
3308cdf0e10cSrcweir 			if( bSmart )
3309cdf0e10cSrcweir 			{
3310cdf0e10cSrcweir 		 		bSttWrd = rShell.IsSttWrd();
3311cdf0e10cSrcweir 				if( bSmart && !bSttWrd && (bInWrd || bEndWrd) )
3312cdf0e10cSrcweir 					rShell.SwEditShell::Insert(' ');
3313cdf0e10cSrcweir 			}
3314cdf0e10cSrcweir //      }
3315cdf0e10cSrcweir 	}
3316cdf0e10cSrcweir 
3317cdf0e10cSrcweir 	int nRet = rShell.Paste( pClpDocFac->GetDoc() );
3318cdf0e10cSrcweir 
3319cdf0e10cSrcweir     if( bKillPaMs )
3320cdf0e10cSrcweir         rShell.KillPams();
3321cdf0e10cSrcweir 
3322cdf0e10cSrcweir 	// Wenn Smart Paste dann Leerzeichen einfuegen
3323cdf0e10cSrcweir 	if( nRet && bSmart && ((bInWrd && !bEndWrd )|| bSttWrd) )
3324cdf0e10cSrcweir 		rShell.SwEditShell::Insert(' ');
3325cdf0e10cSrcweir 
3326cdf0e10cSrcweir 	return nRet;
3327cdf0e10cSrcweir }
3328cdf0e10cSrcweir 
3329cdf0e10cSrcweir int SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt,
3330cdf0e10cSrcweir 								sal_Bool bMove, sal_Bool bIsXSelection )
3331cdf0e10cSrcweir {
3332cdf0e10cSrcweir 	int cWord	 = 0;
3333cdf0e10cSrcweir 	sal_Bool bInWrd  = sal_False;
3334cdf0e10cSrcweir 	sal_Bool bEndWrd = sal_False;
3335cdf0e10cSrcweir 	sal_Bool bSttWrd = sal_False;
3336cdf0e10cSrcweir 	sal_Bool bSttPara= sal_False;
3337cdf0e10cSrcweir 	sal_Bool bTblSel = sal_False;
3338cdf0e10cSrcweir 	sal_Bool bFrmSel = sal_False;
3339cdf0e10cSrcweir 
3340cdf0e10cSrcweir 	SwWrtShell& rSrcSh = *GetShell();
3341cdf0e10cSrcweir 
3342cdf0e10cSrcweir 	rSh.UnSetVisCrsr();
3343cdf0e10cSrcweir 
3344cdf0e10cSrcweir 	if( TRNSFR_INETFLD == eBufferType )
3345cdf0e10cSrcweir 	{
3346cdf0e10cSrcweir 		if( rSh.GetFmtFromObj( rDragPt ) )
3347cdf0e10cSrcweir 		{
3348cdf0e10cSrcweir 			INetBookmark aTmp;
3349cdf0e10cSrcweir 			if( (TRNSFR_INETFLD & eBufferType) && pBkmk )
3350cdf0e10cSrcweir 				aTmp = *pBkmk;
3351cdf0e10cSrcweir 
3352cdf0e10cSrcweir 			// Zielgrafik selektieren
3353cdf0e10cSrcweir 			if( rSh.SelectObj( rDragPt ) )
3354cdf0e10cSrcweir 			{
3355cdf0e10cSrcweir 				rSh.HideCrsr();
3356cdf0e10cSrcweir 				rSh.EnterSelFrmMode( &rDragPt );
3357cdf0e10cSrcweir 				bFrmDrag = sal_True;
3358cdf0e10cSrcweir 			}
3359cdf0e10cSrcweir 
3360cdf0e10cSrcweir 			const int nSelection = rSh.GetSelectionType();
3361cdf0e10cSrcweir 
3362cdf0e10cSrcweir 			// Draw-Objekte erstmal noch nicht beruecksichtigen
3363cdf0e10cSrcweir 			if( nsSelectionType::SEL_GRF & nSelection )
3364cdf0e10cSrcweir 			{
3365cdf0e10cSrcweir 				SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
3366cdf0e10cSrcweir 				rSh.GetFlyFrmAttr( aSet );
3367cdf0e10cSrcweir 				SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
3368cdf0e10cSrcweir 				aURL.SetURL( aTmp.GetURL(), sal_False );
3369cdf0e10cSrcweir 				aSet.Put( aURL );
3370cdf0e10cSrcweir 				rSh.SetFlyFrmAttr( aSet );
3371cdf0e10cSrcweir 				return 1;
3372cdf0e10cSrcweir 			}
3373cdf0e10cSrcweir 
3374cdf0e10cSrcweir 			if( nsSelectionType::SEL_DRW & nSelection )
3375cdf0e10cSrcweir 			{
3376cdf0e10cSrcweir 				rSh.LeaveSelFrmMode();
3377cdf0e10cSrcweir 				rSh.UnSelectFrm();
3378cdf0e10cSrcweir 				rSh.ShowCrsr();
3379cdf0e10cSrcweir 				bFrmDrag = sal_False;
3380cdf0e10cSrcweir 			}
3381cdf0e10cSrcweir 		}
3382cdf0e10cSrcweir 	}
3383cdf0e10cSrcweir 
3384cdf0e10cSrcweir 	if( &rSh != &rSrcSh && (nsSelectionType::SEL_GRF & rSh.GetSelectionType()) &&
3385cdf0e10cSrcweir 		TRNSFR_GRAPHIC == eBufferType )
3386cdf0e10cSrcweir 	{
3387cdf0e10cSrcweir 		// ReRead auf die Grafik
3388cdf0e10cSrcweir 		String sGrfNm, sFltNm;
3389cdf0e10cSrcweir 		rSrcSh.GetGrfNms( &sGrfNm, &sFltNm );
3390cdf0e10cSrcweir         rSh.ReRead( sGrfNm, sFltNm, rSrcSh.GetGraphic() );
3391cdf0e10cSrcweir 		return 1;
3392cdf0e10cSrcweir 	}
3393cdf0e10cSrcweir 
3394cdf0e10cSrcweir 	//Nicht in Selektionen oder selektierten Rahmen
3395cdf0e10cSrcweir 	if( rSh.ChgCurrPam( rDragPt ) ||
3396cdf0e10cSrcweir 		( rSh.IsSelFrmMode() && rSh.IsInsideSelectedObj( rDragPt )) )
3397cdf0e10cSrcweir 		return 0;
3398cdf0e10cSrcweir 
3399cdf0e10cSrcweir 	if( rSrcSh.IsTableMode() )
3400cdf0e10cSrcweir 		bTblSel = sal_True;
3401cdf0e10cSrcweir 	else if( rSrcSh.IsSelFrmMode() || rSrcSh.IsObjSelected() )
3402cdf0e10cSrcweir 	{
3403cdf0e10cSrcweir 		// keine positionsgeschuetzten Objecte verschieben!
3404cdf0e10cSrcweir 		if( bMove && rSrcSh.IsSelObjProtected( FLYPROTECT_POS ) )
3405cdf0e10cSrcweir 			return 0;
3406cdf0e10cSrcweir 
3407cdf0e10cSrcweir 		bFrmSel = sal_True;
3408cdf0e10cSrcweir 	}
3409cdf0e10cSrcweir 
3410cdf0e10cSrcweir 	const int nSel = rSrcSh.GetSelectionType();
3411cdf0e10cSrcweir 
3412cdf0e10cSrcweir     SwUndoId eUndoId = bMove ? UNDO_UI_DRAG_AND_MOVE : UNDO_UI_DRAG_AND_COPY;
3413cdf0e10cSrcweir 
3414cdf0e10cSrcweir     // #111827#
3415cdf0e10cSrcweir     SwRewriter aRewriter;
3416cdf0e10cSrcweir 
3417cdf0e10cSrcweir     aRewriter.AddRule(UNDO_ARG1, rSrcSh.GetSelDescr());
3418cdf0e10cSrcweir 
3419cdf0e10cSrcweir 	if(rSrcSh.GetDoc() != rSh.GetDoc())
3420cdf0e10cSrcweir         rSrcSh.StartUndo( eUndoId, &aRewriter );
3421cdf0e10cSrcweir     rSh.StartUndo( eUndoId, &aRewriter );
3422cdf0e10cSrcweir 
3423cdf0e10cSrcweir 	rSh.StartAction();
3424cdf0e10cSrcweir 	rSrcSh.StartAction();
3425cdf0e10cSrcweir 
3426cdf0e10cSrcweir 	if( &rSrcSh != &rSh )
3427cdf0e10cSrcweir 	{
3428cdf0e10cSrcweir 		rSh.EnterStdMode();
3429cdf0e10cSrcweir 		rSh.SwCrsrShell::SetCrsr( rDragPt, sal_True );
3430cdf0e10cSrcweir 		cWord = rSrcSh.IntelligentCut( nSel, sal_False );
3431cdf0e10cSrcweir 	}
3432cdf0e10cSrcweir 	else if( !bTblSel && !bFrmSel )
3433cdf0e10cSrcweir 	{
3434cdf0e10cSrcweir 		if( !rSh.IsAddMode() )
3435cdf0e10cSrcweir         {
3436cdf0e10cSrcweir             // --> OD 2008-03-19 #i87233#
3437cdf0e10cSrcweir             if ( rSh.IsBlockMode() )
3438cdf0e10cSrcweir             {
3439cdf0e10cSrcweir                 // preserve order of cursors for block mode
3440cdf0e10cSrcweir                 rSh.GoPrevCrsr();
3441cdf0e10cSrcweir             }
3442cdf0e10cSrcweir             // <--
3443cdf0e10cSrcweir 			rSh.SwCrsrShell::CreateCrsr();
3444cdf0e10cSrcweir         }
3445cdf0e10cSrcweir 		rSh.SwCrsrShell::SetCrsr( rDragPt, sal_True, false );
3446cdf0e10cSrcweir 		rSh.GoPrevCrsr();
3447cdf0e10cSrcweir 		cWord = rSh.IntelligentCut( rSh.GetSelectionType(), sal_False );
3448cdf0e10cSrcweir 		rSh.GoNextCrsr();
3449cdf0e10cSrcweir 	}
3450cdf0e10cSrcweir 
3451cdf0e10cSrcweir 	bInWrd	= rSh.IsInWrd();
3452cdf0e10cSrcweir 	bEndWrd = rSh.IsEndWrd();
3453cdf0e10cSrcweir 	bSttWrd = !bEndWrd && rSh.IsSttWrd();
3454cdf0e10cSrcweir 	bSttPara= rSh.IsSttPara();
3455cdf0e10cSrcweir 
3456cdf0e10cSrcweir 	Point aSttPt( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY() );
3457cdf0e10cSrcweir 
3458cdf0e10cSrcweir 	//JP 05.03.96: INetFelder erstmal selektieren !
3459cdf0e10cSrcweir 	if( TRNSFR_INETFLD == eBufferType )
3460cdf0e10cSrcweir 	{
3461cdf0e10cSrcweir 		if( &rSrcSh == &rSh )
3462cdf0e10cSrcweir 		{
3463cdf0e10cSrcweir 			rSh.GoPrevCrsr();
3464cdf0e10cSrcweir 			rSh.SwCrsrShell::SetCrsr( aSttPt, sal_True );
3465cdf0e10cSrcweir 			rSh.SelectTxtAttr( RES_TXTATR_INETFMT );
3466cdf0e10cSrcweir 			if( rSh.ChgCurrPam( rDragPt ) )
3467cdf0e10cSrcweir 			{
3468cdf0e10cSrcweir 				// nicht in sich selbst kopieren/verschieben
3469cdf0e10cSrcweir 				rSh.DestroyCrsr();
3470cdf0e10cSrcweir                 rSh.EndUndo();
3471cdf0e10cSrcweir 				rSh.EndAction();
3472cdf0e10cSrcweir 				rSh.EndAction();
3473cdf0e10cSrcweir 				return 0;
3474cdf0e10cSrcweir 			}
3475cdf0e10cSrcweir 			rSh.GoNextCrsr();
3476cdf0e10cSrcweir 		}
3477cdf0e10cSrcweir 		else
3478cdf0e10cSrcweir 		{
3479cdf0e10cSrcweir 			rSrcSh.SwCrsrShell::SetCrsr( aSttPt, sal_True );
3480cdf0e10cSrcweir 			rSrcSh.SelectTxtAttr( RES_TXTATR_INETFMT );
3481cdf0e10cSrcweir 		}
3482cdf0e10cSrcweir 
3483cdf0e10cSrcweir 		// ist am Einfuege Punkt ein URL-Attribut? Dann das ersetzen,
3484cdf0e10cSrcweir 		// also einfach eine Selektion aufspannen?
3485cdf0e10cSrcweir 		rSh.DelINetAttrWithText();
3486cdf0e10cSrcweir 		bDDINetAttr = sal_True;
3487cdf0e10cSrcweir 	}
3488cdf0e10cSrcweir 
3489cdf0e10cSrcweir 	if ( rSrcSh.IsSelFrmMode() )
3490cdf0e10cSrcweir 	{
3491cdf0e10cSrcweir 		//Hack: Spezialbehandlung austricksen
3492cdf0e10cSrcweir 		aSttPt -= aSttPt - rSrcSh.GetObjRect().Pos();
3493cdf0e10cSrcweir 	}
3494cdf0e10cSrcweir 
3495cdf0e10cSrcweir 	sal_Bool bRet = rSrcSh.SwFEShell::Copy( &rSh, aSttPt, rDragPt, bMove,
3496cdf0e10cSrcweir 											!bIsXSelection );
3497cdf0e10cSrcweir 
3498cdf0e10cSrcweir 	if( !bIsXSelection )
3499cdf0e10cSrcweir 	{
3500cdf0e10cSrcweir 		rSrcSh.Push();
3501cdf0e10cSrcweir 		if ( bRet && bMove && !bFrmSel )
3502cdf0e10cSrcweir 		{
3503cdf0e10cSrcweir 			if ( bTblSel )
3504cdf0e10cSrcweir             {
3505cdf0e10cSrcweir                 /* #109590# delete table contents not cells */
3506cdf0e10cSrcweir 				rSrcSh.Delete();
3507cdf0e10cSrcweir             }
3508cdf0e10cSrcweir 			else
3509cdf0e10cSrcweir 			{
3510cdf0e10cSrcweir 				//SmartCut, eines der Blank mitnehmen.
3511cdf0e10cSrcweir 				rSh.SwCrsrShell::DestroyCrsr();
3512cdf0e10cSrcweir 				if ( cWord == SwWrtShell::WORD_SPACE_BEFORE )
3513cdf0e10cSrcweir 					rSh.ExtendSelection( sal_False );
3514cdf0e10cSrcweir 				else if ( cWord == SwWrtShell::WORD_SPACE_AFTER )
3515cdf0e10cSrcweir 					rSh.ExtendSelection();
3516cdf0e10cSrcweir 				rSrcSh.DelRight();
3517cdf0e10cSrcweir 			}
3518cdf0e10cSrcweir 		}
3519cdf0e10cSrcweir 		rSrcSh.KillPams();
3520cdf0e10cSrcweir 		rSrcSh.Pop( sal_False );
3521cdf0e10cSrcweir 
3522cdf0e10cSrcweir         /* #109590# after dragging a table selection inside one shell
3523cdf0e10cSrcweir             set cursor to the drop position. */
3524cdf0e10cSrcweir         if( &rSh == &rSrcSh && ( bTblSel || rSh.IsBlockMode() ) )
3525cdf0e10cSrcweir         {
3526cdf0e10cSrcweir             rSrcSh.SwCrsrShell::SetCrsr(rDragPt);
3527cdf0e10cSrcweir             rSrcSh.GetSwCrsr()->SetMark();
3528cdf0e10cSrcweir         }
3529cdf0e10cSrcweir 	}
3530cdf0e10cSrcweir 
3531cdf0e10cSrcweir 	if( bRet && !bTblSel && !bFrmSel )
3532cdf0e10cSrcweir 	{
3533cdf0e10cSrcweir 		if( (bInWrd || bEndWrd) &&
3534cdf0e10cSrcweir 			(cWord == SwWrtShell::WORD_SPACE_AFTER ||
3535cdf0e10cSrcweir 				cWord == SwWrtShell::WORD_SPACE_BEFORE) )
3536cdf0e10cSrcweir 		{
3537cdf0e10cSrcweir             if ( bSttWrd || (bInWrd && !bEndWrd))
3538cdf0e10cSrcweir 				rSh.SwEditShell::Insert(' ', bIsXSelection);
3539cdf0e10cSrcweir 			if ( !bSttWrd || (bInWrd && !bSttPara) )
3540cdf0e10cSrcweir 			{
3541cdf0e10cSrcweir 				rSh.SwapPam();
3542cdf0e10cSrcweir 				if ( !bSttWrd )
3543cdf0e10cSrcweir 					rSh.SwEditShell::Insert(' ', bIsXSelection);
3544cdf0e10cSrcweir 				rSh.SwapPam();
3545cdf0e10cSrcweir 			}
3546cdf0e10cSrcweir 		}
3547cdf0e10cSrcweir 
3548cdf0e10cSrcweir 		if( bIsXSelection )
3549cdf0e10cSrcweir 		{
3550cdf0e10cSrcweir 			if( &rSrcSh == &rSh && !rSh.IsAddMode() )
3551cdf0e10cSrcweir 			{
3552cdf0e10cSrcweir 				rSh.SwCrsrShell::DestroyCrsr();
3553cdf0e10cSrcweir 				rSh.GoPrevCrsr();
3554cdf0e10cSrcweir 			}
3555cdf0e10cSrcweir 			else
3556cdf0e10cSrcweir 			{
3557cdf0e10cSrcweir 				rSh.SwapPam();
3558cdf0e10cSrcweir 				rSh.SwCrsrShell::ClearMark();
3559cdf0e10cSrcweir 			}
3560cdf0e10cSrcweir 		}
3561cdf0e10cSrcweir 		else
3562cdf0e10cSrcweir 		{
3563cdf0e10cSrcweir 			if( rSh.IsAddMode() )
3564cdf0e10cSrcweir 				rSh.SwCrsrShell::CreateCrsr();
3565cdf0e10cSrcweir 			else
3566cdf0e10cSrcweir 			{
3567cdf0e10cSrcweir 				// Selektionsmodus einschalten
3568cdf0e10cSrcweir 				rSh.SttSelect();
3569cdf0e10cSrcweir 				rSh.EndSelect();
3570cdf0e10cSrcweir 			}
3571cdf0e10cSrcweir 		}
3572cdf0e10cSrcweir 	}
3573cdf0e10cSrcweir 
3574cdf0e10cSrcweir 	if( bRet && bMove && bFrmSel )
3575cdf0e10cSrcweir 		rSrcSh.LeaveSelFrmMode();
3576cdf0e10cSrcweir 
3577cdf0e10cSrcweir 	if( rSrcSh.GetDoc() != rSh.GetDoc() )
3578cdf0e10cSrcweir         rSrcSh.EndUndo();
3579cdf0e10cSrcweir     rSh.EndUndo();
3580cdf0e10cSrcweir 
3581cdf0e10cSrcweir 		// Shell in den richtigen Status versetzen
3582cdf0e10cSrcweir 	if( &rSrcSh != &rSh && ( rSh.IsFrmSelected() || rSh.IsObjSelected() ))
3583cdf0e10cSrcweir 		rSh.EnterSelFrmMode();
3584cdf0e10cSrcweir 
3585cdf0e10cSrcweir 	rSrcSh.EndAction();
3586cdf0e10cSrcweir 	rSh.EndAction();
3587cdf0e10cSrcweir 	return 1;
3588cdf0e10cSrcweir }
3589cdf0e10cSrcweir 
3590cdf0e10cSrcweir // Interfaces for Selection
3591cdf0e10cSrcweir void SwTransferable::CreateSelection( SwWrtShell& rSh,
3592cdf0e10cSrcweir 									  const ViewShell * _pCreatorView )
3593cdf0e10cSrcweir {
3594cdf0e10cSrcweir 	SwModule *pMod = SW_MOD();
3595cdf0e10cSrcweir 	SwTransferable* pNew = new SwTransferable( rSh );
3596cdf0e10cSrcweir 
3597cdf0e10cSrcweir 	/* #96392#*/
3598cdf0e10cSrcweir  	pNew->pCreatorView = _pCreatorView;
3599cdf0e10cSrcweir 
3600cdf0e10cSrcweir     uno::Reference<
3601cdf0e10cSrcweir             datatransfer::XTransferable > xRef( pNew );
3602cdf0e10cSrcweir 	pMod->pXSelection = pNew;
3603cdf0e10cSrcweir 	pNew->CopyToSelection( rSh.GetWin() );
3604cdf0e10cSrcweir }
3605cdf0e10cSrcweir 
3606cdf0e10cSrcweir void SwTransferable::ClearSelection( SwWrtShell& rSh,
3607cdf0e10cSrcweir 									 const ViewShell * _pCreatorView)
3608cdf0e10cSrcweir {
3609cdf0e10cSrcweir 	SwModule *pMod = SW_MOD();
3610cdf0e10cSrcweir     if( pMod->pXSelection &&
3611cdf0e10cSrcweir         ((!pMod->pXSelection->pWrtShell) || (pMod->pXSelection->pWrtShell == &rSh)) &&
3612cdf0e10cSrcweir 		/* #96392# */
3613cdf0e10cSrcweir         (!_pCreatorView || (pMod->pXSelection->pCreatorView == _pCreatorView)) )
3614cdf0e10cSrcweir 	{
3615cdf0e10cSrcweir 		TransferableHelper::ClearSelection( rSh.GetWin() );
3616cdf0e10cSrcweir 	}
3617cdf0e10cSrcweir }
3618cdf0e10cSrcweir /* -----------------3/31/2003 11:46AM----------------
3619cdf0e10cSrcweir 
3620cdf0e10cSrcweir  --------------------------------------------------*/
3621cdf0e10cSrcweir const Sequence< sal_Int8 >& SwTransferable::getUnoTunnelId()
3622cdf0e10cSrcweir {
3623cdf0e10cSrcweir     static Sequence< sal_Int8 > aSeq;
3624cdf0e10cSrcweir     if( !aSeq.getLength() )
3625cdf0e10cSrcweir     {
3626cdf0e10cSrcweir         static osl::Mutex           aCreateMutex;
3627cdf0e10cSrcweir         osl::Guard< osl::Mutex >    aGuard( aCreateMutex );
3628cdf0e10cSrcweir         aSeq.realloc( 16 );
3629cdf0e10cSrcweir         rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
3630cdf0e10cSrcweir     }
3631cdf0e10cSrcweir     return aSeq;
3632cdf0e10cSrcweir }
3633cdf0e10cSrcweir /* -----------------3/31/2003 11:46AM----------------
3634cdf0e10cSrcweir 
3635cdf0e10cSrcweir  --------------------------------------------------*/
3636cdf0e10cSrcweir sal_Int64 SwTransferable::getSomething( const Sequence< sal_Int8 >& rId ) throw( RuntimeException )
3637cdf0e10cSrcweir {
3638cdf0e10cSrcweir     sal_Int64 nRet;
3639cdf0e10cSrcweir     if( ( rId.getLength() == 16 ) &&
3640cdf0e10cSrcweir         ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
3641cdf0e10cSrcweir     {
3642cdf0e10cSrcweir         nRet = sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
3643cdf0e10cSrcweir     }
3644cdf0e10cSrcweir     else
3645cdf0e10cSrcweir         nRet = TransferableHelper::getSomething(rId);
3646cdf0e10cSrcweir     return nRet;
3647cdf0e10cSrcweir }
3648cdf0e10cSrcweir 
3649cdf0e10cSrcweir SwTransferable* SwTransferable::GetSwTransferable( const TransferableDataHelper& rData )
3650cdf0e10cSrcweir {
3651cdf0e10cSrcweir     SwTransferable* pSwTransferable = NULL;
3652cdf0e10cSrcweir 
3653cdf0e10cSrcweir     uno::Reference<XUnoTunnel> xTunnel( rData.GetTransferable(), UNO_QUERY );
3654cdf0e10cSrcweir     if ( xTunnel.is() )
3655cdf0e10cSrcweir     {
3656cdf0e10cSrcweir         sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() );
3657cdf0e10cSrcweir         if ( nHandle )
3658cdf0e10cSrcweir             pSwTransferable = (SwTransferable*) (sal_IntPtr) nHandle;
3659cdf0e10cSrcweir     }
3660cdf0e10cSrcweir 
3661cdf0e10cSrcweir     return pSwTransferable;
3662cdf0e10cSrcweir 
3663cdf0e10cSrcweir }
3664cdf0e10cSrcweir 
3665cdf0e10cSrcweir /*  */
3666cdf0e10cSrcweir 
3667cdf0e10cSrcweir // -----------------------------------------------------------------------
3668cdf0e10cSrcweir 
3669cdf0e10cSrcweir SwTrnsfrDdeLink::SwTrnsfrDdeLink( SwTransferable& rTrans, SwWrtShell& rSh )
3670cdf0e10cSrcweir     : rTrnsfr( rTrans ), pDocShell( 0 ),
3671cdf0e10cSrcweir     bDelBookmrk( sal_False ), bInDisconnect( sal_False )
3672cdf0e10cSrcweir {
3673cdf0e10cSrcweir     // hier kommen wir nur bei Tabellen- oder Text-Selection an
3674cdf0e10cSrcweir     const int nSelection = rSh.GetSelectionType();
3675cdf0e10cSrcweir     if( nsSelectionType::SEL_TBL_CELLS & nSelection )
3676cdf0e10cSrcweir     {
3677cdf0e10cSrcweir         SwFrmFmt* pFmt = rSh.GetTableFmt();
3678cdf0e10cSrcweir         if( pFmt )
3679cdf0e10cSrcweir             sName = pFmt->GetName();
3680cdf0e10cSrcweir     }
3681cdf0e10cSrcweir     else
3682cdf0e10cSrcweir     {
3683cdf0e10cSrcweir         // creating a temp. bookmark without undo
3684cdf0e10cSrcweir         sal_Bool bUndo = rSh.DoesUndo();
3685cdf0e10cSrcweir         rSh.DoUndo( sal_False );
3686cdf0e10cSrcweir         sal_Bool bIsModified = rSh.IsModified();
3687cdf0e10cSrcweir 
3688cdf0e10cSrcweir         ::sw::mark::IMark* pMark = rSh.SetBookmark(
3689cdf0e10cSrcweir             KeyCode(),
3690cdf0e10cSrcweir             ::rtl::OUString(),
3691cdf0e10cSrcweir             ::rtl::OUString(),
3692cdf0e10cSrcweir             IDocumentMarkAccess::DDE_BOOKMARK);
3693cdf0e10cSrcweir         if(pMark)
3694cdf0e10cSrcweir         {
3695cdf0e10cSrcweir             sName = pMark->GetName();
3696cdf0e10cSrcweir             bDelBookmrk = sal_True;
3697cdf0e10cSrcweir             if( !bIsModified )
3698cdf0e10cSrcweir                 rSh.ResetModified();
3699cdf0e10cSrcweir         }
3700cdf0e10cSrcweir         else
3701cdf0e10cSrcweir             sName.Erase();
3702cdf0e10cSrcweir         rSh.DoUndo( bUndo );
3703cdf0e10cSrcweir     }
3704cdf0e10cSrcweir 
3705cdf0e10cSrcweir     if( sName.Len() &&
3706cdf0e10cSrcweir         0 != ( pDocShell = rSh.GetDoc()->GetDocShell() ) )
3707cdf0e10cSrcweir     {
3708cdf0e10cSrcweir         // dann erzeugen wir uns mal unseren "Server" und connecten uns
3709cdf0e10cSrcweir         // zu diesem
3710cdf0e10cSrcweir         refObj = pDocShell->DdeCreateLinkSource( sName );
3711cdf0e10cSrcweir         if( refObj.Is() )
3712cdf0e10cSrcweir         {
3713cdf0e10cSrcweir             refObj->AddConnectAdvise( this );
3714cdf0e10cSrcweir             refObj->AddDataAdvise( this,
3715cdf0e10cSrcweir //                          SotExchange::GetFormatMimeType( FORMAT_RTF ),
3716cdf0e10cSrcweir                             aEmptyStr,
3717cdf0e10cSrcweir                             ADVISEMODE_NODATA | ADVISEMODE_ONLYONCE );
3718cdf0e10cSrcweir             nOldTimeOut = refObj->GetUpdateTimeout();
3719cdf0e10cSrcweir             refObj->SetUpdateTimeout( 0 );
3720cdf0e10cSrcweir         }
3721cdf0e10cSrcweir     }
3722cdf0e10cSrcweir }
3723cdf0e10cSrcweir 
3724cdf0e10cSrcweir // -----------------------------------------------------------------------
3725cdf0e10cSrcweir 
3726cdf0e10cSrcweir SwTrnsfrDdeLink::~SwTrnsfrDdeLink()
3727cdf0e10cSrcweir {
3728cdf0e10cSrcweir 	if( refObj.Is() )
3729cdf0e10cSrcweir 		Disconnect( sal_True );
3730cdf0e10cSrcweir }
3731cdf0e10cSrcweir 
3732cdf0e10cSrcweir // -----------------------------------------------------------------------
3733cdf0e10cSrcweir 
3734cdf0e10cSrcweir void SwTrnsfrDdeLink::DataChanged( const String& ,
3735cdf0e10cSrcweir                                     const uno::Any& )
3736cdf0e10cSrcweir {
3737cdf0e10cSrcweir 	// tja das wars dann mit dem Link
3738cdf0e10cSrcweir 	if( !bInDisconnect )
3739cdf0e10cSrcweir 	{
3740cdf0e10cSrcweir 		if( FindDocShell() && pDocShell->GetView() )
3741cdf0e10cSrcweir 			rTrnsfr.RemoveDDELinkFormat( pDocShell->GetView()->GetEditWin() );
3742cdf0e10cSrcweir 		Disconnect( sal_False );
3743cdf0e10cSrcweir 	}
3744cdf0e10cSrcweir }
3745cdf0e10cSrcweir 
3746cdf0e10cSrcweir // -----------------------------------------------------------------------
3747cdf0e10cSrcweir 
3748cdf0e10cSrcweir sal_Bool SwTrnsfrDdeLink::WriteData( SvStream& rStrm )
3749cdf0e10cSrcweir {
3750cdf0e10cSrcweir     if( !refObj.Is() || !FindDocShell() )
3751cdf0e10cSrcweir         return sal_False;
3752cdf0e10cSrcweir 
3753cdf0e10cSrcweir     rtl_TextEncoding eEncoding = DDE_TXT_ENCODING;
3754cdf0e10cSrcweir     const ByteString aAppNm( GetpApp()->GetAppName(), eEncoding );
3755cdf0e10cSrcweir     const ByteString aTopic( pDocShell->GetTitle( SFX_TITLE_FULLNAME ),
3756cdf0e10cSrcweir                             eEncoding );
3757cdf0e10cSrcweir     const ByteString aName( sName, eEncoding );
3758cdf0e10cSrcweir 
3759cdf0e10cSrcweir     sal_Char* pMem = new char[ aAppNm.Len() + aTopic.Len() + aName.Len() + 4 ];
3760cdf0e10cSrcweir 
3761cdf0e10cSrcweir     xub_StrLen nLen = aAppNm.Len();
3762cdf0e10cSrcweir     memcpy( pMem, aAppNm.GetBuffer(), nLen );
3763cdf0e10cSrcweir     pMem[ nLen++ ] = 0;
3764cdf0e10cSrcweir     memcpy( pMem + nLen, aTopic.GetBuffer(), aTopic.Len() );
3765cdf0e10cSrcweir     nLen = nLen + aTopic.Len();
3766cdf0e10cSrcweir     pMem[ nLen++ ] = 0;
3767cdf0e10cSrcweir     memcpy( pMem + nLen, aName.GetBuffer(), aName.Len() );
3768cdf0e10cSrcweir     nLen = nLen + aName.Len();
3769cdf0e10cSrcweir     pMem[ nLen++ ] = 0;
3770cdf0e10cSrcweir     pMem[ nLen++ ] = 0;
3771cdf0e10cSrcweir 
3772cdf0e10cSrcweir     rStrm.Write( pMem, nLen );
3773cdf0e10cSrcweir     delete[] pMem;
3774cdf0e10cSrcweir 
3775cdf0e10cSrcweir     IDocumentMarkAccess* const pMarkAccess = pDocShell->GetDoc()->getIDocumentMarkAccess();
3776cdf0e10cSrcweir     IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName);
3777cdf0e10cSrcweir     if(ppMark != pMarkAccess->getMarksEnd()
3778cdf0e10cSrcweir         && IDocumentMarkAccess::GetType(**ppMark) != IDocumentMarkAccess::BOOKMARK)
3779cdf0e10cSrcweir     {
3780cdf0e10cSrcweir         // the mark is still a DdeBookmark
3781cdf0e10cSrcweir         // we replace it with a Bookmark, so it will get saved etc.
3782cdf0e10cSrcweir         ::sw::mark::IMark* const pMark = ppMark->get();
3783cdf0e10cSrcweir         SwServerObject* const pServerObject = dynamic_cast<SwServerObject *>(&refObj);
3784cdf0e10cSrcweir 
3785cdf0e10cSrcweir         // collecting state of old mark
3786cdf0e10cSrcweir         SwPaM aPaM(pMark->GetMarkStart());
3787cdf0e10cSrcweir         *aPaM.GetPoint() = pMark->GetMarkStart();
3788cdf0e10cSrcweir         if(pMark->IsExpanded())
3789cdf0e10cSrcweir         {
3790cdf0e10cSrcweir             aPaM.SetMark();
3791cdf0e10cSrcweir             *aPaM.GetMark() = pMark->GetMarkEnd();
3792cdf0e10cSrcweir         }
3793cdf0e10cSrcweir         ::rtl::OUString sMarkName = pMark->GetName();
3794cdf0e10cSrcweir 
3795cdf0e10cSrcweir         // remove mark
3796cdf0e10cSrcweir         pServerObject->SetNoServer(); // this removes the connection between SwServerObject and mark
3797cdf0e10cSrcweir         // N.B. ppMark was not loaded from file and cannot have xml:id
3798cdf0e10cSrcweir         pMarkAccess->deleteMark(ppMark);
3799cdf0e10cSrcweir 
3800cdf0e10cSrcweir         // recreate as Bookmark
3801cdf0e10cSrcweir         ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark(
3802cdf0e10cSrcweir             aPaM,
3803cdf0e10cSrcweir             sMarkName,
3804cdf0e10cSrcweir             IDocumentMarkAccess::BOOKMARK);
3805cdf0e10cSrcweir         pServerObject->SetDdeBookmark(*pNewMark);
3806cdf0e10cSrcweir     }
3807cdf0e10cSrcweir 
3808cdf0e10cSrcweir     bDelBookmrk = false;
3809cdf0e10cSrcweir     return true;
3810cdf0e10cSrcweir }
3811cdf0e10cSrcweir 
3812cdf0e10cSrcweir // -----------------------------------------------------------------------
3813cdf0e10cSrcweir 
3814cdf0e10cSrcweir void SwTrnsfrDdeLink::Disconnect( sal_Bool bRemoveDataAdvise )
3815cdf0e10cSrcweir {
3816*b0b7a757SOliver-Rainer Wittmann     //JP 29.01.96 Bug 24432:
3817*b0b7a757SOliver-Rainer Wittmann     //		kein DataChanged mehr entgegen nehmen, wenn man
3818*b0b7a757SOliver-Rainer Wittmann     //		sich schon im Disconnet befindet!
3819*b0b7a757SOliver-Rainer Wittmann     // 		(DTOR vom Bookmark verschickt einen DataChanged!)
3820*b0b7a757SOliver-Rainer Wittmann     const sal_Bool bOldDisconnect = bInDisconnect;
3821*b0b7a757SOliver-Rainer Wittmann     bInDisconnect = sal_True;
3822*b0b7a757SOliver-Rainer Wittmann 
3823*b0b7a757SOliver-Rainer Wittmann     // den nicht verwendeten Bookmark wieder zerstoeren (ohne Undo!)?
3824*b0b7a757SOliver-Rainer Wittmann     if( bDelBookmrk && refObj.Is() && FindDocShell() )
3825*b0b7a757SOliver-Rainer Wittmann     {
3826*b0b7a757SOliver-Rainer Wittmann         SwDoc* pDoc = pDocShell->GetDoc();
3827cdf0e10cSrcweir         ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
3828cdf0e10cSrcweir 
3829cdf0e10cSrcweir         // --> OD, CD, OS 2005-11-25 #i58448#
3830cdf0e10cSrcweir         Link aSavedOle2Link( pDoc->GetOle2Link() );
3831cdf0e10cSrcweir         pDoc->SetOle2Link( Link() );
3832cdf0e10cSrcweir         // <--
3833cdf0e10cSrcweir         sal_Bool bIsModified = pDoc->IsModified();
3834cdf0e10cSrcweir 
3835cdf0e10cSrcweir         IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
3836*b0b7a757SOliver-Rainer Wittmann         // check, if DdeBookmark is already in its desctruction
3837*b0b7a757SOliver-Rainer Wittmann         IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName);
3838*b0b7a757SOliver-Rainer Wittmann         if ( ppMark != pMarkAccess->getMarksEnd() )
3839*b0b7a757SOliver-Rainer Wittmann         {
3840*b0b7a757SOliver-Rainer Wittmann             ::sw::mark::DdeBookmark* const pDdeBookmark = dynamic_cast< ::sw::mark::DdeBookmark* >(ppMark->get());
3841*b0b7a757SOliver-Rainer Wittmann             if ( pDdeBookmark && !pDdeBookmark->IsInDestruction() )
3842*b0b7a757SOliver-Rainer Wittmann             {
3843*b0b7a757SOliver-Rainer Wittmann                 pMarkAccess->deleteMark(ppMark);
3844*b0b7a757SOliver-Rainer Wittmann             }
3845*b0b7a757SOliver-Rainer Wittmann         }
3846cdf0e10cSrcweir 
3847*b0b7a757SOliver-Rainer Wittmann         if( !bIsModified )
3848*b0b7a757SOliver-Rainer Wittmann             pDoc->ResetModified();
3849cdf0e10cSrcweir         pDoc->SetOle2Link( aSavedOle2Link );
3850cdf0e10cSrcweir 
3851*b0b7a757SOliver-Rainer Wittmann         bDelBookmrk = sal_False;
3852*b0b7a757SOliver-Rainer Wittmann     }
3853cdf0e10cSrcweir 
3854*b0b7a757SOliver-Rainer Wittmann     if( refObj.Is() )
3855*b0b7a757SOliver-Rainer Wittmann     {
3856*b0b7a757SOliver-Rainer Wittmann         refObj->SetUpdateTimeout( nOldTimeOut );
3857*b0b7a757SOliver-Rainer Wittmann         refObj->RemoveConnectAdvise( this );
3858*b0b7a757SOliver-Rainer Wittmann         if( bRemoveDataAdvise )
3859*b0b7a757SOliver-Rainer Wittmann             // in einem DataChanged darf das SelectionObject NIE geloescht
3860*b0b7a757SOliver-Rainer Wittmann             // werden; wird schon von der Basisklasse erledigt
3861*b0b7a757SOliver-Rainer Wittmann             // (ADVISEMODE_ONLYONCE!!!!)
3862*b0b7a757SOliver-Rainer Wittmann             // Im normalen Disconnet aber schon!
3863*b0b7a757SOliver-Rainer Wittmann             refObj->RemoveAllDataAdvise( this );
3864*b0b7a757SOliver-Rainer Wittmann         refObj.Clear();
3865*b0b7a757SOliver-Rainer Wittmann     }
3866*b0b7a757SOliver-Rainer Wittmann     bInDisconnect = bOldDisconnect;
3867cdf0e10cSrcweir }
3868cdf0e10cSrcweir 
3869cdf0e10cSrcweir // -----------------------------------------------------------------------
3870cdf0e10cSrcweir 
3871cdf0e10cSrcweir sal_Bool SwTrnsfrDdeLink::FindDocShell()
3872cdf0e10cSrcweir {
3873cdf0e10cSrcweir 	TypeId aType( TYPE( SwDocShell ) );
3874cdf0e10cSrcweir 	SfxObjectShell* pTmpSh = SfxObjectShell::GetFirst( &aType );
3875cdf0e10cSrcweir 	while( pTmpSh )
3876cdf0e10cSrcweir 	{
3877cdf0e10cSrcweir 		if( pTmpSh == pDocShell )		// die wollen wir haben
3878cdf0e10cSrcweir 		{
3879cdf0e10cSrcweir 			if( pDocShell->GetDoc() )
3880cdf0e10cSrcweir 				return sal_True;
3881cdf0e10cSrcweir 			break;		// das Doc ist nicht mehr vorhanden, also raus!
3882cdf0e10cSrcweir 		}
3883cdf0e10cSrcweir 		pTmpSh = SfxObjectShell::GetNext( *pTmpSh, &aType );
3884cdf0e10cSrcweir 	}
3885cdf0e10cSrcweir 
3886cdf0e10cSrcweir 	pDocShell = 0;
3887cdf0e10cSrcweir 	return sal_False;
3888cdf0e10cSrcweir }
3889cdf0e10cSrcweir 
3890cdf0e10cSrcweir // -----------------------------------------------------------------------
3891cdf0e10cSrcweir 
3892cdf0e10cSrcweir void SwTrnsfrDdeLink::Closed()
3893cdf0e10cSrcweir {
3894cdf0e10cSrcweir 	if( !bInDisconnect && refObj.Is() )
3895cdf0e10cSrcweir 	{
3896cdf0e10cSrcweir 		refObj->RemoveAllDataAdvise( this );
3897cdf0e10cSrcweir 		refObj->RemoveConnectAdvise( this );
3898cdf0e10cSrcweir 		refObj.Clear();
3899cdf0e10cSrcweir 	}
3900cdf0e10cSrcweir }
3901