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 #ifndef INCLUDED_CUI_SOURCE_INC_TREEOPT_HXX
21 #define INCLUDED_CUI_SOURCE_INC_TREEOPT_HXX
22 
23 #include <sal/config.h>
24 
25 #include <memory>
26 
27 #include <sfx2/basedlgs.hxx>
29 
30 class SfxModule;
31 class SfxShell;
32 
33 // struct OrderedEntry ---------------------------------------------------
34 
36 {
37  sal_Int32 m_nIndex;
38  OUString m_sId;
39 
40  OrderedEntry( sal_Int32 nIndex, const OUString& rId ) :
41  m_nIndex( nIndex ), m_sId( rId ) {}
42 };
43 
44 
45 // struct Module ---------------------------------------------------------
46 
47 struct Module
48 {
49  bool m_bActive;
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( const OUString& rLabel,
66  const OUString& rPageURL,
67  const OUString& rEventHdl,
68  const OUString& rGroupId,
69  sal_Int32 nGroupIndex ) :
70  m_sLabel( rLabel ),
71  m_sPageURL( rPageURL ),
72  m_sEventHdl( rEventHdl ),
73  m_sGroupId( rGroupId ),
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( const OUString& rId,
89  const OUString& rLabel,
90  bool bAllModules ) :
91  m_sId( rId ),
92  m_sLabel( rLabel ),
93  m_bAllModules( bAllModules ) {}
94 };
95 
96 typedef 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 
109 namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
110 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowProvider; } } } }
111 
112 struct OptionsPageInfo;
113 struct Module;
114 class ExtensionsTabPage;
115 class SvxColorTabPage;
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( const OUString& rExtensionId );
154  static OUString GetModuleIdentifier( const css::uno::Reference<
155  css::frame::XFrame >& xFrame );
156  static std::unique_ptr<Module> LoadModule( const OUString& rModuleIdentifier );
157  static VectorOfNodes LoadNodes( Module* pModule, const OUString& rExtensionId );
158  void InsertNodes( const VectorOfNodes& rNodeList );
159 
160  void ApplyOptions( bool deactivate );
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(OKHdl_Impl, weld::Button&, void);
166  void SelectHdl_Impl();
167 
168  virtual short run() override;
169 
170  virtual weld::Button& GetOKButton() const override { return *xOkPB; }
171  virtual const SfxItemSet* GetExampleSet() const override { return nullptr; }
172 
173 public:
175  const css::uno::Reference< css::frame::XFrame >& _xFrame,
176  bool bActivateLastSelection);
177  OfaTreeOptionsDialog(weld::Window* pParent, const OUString& rExtensionId);
178  virtual ~OfaTreeOptionsDialog() override;
179 
180  OptionsPageInfo* AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup );
181  sal_uInt16 AddGroup( const OUString& rGroupName, SfxShell* pCreateShell,
182  SfxModule* pCreateModule, sal_uInt16 nDialogId );
183 
184  void ActivateLastSelection();
185  void ActivatePage( sal_uInt16 nResId );
186  void ActivatePage( const OUString& rPageURL );
187  void ApplyItemSets();
188 
189  // helper functions to call the language settings TabPage from the SpellDialog
190  static void ApplyLanguageOptions(const SfxItemSet& rSet);
191 
192  void SetNeedsRestart( svtools::RestartReason eReason );
193 };
194 
195 // class ExtensionsTabPage -----------------------------------------------
196 
197 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
198 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowEventHandler; } } } }
199 
201 {
202 private:
204  OUString m_sPageURL;
205  css::uno::Reference<css::awt::XWindow> m_xPageParent;
206  css::uno::Reference<css::awt::XWindow> m_xPage;
207  OUString m_sEventHdl;
208  css::uno::Reference< css::awt::XContainerWindowEventHandler >
210  css::uno::Reference< css::awt::XContainerWindowProvider >
212 
214  bool DispatchAction( const OUString& rAction );
215 
216 public:
218  weld::Container* pParent,
219  const OUString& rPageURL, const OUString& rEvtHdl,
220  const css::uno::Reference<
221  css::awt::XContainerWindowProvider >& rProvider );
222 
224 
225  void Show();
226  void Hide();
227 
228  void ActivatePage();
229  void DeactivatePage();
230 
231  void ResetPage();
232  void SavePage();
233 };
234 
235 #endif
236 
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OrderedEntry(sal_Int32 nIndex, const OUString &rId)
Definition: treeopt.hxx:40
std::vector< std::vector< std::unique_ptr< OptionsLeaf > > > m_aGroupedLeaves
Definition: treeopt.hxx:86
virtual weld::Button & GetOKButton() const override
Definition: treeopt.hxx:170
std::unique_ptr< weld::TreeIter > xCurrentPageEntry
Definition: treeopt.hxx:129
OUString m_sPageURL
Definition: treeopt.hxx:60
virtual const SfxItemSet * GetExampleSet() const override
Definition: treeopt.hxx:171
css::uno::Reference< css::awt::XWindow > m_xPageParent
Definition: treeopt.hxx:205
OUString m_sEventHdl
Definition: treeopt.hxx:61
OUString m_sLastPageURL_Tools
Definition: treeopt.hxx:101
bool bIsFromExtensionManager
Definition: treeopt.hxx:134
std::vector< std::unique_ptr< OptionsNode > > VectorOfNodes
Definition: treeopt.hxx:96
sal_Int32 m_nIndex
Definition: treeopt.hxx:37
DECL_LINK(ShowPageHdl_Impl, weld::TreeView &, void)
OUString m_sLastPageURL_ExtMgr
Definition: treeopt.hxx:102
OUString m_sPageURL
Definition: treeopt.hxx:204
OfaTreeOptionsDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XFrame > &_xFrame, bool bActivateLastSelection)
void CreateDialogWithHandler()
Definition: treeopt.cxx:1968
ExtensionsTabPage(weld::Container *pParent, const OUString &rPageURL, const OUString &rEvtHdl, const css::uno::Reference< css::awt::XContainerWindowProvider > &rProvider)
Definition: treeopt.cxx:1928
OptionsLeaf(const OUString &rLabel, const OUString &rPageURL, const OUString &rEventHdl, const OUString &rGroupId, sal_Int32 nGroupIndex)
Definition: treeopt.hxx:65
OUString m_sLabel
Definition: treeopt.hxx:59
bool m_bAllModules
Definition: treeopt.hxx:83
OptionsPageInfo * AddTabPage(sal_uInt16 nId, const OUString &rPageName, sal_uInt16 nGroup)
Definition: treeopt.cxx:577
OUString m_sId
Definition: treeopt.hxx:81
OUString m_sLabel
Definition: treeopt.hxx:82
static VectorOfNodes LoadNodes(Module *pModule, const OUString &rExtensionId)
Definition: treeopt.cxx:1712
sal_Int32 m_nGroupIndex
Definition: treeopt.hxx:63
OUString m_sGroupId
Definition: treeopt.hxx:62
static OUString GetModuleIdentifier(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: treeopt.cxx:1617
css::uno::Reference< css::awt::XWindow > m_xPage
Definition: treeopt.hxx:206
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:1210
void LoadExtensionOptions(const OUString &rExtensionId)
Definition: treeopt.cxx:1603
void DeactivatePage()
Definition: treeopt.cxx:2058
void Initialize(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: treeopt.cxx:1306
std::vector< std::unique_ptr< OptionsLeaf > > m_aLeaves
Definition: treeopt.hxx:84
void ApplyOptions(bool deactivate)
Definition: treeopt.cxx:637
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:52
svtools::RestartReason eRestartReason
Definition: treeopt.hxx:140
css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl
Definition: treeopt.hxx:209
sal_uInt16 m_nLastPageId
Definition: treeopt.hxx:100
std::unique_ptr< weld::Button > xOkPB
Definition: treeopt.hxx:120
bool m_bActive
Definition: treeopt.hxx:49
virtual ~OfaTreeOptionsDialog() override
Definition: treeopt.cxx:521
css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider
Definition: treeopt.hxx:211
OptionsNode(const OUString &rId, const OUString &rLabel, bool bAllModules)
Definition: treeopt.hxx:88
void ActivateLastSelection()
Definition: treeopt.cxx:783
bool DispatchAction(const OUString &rAction)
Definition: treeopt.cxx:2006
void SetNeedsRestart(svtools::RestartReason eReason)
Definition: treeopt.cxx:1900
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:592
static void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
Definition: treeopt.cxx:1131
OUString m_sId
Definition: treeopt.hxx:38
static std::unique_ptr< Module > LoadModule(const OUString &rModuleIdentifier)
Definition: treeopt.cxx:1648
virtual short run() override
Definition: treeopt.cxx:1906
std::unique_ptr< weld::Button > xBackPB
Definition: treeopt.hxx:122
void InsertNodes(const VectorOfNodes &rNodeList)
Definition: treeopt.cxx:1878
weld::Container * m_pContainer
Definition: treeopt.hxx:203
OUString m_sEventHdl
Definition: treeopt.hxx:207
void InitTreeAndHandler()
Definition: treeopt.cxx:744
weld::Window * m_pParent
Definition: treeopt.hxx:127
std::unique_ptr< SfxItemSet > CreateItemSet(sal_uInt16 nId)
Definition: treeopt.cxx:978
std::vector< std::unique_ptr< OrderedEntry > > m_aNodeList
Definition: treeopt.hxx:50
void ActivatePage(sal_uInt16 nResId)
Definition: treeopt.cxx:753