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 #include <vcl/tabpage.hxx>
30 #include <vcl/treelistbox.hxx>
31 
32 class SfxModule;
33 class SfxShell;
34 
35 // struct OrderedEntry ---------------------------------------------------
36 
38 {
39  sal_Int32 m_nIndex;
40  OUString m_sId;
41 
42  OrderedEntry( sal_Int32 nIndex, const OUString& rId ) :
43  m_nIndex( nIndex ), m_sId( rId ) {}
44 };
45 
46 
47 // struct Module ---------------------------------------------------------
48 
49 struct Module
50 {
51  bool m_bActive;
52  std::vector< std::unique_ptr<OrderedEntry> > m_aNodeList;
53 
54  Module() : m_bActive( false ) {}
55 };
56 
57 // struct OptionsLeaf ----------------------------------------------------
58 
60 {
61  OUString m_sLabel;
62  OUString m_sPageURL;
63  OUString m_sEventHdl;
64  OUString m_sGroupId;
65  sal_Int32 m_nGroupIndex;
66 
67  OptionsLeaf( const OUString& rLabel,
68  const OUString& rPageURL,
69  const OUString& rEventHdl,
70  const OUString& rGroupId,
71  sal_Int32 nGroupIndex ) :
72  m_sLabel( rLabel ),
73  m_sPageURL( rPageURL ),
74  m_sEventHdl( rEventHdl ),
75  m_sGroupId( rGroupId ),
76  m_nGroupIndex( nGroupIndex ) {}
77 };
78 
79 // struct OptionsNode ----------------------------------------------------
80 
82 {
83  OUString m_sId;
84  OUString m_sLabel;
86  std::vector< std::unique_ptr<OptionsLeaf> > m_aLeaves;
87  std::vector< std::vector< std::unique_ptr<OptionsLeaf> > >
89 
90  OptionsNode( const OUString& rId,
91  const OUString& rLabel,
92  bool bAllModules ) :
93  m_sId( rId ),
94  m_sLabel( rLabel ),
95  m_bAllModules( bAllModules ) {}
96 };
97 
98 typedef std::vector< std::unique_ptr<OptionsNode> > VectorOfNodes;
99 
101 {
102  sal_uInt16 m_nLastPageId;
105 
106  LastPageSaver() : m_nLastPageId( USHRT_MAX ) {}
107 };
108 
109 // class OfaTreeOptionsDialog --------------------------------------------
110 
111 namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
112 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowProvider; } } } }
113 
114 struct OptionsPageInfo;
115 struct Module;
116 class ExtensionsTabPage;
117 class SvxColorTabPage;
118 
120 {
121 private:
125 
128 
130 
132 
133  OUString sTitle;
134 
137 
138  // check "for the current document only" and set focus to "Western" languages box
140 
143 
144  css::uno::Reference < css::awt::XContainerWindowProvider >
146 
148 
149  std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId );
150  static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
151  void InitTreeAndHandler();
152  void Initialize( const css::uno::Reference< css::frame::XFrame >& _xFrame );
153  void InitWidgets();
154 
155  void LoadExtensionOptions( const OUString& rExtensionId );
156  static OUString GetModuleIdentifier( const css::uno::Reference<
157  css::frame::XFrame >& xFrame );
158  static std::unique_ptr<Module> LoadModule( const OUString& rModuleIdentifier );
159  static VectorOfNodes LoadNodes( Module* pModule, const OUString& rExtensionId );
160  void InsertNodes( const VectorOfNodes& rNodeList );
161 
162  void ApplyOptions( bool deactivate );
163 
164  DECL_STATIC_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, void );
165  DECL_LINK(ShowPageHdl_Impl, SvTreeListBox*, void);
166  DECL_LINK(BackHdl_Impl, Button*, void);
167  DECL_LINK(ApplyHdl_Impl, Button*, void);
168  DECL_LINK(OKHdl_Impl, Button*, void);
169  void SelectHdl_Impl();
170 
171  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
172  virtual short Execute() override;
173 
174 public:
176  const css::uno::Reference< css::frame::XFrame >& _xFrame,
177  bool bActivateLastSelection );
178  OfaTreeOptionsDialog( vcl::Window* pParent, const OUString& rExtensionId );
179  virtual ~OfaTreeOptionsDialog() override;
180  virtual void dispose() override;
181 
182  OptionsPageInfo* AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup );
183  sal_uInt16 AddGroup( const OUString& rGroupName, SfxShell* pCreateShell,
184  SfxModule* pCreateModule, sal_uInt16 nDialogId );
185 
186  void ActivateLastSelection();
187  void ActivatePage( sal_uInt16 nResId );
188  void ActivatePage( const OUString& rPageURL );
189  void ApplyItemSets();
190 
191  // helper functions to call the language settings TabPage from the SpellDialog
192  static void ApplyLanguageOptions(const SfxItemSet& rSet);
193 
194  void SetNeedsRestart( svtools::RestartReason eReason );
195 };
196 
197 // class ExtensionsTabPage -----------------------------------------------
198 
199 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
200 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowEventHandler; } } } }
201 
203 {
204 private:
205  OUString m_sPageURL;
206  css::uno::Reference< css::awt::XWindow >
208  OUString m_sEventHdl;
209  css::uno::Reference< css::awt::XContainerWindowEventHandler >
211  css::uno::Reference< css::awt::XContainerWindowProvider >
213 
215  bool DispatchAction( const OUString& rAction );
216 
217 public:
219  vcl::Window* pParent, WinBits nStyle,
220  const OUString& rPageURL, const OUString& rEvtHdl,
221  const css::uno::Reference<
222  css::awt::XContainerWindowProvider >& rProvider );
223 
224  virtual ~ExtensionsTabPage() override;
225  virtual void dispose() override;
226 
227  virtual void ActivatePage() override;
228  virtual void DeactivatePage() override;
229 
230  void ResetPage();
231  void SavePage();
232 };
233 
234 #endif
235 
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OrderedEntry(sal_Int32 nIndex, const OUString &rId)
Definition: treeopt.hxx:42
std::vector< std::vector< std::unique_ptr< OptionsLeaf > > > m_aGroupedLeaves
Definition: treeopt.hxx:88
OUString m_sPageURL
Definition: treeopt.hxx:62
OUString m_sEventHdl
Definition: treeopt.hxx:63
OUString m_sLastPageURL_Tools
Definition: treeopt.hxx:103
VclPtr< VclBox > pTabBox
Definition: treeopt.hxx:127
bool bIsFromExtensionManager
Definition: treeopt.hxx:136
VclPtr< SvTreeListBox > pTreeLB
Definition: treeopt.hxx:126
std::vector< std::unique_ptr< OptionsNode > > VectorOfNodes
Definition: treeopt.hxx:98
sal_Int32 m_nIndex
Definition: treeopt.hxx:39
OUString m_sLastPageURL_ExtMgr
Definition: treeopt.hxx:104
virtual void dispose() override
Definition: treeopt.cxx:2065
OUString m_sPageURL
Definition: treeopt.hxx:205
ExtensionsTabPage(vcl::Window *pParent, WinBits nStyle, const OUString &rPageURL, const OUString &rEvtHdl, const css::uno::Reference< css::awt::XContainerWindowProvider > &rProvider)
Definition: treeopt.cxx:2048
sal_Int64 WinBits
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: treeopt.cxx:911
void CreateDialogWithHandler()
Definition: treeopt.cxx:2085
OptionsLeaf(const OUString &rLabel, const OUString &rPageURL, const OUString &rEventHdl, const OUString &rGroupId, sal_Int32 nGroupIndex)
Definition: treeopt.hxx:67
OUString m_sLabel
Definition: treeopt.hxx:61
virtual void ActivatePage() override
Definition: treeopt.cxx:2141
bool m_bAllModules
Definition: treeopt.hxx:85
OptionsPageInfo * AddTabPage(sal_uInt16 nId, const OUString &rPageName, sal_uInt16 nGroup)
Definition: treeopt.cxx:616
OUString m_sId
Definition: treeopt.hxx:83
OUString m_sLabel
Definition: treeopt.hxx:84
static VectorOfNodes LoadNodes(Module *pModule, const OUString &rExtensionId)
Definition: treeopt.cxx:1835
sal_Int32 m_nGroupIndex
Definition: treeopt.hxx:65
OUString m_sGroupId
Definition: treeopt.hxx:64
virtual void DeactivatePage() override
Definition: treeopt.cxx:2166
static OUString GetModuleIdentifier(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: treeopt.cxx:1740
virtual void dispose() override
Definition: treeopt.cxx:555
static void ApplyLanguageOptions(const SfxItemSet &rSet)
Definition: treeopt.cxx:1333
VclPtr< PushButton > pBackPB
Definition: treeopt.hxx:124
void LoadExtensionOptions(const OUString &rExtensionId)
Definition: treeopt.cxx:1726
void Initialize(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: treeopt.cxx:1429
std::vector< std::unique_ptr< OptionsLeaf > > m_aLeaves
Definition: treeopt.hxx:86
VclPtr< PushButton > pApplyPB
Definition: treeopt.hxx:123
void ApplyOptions(bool deactivate)
Definition: treeopt.cxx:669
bool bIsForSetDocumentLanguage
Definition: treeopt.hxx:139
static LastPageSaver * pLastPageSaver
Definition: treeopt.hxx:147
Module()
Definition: treeopt.hxx:54
OfaTreeOptionsDialog(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &_xFrame, bool bActivateLastSelection)
svtools::RestartReason eRestartReason
Definition: treeopt.hxx:142
css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl
Definition: treeopt.hxx:210
sal_uInt16 m_nLastPageId
Definition: treeopt.hxx:102
bool m_bActive
Definition: treeopt.hxx:51
virtual ~OfaTreeOptionsDialog() override
Definition: treeopt.cxx:550
DECL_STATIC_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox *, void)
css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider
Definition: treeopt.hxx:212
OptionsNode(const OUString &rId, const OUString &rLabel, bool bAllModules)
Definition: treeopt.hxx:90
void ActivateLastSelection()
Definition: treeopt.cxx:856
bool DispatchAction(const OUString &rAction)
Definition: treeopt.cxx:2124
void SetNeedsRestart(svtools::RestartReason eReason)
Definition: treeopt.cxx:2021
css::uno::Reference< css::awt::XWindow > m_xPage
Definition: treeopt.hxx:207
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
VclPtr< OKButton > pOkPB
Definition: treeopt.hxx:122
css::uno::Reference< css::awt::XContainerWindowProvider > m_xContainerWinProvider
Definition: treeopt.hxx:145
sal_uInt16 AddGroup(const OUString &rGroupName, SfxShell *pCreateShell, SfxModule *pCreateModule, sal_uInt16 nDialogId)
Definition: treeopt.cxx:628
static void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
Definition: treeopt.cxx:1254
OUString m_sId
Definition: treeopt.hxx:40
static std::unique_ptr< Module > LoadModule(const OUString &rModuleIdentifier)
Definition: treeopt.cxx:1771
void InsertNodes(const VectorOfNodes &rNodeList)
Definition: treeopt.cxx:1999
SvTreeListEntry * pCurrentPageEntry
Definition: treeopt.hxx:131
VclPtr< vcl::Window > m_pParent
Definition: treeopt.hxx:129
OUString m_sEventHdl
Definition: treeopt.hxx:208
void InitTreeAndHandler()
Definition: treeopt.cxx:806
std::unique_ptr< SfxItemSet > CreateItemSet(sal_uInt16 nId)
Definition: treeopt.cxx:1101
virtual short Execute() override
Definition: treeopt.cxx:2027
virtual ~ExtensionsTabPage() override
Definition: treeopt.cxx:2060
DECL_LINK(ShowPageHdl_Impl, SvTreeListBox *, void)
std::vector< std::unique_ptr< OrderedEntry > > m_aNodeList
Definition: treeopt.hxx:52
void ActivatePage(sal_uInt16 nResId)
Definition: treeopt.cxx:826