1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
22 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
23 #include <com/sun/star/embed/MSOLEObjectSystemCreator.hpp>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <sot/filelist.hxx>
26 #include <unotools/pathoptions.hxx>
27 #include <editeng/editdata.hxx>
28 #include <svl/urlbmk.hxx>
29 #include <svx/xexch.hxx>
30 #include <svx/xflclit.hxx>
31 #include <svx/xlnclit.hxx>
32 #include <svx/svdpagv.hxx>
33 #include <editeng/eeitem.hxx>
34 #include <editeng/colritem.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <svx/svditer.hxx>
37 #include <svx/svdogrp.hxx>
38 #include <svx/svdoole2.hxx>
39 #include <svx/svdograf.hxx>
40 #include <svx/svdetc.hxx>
41 #include <svx/svdundo.hxx>
42 #include <sfx2/app.hxx>
43 #include <svl/itempool.hxx>
44 #include <comphelper/classids.hxx>
45 #include <svx/fmmodel.hxx>
46 #include <sot/formats.hxx>
47 #include <editeng/outliner.hxx>
48 #include <editeng/editeng.hxx>
49 #include <svx/obj3d.hxx>
50 #include <svx/e3dundo.hxx>
51 #include <svx/unomodel.hxx>
52 #include <unotools/streamwrap.hxx>
53 #include <vcl/metaact.hxx>
54 #include <svx/svxids.hrc>
55 #include <toolkit/helper/vclunohelper.hxx>
57 #include "DrawDocShell.hxx"
62 #include "DrawViewShell.hxx"
63 #include "drawdoc.hxx"
64 #include "sdresid.hxx"
65 #include "strings.hrc"
66 #include "imapinfo.hxx"
67 #include "SlideSorterViewShell.hxx"
69 #include "unomodel.hxx"
70 #include "ViewClipboard.hxx"
72 #include <sfx2/ipclient.hxx>
73 #include <comphelper/storagehelper.hxx>
74 #include <comphelper/processfactory.hxx>
75 #include <tools/stream.hxx>
76 #include <vcl/cvtgrf.hxx>
77 #include <svx/sdrhittesthelper.hxx>
83 using namespace ::com::sun::star
;
84 using namespace ::com::sun::star::lang
;
85 using namespace ::com::sun::star::uno
;
86 using namespace ::com::sun::star::io
;
87 using namespace ::com::sun::star::datatransfer
;
88 using namespace ::com::sun::star::datatransfer::clipboard
;
92 #define CHECK_FORMAT_TRANS( _def_Type ) ( ( nFormat == (_def_Type) || !nFormat ) && aDataHelper.HasFormat( _def_Type ) )
94 /*************************************************************************
98 \************************************************************************/
100 struct ImpRememberOrigAndClone
106 SdrObject
* ImpGetClone(std::vector
<ImpRememberOrigAndClone
*>& aConnectorContainer
, SdrObject
* pConnObj
)
108 for(sal_uInt32
a(0); a
< aConnectorContainer
.size(); a
++)
110 if(pConnObj
== aConnectorContainer
[a
]->pOrig
)
111 return aConnectorContainer
[a
]->pClone
;
116 // restrict movement to WorkArea
117 void ImpCheckInsertPos(Point
& rPos
, const Size
& rSize
, const Rectangle
& rWorkArea
)
119 if(!rWorkArea
.IsEmpty())
121 Rectangle
aMarkRect(Point(rPos
.X() - (rSize
.Width() / 2), rPos
.Y() - (rSize
.Height() / 2)), rSize
);
123 if(!aMarkRect
.IsInside(rWorkArea
))
125 if(aMarkRect
.Left() < rWorkArea
.Left())
127 rPos
.X() += rWorkArea
.Left() - aMarkRect
.Left();
130 if(aMarkRect
.Right() > rWorkArea
.Right())
132 rPos
.X() -= aMarkRect
.Right() - rWorkArea
.Right();
135 if(aMarkRect
.Top() < rWorkArea
.Top())
137 rPos
.Y() += rWorkArea
.Top() - aMarkRect
.Top();
140 if(aMarkRect
.Bottom() > rWorkArea
.Bottom())
142 rPos
.Y() -= aMarkRect
.Bottom() - rWorkArea
.Bottom();
148 bool View::InsertMetaFile( TransferableDataHelper
& rDataHelper
, const Point
& rPos
, ImageMap
* pImageMap
, bool bOptimize
)
152 if( !rDataHelper
.GetGDIMetaFile( FORMAT_GDIMETAFILE
, aMtf
) )
155 bool bVector
= false;
158 // check if metafile only contains a pixel image, if so insert a bitmap instead
161 MetaAction
* pAction
= aMtf
.FirstAction();
162 while( pAction
&& !bVector
)
164 switch( pAction
->GetType() )
166 case META_POINT_ACTION
:
167 case META_LINE_ACTION
:
168 case META_RECT_ACTION
:
169 case META_ROUNDRECT_ACTION
:
170 case META_ELLIPSE_ACTION
:
171 case META_ARC_ACTION
:
172 case META_PIE_ACTION
:
173 case META_CHORD_ACTION
:
174 case META_POLYLINE_ACTION
:
175 case META_POLYGON_ACTION
:
176 case META_POLYPOLYGON_ACTION
:
177 case META_TEXT_ACTION
:
178 case META_TEXTARRAY_ACTION
:
179 case META_STRETCHTEXT_ACTION
:
180 case META_TEXTRECT_ACTION
:
181 case META_GRADIENT_ACTION
:
182 case META_HATCH_ACTION
:
183 case META_WALLPAPER_ACTION
:
184 case META_EPS_ACTION
:
185 case META_TEXTLINE_ACTION
:
186 case META_FLOATTRANSPARENT_ACTION
:
187 case META_GRADIENTEX_ACTION
:
188 case META_BMPSCALEPART_ACTION
:
189 case META_BMPEXSCALEPART_ACTION
:
192 case META_BMP_ACTION
:
193 case META_BMPSCALE_ACTION
:
194 case META_BMPEX_ACTION
:
195 case META_BMPEXSCALE_ACTION
:
196 if( aGraphic
.GetType() != GRAPHIC_NONE
)
200 else switch( pAction
->GetType() )
202 case META_BMP_ACTION
:
204 MetaBmpAction
* pBmpAction
= dynamic_cast< MetaBmpAction
* >( pAction
);
206 aGraphic
= Graphic( pBmpAction
->GetBitmap() );
209 case META_BMPSCALE_ACTION
:
211 MetaBmpScaleAction
* pBmpScaleAction
= dynamic_cast< MetaBmpScaleAction
* >( pAction
);
212 if( pBmpScaleAction
)
213 aGraphic
= Graphic( pBmpScaleAction
->GetBitmap() );
216 case META_BMPEX_ACTION
:
218 MetaBmpExAction
* pBmpExAction
= dynamic_cast< MetaBmpExAction
* >( pAction
);
220 aGraphic
= Graphic( pBmpExAction
->GetBitmapEx() );
223 case META_BMPEXSCALE_ACTION
:
225 MetaBmpExScaleAction
* pBmpExScaleAction
= dynamic_cast< MetaBmpExScaleAction
* >( pAction
);
226 if( pBmpExScaleAction
)
227 aGraphic
= Graphic( pBmpExScaleAction
->GetBitmapEx() );
233 pAction
= aMtf
.NextAction();
237 // it is not a vector metafile but it also has no graphic?
238 if( !bVector
&& (aGraphic
.GetType() == GRAPHIC_NONE
) )
241 // restrict movement to WorkArea
242 Point
aInsertPos( rPos
);
244 aImageSize
= bVector
? aMtf
.GetPrefSize() : aGraphic
.GetSizePixel();
245 ImpCheckInsertPos(aInsertPos
, aImageSize
, GetWorkArea());
248 aGraphic
= Graphic( aMtf
);
250 aGraphic
.SetPrefMapMode( aMtf
.GetPrefMapMode() );
251 aGraphic
.SetPrefSize( aMtf
.GetPrefSize() );
252 InsertGraphic( aGraphic
, mnAction
, aInsertPos
, NULL
, pImageMap
);
257 sal_Bool
View::InsertData( const TransferableDataHelper
& rDataHelper
,
258 const Point
& rPos
, sal_Int8
& rDnDAction
, sal_Bool bDrag
,
259 sal_uLong nFormat
, sal_uInt16 nPage
, sal_uInt16 nLayer
)
262 mnAction
= rDnDAction
;
263 mbIsDropAllowed
= sal_False
;
265 TransferableDataHelper
aDataHelper( rDataHelper
);
266 SdrObject
* pPickObj
= NULL
;
267 SdPage
* pPage
= NULL
;
268 ImageMap
* pImageMap
= NULL
;
269 sal_Bool bReturn
= sal_False
;
270 sal_Bool bLink
= ( ( mnAction
& DND_ACTION_LINK
) != 0 );
271 sal_Bool bCopy
= ( ( ( mnAction
& DND_ACTION_COPY
) != 0 ) || bLink
);
272 sal_uLong nPasteOptions
= SDRINSERT_SETDEFLAYER
;
274 if (mpViewSh
!= NULL
)
276 OSL_ASSERT (mpViewSh
->GetViewShell()!=NULL
);
277 SfxInPlaceClient
* pIpClient
= mpViewSh
->GetViewShell()->GetIPClient();
278 if( mpViewSh
->ISA(::sd::slidesorter::SlideSorterViewShell
)
279 || (pIpClient
!=NULL
&& pIpClient
->IsObjectInPlaceActive()))
280 nPasteOptions
|= SDRINSERT_DONTMARK
;
285 SdrPageView
* pPV
= NULL
;
286 PickObj( rPos
, getHitTolLog(), pPickObj
, pPV
);
289 if( nPage
!= SDRPAGE_NOTFOUND
)
290 pPage
= (SdPage
*) mrDoc
.GetPage( nPage
);
292 SdTransferable
* pOwnData
= NULL
;
293 SdTransferable
* pImplementation
= SdTransferable::getImplementation( aDataHelper
.GetTransferable() );
295 // try to get own transfer data
296 if( pImplementation
)
298 if( SD_MOD()->pTransferClip
== (SdTransferable
*) pImplementation
)
299 pOwnData
= SD_MOD()->pTransferClip
;
300 else if( SD_MOD()->pTransferDrag
== (SdTransferable
*) pImplementation
)
301 pOwnData
= SD_MOD()->pTransferDrag
;
302 else if( SD_MOD()->pTransferSelection
== (SdTransferable
*) pImplementation
)
303 pOwnData
= SD_MOD()->pTransferSelection
;
307 if( !pOwnData
&& aDataHelper
.HasFormat( SOT_FORMATSTR_ID_SVIM
) )
309 SotStorageStreamRef xStm
;
311 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_SVIM
, xStm
) )
313 pImageMap
= new ImageMap
;
314 // mba: clipboard always must contain absolute URLs (could be from alien source)
315 pImageMap
->Read( *xStm
, String() );
320 // check special cases for pasting table formats as RTL
321 if( !bLink
&& (!nFormat
|| (nFormat
== SOT_FORMAT_RTF
)) )
323 // if the objekt supports rtf and there is a table involved, default is to create a table
324 if( aDataHelper
.HasFormat( SOT_FORMAT_RTF
) && ! aDataHelper
.HasFormat( SOT_FORMATSTR_ID_DRAWING
) )
326 SotStorageStreamRef xStm
;
328 if( aDataHelper
.GetSotStorageStream( FORMAT_RTF
, xStm
) )
333 while (xStm
->ReadLine(aLine
))
335 sal_Int32 x
= aLine
.indexOf( "\\trowd" );
339 nFormat
= FORMAT_RTF
;
347 if( pOwnData
&& !nFormat
)
349 const View
* pSourceView
= pOwnData
->GetView();
352 if( pOwnData
->GetDocShell() && pOwnData
->IsPageTransferable() && ISA( View
) )
354 mpClipboard
->HandlePageDrop (*pOwnData
);
356 else if( pSourceView
)
358 if( pSourceView
== this )
361 if( nLayer
!= SDRLAYER_NOTFOUND
)
363 // drop on layer tab bar
364 SdrLayerAdmin
& rLayerAdmin
= mrDoc
.GetLayerAdmin();
365 SdrLayer
* pLayer
= rLayerAdmin
.GetLayerPerID( nLayer
);
366 SdrPageView
* pPV
= GetSdrPageView();
367 String
aLayer( pLayer
->GetName() );
369 if( !pPV
->IsLayerLocked( aLayer
) )
371 pOwnData
->SetInternalMove( sal_True
);
374 for( sal_uLong nM
= 0; nM
< GetMarkedObjectCount(); nM
++ )
376 SdrMark
* pM
= GetSdrMarkByIndex( nM
);
377 SdrObject
* pO
= pM
->GetMarkedSdrObj();
382 if( IsUndoEnabled() )
384 BegUndo(String(SdResId(STR_MODIFYLAYER
)));
385 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO
, pO
->GetLayer(), (SdrLayerID
)nLayer
));
389 pO
->SetLayer( (SdrLayerID
) nLayer
);
398 SdrPageView
* pPV
= GetSdrPageView();
399 sal_Bool bDropOnTabBar
= sal_True
;
401 if( !pPage
&& pPV
->GetPage()->GetPageNum() != mnDragSrcPgNum
)
403 pPage
= (SdPage
*) pPV
->GetPage();
404 bDropOnTabBar
= sal_False
;
409 // drop on other page
410 String
aActiveLayer( GetActiveLayer() );
412 if( !pPV
->IsLayerLocked( aActiveLayer
) )
414 if( !IsPresObjSelected() )
416 SdrMarkList
* pMarkList
;
418 if( (mnDragSrcPgNum
!= SDRPAGE_NOTFOUND
) && (mnDragSrcPgNum
!= pPV
->GetPage()->GetPageNum()) )
420 pMarkList
= mpDragSrcMarkList
;
424 // actual mark list is used
425 pMarkList
= new SdrMarkList( GetMarkedObjectList());
428 pMarkList
->ForceSort();
430 // stuff to remember originals and clones
431 std::vector
<ImpRememberOrigAndClone
*> aConnectorContainer
;
432 sal_uInt32 a
, nConnectorCount(0L);
435 // calculate real position of current
436 // source objects, if necessary (#103207)
437 if( pOwnData
== SD_MOD()->pTransferSelection
)
439 Rectangle aCurBoundRect
;
441 if( pMarkList
->TakeBoundRect( pPV
, aCurBoundRect
) )
442 aCurPos
= aCurBoundRect
.TopLeft();
444 aCurPos
= pOwnData
->GetStartPos();
447 aCurPos
= pOwnData
->GetStartPos();
449 const Size
aVector( maDropPos
.X() - aCurPos
.X(), maDropPos
.Y() - aCurPos
.Y() );
451 for(a
= 0; a
< pMarkList
->GetMarkCount(); a
++)
453 SdrMark
* pM
= pMarkList
->GetMark(a
);
454 SdrObject
* pObj
= pM
->GetMarkedSdrObj()->Clone();
460 // do a NbcMove(...) instead of setting SnapRects here
461 pObj
->NbcMove(aVector
);
464 pPage
->InsertObject(pObj
);
466 if( IsUndoEnabled() )
468 BegUndo(String(SdResId(STR_UNDO_DRAGDROP
)));
469 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj
));
473 ImpRememberOrigAndClone
* pRem
= new ImpRememberOrigAndClone
;
474 pRem
->pOrig
= pM
->GetMarkedSdrObj();
476 aConnectorContainer
.push_back(pRem
);
478 if(pObj
->ISA(SdrEdgeObj
))
483 // try to re-establish connections at clones
486 for(a
= 0; a
< aConnectorContainer
.size(); a
++)
488 ImpRememberOrigAndClone
* pRem
= aConnectorContainer
[a
];
490 if(pRem
->pClone
->ISA(SdrEdgeObj
))
492 SdrEdgeObj
* pOrigEdge
= (SdrEdgeObj
*)pRem
->pOrig
;
493 SdrEdgeObj
* pCloneEdge
= (SdrEdgeObj
*)pRem
->pClone
;
495 // test first connection
496 SdrObjConnection
& rConn0
= pOrigEdge
->GetConnection(sal_False
);
497 SdrObject
* pConnObj
= rConn0
.GetObject();
500 SdrObject
* pConnClone
= ImpGetClone(aConnectorContainer
, pConnObj
);
503 // if dest obj was cloned, too, re-establish connection
504 pCloneEdge
->ConnectToNode(sal_False
, pConnClone
);
505 pCloneEdge
->GetConnection(sal_False
).SetConnectorId(rConn0
.GetConnectorId());
509 // set position of connection point of original connected object
510 const SdrGluePointList
* pGlueList
= pConnObj
->GetGluePointList();
513 sal_uInt16 nInd
= pGlueList
->FindGluePoint(rConn0
.GetConnectorId());
515 if(SDRGLUEPOINT_NOTFOUND
!= nInd
)
517 const SdrGluePoint
& rGluePoint
= (*pGlueList
)[nInd
];
518 Point aPosition
= rGluePoint
.GetAbsolutePos(*pConnObj
);
519 aPosition
.X() += aVector
.A();
520 aPosition
.Y() += aVector
.B();
521 pCloneEdge
->SetTailPoint(sal_False
, aPosition
);
527 // test second connection
528 SdrObjConnection
& rConn1
= pOrigEdge
->GetConnection(sal_True
);
529 pConnObj
= rConn1
.GetObject();
532 SdrObject
* pConnClone
= ImpGetClone(aConnectorContainer
, pConnObj
);
535 // if dest obj was cloned, too, re-establish connection
536 pCloneEdge
->ConnectToNode(sal_True
, pConnClone
);
537 pCloneEdge
->GetConnection(sal_True
).SetConnectorId(rConn1
.GetConnectorId());
541 // set position of connection point of original connected object
542 const SdrGluePointList
* pGlueList
= pConnObj
->GetGluePointList();
545 sal_uInt16 nInd
= pGlueList
->FindGluePoint(rConn1
.GetConnectorId());
547 if(SDRGLUEPOINT_NOTFOUND
!= nInd
)
549 const SdrGluePoint
& rGluePoint
= (*pGlueList
)[nInd
];
550 Point aPosition
= rGluePoint
.GetAbsolutePos(*pConnObj
);
551 aPosition
.X() += aVector
.A();
552 aPosition
.Y() += aVector
.B();
553 pCloneEdge
->SetTailPoint(sal_True
, aPosition
);
562 // cleanup remember classes
563 for(a
= 0; a
< aConnectorContainer
.size(); a
++)
564 delete aConnectorContainer
[a
];
566 if( pMarkList
!= mpDragSrcMarkList
)
573 maDropErrorTimer
.Start();
580 pOwnData
->SetInternalMove( sal_True
);
581 MoveAllMarked( Size( maDropPos
.X() - pOwnData
->GetStartPos().X(),
582 maDropPos
.Y() - pOwnData
->GetStartPos().Y() ), bCopy
);
590 if( !pSourceView
->IsPresObjSelected() )
592 // model is owned by from AllocModel() created DocShell
593 SdDrawDocument
* pSourceDoc
= (SdDrawDocument
*) pSourceView
->GetModel();
594 pSourceDoc
->CreatingDataObj( pOwnData
);
595 SdDrawDocument
* pModel
= (SdDrawDocument
*) pSourceView
->GetMarkedObjModel();
596 bReturn
= Paste( *pModel
, maDropPos
, pPage
, nPasteOptions
);
599 pPage
= (SdPage
*) GetSdrPageView()->GetPage();
601 String
aLayout( pPage
->GetLayoutName() );
602 aLayout
.Erase( aLayout
.SearchAscii( SD_LT_SEPARATOR
) );
603 pPage
->SetPresentationLayout( aLayout
, sal_False
, sal_False
);
604 pSourceDoc
->CreatingDataObj( NULL
);
608 maDropErrorTimer
.Start();
615 SdDrawDocument
* pWorkModel
= (SdDrawDocument
*) pOwnData
->GetWorkDocument();
616 SdPage
* pWorkPage
= (SdPage
*) pWorkModel
->GetSdPage( 0, PK_STANDARD
);
618 pWorkPage
->SetRectsDirty();
620 // Use SnapRect, not BoundRect
621 Size
aSize( pWorkPage
->GetAllObjSnapRect().GetSize() );
623 maDropPos
.X() = pOwnData
->GetStartPos().X() + ( aSize
.Width() >> 1 );
624 maDropPos
.Y() = pOwnData
->GetStartPos().Y() + ( aSize
.Height() >> 1 );
626 // delete pages, that are not of any interest for us
627 for( long i
= ( pWorkModel
->GetPageCount() - 1 ); i
>= 0; i
-- )
629 SdPage
* pP
= static_cast< SdPage
* >( pWorkModel
->GetPage( (sal_uInt16
) i
) );
631 if( pP
->GetPageKind() != PK_STANDARD
)
632 pWorkModel
->DeletePage( (sal_uInt16
) i
);
635 bReturn
= Paste( *pWorkModel
, maDropPos
, pPage
, nPasteOptions
);
638 pPage
= (SdPage
*) GetSdrPageView()->GetPage();
640 String
aLayout(pPage
->GetLayoutName());
641 aLayout
.Erase(aLayout
.SearchAscii(SD_LT_SEPARATOR
));
642 pPage
->SetPresentationLayout( aLayout
, sal_False
, sal_False
);
645 else if( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_DRAWING
) )
647 SotStorageStreamRef xStm
;
649 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING
, xStm
) )
651 sal_Bool bChanged
= sal_False
;
653 DrawDocShellRef xShell
= new DrawDocShell(SFX_CREATE_MODE_INTERNAL
);
654 xShell
->DoInitNew(0);
656 SdDrawDocument
* pModel
= xShell
->GetDoc();
657 pModel
->InsertPage(pModel
->AllocPage(false));
659 Reference
< XComponent
> xComponent( xShell
->GetModel(), UNO_QUERY
);
662 com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> xInputStream( new utl::OInputStreamWrapper( *xStm
) );
663 bReturn
= SvxDrawingLayerImport( pModel
, xInputStream
, xComponent
, "com.sun.star.comp.Impress.XMLOasisImporter" );
665 if( pModel
->GetPageCount() == 0 )
667 OSL_FAIL("empty or invalid drawing xml document on clipboard!" );
673 if( pModel
->GetSdPage( 0, PK_STANDARD
)->GetObjCount() == 1 )
676 SdrObject
* pObj
= pModel
->GetSdPage( 0, PK_STANDARD
)->GetObj( 0 );
677 SdrObject
* pPickObj2
= NULL
;
678 SdrPageView
* pPV
= NULL
;
679 PickObj( rPos
, getHitTolLog(), pPickObj2
, pPV
);
681 if( ( mnAction
& DND_ACTION_MOVE
) && pPickObj2
&& pObj
)
684 SdrObject
* pNewObj
= pObj
->Clone();
685 Rectangle
aPickObjRect( pPickObj2
->GetCurrentBoundRect() );
686 Size
aPickObjSize( aPickObjRect
.GetSize() );
687 Point
aVec( aPickObjRect
.TopLeft() );
688 Rectangle
aObjRect( pNewObj
->GetCurrentBoundRect() );
689 Size
aObjSize( aObjRect
.GetSize() );
691 Fraction
aScaleWidth( aPickObjSize
.Width(), aObjSize
.Width() );
692 Fraction
aScaleHeight( aPickObjSize
.Height(), aObjSize
.Height() );
693 pNewObj
->NbcResize( aObjRect
.TopLeft(), aScaleWidth
, aScaleHeight
);
695 aVec
-= aObjRect
.TopLeft();
696 pNewObj
->NbcMove( Size( aVec
.X(), aVec
.Y() ) );
698 const bool bUndo
= IsUndoEnabled();
701 BegUndo( String( SdResId(STR_UNDO_DRAGDROP
) ) );
702 pNewObj
->NbcSetLayer( pPickObj
->GetLayer() );
703 SdrPage
* pWorkPage
= GetSdrPageView()->GetPage();
704 pWorkPage
->InsertObject( pNewObj
);
707 AddUndo( mrDoc
.GetSdrUndoFactory().CreateUndoNewObject( *pNewObj
) );
708 AddUndo( mrDoc
.GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2
) );
710 pWorkPage
->RemoveObject( pPickObj2
->GetOrdNum() );
718 SdrObject::Free(pPickObj2
);
721 mnAction
= DND_ACTION_COPY
;
723 else if( ( mnAction
& DND_ACTION_LINK
) && pPickObj
&& pObj
&& !pPickObj
->ISA( SdrGrafObj
) && !pPickObj
->ISA( SdrOle2Obj
) )
725 SfxItemSet
aSet( mrDoc
.GetPool() );
727 // set new attributes to object
728 const bool bUndo
= IsUndoEnabled();
731 BegUndo( String( SdResId( STR_UNDO_DRAGDROP
) ) );
732 AddUndo( mrDoc
.GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj
) );
734 aSet
.Put( pObj
->GetMergedItemSet() );
736 /* Do not take over corner radius. There are
737 gradients (rectangles) in the gallery with corner
738 radius of 0. We should not use that on the
740 aSet
.ClearItem( SDRATTR_ECKENRADIUS
);
742 pPickObj
->SetMergedItemSetAndBroadcast( aSet
);
744 if( pPickObj
->ISA( E3dObject
) && pObj
->ISA( E3dObject
) )
746 // handle 3D attribute in addition
747 SfxItemSet
aNewSet( mrDoc
.GetPool(), SID_ATTR_3D_START
, SID_ATTR_3D_END
, 0 );
748 SfxItemSet
aOldSet( mrDoc
.GetPool(), SID_ATTR_3D_START
, SID_ATTR_3D_END
, 0 );
750 aOldSet
.Put(pPickObj
->GetMergedItemSet());
751 aNewSet
.Put( pObj
->GetMergedItemSet() );
754 AddUndo( new E3dAttributesUndoAction( mrDoc
, (E3dObject
*) pPickObj
, aNewSet
, aOldSet
) );
755 pPickObj
->SetMergedItemSetAndBroadcast( aNewSet
);
767 SdrPage
* pWorkPage
= pModel
->GetSdPage( 0, PK_STANDARD
);
769 pWorkPage
->SetRectsDirty();
773 // Use SnapRect, not BoundRect
774 Size
aSize( pWorkPage
->GetAllObjSnapRect().GetSize() );
776 maDropPos
.X() = pOwnData
->GetStartPos().X() + ( aSize
.Width() >> 1 );
777 maDropPos
.Y() = pOwnData
->GetStartPos().Y() + ( aSize
.Height() >> 1 );
780 bReturn
= Paste( *pModel
, maDropPos
, pPage
, nPasteOptions
);
787 else if( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE
) )
791 if( aDataHelper
.GetString( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE
, aOUString
) )
793 SdrObject
* pObj
= CreateFieldControl( aOUString
);
797 Rectangle
aRect( pObj
->GetLogicRect() );
798 Size
aSize( aRect
.GetSize() );
800 maDropPos
.X() -= ( aSize
.Width() >> 1 );
801 maDropPos
.Y() -= ( aSize
.Height() >> 1 );
803 aRect
.SetPos( maDropPos
);
804 pObj
->SetLogicRect( aRect
);
805 InsertObjectAtView( pObj
, *GetSdrPageView(), SDRINSERT_SETDEFLAYER
);
811 ( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBED_SOURCE
) ||
812 CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBEDDED_OBJ
) ) &&
813 aDataHelper
.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
) )
815 //TODO/LATER: is it possible that this format is binary?! (from old versions of SO)
816 uno::Reference
< io::XInputStream
> xStm
;
817 TransferableObjectDescriptor aObjDesc
;
819 if( aDataHelper
.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
, aObjDesc
) &&
820 ( aDataHelper
.GetInputStream( nFormat
? nFormat
: SOT_FORMATSTR_ID_EMBED_SOURCE
, xStm
) ||
821 aDataHelper
.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ
, xStm
) ) )
823 if( mrDoc
.GetDocSh() && ( mrDoc
.GetDocSh()->GetClassName() == aObjDesc
.maClassName
) )
825 uno::Reference
< embed::XStorage
> xStore( ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm
) );
826 ::sd::DrawDocShellRef
xDocShRef( new ::sd::DrawDocShell( SFX_CREATE_MODE_EMBEDDED
, sal_True
, mrDoc
.GetDocumentType() ) );
828 // mba: BaseURL doesn't make sense for clipboard functionality
829 SfxMedium
*pMedium
= new SfxMedium( xStore
, String() );
830 if( xDocShRef
->DoLoad( pMedium
) )
832 SdDrawDocument
* pModel
= (SdDrawDocument
*) xDocShRef
->GetDoc();
833 SdPage
* pWorkPage
= (SdPage
*) pModel
->GetSdPage( 0, PK_STANDARD
);
835 pWorkPage
->SetRectsDirty();
839 // Use SnapRect, not BoundRect
840 Size
aSize( pWorkPage
->GetAllObjSnapRect().GetSize() );
842 maDropPos
.X() = pOwnData
->GetStartPos().X() + ( aSize
.Width() >> 1 );
843 maDropPos
.Y() = pOwnData
->GetStartPos().Y() + ( aSize
.Height() >> 1 );
846 // delete pages, that are not of any interest for us
847 for( long i
= ( pModel
->GetPageCount() - 1 ); i
>= 0; i
-- )
849 SdPage
* pP
= static_cast< SdPage
* >( pModel
->GetPage( (sal_uInt16
) i
) );
851 if( pP
->GetPageKind() != PK_STANDARD
)
852 pModel
->DeletePage( (sal_uInt16
) i
);
855 bReturn
= Paste( *pModel
, maDropPos
, pPage
, nPasteOptions
);
858 pPage
= (SdPage
*) GetSdrPageView()->GetPage();
860 String
aLayout(pPage
->GetLayoutName());
861 aLayout
.Erase(aLayout
.SearchAscii(SD_LT_SEPARATOR
));
862 pPage
->SetPresentationLayout( aLayout
, sal_False
, sal_False
);
865 xDocShRef
->DoClose();
872 uno::Reference
< embed::XEmbeddedObject
> xObj
= mpDocSh
->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm
, aName
);
875 svt::EmbeddedObjectRef
aObjRef( xObj
, aObjDesc
.mnViewAspect
);
877 // try to get the replacement image from the clipboard
879 sal_uLong nGrFormat
= 0;
882 // insert replacement image ( if there is one ) into the object helper
885 datatransfer::DataFlavor aDataFlavor
;
886 SotExchange::GetFormatDataFlavor( nGrFormat
, aDataFlavor
);
887 aObjRef
.SetGraphic( aGraphic
, aDataFlavor
.MimeType
);
891 if ( aObjDesc
.mnViewAspect
== embed::Aspects::MSOLE_ICON
)
893 if( aObjDesc
.maSize
.Width() && aObjDesc
.maSize
.Height() )
894 aSize
= aObjDesc
.maSize
;
897 MapMode
aMapMode( MAP_100TH_MM
);
898 aSize
= aObjRef
.GetSize( &aMapMode
);
904 MapUnit aMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( aObjDesc
.mnViewAspect
) );
905 if( aObjDesc
.maSize
.Width() && aObjDesc
.maSize
.Height() )
907 Size
aTmp( OutputDevice::LogicToLogic( aObjDesc
.maSize
, MAP_100TH_MM
, aMapUnit
) );
908 aSz
.Width
= aTmp
.Width();
909 aSz
.Height
= aTmp
.Height();
910 xObj
->setVisualAreaSize( aObjDesc
.mnViewAspect
, aSz
);
915 aSz
= xObj
->getVisualAreaSize( aObjDesc
.mnViewAspect
);
917 catch( embed::NoVisualAreaSizeException
& )
919 // if the size still was not set the default size will be set later
922 aSize
= Size( aSz
.Width
, aSz
.Height
);
924 if( !aSize
.Width() || !aSize
.Height() )
926 aSize
.Width() = 14100;
927 aSize
.Height() = 10000;
928 aSize
= OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM
, aMapUnit
);
929 aSz
.Width
= aSize
.Width();
930 aSz
.Height
= aSize
.Height();
931 xObj
->setVisualAreaSize( aObjDesc
.mnViewAspect
, aSz
);
934 aSize
= OutputDevice::LogicToLogic( aSize
, aMapUnit
, MAP_100TH_MM
);
937 Size
aMaxSize( mrDoc
.GetMaxObjSize() );
939 maDropPos
.X() -= std::min( aSize
.Width(), aMaxSize
.Width() ) >> 1;
940 maDropPos
.Y() -= std::min( aSize
.Height(), aMaxSize
.Height() ) >> 1;
942 Rectangle
aRect( maDropPos
, aSize
);
943 SdrOle2Obj
* pObj
= new SdrOle2Obj( aObjRef
, aName
, aRect
);
944 SdrPageView
* pPV
= GetSdrPageView();
945 sal_uLong nOptions
= SDRINSERT_SETDEFLAYER
;
949 OSL_ASSERT (mpViewSh
->GetViewShell()!=NULL
);
950 SfxInPlaceClient
* pIpClient
951 = mpViewSh
->GetViewShell()->GetIPClient();
952 if (pIpClient
!=NULL
&& pIpClient
->IsObjectInPlaceActive())
953 nOptions
|= SDRINSERT_DONTMARK
;
956 InsertObjectAtView( pObj
, *pPV
, nOptions
);
959 pObj
->AppendUserData( new SdIMapInfo( *pImageMap
) );
961 if ( pObj
&& pObj
->IsChart() )
963 bool bDisableDataTableDialog
= false;
964 svt::EmbeddedObjectRef::TryRunningState( xObj
);
965 uno::Reference
< beans::XPropertySet
> xProps( xObj
->getComponent(), uno::UNO_QUERY
);
967 ( xProps
->getPropertyValue( "DisableDataTableDialog" ) >>= bDisableDataTableDialog
) &&
968 bDisableDataTableDialog
)
970 xProps
->setPropertyValue( "DisableDataTableDialog" , uno::makeAny( sal_False
) );
971 xProps
->setPropertyValue( "DisableComplexChartTypes" , uno::makeAny( sal_False
) );
972 uno::Reference
< util::XModifiable
> xModifiable( xProps
, uno::UNO_QUERY
);
973 if ( xModifiable
.is() )
975 xModifiable
->setModified( sal_True
);
986 ( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
) ||
987 CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
) ) &&
988 aDataHelper
.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE
) )
990 // online insert ole if format is forced or no gdi metafile is available
991 if( (nFormat
!= 0) || !aDataHelper
.HasFormat( FORMAT_GDIMETAFILE
) )
993 uno::Reference
< io::XInputStream
> xStm
;
994 TransferableObjectDescriptor aObjDesc
;
996 if ( aDataHelper
.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE
, aObjDesc
) )
998 uno::Reference
< embed::XEmbeddedObject
> xObj
;
1001 if ( aDataHelper
.GetInputStream( nFormat
? nFormat
: SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
, xStm
) ||
1002 aDataHelper
.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
, xStm
) )
1004 xObj
= mpDocSh
->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm
, aName
);
1010 uno::Reference
< embed::XStorage
> xTmpStor
= ::comphelper::OStorageHelper::GetTemporaryStorage();
1011 uno::Reference
< embed::XEmbedObjectClipboardCreator
> xClipboardCreator
=
1012 embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() );
1014 embed::InsertedObjectInfo aInfo
= xClipboardCreator
->createInstanceInitFromClipboard(
1017 uno::Sequence
< beans::PropertyValue
>() );
1019 // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
1020 // for example whether the object should be an iconified one
1021 xObj
= aInfo
.Object
;
1023 mpDocSh
->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj
, aName
);
1025 catch( uno::Exception
& )
1031 svt::EmbeddedObjectRef
aObjRef( xObj
, aObjDesc
.mnViewAspect
);
1033 // try to get the replacement image from the clipboard
1035 sal_uLong nGrFormat
= 0;
1037 // (wg. Selection Manager bei Trustet Solaris)
1039 if( aDataHelper
.GetGraphic( SOT_FORMATSTR_ID_SVXB
, aGraphic
) )
1040 nGrFormat
= SOT_FORMATSTR_ID_SVXB
;
1041 else if( aDataHelper
.GetGraphic( FORMAT_GDIMETAFILE
, aGraphic
) )
1042 nGrFormat
= SOT_FORMAT_GDIMETAFILE
;
1043 else if( aDataHelper
.GetGraphic( FORMAT_BITMAP
, aGraphic
) )
1044 nGrFormat
= SOT_FORMAT_BITMAP
;
1047 // insert replacement image ( if there is one ) into the object helper
1050 datatransfer::DataFlavor aDataFlavor
;
1051 SotExchange::GetFormatDataFlavor( nGrFormat
, aDataFlavor
);
1052 aObjRef
.SetGraphic( aGraphic
, aDataFlavor
.MimeType
);
1056 if ( aObjDesc
.mnViewAspect
== embed::Aspects::MSOLE_ICON
)
1058 if( aObjDesc
.maSize
.Width() && aObjDesc
.maSize
.Height() )
1059 aSize
= aObjDesc
.maSize
;
1062 MapMode
aMapMode( MAP_100TH_MM
);
1063 aSize
= aObjRef
.GetSize( &aMapMode
);
1068 MapUnit aMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( aObjDesc
.mnViewAspect
) );
1072 aSz
= xObj
->getVisualAreaSize( aObjDesc
.mnViewAspect
);
1074 catch( embed::NoVisualAreaSizeException
& )
1076 // the default size will be set later
1079 if( aObjDesc
.maSize
.Width() && aObjDesc
.maSize
.Height() )
1081 Size
aTmp( OutputDevice::LogicToLogic( aObjDesc
.maSize
, MAP_100TH_MM
, aMapUnit
) );
1082 if ( aSz
.Width
!= aTmp
.Width() || aSz
.Height
!= aTmp
.Height() )
1084 aSz
.Width
= aTmp
.Width();
1085 aSz
.Height
= aTmp
.Height();
1086 xObj
->setVisualAreaSize( aObjDesc
.mnViewAspect
, aSz
);
1090 aSize
= Size( aSz
.Width
, aSz
.Height
);
1092 if( !aSize
.Width() || !aSize
.Height() )
1094 aSize
= OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM
, aMapUnit
);
1095 aSz
.Width
= aSize
.Width();
1096 aSz
.Height
= aSize
.Height();
1097 xObj
->setVisualAreaSize( aObjDesc
.mnViewAspect
, aSz
);
1100 aSize
= OutputDevice::LogicToLogic( aSize
, aMapUnit
, MAP_100TH_MM
);
1103 Size
aMaxSize( mrDoc
.GetMaxObjSize() );
1105 maDropPos
.X() -= std::min( aSize
.Width(), aMaxSize
.Width() ) >> 1;
1106 maDropPos
.Y() -= std::min( aSize
.Height(), aMaxSize
.Height() ) >> 1;
1108 Rectangle
aRect( maDropPos
, aSize
);
1109 SdrOle2Obj
* pObj
= new SdrOle2Obj( aObjRef
, aName
, aRect
);
1110 SdrPageView
* pPV
= GetSdrPageView();
1111 sal_uLong nOptions
= SDRINSERT_SETDEFLAYER
;
1115 OSL_ASSERT (mpViewSh
->GetViewShell()!=NULL
);
1116 SfxInPlaceClient
* pIpClient
1117 = mpViewSh
->GetViewShell()->GetIPClient();
1118 if (pIpClient
!=NULL
&& pIpClient
->IsObjectInPlaceActive())
1119 nOptions
|= SDRINSERT_DONTMARK
;
1122 InsertObjectAtView( pObj
, *pPV
, nOptions
);
1125 pObj
->AppendUserData( new SdIMapInfo( *pImageMap
) );
1127 // let the object stay in loaded state after insertion
1134 if( !bReturn
&& aDataHelper
.HasFormat( FORMAT_GDIMETAFILE
) )
1136 // if no object was inserted, insert a picture
1137 InsertMetaFile( aDataHelper
, rPos
, pImageMap
, true );
1140 else if( ( !bLink
|| pPickObj
) && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_SVXB
) )
1142 SotStorageStreamRef xStm
;
1144 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB
, xStm
) )
1146 Point
aInsertPos( rPos
);
1151 if( pOwnData
&& pOwnData
->GetWorkDocument() )
1153 const SdDrawDocument
* pWorkModel
= pOwnData
->GetWorkDocument();
1154 SdrPage
* pWorkPage
= (SdrPage
*) ( ( pWorkModel
->GetPageCount() > 1 ) ?
1155 pWorkModel
->GetSdPage( 0, PK_STANDARD
) :
1156 pWorkModel
->GetPage( 0 ) );
1158 pWorkPage
->SetRectsDirty();
1160 // Use SnapRect, not BoundRect
1161 Size
aSize( pWorkPage
->GetAllObjSnapRect().GetSize() );
1163 aInsertPos
.X() = pOwnData
->GetStartPos().X() + ( aSize
.Width() >> 1 );
1164 aInsertPos
.Y() = pOwnData
->GetStartPos().Y() + ( aSize
.Height() >> 1 );
1167 // restrict movement to WorkArea
1168 Size aImageMapSize
= OutputDevice::LogicToLogic(aGraphic
.GetPrefSize(),
1169 aGraphic
.GetPrefMapMode(), MapMode(MAP_100TH_MM
));
1171 ImpCheckInsertPos(aInsertPos
, aImageMapSize
, GetWorkArea());
1173 InsertGraphic( aGraphic
, mnAction
, aInsertPos
, NULL
, pImageMap
);
1177 else if( ( !bLink
|| pPickObj
) && CHECK_FORMAT_TRANS( FORMAT_GDIMETAFILE
) )
1179 Point
aInsertPos( rPos
);
1181 if( pOwnData
&& pOwnData
->GetWorkDocument() )
1184 const SdDrawDocument
* pWorkModel
= pOwnData
->GetWorkDocument();
1185 SdrPage
* pWorkPage
= (SdrPage
*) ( ( pWorkModel
->GetPageCount() > 1 ) ?
1186 pWorkModel
->GetSdPage( 0, PK_STANDARD
) :
1187 pWorkModel
->GetPage( 0 ) );
1189 pWorkPage
->SetRectsDirty();
1191 // Use SnapRect, not BoundRect
1192 Size
aSize( pWorkPage
->GetAllObjSnapRect().GetSize() );
1194 aInsertPos
.X() = pOwnData
->GetStartPos().X() + ( aSize
.Width() >> 1 );
1195 aInsertPos
.Y() = pOwnData
->GetStartPos().Y() + ( aSize
.Height() >> 1 );
1198 bReturn
= InsertMetaFile( aDataHelper
, aInsertPos
, pImageMap
, nFormat
== 0 ? true : false ) ? sal_True
: sal_False
;
1200 else if( ( !bLink
|| pPickObj
) && CHECK_FORMAT_TRANS( FORMAT_BITMAP
) )
1204 if( aDataHelper
.GetBitmap( FORMAT_BITMAP
, aBmp
) )
1206 Point
aInsertPos( rPos
);
1208 if( pOwnData
&& pOwnData
->GetWorkDocument() )
1210 const SdDrawDocument
* pWorkModel
= pOwnData
->GetWorkDocument();
1211 SdrPage
* pWorkPage
= (SdrPage
*) ( ( pWorkModel
->GetPageCount() > 1 ) ?
1212 pWorkModel
->GetSdPage( 0, PK_STANDARD
) :
1213 pWorkModel
->GetPage( 0 ) );
1215 pWorkPage
->SetRectsDirty();
1217 // Use SnapRect, not BoundRect
1218 Size
aSize( pWorkPage
->GetAllObjSnapRect().GetSize() );
1220 aInsertPos
.X() = pOwnData
->GetStartPos().X() + ( aSize
.Width() >> 1 );
1221 aInsertPos
.Y() = pOwnData
->GetStartPos().Y() + ( aSize
.Height() >> 1 );
1224 // restrict movement to WorkArea
1225 Size
aImageMapSize(aBmp
.GetPrefSize());
1226 ImpCheckInsertPos(aInsertPos
, aImageMapSize
, GetWorkArea());
1228 InsertGraphic( aBmp
, mnAction
, aInsertPos
, NULL
, pImageMap
);
1232 else if( pPickObj
&& CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_XFA
) )
1234 SotStorageStreamRef xStm
;
1236 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_XFA
, xStm
) )
1238 XFillExchangeData
aFillData( XFillAttrSetItem( &mrDoc
.GetPool() ) );
1242 if( IsUndoEnabled() )
1244 BegUndo( String( SdResId( STR_UNDO_DRAGDROP
) ) );
1245 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj
) );
1249 XFillAttrSetItem
* pSetItem
= aFillData
.GetXFillAttrSetItem();
1250 SfxItemSet rSet
= pSetItem
->GetItemSet();
1251 XFillStyle eFill
= ( (XFillStyleItem
&) rSet
.Get( XATTR_FILLSTYLE
) ).GetValue();
1253 if( eFill
== XFILL_SOLID
|| eFill
== XFILL_NONE
)
1255 const XFillColorItem
& rColItem
= (XFillColorItem
&) rSet
.Get( XATTR_FILLCOLOR
);
1256 Color
aColor( rColItem
.GetColorValue() );
1257 String
aName( rColItem
.GetName() );
1258 SfxItemSet
aSet( mrDoc
.GetPool() );
1259 sal_Bool bClosed
= pPickObj
->IsClosedObj();
1260 ::sd::Window
* pWin
= mpViewSh
->GetActiveWindow();
1261 sal_uInt16 nHitLog
= (sal_uInt16
) pWin
->PixelToLogic(
1262 Size(FuPoor::HITPIX
, 0 ) ).Width();
1263 const long n2HitLog
= nHitLog
<< 1;
1264 Point
aHitPosR( rPos
);
1265 Point
aHitPosL( rPos
);
1266 Point
aHitPosT( rPos
);
1267 Point
aHitPosB( rPos
);
1268 const SetOfByte
* pVisiLayer
= &GetSdrPageView()->GetVisibleLayers();
1270 aHitPosR
.X() += n2HitLog
;
1271 aHitPosL
.X() -= n2HitLog
;
1272 aHitPosT
.Y() += n2HitLog
;
1273 aHitPosB
.Y() -= n2HitLog
;
1276 SdrObjectPrimitiveHit(*pPickObj
, aHitPosR
, nHitLog
, *GetSdrPageView(), pVisiLayer
, false) &&
1277 SdrObjectPrimitiveHit(*pPickObj
, aHitPosL
, nHitLog
, *GetSdrPageView(), pVisiLayer
, false) &&
1278 SdrObjectPrimitiveHit(*pPickObj
, aHitPosT
, nHitLog
, *GetSdrPageView(), pVisiLayer
, false) &&
1279 SdrObjectPrimitiveHit(*pPickObj
, aHitPosB
, nHitLog
, *GetSdrPageView(), pVisiLayer
, false) )
1282 if(eFill
== XFILL_SOLID
)
1283 aSet
.Put(XFillColorItem(aName
, aColor
));
1285 aSet
.Put( XFillStyleItem( eFill
) );
1288 aSet
.Put( XLineColorItem( aName
, aColor
) );
1291 pPickObj
->SetMergedItemSetAndBroadcast( aSet
);
1295 else if( !bLink
&& CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_HTML
) )
1297 SotStorageStreamRef xStm
;
1299 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_HTML
, xStm
) )
1302 // mba: clipboard always must contain absolute URLs (could be from alien source)
1303 bReturn
= SdrView::Paste( *xStm
, String(), EE_FORMAT_HTML
, maDropPos
, pPage
, nPasteOptions
);
1306 else if( !bLink
&& CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EDITENGINE
) )
1308 SotStorageStreamRef xStm
;
1310 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_EDITENGINE
, xStm
) )
1312 OutlinerView
* pOLV
= GetTextEditOutlinerView();
1318 Rectangle
aRect( pOLV
->GetOutputArea() );
1319 Point
aPos( pOLV
->GetWindow()->PixelToLogic( maDropPos
) );
1321 if( aRect
.IsInside( aPos
) || ( !bDrag
&& IsTextEdit() ) )
1323 // mba: clipboard always must contain absolute URLs (could be from alien source)
1324 pOLV
->Read( *xStm
, String(), EE_FORMAT_BIN
, sal_False
, mpDocSh
->GetHeaderAttributes() );
1330 // mba: clipboard always must contain absolute URLs (could be from alien source)
1331 bReturn
= SdrView::Paste( *xStm
, String(), EE_FORMAT_BIN
, maDropPos
, pPage
, nPasteOptions
);
1334 else if( !bLink
&& CHECK_FORMAT_TRANS( FORMAT_RTF
) )
1336 SotStorageStreamRef xStm
;
1338 if( aDataHelper
.GetSotStorageStream( FORMAT_RTF
, xStm
) )
1344 bReturn
= PasteRTFTable( xStm
, pPage
, nPasteOptions
);
1348 OutlinerView
* pOLV
= GetTextEditOutlinerView();
1352 Rectangle
aRect( pOLV
->GetOutputArea() );
1353 Point
aPos( pOLV
->GetWindow()->PixelToLogic( maDropPos
) );
1355 if( aRect
.IsInside( aPos
) || ( !bDrag
&& IsTextEdit() ) )
1357 // mba: clipboard always must contain absolute URLs (could be from alien source)
1358 pOLV
->Read( *xStm
, String(), EE_FORMAT_RTF
, sal_False
, mpDocSh
->GetHeaderAttributes() );
1364 // mba: clipboard always must contain absolute URLs (could be from alien source)
1365 bReturn
= SdrView::Paste( *xStm
, String(), EE_FORMAT_RTF
, maDropPos
, pPage
, nPasteOptions
);
1369 else if( CHECK_FORMAT_TRANS( FORMAT_FILE_LIST
) )
1371 FileList aDropFileList
;
1373 if( aDataHelper
.GetFileList( FORMAT_FILE_LIST
, aDropFileList
) )
1375 maDropFileVector
.clear();
1377 for( sal_uLong i
= 0, nCount
= aDropFileList
.Count(); i
< nCount
; i
++ )
1378 maDropFileVector
.push_back( aDropFileList
.GetFile( i
) );
1380 maDropInsertFileTimer
.Start();
1385 else if( CHECK_FORMAT_TRANS( FORMAT_FILE
) )
1389 if( aDataHelper
.GetString( FORMAT_FILE
, aDropFile
) )
1391 maDropFileVector
.clear();
1392 maDropFileVector
.push_back( aDropFile
);
1393 maDropInsertFileTimer
.Start();
1398 else if( !bLink
&& CHECK_FORMAT_TRANS( FORMAT_STRING
) )
1400 if( ( FORMAT_STRING
== nFormat
) ||
1401 ( !aDataHelper
.HasFormat( SOT_FORMATSTR_ID_SOLK
) &&
1402 !aDataHelper
.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
) &&
1403 !aDataHelper
.HasFormat( SOT_FORMATSTR_ID_FILENAME
) ) )
1407 if( aDataHelper
.GetString( FORMAT_STRING
, aOUString
) )
1409 OutlinerView
* pOLV
= GetTextEditOutlinerView();
1413 pOLV
->InsertText( aOUString
);
1418 bReturn
= SdrView::Paste( aOUString
, maDropPos
, pPage
, nPasteOptions
);
1423 MarkListHasChanged();
1424 mbIsDropAllowed
= sal_True
;
1425 rDnDAction
= mnAction
;
1431 extern void CreateTableFromRTF( SvStream
& rStream
, SdDrawDocument
* pModel
);
1433 bool View::PasteRTFTable( SotStorageStreamRef xStm
, SdrPage
* pPage
, sal_uLong nPasteOptions
)
1435 SdDrawDocument
* pModel
= new SdDrawDocument( DOCUMENT_TYPE_IMPRESS
, mpDocSh
);
1436 pModel
->NewOrLoadCompleted(NEW_DOC
);
1437 pModel
->GetItemPool().SetDefaultMetric(SFX_MAPUNIT_100TH_MM
);
1438 pModel
->InsertPage(pModel
->AllocPage(false));
1440 Reference
< XComponent
> xComponent( new SdXImpressDocument( pModel
, sal_True
) );
1441 pModel
->setUnoModel( Reference
< XInterface
>::query( xComponent
) );
1443 CreateTableFromRTF( *xStm
, pModel
);
1444 bool bRet
= Paste( *pModel
, maDropPos
, pPage
, nPasteOptions
);
1446 xComponent
->dispose();
1454 } // end of namespace sd
1456 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */