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