xref: /aoo42x/main/sd/source/ui/view/sdview3.cxx (revision 45fd3b9a)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sd.hxx"
24 
25 #include "View.hxx"
26 #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
27 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
28 #include <com/sun/star/lang/XComponent.hpp>
29 #include <sot/filelist.hxx>
30 #include <unotools/pathoptions.hxx>
31 #include <editeng/editdata.hxx>
32 #include <svl/urlbmk.hxx>
33 #include <svx/xexch.hxx>
34 #include <svx/xflclit.hxx>
35 #include <svx/xlnclit.hxx>
36 #include <svx/svdpagv.hxx>
37 #include <editeng/eeitem.hxx>
38 #include <editeng/colritem.hxx>
39 #include <sfx2/docfile.hxx>
40 #include <svx/svditer.hxx>
41 #include <svx/svdogrp.hxx>
42 #include <svx/svdoole2.hxx>
43 #include <svx/svdograf.hxx>
44 #include <svx/svdetc.hxx>
45 #include <svx/svdundo.hxx>
46 #include <sfx2/app.hxx>
47 #include <svl/itempool.hxx>
48 #include <sot/clsids.hxx>
49 #include <svx/fmmodel.hxx>
50 #include <sot/formats.hxx>
51 #include <editeng/outliner.hxx>
52 #include <editeng/editeng.hxx>
53 #include <svx/obj3d.hxx>
54 #include <svx/e3dundo.hxx>
55 #include <svx/dbexch.hrc>
56 #include <svx/unomodel.hxx>
57 #include <unotools/streamwrap.hxx>
58 #include <vcl/metaact.hxx>
59 #include <svx/svxids.hrc>
60 #include <toolkit/helper/vclunohelper.hxx>
61 #include "DrawDocShell.hxx"
62 #include "fupoor.hxx"
63 #include "Window.hxx"
64 #include "sdxfer.hxx"
65 #include "sdpage.hxx"
66 #include "DrawViewShell.hxx"
67 #include "drawdoc.hxx"
68 #include "sdresid.hxx"
69 #include "strings.hrc"
70 #include "imapinfo.hxx"
71 #include "SlideSorterViewShell.hxx"
72 #include "strmname.h"
73 #include "unomodel.hxx"
74 #include "ViewClipboard.hxx"
75 #include <sfx2/ipclient.hxx>
76 #include <comphelper/storagehelper.hxx>
77 #include <comphelper/processfactory.hxx>
78 #include <tools/stream.hxx>
79 #include <vcl/cvtgrf.hxx>
80 #include <svx/sdrhittesthelper.hxx>
81 #include <svx/xbtmpit.hxx>
82 
83 // --------------
84 // - Namespaces -
85 // --------------
86 
87 using namespace ::com::sun::star;
88 using namespace ::com::sun::star::lang;
89 using namespace ::com::sun::star::uno;
90 using namespace ::com::sun::star::io;
91 using namespace ::com::sun::star::datatransfer;
92 using namespace ::com::sun::star::datatransfer::clipboard;
93 
94 namespace sd {
95 
96 #define CHECK_FORMAT_TRANS( _def_Type ) ( ( nFormat == (_def_Type) || !nFormat ) && aDataHelper.HasFormat( _def_Type ) )
97 
98 /*************************************************************************
99 |*
100 |* Paste
101 |*
102 \************************************************************************/
103 
104 // #83525#
105 struct ImpRememberOrigAndClone
106 {
107 	SdrObject*		pOrig;
108 	SdrObject*		pClone;
109 };
110 
111 SdrObject* ImpGetClone(Container& aConnectorContainer, SdrObject* pConnObj)
112 {
113 	for(sal_uInt32 a(0); a < aConnectorContainer.Count(); a++)
114 	{
115 		if(pConnObj == ((ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a))->pOrig)
116 			return ((ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a))->pClone;
117 	}
118 	return 0L;
119 }
120 
121 // #90129# restrict movement to WorkArea
122 void ImpCheckInsertPos(Point& rPos, const Size& rSize, const Rectangle& rWorkArea)
123 {
124 	if(!rWorkArea.IsEmpty())
125 	{
126 		Rectangle aMarkRect(Point(rPos.X() - (rSize.Width() / 2), rPos.Y() - (rSize.Height() / 2)), rSize);
127 
128 		if(!aMarkRect.IsInside(rWorkArea))
129 		{
130 			if(aMarkRect.Left() < rWorkArea.Left())
131 			{
132 				rPos.X() += rWorkArea.Left() - aMarkRect.Left();
133 			}
134 
135 			if(aMarkRect.Right() > rWorkArea.Right())
136 			{
137 				rPos.X() -= aMarkRect.Right() - rWorkArea.Right();
138 			}
139 
140 			if(aMarkRect.Top() < rWorkArea.Top())
141 			{
142 				rPos.Y() += rWorkArea.Top() - aMarkRect.Top();
143 			}
144 
145 			if(aMarkRect.Bottom() > rWorkArea.Bottom())
146 			{
147 				rPos.Y() -= aMarkRect.Bottom() - rWorkArea.Bottom();
148 			}
149 		}
150 	}
151 }
152 
153 bool View::InsertMetaFile( TransferableDataHelper& rDataHelper, const Point& rPos, ImageMap* pImageMap, bool bOptimize )
154 {
155 	GDIMetaFile aMtf;
156 
157 	if( !rDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) )
158 		return false;
159 
160 /*
161 SvFileStream	aSvOutputStream( String( RTL_CONSTASCII_USTRINGPARAM( "/tmp/test.png" ) ), STREAM_WRITE | STREAM_TRUNC );
162 Graphic			aMtfGraphic( aMtf );
163 Size			aPreviewSizePixel( OutputDevice::LogicToLogic( aMtf.GetPrefSize(), aMtf.GetPrefMapMode(), MAP_PIXEL ) );
164 
165 if( aPreviewSizePixel.Width() && aPreviewSizePixel.Height() )
166 {
167 	const double fWH = static_cast< double >( aPreviewSizePixel.Width() ) / static_cast< double >( aPreviewSizePixel.Height() );
168 
169 	if( fWH <= 1.0 )
170 		aPreviewSizePixel.Width() = static_cast< long >( 128.0 * fWH ), aPreviewSizePixel.Height() = 128;
171 	else
172 		aPreviewSizePixel.Width() = 128, aPreviewSizePixel.Height() = static_cast< long >( 128.0 / fWH );
173 
174 	if( GraphicConverter::Export( aSvOutputStream, aMtfGraphic.GetBitmapEx( &aPreviewSizePixel ), CVT_PNG ) )
175 	{
176 		// handle errror case here
177 	}
178 	else
179 	{
180 		// Success
181 	}
182 }
183 */
184 	bool bVector = false;
185 	Graphic aGraphic;
186 
187 	// check if metafile only contains a pixel image, if so insert a bitmap instead
188 	if( bOptimize )
189 	{
190 		MetaAction* pAction = aMtf.FirstAction();
191 		while( pAction && !bVector )
192 		{
193 			switch( pAction->GetType() )
194 			{
195 				case META_POINT_ACTION:
196 				case META_LINE_ACTION:
197 				case META_RECT_ACTION:
198 				case META_ROUNDRECT_ACTION:
199 				case META_ELLIPSE_ACTION:
200 				case META_ARC_ACTION:
201 				case META_PIE_ACTION:
202 				case META_CHORD_ACTION:
203 				case META_POLYLINE_ACTION:
204 				case META_POLYGON_ACTION:
205 				case META_POLYPOLYGON_ACTION:
206 				case META_TEXT_ACTION:
207 				case META_TEXTARRAY_ACTION:
208 				case META_STRETCHTEXT_ACTION:
209 				case META_TEXTRECT_ACTION:
210 				case META_GRADIENT_ACTION:
211 				case META_HATCH_ACTION:
212 				case META_WALLPAPER_ACTION:
213 				case META_EPS_ACTION:
214 				case META_TEXTLINE_ACTION:
215 				case META_FLOATTRANSPARENT_ACTION:
216 				case META_GRADIENTEX_ACTION:
217 				case META_BMPSCALEPART_ACTION:
218 				case META_BMPEXSCALEPART_ACTION:
219 					bVector = true;
220 					break;
221 				case META_BMP_ACTION:
222 				case META_BMPSCALE_ACTION:
223 				case META_BMPEX_ACTION:
224 				case META_BMPEXSCALE_ACTION:
225 					if( aGraphic.GetType() != GRAPHIC_NONE )
226 					{
227 						bVector = true;
228 					}
229 					else switch( pAction->GetType() )
230 					{
231 						case META_BMP_ACTION:
232 							{
233 								MetaBmpAction* pBmpAction = dynamic_cast< MetaBmpAction* >( pAction );
234 								if( pBmpAction )
235 									aGraphic = Graphic( pBmpAction->GetBitmap() );
236 							}
237 							break;
238 						case META_BMPSCALE_ACTION:
239 							{
240 								MetaBmpScaleAction* pBmpScaleAction = dynamic_cast< MetaBmpScaleAction* >( pAction );
241 								if( pBmpScaleAction )
242 									aGraphic = Graphic( pBmpScaleAction->GetBitmap() );
243 							}
244 							break;
245 						case META_BMPEX_ACTION:
246 							{
247 								MetaBmpExAction* pBmpExAction = dynamic_cast< MetaBmpExAction* >( pAction );
248 								if( pBmpExAction )
249 									aGraphic = Graphic( pBmpExAction->GetBitmapEx() );
250 							}
251 							break;
252 						case META_BMPEXSCALE_ACTION:
253 							{
254 								MetaBmpExScaleAction* pBmpExScaleAction = dynamic_cast< MetaBmpExScaleAction* >( pAction );
255 								if( pBmpExScaleAction )
256 									aGraphic = Graphic( pBmpExScaleAction->GetBitmapEx() );
257 							}
258 							break;
259 					}
260 			}
261 
262 			pAction = aMtf.NextAction();
263 		}
264 	}
265 
266 	// it is not a vector metafile but it also has no graphic?
267 	if( !bVector && (aGraphic.GetType() == GRAPHIC_NONE) )
268 		bVector = true;
269 
270 	// #90129# restrict movement to WorkArea
271 	Point aInsertPos( rPos );
272 	Size aImageSize;
273 	aImageSize = bVector ? aMtf.GetPrefSize() : aGraphic.GetSizePixel();
274 	ImpCheckInsertPos(aInsertPos, aImageSize, GetWorkArea());
275 
276 	if( bVector )
277 		aGraphic = Graphic( aMtf );
278 
279 	aGraphic.SetPrefMapMode( aMtf.GetPrefMapMode() );
280 	aGraphic.SetPrefSize( aMtf.GetPrefSize() );
281 	InsertGraphic( aGraphic, mnAction, aInsertPos, NULL, pImageMap );
282 
283 	return true;
284 }
285 
286 sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper,
287 						 const Point& rPos, sal_Int8& rDnDAction, sal_Bool bDrag,
288 						 sal_uLong nFormat, sal_uInt16 nPage, sal_uInt16 nLayer )
289 {
290 	maDropPos = rPos;
291 	mnAction = rDnDAction;
292 	mbIsDropAllowed = sal_False;
293 
294 	TransferableDataHelper	aDataHelper( rDataHelper );
295 	SdrObject*				pPickObj = NULL;
296 	SdPage*					pPage = NULL;
297 	ImageMap*				pImageMap = NULL;
298 	sal_Bool					bReturn = sal_False;
299 	sal_Bool					bLink = ( ( mnAction & DND_ACTION_LINK ) != 0 );
300 	sal_Bool					bCopy = ( ( ( mnAction & DND_ACTION_COPY ) != 0 ) || bLink );
301 	sal_uLong					nPasteOptions = SDRINSERT_SETDEFLAYER;
302 
303     if (mpViewSh != NULL)
304     {
305         OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
306         SfxInPlaceClient* pIpClient = mpViewSh->GetViewShell()->GetIPClient();
307         if( mpViewSh->ISA(::sd::slidesorter::SlideSorterViewShell)
308             || (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive()))
309         nPasteOptions |= SDRINSERT_DONTMARK;
310     }
311 
312 	if( bDrag )
313 	{
314 		SdrPageView* pPV = NULL;
315 		PickObj( rPos, getHitTolLog(), pPickObj, pPV );
316 	}
317 
318 	if( nPage != SDRPAGE_NOTFOUND )
319 		pPage = (SdPage*) mpDoc->GetPage( nPage );
320 
321 	SdTransferable* pOwnData = NULL;
322     SdTransferable* pImplementation = SdTransferable::getImplementation( aDataHelper.GetTransferable() );
323 
324 	// try to get own transfer data
325 	if( pImplementation )
326 	{
327 		if( SD_MOD()->pTransferClip == (SdTransferable*) pImplementation )
328 			pOwnData = SD_MOD()->pTransferClip;
329 		else if( SD_MOD()->pTransferDrag == (SdTransferable*) pImplementation )
330 			pOwnData = SD_MOD()->pTransferDrag;
331 		else if( SD_MOD()->pTransferSelection == (SdTransferable*) pImplementation )
332 			pOwnData = SD_MOD()->pTransferSelection;
333 	}
334 
335 	// ImageMap?
336 	if( !pOwnData && aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVIM ) )
337 	{
338 		SotStorageStreamRef xStm;
339 
340 		if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVIM, xStm ) )
341 		{
342 			pImageMap = new ImageMap;
343             // mba: clipboard always must contain absolute URLs (could be from alien source)
344             pImageMap->Read( *xStm, String() );
345 		}
346 	}
347 
348 	bool bTable = false;
349 	// check special cases for pasting table formats as RTL
350 	if( !bLink && (!nFormat || (nFormat == SOT_FORMAT_RTF)) )
351 	{
352 		// if the objekt supports rtf and there is a table involved, default is to create a table
353 		if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) && ! aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
354 		{
355 			SotStorageStreamRef xStm;
356 
357 			if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
358 			{
359 				xStm->Seek( 0 );
360 
361 				ByteString aLine;
362 				while( xStm->ReadLine(aLine) )
363 				{
364 					xub_StrLen x = aLine.Search( "\\trowd" );
365 					if( x != STRING_NOTFOUND )
366 					{
367 						bTable = true;
368 						nFormat = FORMAT_RTF;
369 						break;
370 					}
371 				}
372 			}
373 		}
374 	}
375 
376 	if( pOwnData && !nFormat )
377 	{
378 		const View* pSourceView = pOwnData->GetView();
379 
380 
381         if( pOwnData->GetDocShell() && pOwnData->IsPageTransferable() && ISA( View ) )
382 		{
383             mpClipboard->HandlePageDrop (*pOwnData);
384 		}
385         else if( pSourceView )
386 		{
387 			if( pSourceView == this )
388 			{
389 				// same view
390 				if( nLayer != SDRLAYER_NOTFOUND )
391 				{
392 					// drop on layer tab bar
393 					SdrLayerAdmin&	rLayerAdmin = mpDoc->GetLayerAdmin();
394 					SdrLayer*		pLayer = rLayerAdmin.GetLayerPerID( nLayer );
395 					SdrPageView*	pPV = GetSdrPageView();
396 					String			aLayer( pLayer->GetName() );
397 
398 					if( !pPV->IsLayerLocked( aLayer ) )
399 					{
400 						pOwnData->SetInternalMove( sal_True );
401 						SortMarkedObjects();
402 
403 						for( sal_uLong nM = 0; nM < GetMarkedObjectCount(); nM++ )
404 						{
405 							SdrMark*	pM = GetSdrMarkByIndex( nM );
406 							SdrObject*	pO = pM->GetMarkedSdrObj();
407 
408 							if( pO )
409 							{
410 								// #i11702#
411 								if( IsUndoEnabled() )
412 								{
413 									BegUndo(String(SdResId(STR_MODIFYLAYER)));
414 									AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), (SdrLayerID)nLayer));
415 									EndUndo();
416 								}
417 
418 								pO->SetLayer( (SdrLayerID) nLayer );
419 							}
420 						}
421 
422 						bReturn = sal_True;
423 					}
424 				}
425 				else
426 				{
427 					SdrPageView*	pPV = GetSdrPageView();
428 					sal_Bool			bDropOnTabBar = sal_True;
429 
430 					if( !pPage && pPV->GetPage()->GetPageNum() != mnDragSrcPgNum )
431 					{
432 						pPage = (SdPage*) pPV->GetPage();
433 						bDropOnTabBar = sal_False;
434 					}
435 
436 					if( pPage )
437 					{
438 						// drop on other page
439 						String aActiveLayer( GetActiveLayer() );
440 
441 						if( !pPV->IsLayerLocked( aActiveLayer ) )
442 						{
443 							if( !IsPresObjSelected() )
444 							{
445 								SdrMarkList* pMarkList;
446 
447 								if( (mnDragSrcPgNum != SDRPAGE_NOTFOUND) && (mnDragSrcPgNum != pPV->GetPage()->GetPageNum()) )
448 								{
449 									pMarkList = mpDragSrcMarkList;
450 								}
451 								else
452 								{
453 									// actual mark list is used
454 									pMarkList = new SdrMarkList( GetMarkedObjectList());
455 								}
456 
457 								pMarkList->ForceSort();
458 
459 								// #83525# stuff to remember originals and clones
460 								Container	aConnectorContainer(0);
461 								sal_uInt32	a, nConnectorCount(0L);
462 								Point		aCurPos;
463 
464 								// calculate real position of current
465 								// source objects, if necessary (#103207)
466 								if( pOwnData == SD_MOD()->pTransferSelection )
467 								{
468 									Rectangle aCurBoundRect;
469 
470 									if( pMarkList->TakeBoundRect( pPV, aCurBoundRect ) )
471 										aCurPos = aCurBoundRect.TopLeft();
472 									else
473 										aCurPos = pOwnData->GetStartPos();
474 								}
475 								else
476 									aCurPos = pOwnData->GetStartPos();
477 
478 								const Size aVector( maDropPos.X() - aCurPos.X(), maDropPos.Y() - aCurPos.Y() );
479 
480 								for(a = 0; a < pMarkList->GetMarkCount(); a++)
481 								{
482 									SdrMark* pM = pMarkList->GetMark(a);
483 									SdrObject* pObj = pM->GetMarkedSdrObj()->Clone();
484 
485 									if(pObj)
486 									{
487 										if(!bDropOnTabBar)
488 										{
489 											// #83525# do a NbcMove(...) instead of setting SnapRects here
490 											pObj->NbcMove(aVector);
491 										}
492 
493 										pPage->InsertObject(pObj);
494 
495 										if( IsUndoEnabled() )
496 										{
497 											BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
498 											AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
499 											EndUndo();
500 										}
501 
502 										// #83525#
503 										ImpRememberOrigAndClone* pRem = new ImpRememberOrigAndClone;
504 										pRem->pOrig = pM->GetMarkedSdrObj();
505 										pRem->pClone = pObj;
506 										aConnectorContainer.Insert(pRem, CONTAINER_APPEND);
507 
508 										if(pObj->ISA(SdrEdgeObj))
509 											nConnectorCount++;
510 									}
511 								}
512 
513 								// #83525# try to re-establish connections at clones
514 								if(nConnectorCount)
515 								{
516 									for(a = 0; a < aConnectorContainer.Count(); a++)
517 									{
518 										ImpRememberOrigAndClone* pRem = (ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a);
519 
520 										if(pRem->pClone->ISA(SdrEdgeObj))
521 										{
522 											SdrEdgeObj* pOrigEdge = (SdrEdgeObj*)pRem->pOrig;
523 											SdrEdgeObj* pCloneEdge = (SdrEdgeObj*)pRem->pClone;
524 
525 											// test first connection
526 											SdrObjConnection& rConn0 = pOrigEdge->GetConnection(sal_False);
527 											SdrObject* pConnObj = rConn0.GetObject();
528 											if(pConnObj)
529 											{
530 												SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
531 												if(pConnClone)
532 												{
533 													// if dest obj was cloned, too, re-establish connection
534 													pCloneEdge->ConnectToNode(sal_False, pConnClone);
535 													pCloneEdge->GetConnection(sal_False).SetConnectorId(rConn0.GetConnectorId());
536 												}
537 												else
538 												{
539 													// set position of connection point of original connected object
540 													const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
541 													if(pGlueList)
542 													{
543 														sal_uInt16 nInd = pGlueList->FindGluePoint(rConn0.GetConnectorId());
544 
545 														if(SDRGLUEPOINT_NOTFOUND != nInd)
546 														{
547 															const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
548 															Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
549 															aPosition.X() += aVector.A();
550 															aPosition.Y() += aVector.B();
551 															pCloneEdge->SetTailPoint(sal_False, aPosition);
552 														}
553 													}
554 												}
555 											}
556 
557 											// test second connection
558 											SdrObjConnection& rConn1 = pOrigEdge->GetConnection(sal_True);
559 											pConnObj = rConn1.GetObject();
560 											if(pConnObj)
561 											{
562 												SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
563 												if(pConnClone)
564 												{
565 													// if dest obj was cloned, too, re-establish connection
566 													pCloneEdge->ConnectToNode(sal_True, pConnClone);
567 													pCloneEdge->GetConnection(sal_True).SetConnectorId(rConn1.GetConnectorId());
568 												}
569 												else
570 												{
571 													// set position of connection point of original connected object
572 													const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
573 													if(pGlueList)
574 													{
575 														sal_uInt16 nInd = pGlueList->FindGluePoint(rConn1.GetConnectorId());
576 
577 														if(SDRGLUEPOINT_NOTFOUND != nInd)
578 														{
579 															const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
580 															Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
581 															aPosition.X() += aVector.A();
582 															aPosition.Y() += aVector.B();
583 															pCloneEdge->SetTailPoint(sal_True, aPosition);
584 														}
585 													}
586 												}
587 											}
588 										}
589 									}
590 								}
591 
592 								// #83525# cleanup remember classes
593 								for(a = 0; a < aConnectorContainer.Count(); a++)
594 									delete (ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a);
595 
596 								if( pMarkList != mpDragSrcMarkList )
597 									delete pMarkList;
598 
599 								bReturn = sal_True;
600 							}
601 							else
602 							{
603 								maDropErrorTimer.Start();
604 								bReturn = sal_False;
605 							}
606 						}
607 					}
608 					else
609 					{
610 						pOwnData->SetInternalMove( sal_True );
611 						MoveAllMarked( Size( maDropPos.X() - pOwnData->GetStartPos().X(),
612 											 maDropPos.Y() - pOwnData->GetStartPos().Y() ), bCopy );
613 						bReturn = sal_True;
614 					}
615 				}
616 			}
617 			else
618 			{
619 				// different views
620 				if( !pSourceView->IsPresObjSelected() )
621 				{
622 					// model is owned by from AllocModel() created DocShell
623 					SdDrawDocument* pSourceDoc = (SdDrawDocument*) pSourceView->GetModel();
624 					pSourceDoc->CreatingDataObj( pOwnData );
625 					SdDrawDocument* pModel = (SdDrawDocument*) pSourceView->GetAllMarkedModel();
626 					bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
627 
628 					if( !pPage )
629 						pPage = (SdPage*) GetSdrPageView()->GetPage();
630 
631 					String aLayout( pPage->GetLayoutName() );
632 					aLayout.Erase( aLayout.SearchAscii( SD_LT_SEPARATOR ) );
633 					pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
634 					pSourceDoc->CreatingDataObj( NULL );
635 				}
636 				else
637 				{
638 					maDropErrorTimer.Start();
639 					bReturn = sal_False;
640 				}
641 			}
642 		}
643 		else
644 		{
645 		    SdDrawDocument*	pWorkModel = (SdDrawDocument*) pOwnData->GetWorkDocument();
646 		    SdPage*			pWorkPage = (SdPage*) pWorkModel->GetSdPage( 0, PK_STANDARD );
647 
648 		    pWorkPage->SetRectsDirty();
649 
650             // #120393# Clipboard data uses full object geometry range
651 		    const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
652 
653 		    maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
654 		    maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
655 
656 		    // delete pages, that are not of any interest for us
657 		    for( long i = ( pWorkModel->GetPageCount() - 1 ); i >= 0; i-- )
658 		    {
659 			    SdPage* pP = static_cast< SdPage* >( pWorkModel->GetPage( (sal_uInt16) i ) );
660 
661 			    if( pP->GetPageKind() != PK_STANDARD )
662 				    pWorkModel->DeletePage( (sal_uInt16) i );
663 		    }
664 
665 		    bReturn = Paste( *pWorkModel, maDropPos, pPage, nPasteOptions );
666 
667 		    if( !pPage )
668 			    pPage = (SdPage*) GetSdrPageView()->GetPage();
669 
670 		    String aLayout(pPage->GetLayoutName());
671 		    aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
672 		    pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
673 	   }
674 	}
675 	else if( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_DRAWING ) )
676 	{
677 		SotStorageStreamRef xStm;
678 
679 		if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
680 		{
681 			sal_Bool bChanged = sal_False;
682 
683             DrawDocShellRef xShell = new DrawDocShell(SFX_CREATE_MODE_INTERNAL);
684             xShell->DoInitNew(0);
685 
686 			SdDrawDocument* pModel = xShell->GetDoc();
687             pModel->InsertPage(pModel->AllocPage(false));
688 
689             Reference< XComponent > xComponent( xShell->GetModel(), UNO_QUERY );
690 			xStm->Seek( 0 );
691 
692 			com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
693 			bReturn = SvxDrawingLayerImport( pModel, xInputStream, xComponent, "com.sun.star.comp.Impress.XMLOasisImporter" );
694 
695 			if( pModel->GetPageCount() == 0 )
696 			{
697 				DBG_ERROR("empty or invalid drawing xml document on clipboard!" );
698 			}
699 			else
700 			{
701 				if( bReturn )
702 				{
703 					if( pModel->GetSdPage( 0, PK_STANDARD )->GetObjCount() == 1 )
704 					{
705 						// only one object
706 						SdrObject*		pObj = pModel->GetSdPage( 0, PK_STANDARD )->GetObj( 0 );
707 						SdrObject*		pPickObj2 = NULL;
708 						SdrPageView*	pPV = NULL;
709 						PickObj( rPos, getHitTolLog(), pPickObj2, pPV );
710 
711 						if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && pObj )
712 						{
713 							// replace object
714 							SdrObject*	pNewObj = pObj->Clone();
715 							Rectangle	aPickObjRect( pPickObj2->GetCurrentBoundRect() );
716 							Size		aPickObjSize( aPickObjRect.GetSize() );
717 							Point		aVec( aPickObjRect.TopLeft() );
718 							Rectangle	aObjRect( pNewObj->GetCurrentBoundRect() );
719 							Size		aObjSize( aObjRect.GetSize() );
720 
721 							Fraction aScaleWidth( aPickObjSize.Width(), aObjSize.Width() );
722 							Fraction aScaleHeight( aPickObjSize.Height(), aObjSize.Height() );
723 							pNewObj->NbcResize( aObjRect.TopLeft(), aScaleWidth, aScaleHeight );
724 
725 							aVec -= aObjRect.TopLeft();
726 							pNewObj->NbcMove( Size( aVec.X(), aVec.Y() ) );
727 
728 							const bool bUndo = IsUndoEnabled();
729 
730 							if( bUndo )
731 								BegUndo( String( SdResId(STR_UNDO_DRAGDROP ) ) );
732 							pNewObj->NbcSetLayer( pPickObj->GetLayer() );
733 							SdrPage* pWorkPage = GetSdrPageView()->GetPage();
734 							pWorkPage->InsertObject( pNewObj );
735 							if( bUndo )
736 							{
737 								AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
738 								AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2 ) );
739 							}
740 							pWorkPage->RemoveObject( pPickObj2->GetOrdNum() );
741 
742 							if( bUndo )
743 							{
744 								EndUndo();
745 							}
746 							else
747 							{
748 								SdrObject::Free(pPickObj2 );
749 							}
750 							bChanged = sal_True;
751 							mnAction = DND_ACTION_COPY;
752 						}
753 						else if( ( mnAction & DND_ACTION_LINK ) && pPickObj && pObj && !pPickObj->ISA( SdrGrafObj ) && !pPickObj->ISA( SdrOle2Obj ) )
754 						{
755 							SfxItemSet aSet( mpDoc->GetPool() );
756 
757 							// set new attributes to object
758 							const bool bUndo = IsUndoEnabled();
759 							if( bUndo )
760 							{
761 								BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
762 								AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
763 							}
764 
765 							aSet.Put( pObj->GetMergedItemSet() );
766 
767 							// Eckenradius soll nicht uebernommen werden.
768 							// In der Gallery stehen Farbverlauefe (Rechtecke)
769 							// welche den Eckenradius == 0 haben. Dieser soll
770 							// nicht auf das Objekt uebertragen werden.
771 							aSet.ClearItem( SDRATTR_ECKENRADIUS );
772 
773                             const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
774 
775                             if(pSdrGrafObj)
776                             {
777                                 // If we have a graphic as source object, use it's graphic
778                                 // content as fill style
779                                 aSet.Put(XFillStyleItem(XFILL_BITMAP));
780                                 aSet.Put(XFillBitmapItem(&mpDoc->GetPool(), pSdrGrafObj->GetGraphic()));
781                             }
782 
783                             pPickObj->SetMergedItemSetAndBroadcast( aSet );
784 
785 							if( pPickObj->ISA( E3dObject ) && pObj->ISA( E3dObject ) )
786 							{
787 								// Zusaetzlich 3D Attribute handeln
788 								SfxItemSet aNewSet( mpDoc->GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
789 								SfxItemSet aOldSet( mpDoc->GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
790 
791 								aOldSet.Put(pPickObj->GetMergedItemSet());
792 								aNewSet.Put( pObj->GetMergedItemSet() );
793 
794 								if( bUndo )
795 									AddUndo( new E3dAttributesUndoAction( *mpDoc, this, (E3dObject*) pPickObj, aNewSet, aOldSet, sal_False ) );
796 								pPickObj->SetMergedItemSetAndBroadcast( aNewSet );
797 							}
798 
799 							if( bUndo )
800 								EndUndo();
801 							bChanged = sal_True;
802 						}
803 					}
804 				}
805 
806 				if( !bChanged )
807 				{
808 					SdrPage* pWorkPage = pModel->GetSdPage( 0, PK_STANDARD );
809 
810 					pWorkPage->SetRectsDirty();
811 
812 					if( pOwnData )
813 					{
814                         // #120393# Clipboard data uses full object geometry range
815 						const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
816 
817 						maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
818 						maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
819 					}
820 
821 					bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
822 				}
823 
824                 xShell->DoClose();
825 			}
826 		}
827 	}
828 	else if( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) )
829 	{
830 		::rtl::OUString aOUString;
831 
832 		if( aDataHelper.GetString( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE, aOUString ) )
833 		{
834 			SdrObject* pObj = CreateFieldControl( aOUString );
835 
836 			if( pObj )
837 			{
838 				Rectangle	aRect( pObj->GetLogicRect() );
839 				Size		aSize( aRect.GetSize() );
840 
841 				maDropPos.X() -= ( aSize.Width() >> 1 );
842 				maDropPos.Y() -= ( aSize.Height() >> 1 );
843 
844 				aRect.SetPos( maDropPos );
845 				pObj->SetLogicRect( aRect );
846 				InsertObjectAtView( pObj, *GetSdrPageView(), SDRINSERT_SETDEFLAYER );
847 				bReturn = sal_True;
848 			}
849 		}
850 	}
851 	else if( !bLink &&
852 			 ( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBED_SOURCE ) ||
853 			   CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) )  &&
854 			   aDataHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
855 	{
856         //TODO/LATER: is it possible that this format is binary?! (from old versions of SO)
857         uno::Reference < io::XInputStream > xStm;
858 		TransferableObjectDescriptor	aObjDesc;
859 
860 		if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
861             ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE, xStm ) ||
862               aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ, xStm ) ) )
863 		{
864 			if( mpDoc->GetDocSh() && ( mpDoc->GetDocSh()->GetClassName() == aObjDesc.maClassName ) )
865 			{
866                 uno::Reference < embed::XStorage > xStore( ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm ) );
867 				::sd::DrawDocShellRef xDocShRef( new ::sd::DrawDocShell( SFX_CREATE_MODE_EMBEDDED, sal_True, mpDoc->GetDocumentType() ) );
868 
869                 // mba: BaseURL doesn't make sense for clipboard functionality
870                 SfxMedium *pMedium = new SfxMedium( xStore, String() );
871                 if( xDocShRef->DoLoad( pMedium ) )
872                 {
873 					SdDrawDocument*	pModel = (SdDrawDocument*) xDocShRef->GetDoc();
874 					SdPage*			pWorkPage = (SdPage*) pModel->GetSdPage( 0, PK_STANDARD );
875 
876 					pWorkPage->SetRectsDirty();
877 
878 					if( pOwnData )
879 					{
880                         // #120393# Clipboard data uses full object geometry range
881 						const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
882 
883 						maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
884 						maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
885 					}
886 
887 					// delete pages, that are not of any interest for us
888 					for( long i = ( pModel->GetPageCount() - 1 ); i >= 0; i-- )
889 					{
890 						SdPage* pP = static_cast< SdPage* >( pModel->GetPage( (sal_uInt16) i ) );
891 
892 						if( pP->GetPageKind() != PK_STANDARD )
893 							pModel->DeletePage( (sal_uInt16) i );
894 					}
895 
896 					bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
897 
898 					if( !pPage )
899 						pPage = (SdPage*) GetSdrPageView()->GetPage();
900 
901 					String aLayout(pPage->GetLayoutName());
902 					aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
903 					pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
904 				}
905 
906 				xDocShRef->DoClose();
907 				xDocShRef.Clear();
908 
909 			}
910 			else
911 			{
912                 ::rtl::OUString aName;
913                 uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
914                 if ( xObj.is() )
915                 {
916 					svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
917 
918 					// try to get the replacement image from the clipboard
919 					Graphic aGraphic;
920 					sal_uLong nGrFormat = 0;
921 
922 // (wg. Selection Manager bei Trustet Solaris)
923 #ifndef SOLARIS
924 /*
925                     if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
926 						nGrFormat = SOT_FORMATSTR_ID_SVXB;
927 					else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
928 						nGrFormat = SOT_FORMAT_GDIMETAFILE;
929 					else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
930 						nGrFormat = SOT_FORMAT_BITMAP;
931 */
932 #endif
933 
934 					// insert replacement image ( if there is one ) into the object helper
935 					if ( nGrFormat )
936 					{
937 						datatransfer::DataFlavor aDataFlavor;
938 						SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
939 						aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
940 					}
941 
942 					Size aSize;
943 					if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
944 					{
945                     	if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
946 							aSize = aObjDesc.maSize;
947 						else
948 						{
949 							MapMode aMapMode( MAP_100TH_MM );
950 							aSize = aObjRef.GetSize( &aMapMode );
951 						}
952 					}
953 					else
954 					{
955                     	awt::Size aSz;
956                     	MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
957                     	if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
958                     	{
959                         	Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
960                         	aSz.Width = aTmp.Width();
961                         	aSz.Height = aTmp.Height();
962                         	xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
963                     	}
964 
965 						try
966 						{
967                     		aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
968 						}
969 						catch( embed::NoVisualAreaSizeException& )
970 						{
971 							// if the size still was not set the default size will be set later
972 						}
973 
974                     	aSize = Size( aSz.Width, aSz.Height );
975 
976                     	if( !aSize.Width() || !aSize.Height() )
977                     	{
978                         	aSize.Width()  = 14100;
979                         	aSize.Height() = 10000;
980                         	aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
981                         	aSz.Width = aSize.Width();
982                         	aSz.Height = aSize.Height();
983                         	xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
984                     	}
985 
986                     	aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
987 					}
988 
989                     Size aMaxSize( mpDoc->GetMaxObjSize() );
990 
991                     maDropPos.X() -= Min( aSize.Width(), aMaxSize.Width() ) >> 1;
992                     maDropPos.Y() -= Min( aSize.Height(), aMaxSize.Height() ) >> 1;
993 
994                     Rectangle       aRect( maDropPos, aSize );
995                     SdrOle2Obj*     pObj = new SdrOle2Obj( aObjRef, aName, aRect );
996                     SdrPageView*    pPV = GetSdrPageView();
997                     sal_uLong           nOptions = SDRINSERT_SETDEFLAYER;
998 
999                     if (mpViewSh!=NULL)
1000                     {
1001                         OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
1002                         SfxInPlaceClient* pIpClient
1003                             = mpViewSh->GetViewShell()->GetIPClient();
1004                         if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
1005                             nOptions |= SDRINSERT_DONTMARK;
1006                     }
1007 
1008                     InsertObjectAtView( pObj, *pPV, nOptions );
1009 
1010                     if( pImageMap )
1011                         pObj->InsertUserData( new SdIMapInfo( *pImageMap ) );
1012 
1013                     if ( pObj && pObj->IsChart() )
1014                     {
1015                         bool bDisableDataTableDialog = false;
1016                         svt::EmbeddedObjectRef::TryRunningState( xObj );
1017                         uno::Reference< beans::XPropertySet > xProps( xObj->getComponent(), uno::UNO_QUERY );
1018                         if ( xProps.is() &&
1019                              ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) &&
1020                              bDisableDataTableDialog )
1021                         {
1022                             xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ),
1023                                 uno::makeAny( sal_False ) );
1024                             xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ),
1025                                 uno::makeAny( sal_False ) );
1026                             uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
1027                             if ( xModifiable.is() )
1028                             {
1029                                 xModifiable->setModified( sal_True );
1030                             }
1031                         }
1032                     }
1033 
1034                     bReturn = sal_True;
1035                 }
1036 			}
1037 		}
1038 	}
1039 	else if( !bLink &&
1040 			 ( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ||
1041 			   CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ) &&
1042 			   aDataHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE ) )
1043 	{
1044 		// online insert ole if format is forced or no gdi metafile is available
1045 		if( (nFormat != 0) || !aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
1046 		{
1047 			uno::Reference < io::XInputStream > xStm;
1048 			TransferableObjectDescriptor	aObjDesc;
1049 
1050 			if ( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aObjDesc ) )
1051 			{
1052 				uno::Reference < embed::XEmbeddedObject > xObj;
1053 				::rtl::OUString aName;
1054 
1055 				if ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStm ) ||
1056 					aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStm ) )
1057 				{
1058             		xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
1059 				}
1060 				else
1061 				{
1062 					try
1063 					{
1064 						uno::Reference< embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
1065 						uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator(
1066 							::comphelper::getProcessServiceFactory()->createInstance(
1067                            		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
1068 							uno::UNO_QUERY_THROW );
1069 
1070 						embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
1071 																xTmpStor,
1072 																::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
1073 																uno::Sequence< beans::PropertyValue >() );
1074 
1075 						// TODO/LATER: in future InsertedObjectInfo will be used to get container related information
1076 						// for example whether the object should be an iconified one
1077 						xObj = aInfo.Object;
1078 						if ( xObj.is() )
1079 							mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
1080 					}
1081 					catch( uno::Exception& )
1082 					{}
1083 				}
1084 
1085 				if ( xObj.is() )
1086 				{
1087 					svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
1088 
1089 					// try to get the replacement image from the clipboard
1090 					Graphic aGraphic;
1091 					sal_uLong nGrFormat = 0;
1092 
1093 // (wg. Selection Manager bei Trustet Solaris)
1094 #ifndef SOLARIS
1095                     if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
1096 						nGrFormat = SOT_FORMATSTR_ID_SVXB;
1097 					else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
1098 						nGrFormat = SOT_FORMAT_GDIMETAFILE;
1099 					else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
1100 						nGrFormat = SOT_FORMAT_BITMAP;
1101 #endif
1102 
1103 					// insert replacement image ( if there is one ) into the object helper
1104 					if ( nGrFormat )
1105 					{
1106 						datatransfer::DataFlavor aDataFlavor;
1107 						SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
1108 						aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
1109 					}
1110 
1111 					Size aSize;
1112 					if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
1113 					{
1114                     	if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1115 							aSize = aObjDesc.maSize;
1116 						else
1117 						{
1118 							MapMode aMapMode( MAP_100TH_MM );
1119 							aSize = aObjRef.GetSize( &aMapMode );
1120 						}
1121 					}
1122 					else
1123 					{
1124             			MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
1125 
1126             			awt::Size aSz;
1127 						try{
1128 							aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
1129 						}
1130 						catch( embed::NoVisualAreaSizeException& )
1131 						{
1132 							// the default size will be set later
1133 						}
1134 
1135             			if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1136             			{
1137                 			Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
1138 							if ( aSz.Width != aTmp.Width() || aSz.Height != aTmp.Height() )
1139 							{
1140                 				aSz.Width = aTmp.Width();
1141                 				aSz.Height = aTmp.Height();
1142                 				xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
1143 							}
1144             			}
1145 
1146             			aSize = Size( aSz.Width, aSz.Height );
1147 
1148             			if( !aSize.Width() || !aSize.Height() )
1149             			{
1150                 			aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
1151                 			aSz.Width = aSize.Width();
1152                 			aSz.Height = aSize.Height();
1153                 			xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
1154             			}
1155 
1156             			aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
1157 					}
1158 
1159             		Size aMaxSize( mpDoc->GetMaxObjSize() );
1160 
1161             		maDropPos.X() -= Min( aSize.Width(), aMaxSize.Width() ) >> 1;
1162             		maDropPos.Y() -= Min( aSize.Height(), aMaxSize.Height() ) >> 1;
1163 
1164             		Rectangle       aRect( maDropPos, aSize );
1165             		SdrOle2Obj*     pObj = new SdrOle2Obj( aObjRef, aName, aRect );
1166             		SdrPageView*    pPV = GetSdrPageView();
1167             		sal_uLong           nOptions = SDRINSERT_SETDEFLAYER;
1168 
1169             		if (mpViewSh!=NULL)
1170             		{
1171                 		OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
1172                 		SfxInPlaceClient* pIpClient
1173                     		= mpViewSh->GetViewShell()->GetIPClient();
1174                 		if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
1175                     		nOptions |= SDRINSERT_DONTMARK;
1176             		}
1177 
1178             		InsertObjectAtView( pObj, *pPV, nOptions );
1179 
1180             		if( pImageMap )
1181                 		pObj->InsertUserData( new SdIMapInfo( *pImageMap ) );
1182 
1183 					// let the object stay in loaded state after insertion
1184 					pObj->Unload();
1185             		bReturn = sal_True;
1186 				}
1187 			}
1188 		}
1189 
1190 		if( !bReturn && aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
1191 		{
1192 			// if no object was inserted, insert a picture
1193 			InsertMetaFile( aDataHelper, rPos, pImageMap, true );
1194 		}
1195 	}
1196 	else if( ( !bLink || pPickObj ) && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_SVXB ) )
1197 	{
1198 		SotStorageStreamRef xStm;
1199 
1200 		if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) )
1201 		{
1202 			Point   aInsertPos( rPos );
1203 			Graphic aGraphic;
1204 
1205 			*xStm >> aGraphic;
1206 
1207 			if( pOwnData && pOwnData->GetWorkDocument() )
1208 			{
1209 		        const SdDrawDocument*	pWorkModel = pOwnData->GetWorkDocument();
1210                 SdrPage*	            pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
1211                                                     pWorkModel->GetSdPage( 0, PK_STANDARD ) :
1212                                                     pWorkModel->GetPage( 0 ) );
1213 
1214 				pWorkPage->SetRectsDirty();
1215 
1216                 // #120393# Clipboard data uses full object geometry range
1217 				const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1218 
1219 				aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
1220 				aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
1221 			}
1222 
1223 			// #90129# restrict movement to WorkArea
1224 			Size aImageMapSize = OutputDevice::LogicToLogic(aGraphic.GetPrefSize(),
1225 				aGraphic.GetPrefMapMode(), MapMode(MAP_100TH_MM));
1226 
1227 			ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
1228 
1229 			InsertGraphic( aGraphic, mnAction, aInsertPos, NULL, pImageMap );
1230 			bReturn = sal_True;
1231 		}
1232 	}
1233 	else if( ( !bLink || pPickObj ) && CHECK_FORMAT_TRANS( FORMAT_GDIMETAFILE ) )
1234 	{
1235 		Point aInsertPos( rPos );
1236 
1237 		if( pOwnData && pOwnData->GetWorkDocument() )
1238 
1239 		{
1240 			const SdDrawDocument*	pWorkModel = pOwnData->GetWorkDocument();
1241             SdrPage*	            pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
1242                                                 pWorkModel->GetSdPage( 0, PK_STANDARD ) :
1243                                                 pWorkModel->GetPage( 0 ) );
1244 
1245 			pWorkPage->SetRectsDirty();
1246 
1247             // #120393# Clipboard data uses full object geometry range
1248 			const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1249 
1250 			aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
1251 			aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
1252 		}
1253 
1254 		bReturn = InsertMetaFile( aDataHelper, aInsertPos, pImageMap, nFormat == 0 ? true : false ) ? sal_True : sal_False;
1255 	}
1256 	else if( ( !bLink || pPickObj ) && CHECK_FORMAT_TRANS( FORMAT_BITMAP ) )
1257 	{
1258 		BitmapEx aBmpEx;
1259 
1260 		if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ) )
1261 		{
1262 			Point aInsertPos( rPos );
1263 
1264 			if( pOwnData && pOwnData->GetWorkDocument() )
1265 			{
1266 			    const SdDrawDocument*	pWorkModel = pOwnData->GetWorkDocument();
1267                 SdrPage*	            pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
1268                                                     pWorkModel->GetSdPage( 0, PK_STANDARD ) :
1269                                                     pWorkModel->GetPage( 0 ) );
1270 
1271 				pWorkPage->SetRectsDirty();
1272 
1273                 // #120393# Clipboard data uses full object geometry range
1274 				const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1275 
1276 				aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
1277 				aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
1278 			}
1279 
1280 			// #90129# restrict movement to WorkArea
1281 			Size aImageMapSize(aBmpEx.GetPrefSize());
1282 			ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
1283 
1284 			InsertGraphic( aBmpEx, mnAction, aInsertPos, NULL, pImageMap );
1285 			bReturn = sal_True;
1286 		}
1287 	}
1288 	else if( pPickObj && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_XFA ) )
1289 	{
1290 		SotStorageStreamRef xStm;
1291 
1292 		if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_XFA, xStm ) )
1293 		{
1294 			XFillExchangeData aFillData( XFillAttrSetItem( &mpDoc->GetPool() ) );
1295 
1296 			*xStm >> aFillData;
1297 
1298 			if( IsUndoEnabled() )
1299 			{
1300 				BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
1301 				AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
1302 				EndUndo();
1303 			}
1304 
1305 			XFillAttrSetItem*	pSetItem = aFillData.GetXFillAttrSetItem();
1306 			SfxItemSet			rSet = pSetItem->GetItemSet();
1307 			XFillStyle			eFill= ( (XFillStyleItem&) rSet.Get( XATTR_FILLSTYLE ) ).GetValue();
1308 
1309 			if( eFill == XFILL_SOLID || eFill == XFILL_NONE )
1310 			{
1311 				const XFillColorItem&	rColItem = (XFillColorItem&) rSet.Get( XATTR_FILLCOLOR );
1312 				Color					aColor( rColItem.GetColorValue() );
1313 				String					aName( rColItem.GetName() );
1314 				SfxItemSet				aSet( mpDoc->GetPool() );
1315 				sal_Bool					bClosed = pPickObj->IsClosedObj();
1316 				::sd::Window* pWin = mpViewSh->GetActiveWindow();
1317 				sal_uInt16 nHitLog = (sal_uInt16) pWin->PixelToLogic(
1318                     Size(FuPoor::HITPIX, 0 ) ).Width();
1319 				const long				n2HitLog = nHitLog << 1;
1320 				Point					aHitPosR( rPos );
1321 				Point					aHitPosL( rPos );
1322 				Point					aHitPosT( rPos );
1323 				Point					aHitPosB( rPos );
1324 				const SetOfByte*		pVisiLayer = &GetSdrPageView()->GetVisibleLayers();
1325 
1326 				aHitPosR.X() += n2HitLog;
1327 				aHitPosL.X() -= n2HitLog;
1328 				aHitPosT.Y() += n2HitLog;
1329 				aHitPosB.Y() -= n2HitLog;
1330 
1331 				if( bClosed &&
1332 					SdrObjectPrimitiveHit(*pPickObj, aHitPosR, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1333 					SdrObjectPrimitiveHit(*pPickObj, aHitPosL, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1334 					SdrObjectPrimitiveHit(*pPickObj, aHitPosT, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1335 					SdrObjectPrimitiveHit(*pPickObj, aHitPosB, nHitLog, *GetSdrPageView(), pVisiLayer, false) )
1336 				{
1337 					// area fill
1338 					if(eFill == XFILL_SOLID )
1339 						aSet.Put(XFillColorItem(aName, aColor));
1340 
1341 					aSet.Put( XFillStyleItem( eFill ) );
1342 				}
1343 				else
1344 					aSet.Put( XLineColorItem( aName, aColor ) );
1345 
1346 				// Textfarbe hinzufuegen
1347 				pPickObj->SetMergedItemSetAndBroadcast( aSet );
1348 			}
1349 		}
1350 	}
1351 	else if( !bLink && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_HTML ) )
1352 	{
1353 		SotStorageStreamRef xStm;
1354 
1355 		if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_HTML, xStm ) )
1356 		{
1357 			xStm->Seek( 0 );
1358             // mba: clipboard always must contain absolute URLs (could be from alien source)
1359             bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_HTML, maDropPos, pPage, nPasteOptions );
1360 		}
1361 	}
1362 	else if( !bLink && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EDITENGINE ) )
1363 	{
1364 		SotStorageStreamRef xStm;
1365 
1366 		if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_EDITENGINE, xStm ) )
1367 		{
1368 			OutlinerView* pOLV = GetTextEditOutlinerView();
1369 
1370             xStm->Seek( 0 );
1371 
1372 			if( pOLV )
1373 			{
1374 				Rectangle   aRect( pOLV->GetOutputArea() );
1375    				Point       aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
1376 
1377 				if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
1378 				{
1379                     // mba: clipboard always must contain absolute URLs (could be from alien source)
1380                     pOLV->Read( *xStm, String(), EE_FORMAT_BIN, sal_False, mpDocSh->GetHeaderAttributes() );
1381 					bReturn = sal_True;
1382 				}
1383 			}
1384 
1385 			if( !bReturn )
1386                 // mba: clipboard always must contain absolute URLs (could be from alien source)
1387                 bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_BIN, maDropPos, pPage, nPasteOptions );
1388 		}
1389 	}
1390 	else if( !bLink && CHECK_FORMAT_TRANS( FORMAT_RTF ) )
1391 	{
1392 		SotStorageStreamRef xStm;
1393 
1394 		if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
1395 		{
1396             xStm->Seek( 0 );
1397 
1398 			if( bTable )
1399 			{
1400 				bReturn = PasteRTFTable( xStm, pPage, nPasteOptions );
1401 			}
1402 			else
1403 			{
1404 				OutlinerView* pOLV = GetTextEditOutlinerView();
1405 
1406 				if( pOLV )
1407 				{
1408 					Rectangle   aRect( pOLV->GetOutputArea() );
1409    					Point       aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
1410 
1411 					if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
1412 					{
1413 						// mba: clipboard always must contain absolute URLs (could be from alien source)
1414 						pOLV->Read( *xStm, String(), EE_FORMAT_RTF, sal_False, mpDocSh->GetHeaderAttributes() );
1415 						bReturn = sal_True;
1416 					}
1417 				}
1418 
1419 				if( !bReturn )
1420 					// mba: clipboard always must contain absolute URLs (could be from alien source)
1421 					bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_RTF, maDropPos, pPage, nPasteOptions );
1422 			}
1423 		}
1424 	}
1425 	else if( CHECK_FORMAT_TRANS( FORMAT_FILE_LIST ) )
1426 	{
1427         FileList aDropFileList;
1428 
1429         if( aDataHelper.GetFileList( FORMAT_FILE_LIST, aDropFileList ) )
1430         {
1431             maDropFileVector.clear();
1432 
1433             for( sal_uLong i = 0, nCount = aDropFileList.Count(); i < nCount; i++ )
1434                 maDropFileVector.push_back( aDropFileList.GetFile( i ) );
1435 
1436             maDropInsertFileTimer.Start();
1437         }
1438 
1439 		bReturn = sal_True;
1440 	}
1441 	else if( CHECK_FORMAT_TRANS( FORMAT_FILE ) )
1442 	{
1443         String aDropFile;
1444 
1445         if( aDataHelper.GetString( FORMAT_FILE, aDropFile ) )
1446         {
1447             maDropFileVector.clear();
1448             maDropFileVector.push_back( aDropFile );
1449 			maDropInsertFileTimer.Start();
1450         }
1451 
1452 		bReturn = sal_True;
1453 	}
1454 	else if( !bLink && CHECK_FORMAT_TRANS( FORMAT_STRING ) )
1455 	{
1456 		if( ( FORMAT_STRING == nFormat ) ||
1457             ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) &&
1458 			  !aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
1459 			  !aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILENAME ) ) )
1460 		{
1461 			::rtl::OUString aOUString;
1462 
1463 			if( aDataHelper.GetString( FORMAT_STRING, aOUString ) )
1464 			{
1465 				OutlinerView* pOLV = GetTextEditOutlinerView();
1466 
1467 				if( pOLV )
1468 				{
1469 					pOLV->InsertText( aOUString );
1470 					bReturn = sal_True;
1471 				}
1472 
1473                 if( !bReturn )
1474                     bReturn = SdrView::Paste( aOUString, maDropPos, pPage, nPasteOptions );
1475 			}
1476 		}
1477 	}
1478 
1479 	MarkListHasChanged();
1480 	mbIsDropAllowed = sal_True;
1481 	rDnDAction = mnAction;
1482 	delete pImageMap;
1483 
1484 	return bReturn;
1485 }
1486 
1487 extern void CreateTableFromRTF( SvStream& rStream, SdDrawDocument* pModel  );
1488 
1489 bool View::PasteRTFTable( SotStorageStreamRef xStm, SdrPage* pPage, sal_uLong nPasteOptions )
1490 {
1491 	SdDrawDocument* pModel = new SdDrawDocument( DOCUMENT_TYPE_IMPRESS, mpDocSh );
1492 	pModel->NewOrLoadCompleted(NEW_DOC);
1493 	pModel->GetItemPool().SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
1494 	pModel->InsertPage(pModel->AllocPage(false));
1495 
1496 	Reference< XComponent > xComponent( new SdXImpressDocument( pModel, sal_True ) );
1497 	pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );
1498 
1499 	CreateTableFromRTF( *xStm, pModel );
1500 	bool bRet = Paste( *pModel, maDropPos, pPage, nPasteOptions );
1501 
1502 	xComponent->dispose();
1503 	xComponent.clear();
1504 
1505 	delete pModel;
1506 
1507 	return bRet;
1508 }
1509 
1510 } // end of namespace sd
1511