xref: /AOO41X/main/sd/source/ui/view/sdview2.cxx (revision ff0525f24f03981d56b7579b645949f111420994)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include "View.hxx"
29 
30 #include <vector>
31 #include <com/sun/star/embed/XEmbedPersist.hpp>
32 #include <tools/ref.hxx>
33 #include <tools/urlobj.hxx>
34 #ifndef _MSGBOX_HXX //autogen
35 #include <vcl/msgbox.hxx>
36 #endif
37 #include <svx/svdetc.hxx>
38 #include <svx/svdoole2.hxx>
39 #include <svx/svdograf.hxx>
40 #include <vcl/graph.hxx>
41 #include <svx/xexch.hxx>
42 #include <svx/svxdlg.hxx>
43 #include <svx/dialogs.hrc>
44 #include <sfx2/docfile.hxx>
45 #include <sfx2/childwin.hxx>
46 #include <svx/svdundo.hxx>
47 #include <svx/svdpagv.hxx>
48 #include <svl/urlbmk.hxx>
49 #include <svl/urlbmk.hxx>
50 #include <editeng/outliner.hxx>
51 #include <svx/xflclit.hxx>
52 #include <svx/dbexch.hrc>
53 #include <sot/formats.hxx>
54 #include <editeng/editeng.hxx>
55 #include <svx/svditer.hxx>
56 #include <svx/obj3d.hxx>
57 #include <svx/scene3d.hxx>
58 
59 #include <sfx2/objsh.hxx>
60 #include <svtools/embedtransfer.hxx>
61 
62 #include "navigatr.hxx"
63 #include "anminfo.hxx"
64 #include "strings.hrc"
65 #include "glob.hrc"
66 #include "sdxfer.hxx"
67 #include "sdresid.hxx"
68 #include "sdmod.hxx"
69 #include "DrawViewShell.hxx"
70 #include "DrawDocShell.hxx"
71 #include "fudraw.hxx"
72 #include "drawdoc.hxx"
73 #include "Window.hxx"
74 #include "sdpage.hxx"
75 #include "unoaprms.hxx"
76 #include "drawview.hxx"
77 #include "helpids.h"
78 #include <vcl/svapp.hxx>
79 
80 #include "slideshow.hxx"
81 
82 namespace sd {
83 
84 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
85 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
86 SO2_DECL_REF(SvInPlaceObject)
87 #endif
88 #ifndef SO2_DECL_SVSTORAGE_DEFINED
89 #define SO2_DECL_SVSTORAGE_DEFINED
90 SO2_DECL_REF(SvStorage)
91 #endif
92 
93 using namespace ::com::sun::star;
94 
95 // ------------------------
96 // - SdNavigatorDropEvent -
97 // ------------------------
98 
99 struct SdNavigatorDropEvent : public ExecuteDropEvent
100 {
101     DropTargetHelper&       mrTargetHelper;
102     ::sd::Window* mpTargetWindow;
103     sal_uInt16                  mnPage;
104     sal_uInt16                  mnLayer;
105 
106     SdNavigatorDropEvent (
107         const ExecuteDropEvent& rEvt,
108         DropTargetHelper& rTargetHelper,
109         ::sd::Window* pTargetWindow,
110         sal_uInt16 nPage,
111         sal_uInt16 nLayer )
112         : ExecuteDropEvent( rEvt ),
113           mrTargetHelper( rTargetHelper ),
114           mpTargetWindow( pTargetWindow ),
115           mnPage( nPage ),
116           mnLayer( nLayer )
117     {}
118 };
119 
120 // -----------------------------------------------------------------------------
121 
122 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > View::CreateClipboardDataObject( View*, ::Window& )
123 {
124     // since SdTransferable::CopyToClipboard is called, this
125     // dynamically created object ist destroyed automatically
126     SdTransferable* pTransferable = new SdTransferable( mpDoc, NULL, sal_False );
127     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRet( pTransferable );
128 
129     SD_MOD()->pTransferClip = pTransferable;
130 
131     mpDoc->CreatingDataObj( pTransferable );
132     pTransferable->SetWorkDocument( (SdDrawDocument*) GetAllMarkedModel() );
133     mpDoc->CreatingDataObj( NULL );
134 
135     // #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get
136     // fat lines correctly
137     const Rectangle                 aMarkRect( GetAllMarkedBoundRect() );
138     TransferableObjectDescriptor    aObjDesc;
139     String                          aDisplayName;
140     SdrOle2Obj*                     pSdrOleObj = NULL;
141     SdrPageView*                    pPgView = GetSdrPageView();
142     SdPage*                         pOldPage = pPgView ? ( (SdPage*) pPgView->GetPage() ) : NULL;
143     SdPage*                         pNewPage = (SdPage*) pTransferable->GetWorkDocument()->GetPage( 0 );
144 
145     if( pOldPage )
146     {
147         pNewPage->SetSize( pOldPage->GetSize() );
148         pNewPage->SetLayoutName( pOldPage->GetLayoutName() );
149     }
150 
151     if( GetMarkedObjectCount() == 1 )
152     {
153         SdrObject* pObj = GetMarkedObjectByIndex(0);
154 
155         if( pObj && pObj->ISA(SdrOle2Obj) && ((SdrOle2Obj*) pObj)->GetObjRef().is() )
156         {
157             // If object has no persistence it must be copied as part of the document
158             try
159             {
160                 uno::Reference< embed::XEmbedPersist > xPersObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
161                 if ( xPersObj.is() && xPersObj->hasEntry() )
162                     pSdrOleObj = (SdrOle2Obj*) pObj;
163             }
164             catch( uno::Exception& )
165             {}
166         }
167     }
168 
169     if( pSdrOleObj )
170         SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
171     else
172         pTransferable->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( aObjDesc );
173 
174     if( mpDocSh )
175         aObjDesc.maDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
176 
177     aObjDesc.maSize = aMarkRect.GetSize();
178 
179     pTransferable->SetStartPos( aMarkRect.TopLeft() );
180     pTransferable->SetObjectDescriptor( aObjDesc );
181     pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() );
182 
183     return xRet;
184 }
185 
186 // -----------------------------------------------------------------------------
187 
188 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > View::CreateDragDataObject( View* pWorkView, ::Window& rWindow, const Point& rDragPos )
189 {
190     SdTransferable* pTransferable = new SdTransferable( mpDoc, pWorkView, sal_False );
191     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRet( pTransferable );
192 
193     SD_MOD()->pTransferDrag = pTransferable;
194 
195     TransferableObjectDescriptor    aObjDesc;
196     String                          aDisplayName;
197     SdrOle2Obj*                     pSdrOleObj = NULL;
198 
199     if( GetMarkedObjectCount() == 1 )
200     {
201         SdrObject* pObj = GetMarkedObjectByIndex( 0 );
202 
203         if( pObj && pObj->ISA( SdrOle2Obj ) && ( (SdrOle2Obj*) pObj )->GetObjRef().is() )
204         {
205             // If object has no persistence it must be copied as part of the document
206             try
207             {
208                 uno::Reference< embed::XEmbedPersist > xPersObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
209                 if ( xPersObj.is() && xPersObj->hasEntry() )
210                     pSdrOleObj = (SdrOle2Obj*) pObj;
211             }
212             catch( uno::Exception& )
213             {}
214         }
215     }
216 
217     if( mpDocSh )
218         aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
219 
220     if( pSdrOleObj )
221         SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
222     else
223         mpDocSh->FillTransferableObjectDescriptor( aObjDesc );
224 
225     aObjDesc.maSize = GetAllMarkedRect().GetSize();
226     aObjDesc.maDragStartPos = rDragPos;
227     aObjDesc.maDisplayName = aDisplayName;
228     aObjDesc.mbCanLink = sal_False;
229 
230     pTransferable->SetStartPos( rDragPos );
231     pTransferable->SetObjectDescriptor( aObjDesc );
232     pTransferable->StartDrag( &rWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
233 
234     return xRet;
235 }
236 
237 // -----------------------------------------------------------------------------
238 
239 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > View::CreateSelectionDataObject( View* pWorkView, ::Window& rWindow )
240 {
241     SdTransferable*                 pTransferable = new SdTransferable( mpDoc, pWorkView, sal_True );
242     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRet( pTransferable );
243     TransferableObjectDescriptor    aObjDesc;
244     const Rectangle                 aMarkRect( GetAllMarkedRect() );
245     String                          aDisplayName;
246 
247     SD_MOD()->pTransferSelection = pTransferable;
248 
249     if( mpDocSh )
250     {
251         aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
252         mpDocSh->FillTransferableObjectDescriptor( aObjDesc );
253     }
254 
255     aObjDesc.maSize = aMarkRect.GetSize();
256 
257     pTransferable->SetStartPos( aMarkRect.TopLeft() );
258     pTransferable->SetObjectDescriptor( aObjDesc );
259     pTransferable->CopyToSelection( &rWindow );
260 
261     return xRet;
262 }
263 
264 // -----------------------------------------------------------------------------
265 
266 void View::UpdateSelectionClipboard( sal_Bool bForceDeselect )
267 {
268     if( mpViewSh && mpViewSh->GetActiveWindow() )
269     {
270         if( !bForceDeselect && GetMarkedObjectList().GetMarkCount() )
271             CreateSelectionDataObject( this, *mpViewSh->GetActiveWindow() );
272         else if( SD_MOD()->pTransferSelection && ( SD_MOD()->pTransferSelection->GetView() == this ) )
273         {
274             TransferableHelper::ClearSelection( mpViewSh->GetActiveWindow() );
275             SD_MOD()->pTransferSelection = NULL;
276         }
277     }
278 }
279 
280 // -----------------------------------------------------------------------------
281 
282 void View::DoCut(::Window* )
283 {
284     const OutlinerView* pOLV = GetTextEditOutlinerView();
285 
286     if( pOLV )
287         ( (OutlinerView*) pOLV)->Cut();
288     else if( AreObjectsMarked() )
289     {
290         String aStr( SdResId(STR_UNDO_CUT) );
291 
292         DoCopy();
293         BegUndo( ( aStr += sal_Unicode(' ') ) += GetDescriptionOfMarkedObjects() );
294         DeleteMarked();
295         EndUndo();
296     }
297 }
298 
299 // -----------------------------------------------------------------------------
300 
301 void View::DoCopy (::Window* pWindow)
302 {
303     const OutlinerView* pOLV = GetTextEditOutlinerView();
304 
305     if( pOLV )
306         ( (OutlinerView*) pOLV)->Copy();
307     else if( AreObjectsMarked() )
308     {
309         BrkAction();
310         CreateClipboardDataObject( this, *pWindow );
311     }
312 }
313 
314 // -----------------------------------------------------------------------------
315 
316 void View::DoPaste (::Window* pWindow)
317 {
318     TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewSh->GetActiveWindow() ) );
319     if( !aDataHelper.GetTransferable().is() )
320         return; // empty clipboard?
321 
322     const OutlinerView* pOLV = GetTextEditOutlinerView();
323 
324     if( pOLV && EditEngine::HasValidData( aDataHelper.GetTransferable() ) )
325     {
326         const_cast< OutlinerView* >(pOLV)->PasteSpecial();
327 
328         SdrObject*  pObj = GetTextEditObject();
329         SdPage*     pPage = (SdPage*)( pObj ? pObj->GetPage() : NULL );
330         ::Outliner* pOutliner = pOLV->GetOutliner();
331 
332         if( pOutliner)
333         {
334             if( pObj && pPage && pPage->GetPresObjKind(pObj) == PRESOBJ_TITLE )
335             {
336                 // remove all hard linebreaks from the title
337                 if( pOutliner && pOutliner->GetParagraphCount() > 1 )
338                 {
339                     sal_Bool bOldUpdateMode = pOutliner->GetUpdateMode();
340 
341                     pOutliner->SetUpdateMode( sal_False );
342 
343                     const EditEngine& rEdit = pOutliner->GetEditEngine();
344                     const int nParaCount = rEdit.GetParagraphCount();
345 
346                     for( int nPara = nParaCount - 2; nPara >= 0; nPara-- )
347                     {
348                         const sal_uInt16 nParaLen = (sal_uInt16)rEdit.GetTextLen( (sal_uInt16)nPara );
349                         pOutliner->QuickDelete( ESelection( (sal_uInt16)nPara, nParaLen, (sal_uInt16)nPara+1, 0 ) );
350                         pOutliner->QuickInsertLineBreak( ESelection( (sal_uInt16)nPara, nParaLen, (sal_uInt16)nPara, nParaLen ) );
351                     }
352 
353                     DBG_ASSERT( rEdit.GetParagraphCount() <= 1, "Titelobjekt contains hard line breaks" );
354                     pOutliner->SetUpdateMode(bOldUpdateMode);
355                 }
356             }
357 
358             if( !mpDoc->IsChanged() )
359             {
360                 if( pOutliner && pOutliner->IsModified() )
361                     mpDoc->SetChanged( sal_True );
362             }
363         }
364     }
365     else
366     {
367         Point       aPos;
368         sal_Int8    nDnDAction = DND_ACTION_COPY;
369 
370         if( pWindow )
371             aPos = pWindow->PixelToLogic( Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() );
372 
373         DrawViewShell* pDrViewSh = (DrawViewShell*) mpDocSh->GetViewShell();
374 
375         if (pDrViewSh != NULL)
376         {
377             if( !InsertData( aDataHelper, aPos, nDnDAction, sal_False ) )
378             {
379                 INetBookmark    aINetBookmark( aEmptyStr, aEmptyStr );
380 
381                 if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
382                       aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
383                     ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
384                       aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
385                     ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
386                       aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
387                 {
388                     pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
389                 }
390             }
391         }
392     }
393 }
394 
395 // -----------------------------------------------------------------------------
396 
397 void View::StartDrag( const Point& rStartPos, ::Window* pWindow )
398 {
399     if( AreObjectsMarked() && IsAction() && mpViewSh && pWindow && !mpDragSrcMarkList )
400     {
401         BrkAction();
402 
403         if( IsTextEdit() )
404             SdrEndTextEdit();
405 
406         DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpDocSh ? mpDocSh->GetViewShell() : 0 );
407 
408         if( pDrawViewShell )
409         {
410             FunctionReference xFunction( pDrawViewShell->GetCurrentFunction() );
411 
412             if( xFunction.is() && xFunction->ISA( FuDraw ) )
413                 static_cast<FuDraw*>(xFunction.get())->ForcePointer( NULL );
414         }
415 
416         mpDragSrcMarkList = new SdrMarkList(GetMarkedObjectList());
417         mnDragSrcPgNum = GetSdrPageView()->GetPage()->GetPageNum();
418 
419         if( IsUndoEnabled() )
420         {
421             String aStr( SdResId(STR_UNDO_DRAGDROP) );
422             aStr += sal_Unicode(' ');
423             aStr += mpDragSrcMarkList->GetMarkDescription();
424             BegUndo(aStr);
425         }
426         CreateDragDataObject( this, *pWindow, rStartPos );
427     }
428 }
429 
430 // -----------------------------------------------------------------------------
431 
432 void View::DragFinished( sal_Int8 nDropAction )
433 {
434     const bool bUndo = IsUndoEnabled();
435 
436     SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
437 
438     if( pDragTransferable )
439         pDragTransferable->SetView( NULL );
440 
441     if( ( nDropAction & DND_ACTION_MOVE ) &&
442         pDragTransferable && !pDragTransferable->IsInternalMove() &&
443         mpDragSrcMarkList && mpDragSrcMarkList->GetMarkCount() &&
444         !IsPresObjSelected() )
445     {
446         mpDragSrcMarkList->ForceSort();
447 
448         if( bUndo )
449             BegUndo();
450 
451         sal_uLong nm, nAnz = mpDragSrcMarkList->GetMarkCount();
452 
453         for( nm = nAnz; nm>0; )
454         {
455             nm--;
456             SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
457             if( bUndo )
458                 AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pM->GetMarkedSdrObj()));
459         }
460 
461         mpDragSrcMarkList->GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
462 
463         for (nm=nAnz; nm>0;)
464         {
465             nm--;
466             SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
467             SdrObject* pObj=pM->GetMarkedSdrObj();
468             sal_uInt32 nOrdNum=pObj->GetOrdNumDirect();
469 
470             if( pObj && pObj->GetPage() )
471             {
472 #ifdef DBG_UTIL
473                 SdrObject* pChkObj =
474 #endif
475                     pObj->GetPage()->RemoveObject(nOrdNum);
476                 DBG_ASSERT(pChkObj==pObj,"pChkObj!=pObj beim RemoveObject()");
477             }
478         }
479 
480         if( bUndo )
481             EndUndo();
482     }
483 
484     if( pDragTransferable )
485         pDragTransferable->SetInternalMove( sal_False );
486 
487     if( bUndo )
488         EndUndo();
489     mnDragSrcPgNum = SDRPAGE_NOTFOUND;
490     delete mpDragSrcMarkList;
491     mpDragSrcMarkList = NULL;
492 }
493 
494 // -----------------------------------------------------------------------------
495 
496 sal_Int8 View::AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
497                              ::sd::Window*, sal_uInt16, sal_uInt16 nLayer )
498 {
499     String          aLayerName( GetActiveLayer() );
500     SdrPageView*    pPV = GetSdrPageView();
501     sal_Int8        nDropAction = rEvt.mnAction;
502     sal_Int8        nRet = DND_ACTION_NONE;
503 
504     if( nLayer != SDRLAYER_NOTFOUND )
505     {
506         SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
507         aLayerName = rLayerAdmin.GetLayerPerID(nLayer)->GetName();
508     }
509 
510     if( mbIsDropAllowed && !pPV->IsLayerLocked( aLayerName ) && pPV->IsLayerVisible( aLayerName ) )
511     {
512         const OutlinerView* pOLV = GetTextEditOutlinerView();
513         sal_Bool                bIsInsideOutlinerView = sal_False;
514 
515         if( pOLV )
516         {
517             Rectangle aRect( pOLV->GetOutputArea() );
518 
519             if (GetMarkedObjectCount() == 1)
520             {
521                 SdrMark* pMark = GetSdrMarkByIndex(0);
522                 SdrObject* pObj = pMark->GetMarkedSdrObj();
523                 aRect.Union( pObj->GetLogicRect() );
524             }
525 
526             if( aRect.IsInside( pOLV->GetWindow()->PixelToLogic( rEvt.maPosPixel ) ) )
527             {
528                 bIsInsideOutlinerView = sal_True;
529             }
530         }
531 
532         if( !bIsInsideOutlinerView )
533         {
534             SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
535 
536             if( pDragTransferable )
537             {
538                 const View* pSourceView = pDragTransferable->GetView();
539 
540                 if( pDragTransferable->IsPageTransferable() )
541                 {
542                     nRet = DND_ACTION_COPY;
543                 }
544                 else if( pSourceView )
545                 {
546                     if( !( nDropAction & DND_ACTION_LINK ) ||
547                         pSourceView->GetDocSh()->GetMedium()->GetName().Len() )
548                     {
549                         nRet = nDropAction;
550                     }
551                 }
552             }
553             else
554             {
555                 const sal_Bool  bDrawing = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING );
556                 const sal_Bool  bGraphic = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB );
557                 const sal_Bool  bMtf = rTargetHelper.IsDropFormatSupported( FORMAT_GDIMETAFILE );
558                 const sal_Bool  bBitmap = rTargetHelper.IsDropFormatSupported( FORMAT_BITMAP );
559                 sal_Bool        bBookmark = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
560                 sal_Bool        bXFillExchange = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_XFA );
561 
562                 // check handle insert
563                 if( !nRet && ( (bXFillExchange && ( SDRDRAG_GRADIENT == GetDragMode() )) || ( SDRDRAG_TRANSPARENCE == GetDragMode() ) ) )
564                 {
565                     const SdrHdlList& rHdlList = GetHdlList();
566 
567                     for( sal_uInt32 n = 0; n < rHdlList.GetHdlCount(); n++ )
568                     {
569                         SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
570 
571                         if( pIAOHandle && ( HDL_COLR == pIAOHandle->GetKind() ) )
572                         {
573                             if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
574                             {
575                                 nRet = nDropAction;
576                                 static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_SELECTED );
577                             }
578                             else
579                             {
580                                 static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_NORMAL );
581                             }
582                         }
583                     }
584                 }
585 
586                 // check object insert
587                 if( !nRet && ( bXFillExchange || ( ( bDrawing || bGraphic || bMtf || bBitmap || bBookmark ) && ( nDropAction & DND_ACTION_LINK ) ) ) )
588                 {
589                     SdrObject*      pPickObj = NULL;
590                     SdrPageView*    pPageView = NULL;
591                     ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
592                     Point           aPos( pWindow->PixelToLogic( rEvt.maPosPixel ) );
593                     const sal_Bool      bHasPickObj = PickObj( aPos, getHitTolLog(), pPickObj, pPageView );
594                     sal_Bool            bIsPresTarget = sal_False;
595 
596                     if( bHasPickObj && pPickObj && ( pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall() ) )
597                     {
598                         SdPage* pPage = (SdPage*) pPickObj->GetPage();
599 
600                         if( pPage && pPage->IsMasterPage() )
601                             bIsPresTarget = pPage->IsPresObj( pPickObj );
602                     }
603 
604                     if( bHasPickObj && !bIsPresTarget &&
605                         ( !pPickObj->ISA( SdrGrafObj ) || bGraphic || bMtf || bBitmap || ( bXFillExchange && !pPickObj->ISA( SdrGrafObj ) && !pPickObj->ISA( SdrOle2Obj ) ) ) )
606                     {
607                         if( mpDropMarkerObj != pPickObj )
608                         {
609                             mpDropMarkerObj = pPickObj;
610                             ImplClearDrawDropMarker();
611 
612                             if(mpDropMarkerObj)
613                             {
614                                 mpDropMarker = new SdrDropMarkerOverlay(*this, *mpDropMarkerObj);
615                             }
616                         }
617 
618                         nRet = nDropAction;
619                     }
620                     else
621                         bXFillExchange = sal_False;
622                 }
623 
624                 // check normal insert
625                 if( !nRet )
626                 {
627                     const sal_Bool  bSBAFormat = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_SVX_FORMFIELDEXCH );
628                     const sal_Bool  bEditEngine = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_EDITENGINE );
629                     const sal_Bool  bString = rTargetHelper.IsDropFormatSupported( FORMAT_STRING );
630                     const sal_Bool  bRTF = rTargetHelper.IsDropFormatSupported( FORMAT_RTF );
631                     const sal_Bool  bFile = rTargetHelper.IsDropFormatSupported( FORMAT_FILE );
632                     const sal_Bool  bFileList = rTargetHelper.IsDropFormatSupported( FORMAT_FILE_LIST );
633 
634                     if( mpDropMarker )
635                     {
636                         ImplClearDrawDropMarker();
637                         mpDropMarkerObj = NULL;
638                     }
639 
640                     if( bBookmark && bFile && ( nDropAction & DND_ACTION_MOVE ) && mpViewSh && SlideShow::IsRunning(mpViewSh->GetViewShellBase()) )
641                         bBookmark = sal_False;
642 
643                     if( bDrawing || bGraphic || bMtf || bBitmap || bBookmark || bFile || bFileList || bXFillExchange || bSBAFormat || bEditEngine || bString || bRTF )
644                         nRet = nDropAction;
645 
646                     // For entries from the navigator, change action copy.
647                     if (bBookmark
648                         && rTargetHelper.IsDropFormatSupported(
649                             SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId())
650                         && (nDropAction & DND_ACTION_MOVE)!=0)
651                     {
652                         nRet = DND_ACTION_COPY;
653                     }
654                 }
655             }
656         }
657     }
658 
659     // destroy drop marker if this is a leaving event
660     if( rEvt.mbLeaving && mpDropMarker )
661     {
662         ImplClearDrawDropMarker();
663         mpDropMarkerObj = NULL;
664     }
665 
666     return nRet;
667 }
668 
669 // -----------------------------------------------------------------------------
670 
671 sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
672                               ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer )
673 {
674     SdrPageView*    pPV = GetSdrPageView();
675     String          aActiveLayer = GetActiveLayer();
676     sal_Int8        nDropAction = rEvt.mnAction;
677     sal_Int8        nRet = DND_ACTION_NONE;
678 
679     // destroy drop marker if it is shown
680     if( mpDropMarker )
681     {
682         ImplClearDrawDropMarker();
683         mpDropMarkerObj = NULL;
684     }
685 
686     if( !pPV->IsLayerLocked( aActiveLayer ) )
687     {
688         const OutlinerView* pOLV = GetTextEditOutlinerView();
689         sal_Bool                bIsInsideOutlinerView = sal_False;
690 
691         if( pOLV )
692         {
693             Rectangle aRect( pOLV->GetOutputArea() );
694 
695             if( GetMarkedObjectCount() == 1 )
696             {
697                 SdrMark* pMark = GetSdrMarkByIndex(0);
698                 SdrObject* pObj = pMark->GetMarkedSdrObj();
699                 aRect.Union( pObj->GetLogicRect() );
700             }
701 
702             Point aPos( pOLV->GetWindow()->PixelToLogic( rEvt.maPosPixel ) );
703 
704             if( aRect.IsInside( aPos ) )
705             {
706                 bIsInsideOutlinerView = sal_True;
707             }
708         }
709 
710         if( !bIsInsideOutlinerView )
711         {
712             Point                   aPos;
713             TransferableDataHelper  aDataHelper( rEvt.maDropEvent.Transferable );
714 
715             if( pTargetWindow )
716                 aPos = pTargetWindow->PixelToLogic( rEvt.maPosPixel );
717 
718             // handle insert?
719             if( (!nRet && ( SDRDRAG_GRADIENT == GetDragMode() )) || (( SDRDRAG_TRANSPARENCE == GetDragMode() ) && aDataHelper.HasFormat( SOT_FORMATSTR_ID_XFA )) )
720             {
721                 const SdrHdlList& rHdlList = GetHdlList();
722 
723                 for( sal_uInt32 n = 0; !nRet && n < rHdlList.GetHdlCount(); n++ )
724                 {
725                     SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
726 
727                     if( pIAOHandle && ( HDL_COLR == pIAOHandle->GetKind() ) )
728                     {
729                         if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
730                         {
731                             SotStorageStreamRef xStm;
732 
733                             if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_XFA, xStm ) && xStm.Is() )
734                             {
735                                 XFillExchangeData aFillData( XFillAttrSetItem( &mpDoc->GetPool() ) );
736 
737                                 *xStm >> aFillData;
738                                 const Color aColor( ( (XFillColorItem&) aFillData.GetXFillAttrSetItem()->GetItemSet().Get( XATTR_FILLCOLOR ) ).GetColorValue() );
739                                 static_cast< SdrHdlColor* >( pIAOHandle )->SetColor( aColor, sal_True );
740                                 nRet = nDropAction;
741                             }
742                         }
743                     }
744                 }
745             }
746 
747             // standard insert?
748             if( !nRet && InsertData( aDataHelper, aPos, nDropAction, sal_True, 0, nPage, nLayer ) )
749                 nRet = nDropAction;
750 
751             // special insert?
752             if( !nRet && mpViewSh )
753             {
754                 String          aTmpString1, aTmpString2;
755                 INetBookmark    aINetBookmark( aTmpString1, aTmpString2 );
756 
757                 // insert bookmark
758                 if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
759                     aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) )
760                 {
761                     SdPageObjsTLB::SdPageObjsTransferable* pPageObjsTransferable = SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper.GetXTransferable() );
762 
763                     if( pPageObjsTransferable &&
764                         ( NAVIGATOR_DRAGTYPE_LINK == pPageObjsTransferable->GetDragType() ||
765                           NAVIGATOR_DRAGTYPE_EMBEDDED == pPageObjsTransferable->GetDragType() ) )
766                     {
767                         // insert bookmark from own navigator (handled async. due to possible message box )
768                         Application::PostUserEvent( LINK( this, View, ExecuteNavigatorDrop ),
769                                                     new SdNavigatorDropEvent( rEvt, rTargetHelper, pTargetWindow,
770                                                                               nPage, nLayer ) );
771                         nRet = nDropAction;
772                     }
773                     else
774                     {
775                         SdrObject*      pPickObj = NULL;
776                         SdrPageView*    pPageView = NULL;
777 
778                         if( PickObj( aPos, getHitTolLog(), pPickObj, pPageView ) )
779                         {
780                             // insert as clip action => jump
781                             rtl::OUString       aBookmark( aINetBookmark.GetURL() );
782                             SdAnimationInfo*    pInfo = mpDoc->GetAnimationInfo( pPickObj );
783                             sal_Bool                bCreated = sal_False;
784 
785                             if( aBookmark.getLength() )
786                             {
787                                 presentation::ClickAction eClickAction = presentation::ClickAction_DOCUMENT;
788 
789                                 sal_Int32 nIndex = aBookmark.indexOf( (sal_Unicode)'#' );
790                                 if( nIndex != -1 )
791                                 {
792                                     const String aDocName( aBookmark.copy( 0, nIndex ) );
793 
794                                     if( mpDocSh->GetMedium()->GetName() == aDocName || mpDocSh->GetName() == aDocName )
795                                     {
796                                         // internal jump, only use the part after and including '#'
797                                         eClickAction = presentation::ClickAction_BOOKMARK;
798                                         aBookmark = aBookmark.copy( nIndex+1 );
799                                     }
800                                 }
801 
802                                 if( !pInfo )
803                                 {
804                                     pInfo = SdDrawDocument::GetShapeUserData( *pPickObj, true );
805                                     bCreated = sal_True;
806                                 }
807 
808                                 // Undo-Action mit alten und neuen Groessen erzeugen
809                                 SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction(mpDoc, pPickObj, bCreated);
810                                 pAction->SetActive(pInfo->mbActive, pInfo->mbActive);
811                                 pAction->SetEffect(pInfo->meEffect, pInfo->meEffect);
812                                 pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect);
813                                 pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed);
814                                 pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious);
815                                 pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor);
816                                 pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide);
817                                 pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn);
818                                 pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile);
819                                 pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull);
820                                 pAction->SetPathObj(pInfo->mpPathObj, pInfo->mpPathObj);
821                                 pAction->SetClickAction(pInfo->meClickAction, eClickAction);
822                                 pAction->SetBookmark(pInfo->GetBookmark(), aBookmark);
823 //                              pAction->SetInvisibleInPres(pInfo->mbInvisibleInPresentation, sal_True);
824                                 pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb);
825                                 pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect);
826                                 pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed);
827                                 pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn);
828                                 pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull);
829 
830                                 String aString(SdResId(STR_UNDO_ANIMATION));
831                                 pAction->SetComment(aString);
832                                 mpDocSh->GetUndoManager()->AddUndoAction(pAction);
833                                 pInfo->meClickAction = eClickAction;
834                                 pInfo->SetBookmark( aBookmark );
835                                 mpDoc->SetChanged();
836 
837                                 nRet = nDropAction;
838                             }
839                         }
840                         else if( mpViewSh->ISA( DrawViewShell ) )
841                         {
842                             // insert as normal URL button
843                             ( (DrawViewShell*) mpViewSh )->InsertURLButton( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), String(), &aPos );
844                             nRet = nDropAction;
845                         }
846                     }
847                 }
848             }
849         }
850     }
851 
852     return nRet;
853 }
854 
855 // -----------------------------------------------------------------------------
856 
857 IMPL_LINK( View, ExecuteNavigatorDrop, SdNavigatorDropEvent*, pSdNavigatorDropEvent )
858 {
859     TransferableDataHelper                  aDataHelper( pSdNavigatorDropEvent->maDropEvent.Transferable );
860     SdPageObjsTLB::SdPageObjsTransferable*  pPageObjsTransferable = SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper.GetXTransferable() );
861     INetBookmark                            aINetBookmark;
862 
863     if( pPageObjsTransferable && aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) )
864     {
865         Point   aPos;
866         List    aBookmarkList;
867         String  aBookmark;
868         SdPage* pPage = (SdPage*) GetSdrPageView()->GetPage();
869         sal_uInt16  nPgPos = 0xFFFF;
870 
871         if( pSdNavigatorDropEvent->mpTargetWindow )
872             aPos = pSdNavigatorDropEvent->mpTargetWindow->PixelToLogic( pSdNavigatorDropEvent->maPosPixel );
873 
874         const rtl::OUString aURL( aINetBookmark.GetURL() );
875         sal_Int32 nIndex = aURL.indexOf( (sal_Unicode)'#' );
876         if( nIndex != -1 )
877             aBookmark = aURL.copy( nIndex+1 );
878         aBookmarkList.Insert( &aBookmark );
879 
880         if( !pPage->IsMasterPage() )
881         {
882             if( pPage->GetPageKind() == PK_STANDARD )
883                 nPgPos = pPage->GetPageNum() + 2;
884             else if( pPage->GetPageKind() == PK_NOTES )
885                 nPgPos = pPage->GetPageNum() + 1;
886         }
887 
888         // Um zu gewaehrleisten, dass alle Seitennamen eindeutig sind, werden
889         // die einzufuegenden geprueft und gegebenenfalls in einer Ersatzliste
890         // aufgenommen (bNameOK == sal_False -> Benutzer hat abgebrochen)
891         List*   pExchangeList = NULL;
892         sal_Bool    bLink = ( NAVIGATOR_DRAGTYPE_LINK == pPageObjsTransferable->GetDragType()  ? sal_True : sal_False );
893         sal_Bool    bNameOK = GetExchangeList( pExchangeList, &aBookmarkList, 2 );
894         sal_Bool    bReplace = sal_False;
895 
896         // Da man hier nicht weiss, ob es sich um eine Seite oder ein Objekt handelt,
897         // wird eine Liste sowohl mit Seiten, als auch mit Objekten gefuellt.
898         // Sollten Seitennamen und Objektnamen identisch sein gibt es hier natuerlich Probleme !!!
899         if( bNameOK )
900         {
901             mpDoc->InsertBookmark( &aBookmarkList, pExchangeList,
902                                   bLink, bReplace, nPgPos, sal_False,
903                                   &pPageObjsTransferable->GetDocShell(),
904                                   sal_True, &aPos );
905         }
906 
907         // Loeschen der ExchangeList
908         if( pExchangeList )
909         {
910             for( void* p = pExchangeList->First(); p; p = pExchangeList->Next() )
911                 delete (String*) p;
912 
913             delete pExchangeList;
914         }
915     }
916 
917     delete pSdNavigatorDropEvent;
918 
919     return 0;
920 }
921 
922 /*************************************************************************
923 |*
924 |* Rueckgabeparameter:
925 |* pExchangeList == NULL -> Namen sind alle eindeutig
926 |* bNameOK == sal_False -> Benutzer hat abgebrochen
927 |* nType == 0 -> Seiten
928 |* nType == 1 -> Objekte
929 |* nType == 2 -> Seiten + Objekte
930 |*
931 \************************************************************************/
932 
933 sal_Bool View::GetExchangeList( List*& rpExchangeList, List* pBookmarkList, sal_uInt16 nType )
934 {
935     DBG_ASSERT( !rpExchangeList, "ExchangeList muss NULL sein!");
936 
937     sal_Bool bListIdentical = sal_True; // BookmarkList und ExchangeList sind gleich
938     sal_Bool bNameOK = sal_True;        // Name ist eindeutig
939 
940     rpExchangeList = new List();
941 
942     if( pBookmarkList )
943     {
944         String* pString = (String*) pBookmarkList->First();
945 
946         while( pString && bNameOK )
947         {
948             String* pNewName = new String( *pString );
949 
950             if( nType == 0  || nType == 2 )
951                 bNameOK = mpDocSh->CheckPageName (
952                     mpViewSh->GetActiveWindow(), *pNewName);
953 
954             if( bNameOK && ( nType == 1  || nType == 2 ) )
955             {
956                 if( mpDoc->GetObj( *pNewName ) )
957                 {
958                     String          aTitle( SdResId( STR_TITLE_NAMEGROUP ) );
959                     String          aDesc( SdResId( STR_DESC_NAMEGROUP ) );
960                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
961                     AbstractSvxNameDialog* pDlg = pFact ? pFact->CreateSvxNameDialog( mpViewSh->GetActiveWindow(), *pNewName, aDesc ) : 0;
962                     if( pDlg )
963                     {
964                         pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_OBJECT );
965 
966                         bNameOK = sal_False;
967                         pDlg->SetText( aTitle );
968 
969                         while( !bNameOK && pDlg->Execute() == RET_OK )
970                         {
971                             pDlg->GetName( *pNewName );
972 
973                             if( !mpDoc->GetObj( *pNewName ) )
974                                 bNameOK = sal_True;
975                         }
976 
977                         delete pDlg;
978                     }
979                 }
980             }
981 
982             if( bListIdentical )
983                 bListIdentical = ( *pString == *pNewName );
984 
985             rpExchangeList->Insert( pNewName, LIST_APPEND );
986             pString = (String*) pBookmarkList->Next();
987         }
988     }
989 
990     // ExchangeList ist mit BookmarkList identisch
991     if( rpExchangeList && bListIdentical )
992     {
993         String* pString = (String*) rpExchangeList->First();
994         while( pString )
995         {
996             delete pString;
997             pString = (String*) rpExchangeList->Next();
998         }
999         delete rpExchangeList;
1000         rpExchangeList = NULL;
1001     }
1002 
1003     return( bNameOK );
1004 }
1005 
1006 typedef std::vector< std::pair< sal_uInt32, sal_uInt32 > > PathSurrogateVector;
1007 typedef std::vector< SdrObject* > SdrObjectVector;
1008 
1009 void ImplProcessObjectList(SdrObject* pObj, SdrObjectVector& rVector )
1010 {
1011     sal_Bool bIsGroup(pObj->IsGroupObject());
1012     if(bIsGroup && pObj->ISA(E3dObject) && !pObj->ISA(E3dScene))
1013         bIsGroup = sal_False;
1014 
1015     rVector.push_back( pObj );
1016 
1017     if(bIsGroup)
1018     {
1019         SdrObjList* pObjList = pObj->GetSubList();
1020         sal_uInt32 a;
1021         for( a = 0; a < pObjList->GetObjCount(); a++)
1022             ImplProcessObjectList(pObjList->GetObj(a), rVector);
1023     }
1024 }
1025 
1026 SdrModel* View::GetMarkedObjModel() const
1027 {
1028     return FmFormView::GetMarkedObjModel();;
1029 }
1030 
1031 sal_Bool View::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst /* =NULL */, sal_uInt32 nOptions /* =0 */)
1032 {
1033     return FmFormView::Paste( rMod, rPos, pLst,nOptions );;
1034 }
1035 
1036 } // end of namespace sd
1037