bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / inc / treeopt.hxx
blob86f7af92fbec56a181116598f69506813149c47c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_CUI_SOURCE_INC_TREEOPT_HXX
21 #define INCLUDED_CUI_SOURCE_INC_TREEOPT_HXX
23 #include <tools/resary.hxx>
24 #include <vcl/fixed.hxx>
26 class SfxModule;
27 class SfxShell;
29 // static ----------------------------------------------------------------
31 bool EnableSSO();
32 CreateTabPage GetSSOCreator();
34 // struct OrderedEntry ---------------------------------------------------
36 struct OrderedEntry
38 sal_Int32 m_nIndex;
39 OUString m_sId;
41 OrderedEntry( sal_Int32 nIndex, const OUString& rId ) :
42 m_nIndex( nIndex ), m_sId( rId ) {}
45 typedef std::vector< OrderedEntry* > VectorOfOrderedEntries;
47 // struct Module ---------------------------------------------------------
49 struct Module
51 OUString m_sName;
52 bool m_bActive;
53 VectorOfOrderedEntries m_aNodeList;
55 Module( const OUString& rName ) : m_sName( rName ), m_bActive( false ) {}
58 // struct OptionsLeaf ----------------------------------------------------
60 struct OptionsLeaf
62 OUString m_sId;
63 OUString m_sLabel;
64 OUString m_sPageURL;
65 OUString m_sEventHdl;
66 OUString m_sGroupId;
67 sal_Int32 m_nGroupIndex;
69 OptionsLeaf( const OUString& rId,
70 const OUString& rLabel,
71 const OUString& rPageURL,
72 const OUString& rEventHdl,
73 const OUString& rGroupId,
74 sal_Int32 nGroupIndex ) :
75 m_sId( rId ),
76 m_sLabel( rLabel ),
77 m_sPageURL( rPageURL ),
78 m_sEventHdl( rEventHdl ),
79 m_sGroupId( rGroupId ),
80 m_nGroupIndex( nGroupIndex ) {}
83 typedef ::std::vector< OptionsLeaf* > VectorOfLeaves;
84 typedef ::std::vector< VectorOfLeaves > VectorOfGroupedLeaves;
86 // struct OptionsNode ----------------------------------------------------
88 struct OptionsNode
90 OUString m_sId;
91 OUString m_sLabel;
92 OUString m_sPageURL;
93 bool m_bAllModules;
94 OUString m_sGroupId;
95 sal_Int32 m_nGroupIndex;
96 VectorOfLeaves m_aLeaves;
97 VectorOfGroupedLeaves m_aGroupedLeaves;
99 OptionsNode( const OUString& rId,
100 const OUString& rLabel,
101 const OUString& rPageURL,
102 bool bAllModules,
103 const OUString& rGroupId,
104 sal_Int32 nGroupIndex ) :
105 m_sId( rId ),
106 m_sLabel( rLabel ),
107 m_sPageURL( rPageURL ),
108 m_bAllModules( bAllModules ),
109 m_sGroupId( rGroupId ),
110 m_nGroupIndex( nGroupIndex ) {}
112 ~OptionsNode()
114 for ( sal_uInt32 i = 0; i < m_aLeaves.size(); ++i )
115 delete m_aLeaves[i];
116 m_aLeaves.clear();
117 m_aGroupedLeaves.clear();
121 typedef ::std::vector< OptionsNode* > VectorOfNodes;
123 struct LastPageSaver
125 sal_uInt16 m_nLastPageId;
126 OUString m_sLastPageURL_Tools;
127 OUString m_sLastPageURL_ExtMgr;
129 LastPageSaver() : m_nLastPageId( USHRT_MAX ) {}
132 // class OfaTreeOptionsDialog --------------------------------------------
134 namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
135 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowProvider; } } } }
137 struct OptionsPageInfo;
138 struct Module;
139 class ExtensionsTabPage;
140 class SvxColorTabPage;
141 typedef std::vector< ExtensionsTabPage* > VectorOfPages;
143 class OfaTreeOptionsDialog : public SfxModalDialog
145 private:
146 SvTreeListEntry* pCurrentPageEntry;
147 bool hasTreePendingLayout() const;
149 VclPtr<OKButton> pOkPB;
150 VclPtr<PushButton> pBackPB;
152 VclPtr<SvTreeListBox> pTreeLB;
153 VclPtr<VclBox> pTabBox;
155 OUString sTitle;
156 OUString sNotLoadedError;
158 // for the ColorTabPage
159 SfxItemSet* pColorPageItemSet;
160 VclPtr<SvxColorTabPage> mpColorPage;
162 bool bForgetSelection;
163 bool bIsFromExtensionManager;
165 // check "for the current document only" and set focus to "Western" languages box
166 bool bIsForSetDocumentLanguage;
168 com::sun::star::uno::Reference < com::sun::star::awt::XContainerWindowProvider >
169 m_xContainerWinProvider;
171 static LastPageSaver* pLastPageSaver;
173 SfxItemSet* CreateItemSet( sal_uInt16 nId );
174 static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
175 void InitTreeAndHandler();
176 void Initialize( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& _xFrame );
177 void InitWidgets();
179 void LoadExtensionOptions( const OUString& rExtensionId );
180 static OUString GetModuleIdentifier( const com::sun::star::uno::Reference<
181 com::sun::star::frame::XFrame >& xFrame );
182 static Module* LoadModule( const OUString& rModuleIdentifier );
183 static VectorOfNodes LoadNodes( Module* pModule, const OUString& rExtensionId );
184 void InsertNodes( const VectorOfNodes& rNodeList );
186 protected:
187 DECL_STATIC_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox* );
188 DECL_LINK(ShowPageHdl_Impl, void *);
189 DECL_LINK(BackHdl_Impl, void *);
190 DECL_LINK(OKHdl_Impl, void *);
191 DECL_LINK( HintHdl_Impl, Timer * );
192 void SelectHdl_Impl();
194 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
195 virtual short Execute() SAL_OVERRIDE;
197 public:
198 OfaTreeOptionsDialog( vcl::Window* pParent,
199 const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& _xFrame,
200 bool bActivateLastSelection = true );
201 OfaTreeOptionsDialog( vcl::Window* pParent, const OUString& rExtensionId );
202 virtual ~OfaTreeOptionsDialog();
203 virtual void dispose() SAL_OVERRIDE;
205 OptionsPageInfo* AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup );
206 sal_uInt16 AddGroup( const OUString& rGroupName, SfxShell* pCreateShell,
207 SfxModule* pCreateModule, sal_uInt16 nDialogId );
209 void ActivateLastSelection();
210 void ActivatePage( sal_uInt16 nResId );
211 void ActivatePage( const OUString& rPageURL );
212 void ApplyItemSets();
214 // helper functions to call the language settings TabPage from the SpellDialog
215 static void ApplyLanguageOptions(const SfxItemSet& rSet);
218 // class OfaPageResource -------------------------------------------------
220 class OfaPageResource : public Resource
222 ResStringArray aGeneralDlgAry;
223 ResStringArray aInetDlgAry;
224 ResStringArray aLangDlgAry;
225 ResStringArray aTextDlgAry;
226 ResStringArray aHTMLDlgAry;
227 ResStringArray aCalcDlgAry;
228 ResStringArray aStarMathDlgAry;
229 ResStringArray aImpressDlgAry;
230 ResStringArray aDrawDlgAry;
231 ResStringArray aChartDlgAry;
232 ResStringArray aFilterDlgAry;
233 ResStringArray aDatasourcesDlgAry;
235 public:
236 OfaPageResource();
238 ResStringArray& GetGeneralArray() {return aGeneralDlgAry;}
239 ResStringArray& GetInetArray() {return aInetDlgAry;}
240 ResStringArray& GetLangArray() {return aLangDlgAry;}
241 ResStringArray& GetTextArray() {return aTextDlgAry;}
242 ResStringArray& GetHTMLArray() {return aHTMLDlgAry;}
243 ResStringArray& GetCalcArray() {return aCalcDlgAry;}
244 ResStringArray& GetStarMathArray() {return aStarMathDlgAry;}
245 ResStringArray& GetImpressArray() {return aImpressDlgAry;}
246 ResStringArray& GetDrawArray() {return aDrawDlgAry;}
247 ResStringArray& GetChartArray() {return aChartDlgAry;}
248 ResStringArray& GetFilterArray() {return aFilterDlgAry;}
249 ResStringArray& GetDatasourcesArray() {return aDatasourcesDlgAry;}
252 // class ExtensionsTabPage -----------------------------------------------
254 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
255 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowEventHandler; } } } }
257 class ExtensionsTabPage : public TabPage
259 private:
260 OUString m_sPageURL;
261 com::sun::star::uno::Reference< com::sun::star::awt::XWindow >
262 m_xPage;
263 OUString m_sEventHdl;
264 com::sun::star::uno::Reference< com::sun::star::awt::XContainerWindowEventHandler >
265 m_xEventHdl;
266 com::sun::star::uno::Reference< com::sun::star::awt::XContainerWindowProvider >
267 m_xWinProvider;
268 bool m_bIsWindowHidden;
270 void CreateDialogWithHandler();
271 bool DispatchAction( const OUString& rAction );
273 public:
274 ExtensionsTabPage(
275 vcl::Window* pParent, WinBits nStyle,
276 const OUString& rPageURL, const OUString& rEvtHdl,
277 const com::sun::star::uno::Reference<
278 com::sun::star::awt::XContainerWindowProvider >& rProvider );
280 virtual ~ExtensionsTabPage();
281 virtual void dispose() SAL_OVERRIDE;
283 virtual void ActivatePage() SAL_OVERRIDE;
284 virtual void DeactivatePage() SAL_OVERRIDE;
286 void ResetPage();
287 void SavePage();
290 #endif
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */