Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / inc / treeopt.hxx
blobee6fa4069664c9350654b8a3a177791992f962bc
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 #include <tools/resary.hxx>
21 #include <vcl/fixed.hxx>
23 class SfxModule;
24 class SfxShell;
26 // static ----------------------------------------------------------------
28 sal_Bool EnableSSO();
29 CreateTabPage GetSSOCreator( void );
31 // struct OrderedEntry ---------------------------------------------------
33 struct OrderedEntry
35 sal_Int32 m_nIndex;
36 rtl::OUString m_sId;
38 OrderedEntry( sal_Int32 nIndex, const rtl::OUString& rId ) :
39 m_nIndex( nIndex ), m_sId( rId ) {}
42 typedef std::vector< OrderedEntry* > VectorOfOrderedEntries;
44 // struct Module ---------------------------------------------------------
46 struct Module
48 rtl::OUString m_sName;
49 bool m_bActive;
50 VectorOfOrderedEntries m_aNodeList;
52 Module( const rtl::OUString& rName ) : m_sName( rName ), m_bActive( false ) {}
55 // struct OptionsLeaf ----------------------------------------------------
57 struct OptionsLeaf
59 rtl::OUString m_sId;
60 rtl::OUString m_sLabel;
61 rtl::OUString m_sPageURL;
62 rtl::OUString m_sEventHdl;
63 rtl::OUString m_sGroupId;
64 sal_Int32 m_nGroupIndex;
66 OptionsLeaf( const rtl::OUString& rId,
67 const rtl::OUString& rLabel,
68 const rtl::OUString& rPageURL,
69 const rtl::OUString& rEventHdl,
70 const rtl::OUString& rGroupId,
71 sal_Int32 nGroupIndex ) :
72 m_sId( rId ),
73 m_sLabel( rLabel ),
74 m_sPageURL( rPageURL ),
75 m_sEventHdl( rEventHdl ),
76 m_sGroupId( rGroupId ),
77 m_nGroupIndex( nGroupIndex ) {}
80 typedef ::std::vector< OptionsLeaf* > VectorOfLeaves;
81 typedef ::std::vector< VectorOfLeaves > VectorOfGroupedLeaves;
83 // struct OptionsNode ----------------------------------------------------
85 struct OptionsNode
87 rtl::OUString m_sId;
88 rtl::OUString m_sLabel;
89 rtl::OUString m_sPageURL;
90 bool m_bAllModules;
91 rtl::OUString m_sGroupId;
92 sal_Int32 m_nGroupIndex;
93 VectorOfLeaves m_aLeaves;
94 VectorOfGroupedLeaves m_aGroupedLeaves;
96 OptionsNode( const rtl::OUString& rId,
97 const rtl::OUString& rLabel,
98 const rtl::OUString& rPageURL,
99 bool bAllModules,
100 const rtl::OUString& rGroupId,
101 sal_Int32 nGroupIndex ) :
102 m_sId( rId ),
103 m_sLabel( rLabel ),
104 m_sPageURL( rPageURL ),
105 m_bAllModules( bAllModules ),
106 m_sGroupId( rGroupId ),
107 m_nGroupIndex( nGroupIndex ) {}
109 ~OptionsNode()
111 for ( sal_uInt32 i = 0; i < m_aLeaves.size(); ++i )
112 delete m_aLeaves[i];
113 m_aLeaves.clear();
114 m_aGroupedLeaves.clear();
118 typedef ::std::vector< OptionsNode* > VectorOfNodes;
120 struct LastPageSaver
122 sal_uInt16 m_nLastPageId;
123 rtl::OUString m_sLastPageURL_Tools;
124 rtl::OUString m_sLastPageURL_ExtMgr;
126 LastPageSaver() : m_nLastPageId( USHRT_MAX ) {}
129 // class OfaTreeOptionsDialog --------------------------------------------
131 namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
132 namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } }
133 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowProvider; } } } }
135 struct OptionsPageInfo;
136 struct Module;
137 class ExtensionsTabPage;
138 class SvxColorTabPage;
139 typedef std::vector< ExtensionsTabPage* > VectorOfPages;
141 class OfaTreeOptionsDialog : public SfxModalDialog
143 private:
144 OKButton aOkPB;
145 CancelButton aCancelPB;
146 HelpButton aHelpPB;
147 PushButton aBackPB;
149 FixedLine aSeparatorFL;
151 SvTreeListBox aTreeLB;
153 String sTitle;
154 String sNotLoadedError;
156 SvTreeListEntry* pCurrentPageEntry;
158 // for the ColorTabPage
159 SfxItemSet* pColorPageItemSet;
160 SvxColorTabPage *mpColorPage;
162 sal_Bool bForgetSelection;
163 sal_Bool bExternBrowserActive;
164 bool bIsFromExtensionManager;
166 // check "for the current document only" and set focus to "Western" languages box
167 bool bIsForSetDocumentLanguage;
169 com::sun::star::uno::Reference < com::sun::star::awt::XContainerWindowProvider >
170 m_xContainerWinProvider;
172 static LastPageSaver* pLastPageSaver;
174 SfxItemSet* CreateItemSet( sal_uInt16 nId );
175 void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
176 void InitTreeAndHandler();
177 void Initialize( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& _xFrame );
178 void ResizeTreeLB( void ); // resizes dialog so that treelistbox has no horizontal scroll bar
180 void LoadExtensionOptions( const rtl::OUString& rExtensionId );
181 rtl::OUString GetModuleIdentifier( const com::sun::star::uno::Reference<
182 com::sun::star::lang::XMultiServiceFactory >& xMFac,
183 const com::sun::star::uno::Reference<
184 com::sun::star::frame::XFrame >& xFrame );
185 Module* LoadModule( const rtl::OUString& rModuleIdentifier );
186 VectorOfNodes LoadNodes( Module* pModule, const rtl::OUString& rExtensionId );
187 void InsertNodes( const VectorOfNodes& rNodeList );
189 void SetPaneSize(Window *pPane);
191 protected:
192 DECL_LINK(ExpandedHdl_Impl, SvTreeListBox* );
193 DECL_LINK(ShowPageHdl_Impl, void *);
194 DECL_LINK(BackHdl_Impl, void *);
195 DECL_LINK(OKHdl_Impl, void *);
196 DECL_LINK( HintHdl_Impl, Timer * );
197 void SelectHdl_Impl();
199 virtual long Notify( NotifyEvent& rNEvt );
200 virtual short Execute();
202 public:
203 OfaTreeOptionsDialog( Window* pParent,
204 const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& _xFrame,
205 bool bActivateLastSelection = true );
206 OfaTreeOptionsDialog( Window* pParent, const rtl::OUString& rExtensionId );
207 ~OfaTreeOptionsDialog();
209 OptionsPageInfo* AddTabPage( sal_uInt16 nId, const String& rPageName, sal_uInt16 nGroup );
210 sal_uInt16 AddGroup( const String& rGroupName, SfxShell* pCreateShell,
211 SfxModule* pCreateModule, sal_uInt16 nDialogId );
213 void ActivateLastSelection();
214 void ActivatePage( sal_uInt16 nResId );
215 void ActivatePage( const String& rPageURL );
216 void ApplyItemSets();
218 // helper functions to call the language settings TabPage from the SpellDialog
219 static void ApplyLanguageOptions(const SfxItemSet& rSet);
222 // class OfaPageResource -------------------------------------------------
224 class OfaPageResource : public Resource
226 ResStringArray aGeneralDlgAry;
227 ResStringArray aInetDlgAry;
228 ResStringArray aLangDlgAry;
229 ResStringArray aTextDlgAry;
230 ResStringArray aHTMLDlgAry;
231 ResStringArray aCalcDlgAry;
232 ResStringArray aStarMathDlgAry;
233 ResStringArray aImpressDlgAry;
234 ResStringArray aDrawDlgAry;
235 ResStringArray aChartDlgAry;
236 ResStringArray aFilterDlgAry;
237 ResStringArray aDatasourcesDlgAry;
239 public:
240 OfaPageResource();
242 ResStringArray& GetGeneralArray() {return aGeneralDlgAry;}
243 ResStringArray& GetInetArray() {return aInetDlgAry;}
244 ResStringArray& GetLangArray() {return aLangDlgAry;}
245 ResStringArray& GetTextArray() {return aTextDlgAry;}
246 ResStringArray& GetHTMLArray() {return aHTMLDlgAry;}
247 ResStringArray& GetCalcArray() {return aCalcDlgAry;}
248 ResStringArray& GetStarMathArray() {return aStarMathDlgAry;}
249 ResStringArray& GetImpressArray() {return aImpressDlgAry;}
250 ResStringArray& GetDrawArray() {return aDrawDlgAry;}
251 ResStringArray& GetChartArray() {return aChartDlgAry;}
252 ResStringArray& GetFilterArray() {return aFilterDlgAry;}
253 ResStringArray& GetDatasourcesArray() {return aDatasourcesDlgAry;}
256 // class ExtensionsTabPage -----------------------------------------------
258 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
259 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowEventHandler; } } } }
261 class ExtensionsTabPage : public TabPage
263 private:
264 rtl::OUString m_sPageURL;
265 com::sun::star::uno::Reference< com::sun::star::awt::XWindow >
266 m_xPage;
267 rtl::OUString m_sEventHdl;
268 com::sun::star::uno::Reference< com::sun::star::awt::XContainerWindowEventHandler >
269 m_xEventHdl;
270 com::sun::star::uno::Reference< com::sun::star::awt::XContainerWindowProvider >
271 m_xWinProvider;
272 bool m_bIsWindowHidden;
274 void CreateDialogWithHandler();
275 sal_Bool DispatchAction( const rtl::OUString& rAction );
277 public:
278 ExtensionsTabPage(
279 Window* pParent, WinBits nStyle,
280 const rtl::OUString& rPageURL, const rtl::OUString& rEvtHdl,
281 const com::sun::star::uno::Reference<
282 com::sun::star::awt::XContainerWindowProvider >& rProvider );
284 virtual ~ExtensionsTabPage();
286 virtual void ActivatePage();
287 virtual void DeactivatePage();
289 void ResetPage();
290 void SavePage();
293 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */