1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: navigatr.cxx,v $
10 * $Revision: 1.40.70.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <tools/urlobj.hxx>
36 #include <unotools/localfilehelper.hxx>
37 #include <sfx2/imgmgr.hxx>
38 #include <sfx2/fcontnr.hxx>
39 #include <svtools/eitem.hxx>
40 #include <svtools/stritem.hxx>
41 #include <sfx2/docfilt.hxx>
42 #include <sfx2/docfile.hxx>
43 #include <svtools/intitem.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <svx/svxids.hrc>
46 #include <vcl/menu.hxx>
48 #include <sfx2/viewfrm.hxx>
49 #include <sfx2/dockwin.hxx>
52 #include "navigatr.hxx"
53 //#include "navichld.hxx"
54 #include "navigatr.hrc"
57 #include "strings.hrc"
58 #include "res_bmp.hrc"
59 #include "drawdoc.hxx"
60 #include "DrawDocShell.hxx"
61 #include "sdresid.hxx"
62 #include "ViewShell.hxx"
63 #include "ViewShellBase.hxx"
64 #include "DrawViewShell.hxx"
65 #include "slideshow.hxx"
66 #include "FrameView.hxx"
70 static const sal_uInt16 nShowNamedShapesFilter
=1;
71 static const sal_uInt16 nShowAllShapesFilter
=2;
74 /*************************************************************************
75 |* SdNavigatorWin - FloatingWindow
76 \************************************************************************/
78 SdNavigatorWin::SdNavigatorWin(
80 ::sd::NavigatorChildWindow
* pChWinCtxt
,
81 const SdResId
& rSdResId
,
82 SfxBindings
* pInBindings
)
83 : ::Window( pParent
, rSdResId
)
84 , maToolbox ( this, SdResId( 1 ) )
85 , maTlbObjects( this, SdResId( TLB_OBJECTS
) )
86 , maLbDocs ( this, SdResId( LB_DOCS
) )
87 , mpChildWinContext( pChWinCtxt
)
88 , mbDocImported ( FALSE
)
89 // Bei Aenderung des DragTypes: SelectionMode der TLB anpassen!
90 , meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED
)
91 , mpBindings ( pInBindings
)
92 , maImageList ( SdResId( IL_NAVIGATR
) )
93 , maImageListH ( SdResId( ILH_NAVIGATR
) )
95 maTlbObjects
.SetViewFrame( mpBindings
->GetDispatcher()->GetFrame() );
99 mpNavigatorCtrlItem
= new SdNavigatorControllerItem( SID_NAVIGATOR_STATE
, this, mpBindings
);
100 mpPageNameCtrlItem
= new SdPageNameControllerItem( SID_NAVIGATOR_PAGENAME
, this, mpBindings
);
101 mpDocList
= new List();
103 ApplyImageList(); // load images *before* calculating sizes to get something useful !!!
105 Size
aTbxSize( maToolbox
.CalcWindowSizePixel() );
106 maToolbox
.SetOutputSizePixel( aTbxSize
);
107 maToolbox
.SetSelectHdl( LINK( this, SdNavigatorWin
, SelectToolboxHdl
) );
108 maToolbox
.SetClickHdl( LINK( this, SdNavigatorWin
, ClickToolboxHdl
) );
109 maToolbox
.SetDropdownClickHdl( LINK(this, SdNavigatorWin
, DropdownClickToolBoxHdl
) );
110 maToolbox
.SetItemBits( TBI_DRAGTYPE
, maToolbox
.GetItemBits( TBI_DRAGTYPE
) | TIB_DROPDOWNONLY
);
112 // Shape filter drop down menu.
113 maToolbox
.SetItemBits(TBI_SHAPE_FILTER
,
114 maToolbox
.GetItemBits(TBI_SHAPE_FILTER
) | TIB_DROPDOWNONLY
);
117 // set position below toolbox
118 long nListboxYPos
= maToolbox
.GetPosPixel().Y() + maToolbox
.GetSizePixel().Height() + 4;
119 maTlbObjects
.SetPosSizePixel( 0, nListboxYPos
, 0, 0, WINDOW_POSSIZE_Y
);
120 maTlbObjects
.SetDoubleClickHdl( LINK( this, SdNavigatorWin
, ClickObjectHdl
) );
121 maTlbObjects
.SetSelectionMode( SINGLE_SELECTION
);
122 // set focus to listbox, otherwise it is in the toolbox which is only useful
123 // for keyboard navigation
124 maTlbObjects
.GrabFocus();
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
);
132 // set min outputsize after all sizes are known
133 long nFullHeight
= nListboxYPos
+ maLbDocs
.GetSizePixel().Height() + 4;
134 maSize
= GetOutputSizePixel();
135 if( maSize
.Height() < nFullHeight
)
137 maSize
.Height() = nFullHeight
;
138 SetOutputSizePixel( maSize
);
141 long nMinWidth
= 2*maToolbox
.GetPosPixel().X() + aTbxSize
.Width(); // never clip the toolbox
142 if( nMinWidth
> maMinSize
.Width() )
143 maMinSize
.Width() = nMinWidth
;
144 maMinSize
.Height() -= 40;
145 ((SfxDockingWindow
*)GetParent())->SetMinOutputSizePixel( maMinSize
);
147 // InitTlb; Wird ueber Slot initiiert
148 SfxBoolItem
aItem( SID_NAVIGATOR_INIT
, TRUE
);
149 mpBindings
->GetDispatcher()->Execute(
150 SID_NAVIGATOR_INIT
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
154 // -----------------------------------------------------------------------
156 SdNavigatorWin::~SdNavigatorWin()
158 delete mpNavigatorCtrlItem
;
159 delete mpPageNameCtrlItem
;
161 // Liste der DocInfos loeschen
162 long nCount
= mpDocList
->Count();
164 delete (NavDocInfo
*) mpDocList
->Remove( (ULONG
)0 );
169 // -----------------------------------------------------------------------
171 void SdNavigatorWin::InitTreeLB( const SdDrawDocument
* pDoc
)
173 SdDrawDocument
* pNonConstDoc
= (SdDrawDocument
*) pDoc
; // const as const can...
174 ::sd::DrawDocShell
* pDocShell
= pNonConstDoc
->GetDocSh();
175 String
aDocShName( pDocShell
->GetName() );
176 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
178 // Restore the 'ShowAllShapes' flag from the last time (in this session)
179 // that the navigator was shown.
180 if (pViewShell
!= NULL
)
182 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
183 if (pFrameView
!= NULL
)
184 maTlbObjects
.SetShowAllShapes(pFrameView
->IsNavigatorShowingAllShapes(), false);
187 // Disable the shape filter drop down menu when there is a running slide
189 if (pViewShell
!=NULL
&& sd::SlideShow::IsRunning( pViewShell
->GetViewShellBase() ))
190 maToolbox
.EnableItem(TBI_SHAPE_FILTER
, FALSE
);
192 maToolbox
.EnableItem(TBI_SHAPE_FILTER
);
194 if( !maTlbObjects
.IsEqualToDoc( pDoc
) )
196 String aDocName
= pDocShell
->GetMedium()->GetName();
197 maTlbObjects
.Clear();
198 maTlbObjects
.Fill( pDoc
, (BOOL
) FALSE
, aDocName
); // Nur normale Seiten
201 maLbDocs
.SelectEntry( aDocShName
);
205 maLbDocs
.SetNoSelection();
206 maLbDocs
.SelectEntry( aDocShName
);
208 // auskommentiert um 30246 zu fixen
209 // if( maLbDocs.GetSelectEntryCount() == 0 )
212 maLbDocs
.SelectEntry( aDocShName
);
216 SfxViewFrame
* pViewFrame
= ( ( pViewShell
&& pViewShell
->GetViewFrame() ) ? pViewShell
->GetViewFrame() : SfxViewFrame::Current() );
218 pViewFrame
->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME
, TRUE
, TRUE
);
221 /*************************************************************************
223 |* DragType wird in Abhaengigkeit davon gesetzt, ob ein Drag ueberhaupt
224 |* moeglich ist. Graphiken duerfen beispielsweise unter gewissen Umstaenden
225 |* nicht gedragt werden (#31038#).
227 \************************************************************************/
229 NavigatorDragType
SdNavigatorWin::GetNavigatorDragType()
231 NavigatorDragType eDT
= meDragType
;
232 NavDocInfo
* pInfo
= GetDocInfo();
234 if( ( eDT
== NAVIGATOR_DRAGTYPE_LINK
) && ( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
.IsLinkableSelected() ) )
235 eDT
= NAVIGATOR_DRAGTYPE_NONE
;
240 // -----------------------------------------------------------------------
243 IMPL_LINK( SdNavigatorWin
, SelectToolboxHdl
, void *, EMPTYARG
)
245 USHORT nId
= maToolbox
.GetCurItemId();
247 PageJump ePage
= PAGE_NONE
;
255 nSId
= SID_NAVIGATOR_PEN
;
260 SfxBoolItem
aItem( nSId
, TRUE
);
261 mpBindings
->GetDispatcher()->Execute(
262 nSId
, SFX_CALLMODE_SLOT
|SFX_CALLMODE_RECORD
, &aItem
, 0L );
272 if( nId
== TBI_FIRST
)
274 else if( nId
== TBI_PREVIOUS
)
275 ePage
= PAGE_PREVIOUS
;
276 else if( nId
== TBI_NEXT
)
278 else if( nId
== TBI_LAST
)
281 if( ePage
!= PAGE_NONE
)
283 SfxUInt16Item
aItem( SID_NAVIGATOR_PAGE
, (UINT16
)ePage
);
284 mpBindings
->GetDispatcher()->Execute(
285 SID_NAVIGATOR_PAGE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
293 // -----------------------------------------------------------------------
296 IMPL_LINK( SdNavigatorWin
, ClickToolboxHdl
, ToolBox
*, EMPTYARG
)
301 // -----------------------------------------------------------------------
303 IMPL_LINK( SdNavigatorWin
, DropdownClickToolBoxHdl
, ToolBox
*, pBox
)
305 USHORT nId
= maToolbox
.GetCurItemId();
311 // Popup-Menu wird in Abhaengigkeit davon erzeugt, ob Dokument
312 // gespeichert ist oder nicht
313 PopupMenu
*pMenu
= new PopupMenu
;
315 for( USHORT nID
= NAVIGATOR_DRAGTYPE_URL
;
316 nID
< NAVIGATOR_DRAGTYPE_COUNT
;
319 USHORT nRId
= GetDragTypeSdResId( (NavigatorDragType
)nID
);
322 pMenu
->InsertItem( nID
, String( SdResId( nRId
) ) );
323 pMenu
->SetHelpId( nID
, HID_SD_NAVIGATOR_MENU1
+
324 nID
- NAVIGATOR_DRAGTYPE_URL
);
328 NavDocInfo
* pInfo
= GetDocInfo();
330 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
.IsLinkableSelected() )
332 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_LINK
, FALSE
);
333 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_URL
, FALSE
);
334 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
337 pMenu
->CheckItem( (UINT16
)meDragType
);
338 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, MenuSelectHdl
) );
340 pMenu
->Execute( this, maToolbox
.GetItemRect( nId
), POPUPMENU_EXECUTE_DOWN
);
341 pBox
->EndSelection();
343 //pBox->Invalidate();
347 case TBI_SHAPE_FILTER
:
349 PopupMenu
*pMenu
= new PopupMenu
;
352 nShowNamedShapesFilter
,
353 String(SdResId(STR_NAVIGATOR_SHOW_NAMED_SHAPES
)));
355 nShowAllShapesFilter
,
356 String(SdResId(STR_NAVIGATOR_SHOW_ALL_SHAPES
)));
358 if (maTlbObjects
.GetShowAllShapes())
359 pMenu
->CheckItem(nShowAllShapesFilter
);
361 pMenu
->CheckItem(nShowNamedShapesFilter
);
362 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, ShapeFilterCallback
) );
364 pMenu
->Execute( this, maToolbox
.GetItemRect( nId
), POPUPMENU_EXECUTE_DOWN
);
365 pBox
->EndSelection();
373 // -----------------------------------------------------------------------
375 IMPL_LINK( SdNavigatorWin
, ClickObjectHdl
, void *, EMPTYARG
)
377 if( !mbDocImported
|| maLbDocs
.GetSelectEntryPos() != 0 )
379 NavDocInfo
* pInfo
= GetDocInfo();
381 // Nur wenn es sich um das aktive Fenster handelt, wird
382 // auf die Seite gesprungen
383 if( pInfo
&& pInfo
->IsActive() )
385 String
aStr( maTlbObjects
.GetSelectEntry() );
389 SfxStringItem
aItem( SID_NAVIGATOR_OBJECT
, aStr
);
390 mpBindings
->GetDispatcher()->Execute(
391 SID_NAVIGATOR_OBJECT
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
393 // #98821# moved here from SetGetFocusHdl. Reset the
394 // focus only if something has been selected in the
396 SfxViewShell
* pCurSh
= SfxViewShell::Current();
400 Window
* pShellWnd
= pCurSh
->GetWindow();
402 pShellWnd
->GrabFocus();
410 // -----------------------------------------------------------------------
412 IMPL_LINK( SdNavigatorWin
, SelectDocumentHdl
, void *, EMPTYARG
)
414 String aStrLb
= maLbDocs
.GetSelectEntry();
415 long nPos
= maLbDocs
.GetSelectEntryPos();
417 ::sd::DrawDocShell
* pDocShell
= NULL
;
418 NavDocInfo
* pInfo
= GetDocInfo();
420 // Handelt es sich um ein gedragtes Objekt?
421 if( mbDocImported
&& nPos
== 0 )
423 // Dokument in TLB aufbauen
424 InsertFile( aStrLb
);
428 pDocShell
= pInfo
->mpDocShell
;
435 SdDrawDocument
* pDoc
= pDocShell
->GetDoc();
436 if( !maTlbObjects
.IsEqualToDoc( pDoc
) )
438 SdDrawDocument
* pNonConstDoc
= (SdDrawDocument
*) pDoc
; // const as const can...
439 ::sd::DrawDocShell
* pNCDocShell
= pNonConstDoc
->GetDocSh();
440 String aDocName
= pNCDocShell
->GetMedium()->GetName();
441 maTlbObjects
.Clear();
442 maTlbObjects
.Fill( pDoc
, (BOOL
) FALSE
, aDocName
); // Nur normale Seiten
446 // Pruefen, ob Link oder URL moeglich ist
447 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
.IsLinkableSelected() || ( meDragType
!= NAVIGATOR_DRAGTYPE_EMBEDDED
) )
449 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
456 /*************************************************************************
458 |* DrageType wird gesetzt und Image wird entspr. gesetzt.
459 |* Sollte Handler mit NULL gerufen werden, so wird der Default (URL) gesetzt.
461 \************************************************************************/
463 IMPL_LINK( SdNavigatorWin
, MenuSelectHdl
, Menu
*, pMenu
)
467 nMenuId
= pMenu
->GetCurItemId();
469 nMenuId
= NAVIGATOR_DRAGTYPE_URL
;
471 if( nMenuId
!= USHRT_MAX
) // Notwendig ?
473 NavigatorDragType eDT
= (NavigatorDragType
) nMenuId
;
474 if( meDragType
!= eDT
)
479 if( meDragType
== NAVIGATOR_DRAGTYPE_URL
)
481 // Fix, um Endlosschleife zu unterbinden
482 if( maTlbObjects
.GetSelectionCount() > 1 )
483 maTlbObjects
.SelectAll( FALSE
);
485 maTlbObjects
.SetSelectionMode( SINGLE_SELECTION
);
488 maTlbObjects
.SetSelectionMode( MULTIPLE_SELECTION
);
497 IMPL_LINK( SdNavigatorWin
, ShapeFilterCallback
, Menu
*, pMenu
)
501 bool bShowAllShapes (maTlbObjects
.GetShowAllShapes());
502 USHORT
nMenuId (pMenu
->GetCurItemId());
505 case nShowNamedShapesFilter
:
506 bShowAllShapes
= false;
509 case nShowAllShapesFilter
:
510 bShowAllShapes
= true;
515 false, "SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
519 maTlbObjects
.SetShowAllShapes(bShowAllShapes
, true);
521 // Remember the selection in the FrameView.
522 NavDocInfo
* pInfo
= GetDocInfo();
525 ::sd::DrawDocShell
* pDocShell
= pInfo
->mpDocShell
;
526 if (pDocShell
!= NULL
)
528 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
529 if (pViewShell
!= NULL
)
531 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
532 if (pFrameView
!= NULL
)
534 pFrameView
->SetIsNavigatorShowingAllShapes(bShowAllShapes
);
544 // -----------------------------------------------------------------------
546 void SdNavigatorWin::Resize()
548 Size
aWinSize( GetOutputSizePixel() );
549 if( aWinSize
.Height() >= maMinSize
.Height() )
550 //aWinSize.Width() >= maMinSize.Width() )
553 aDiffSize
.Width() = aWinSize
.Width() - maSize
.Width();
554 aDiffSize
.Height() = aWinSize
.Height() - maSize
.Height();
556 // Umgroessern der Toolbox
557 Size
aObjSize( maToolbox
.GetOutputSizePixel() );
558 aObjSize
.Width() += aDiffSize
.Width();
559 maToolbox
.SetOutputSizePixel( aObjSize
);
561 // Umgroessern der TreeLB
562 aObjSize
= maTlbObjects
.Control::GetOutputSizePixel();
563 aObjSize
.Width() += aDiffSize
.Width();
564 aObjSize
.Height() += aDiffSize
.Height();
565 maTlbObjects
.SetOutputSizePixel( aObjSize
);
567 Point
aPt( 0, aDiffSize
.Height() );
569 // Verschieben der anderen Controls (DocumentLB)
571 aObjSize
= maLbDocs
.GetOutputSizePixel();
572 aObjSize
.Width() += aDiffSize
.Width();
573 maLbDocs
.SetPosPixel( maLbDocs
.GetPosPixel() + aPt
);
574 maLbDocs
.SetOutputSizePixel( aObjSize
);
582 // -----------------------------------------------------------------------
584 BOOL
SdNavigatorWin::InsertFile(const String
& rFileName
)
586 INetURLObject
aURL( rFileName
);
589 if( aURL
.GetProtocol() == INET_PROT_NOT_VALID
)
592 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rFileName
, aURLStr
);
593 aURL
= INetURLObject( aURLStr
);
596 // get adjusted FileName
597 String
aFileName( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
599 if (!aFileName
.Len())
601 /**********************************************************************
602 * Wieder aktuelles Dokument anzeigen
603 **********************************************************************/
604 maDropFileName
= aFileName
;
608 /**********************************************************************
609 * Hineingedraggtes Dokument anzeigen
610 **********************************************************************/
611 const SfxFilter
* pFilter
= NULL
;
614 if (aFileName
!= maDropFileName
)
616 SfxMedium
aMed(aFileName
, (STREAM_READ
| STREAM_SHARE_DENYNONE
), FALSE
);
617 SfxFilterMatcher
aMatch( String::CreateFromAscii("simpress") );
618 aMed
.UseInteractionHandler( TRUE
);
619 nErr
= aMatch
.GuessFilter(aMed
, &pFilter
);
622 if ((pFilter
&& !nErr
) || aFileName
== maDropFileName
)
624 // Das Medium muss ggf. mit READ/WRITE geoeffnet werden, daher wird
625 // ersteinmal nachgeschaut, ob es einen Storage enthaelt
626 SfxMedium
* pMedium
= new SfxMedium( aFileName
,
627 STREAM_READ
| STREAM_NOCREATE
,
630 if (pMedium
->IsStorage())
632 // Jetzt modusabhaengig:
633 // maTlbObjects.SetSelectionMode(MULTIPLE_SELECTION);
634 // Eigentuemeruebergabe von pMedium;
635 SdDrawDocument
* pDropDoc
= maTlbObjects
.GetBookmarkDoc(pMedium
);
639 maTlbObjects
.Clear();
640 maDropFileName
= aFileName
;
642 if( !maTlbObjects
.IsEqualToDoc( pDropDoc
) )
644 // Nur normale Seiten
645 maTlbObjects
.Fill(pDropDoc
, (BOOL
) FALSE
, maDropFileName
);
646 RefreshDocumentLB( &maDropFileName
);
665 // -----------------------------------------------------------------------
667 void SdNavigatorWin::RefreshDocumentLB( const String
* pDocName
)
674 maLbDocs
.RemoveEntry( 0 );
676 maLbDocs
.InsertEntry( *pDocName
, 0 );
677 mbDocImported
= TRUE
;
681 nPos
= maLbDocs
.GetSelectEntryPos();
682 if( nPos
== LISTBOX_ENTRY_NOTFOUND
)
687 aStr
= maLbDocs
.GetEntry( 0 );
691 // Liste der DocInfos loeschen
692 long nCount
= mpDocList
->Count();
694 delete (NavDocInfo
*) mpDocList
->Remove( (ULONG
)0 );
697 maLbDocs
.InsertEntry( aStr
, 0 );
699 ::sd::DrawDocShell
* pCurrentDocShell
=
700 PTR_CAST(::sd::DrawDocShell
, SfxObjectShell::Current() );
701 SfxObjectShell
* pSfxDocShell
= SfxObjectShell::GetFirst(0, FALSE
);
702 while( pSfxDocShell
)
704 ::sd::DrawDocShell
* pDocShell
= PTR_CAST(::sd::DrawDocShell
, pSfxDocShell
);
705 if( pDocShell
&& !pDocShell
->IsInDestruction() && ( pDocShell
->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) )
707 NavDocInfo
* pInfo
= new NavDocInfo();
708 pInfo
->mpDocShell
= pDocShell
;
710 aStr
= pDocShell
->GetMedium()->GetName();
714 pInfo
->SetName( FALSE
);
715 // z.Z. wird wieder der Name der Shell genommen (also ohne Pfad)
716 // da Koose es als Fehler ansieht, wenn er Pfad in URL-Notation
718 aStr
= pDocShell
->GetName();
720 maLbDocs
.InsertEntry( aStr
, LISTBOX_APPEND
);
723 if( pDocShell
== pCurrentDocShell
)
726 pInfo
->SetActive( FALSE
);
728 mpDocList
->Insert( pInfo
, LIST_APPEND
);
730 pSfxDocShell
= SfxObjectShell::GetNext( *pSfxDocShell
, 0 , FALSE
);
733 maLbDocs
.SelectEntryPos( nPos
);
736 //------------------------------------------------------------------------
738 USHORT
SdNavigatorWin::GetDragTypeSdResId( NavigatorDragType eDT
, BOOL bImage
)
742 case NAVIGATOR_DRAGTYPE_NONE
:
743 return( bImage
? 0 : STR_NONE
);
744 case NAVIGATOR_DRAGTYPE_URL
:
745 return( bImage
? TBI_HYPERLINK
: STR_DRAGTYPE_URL
);
746 case NAVIGATOR_DRAGTYPE_EMBEDDED
:
747 return( bImage
? TBI_EMBEDDED
: STR_DRAGTYPE_EMBEDDED
);
748 case NAVIGATOR_DRAGTYPE_LINK
:
749 return( bImage
? TBI_LINK
: STR_DRAGTYPE_LINK
);
750 default: DBG_ERROR( "Keine Resource fuer DragType vorhanden!" );
755 //------------------------------------------------------------------------
757 NavDocInfo
* SdNavigatorWin::GetDocInfo()
759 long nPos
= maLbDocs
.GetSelectEntryPos();
770 NavDocInfo
* pInfo
= (NavDocInfo
*)mpDocList
->GetObject( nPos
);
775 /*************************************************************************
779 \************************************************************************/
781 long SdNavigatorWin::Notify(NotifyEvent
& rNEvt
)
783 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
788 if( KEY_ESCAPE
== pKEvt
->GetKeyCode().GetCode() )
790 if( SdPageObjsTLB::IsInDrag() )
792 // during drag'n'drop we just stop the drag but do not close the navigator
797 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
800 sd::SlideShow::Stop( *pBase
);
801 // Stopping the slide show may result in a synchronous
802 // deletion of the navigator window. Calling the
803 // parents Notify after this is unsafe. Therefore we
812 nOK
= Window::Notify( rNEvt
);
818 /*************************************************************************
820 |* KeyInput: ESCAPE abfangen, um Show zu beenden
822 \************************************************************************/
824 void SdNavigatorWin::KeyInput( const KeyEvent
& rKEvt
)
828 if (rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
)
830 if( SdPageObjsTLB::IsInDrag() )
832 // during drag'n'drop we just stop the drag but do not close the navigator
837 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
840 ::sd::SlideShow::Stop( *pBase
);
847 Window::KeyInput(rKEvt
);
851 void SdNavigatorWin::DataChanged( const DataChangedEvent
& rDCEvt
)
853 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
856 Window::DataChanged( rDCEvt
);
859 void SdNavigatorWin::SetDragImage()
861 maToolbox
.SetItemImage( TBI_DRAGTYPE
, maToolbox
.GetImageList().GetImage( GetDragTypeSdResId( meDragType
, TRUE
) ) );
864 void SdNavigatorWin::ApplyImageList()
866 const bool bHighContrast
= GetDisplayBackground().GetColor().IsDark() != 0;
868 maToolbox
.SetImageList( bHighContrast
? maImageListH
: maImageList
);
870 maToolbox
.SetItemImage(TBI_SHAPE_FILTER
, BitmapEx(SdResId( bHighContrast
? BMP_GRAPHIC_H
: BMP_GRAPHIC
)));
877 /*************************************************************************
879 |* ControllerItem fuer Navigator
881 \************************************************************************/
883 SdNavigatorControllerItem::SdNavigatorControllerItem( USHORT _nId
,
884 SdNavigatorWin
* pNavWin
,
885 SfxBindings
* _pBindings
) :
886 SfxControllerItem( _nId
, *_pBindings
),
887 pNavigatorWin( pNavWin
)
891 // -----------------------------------------------------------------------
893 void SdNavigatorControllerItem::StateChanged( USHORT nSId
,
894 SfxItemState eState
, const SfxPoolItem
* pItem
)
896 if( eState
>= SFX_ITEM_AVAILABLE
&& nSId
== SID_NAVIGATOR_STATE
)
898 const SfxUInt32Item
* pStateItem
= PTR_CAST( SfxUInt32Item
, pItem
);
899 DBG_ASSERT( pStateItem
, "SfxUInt16Item erwartet");
900 UINT32 nState
= pStateItem
->GetValue();
903 if( nState
& NAVBTN_PEN_ENABLED
&&
904 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PEN
) )
905 pNavigatorWin
->maToolbox
.EnableItem( TBI_PEN
);
906 if( nState
& NAVBTN_PEN_DISABLED
&&
907 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PEN
) )
908 pNavigatorWin
->maToolbox
.EnableItem( TBI_PEN
, FALSE
);
909 if( nState
& NAVBTN_PEN_CHECKED
&&
910 !pNavigatorWin
->maToolbox
.IsItemChecked( TBI_PEN
) )
911 pNavigatorWin
->maToolbox
.CheckItem( TBI_PEN
);
912 if( nState
& NAVBTN_PEN_UNCHECKED
&&
913 pNavigatorWin
->maToolbox
.IsItemChecked( TBI_PEN
) )
914 pNavigatorWin
->maToolbox
.CheckItem( TBI_PEN
, FALSE
);
916 // Nur wenn Doc in LB das Aktive ist
917 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
918 if( pInfo
&& pInfo
->IsActive() )
921 if( nState
& NAVBTN_FIRST_ENABLED
&&
922 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_FIRST
) )
923 pNavigatorWin
->maToolbox
.EnableItem( TBI_FIRST
);
924 if( nState
& NAVBTN_FIRST_DISABLED
&&
925 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_FIRST
) )
926 pNavigatorWin
->maToolbox
.EnableItem( TBI_FIRST
, FALSE
);
929 if( nState
& NAVBTN_PREV_ENABLED
&&
930 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PREVIOUS
) )
931 pNavigatorWin
->maToolbox
.EnableItem( TBI_PREVIOUS
);
932 if( nState
& NAVBTN_PREV_DISABLED
&&
933 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PREVIOUS
) )
934 pNavigatorWin
->maToolbox
.EnableItem( TBI_PREVIOUS
, FALSE
);
937 if( nState
& NAVBTN_LAST_ENABLED
&&
938 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_LAST
) )
939 pNavigatorWin
->maToolbox
.EnableItem( TBI_LAST
);
940 if( nState
& NAVBTN_LAST_DISABLED
&&
941 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_LAST
) )
942 pNavigatorWin
->maToolbox
.EnableItem( TBI_LAST
, FALSE
);
945 if( nState
& NAVBTN_NEXT_ENABLED
&&
946 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_NEXT
) )
947 pNavigatorWin
->maToolbox
.EnableItem( TBI_NEXT
);
948 if( nState
& NAVBTN_NEXT_DISABLED
&&
949 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_NEXT
) )
950 pNavigatorWin
->maToolbox
.EnableItem( TBI_NEXT
, FALSE
);
952 if( nState
& NAVTLB_UPDATE
)
954 // InitTlb; Wird ueber Slot initiiert
955 SfxBoolItem
aItem( SID_NAVIGATOR_INIT
, TRUE
);
956 GetBindings().GetDispatcher()->Execute(
957 SID_NAVIGATOR_INIT
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
963 /*************************************************************************
965 |* ControllerItem fuer Navigator, um die Seite in der TreeLB anzuzeigen
967 \************************************************************************/
969 SdPageNameControllerItem::SdPageNameControllerItem( USHORT _nId
,
970 SdNavigatorWin
* pNavWin
,
971 SfxBindings
* _pBindings
) :
972 SfxControllerItem( _nId
, *_pBindings
),
973 pNavigatorWin( pNavWin
)
977 // -----------------------------------------------------------------------
979 void SdPageNameControllerItem::StateChanged( USHORT nSId
,
980 SfxItemState eState
, const SfxPoolItem
* pItem
)
982 if( eState
>= SFX_ITEM_AVAILABLE
&& nSId
== SID_NAVIGATOR_PAGENAME
)
984 // Nur wenn Doc in LB das Aktive ist
985 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
986 if( pInfo
&& pInfo
->IsActive() )
988 const SfxStringItem
* pStateItem
= PTR_CAST( SfxStringItem
, pItem
);
989 DBG_ASSERT( pStateItem
, "SfxStringItem erwartet");
990 String aPageName
= pStateItem
->GetValue();
992 if( !pNavigatorWin
->maTlbObjects
.HasSelectedChilds( aPageName
) )
994 if( pNavigatorWin
->maTlbObjects
.GetSelectionMode() == MULTIPLE_SELECTION
)
996 // Weil sonst immer dazuselektiert wird
997 pNavigatorWin
->maTlbObjects
.SelectAll( FALSE
);
999 pNavigatorWin
->maTlbObjects
.SelectEntry( aPageName
);