1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/urlobj.hxx>
21 #include <unotools/localfilehelper.hxx>
22 #include <sfx2/imgmgr.hxx>
23 #include <sfx2/fcontnr.hxx>
24 #include <svl/eitem.hxx>
25 #include <svl/stritem.hxx>
26 #include <sfx2/docfilt.hxx>
27 #include <sfx2/docfile.hxx>
28 #include <svl/intitem.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <svx/svxids.hrc>
31 #include <vcl/menu.hxx>
33 #include <sfx2/viewfrm.hxx>
34 #include <sfx2/dockwin.hxx>
35 #include <sfx2/sfxresid.hxx>
38 #include "navigatr.hxx"
39 #include "navigatr.hrc"
42 #include "strings.hrc"
43 #include "res_bmp.hrc"
44 #include "drawdoc.hxx"
45 #include "DrawDocShell.hxx"
46 #include "sdresid.hxx"
47 #include "ViewShell.hxx"
48 #include "ViewShellBase.hxx"
49 #include "DrawViewShell.hxx"
50 #include "slideshow.hxx"
51 #include "FrameView.hxx"
55 static const sal_uInt16 nShowNamedShapesFilter
=1;
56 static const sal_uInt16 nShowAllShapesFilter
=2;
60 * SdNavigatorWin - FloatingWindow
62 SdNavigatorWin::SdNavigatorWin(
64 ::sd::NavigatorChildWindow
* pChWinCtxt
,
65 const SdResId
& rSdResId
,
66 SfxBindings
* pInBindings
,
67 const UpdateRequestFunctor
& rUpdateRequest
)
68 : ::Window( pParent
, rSdResId
)
69 , maToolbox ( this, SdResId( 1 ) )
70 , maTlbObjects( this, SdResId( TLB_OBJECTS
) )
71 , maLbDocs ( this, SdResId( LB_DOCS
) )
72 , mpChildWinContext( pChWinCtxt
)
73 , mbDocImported ( sal_False
)
74 // On changes of the DragType: adjust SelectionMode of TLB!
75 , meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED
)
76 , mpBindings ( pInBindings
)
77 , maImageList ( SdResId( IL_NAVIGATR
) )
79 maTlbObjects
.SetViewFrame( mpBindings
->GetDispatcher()->GetFrame() );
83 maTlbObjects
.SetAccessibleName(String(SdResId(STR_OBJECTS_TREE
)));
85 mpNavigatorCtrlItem
= new SdNavigatorControllerItem( SID_NAVIGATOR_STATE
, this, mpBindings
, rUpdateRequest
);
86 mpPageNameCtrlItem
= new SdPageNameControllerItem( SID_NAVIGATOR_PAGENAME
, this, mpBindings
, rUpdateRequest
);
88 ApplyImageList(); // load images *before* calculating sizes to get something useful !!!
90 Size
aTbxSize( maToolbox
.CalcWindowSizePixel() );
91 maToolbox
.SetOutputSizePixel( aTbxSize
);
92 maToolbox
.SetSelectHdl( LINK( this, SdNavigatorWin
, SelectToolboxHdl
) );
93 maToolbox
.SetClickHdl( LINK( this, SdNavigatorWin
, ClickToolboxHdl
) );
94 maToolbox
.SetDropdownClickHdl( LINK(this, SdNavigatorWin
, DropdownClickToolBoxHdl
) );
95 maToolbox
.SetItemBits( TBI_DRAGTYPE
, maToolbox
.GetItemBits( TBI_DRAGTYPE
) | TIB_DROPDOWNONLY
);
97 // Shape filter drop down menu.
98 maToolbox
.SetItemBits(
100 maToolbox
.GetItemBits(TBI_SHAPE_FILTER
) | TIB_DROPDOWNONLY
);
103 // set position below toolbox
104 long nListboxYPos
= maToolbox
.GetPosPixel().Y() + maToolbox
.GetSizePixel().Height() + 4;
105 maTlbObjects
.setPosSizePixel( 0, nListboxYPos
, 0, 0, WINDOW_POSSIZE_Y
);
106 maTlbObjects
.SetDoubleClickHdl( LINK( this, SdNavigatorWin
, ClickObjectHdl
) );
107 maTlbObjects
.SetSelectionMode( SINGLE_SELECTION
);
108 // set focus to listbox, otherwise it is in the toolbox which is only useful
109 // for keyboard navigation
110 maTlbObjects
.GrabFocus();
113 maLbDocs
.SetSelectHdl( LINK( this, SdNavigatorWin
, SelectDocumentHdl
) );
114 // set position below treelistbox
115 nListboxYPos
= maTlbObjects
.GetPosPixel().Y() + maTlbObjects
.GetSizePixel().Height() + 4;
116 maLbDocs
.setPosSizePixel( 0, nListboxYPos
, 0, 0, WINDOW_POSSIZE_Y
);
118 // assure that tool box is at least as wide as the tree list box
120 const Size
aTlbSize( maTlbObjects
.GetOutputSizePixel() );
121 if ( aTlbSize
.Width() > aTbxSize
.Width() )
123 maToolbox
.setPosSizePixel( 0, 0, aTlbSize
.Width(), 0, WINDOW_POSSIZE_WIDTH
);
124 aTbxSize
= maToolbox
.GetOutputSizePixel();
128 // set min outputsize after all sizes are known
129 const long nFullHeight
= nListboxYPos
+ maLbDocs
.GetSizePixel().Height() + 4;
130 maSize
= GetOutputSizePixel();
131 if( maSize
.Height() < nFullHeight
)
133 maSize
.Height() = nFullHeight
;
134 SetOutputSizePixel( maSize
);
137 const long nMinWidth
= 2*maToolbox
.GetPosPixel().X() + aTbxSize
.Width(); // never clip the toolbox
138 if( nMinWidth
> maMinSize
.Width() )
139 maMinSize
.Width() = nMinWidth
;
140 maMinSize
.Height() -= 40;
141 SfxDockingWindow
* pDockingParent
= dynamic_cast<SfxDockingWindow
*>(GetParent());
142 if (pDockingParent
!= NULL
)
143 pDockingParent
->SetMinOutputSizePixel( maMinSize
);
145 // InitTlb; is initiated over Slot
150 // -----------------------------------------------------------------------
152 SdNavigatorWin::~SdNavigatorWin()
154 delete mpNavigatorCtrlItem
;
155 delete mpPageNameCtrlItem
;
158 // -----------------------------------------------------------------------
160 void SdNavigatorWin::InitTreeLB( const SdDrawDocument
* pDoc
)
162 SdDrawDocument
* pNonConstDoc
= (SdDrawDocument
*) pDoc
; // const as const can...
163 ::sd::DrawDocShell
* pDocShell
= pNonConstDoc
->GetDocSh();
164 String
aDocShName( pDocShell
->GetName() );
165 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
167 // Restore the 'ShowAllShapes' flag from the last time (in this session)
168 // that the navigator was shown.
169 if (pViewShell
!= NULL
)
171 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
172 if (pFrameView
!= NULL
)
173 maTlbObjects
.SetShowAllShapes(pFrameView
->IsNavigatorShowingAllShapes(), false);
176 // Disable the shape filter drop down menu when there is a running slide
178 if (pViewShell
!=NULL
&& sd::SlideShow::IsRunning( pViewShell
->GetViewShellBase() ))
179 maToolbox
.EnableItem(TBI_SHAPE_FILTER
, sal_False
);
181 maToolbox
.EnableItem(TBI_SHAPE_FILTER
);
183 if( !maTlbObjects
.IsEqualToDoc( pDoc
) )
185 String aDocName
= pDocShell
->GetMedium()->GetName();
186 maTlbObjects
.Clear();
187 maTlbObjects
.Fill( pDoc
, (sal_Bool
) sal_False
, aDocName
); // only normal pages
190 maLbDocs
.SelectEntry( aDocShName
);
194 maLbDocs
.SetNoSelection();
195 maLbDocs
.SelectEntry( aDocShName
);
197 // commented in order to fix 30246
198 // if( maLbDocs.GetSelectEntryCount() == 0 )
201 maLbDocs
.SelectEntry( aDocShName
);
205 SfxViewFrame
* pViewFrame
= ( ( pViewShell
&& pViewShell
->GetViewFrame() ) ? pViewShell
->GetViewFrame() : SfxViewFrame::Current() );
207 pViewFrame
->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME
, sal_True
, sal_True
);
211 * DragType is set on dependance if a Drag is even possible. For example,
212 * under certain circumstances, it is not allowed to drag graphics (#31038#).
214 NavigatorDragType
SdNavigatorWin::GetNavigatorDragType()
216 NavigatorDragType eDT
= meDragType
;
217 NavDocInfo
* pInfo
= GetDocInfo();
219 if( ( eDT
== NAVIGATOR_DRAGTYPE_LINK
) && ( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
.IsLinkableSelected() ) )
220 eDT
= NAVIGATOR_DRAGTYPE_NONE
;
225 // -----------------------------------------------------------------------
228 IMPL_LINK_NOARG(SdNavigatorWin
, SelectToolboxHdl
)
230 sal_uInt16 nId
= maToolbox
.GetCurItemId();
232 PageJump ePage
= PAGE_NONE
;
240 nSId
= SID_NAVIGATOR_PEN
;
245 SfxBoolItem
aItem( nSId
, sal_True
);
246 mpBindings
->GetDispatcher()->Execute(
247 nSId
, SFX_CALLMODE_SLOT
|SFX_CALLMODE_RECORD
, &aItem
, 0L );
257 if( nId
== TBI_FIRST
)
259 else if( nId
== TBI_PREVIOUS
)
260 ePage
= PAGE_PREVIOUS
;
261 else if( nId
== TBI_NEXT
)
263 else if( nId
== TBI_LAST
)
266 if( ePage
!= PAGE_NONE
)
268 SfxUInt16Item
aItem( SID_NAVIGATOR_PAGE
, (sal_uInt16
)ePage
);
269 mpBindings
->GetDispatcher()->Execute(
270 SID_NAVIGATOR_PAGE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
278 // -----------------------------------------------------------------------
281 IMPL_LINK_NOARG(SdNavigatorWin
, ClickToolboxHdl
)
286 // -----------------------------------------------------------------------
288 IMPL_LINK( SdNavigatorWin
, DropdownClickToolBoxHdl
, ToolBox
*, pBox
)
290 sal_uInt16 nId
= maToolbox
.GetCurItemId();
296 // Popup menu is created depending if the document is saved or not
297 PopupMenu
*pMenu
= new PopupMenu
;
299 static const char* aHIDs
[] =
301 HID_SD_NAVIGATOR_MENU1
,
302 HID_SD_NAVIGATOR_MENU2
,
303 HID_SD_NAVIGATOR_MENU3
,
307 for( sal_uInt16 nID
= NAVIGATOR_DRAGTYPE_URL
;
308 nID
< NAVIGATOR_DRAGTYPE_COUNT
;
311 sal_uInt16 nRId
= GetDragTypeSdResId( (NavigatorDragType
)nID
);
314 DBG_ASSERT(aHIDs
[nID
-NAVIGATOR_DRAGTYPE_URL
],"HelpId not added!");
315 pMenu
->InsertItem( nID
, String( SdResId( nRId
) ) );
316 pMenu
->SetHelpId( nID
, aHIDs
[nID
- NAVIGATOR_DRAGTYPE_URL
] );
320 NavDocInfo
* pInfo
= GetDocInfo();
322 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
.IsLinkableSelected() )
324 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_LINK
, sal_False
);
325 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_URL
, sal_False
);
326 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
329 pMenu
->CheckItem( (sal_uInt16
)meDragType
);
330 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, MenuSelectHdl
) );
332 pMenu
->Execute( this, maToolbox
.GetItemRect( nId
), POPUPMENU_EXECUTE_DOWN
);
333 pBox
->EndSelection();
338 case TBI_SHAPE_FILTER
:
340 PopupMenu
*pMenu
= new PopupMenu
;
343 nShowNamedShapesFilter
,
344 String(SdResId(STR_NAVIGATOR_SHOW_NAMED_SHAPES
)));
346 nShowAllShapesFilter
,
347 String(SdResId(STR_NAVIGATOR_SHOW_ALL_SHAPES
)));
349 if (maTlbObjects
.GetShowAllShapes())
350 pMenu
->CheckItem(nShowAllShapesFilter
);
352 pMenu
->CheckItem(nShowNamedShapesFilter
);
353 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, ShapeFilterCallback
) );
355 pMenu
->Execute( this, maToolbox
.GetItemRect( nId
), POPUPMENU_EXECUTE_DOWN
);
356 pBox
->EndSelection();
364 // -----------------------------------------------------------------------
366 IMPL_LINK_NOARG(SdNavigatorWin
, ClickObjectHdl
)
368 if( !mbDocImported
|| maLbDocs
.GetSelectEntryPos() != 0 )
370 NavDocInfo
* pInfo
= GetDocInfo();
372 // if it is the active window, we jump to the page
373 if( pInfo
&& pInfo
->IsActive() )
375 String
aStr( maTlbObjects
.GetSelectEntry() );
379 SfxStringItem
aItem( SID_NAVIGATOR_OBJECT
, aStr
);
380 mpBindings
->GetDispatcher()->Execute(
381 SID_NAVIGATOR_OBJECT
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
383 // moved here from SetGetFocusHdl. Reset the
384 // focus only if something has been selected in the
386 SfxViewShell
* pCurSh
= SfxViewShell::Current();
390 Window
* pShellWnd
= pCurSh
->GetWindow();
392 pShellWnd
->GrabFocus();
400 // -----------------------------------------------------------------------
402 IMPL_LINK_NOARG(SdNavigatorWin
, SelectDocumentHdl
)
404 String aStrLb
= maLbDocs
.GetSelectEntry();
405 long nPos
= maLbDocs
.GetSelectEntryPos();
406 sal_Bool bFound
= sal_False
;
407 ::sd::DrawDocShell
* pDocShell
= NULL
;
408 NavDocInfo
* pInfo
= GetDocInfo();
410 // is it a dragged object?
411 if( mbDocImported
&& nPos
== 0 )
413 // construct document in TLB
414 InsertFile( aStrLb
);
418 pDocShell
= pInfo
->mpDocShell
;
425 SdDrawDocument
* pDoc
= pDocShell
->GetDoc();
426 if( !maTlbObjects
.IsEqualToDoc( pDoc
) )
428 SdDrawDocument
* pNonConstDoc
= (SdDrawDocument
*) pDoc
; // const as const can...
429 ::sd::DrawDocShell
* pNCDocShell
= pNonConstDoc
->GetDocSh();
430 String aDocName
= pNCDocShell
->GetMedium()->GetName();
431 maTlbObjects
.Clear();
432 maTlbObjects
.Fill( pDoc
, (sal_Bool
) sal_False
, aDocName
); // only normal pages
436 // check if link or url is possible
437 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
.IsLinkableSelected() || ( meDragType
!= NAVIGATOR_DRAGTYPE_EMBEDDED
) )
439 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
447 * Set DrageType and set image accordingly to it.
448 * If the handler is called with NULL, the default (URL) is set.
450 IMPL_LINK( SdNavigatorWin
, MenuSelectHdl
, Menu
*, pMenu
)
454 nMenuId
= pMenu
->GetCurItemId();
456 nMenuId
= NAVIGATOR_DRAGTYPE_URL
;
458 if( nMenuId
!= USHRT_MAX
) // Necessary ?
460 NavigatorDragType eDT
= (NavigatorDragType
) nMenuId
;
461 if( meDragType
!= eDT
)
466 if( meDragType
== NAVIGATOR_DRAGTYPE_URL
)
468 // patch, prevents endless loop
469 if( maTlbObjects
.GetSelectionCount() > 1 )
470 maTlbObjects
.SelectAll( sal_False
);
472 maTlbObjects
.SetSelectionMode( SINGLE_SELECTION
);
475 maTlbObjects
.SetSelectionMode( MULTIPLE_SELECTION
);
484 IMPL_LINK( SdNavigatorWin
, ShapeFilterCallback
, Menu
*, pMenu
)
488 bool bShowAllShapes (maTlbObjects
.GetShowAllShapes());
489 sal_uInt16
nMenuId (pMenu
->GetCurItemId());
492 case nShowNamedShapesFilter
:
493 bShowAllShapes
= false;
496 case nShowAllShapesFilter
:
497 bShowAllShapes
= true;
502 "SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
506 maTlbObjects
.SetShowAllShapes(bShowAllShapes
, true);
508 // Remember the selection in the FrameView.
509 NavDocInfo
* pInfo
= GetDocInfo();
512 ::sd::DrawDocShell
* pDocShell
= pInfo
->mpDocShell
;
513 if (pDocShell
!= NULL
)
515 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
516 if (pViewShell
!= NULL
)
518 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
519 if (pFrameView
!= NULL
)
521 pFrameView
->SetIsNavigatorShowingAllShapes(bShowAllShapes
);
531 // -----------------------------------------------------------------------
533 void SdNavigatorWin::Resize()
535 Size
aWinSize( GetOutputSizePixel() );
536 if( aWinSize
.Height() >= maMinSize
.Height() )
537 //aWinSize.Width() >= maMinSize.Width() )
540 aDiffSize
.Width() = aWinSize
.Width() - maSize
.Width();
541 aDiffSize
.Height() = aWinSize
.Height() - maSize
.Height();
543 // change size of Toolbox
544 Size
aObjSize( maToolbox
.GetOutputSizePixel() );
545 aObjSize
.Width() += aDiffSize
.Width();
546 maToolbox
.SetOutputSizePixel( aObjSize
);
548 // change size of TreeLB
549 aObjSize
= maTlbObjects
.GetSizePixel();
550 aObjSize
.Width() += aDiffSize
.Width();
551 aObjSize
.Height() = maLbDocs
.GetPosPixel().Y() + aDiffSize
.Height() -
552 maTlbObjects
.GetPosPixel().Y() - 4;
553 maTlbObjects
.SetSizePixel( aObjSize
);
555 Point
aPt( 0, aDiffSize
.Height() );
557 // move other controls (DocumentLB)
559 aObjSize
= maLbDocs
.GetOutputSizePixel();
560 aObjSize
.Width() += aDiffSize
.Width();
561 maLbDocs
.SetPosPixel( maLbDocs
.GetPosPixel() + aPt
);
562 maLbDocs
.SetOutputSizePixel( aObjSize
);
570 // -----------------------------------------------------------------------
572 sal_Bool
SdNavigatorWin::InsertFile(const String
& rFileName
)
574 INetURLObject
aURL( rFileName
);
575 sal_Bool bReturn
= sal_True
;
577 if( aURL
.GetProtocol() == INET_PROT_NOT_VALID
)
580 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rFileName
, aURLStr
);
581 aURL
= INetURLObject( aURLStr
);
584 // get adjusted FileName
585 String
aFileName( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
587 if (!aFileName
.Len())
589 // show actual document again
590 maDropFileName
= aFileName
;
594 // show dragged-in document
595 const SfxFilter
* pFilter
= NULL
;
598 if (aFileName
!= maDropFileName
)
600 SfxMedium
aMed(aFileName
, (STREAM_READ
| STREAM_SHARE_DENYNONE
));
601 SfxFilterMatcher
aMatch( OUString("simpress") );
602 aMed
.UseInteractionHandler( sal_True
);
603 nErr
= aMatch
.GuessFilter(aMed
, &pFilter
);
606 if ((pFilter
&& !nErr
) || aFileName
== maDropFileName
)
608 // The medium may be opened with READ/WRITE. Therefore, we first
609 // check if it contains a Storage.
610 SfxMedium
* pMedium
= new SfxMedium( aFileName
,
611 STREAM_READ
| STREAM_NOCREATE
);
613 if (pMedium
->IsStorage())
615 // Now depending on mode:
616 // maTlbObjects.SetSelectionMode(MULTIPLE_SELECTION);
617 // handover of ownership of pMedium;
618 SdDrawDocument
* pDropDoc
= maTlbObjects
.GetBookmarkDoc(pMedium
);
622 maTlbObjects
.Clear();
623 maDropFileName
= aFileName
;
625 if( !maTlbObjects
.IsEqualToDoc( pDropDoc
) )
628 maTlbObjects
.Fill(pDropDoc
, (sal_Bool
) sal_False
, maDropFileName
);
629 RefreshDocumentLB( &maDropFileName
);
648 // -----------------------------------------------------------------------
650 void SdNavigatorWin::RefreshDocumentLB( const String
* pDocName
)
657 maLbDocs
.RemoveEntry( 0 );
659 maLbDocs
.InsertEntry( *pDocName
, 0 );
660 mbDocImported
= sal_True
;
664 nPos
= maLbDocs
.GetSelectEntryPos();
665 if( nPos
== LISTBOX_ENTRY_NOTFOUND
)
670 aStr
= maLbDocs
.GetEntry( 0 );
674 // delete list of DocInfos
678 maLbDocs
.InsertEntry( aStr
, 0 );
680 ::sd::DrawDocShell
* pCurrentDocShell
=
681 PTR_CAST(::sd::DrawDocShell
, SfxObjectShell::Current() );
682 SfxObjectShell
* pSfxDocShell
= SfxObjectShell::GetFirst(0, sal_False
);
683 while( pSfxDocShell
)
685 ::sd::DrawDocShell
* pDocShell
= PTR_CAST(::sd::DrawDocShell
, pSfxDocShell
);
686 if( pDocShell
&& !pDocShell
->IsInDestruction() && ( pDocShell
->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) )
689 aInfo
.mpDocShell
= pDocShell
;
691 SfxMedium
*pMedium
= pDocShell
->GetMedium();
692 aStr
= pMedium
? pMedium
->GetName() : OUString();
696 aInfo
.SetName( sal_False
);
697 // at the moment, we use the name of the shell again (i.e.
698 // without path) since Koose thinks it is an error if the path
699 // is shown in url notation!
700 aStr
= pDocShell
->GetName();
702 maLbDocs
.InsertEntry( aStr
, LISTBOX_APPEND
);
704 if( pDocShell
== pCurrentDocShell
)
707 aInfo
.SetActive( sal_False
);
709 maDocList
.push_back( aInfo
);
711 pSfxDocShell
= SfxObjectShell::GetNext( *pSfxDocShell
, 0 , sal_False
);
714 maLbDocs
.SelectEntryPos( nPos
);
717 //------------------------------------------------------------------------
719 sal_uInt16
SdNavigatorWin::GetDragTypeSdResId( NavigatorDragType eDT
, sal_Bool bImage
)
723 case NAVIGATOR_DRAGTYPE_NONE
:
724 return( bImage
? 0 : STR_NONE
);
725 case NAVIGATOR_DRAGTYPE_URL
:
726 return( bImage
? TBI_HYPERLINK
: STR_DRAGTYPE_URL
);
727 case NAVIGATOR_DRAGTYPE_EMBEDDED
:
728 return( bImage
? TBI_EMBEDDED
: STR_DRAGTYPE_EMBEDDED
);
729 case NAVIGATOR_DRAGTYPE_LINK
:
730 return( bImage
? TBI_LINK
: STR_DRAGTYPE_LINK
);
731 default: OSL_FAIL( "No resource for DragType available!" );
736 //------------------------------------------------------------------------
738 NavDocInfo
* SdNavigatorWin::GetDocInfo()
740 sal_uInt32 nPos
= maLbDocs
.GetSelectEntryPos();
751 return nPos
< maDocList
.size() ? &(maDocList
[ nPos
]) : NULL
;
757 long SdNavigatorWin::Notify(NotifyEvent
& rNEvt
)
759 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
760 long nOK
= sal_False
;
764 if( KEY_ESCAPE
== pKEvt
->GetKeyCode().GetCode() )
766 if( SdPageObjsTLB::IsInDrag() )
768 // during drag'n'drop we just stop the drag but do not close the navigator
773 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
776 sd::SlideShow::Stop( *pBase
);
777 // Stopping the slide show may result in a synchronous
778 // deletion of the navigator window. Calling the
779 // parents Notify after this is unsafe. Therefore we
788 nOK
= Window::Notify( rNEvt
);
795 * catch ESCAPE in order to end show
797 void SdNavigatorWin::KeyInput( const KeyEvent
& rKEvt
)
799 long nOK
= sal_False
;
801 if (rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
)
803 if( SdPageObjsTLB::IsInDrag() )
805 // during drag'n'drop we just stop the drag but do not close the navigator
810 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
813 ::sd::SlideShow::Stop( *pBase
);
820 Window::KeyInput(rKEvt
);
824 void SdNavigatorWin::DataChanged( const DataChangedEvent
& rDCEvt
)
826 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
829 Window::DataChanged( rDCEvt
);
832 void SdNavigatorWin::SetDragImage()
834 maToolbox
.SetItemImage( TBI_DRAGTYPE
, maToolbox
.GetImageList().GetImage( GetDragTypeSdResId( meDragType
, sal_True
) ) );
837 void SdNavigatorWin::ApplyImageList()
840 maToolbox
.SetImageList( maImageList
);
841 maToolbox
.SetItemImage( TBI_SHAPE_FILTER
, BitmapEx( SdResId( BMP_GRAPHIC
) ) );
849 * ControllerItem for Navigator
851 SdNavigatorControllerItem::SdNavigatorControllerItem(
853 SdNavigatorWin
* pNavWin
,
854 SfxBindings
* _pBindings
,
855 const SdNavigatorWin::UpdateRequestFunctor
& rUpdateRequest
)
856 : SfxControllerItem( _nId
, *_pBindings
),
857 pNavigatorWin( pNavWin
),
858 maUpdateRequest(rUpdateRequest
)
862 // -----------------------------------------------------------------------
864 void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId
,
865 SfxItemState eState
, const SfxPoolItem
* pItem
)
867 if( eState
>= SFX_ITEM_AVAILABLE
&& nSId
== SID_NAVIGATOR_STATE
)
869 const SfxUInt32Item
* pStateItem
= PTR_CAST( SfxUInt32Item
, pItem
);
870 DBG_ASSERT( pStateItem
, "SfxUInt16Item expected");
871 sal_uInt32 nState
= pStateItem
->GetValue();
874 if( nState
& NAVBTN_PEN_ENABLED
&&
875 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PEN
) )
876 pNavigatorWin
->maToolbox
.EnableItem( TBI_PEN
);
877 if( nState
& NAVBTN_PEN_DISABLED
&&
878 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PEN
) )
879 pNavigatorWin
->maToolbox
.EnableItem( TBI_PEN
, sal_False
);
880 if( nState
& NAVBTN_PEN_CHECKED
&&
881 !pNavigatorWin
->maToolbox
.IsItemChecked( TBI_PEN
) )
882 pNavigatorWin
->maToolbox
.CheckItem( TBI_PEN
);
883 if( nState
& NAVBTN_PEN_UNCHECKED
&&
884 pNavigatorWin
->maToolbox
.IsItemChecked( TBI_PEN
) )
885 pNavigatorWin
->maToolbox
.CheckItem( TBI_PEN
, sal_False
);
887 // only if doc in LB is the active
888 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
889 if( pInfo
&& pInfo
->IsActive() )
892 if( nState
& NAVBTN_FIRST_ENABLED
&&
893 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_FIRST
) )
894 pNavigatorWin
->maToolbox
.EnableItem( TBI_FIRST
);
895 if( nState
& NAVBTN_FIRST_DISABLED
&&
896 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_FIRST
) )
897 pNavigatorWin
->maToolbox
.EnableItem( TBI_FIRST
, sal_False
);
900 if( nState
& NAVBTN_PREV_ENABLED
&&
901 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PREVIOUS
) )
902 pNavigatorWin
->maToolbox
.EnableItem( TBI_PREVIOUS
);
903 if( nState
& NAVBTN_PREV_DISABLED
&&
904 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_PREVIOUS
) )
905 pNavigatorWin
->maToolbox
.EnableItem( TBI_PREVIOUS
, sal_False
);
908 if( nState
& NAVBTN_LAST_ENABLED
&&
909 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_LAST
) )
910 pNavigatorWin
->maToolbox
.EnableItem( TBI_LAST
);
911 if( nState
& NAVBTN_LAST_DISABLED
&&
912 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_LAST
) )
913 pNavigatorWin
->maToolbox
.EnableItem( TBI_LAST
, sal_False
);
916 if( nState
& NAVBTN_NEXT_ENABLED
&&
917 !pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_NEXT
) )
918 pNavigatorWin
->maToolbox
.EnableItem( TBI_NEXT
);
919 if( nState
& NAVBTN_NEXT_DISABLED
&&
920 pNavigatorWin
->maToolbox
.IsItemEnabled( TBI_NEXT
) )
921 pNavigatorWin
->maToolbox
.EnableItem( TBI_NEXT
, sal_False
);
923 if( nState
& NAVTLB_UPDATE
)
925 // InitTlb; is initiated by Slot
934 * ControllerItem for Navigator to show page in TreeLB
936 SdPageNameControllerItem::SdPageNameControllerItem(
938 SdNavigatorWin
* pNavWin
,
939 SfxBindings
* _pBindings
,
940 const SdNavigatorWin::UpdateRequestFunctor
& rUpdateRequest
)
941 : SfxControllerItem( _nId
, *_pBindings
),
942 pNavigatorWin( pNavWin
),
943 maUpdateRequest(rUpdateRequest
)
947 // -----------------------------------------------------------------------
949 void SdPageNameControllerItem::StateChanged( sal_uInt16 nSId
,
950 SfxItemState eState
, const SfxPoolItem
* pItem
)
952 if( eState
>= SFX_ITEM_AVAILABLE
&& nSId
== SID_NAVIGATOR_PAGENAME
)
954 // only if doc in LB is the active
955 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
956 if( pInfo
&& pInfo
->IsActive() )
958 const SfxStringItem
* pStateItem
= PTR_CAST( SfxStringItem
, pItem
);
959 DBG_ASSERT( pStateItem
, "SfxStringItem expected");
960 String aPageName
= pStateItem
->GetValue();
962 if( !pNavigatorWin
->maTlbObjects
.HasSelectedChildren( aPageName
) )
964 if( pNavigatorWin
->maTlbObjects
.GetSelectionMode() == MULTIPLE_SELECTION
)
966 // because otherwise it is always additional select
967 pNavigatorWin
->maTlbObjects
.SelectAll( sal_False
);
969 pNavigatorWin
->maTlbObjects
.SelectEntry( aPageName
);
975 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */