23#include <osl/file.hxx>
38#include <bitmaps.hlst>
57 :
PanelLayout(pParent,
"NavigatorPanel",
"modules/simpress/ui/navigatorpanel.ui")
58 , mxToolbox(m_xBuilder->weld_toolbar(
"toolbox"))
59 , mxTlbObjects(new
SdPageObjsTLV(m_xBuilder->weld_tree_view(
"tree")))
60 , mxLbDocs(m_xBuilder->weld_combo_box(
"documents"))
61 , mxDragModeMenu(m_xBuilder->weld_menu(
"dragmodemenu"))
62 , mxShapeMenu(m_xBuilder->weld_menu(
"shapemenu"))
63 , mxNavigatorDlg(pNavigatorDlg)
64 , mbDocImported ( false )
67 , mpBindings ( pInBindings )
72 mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
143 auto vMarkedObjects = pView->GetMarkedObjects();
144 if (vMarkedObjects.size())
147 for (
auto rMarkedObject: vMarkedObjects)
160 const OUString& aDocShName( pDocShell->
GetName() );
166 mxLbDocs->set_active_text(aDocShName);
176 OUString aDocShName( pDocShell->
GetName() );
181 if (pViewShell !=
nullptr)
184 if (pFrameView !=
nullptr)
191 mxToolbox->set_item_sensitive(
"shapes",
false);
193 mxToolbox->set_item_sensitive(
"shapes",
true);
202 mxLbDocs->set_active_text(aDocShName);
207 mxLbDocs->set_active_text(aDocShName);
213 mxLbDocs->set_active_text(aDocShName);
252 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
256 "modules/sdraw/ui/navigatorcontextmenu.ui"));
257 std::unique_ptr<weld::Menu> xPop = xBuilder->weld_menu(
"navmenu");
258 OUString sCommand = xPop->popup_at_rect(&rTreeView,
260 if (!sCommand.isEmpty())
261 ExecuteContextMenuAction(sCommand);
267 if (rSelectedPopupEntry ==
u"rename")
275 if (rCommand ==
"first")
277 else if (rCommand ==
"previous")
279 else if (rCommand ==
"next")
281 else if (rCommand ==
"last")
283 else if (rCommand ==
"dragmode")
284 mxToolbox->set_menu_item_active(
"dragmode", !mxToolbox->get_menu_item_active(
"dragmode"));
285 else if (rCommand ==
"shapes")
286 mxToolbox->set_menu_item_active(
"shapes", !mxToolbox->get_menu_item_active(
"shapes"));
290 SfxUInt16Item aItem( SID_NAVIGATOR_PAGE,
static_cast<sal_uInt16
>(ePage) );
291 mpBindings->GetDispatcher()->ExecuteList(SID_NAVIGATOR_PAGE,
292 SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
298 if (!mxToolbox->get_menu_item_active(rCommand))
301 if (rCommand ==
"dragmode")
304 if( ( pInfo && !pInfo->
HasName() ) || !mxTlbObjects->IsLinkableSelected() )
311 mxDragModeMenu->set_active(OUString::number(meDragType),
true);
313 else if (rCommand ==
"shapes")
315 bool bAll = mxTlbObjects->GetShowAllShapes();
316 mxShapeMenu->set_active(
"named", !bAll);
317 mxShapeMenu->set_active(
"all", bAll);
318 bool bOrderFrontToBack = mxTlbObjects->GetOrderFrontToBack();
319 mxShapeMenu->set_active(
"fronttoback", bOrderFrontToBack);
320 mxShapeMenu->set_active(
"backtofront", !bOrderFrontToBack);
326 if( !mbDocImported || mxLbDocs->get_active() != 0 )
333 OUString
aStr(mxTlbObjects->get_cursor_text());
335 if( !
aStr.isEmpty() )
348 auto vSelectedEntryIds = mxTlbObjects->GetSelectedEntryIds();
352 const auto& rCursorEntryId = mxTlbObjects->get_cursor_id();
353 auto nCursorEntryId = rCursorEntryId.toInt64();
354 SdrObject* pCursorEntryObject = weld::fromId<SdrObject*>(rCursorEntryId);
356 bool bIsCursorEntrySelected(std::find(vSelectedEntryIds.begin(),
357 vSelectedEntryIds.end(),
358 rCursorEntryId) != vSelectedEntryIds.end());
360 if (bIsCursorEntrySelected)
363 bool bCursorEntryObjectHasEmptyName =
false;
364 if (nCursorEntryId != 1 && pCursorEntryObject
365 && pCursorEntryObject->
GetName().isEmpty())
367 bCursorEntryObjectHasEmptyName =
true;
376 mpBindings->GetDispatcher()->ExecuteList(SID_NAVIGATOR_OBJECT,
377 SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
379 if (bCursorEntryObjectHasEmptyName)
383 pCursorEntryObject->
SetName(OUString(),
false);
388 if (bIsCursorEntrySelected)
391 for (
auto& rEntryId: vSelectedEntryIds)
395 SdrObject* pEntryObject = weld::fromId<SdrObject*>(rEntryId);
402 else if (nCursorEntryId != 1 && pCursorEntryObject)
428 if (!mxTlbObjects->IsNavigationGrabsFocus())
433 mxNavigatorDlg->GrabFocus();
434 mxTlbObjects->grab_focus();
444 OUString aStrLb = mxLbDocs->get_active_text();
451 if( mbDocImported &&
nPos == 0 )
466 if( !mxTlbObjects->IsEqualToDoc( pDoc ) )
471 mxTlbObjects->clear();
472 mxTlbObjects->Fill( pDoc,
false, aDocName );
489 sal_uInt32 nMenuId = rIdent.toUInt32();
492 if( meDragType == eDT )
501 if (mxTlbObjects->count_selected_rows() > 1)
502 mxTlbObjects->unselect_all();
504 mxTlbObjects->set_selection_mode(SelectionMode::Single);
507 mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
512 bool bShowAllShapes(mxTlbObjects->GetShowAllShapes());
513 bool bOrderFrontToBack(mxTlbObjects->GetOrderFrontToBack());
514 if (rIdent ==
"named")
515 bShowAllShapes =
false;
516 else if (rIdent ==
"all")
517 bShowAllShapes =
true;
518 else if (rIdent ==
"fronttoback")
519 bOrderFrontToBack =
true;
520 else if (rIdent ==
"backtofront")
521 bOrderFrontToBack =
false;
523 OSL_FAIL(
"SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
525 mxTlbObjects->SetOrderFrontToBack(bOrderFrontToBack);
526 mxTlbObjects->SetShowAllShapes(bShowAllShapes,
true);
530 if (pInfo ==
nullptr)
534 if (pDocShell !=
nullptr)
537 if (pViewShell !=
nullptr)
540 if (pFrameView !=
nullptr)
553 if(
aURL.GetProtocol() == INetProtocol::NotValid )
556 osl::FileBase::getFileURLFromSystemPath( rFileName, aURLStr );
563 if (aFileName.isEmpty())
571 std::shared_ptr<const SfxFilter> pFilter;
576 SfxMedium aMed(aFileName, (StreamMode::READ | StreamMode::SHARE_DENYNONE));
586 std::unique_ptr<SfxMedium> xMedium(
new SfxMedium(aFileName,
587 StreamMode::READ | StreamMode::NOCREATE));
589 if (xMedium->IsStorage())
632 mxLbDocs->insert_text(0, *pDocName);
656 while( pSfxDocShell )
666 if( !
aStr.isEmpty() )
677 if( pDocShell == pCurrentDocShell )
697 return BMP_HYPERLINK;
702 default: OSL_FAIL(
"No resource for DragType available!" );
728 bool bConsumed =
false;
730 if (
KEY_ESCAPE == rKEvt.GetKeyCode().GetCode())
759 pNavigatorWin( pNavWin ),
760 maUpdateRequest(
std::move(aUpdateRequest))
767 if( eState < SfxItemState::DEFAULT || nSId != SID_NAVIGATOR_STATE )
777 const auto pDrawViewShell =
782 bool bEditModePage(pDrawViewShell->GetEditMode() ==
EditMode::Page);
840 pNavigatorWin( pNavWin )
847 if( eState < SfxItemState::DEFAULT || nSId != SID_NAVIGATOR_PAGENAME )
858 bool bDrawViewHasMarkedObjects =
false;
863 bDrawViewHasMarkedObjects =
true;
867 const OUString& aPageName = rStateItem.
GetValue();
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
sal_uInt32 GetValue() const
const OUString & GetValue() const
::sd::DrawDocShell * mpDocShell
::sd::DrawDocShell * GetDrawDocShell()
virtual weld::Window * GetFrameWeld() const
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem *pState) override
SdNavigatorWin * pNavigatorWin
SdNavigatorControllerItem(sal_uInt16, SdNavigatorWin *, SfxBindings *, SdNavigatorWin::UpdateRequestFunctor aUpdateRequest)
ControllerItem for Navigator.
const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest
NavigatorDragType GetNavigatorDragType()
DragType is set on dependence if a Drag is even possible.
void ExecuteContextMenuAction(std::u16string_view rSelectedPopupEntry)
std::unique_ptr< weld::Menu > mxDragModeMenu
void InitTreeLB(const SdDrawDocument *pDoc)
std::unique_ptr< weld::Menu > mxShapeMenu
virtual weld::Window * GetFrameWeld() const override
std::vector< NavDocInfo > maDocList
static OUString GetDragTypeSdBmpId(NavigatorDragType eDT)
This flag controls whether all shapes or only the named shapes are shown.
SdPageObjsTLV & GetObjects()
void FreshTree(const SdDrawDocument *pDoc)
virtual ~SdNavigatorWin() override
std::unique_ptr< weld::ComboBox > mxLbDocs
std::unique_ptr< SdPageObjsTLV > mxTlbObjects
SdNavigatorWin(weld::Widget *pParent, SfxBindings *pBindings, SfxNavigator *pNavigatorDlg)
Create a new instance of the navigator.
friend class SdNavigatorControllerItem
NavigatorDragType meDragType
std::unique_ptr< SdPageNameControllerItem > mpPageNameCtrlItem
NavDocInfo * GetDocInfo()
bool InsertFile(const OUString &rFileName)
void RefreshDocumentLB(const OUString *pDocName=nullptr)
VclPtr< SfxNavigator > mxNavigatorDlg
std::unique_ptr< weld::Toolbar > mxToolbox
friend class SdPageNameControllerItem
::std::function< void()> UpdateRequestFunctor
void SetUpdateRequestFunctor(const UpdateRequestFunctor &rUpdateRequest)
std::unique_ptr< SdNavigatorControllerItem > mpNavigatorCtrlItem
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem *pState) override
SdPageNameControllerItem(sal_uInt16, SdNavigatorWin *, SfxBindings *)
ControllerItem for Navigator to show page in TreeLB.
SdNavigatorWin * pNavigatorWin
weld::TreeView & get_treeview()
bool SelectEntry(std::u16string_view rName)
select an entry in TreeLB
size_t GetMarkedObjectCount() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
void EnableUndo(bool bEnable)
bool IsUndoEnabled() const
SdrModel & getSdrModelFromSdrObject() const
virtual const OUString & GetName() const
virtual void SetName(const OUString &rStr, const bool bSetChanged=true)
SdrPageView * GetSdrPageView() const
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
SfxViewFrame * GetFrame() const
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
void UseInteractionHandler(bool)
const OUString & GetName() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxMedium * GetMedium() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxObjectCreateMode GetCreateMode() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
const OUString & GetName() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
vcl::Window * GetWindow() const
sd::ViewShell * GetViewShell()
bool IsInDestruction() const
SdDrawDocument * GetDoc()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
bool IsNavigatorShowingAllShapes() const
void SetIsNavigatorShowingAllShapes(const bool bIsNavigatorShowingAllShapes)
static bool IsRunning(ViewShellBase const &rBase)
returns true if there is a running presentation for the given ViewShellBase
static void Stop(ViewShellBase const &rBase)
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
static ViewShellBase * GetViewShellBase(SfxViewFrame const *pFrame)
When given a view frame this static method returns the corresponding sd::ViewShellBase object.
Base class of the stacked shell hierarchy.
FrameView * GetFrameView()
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
SdrView * GetDrawView() const
constexpr sal_uInt16 KEY_ESCAPE
#define LINK(Instance, Class, Member)
void InsertFile(SwUnoCursor *pUnoCursor, const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions)
IMPL_LINK(SdNavigatorWin, CommandHdl, const CommandEvent &, rCEvt, bool)
IMPL_STATIC_LINK_NOARG(SdNavigatorWin, MouseReleaseHdl, const MouseEvent &, bool)
IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, weld::TreeView &, bool)
static void lcl_select_marked_object(const sd::ViewShell *pViewShell, SdPageObjsTLV *pTlbObjects)
@ NAVIGATOR_DRAGTYPE_NONE
@ NAVIGATOR_DRAGTYPE_EMBEDDED
@ NAVIGATOR_DRAGTYPE_LINK