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
ImpGetClone(Container & aConnectorContainer,SdrObject * pConnObj)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
ImpCheckInsertPos(Point & rPos,const Size & rSize,const Rectangle & rWorkArea)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
InsertMetaFile(TransferableDataHelper & rDataHelper,const Point & rPos,ImageMap * pImageMap,bool bOptimize)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 {
176*54883b22Smseidel // handle error 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
InsertData(const TransferableDataHelper & rDataHelper,const Point & rPos,sal_Int8 & rDnDAction,sal_Bool bDrag,sal_uLong nFormat,sal_uInt16 nPage,sal_uInt16 nLayer)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;
2981cd65da9SArmin Le Grand bool bReturn = 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
3241cd65da9SArmin Le Grand if(pImplementation && (rDnDAction & DND_ACTION_LINK))
3251cd65da9SArmin Le Grand {
3261cd65da9SArmin Le Grand // suppress own data when it's intention is to use it as fill information
3271cd65da9SArmin Le Grand pImplementation = 0;
3281cd65da9SArmin Le Grand }
3291cd65da9SArmin Le Grand
330cdf0e10cSrcweir // try to get own transfer data
331cdf0e10cSrcweir if( pImplementation )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir if( SD_MOD()->pTransferClip == (SdTransferable*) pImplementation )
334cdf0e10cSrcweir pOwnData = SD_MOD()->pTransferClip;
335cdf0e10cSrcweir else if( SD_MOD()->pTransferDrag == (SdTransferable*) pImplementation )
336cdf0e10cSrcweir pOwnData = SD_MOD()->pTransferDrag;
337cdf0e10cSrcweir else if( SD_MOD()->pTransferSelection == (SdTransferable*) pImplementation )
338cdf0e10cSrcweir pOwnData = SD_MOD()->pTransferSelection;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
341cdf0e10cSrcweir // ImageMap?
342cdf0e10cSrcweir if( !pOwnData && aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVIM ) )
343cdf0e10cSrcweir {
344cdf0e10cSrcweir SotStorageStreamRef xStm;
345cdf0e10cSrcweir
346cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVIM, xStm ) )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir pImageMap = new ImageMap;
349cdf0e10cSrcweir // mba: clipboard always must contain absolute URLs (could be from alien source)
350cdf0e10cSrcweir pImageMap->Read( *xStm, String() );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
354cdf0e10cSrcweir bool bTable = false;
355cdf0e10cSrcweir // check special cases for pasting table formats as RTL
356cdf0e10cSrcweir if( !bLink && (!nFormat || (nFormat == SOT_FORMAT_RTF)) )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir // if the objekt supports rtf and there is a table involved, default is to create a table
359cdf0e10cSrcweir if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) && ! aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir SotStorageStreamRef xStm;
362cdf0e10cSrcweir
363cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
364cdf0e10cSrcweir {
365cdf0e10cSrcweir xStm->Seek( 0 );
366cdf0e10cSrcweir
367cdf0e10cSrcweir ByteString aLine;
368cdf0e10cSrcweir while( xStm->ReadLine(aLine) )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir xub_StrLen x = aLine.Search( "\\trowd" );
371cdf0e10cSrcweir if( x != STRING_NOTFOUND )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir bTable = true;
374cdf0e10cSrcweir nFormat = FORMAT_RTF;
375cdf0e10cSrcweir break;
376cdf0e10cSrcweir }
377cdf0e10cSrcweir }
378cdf0e10cSrcweir }
379cdf0e10cSrcweir }
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
3821cd65da9SArmin Le Grand // Changed the whole decision tree to be dependent of bReturn as a flag that
3831cd65da9SArmin Le Grand // the work was done; this allows to check multiple formats and not just fail
3841cd65da9SArmin Le Grand // when a CHECK_FORMAT_TRANS(*format*) detected format does not work. This is
3851cd65da9SArmin Le Grand // e.g. necessary for FORMAT_BITMAP
3861cd65da9SArmin Le Grand if( pOwnData && !nFormat )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir const View* pSourceView = pOwnData->GetView();
389cdf0e10cSrcweir
390cdf0e10cSrcweir if( pOwnData->GetDocShell() && pOwnData->IsPageTransferable() && ISA( View ) )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir mpClipboard->HandlePageDrop (*pOwnData);
393cdf0e10cSrcweir }
394cdf0e10cSrcweir else if( pSourceView )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir if( pSourceView == this )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir // same view
399cdf0e10cSrcweir if( nLayer != SDRLAYER_NOTFOUND )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir // drop on layer tab bar
402cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
403cdf0e10cSrcweir SdrLayer* pLayer = rLayerAdmin.GetLayerPerID( nLayer );
404cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView();
405cdf0e10cSrcweir String aLayer( pLayer->GetName() );
406cdf0e10cSrcweir
407cdf0e10cSrcweir if( !pPV->IsLayerLocked( aLayer ) )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir pOwnData->SetInternalMove( sal_True );
410cdf0e10cSrcweir SortMarkedObjects();
411cdf0e10cSrcweir
412cdf0e10cSrcweir for( sal_uLong nM = 0; nM < GetMarkedObjectCount(); nM++ )
413cdf0e10cSrcweir {
414cdf0e10cSrcweir SdrMark* pM = GetSdrMarkByIndex( nM );
415cdf0e10cSrcweir SdrObject* pO = pM->GetMarkedSdrObj();
416cdf0e10cSrcweir
417cdf0e10cSrcweir if( pO )
418cdf0e10cSrcweir {
419cdf0e10cSrcweir // #i11702#
420cdf0e10cSrcweir if( IsUndoEnabled() )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir BegUndo(String(SdResId(STR_MODIFYLAYER)));
423cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), (SdrLayerID)nLayer));
424cdf0e10cSrcweir EndUndo();
425cdf0e10cSrcweir }
426cdf0e10cSrcweir
427cdf0e10cSrcweir pO->SetLayer( (SdrLayerID) nLayer );
428cdf0e10cSrcweir }
429cdf0e10cSrcweir }
430cdf0e10cSrcweir
4311cd65da9SArmin Le Grand bReturn = true;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir }
434cdf0e10cSrcweir else
435cdf0e10cSrcweir {
436cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView();
437cdf0e10cSrcweir sal_Bool bDropOnTabBar = sal_True;
438cdf0e10cSrcweir
439cdf0e10cSrcweir if( !pPage && pPV->GetPage()->GetPageNum() != mnDragSrcPgNum )
440cdf0e10cSrcweir {
441cdf0e10cSrcweir pPage = (SdPage*) pPV->GetPage();
442cdf0e10cSrcweir bDropOnTabBar = sal_False;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir
445cdf0e10cSrcweir if( pPage )
446cdf0e10cSrcweir {
447cdf0e10cSrcweir // drop on other page
448cdf0e10cSrcweir String aActiveLayer( GetActiveLayer() );
449cdf0e10cSrcweir
450cdf0e10cSrcweir if( !pPV->IsLayerLocked( aActiveLayer ) )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir if( !IsPresObjSelected() )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir SdrMarkList* pMarkList;
455cdf0e10cSrcweir
456cdf0e10cSrcweir if( (mnDragSrcPgNum != SDRPAGE_NOTFOUND) && (mnDragSrcPgNum != pPV->GetPage()->GetPageNum()) )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir pMarkList = mpDragSrcMarkList;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir else
461cdf0e10cSrcweir {
462cdf0e10cSrcweir // actual mark list is used
463cdf0e10cSrcweir pMarkList = new SdrMarkList( GetMarkedObjectList());
464cdf0e10cSrcweir }
465cdf0e10cSrcweir
466cdf0e10cSrcweir pMarkList->ForceSort();
467cdf0e10cSrcweir
468cdf0e10cSrcweir // #83525# stuff to remember originals and clones
469cdf0e10cSrcweir Container aConnectorContainer(0);
470cdf0e10cSrcweir sal_uInt32 a, nConnectorCount(0L);
471cdf0e10cSrcweir Point aCurPos;
472cdf0e10cSrcweir
473cdf0e10cSrcweir // calculate real position of current
474cdf0e10cSrcweir // source objects, if necessary (#103207)
475cdf0e10cSrcweir if( pOwnData == SD_MOD()->pTransferSelection )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir Rectangle aCurBoundRect;
478cdf0e10cSrcweir
479cdf0e10cSrcweir if( pMarkList->TakeBoundRect( pPV, aCurBoundRect ) )
480cdf0e10cSrcweir aCurPos = aCurBoundRect.TopLeft();
481cdf0e10cSrcweir else
482cdf0e10cSrcweir aCurPos = pOwnData->GetStartPos();
483cdf0e10cSrcweir }
484cdf0e10cSrcweir else
485cdf0e10cSrcweir aCurPos = pOwnData->GetStartPos();
486cdf0e10cSrcweir
487cdf0e10cSrcweir const Size aVector( maDropPos.X() - aCurPos.X(), maDropPos.Y() - aCurPos.Y() );
488cdf0e10cSrcweir
489cdf0e10cSrcweir for(a = 0; a < pMarkList->GetMarkCount(); a++)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir SdrMark* pM = pMarkList->GetMark(a);
492cdf0e10cSrcweir SdrObject* pObj = pM->GetMarkedSdrObj()->Clone();
493cdf0e10cSrcweir
494cdf0e10cSrcweir if(pObj)
495cdf0e10cSrcweir {
496cdf0e10cSrcweir if(!bDropOnTabBar)
497cdf0e10cSrcweir {
498cdf0e10cSrcweir // #83525# do a NbcMove(...) instead of setting SnapRects here
499cdf0e10cSrcweir pObj->NbcMove(aVector);
500cdf0e10cSrcweir }
501cdf0e10cSrcweir
502cdf0e10cSrcweir pPage->InsertObject(pObj);
503cdf0e10cSrcweir
504cdf0e10cSrcweir if( IsUndoEnabled() )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
507cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
508cdf0e10cSrcweir EndUndo();
509cdf0e10cSrcweir }
510cdf0e10cSrcweir
511cdf0e10cSrcweir // #83525#
512cdf0e10cSrcweir ImpRememberOrigAndClone* pRem = new ImpRememberOrigAndClone;
513cdf0e10cSrcweir pRem->pOrig = pM->GetMarkedSdrObj();
514cdf0e10cSrcweir pRem->pClone = pObj;
515cdf0e10cSrcweir aConnectorContainer.Insert(pRem, CONTAINER_APPEND);
516cdf0e10cSrcweir
517cdf0e10cSrcweir if(pObj->ISA(SdrEdgeObj))
518cdf0e10cSrcweir nConnectorCount++;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir }
521cdf0e10cSrcweir
522cdf0e10cSrcweir // #83525# try to re-establish connections at clones
523cdf0e10cSrcweir if(nConnectorCount)
524cdf0e10cSrcweir {
525cdf0e10cSrcweir for(a = 0; a < aConnectorContainer.Count(); a++)
526cdf0e10cSrcweir {
527cdf0e10cSrcweir ImpRememberOrigAndClone* pRem = (ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a);
528cdf0e10cSrcweir
529cdf0e10cSrcweir if(pRem->pClone->ISA(SdrEdgeObj))
530cdf0e10cSrcweir {
531cdf0e10cSrcweir SdrEdgeObj* pOrigEdge = (SdrEdgeObj*)pRem->pOrig;
532cdf0e10cSrcweir SdrEdgeObj* pCloneEdge = (SdrEdgeObj*)pRem->pClone;
533cdf0e10cSrcweir
534cdf0e10cSrcweir // test first connection
535cdf0e10cSrcweir SdrObjConnection& rConn0 = pOrigEdge->GetConnection(sal_False);
536cdf0e10cSrcweir SdrObject* pConnObj = rConn0.GetObject();
537cdf0e10cSrcweir if(pConnObj)
538cdf0e10cSrcweir {
539cdf0e10cSrcweir SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
540cdf0e10cSrcweir if(pConnClone)
541cdf0e10cSrcweir {
542cdf0e10cSrcweir // if dest obj was cloned, too, re-establish connection
543cdf0e10cSrcweir pCloneEdge->ConnectToNode(sal_False, pConnClone);
544cdf0e10cSrcweir pCloneEdge->GetConnection(sal_False).SetConnectorId(rConn0.GetConnectorId());
545cdf0e10cSrcweir }
546cdf0e10cSrcweir else
547cdf0e10cSrcweir {
548cdf0e10cSrcweir // set position of connection point of original connected object
549cdf0e10cSrcweir const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
550cdf0e10cSrcweir if(pGlueList)
551cdf0e10cSrcweir {
552cdf0e10cSrcweir sal_uInt16 nInd = pGlueList->FindGluePoint(rConn0.GetConnectorId());
553cdf0e10cSrcweir
554cdf0e10cSrcweir if(SDRGLUEPOINT_NOTFOUND != nInd)
555cdf0e10cSrcweir {
556cdf0e10cSrcweir const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
557cdf0e10cSrcweir Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
558cdf0e10cSrcweir aPosition.X() += aVector.A();
559cdf0e10cSrcweir aPosition.Y() += aVector.B();
560cdf0e10cSrcweir pCloneEdge->SetTailPoint(sal_False, aPosition);
561cdf0e10cSrcweir }
562cdf0e10cSrcweir }
563cdf0e10cSrcweir }
564cdf0e10cSrcweir }
565cdf0e10cSrcweir
566cdf0e10cSrcweir // test second connection
567cdf0e10cSrcweir SdrObjConnection& rConn1 = pOrigEdge->GetConnection(sal_True);
568cdf0e10cSrcweir pConnObj = rConn1.GetObject();
569cdf0e10cSrcweir if(pConnObj)
570cdf0e10cSrcweir {
571cdf0e10cSrcweir SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
572cdf0e10cSrcweir if(pConnClone)
573cdf0e10cSrcweir {
574cdf0e10cSrcweir // if dest obj was cloned, too, re-establish connection
575cdf0e10cSrcweir pCloneEdge->ConnectToNode(sal_True, pConnClone);
576cdf0e10cSrcweir pCloneEdge->GetConnection(sal_True).SetConnectorId(rConn1.GetConnectorId());
577cdf0e10cSrcweir }
578cdf0e10cSrcweir else
579cdf0e10cSrcweir {
580cdf0e10cSrcweir // set position of connection point of original connected object
581cdf0e10cSrcweir const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
582cdf0e10cSrcweir if(pGlueList)
583cdf0e10cSrcweir {
584cdf0e10cSrcweir sal_uInt16 nInd = pGlueList->FindGluePoint(rConn1.GetConnectorId());
585cdf0e10cSrcweir
586cdf0e10cSrcweir if(SDRGLUEPOINT_NOTFOUND != nInd)
587cdf0e10cSrcweir {
588cdf0e10cSrcweir const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
589cdf0e10cSrcweir Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
590cdf0e10cSrcweir aPosition.X() += aVector.A();
591cdf0e10cSrcweir aPosition.Y() += aVector.B();
592cdf0e10cSrcweir pCloneEdge->SetTailPoint(sal_True, aPosition);
593cdf0e10cSrcweir }
594cdf0e10cSrcweir }
595cdf0e10cSrcweir }
596cdf0e10cSrcweir }
597cdf0e10cSrcweir }
598cdf0e10cSrcweir }
599cdf0e10cSrcweir }
600cdf0e10cSrcweir
601cdf0e10cSrcweir // #83525# cleanup remember classes
602cdf0e10cSrcweir for(a = 0; a < aConnectorContainer.Count(); a++)
603cdf0e10cSrcweir delete (ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a);
604cdf0e10cSrcweir
605cdf0e10cSrcweir if( pMarkList != mpDragSrcMarkList )
606cdf0e10cSrcweir delete pMarkList;
607cdf0e10cSrcweir
6081cd65da9SArmin Le Grand bReturn = true;
609cdf0e10cSrcweir }
610cdf0e10cSrcweir else
611cdf0e10cSrcweir {
612cdf0e10cSrcweir maDropErrorTimer.Start();
6131cd65da9SArmin Le Grand bReturn = false;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir }
616cdf0e10cSrcweir }
617cdf0e10cSrcweir else
618cdf0e10cSrcweir {
619cdf0e10cSrcweir pOwnData->SetInternalMove( sal_True );
620cdf0e10cSrcweir MoveAllMarked( Size( maDropPos.X() - pOwnData->GetStartPos().X(),
621cdf0e10cSrcweir maDropPos.Y() - pOwnData->GetStartPos().Y() ), bCopy );
6221cd65da9SArmin Le Grand bReturn = true;
623cdf0e10cSrcweir }
624cdf0e10cSrcweir }
625cdf0e10cSrcweir }
626cdf0e10cSrcweir else
627cdf0e10cSrcweir {
628cdf0e10cSrcweir // different views
629cdf0e10cSrcweir if( !pSourceView->IsPresObjSelected() )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir // model is owned by from AllocModel() created DocShell
632cdf0e10cSrcweir SdDrawDocument* pSourceDoc = (SdDrawDocument*) pSourceView->GetModel();
633cdf0e10cSrcweir pSourceDoc->CreatingDataObj( pOwnData );
634cdf0e10cSrcweir SdDrawDocument* pModel = (SdDrawDocument*) pSourceView->GetAllMarkedModel();
635cdf0e10cSrcweir bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
636cdf0e10cSrcweir
637cdf0e10cSrcweir if( !pPage )
638cdf0e10cSrcweir pPage = (SdPage*) GetSdrPageView()->GetPage();
639cdf0e10cSrcweir
640cdf0e10cSrcweir String aLayout( pPage->GetLayoutName() );
641cdf0e10cSrcweir aLayout.Erase( aLayout.SearchAscii( SD_LT_SEPARATOR ) );
642cdf0e10cSrcweir pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
643cdf0e10cSrcweir pSourceDoc->CreatingDataObj( NULL );
644cdf0e10cSrcweir }
645cdf0e10cSrcweir else
646cdf0e10cSrcweir {
647cdf0e10cSrcweir maDropErrorTimer.Start();
6481cd65da9SArmin Le Grand bReturn = false;
649cdf0e10cSrcweir }
650cdf0e10cSrcweir }
651cdf0e10cSrcweir }
652cdf0e10cSrcweir else
653cdf0e10cSrcweir {
654cdf0e10cSrcweir SdDrawDocument* pWorkModel = (SdDrawDocument*) pOwnData->GetWorkDocument();
655cdf0e10cSrcweir SdPage* pWorkPage = (SdPage*) pWorkModel->GetSdPage( 0, PK_STANDARD );
656cdf0e10cSrcweir
657cdf0e10cSrcweir pWorkPage->SetRectsDirty();
658cdf0e10cSrcweir
6590415cdefSArmin Le Grand // #120393# Clipboard data uses full object geometry range
6600415cdefSArmin Le Grand const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
661cdf0e10cSrcweir
662cdf0e10cSrcweir maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
663cdf0e10cSrcweir maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
664cdf0e10cSrcweir
665cdf0e10cSrcweir // delete pages, that are not of any interest for us
666cdf0e10cSrcweir for( long i = ( pWorkModel->GetPageCount() - 1 ); i >= 0; i-- )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir SdPage* pP = static_cast< SdPage* >( pWorkModel->GetPage( (sal_uInt16) i ) );
669cdf0e10cSrcweir
670cdf0e10cSrcweir if( pP->GetPageKind() != PK_STANDARD )
671cdf0e10cSrcweir pWorkModel->DeletePage( (sal_uInt16) i );
672cdf0e10cSrcweir }
673cdf0e10cSrcweir
674cdf0e10cSrcweir bReturn = Paste( *pWorkModel, maDropPos, pPage, nPasteOptions );
675cdf0e10cSrcweir
676cdf0e10cSrcweir if( !pPage )
677cdf0e10cSrcweir pPage = (SdPage*) GetSdrPageView()->GetPage();
678cdf0e10cSrcweir
679cdf0e10cSrcweir String aLayout(pPage->GetLayoutName());
680cdf0e10cSrcweir aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
681cdf0e10cSrcweir pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
682cdf0e10cSrcweir }
683cdf0e10cSrcweir }
6841cd65da9SArmin Le Grand
6851cd65da9SArmin Le Grand if(!bReturn && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_DRAWING ))
686cdf0e10cSrcweir {
687cdf0e10cSrcweir SotStorageStreamRef xStm;
688cdf0e10cSrcweir
689cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir sal_Bool bChanged = sal_False;
692cdf0e10cSrcweir
693cdf0e10cSrcweir DrawDocShellRef xShell = new DrawDocShell(SFX_CREATE_MODE_INTERNAL);
694cdf0e10cSrcweir xShell->DoInitNew(0);
695cdf0e10cSrcweir
696cdf0e10cSrcweir SdDrawDocument* pModel = xShell->GetDoc();
697cdf0e10cSrcweir pModel->InsertPage(pModel->AllocPage(false));
698cdf0e10cSrcweir
699cdf0e10cSrcweir Reference< XComponent > xComponent( xShell->GetModel(), UNO_QUERY );
700cdf0e10cSrcweir xStm->Seek( 0 );
701cdf0e10cSrcweir
702cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
703cdf0e10cSrcweir bReturn = SvxDrawingLayerImport( pModel, xInputStream, xComponent, "com.sun.star.comp.Impress.XMLOasisImporter" );
704cdf0e10cSrcweir
705cdf0e10cSrcweir if( pModel->GetPageCount() == 0 )
706cdf0e10cSrcweir {
707cdf0e10cSrcweir DBG_ERROR("empty or invalid drawing xml document on clipboard!" );
708cdf0e10cSrcweir }
709cdf0e10cSrcweir else
710cdf0e10cSrcweir {
711cdf0e10cSrcweir if( bReturn )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir if( pModel->GetSdPage( 0, PK_STANDARD )->GetObjCount() == 1 )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir // only one object
716cdf0e10cSrcweir SdrObject* pObj = pModel->GetSdPage( 0, PK_STANDARD )->GetObj( 0 );
717cdf0e10cSrcweir SdrObject* pPickObj2 = NULL;
718cdf0e10cSrcweir SdrPageView* pPV = NULL;
719cdf0e10cSrcweir PickObj( rPos, getHitTolLog(), pPickObj2, pPV );
720cdf0e10cSrcweir
721cdf0e10cSrcweir if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && pObj )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir // replace object
724cdf0e10cSrcweir SdrObject* pNewObj = pObj->Clone();
725cdf0e10cSrcweir Rectangle aPickObjRect( pPickObj2->GetCurrentBoundRect() );
726cdf0e10cSrcweir Size aPickObjSize( aPickObjRect.GetSize() );
727cdf0e10cSrcweir Point aVec( aPickObjRect.TopLeft() );
728cdf0e10cSrcweir Rectangle aObjRect( pNewObj->GetCurrentBoundRect() );
729cdf0e10cSrcweir Size aObjSize( aObjRect.GetSize() );
730cdf0e10cSrcweir
731cdf0e10cSrcweir Fraction aScaleWidth( aPickObjSize.Width(), aObjSize.Width() );
732cdf0e10cSrcweir Fraction aScaleHeight( aPickObjSize.Height(), aObjSize.Height() );
733cdf0e10cSrcweir pNewObj->NbcResize( aObjRect.TopLeft(), aScaleWidth, aScaleHeight );
734cdf0e10cSrcweir
735cdf0e10cSrcweir aVec -= aObjRect.TopLeft();
736cdf0e10cSrcweir pNewObj->NbcMove( Size( aVec.X(), aVec.Y() ) );
737cdf0e10cSrcweir
738cdf0e10cSrcweir const bool bUndo = IsUndoEnabled();
739cdf0e10cSrcweir
740cdf0e10cSrcweir if( bUndo )
741cdf0e10cSrcweir BegUndo( String( SdResId(STR_UNDO_DRAGDROP ) ) );
742cdf0e10cSrcweir pNewObj->NbcSetLayer( pPickObj->GetLayer() );
743cdf0e10cSrcweir SdrPage* pWorkPage = GetSdrPageView()->GetPage();
744cdf0e10cSrcweir pWorkPage->InsertObject( pNewObj );
745cdf0e10cSrcweir if( bUndo )
746cdf0e10cSrcweir {
747cdf0e10cSrcweir AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
748cdf0e10cSrcweir AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2 ) );
749cdf0e10cSrcweir }
750cdf0e10cSrcweir pWorkPage->RemoveObject( pPickObj2->GetOrdNum() );
751cdf0e10cSrcweir
752cdf0e10cSrcweir if( bUndo )
753cdf0e10cSrcweir {
754cdf0e10cSrcweir EndUndo();
755cdf0e10cSrcweir }
756cdf0e10cSrcweir else
757cdf0e10cSrcweir {
758cdf0e10cSrcweir SdrObject::Free(pPickObj2 );
759cdf0e10cSrcweir }
760cdf0e10cSrcweir bChanged = sal_True;
761cdf0e10cSrcweir mnAction = DND_ACTION_COPY;
762cdf0e10cSrcweir }
763cdf0e10cSrcweir else if( ( mnAction & DND_ACTION_LINK ) && pPickObj && pObj && !pPickObj->ISA( SdrGrafObj ) && !pPickObj->ISA( SdrOle2Obj ) )
764cdf0e10cSrcweir {
765cdf0e10cSrcweir SfxItemSet aSet( mpDoc->GetPool() );
766cdf0e10cSrcweir
767cdf0e10cSrcweir // set new attributes to object
768cdf0e10cSrcweir const bool bUndo = IsUndoEnabled();
769cdf0e10cSrcweir if( bUndo )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
772cdf0e10cSrcweir AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
773cdf0e10cSrcweir }
77417e8bc19SArmin Le Grand
775cdf0e10cSrcweir aSet.Put( pObj->GetMergedItemSet() );
776cdf0e10cSrcweir
777cdf0e10cSrcweir // Eckenradius soll nicht uebernommen werden.
778cdf0e10cSrcweir // In der Gallery stehen Farbverlauefe (Rechtecke)
779cdf0e10cSrcweir // welche den Eckenradius == 0 haben. Dieser soll
780cdf0e10cSrcweir // nicht auf das Objekt uebertragen werden.
781cdf0e10cSrcweir aSet.ClearItem( SDRATTR_ECKENRADIUS );
782cdf0e10cSrcweir
78317e8bc19SArmin Le Grand const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
78417e8bc19SArmin Le Grand
78517e8bc19SArmin Le Grand if(pSdrGrafObj)
78617e8bc19SArmin Le Grand {
78717e8bc19SArmin Le Grand // If we have a graphic as source object, use it's graphic
78817e8bc19SArmin Le Grand // content as fill style
78917e8bc19SArmin Le Grand aSet.Put(XFillStyleItem(XFILL_BITMAP));
79017e8bc19SArmin Le Grand aSet.Put(XFillBitmapItem(&mpDoc->GetPool(), pSdrGrafObj->GetGraphic()));
79117e8bc19SArmin Le Grand }
79217e8bc19SArmin Le Grand
79317e8bc19SArmin Le Grand pPickObj->SetMergedItemSetAndBroadcast( aSet );
794cdf0e10cSrcweir
795cdf0e10cSrcweir if( pPickObj->ISA( E3dObject ) && pObj->ISA( E3dObject ) )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir // Zusaetzlich 3D Attribute handeln
798cdf0e10cSrcweir SfxItemSet aNewSet( mpDoc->GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
799cdf0e10cSrcweir SfxItemSet aOldSet( mpDoc->GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
800cdf0e10cSrcweir
801cdf0e10cSrcweir aOldSet.Put(pPickObj->GetMergedItemSet());
802cdf0e10cSrcweir aNewSet.Put( pObj->GetMergedItemSet() );
803cdf0e10cSrcweir
804cdf0e10cSrcweir if( bUndo )
805cdf0e10cSrcweir AddUndo( new E3dAttributesUndoAction( *mpDoc, this, (E3dObject*) pPickObj, aNewSet, aOldSet, sal_False ) );
806cdf0e10cSrcweir pPickObj->SetMergedItemSetAndBroadcast( aNewSet );
807cdf0e10cSrcweir }
808cdf0e10cSrcweir
809cdf0e10cSrcweir if( bUndo )
810cdf0e10cSrcweir EndUndo();
811cdf0e10cSrcweir bChanged = sal_True;
812cdf0e10cSrcweir }
813cdf0e10cSrcweir }
814cdf0e10cSrcweir }
815cdf0e10cSrcweir
816cdf0e10cSrcweir if( !bChanged )
817cdf0e10cSrcweir {
818cdf0e10cSrcweir SdrPage* pWorkPage = pModel->GetSdPage( 0, PK_STANDARD );
819cdf0e10cSrcweir
820cdf0e10cSrcweir pWorkPage->SetRectsDirty();
821cdf0e10cSrcweir
822cdf0e10cSrcweir if( pOwnData )
823cdf0e10cSrcweir {
8240415cdefSArmin Le Grand // #120393# Clipboard data uses full object geometry range
8250415cdefSArmin Le Grand const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
826cdf0e10cSrcweir
827cdf0e10cSrcweir maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
828cdf0e10cSrcweir maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
829cdf0e10cSrcweir }
830cdf0e10cSrcweir
831cdf0e10cSrcweir bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
832cdf0e10cSrcweir }
833cdf0e10cSrcweir
834cdf0e10cSrcweir xShell->DoClose();
835cdf0e10cSrcweir }
836cdf0e10cSrcweir }
837cdf0e10cSrcweir }
8381cd65da9SArmin Le Grand
8391cd65da9SArmin Le Grand if(!bReturn && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE))
840cdf0e10cSrcweir {
841cdf0e10cSrcweir ::rtl::OUString aOUString;
842cdf0e10cSrcweir
843cdf0e10cSrcweir if( aDataHelper.GetString( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE, aOUString ) )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir SdrObject* pObj = CreateFieldControl( aOUString );
846cdf0e10cSrcweir
847cdf0e10cSrcweir if( pObj )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir Rectangle aRect( pObj->GetLogicRect() );
850cdf0e10cSrcweir Size aSize( aRect.GetSize() );
851cdf0e10cSrcweir
852cdf0e10cSrcweir maDropPos.X() -= ( aSize.Width() >> 1 );
853cdf0e10cSrcweir maDropPos.Y() -= ( aSize.Height() >> 1 );
854cdf0e10cSrcweir
855cdf0e10cSrcweir aRect.SetPos( maDropPos );
856cdf0e10cSrcweir pObj->SetLogicRect( aRect );
857cdf0e10cSrcweir InsertObjectAtView( pObj, *GetSdrPageView(), SDRINSERT_SETDEFLAYER );
8581cd65da9SArmin Le Grand bReturn = true;
859cdf0e10cSrcweir }
860cdf0e10cSrcweir }
861cdf0e10cSrcweir }
8621cd65da9SArmin Le Grand
8631cd65da9SArmin Le Grand if(!bReturn &&
8641cd65da9SArmin Le Grand !bLink &&
8651cd65da9SArmin Le Grand (CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBED_SOURCE) || CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBEDDED_OBJ)) &&
8661cd65da9SArmin Le Grand aDataHelper.HasFormat(SOT_FORMATSTR_ID_OBJECTDESCRIPTOR))
867cdf0e10cSrcweir {
868cdf0e10cSrcweir //TODO/LATER: is it possible that this format is binary?! (from old versions of SO)
869cdf0e10cSrcweir uno::Reference < io::XInputStream > xStm;
870cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc;
871cdf0e10cSrcweir
872cdf0e10cSrcweir if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
873cdf0e10cSrcweir ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE, xStm ) ||
874cdf0e10cSrcweir aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ, xStm ) ) )
875cdf0e10cSrcweir {
876cdf0e10cSrcweir if( mpDoc->GetDocSh() && ( mpDoc->GetDocSh()->GetClassName() == aObjDesc.maClassName ) )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir uno::Reference < embed::XStorage > xStore( ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm ) );
879cdf0e10cSrcweir ::sd::DrawDocShellRef xDocShRef( new ::sd::DrawDocShell( SFX_CREATE_MODE_EMBEDDED, sal_True, mpDoc->GetDocumentType() ) );
880cdf0e10cSrcweir
881cdf0e10cSrcweir // mba: BaseURL doesn't make sense for clipboard functionality
882cdf0e10cSrcweir SfxMedium *pMedium = new SfxMedium( xStore, String() );
883cdf0e10cSrcweir if( xDocShRef->DoLoad( pMedium ) )
884cdf0e10cSrcweir {
885cdf0e10cSrcweir SdDrawDocument* pModel = (SdDrawDocument*) xDocShRef->GetDoc();
886cdf0e10cSrcweir SdPage* pWorkPage = (SdPage*) pModel->GetSdPage( 0, PK_STANDARD );
887cdf0e10cSrcweir
888cdf0e10cSrcweir pWorkPage->SetRectsDirty();
889cdf0e10cSrcweir
890cdf0e10cSrcweir if( pOwnData )
891cdf0e10cSrcweir {
8920415cdefSArmin Le Grand // #120393# Clipboard data uses full object geometry range
8930415cdefSArmin Le Grand const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
894cdf0e10cSrcweir
895cdf0e10cSrcweir maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
896cdf0e10cSrcweir maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
897cdf0e10cSrcweir }
898cdf0e10cSrcweir
899cdf0e10cSrcweir // delete pages, that are not of any interest for us
900cdf0e10cSrcweir for( long i = ( pModel->GetPageCount() - 1 ); i >= 0; i-- )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir SdPage* pP = static_cast< SdPage* >( pModel->GetPage( (sal_uInt16) i ) );
903cdf0e10cSrcweir
904cdf0e10cSrcweir if( pP->GetPageKind() != PK_STANDARD )
905cdf0e10cSrcweir pModel->DeletePage( (sal_uInt16) i );
906cdf0e10cSrcweir }
907cdf0e10cSrcweir
908cdf0e10cSrcweir bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
909cdf0e10cSrcweir
910cdf0e10cSrcweir if( !pPage )
911cdf0e10cSrcweir pPage = (SdPage*) GetSdrPageView()->GetPage();
912cdf0e10cSrcweir
913cdf0e10cSrcweir String aLayout(pPage->GetLayoutName());
914cdf0e10cSrcweir aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
915cdf0e10cSrcweir pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
916cdf0e10cSrcweir }
917cdf0e10cSrcweir
918cdf0e10cSrcweir xDocShRef->DoClose();
919cdf0e10cSrcweir xDocShRef.Clear();
920cdf0e10cSrcweir
921cdf0e10cSrcweir }
922cdf0e10cSrcweir else
923cdf0e10cSrcweir {
924cdf0e10cSrcweir ::rtl::OUString aName;
925cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
926cdf0e10cSrcweir if ( xObj.is() )
927cdf0e10cSrcweir {
928cdf0e10cSrcweir svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
929cdf0e10cSrcweir
930cdf0e10cSrcweir // try to get the replacement image from the clipboard
931cdf0e10cSrcweir Graphic aGraphic;
932cdf0e10cSrcweir sal_uLong nGrFormat = 0;
933cdf0e10cSrcweir
934cdf0e10cSrcweir // (wg. Selection Manager bei Trustet Solaris)
935cdf0e10cSrcweir #ifndef SOLARIS
936cdf0e10cSrcweir /*
937cdf0e10cSrcweir if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
938cdf0e10cSrcweir nGrFormat = SOT_FORMATSTR_ID_SVXB;
939cdf0e10cSrcweir else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
940cdf0e10cSrcweir nGrFormat = SOT_FORMAT_GDIMETAFILE;
941cdf0e10cSrcweir else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
942cdf0e10cSrcweir nGrFormat = SOT_FORMAT_BITMAP;
943cdf0e10cSrcweir */
944cdf0e10cSrcweir #endif
945cdf0e10cSrcweir
946cdf0e10cSrcweir // insert replacement image ( if there is one ) into the object helper
947cdf0e10cSrcweir if ( nGrFormat )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir datatransfer::DataFlavor aDataFlavor;
950cdf0e10cSrcweir SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
951cdf0e10cSrcweir aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
952cdf0e10cSrcweir }
953cdf0e10cSrcweir
954cdf0e10cSrcweir Size aSize;
955cdf0e10cSrcweir if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
956cdf0e10cSrcweir {
957cdf0e10cSrcweir if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
958cdf0e10cSrcweir aSize = aObjDesc.maSize;
959cdf0e10cSrcweir else
960cdf0e10cSrcweir {
961cdf0e10cSrcweir MapMode aMapMode( MAP_100TH_MM );
962cdf0e10cSrcweir aSize = aObjRef.GetSize( &aMapMode );
963cdf0e10cSrcweir }
964cdf0e10cSrcweir }
965cdf0e10cSrcweir else
966cdf0e10cSrcweir {
967cdf0e10cSrcweir awt::Size aSz;
968cdf0e10cSrcweir MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
969cdf0e10cSrcweir if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
970cdf0e10cSrcweir {
971cdf0e10cSrcweir Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
972cdf0e10cSrcweir aSz.Width = aTmp.Width();
973cdf0e10cSrcweir aSz.Height = aTmp.Height();
974cdf0e10cSrcweir xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
975cdf0e10cSrcweir }
976cdf0e10cSrcweir
977cdf0e10cSrcweir try
978cdf0e10cSrcweir {
979cdf0e10cSrcweir aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
980cdf0e10cSrcweir }
981cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& )
982cdf0e10cSrcweir {
983cdf0e10cSrcweir // if the size still was not set the default size will be set later
984cdf0e10cSrcweir }
985cdf0e10cSrcweir
986cdf0e10cSrcweir aSize = Size( aSz.Width, aSz.Height );
987cdf0e10cSrcweir
988cdf0e10cSrcweir if( !aSize.Width() || !aSize.Height() )
989cdf0e10cSrcweir {
990cdf0e10cSrcweir aSize.Width() = 14100;
991cdf0e10cSrcweir aSize.Height() = 10000;
992cdf0e10cSrcweir aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
993cdf0e10cSrcweir aSz.Width = aSize.Width();
994cdf0e10cSrcweir aSz.Height = aSize.Height();
995cdf0e10cSrcweir xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
996cdf0e10cSrcweir }
997cdf0e10cSrcweir
998cdf0e10cSrcweir aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
999cdf0e10cSrcweir }
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir Size aMaxSize( mpDoc->GetMaxObjSize() );
1002cdf0e10cSrcweir
1003cdf0e10cSrcweir maDropPos.X() -= Min( aSize.Width(), aMaxSize.Width() ) >> 1;
1004cdf0e10cSrcweir maDropPos.Y() -= Min( aSize.Height(), aMaxSize.Height() ) >> 1;
1005cdf0e10cSrcweir
1006cdf0e10cSrcweir Rectangle aRect( maDropPos, aSize );
1007cdf0e10cSrcweir SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect );
1008cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView();
1009cdf0e10cSrcweir sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir if (mpViewSh!=NULL)
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
1014cdf0e10cSrcweir SfxInPlaceClient* pIpClient
1015cdf0e10cSrcweir = mpViewSh->GetViewShell()->GetIPClient();
1016cdf0e10cSrcweir if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
1017cdf0e10cSrcweir nOptions |= SDRINSERT_DONTMARK;
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir InsertObjectAtView( pObj, *pPV, nOptions );
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir if( pImageMap )
1023cdf0e10cSrcweir pObj->InsertUserData( new SdIMapInfo( *pImageMap ) );
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir if ( pObj && pObj->IsChart() )
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir bool bDisableDataTableDialog = false;
1028cdf0e10cSrcweir svt::EmbeddedObjectRef::TryRunningState( xObj );
1029cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( xObj->getComponent(), uno::UNO_QUERY );
1030cdf0e10cSrcweir if ( xProps.is() &&
1031cdf0e10cSrcweir ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) &&
1032cdf0e10cSrcweir bDisableDataTableDialog )
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ),
1035cdf0e10cSrcweir uno::makeAny( sal_False ) );
1036cdf0e10cSrcweir xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ),
1037cdf0e10cSrcweir uno::makeAny( sal_False ) );
1038cdf0e10cSrcweir uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
1039cdf0e10cSrcweir if ( xModifiable.is() )
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir xModifiable->setModified( sal_True );
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir
10461cd65da9SArmin Le Grand bReturn = true;
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir }
10511cd65da9SArmin Le Grand
10521cd65da9SArmin Le Grand if(!bReturn &&
10531cd65da9SArmin Le Grand !bLink &&
10541cd65da9SArmin Le Grand (CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE) || CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBED_SOURCE_OLE)) &&
10551cd65da9SArmin Le Grand aDataHelper.HasFormat(SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE))
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir // online insert ole if format is forced or no gdi metafile is available
1058cdf0e10cSrcweir if( (nFormat != 0) || !aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir uno::Reference < io::XInputStream > xStm;
1061cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc;
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir if ( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aObjDesc ) )
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj;
1066cdf0e10cSrcweir ::rtl::OUString aName;
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir if ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStm ) ||
1069cdf0e10cSrcweir aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStm ) )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir else
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir try
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir uno::Reference< embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
1078cdf0e10cSrcweir uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator(
1079cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance(
1080cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
1081cdf0e10cSrcweir uno::UNO_QUERY_THROW );
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
1084cdf0e10cSrcweir xTmpStor,
1085cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
1086cdf0e10cSrcweir uno::Sequence< beans::PropertyValue >() );
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
1089cdf0e10cSrcweir // for example whether the object should be an iconified one
1090cdf0e10cSrcweir xObj = aInfo.Object;
1091cdf0e10cSrcweir if ( xObj.is() )
1092cdf0e10cSrcweir mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir catch( uno::Exception& )
1095cdf0e10cSrcweir {}
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir
1098cdf0e10cSrcweir if ( xObj.is() )
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir // try to get the replacement image from the clipboard
1103cdf0e10cSrcweir Graphic aGraphic;
1104cdf0e10cSrcweir sal_uLong nGrFormat = 0;
1105cdf0e10cSrcweir
1106cdf0e10cSrcweir // (wg. Selection Manager bei Trustet Solaris)
1107cdf0e10cSrcweir #ifndef SOLARIS
1108cdf0e10cSrcweir if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
1109cdf0e10cSrcweir nGrFormat = SOT_FORMATSTR_ID_SVXB;
1110cdf0e10cSrcweir else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
1111cdf0e10cSrcweir nGrFormat = SOT_FORMAT_GDIMETAFILE;
1112cdf0e10cSrcweir else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
1113cdf0e10cSrcweir nGrFormat = SOT_FORMAT_BITMAP;
1114cdf0e10cSrcweir #endif
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir // insert replacement image ( if there is one ) into the object helper
1117cdf0e10cSrcweir if ( nGrFormat )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir datatransfer::DataFlavor aDataFlavor;
1120cdf0e10cSrcweir SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
1121cdf0e10cSrcweir aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir Size aSize;
1125cdf0e10cSrcweir if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1128cdf0e10cSrcweir aSize = aObjDesc.maSize;
1129cdf0e10cSrcweir else
1130cdf0e10cSrcweir {
1131cdf0e10cSrcweir MapMode aMapMode( MAP_100TH_MM );
1132cdf0e10cSrcweir aSize = aObjRef.GetSize( &aMapMode );
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir else
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
1138cdf0e10cSrcweir
1139cdf0e10cSrcweir awt::Size aSz;
1140cdf0e10cSrcweir try{
1141cdf0e10cSrcweir aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& )
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir // the default size will be set later
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
1151cdf0e10cSrcweir if ( aSz.Width != aTmp.Width() || aSz.Height != aTmp.Height() )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir aSz.Width = aTmp.Width();
1154cdf0e10cSrcweir aSz.Height = aTmp.Height();
1155cdf0e10cSrcweir xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir aSize = Size( aSz.Width, aSz.Height );
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir if( !aSize.Width() || !aSize.Height() )
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
1164cdf0e10cSrcweir aSz.Width = aSize.Width();
1165cdf0e10cSrcweir aSz.Height = aSize.Height();
1166cdf0e10cSrcweir xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
1167cdf0e10cSrcweir }
1168cdf0e10cSrcweir
1169cdf0e10cSrcweir aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir Size aMaxSize( mpDoc->GetMaxObjSize() );
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir maDropPos.X() -= Min( aSize.Width(), aMaxSize.Width() ) >> 1;
1175cdf0e10cSrcweir maDropPos.Y() -= Min( aSize.Height(), aMaxSize.Height() ) >> 1;
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir Rectangle aRect( maDropPos, aSize );
1178cdf0e10cSrcweir SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect );
1179cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView();
1180cdf0e10cSrcweir sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
1181cdf0e10cSrcweir
1182cdf0e10cSrcweir if (mpViewSh!=NULL)
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
1185cdf0e10cSrcweir SfxInPlaceClient* pIpClient
1186cdf0e10cSrcweir = mpViewSh->GetViewShell()->GetIPClient();
1187cdf0e10cSrcweir if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
1188cdf0e10cSrcweir nOptions |= SDRINSERT_DONTMARK;
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir InsertObjectAtView( pObj, *pPV, nOptions );
1192cdf0e10cSrcweir
1193cdf0e10cSrcweir if( pImageMap )
1194cdf0e10cSrcweir pObj->InsertUserData( new SdIMapInfo( *pImageMap ) );
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir // let the object stay in loaded state after insertion
1197cdf0e10cSrcweir pObj->Unload();
11981cd65da9SArmin Le Grand bReturn = true;
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir if( !bReturn && aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir // if no object was inserted, insert a picture
1206cdf0e10cSrcweir InsertMetaFile( aDataHelper, rPos, pImageMap, true );
1207a1ee43c7SArmin Le Grand bReturn = true;
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir }
12101cd65da9SArmin Le Grand
12111cd65da9SArmin Le Grand if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_SVXB))
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir SotStorageStreamRef xStm;
1214cdf0e10cSrcweir
1215cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) )
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir Point aInsertPos( rPos );
1218cdf0e10cSrcweir Graphic aGraphic;
1219cdf0e10cSrcweir
1220cdf0e10cSrcweir *xStm >> aGraphic;
1221cdf0e10cSrcweir
1222cdf0e10cSrcweir if( pOwnData && pOwnData->GetWorkDocument() )
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
1225cdf0e10cSrcweir SdrPage* pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
1226cdf0e10cSrcweir pWorkModel->GetSdPage( 0, PK_STANDARD ) :
1227cdf0e10cSrcweir pWorkModel->GetPage( 0 ) );
1228cdf0e10cSrcweir
1229cdf0e10cSrcweir pWorkPage->SetRectsDirty();
1230cdf0e10cSrcweir
12310415cdefSArmin Le Grand // #120393# Clipboard data uses full object geometry range
12320415cdefSArmin Le Grand const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1233cdf0e10cSrcweir
1234cdf0e10cSrcweir aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
1235cdf0e10cSrcweir aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
1236cdf0e10cSrcweir }
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir // #90129# restrict movement to WorkArea
1239cdf0e10cSrcweir Size aImageMapSize = OutputDevice::LogicToLogic(aGraphic.GetPrefSize(),
1240cdf0e10cSrcweir aGraphic.GetPrefMapMode(), MapMode(MAP_100TH_MM));
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
1243cdf0e10cSrcweir
1244cdf0e10cSrcweir InsertGraphic( aGraphic, mnAction, aInsertPos, NULL, pImageMap );
12451cd65da9SArmin Le Grand bReturn = true;
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir }
12481cd65da9SArmin Le Grand
12491cd65da9SArmin Le Grand if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(FORMAT_GDIMETAFILE))
1250cdf0e10cSrcweir {
1251cdf0e10cSrcweir Point aInsertPos( rPos );
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir if( pOwnData && pOwnData->GetWorkDocument() )
1254cdf0e10cSrcweir
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
1257cdf0e10cSrcweir SdrPage* pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
1258cdf0e10cSrcweir pWorkModel->GetSdPage( 0, PK_STANDARD ) :
1259cdf0e10cSrcweir pWorkModel->GetPage( 0 ) );
1260cdf0e10cSrcweir
1261cdf0e10cSrcweir pWorkPage->SetRectsDirty();
1262cdf0e10cSrcweir
12630415cdefSArmin Le Grand // #120393# Clipboard data uses full object geometry range
12640415cdefSArmin Le Grand const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1265cdf0e10cSrcweir
1266cdf0e10cSrcweir aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
1267cdf0e10cSrcweir aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir bReturn = InsertMetaFile( aDataHelper, aInsertPos, pImageMap, nFormat == 0 ? true : false ) ? sal_True : sal_False;
1271cdf0e10cSrcweir }
12721cd65da9SArmin Le Grand
12731cd65da9SArmin Le Grand if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(FORMAT_BITMAP))
1274cdf0e10cSrcweir {
1275a1ee43c7SArmin Le Grand BitmapEx aBmpEx;
1276a1ee43c7SArmin Le Grand
1277a1ee43c7SArmin Le Grand // get basic Bitmap data
1278a1ee43c7SArmin Le Grand aDataHelper.GetBitmapEx(FORMAT_BITMAP, aBmpEx);
1279a1ee43c7SArmin Le Grand
1280a1ee43c7SArmin Le Grand if(aBmpEx.IsEmpty())
1281a1ee43c7SArmin Le Grand {
1282a1ee43c7SArmin Le Grand // if this did not work, try to get graphic formats and convert these to bitmap
1283a1ee43c7SArmin Le Grand Graphic aGraphic;
1284a1ee43c7SArmin Le Grand
1285a1ee43c7SArmin Le Grand if(aDataHelper.GetGraphic(FORMAT_GDIMETAFILE, aGraphic))
1286a1ee43c7SArmin Le Grand {
1287a1ee43c7SArmin Le Grand aBmpEx = aGraphic.GetBitmapEx();
1288a1ee43c7SArmin Le Grand }
1289a1ee43c7SArmin Le Grand else if(aDataHelper.GetGraphic(SOT_FORMATSTR_ID_SVXB, aGraphic))
1290a1ee43c7SArmin Le Grand {
1291a1ee43c7SArmin Le Grand aBmpEx = aGraphic.GetBitmapEx();
1292a1ee43c7SArmin Le Grand }
1293a1ee43c7SArmin Le Grand else if(aDataHelper.GetGraphic(FORMAT_BITMAP, aGraphic))
1294a1ee43c7SArmin Le Grand {
1295a1ee43c7SArmin Le Grand aBmpEx = aGraphic.GetBitmapEx();
1296a1ee43c7SArmin Le Grand }
1297a1ee43c7SArmin Le Grand }
1298a1ee43c7SArmin Le Grand
1299a1ee43c7SArmin Le Grand if(!aBmpEx.IsEmpty())
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir Point aInsertPos( rPos );
1302cdf0e10cSrcweir
1303cdf0e10cSrcweir if( pOwnData && pOwnData->GetWorkDocument() )
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
1306cdf0e10cSrcweir SdrPage* pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
1307cdf0e10cSrcweir pWorkModel->GetSdPage( 0, PK_STANDARD ) :
1308cdf0e10cSrcweir pWorkModel->GetPage( 0 ) );
1309cdf0e10cSrcweir
1310cdf0e10cSrcweir pWorkPage->SetRectsDirty();
1311cdf0e10cSrcweir
13120415cdefSArmin Le Grand // #120393# Clipboard data uses full object geometry range
13130415cdefSArmin Le Grand const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1314cdf0e10cSrcweir
1315cdf0e10cSrcweir aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
1316cdf0e10cSrcweir aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir
1319cdf0e10cSrcweir // #90129# restrict movement to WorkArea
132045fd3b9aSArmin Le Grand Size aImageMapSize(aBmpEx.GetPrefSize());
1321cdf0e10cSrcweir ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
1322cdf0e10cSrcweir
132345fd3b9aSArmin Le Grand InsertGraphic( aBmpEx, mnAction, aInsertPos, NULL, pImageMap );
13241cd65da9SArmin Le Grand bReturn = true;
1325cdf0e10cSrcweir }
1326a1ee43c7SArmin Le Grand }
13271cd65da9SArmin Le Grand
13281cd65da9SArmin Le Grand if(!bReturn && pPickObj && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_XFA ) )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir SotStorageStreamRef xStm;
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_XFA, xStm ) )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir XFillExchangeData aFillData( XFillAttrSetItem( &mpDoc->GetPool() ) );
1335cdf0e10cSrcweir
1336cdf0e10cSrcweir *xStm >> aFillData;
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir if( IsUndoEnabled() )
1339cdf0e10cSrcweir {
1340cdf0e10cSrcweir BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
1341cdf0e10cSrcweir AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
1342cdf0e10cSrcweir EndUndo();
1343cdf0e10cSrcweir }
1344cdf0e10cSrcweir
1345cdf0e10cSrcweir XFillAttrSetItem* pSetItem = aFillData.GetXFillAttrSetItem();
1346cdf0e10cSrcweir SfxItemSet rSet = pSetItem->GetItemSet();
1347cdf0e10cSrcweir XFillStyle eFill= ( (XFillStyleItem&) rSet.Get( XATTR_FILLSTYLE ) ).GetValue();
1348cdf0e10cSrcweir
1349cdf0e10cSrcweir if( eFill == XFILL_SOLID || eFill == XFILL_NONE )
1350cdf0e10cSrcweir {
1351cdf0e10cSrcweir const XFillColorItem& rColItem = (XFillColorItem&) rSet.Get( XATTR_FILLCOLOR );
1352cdf0e10cSrcweir Color aColor( rColItem.GetColorValue() );
1353cdf0e10cSrcweir String aName( rColItem.GetName() );
1354cdf0e10cSrcweir SfxItemSet aSet( mpDoc->GetPool() );
1355cdf0e10cSrcweir sal_Bool bClosed = pPickObj->IsClosedObj();
1356cdf0e10cSrcweir ::sd::Window* pWin = mpViewSh->GetActiveWindow();
1357cdf0e10cSrcweir sal_uInt16 nHitLog = (sal_uInt16) pWin->PixelToLogic(
1358cdf0e10cSrcweir Size(FuPoor::HITPIX, 0 ) ).Width();
1359cdf0e10cSrcweir const long n2HitLog = nHitLog << 1;
1360cdf0e10cSrcweir Point aHitPosR( rPos );
1361cdf0e10cSrcweir Point aHitPosL( rPos );
1362cdf0e10cSrcweir Point aHitPosT( rPos );
1363cdf0e10cSrcweir Point aHitPosB( rPos );
1364cdf0e10cSrcweir const SetOfByte* pVisiLayer = &GetSdrPageView()->GetVisibleLayers();
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir aHitPosR.X() += n2HitLog;
1367cdf0e10cSrcweir aHitPosL.X() -= n2HitLog;
1368cdf0e10cSrcweir aHitPosT.Y() += n2HitLog;
1369cdf0e10cSrcweir aHitPosB.Y() -= n2HitLog;
1370cdf0e10cSrcweir
1371cdf0e10cSrcweir if( bClosed &&
1372cdf0e10cSrcweir SdrObjectPrimitiveHit(*pPickObj, aHitPosR, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1373cdf0e10cSrcweir SdrObjectPrimitiveHit(*pPickObj, aHitPosL, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1374cdf0e10cSrcweir SdrObjectPrimitiveHit(*pPickObj, aHitPosT, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1375cdf0e10cSrcweir SdrObjectPrimitiveHit(*pPickObj, aHitPosB, nHitLog, *GetSdrPageView(), pVisiLayer, false) )
1376cdf0e10cSrcweir {
1377cdf0e10cSrcweir // area fill
1378cdf0e10cSrcweir if(eFill == XFILL_SOLID )
1379cdf0e10cSrcweir aSet.Put(XFillColorItem(aName, aColor));
1380cdf0e10cSrcweir
1381cdf0e10cSrcweir aSet.Put( XFillStyleItem( eFill ) );
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir else
1384cdf0e10cSrcweir aSet.Put( XLineColorItem( aName, aColor ) );
1385cdf0e10cSrcweir
1386cdf0e10cSrcweir // Textfarbe hinzufuegen
1387cdf0e10cSrcweir pPickObj->SetMergedItemSetAndBroadcast( aSet );
1388cdf0e10cSrcweir }
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir }
13911cd65da9SArmin Le Grand
13921cd65da9SArmin Le Grand if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_HTML))
1393cdf0e10cSrcweir {
1394cdf0e10cSrcweir SotStorageStreamRef xStm;
1395cdf0e10cSrcweir
1396cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_HTML, xStm ) )
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir xStm->Seek( 0 );
1399cdf0e10cSrcweir // mba: clipboard always must contain absolute URLs (could be from alien source)
1400cdf0e10cSrcweir bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_HTML, maDropPos, pPage, nPasteOptions );
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir }
14031cd65da9SArmin Le Grand
14041cd65da9SArmin Le Grand if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EDITENGINE))
1405cdf0e10cSrcweir {
1406cdf0e10cSrcweir SotStorageStreamRef xStm;
1407cdf0e10cSrcweir
1408cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_EDITENGINE, xStm ) )
1409cdf0e10cSrcweir {
1410cdf0e10cSrcweir OutlinerView* pOLV = GetTextEditOutlinerView();
1411cdf0e10cSrcweir
1412cdf0e10cSrcweir xStm->Seek( 0 );
1413cdf0e10cSrcweir
1414cdf0e10cSrcweir if( pOLV )
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir Rectangle aRect( pOLV->GetOutputArea() );
1417cdf0e10cSrcweir Point aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
1418cdf0e10cSrcweir
1419cdf0e10cSrcweir if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
1420cdf0e10cSrcweir {
1421cdf0e10cSrcweir // mba: clipboard always must contain absolute URLs (could be from alien source)
1422cdf0e10cSrcweir pOLV->Read( *xStm, String(), EE_FORMAT_BIN, sal_False, mpDocSh->GetHeaderAttributes() );
14231cd65da9SArmin Le Grand bReturn = true;
1424cdf0e10cSrcweir }
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir
1427cdf0e10cSrcweir if( !bReturn )
1428cdf0e10cSrcweir // mba: clipboard always must contain absolute URLs (could be from alien source)
1429cdf0e10cSrcweir bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_BIN, maDropPos, pPage, nPasteOptions );
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir }
14321cd65da9SArmin Le Grand
14331cd65da9SArmin Le Grand if(!bReturn && !bLink && CHECK_FORMAT_TRANS(FORMAT_RTF))
1434cdf0e10cSrcweir {
1435cdf0e10cSrcweir SotStorageStreamRef xStm;
1436cdf0e10cSrcweir
1437cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
1438cdf0e10cSrcweir {
1439cdf0e10cSrcweir xStm->Seek( 0 );
1440cdf0e10cSrcweir
1441cdf0e10cSrcweir if( bTable )
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir bReturn = PasteRTFTable( xStm, pPage, nPasteOptions );
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir else
1446cdf0e10cSrcweir {
1447cdf0e10cSrcweir OutlinerView* pOLV = GetTextEditOutlinerView();
1448cdf0e10cSrcweir
1449cdf0e10cSrcweir if( pOLV )
1450cdf0e10cSrcweir {
1451cdf0e10cSrcweir Rectangle aRect( pOLV->GetOutputArea() );
1452cdf0e10cSrcweir Point aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
1453cdf0e10cSrcweir
1454cdf0e10cSrcweir if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir // mba: clipboard always must contain absolute URLs (could be from alien source)
1457cdf0e10cSrcweir pOLV->Read( *xStm, String(), EE_FORMAT_RTF, sal_False, mpDocSh->GetHeaderAttributes() );
14581cd65da9SArmin Le Grand bReturn = true;
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir }
1461cdf0e10cSrcweir
1462cdf0e10cSrcweir if( !bReturn )
1463cdf0e10cSrcweir // mba: clipboard always must contain absolute URLs (could be from alien source)
1464cdf0e10cSrcweir bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_RTF, maDropPos, pPage, nPasteOptions );
1465cdf0e10cSrcweir }
1466cdf0e10cSrcweir }
1467cdf0e10cSrcweir }
14681cd65da9SArmin Le Grand
14691cd65da9SArmin Le Grand if(!bReturn && CHECK_FORMAT_TRANS(FORMAT_FILE_LIST))
1470cdf0e10cSrcweir {
1471cdf0e10cSrcweir FileList aDropFileList;
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir if( aDataHelper.GetFileList( FORMAT_FILE_LIST, aDropFileList ) )
1474cdf0e10cSrcweir {
1475cdf0e10cSrcweir maDropFileVector.clear();
1476cdf0e10cSrcweir
1477cdf0e10cSrcweir for( sal_uLong i = 0, nCount = aDropFileList.Count(); i < nCount; i++ )
1478cdf0e10cSrcweir maDropFileVector.push_back( aDropFileList.GetFile( i ) );
1479cdf0e10cSrcweir
1480cdf0e10cSrcweir maDropInsertFileTimer.Start();
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir
14831cd65da9SArmin Le Grand bReturn = true;
1484cdf0e10cSrcweir }
14851cd65da9SArmin Le Grand
14861cd65da9SArmin Le Grand if(!bReturn && CHECK_FORMAT_TRANS(FORMAT_FILE))
1487cdf0e10cSrcweir {
1488cdf0e10cSrcweir String aDropFile;
1489cdf0e10cSrcweir
1490cdf0e10cSrcweir if( aDataHelper.GetString( FORMAT_FILE, aDropFile ) )
1491cdf0e10cSrcweir {
1492cdf0e10cSrcweir maDropFileVector.clear();
1493cdf0e10cSrcweir maDropFileVector.push_back( aDropFile );
1494cdf0e10cSrcweir maDropInsertFileTimer.Start();
1495cdf0e10cSrcweir }
1496cdf0e10cSrcweir
14971cd65da9SArmin Le Grand bReturn = true;
1498cdf0e10cSrcweir }
14991cd65da9SArmin Le Grand
15001cd65da9SArmin Le Grand if(!bReturn && !bLink && CHECK_FORMAT_TRANS(FORMAT_STRING))
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir if( ( FORMAT_STRING == nFormat ) ||
1503cdf0e10cSrcweir ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) &&
1504cdf0e10cSrcweir !aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
1505cdf0e10cSrcweir !aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILENAME ) ) )
1506cdf0e10cSrcweir {
1507cdf0e10cSrcweir ::rtl::OUString aOUString;
1508cdf0e10cSrcweir
1509cdf0e10cSrcweir if( aDataHelper.GetString( FORMAT_STRING, aOUString ) )
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir OutlinerView* pOLV = GetTextEditOutlinerView();
1512cdf0e10cSrcweir
1513cdf0e10cSrcweir if( pOLV )
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir pOLV->InsertText( aOUString );
15161cd65da9SArmin Le Grand bReturn = true;
1517cdf0e10cSrcweir }
1518cdf0e10cSrcweir
1519cdf0e10cSrcweir if( !bReturn )
1520cdf0e10cSrcweir bReturn = SdrView::Paste( aOUString, maDropPos, pPage, nPasteOptions );
1521cdf0e10cSrcweir }
1522cdf0e10cSrcweir }
1523cdf0e10cSrcweir }
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir MarkListHasChanged();
1526cdf0e10cSrcweir mbIsDropAllowed = sal_True;
1527cdf0e10cSrcweir rDnDAction = mnAction;
1528cdf0e10cSrcweir delete pImageMap;
1529cdf0e10cSrcweir
1530cdf0e10cSrcweir return bReturn;
1531cdf0e10cSrcweir }
1532cdf0e10cSrcweir
1533cdf0e10cSrcweir extern void CreateTableFromRTF( SvStream& rStream, SdDrawDocument* pModel );
1534cdf0e10cSrcweir
PasteRTFTable(SotStorageStreamRef xStm,SdrPage * pPage,sal_uLong nPasteOptions)1535cdf0e10cSrcweir bool View::PasteRTFTable( SotStorageStreamRef xStm, SdrPage* pPage, sal_uLong nPasteOptions )
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir SdDrawDocument* pModel = new SdDrawDocument( DOCUMENT_TYPE_IMPRESS, mpDocSh );
1538cdf0e10cSrcweir pModel->NewOrLoadCompleted(NEW_DOC);
1539cdf0e10cSrcweir pModel->GetItemPool().SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
1540cdf0e10cSrcweir pModel->InsertPage(pModel->AllocPage(false));
1541cdf0e10cSrcweir
1542cdf0e10cSrcweir Reference< XComponent > xComponent( new SdXImpressDocument( pModel, sal_True ) );
1543cdf0e10cSrcweir pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );
1544cdf0e10cSrcweir
1545cdf0e10cSrcweir CreateTableFromRTF( *xStm, pModel );
1546cdf0e10cSrcweir bool bRet = Paste( *pModel, maDropPos, pPage, nPasteOptions );
1547cdf0e10cSrcweir
1548cdf0e10cSrcweir xComponent->dispose();
1549cdf0e10cSrcweir xComponent.clear();
1550cdf0e10cSrcweir
1551cdf0e10cSrcweir delete pModel;
1552cdf0e10cSrcweir
1553cdf0e10cSrcweir return bRet;
1554cdf0e10cSrcweir }
1555cdf0e10cSrcweir
1556cdf0e10cSrcweir } // end of namespace sd
1557