LibreOffice Module cui (master) 1
treeopt.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <memory>
25
26#include <sfx2/basedlgs.hxx>
28#include <utility>
29
30class SfxModule;
31class SfxShell;
32
33// struct OrderedEntry ---------------------------------------------------
34
36{
37 sal_Int32 m_nIndex;
38 OUString m_sId;
39
40 OrderedEntry( sal_Int32 nIndex, OUString aId ) :
41 m_nIndex( nIndex ), m_sId(std::move( aId )) {}
42};
43
44
45// struct Module ---------------------------------------------------------
46
47struct Module
48{
50 std::vector< std::unique_ptr<OrderedEntry> > m_aNodeList;
51
52 Module() : m_bActive( false ) {}
53};
54
55// struct OptionsLeaf ----------------------------------------------------
56
58{
59 OUString m_sLabel;
60 OUString m_sPageURL;
61 OUString m_sEventHdl;
62 OUString m_sGroupId;
63 sal_Int32 m_nGroupIndex;
64
65 OptionsLeaf( OUString aLabel,
66 OUString aPageURL,
67 OUString aEventHdl,
68 OUString aGroupId,
69 sal_Int32 nGroupIndex ) :
70 m_sLabel(std::move( aLabel )),
71 m_sPageURL(std::move( aPageURL )),
72 m_sEventHdl(std::move( aEventHdl )),
73 m_sGroupId(std::move( aGroupId )),
74 m_nGroupIndex( nGroupIndex ) {}
75};
76
77// struct OptionsNode ----------------------------------------------------
78
80{
81 OUString m_sId;
82 OUString m_sLabel;
84 std::vector< std::unique_ptr<OptionsLeaf> > m_aLeaves;
85 std::vector< std::vector< std::unique_ptr<OptionsLeaf> > >
87
88 OptionsNode( OUString aId,
89 OUString aLabel,
90 bool bAllModules ) :
91 m_sId(std::move( aId )),
92 m_sLabel(std::move( aLabel )),
93 m_bAllModules( bAllModules ) {}
94};
95
96typedef std::vector< std::unique_ptr<OptionsNode> > VectorOfNodes;
97
99{
100 sal_uInt16 m_nLastPageId;
103
104 LastPageSaver() : m_nLastPageId( USHRT_MAX ) {}
105};
106
107// class OfaTreeOptionsDialog --------------------------------------------
108
109namespace com::sun::star::frame { class XFrame; }
110namespace com::sun::star::awt { class XContainerWindowProvider; }
111
112struct OptionsPageInfo;
113struct Module;
115class SvxColorTabPage;
116struct OptionsGroupInfo;
117
119{
120private:
121 std::unique_ptr<weld::Button> xOkPB;
122 std::unique_ptr<weld::Button> xApplyPB;
123 std::unique_ptr<weld::Button> xBackPB;
124
125 std::unique_ptr<weld::TreeView> xTreeLB;
126 std::unique_ptr<weld::Container> xTabBox;
127
129
130 std::unique_ptr<weld::TreeIter> xCurrentPageEntry;
131
132 OUString sTitle;
133
136
137 // check "for the current document only" and set focus to "Western" languages box
139
142
143 css::uno::Reference < css::awt::XContainerWindowProvider >
145 css::uno::Reference<css::frame::XFrame> m_xFrame;
146
148
149 std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId );
150 static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
151 void Initialize( const css::uno::Reference< css::frame::XFrame >& _xFrame );
152
153 void LoadExtensionOptions( std::u16string_view rExtensionId );
154 static OUString GetModuleIdentifier( const css::uno::Reference<
155 css::frame::XFrame >& xFrame );
156 static std::unique_ptr<Module> LoadModule( std::u16string_view rModuleIdentifier );
157 static VectorOfNodes LoadNodes( Module* pModule, std::u16string_view rExtensionId );
158 void InsertNodes( const VectorOfNodes& rNodeList );
159
160 void ApplyOptions();
161
162 DECL_LINK(ShowPageHdl_Impl, weld::TreeView&, void);
163 DECL_LINK(BackHdl_Impl, weld::Button&, void);
164 DECL_LINK(ApplyHdl_Impl, weld::Button&, void);
165 DECL_LINK(HelpHdl_Impl, weld::Widget&, bool);
167 void SelectHdl_Impl();
168
169 void InitItemSets(OptionsGroupInfo& rGroupInfo);
170
171 virtual short run() override;
172
173 virtual weld::Button& GetOKButton() const override { return *xOkPB; }
174 virtual const SfxItemSet* GetExampleSet() const override { return nullptr; }
175
176 // Common initialization
177 OfaTreeOptionsDialog(weld::Window* pParent, bool fromExtensionManager);
178
179public:
181 const css::uno::Reference< css::frame::XFrame >& _xFrame,
182 bool bActivateLastSelection);
183 OfaTreeOptionsDialog(weld::Window* pParent, std::u16string_view rExtensionId);
184 virtual ~OfaTreeOptionsDialog() override;
185
186 OptionsPageInfo* AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup );
187 sal_uInt16 AddGroup( const OUString& rGroupName, SfxShell* pCreateShell,
188 SfxModule* pCreateModule, sal_uInt16 nDialogId );
189
191 void ActivatePage( sal_uInt16 nResId );
192 void ActivatePage( const OUString& rPageURL );
193 void ApplyItemSets();
194
195 // helper functions to call the language settings TabPage from the SpellDialog
196 static void ApplyLanguageOptions(const SfxItemSet& rSet);
197 static OUString getCurrentFactory_Impl( const css::uno::Reference< css::frame::XFrame >& _xFrame );
198
200};
201
202// class ExtensionsTabPage -----------------------------------------------
203
204namespace com::sun::star::awt { class XWindow; }
205namespace com::sun::star::awt { class XContainerWindowEventHandler; }
206
208{
209private:
211 OUString m_sPageURL;
212 css::uno::Reference<css::awt::XWindow> m_xPageParent;
213 css::uno::Reference<css::awt::XWindow> m_xPage;
214 OUString m_sEventHdl;
215 css::uno::Reference< css::awt::XContainerWindowEventHandler >
217 css::uno::Reference< css::awt::XContainerWindowProvider >
219
221 bool DispatchAction( const OUString& rAction );
222
223public:
225 weld::Container* pParent,
226 OUString rPageURL, OUString aEvtHdl,
227 const css::uno::Reference<
228 css::awt::XContainerWindowProvider >& rProvider );
229
231
232 void Show();
233 void Hide();
234
235 void ActivatePage();
236 void DeactivatePage();
237
238 void ResetPage();
239 void SavePage();
240};
241
242/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool DispatchAction(const OUString &rAction)
Definition: treeopt.cxx:2007
css::uno::Reference< css::awt::XWindow > m_xPageParent
Definition: treeopt.hxx:212
ExtensionsTabPage(weld::Container *pParent, OUString rPageURL, OUString aEvtHdl, const css::uno::Reference< css::awt::XContainerWindowProvider > &rProvider)
Definition: treeopt.cxx:1929
css::uno::Reference< css::awt::XWindow > m_xPage
Definition: treeopt.hxx:213
void CreateDialogWithHandler()
Definition: treeopt.cxx:1969
css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider
Definition: treeopt.hxx:218
weld::Container * m_pContainer
Definition: treeopt.hxx:210
OUString m_sPageURL
Definition: treeopt.hxx:211
css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl
Definition: treeopt.hxx:216
OUString m_sEventHdl
Definition: treeopt.hxx:214
void DeactivatePage()
Definition: treeopt.cxx:2068
virtual ~OfaTreeOptionsDialog() override
Definition: treeopt.cxx:494
std::unique_ptr< weld::Button > xBackPB
Definition: treeopt.hxx:123
OfaTreeOptionsDialog(weld::Window *pParent, bool fromExtensionManager)
Definition: treeopt.cxx:442
std::unique_ptr< weld::TreeIter > xCurrentPageEntry
Definition: treeopt.hxx:130
virtual weld::Button & GetOKButton() const override
Definition: treeopt.hxx:173
static void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
Definition: treeopt.cxx:1135
svtools::RestartReason eRestartReason
Definition: treeopt.hxx:141
std::unique_ptr< weld::Button > xApplyPB
Definition: treeopt.hxx:122
static void ApplyLanguageOptions(const SfxItemSet &rSet)
Definition: treeopt.cxx:1216
void SetNeedsRestart(svtools::RestartReason eReason)
Definition: treeopt.cxx:1909
bool bIsForSetDocumentLanguage
Definition: treeopt.hxx:138
void InsertNodes(const VectorOfNodes &rNodeList)
Definition: treeopt.cxx:1887
static OUString getCurrentFactory_Impl(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: treeopt.cxx:1280
virtual const SfxItemSet * GetExampleSet() const override
Definition: treeopt.hxx:174
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: treeopt.hxx:145
DECL_LINK(HelpHdl_Impl, weld::Widget &, bool)
static std::unique_ptr< Module > LoadModule(std::u16string_view rModuleIdentifier)
Definition: treeopt.cxx:1659
OptionsPageInfo * AddTabPage(sal_uInt16 nId, const OUString &rPageName, sal_uInt16 nGroup)
Definition: treeopt.cxx:550
void ActivatePage(sal_uInt16 nResId)
Definition: treeopt.cxx:763
void InitItemSets(OptionsGroupInfo &rGroupInfo)
Definition: treeopt.cxx:857
static LastPageSaver * pLastPageSaver
Definition: treeopt.hxx:147
DECL_LINK(ShowPageHdl_Impl, weld::TreeView &, void)
virtual short run() override
Definition: treeopt.cxx:1915
void LoadExtensionOptions(std::u16string_view rExtensionId)
Definition: treeopt.cxx:1614
static VectorOfNodes LoadNodes(Module *pModule, std::u16string_view rExtensionId)
Definition: treeopt.cxx:1722
DECL_LINK(ApplyHdl_Impl, weld::Button &, void)
void Initialize(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: treeopt.cxx:1310
bool bIsFromExtensionManager
Definition: treeopt.hxx:135
sal_uInt16 AddGroup(const OUString &rGroupName, SfxShell *pCreateShell, SfxModule *pCreateModule, sal_uInt16 nDialogId)
Definition: treeopt.cxx:565
std::unique_ptr< weld::Container > xTabBox
Definition: treeopt.hxx:126
std::unique_ptr< weld::Button > xOkPB
Definition: treeopt.hxx:121
void ResetCurrentPageFromConfig()
Definition: treeopt.cxx:592
std::optional< SfxItemSet > CreateItemSet(sal_uInt16 nId)
Definition: treeopt.cxx:995
void ActivateLastSelection()
Definition: treeopt.cxx:793
weld::Window * m_pParent
Definition: treeopt.hxx:128
static OUString GetModuleIdentifier(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: treeopt.cxx:1628
DECL_LINK(BackHdl_Impl, weld::Button &, void)
OfaTreeOptionsDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XFrame > &_xFrame, bool bActivateLastSelection)
css::uno::Reference< css::awt::XContainerWindowProvider > m_xContainerWinProvider
Definition: treeopt.hxx:144
std::unique_ptr< weld::TreeView > xTreeLB
Definition: treeopt.hxx:125
sal_Int32 nIndex
OUString m_sLastPageURL_ExtMgr
Definition: treeopt.hxx:102
OUString m_sLastPageURL_Tools
Definition: treeopt.hxx:101
sal_uInt16 m_nLastPageId
Definition: treeopt.hxx:100
bool m_bActive
Definition: treeopt.hxx:49
std::vector< std::unique_ptr< OrderedEntry > > m_aNodeList
Definition: treeopt.hxx:50
Module()
Definition: treeopt.hxx:52
OptionsLeaf(OUString aLabel, OUString aPageURL, OUString aEventHdl, OUString aGroupId, sal_Int32 nGroupIndex)
Definition: treeopt.hxx:65
sal_Int32 m_nGroupIndex
Definition: treeopt.hxx:63
OUString m_sGroupId
Definition: treeopt.hxx:62
OUString m_sPageURL
Definition: treeopt.hxx:60
OUString m_sLabel
Definition: treeopt.hxx:59
OUString m_sEventHdl
Definition: treeopt.hxx:61
OUString m_sLabel
Definition: treeopt.hxx:82
std::vector< std::unique_ptr< OptionsLeaf > > m_aLeaves
Definition: treeopt.hxx:84
bool m_bAllModules
Definition: treeopt.hxx:83
std::vector< std::vector< std::unique_ptr< OptionsLeaf > > > m_aGroupedLeaves
Definition: treeopt.hxx:86
OUString m_sId
Definition: treeopt.hxx:81
OptionsNode(OUString aId, OUString aLabel, bool bAllModules)
Definition: treeopt.hxx:88
sal_Int32 m_nIndex
Definition: treeopt.hxx:37
OUString m_sId
Definition: treeopt.hxx:38
OrderedEntry(sal_Int32 nIndex, OUString aId)
Definition: treeopt.hxx:40
std::vector< std::unique_ptr< OptionsNode > > VectorOfNodes
Definition: treeopt.hxx:96
OUString aLabel