Line data Source code
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 : #include <tools/resary.hxx>
21 : #include <vcl/fixed.hxx>
22 :
23 : class SfxModule;
24 : class SfxShell;
25 :
26 : // static ----------------------------------------------------------------
27 :
28 : sal_Bool EnableSSO();
29 : CreateTabPage GetSSOCreator( void );
30 :
31 : // struct OrderedEntry ---------------------------------------------------
32 :
33 : struct OrderedEntry
34 : {
35 : sal_Int32 m_nIndex;
36 : rtl::OUString m_sId;
37 :
38 0 : OrderedEntry( sal_Int32 nIndex, const rtl::OUString& rId ) :
39 0 : m_nIndex( nIndex ), m_sId( rId ) {}
40 : };
41 :
42 : typedef std::vector< OrderedEntry* > VectorOfOrderedEntries;
43 :
44 : // struct Module ---------------------------------------------------------
45 :
46 0 : struct Module
47 : {
48 : rtl::OUString m_sName;
49 : bool m_bActive;
50 : VectorOfOrderedEntries m_aNodeList;
51 :
52 0 : Module( const rtl::OUString& rName ) : m_sName( rName ), m_bActive( false ) {}
53 : };
54 :
55 : // struct OptionsLeaf ----------------------------------------------------
56 :
57 0 : struct OptionsLeaf
58 : {
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;
65 :
66 0 : 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 0 : m_nGroupIndex( nGroupIndex ) {}
78 : };
79 :
80 : typedef ::std::vector< OptionsLeaf* > VectorOfLeaves;
81 : typedef ::std::vector< VectorOfLeaves > VectorOfGroupedLeaves;
82 :
83 : // struct OptionsNode ----------------------------------------------------
84 :
85 : struct OptionsNode
86 : {
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;
95 :
96 0 : 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 0 : m_nGroupIndex( nGroupIndex ) {}
108 :
109 0 : ~OptionsNode()
110 0 : {
111 0 : for ( sal_uInt32 i = 0; i < m_aLeaves.size(); ++i )
112 0 : delete m_aLeaves[i];
113 0 : m_aLeaves.clear();
114 0 : m_aGroupedLeaves.clear();
115 0 : }
116 : };
117 :
118 : typedef ::std::vector< OptionsNode* > VectorOfNodes;
119 :
120 : struct LastPageSaver
121 : {
122 : sal_uInt16 m_nLastPageId;
123 : rtl::OUString m_sLastPageURL_Tools;
124 : rtl::OUString m_sLastPageURL_ExtMgr;
125 :
126 0 : LastPageSaver() : m_nLastPageId( USHRT_MAX ) {}
127 : };
128 :
129 : // class OfaTreeOptionsDialog --------------------------------------------
130 :
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; } } } }
134 :
135 : struct OptionsPageInfo;
136 : struct Module;
137 : class ExtensionsTabPage;
138 : class SvxColorTabPage;
139 : typedef std::vector< ExtensionsTabPage* > VectorOfPages;
140 :
141 : class OfaTreeOptionsDialog : public SfxModalDialog
142 : {
143 : private:
144 : OKButton aOkPB;
145 : CancelButton aCancelPB;
146 : HelpButton aHelpPB;
147 : PushButton aBackPB;
148 :
149 : FixedLine aSeparatorFL;
150 :
151 : SvTreeListBox aTreeLB;
152 :
153 : String sTitle;
154 : String sNotLoadedError;
155 :
156 : SvTreeListEntry* pCurrentPageEntry;
157 :
158 : // for the ColorTabPage
159 : SfxItemSet* pColorPageItemSet;
160 : SvxColorTabPage *mpColorPage;
161 :
162 : sal_Bool bForgetSelection;
163 : sal_Bool bExternBrowserActive;
164 : bool bIsFromExtensionManager;
165 :
166 : // check "for the current document only" and set focus to "Western" languages box
167 : bool bIsForSetDocumentLanguage;
168 :
169 : com::sun::star::uno::Reference < com::sun::star::awt::XContainerWindowProvider >
170 : m_xContainerWinProvider;
171 :
172 : static LastPageSaver* pLastPageSaver;
173 :
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
179 :
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 );
188 :
189 : void SetPaneSize(Window *pPane);
190 :
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();
198 :
199 : virtual long Notify( NotifyEvent& rNEvt );
200 : virtual short Execute();
201 :
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();
208 :
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 );
212 :
213 : void ActivateLastSelection();
214 : void ActivatePage( sal_uInt16 nResId );
215 : void ActivatePage( const String& rPageURL );
216 : void ApplyItemSets();
217 :
218 : // helper functions to call the language settings TabPage from the SpellDialog
219 : static void ApplyLanguageOptions(const SfxItemSet& rSet);
220 : };
221 :
222 : // class OfaPageResource -------------------------------------------------
223 :
224 0 : class OfaPageResource : public Resource
225 : {
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;
238 :
239 : public:
240 : OfaPageResource();
241 :
242 0 : ResStringArray& GetGeneralArray() {return aGeneralDlgAry;}
243 0 : ResStringArray& GetInetArray() {return aInetDlgAry;}
244 0 : ResStringArray& GetLangArray() {return aLangDlgAry;}
245 0 : ResStringArray& GetTextArray() {return aTextDlgAry;}
246 0 : ResStringArray& GetHTMLArray() {return aHTMLDlgAry;}
247 0 : ResStringArray& GetCalcArray() {return aCalcDlgAry;}
248 0 : ResStringArray& GetStarMathArray() {return aStarMathDlgAry;}
249 0 : ResStringArray& GetImpressArray() {return aImpressDlgAry;}
250 0 : ResStringArray& GetDrawArray() {return aDrawDlgAry;}
251 0 : ResStringArray& GetChartArray() {return aChartDlgAry;}
252 0 : ResStringArray& GetFilterArray() {return aFilterDlgAry;}
253 0 : ResStringArray& GetDatasourcesArray() {return aDatasourcesDlgAry;}
254 : };
255 :
256 : // class ExtensionsTabPage -----------------------------------------------
257 :
258 : namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
259 : namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowEventHandler; } } } }
260 :
261 : class ExtensionsTabPage : public TabPage
262 : {
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;
273 :
274 : void CreateDialogWithHandler();
275 : sal_Bool DispatchAction( const rtl::OUString& rAction );
276 :
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 );
283 :
284 : virtual ~ExtensionsTabPage();
285 :
286 : virtual void ActivatePage();
287 : virtual void DeactivatePage();
288 :
289 : void ResetPage();
290 : void SavePage();
291 : };
292 :
293 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|