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>
32 #include <vcl/menu.hxx>
33 #include <vcl/settings.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/dockwin.hxx>
37 #include <sfx2/sfxresid.hxx>
40 #include "navigatr.hxx"
41 #include "navigatr.hrc"
44 #include "strings.hrc"
45 #include "res_bmp.hrc"
46 #include "drawdoc.hxx"
47 #include "DrawDocShell.hxx"
48 #include "sdresid.hxx"
49 #include "ViewShell.hxx"
50 #include "ViewShellBase.hxx"
51 #include "DrawViewShell.hxx"
52 #include "slideshow.hxx"
53 #include "FrameView.hxx"
57 static const sal_uInt16 nShowNamedShapesFilter
=1;
58 static const sal_uInt16 nShowAllShapesFilter
=2;
62 * SdNavigatorWin - FloatingWindow
64 SdNavigatorWin::SdNavigatorWin(
66 ::sd::NavigatorChildWindow
* pChWinCtxt
,
67 const SdResId
& rSdResId
,
68 SfxBindings
* pInBindings
)
69 : vcl::Window( pParent
, rSdResId
)
70 , maToolbox ( VclPtr
<ToolBox
>::Create( this, SdResId( 1 ) ) )
71 , maTlbObjects( VclPtr
<SdPageObjsTLB
>::Create( this, SdResId( TLB_OBJECTS
) ) )
72 , maLbDocs ( VclPtr
<ListBox
>::Create( this, SdResId( LB_DOCS
) ) )
73 , mpChildWinContext( pChWinCtxt
)
74 , mbDocImported ( false )
75 // On changes of the DragType: adjust SelectionMode of TLB!
76 , meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED
)
77 , mpBindings ( pInBindings
)
78 , mpNavigatorCtrlItem( 0 )
79 , mpPageNameCtrlItem( 0 )
80 , maImageList ( SdResId( IL_NAVIGATR
) )
82 maTlbObjects
->SetViewFrame( mpBindings
->GetDispatcher()->GetFrame() );
86 maTlbObjects
->SetAccessibleName(SD_RESSTR(STR_OBJECTS_TREE
));
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
) | ToolBoxItemBits::DROPDOWNONLY
);
97 // Shape filter drop down menu.
98 maToolbox
->SetItemBits(
100 maToolbox
->GetItemBits(TBI_SHAPE_FILTER
) | ToolBoxItemBits::DROPDOWNONLY
);
103 // set position below toolbox
104 long nListboxYPos
= maToolbox
->GetPosPixel().Y() + maToolbox
->GetSizePixel().Height() + 4;
105 maTlbObjects
->setPosSizePixel( 0, nListboxYPos
, 0, 0, PosSizeFlags::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();
111 maTlbObjects
->SetSdNavigatorWinFlag(true);
114 maLbDocs
->SetSelectHdl( LINK( this, SdNavigatorWin
, SelectDocumentHdl
) );
115 // set position below treelistbox
116 nListboxYPos
= maTlbObjects
->GetPosPixel().Y() + maTlbObjects
->GetSizePixel().Height() + 4;
117 maLbDocs
->setPosSizePixel( 0, nListboxYPos
, 0, 0, PosSizeFlags::Y
);
119 // assure that tool box is at least as wide as the tree list box
121 const Size
aTlbSize( maTlbObjects
->GetOutputSizePixel() );
122 if ( aTlbSize
.Width() > aTbxSize
.Width() )
124 maToolbox
->setPosSizePixel( 0, 0, aTlbSize
.Width(), 0, PosSizeFlags::Width
);
125 aTbxSize
= maToolbox
->GetOutputSizePixel();
129 // set min outputsize after all sizes are known
130 const long nFullHeight
= nListboxYPos
+ maLbDocs
->GetSizePixel().Height() + 4;
131 maSize
= GetOutputSizePixel();
132 if( maSize
.Height() < nFullHeight
)
134 maSize
.Height() = nFullHeight
;
135 SetOutputSizePixel( maSize
);
138 const long nMinWidth
= 2*maToolbox
->GetPosPixel().X() + aTbxSize
.Width(); // never clip the toolbox
139 if( nMinWidth
> maMinSize
.Width() )
140 maMinSize
.Width() = nMinWidth
;
141 maMinSize
.Height() -= 40;
142 SfxDockingWindow
* pDockingParent
= dynamic_cast<SfxDockingWindow
*>(GetParent());
143 if (pDockingParent
!= NULL
)
144 pDockingParent
->SetMinOutputSizePixel( maMinSize
);
148 void SdNavigatorWin::SetUpdateRequestFunctor(const UpdateRequestFunctor
& rUpdateRequest
)
150 mpNavigatorCtrlItem
= new SdNavigatorControllerItem( SID_NAVIGATOR_STATE
, this, mpBindings
, rUpdateRequest
);
151 mpPageNameCtrlItem
= new SdPageNameControllerItem( SID_NAVIGATOR_PAGENAME
, this, mpBindings
, rUpdateRequest
);
153 // InitTlb; is initiated over Slot
158 SdNavigatorWin::~SdNavigatorWin()
163 void SdNavigatorWin::dispose()
165 DELETEZ( mpNavigatorCtrlItem
);
166 DELETEZ( mpPageNameCtrlItem
);
167 maToolbox
.disposeAndClear();
168 maTlbObjects
.disposeAndClear();
169 maLbDocs
.disposeAndClear();
170 vcl::Window::dispose();
173 //when object is marked , fresh the corresponding entry tree .
174 void SdNavigatorWin::FreshTree( const SdDrawDocument
* pDoc
)
176 SdDrawDocument
* pNonConstDoc
= const_cast<SdDrawDocument
*>(pDoc
); // const as const can...
177 sd::DrawDocShell
* pDocShell
= pNonConstDoc
->GetDocSh();
178 OUString
aDocShName( pDocShell
->GetName() );
179 OUString aDocName
= pDocShell
->GetMedium()->GetName();
180 maTlbObjects
->SetSaveTreeItemStateFlag(true); //Added by yanjun for sym2_6385
181 maTlbObjects
->Clear();
182 maTlbObjects
->Fill( pDoc
, false, aDocName
); // Nur normale Seiten
183 maTlbObjects
->SetSaveTreeItemStateFlag(false); //Added by yanjun for sym2_6385
185 maLbDocs
->SelectEntry( aDocShName
);
188 void SdNavigatorWin::FreshEntry( )
190 maTlbObjects
->FreshCurEntry();
193 void SdNavigatorWin::InitTreeLB( const SdDrawDocument
* pDoc
)
195 SdDrawDocument
* pNonConstDoc
= const_cast<SdDrawDocument
*>(pDoc
); // const as const can...
196 ::sd::DrawDocShell
* pDocShell
= pNonConstDoc
->GetDocSh();
197 OUString
aDocShName( pDocShell
->GetName() );
198 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
200 // Restore the 'ShowAllShapes' flag from the last time (in this session)
201 // that the navigator was shown.
202 if (pViewShell
!= NULL
)
204 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
205 if (pFrameView
!= NULL
)
206 maTlbObjects
->SetShowAllShapes(pFrameView
->IsNavigatorShowingAllShapes(), false);
209 // Disable the shape filter drop down menu when there is a running slide
211 if (pViewShell
!=NULL
&& sd::SlideShow::IsRunning( pViewShell
->GetViewShellBase() ))
212 maToolbox
->EnableItem(TBI_SHAPE_FILTER
, false);
214 maToolbox
->EnableItem(TBI_SHAPE_FILTER
);
216 if( !maTlbObjects
->IsEqualToDoc( pDoc
) )
218 OUString aDocName
= pDocShell
->GetMedium()->GetName();
219 maTlbObjects
->Clear();
220 maTlbObjects
->Fill( pDoc
, false, aDocName
); // only normal pages
223 maLbDocs
->SelectEntry( aDocShName
);
227 maLbDocs
->SetNoSelection();
228 maLbDocs
->SelectEntry( aDocShName
);
230 // commented in order to fix 30246
231 // if( maLbDocs->GetSelectEntryCount() == 0 )
234 maLbDocs
->SelectEntry( aDocShName
);
238 SfxViewFrame
* pViewFrame
= ( ( pViewShell
&& pViewShell
->GetViewFrame() ) ? pViewShell
->GetViewFrame() : SfxViewFrame::Current() );
240 pViewFrame
->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME
, true, true);
244 * DragType is set on dependence if a Drag is even possible. For example,
245 * under certain circumstances, it is not allowed to drag graphics (#31038#).
247 NavigatorDragType
SdNavigatorWin::GetNavigatorDragType()
249 NavigatorDragType eDT
= meDragType
;
250 NavDocInfo
* pInfo
= GetDocInfo();
252 if( ( eDT
== NAVIGATOR_DRAGTYPE_LINK
) && ( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
->IsLinkableSelected() ) )
253 eDT
= NAVIGATOR_DRAGTYPE_NONE
;
259 sd::DrawDocShell
* SdNavigatorWin::GetDrawDocShell( const SdDrawDocument
* pDoc
)
262 return NULL
; // const as const can...
263 sd::DrawDocShell
* pDocShell
= pDoc
->GetDocSh();
267 IMPL_LINK_NOARG_TYPED(SdNavigatorWin
, SelectToolboxHdl
, ToolBox
*, void)
269 sal_uInt16 nId
= maToolbox
->GetCurItemId();
271 PageJump ePage
= PAGE_NONE
;
279 nSId
= SID_NAVIGATOR_PEN
;
284 SfxBoolItem
aItem( nSId
, true );
285 mpBindings
->GetDispatcher()->Execute(
286 nSId
, SfxCallMode::SLOT
|SfxCallMode::RECORD
, &aItem
, 0L );
296 if( nId
== TBI_FIRST
)
298 else if( nId
== TBI_PREVIOUS
)
299 ePage
= PAGE_PREVIOUS
;
300 else if( nId
== TBI_NEXT
)
302 else if( nId
== TBI_LAST
)
305 if( ePage
!= PAGE_NONE
)
307 SfxUInt16Item
aItem( SID_NAVIGATOR_PAGE
, (sal_uInt16
)ePage
);
308 mpBindings
->GetDispatcher()->Execute(
309 SID_NAVIGATOR_PAGE
, SfxCallMode::SLOT
| SfxCallMode::RECORD
, &aItem
, 0L );
316 IMPL_STATIC_LINK_NOARG_TYPED(
317 SdNavigatorWin
, ClickToolboxHdl
, ToolBox
*, void)
320 IMPL_LINK_TYPED( SdNavigatorWin
, DropdownClickToolBoxHdl
, ToolBox
*, pBox
, void )
322 sal_uInt16 nId
= maToolbox
->GetCurItemId();
328 // Popup menu is created depending if the document is saved or not
329 PopupMenu
*pMenu
= new PopupMenu
;
331 static const char* aHIDs
[] =
333 HID_SD_NAVIGATOR_MENU1
,
334 HID_SD_NAVIGATOR_MENU2
,
335 HID_SD_NAVIGATOR_MENU3
,
339 for( sal_uInt16 nID
= NAVIGATOR_DRAGTYPE_URL
;
340 nID
< NAVIGATOR_DRAGTYPE_COUNT
;
343 sal_uInt16 nRId
= GetDragTypeSdResId( (NavigatorDragType
)nID
);
346 DBG_ASSERT(aHIDs
[nID
-NAVIGATOR_DRAGTYPE_URL
],"HelpId not added!");
347 pMenu
->InsertItem( nID
, SD_RESSTR( nRId
) );
348 pMenu
->SetHelpId( nID
, aHIDs
[nID
- NAVIGATOR_DRAGTYPE_URL
] );
352 NavDocInfo
* pInfo
= GetDocInfo();
354 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
->IsLinkableSelected() )
356 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_LINK
, false );
357 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_URL
, false );
358 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
361 pMenu
->CheckItem( (sal_uInt16
)meDragType
);
362 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, MenuSelectHdl
) );
364 pMenu
->Execute( this, maToolbox
->GetItemRect( nId
), PopupMenuFlags::ExecuteDown
);
365 pBox
->EndSelection();
370 case TBI_SHAPE_FILTER
:
372 PopupMenu
*pMenu
= new PopupMenu
;
375 nShowNamedShapesFilter
,
376 SD_RESSTR(STR_NAVIGATOR_SHOW_NAMED_SHAPES
));
378 nShowAllShapesFilter
,
379 SD_RESSTR(STR_NAVIGATOR_SHOW_ALL_SHAPES
));
381 if (maTlbObjects
->GetShowAllShapes())
382 pMenu
->CheckItem(nShowAllShapesFilter
);
384 pMenu
->CheckItem(nShowNamedShapesFilter
);
385 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, ShapeFilterCallback
) );
387 pMenu
->Execute( this, maToolbox
->GetItemRect( nId
), PopupMenuFlags::ExecuteDown
);
388 pBox
->EndSelection();
395 IMPL_LINK_NOARG(SdNavigatorWin
, ClickObjectHdl
)
397 if( !mbDocImported
|| maLbDocs
->GetSelectEntryPos() != 0 )
399 NavDocInfo
* pInfo
= GetDocInfo();
401 // if it is the active window, we jump to the page
402 if( pInfo
&& pInfo
->IsActive() )
404 OUString
aStr( maTlbObjects
->GetSelectEntry() );
406 if( !aStr
.isEmpty() )
408 SfxStringItem
aItem( SID_NAVIGATOR_OBJECT
, aStr
);
409 mpBindings
->GetDispatcher()->Execute(
410 SID_NAVIGATOR_OBJECT
, SfxCallMode::SLOT
| SfxCallMode::RECORD
, &aItem
, 0L );
412 maTlbObjects
->MarkCurEntry(aStr
);
414 // moved here from SetGetFocusHdl. Reset the
415 // focus only if something has been selected in the
417 SfxViewShell
* pCurSh
= SfxViewShell::Current();
421 vcl::Window
* pShellWnd
= pCurSh
->GetWindow();
423 pShellWnd
->GrabFocus();
431 IMPL_LINK_NOARG(SdNavigatorWin
, SelectDocumentHdl
)
433 OUString aStrLb
= maLbDocs
->GetSelectEntry();
434 long nPos
= maLbDocs
->GetSelectEntryPos();
436 ::sd::DrawDocShell
* pDocShell
= NULL
;
437 NavDocInfo
* pInfo
= GetDocInfo();
439 // is it a dragged object?
440 if( mbDocImported
&& nPos
== 0 )
442 // construct document in TLB
443 InsertFile( aStrLb
);
447 pDocShell
= pInfo
->mpDocShell
;
454 SdDrawDocument
* pDoc
= pDocShell
->GetDoc();
455 if( !maTlbObjects
->IsEqualToDoc( pDoc
) )
457 SdDrawDocument
* pNonConstDoc
= pDoc
; // const as const can...
458 ::sd::DrawDocShell
* pNCDocShell
= pNonConstDoc
->GetDocSh();
459 OUString aDocName
= pNCDocShell
->GetMedium()->GetName();
460 maTlbObjects
->Clear();
461 maTlbObjects
->Fill( pDoc
, false, aDocName
); // only normal pages
465 // check if link or url is possible
466 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
->IsLinkableSelected() || ( meDragType
!= NAVIGATOR_DRAGTYPE_EMBEDDED
) )
468 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
476 * Set DrageType and set image accordingly to it.
477 * If the handler is called with NULL, the default (URL) is set.
479 IMPL_LINK( SdNavigatorWin
, MenuSelectHdl
, Menu
*, pMenu
)
483 nMenuId
= pMenu
->GetCurItemId();
485 nMenuId
= NAVIGATOR_DRAGTYPE_URL
;
487 if( nMenuId
!= USHRT_MAX
) // Necessary ?
489 NavigatorDragType eDT
= (NavigatorDragType
) nMenuId
;
490 if( meDragType
!= eDT
)
495 if( meDragType
== NAVIGATOR_DRAGTYPE_URL
)
497 // patch, prevents endless loop
498 if( maTlbObjects
->GetSelectionCount() > 1 )
499 maTlbObjects
->SelectAll( false );
501 maTlbObjects
->SetSelectionMode( SINGLE_SELECTION
);
504 maTlbObjects
->SetSelectionMode( MULTIPLE_SELECTION
);
510 IMPL_LINK( SdNavigatorWin
, ShapeFilterCallback
, Menu
*, pMenu
)
514 bool bShowAllShapes (maTlbObjects
->GetShowAllShapes());
515 sal_uInt16
nMenuId (pMenu
->GetCurItemId());
518 case nShowNamedShapesFilter
:
519 bShowAllShapes
= false;
522 case nShowAllShapesFilter
:
523 bShowAllShapes
= true;
528 "SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
532 maTlbObjects
->SetShowAllShapes(bShowAllShapes
, true);
534 // Remember the selection in the FrameView.
535 NavDocInfo
* pInfo
= GetDocInfo();
538 ::sd::DrawDocShell
* pDocShell
= pInfo
->mpDocShell
;
539 if (pDocShell
!= NULL
)
541 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
542 if (pViewShell
!= NULL
)
544 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
545 if (pFrameView
!= NULL
)
547 pFrameView
->SetIsNavigatorShowingAllShapes(bShowAllShapes
);
557 void SdNavigatorWin::Resize()
559 Size
aWinSize( GetOutputSizePixel() );
560 if( aWinSize
.Height() >= maMinSize
.Height() )
561 //aWinSize.Width() >= maMinSize.Width() )
564 aDiffSize
.Width() = aWinSize
.Width() - maSize
.Width();
565 aDiffSize
.Height() = aWinSize
.Height() - maSize
.Height();
567 // change size of Toolbox
568 Size
aObjSize( maToolbox
->GetOutputSizePixel() );
569 aObjSize
.Width() += aDiffSize
.Width();
570 maToolbox
->SetOutputSizePixel( aObjSize
);
572 // change size of TreeLB
573 aObjSize
= maTlbObjects
->GetSizePixel();
574 aObjSize
.Width() += aDiffSize
.Width();
575 aObjSize
.Height() = maLbDocs
->GetPosPixel().Y() + aDiffSize
.Height() -
576 maTlbObjects
->GetPosPixel().Y() - 4;
577 maTlbObjects
->SetSizePixel( aObjSize
);
579 Point
aPt( 0, aDiffSize
.Height() );
581 // move other controls (DocumentLB)
583 aObjSize
= maLbDocs
->GetOutputSizePixel();
584 aObjSize
.Width() += aDiffSize
.Width();
585 maLbDocs
->SetPosPixel( maLbDocs
->GetPosPixel() + aPt
);
586 maLbDocs
->SetOutputSizePixel( aObjSize
);
594 bool SdNavigatorWin::InsertFile(const OUString
& rFileName
)
596 INetURLObject
aURL( rFileName
);
598 if( aURL
.GetProtocol() == INetProtocol::NotValid
)
601 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rFileName
, aURLStr
);
602 aURL
= INetURLObject( aURLStr
);
605 // get adjusted FileName
606 OUString
aFileName( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
608 if (aFileName
.isEmpty())
610 // show actual document again
611 maDropFileName
= aFileName
;
615 // show dragged-in document
616 const SfxFilter
* pFilter
= NULL
;
619 if (aFileName
!= maDropFileName
)
621 SfxMedium
aMed(aFileName
, (StreamMode::READ
| StreamMode::SHARE_DENYNONE
));
622 SfxFilterMatcher
aMatch( OUString("simpress") );
623 aMed
.UseInteractionHandler( true );
624 nErr
= aMatch
.GuessFilter(aMed
, &pFilter
);
627 if ((pFilter
&& !nErr
) || aFileName
== maDropFileName
)
629 // The medium may be opened with READ/WRITE. Therefore, we first
630 // check if it contains a Storage.
631 SfxMedium
* pMedium
= new SfxMedium( aFileName
,
632 StreamMode::READ
| StreamMode::NOCREATE
);
634 if (pMedium
->IsStorage())
636 // Now depending on mode:
637 // maTlbObjects->SetSelectionMode(MULTIPLE_SELECTION);
638 // handover of ownership of pMedium;
639 SdDrawDocument
* pDropDoc
= maTlbObjects
->GetBookmarkDoc(pMedium
);
643 maTlbObjects
->Clear();
644 maDropFileName
= aFileName
;
646 if( !maTlbObjects
->IsEqualToDoc( pDropDoc
) )
649 maTlbObjects
->Fill(pDropDoc
, false, maDropFileName
);
650 RefreshDocumentLB( &maDropFileName
);
669 void SdNavigatorWin::RefreshDocumentLB( const OUString
* pDocName
)
676 maLbDocs
->RemoveEntry( 0 );
678 maLbDocs
->InsertEntry( *pDocName
, 0 );
679 mbDocImported
= true;
683 nPos
= maLbDocs
->GetSelectEntryPos();
684 if( nPos
== LISTBOX_ENTRY_NOTFOUND
)
689 aStr
= maLbDocs
->GetEntry( 0 );
693 // delete list of DocInfos
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() != SfxObjectCreateMode::EMBEDDED
) )
708 aInfo
.mpDocShell
= pDocShell
;
710 SfxMedium
*pMedium
= pDocShell
->GetMedium();
711 aStr
= pMedium
? pMedium
->GetName() : OUString();
712 if( !aStr
.isEmpty() )
715 aInfo
.SetName( false );
716 // at the moment, we use the name of the shell again (i.e.
717 // without path) since Koose thinks it is an error if the path
718 // is shown in url notation!
719 aStr
= pDocShell
->GetName();
721 maLbDocs
->InsertEntry( aStr
, LISTBOX_APPEND
);
723 if( pDocShell
== pCurrentDocShell
)
726 aInfo
.SetActive( false );
728 maDocList
.push_back( aInfo
);
730 pSfxDocShell
= SfxObjectShell::GetNext( *pSfxDocShell
, 0, false );
733 maLbDocs
->SelectEntryPos( nPos
);
736 sal_uInt16
SdNavigatorWin::GetDragTypeSdResId( NavigatorDragType eDT
, bool bImage
)
740 case NAVIGATOR_DRAGTYPE_NONE
:
741 return( bImage
? 0 : STR_NONE
);
742 case NAVIGATOR_DRAGTYPE_URL
:
743 return( bImage
? TBI_HYPERLINK
: STR_DRAGTYPE_URL
);
744 case NAVIGATOR_DRAGTYPE_EMBEDDED
:
745 return( bImage
? TBI_EMBEDDED
: STR_DRAGTYPE_EMBEDDED
);
746 case NAVIGATOR_DRAGTYPE_LINK
:
747 return( bImage
? TBI_LINK
: STR_DRAGTYPE_LINK
);
748 default: OSL_FAIL( "No resource for DragType available!" );
753 NavDocInfo
* SdNavigatorWin::GetDocInfo()
755 sal_uInt32 nPos
= maLbDocs
->GetSelectEntryPos();
766 return nPos
< maDocList
.size() ? &(maDocList
[ nPos
]) : NULL
;
772 bool SdNavigatorWin::Notify(NotifyEvent
& rNEvt
)
774 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
779 if( KEY_ESCAPE
== pKEvt
->GetKeyCode().GetCode() )
781 if( SdPageObjsTLB::IsInDrag() )
783 // during drag'n'drop we just stop the drag but do not close the navigator
788 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
791 sd::SlideShow::Stop( *pBase
);
792 // Stopping the slide show may result in a synchronous
793 // deletion of the navigator window. Calling the
794 // parents Notify after this is unsafe. Therefore we
803 nOK
= Window::Notify( rNEvt
);
809 * catch ESCAPE in order to end show
811 void SdNavigatorWin::KeyInput( const KeyEvent
& rKEvt
)
815 if (rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
)
817 if( SdPageObjsTLB::IsInDrag() )
819 // during drag'n'drop we just stop the drag but do not close the navigator
824 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
827 ::sd::SlideShow::Stop( *pBase
);
834 Window::KeyInput(rKEvt
);
838 void SdNavigatorWin::DataChanged( const DataChangedEvent
& rDCEvt
)
840 if ( (rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) && (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
843 Window::DataChanged( rDCEvt
);
846 void SdNavigatorWin::SetDragImage()
848 maToolbox
->SetItemImage( TBI_DRAGTYPE
, maToolbox
->GetImageList().GetImage( GetDragTypeSdResId( meDragType
, true ) ) );
851 void SdNavigatorWin::ApplyImageList()
854 maToolbox
->SetImageList( maImageList
);
855 maToolbox
->SetItemImage(TBI_SHAPE_FILTER
, Image(BitmapEx(SdResId(BMP_GRAPHIC
))));
861 * ControllerItem for Navigator
863 SdNavigatorControllerItem::SdNavigatorControllerItem(
865 SdNavigatorWin
* pNavWin
,
866 SfxBindings
* _pBindings
,
867 const SdNavigatorWin::UpdateRequestFunctor
& rUpdateRequest
)
868 : SfxControllerItem( _nId
, *_pBindings
),
869 pNavigatorWin( pNavWin
),
870 maUpdateRequest(rUpdateRequest
)
874 void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId
,
875 SfxItemState eState
, const SfxPoolItem
* pItem
)
877 if( eState
>= SfxItemState::DEFAULT
&& nSId
== SID_NAVIGATOR_STATE
)
879 const SfxUInt32Item
* pStateItem
= PTR_CAST( SfxUInt32Item
, pItem
);
880 DBG_ASSERT( pStateItem
, "SfxUInt16Item expected");
881 sal_uInt32 nState
= pStateItem
->GetValue();
884 if( nState
& NAVBTN_PEN_ENABLED
&&
885 !pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_PEN
) )
886 pNavigatorWin
->maToolbox
->EnableItem( TBI_PEN
);
887 if( nState
& NAVBTN_PEN_DISABLED
&&
888 pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_PEN
) )
889 pNavigatorWin
->maToolbox
->EnableItem( TBI_PEN
, false );
890 if( nState
& NAVBTN_PEN_CHECKED
&&
891 !pNavigatorWin
->maToolbox
->IsItemChecked( TBI_PEN
) )
892 pNavigatorWin
->maToolbox
->CheckItem( TBI_PEN
);
893 if( nState
& NAVBTN_PEN_UNCHECKED
&&
894 pNavigatorWin
->maToolbox
->IsItemChecked( TBI_PEN
) )
895 pNavigatorWin
->maToolbox
->CheckItem( TBI_PEN
, false );
897 // only if doc in LB is the active
898 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
899 if( pInfo
&& pInfo
->IsActive() )
902 if( nState
& NAVBTN_FIRST_ENABLED
&&
903 !pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_FIRST
) )
904 pNavigatorWin
->maToolbox
->EnableItem( TBI_FIRST
);
905 if( nState
& NAVBTN_FIRST_DISABLED
&&
906 pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_FIRST
) )
907 pNavigatorWin
->maToolbox
->EnableItem( TBI_FIRST
, false );
910 if( nState
& NAVBTN_PREV_ENABLED
&&
911 !pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_PREVIOUS
) )
912 pNavigatorWin
->maToolbox
->EnableItem( TBI_PREVIOUS
);
913 if( nState
& NAVBTN_PREV_DISABLED
&&
914 pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_PREVIOUS
) )
915 pNavigatorWin
->maToolbox
->EnableItem( TBI_PREVIOUS
, false );
918 if( nState
& NAVBTN_LAST_ENABLED
&&
919 !pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_LAST
) )
920 pNavigatorWin
->maToolbox
->EnableItem( TBI_LAST
);
921 if( nState
& NAVBTN_LAST_DISABLED
&&
922 pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_LAST
) )
923 pNavigatorWin
->maToolbox
->EnableItem( TBI_LAST
, false );
926 if( nState
& NAVBTN_NEXT_ENABLED
&&
927 !pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_NEXT
) )
928 pNavigatorWin
->maToolbox
->EnableItem( TBI_NEXT
);
929 if( nState
& NAVBTN_NEXT_DISABLED
&&
930 pNavigatorWin
->maToolbox
->IsItemEnabled( TBI_NEXT
) )
931 pNavigatorWin
->maToolbox
->EnableItem( TBI_NEXT
, false );
933 if( nState
& NAVTLB_UPDATE
)
935 // InitTlb; is initiated by Slot
944 * ControllerItem for Navigator to show page in TreeLB
946 SdPageNameControllerItem::SdPageNameControllerItem(
948 SdNavigatorWin
* pNavWin
,
949 SfxBindings
* _pBindings
,
950 const SdNavigatorWin::UpdateRequestFunctor
& rUpdateRequest
)
951 : SfxControllerItem( _nId
, *_pBindings
),
952 pNavigatorWin( pNavWin
),
953 maUpdateRequest(rUpdateRequest
)
957 void SdPageNameControllerItem::StateChanged( sal_uInt16 nSId
,
958 SfxItemState eState
, const SfxPoolItem
* pItem
)
960 if( eState
>= SfxItemState::DEFAULT
&& nSId
== SID_NAVIGATOR_PAGENAME
)
962 // only if doc in LB is the active
963 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
964 if( pInfo
&& pInfo
->IsActive() )
966 const SfxStringItem
* pStateItem
= PTR_CAST( SfxStringItem
, pItem
);
967 DBG_ASSERT( pStateItem
, "SfxStringItem expected");
968 OUString aPageName
= pStateItem
->GetValue();
970 if( !pNavigatorWin
->maTlbObjects
->HasSelectedChildren( aPageName
) )
972 if( pNavigatorWin
->maTlbObjects
->GetSelectionMode() == MULTIPLE_SELECTION
)
974 // because otherwise it is always additional select
975 pNavigatorWin
->maTlbObjects
->SelectAll( false );
977 pNavigatorWin
->maTlbObjects
->SelectEntry( aPageName
);
983 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */