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"
29 namespace vcl
{ class Window
; }
33 class SdNavigatorFloat
;
36 class SdNavigatorControllerItem
;
37 class SdPageNameControllerItem
;
41 TableUpdate
= 0x000100,
42 BtnFirstEnabled
= 0x001000,
43 BtnFirstDisabled
= 0x002000,
44 BtnPrevEnabled
= 0x004000,
45 BtnPrevDisabled
= 0x008000,
46 BtnLastEnabled
= 0x010000,
47 BtnLastDisabled
= 0x020000,
48 BtnNextEnabled
= 0x040000,
49 BtnNextDisabled
= 0x080000,
52 template<> struct typed_flags
<NavState
> : is_typed_flags
<NavState
, 0x0ff100> {};
65 bool HasName() const { return bName
; }
66 bool IsActive() const { return bActive
; }
68 void SetName( bool bOn
) { bName
= bOn
; }
69 void SetActive( bool bOn
) { bActive
= bOn
; }
71 ::sd::DrawDocShell
* GetDrawDocShell() {return mpDocShell
;}
74 friend class SdNavigatorWin
;
77 ::sd::DrawDocShell
* mpDocShell
;
82 class SdNavigatorFloat final
: public SfxNavigator
85 std::unique_ptr
<SdNavigatorWin
> m_xNavWin
;
86 bool m_bSetInitialFocusOnActivate
;
89 SdNavigatorFloat(SfxBindings
* _pBindings
, SfxChildWindow
* pMgr
,
90 vcl::Window
* pParent
, SfxChildWinInfo
* pInfo
);
91 void InitTreeLB(const SdDrawDocument
* pDoc
);
92 void FreshTree(const SdDrawDocument
* pDoc
);
93 virtual void Activate() override
;
94 virtual void dispose() override
;
95 virtual ~SdNavigatorFloat() override
;
100 class SD_DLLPUBLIC SdNavigatorWin
: public PanelLayout
103 typedef ::std::function
<void ()> UpdateRequestFunctor
;
105 /** Create a new instance of the navigator.
106 @param bUseActiveUpdate
107 When <TRUE/>, the default, then the SdNavigatorWin object
108 will make a SID_NAVIGATOR_INIT call whenever it thinks an
109 update is necessary. When <FALSE/> the navigator will
110 rely on others to trigger updates.
112 SdNavigatorWin(weld::Widget
* pParent
, SfxBindings
* pBindings
, SfxNavigator
* pNavigatorDlg
);
113 void SetUpdateRequestFunctor(const UpdateRequestFunctor
& rUpdateRequest
);
114 virtual ~SdNavigatorWin() override
;
116 void InitTreeLB( const SdDrawDocument
* pDoc
);
117 void RefreshDocumentLB( const OUString
* pDocName
= nullptr );
120 bool InsertFile(const OUString
& rFileName
);
122 NavigatorDragType
GetNavigatorDragType();
123 SdPageObjsTLV
& GetObjects();
126 friend class SdNavigatorFloat
;
127 friend class SdNavigatorControllerItem
;
128 friend class SdPageNameControllerItem
;
130 std::unique_ptr
<weld::Toolbar
> mxToolbox
;
131 std::unique_ptr
<SdPageObjsTLV
> mxTlbObjects
;
132 std::unique_ptr
<weld::ComboBox
> mxLbDocs
;
133 std::unique_ptr
<weld::Menu
> mxDragModeMenu
;
134 std::unique_ptr
<weld::Menu
> mxShapeMenu
;
136 VclPtr
<SfxNavigator
> mxNavigatorDlg
;
139 OUString maDropFileName
;
140 NavigatorDragType meDragType
;
141 std::vector
<NavDocInfo
> maDocList
;
142 SfxBindings
* mpBindings
;
143 std::unique_ptr
<SdNavigatorControllerItem
> mpNavigatorCtrlItem
;
144 std::unique_ptr
<SdPageNameControllerItem
> mpPageNameCtrlItem
;
146 /** This flag controls whether all shapes or only the named shapes are
149 // bool mbShowAllShapes;
151 static OUString
GetDragTypeSdBmpId(NavigatorDragType eDT
);
152 NavDocInfo
* GetDocInfo();
154 DECL_DLLPRIVATE_LINK( SelectToolboxHdl
, const OUString
&, void );
155 DECL_DLLPRIVATE_LINK( DropdownClickToolBoxHdl
, const OUString
&, void );
156 DECL_DLLPRIVATE_LINK( ClickObjectHdl
, weld::TreeView
&, bool );
157 DECL_DLLPRIVATE_LINK( SelectDocumentHdl
, weld::ComboBox
&, void );
158 DECL_DLLPRIVATE_LINK( MenuSelectHdl
, const OUString
&, void );
159 DECL_DLLPRIVATE_LINK( ShapeFilterCallback
, const OUString
&, void );
160 DECL_DLLPRIVATE_LINK( KeyInputHdl
, const KeyEvent
&, bool );
161 DECL_DLLPRIVATE_STATIC_LINK(SdNavigatorWin
, MouseReleaseHdl
, const MouseEvent
&, bool);
162 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
166 void ExecuteContextMenuAction(std::u16string_view rSelectedPopupEntry
);
169 //when object is marked , fresh the corresponding entry tree .
170 void FreshTree ( const SdDrawDocument
* pDoc
);
172 virtual weld::Window
* GetFrameWeld() const override
;
176 * ControllerItem for Navigator
178 class SdNavigatorControllerItem final
: public SfxControllerItem
181 SdNavigatorControllerItem( sal_uInt16
, SdNavigatorWin
*, SfxBindings
*,
182 SdNavigatorWin::UpdateRequestFunctor aUpdateRequest
);
185 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSId
, SfxItemState eState
,
186 const SfxPoolItem
* pState
) override
;
189 SdNavigatorWin
* pNavigatorWin
;
190 const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest
;
194 * ControllerItem for Navigator to show the page in the TreeLB
196 class SdPageNameControllerItem final
: public SfxControllerItem
199 SdPageNameControllerItem( sal_uInt16
, SdNavigatorWin
*, SfxBindings
*);
202 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSId
, SfxItemState eState
,
203 const SfxPoolItem
* pState
) override
;
206 SdNavigatorWin
* pNavigatorWin
;
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */