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 .
22 #include <sfx2/ctrlitem.hxx>
23 #include <sfx2/sidebar/PanelLayout.hxx>
24 #include <sfx2/navigat.hxx>
25 #include "sdtreelb.hxx"
28 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
29 #include <vcl/EnumContext.hxx>
32 namespace vcl
{ class Window
; }
36 class SdNavigatorFloat
;
39 class SdNavigatorControllerItem
;
40 class SdPageNameControllerItem
;
44 TableUpdate
= 0x000100,
45 BtnFirstEnabled
= 0x001000,
46 BtnFirstDisabled
= 0x002000,
47 BtnPrevEnabled
= 0x004000,
48 BtnPrevDisabled
= 0x008000,
49 BtnLastEnabled
= 0x010000,
50 BtnLastDisabled
= 0x020000,
51 BtnNextEnabled
= 0x040000,
52 BtnNextDisabled
= 0x080000,
55 template<> struct typed_flags
<NavState
> : is_typed_flags
<NavState
, 0x0ff100> {};
68 bool HasName() const { return bName
; }
69 bool IsActive() const { return bActive
; }
71 void SetName( bool bOn
) { bName
= bOn
; }
72 void SetActive( bool bOn
) { bActive
= bOn
; }
74 ::sd::DrawDocShell
* GetDrawDocShell() {return mpDocShell
;}
77 friend class SdNavigatorWin
;
80 ::sd::DrawDocShell
* mpDocShell
;
85 class SdNavigatorFloat final
: public SfxNavigator
88 std::unique_ptr
<SdNavigatorWin
> m_xNavWin
;
89 bool m_bSetInitialFocusOnActivate
;
92 SdNavigatorFloat(SfxBindings
* _pBindings
, SfxChildWindow
* pMgr
,
93 vcl::Window
* pParent
, SfxChildWinInfo
* pInfo
);
94 void InitTreeLB(const SdDrawDocument
* pDoc
);
95 virtual void Activate() override
;
96 virtual void dispose() override
;
97 virtual ~SdNavigatorFloat() override
;
102 class SAL_DLLPUBLIC_RTTI SdNavigatorWin
: public PanelLayout
, public sfx2::sidebar::IContextChangeReceiver
105 typedef ::std::function
<void ()> UpdateRequestFunctor
;
107 /** Create a new instance of the navigator.
108 @param bUseActiveUpdate
109 When <TRUE/>, the default, then the SdNavigatorWin object
110 will make a SID_NAVIGATOR_INIT call whenever it thinks an
111 update is necessary. When <FALSE/> the navigator will
112 rely on others to trigger updates.
114 SD_DLLPUBLIC
SdNavigatorWin(weld::Widget
* pParent
, SfxBindings
* pBindings
, SfxNavigator
* pNavigatorDlg
);
115 void SetUpdateRequestFunctor(const UpdateRequestFunctor
& rUpdateRequest
);
116 virtual ~SdNavigatorWin() override
;
118 SD_DLLPUBLIC
void InitTreeLB( const SdDrawDocument
* pDoc
);
119 void RefreshDocumentLB( const OUString
* pDocName
= nullptr );
122 bool InsertFile(const OUString
& rFileName
);
124 NavigatorDragType
GetNavigatorDragType();
125 SD_DLLPUBLIC SdPageObjsTLV
& GetObjects();
127 virtual void HandleContextChange(const vcl::EnumContext
& eContext
) override
;
130 friend class SdNavigatorFloat
;
131 friend class SdNavigatorControllerItem
;
132 friend class SdPageNameControllerItem
;
134 std::unique_ptr
<weld::Toolbar
> mxToolbox
;
135 std::unique_ptr
<SdPageObjsTLV
> mxTlbObjects
;
136 std::unique_ptr
<weld::ComboBox
> mxLbDocs
;
137 std::unique_ptr
<weld::Menu
> mxDragModeMenu
;
138 std::unique_ptr
<weld::Menu
> mxShapeMenu
;
140 VclPtr
<SfxNavigator
> mxNavigatorDlg
;
143 OUString maDropFileName
;
144 NavigatorDragType meDragType
;
145 std::vector
<NavDocInfo
> maDocList
;
146 SfxBindings
* mpBindings
;
147 std::unique_ptr
<SdNavigatorControllerItem
> mpNavigatorCtrlItem
;
148 std::unique_ptr
<SdPageNameControllerItem
> mpPageNameCtrlItem
;
150 /** This flag controls whether all shapes or only the named shapes are
153 // bool mbShowAllShapes;
155 static const OUString
& GetDragTypeSdBmpId(NavigatorDragType eDT
);
156 NavDocInfo
* GetDocInfo();
158 DECL_DLLPRIVATE_LINK( SelectToolboxHdl
, const OUString
&, void );
159 DECL_DLLPRIVATE_LINK( DropdownClickToolBoxHdl
, const OUString
&, void );
160 DECL_DLLPRIVATE_LINK( ClickObjectHdl
, weld::TreeView
&, bool );
161 DECL_DLLPRIVATE_LINK( SelectDocumentHdl
, weld::ComboBox
&, void );
162 DECL_DLLPRIVATE_LINK( MenuSelectHdl
, const OUString
&, void );
163 DECL_DLLPRIVATE_LINK( ShapeFilterCallback
, const OUString
&, void );
164 DECL_DLLPRIVATE_LINK( KeyInputHdl
, const KeyEvent
&, bool );
165 DECL_DLLPRIVATE_STATIC_LINK(SdNavigatorWin
, MouseReleaseHdl
, const MouseEvent
&, bool);
166 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
170 void ExecuteContextMenuAction(std::u16string_view rSelectedPopupEntry
);
173 virtual weld::Window
* GetFrameWeld() const override
;
177 * ControllerItem for Navigator
179 class SdNavigatorControllerItem final
: public SfxControllerItem
182 SdNavigatorControllerItem( sal_uInt16
, SdNavigatorWin
*, SfxBindings
*,
183 SdNavigatorWin::UpdateRequestFunctor aUpdateRequest
);
186 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSId
, SfxItemState eState
,
187 const SfxPoolItem
* pState
) override
;
190 SdNavigatorWin
* pNavigatorWin
;
191 const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest
;
195 * ControllerItem for Navigator to show the page in the TreeLB
197 class SdPageNameControllerItem final
: public SfxControllerItem
200 SdPageNameControllerItem( sal_uInt16
, SdNavigatorWin
*, SfxBindings
*);
203 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSId
, SfxItemState eState
,
204 const SfxPoolItem
* pState
) override
;
207 SdNavigatorWin
* pNavigatorWin
;
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */