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 
29 class SfxModule;
30 class SfxShell;
31 
32 // struct OrderedEntry ---------------------------------------------------
33 
35 {
36  sal_Int32 m_nIndex;
37  OUString m_sId;
38 
39  OrderedEntry( sal_Int32 nIndex, const OUString& rId ) :
40  m_nIndex( nIndex ), m_sId( rId ) {}
41 };
42 
43 
44 // struct Module ---------------------------------------------------------
45 
46 struct Module
47 {
48  bool m_bActive;
49  std::vector< std::unique_ptr<OrderedEntry> > m_aNodeList;
50 
51  Module() : m_bActive( false ) {}
52 };
53 
54 // struct OptionsLeaf ----------------------------------------------------
55 
57 {
58  OUString m_sLabel;
59  OUString m_sPageURL;
60  OUString m_sEventHdl;
61  OUString m_sGroupId;
62  sal_Int32 m_nGroupIndex;
63 
64  OptionsLeaf( const OUString& rLabel,
65  const OUString& rPageURL,
66  const OUString& rEventHdl,
67  const OUString& rGroupId,
68  sal_Int32 nGroupIndex ) :
69  m_sLabel( rLabel ),
70  m_sPageURL( rPageURL ),
71  m_sEventHdl( rEventHdl ),
72  m_sGroupId( rGroupId ),
73  m_nGroupIndex( nGroupIndex ) {}
74 };
75 
76 // struct OptionsNode ----------------------------------------------------
77 
79 {
80  OUString m_sId;
81  OUString m_sLabel;
83  std::vector< std::unique_ptr<OptionsLeaf> > m_aLeaves;
84  std::vector< std::vector< std::unique_ptr<OptionsLeaf> > >
86 
87  OptionsNode( const OUString& rId,
88  const OUString& rLabel,
89  bool bAllModules ) :
90  m_sId( rId ),
91  m_sLabel( rLabel ),
92  m_bAllModules( bAllModules ) {}
93 };
94 
95 typedef std::vector< std::unique_ptr<OptionsNode> > VectorOfNodes;
96 
98 {
99  sal_uInt16 m_nLastPageId;
102 
103  LastPageSaver() : m_nLastPageId( USHRT_MAX ) {}
104 };
105 
106 // class OfaTreeOptionsDialog --------------------------------------------
107 
108 namespace com::sun::star::frame { class XFrame; }
109 namespace com::sun::star::awt { class XContainerWindowProvider; }
110 
111 struct OptionsPageInfo;
112 struct Module;
113 class ExtensionsTabPage;
114 class SvxColorTabPage;
115 struct OptionsGroupInfo;
116 
118 {
119 private:
120  std::unique_ptr<weld::Button> xOkPB;
121  std::unique_ptr<weld::Button> xApplyPB;
122  std::unique_ptr<weld::Button> xBackPB;
123 
124  std::unique_ptr<weld::TreeView> xTreeLB;
125  std::unique_ptr<weld::Container> xTabBox;
126 
128 
129  std::unique_ptr<weld::TreeIter> xCurrentPageEntry;
130 
131  OUString sTitle;
132 
135 
136  // check "for the current document only" and set focus to "Western" languages box
138 
141 
142  css::uno::Reference < css::awt::XContainerWindowProvider >
144 
146 
147  std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId );
148  static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
149  void InitTreeAndHandler();
150  void Initialize( const css::uno::Reference< css::frame::XFrame >& _xFrame );
151  void InitWidgets();
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 public:
178  const css::uno::Reference< css::frame::XFrame >& _xFrame,
179  bool bActivateLastSelection);
180  OfaTreeOptionsDialog(weld::Window* pParent, std::u16string_view rExtensionId);
181  virtual ~OfaTreeOptionsDialog() override;
182 
183  OptionsPageInfo* AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup );
184  sal_uInt16 AddGroup( const OUString& rGroupName, SfxShell* pCreateShell,
185  SfxModule* pCreateModule, sal_uInt16 nDialogId );
186 
187  void ActivateLastSelection();
188  void ActivatePage( sal_uInt16 nResId );
189  void ActivatePage( const OUString& rPageURL );
190  void ApplyItemSets();
191 
192  // helper functions to call the language settings TabPage from the SpellDialog
193  static void ApplyLanguageOptions(const SfxItemSet& rSet);
194 
195  void SetNeedsRestart( svtools::RestartReason eReason );
196 };
197 
198 // class ExtensionsTabPage -----------------------------------------------
199 
200 namespace com::sun::star::awt { class XWindow; }
201 namespace com::sun::star::awt { class XContainerWindowEventHandler; }
202 
204 {
205 private:
207  OUString m_sPageURL;
208  css::uno::Reference<css::awt::XWindow> m_xPageParent;
209  css::uno::Reference<css::awt::XWindow> m_xPage;
210  OUString m_sEventHdl;
211  css::uno::Reference< css::awt::XContainerWindowEventHandler >
213  css::uno::Reference< css::awt::XContainerWindowProvider >
215 
217  bool DispatchAction( const OUString& rAction );
218 
219 public:
221  weld::Container* pParent,
222  const OUString& rPageURL, const OUString& rEvtHdl,
223  const css::uno::Reference<
224  css::awt::XContainerWindowProvider >& rProvider );
225 
227 
228  void Show();
229  void Hide();
230 
231  void ActivatePage();
232  void DeactivatePage();
233 
234  void ResetPage();
235  void SavePage();
236 };
237 
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OrderedEntry(sal_Int32 nIndex, const OUString &rId)
Definition: treeopt.hxx:39
std::vector< std::vector< std::unique_ptr< OptionsLeaf > > > m_aGroupedLeaves
Definition: treeopt.hxx:85
virtual weld::Button & GetOKButton() const override
Definition: treeopt.hxx:173
std::unique_ptr< weld::TreeIter > xCurrentPageEntry
Definition: treeopt.hxx:129
OUString m_sPageURL
Definition: treeopt.hxx:59
virtual const SfxItemSet * GetExampleSet() const override
Definition: treeopt.hxx:174
css::uno::Reference< css::awt::XWindow > m_xPageParent
Definition: treeopt.hxx:208
OUString m_sEventHdl
Definition: treeopt.hxx:60
OUString m_sLastPageURL_Tools
Definition: treeopt.hxx:100
bool bIsFromExtensionManager
Definition: treeopt.hxx:134
std::vector< std::unique_ptr< OptionsNode > > VectorOfNodes
Definition: treeopt.hxx:95
sal_Int32 m_nIndex
Definition: treeopt.hxx:36
DECL_LINK(ShowPageHdl_Impl, weld::TreeView &, void)
OUString m_sLastPageURL_ExtMgr
Definition: treeopt.hxx:101
void InitItemSets(OptionsGroupInfo &rGroupInfo)
Definition: treeopt.cxx:892
OUString m_sPageURL
Definition: treeopt.hxx:207
OfaTreeOptionsDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XFrame > &_xFrame, bool bActivateLastSelection)
void CreateDialogWithHandler()
Definition: treeopt.cxx:2008
ExtensionsTabPage(weld::Container *pParent, const OUString &rPageURL, const OUString &rEvtHdl, const css::uno::Reference< css::awt::XContainerWindowProvider > &rProvider)
Definition: treeopt.cxx:1968
OptionsLeaf(const OUString &rLabel, const OUString &rPageURL, const OUString &rEventHdl, const OUString &rGroupId, sal_Int32 nGroupIndex)
Definition: treeopt.hxx:64
OUString m_sLabel
Definition: treeopt.hxx:58
void ResetCurrentPageFromConfig()
Definition: treeopt.cxx:617
bool m_bAllModules
Definition: treeopt.hxx:82
OptionsPageInfo * AddTabPage(sal_uInt16 nId, const OUString &rPageName, sal_uInt16 nGroup)
Definition: treeopt.cxx:575
OUString m_sId
Definition: treeopt.hxx:80
OUString m_sLabel
Definition: treeopt.hxx:81
sal_Int32 m_nGroupIndex
Definition: treeopt.hxx:62
OUString m_sGroupId
Definition: treeopt.hxx:61
static OUString GetModuleIdentifier(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: treeopt.cxx:1667
css::uno::Reference< css::awt::XWindow > m_xPage
Definition: treeopt.hxx:209
std::unique_ptr< weld::TreeView > xTreeLB
Definition: treeopt.hxx:124
std::unique_ptr< weld::Container > xTabBox
Definition: treeopt.hxx:125
static void ApplyLanguageOptions(const SfxItemSet &rSet)
Definition: treeopt.cxx:1261
void DeactivatePage()
Definition: treeopt.cxx:2107
void Initialize(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: treeopt.cxx:1357
std::vector< std::unique_ptr< OptionsLeaf > > m_aLeaves
Definition: treeopt.hxx:83
bool bIsForSetDocumentLanguage
Definition: treeopt.hxx:137
std::unique_ptr< weld::Button > xApplyPB
Definition: treeopt.hxx:121
static LastPageSaver * pLastPageSaver
Definition: treeopt.hxx:145
Module()
Definition: treeopt.hxx:51
static VectorOfNodes LoadNodes(Module *pModule, std::u16string_view rExtensionId)
Definition: treeopt.cxx:1761
svtools::RestartReason eRestartReason
Definition: treeopt.hxx:140
css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl
Definition: treeopt.hxx:212
sal_uInt16 m_nLastPageId
Definition: treeopt.hxx:99
std::unique_ptr< weld::Button > xOkPB
Definition: treeopt.hxx:120
bool m_bActive
Definition: treeopt.hxx:48
void LoadExtensionOptions(std::u16string_view rExtensionId)
Definition: treeopt.cxx:1653
virtual ~OfaTreeOptionsDialog() override
Definition: treeopt.cxx:519
css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider
Definition: treeopt.hxx:214
OptionsNode(const OUString &rId, const OUString &rLabel, bool bAllModules)
Definition: treeopt.hxx:87
void ActivateLastSelection()
Definition: treeopt.cxx:828
bool DispatchAction(const OUString &rAction)
Definition: treeopt.cxx:2046
static std::unique_ptr< Module > LoadModule(std::u16string_view rModuleIdentifier)
Definition: treeopt.cxx:1698
void SetNeedsRestart(svtools::RestartReason eReason)
Definition: treeopt.cxx:1948
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
css::uno::Reference< css::awt::XContainerWindowProvider > m_xContainerWinProvider
Definition: treeopt.hxx:143
sal_uInt16 AddGroup(const OUString &rGroupName, SfxShell *pCreateShell, SfxModule *pCreateModule, sal_uInt16 nDialogId)
Definition: treeopt.cxx:590
static void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
Definition: treeopt.cxx:1181
OUString m_sId
Definition: treeopt.hxx:37
virtual short run() override
Definition: treeopt.cxx:1954
std::unique_ptr< weld::Button > xBackPB
Definition: treeopt.hxx:122
void InsertNodes(const VectorOfNodes &rNodeList)
Definition: treeopt.cxx:1926
weld::Container * m_pContainer
Definition: treeopt.hxx:206
OUString m_sEventHdl
Definition: treeopt.hxx:210
void InitTreeAndHandler()
Definition: treeopt.cxx:788
weld::Window * m_pParent
Definition: treeopt.hxx:127
std::unique_ptr< SfxItemSet > CreateItemSet(sal_uInt16 nId)
Definition: treeopt.cxx:1029
std::vector< std::unique_ptr< OrderedEntry > > m_aNodeList
Definition: treeopt.hxx:49
void ActivatePage(sal_uInt16 nResId)
Definition: treeopt.cxx:798