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 .
23 #include <vcl/idle.hxx>
24 #include <svl/lstner.hxx>
25 #include <sfx2/childwin.hxx>
26 #include <sfx2/navigat.hxx>
27 #include <sfx2/sidebar/PanelLayout.hxx>
28 #include <rangeutl.hxx>
29 #include "content.hxx"
34 class ScScenarioWindow
;
35 class ScNavigatorControllerItem
;
37 class ScNavigatorSettings
;
39 #define SC_DROPMODE_URL 0
40 #define SC_DROPMODE_LINK 1
41 #define SC_DROPMODE_COPY 2
43 enum NavListMode
{ NAV_LMODE_NONE
= 0x4000,
44 NAV_LMODE_AREAS
= 0x2000,
45 NAV_LMODE_SCENARIOS
= 0x400 };
47 class ScScenarioWindow
50 ScScenarioWindow(weld::Builder
& rBuilder
, const OUString
& rQH_List
, const OUString
& rQH_Comment
);
52 void NotifyState(const SfxPoolItem
* pState
);
53 void SetComment(const OUString
& rComment
)
55 m_xEdComment
->set_text(rComment
);
59 std::unique_ptr
<weld::TreeView
> m_xLbScenario
;
60 std::unique_ptr
<weld::TextView
> m_xEdComment
;
68 explicit ScenarioEntry() : mbProtected( false ) {}
71 std::vector
< ScenarioEntry
> m_aEntries
;
73 void UpdateEntries(const std::vector
<OUString
> &rNewEntryList
);
74 void SelectScenario();
75 void ExecuteScenarioSlot(sal_uInt16 nSlotId
);
77 void DeleteScenario();
78 const ScenarioEntry
* GetSelectedScenarioEntry() const;
80 DECL_LINK(SelectHdl
, weld::TreeView
&, void);
81 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
82 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
83 DECL_LINK(ContextMenuHdl
, const CommandEvent
&, bool);
86 class ScNavigatorDlg
: public PanelLayout
, public SfxListener
88 friend class ScNavigatorWin
;
89 friend class ScNavigatorControllerItem
;
90 friend class ScContentTree
;
93 static constexpr int CTRL_ITEMS
= 4;
95 SfxBindings
& rBindings
; // must be first member
97 std::unique_ptr
<weld::SpinButton
> m_xEdCol
;
98 std::unique_ptr
<weld::SpinButton
> m_xEdRow
;
99 std::unique_ptr
<weld::Toolbar
> m_xTbxCmd1
;
100 std::unique_ptr
<weld::Toolbar
> m_xTbxCmd2
;
101 std::unique_ptr
<ScContentTree
> m_xLbEntries
;
102 std::unique_ptr
<weld::Widget
> m_xScenarioBox
;
103 std::unique_ptr
<ScScenarioWindow
> m_xWndScenarios
;
104 std::unique_ptr
<weld::ComboBox
> m_xLbDocuments
;
105 std::unique_ptr
<weld::Menu
> m_xDragModeMenu
;
107 VclPtr
<SfxNavigator
> m_xNavigatorDlg
;
113 OUString aStrNotActive
;
114 OUString aStrActiveWin
;
116 std::optional
<ScArea
> moMarkArea
;
117 ScViewData
* pViewData
;
119 NavListMode eListMode
;
120 sal_uInt16 nDropMode
;
125 std::array
<std::unique_ptr
<ScNavigatorControllerItem
>,CTRL_ITEMS
> mvBoundItems
;
127 DECL_LINK(TimeHdl
, Timer
*, void);
128 DECL_LINK(DocumentSelectHdl
, weld::ComboBox
&, void);
129 DECL_LINK(ExecuteRowHdl
, weld::Entry
&, bool);
130 DECL_LINK(ExecuteColHdl
, weld::Entry
&, bool);
131 DECL_LINK(ToolBoxSelectHdl
, const OUString
&, void);
132 DECL_LINK(ToolBoxDropdownClickHdl
, const OUString
&, void);
133 DECL_LINK(MenuSelectHdl
, const OUString
&, void);
134 DECL_LINK(FormatRowOutputHdl
, weld::SpinButton
&, void);
135 DECL_LINK(ParseRowInputHdl
, int*, bool);
137 void UpdateButtons();
138 void SetCurrentCell( SCCOL nCol
, SCROW Row
);
139 void SetCurrentCellStr( const OUString
& rName
);
140 void SetCurrentTable( SCTAB nTab
);
141 void SetCurrentTableStr( std::u16string_view rName
);
142 void SetCurrentObject( const OUString
& rName
);
143 void SetCurrentDoc( const OUString
& rDocName
);
144 void UpdateSelection();
145 void ContentUpdated(); // stop aContentIdle because content is up to date
147 SAL_RET_MAYBENULL
static ScTabViewShell
* GetTabViewShell();
148 static ScNavigatorSettings
* GetNavigatorSettings();
149 ScViewData
* GetViewData();
151 void UpdateSheetLimits();
153 void UpdateColumn ( const SCCOL
* pCol
= nullptr );
154 void UpdateRow ( const SCROW
* pRow
= nullptr );
155 void UpdateTable ( const SCTAB
* pTab
);
158 void GetDocNames(const OUString
* pSelEntry
);
160 void SetListMode(NavListMode eMode
);
161 void ShowList(bool bShow
);
162 void ShowScenarios();
164 void SetDropMode(sal_uInt16 nNew
);
165 sal_uInt16
GetDropMode() const { return nDropMode
; }
167 void MarkDataArea ();
168 void UnmarkDataArea ();
169 void StartOfDataArea ();
170 void EndOfDataArea ();
172 void UpdateInitShow();
174 static void ReleaseFocus();
177 ScNavigatorDlg(SfxBindings
* pB
, weld::Widget
* pParent
, SfxNavigator
* pNavigatorDlg
);
178 virtual weld::Window
* GetFrameWeld() const override
;
179 virtual ~ScNavigatorDlg() override
;
181 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
185 class ScNavigatorWrapper final
: public SfxNavigatorWrapper
188 ScNavigatorWrapper(vcl::Window
*pParent
, sal_uInt16 nId
,
189 SfxBindings
* pBindings
, SfxChildWinInfo
* pInfo
);
190 SFX_DECL_CHILDWINDOW(ScNavigatorWrapper
);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */