1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: treeopt.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <com/sun/star/uno/Reference.h>
32 #include <sfx2/basedlgs.hxx>
33 #include <sfx2/tabdlg.hxx>
34 #include <svtools/svtreebx.hxx>
35 #include <tools/resary.hxx>
36 #include <vcl/image.hxx>
37 #include <vcl/fixbrd.hxx>
38 #include <vcl/fixed.hxx>
42 // static ----------------------------------------------------------------
45 CreateTabPage
GetSSOCreator( void );
47 // class OfaOptionsTreeListBox -------------------------------------------
49 //!#define NUMBER_OF_OPTION_PAGES 12
54 class OfaOptionsTreeListBox
: public SvTreeListBox
56 using SvListView::Collapse
;
62 OfaOptionsTreeListBox(Window
* pParent
, const ResId
& rResId
) :
63 SvTreeListBox( pParent
, rResId
), bInCollapse(FALSE
) {}
65 virtual BOOL
Collapse( SvLBoxEntry
* pParent
);
66 BOOL
IsInCollapse()const {return bInCollapse
;}
69 // struct OrderedEntry ---------------------------------------------------
76 OrderedEntry( sal_Int32 nIndex
, const rtl::OUString
& rId
) :
77 m_nIndex( nIndex
), m_sId( rId
) {}
80 typedef std::vector
< OrderedEntry
* > VectorOfOrderedEntries
;
82 // struct Module ---------------------------------------------------------
86 rtl::OUString m_sName
;
88 VectorOfOrderedEntries m_aNodeList
;
90 Module( const rtl::OUString
& rName
) : m_sName( rName
), m_bActive( false ) {}
93 // struct OptionsLeaf ----------------------------------------------------
98 rtl::OUString m_sLabel
;
99 rtl::OUString m_sPageURL
;
100 rtl::OUString m_sEventHdl
;
101 rtl::OUString m_sGroupId
;
102 sal_Int32 m_nGroupIndex
;
104 OptionsLeaf( const rtl::OUString
& rId
,
105 const rtl::OUString
& rLabel
,
106 const rtl::OUString
& rPageURL
,
107 const rtl::OUString
& rEventHdl
,
108 const rtl::OUString
& rGroupId
,
109 sal_Int32 nGroupIndex
) :
112 m_sPageURL( rPageURL
),
113 m_sEventHdl( rEventHdl
),
114 m_sGroupId( rGroupId
),
115 m_nGroupIndex( nGroupIndex
) {}
118 typedef ::std::vector
< OptionsLeaf
* > VectorOfLeaves
;
119 typedef ::std::vector
< VectorOfLeaves
> VectorOfGroupedLeaves
;
121 // struct OptionsNode ----------------------------------------------------
126 rtl::OUString m_sLabel
;
127 rtl::OUString m_sPageURL
;
129 rtl::OUString m_sGroupId
;
130 sal_Int32 m_nGroupIndex
;
131 VectorOfLeaves m_aLeaves
;
132 VectorOfGroupedLeaves m_aGroupedLeaves
;
134 OptionsNode( const rtl::OUString
& rId
,
135 const rtl::OUString
& rLabel
,
136 const rtl::OUString
& rPageURL
,
138 const rtl::OUString
& rGroupId
,
139 sal_Int32 nGroupIndex
) :
142 m_sPageURL( rPageURL
),
143 m_bAllModules( bAllModules
),
144 m_sGroupId( rGroupId
),
145 m_nGroupIndex( nGroupIndex
) {}
149 for ( sal_uInt32 i
= 0; i
< m_aLeaves
.size(); ++i
)
152 m_aGroupedLeaves
.clear();
156 typedef ::std::vector
< OptionsNode
* > VectorOfNodes
;
160 USHORT m_nLastPageId
;
161 rtl::OUString m_sLastPageURL_Tools
;
162 rtl::OUString m_sLastPageURL_ExtMgr
;
164 LastPageSaver() : m_nLastPageId( USHRT_MAX
) {}
167 // class OfaTreeOptionsDialog --------------------------------------------
169 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XFrame
; } } } }
170 namespace com
{ namespace sun
{ namespace star
{ namespace container
{ class XNameAccess
; } } } }
171 namespace com
{ namespace sun
{ namespace star
{ namespace lang
{ class XMultiServiceFactory
; } } } }
172 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XContainerWindowProvider
; } } } }
174 struct OptionsPageInfo
;
176 class ExtensionsTabPage
;
177 typedef std::vector
< ExtensionsTabPage
* > VectorOfPages
;
179 class OfaTreeOptionsDialog
: public SfxModalDialog
183 CancelButton aCancelPB
;
187 FixedBorder aHiddenGB
;
188 FixedText aPageTitleFT
;
193 ImageList aPageImages
;
194 ImageList aPageImagesHC
;
196 ResStringArray aHelpTextsArr
;
198 OfaOptionsTreeListBox aTreeLB
;
201 String sNotLoadedError
;
203 SvLBoxEntry
* pCurrentPageEntry
;
205 // for the ColorTabPage
206 SfxItemSet
* pColorPageItemSet
;
207 XColorTable
* pColorTab
;
213 BOOL bForgetSelection
;
214 BOOL bExternBrowserActive
;
216 bool bInSelectHdl_Impl
;
217 bool bIsFromExtensionManager
;
219 // check "for the current document only" and set focus to "Western" languages box
220 bool bIsForSetDocumentLanguage
;
224 com::sun::star::uno::Reference
< com::sun::star::awt::XContainerWindowProvider
>
225 m_xContainerWinProvider
;
227 static LastPageSaver
* pLastPageSaver
;
229 SfxItemSet
* CreateItemSet( USHORT nId
);
230 void ApplyItemSet( USHORT nId
, const SfxItemSet
& rSet
);
231 void InitTreeAndHandler();
232 void Initialize( const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& _xFrame
);
233 void ResizeTreeLB( void ); // resizes dialog so that treelistbox has no horizontal scroll bar
235 void LoadExtensionOptions( const rtl::OUString
& rExtensionId
);
236 rtl::OUString
GetModuleIdentifier( const com::sun::star::uno::Reference
<
237 com::sun::star::lang::XMultiServiceFactory
>& xMFac
,
238 const com::sun::star::uno::Reference
<
239 com::sun::star::frame::XFrame
>& xFrame
);
240 Module
* LoadModule( const rtl::OUString
& rModuleIdentifier
,
241 const com::sun::star::uno::Reference
<
242 com::sun::star::container::XNameAccess
>& xRoot
);
243 void LoadNodes( const com::sun::star::uno::Reference
<
244 com::sun::star::container::XNameAccess
>& xRoot
,
246 const rtl::OUString
& rExtensionId
,
247 VectorOfNodes
& rOutNodeList
);
248 void InsertNodes( const VectorOfNodes
& rNodeList
);
251 DECL_LINK(ExpandedHdl_Impl
, SvTreeListBox
* );
252 DECL_LINK(ShowPageHdl_Impl
, SvTreeListBox
* );
253 DECL_LINK(BackHdl_Impl
, PushButton
* );
254 DECL_LINK( OKHdl_Impl
, Button
* );
255 DECL_LINK( HintHdl_Impl
, Timer
* );
256 DECL_LINK( SelectHdl_Impl
, Timer
* );
258 virtual long Notify( NotifyEvent
& rNEvt
);
259 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
260 virtual short Execute();
263 OfaTreeOptionsDialog( Window
* pParent
,
264 const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& _xFrame
,
265 bool bActivateLastSelection
= true );
266 OfaTreeOptionsDialog( Window
* pParent
, const rtl::OUString
& rExtensionId
);
267 ~OfaTreeOptionsDialog();
269 OptionsPageInfo
* AddTabPage( USHORT nId
, const String
& rPageName
, USHORT nGroup
);
270 USHORT
AddGroup( const String
& rGroupName
, SfxShell
* pCreateShell
,
271 SfxModule
* pCreateModule
, USHORT nDialogId
);
273 void ActivateLastSelection();
274 void ActivatePage( USHORT nResId
);
275 void ActivatePage( const String
& rPageURL
);
276 void ApplyItemSets();
278 USHORT
GetColorChanged() const { return nChangeType
; }
279 XColorTable
* GetColorTable() { return pColorTab
; }
281 // helper functions to call the language settings TabPage from the SpellDialog
282 static void ApplyLanguageOptions(const SfxItemSet
& rSet
);
285 // class OfaPageResource -------------------------------------------------
287 class OfaPageResource
: public Resource
289 ResStringArray aGeneralDlgAry
;
290 ResStringArray aInetDlgAry
;
291 ResStringArray aLangDlgAry
;
292 ResStringArray aTextDlgAry
;
293 ResStringArray aHTMLDlgAry
;
294 ResStringArray aCalcDlgAry
;
295 ResStringArray aStarMathDlgAry
;
296 ResStringArray aImpressDlgAry
;
297 ResStringArray aDrawDlgAry
;
298 ResStringArray aChartDlgAry
;
299 ResStringArray aFilterDlgAry
;
300 ResStringArray aDatasourcesDlgAry
;
305 ResStringArray
& GetGeneralArray() {return aGeneralDlgAry
;}
306 ResStringArray
& GetInetArray() {return aInetDlgAry
;}
307 ResStringArray
& GetLangArray() {return aLangDlgAry
;}
308 ResStringArray
& GetTextArray() {return aTextDlgAry
;}
309 ResStringArray
& GetHTMLArray() {return aHTMLDlgAry
;}
310 ResStringArray
& GetCalcArray() {return aCalcDlgAry
;}
311 ResStringArray
& GetStarMathArray() {return aStarMathDlgAry
;}
312 ResStringArray
& GetImpressArray() {return aImpressDlgAry
;}
313 ResStringArray
& GetDrawArray() {return aDrawDlgAry
;}
314 ResStringArray
& GetChartArray() {return aChartDlgAry
;}
315 ResStringArray
& GetFilterArray() {return aFilterDlgAry
;}
316 ResStringArray
& GetDatasourcesArray() {return aDatasourcesDlgAry
;}
319 // class ExtensionsTabPage -----------------------------------------------
321 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XWindow
; } } } }
322 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XContainerWindowEventHandler
; } } } }
324 class ExtensionsTabPage
: public TabPage
327 rtl::OUString m_sPageURL
;
328 com::sun::star::uno::Reference
< com::sun::star::awt::XWindow
>
330 rtl::OUString m_sEventHdl
;
331 com::sun::star::uno::Reference
< com::sun::star::awt::XContainerWindowEventHandler
>
333 com::sun::star::uno::Reference
< com::sun::star::awt::XContainerWindowProvider
>
335 bool m_bIsWindowHidden
;
337 void CreateDialogWithHandler();
338 sal_Bool
DispatchAction( const rtl::OUString
& rAction
);
342 Window
* pParent
, const ResId
&,
343 const rtl::OUString
& rPageURL
, const rtl::OUString
& rEvtHdl
,
344 const com::sun::star::uno::Reference
<
345 com::sun::star::awt::XContainerWindowProvider
>& rProvider
);
348 Window
* pParent
, WinBits nStyle
,
349 const rtl::OUString
& rPageURL
, const rtl::OUString
& rEvtHdl
,
350 const com::sun::star::uno::Reference
<
351 com::sun::star::awt::XContainerWindowProvider
>& rProvider
);
353 virtual ~ExtensionsTabPage();
355 virtual void ActivatePage();
356 virtual void DeactivatePage();