xref: /aoo41x/main/sd/source/ui/dlg/sdtreelb.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include <sal/types.h>
32 #include <sot/formats.hxx>
33 #include <sot/storage.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <svl/urihelper.hxx>
36 #include <svx/svditer.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <svx/svdoole2.hxx>
39 #include <vcl/svapp.hxx>
40 #include "cusshow.hxx"
41 #include <sfx2/childwin.hxx>
42 
43 #include <sfx2/viewfrm.hxx>
44 
45 #include "strmname.h"
46 #include "sdtreelb.hxx"
47 #include "DrawDocShell.hxx"
48 #include "drawdoc.hxx"
49 #include "sdpage.hxx"
50 #include "sdresid.hxx"
51 #include "navigatr.hxx"
52 #ifndef _SD_CFGID_HXX
53 #include "strings.hrc"
54 #endif
55 #include "res_bmp.hrc"
56 #include "ViewShell.hxx"
57 #include "DrawController.hxx"
58 #include "ViewShellBase.hxx"
59 
60 #include <com/sun/star/embed/XEmbedPersist.hpp>
61 #include <com/sun/star/frame/XDesktop.hpp>
62 #include <com/sun/star/frame/XFramesSupplier.hpp>
63 #include <svtools/embedtransfer.hxx>
64 #include <comphelper/processfactory.hxx>
65 #include <tools/diagnose_ex.h>
66 
67 using namespace com::sun::star;
68 
69 class SdPageObjsTLB::IconProvider
70 {
71 public:
72     IconProvider (void);
73 
74     // Regular icons.
75     Image maImgPage;
76     Image maImgPageExcl;
77     Image maImgPageObjsExcl;
78     Image maImgPageObjs;
79     Image maImgObjects;
80     Image maImgGroup;
81 
82     // High contrast icons.
83     Image maImgPageH;
84     Image maImgPageExclH;
85     Image maImgPageObjsExclH;
86     Image maImgPageObjsH;
87     Image maImgObjectsH;
88     Image maImgGroupH;
89 };
90 
91 
92 sal_Bool SD_DLLPRIVATE SdPageObjsTLB::bIsInDrag = sal_False;
93 
94 sal_Bool SdPageObjsTLB::IsInDrag()
95 {
96 	return bIsInDrag;
97 }
98 
99 sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::mnListBoxDropFormatId = SAL_MAX_UINT32;
100 
101 // -----------------------------------------
102 // - SdPageObjsTLB::SdPageObjsTransferable -
103 // -----------------------------------------
104 
105 SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable(
106     SdPageObjsTLB& rParent,
107         const INetBookmark& rBookmark,
108     ::sd::DrawDocShell& rDocShell,
109     NavigatorDragType eDragType,
110     const ::com::sun::star::uno::Any& rTreeListBoxData )
111     : SdTransferable(rDocShell.GetDoc(), NULL, sal_True),
112       mrParent( rParent ),
113       maBookmark( rBookmark ),
114       mrDocShell( rDocShell ),
115       meDragType( eDragType ),
116       maTreeListBoxData( rTreeListBoxData )
117 {
118 }
119 
120 
121 
122 
123 SdPageObjsTLB::SdPageObjsTransferable::~SdPageObjsTransferable()
124 {
125 }
126 
127 // -----------------------------------------------------------------------------
128 
129 void SdPageObjsTLB::SdPageObjsTransferable::AddSupportedFormats()
130 {
131     AddFormat(SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK);
132     AddFormat(SOT_FORMATSTR_ID_TREELISTBOX);
133     AddFormat(GetListBoxDropFormatId());
134 }
135 
136 // -----------------------------------------------------------------------------
137 
138 sal_Bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
139 {
140 	sal_uLong nFormatId = SotExchange::GetFormat( rFlavor );
141     switch (nFormatId)
142     {
143         case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
144             SetINetBookmark( maBookmark, rFlavor );
145             return sal_True;
146 
147         case SOT_FORMATSTR_ID_TREELISTBOX:
148             SetAny(maTreeListBoxData, rFlavor);
149             return sal_True;
150 
151         default:
152             return sal_False;
153     }
154 }
155 
156 // -----------------------------------------------------------------------------
157 
158 void SdPageObjsTLB::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction )
159 {
160 	mrParent.OnDragFinished( nDropAction );
161     SdTransferable::DragFinished(nDropAction);
162 }
163 
164 // -----------------------------------------------------------------------------
165 
166 ::sd::DrawDocShell& SdPageObjsTLB::SdPageObjsTransferable::GetDocShell() const
167 {
168     return mrDocShell;
169 }
170 
171 // -----------------------------------------------------------------------------
172 
173 NavigatorDragType SdPageObjsTLB::SdPageObjsTransferable::GetDragType() const
174 {
175     return meDragType;
176 }
177 
178 // -----------------------------------------------------------------------------
179 
180 sal_Int64 SAL_CALL SdPageObjsTLB::SdPageObjsTransferable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException )
181 {
182     sal_Int64 nRet;
183 
184     if( ( rId.getLength() == 16 ) &&
185         ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
186     {
187         nRet = (sal_Int64)(sal_IntPtr)this;
188     }
189     else
190         nRet = SdTransferable::getSomething(rId);
191 
192 	return nRet;
193 }
194 
195 // -----------------------------------------------------------------------------
196 
197 const ::com::sun::star::uno::Sequence< sal_Int8 >& SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()
198 {
199     static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
200 
201 	if( !aSeq.getLength() )
202 	{
203 		static osl::Mutex   aCreateMutex;
204     	osl::MutexGuard     aGuard( aCreateMutex );
205 
206 		aSeq.realloc( 16 );
207     	rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
208 	}
209 
210     return aSeq;
211 }
212 
213 // -----------------------------------------------------------------------------
214 
215 SdPageObjsTLB::SdPageObjsTransferable* SdPageObjsTLB::SdPageObjsTransferable::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData )
216     throw()
217 {
218     try
219     {
220 	    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, ::com::sun::star::uno::UNO_QUERY_THROW );
221 
222 		return reinterpret_cast<SdPageObjsTLB::SdPageObjsTransferable*>(
223 				sal::static_int_cast<sal_uIntPtr>(
224 					xUnoTunnel->getSomething( SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()) ) );
225     }
226     catch( const ::com::sun::star::uno::Exception& )
227 	{
228 	}
229 	return 0;
230 }
231 
232 
233 sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId (void)
234 {
235     if (mnListBoxDropFormatId == SAL_MAX_UINT32)
236         mnListBoxDropFormatId = SotExchange::RegisterFormatMimeType(
237             ::rtl::OUString::createFromAscii(
238                 "application/x-openoffice-treelistbox-moveonly;"
239                     "windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\""));
240     return mnListBoxDropFormatId;
241 }
242 
243 
244 
245 
246 /*************************************************************************
247 |*
248 |* Ctor1 SdPageObjsTLB
249 |*
250 \************************************************************************/
251 
252 SdPageObjsTLB::SdPageObjsTLB( Window* pParentWin, const SdResId& rSdResId )
253 :	SvTreeListBox       ( pParentWin, rSdResId )
254 ,	mpParent 		    ( pParentWin )
255 ,	mpDoc			    ( NULL )
256 ,	mpBookmarkDoc	    ( NULL )
257 ,	mpMedium 	    	( NULL )
258 ,	mpOwnMedium		    ( NULL )
259 ,	maImgOle             ( BitmapEx( SdResId( BMP_OLE ) ) )
260 ,	maImgGraphic         ( BitmapEx( SdResId( BMP_GRAPHIC ) ) )
261 ,	maImgOleH            ( BitmapEx( SdResId( BMP_OLE_H ) ) )
262 ,	maImgGraphicH        ( BitmapEx( SdResId( BMP_GRAPHIC_H ) ) )
263 ,	mbLinkableSelected  ( sal_False )
264 ,	mpDropNavWin		( NULL )
265 ,   mbShowAllShapes     ( false )
266 ,   mbShowAllPages      ( false )
267 
268 {
269 	// Tree-ListBox mit Linien versehen
270 	SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
271 						   WB_HASBUTTONS | // WB_HASLINESATROOT |
272 						   WB_HSCROLL | // #31562#
273 						   WB_HASBUTTONSATROOT |
274                            WB_QUICK_SEARCH /* i31275 */ );
275 	SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND ) ),
276 					Bitmap( SdResId( BMP_COLLAPSE ) ) );
277 
278 	SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND_H ) ),
279 					Bitmap( SdResId( BMP_COLLAPSE_H ) ),
280 					BMP_COLOR_HIGHCONTRAST );
281 
282     SetDragDropMode(
283  		SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY |
284             SV_DRAGDROP_APP_MOVE  | SV_DRAGDROP_APP_COPY  | SV_DRAGDROP_APP_DROP );
285 }
286 
287 /*************************************************************************
288 |*
289 |* Dtor SdPageObjsTLB
290 |*
291 \************************************************************************/
292 
293 SdPageObjsTLB::~SdPageObjsTLB()
294 {
295     if ( mpBookmarkDoc )
296         CloseBookmarkDoc();
297     else
298         // no document was created from mpMedium, so this object is still the owner of it
299         delete mpMedium;
300 }
301 
302 /*************************************************************************
303 |*
304 |* return name of object
305 |*
306 \************************************************************************/
307 
308 String SdPageObjsTLB::GetObjectName(
309     const SdrObject* pObject,
310     const bool bCreate) const
311 {
312     String aRet;
313 
314     if ( pObject )
315     {
316         aRet = pObject->GetName();
317 
318         if( !aRet.Len() && pObject->ISA( SdrOle2Obj ) )
319             aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
320     }
321 
322     if (bCreate
323         && mbShowAllShapes
324         && aRet.Len() == 0
325         && pObject!=NULL)
326     {
327         aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME);
328         aRet.SearchAndReplaceAscii("%1", String::CreateFromInt32(pObject->GetOrdNum() + 1));
329     }
330 
331     return aRet;
332 }
333 
334 /*************************************************************************
335 |*
336 |* In TreeLB Eintrag selektieren
337 |*
338 \************************************************************************/
339 
340 sal_Bool SdPageObjsTLB::SelectEntry( const String& rName )
341 {
342 	sal_Bool bFound = sal_False;
343 
344 	if( rName.Len() )
345 	{
346 		SvLBoxEntry* pEntry = NULL;
347 		String aTmp;
348 
349 		for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
350 		{
351 			aTmp = GetEntryText( pEntry );
352 			if( aTmp == rName )
353 			{
354 				bFound = sal_True;
355 				SetCurEntry( pEntry );
356 			}
357 		}
358 	}
359 	return( bFound );
360 }
361 
362 /*************************************************************************
363 |*
364 |* Gibt zurueck, ob Childs des uebergebenen Strings selektiert sind
365 |*
366 \************************************************************************/
367 
368 sal_Bool SdPageObjsTLB::HasSelectedChilds( const String& rName )
369 {
370 	sal_Bool bFound  = sal_False;
371 	sal_Bool bChilds = sal_False;
372 
373 	if( rName.Len() )
374 	{
375 		SvLBoxEntry* pEntry = NULL;
376 		String aTmp;
377 
378 		for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
379 		{
380 			aTmp = GetEntryText( pEntry );
381 			if( aTmp == rName )
382 			{
383 				bFound = sal_True;
384 				sal_Bool bExpanded = IsExpanded( pEntry );
385 				long nCount = GetChildSelectionCount( pEntry );
386 				if( bExpanded && nCount > 0 )
387 					bChilds = sal_True;
388 			}
389 		}
390 	}
391 	return( bChilds );
392 }
393 
394 
395 /*************************************************************************
396 |*
397 |* TreeLB mit Seiten und Objekten fuellen
398 |*
399 \************************************************************************/
400 
401 void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, sal_Bool bAllPages,
402 						  const String& rDocName)
403 {
404 	String aSelection;
405 	if( GetSelectionCount() > 0 )
406 	{
407 		aSelection = GetSelectEntry();
408 		Clear();
409 	}
410 
411 	mpDoc = pInDoc;
412 	maDocName = rDocName;
413     mbShowAllPages = (bAllPages == sal_True);
414 	mpMedium = NULL;
415 
416 	SdPage* 	 pPage = NULL;
417 
418     IconProvider aIconProvider;
419 
420 	// first insert all pages including objects
421 	sal_uInt16 nPage = 0;
422 	const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
423 
424 	while( nPage < nMaxPages )
425 	{
426 		pPage = (SdPage*) mpDoc->GetPage( nPage );
427 		if(  (mbShowAllPages || pPage->GetPageKind() == PK_STANDARD)
428 		     && !(pPage->GetPageKind()==PK_HANDOUT)   ) //#94954# never list the normal handout page ( handout-masterpage is used instead )
429 		{
430 			sal_Bool bPageExluded = pPage->IsExcluded();
431 
432             bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage);
433             bPageExluded |= !bPageBelongsToShow;
434 
435             AddShapeList(*pPage, NULL, pPage->GetName(), bPageExluded, NULL, aIconProvider);
436 		}
437 		nPage++;
438 	}
439 
440 	// dann alle MasterPages incl. Objekte einfuegen
441 	if( mbShowAllPages )
442 	{
443 		nPage = 0;
444 		const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
445 
446 		while( nPage < nMaxMasterPages )
447 		{
448 			pPage = (SdPage*) mpDoc->GetMasterPage( nPage );
449             AddShapeList(*pPage, NULL, pPage->GetName(), false, NULL, aIconProvider);
450 			nPage++;
451 		}
452 	}
453 	if( aSelection.Len() )
454 		SelectEntry( aSelection );
455 }
456 
457 /*************************************************************************
458 |*
459 |* Es wird nur der erste Eintrag eingefuegt. Childs werden OnDemand erzeugt
460 |*
461 \************************************************************************/
462 
463 void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium,
464 						  const String& rDocName )
465 {
466 	mpDoc = pInDoc;
467 
468     // this object now owns the Medium
469 	mpMedium = pInMedium;
470 	maDocName = rDocName;
471 
472 	Image aImgDocOpen=Image( BitmapEx( SdResId( BMP_DOC_OPEN ) ) );
473 	Image aImgDocClosed=Image( BitmapEx( SdResId( BMP_DOC_CLOSED ) ) );
474 	Image aImgDocOpenH=Image( BitmapEx( SdResId( BMP_DOC_OPEN_H ) ) );
475 	Image aImgDocClosedH=Image( BitmapEx( SdResId( BMP_DOC_CLOSED_H ) ) );
476 
477 	// Dokumentnamen einfuegen
478 	SvLBoxEntry* pFileEntry = InsertEntry( maDocName,
479 	                          aImgDocOpen,
480 	                          aImgDocClosed,
481 	                          NULL,
482 	                          sal_True,
483 							  LIST_APPEND,
484 							  reinterpret_cast< void* >( 1 ) );
485 
486 	SetExpandedEntryBmp( pFileEntry, aImgDocOpenH, BMP_COLOR_HIGHCONTRAST );
487 	SetCollapsedEntryBmp( pFileEntry, aImgDocClosedH, BMP_COLOR_HIGHCONTRAST );
488 }
489 
490 
491 
492 
493 void SdPageObjsTLB::AddShapeList (
494     const SdrObjList& rList,
495     SdrObject* pShape,
496     const ::rtl::OUString& rsName,
497     const bool bIsExcluded,
498     SvLBoxEntry* pParentEntry,
499     const IconProvider& rIconProvider)
500 {
501     Image aIcon (rIconProvider.maImgPage);
502     if (bIsExcluded)
503         aIcon = rIconProvider.maImgPageExcl;
504     else if (pShape != NULL)
505         aIcon = rIconProvider.maImgGroup;
506 
507     void* pUserData (reinterpret_cast<void*>(1));
508     if (pShape != NULL)
509         pUserData = pShape;
510 
511 	SvLBoxEntry* pEntry = InsertEntry(
512         rsName,
513         aIcon,
514         aIcon,
515         pParentEntry,
516         sal_False,
517         LIST_APPEND,
518         pUserData);
519 
520     SetExpandedEntryBmp(
521         pEntry,
522         bIsExcluded ? rIconProvider.maImgPageExclH : rIconProvider.maImgPageH,
523         BMP_COLOR_HIGHCONTRAST );
524     SetCollapsedEntryBmp(
525         pEntry,
526         bIsExcluded ? rIconProvider.maImgPageExclH : rIconProvider.maImgPageH,
527         BMP_COLOR_HIGHCONTRAST );
528 
529     SdrObjListIter aIter(
530         rList,
531         !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
532         IM_FLAT,
533         sal_False /*not reverse*/);
534 
535     while( aIter.IsMore() )
536     {
537         SdrObject* pObj = aIter.Next();
538         OSL_ASSERT(pObj!=NULL);
539 
540         // Get the shape name.
541         String aStr (GetObjectName( pObj ) );
542 
543         if( aStr.Len() )
544         {
545             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
546             {
547                 SvLBoxEntry* pNewEntry = InsertEntry( aStr, maImgOle, maImgOle, pEntry,
548                     sal_False, LIST_APPEND, pObj);
549 
550                 SetExpandedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
551                 SetCollapsedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
552             }
553             else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
554             {
555                 SvLBoxEntry* pNewEntry = InsertEntry( aStr, maImgGraphic, maImgGraphic, pEntry,
556                     sal_False, LIST_APPEND, pObj );
557 
558                 SetExpandedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
559                 SetCollapsedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
560             }
561             else if (pObj->IsGroupObject())
562             {
563                 AddShapeList(
564                     *pObj->GetSubList(),
565                     pObj,
566                     aStr,
567                     false,
568                     pEntry,
569                     rIconProvider);
570             }
571             else
572             {
573                 SvLBoxEntry* pNewEntry = InsertEntry( aStr, rIconProvider.maImgObjects, rIconProvider.maImgObjects, pEntry,
574                     sal_False, LIST_APPEND, pObj );
575 
576                 SetExpandedEntryBmp( pNewEntry, rIconProvider.maImgObjectsH, BMP_COLOR_HIGHCONTRAST );
577                 SetCollapsedEntryBmp( pNewEntry, rIconProvider.maImgObjectsH, BMP_COLOR_HIGHCONTRAST );
578             }
579         }
580     }
581 
582     if( pEntry->HasChilds() )
583     {
584         SetExpandedEntryBmp(
585             pEntry,
586             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
587         SetCollapsedEntryBmp(
588             pEntry,
589             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
590         SetExpandedEntryBmp(
591             pEntry,
592             bIsExcluded ? rIconProvider.maImgPageObjsExclH : rIconProvider.maImgPageObjsH,
593             BMP_COLOR_HIGHCONTRAST);
594         SetCollapsedEntryBmp(
595             pEntry,
596             bIsExcluded ? rIconProvider.maImgPageObjsExclH : rIconProvider.maImgPageObjsH,
597             BMP_COLOR_HIGHCONTRAST);
598     }
599 }
600 
601 
602 
603 
604 void SdPageObjsTLB::SetShowAllShapes (
605     const bool bShowAllShapes,
606     const bool bFillList)
607 {
608     mbShowAllShapes = bShowAllShapes;
609     if (bFillList)
610     {
611         if (mpMedium == NULL)
612             Fill(mpDoc, mbShowAllPages, maDocName);
613         else
614             Fill(mpDoc, mpMedium, maDocName);
615     }
616 }
617 
618 
619 
620 
621 bool SdPageObjsTLB::GetShowAllShapes (void) const
622 {
623     return mbShowAllShapes;
624 }
625 
626 
627 
628 
629 /*************************************************************************
630 |*
631 |* Prueft, ob die Seiten (PK_STANDARD) und die darauf befindlichen Objekte
632 |* des Docs und der TreeLB identisch sind.
633 |* Wird ein Doc uebergeben, wird dieses zum aktuellem Doc (Wichtig bei
634 |* mehreren Documenten).
635 |*
636 \************************************************************************/
637 
638 sal_Bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
639 {
640 	if( pInDoc )
641 		mpDoc = pInDoc;
642 
643 	if( !mpDoc )
644 		return( sal_False );
645 
646 	SdrObject*	 pObj = NULL;
647 	SdPage* 	 pPage = NULL;
648 	SvLBoxEntry* pEntry = First();
649 	String		 aName;
650 
651 	// Alle Pages incl. Objekte vergleichen
652 	sal_uInt16 nPage = 0;
653 	const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
654 
655 	while( nPage < nMaxPages )
656 	{
657 		pPage = (SdPage*) mpDoc->GetPage( nPage );
658 		if( pPage->GetPageKind() == PK_STANDARD )
659 		{
660 			if( !pEntry )
661 				return( sal_False );
662 			aName = GetEntryText( pEntry );
663 
664 			if( pPage->GetName() != aName )
665 				return( sal_False );
666 
667 			pEntry = Next( pEntry );
668 
669 			SdrObjListIter aIter(
670                 *pPage,
671                 !pPage->HasObjectNavigationOrder() /* use navigation order, if available */,
672                 IM_DEEPWITHGROUPS );
673 
674 			while( aIter.IsMore() )
675 			{
676 				pObj = aIter.Next();
677 
678                 const String aObjectName( GetObjectName( pObj ) );
679 
680 				if( aObjectName.Len() )
681 				{
682 					if( !pEntry )
683 						return( sal_False );
684 
685                 	aName = GetEntryText( pEntry );
686 
687 					if( aObjectName != aName )
688 						return( sal_False );
689 
690 					pEntry = Next( pEntry );
691 				}
692 			}
693 		}
694 		nPage++;
695 	}
696 	// Wenn noch Eintraege in der Listbox vorhanden sind, wurden
697 	// Objekte (mit Namen) oder Seiten geloescht
698 	return( !pEntry );
699 }
700 
701 /*************************************************************************
702 |*
703 |* Selectierten String zurueckgeben
704 |*
705 \************************************************************************/
706 
707 String SdPageObjsTLB::GetSelectEntry()
708 {
709 	return( GetEntryText( GetCurEntry() ) );
710 }
711 
712 /*************************************************************************
713 |*
714 |* Selektierte Eintrage zurueckgeben
715 |* nDepth == 0 -> Seiten
716 |* nDepth == 1 -> Objekte
717 |*
718 \************************************************************************/
719 
720 List* SdPageObjsTLB::GetSelectEntryList( sal_uInt16 nDepth )
721 {
722 	List*		 pList	= NULL;
723 	SvLBoxEntry* pEntry = FirstSelected();
724 
725 	while( pEntry )
726 	{
727 		sal_uInt16 nListDepth = GetModel()->GetDepth( pEntry );
728 		if( nListDepth == nDepth )
729 		{
730 			if( !pList )
731 				pList = new List();
732 
733 			const String aEntryText( GetEntryText( pEntry ) );
734 			pList->Insert( new String( aEntryText ), LIST_APPEND );
735 		}
736 		pEntry = NextSelected( pEntry );
737 	}
738 
739 	return( pList );
740 }
741 
742 /*************************************************************************
743 |*
744 |* Eintraege werden erst auf Anforderung (Doppelklick) eingefuegt
745 |*
746 \************************************************************************/
747 
748 void SdPageObjsTLB::RequestingChilds( SvLBoxEntry* pFileEntry )
749 {
750 	if( !pFileEntry->HasChilds() )
751 	{
752 		if( GetBookmarkDoc() )
753 		{
754 			SdrObject*	 pObj = NULL;
755 			SdPage* 	 pPage = NULL;
756 			SvLBoxEntry* pPageEntry = NULL;
757 
758 			Image aImgPage=Image( BitmapEx( SdResId( BMP_PAGE ) ) );
759 			Image aImgPageObjs=Image( BitmapEx( SdResId( BMP_PAGEOBJS ) ) );
760 			Image aImgObjects=Image( BitmapEx( SdResId( BMP_OBJECTS ) ) );
761 			Image aImgPageH=Image( BitmapEx( SdResId( BMP_PAGE_H ) ) );
762 			Image aImgPageObjsH=Image( BitmapEx( SdResId( BMP_PAGEOBJS_H ) ) );
763 			Image aImgObjectsH=Image( BitmapEx( SdResId( BMP_OBJECTS_H ) ) );
764 
765 			// document name already inserted
766 
767 			// only insert all "normal" ? slides with objects
768 			sal_uInt16 nPage = 0;
769 			const sal_uInt16 nMaxPages = mpBookmarkDoc->GetPageCount();
770 
771 			while( nPage < nMaxPages )
772 			{
773 				pPage = (SdPage*) mpBookmarkDoc->GetPage( nPage );
774 				if( pPage->GetPageKind() == PK_STANDARD )
775 				{
776 					pPageEntry = InsertEntry( pPage->GetName(),
777 					                          aImgPage,
778 					                          aImgPage,
779 					                          pFileEntry,
780 							                  sal_False,
781 								              LIST_APPEND,
782 								              reinterpret_cast< void* >( 1 ) );
783 
784 					SetExpandedEntryBmp( pPageEntry, aImgPageH, BMP_COLOR_HIGHCONTRAST );
785 					SetCollapsedEntryBmp( pPageEntry, aImgPageH, BMP_COLOR_HIGHCONTRAST );
786 
787 					SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
788 
789 					while( aIter.IsMore() )
790 					{
791 						pObj = aIter.Next();
792 						String aStr( GetObjectName( pObj ) );
793 						if( aStr.Len() )
794 						{
795 							if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
796 							{
797 								SvLBoxEntry* pNewEntry = InsertEntry(aStr, maImgOle, maImgOle, pPageEntry);
798 
799 
800 								SetExpandedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
801 								SetCollapsedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
802 							}
803 							else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
804 							{
805 								SvLBoxEntry* pNewEntry = InsertEntry(aStr, maImgGraphic, maImgGraphic, pPageEntry);
806 
807 								SetExpandedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
808 								SetCollapsedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
809 							}
810 							else
811 							{
812 								SvLBoxEntry* pNewEntry = InsertEntry(aStr, aImgObjects, aImgObjects, pPageEntry);
813 
814 								SetExpandedEntryBmp( pNewEntry, aImgObjectsH, BMP_COLOR_HIGHCONTRAST );
815 								SetCollapsedEntryBmp( pNewEntry, aImgObjectsH, BMP_COLOR_HIGHCONTRAST );
816 							}
817 						}
818 					}
819 					if( pPageEntry->HasChilds() )
820 					{
821 						SetExpandedEntryBmp( pPageEntry, aImgPageObjs );
822 						SetCollapsedEntryBmp( pPageEntry, aImgPageObjs );
823 						SetExpandedEntryBmp( pPageEntry, aImgPageObjsH, BMP_COLOR_HIGHCONTRAST );
824 						SetCollapsedEntryBmp( pPageEntry, aImgPageObjsH, BMP_COLOR_HIGHCONTRAST );
825 					}
826 				}
827 				nPage++;
828 			}
829 		}
830 	}
831 	else
832 		SvTreeListBox::RequestingChilds( pFileEntry );
833 }
834 
835 /*************************************************************************
836 |*
837 |*	Prueft, ob es sich um eine Draw-Datei handelt und oeffnet anhand des
838 |*	uebergebenen Docs das BookmarkDoc
839 |*
840 \************************************************************************/
841 
842 SdDrawDocument* SdPageObjsTLB::GetBookmarkDoc(SfxMedium* pMed)
843 {
844 	if (
845        !mpBookmarkDoc ||
846 		 (pMed && (!mpOwnMedium || mpOwnMedium->GetName() != pMed->GetName()))
847       )
848 	{
849         // create a new BookmarkDoc if now one exists or if a new Medium is provided
850         if (mpOwnMedium != pMed)
851 		{
852 			CloseBookmarkDoc();
853 		}
854 
855 		if (pMed)
856 		{
857             // it looks that it is undefined if a Medium was set by Fill() allready
858             DBG_ASSERT( !mpMedium, "SfxMedium confusion!" );
859             delete mpMedium;
860             mpMedium = NULL;
861 
862             // take over this Medium (currently used only be Navigator)
863 			mpOwnMedium = pMed;
864         }
865 
866         DBG_ASSERT( mpMedium || pMed, "No SfxMedium provided!" );
867 
868         if( pMed )
869         {
870             // in this mode the document is also owned and controlled by this instance
871             mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True);
872             if (mxBookmarkDocShRef->DoLoad(pMed))
873                 mpBookmarkDoc = mxBookmarkDocShRef->GetDoc();
874             else
875                 mpBookmarkDoc = NULL;
876         }
877         else if ( mpMedium )
878             // in this mode the document is owned and controlled by the SdDrawDocument
879             // it can be released by calling the corresponding CloseBookmarkDoc method
880             // successfull creation of a document makes this the owner of the medium
881             mpBookmarkDoc = ((SdDrawDocument*) mpDoc)->OpenBookmarkDoc(*mpMedium);
882 
883         if ( !mpBookmarkDoc )
884 		{
885 			ErrorBox aErrorBox( this, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
886 			aErrorBox.Execute();
887             mpMedium = 0; //On failure the SfxMedium is invalid
888 		}
889 	}
890 
891 	return( mpBookmarkDoc );
892 }
893 
894 /*************************************************************************
895 |*
896 |* Bookmark-Dokument schlie�en und loeschen
897 |*
898 \************************************************************************/
899 
900 void SdPageObjsTLB::CloseBookmarkDoc()
901 {
902 	if (mxBookmarkDocShRef.Is())
903 	{
904 		mxBookmarkDocShRef->DoClose();
905         mxBookmarkDocShRef.Clear();
906 
907         // Medium is owned by document, so it's destroyed already
908         mpOwnMedium = 0;
909 	}
910     else if ( mpBookmarkDoc )
911 	{
912         DBG_ASSERT( !mpOwnMedium, "SfxMedium confusion!" );
913         if ( mpDoc )
914         {
915             // The document owns the Medium, so the Medium will be invalid after closing the document
916 			((SdDrawDocument*) mpDoc)->CloseBookmarkDoc();
917             mpMedium = 0;
918         }
919 	}
920     else
921     {
922         // perhaps mpOwnMedium provided, but no successfull creation of BookmarkDoc
923         delete mpOwnMedium;
924         mpOwnMedium = NULL;
925     }
926 
927 	mpBookmarkDoc = NULL;
928 }
929 
930 /*************************************************************************
931 |*
932 |*
933 |*
934 \************************************************************************/
935 
936 void SdPageObjsTLB::SelectHdl()
937 {
938 	SvLBoxEntry* pEntry = FirstSelected();
939 
940 	mbLinkableSelected = sal_True;
941 
942 	while( pEntry && mbLinkableSelected )
943 	{
944 	    if( NULL == pEntry->GetUserData() )
945 	        mbLinkableSelected = sal_False;
946 
947 		pEntry = NextSelected( pEntry );
948 	}
949 
950 	SvTreeListBox::SelectHdl();
951 }
952 
953 /*************************************************************************
954 |*
955 |* Ueberlaedt RETURN mit der Funktionsweise von DoubleClick
956 |*
957 \************************************************************************/
958 
959 void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt )
960 {
961 	if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
962 	{
963 		// Auskommentierter Code aus svtools/source/contnr/svimpbox.cxx
964 		SvLBoxEntry* pCursor = GetCurEntry();
965 		if( pCursor->HasChilds() || pCursor->HasChildsOnDemand() )
966 		{
967 			if( IsExpanded( pCursor ) )
968 				Collapse( pCursor );
969 			else
970 				Expand( pCursor );
971 		}
972 
973 		DoubleClickHdl();
974 	}
975 	else
976 		SvTreeListBox::KeyInput( rKEvt );
977 }
978 
979 /*************************************************************************
980 |*
981 |* StartDrag-Request
982 |*
983 \************************************************************************/
984 
985 void SdPageObjsTLB::StartDrag( sal_Int8 nAction, const Point& rPosPixel)
986 {
987     (void)nAction;
988     (void)rPosPixel;
989 
990 	SdNavigatorWin* pNavWin = NULL;
991     SvLBoxEntry* pEntry = GetEntry(rPosPixel);
992 
993 	if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
994 		pNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
995 
996 	if (pEntry != NULL
997         && pNavWin !=NULL
998         && pNavWin == mpParent
999         && pNavWin->GetNavigatorDragType() != NAVIGATOR_DRAGTYPE_NONE )
1000 	{
1001         // Mark only the children of the page under the mouse as drop
1002         // targets.  This prevents moving shapes from one page to another.
1003 
1004         // Select all entries and disable them as drop targets.
1005         SetSelectionMode(MULTIPLE_SELECTION);
1006         SetCursor(NULL, sal_False);
1007         SelectAll(sal_True, sal_False);
1008         EnableSelectionAsDropTarget(sal_False, sal_True);
1009 
1010         // Enable only the entries as drop targets that are children of the
1011         // page under the mouse.
1012         SvLBoxEntry* pParent = GetRootLevelParent(pEntry);
1013         if (pParent != NULL)
1014         {
1015             SelectAll(sal_False, sal_False);
1016             Select(pParent, sal_True);
1017             //            for (SvLBoxEntry*pChild=FirstChild(pParent); pChild!=NULL; pChild=NextSibling(pChild))
1018             //                Select(pChild, sal_True);
1019             EnableSelectionAsDropTarget(sal_True, sal_True);//sal_False);
1020         }
1021 
1022         // Set selection back to the entry under the mouse.
1023         SelectAll(sal_False,sal_False);
1024         SetSelectionMode(SINGLE_SELECTION);
1025         Select(pEntry, sal_True);
1026 
1027 		//  Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
1028 		//  (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
1029 		//  den StarView MouseMove-Handler, der Command() aufruft, umbringen.
1030 		//  Deshalb Drag&Drop asynchron:
1031         Application::PostUserEvent( STATIC_LINK( this, SdPageObjsTLB, ExecDragHdl ) );
1032 	}
1033 }
1034 
1035 /*************************************************************************
1036 |*
1037 |* Begin drag
1038 |*
1039 \************************************************************************/
1040 
1041 void SdPageObjsTLB::DoDrag()
1042 {
1043 	mpDropNavWin = ( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) ?
1044 				  (SdNavigatorWin*)( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ) :
1045 				  NULL;
1046 
1047 	if( mpDropNavWin )
1048 	{
1049 		::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
1050         String aURL = INetURLObject( pDocShell->GetMedium()->GetPhysicalName(), INET_PROT_FILE ).GetMainURL( INetURLObject::NO_DECODE );
1051 		NavigatorDragType	eDragType = mpDropNavWin->GetNavigatorDragType();
1052 
1053 		aURL.Append( '#' );
1054 		aURL.Append( GetSelectEntry() );
1055 
1056 		INetBookmark	aBookmark( aURL, GetSelectEntry() );
1057 		sal_Int8		nDNDActions = DND_ACTION_COPYMOVE;
1058 
1059 		if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
1060 			nDNDActions = DND_ACTION_LINK;	// #93240# Either COPY *or* LINK, never both!
1061         else if (mpDoc->GetSdPageCount(PK_STANDARD) == 1)
1062         {
1063             // Can not move away the last slide in a document.
1064             nDNDActions = DND_ACTION_COPY;
1065         }
1066 
1067 		SvTreeListBox::ReleaseMouse();
1068 
1069 		bIsInDrag = sal_True;
1070 
1071         SvLBoxDDInfo aDDInfo;
1072         memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
1073         aDDInfo.pApp = GetpApp();
1074         aDDInfo.pSource = this;
1075         //            aDDInfo.pDDStartEntry = pEntry;
1076 		::com::sun::star::uno::Sequence<sal_Int8> aSequence (sizeof(SvLBoxDDInfo));
1077 		memcpy(aSequence.getArray(), (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo));
1078 		::com::sun::star::uno::Any aTreeListBoxData (aSequence);
1079 
1080 		// object is destroyed by internal reference mechanism
1081 		SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable(
1082             *this, aBookmark, *pDocShell, eDragType, aTreeListBoxData);
1083 
1084         // Get the view.
1085         ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell);
1086         if (pViewShell == NULL)
1087         {
1088             OSL_ASSERT(pViewShell!=NULL);
1089             return;
1090         }
1091         sd::View* pView = pViewShell->GetView();
1092         if (pView == NULL)
1093         {
1094             OSL_ASSERT(pView!=NULL);
1095             return;
1096         }
1097 
1098         SdrObject* pObject = NULL;
1099         void* pUserData = GetCurEntry()->GetUserData();
1100         if (pUserData != NULL && pUserData != (void*)1)
1101             pObject = reinterpret_cast<SdrObject*>(pUserData);
1102         if (pObject != NULL)
1103         {
1104             // For shapes without a user supplied name (the automatically
1105             // created name does not count), a different drag and drop technique
1106             // is used.
1107             if (GetObjectName(pObject, false).Len() == 0)
1108             {
1109                 AddShapeToTransferable(*pTransferable, *pObject);
1110                 pTransferable->SetView(pView);
1111                 SD_MOD()->pTransferDrag = pTransferable;
1112             }
1113 
1114             // Unnamed shapes have to be selected to be recognized by the
1115             // current drop implementation.  In order to have a consistent
1116             // behaviour for all shapes, every shape that is to be dragged is
1117             // selected first.
1118             SdrPageView* pPageView = pView->GetSdrPageView();
1119             pView->UnmarkAllObj(pPageView);
1120             pView->MarkObj(pObject, pPageView);
1121         }
1122         else
1123         {
1124             pTransferable->SetView(pView);
1125             SD_MOD()->pTransferDrag = pTransferable;
1126         }
1127 
1128         pTransferable->StartDrag( this, nDNDActions );
1129 	}
1130 }
1131 
1132 /*************************************************************************
1133 |*
1134 |* Drag finished
1135 |*
1136 \************************************************************************/
1137 
1138 void SdPageObjsTLB::OnDragFinished( sal_uInt8 )
1139 {
1140 	if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
1141 	{
1142 		SdNavigatorWin* pNewNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
1143 
1144 		if( mpDropNavWin == pNewNavWin)
1145 		{
1146 			MouseEvent aMEvt( mpDropNavWin->GetPointerPosPixel() );
1147 			SvTreeListBox::MouseButtonUp( aMEvt );
1148 		}
1149 	}
1150 
1151 	mpDropNavWin = NULL;
1152 	bIsInDrag = sal_False;
1153 }
1154 
1155 /*************************************************************************
1156 |*
1157 |* AcceptDrop-Event
1158 |*
1159 \************************************************************************/
1160 
1161 sal_Int8 SdPageObjsTLB::AcceptDrop (const AcceptDropEvent& rEvent)
1162 {
1163     sal_Int8 nResult (DND_ACTION_NONE);
1164 
1165 	if ( !bIsInDrag && IsDropFormatSupported( FORMAT_FILE ) )
1166     {
1167         nResult = rEvent.mnAction;
1168     }
1169     else
1170     {
1171         SvLBoxEntry* pEntry = GetDropTarget(rEvent.maPosPixel);
1172         if (rEvent.mbLeaving || !CheckDragAndDropMode( this, rEvent.mnAction ))
1173         {
1174             ImplShowTargetEmphasis( pTargetEntry, sal_False );
1175         }
1176         else if( !nDragDropMode )
1177         {
1178             DBG_ERRORFILE( "SdPageObjsTLB::AcceptDrop(): no target" );
1179         }
1180         else if (IsDropAllowed(pEntry))
1181         {
1182             nResult = DND_ACTION_MOVE;
1183 
1184             // Draw emphasis.
1185             if (pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS))
1186             {
1187                 ImplShowTargetEmphasis( pTargetEntry, sal_False );
1188                 pTargetEntry = pEntry;
1189                 ImplShowTargetEmphasis( pTargetEntry, sal_True );
1190             }
1191         }
1192     }
1193 
1194     // Hide emphasis when there is no valid drop action.
1195     if (nResult == DND_ACTION_NONE)
1196         ImplShowTargetEmphasis(pTargetEntry, sal_False);
1197 
1198     return nResult;
1199 }
1200 
1201 /*************************************************************************
1202 |*
1203 |* ExecuteDrop-Event
1204 |*
1205 \************************************************************************/
1206 
1207 sal_Int8 SdPageObjsTLB::ExecuteDrop( const ExecuteDropEvent& rEvt )
1208 {
1209 	sal_Int8 nRet = DND_ACTION_NONE;
1210 
1211     try
1212     {
1213         if( !bIsInDrag )
1214         {
1215             SdNavigatorWin* pNavWin = NULL;
1216             sal_uInt16			nId = SID_NAVIGATOR;
1217 
1218             if( mpFrame->HasChildWindow( nId ) )
1219                 pNavWin = (SdNavigatorWin*)( mpFrame->GetChildWindow( nId )->GetContextWindow( SD_MOD() ) );
1220 
1221             if( pNavWin && ( pNavWin == mpParent ) )
1222             {
1223                 TransferableDataHelper	aDataHelper( rEvt.maDropEvent.Transferable );
1224                 String					aFile;
1225 
1226                 if( aDataHelper.GetString( FORMAT_FILE, aFile ) &&
1227                     ( (SdNavigatorWin*) mpParent)->InsertFile( aFile ) )
1228                 {
1229                     nRet = rEvt.mnAction;
1230                 }
1231             }
1232         }
1233     }
1234     catch (com::sun::star::uno::Exception&)
1235     {
1236         DBG_UNHANDLED_EXCEPTION();
1237     }
1238 
1239     if (nRet == DND_ACTION_NONE)
1240         SvTreeListBox::ExecuteDrop(rEvt, this);
1241 
1242 
1243 	return nRet;
1244 }
1245 
1246 /*************************************************************************
1247 |*
1248 |* Handler fuers Dragging
1249 |*
1250 \************************************************************************/
1251 
1252 IMPL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*, EMPTYARG)
1253 {
1254 	//	als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
1255 	//	Navigator geloescht werden darf
1256 	pThis->DoDrag();
1257 	return 0;
1258 }
1259 
1260 
1261 bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const
1262 {
1263     // Return <TRUE/> as default when there is no custom show or when none
1264     // is used.  The page does then belong to the standard show.
1265     bool bBelongsToShow = true;
1266 
1267     if (mpDoc->getPresentationSettings().mbCustomShow)
1268     {
1269         // Get the current custom show.
1270         SdCustomShow* pCustomShow = NULL;
1271         List* pShowList = const_cast<SdDrawDocument*>(mpDoc)->GetCustomShowList();
1272         if (pShowList != NULL)
1273         {
1274             sal_uLong nCurrentShowIndex = pShowList->GetCurPos();
1275             void* pObject = pShowList->GetObject(nCurrentShowIndex);
1276             pCustomShow = static_cast<SdCustomShow*>(pObject);
1277         }
1278 
1279         // Check whether the given page is part of that custom show.
1280         if (pCustomShow != NULL)
1281         {
1282             bBelongsToShow = false;
1283             sal_uLong nPageCount = pCustomShow->Count();
1284             for (sal_uInt16 i=0; i<nPageCount && !bBelongsToShow; i++)
1285                 if (pPage == static_cast<SdPage*>(pCustomShow->GetObject (i)))
1286                     bBelongsToShow = true;
1287         }
1288     }
1289 
1290     return bBelongsToShow;
1291 }
1292 
1293 
1294 
1295 
1296 sal_Bool SdPageObjsTLB::NotifyMoving(
1297     SvLBoxEntry* pTarget,
1298     SvLBoxEntry* pEntry,
1299     SvLBoxEntry*& rpNewParent,
1300     sal_uLong& rNewChildPos)
1301 {
1302     SvLBoxEntry* pDestination = pTarget;
1303     while (GetParent(pDestination) != NULL && GetParent(GetParent(pDestination)) != NULL)
1304         pDestination = GetParent(pDestination);
1305 
1306     SdrObject* pTargetObject = reinterpret_cast<SdrObject*>(pDestination->GetUserData());
1307     SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(pEntry->GetUserData());
1308     if (pSourceObject == reinterpret_cast<SdrObject*>(1))
1309         pSourceObject = NULL;
1310 
1311     if (pTargetObject != NULL && pSourceObject != NULL)
1312     {
1313         SdrPage* pObjectList = pSourceObject->GetPage();
1314         if (pObjectList != NULL)
1315         {
1316             sal_uInt32 nNewPosition;
1317             if (pTargetObject == reinterpret_cast<SdrObject*>(1))
1318                 nNewPosition = 0;
1319             else
1320                 nNewPosition = pTargetObject->GetNavigationPosition() + 1;
1321             pObjectList->SetObjectNavigationPosition(*pSourceObject, nNewPosition);
1322         }
1323 
1324         // Update the tree list.
1325         if (pTarget == NULL)
1326         {
1327             rpNewParent = 0;
1328             rNewChildPos = 0;
1329             return sal_True;
1330         }
1331         else if (GetParent(pDestination) == NULL)
1332         {
1333             rpNewParent = pDestination;
1334             rNewChildPos = 0;
1335         }
1336         else
1337         {
1338             rpNewParent = GetParent(pDestination);
1339             rNewChildPos = pModel->GetRelPos(pDestination) + 1;
1340             rNewChildPos += nCurEntrySelPos;
1341             nCurEntrySelPos++;
1342         }
1343         return sal_True;
1344     }
1345     else
1346         return sal_False;
1347 }
1348 
1349 
1350 
1351 
1352 SvLBoxEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation)
1353 {
1354     SvLBoxEntry* pEntry = SvTreeListBox::GetDropTarget(rLocation);
1355     if (pEntry == NULL)
1356         return NULL;
1357 
1358     if (GetParent(pEntry) == NULL)
1359     {
1360         // Use page entry as insertion position.
1361     }
1362     else
1363     {
1364         // Go to second hierarchy level, i.e. top level shapes,
1365         // i.e. children of pages.
1366         while (GetParent(pEntry) != NULL && GetParent(GetParent(pEntry)) != NULL)
1367             pEntry = GetParent(pEntry);
1368 
1369         // Advance to next sibling.
1370         SvLBoxEntry* pNext;
1371         sal_uInt16 nDepth (0);
1372         while (pEntry != NULL)
1373         {
1374             pNext = dynamic_cast<SvLBoxEntry*>(NextVisible(pEntry, &nDepth));
1375             if (pNext != NULL && nDepth > 0 && nDepth!=0xffff)
1376                 pEntry = pNext;
1377             else
1378                 break;
1379         }
1380     }
1381 
1382     return pEntry;
1383 }
1384 
1385 
1386 
1387 
1388 bool SdPageObjsTLB::IsDropAllowed (SvLBoxEntry* pEntry)
1389 {
1390     if (pEntry == NULL)
1391         return false;
1392 
1393     if ( ! IsDropFormatSupported(SdPageObjsTransferable::GetListBoxDropFormatId()))
1394         return false;
1395 
1396     if ((pEntry->GetFlags() & SV_ENTRYFLAG_DISABLE_DROP) != 0)
1397         return false;
1398 
1399     return true;
1400 }
1401 
1402 
1403 
1404 
1405 void SdPageObjsTLB::AddShapeToTransferable (
1406     SdTransferable& rTransferable,
1407     SdrObject& rObject) const
1408 {
1409 	TransferableObjectDescriptor aObjectDescriptor;
1410     bool bIsDescriptorFillingPending (true);
1411 
1412     const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
1413     if (pOleObject != NULL && pOleObject->GetObjRef().is())
1414     {
1415         // If object has no persistence it must be copied as part of the document
1416         try
1417         {
1418             uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->GetObjRef(), uno::UNO_QUERY );
1419             if (xPersObj.is() && xPersObj->hasEntry())
1420             {
1421                 SvEmbedTransferHelper::FillTransferableObjectDescriptor(
1422                     aObjectDescriptor,
1423                     pOleObject->GetObjRef(),
1424                     pOleObject->GetGraphic(),
1425                     pOleObject->GetAspect());
1426                 bIsDescriptorFillingPending = false;
1427             }
1428         }
1429         catch( uno::Exception& )
1430         {
1431         }
1432 	}
1433 
1434     ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
1435 	if (bIsDescriptorFillingPending && pDocShell!=NULL)
1436     {
1437         bIsDescriptorFillingPending = false;
1438         pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor);
1439     }
1440 
1441     Point aDragPos (rObject.GetCurrentBoundRect().Center());
1442     //Point aDragPos (0,0);
1443 	aObjectDescriptor.maDragStartPos = aDragPos;
1444     //	aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
1445     if (pDocShell != NULL)
1446         aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
1447     else
1448         aObjectDescriptor.maDisplayName = String();
1449 	aObjectDescriptor.mbCanLink = sal_False;
1450 
1451 	rTransferable.SetStartPos(aDragPos);
1452 	rTransferable.SetObjectDescriptor( aObjectDescriptor );
1453 }
1454 
1455 
1456 
1457 
1458 ::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
1459 {
1460     {
1461         ::sd::ViewShell* pViewShell = rDocShell.GetViewShell();
1462         if (pViewShell != NULL)
1463             return pViewShell;
1464     }
1465 
1466     try
1467     {
1468         // Get a component enumeration from the desktop and search it for documents.
1469         uno::Reference<lang::XMultiServiceFactory> xFactory (
1470             ::comphelper::getProcessServiceFactory ());
1471         if ( ! xFactory.is())
1472             return NULL;
1473 
1474         uno::Reference<frame::XDesktop> xDesktop (xFactory->createInstance (
1475                 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), uno::UNO_QUERY);
1476         if ( ! xDesktop.is())
1477             return NULL;
1478 
1479         uno::Reference<frame::XFramesSupplier> xFrameSupplier (xDesktop, uno::UNO_QUERY);
1480         if ( ! xFrameSupplier.is())
1481             return NULL;
1482 
1483         uno::Reference<container::XIndexAccess> xFrameAccess (xFrameSupplier->getFrames(), uno::UNO_QUERY);
1484         if ( ! xFrameAccess.is())
1485             return NULL;
1486 
1487         for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex<nCount; ++nIndex)
1488         {
1489             uno::Reference<frame::XFrame> xFrame;
1490             if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame))
1491                 continue;
1492 
1493             ::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xFrame->getController().get());
1494             if (pController == NULL)
1495                 continue;
1496             ::sd::ViewShellBase* pBase = pController->GetViewShellBase();
1497             if (pBase == NULL)
1498                 continue;
1499             if (pBase->GetDocShell() != &rDocShell)
1500                 continue;
1501 
1502             const ::boost::shared_ptr<sd::ViewShell> pViewShell (pBase->GetMainViewShell());
1503             if (pViewShell)
1504                 return pViewShell.get();
1505         }
1506     }
1507     catch (uno::Exception e)
1508     {
1509         // When there is an exception then simply use the default value of
1510         // bIsEnabled and disable the controls.
1511     }
1512     return NULL;
1513 }
1514 
1515 
1516 
1517 
1518 //===== IconProvider ==========================================================
1519 
1520 SdPageObjsTLB::IconProvider::IconProvider (void)
1521     : maImgPage( BitmapEx( SdResId( BMP_PAGE ) ) ),
1522       maImgPageExcl( BitmapEx( SdResId( BMP_PAGE_EXCLUDED ) ) ),
1523       maImgPageObjsExcl( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED ) ) ),
1524       maImgPageObjs( BitmapEx( SdResId( BMP_PAGEOBJS ) ) ),
1525       maImgObjects( BitmapEx( SdResId( BMP_OBJECTS ) ) ),
1526       maImgGroup( BitmapEx( SdResId( BMP_GROUP ) ) ),
1527 
1528       maImgPageH( BitmapEx( SdResId( BMP_PAGE_H ) ) ),
1529       maImgPageExclH( BitmapEx( SdResId( BMP_PAGE_EXCLUDED_H ) ) ),
1530       maImgPageObjsExclH( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED_H ) ) ),
1531       maImgPageObjsH( BitmapEx( SdResId( BMP_PAGEOBJS_H ) ) ),
1532       maImgObjectsH( BitmapEx( SdResId( BMP_OBJECTS_H ) ) ),
1533       maImgGroupH( BitmapEx( SdResId( BMP_GROUP_H ) ) )
1534 {
1535 }
1536