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