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