1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdview2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
38 #include <com/sun/star/embed/XEmbedPersist.hpp>
39 #include <tools/ref.hxx>
40 #include <tools/urlobj.hxx>
41 #ifndef _MSGBOX_HXX //autogen
42 #include <vcl/msgbox.hxx>
44 #include <svx/svdetc.hxx>
45 #include <svx/svdoole2.hxx>
46 #include <svx/svdograf.hxx>
47 #include <vcl/graph.hxx>
48 #include <svx/xexch.hxx>
49 #include <svx/svxdlg.hxx>
50 #include <svx/dialogs.hrc>
51 #include <sfx2/docfile.hxx>
52 #include <sfx2/childwin.hxx>
53 #include <svx/svdundo.hxx>
54 #include <svx/svdpagv.hxx>
55 #include <svtools/urlbmk.hxx>
56 #include <svtools/urlbmk.hxx>
57 #include <svx/outliner.hxx>
58 #include <svx/xflclit.hxx>
59 #include <svx/dbexch.hrc>
60 #include <sot/formats.hxx>
61 #include <svx/editeng.hxx>
62 #include <svx/svditer.hxx>
63 #include <svx/obj3d.hxx>
64 #include <svx/scene3d.hxx>
66 #include <sfx2/objsh.hxx>
67 #include <svtools/embedtransfer.hxx>
69 #include "navigatr.hxx"
70 #include "anminfo.hxx"
71 #include "strings.hrc"
74 #include "sdresid.hxx"
76 #include "DrawViewShell.hxx"
77 #include "DrawDocShell.hxx"
79 #include "drawdoc.hxx"
82 #include "unoaprms.hxx"
83 #include "drawview.hxx"
85 #include <vcl/svapp.hxx>
87 #include "slideshow.hxx"
91 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
92 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
93 SO2_DECL_REF(SvInPlaceObject
)
95 #ifndef SO2_DECL_SVSTORAGE_DEFINED
96 #define SO2_DECL_SVSTORAGE_DEFINED
97 SO2_DECL_REF(SvStorage
)
100 using namespace ::com::sun::star
;
102 // ------------------------
103 // - SdNavigatorDropEvent -
104 // ------------------------
106 struct SdNavigatorDropEvent
: public ExecuteDropEvent
108 DropTargetHelper
& mrTargetHelper
;
109 ::sd::Window
* mpTargetWindow
;
113 SdNavigatorDropEvent (
114 const ExecuteDropEvent
& rEvt
,
115 DropTargetHelper
& rTargetHelper
,
116 ::sd::Window
* pTargetWindow
,
119 : ExecuteDropEvent( rEvt
),
120 mrTargetHelper( rTargetHelper
),
121 mpTargetWindow( pTargetWindow
),
127 // -----------------------------------------------------------------------------
129 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> View::CreateClipboardDataObject( View
*, ::Window
& )
131 // since SdTransferable::CopyToClipboard is called, this
132 // dynamically created object ist destroyed automatically
133 SdTransferable
* pTransferable
= new SdTransferable( mpDoc
, NULL
, FALSE
);
134 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> xRet( pTransferable
);
136 SD_MOD()->pTransferClip
= pTransferable
;
138 mpDoc
->CreatingDataObj( pTransferable
);
139 pTransferable
->SetWorkDocument( (SdDrawDocument
*) GetAllMarkedModel() );
140 mpDoc
->CreatingDataObj( NULL
);
142 const Rectangle
aMarkRect( GetAllMarkedRect() );
143 TransferableObjectDescriptor aObjDesc
;
145 SdrOle2Obj
* pSdrOleObj
= NULL
;
146 SdrPageView
* pPgView
= GetSdrPageView();
147 SdPage
* pOldPage
= pPgView
? ( (SdPage
*) pPgView
->GetPage() ) : NULL
;
148 SdPage
* pNewPage
= (SdPage
*) pTransferable
->GetWorkDocument()->GetPage( 0 );
152 pNewPage
->SetSize( pOldPage
->GetSize() );
153 pNewPage
->SetLayoutName( pOldPage
->GetLayoutName() );
156 if( GetMarkedObjectCount() == 1 )
158 SdrObject
* pObj
= GetMarkedObjectByIndex(0);
160 if( pObj
&& pObj
->ISA(SdrOle2Obj
) && ((SdrOle2Obj
*) pObj
)->GetObjRef().is() )
162 // If object has no persistence it must be copied as part of the document
165 uno::Reference
< embed::XEmbedPersist
> xPersObj( ((SdrOle2Obj
*)pObj
)->GetObjRef(), uno::UNO_QUERY
);
166 if ( xPersObj
.is() && xPersObj
->hasEntry() )
167 pSdrOleObj
= (SdrOle2Obj
*) pObj
;
169 catch( uno::Exception
& )
175 SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc
, pSdrOleObj
->GetObjRef(), pSdrOleObj
->GetGraphic(), pSdrOleObj
->GetAspect() );
177 pTransferable
->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( aObjDesc
);
180 aObjDesc
.maDisplayName
= mpDocSh
->GetMedium()->GetURLObject().GetURLNoPass();
182 aObjDesc
.maSize
= aMarkRect
.GetSize();
184 pTransferable
->SetStartPos( aMarkRect
.TopLeft() );
185 pTransferable
->SetObjectDescriptor( aObjDesc
);
186 pTransferable
->CopyToClipboard( mpViewSh
->GetActiveWindow() );
191 // -----------------------------------------------------------------------------
193 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> View::CreateDragDataObject( View
* pWorkView
, ::Window
& rWindow
, const Point
& rDragPos
)
195 SdTransferable
* pTransferable
= new SdTransferable( mpDoc
, pWorkView
, FALSE
);
196 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> xRet( pTransferable
);
198 SD_MOD()->pTransferDrag
= pTransferable
;
200 TransferableObjectDescriptor aObjDesc
;
202 SdrOle2Obj
* pSdrOleObj
= NULL
;
204 if( GetMarkedObjectCount() == 1 )
206 SdrObject
* pObj
= GetMarkedObjectByIndex( 0 );
208 if( pObj
&& pObj
->ISA( SdrOle2Obj
) && ( (SdrOle2Obj
*) pObj
)->GetObjRef().is() )
210 // If object has no persistence it must be copied as part of the document
213 uno::Reference
< embed::XEmbedPersist
> xPersObj( ((SdrOle2Obj
*)pObj
)->GetObjRef(), uno::UNO_QUERY
);
214 if ( xPersObj
.is() && xPersObj
->hasEntry() )
215 pSdrOleObj
= (SdrOle2Obj
*) pObj
;
217 catch( uno::Exception
& )
223 aDisplayName
= mpDocSh
->GetMedium()->GetURLObject().GetURLNoPass();
226 SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc
, pSdrOleObj
->GetObjRef(), pSdrOleObj
->GetGraphic(), pSdrOleObj
->GetAspect() );
228 mpDocSh
->FillTransferableObjectDescriptor( aObjDesc
);
230 aObjDesc
.maSize
= GetAllMarkedRect().GetSize();
231 aObjDesc
.maDragStartPos
= rDragPos
;
232 aObjDesc
.maDisplayName
= aDisplayName
;
233 aObjDesc
.mbCanLink
= FALSE
;
235 pTransferable
->SetStartPos( rDragPos
);
236 pTransferable
->SetObjectDescriptor( aObjDesc
);
237 pTransferable
->StartDrag( &rWindow
, DND_ACTION_COPYMOVE
| DND_ACTION_LINK
);
242 // -----------------------------------------------------------------------------
244 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> View::CreateSelectionDataObject( View
* pWorkView
, ::Window
& rWindow
)
246 SdTransferable
* pTransferable
= new SdTransferable( mpDoc
, pWorkView
, TRUE
);
247 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> xRet( pTransferable
);
248 TransferableObjectDescriptor aObjDesc
;
249 const Rectangle
aMarkRect( GetAllMarkedRect() );
252 SD_MOD()->pTransferSelection
= pTransferable
;
256 aDisplayName
= mpDocSh
->GetMedium()->GetURLObject().GetURLNoPass();
257 mpDocSh
->FillTransferableObjectDescriptor( aObjDesc
);
260 aObjDesc
.maSize
= aMarkRect
.GetSize();
262 pTransferable
->SetStartPos( aMarkRect
.TopLeft() );
263 pTransferable
->SetObjectDescriptor( aObjDesc
);
264 pTransferable
->CopyToSelection( &rWindow
);
269 // -----------------------------------------------------------------------------
271 void View::UpdateSelectionClipboard( BOOL bForceDeselect
)
273 if( mpViewSh
&& mpViewSh
->GetActiveWindow() )
275 if( !bForceDeselect
&& GetMarkedObjectList().GetMarkCount() )
276 CreateSelectionDataObject( this, *mpViewSh
->GetActiveWindow() );
277 else if( SD_MOD()->pTransferSelection
&& ( SD_MOD()->pTransferSelection
->GetView() == this ) )
279 TransferableHelper::ClearSelection( mpViewSh
->GetActiveWindow() );
280 SD_MOD()->pTransferSelection
= NULL
;
285 // -----------------------------------------------------------------------------
287 void View::DoCut(::Window
* )
289 const OutlinerView
* pOLV
= GetTextEditOutlinerView();
292 ( (OutlinerView
*) pOLV
)->Cut();
293 else if( AreObjectsMarked() )
295 String
aStr( SdResId(STR_UNDO_CUT
) );
298 BegUndo( ( aStr
+= sal_Unicode(' ') ) += GetDescriptionOfMarkedObjects() );
304 // -----------------------------------------------------------------------------
306 void View::DoCopy (::Window
* pWindow
)
308 const OutlinerView
* pOLV
= GetTextEditOutlinerView();
311 ( (OutlinerView
*) pOLV
)->Copy();
312 else if( AreObjectsMarked() )
315 CreateClipboardDataObject( this, *pWindow
);
319 // -----------------------------------------------------------------------------
321 void View::DoPaste (::Window
* pWindow
)
323 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewSh
->GetActiveWindow() ) );
324 if( !aDataHelper
.GetTransferable().is() )
325 return; // empty clipboard?
327 const OutlinerView
* pOLV
= GetTextEditOutlinerView();
329 if( pOLV
&& EditEngine::HasValidData( aDataHelper
.GetTransferable() ) )
331 const_cast< OutlinerView
* >(pOLV
)->PasteSpecial();
333 SdrObject
* pObj
= GetTextEditObject();
334 SdPage
* pPage
= (SdPage
*)( pObj
? pObj
->GetPage() : NULL
);
335 ::Outliner
* pOutliner
= pOLV
->GetOutliner();
339 if( pObj
&& pPage
&& pPage
->GetPresObjKind(pObj
) == PRESOBJ_TITLE
)
341 // remove all hard linebreaks from the title
342 if( pOutliner
&& pOutliner
->GetParagraphCount() > 1 )
344 BOOL bOldUpdateMode
= pOutliner
->GetUpdateMode();
346 pOutliner
->SetUpdateMode( FALSE
);
348 const EditEngine
& rEdit
= pOutliner
->GetEditEngine();
349 const int nParaCount
= rEdit
.GetParagraphCount();
351 for( int nPara
= nParaCount
- 2; nPara
>= 0; nPara
-- )
353 const USHORT nParaLen
= (USHORT
)rEdit
.GetTextLen( (USHORT
)nPara
);
354 pOutliner
->QuickDelete( ESelection( (USHORT
)nPara
, nParaLen
, (USHORT
)nPara
+1, 0 ) );
355 pOutliner
->QuickInsertLineBreak( ESelection( (USHORT
)nPara
, nParaLen
, (USHORT
)nPara
, nParaLen
) );
358 DBG_ASSERT( rEdit
.GetParagraphCount() <= 1, "Titelobjekt contains hard line breaks" );
359 pOutliner
->SetUpdateMode(bOldUpdateMode
);
363 if( !mpDoc
->IsChanged() )
365 if( pOutliner
&& pOutliner
->IsModified() )
366 mpDoc
->SetChanged( TRUE
);
373 sal_Int8 nDnDAction
= DND_ACTION_COPY
;
376 aPos
= pWindow
->PixelToLogic( Rectangle( aPos
, pWindow
->GetOutputSizePixel() ).Center() );
378 DrawViewShell
* pDrViewSh
= (DrawViewShell
*) mpDocSh
->GetViewShell();
380 if (pDrViewSh
!= NULL
)
382 if( !InsertData( aDataHelper
, aPos
, nDnDAction
, FALSE
) )
384 INetBookmark
aINetBookmark( aEmptyStr
, aEmptyStr
);
386 if( ( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
) &&
387 aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aINetBookmark
) ) ||
388 ( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
) &&
389 aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
, aINetBookmark
) ) ||
390 ( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
) &&
391 aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
, aINetBookmark
) ) )
393 pDrViewSh
->InsertURLField( aINetBookmark
.GetURL(), aINetBookmark
.GetDescription(), aEmptyStr
, NULL
);
400 // -----------------------------------------------------------------------------
402 void View::StartDrag( const Point
& rStartPos
, ::Window
* pWindow
)
404 if( AreObjectsMarked() && IsAction() && mpViewSh
&& pWindow
&& !mpDragSrcMarkList
)
411 DrawViewShell
* pDrawViewShell
= dynamic_cast< DrawViewShell
* >( mpDocSh
? mpDocSh
->GetViewShell() : 0 );
415 FunctionReference
xFunction( pDrawViewShell
->GetCurrentFunction() );
417 if( xFunction
.is() && xFunction
->ISA( FuDraw
) )
418 static_cast<FuDraw
*>(xFunction
.get())->ForcePointer( NULL
);
421 mpDragSrcMarkList
= new SdrMarkList(GetMarkedObjectList());
422 mnDragSrcPgNum
= GetSdrPageView()->GetPage()->GetPageNum();
424 if( IsUndoEnabled() )
426 String
aStr( SdResId(STR_UNDO_DRAGDROP
) );
427 aStr
+= sal_Unicode(' ');
428 aStr
+= mpDragSrcMarkList
->GetMarkDescription();
431 CreateDragDataObject( this, *pWindow
, rStartPos
);
435 // -----------------------------------------------------------------------------
437 void View::DragFinished( sal_Int8 nDropAction
)
439 const bool bUndo
= IsUndoEnabled();
441 SdTransferable
* pDragTransferable
= SD_MOD()->pTransferDrag
;
443 if( pDragTransferable
)
444 pDragTransferable
->SetView( NULL
);
446 if( ( nDropAction
& DND_ACTION_MOVE
) &&
447 pDragTransferable
&& !pDragTransferable
->IsInternalMove() &&
448 mpDragSrcMarkList
&& mpDragSrcMarkList
->GetMarkCount() &&
449 !IsPresObjSelected() )
451 mpDragSrcMarkList
->ForceSort();
456 ULONG nm
, nAnz
= mpDragSrcMarkList
->GetMarkCount();
458 for( nm
= nAnz
; nm
>0; )
461 SdrMark
* pM
=mpDragSrcMarkList
->GetMark(nm
);
463 AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoDeleteObject(*pM
->GetMarkedSdrObj()));
466 mpDragSrcMarkList
->GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
471 SdrMark
* pM
=mpDragSrcMarkList
->GetMark(nm
);
472 SdrObject
* pObj
=pM
->GetMarkedSdrObj();
473 UINT32 nOrdNum
=pObj
->GetOrdNumDirect();
475 if( pObj
&& pObj
->GetPage() )
480 pObj
->GetPage()->RemoveObject(nOrdNum
);
481 DBG_ASSERT(pChkObj
==pObj
,"pChkObj!=pObj beim RemoveObject()");
489 if( pDragTransferable
)
490 pDragTransferable
->SetInternalMove( FALSE
);
494 mnDragSrcPgNum
= SDRPAGE_NOTFOUND
;
495 delete mpDragSrcMarkList
;
496 mpDragSrcMarkList
= NULL
;
499 // -----------------------------------------------------------------------------
501 sal_Int8
View::AcceptDrop( const AcceptDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
502 ::sd::Window
*, USHORT
, USHORT nLayer
)
504 String
aLayerName( GetActiveLayer() );
505 SdrPageView
* pPV
= GetSdrPageView();
506 sal_Int8 nDropAction
= rEvt
.mnAction
;
507 sal_Int8 nRet
= DND_ACTION_NONE
;
509 if( nLayer
!= SDRLAYER_NOTFOUND
)
511 SdrLayerAdmin
& rLayerAdmin
= mpDoc
->GetLayerAdmin();
512 aLayerName
= rLayerAdmin
.GetLayerPerID(nLayer
)->GetName();
515 if( mbIsDropAllowed
&& !pPV
->IsLayerLocked( aLayerName
) && pPV
->IsLayerVisible( aLayerName
) )
517 const OutlinerView
* pOLV
= GetTextEditOutlinerView();
518 BOOL bIsInsideOutlinerView
= FALSE
;
522 Rectangle
aRect( pOLV
->GetOutputArea() );
524 if (GetMarkedObjectCount() == 1)
526 SdrMark
* pMark
= GetSdrMarkByIndex(0);
527 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
528 aRect
.Union( pObj
->GetLogicRect() );
531 if( aRect
.IsInside( pOLV
->GetWindow()->PixelToLogic( rEvt
.maPosPixel
) ) )
533 bIsInsideOutlinerView
= TRUE
;
537 if( !bIsInsideOutlinerView
)
539 SdTransferable
* pDragTransferable
= SD_MOD()->pTransferDrag
;
541 if( pDragTransferable
)
543 const View
* pSourceView
= pDragTransferable
->GetView();
545 if( pDragTransferable
->IsPageTransferable() )
547 nRet
= DND_ACTION_COPY
;
549 else if( pSourceView
)
551 if( !( nDropAction
& DND_ACTION_LINK
) ||
552 pSourceView
->GetDocSh()->GetMedium()->GetName().Len() )
560 const BOOL bDrawing
= rTargetHelper
.IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING
);
561 const BOOL bGraphic
= rTargetHelper
.IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB
);
562 const BOOL bMtf
= rTargetHelper
.IsDropFormatSupported( FORMAT_GDIMETAFILE
);
563 const BOOL bBitmap
= rTargetHelper
.IsDropFormatSupported( FORMAT_BITMAP
);
564 BOOL bBookmark
= rTargetHelper
.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
);
565 BOOL bXFillExchange
= rTargetHelper
.IsDropFormatSupported( SOT_FORMATSTR_ID_XFA
);
567 // check handle insert
568 if( !nRet
&& ( (bXFillExchange
&& ( SDRDRAG_GRADIENT
== GetDragMode() )) || ( SDRDRAG_TRANSPARENCE
== GetDragMode() ) ) )
570 const SdrHdlList
& rHdlList
= GetHdlList();
572 for( sal_uInt32 n
= 0; n
< rHdlList
.GetHdlCount(); n
++ )
574 SdrHdl
* pIAOHandle
= rHdlList
.GetHdl( n
);
576 if( pIAOHandle
&& ( HDL_COLR
== pIAOHandle
->GetKind() ) )
578 if(pIAOHandle
->getOverlayObjectList().isHitPixel(rEvt
.maPosPixel
))
581 static_cast< SdrHdlColor
* >( pIAOHandle
)->SetSize( SDR_HANDLE_COLOR_SIZE_SELECTED
);
585 static_cast< SdrHdlColor
* >( pIAOHandle
)->SetSize( SDR_HANDLE_COLOR_SIZE_NORMAL
);
591 // check object insert
592 if( !nRet
&& ( bXFillExchange
|| ( ( bDrawing
|| bGraphic
|| bMtf
|| bBitmap
|| bBookmark
) && ( nDropAction
& DND_ACTION_LINK
) ) ) )
594 SdrObject
* pPickObj
= NULL
;
595 SdrPageView
* pPageView
= NULL
;
596 ::sd::Window
* pWindow
= mpViewSh
->GetActiveWindow();
597 Point
aPos( pWindow
->PixelToLogic( rEvt
.maPosPixel
) );
598 const BOOL bHasPickObj
= PickObj( aPos
, getHitTolLog(), pPickObj
, pPageView
);
599 BOOL bIsPresTarget
= FALSE
;
601 if( bHasPickObj
&& pPickObj
&& ( pPickObj
->IsEmptyPresObj() || pPickObj
->GetUserCall() ) )
603 SdPage
* pPage
= (SdPage
*) pPickObj
->GetPage();
605 if( pPage
&& pPage
->IsMasterPage() )
606 bIsPresTarget
= pPage
->IsPresObj( pPickObj
);
609 if( bHasPickObj
&& !bIsPresTarget
&&
610 ( !pPickObj
->ISA( SdrGrafObj
) || bGraphic
|| bMtf
|| bBitmap
|| ( bXFillExchange
&& !pPickObj
->ISA( SdrGrafObj
) && !pPickObj
->ISA( SdrOle2Obj
) ) ) )
612 if( mpDropMarkerObj
!= pPickObj
)
614 mpDropMarkerObj
= pPickObj
;
615 ImplClearDrawDropMarker();
619 mpDropMarker
= new SdrDropMarkerOverlay(*this, *mpDropMarkerObj
);
626 bXFillExchange
= FALSE
;
629 // check normal insert
632 const BOOL bSBAFormat
= rTargetHelper
.IsDropFormatSupported( SOT_FORMATSTR_ID_SVX_FORMFIELDEXCH
);
633 const BOOL bEditEngine
= rTargetHelper
.IsDropFormatSupported( SOT_FORMATSTR_ID_EDITENGINE
);
634 const BOOL bString
= rTargetHelper
.IsDropFormatSupported( FORMAT_STRING
);
635 const BOOL bRTF
= rTargetHelper
.IsDropFormatSupported( FORMAT_RTF
);
636 const BOOL bFile
= rTargetHelper
.IsDropFormatSupported( FORMAT_FILE
);
637 const BOOL bFileList
= rTargetHelper
.IsDropFormatSupported( FORMAT_FILE_LIST
);
641 ImplClearDrawDropMarker();
642 mpDropMarkerObj
= NULL
;
645 if( bBookmark
&& bFile
&& ( nDropAction
& DND_ACTION_MOVE
) && mpViewSh
&& SlideShow::IsRunning(mpViewSh
->GetViewShellBase()) )
648 if( bDrawing
|| bGraphic
|| bMtf
|| bBitmap
|| bBookmark
|| bFile
|| bFileList
|| bXFillExchange
|| bSBAFormat
|| bEditEngine
|| bString
|| bRTF
)
651 // For entries from the navigator, change action copy.
653 && rTargetHelper
.IsDropFormatSupported(
654 SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId())
655 && (nDropAction
& DND_ACTION_MOVE
)!=0)
657 nRet
= DND_ACTION_COPY
;
664 // destroy drop marker if this is a leaving event
665 if( rEvt
.mbLeaving
&& mpDropMarker
)
667 ImplClearDrawDropMarker();
668 mpDropMarkerObj
= NULL
;
674 // -----------------------------------------------------------------------------
676 sal_Int8
View::ExecuteDrop( const ExecuteDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
677 ::sd::Window
* pTargetWindow
, USHORT nPage
, USHORT nLayer
)
679 SdrPageView
* pPV
= GetSdrPageView();
680 String aActiveLayer
= GetActiveLayer();
681 sal_Int8 nDropAction
= rEvt
.mnAction
;
682 sal_Int8 nRet
= DND_ACTION_NONE
;
684 // destroy drop marker if it is shown
687 ImplClearDrawDropMarker();
688 mpDropMarkerObj
= NULL
;
691 if( !pPV
->IsLayerLocked( aActiveLayer
) )
693 const OutlinerView
* pOLV
= GetTextEditOutlinerView();
694 BOOL bIsInsideOutlinerView
= FALSE
;
698 Rectangle
aRect( pOLV
->GetOutputArea() );
700 if( GetMarkedObjectCount() == 1 )
702 SdrMark
* pMark
= GetSdrMarkByIndex(0);
703 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
704 aRect
.Union( pObj
->GetLogicRect() );
707 Point
aPos( pOLV
->GetWindow()->PixelToLogic( rEvt
.maPosPixel
) );
709 if( aRect
.IsInside( aPos
) )
711 bIsInsideOutlinerView
= TRUE
;
715 if( !bIsInsideOutlinerView
)
718 TransferableDataHelper
aDataHelper( rEvt
.maDropEvent
.Transferable
);
721 aPos
= pTargetWindow
->PixelToLogic( rEvt
.maPosPixel
);
724 if( (!nRet
&& ( SDRDRAG_GRADIENT
== GetDragMode() )) || (( SDRDRAG_TRANSPARENCE
== GetDragMode() ) && aDataHelper
.HasFormat( SOT_FORMATSTR_ID_XFA
)) )
726 const SdrHdlList
& rHdlList
= GetHdlList();
728 for( sal_uInt32 n
= 0; !nRet
&& n
< rHdlList
.GetHdlCount(); n
++ )
730 SdrHdl
* pIAOHandle
= rHdlList
.GetHdl( n
);
732 if( pIAOHandle
&& ( HDL_COLR
== pIAOHandle
->GetKind() ) )
734 if(pIAOHandle
->getOverlayObjectList().isHitPixel(rEvt
.maPosPixel
))
736 SotStorageStreamRef xStm
;
738 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_XFA
, xStm
) && xStm
.Is() )
740 XFillExchangeData
aFillData( XFillAttrSetItem( &mpDoc
->GetPool() ) );
743 const Color
aColor( ( (XFillColorItem
&) aFillData
.GetXFillAttrSetItem()->GetItemSet().Get( XATTR_FILLCOLOR
) ).GetColorValue() );
744 static_cast< SdrHdlColor
* >( pIAOHandle
)->SetColor( aColor
, TRUE
);
753 if( !nRet
&& InsertData( aDataHelper
, aPos
, nDropAction
, TRUE
, 0, nPage
, nLayer
) )
757 if( !nRet
&& mpViewSh
)
759 String aTmpString1
, aTmpString2
;
760 INetBookmark
aINetBookmark( aTmpString1
, aTmpString2
);
763 if( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
) &&
764 aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aINetBookmark
) )
766 SdPageObjsTLB::SdPageObjsTransferable
* pPageObjsTransferable
= SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper
.GetXTransferable() );
768 if( pPageObjsTransferable
&&
769 ( NAVIGATOR_DRAGTYPE_LINK
== pPageObjsTransferable
->GetDragType() ||
770 NAVIGATOR_DRAGTYPE_EMBEDDED
== pPageObjsTransferable
->GetDragType() ) )
772 // insert bookmark from own navigator (handled async. due to possible message box )
773 Application::PostUserEvent( LINK( this, View
, ExecuteNavigatorDrop
),
774 new SdNavigatorDropEvent( rEvt
, rTargetHelper
, pTargetWindow
,
780 SdrObject
* pPickObj
= NULL
;
781 SdrPageView
* pPageView
= NULL
;
783 if( PickObj( aPos
, getHitTolLog(), pPickObj
, pPageView
) )
785 // insert as clip action => jump
786 rtl::OUString
aBookmark( aINetBookmark
.GetURL() );
787 SdAnimationInfo
* pInfo
= mpDoc
->GetAnimationInfo( pPickObj
);
788 BOOL bCreated
= FALSE
;
790 if( aBookmark
.getLength() )
792 presentation::ClickAction eClickAction
= presentation::ClickAction_DOCUMENT
;
794 sal_Int32 nIndex
= aBookmark
.indexOf( (sal_Unicode
)'#' );
797 const String
aDocName( aBookmark
.copy( 0, nIndex
) );
799 if( mpDocSh
->GetMedium()->GetName() == aDocName
|| mpDocSh
->GetName() == aDocName
)
801 // internal jump, only use the part after and including '#'
802 eClickAction
= presentation::ClickAction_BOOKMARK
;
803 aBookmark
= aBookmark
.copy( nIndex
+1 );
809 pInfo
= SdDrawDocument::GetShapeUserData( *pPickObj
, true );
813 // Undo-Action mit alten und neuen Groessen erzeugen
814 SdAnimationPrmsUndoAction
* pAction
= new SdAnimationPrmsUndoAction(mpDoc
, pPickObj
, bCreated
);
815 pAction
->SetActive(pInfo
->mbActive
, pInfo
->mbActive
);
816 pAction
->SetEffect(pInfo
->meEffect
, pInfo
->meEffect
);
817 pAction
->SetTextEffect(pInfo
->meTextEffect
, pInfo
->meTextEffect
);
818 pAction
->SetSpeed(pInfo
->meSpeed
, pInfo
->meSpeed
);
819 pAction
->SetDim(pInfo
->mbDimPrevious
, pInfo
->mbDimPrevious
);
820 pAction
->SetDimColor(pInfo
->maDimColor
, pInfo
->maDimColor
);
821 pAction
->SetDimHide(pInfo
->mbDimHide
, pInfo
->mbDimHide
);
822 pAction
->SetSoundOn(pInfo
->mbSoundOn
, pInfo
->mbSoundOn
);
823 pAction
->SetSound(pInfo
->maSoundFile
, pInfo
->maSoundFile
);
824 pAction
->SetPlayFull(pInfo
->mbPlayFull
, pInfo
->mbPlayFull
);
825 pAction
->SetPathObj(pInfo
->mpPathObj
, pInfo
->mpPathObj
);
826 pAction
->SetClickAction(pInfo
->meClickAction
, eClickAction
);
827 pAction
->SetBookmark(pInfo
->GetBookmark(), aBookmark
);
828 // pAction->SetInvisibleInPres(pInfo->mbInvisibleInPresentation, TRUE);
829 pAction
->SetVerb(pInfo
->mnVerb
, pInfo
->mnVerb
);
830 pAction
->SetSecondEffect(pInfo
->meSecondEffect
, pInfo
->meSecondEffect
);
831 pAction
->SetSecondSpeed(pInfo
->meSecondSpeed
, pInfo
->meSecondSpeed
);
832 pAction
->SetSecondSoundOn(pInfo
->mbSecondSoundOn
, pInfo
->mbSecondSoundOn
);
833 pAction
->SetSecondPlayFull(pInfo
->mbSecondPlayFull
, pInfo
->mbSecondPlayFull
);
835 String
aString(SdResId(STR_UNDO_ANIMATION
));
836 pAction
->SetComment(aString
);
837 mpDocSh
->GetUndoManager()->AddUndoAction(pAction
);
838 pInfo
->meClickAction
= eClickAction
;
839 pInfo
->SetBookmark( aBookmark
);
845 else if( mpViewSh
->ISA( DrawViewShell
) )
847 // insert as normal URL button
848 ( (DrawViewShell
*) mpViewSh
)->InsertURLButton( aINetBookmark
.GetURL(), aINetBookmark
.GetDescription(), String(), &aPos
);
860 // -----------------------------------------------------------------------------
862 IMPL_LINK( View
, ExecuteNavigatorDrop
, SdNavigatorDropEvent
*, pSdNavigatorDropEvent
)
864 TransferableDataHelper
aDataHelper( pSdNavigatorDropEvent
->maDropEvent
.Transferable
);
865 SdPageObjsTLB::SdPageObjsTransferable
* pPageObjsTransferable
= SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper
.GetXTransferable() );
866 INetBookmark aINetBookmark
;
868 if( pPageObjsTransferable
&& aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aINetBookmark
) )
873 SdPage
* pPage
= (SdPage
*) GetSdrPageView()->GetPage();
874 USHORT nPgPos
= 0xFFFF;
876 if( pSdNavigatorDropEvent
->mpTargetWindow
)
877 aPos
= pSdNavigatorDropEvent
->mpTargetWindow
->PixelToLogic( pSdNavigatorDropEvent
->maPosPixel
);
879 const rtl::OUString
aURL( aINetBookmark
.GetURL() );
880 sal_Int32 nIndex
= aURL
.indexOf( (sal_Unicode
)'#' );
882 aBookmark
= aURL
.copy( nIndex
+1 );
883 aBookmarkList
.Insert( &aBookmark
);
885 if( !pPage
->IsMasterPage() )
887 if( pPage
->GetPageKind() == PK_STANDARD
)
888 nPgPos
= pPage
->GetPageNum() + 2;
889 else if( pPage
->GetPageKind() == PK_NOTES
)
890 nPgPos
= pPage
->GetPageNum() + 1;
893 // Um zu gewaehrleisten, dass alle Seitennamen eindeutig sind, werden
894 // die einzufuegenden geprueft und gegebenenfalls in einer Ersatzliste
895 // aufgenommen (bNameOK == FALSE -> Benutzer hat abgebrochen)
896 List
* pExchangeList
= NULL
;
897 BOOL bLink
= ( NAVIGATOR_DRAGTYPE_LINK
== pPageObjsTransferable
->GetDragType() ? TRUE
: FALSE
);
898 BOOL bNameOK
= GetExchangeList( pExchangeList
, &aBookmarkList
, 2 );
899 BOOL bReplace
= FALSE
;
901 // Da man hier nicht weiss, ob es sich um eine Seite oder ein Objekt handelt,
902 // wird eine Liste sowohl mit Seiten, als auch mit Objekten gefuellt.
903 // Sollten Seitennamen und Objektnamen identisch sein gibt es hier natuerlich Probleme !!!
906 mpDoc
->InsertBookmark( &aBookmarkList
, pExchangeList
,
907 bLink
, bReplace
, nPgPos
, FALSE
,
908 &pPageObjsTransferable
->GetDocShell(),
912 // Loeschen der ExchangeList
915 for( void* p
= pExchangeList
->First(); p
; p
= pExchangeList
->Next() )
918 delete pExchangeList
;
922 delete pSdNavigatorDropEvent
;
927 /*************************************************************************
929 |* Rueckgabeparameter:
930 |* pExchangeList == NULL -> Namen sind alle eindeutig
931 |* bNameOK == FALSE -> Benutzer hat abgebrochen
932 |* nType == 0 -> Seiten
933 |* nType == 1 -> Objekte
934 |* nType == 2 -> Seiten + Objekte
936 \************************************************************************/
938 BOOL
View::GetExchangeList( List
*& rpExchangeList
, List
* pBookmarkList
, USHORT nType
)
940 DBG_ASSERT( !rpExchangeList
, "ExchangeList muss NULL sein!");
942 BOOL bListIdentical
= TRUE
; // BookmarkList und ExchangeList sind gleich
943 BOOL bNameOK
= TRUE
; // Name ist eindeutig
945 rpExchangeList
= new List();
949 String
* pString
= (String
*) pBookmarkList
->First();
951 while( pString
&& bNameOK
)
953 String
* pNewName
= new String( *pString
);
955 if( nType
== 0 || nType
== 2 )
956 bNameOK
= mpDocSh
->CheckPageName (
957 mpViewSh
->GetActiveWindow(), *pNewName
);
959 if( bNameOK
&& ( nType
== 1 || nType
== 2 ) )
961 if( mpDoc
->GetObj( *pNewName
) )
963 String
aTitle( SdResId( STR_TITLE_NAMEGROUP
) );
964 String
aDesc( SdResId( STR_DESC_NAMEGROUP
) );
965 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
966 AbstractSvxNameDialog
* pDlg
= pFact
? pFact
->CreateSvxNameDialog( mpViewSh
->GetActiveWindow(), *pNewName
, aDesc
, RID_SVXDLG_NAME
) : 0;
969 pDlg
->SetEditHelpId( HID_SD_NAMEDIALOG_OBJECT
);
972 pDlg
->SetText( aTitle
);
974 while( !bNameOK
&& pDlg
->Execute() == RET_OK
)
976 pDlg
->GetName( *pNewName
);
978 if( !mpDoc
->GetObj( *pNewName
) )
988 bListIdentical
= ( *pString
== *pNewName
);
990 rpExchangeList
->Insert( pNewName
, LIST_APPEND
);
991 pString
= (String
*) pBookmarkList
->Next();
995 // ExchangeList ist mit BookmarkList identisch
996 if( rpExchangeList
&& bListIdentical
)
998 String
* pString
= (String
*) rpExchangeList
->First();
1002 pString
= (String
*) rpExchangeList
->Next();
1004 delete rpExchangeList
;
1005 rpExchangeList
= NULL
;
1011 typedef std::vector
< std::pair
< sal_uInt32
, sal_uInt32
> > PathSurrogateVector
;
1012 typedef std::vector
< SdrObject
* > SdrObjectVector
;
1014 void ImplProcessObjectList(SdrObject
* pObj
, SdrObjectVector
& rVector
)
1016 sal_Bool
bIsGroup(pObj
->IsGroupObject());
1017 if(bIsGroup
&& pObj
->ISA(E3dObject
) && !pObj
->ISA(E3dScene
))
1018 bIsGroup
= sal_False
;
1020 rVector
.push_back( pObj
);
1024 SdrObjList
* pObjList
= pObj
->GetSubList();
1026 for( a
= 0; a
< pObjList
->GetObjCount(); a
++)
1027 ImplProcessObjectList(pObjList
->GetObj(a
), rVector
);
1031 SdrModel
* View::GetMarkedObjModel() const
1033 return FmFormView::GetMarkedObjModel();;
1036 BOOL
View::Paste(const SdrModel
& rMod
, const Point
& rPos
, SdrObjList
* pLst
/* =NULL */, UINT32 nOptions
/* =0 */)
1038 return FmFormView::Paste( rMod
, rPos
, pLst
,nOptions
);;
1041 } // end of namespace sd