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 .
21 #include <sal/config.h>
23 #include <osl/file.hxx>
24 #include <tools/urlobj.hxx>
25 #include <sfx2/fcontnr.hxx>
26 #include <svl/eitem.hxx>
27 #include <svl/stritem.hxx>
28 #include <sfx2/docfilt.hxx>
29 #include <sfx2/docfile.hxx>
30 #include <svl/intitem.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <svx/svxids.hrc>
34 #include <vcl/menu.hxx>
35 #include <vcl/settings.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <sfx2/dockwin.hxx>
41 #include <navigatr.hxx>
44 #include <strings.hrc>
46 #include <bitmaps.hlst>
47 #include <drawdoc.hxx>
48 #include <DrawDocShell.hxx>
49 #include <sdresid.hxx>
50 #include <ViewShell.hxx>
51 #include <ViewShellBase.hxx>
52 #include <DrawViewShell.hxx>
53 #include <slideshow.hxx>
54 #include <FrameView.hxx>
59 static const sal_uInt16 nShowNamedShapesFilter
=1;
60 static const sal_uInt16 nShowAllShapesFilter
=2;
64 * SdNavigatorWin - FloatingWindow
66 SdNavigatorWin::SdNavigatorWin(vcl::Window
* pParent
, SfxBindings
* pInBindings
)
67 : PanelLayout(pParent
, "NavigatorPanel", "modules/simpress/ui/navigatorpanel.ui", nullptr)
68 , mbDocImported ( false )
69 // On changes of the DragType: adjust SelectionMode of TLB!
70 , meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED
)
71 , mpBindings ( pInBindings
)
72 , mpNavigatorCtrlItem( nullptr )
73 , mpPageNameCtrlItem( nullptr )
75 get(maToolbox
, "toolbox");
76 get(maTlbObjects
, "tree");
77 Size
aSize(maTlbObjects
->LogicToPixel(Size(97, 67), MapMode(MapUnit::MapAppFont
)));
78 maTlbObjects
->set_height_request(aSize
.Width());
79 maTlbObjects
->set_width_request(aSize
.Height());
80 get(maLbDocs
, "documents");
82 maTlbObjects
->SetViewFrame( mpBindings
->GetDispatcher()->GetFrame() );
84 maTlbObjects
->SetAccessibleName(SdResId(STR_OBJECTS_TREE
));
86 maTlbObjects
->SetDoubleClickHdl(LINK(this, SdNavigatorWin
, ClickObjectHdl
));
87 maTlbObjects
->SetSelectionMode(SelectionMode::Single
);
89 maToolbox
->SetSelectHdl( LINK( this, SdNavigatorWin
, SelectToolboxHdl
) );
90 maToolbox
->SetDropdownClickHdl( LINK(this, SdNavigatorWin
, DropdownClickToolBoxHdl
) );
91 const sal_uInt16 nDragTypeId
= maToolbox
->GetItemId("dragmode");
92 maToolbox
->SetItemBits(nDragTypeId
, maToolbox
->GetItemBits(nDragTypeId
) | ToolBoxItemBits::DROPDOWNONLY
);
94 // Shape filter drop down menu.
95 const sal_uInt16 nShapeId
= maToolbox
->GetItemId("shapes");
96 maToolbox
->SetItemBits(nShapeId
, maToolbox
->GetItemBits(nShapeId
) | ToolBoxItemBits::DROPDOWNONLY
);
98 // set focus to listbox, otherwise it is in the toolbox which is only useful
99 // for keyboard navigation
100 maTlbObjects
->GrabFocus();
101 maTlbObjects
->SetSdNavigatorWinFlag(true);
104 maLbDocs
->SetSelectHdl( LINK( this, SdNavigatorWin
, SelectDocumentHdl
) );
107 void SdNavigatorWin::SetUpdateRequestFunctor(const UpdateRequestFunctor
& rUpdateRequest
)
109 mpNavigatorCtrlItem
= new SdNavigatorControllerItem(SID_NAVIGATOR_STATE
, this, mpBindings
, rUpdateRequest
);
110 mpPageNameCtrlItem
= new SdPageNameControllerItem(SID_NAVIGATOR_PAGENAME
, this, mpBindings
);
112 // InitTlb; is initiated over Slot
117 SdNavigatorWin::~SdNavigatorWin()
122 void SdNavigatorWin::dispose()
124 DELETEZ(mpNavigatorCtrlItem
);
125 DELETEZ(mpPageNameCtrlItem
);
127 maTlbObjects
.clear();
129 PanelLayout::dispose();
132 //when object is marked , fresh the corresponding entry tree .
133 void SdNavigatorWin::FreshTree( const SdDrawDocument
* pDoc
)
135 SdDrawDocument
* pNonConstDoc
= const_cast<SdDrawDocument
*>(pDoc
); // const as const can...
136 sd::DrawDocShell
* pDocShell
= pNonConstDoc
->GetDocSh();
137 OUString
aDocShName( pDocShell
->GetName() );
138 OUString aDocName
= pDocShell
->GetMedium()->GetName();
139 maTlbObjects
->SetSaveTreeItemStateFlag(true); //Added by yanjun for sym2_6385
140 maTlbObjects
->Clear();
141 maTlbObjects
->Fill( pDoc
, false, aDocName
); // Only normal pages
142 maTlbObjects
->SetSaveTreeItemStateFlag(false); //Added by yanjun for sym2_6385
144 maLbDocs
->SelectEntry( aDocShName
);
147 void SdNavigatorWin::FreshEntry( )
149 maTlbObjects
->Invalidate();
152 void SdNavigatorWin::InitTreeLB( const SdDrawDocument
* pDoc
)
154 SdDrawDocument
* pNonConstDoc
= const_cast<SdDrawDocument
*>(pDoc
); // const as const can...
155 ::sd::DrawDocShell
* pDocShell
= pNonConstDoc
->GetDocSh();
156 OUString
aDocShName( pDocShell
->GetName() );
157 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
159 // Restore the 'ShowAllShapes' flag from the last time (in this session)
160 // that the navigator was shown.
161 if (pViewShell
!= nullptr)
163 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
164 if (pFrameView
!= nullptr)
165 maTlbObjects
->SetShowAllShapes(pFrameView
->IsNavigatorShowingAllShapes(), false);
168 // Disable the shape filter drop down menu when there is a running slide
170 const sal_uInt16 nShapeId
= maToolbox
->GetItemId("shapes");
171 if (pViewShell
!=nullptr && sd::SlideShow::IsRunning( pViewShell
->GetViewShellBase() ))
172 maToolbox
->EnableItem(nShapeId
, false);
174 maToolbox
->EnableItem(nShapeId
);
176 if( !maTlbObjects
->IsEqualToDoc( pDoc
) )
178 OUString aDocName
= pDocShell
->GetMedium()->GetName();
179 maTlbObjects
->Clear();
180 maTlbObjects
->Fill( pDoc
, false, aDocName
); // only normal pages
183 maLbDocs
->SelectEntry( aDocShName
);
187 maLbDocs
->SetNoSelection();
188 maLbDocs
->SelectEntry( aDocShName
);
190 // commented in order to fix 30246
191 // if( maLbDocs->GetSelectedEntryCount() == 0 )
194 maLbDocs
->SelectEntry( aDocShName
);
198 SfxViewFrame
* pViewFrame
= ( ( pViewShell
&& pViewShell
->GetViewFrame() ) ? pViewShell
->GetViewFrame() : SfxViewFrame::Current() );
200 pViewFrame
->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME
, true, true);
204 * DragType is set on dependence if a Drag is even possible. For example,
205 * under certain circumstances, it is not allowed to drag graphics (#31038#).
207 NavigatorDragType
SdNavigatorWin::GetNavigatorDragType()
209 NavigatorDragType eDT
= meDragType
;
210 NavDocInfo
* pInfo
= GetDocInfo();
212 if( ( eDT
== NAVIGATOR_DRAGTYPE_LINK
) && ( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
->IsLinkableSelected() ) )
213 eDT
= NAVIGATOR_DRAGTYPE_NONE
;
218 VclPtr
<SdPageObjsTLB
> const & SdNavigatorWin::GetObjects()
223 IMPL_LINK_NOARG(SdNavigatorWin
, SelectToolboxHdl
, ToolBox
*, void)
225 sal_uInt16 nId
= maToolbox
->GetCurItemId();
226 const OUString sCommand
= maToolbox
->GetItemCommand(nId
);
227 PageJump ePage
= PAGE_NONE
;
229 if (sCommand
== "first")
232 maTlbObjects
->Select( maTlbObjects
->GetFirstEntryInView() );
234 else if (sCommand
== "previous")
236 ePage
= PAGE_PREVIOUS
;
237 if( maTlbObjects
->GetPrevEntryInView( maTlbObjects
->GetCurEntry() ) != nullptr )
238 maTlbObjects
->Select( maTlbObjects
->GetPrevEntryInView( maTlbObjects
->GetCurEntry() ) );
240 else if (sCommand
== "next")
243 if( maTlbObjects
->GetNextEntryInView( maTlbObjects
->GetCurEntry() ) != nullptr )
244 maTlbObjects
->Select( maTlbObjects
->GetNextEntryInView( maTlbObjects
->GetCurEntry() ) );
246 else if (sCommand
== "last")
249 maTlbObjects
->Select( maTlbObjects
->GetLastEntryInView() );
252 if (ePage
!= PAGE_NONE
)
254 SfxUInt16Item
aItem( SID_NAVIGATOR_PAGE
, static_cast<sal_uInt16
>(ePage
) );
255 mpBindings
->GetDispatcher()->ExecuteList(SID_NAVIGATOR_PAGE
,
256 SfxCallMode::SLOT
| SfxCallMode::RECORD
, { &aItem
});
260 IMPL_LINK( SdNavigatorWin
, DropdownClickToolBoxHdl
, ToolBox
*, pBox
, void )
262 sal_uInt16 nId
= maToolbox
->GetCurItemId();
263 const OUString sCommand
= maToolbox
->GetItemCommand(nId
);
265 if (sCommand
== "dragmode")
267 // Popup menu is created depending if the document is saved or not
268 ScopedVclPtrInstance
<PopupMenu
> pMenu
;
270 static const char* aHIDs
[] =
272 HID_SD_NAVIGATOR_MENU1
,
273 HID_SD_NAVIGATOR_MENU2
,
274 HID_SD_NAVIGATOR_MENU3
,
278 for (sal_uInt16 nID
= NAVIGATOR_DRAGTYPE_URL
; nID
< NAVIGATOR_DRAGTYPE_COUNT
; ++nID
)
280 const char* pRId
= GetDragTypeSdStrId(static_cast<NavigatorDragType
>(nID
));
283 DBG_ASSERT(aHIDs
[nID
-NAVIGATOR_DRAGTYPE_URL
],"HelpId not added!");
284 pMenu
->InsertItem(nID
, SdResId(pRId
), MenuItemBits::RADIOCHECK
);
285 pMenu
->SetHelpId(nID
, aHIDs
[nID
- NAVIGATOR_DRAGTYPE_URL
]);
289 NavDocInfo
* pInfo
= GetDocInfo();
291 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
->IsLinkableSelected() )
293 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_LINK
, false );
294 pMenu
->EnableItem( NAVIGATOR_DRAGTYPE_URL
, false );
295 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
298 pMenu
->CheckItem( static_cast<sal_uInt16
>(meDragType
) );
299 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, MenuSelectHdl
) );
301 pMenu
->Execute( this, maToolbox
->GetItemRect( nId
), PopupMenuFlags::ExecuteDown
);
302 pBox
->EndSelection();
304 else if (sCommand
== "shapes")
306 ScopedVclPtrInstance
<PopupMenu
> pMenu
;
309 nShowNamedShapesFilter
,
310 SdResId(STR_NAVIGATOR_SHOW_NAMED_SHAPES
),
311 MenuItemBits::RADIOCHECK
);
313 nShowAllShapesFilter
,
314 SdResId(STR_NAVIGATOR_SHOW_ALL_SHAPES
),
315 MenuItemBits::RADIOCHECK
);
317 if (maTlbObjects
->GetShowAllShapes())
318 pMenu
->CheckItem(nShowAllShapesFilter
);
320 pMenu
->CheckItem(nShowNamedShapesFilter
);
321 pMenu
->SetSelectHdl( LINK( this, SdNavigatorWin
, ShapeFilterCallback
) );
323 pMenu
->Execute( this, maToolbox
->GetItemRect( nId
), PopupMenuFlags::ExecuteDown
);
324 pBox
->EndSelection();
328 IMPL_LINK_NOARG(SdNavigatorWin
, ClickObjectHdl
, SvTreeListBox
*, bool)
330 if( !mbDocImported
|| maLbDocs
->GetSelectedEntryPos() != 0 )
332 NavDocInfo
* pInfo
= GetDocInfo();
334 // if it is the active window, we jump to the page
335 if( pInfo
&& pInfo
->IsActive() )
337 OUString
aStr( maTlbObjects
->GetSelectedEntry() );
339 if( !aStr
.isEmpty() )
341 SfxStringItem
aItem( SID_NAVIGATOR_OBJECT
, aStr
);
342 mpBindings
->GetDispatcher()->ExecuteList(
343 SID_NAVIGATOR_OBJECT
,
344 SfxCallMode::SLOT
| SfxCallMode::RECORD
, { &aItem
});
346 maTlbObjects
->Invalidate();
348 // moved here from SetGetFocusHdl. Reset the
349 // focus only if something has been selected in the
351 SfxViewShell
* pCurSh
= SfxViewShell::Current();
355 vcl::Window
* pShellWnd
= pCurSh
->GetWindow();
357 pShellWnd
->GrabFocus();
360 // We navigated to an object, but the current shell may be
361 // still the slide sorter. Explicitly try to grab the draw
362 // shell focus, so follow-up operations work with the object
363 // and not with the whole slide.
364 sd::DrawDocShell
* pDocShell
= pInfo
->mpDocShell
;
367 sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
370 vcl::Window
* pWindow
= pViewShell
->GetActiveWindow();
372 pWindow
->GrabFocus();
376 if (!maTlbObjects
->IsNavigationGrabsFocus())
377 // This is the case when keyboard navigation inside the
378 // navigator should continue to work.
379 maTlbObjects
->GrabFocus();
386 IMPL_LINK_NOARG(SdNavigatorWin
, SelectDocumentHdl
, ListBox
&, void)
388 OUString aStrLb
= maLbDocs
->GetSelectedEntry();
389 long nPos
= maLbDocs
->GetSelectedEntryPos();
391 ::sd::DrawDocShell
* pDocShell
= nullptr;
392 NavDocInfo
* pInfo
= GetDocInfo();
394 // is it a dragged object?
395 if( mbDocImported
&& nPos
== 0 )
397 // construct document in TLB
398 InsertFile( aStrLb
);
402 pDocShell
= pInfo
->mpDocShell
;
409 SdDrawDocument
* pDoc
= pDocShell
->GetDoc();
410 if( !maTlbObjects
->IsEqualToDoc( pDoc
) )
412 SdDrawDocument
* pNonConstDoc
= pDoc
; // const as const can...
413 ::sd::DrawDocShell
* pNCDocShell
= pNonConstDoc
->GetDocSh();
414 OUString aDocName
= pNCDocShell
->GetMedium()->GetName();
415 maTlbObjects
->Clear();
416 maTlbObjects
->Fill( pDoc
, false, aDocName
); // only normal pages
420 // check if link or url is possible
421 if( ( pInfo
&& !pInfo
->HasName() ) || !maTlbObjects
->IsLinkableSelected() || ( meDragType
!= NAVIGATOR_DRAGTYPE_EMBEDDED
) )
423 meDragType
= NAVIGATOR_DRAGTYPE_EMBEDDED
;
429 * Set DrageType and set image accordingly to it.
430 * If the handler is called with NULL, the default (URL) is set.
432 IMPL_LINK( SdNavigatorWin
, MenuSelectHdl
, Menu
*, pMenu
, bool )
436 nMenuId
= pMenu
->GetCurItemId();
438 nMenuId
= NAVIGATOR_DRAGTYPE_URL
;
440 if( nMenuId
!= USHRT_MAX
) // Necessary ?
442 NavigatorDragType eDT
= static_cast<NavigatorDragType
>(nMenuId
);
443 if( meDragType
!= eDT
)
448 if( meDragType
== NAVIGATOR_DRAGTYPE_URL
)
450 // patch, prevents endless loop
451 if( maTlbObjects
->GetSelectionCount() > 1 )
452 maTlbObjects
->SelectAll( false );
454 maTlbObjects
->SetSelectionMode( SelectionMode::Single
);
457 maTlbObjects
->SetSelectionMode( SelectionMode::Multiple
);
463 IMPL_LINK( SdNavigatorWin
, ShapeFilterCallback
, Menu
*, pMenu
, bool )
465 if (pMenu
!= nullptr)
467 bool bShowAllShapes (maTlbObjects
->GetShowAllShapes());
468 sal_uInt16
nMenuId (pMenu
->GetCurItemId());
471 case nShowNamedShapesFilter
:
472 bShowAllShapes
= false;
475 case nShowAllShapesFilter
:
476 bShowAllShapes
= true;
481 "SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
485 maTlbObjects
->SetShowAllShapes(bShowAllShapes
, true);
487 // Remember the selection in the FrameView.
488 NavDocInfo
* pInfo
= GetDocInfo();
489 if (pInfo
!= nullptr)
491 ::sd::DrawDocShell
* pDocShell
= pInfo
->mpDocShell
;
492 if (pDocShell
!= nullptr)
494 ::sd::ViewShell
* pViewShell
= pDocShell
->GetViewShell();
495 if (pViewShell
!= nullptr)
497 ::sd::FrameView
* pFrameView
= pViewShell
->GetFrameView();
498 if (pFrameView
!= nullptr)
500 pFrameView
->SetIsNavigatorShowingAllShapes(bShowAllShapes
);
510 bool SdNavigatorWin::InsertFile(const OUString
& rFileName
)
512 INetURLObject
aURL( rFileName
);
514 if( aURL
.GetProtocol() == INetProtocol::NotValid
)
517 osl::FileBase::getFileURLFromSystemPath( rFileName
, aURLStr
);
518 aURL
= INetURLObject( aURLStr
);
521 // get adjusted FileName
522 OUString
aFileName( aURL
.GetMainURL( INetURLObject::DecodeMechanism::NONE
) );
524 if (aFileName
.isEmpty())
526 // show actual document again
527 maDropFileName
= aFileName
;
531 // show dragged-in document
532 std::shared_ptr
<const SfxFilter
> pFilter
;
533 ErrCode nErr
= ERRCODE_NONE
;
535 if (aFileName
!= maDropFileName
)
537 SfxMedium
aMed(aFileName
, (StreamMode::READ
| StreamMode::SHARE_DENYNONE
));
538 SfxFilterMatcher
aMatch( "simpress" );
539 aMed
.UseInteractionHandler( true );
540 nErr
= aMatch
.GuessFilter(aMed
, pFilter
);
543 if ((pFilter
&& !nErr
) || aFileName
== maDropFileName
)
545 // The medium may be opened with READ/WRITE. Therefore, we first
546 // check if it contains a Storage.
547 std::unique_ptr
<SfxMedium
> xMedium(new SfxMedium(aFileName
,
548 StreamMode::READ
| StreamMode::NOCREATE
));
550 if (xMedium
->IsStorage())
552 // Now depending on mode:
553 // maTlbObjects->SetSelectionMode(SelectionMode::Multiple);
554 // handover of ownership of xMedium;
555 SdDrawDocument
* pDropDoc
= maTlbObjects
->GetBookmarkDoc(xMedium
.release());
559 maTlbObjects
->Clear();
560 maDropFileName
= aFileName
;
562 if( !maTlbObjects
->IsEqualToDoc( pDropDoc
) )
565 maTlbObjects
->Fill(pDropDoc
, false, maDropFileName
);
566 RefreshDocumentLB( &maDropFileName
);
584 void SdNavigatorWin::RefreshDocumentLB( const OUString
* pDocName
)
591 maLbDocs
->RemoveEntry( 0 );
593 maLbDocs
->InsertEntry( *pDocName
, 0 );
594 mbDocImported
= true;
598 nPos
= maLbDocs
->GetSelectedEntryPos();
599 if( nPos
== LISTBOX_ENTRY_NOTFOUND
)
604 aStr
= maLbDocs
->GetEntry( 0 );
608 // delete list of DocInfos
612 maLbDocs
->InsertEntry( aStr
, 0 );
614 ::sd::DrawDocShell
* pCurrentDocShell
=
615 dynamic_cast< ::sd::DrawDocShell
*>( SfxObjectShell::Current() );
616 SfxObjectShell
* pSfxDocShell
= SfxObjectShell::GetFirst([](const SfxObjectShell
*){return true;}, false);
617 while( pSfxDocShell
)
619 ::sd::DrawDocShell
* pDocShell
= dynamic_cast< ::sd::DrawDocShell
*>( pSfxDocShell
);
620 if( pDocShell
&& !pDocShell
->IsInDestruction() && ( pDocShell
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
) )
623 aInfo
.mpDocShell
= pDocShell
;
625 SfxMedium
*pMedium
= pDocShell
->GetMedium();
626 aStr
= pMedium
? pMedium
->GetName() : OUString();
627 if( !aStr
.isEmpty() )
628 aInfo
.SetName( true );
630 aInfo
.SetName( false );
631 // at the moment, we use the name of the shell again (i.e.
632 // without path) since Koose thinks it is an error if the path
633 // is shown in url notation!
634 aStr
= pDocShell
->GetName();
636 maLbDocs
->InsertEntry( aStr
);
638 if( pDocShell
== pCurrentDocShell
)
639 aInfo
.SetActive( true );
641 aInfo
.SetActive( false );
643 maDocList
.push_back( aInfo
);
645 pSfxDocShell
= SfxObjectShell::GetNext( *pSfxDocShell
, [](const SfxObjectShell
*){return true;}, false );
648 maLbDocs
->SelectEntryPos( nPos
);
651 const char* SdNavigatorWin::GetDragTypeSdStrId(NavigatorDragType eDT
)
655 case NAVIGATOR_DRAGTYPE_NONE
:
657 case NAVIGATOR_DRAGTYPE_URL
:
658 return STR_DRAGTYPE_URL
;
659 case NAVIGATOR_DRAGTYPE_EMBEDDED
:
660 return STR_DRAGTYPE_EMBEDDED
;
661 case NAVIGATOR_DRAGTYPE_LINK
:
662 return STR_DRAGTYPE_LINK
;
663 default: OSL_FAIL( "No resource for DragType available!" );
668 OUString
SdNavigatorWin::GetDragTypeSdBmpId(NavigatorDragType eDT
)
672 case NAVIGATOR_DRAGTYPE_NONE
:
674 case NAVIGATOR_DRAGTYPE_URL
:
675 return OUString(BMP_HYPERLINK
);
676 case NAVIGATOR_DRAGTYPE_EMBEDDED
:
677 return OUString(BMP_EMBEDDED
);
678 case NAVIGATOR_DRAGTYPE_LINK
:
679 return OUString(BMP_LINK
);
680 default: OSL_FAIL( "No resource for DragType available!" );
685 NavDocInfo
* SdNavigatorWin::GetDocInfo()
687 sal_uInt32 nPos
= maLbDocs
->GetSelectedEntryPos();
698 return nPos
< maDocList
.size() ? &(maDocList
[ nPos
]) : nullptr;
704 bool SdNavigatorWin::EventNotify(NotifyEvent
& rNEvt
)
706 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
711 if( KEY_ESCAPE
== pKEvt
->GetKeyCode().GetCode() )
713 if( SdPageObjsTLB::IsInDrag() )
715 // during drag'n'drop we just stop the drag but do not close the navigator
720 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
723 sd::SlideShow::Stop( *pBase
);
724 // Stopping the slide show may result in a synchronous
725 // deletion of the navigator window. Calling the
726 // parent's EventNotify after this is unsafe. Therefore we
735 bOK
= Window::EventNotify(rNEvt
);
741 * catch ESCAPE in order to end show
743 void SdNavigatorWin::KeyInput( const KeyEvent
& rKEvt
)
747 if (rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
)
749 if( SdPageObjsTLB::IsInDrag() )
751 // during drag'n'drop we just stop the drag but do not close the navigator
756 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( mpBindings
->GetDispatcher()->GetFrame());
759 ::sd::SlideShow::Stop( *pBase
);
766 Window::KeyInput(rKEvt
);
770 void SdNavigatorWin::SetDragImage()
772 const sal_uInt16 nDragTypeId
= maToolbox
->GetItemId("dragmode");
773 maToolbox
->SetItemImage(nDragTypeId
, Image(BitmapEx(GetDragTypeSdBmpId(meDragType
))));
777 * ControllerItem for Navigator
779 SdNavigatorControllerItem::SdNavigatorControllerItem(
781 SdNavigatorWin
* pNavWin
,
782 SfxBindings
* _pBindings
,
783 const SdNavigatorWin::UpdateRequestFunctor
& rUpdateRequest
)
784 : SfxControllerItem( _nId
, *_pBindings
),
785 pNavigatorWin( pNavWin
),
786 maUpdateRequest(rUpdateRequest
)
790 void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId
,
791 SfxItemState eState
, const SfxPoolItem
* pItem
)
793 if( eState
>= SfxItemState::DEFAULT
&& nSId
== SID_NAVIGATOR_STATE
)
795 const SfxUInt32Item
& rStateItem
= dynamic_cast<const SfxUInt32Item
&>(*pItem
);
796 NavState nState
= static_cast<NavState
>(rStateItem
.GetValue());
798 // only if doc in LB is the active
799 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
800 if( pInfo
&& pInfo
->IsActive() )
802 sal_uInt16 nFirstId
= pNavigatorWin
->maToolbox
->GetItemId("first");
803 sal_uInt16 nPrevId
= pNavigatorWin
->maToolbox
->GetItemId("previous");
804 sal_uInt16 nLastId
= pNavigatorWin
->maToolbox
->GetItemId("last");
805 sal_uInt16 nNextId
= pNavigatorWin
->maToolbox
->GetItemId("next");
808 if (nState
& NavState::BtnFirstEnabled
&&
809 !pNavigatorWin
->maToolbox
->IsItemEnabled(nFirstId
))
810 pNavigatorWin
->maToolbox
->EnableItem(nFirstId
);
811 if (nState
& NavState::BtnFirstDisabled
&&
812 pNavigatorWin
->maToolbox
->IsItemEnabled(nFirstId
))
813 pNavigatorWin
->maToolbox
->EnableItem(nFirstId
, false);
816 if (nState
& NavState::BtnPrevEnabled
&&
817 !pNavigatorWin
->maToolbox
->IsItemEnabled(nPrevId
))
818 pNavigatorWin
->maToolbox
->EnableItem(nPrevId
);
819 if (nState
& NavState::BtnPrevDisabled
&&
820 pNavigatorWin
->maToolbox
->IsItemEnabled(nPrevId
))
821 pNavigatorWin
->maToolbox
->EnableItem(nPrevId
, false);
824 if (nState
& NavState::BtnLastEnabled
&&
825 !pNavigatorWin
->maToolbox
->IsItemEnabled(nLastId
))
826 pNavigatorWin
->maToolbox
->EnableItem(nLastId
);
827 if (nState
& NavState::BtnLastDisabled
&&
828 pNavigatorWin
->maToolbox
->IsItemEnabled(nLastId
))
829 pNavigatorWin
->maToolbox
->EnableItem(nLastId
, false);
832 if (nState
& NavState::BtnNextEnabled
&&
833 !pNavigatorWin
->maToolbox
->IsItemEnabled(nNextId
))
834 pNavigatorWin
->maToolbox
->EnableItem(nNextId
);
835 if (nState
& NavState::BtnNextDisabled
&&
836 pNavigatorWin
->maToolbox
->IsItemEnabled(nNextId
))
837 pNavigatorWin
->maToolbox
->EnableItem(nNextId
, false);
839 if (nState
& NavState::TableUpdate
)
841 // InitTlb; is initiated by Slot
850 * ControllerItem for Navigator to show page in TreeLB
852 SdPageNameControllerItem::SdPageNameControllerItem(
854 SdNavigatorWin
* pNavWin
,
855 SfxBindings
* _pBindings
)
856 : SfxControllerItem( _nId
, *_pBindings
),
857 pNavigatorWin( pNavWin
)
861 void SdPageNameControllerItem::StateChanged( sal_uInt16 nSId
,
862 SfxItemState eState
, const SfxPoolItem
* pItem
)
864 if( eState
>= SfxItemState::DEFAULT
&& nSId
== SID_NAVIGATOR_PAGENAME
)
866 // only if doc in LB is the active
867 NavDocInfo
* pInfo
= pNavigatorWin
->GetDocInfo();
868 if( pInfo
&& pInfo
->IsActive() )
870 const SfxStringItem
& rStateItem
= dynamic_cast<const SfxStringItem
&>(*pItem
);
871 const OUString
& aPageName
= rStateItem
.GetValue();
873 if( !pNavigatorWin
->maTlbObjects
->HasSelectedChildren( aPageName
) )
875 if( pNavigatorWin
->maTlbObjects
->GetSelectionMode() == SelectionMode::Multiple
)
877 // because otherwise it is always additional select
878 pNavigatorWin
->maTlbObjects
->SelectAll( false );
880 pNavigatorWin
->maTlbObjects
->SelectEntry( aPageName
);
886 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */