xref: /trunk/main/sd/source/ui/dlg/navigatr.cxx (revision 0deba7fb)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include <tools/urlobj.hxx>
29 #include <unotools/localfilehelper.hxx>
30 #include <sfx2/imgmgr.hxx>
31 #include <sfx2/fcontnr.hxx>
32 #include <svl/eitem.hxx>
33 #include <svl/stritem.hxx>
34 #include <sfx2/docfilt.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <svl/intitem.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <svx/svxids.hrc>
39 #include <vcl/menu.hxx>
40 
41 #include <sfx2/viewfrm.hxx>
42 #include <sfx2/dockwin.hxx>
43 #include <sfx2/sfxresid.hxx>
44 
45 #include "pres.hxx"
46 #include "navigatr.hxx"
47 #include "navigatr.hrc"
48 #include "pgjump.hxx"
49 #include "app.hrc"
50 #include "strings.hrc"
51 #include "res_bmp.hrc"
52 #include "drawdoc.hxx"
53 #include "DrawDocShell.hxx"
54 #include "sdresid.hxx"
55 #include "ViewShell.hxx"
56 #include "ViewShellBase.hxx"
57 #include "DrawViewShell.hxx"
58 #include "slideshow.hxx"
59 #include "FrameView.hxx"
60 #include "helpids.h"
61 
62 namespace {
63 static const sal_uInt16 nShowNamedShapesFilter=1;
64 static const sal_uInt16 nShowAllShapesFilter=2;
65 }
66 
67 /*************************************************************************
68 |*	SdNavigatorWin - FloatingWindow
69 \************************************************************************/
70 
71 SdNavigatorWin::SdNavigatorWin(
72     ::Window* pParent,
73     ::sd::NavigatorChildWindow* pChWinCtxt,
74     const SdResId& rSdResId,
75     SfxBindings* pInBindings,
76     const UpdateRequestFunctor& rUpdateRequest)
77     : ::Window( pParent, rSdResId ),
78       maToolbox        ( this, SdResId( 1 ) ),
79       maTlbObjects( this, SdResId( TLB_OBJECTS ) ),
80       maLbDocs         ( this, SdResId( LB_DOCS ) ),
81       mpChildWinContext( pChWinCtxt ),
82       mbDocImported	( sal_False ),
83       // Bei Aenderung des DragTypes: SelectionMode der TLB anpassen!
84       meDragType		( NAVIGATOR_DRAGTYPE_EMBEDDED ),
85       mpBindings		( pInBindings ),
86       maImageList		( SdResId( IL_NAVIGATR ) ),
87       maImageListH	( SdResId( ILH_NAVIGATR ) )
88 {
89     maTlbObjects.SetViewFrame( mpBindings->GetDispatcher()->GetFrame() );
90 
91     FreeResource();
92 
93     maTlbObjects.SetAccessibleName(String(SdResId(STR_OBJECTS_TREE)));
94 
95     mpNavigatorCtrlItem = new SdNavigatorControllerItem( SID_NAVIGATOR_STATE, this, mpBindings, rUpdateRequest);
96     mpPageNameCtrlItem = new SdPageNameControllerItem( SID_NAVIGATOR_PAGENAME, this, mpBindings, rUpdateRequest);
97     mpDocList = new List();
98 
99     ApplyImageList(); // load images *before* calculating sizes to get something useful !!!
100 
101     Size aTbxSize( maToolbox.CalcWindowSizePixel() );
102     maToolbox.SetOutputSizePixel( aTbxSize );
103     maToolbox.SetSelectHdl( LINK( this, SdNavigatorWin, SelectToolboxHdl ) );
104     maToolbox.SetClickHdl( LINK( this, SdNavigatorWin, ClickToolboxHdl ) );
105     maToolbox.SetDropdownClickHdl( LINK(this, SdNavigatorWin, DropdownClickToolBoxHdl) );
106     maToolbox.SetItemBits( TBI_DRAGTYPE, maToolbox.GetItemBits( TBI_DRAGTYPE ) | TIB_DROPDOWNONLY );
107 
108     // Shape filter drop down menu.
109     maToolbox.SetItemBits(
110         TBI_SHAPE_FILTER,
111         maToolbox.GetItemBits(TBI_SHAPE_FILTER) | TIB_DROPDOWNONLY);
112 
113     // TreeListBox
114     // set position below toolbox
115     long nListboxYPos = maToolbox.GetPosPixel().Y() + maToolbox.GetSizePixel().Height() + 4;
116     maTlbObjects.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
117     maTlbObjects.SetDoubleClickHdl( LINK( this, SdNavigatorWin, ClickObjectHdl ) );
118     maTlbObjects.SetSelectionMode( SINGLE_SELECTION );
119     // set focus to listbox, otherwise it is in the toolbox which is only useful
120     // for keyboard navigation
121     maTlbObjects.GrabFocus();
122 //IAccessibility2 Implementation 2009-----
123        maTlbObjects.SetSdNavigatorWinFlag(sal_True);
124 //-----IAccessibility2 Implementation 2009
125 
126     // DragTypeListBox
127     maLbDocs.SetSelectHdl( LINK( this, SdNavigatorWin, SelectDocumentHdl ) );
128     // set position below treelistbox
129     nListboxYPos = maTlbObjects.GetPosPixel().Y() + maTlbObjects.GetSizePixel().Height() + 4;
130     maLbDocs.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
131 
132     // assure that tool box is at least as wide as the tree list box
133     {
134         const Size aTlbSize( maTlbObjects.GetOutputSizePixel() );
135         if ( aTlbSize.Width() > aTbxSize.Width() )
136         {
137             maToolbox.SetPosSizePixel( 0, 0, aTlbSize.Width(), 0, WINDOW_POSSIZE_WIDTH );
138             aTbxSize = maToolbox.GetOutputSizePixel();
139         }
140     }
141 
142     // set min outputsize after all sizes are known
143     const long nFullHeight = nListboxYPos + maLbDocs.GetSizePixel().Height() + 4;
144     maSize = GetOutputSizePixel();
145     if( maSize.Height() < nFullHeight )
146     {
147         maSize.Height() = nFullHeight;
148         SetOutputSizePixel( maSize );
149     }
150     maMinSize = maSize;
151     const long nMinWidth = 2*maToolbox.GetPosPixel().X() + aTbxSize.Width(); // never clip the toolbox
152     if( nMinWidth > maMinSize.Width() )
153         maMinSize.Width() = nMinWidth;
154     maMinSize.Height() -= 40;
155     SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(GetParent());
156     if (pDockingParent != NULL)
157         pDockingParent->SetMinOutputSizePixel( maMinSize );
158 
159     // InitTlb; Wird ueber Slot initiiert
160     if (rUpdateRequest)
161         rUpdateRequest();
162 }
163 
164 // -----------------------------------------------------------------------
165 
166 SdNavigatorWin::~SdNavigatorWin()
167 {
168 	delete mpNavigatorCtrlItem;
169 	delete mpPageNameCtrlItem;
170 
171 	// Liste der DocInfos loeschen
172 	long nCount = mpDocList->Count();
173 	while( nCount-- )
174 		delete (NavDocInfo*) mpDocList->Remove( (sal_uLong)0 );
175 
176 	delete mpDocList;
177 }
178 
179 // -----------------------------------------------------------------------
180 
181 //IAccessibility2 Implementation 2009-----
182 //Solution: when object is marked , fresh the corresponding entry tree .
183 //==================================================
184 void SdNavigatorWin::FreshTree( const SdDrawDocument* pDoc )
185 {
186 	SdDrawDocument* pNonConstDoc = (SdDrawDocument*) pDoc; // const as const can...
187 	sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh();
188 	String aDocShName( pDocShell->GetName() );
189 	String aDocName = pDocShell->GetMedium()->GetName();
190 	maTlbObjects.SetSaveTreeItemStateFlag(sal_True); //Added by yanjun for sym2_6385
191 	maTlbObjects.Clear();
192 	maTlbObjects.Fill( pDoc, sal_False, aDocName ); // Nur normale Seiten
193 	maTlbObjects.SetSaveTreeItemStateFlag(sal_False); //Added by yanjun for sym2_6385
194 	RefreshDocumentLB();
195 	maLbDocs.SelectEntry( aDocShName );
196 }
197 void SdNavigatorWin::FreshEntry( )
198 {
199 	maTlbObjects.FreshCurEntry();
200 }
201 //==================================================
202 //-----IAccessibility2 Implementation 2009
203 void SdNavigatorWin::InitTreeLB( const SdDrawDocument* pDoc )
204 {
205 	SdDrawDocument* pNonConstDoc = (SdDrawDocument*) pDoc; // const as const can...
206 	::sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh();
207 	String aDocShName( pDocShell->GetName() );
208 	::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
209 
210     // Restore the 'ShowAllShapes' flag from the last time (in this session)
211     // that the navigator was shown.
212     if (pViewShell != NULL)
213     {
214         ::sd::FrameView* pFrameView = pViewShell->GetFrameView();
215         if (pFrameView != NULL)
216             maTlbObjects.SetShowAllShapes(pFrameView->IsNavigatorShowingAllShapes(), false);
217     }
218 
219     // Disable the shape filter drop down menu when there is a running slide
220     // show.
221 	if (pViewShell!=NULL && sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ))
222         maToolbox.EnableItem(TBI_SHAPE_FILTER, sal_False);
223     else
224         maToolbox.EnableItem(TBI_SHAPE_FILTER);
225 
226 	if( !maTlbObjects.IsEqualToDoc( pDoc ) )
227 	{
228 		String aDocName = pDocShell->GetMedium()->GetName();
229 		maTlbObjects.Clear();
230 		maTlbObjects.Fill( pDoc, (sal_Bool) sal_False, aDocName ); // Nur normale Seiten
231 
232 		RefreshDocumentLB();
233 		maLbDocs.SelectEntry( aDocShName );
234 	}
235 	else
236 	{
237 		maLbDocs.SetNoSelection();
238 		maLbDocs.SelectEntry( aDocShName );
239 
240 // auskommentiert um 30246 zu fixen
241 //		  if( maLbDocs.GetSelectEntryCount() == 0 )
242 		{
243 			RefreshDocumentLB();
244 			maLbDocs.SelectEntry( aDocShName );
245 		}
246 	}
247 
248 	SfxViewFrame* pViewFrame = ( ( pViewShell && pViewShell->GetViewFrame() ) ? pViewShell->GetViewFrame() : SfxViewFrame::Current() );
249 	if( pViewFrame )
250 		pViewFrame->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_True);
251 }
252 
253 /*************************************************************************
254 |*
255 |* DragType wird in Abhaengigkeit davon gesetzt, ob ein Drag ueberhaupt
256 |* moeglich ist. Graphiken duerfen beispielsweise unter gewissen Umstaenden
257 |* nicht gedragt werden (#31038#).
258 |*
259 \************************************************************************/
260 
261 NavigatorDragType SdNavigatorWin::GetNavigatorDragType()
262 {
263 	NavigatorDragType   eDT = meDragType;
264 	NavDocInfo*         pInfo = GetDocInfo();
265 
266 	if( ( eDT == NAVIGATOR_DRAGTYPE_LINK ) && ( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() ) )
267 		eDT = NAVIGATOR_DRAGTYPE_NONE;
268 
269 	return( eDT );
270 }
271 
272 // -----------------------------------------------------------------------
273 //IAccessibility2 Implementation 2009-----
274 //Solution: Get  SdDrawDocShell
275 sd::DrawDocShell* SdNavigatorWin::GetDrawDocShell( const SdDrawDocument* pDoc )
276 {
277 	if( !pDoc )
278 		return NULL; // const as const can...
279 	sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
280 	return pDocShell;
281 }
282 //-----IAccessibility2 Implementation 2009
283 
284 IMPL_LINK( SdNavigatorWin, SelectToolboxHdl, void *, EMPTYARG )
285 {
286 	sal_uInt16 nId = maToolbox.GetCurItemId();
287 	sal_uInt16 nSId = 0;
288 	PageJump ePage = PAGE_NONE;
289 
290 	switch( nId )
291 	{
292 		case TBI_PEN:
293 		{
294 			if( nId == TBI_PEN )
295 			{
296 				nSId = SID_NAVIGATOR_PEN;
297 			}
298 
299 			if( nSId > 0 )
300 			{
301 				SfxBoolItem aItem( nSId, sal_True );
302 				mpBindings->GetDispatcher()->Execute(
303 					nSId, SFX_CALLMODE_SLOT |SFX_CALLMODE_RECORD, &aItem, 0L );
304 			}
305 		}
306 		break;
307 
308 		case TBI_FIRST:
309 		case TBI_PREVIOUS:
310 		case TBI_NEXT:
311 		case TBI_LAST:
312 		{
313 			if( nId == TBI_FIRST )
314 				ePage = PAGE_FIRST;
315 			else if( nId == TBI_PREVIOUS )
316 				ePage = PAGE_PREVIOUS;
317 			else if( nId == TBI_NEXT )
318 				ePage = PAGE_NEXT;
319 			else if( nId == TBI_LAST )
320 				ePage = PAGE_LAST;
321 
322 			if( ePage != PAGE_NONE )
323 			{
324 				SfxUInt16Item aItem( SID_NAVIGATOR_PAGE, (sal_uInt16)ePage );
325 				mpBindings->GetDispatcher()->Execute(
326 					SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L );
327 			}
328 		}
329 		break;
330 	}
331 	return 0;
332 }
333 
334 // -----------------------------------------------------------------------
335 
336 
337 IMPL_LINK( SdNavigatorWin, ClickToolboxHdl, ToolBox*, EMPTYARG )
338 {
339 	return 0;
340 }
341 
342 // -----------------------------------------------------------------------
343 
344 IMPL_LINK( SdNavigatorWin, DropdownClickToolBoxHdl, ToolBox*, pBox )
345 {
346 	sal_uInt16 nId = maToolbox.GetCurItemId();
347 
348 	switch( nId )
349 	{
350 		case TBI_DRAGTYPE:
351 		{
352 			// Popup-Menu wird in Abhaengigkeit davon erzeugt, ob Dokument
353 			// gespeichert ist oder nicht
354 			PopupMenu *pMenu = new PopupMenu;
355 
356             static const char* aHIDs[] =
357             {
358                  HID_SD_NAVIGATOR_MENU1,
359                  HID_SD_NAVIGATOR_MENU2,
360                  HID_SD_NAVIGATOR_MENU3,
361                  0
362             };
363 
364 			for( sal_uInt16 nID = NAVIGATOR_DRAGTYPE_URL;
365 				 nID < NAVIGATOR_DRAGTYPE_COUNT;
366 				 nID++ )
367 			{
368 				sal_uInt16 nRId = GetDragTypeSdResId( (NavigatorDragType)nID );
369 				if( nRId > 0 )
370 				{
371                     DBG_ASSERT(aHIDs[nID-NAVIGATOR_DRAGTYPE_URL],"HelpId not added!");
372 					pMenu->InsertItem( nID, String( SdResId( nRId ) ) );
373 					pMenu->SetHelpId( nID, aHIDs[nID - NAVIGATOR_DRAGTYPE_URL] );
374 				}
375 
376 			}
377 			NavDocInfo* pInfo = GetDocInfo();
378 
379 			if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() )
380 			{
381 				pMenu->EnableItem( NAVIGATOR_DRAGTYPE_LINK, sal_False );
382 				pMenu->EnableItem( NAVIGATOR_DRAGTYPE_URL, sal_False );
383 				meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
384 			}
385 
386 			pMenu->CheckItem( (sal_uInt16)meDragType );
387 			pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, MenuSelectHdl ) );
388 
389 			pMenu->Execute( this, maToolbox.GetItemRect( nId ), POPUPMENU_EXECUTE_DOWN );
390 			pBox->EndSelection();
391 			delete pMenu;
392 		}
393 		break;
394 
395 		case TBI_SHAPE_FILTER:
396 		{
397 			PopupMenu *pMenu = new PopupMenu;
398 
399             pMenu->InsertItem(
400                 nShowNamedShapesFilter,
401                 String(SdResId(STR_NAVIGATOR_SHOW_NAMED_SHAPES)));
402             pMenu->InsertItem(
403                 nShowAllShapesFilter,
404                 String(SdResId(STR_NAVIGATOR_SHOW_ALL_SHAPES)));
405 
406             if (maTlbObjects.GetShowAllShapes())
407                 pMenu->CheckItem(nShowAllShapesFilter);
408             else
409                 pMenu->CheckItem(nShowNamedShapesFilter);
410 			pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, ShapeFilterCallback ) );
411 
412 			pMenu->Execute( this, maToolbox.GetItemRect( nId ), POPUPMENU_EXECUTE_DOWN );
413 			pBox->EndSelection();
414 			delete pMenu;
415 		}
416 		break;
417 	}
418 	return 0;
419 }
420 
421 // -----------------------------------------------------------------------
422 
423 IMPL_LINK( SdNavigatorWin, ClickObjectHdl, void *, EMPTYARG )
424 {
425 	if( !mbDocImported || maLbDocs.GetSelectEntryPos() != 0 )
426 	{
427 		NavDocInfo* pInfo = GetDocInfo();
428 
429 		// Nur wenn es sich um das aktive Fenster handelt, wird
430 		// auf die Seite gesprungen
431 		if( pInfo && pInfo->IsActive() )
432 		{
433 			String aStr( maTlbObjects.GetSelectEntry() );
434 
435 			if( aStr.Len() > 0 )
436 			{
437 				SfxStringItem aItem( SID_NAVIGATOR_OBJECT, aStr );
438 				mpBindings->GetDispatcher()->Execute(
439 					SID_NAVIGATOR_OBJECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L );
440 //IAccessibility2 Implementation 2009-----
441 				//Solution: set sign variable
442 				maTlbObjects.MarkCurEntry(aStr);
443 //-----IAccessibility2 Implementation 2009
444 
445                 // #98821# moved here from SetGetFocusHdl. Reset the
446                 // focus only if something has been selected in the
447                 // document.
448                 SfxViewShell* pCurSh = SfxViewShell::Current();
449 
450                 if ( pCurSh )
451                 {
452                     Window* pShellWnd = pCurSh->GetWindow();
453                     if ( pShellWnd )
454                         pShellWnd->GrabFocus();
455                 }
456 			}
457 		}
458 	}
459 	return( 0L );
460 }
461 
462 // -----------------------------------------------------------------------
463 
464 IMPL_LINK( SdNavigatorWin, SelectDocumentHdl, void *, EMPTYARG )
465 {
466 	String aStrLb = maLbDocs.GetSelectEntry();
467 	long   nPos = maLbDocs.GetSelectEntryPos();
468 	sal_Bool   bFound = sal_False;
469 	::sd::DrawDocShell* pDocShell = NULL;
470 	NavDocInfo* pInfo = GetDocInfo();
471 
472 	// Handelt es sich um ein gedragtes Objekt?
473 	if( mbDocImported && nPos == 0 )
474 	{
475 		// Dokument in TLB aufbauen
476 		InsertFile( aStrLb );
477 	}
478 	else if (pInfo)
479 	{
480 		pDocShell = pInfo->mpDocShell;
481 
482 		bFound = sal_True;
483 	}
484 
485 	if( bFound )
486 	{
487 		SdDrawDocument* pDoc = pDocShell->GetDoc();
488 		if( !maTlbObjects.IsEqualToDoc( pDoc ) )
489 		{
490 			SdDrawDocument* pNonConstDoc = (SdDrawDocument*) pDoc; // const as const can...
491 			::sd::DrawDocShell* pNCDocShell = pNonConstDoc->GetDocSh();
492 			String aDocName = pNCDocShell->GetMedium()->GetName();
493 			maTlbObjects.Clear();
494 			maTlbObjects.Fill( pDoc, (sal_Bool) sal_False, aDocName ); // Nur normale Seiten
495 		}
496 	}
497 
498 	// Pruefen, ob Link oder URL moeglich ist
499 	if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() || ( meDragType != NAVIGATOR_DRAGTYPE_EMBEDDED ) )
500 	{
501 		meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
502 		SetDragImage();
503 	}
504 
505 	return( 0L );
506 }
507 
508 /*************************************************************************
509 |*
510 |* DrageType wird gesetzt und Image wird entspr. gesetzt.
511 |* Sollte Handler mit NULL gerufen werden, so wird der Default (URL) gesetzt.
512 |*
513 \************************************************************************/
514 
515 IMPL_LINK( SdNavigatorWin, MenuSelectHdl, Menu *, pMenu )
516 {
517 	sal_uInt16 nMenuId;
518 	if( pMenu )
519 		nMenuId = pMenu->GetCurItemId();
520 	else
521 		nMenuId = NAVIGATOR_DRAGTYPE_URL;
522 
523 	if( nMenuId != USHRT_MAX ) // Notwendig ?
524 	{
525 		NavigatorDragType eDT = (NavigatorDragType) nMenuId;
526 		if( meDragType != eDT )
527 		{
528 			meDragType = eDT;
529 			SetDragImage();
530 
531 			if( meDragType == NAVIGATOR_DRAGTYPE_URL )
532 			{
533 				// Fix, um Endlosschleife zu unterbinden
534 				if( maTlbObjects.GetSelectionCount() > 1 )
535 					maTlbObjects.SelectAll( sal_False );
536 
537 				maTlbObjects.SetSelectionMode( SINGLE_SELECTION );
538 			}
539 			else
540 				maTlbObjects.SetSelectionMode( MULTIPLE_SELECTION );
541 		}
542 	}
543 	return( 0 );
544 }
545 
546 
547 
548 
549 IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, Menu *, pMenu )
550 {
551 	if (pMenu != NULL)
552     {
553         bool bShowAllShapes (maTlbObjects.GetShowAllShapes());
554         sal_uInt16 nMenuId (pMenu->GetCurItemId());
555         switch (nMenuId)
556         {
557             case nShowNamedShapesFilter:
558                 bShowAllShapes = false;
559                 break;
560 
561             case nShowAllShapesFilter:
562                 bShowAllShapes = true;
563                 break;
564 
565             default:
566                 OSL_ENSURE(
567                     false, "SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
568                 break;
569         }
570 
571         maTlbObjects.SetShowAllShapes(bShowAllShapes, true);
572 
573         // Remember the selection in the FrameView.
574         NavDocInfo* pInfo = GetDocInfo();
575         if (pInfo != NULL)
576         {
577             ::sd::DrawDocShell* pDocShell = pInfo->mpDocShell;
578             if (pDocShell != NULL)
579             {
580                 ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
581                 if (pViewShell != NULL)
582                 {
583                     ::sd::FrameView* pFrameView = pViewShell->GetFrameView();
584                     if (pFrameView != NULL)
585                     {
586                         pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes);
587                     }
588                 }
589             }
590         }
591 	}
592 
593 	return 0;
594 }
595 
596 // -----------------------------------------------------------------------
597 
598 void SdNavigatorWin::Resize()
599 {
600 	Size aWinSize( GetOutputSizePixel() );
601 	if( aWinSize.Height() >= maMinSize.Height() )
602 		//aWinSize.Width() >= maMinSize.Width() )
603 	{
604 		Size aDiffSize;
605 		aDiffSize.Width() = aWinSize.Width() - maSize.Width();
606 		aDiffSize.Height() = aWinSize.Height() - maSize.Height();
607 
608 		// Umgroessern der Toolbox
609 		Size aObjSize( maToolbox.GetOutputSizePixel() );
610 		aObjSize.Width() += aDiffSize.Width();
611 		maToolbox.SetOutputSizePixel( aObjSize );
612 
613 		// Umgroessern der TreeLB
614 		aObjSize = maTlbObjects.Control::GetOutputSizePixel();
615 		aObjSize.Width() += aDiffSize.Width();
616 		aObjSize.Height() += aDiffSize.Height();
617 		maTlbObjects.SetOutputSizePixel( aObjSize );
618 
619 		Point aPt( 0, aDiffSize.Height() );
620 
621 		// Verschieben der anderen Controls (DocumentLB)
622 		maLbDocs.Hide();
623 		aObjSize = maLbDocs.GetOutputSizePixel();
624 		aObjSize.Width() += aDiffSize.Width();
625 		maLbDocs.SetPosPixel( maLbDocs.GetPosPixel() + aPt );
626 		maLbDocs.SetOutputSizePixel( aObjSize );
627 		maLbDocs.Show();
628 
629 		maSize = aWinSize;
630 	}
631 	Window::Resize();
632 }
633 
634 // -----------------------------------------------------------------------
635 
636 sal_Bool SdNavigatorWin::InsertFile(const String& rFileName)
637 {
638 	INetURLObject	aURL( rFileName );
639 	sal_Bool			bReturn = sal_True;
640 
641 	if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
642 	{
643 		String aURLStr;
644 		::utl::LocalFileHelper::ConvertPhysicalNameToURL( rFileName, aURLStr );
645 		aURL = INetURLObject( aURLStr );
646 	}
647 
648 	// get adjusted FileName
649 	String aFileName( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
650 
651 	if (!aFileName.Len())
652 	{
653 		/**********************************************************************
654 		* Wieder aktuelles Dokument anzeigen
655 		**********************************************************************/
656 		maDropFileName = aFileName;
657 	}
658 	else
659 	{
660 		/**********************************************************************
661 		* Hineingedraggtes Dokument anzeigen
662 		**********************************************************************/
663 		const SfxFilter* pFilter = NULL;
664 		ErrCode nErr = 0;
665 
666 		if (aFileName != maDropFileName)
667 		{
668 			SfxMedium aMed(aFileName, (STREAM_READ | STREAM_SHARE_DENYNONE), sal_False);
669 			SfxFilterMatcher aMatch( String::CreateFromAscii("simpress") );
670             aMed.UseInteractionHandler( sal_True );
671 			nErr = aMatch.GuessFilter(aMed, &pFilter);
672 		}
673 
674 		if ((pFilter && !nErr) || aFileName == maDropFileName)
675 		{
676 			// Das Medium muss ggf. mit READ/WRITE geoeffnet werden, daher wird
677 			// ersteinmal nachgeschaut, ob es einen Storage enthaelt
678 			SfxMedium* pMedium = new SfxMedium( aFileName,
679 												STREAM_READ | STREAM_NOCREATE,
680 												sal_True);				  // Download
681 
682 			if (pMedium->IsStorage())
683 			{
684 				// Jetzt modusabhaengig:
685 				// maTlbObjects.SetSelectionMode(MULTIPLE_SELECTION);
686 				// Eigentuemeruebergabe von pMedium;
687 				SdDrawDocument* pDropDoc = maTlbObjects.GetBookmarkDoc(pMedium);
688 
689 				if (pDropDoc)
690 				{
691 					maTlbObjects.Clear();
692 					maDropFileName = aFileName;
693 
694 					if( !maTlbObjects.IsEqualToDoc( pDropDoc ) )
695 					{
696 						// Nur normale Seiten
697 						maTlbObjects.Fill(pDropDoc, (sal_Bool) sal_False, maDropFileName);
698 						RefreshDocumentLB( &maDropFileName );
699 					}
700 				}
701 			}
702 			else
703 			{
704 				bReturn = sal_False;
705 				delete pMedium;
706 			}
707 		}
708 		else
709 		{
710 			bReturn = sal_False;
711 		}
712 	}
713 
714 	return (bReturn);
715 }
716 
717 // -----------------------------------------------------------------------
718 
719 void SdNavigatorWin::RefreshDocumentLB( const String* pDocName )
720 {
721 	sal_uInt16 nPos = 0;
722 
723 	if( pDocName )
724 	{
725 		if( mbDocImported )
726 			maLbDocs.RemoveEntry( 0 );
727 
728 		maLbDocs.InsertEntry( *pDocName, 0 );
729 		mbDocImported = sal_True;
730 	}
731 	else
732 	{
733 		nPos = maLbDocs.GetSelectEntryPos();
734 		if( nPos == LISTBOX_ENTRY_NOTFOUND )
735 			nPos = 0;
736 
737 		String aStr;
738 		if( mbDocImported )
739 			aStr = maLbDocs.GetEntry( 0 );
740 
741 		maLbDocs.Clear();
742 
743 		// Liste der DocInfos loeschen
744 		long nCount = mpDocList->Count();
745 		while( nCount-- )
746 			delete (NavDocInfo*) mpDocList->Remove( (sal_uLong)0 );
747 
748 		if( mbDocImported )
749 			maLbDocs.InsertEntry( aStr, 0 );
750 
751 		::sd::DrawDocShell* pCurrentDocShell =
752               PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
753 		SfxObjectShell* pSfxDocShell = SfxObjectShell::GetFirst(0, sal_False);
754 		while( pSfxDocShell )
755 		{
756 			::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, pSfxDocShell );
757 			if( pDocShell  && !pDocShell->IsInDestruction() && ( pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) )
758 			{
759 				NavDocInfo* pInfo = new NavDocInfo();
760 				pInfo->mpDocShell = pDocShell;
761 
762 				aStr = pDocShell->GetMedium()->GetName();
763 				if( aStr.Len() )
764 					pInfo->SetName();
765 				else
766 					pInfo->SetName( sal_False );
767 				// z.Z. wird wieder der Name der Shell genommen (also ohne Pfad)
768 				// da Koose es als Fehler ansieht, wenn er Pfad in URL-Notation
769 				// angezeigt wird!
770 				aStr = pDocShell->GetName();
771 
772 				maLbDocs.InsertEntry( aStr, LISTBOX_APPEND );
773 
774 				//
775 				if( pDocShell == pCurrentDocShell )
776 					pInfo->SetActive();
777 				else
778 					pInfo->SetActive( sal_False );
779 
780 				mpDocList->Insert( pInfo, LIST_APPEND );
781 			}
782 			pSfxDocShell = SfxObjectShell::GetNext( *pSfxDocShell, 0 , sal_False );
783 		}
784 	}
785 	maLbDocs.SelectEntryPos( nPos );
786 }
787 
788 //------------------------------------------------------------------------
789 
790 sal_uInt16 SdNavigatorWin::GetDragTypeSdResId( NavigatorDragType eDT, sal_Bool bImage )
791 {
792 	switch( eDT )
793 	{
794 		case NAVIGATOR_DRAGTYPE_NONE:
795 				return( bImage ? 0 : STR_NONE );
796 		case NAVIGATOR_DRAGTYPE_URL:
797 				return( bImage ? TBI_HYPERLINK : STR_DRAGTYPE_URL );
798 		case NAVIGATOR_DRAGTYPE_EMBEDDED:
799 				return( bImage ? TBI_EMBEDDED : STR_DRAGTYPE_EMBEDDED );
800 		case NAVIGATOR_DRAGTYPE_LINK:
801 				return( bImage ? TBI_LINK : STR_DRAGTYPE_LINK );
802 		default: DBG_ERROR( "Keine Resource fuer DragType vorhanden!" );
803 	}
804 	return( 0 );
805 }
806 
807 //------------------------------------------------------------------------
808 
809 NavDocInfo* SdNavigatorWin::GetDocInfo()
810 {
811 	long nPos = maLbDocs.GetSelectEntryPos();
812 
813 	if( mbDocImported )
814 	{
815 		if( nPos == 0 )
816 		{
817 			return( NULL );
818 		}
819 		nPos--;
820 	}
821 
822 	NavDocInfo* pInfo = (NavDocInfo*)mpDocList->GetObject( nPos );
823 
824 	return( pInfo );
825 }
826 
827 /*************************************************************************
828 |*
829 |* PreNotify
830 |*
831 \************************************************************************/
832 
833 long SdNavigatorWin::Notify(NotifyEvent& rNEvt)
834 {
835 	const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
836 	long			nOK = sal_False;
837 
838 	if( pKEvt )
839 	{
840 		if( KEY_ESCAPE == pKEvt->GetKeyCode().GetCode() )
841 		{
842 			if( SdPageObjsTLB::IsInDrag() )
843 			{
844 				// during drag'n'drop we just stop the drag but do not close the navigator
845 				nOK = sal_True;
846 			}
847 			else
848 			{
849                 ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame());
850                 if( pBase )
851                 {
852                     sd::SlideShow::Stop( *pBase );
853                     // Stopping the slide show may result in a synchronous
854                     // deletion of the navigator window.  Calling the
855                     // parents Notify after this is unsafe.  Therefore we
856                     // return now.
857                     return sal_True;
858                 }
859             }
860         }
861     }
862 
863     if( !nOK )
864 		nOK = Window::Notify( rNEvt );
865 
866 	return( nOK );
867 }
868 
869 
870 /*************************************************************************
871 |*
872 |* KeyInput: ESCAPE abfangen, um Show zu beenden
873 |*
874 \************************************************************************/
875 
876 void SdNavigatorWin::KeyInput( const KeyEvent& rKEvt )
877 {
878 	long nOK = sal_False;
879 
880 	if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
881 	{
882 		if( SdPageObjsTLB::IsInDrag() )
883 		{
884 			// during drag'n'drop we just stop the drag but do not close the navigator
885 			nOK = sal_True;
886 		}
887 		else
888 		{
889             ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame());
890 			if(pBase)
891 			{
892 				::sd::SlideShow::Stop( *pBase );
893 			}
894 		}
895 	}
896 
897 	if (!nOK)
898 	{
899 		Window::KeyInput(rKEvt);
900 	}
901 }
902 
903 void SdNavigatorWin::DataChanged( const DataChangedEvent& rDCEvt )
904 {
905 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
906             ApplyImageList();
907 
908     Window::DataChanged( rDCEvt );
909 }
910 
911 void SdNavigatorWin::SetDragImage()
912 {
913 	maToolbox.SetItemImage( TBI_DRAGTYPE, maToolbox.GetImageList().GetImage( GetDragTypeSdResId( meDragType, sal_True ) ) );
914 }
915 
916 void SdNavigatorWin::ApplyImageList()
917 {
918 	const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
919 
920 	maToolbox.SetImageList( bHighContrast ? maImageListH : maImageList );
921 
922     maToolbox.SetItemImage(TBI_SHAPE_FILTER, BitmapEx(SdResId( bHighContrast ? BMP_GRAPHIC_H : BMP_GRAPHIC)));
923 
924 	SetDragImage();
925 }
926 
927 
928 
929 /*************************************************************************
930 |*
931 |* ControllerItem fuer Navigator
932 |*
933 \************************************************************************/
934 
935 SdNavigatorControllerItem::SdNavigatorControllerItem(
936     sal_uInt16 _nId,
937     SdNavigatorWin* pNavWin,
938     SfxBindings*	_pBindings,
939     const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest)
940     : SfxControllerItem( _nId, *_pBindings ),
941       pNavigatorWin( pNavWin ),
942       maUpdateRequest(rUpdateRequest)
943 {
944 }
945 
946 // -----------------------------------------------------------------------
947 
948 void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId,
949 						SfxItemState eState, const SfxPoolItem* pItem )
950 {
951 	if( eState >= SFX_ITEM_AVAILABLE && nSId == SID_NAVIGATOR_STATE )
952 	{
953 		const SfxUInt32Item* pStateItem = PTR_CAST( SfxUInt32Item, pItem );
954 		DBG_ASSERT( pStateItem, "SfxUInt16Item erwartet");
955 		sal_uInt32 nState = pStateItem->GetValue();
956 
957 		// Stift
958 		if( nState & NAVBTN_PEN_ENABLED &&
959 			!pNavigatorWin->maToolbox.IsItemEnabled( TBI_PEN ) )
960 			pNavigatorWin->maToolbox.EnableItem( TBI_PEN );
961 		if( nState & NAVBTN_PEN_DISABLED &&
962 			pNavigatorWin->maToolbox.IsItemEnabled( TBI_PEN ) )
963 			pNavigatorWin->maToolbox.EnableItem( TBI_PEN, sal_False );
964 		if( nState & NAVBTN_PEN_CHECKED &&
965 			!pNavigatorWin->maToolbox.IsItemChecked( TBI_PEN ) )
966 			pNavigatorWin->maToolbox.CheckItem( TBI_PEN );
967 		if( nState & NAVBTN_PEN_UNCHECKED &&
968 			pNavigatorWin->maToolbox.IsItemChecked( TBI_PEN ) )
969 			pNavigatorWin->maToolbox.CheckItem( TBI_PEN, sal_False );
970 
971 		// Nur wenn Doc in LB das Aktive ist
972 		NavDocInfo* pInfo = pNavigatorWin->GetDocInfo();
973 		if( pInfo && pInfo->IsActive() )
974 		{
975 			// First
976 			if( nState & NAVBTN_FIRST_ENABLED &&
977 				!pNavigatorWin->maToolbox.IsItemEnabled( TBI_FIRST ) )
978 				pNavigatorWin->maToolbox.EnableItem( TBI_FIRST );
979 			if( nState & NAVBTN_FIRST_DISABLED &&
980 				pNavigatorWin->maToolbox.IsItemEnabled( TBI_FIRST ) )
981 				pNavigatorWin->maToolbox.EnableItem( TBI_FIRST, sal_False );
982 
983 			// Prev
984 			if( nState & NAVBTN_PREV_ENABLED &&
985 				!pNavigatorWin->maToolbox.IsItemEnabled( TBI_PREVIOUS ) )
986 				pNavigatorWin->maToolbox.EnableItem( TBI_PREVIOUS );
987 			if( nState & NAVBTN_PREV_DISABLED &&
988 				pNavigatorWin->maToolbox.IsItemEnabled( TBI_PREVIOUS ) )
989 				pNavigatorWin->maToolbox.EnableItem( TBI_PREVIOUS, sal_False );
990 
991 			// Last
992 			if( nState & NAVBTN_LAST_ENABLED &&
993 				!pNavigatorWin->maToolbox.IsItemEnabled( TBI_LAST ) )
994 				pNavigatorWin->maToolbox.EnableItem( TBI_LAST );
995 			if( nState & NAVBTN_LAST_DISABLED &&
996 				pNavigatorWin->maToolbox.IsItemEnabled( TBI_LAST ) )
997 				pNavigatorWin->maToolbox.EnableItem( TBI_LAST, sal_False );
998 
999 			// Next
1000 			if( nState & NAVBTN_NEXT_ENABLED &&
1001 				!pNavigatorWin->maToolbox.IsItemEnabled( TBI_NEXT ) )
1002 				pNavigatorWin->maToolbox.EnableItem( TBI_NEXT );
1003 			if( nState & NAVBTN_NEXT_DISABLED &&
1004 				pNavigatorWin->maToolbox.IsItemEnabled( TBI_NEXT ) )
1005 				pNavigatorWin->maToolbox.EnableItem( TBI_NEXT, sal_False );
1006 
1007 			if( nState & NAVTLB_UPDATE )
1008 			{
1009 				// InitTlb; Wird ueber Slot initiiert
1010                 if (maUpdateRequest)
1011                     maUpdateRequest();
1012 			}
1013 		}
1014 	}
1015 }
1016 
1017 /*************************************************************************
1018 |*
1019 |* ControllerItem fuer Navigator, um die Seite in der TreeLB anzuzeigen
1020 |*
1021 \************************************************************************/
1022 
1023 SdPageNameControllerItem::SdPageNameControllerItem(
1024     sal_uInt16 _nId,
1025     SdNavigatorWin* pNavWin,
1026     SfxBindings*	_pBindings,
1027     const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest)
1028 	: SfxControllerItem( _nId, *_pBindings ),
1029       pNavigatorWin( pNavWin ),
1030       maUpdateRequest(rUpdateRequest)
1031 {
1032 }
1033 
1034 // -----------------------------------------------------------------------
1035 
1036 void SdPageNameControllerItem::StateChanged( sal_uInt16 nSId,
1037 						SfxItemState eState, const SfxPoolItem* pItem )
1038 {
1039 	if( eState >= SFX_ITEM_AVAILABLE && nSId == SID_NAVIGATOR_PAGENAME )
1040 	{
1041 		// Nur wenn Doc in LB das Aktive ist
1042 		NavDocInfo* pInfo = pNavigatorWin->GetDocInfo();
1043 		if( pInfo && pInfo->IsActive() )
1044 		{
1045 			const SfxStringItem* pStateItem = PTR_CAST( SfxStringItem, pItem );
1046 			DBG_ASSERT( pStateItem, "SfxStringItem erwartet");
1047 			String aPageName = pStateItem->GetValue();
1048 
1049 			if( !pNavigatorWin->maTlbObjects.HasSelectedChilds( aPageName ) )
1050 			{
1051 				if( pNavigatorWin->maTlbObjects.GetSelectionMode() == MULTIPLE_SELECTION )
1052 				{
1053 					// Weil sonst immer dazuselektiert wird
1054 					pNavigatorWin->maTlbObjects.SelectAll( sal_False );
1055 				}
1056 				pNavigatorWin->maTlbObjects.SelectEntry( aPageName );
1057 			}
1058 		}
1059 	}
1060 }
1061