xref: /aoo42x/main/sd/source/ui/view/sdview2.cxx (revision 1cd65da9)
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 && (nDropAction & DND_ACTION_LINK))
537             {
538                 // suppress own data when it's intention is to use it as fill information
539                 pDragTransferable = 0;
540             }
541 
542 			if( pDragTransferable )
543 			{
544 				const View* pSourceView = pDragTransferable->GetView();
545 
546 				if( pDragTransferable->IsPageTransferable() )
547 				{
548 					nRet = DND_ACTION_COPY;
549 				}
550 				else if( pSourceView )
551 				{
552 					if( !( nDropAction & DND_ACTION_LINK ) ||
553                         pSourceView->GetDocSh()->GetMedium()->GetName().Len() )
554                     {
555 						nRet = nDropAction;
556                     }
557 				}
558 			}
559 			else
560 			{
561 				const sal_Bool  bDrawing = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING );
562 				const sal_Bool  bGraphic = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB );
563 				const sal_Bool	bMtf = rTargetHelper.IsDropFormatSupported( FORMAT_GDIMETAFILE );
564 				const sal_Bool	bBitmap = rTargetHelper.IsDropFormatSupported( FORMAT_BITMAP );
565 				sal_Bool	    bBookmark = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
566 				sal_Bool	    bXFillExchange = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_XFA );
567 
568 		        // check handle insert
569                 if( !nRet && ( (bXFillExchange && ( SDRDRAG_GRADIENT == GetDragMode() )) || ( SDRDRAG_TRANSPARENCE == GetDragMode() ) ) )
570 		        {
571 			        const SdrHdlList& rHdlList = GetHdlList();
572 
573 			        for( sal_uInt32 n = 0; n < rHdlList.GetHdlCount(); n++ )
574 			        {
575 				        SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
576 
577 				        if( pIAOHandle && ( HDL_COLR == pIAOHandle->GetKind() ) )
578 				        {
579 							if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
580 							{
581                                 nRet = nDropAction;
582 						        static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_SELECTED );
583 							}
584 							else
585 							{
586 						        static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_NORMAL );
587 							}
588 				        }
589 			        }
590 		        }
591 
592 		        // check object insert
593 				if( !nRet && ( bXFillExchange || ( ( bDrawing || bGraphic || bMtf || bBitmap || bBookmark ) && ( nDropAction & DND_ACTION_LINK ) ) ) )
594 				{
595 					SdrObject*		pPickObj = NULL;
596 					SdrPageView*	pPageView = NULL;
597                     ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
598 					Point			aPos( pWindow->PixelToLogic( rEvt.maPosPixel ) );
599 					const sal_Bool		bHasPickObj = PickObj( aPos, getHitTolLog(), pPickObj, pPageView );
600                     sal_Bool            bIsPresTarget = sal_False;
601 
602 					if( bHasPickObj && pPickObj && ( pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall() ) )
603 					{
604 						SdPage* pPage = (SdPage*) pPickObj->GetPage();
605 
606 						if( pPage && pPage->IsMasterPage() )
607 							bIsPresTarget = pPage->IsPresObj( pPickObj );
608 					}
609 
610 					if( bHasPickObj && !bIsPresTarget &&
611 					    ( bGraphic || bMtf || bBitmap || bXFillExchange ) )
612 					{
613 						if( mpDropMarkerObj != pPickObj )
614 						{
615 							mpDropMarkerObj = pPickObj;
616 							ImplClearDrawDropMarker();
617 
618 							if(mpDropMarkerObj)
619 							{
620 								mpDropMarker = new SdrDropMarkerOverlay(*this, *mpDropMarkerObj);
621 							}
622 						}
623 
624                         nRet = nDropAction;
625 					}
626 					else
627 						bXFillExchange = sal_False;
628 				}
629 
630                 // check normal insert
631                 if( !nRet )
632                 {
633                     const sal_Bool  bSBAFormat = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_SVX_FORMFIELDEXCH );
634                     const sal_Bool  bEditEngine = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_EDITENGINE );
635                     const sal_Bool  bString = rTargetHelper.IsDropFormatSupported( FORMAT_STRING );
636                     const sal_Bool  bRTF = rTargetHelper.IsDropFormatSupported( FORMAT_RTF );
637                     const sal_Bool  bFile = rTargetHelper.IsDropFormatSupported( FORMAT_FILE );
638                     const sal_Bool  bFileList = rTargetHelper.IsDropFormatSupported( FORMAT_FILE_LIST );
639 
640 					if( mpDropMarker )
641 					{
642 						ImplClearDrawDropMarker();
643 						mpDropMarkerObj = NULL;
644 					}
645 
646 					if( bBookmark && bFile && ( nDropAction & DND_ACTION_MOVE ) && mpViewSh && SlideShow::IsRunning(mpViewSh->GetViewShellBase()) )
647 		    			bBookmark = sal_False;
648 
649 				    if( bDrawing || bGraphic || bMtf || bBitmap || bBookmark || bFile || bFileList || bXFillExchange || bSBAFormat || bEditEngine || bString || bRTF )
650 					    nRet = nDropAction;
651 
652                     // For entries from the navigator, change action copy.
653                     if (bBookmark
654                         && rTargetHelper.IsDropFormatSupported(
655                             SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId())
656                         && (nDropAction & DND_ACTION_MOVE)!=0)
657                     {
658                         nRet = DND_ACTION_COPY;
659                     }
660                 }
661     		}
662 		}
663 	}
664 
665     // destroy drop marker if this is a leaving event
666     if( rEvt.mbLeaving && mpDropMarker )
667 	{
668 		ImplClearDrawDropMarker();
669 		mpDropMarkerObj = NULL;
670 	}
671 
672 	return nRet;
673 }
674 
675 // -----------------------------------------------------------------------------
676 
677 sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
678                               ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer )
679 {
680 	SdrPageView*	pPV = GetSdrPageView();
681 	String			aActiveLayer = GetActiveLayer();
682 	sal_Int8		nDropAction = rEvt.mnAction;
683 	sal_Int8		nRet = DND_ACTION_NONE;
684 
685     // destroy drop marker if it is shown
686 	if( mpDropMarker )
687 	{
688 		ImplClearDrawDropMarker();
689 		mpDropMarkerObj = NULL;
690 	}
691 
692 	if( !pPV->IsLayerLocked( aActiveLayer ) )
693 	{
694 		const OutlinerView* pOLV = GetTextEditOutlinerView();
695 		sal_Bool				bIsInsideOutlinerView = sal_False;
696 
697 		if( pOLV )
698 		{
699 			Rectangle aRect( pOLV->GetOutputArea() );
700 
701 			if( GetMarkedObjectCount() == 1 )
702 			{
703 				SdrMark* pMark = GetSdrMarkByIndex(0);
704 				SdrObject* pObj = pMark->GetMarkedSdrObj();
705 				aRect.Union( pObj->GetLogicRect() );
706 			}
707 
708 			Point aPos( pOLV->GetWindow()->PixelToLogic( rEvt.maPosPixel ) );
709 
710 			if( aRect.IsInside( aPos ) )
711 			{
712 				bIsInsideOutlinerView = sal_True;
713 			}
714 		}
715 
716 		if( !bIsInsideOutlinerView )
717 		{
718 			Point				    aPos;
719 			TransferableDataHelper	aDataHelper( rEvt.maDropEvent.Transferable );
720 
721 			if( pTargetWindow )
722 				aPos = pTargetWindow->PixelToLogic( rEvt.maPosPixel );
723 
724             // handle insert?
725             if( (!nRet && ( SDRDRAG_GRADIENT == GetDragMode() )) || (( SDRDRAG_TRANSPARENCE == GetDragMode() ) && aDataHelper.HasFormat( SOT_FORMATSTR_ID_XFA )) )
726 	        {
727 		        const SdrHdlList& rHdlList = GetHdlList();
728 
729 		        for( sal_uInt32 n = 0; !nRet && n < rHdlList.GetHdlCount(); n++ )
730 		        {
731 			        SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
732 
733 			        if( pIAOHandle && ( HDL_COLR == pIAOHandle->GetKind() ) )
734 			        {
735 						if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
736 						{
737                     		SotStorageStreamRef xStm;
738 
739                     		if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_XFA, xStm ) && xStm.Is() )
740 		                    {
741 			                    XFillExchangeData aFillData( XFillAttrSetItem( &mpDoc->GetPool() ) );
742 
743                     			*xStm >> aFillData;
744                                 const Color aColor( ( (XFillColorItem&) aFillData.GetXFillAttrSetItem()->GetItemSet().Get( XATTR_FILLCOLOR ) ).GetColorValue() );
745             					static_cast< SdrHdlColor* >( pIAOHandle )->SetColor( aColor, sal_True );
746                                 nRet = nDropAction;
747 					        }
748 						}
749 			        }
750 		        }
751         	}
752 
753             // standard insert?
754             if( !nRet && InsertData( aDataHelper, aPos, nDropAction, sal_True, 0, nPage, nLayer ) )
755     			nRet = nDropAction;
756 
757 			// special insert?
758             if( !nRet && mpViewSh )
759 			{
760 				String		    aTmpString1, aTmpString2;
761 				INetBookmark	aINetBookmark( aTmpString1, aTmpString2 );
762 
763 				// insert bookmark
764 				if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
765 					aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) )
766 				{
767 				    SdPageObjsTLB::SdPageObjsTransferable* pPageObjsTransferable = SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper.GetXTransferable() );
768 
769 				    if( pPageObjsTransferable &&
770 				        ( NAVIGATOR_DRAGTYPE_LINK == pPageObjsTransferable->GetDragType() ||
771 				          NAVIGATOR_DRAGTYPE_EMBEDDED == pPageObjsTransferable->GetDragType() ) )
772 				    {
773 						// insert bookmark from own navigator (handled async. due to possible message box )
774 						Application::PostUserEvent( LINK( this, View, ExecuteNavigatorDrop ),
775 													new SdNavigatorDropEvent( rEvt, rTargetHelper, pTargetWindow,
776                                                                               nPage, nLayer ) );
777 						nRet = nDropAction;
778 					}
779 					else
780 					{
781 						SdrObject*		pPickObj = NULL;
782 						SdrPageView*	pPageView = NULL;
783 
784 						if( PickObj( aPos, getHitTolLog(), pPickObj, pPageView ) )
785 						{
786 							// insert as clip action => jump
787 							rtl::OUString		aBookmark( aINetBookmark.GetURL() );
788 							SdAnimationInfo*	pInfo = mpDoc->GetAnimationInfo( pPickObj );
789 							sal_Bool				bCreated = sal_False;
790 
791 							if( aBookmark.getLength() )
792 							{
793 								presentation::ClickAction eClickAction = presentation::ClickAction_DOCUMENT;
794 
795 								sal_Int32 nIndex = aBookmark.indexOf( (sal_Unicode)'#' );
796 								if( nIndex != -1 )
797 								{
798 									const String aDocName( aBookmark.copy( 0, nIndex ) );
799 
800 									if( mpDocSh->GetMedium()->GetName() == aDocName || mpDocSh->GetName() == aDocName )
801 									{
802 										// internal jump, only use the part after and including '#'
803 										eClickAction = presentation::ClickAction_BOOKMARK;
804 										aBookmark = aBookmark.copy( nIndex+1 );
805 									}
806 								}
807 
808 								if( !pInfo )
809 								{
810 									pInfo = SdDrawDocument::GetShapeUserData( *pPickObj, true );
811 									bCreated = sal_True;
812 								}
813 
814 								// Undo-Action mit alten und neuen Groessen erzeugen
815 								SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction(mpDoc, pPickObj, bCreated);
816 								pAction->SetActive(pInfo->mbActive, pInfo->mbActive);
817 								pAction->SetEffect(pInfo->meEffect, pInfo->meEffect);
818 								pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect);
819 								pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed);
820 								pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious);
821 								pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor);
822 								pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide);
823 								pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn);
824 								pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile);
825 								pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull);
826 								pAction->SetPathObj(pInfo->mpPathObj, pInfo->mpPathObj);
827 								pAction->SetClickAction(pInfo->meClickAction, eClickAction);
828 								pAction->SetBookmark(pInfo->GetBookmark(), aBookmark);
829 //								pAction->SetInvisibleInPres(pInfo->mbInvisibleInPresentation, sal_True);
830 								pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb);
831 								pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect);
832 								pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed);
833 								pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn);
834 								pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull);
835 
836 								String aString(SdResId(STR_UNDO_ANIMATION));
837 								pAction->SetComment(aString);
838 								mpDocSh->GetUndoManager()->AddUndoAction(pAction);
839 								pInfo->meClickAction = eClickAction;
840 								pInfo->SetBookmark( aBookmark );
841 								mpDoc->SetChanged();
842 
843 								nRet = nDropAction;
844 							}
845 						}
846 						else if( mpViewSh->ISA( DrawViewShell ) )
847 						{
848 							// insert as normal URL button
849 							( (DrawViewShell*) mpViewSh )->InsertURLButton( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), String(), &aPos );
850 							nRet = nDropAction;
851 						}
852 					}
853 				}
854 			}
855 		}
856 	}
857 
858 	return nRet;
859 }
860 
861 // -----------------------------------------------------------------------------
862 
863 IMPL_LINK( View, ExecuteNavigatorDrop, SdNavigatorDropEvent*, pSdNavigatorDropEvent )
864 {
865 	TransferableDataHelper	                aDataHelper( pSdNavigatorDropEvent->maDropEvent.Transferable );
866     SdPageObjsTLB::SdPageObjsTransferable*  pPageObjsTransferable = SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper.GetXTransferable() );
867 	INetBookmark			                aINetBookmark;
868 
869 	if( pPageObjsTransferable && aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) )
870 	{
871 		Point	aPos;
872 		List	aBookmarkList;
873 		String	aBookmark;
874 		SdPage*	pPage = (SdPage*) GetSdrPageView()->GetPage();
875 		sal_uInt16	nPgPos = 0xFFFF;
876 
877 		if( pSdNavigatorDropEvent->mpTargetWindow )
878 			aPos = pSdNavigatorDropEvent->mpTargetWindow->PixelToLogic( pSdNavigatorDropEvent->maPosPixel );
879 
880 		const rtl::OUString aURL( aINetBookmark.GetURL() );
881 		sal_Int32 nIndex = aURL.indexOf( (sal_Unicode)'#' );
882 		if( nIndex != -1 )
883 			aBookmark = aURL.copy( nIndex+1 );
884 		aBookmarkList.Insert( &aBookmark );
885 
886 		if( !pPage->IsMasterPage() )
887 		{
888 			if( pPage->GetPageKind() == PK_STANDARD )
889 				nPgPos = pPage->GetPageNum() + 2;
890 			else if( pPage->GetPageKind() == PK_NOTES )
891 				nPgPos = pPage->GetPageNum() + 1;
892 		}
893 
894 		// Um zu gewaehrleisten, dass alle Seitennamen eindeutig sind, werden
895 		// die einzufuegenden geprueft und gegebenenfalls in einer Ersatzliste
896 		// aufgenommen (bNameOK == sal_False -> Benutzer hat abgebrochen)
897 		List*	pExchangeList = NULL;
898 		sal_Bool	bLink = ( NAVIGATOR_DRAGTYPE_LINK == pPageObjsTransferable->GetDragType()  ? sal_True : sal_False );
899 		sal_Bool	bNameOK = GetExchangeList( pExchangeList, &aBookmarkList, 2 );
900 		sal_Bool	bReplace = sal_False;
901 
902 		// Da man hier nicht weiss, ob es sich um eine Seite oder ein Objekt handelt,
903 		// wird eine Liste sowohl mit Seiten, als auch mit Objekten gefuellt.
904 		// Sollten Seitennamen und Objektnamen identisch sein gibt es hier natuerlich Probleme !!!
905 		if( bNameOK )
906 		{
907 			mpDoc->InsertBookmark( &aBookmarkList, pExchangeList,
908 								  bLink, bReplace, nPgPos, sal_False,
909 								  &pPageObjsTransferable->GetDocShell(),
910 								  sal_True, &aPos );
911 		}
912 
913 		// Loeschen der ExchangeList
914 		if( pExchangeList )
915 		{
916 			for( void* p = pExchangeList->First(); p; p = pExchangeList->Next() )
917 				delete (String*) p;
918 
919 			delete pExchangeList;
920 		}
921 	}
922 
923 	delete pSdNavigatorDropEvent;
924 
925 	return 0;
926 }
927 
928 /*************************************************************************
929 |*
930 |* Rueckgabeparameter:
931 |* pExchangeList == NULL -> Namen sind alle eindeutig
932 |* bNameOK == sal_False -> Benutzer hat abgebrochen
933 |* nType == 0 -> Seiten
934 |* nType == 1 -> Objekte
935 |* nType == 2 -> Seiten + Objekte
936 |*
937 \************************************************************************/
938 
939 sal_Bool View::GetExchangeList( List*& rpExchangeList, List* pBookmarkList, sal_uInt16 nType )
940 {
941 	DBG_ASSERT( !rpExchangeList, "ExchangeList muss NULL sein!");
942 
943 	sal_Bool bListIdentical = sal_True; // BookmarkList und ExchangeList sind gleich
944 	sal_Bool bNameOK = sal_True;		// Name ist eindeutig
945 
946 	rpExchangeList = new List();
947 
948 	if( pBookmarkList )
949 	{
950 		String* pString = (String*) pBookmarkList->First();
951 
952         while( pString && bNameOK )
953 		{
954 			String* pNewName = new String( *pString );
955 
956             if( nType == 0  || nType == 2 )
957 				bNameOK = mpDocSh->CheckPageName (
958                     mpViewSh->GetActiveWindow(), *pNewName);
959 
960             if( bNameOK && ( nType == 1  || nType == 2 ) )
961             {
962                 if( mpDoc->GetObj( *pNewName ) )
963 	            {
964                     String          aTitle( SdResId( STR_TITLE_NAMEGROUP ) );
965                     String          aDesc( SdResId( STR_DESC_NAMEGROUP ) );
966 					SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
967 					AbstractSvxNameDialog* pDlg = pFact ? pFact->CreateSvxNameDialog( mpViewSh->GetActiveWindow(), *pNewName, aDesc ) : 0;
968 					if( pDlg )
969 					{
970 						pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_OBJECT );
971 
972 						bNameOK = sal_False;
973 						pDlg->SetText( aTitle );
974 
975 						while( !bNameOK && pDlg->Execute() == RET_OK )
976 						{
977 							pDlg->GetName( *pNewName );
978 
979 							if( !mpDoc->GetObj( *pNewName ) )
980 								bNameOK = sal_True;
981 						}
982 
983 						delete pDlg;
984 					}
985 	            }
986             }
987 
988 			if( bListIdentical )
989 				bListIdentical = ( *pString == *pNewName );
990 
991 			rpExchangeList->Insert( pNewName, LIST_APPEND );
992 			pString = (String*) pBookmarkList->Next();
993 		}
994 	}
995 
996 	// ExchangeList ist mit BookmarkList identisch
997 	if( rpExchangeList && bListIdentical )
998 	{
999 		String* pString = (String*) rpExchangeList->First();
1000 		while( pString )
1001 		{
1002 			delete pString;
1003 			pString = (String*) rpExchangeList->Next();
1004 		}
1005 		delete rpExchangeList;
1006 		rpExchangeList = NULL;
1007 	}
1008 
1009 	return( bNameOK );
1010 }
1011 
1012 typedef std::vector< std::pair< sal_uInt32, sal_uInt32 > > PathSurrogateVector;
1013 typedef std::vector< SdrObject* > SdrObjectVector;
1014 
1015 void ImplProcessObjectList(SdrObject* pObj, SdrObjectVector& rVector )
1016 {
1017 	sal_Bool bIsGroup(pObj->IsGroupObject());
1018 	if(bIsGroup && pObj->ISA(E3dObject) && !pObj->ISA(E3dScene))
1019 		bIsGroup = sal_False;
1020 
1021 	rVector.push_back( pObj );
1022 
1023 	if(bIsGroup)
1024 	{
1025 		SdrObjList* pObjList = pObj->GetSubList();
1026 		sal_uInt32 a;
1027 		for( a = 0; a < pObjList->GetObjCount(); a++)
1028 			ImplProcessObjectList(pObjList->GetObj(a), rVector);
1029 	}
1030 }
1031 
1032 SdrModel* View::GetMarkedObjModel() const
1033 {
1034 	return FmFormView::GetMarkedObjModel();;
1035 }
1036 
1037 sal_Bool View::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst /* =NULL */, sal_uInt32 nOptions /* =0 */)
1038 {
1039 	return FmFormView::Paste( rMod, rPos, pLst,nOptions );;
1040 }
1041 
1042 } // end of namespace sd
1043