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