xref: /aoo41x/main/cui/source/options/treeopt.cxx (revision c7be74b1)
12ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32ee96f1cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42ee96f1cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52ee96f1cSAndrew Rist  * distributed with this work for additional information
62ee96f1cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72ee96f1cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82ee96f1cSAndrew Rist  * "License"); you may not use this file except in compliance
92ee96f1cSAndrew Rist  * with the License.  You may obtain a copy of the License at
102ee96f1cSAndrew Rist  *
112ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122ee96f1cSAndrew Rist  *
132ee96f1cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142ee96f1cSAndrew Rist  * software distributed under the License is distributed on an
152ee96f1cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162ee96f1cSAndrew Rist  * KIND, either express or implied.  See the License for the
172ee96f1cSAndrew Rist  * specific language governing permissions and limitations
182ee96f1cSAndrew Rist  * under the License.
192ee96f1cSAndrew Rist  *
202ee96f1cSAndrew Rist  *************************************************************/
212ee96f1cSAndrew Rist 
222ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28cdf0e10cSrcweir #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
29cdf0e10cSrcweir #include <com/sun/star/linguistic2/XDictionaryList.hpp>
30cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
33cdf0e10cSrcweir #include <com/sun/star/util/XMacroExpander.hpp>
34cdf0e10cSrcweir #include <osl/module.hxx>
35cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
36cdf0e10cSrcweir #include <com/sun/star/frame/XLoadable.hpp>
37cdf0e10cSrcweir #include <tools/rcid.h>
38cdf0e10cSrcweir #include <tools/shl.hxx>
39cdf0e10cSrcweir #include <tools/urlobj.hxx>
40cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
41cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
43cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
44cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
45cdf0e10cSrcweir #include <com/sun/star/oooimprovement/XCoreController.hpp>
46cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
47cdf0e10cSrcweir #include <com/sun/star/awt/XDialogProvider.hpp>
48cdf0e10cSrcweir #include <com/sun/star/awt/XDialogProvider2.hpp>
49cdf0e10cSrcweir #include <com/sun/star/awt/XContainerWindowProvider.hpp>
50cdf0e10cSrcweir #include <com/sun/star/awt/XDialogEventHandler.hpp>
51cdf0e10cSrcweir #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
52cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
53cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp>
54cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp>
55cdf0e10cSrcweir #include <com/sun/star/awt/XTabController.hpp>
56cdf0e10cSrcweir #include <vcl/help.hxx>
57cdf0e10cSrcweir #include <linguistic/misc.hxx>
58cdf0e10cSrcweir #include <svtools/helpopt.hxx>
59cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
60cdf0e10cSrcweir #include <svl/languageoptions.hxx>
61cdf0e10cSrcweir #include <unotools/optionsdlg.hxx>
62cdf0e10cSrcweir #include <sfx2/module.hxx>
63cdf0e10cSrcweir #include <vcl/msgbox.hxx>
64cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
65cdf0e10cSrcweir #include <vcl/waitobj.hxx>
66cdf0e10cSrcweir #include <svl/slstitm.hxx>
67cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
68cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
69cdf0e10cSrcweir #include <sfx2/printopt.hxx>
70cdf0e10cSrcweir #include <osl/module.h>
71cdf0e10cSrcweir #include <osl/process.h>
72cdf0e10cSrcweir #include <rtl/bootstrap.hxx>
73cdf0e10cSrcweir #include <unotools/misccfg.hxx>
74cdf0e10cSrcweir #include <sfx2/objsh.hxx>
75cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
76cdf0e10cSrcweir #include <sfx2/tplpitem.hxx>
77cdf0e10cSrcweir #include <svtools/apearcfg.hxx>
78cdf0e10cSrcweir #include <unotools/linguprops.hxx>
79cdf0e10cSrcweir #include <sfx2/app.hxx>
80cdf0e10cSrcweir #include <svx/xdef.hxx>
81cdf0e10cSrcweir #include <svx/xflclit.hxx>
82cdf0e10cSrcweir #include <svx/xpool.hxx>
83cdf0e10cSrcweir #include "cuitabarea.hxx"
84cdf0e10cSrcweir #include <svx/ofaitem.hxx>
85cdf0e10cSrcweir #include "opthtml.hxx"
86cdf0e10cSrcweir #include "optcolor.hxx"
87cdf0e10cSrcweir #include "optctl.hxx"
88cdf0e10cSrcweir #include "optjava.hxx"
89cdf0e10cSrcweir #include "optsave.hxx"
90cdf0e10cSrcweir #include "optpath.hxx"
91cdf0e10cSrcweir #include "cuioptgenrl.hxx"
92cdf0e10cSrcweir #include "optlingu.hxx"
93cdf0e10cSrcweir #include "optinet2.hxx"
94cdf0e10cSrcweir #include "optasian.hxx"
95cdf0e10cSrcweir #include "optaccessibility.hxx"
96cdf0e10cSrcweir #include "optjsearch.hxx"
97cdf0e10cSrcweir #include "connpooloptions.hxx"
98cdf0e10cSrcweir #include "optupdt.hxx"
99cdf0e10cSrcweir #include <optimprove.hxx>
100cdf0e10cSrcweir #include "optchart.hxx"
101cdf0e10cSrcweir #include "optgdlg.hxx"
102cdf0e10cSrcweir #include "optmemory.hxx"
103cdf0e10cSrcweir #include "optfltr.hxx"
104cdf0e10cSrcweir #include <cuires.hrc>
105cdf0e10cSrcweir #include "helpid.hrc"
106cdf0e10cSrcweir #include <dialmgr.hxx>
107cdf0e10cSrcweir #include "treeopt.hxx"
108cdf0e10cSrcweir #include "treeopt.hrc"
109cdf0e10cSrcweir #include "fontsubs.hxx"
110cdf0e10cSrcweir #include <editeng/unolingu.hxx>
111cdf0e10cSrcweir #include <svx/xtable.hxx>
112cdf0e10cSrcweir #include "connpoolconfig.hxx"
113cdf0e10cSrcweir #include "dbregister.hxx"
114cdf0e10cSrcweir #include "dbregisterednamesconfig.hxx"
115cdf0e10cSrcweir #include "cfgchart.hxx"
116cdf0e10cSrcweir #include <svx/dialogs.hrc>
117cdf0e10cSrcweir 
118cdf0e10cSrcweir #ifndef _SVX_LANGITEM_HXX
119cdf0e10cSrcweir #define	ITEMID_LANGUAGE SID_ATTR_CHAR_LANGUAGE
120cdf0e10cSrcweir #include <editeng/langitem.hxx>
121cdf0e10cSrcweir #endif
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir #include <editeng/optitems.hxx>
125cdf0e10cSrcweir 
126cdf0e10cSrcweir #include <svx/drawitem.hxx>
127cdf0e10cSrcweir #include <rtl/uri.hxx>
128cdf0e10cSrcweir 
129cdf0e10cSrcweir #ifdef LINUX
130cdf0e10cSrcweir #include <string.h>
131cdf0e10cSrcweir #include <sys/types.h>
132cdf0e10cSrcweir #include <sys/stat.h>
133cdf0e10cSrcweir #include <unistd.h>
134cdf0e10cSrcweir #endif
135cdf0e10cSrcweir 
136cdf0e10cSrcweir using namespace ::com::sun::star;
137cdf0e10cSrcweir using namespace ::com::sun::star::beans;
138cdf0e10cSrcweir using namespace ::com::sun::star::container;
139cdf0e10cSrcweir using namespace ::com::sun::star::frame;
140cdf0e10cSrcweir using namespace ::com::sun::star::lang;
141cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
142cdf0e10cSrcweir using namespace ::com::sun::star::uno;
143cdf0e10cSrcweir using namespace ::com::sun::star::util;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #ifdef C2U
146cdf0e10cSrcweir     #error  "Who define C2U before! I use it to create const ascii strings ..."
147cdf0e10cSrcweir #else
148cdf0e10cSrcweir     #define C2U(cChar)      rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( cChar ) )
149cdf0e10cSrcweir #endif
150cdf0e10cSrcweir 
151cdf0e10cSrcweir #define HINT_TIMEOUT            200
152cdf0e10cSrcweir #define SELECT_FIRST_TIMEOUT	0
153cdf0e10cSrcweir #define SELECT_TIMEOUT			300
154cdf0e10cSrcweir #define COLORPAGE_UNKNOWN		((sal_uInt16)0xFFFF)
155cdf0e10cSrcweir #define EXPAND_PROTOCOL         "vnd.sun.star.expand:"
156cdf0e10cSrcweir 
157cdf0e10cSrcweir LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // some stuff for easier changes for SvtViewOptions
160cdf0e10cSrcweir static const sal_Char*		pViewOptDataName = "page data";
161cdf0e10cSrcweir #define VIEWOPT_DATANAME    rtl::OUString::createFromAscii( pViewOptDataName )
162cdf0e10cSrcweir 
163cdf0e10cSrcweir static XOutdevItemPool* mpStaticXOutdevItemPool = 0L;
164cdf0e10cSrcweir 
SetViewOptUserItem(SvtViewOptions & rOpt,const String & rData)165cdf0e10cSrcweir static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( rtl::OUString( rData ) ) );
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
GetViewOptUserItem(const SvtViewOptions & rOpt)170cdf0e10cSrcweir static inline String GetViewOptUserItem( const SvtViewOptions& rOpt )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir     Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
173cdf0e10cSrcweir     rtl::OUString aUserData;
174cdf0e10cSrcweir 	aAny >>= aUserData;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	return String( aUserData );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir struct ModuleToGroupNameMap_Impl
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     const char* m_pModule;
182cdf0e10cSrcweir     String      m_sGroupName;
183cdf0e10cSrcweir     sal_uInt16      m_nNodeId;
184cdf0e10cSrcweir };
185cdf0e10cSrcweir 
186cdf0e10cSrcweir static OfaPageResource* pPageRes = NULL;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir static ModuleToGroupNameMap_Impl ModuleMap[] =
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     { "ProductName", String::EmptyString(), SID_GENERAL_OPTIONS },
191cdf0e10cSrcweir     { "LanguageSettings", String::EmptyString(), SID_LANGUAGE_OPTIONS },
192cdf0e10cSrcweir     { "Internet", String::EmptyString(), SID_INET_DLG },
193cdf0e10cSrcweir     { "LoadSave", String::EmptyString(), SID_FILTER_DLG },
194cdf0e10cSrcweir     { "Writer", String::EmptyString(), SID_SW_EDITOPTIONS },
195cdf0e10cSrcweir     { "WriterWeb", String::EmptyString(), SID_SW_ONLINEOPTIONS },
196cdf0e10cSrcweir     { "Math", String::EmptyString(), SID_SM_EDITOPTIONS },
197cdf0e10cSrcweir     { "Calc", String::EmptyString(), SID_SC_EDITOPTIONS },
198cdf0e10cSrcweir     { "Impress", String::EmptyString(), SID_SD_EDITOPTIONS },
199cdf0e10cSrcweir     { "Draw", String::EmptyString(), SID_SD_GRAPHIC_OPTIONS },
200cdf0e10cSrcweir     { "Charts", String::EmptyString(), SID_SCH_EDITOPTIONS },
201cdf0e10cSrcweir     { "Base", String::EmptyString(), SID_SB_STARBASEOPTIONS },
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     { NULL, String::EmptyString(), 0xFFFF }
204cdf0e10cSrcweir };
205cdf0e10cSrcweir 
setGroupName(const rtl::OUString & rModule,const String & rGroupName)206cdf0e10cSrcweir static void setGroupName( const rtl::OUString& rModule, const String& rGroupName )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir     sal_uInt16 nIndex = 0;
209cdf0e10cSrcweir     while ( ModuleMap[ nIndex ].m_pModule )
210cdf0e10cSrcweir     {
211cdf0e10cSrcweir         rtl::OUString sTemp =
212cdf0e10cSrcweir             rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
213cdf0e10cSrcweir         if ( sTemp == rModule )
214cdf0e10cSrcweir         {
215cdf0e10cSrcweir             ModuleMap[ nIndex ].m_sGroupName = rGroupName;
216cdf0e10cSrcweir             break;
217cdf0e10cSrcweir         }
218cdf0e10cSrcweir         ++nIndex;
219cdf0e10cSrcweir     }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
getGroupName(const rtl::OUString & rModule,bool bForced)222cdf0e10cSrcweir static String getGroupName( const rtl::OUString& rModule, bool bForced )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     String sGroupName;
225cdf0e10cSrcweir     sal_uInt16 nIndex = 0;
226cdf0e10cSrcweir     while ( ModuleMap[ nIndex ].m_pModule )
227cdf0e10cSrcweir     {
228cdf0e10cSrcweir         rtl::OUString sTemp =
229cdf0e10cSrcweir             rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
230cdf0e10cSrcweir         if ( sTemp == rModule )
231cdf0e10cSrcweir         {
232cdf0e10cSrcweir             sGroupName = ModuleMap[ nIndex ].m_sGroupName;
233cdf0e10cSrcweir             break;
234cdf0e10cSrcweir         }
235cdf0e10cSrcweir         ++nIndex;
236cdf0e10cSrcweir     }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     if ( sGroupName.Len() == 0 && bForced )
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         if ( !pPageRes )
241cdf0e10cSrcweir             pPageRes = new OfaPageResource;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         if ( rModule == C2U("Writer") )
244cdf0e10cSrcweir             sGroupName = pPageRes->GetTextArray().GetString(0);
245cdf0e10cSrcweir         else if ( rModule == C2U("WriterWeb") )
246cdf0e10cSrcweir             sGroupName = pPageRes->GetHTMLArray().GetString(0);
247cdf0e10cSrcweir         else if ( rModule == C2U("Calc") )
248cdf0e10cSrcweir             sGroupName = pPageRes->GetCalcArray().GetString(0);
249cdf0e10cSrcweir         else if ( rModule == C2U("Impress") )
250cdf0e10cSrcweir             sGroupName = pPageRes->GetImpressArray().GetString(0);
251cdf0e10cSrcweir         else if ( rModule == C2U("Draw") )
252cdf0e10cSrcweir             sGroupName = pPageRes->GetDrawArray().GetString(0);
253cdf0e10cSrcweir         else if ( rModule == C2U("Math") )
254cdf0e10cSrcweir             sGroupName = pPageRes->GetStarMathArray().GetString(0);
255cdf0e10cSrcweir         else if ( rModule == C2U("Base") )
256cdf0e10cSrcweir             sGroupName = pPageRes->GetDatasourcesArray().GetString(0);
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir     return sGroupName;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
deleteGroupNames()261cdf0e10cSrcweir static void deleteGroupNames()
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     sal_uInt16 nIndex = 0;
264cdf0e10cSrcweir     while ( ModuleMap[ nIndex ].m_pModule )
265cdf0e10cSrcweir         ModuleMap[ nIndex++ ].m_sGroupName = String::EmptyString();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
getGroupNodeId(const rtl::OUString & rModule)268cdf0e10cSrcweir static sal_uInt16 getGroupNodeId( const rtl::OUString& rModule )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir     sal_uInt16 nNodeId = 0xFFFF, nIndex = 0;
271cdf0e10cSrcweir     while ( ModuleMap[ nIndex ].m_pModule )
272cdf0e10cSrcweir     {
273cdf0e10cSrcweir         rtl::OUString sTemp =
274cdf0e10cSrcweir             rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
275cdf0e10cSrcweir         if ( sTemp == rModule )
276cdf0e10cSrcweir         {
277cdf0e10cSrcweir             nNodeId = ModuleMap[ nIndex ].m_nNodeId;
278cdf0e10cSrcweir             break;
279cdf0e10cSrcweir         }
280cdf0e10cSrcweir         ++nIndex;
281cdf0e10cSrcweir     }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     return nNodeId;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir /*-- 29.10.2004 13:57:25---------------------------------------------------
287cdf0e10cSrcweir 
288cdf0e10cSrcweir   -----------------------------------------------------------------------*/
289cdf0e10cSrcweir class MailMergeCfg_Impl : public utl::ConfigItem
290cdf0e10cSrcweir {
291cdf0e10cSrcweir     friend class SvxEMailTabPage;
292cdf0e10cSrcweir     // variables
293cdf0e10cSrcweir     sal_Bool bIsEmailSupported;
294cdf0e10cSrcweir 
295cdf0e10cSrcweir public:
296cdf0e10cSrcweir     MailMergeCfg_Impl();
297cdf0e10cSrcweir     virtual ~MailMergeCfg_Impl();
298cdf0e10cSrcweir 
299cdf0e10cSrcweir     virtual void    Commit();
300cdf0e10cSrcweir 	virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames);
301cdf0e10cSrcweir 
IsEmailSupported() const302cdf0e10cSrcweir     sal_Bool IsEmailSupported() const {return bIsEmailSupported;}
303cdf0e10cSrcweir 
304cdf0e10cSrcweir };
305cdf0e10cSrcweir /*-- 29.10.2004 13:57:25---------------------------------------------------
306cdf0e10cSrcweir 
307cdf0e10cSrcweir   -----------------------------------------------------------------------*/
MailMergeCfg_Impl()308cdf0e10cSrcweir MailMergeCfg_Impl::MailMergeCfg_Impl() :
309cdf0e10cSrcweir     utl::ConfigItem(C2U("Office.Writer/MailMergeWizard")),
310cdf0e10cSrcweir     bIsEmailSupported(sal_False)
311cdf0e10cSrcweir {
312cdf0e10cSrcweir     Sequence<rtl::OUString> aNames(1);
313cdf0e10cSrcweir     aNames.getArray()[0] = C2U("EMailSupported");
314cdf0e10cSrcweir     const Sequence< Any > aValues = GetProperties(aNames);
315cdf0e10cSrcweir     const Any* pValues = aValues.getConstArray();
316cdf0e10cSrcweir     if(aValues.getLength() && pValues[0].hasValue())
317cdf0e10cSrcweir         pValues[0] >>= bIsEmailSupported;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir /*-- 29.10.2004 13:57:25---------------------------------------------------
320cdf0e10cSrcweir 
321cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~MailMergeCfg_Impl()322cdf0e10cSrcweir MailMergeCfg_Impl::~MailMergeCfg_Impl()
323cdf0e10cSrcweir {
324cdf0e10cSrcweir }
325cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
Commit()326cdf0e10cSrcweir void MailMergeCfg_Impl::Commit()
327cdf0e10cSrcweir {
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
Notify(const com::sun::star::uno::Sequence<rtl::OUString> &)330cdf0e10cSrcweir void MailMergeCfg_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir //typedef SfxTabPage* (*FNCreateTabPage)( Window *pParent, const SfxItemSet &rAttrSet );
CreateGeneralTabPage(sal_uInt16 nId,Window * pParent,const SfxItemSet & rSet)335cdf0e10cSrcweir SfxTabPage*	CreateGeneralTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	CreateTabPage fnCreate = 0;
338cdf0e10cSrcweir 	switch(nId)
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		case RID_SFXPAGE_SAVE:						fnCreate = &SvxSaveTabPage::Create; break;
341cdf0e10cSrcweir 		case RID_SFXPAGE_PATH:						fnCreate = &SvxPathTabPage::Create; break;
342cdf0e10cSrcweir 		case RID_SFXPAGE_GENERAL:					fnCreate = &SvxGeneralTabPage::Create; break;
343cdf0e10cSrcweir 		case RID_SFXPAGE_PRINTOPTIONS:				fnCreate = &SfxCommonPrintOptionsTabPage::Create; break;
344cdf0e10cSrcweir 		case OFA_TP_LANGUAGES:						fnCreate = &OfaLanguagesTabPage::Create; break;
345cdf0e10cSrcweir 		case RID_SFXPAGE_LINGU:						fnCreate = &SvxLinguTabPage::Create; break;
346cdf0e10cSrcweir 		case RID_SVXPAGE_COLOR:						fnCreate = &SvxColorTabPage::Create; break;
347cdf0e10cSrcweir 		case OFA_TP_VIEW:							fnCreate = &OfaViewTabPage::Create; break;
348cdf0e10cSrcweir 		case OFA_TP_MISC:							fnCreate = &OfaMiscTabPage::Create; break;
349cdf0e10cSrcweir 		case OFA_TP_MEMORY:							fnCreate = &OfaMemoryOptionsPage::Create; break;
350cdf0e10cSrcweir 		case RID_SVXPAGE_ASIAN_LAYOUT:				fnCreate = &SvxAsianLayoutPage::Create; break;
351cdf0e10cSrcweir 		case RID_SVX_FONT_SUBSTITUTION:				fnCreate = &SvxFontSubstTabPage::Create; break;
352cdf0e10cSrcweir 		case RID_SVXPAGE_INET_PROXY:				fnCreate = &SvxProxyTabPage::Create; break;
353cdf0e10cSrcweir 		case RID_SVXPAGE_INET_SEARCH:				fnCreate = &SvxSearchTabPage::Create; break;
354cdf0e10cSrcweir 		case RID_SVXPAGE_INET_SECURITY:				fnCreate = &SvxSecurityTabPage::Create; break;
355cdf0e10cSrcweir 		case RID_SVXPAGE_INET_MAIL:					fnCreate = &SvxEMailTabPage::Create; break;
356cdf0e10cSrcweir 		case RID_SVXPAGE_COLORCONFIG:				fnCreate = &SvxColorOptionsTabPage::Create; break;
357cdf0e10cSrcweir 		case RID_OFAPAGE_HTMLOPT:					fnCreate = &OfaHtmlTabPage::Create; break;
358cdf0e10cSrcweir 		case SID_OPTFILTER_MSOFFICE:				fnCreate = &OfaMSFilterTabPage::Create; break;
359cdf0e10cSrcweir 		case RID_OFAPAGE_MSFILTEROPT2:				fnCreate = &OfaMSFilterTabPage2::Create; break;
360cdf0e10cSrcweir 		case RID_SVXPAGE_JSEARCH_OPTIONS:			fnCreate = &SvxJSearchOptionsPage::Create ; break;
361cdf0e10cSrcweir 		case SID_SB_CONNECTIONPOOLING:				fnCreate = &::offapp::ConnectionPoolOptionsPage::Create; break;
362cdf0e10cSrcweir 		case SID_SB_DBREGISTEROPTIONS:				fnCreate = &::svx::DbRegistrationOptionsPage::Create; break;
363cdf0e10cSrcweir 		case RID_SVXPAGE_ACCESSIBILITYCONFIG:		fnCreate = &SvxAccessibilityOptionsTabPage::Create; break;
364cdf0e10cSrcweir 		case RID_SVXPAGE_SSO:						fnCreate = GetSSOCreator(); break;
365cdf0e10cSrcweir 		case RID_SVXPAGE_OPTIONS_CTL:				fnCreate = &SvxCTLOptionsPage::Create ; break;
366cdf0e10cSrcweir 		case RID_SVXPAGE_OPTIONS_JAVA:				fnCreate = &SvxJavaOptionsPage::Create ; break;
367cdf0e10cSrcweir         case RID_SVXPAGE_ONLINEUPDATE:				fnCreate = &SvxOnlineUpdateTabPage::Create; break;
368cdf0e10cSrcweir         case RID_OPTPAGE_CHART_DEFCOLORS:			fnCreate = &SvxDefaultColorOptPage::Create; break;
369cdf0e10cSrcweir         case RID_SVXPAGE_IMPROVEMENT:               fnCreate = &SvxImprovementOptionsPage::Create; break;
370cdf0e10cSrcweir 	}
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	SfxTabPage*	pRet = fnCreate ? (*fnCreate)( pParent, rSet ) : NULL;
373cdf0e10cSrcweir 	return pRet;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 
377cdf0e10cSrcweir struct OptionsMapping_Impl
378cdf0e10cSrcweir {
379cdf0e10cSrcweir     const char* m_pGroupName;
380cdf0e10cSrcweir     const char* m_pPageName;
381cdf0e10cSrcweir     sal_uInt16      m_nPageId;
382cdf0e10cSrcweir };
383cdf0e10cSrcweir 
384cdf0e10cSrcweir static OptionsMapping_Impl __READONLY_DATA OptionsMap_Impl[] =
385cdf0e10cSrcweir {
386cdf0e10cSrcweir //    GROUP                 PAGE                    PAGE-ID
387cdf0e10cSrcweir     { "ProductName",        NULL,                   SID_GENERAL_OPTIONS },
388cdf0e10cSrcweir     { "ProductName",        "UserData",             RID_SFXPAGE_GENERAL },
389cdf0e10cSrcweir     { "ProductName",        "General",              OFA_TP_MISC },
390cdf0e10cSrcweir     { "ProductName",        "Memory",               OFA_TP_MEMORY },
391cdf0e10cSrcweir     { "ProductName",        "View",                 OFA_TP_VIEW },
392cdf0e10cSrcweir     { "ProductName",        "Print",                RID_SFXPAGE_PRINTOPTIONS },
393cdf0e10cSrcweir     { "ProductName",        "Paths",                RID_SFXPAGE_PATH },
394cdf0e10cSrcweir     { "ProductName",        "Colors",               RID_SVXPAGE_COLOR },
395cdf0e10cSrcweir     { "ProductName",        "Fonts",                RID_SVX_FONT_SUBSTITUTION },
396cdf0e10cSrcweir     { "ProductName",        "Security",             RID_SVXPAGE_INET_SECURITY },
397cdf0e10cSrcweir     { "ProductName",        "Appearance",           RID_SVXPAGE_COLORCONFIG },
398cdf0e10cSrcweir     { "ProductName",        "Accessibility",        RID_SVXPAGE_ACCESSIBILITYCONFIG },
399cdf0e10cSrcweir     { "ProductName",        "Java",                 RID_SVXPAGE_OPTIONS_JAVA },
400cdf0e10cSrcweir     { "ProductName",        "NetworkIdentity",      RID_SVXPAGE_SSO },
401cdf0e10cSrcweir     { "ProductName",        "OnlineUpdate",         RID_SVXPAGE_ONLINEUPDATE },
402cdf0e10cSrcweir     { "ProductName",        "ImprovementProgram",   RID_SVXPAGE_IMPROVEMENT },
403cdf0e10cSrcweir     { "LanguageSettings",   NULL,                   SID_LANGUAGE_OPTIONS },
404cdf0e10cSrcweir     { "LanguageSettings",   "Languages",            OFA_TP_LANGUAGES  },
405cdf0e10cSrcweir     { "LanguageSettings",   "WritingAids",          RID_SFXPAGE_LINGU },
406cdf0e10cSrcweir     { "LanguageSettings",   "SearchingInJapanese",  RID_SVXPAGE_JSEARCH_OPTIONS },
407cdf0e10cSrcweir     { "LanguageSettings",   "AsianLayout",          RID_SVXPAGE_ASIAN_LAYOUT },
408cdf0e10cSrcweir     { "LanguageSettings",   "ComplexTextLayout",    RID_SVXPAGE_OPTIONS_CTL },
409cdf0e10cSrcweir     { "Internet",           NULL,                   SID_INET_DLG },
410cdf0e10cSrcweir     { "Internet",           "Proxy",                RID_SVXPAGE_INET_PROXY },
411cdf0e10cSrcweir     { "Internet",           "Search",               RID_SVXPAGE_INET_SEARCH },
412cdf0e10cSrcweir     { "Internet",           "Email",                RID_SVXPAGE_INET_MAIL },
413cdf0e10cSrcweir     { "LoadSave",           NULL,                   SID_FILTER_DLG },
414cdf0e10cSrcweir     { "LoadSave",           "General",              RID_SFXPAGE_SAVE },
415cdf0e10cSrcweir     { "LoadSave",           "VBAProperties",        SID_OPTFILTER_MSOFFICE },
416cdf0e10cSrcweir     { "LoadSave",           "MicrosoftOffice",      RID_OFAPAGE_MSFILTEROPT2 },
417cdf0e10cSrcweir     { "LoadSave",           "HTMLCompatibility",    RID_OFAPAGE_HTMLOPT },
418cdf0e10cSrcweir     { "Writer",             NULL,                   SID_SW_EDITOPTIONS },
419cdf0e10cSrcweir     { "Writer",             "General",              RID_SW_TP_OPTLOAD_PAGE },
420cdf0e10cSrcweir     { "Writer",             "View",                 RID_SW_TP_CONTENT_OPT },
421cdf0e10cSrcweir     { "Writer",             "FormattingAids",       RID_SW_TP_OPTSHDWCRSR },
422cdf0e10cSrcweir     { "Writer",             "Grid",                 RID_SVXPAGE_GRID },
423cdf0e10cSrcweir     { "Writer",             "BasicFontsWestern",    RID_SW_TP_STD_FONT },
424cdf0e10cSrcweir     { "Writer",             "BasicFontsAsian",      RID_SW_TP_STD_FONT_CJK },
425cdf0e10cSrcweir     { "Writer",             "BasicFontsCTL",        RID_SW_TP_STD_FONT_CTL },
426cdf0e10cSrcweir     { "Writer",             "Print",                RID_SW_TP_OPTPRINT_PAGE },
427cdf0e10cSrcweir     { "Writer",             "Table",                RID_SW_TP_OPTTABLE_PAGE },
428cdf0e10cSrcweir     { "Writer",             "Changes",              RID_SW_TP_REDLINE_OPT },
429cdf0e10cSrcweir     { "Writer",             "Compatibility",        RID_SW_TP_OPTCOMPATIBILITY_PAGE },
430cdf0e10cSrcweir     { "Writer",             "AutoCaption",          RID_SW_TP_OPTCAPTION_PAGE },
431cdf0e10cSrcweir     { "Writer",             "MailMerge",            RID_SW_TP_MAILCONFIG },
432cdf0e10cSrcweir     { "WriterWeb",          NULL,                   SID_SW_ONLINEOPTIONS },
433cdf0e10cSrcweir     { "WriterWeb",          "View",                 RID_SW_TP_HTML_CONTENT_OPT },
434cdf0e10cSrcweir     { "WriterWeb",          "FormattingAids",       RID_SW_TP_HTML_OPTSHDWCRSR },
435cdf0e10cSrcweir     { "WriterWeb",          "Grid",                 RID_SW_TP_HTML_OPTGRID_PAGE },
436cdf0e10cSrcweir     { "WriterWeb",          "Print",                RID_SW_TP_HTML_OPTPRINT_PAGE },
437cdf0e10cSrcweir     { "WriterWeb",          "Table",                RID_SW_TP_HTML_OPTTABLE_PAGE },
438cdf0e10cSrcweir     { "WriterWeb",          "Background",           RID_SW_TP_BACKGROUND },
439cdf0e10cSrcweir     { "Math",               NULL,                   SID_SM_EDITOPTIONS },
440cdf0e10cSrcweir     { "Math",               "Settings",             SID_SM_TP_PRINTOPTIONS },
441cdf0e10cSrcweir     { "Calc",               NULL,                   SID_SC_EDITOPTIONS },
442cdf0e10cSrcweir     { "Calc",               "General",              SID_SC_TP_LAYOUT },
443cdf0e10cSrcweir     { "Calc",               "View",                 SID_SC_TP_CONTENT },
444cdf0e10cSrcweir     { "Calc",               "International",        RID_OFA_TP_INTERNATIONAL },
445cdf0e10cSrcweir     { "Calc",               "Calculate",            SID_SC_TP_CALC },
446cdf0e10cSrcweir     { "Calc",               "SortLists",            SID_SC_TP_USERLISTS },
447cdf0e10cSrcweir     { "Calc",               "Changes",              SID_SC_TP_CHANGES },
448cdf0e10cSrcweir     { "Calc",               "Grid",                 SID_SC_TP_GRID },
449cdf0e10cSrcweir     { "Calc",               "Print",                RID_SC_TP_PRINT },
450cdf0e10cSrcweir     { "Impress",            NULL,                   SID_SD_EDITOPTIONS },
451cdf0e10cSrcweir     { "Impress",            "General",              SID_SI_TP_MISC },
452cdf0e10cSrcweir     { "Impress",            "View",                 SID_SI_TP_CONTENTS },
453cdf0e10cSrcweir     { "Impress",            "Grid",                 SID_SI_TP_SNAP },
454cdf0e10cSrcweir     { "Impress",            "Print",                SID_SI_TP_PRINT },
455cdf0e10cSrcweir     { "Draw",               NULL,                   SID_SD_GRAPHIC_OPTIONS },
456cdf0e10cSrcweir     { "Draw",               "General",              SID_SD_TP_MISC },
457cdf0e10cSrcweir     { "Draw",               "View",                 SID_SD_TP_CONTENTS },
458cdf0e10cSrcweir     { "Draw",               "Grid",                 SID_SD_TP_SNAP },
459cdf0e10cSrcweir     { "Draw",               "Print",                SID_SD_TP_PRINT },
460cdf0e10cSrcweir     { "Charts",             NULL,                   SID_SCH_EDITOPTIONS },
461cdf0e10cSrcweir     { "Charts",             "DefaultColors",        RID_OPTPAGE_CHART_DEFCOLORS },
462cdf0e10cSrcweir     { "Base",               NULL,                   SID_SB_STARBASEOPTIONS },
463cdf0e10cSrcweir     { "Base",               "Connections",          SID_SB_CONNECTIONPOOLING },
464cdf0e10cSrcweir     { "Base",               "Databases",            SID_SB_DBREGISTEROPTIONS },
465cdf0e10cSrcweir     { NULL,                 NULL,                   0 }
466cdf0e10cSrcweir };
467cdf0e10cSrcweir 
lcl_getStringFromID(sal_uInt16 _nPageId,String & _rGroupName,String & _rPageName)468cdf0e10cSrcweir static sal_Bool lcl_getStringFromID( sal_uInt16 _nPageId, String& _rGroupName, String& _rPageName )
469cdf0e10cSrcweir {
470cdf0e10cSrcweir     sal_Bool bRet = sal_False;
471cdf0e10cSrcweir 
472cdf0e10cSrcweir     sal_uInt16 nIdx = 0;
473cdf0e10cSrcweir     while ( OptionsMap_Impl[nIdx].m_pGroupName != NULL )
474cdf0e10cSrcweir     {
475cdf0e10cSrcweir         if ( _nPageId == OptionsMap_Impl[nIdx].m_nPageId )
476cdf0e10cSrcweir         {
477cdf0e10cSrcweir             bRet = sal_True;
478cdf0e10cSrcweir             _rGroupName = String( OptionsMap_Impl[nIdx].m_pGroupName, RTL_TEXTENCODING_ASCII_US );
479cdf0e10cSrcweir             if ( OptionsMap_Impl[nIdx].m_pPageName != NULL )
480cdf0e10cSrcweir                 _rPageName = String( OptionsMap_Impl[nIdx].m_pPageName, RTL_TEXTENCODING_ASCII_US );
481cdf0e10cSrcweir             break;
482cdf0e10cSrcweir         }
483cdf0e10cSrcweir         ++nIdx;
484cdf0e10cSrcweir     }
485cdf0e10cSrcweir 
486cdf0e10cSrcweir     return bRet;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
lcl_isOptionHidden(sal_uInt16 _nPageId,const SvtOptionsDialogOptions & _rOptOptions)489cdf0e10cSrcweir static sal_Bool lcl_isOptionHidden( sal_uInt16 _nPageId, const SvtOptionsDialogOptions& _rOptOptions )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     sal_Bool bIsHidden = sal_False;
492cdf0e10cSrcweir     String sGroupName, sPageName;
493cdf0e10cSrcweir     if ( lcl_getStringFromID( _nPageId, sGroupName, sPageName ) )
494cdf0e10cSrcweir     {
495cdf0e10cSrcweir         if ( sPageName.Len() == 0 )
496cdf0e10cSrcweir             bIsHidden =  _rOptOptions.IsGroupHidden( sGroupName );
497cdf0e10cSrcweir         else
498cdf0e10cSrcweir             bIsHidden =  _rOptOptions.IsPageHidden( sPageName, sGroupName );
499cdf0e10cSrcweir     }
500cdf0e10cSrcweir     return bIsHidden;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir /* -----------------11.02.99 09:56-------------------
504cdf0e10cSrcweir  *
505cdf0e10cSrcweir  * --------------------------------------------------*/
506cdf0e10cSrcweir struct OptionsPageInfo
507cdf0e10cSrcweir {
508cdf0e10cSrcweir     SfxTabPage*         m_pPage;
509cdf0e10cSrcweir     sal_uInt16          m_nPageId;
510cdf0e10cSrcweir     rtl::OUString       m_sPageURL;
511cdf0e10cSrcweir     rtl::OUString       m_sEventHdl;
512cdf0e10cSrcweir     ExtensionsTabPage*  m_pExtPage;
513cdf0e10cSrcweir 
OptionsPageInfoOptionsPageInfo514cdf0e10cSrcweir     OptionsPageInfo( sal_uInt16 nId ) : m_pPage( NULL ), m_nPageId( nId ), m_pExtPage( NULL ) {}
515cdf0e10cSrcweir };
516cdf0e10cSrcweir 
517cdf0e10cSrcweir struct OptionsGroupInfo
518cdf0e10cSrcweir {
519cdf0e10cSrcweir     SfxItemSet*         m_pInItemSet;
520cdf0e10cSrcweir     SfxItemSet*         m_pOutItemSet;
521cdf0e10cSrcweir     SfxShell*           m_pShell;       // used to create the page
522cdf0e10cSrcweir     SfxModule*          m_pModule;      // used to create the ItemSet
523cdf0e10cSrcweir     sal_uInt16          m_nDialogId;    // Id of the former dialog
524cdf0e10cSrcweir     sal_Bool            m_bLoadError;   // load fails?
525cdf0e10cSrcweir     rtl::OUString       m_sPageURL;
526cdf0e10cSrcweir     ExtensionsTabPage*  m_pExtPage;
527cdf0e10cSrcweir 
OptionsGroupInfoOptionsGroupInfo528cdf0e10cSrcweir 	OptionsGroupInfo( SfxShell* pSh, SfxModule* pMod, sal_uInt16 nId ) :
529cdf0e10cSrcweir         m_pInItemSet( NULL ), m_pOutItemSet( NULL ), m_pShell( pSh ),
530cdf0e10cSrcweir         m_pModule( pMod ), m_nDialogId( nId ), m_bLoadError( sal_False ),
531cdf0e10cSrcweir         m_sPageURL( rtl::OUString() ), m_pExtPage( NULL ) {}
~OptionsGroupInfoOptionsGroupInfo532cdf0e10cSrcweir     ~OptionsGroupInfo() { delete m_pInItemSet; delete m_pOutItemSet; }
533cdf0e10cSrcweir };
534cdf0e10cSrcweir 
535cdf0e10cSrcweir /* -----------------04.05.99 15:51-------------------
536cdf0e10cSrcweir  *
537cdf0e10cSrcweir  * --------------------------------------------------*/
Collapse(SvLBoxEntry * pParent)538cdf0e10cSrcweir sal_Bool OfaOptionsTreeListBox::Collapse( SvLBoxEntry* pParent )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir 	bInCollapse = sal_True;
541cdf0e10cSrcweir 	sal_Bool bRet = SvTreeListBox::Collapse(pParent);
542cdf0e10cSrcweir 	bInCollapse = sal_False;
543cdf0e10cSrcweir 	return bRet;
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir // -----------------------------------------------------------------------
547cdf0e10cSrcweir 
548cdf0e10cSrcweir #define INI_LIST() \
549cdf0e10cSrcweir     aOkPB               ( this, CUI_RES( PB_OK ) ),\
550cdf0e10cSrcweir     aCancelPB           ( this, CUI_RES( PB_CANCEL ) ),\
551cdf0e10cSrcweir     aHelpPB             ( this, CUI_RES( PB_HELP ) ),\
552cdf0e10cSrcweir     aBackPB             ( this, CUI_RES( PB_BACK ) ),\
553cdf0e10cSrcweir     aHiddenGB           ( this, CUI_RES( FB_BORDER ) ),\
554cdf0e10cSrcweir     aPageTitleFT        ( this, CUI_RES( FT_PAGE_TITLE ) ),\
555cdf0e10cSrcweir     aLine1FL            ( this, CUI_RES( FL_LINE_1 ) ),\
556cdf0e10cSrcweir     aHelpFT             ( this, CUI_RES( FT_HELPTEXT ) ),\
557cdf0e10cSrcweir     aHelpImg            ( this, CUI_RES( IMG_HELP ) ),\
558cdf0e10cSrcweir     aHelpTextsArr       (       CUI_RES( STR_HELPTEXTS ) ),\
559cdf0e10cSrcweir     aTreeLB             ( this, CUI_RES( TLB_PAGES ) ),\
560cdf0e10cSrcweir     sTitle              ( GetText() ),\
561cdf0e10cSrcweir     sNotLoadedError     (       CUI_RES( ST_LOAD_ERROR ) ),\
562cdf0e10cSrcweir     pCurrentPageEntry   ( NULL ),\
563cdf0e10cSrcweir     pColorPageItemSet   ( NULL ),\
564*c7be74b1SArmin Le Grand     maColorTab           (),\
565cdf0e10cSrcweir     nChangeType         ( CT_NONE ),\
566cdf0e10cSrcweir     nUnknownType        ( COLORPAGE_UNKNOWN ),\
567cdf0e10cSrcweir     nUnknownPos         ( COLORPAGE_UNKNOWN ),\
568cdf0e10cSrcweir     bIsAreaTP           ( sal_False ),\
569cdf0e10cSrcweir     bForgetSelection    ( sal_False ),\
570cdf0e10cSrcweir     bImageResized       ( sal_False ),\
571cdf0e10cSrcweir     bInSelectHdl_Impl   ( false ),\
572cdf0e10cSrcweir     bIsFromExtensionManager( false ), \
573cdf0e10cSrcweir     bIsForSetDocumentLanguage( false )
574cdf0e10cSrcweir 
575cdf0e10cSrcweir // Ctor() with Frame -----------------------------------------------------
576cdf0e10cSrcweir using namespace ::com::sun::star;
OfaTreeOptionsDialog(Window * pParent,const Reference<XFrame> & _xFrame,bool bActivateLastSelection)577cdf0e10cSrcweir OfaTreeOptionsDialog::OfaTreeOptionsDialog(
578cdf0e10cSrcweir     Window* pParent,
579cdf0e10cSrcweir     const Reference< XFrame >& _xFrame,
580cdf0e10cSrcweir     bool bActivateLastSelection ) :
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 	SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ),
583cdf0e10cSrcweir     INI_LIST()
584cdf0e10cSrcweir {
585cdf0e10cSrcweir 	FreeResource();
586cdf0e10cSrcweir 
587cdf0e10cSrcweir     InitTreeAndHandler();
588cdf0e10cSrcweir     Initialize( _xFrame );
589cdf0e10cSrcweir     LoadExtensionOptions( rtl::OUString() );
590cdf0e10cSrcweir     ResizeTreeLB();
591cdf0e10cSrcweir     if (bActivateLastSelection)
592cdf0e10cSrcweir         ActivateLastSelection();
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 	aTreeLB.SetAccessibleName(GetDisplayText());
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
597cdf0e10cSrcweir // Ctor() with ExtensionId -----------------------------------------------
598cdf0e10cSrcweir 
OfaTreeOptionsDialog(Window * pParent,const rtl::OUString & rExtensionId)599cdf0e10cSrcweir OfaTreeOptionsDialog::OfaTreeOptionsDialog( Window* pParent, const rtl::OUString& rExtensionId ) :
600cdf0e10cSrcweir 
601cdf0e10cSrcweir     SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ),
602cdf0e10cSrcweir 
603cdf0e10cSrcweir     INI_LIST()
604cdf0e10cSrcweir 
605cdf0e10cSrcweir {
606cdf0e10cSrcweir     FreeResource();
607cdf0e10cSrcweir 
608cdf0e10cSrcweir     bIsFromExtensionManager = ( rExtensionId.getLength() > 0 );
609cdf0e10cSrcweir     InitTreeAndHandler();
610cdf0e10cSrcweir     LoadExtensionOptions( rExtensionId );
611cdf0e10cSrcweir     ResizeTreeLB();
612cdf0e10cSrcweir     ActivateLastSelection();
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir /* -----------------11.02.99 07:58-------------------
616cdf0e10cSrcweir  *
617cdf0e10cSrcweir  * --------------------------------------------------*/
618cdf0e10cSrcweir 
~OfaTreeOptionsDialog()619cdf0e10cSrcweir OfaTreeOptionsDialog::~OfaTreeOptionsDialog()
620cdf0e10cSrcweir {
621cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTreeLB.First();
622cdf0e10cSrcweir     // first children
623cdf0e10cSrcweir     while(pEntry)
624cdf0e10cSrcweir     {
625cdf0e10cSrcweir         // if Child (has parent), then OptionsPageInfo
626cdf0e10cSrcweir         if(aTreeLB.GetParent(pEntry))
627cdf0e10cSrcweir         {
628cdf0e10cSrcweir             OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
629cdf0e10cSrcweir             if(pPageInfo->m_pPage)
630cdf0e10cSrcweir             {
631cdf0e10cSrcweir                 pPageInfo->m_pPage->FillUserData();
632cdf0e10cSrcweir                 String aPageData(pPageInfo->m_pPage->GetUserData());
633cdf0e10cSrcweir                 if ( aPageData.Len() )
634cdf0e10cSrcweir                 {
635cdf0e10cSrcweir                     SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pPageInfo->m_nPageId ) );
636cdf0e10cSrcweir                     SetViewOptUserItem( aTabPageOpt, aPageData );
637cdf0e10cSrcweir                 }
638cdf0e10cSrcweir                 delete pPageInfo->m_pPage;
639cdf0e10cSrcweir             }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir             if (pPageInfo->m_nPageId == RID_SFXPAGE_LINGU)
642cdf0e10cSrcweir             {
643cdf0e10cSrcweir                 // write personal dictionaries
644cdf0e10cSrcweir                 Reference< XDictionaryList >  xDicList( SvxGetDictionaryList() );
645cdf0e10cSrcweir                 if (xDicList.is())
646cdf0e10cSrcweir                 {
647cdf0e10cSrcweir                     linguistic::SaveDictionaries( xDicList );
648cdf0e10cSrcweir                 }
649cdf0e10cSrcweir             }
650cdf0e10cSrcweir 
651cdf0e10cSrcweir             if( pPageInfo->m_pExtPage )
652cdf0e10cSrcweir                 delete pPageInfo->m_pExtPage;
653cdf0e10cSrcweir 
654cdf0e10cSrcweir             delete pPageInfo;
655cdf0e10cSrcweir         }
656cdf0e10cSrcweir         pEntry = aTreeLB.Next(pEntry);
657cdf0e10cSrcweir     }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir     // and parents
660cdf0e10cSrcweir     pEntry = aTreeLB.First();
661cdf0e10cSrcweir     while(pEntry)
662cdf0e10cSrcweir     {
663cdf0e10cSrcweir         if(!aTreeLB.GetParent(pEntry))
664cdf0e10cSrcweir         {
665cdf0e10cSrcweir             OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pEntry->GetUserData();
666cdf0e10cSrcweir             if ( pGroupInfo && pGroupInfo->m_pExtPage )
667cdf0e10cSrcweir                 delete pGroupInfo->m_pExtPage;
668cdf0e10cSrcweir             delete pGroupInfo;
669cdf0e10cSrcweir         }
670cdf0e10cSrcweir         pEntry = aTreeLB.Next(pEntry);
671cdf0e10cSrcweir     }
672cdf0e10cSrcweir 	delete pColorPageItemSet;
673cdf0e10cSrcweir     deleteGroupNames();
674cdf0e10cSrcweir }
675cdf0e10cSrcweir 
676cdf0e10cSrcweir /* -----------------11.02.99 08:21-------------------
677cdf0e10cSrcweir  *
678cdf0e10cSrcweir  * --------------------------------------------------*/
AddTabPage(sal_uInt16 nId,const String & rPageName,sal_uInt16 nGroup)679cdf0e10cSrcweir OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage(
680cdf0e10cSrcweir     sal_uInt16 nId, const String& rPageName, sal_uInt16 nGroup )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId );
683cdf0e10cSrcweir 	SvLBoxEntry* pParent = aTreeLB.GetEntry( 0, nGroup );
684cdf0e10cSrcweir     DBG_ASSERT( pParent, "OfaTreeOptionsDialog::AddTabPage(): no group found" );
685cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTreeLB.InsertEntry( rPageName, pParent );
686cdf0e10cSrcweir     pEntry->SetUserData( pPageInfo );
687cdf0e10cSrcweir     return pPageInfo;
688cdf0e10cSrcweir }
689cdf0e10cSrcweir 
690cdf0e10cSrcweir /* -----------------11.02.99 10:02-------------------
691cdf0e10cSrcweir  *	der ItemSet* geht in den Besitz des Dialogs
692cdf0e10cSrcweir  * --------------------------------------------------*/
AddGroup(const String & rGroupName,SfxShell * pCreateShell,SfxModule * pCreateModule,sal_uInt16 nDialogId)693cdf0e10cSrcweir sal_uInt16	OfaTreeOptionsDialog::AddGroup(const String& rGroupName,
694cdf0e10cSrcweir 										SfxShell* pCreateShell,
695cdf0e10cSrcweir 										SfxModule* pCreateModule,
696cdf0e10cSrcweir 										sal_uInt16 nDialogId )
697cdf0e10cSrcweir {
698cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aTreeLB.InsertEntry(rGroupName);
699cdf0e10cSrcweir 	OptionsGroupInfo* pInfo =
700cdf0e10cSrcweir 		new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId );
701cdf0e10cSrcweir 	pEntry->SetUserData(pInfo);
702cdf0e10cSrcweir 	sal_uInt16 nRet = 0;
703cdf0e10cSrcweir 	pEntry = aTreeLB.First();
704cdf0e10cSrcweir 	while(pEntry)
705cdf0e10cSrcweir 	{
706cdf0e10cSrcweir 		if(!aTreeLB.GetParent(pEntry))
707cdf0e10cSrcweir 			nRet++;
708cdf0e10cSrcweir 		pEntry = aTreeLB.Next(pEntry);
709cdf0e10cSrcweir 	}
710cdf0e10cSrcweir 	return nRet - 1;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir 
713cdf0e10cSrcweir /* -----------------11.02.99 10:31-------------------
714cdf0e10cSrcweir  *
715cdf0e10cSrcweir  * --------------------------------------------------*/
IMPL_LINK(OfaTreeOptionsDialog,ShowPageHdl_Impl,SvTreeListBox *,EMPTYARG)716cdf0e10cSrcweir IMPL_LINK(OfaTreeOptionsDialog, ShowPageHdl_Impl, SvTreeListBox*, EMPTYARG)
717cdf0e10cSrcweir {
718cdf0e10cSrcweir 	if ( aSelectTimer.GetTimeout() == SELECT_FIRST_TIMEOUT )
719cdf0e10cSrcweir 	{
720cdf0e10cSrcweir 		aSelectTimer.SetTimeout( SELECT_TIMEOUT );
721cdf0e10cSrcweir 		SelectHdl_Impl( NULL );
722cdf0e10cSrcweir 	}
723cdf0e10cSrcweir     else if ( aSelectTimer.GetTimeout() == SELECT_TIMEOUT )
724cdf0e10cSrcweir 		aSelectTimer.Start();
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 	return 0;
727cdf0e10cSrcweir }
728cdf0e10cSrcweir /* -----------------11.02.99 10:49-------------------
729cdf0e10cSrcweir  *
730cdf0e10cSrcweir  * --------------------------------------------------*/
IMPL_LINK(OfaTreeOptionsDialog,BackHdl_Impl,PushButton *,EMPTYARG)731cdf0e10cSrcweir IMPL_LINK( OfaTreeOptionsDialog, BackHdl_Impl, PushButton*, EMPTYARG )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir     if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
734cdf0e10cSrcweir 	{
735cdf0e10cSrcweir 		OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pCurrentPageEntry->GetUserData();
736cdf0e10cSrcweir         if ( pPageInfo->m_pPage )
737cdf0e10cSrcweir         {
738cdf0e10cSrcweir             OptionsGroupInfo* pGroupInfo =
739cdf0e10cSrcweir                 (OptionsGroupInfo*)aTreeLB.GetParent( pCurrentPageEntry )->GetUserData();
740cdf0e10cSrcweir             if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
741cdf0e10cSrcweir                 pPageInfo->m_pPage->Reset( *pColorPageItemSet );
742cdf0e10cSrcweir             else
743cdf0e10cSrcweir                 pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
744cdf0e10cSrcweir         }
745cdf0e10cSrcweir         else if ( pPageInfo->m_pExtPage )
746cdf0e10cSrcweir             pPageInfo->m_pExtPage->ResetPage();
747cdf0e10cSrcweir 	}
748cdf0e10cSrcweir 	return 0;
749cdf0e10cSrcweir }
750cdf0e10cSrcweir /* -----------------11.02.99 16:45-------------------
751cdf0e10cSrcweir  *
752cdf0e10cSrcweir  * --------------------------------------------------*/
IMPL_LINK(OfaTreeOptionsDialog,OKHdl_Impl,Button *,EMPTYARG)753cdf0e10cSrcweir IMPL_LINK( OfaTreeOptionsDialog, OKHdl_Impl, Button *, EMPTYARG )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir 	aTreeLB.EndSelection();
756cdf0e10cSrcweir     if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
757cdf0e10cSrcweir 	{
758cdf0e10cSrcweir         OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pCurrentPageEntry->GetUserData();
759cdf0e10cSrcweir         if ( pPageInfo->m_pPage )
760cdf0e10cSrcweir         {
761cdf0e10cSrcweir             OptionsGroupInfo* pGroupInfo =
762cdf0e10cSrcweir                 (OptionsGroupInfo *)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
763cdf0e10cSrcweir             if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId
764cdf0e10cSrcweir                 && pPageInfo->m_pPage->HasExchangeSupport() )
765cdf0e10cSrcweir             {
766cdf0e10cSrcweir                 int nLeave = pPageInfo->m_pPage->DeactivatePage(pGroupInfo->m_pOutItemSet);
767cdf0e10cSrcweir                 if ( nLeave == SfxTabPage::KEEP_PAGE )
768cdf0e10cSrcweir                 {
769cdf0e10cSrcweir                     //die Seite darf nicht verlassen werden!
770cdf0e10cSrcweir                     aTreeLB.Select(pCurrentPageEntry);
771cdf0e10cSrcweir                     return 0;
772cdf0e10cSrcweir                 }
773cdf0e10cSrcweir             }
774cdf0e10cSrcweir             pPageInfo->m_pPage->Hide();
775cdf0e10cSrcweir         }
776cdf0e10cSrcweir 	}
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aTreeLB.First();
779cdf0e10cSrcweir     while ( pEntry )
780cdf0e10cSrcweir 	{
781cdf0e10cSrcweir         if ( aTreeLB.GetParent( pEntry ) )
782cdf0e10cSrcweir 		{
783cdf0e10cSrcweir             OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
784cdf0e10cSrcweir             if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() )
785cdf0e10cSrcweir 			{
786cdf0e10cSrcweir                 OptionsGroupInfo* pGroupInfo =
787cdf0e10cSrcweir                     (OptionsGroupInfo*)aTreeLB.GetParent(pEntry)->GetUserData();
788cdf0e10cSrcweir                 pPageInfo->m_pPage->FillItemSet(*pGroupInfo->m_pOutItemSet);
789cdf0e10cSrcweir 			}
790cdf0e10cSrcweir 
791cdf0e10cSrcweir             if ( pPageInfo->m_pExtPage )
792cdf0e10cSrcweir             {
793cdf0e10cSrcweir                 pPageInfo->m_pExtPage->DeactivatePage();
794cdf0e10cSrcweir                 pPageInfo->m_pExtPage->SavePage();
795cdf0e10cSrcweir             }
796cdf0e10cSrcweir 		}
797cdf0e10cSrcweir 		pEntry = aTreeLB.Next(pEntry);
798cdf0e10cSrcweir 	}
799cdf0e10cSrcweir 	EndDialog(RET_OK);
800cdf0e10cSrcweir 	return 0;
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
803cdf0e10cSrcweir /* -----------------17.02.99 09:15-------------------
804cdf0e10cSrcweir  * Eine aufgeklappte Gruppe soll vollstaendig sichtbar sein
805cdf0e10cSrcweir  * --------------------------------------------------*/
IMPL_LINK(OfaTreeOptionsDialog,ExpandedHdl_Impl,SvTreeListBox *,pBox)806cdf0e10cSrcweir IMPL_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, pBox )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir 	pBox->Update();
809cdf0e10cSrcweir 	pBox->InitStartEntry();
810cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pBox->GetHdlEntry();
811cdf0e10cSrcweir 	if(pEntry && pBox->IsExpanded(pEntry))
812cdf0e10cSrcweir 	{
813cdf0e10cSrcweir 		sal_uInt32 nChildCount = pBox->GetChildCount( pEntry );
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 		SvLBoxEntry* pNext = pEntry;
816cdf0e10cSrcweir 		for(sal_uInt32 i = 0; i < nChildCount;i++)
817cdf0e10cSrcweir 		{
818cdf0e10cSrcweir 			pNext = pBox->GetNextEntryInView(pNext);
819cdf0e10cSrcweir 			if(!pNext)
820cdf0e10cSrcweir 			{
821cdf0e10cSrcweir 				pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
822cdf0e10cSrcweir 				break;
823cdf0e10cSrcweir 			}
824cdf0e10cSrcweir 			else
825cdf0e10cSrcweir 			{
826cdf0e10cSrcweir 				Size aSz(pBox->GetOutputSizePixel());
827cdf0e10cSrcweir 				int nHeight = pBox->GetEntryHeight();
828cdf0e10cSrcweir                 Point aPos(pBox->GetEntryPosition(pNext));
829cdf0e10cSrcweir 				if(aPos.Y()+nHeight > aSz.Height())
830cdf0e10cSrcweir 				{
831cdf0e10cSrcweir 					pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
832cdf0e10cSrcweir 					break;
833cdf0e10cSrcweir 				}
834cdf0e10cSrcweir 			}
835cdf0e10cSrcweir 		}
836cdf0e10cSrcweir 	}
837cdf0e10cSrcweir 	return 0;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir 
840cdf0e10cSrcweir /* -----------------11.02.99 10:49-------------------
841cdf0e10cSrcweir  *
842cdf0e10cSrcweir  * --------------------------------------------------*/
ApplyItemSets()843cdf0e10cSrcweir void OfaTreeOptionsDialog::ApplyItemSets()
844cdf0e10cSrcweir {
845cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aTreeLB.First();
846cdf0e10cSrcweir 	while(pEntry)
847cdf0e10cSrcweir 	{
848cdf0e10cSrcweir 		if(!aTreeLB.GetParent(pEntry))
849cdf0e10cSrcweir 		{
850cdf0e10cSrcweir 			OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pEntry->GetUserData();
851cdf0e10cSrcweir             if(pGroupInfo->m_pOutItemSet)
852cdf0e10cSrcweir 			{
853cdf0e10cSrcweir                 if(pGroupInfo->m_pShell)
854cdf0e10cSrcweir                     pGroupInfo->m_pShell->ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
855cdf0e10cSrcweir 				else
856cdf0e10cSrcweir                     ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
857cdf0e10cSrcweir 			}
858cdf0e10cSrcweir 		}
859cdf0e10cSrcweir 		pEntry = aTreeLB.Next(pEntry);
860cdf0e10cSrcweir 	}
861cdf0e10cSrcweir }
862cdf0e10cSrcweir 
InitTreeAndHandler()863cdf0e10cSrcweir void OfaTreeOptionsDialog::InitTreeAndHandler()
864cdf0e10cSrcweir {
865cdf0e10cSrcweir     aTreeLB.SetNodeDefaultImages();
866cdf0e10cSrcweir     aPageImages = ImageList( CUI_RES( RID_IMGLIST_TREEOPT ) );
867cdf0e10cSrcweir     aPageImagesHC = ImageList( CUI_RES( RID_IMGLIST_TREEOPT_HC ) );
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     aTreeLB.SetHelpId( HID_OFADLG_TREELISTBOX );
870cdf0e10cSrcweir     aTreeLB.SetStyle( aTreeLB.GetStyle()|WB_HASBUTTONS | WB_HASBUTTONSATROOT |
871cdf0e10cSrcweir                            WB_HASLINES | WB_HASLINESATROOT |
872cdf0e10cSrcweir                            WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE | WB_QUICK_SEARCH );
873cdf0e10cSrcweir     aTreeLB.SetSpaceBetweenEntries( 0 );
874cdf0e10cSrcweir     aTreeLB.SetSelectionMode( SINGLE_SELECTION );
875cdf0e10cSrcweir     aTreeLB.SetSublistOpenWithLeftRight( sal_True );
876cdf0e10cSrcweir     aTreeLB.SetExpandedHdl( LINK( this, OfaTreeOptionsDialog, ExpandedHdl_Impl ) );
877cdf0e10cSrcweir     aTreeLB.SetSelectHdl( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) );
878cdf0e10cSrcweir     aBackPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) );
879cdf0e10cSrcweir     aOkPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) );
880cdf0e10cSrcweir 
881cdf0e10cSrcweir     aHiddenGB.Show();
882cdf0e10cSrcweir     aSelectTimer.SetTimeout( SELECT_FIRST_TIMEOUT );
883cdf0e10cSrcweir     aSelectTimer.SetTimeoutHdl( LINK( this, OfaTreeOptionsDialog, SelectHdl_Impl ) );
884cdf0e10cSrcweir }
885cdf0e10cSrcweir 
886cdf0e10cSrcweir /* -----------------17.02.99 09:51-------------------
887cdf0e10cSrcweir  *
888cdf0e10cSrcweir  * --------------------------------------------------*/
ActivatePage(sal_uInt16 nResId)889cdf0e10cSrcweir void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir     bIsForSetDocumentLanguage = false;
892cdf0e10cSrcweir     if ( nResId == OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE )
893cdf0e10cSrcweir 	{
894cdf0e10cSrcweir         bIsForSetDocumentLanguage = true;
895cdf0e10cSrcweir         nResId = OFA_TP_LANGUAGES;
896cdf0e10cSrcweir 	}
897cdf0e10cSrcweir 
898cdf0e10cSrcweir     DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
899cdf0e10cSrcweir     if ( !pLastPageSaver )
900cdf0e10cSrcweir         pLastPageSaver = new LastPageSaver;
901cdf0e10cSrcweir 	bForgetSelection = sal_True;
902cdf0e10cSrcweir     sal_uInt16 nTemp = pLastPageSaver->m_nLastPageId;
903cdf0e10cSrcweir     pLastPageSaver->m_nLastPageId = nResId;
904cdf0e10cSrcweir 	ActivateLastSelection();
905cdf0e10cSrcweir     pLastPageSaver->m_nLastPageId = nTemp;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
ActivatePage(const String & rPageURL)908cdf0e10cSrcweir void OfaTreeOptionsDialog::ActivatePage( const String& rPageURL )
909cdf0e10cSrcweir {
910cdf0e10cSrcweir     DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
911cdf0e10cSrcweir     if ( !pLastPageSaver )
912cdf0e10cSrcweir         pLastPageSaver = new LastPageSaver;
913cdf0e10cSrcweir     bForgetSelection = sal_True;
914cdf0e10cSrcweir     pLastPageSaver->m_nLastPageId = 0;
915cdf0e10cSrcweir     pLastPageSaver->m_sLastPageURL_Tools = rPageURL;
916cdf0e10cSrcweir     ActivateLastSelection();
917cdf0e10cSrcweir }
918cdf0e10cSrcweir 
919cdf0e10cSrcweir /* -----------------16.02.99 13:17-------------------
920cdf0e10cSrcweir  *
921cdf0e10cSrcweir  * --------------------------------------------------*/
ActivateLastSelection()922cdf0e10cSrcweir void OfaTreeOptionsDialog::ActivateLastSelection()
923cdf0e10cSrcweir {
924cdf0e10cSrcweir     SvLBoxEntry* pEntry = NULL;
925cdf0e10cSrcweir     if ( pLastPageSaver )
926cdf0e10cSrcweir 	{
927cdf0e10cSrcweir         String sExpand( RTL_CONSTASCII_STRINGPARAM( EXPAND_PROTOCOL ) );
928cdf0e10cSrcweir         String sLastURL = bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
929cdf0e10cSrcweir                                                   : pLastPageSaver->m_sLastPageURL_Tools;
930cdf0e10cSrcweir         if ( sLastURL.Len() == 0 )
931cdf0e10cSrcweir         {
932cdf0e10cSrcweir             sLastURL = !bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
933cdf0e10cSrcweir                                                 : pLastPageSaver->m_sLastPageURL_Tools;
934cdf0e10cSrcweir         }
935cdf0e10cSrcweir 
936cdf0e10cSrcweir         // MacroExpander to convert "expand"-URL to "file"-URL
937cdf0e10cSrcweir         Reference< XMacroExpander > m_xMacroExpander;
938cdf0e10cSrcweir         bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INET_PROT_FILE );
939cdf0e10cSrcweir 
940cdf0e10cSrcweir         if ( bMustExpand )
941cdf0e10cSrcweir         {
942cdf0e10cSrcweir             Reference< XComponentContext > xContext;
943cdf0e10cSrcweir             Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
944cdf0e10cSrcweir             xProps->getPropertyValue(
945cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext;
946cdf0e10cSrcweir             if ( xContext.is() )
947cdf0e10cSrcweir                 m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >(
948cdf0e10cSrcweir                     xContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
949cdf0e10cSrcweir                         "/singletons/com.sun.star.util.theMacroExpander" ) ) ), UNO_QUERY );
950cdf0e10cSrcweir         }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 		SvLBoxEntry* pTemp = aTreeLB.First();
953cdf0e10cSrcweir         while( !pEntry && pTemp )
954cdf0e10cSrcweir 		{
955cdf0e10cSrcweir             // restore only selection of a leaf
956cdf0e10cSrcweir             if ( aTreeLB.GetParent( pTemp ) && pTemp->GetUserData() )
957cdf0e10cSrcweir 			{
958cdf0e10cSrcweir                 OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pTemp->GetUserData();
959cdf0e10cSrcweir                 String sPageURL = pPageInfo->m_sPageURL;
960cdf0e10cSrcweir                 if ( bMustExpand
961cdf0e10cSrcweir                     && sPageURL.Len() > 0
962cdf0e10cSrcweir                     && sExpand.Match( sPageURL ) == STRING_MATCH )
963cdf0e10cSrcweir                 {
964cdf0e10cSrcweir                     // cut protocol
965cdf0e10cSrcweir                     ::rtl::OUString sTemp( sPageURL.Copy( sizeof( EXPAND_PROTOCOL ) -1 ) );
966cdf0e10cSrcweir                     // decode uri class chars
967cdf0e10cSrcweir                     sTemp = ::rtl::Uri::decode(
968cdf0e10cSrcweir                         sTemp, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
969cdf0e10cSrcweir                     // expand string
970cdf0e10cSrcweir                     sPageURL = m_xMacroExpander->expandMacros( sTemp );
971cdf0e10cSrcweir                 }
972cdf0e10cSrcweir 
973cdf0e10cSrcweir                 if ( ( !bIsFromExtensionManager
974cdf0e10cSrcweir                         && pPageInfo->m_nPageId && pPageInfo->m_nPageId == pLastPageSaver->m_nLastPageId )
975cdf0e10cSrcweir                             || ( !pPageInfo->m_nPageId && sLastURL == sPageURL ) )
976cdf0e10cSrcweir                     pEntry = pTemp;
977cdf0e10cSrcweir 			}
978cdf0e10cSrcweir 			pTemp = aTreeLB.Next(pTemp);
979cdf0e10cSrcweir 		}
980cdf0e10cSrcweir 	}
981cdf0e10cSrcweir 
982cdf0e10cSrcweir     if ( !pEntry )
983cdf0e10cSrcweir     {
984cdf0e10cSrcweir         pEntry = aTreeLB.First();
985cdf0e10cSrcweir         pEntry = aTreeLB.Next(pEntry);
986cdf0e10cSrcweir     }
987cdf0e10cSrcweir 
988cdf0e10cSrcweir     SvLBoxEntry* pParent = aTreeLB.GetParent(pEntry);
989cdf0e10cSrcweir     aTreeLB.Expand(pParent);
990cdf0e10cSrcweir     aTreeLB.MakeVisible(pParent);
991cdf0e10cSrcweir     aTreeLB.MakeVisible(pEntry);
992cdf0e10cSrcweir     aTreeLB.Select(pEntry);
993cdf0e10cSrcweir     aTreeLB.GrabFocus();
994cdf0e10cSrcweir }
995cdf0e10cSrcweir 
996cdf0e10cSrcweir /* -----------------22.02.99 08:52-------------------
997cdf0e10cSrcweir  *
998cdf0e10cSrcweir  * --------------------------------------------------*/
Notify(NotifyEvent & rNEvt)999cdf0e10cSrcweir long	OfaTreeOptionsDialog::Notify( NotifyEvent& rNEvt )
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
1002cdf0e10cSrcweir 	{
1003cdf0e10cSrcweir 		const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
1004cdf0e10cSrcweir 		const KeyCode aKeyCode = pKEvt->GetKeyCode();
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 		if( aKeyCode.GetCode() == KEY_PAGEUP ||
1007cdf0e10cSrcweir 				aKeyCode.GetCode() == KEY_PAGEDOWN)
1008cdf0e10cSrcweir 		{
1009cdf0e10cSrcweir 			SvLBoxEntry* pCurEntry = aTreeLB.FirstSelected();
1010cdf0e10cSrcweir 			SvLBoxEntry*  pTemp = 0;
1011cdf0e10cSrcweir 			if(aKeyCode.GetCode() == KEY_PAGEDOWN)
1012cdf0e10cSrcweir 			{
1013cdf0e10cSrcweir 				pTemp =  aTreeLB.Next( pCurEntry ) ;
1014cdf0e10cSrcweir 				if(pTemp && !aTreeLB.GetParent(pTemp))
1015cdf0e10cSrcweir 				{
1016cdf0e10cSrcweir 					pTemp =  aTreeLB.Next( pTemp ) ;
1017cdf0e10cSrcweir 					aTreeLB.Select(pTemp);
1018cdf0e10cSrcweir 				}
1019cdf0e10cSrcweir 			}
1020cdf0e10cSrcweir 			else
1021cdf0e10cSrcweir 			{
1022cdf0e10cSrcweir 				pTemp =  aTreeLB.Prev( pCurEntry ) ;
1023cdf0e10cSrcweir 				if(pTemp && !aTreeLB.GetParent(pTemp))
1024cdf0e10cSrcweir 				{
1025cdf0e10cSrcweir 					pTemp =  aTreeLB.Prev( pTemp ) ;
1026cdf0e10cSrcweir 				}
1027cdf0e10cSrcweir 			}
1028cdf0e10cSrcweir 			if(pTemp)
1029cdf0e10cSrcweir 			{
1030cdf0e10cSrcweir 				if(!aTreeLB.IsExpanded(aTreeLB.GetParent(pTemp)))
1031cdf0e10cSrcweir 					aTreeLB.Expand(aTreeLB.GetParent(pTemp));
1032cdf0e10cSrcweir 				aTreeLB.MakeVisible(pTemp);
1033cdf0e10cSrcweir 				aTreeLB.Select(pTemp);
1034cdf0e10cSrcweir 			}
1035cdf0e10cSrcweir 		}
1036cdf0e10cSrcweir 	}
1037cdf0e10cSrcweir 	return SfxModalDialog::Notify(rNEvt);
1038cdf0e10cSrcweir }
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir // --------------------------------------------------------------------
1041cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)1042cdf0e10cSrcweir void OfaTreeOptionsDialog::DataChanged( const DataChangedEvent& rDCEvt )
1043cdf0e10cSrcweir {
1044cdf0e10cSrcweir 	SfxModalDialog::DataChanged( rDCEvt );
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aTreeLB.GetCurEntry();
1047cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) &&
1048cdf0e10cSrcweir 		!aTreeLB.GetParent(pEntry))
1049cdf0e10cSrcweir 	{
1050cdf0e10cSrcweir 		OptionsGroupInfo* pInfo = static_cast<OptionsGroupInfo*>(pEntry->GetUserData());
1051cdf0e10cSrcweir 		bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
1052cdf0e10cSrcweir 		ImageList* pImgLst = bHighContrast ? &aPageImagesHC : &aPageImages;
1053cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < aHelpTextsArr.Count(); ++i )
1054cdf0e10cSrcweir 		{
1055cdf0e10cSrcweir             if ( aHelpTextsArr.GetValue(i) == pInfo->m_nDialogId )
1056cdf0e10cSrcweir 			{
1057cdf0e10cSrcweir                 aHelpImg.SetImage( pImgLst->GetImage( pInfo->m_nDialogId ) );
1058cdf0e10cSrcweir 				break;
1059cdf0e10cSrcweir 			}
1060cdf0e10cSrcweir 		}
1061cdf0e10cSrcweir 	}
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir class FlagSet_Impl
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir     bool & rFlag;
1066cdf0e10cSrcweir     public:
FlagSet_Impl(bool & bFlag)1067cdf0e10cSrcweir         FlagSet_Impl(bool& bFlag) : rFlag(bFlag){rFlag = true;}
~FlagSet_Impl()1068cdf0e10cSrcweir         ~FlagSet_Impl(){rFlag = false;}
1069cdf0e10cSrcweir };
1070cdf0e10cSrcweir 
IMPL_LINK(OfaTreeOptionsDialog,SelectHdl_Impl,Timer *,EMPTYARG)1071cdf0e10cSrcweir IMPL_LINK( OfaTreeOptionsDialog, SelectHdl_Impl, Timer*, EMPTYARG )
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir 	SvTreeListBox* pBox = &aTreeLB;
1074cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pBox->GetCurEntry();
1075cdf0e10cSrcweir 	SvLBoxEntry* pParent = pBox->GetParent(pEntry);
1076cdf0e10cSrcweir 	pBox->EndSelection();
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 	DBG_ASSERT(!bInSelectHdl_Impl, "Timeout handler called twice");
1079cdf0e10cSrcweir     if(bInSelectHdl_Impl || pCurrentPageEntry == pEntry)
1080cdf0e10cSrcweir         return 0;
1081cdf0e10cSrcweir     //#111938# lock the SelectHdl_Impl to prevent multiple executes
1082cdf0e10cSrcweir     FlagSet_Impl aFlag(bInSelectHdl_Impl);
1083cdf0e10cSrcweir 	TabPage* pOldPage = NULL;
1084cdf0e10cSrcweir 	TabPage* pNewPage = NULL;
1085cdf0e10cSrcweir     OptionsPageInfo* pOptPageInfo = ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
1086cdf0e10cSrcweir         ? (OptionsPageInfo*)pCurrentPageEntry->GetUserData() : NULL;
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir     if ( pOptPageInfo && pOptPageInfo->m_pPage && pOptPageInfo->m_pPage->IsVisible() )
1089cdf0e10cSrcweir 	{
1090cdf0e10cSrcweir         pOldPage = pOptPageInfo->m_pPage;
1091cdf0e10cSrcweir         OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
1092cdf0e10cSrcweir 		int nLeave = SfxTabPage::LEAVE_PAGE;
1093cdf0e10cSrcweir         if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_pPage->HasExchangeSupport() )
1094cdf0e10cSrcweir            nLeave = pOptPageInfo->m_pPage->DeactivatePage( pGroupInfo->m_pOutItemSet );
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir         if ( nLeave == SfxTabPage::KEEP_PAGE )
1097cdf0e10cSrcweir 		{
1098cdf0e10cSrcweir             // we cannot leave this page
1099cdf0e10cSrcweir             pBox->Select( pCurrentPageEntry );
1100cdf0e10cSrcweir 			return 0;
1101cdf0e10cSrcweir 		}
1102cdf0e10cSrcweir 		else
1103cdf0e10cSrcweir             pOptPageInfo->m_pPage->Hide();
1104cdf0e10cSrcweir 	}
1105cdf0e10cSrcweir     else if ( pOptPageInfo && pOptPageInfo->m_pExtPage )
1106cdf0e10cSrcweir     {
1107cdf0e10cSrcweir         pOptPageInfo->m_pExtPage->Hide();
1108cdf0e10cSrcweir         pOptPageInfo->m_pExtPage->DeactivatePage();
1109cdf0e10cSrcweir     }
1110cdf0e10cSrcweir     else if ( pCurrentPageEntry && !aTreeLB.GetParent( pCurrentPageEntry ) )
1111cdf0e10cSrcweir     {
1112cdf0e10cSrcweir         OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pCurrentPageEntry->GetUserData();
1113cdf0e10cSrcweir         if ( pGroupInfo && pGroupInfo->m_pExtPage )
1114cdf0e10cSrcweir         {
1115cdf0e10cSrcweir             pGroupInfo->m_pExtPage->Hide();
1116cdf0e10cSrcweir             pGroupInfo->m_pExtPage->DeactivatePage();
1117cdf0e10cSrcweir         }
1118cdf0e10cSrcweir     }
1119cdf0e10cSrcweir     if ( pParent )
1120cdf0e10cSrcweir 	{
1121cdf0e10cSrcweir 		aPageTitleFT.Hide();
1122cdf0e10cSrcweir 		aLine1FL.Hide();
1123cdf0e10cSrcweir 		aHelpFT.Hide();
1124cdf0e10cSrcweir 		aHelpImg.Hide();
1125cdf0e10cSrcweir 		OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
1126cdf0e10cSrcweir 		OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pParent->GetUserData();
1127cdf0e10cSrcweir         if(!pPageInfo->m_pPage && pPageInfo->m_nPageId > 0)
1128cdf0e10cSrcweir 		{
1129cdf0e10cSrcweir             if(pGroupInfo->m_bLoadError)
1130cdf0e10cSrcweir 				return 0;
1131cdf0e10cSrcweir             if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
1132cdf0e10cSrcweir 			{
1133cdf0e10cSrcweir 				if(!pColorPageItemSet)
1134cdf0e10cSrcweir 				{
1135cdf0e10cSrcweir 					// Move usage of a static XOutdevItemPool instance here
1136cdf0e10cSrcweir 					if(!mpStaticXOutdevItemPool)
1137cdf0e10cSrcweir 					{
1138cdf0e10cSrcweir 						mpStaticXOutdevItemPool = new XOutdevItemPool();
1139cdf0e10cSrcweir 					}
1140cdf0e10cSrcweir 					pColorPageItemSet = new SfxItemSet( *mpStaticXOutdevItemPool, XATTR_FILLSTYLE, XATTR_FILLCOLOR);
1141cdf0e10cSrcweir 					pColorPageItemSet->Put( XFillColorItem() );
1142cdf0e10cSrcweir 				}
1143cdf0e10cSrcweir 			}
1144cdf0e10cSrcweir 			else
1145cdf0e10cSrcweir 			{
1146cdf0e10cSrcweir                 if(pGroupInfo->m_pModule /*&& !pGroupInfo->pModule->IsLoaded()*/)
1147cdf0e10cSrcweir 				{
1148cdf0e10cSrcweir                     SfxModule* pOldModule = pGroupInfo->m_pModule;
1149cdf0e10cSrcweir                     sal_Bool bIdentical = pGroupInfo->m_pModule == pGroupInfo->m_pShell;
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir 					WaitObject aWait(this);
1152cdf0e10cSrcweir 					//pGroupInfo->pModule = pGroupInfo->pModule->Load();
1153cdf0e10cSrcweir                     if(!pGroupInfo->m_pModule)
1154cdf0e10cSrcweir 					{
1155cdf0e10cSrcweir                         pGroupInfo->m_bLoadError = sal_True;
1156cdf0e10cSrcweir 						InfoBox(pBox, sNotLoadedError).Execute();
1157cdf0e10cSrcweir 						return 0;
1158cdf0e10cSrcweir 					}
1159cdf0e10cSrcweir 					if(bIdentical)
1160cdf0e10cSrcweir                          pGroupInfo->m_pShell = pGroupInfo->m_pModule;
1161cdf0e10cSrcweir 					//jetzt noch testen, ob es auch in anderen Gruppen das gleiche Module gab (z.B. Text+HTML)
1162cdf0e10cSrcweir 					SvLBoxEntry* pTemp = aTreeLB.First();
1163cdf0e10cSrcweir 					while(pTemp)
1164cdf0e10cSrcweir 					{
1165cdf0e10cSrcweir 						if(!aTreeLB.GetParent(pTemp) && pTemp != pEntry)
1166cdf0e10cSrcweir 						{
1167cdf0e10cSrcweir 							OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pTemp->GetUserData();
1168cdf0e10cSrcweir                             if(pTGInfo->m_pModule == pOldModule)
1169cdf0e10cSrcweir 							{
1170cdf0e10cSrcweir                                 pTGInfo->m_pModule = pGroupInfo->m_pModule;
1171cdf0e10cSrcweir 								if(bIdentical)
1172cdf0e10cSrcweir                                     pTGInfo->m_pShell = pGroupInfo->m_pModule;
1173cdf0e10cSrcweir 							}
1174cdf0e10cSrcweir 						}
1175cdf0e10cSrcweir 						pTemp = aTreeLB.Next(pTemp);
1176cdf0e10cSrcweir 					}
1177cdf0e10cSrcweir 				}
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir //				if ( pPageInfo->nPageId != RID_OPTPAGE_CHART_DEFCOLORS )
1180cdf0e10cSrcweir 				{
1181cdf0e10cSrcweir                     if(!pGroupInfo->m_pInItemSet)
1182cdf0e10cSrcweir                         pGroupInfo->m_pInItemSet = pGroupInfo->m_pShell
1183cdf0e10cSrcweir                             ? pGroupInfo->m_pShell->CreateItemSet( pGroupInfo->m_nDialogId )
1184cdf0e10cSrcweir                             : CreateItemSet( pGroupInfo->m_nDialogId );
1185cdf0e10cSrcweir                     if(!pGroupInfo->m_pOutItemSet)
1186cdf0e10cSrcweir                         pGroupInfo->m_pOutItemSet = new SfxItemSet(
1187cdf0e10cSrcweir                             *pGroupInfo->m_pInItemSet->GetPool(),
1188cdf0e10cSrcweir                             pGroupInfo->m_pInItemSet->GetRanges());
1189cdf0e10cSrcweir 				}
1190cdf0e10cSrcweir 			}
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir             if(pGroupInfo->m_pModule)
1193cdf0e10cSrcweir 			{
1194cdf0e10cSrcweir                 pPageInfo->m_pPage = pGroupInfo->m_pModule->CreateTabPage(
1195cdf0e10cSrcweir                     pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet );
1196cdf0e10cSrcweir 			}
1197cdf0e10cSrcweir             else if(RID_SVXPAGE_COLOR != pPageInfo->m_nPageId)
1198cdf0e10cSrcweir                 pPageInfo->m_pPage = ::CreateGeneralTabPage( pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet );
1199cdf0e10cSrcweir 			else
1200cdf0e10cSrcweir 			{
1201cdf0e10cSrcweir                 pPageInfo->m_pPage = ::CreateGeneralTabPage(
1202cdf0e10cSrcweir                     pPageInfo->m_nPageId, this, *pColorPageItemSet );
1203cdf0e10cSrcweir                 SvxColorTabPage& rColPage = *(SvxColorTabPage*)pPageInfo->m_pPage;
1204*c7be74b1SArmin Le Grand 				const SvxColorTableItem* pPtr = NULL;
1205cdf0e10cSrcweir 				if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
1206*c7be74b1SArmin Le Grand 					pPtr = dynamic_cast< const SvxColorTableItem* >(SfxViewFrame::Current()->
1207*c7be74b1SArmin Le Grand 						GetDispatcher()->Execute(SID_GET_COLORTABLE, SFX_CALLMODE_SYNCHRON));
1208*c7be74b1SArmin Le Grand 				maColorTab = pPtr ? pPtr->GetColorTable() : XColorList::GetStdColorList();
1209cdf0e10cSrcweir 
1210*c7be74b1SArmin Le Grand 				rColPage.SetColorTable( maColorTab );
1211cdf0e10cSrcweir 				rColPage.SetPageType( &nUnknownType );
1212cdf0e10cSrcweir 				rColPage.SetDlgType( &nUnknownType );
1213cdf0e10cSrcweir 				rColPage.SetPos( &nUnknownPos );
1214cdf0e10cSrcweir 				rColPage.SetAreaTP( &bIsAreaTP );
1215cdf0e10cSrcweir 				rColPage.SetColorChgd( (ChangeType*)&nChangeType );
1216cdf0e10cSrcweir 				rColPage.Construct();
1217cdf0e10cSrcweir 			}
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir             DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created");
1220cdf0e10cSrcweir             if ( pPageInfo->m_pPage )
1221cdf0e10cSrcweir 			{
1222cdf0e10cSrcweir                 SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pPageInfo->m_nPageId ) );
1223cdf0e10cSrcweir                 pPageInfo->m_pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir 				Point aTreePos(aTreeLB.GetPosPixel());
1226cdf0e10cSrcweir 				Size aTreeSize(aTreeLB.GetSizePixel());
1227cdf0e10cSrcweir 				Point aGBPos(aHiddenGB.GetPosPixel());
1228cdf0e10cSrcweir                 Size aPageSize(pPageInfo->m_pPage->GetSizePixel());
1229cdf0e10cSrcweir 				Size aGBSize(aHiddenGB.GetSizePixel());
1230cdf0e10cSrcweir 				Point aPagePos( aGBPos.X() + ( aGBSize.Width() - aPageSize.Width() ) / 2,
1231cdf0e10cSrcweir 								aGBPos.Y() + ( aGBSize.Height() - aPageSize.Height() ) / 2 );
1232cdf0e10cSrcweir                 pPageInfo->m_pPage->SetPosPixel( aPagePos );
1233cdf0e10cSrcweir                 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
1234cdf0e10cSrcweir 				{
1235cdf0e10cSrcweir                     pPageInfo->m_pPage->Reset( *pColorPageItemSet );
1236cdf0e10cSrcweir                     pPageInfo->m_pPage->ActivatePage( *pColorPageItemSet );
1237cdf0e10cSrcweir 				}
1238cdf0e10cSrcweir 				else
1239cdf0e10cSrcweir 				{
1240cdf0e10cSrcweir                     pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
1241cdf0e10cSrcweir 				}
1242cdf0e10cSrcweir 			}
1243cdf0e10cSrcweir 		}
1244cdf0e10cSrcweir         else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_pExtPage )
1245cdf0e10cSrcweir         {
1246cdf0e10cSrcweir             if ( !m_xContainerWinProvider.is() )
1247cdf0e10cSrcweir             {
1248cdf0e10cSrcweir                 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1249cdf0e10cSrcweir                 m_xContainerWinProvider = Reference < awt::XContainerWindowProvider >(
1250cdf0e10cSrcweir                     xFactory->createInstance(
1251cdf0e10cSrcweir                         C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY );
1252cdf0e10cSrcweir                 DBG_ASSERT( m_xContainerWinProvider.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" );
1253cdf0e10cSrcweir             }
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir             pPageInfo->m_pExtPage = new ExtensionsTabPage(
1256cdf0e10cSrcweir                 this, 0, pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider );
1257cdf0e10cSrcweir             Size aSize = aHiddenGB.GetSizePixel();
1258cdf0e10cSrcweir             aSize.Width() = aSize.Width() - 4;
1259cdf0e10cSrcweir             aSize.Height() = aSize.Height() - 4;
1260cdf0e10cSrcweir             Point aPos = aHiddenGB.GetPosPixel();
1261cdf0e10cSrcweir             aPos.X() = aPos.X() + 2;
1262cdf0e10cSrcweir             aPos.Y() = aPos.Y() + 2;
1263cdf0e10cSrcweir             pPageInfo->m_pExtPage->SetPosSizePixel( aPos, aSize );
1264cdf0e10cSrcweir         }
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir         if ( pPageInfo->m_pPage )
1267cdf0e10cSrcweir 		{
1268cdf0e10cSrcweir             if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId &&
1269cdf0e10cSrcweir                  pPageInfo->m_pPage->HasExchangeSupport())
1270cdf0e10cSrcweir 			{
1271cdf0e10cSrcweir                 pPageInfo->m_pPage->ActivatePage(*pGroupInfo->m_pOutItemSet);
1272cdf0e10cSrcweir 			}
1273cdf0e10cSrcweir             pPageInfo->m_pPage->Show();
1274cdf0e10cSrcweir         }
1275cdf0e10cSrcweir         else if ( pPageInfo->m_pExtPage )
1276cdf0e10cSrcweir         {
1277cdf0e10cSrcweir             pPageInfo->m_pExtPage->Show();
1278cdf0e10cSrcweir             pPageInfo->m_pExtPage->ActivatePage();
1279cdf0e10cSrcweir         }
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir         String sTmpTitle = sTitle;
1282cdf0e10cSrcweir         sTmpTitle += String::CreateFromAscii(" - ");
1283cdf0e10cSrcweir         sTmpTitle += aTreeLB.GetEntryText(pParent);
1284cdf0e10cSrcweir         sTmpTitle += String::CreateFromAscii(" - ");
1285cdf0e10cSrcweir         sTmpTitle += aTreeLB.GetEntryText(pEntry);
1286cdf0e10cSrcweir         SetText(sTmpTitle);
1287cdf0e10cSrcweir         pCurrentPageEntry = pEntry;
1288cdf0e10cSrcweir         if ( !bForgetSelection )
1289cdf0e10cSrcweir         {
1290cdf0e10cSrcweir             if ( !pLastPageSaver )
1291cdf0e10cSrcweir                 pLastPageSaver = new LastPageSaver;
1292cdf0e10cSrcweir             if ( !bIsFromExtensionManager )
1293cdf0e10cSrcweir                 pLastPageSaver->m_nLastPageId = pPageInfo->m_nPageId;
1294cdf0e10cSrcweir             if ( pPageInfo->m_pExtPage )
1295cdf0e10cSrcweir             {
1296cdf0e10cSrcweir                 if ( bIsFromExtensionManager )
1297cdf0e10cSrcweir                     pLastPageSaver->m_sLastPageURL_ExtMgr = pPageInfo->m_sPageURL;
1298cdf0e10cSrcweir                 else
1299cdf0e10cSrcweir                     pLastPageSaver->m_sLastPageURL_Tools = pPageInfo->m_sPageURL;
1300cdf0e10cSrcweir             }
1301cdf0e10cSrcweir         }
1302cdf0e10cSrcweir         pNewPage = pPageInfo->m_pPage;
1303cdf0e10cSrcweir 	}
1304cdf0e10cSrcweir 	else
1305cdf0e10cSrcweir 	{
1306cdf0e10cSrcweir 		OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pEntry->GetUserData();
1307cdf0e10cSrcweir         if ( pTGInfo->m_sPageURL.getLength() == 0 )
1308cdf0e10cSrcweir         {
1309cdf0e10cSrcweir             bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
1310cdf0e10cSrcweir             ImageList* pImgLst = bHighContrast ? &aPageImagesHC : &aPageImages;
1311cdf0e10cSrcweir             //hier den Hilfetext anzeigen
1312cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < aHelpTextsArr.Count(); ++i )
1313cdf0e10cSrcweir             {
1314cdf0e10cSrcweir                 if ( aHelpTextsArr.GetValue(i) == pTGInfo->m_nDialogId )
1315cdf0e10cSrcweir                 {
1316cdf0e10cSrcweir                     aHelpFT.SetText(aHelpTextsArr.GetString(i));
1317cdf0e10cSrcweir                     aHelpImg.SetImage(pImgLst->GetImage(pTGInfo->m_nDialogId));
1318cdf0e10cSrcweir                     break;
1319cdf0e10cSrcweir                 }
1320cdf0e10cSrcweir             }
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir             aPageTitleFT.Show();
1323cdf0e10cSrcweir             aLine1FL.Show();
1324cdf0e10cSrcweir             aHelpFT.Show();
1325cdf0e10cSrcweir             aHelpImg.Show();
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir             //auf die Groesse der Bitmap anpassen
1328cdf0e10cSrcweir             if(!bImageResized)
1329cdf0e10cSrcweir             {
1330cdf0e10cSrcweir                 const long nCtrlDist = 2;
1331cdf0e10cSrcweir                 bImageResized = sal_True;
1332cdf0e10cSrcweir                 Point aImgPos(aHelpImg.GetPosPixel());
1333cdf0e10cSrcweir                 Size aImgSize(aHelpImg.GetSizePixel());
1334cdf0e10cSrcweir                 Point aTitlePos(aPageTitleFT.GetPosPixel());
1335cdf0e10cSrcweir                 Point aLinePos(aLine1FL.GetPosPixel());
1336cdf0e10cSrcweir                 Point aHelpPos(aHelpFT.GetPosPixel());
1337cdf0e10cSrcweir                 Size aHelpSize(aHelpFT.GetSizePixel());
1338cdf0e10cSrcweir                 long nXDiff = 0;
1339cdf0e10cSrcweir                 long nYDiff = 0;
1340cdf0e10cSrcweir                 if(aTitlePos.X() <= (aImgPos.X() + aImgSize.Width() + nCtrlDist))
1341cdf0e10cSrcweir                 {
1342cdf0e10cSrcweir                     nXDiff = aImgPos.X() + aImgSize.Width() + nCtrlDist - aTitlePos.X();
1343cdf0e10cSrcweir                 }
1344cdf0e10cSrcweir                 if(aLinePos.Y() <= (aImgPos.Y() + aImgSize.Height() + nCtrlDist))
1345cdf0e10cSrcweir                 {
1346cdf0e10cSrcweir                     nYDiff = aImgPos.Y() + aImgSize.Height() + nCtrlDist - aLinePos.Y();
1347cdf0e10cSrcweir                 }
1348cdf0e10cSrcweir                 aLinePos.Y() += nYDiff;
1349cdf0e10cSrcweir                 aLine1FL.SetPosPixel(aLinePos);
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir                 aTitlePos.X() += nXDiff;
1352cdf0e10cSrcweir                 aPageTitleFT.SetPosPixel(aTitlePos);
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir                 aHelpPos.X() += nXDiff;
1355cdf0e10cSrcweir                 aHelpPos.Y() += nYDiff;
1356cdf0e10cSrcweir                 aHelpSize.Width() -= nXDiff;
1357cdf0e10cSrcweir                 aHelpSize.Height() -= nYDiff;
1358cdf0e10cSrcweir                 aHelpFT.SetPosSizePixel(aHelpPos, aHelpSize);
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir                 Font aFont = aHelpFT.GetFont();
1361cdf0e10cSrcweir                 Size aSz = aFont.GetSize();
1362cdf0e10cSrcweir                 aSz.Height() = (aSz.Height() * 14 ) / 10;
1363cdf0e10cSrcweir                 aFont.SetSize(aSz);
1364cdf0e10cSrcweir                 aPageTitleFT.SetFont(aFont);
1365cdf0e10cSrcweir             }
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir             String sTmpTitle = sTitle;
1368cdf0e10cSrcweir             sTmpTitle += String::CreateFromAscii(" - ");
1369cdf0e10cSrcweir             aPageTitleFT.SetText(aTreeLB.GetEntryText(pEntry));
1370cdf0e10cSrcweir             sTmpTitle += aPageTitleFT.GetText();
1371cdf0e10cSrcweir             SetText(sTmpTitle);
1372cdf0e10cSrcweir             pCurrentPageEntry = NULL;
1373cdf0e10cSrcweir         }
1374cdf0e10cSrcweir         else
1375cdf0e10cSrcweir         {
1376cdf0e10cSrcweir             if ( !pTGInfo->m_pExtPage )
1377cdf0e10cSrcweir             {
1378cdf0e10cSrcweir                 if ( !m_xContainerWinProvider.is() )
1379cdf0e10cSrcweir                 {
1380cdf0e10cSrcweir                     Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1381cdf0e10cSrcweir                     m_xContainerWinProvider = Reference < awt::XContainerWindowProvider >(
1382cdf0e10cSrcweir                         xFactory->createInstance(
1383cdf0e10cSrcweir                             C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY );
1384cdf0e10cSrcweir                     DBG_ASSERT( m_xContainerWinProvider.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" );
1385cdf0e10cSrcweir                 }
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir                 pTGInfo->m_pExtPage =
1388cdf0e10cSrcweir                     new ExtensionsTabPage( this, 0, pTGInfo->m_sPageURL, rtl::OUString(), m_xContainerWinProvider );
1389cdf0e10cSrcweir                 Size aSize = aHiddenGB.GetSizePixel();
1390cdf0e10cSrcweir                 aSize.Width() = aSize.Width() - 4;
1391cdf0e10cSrcweir                 aSize.Height() = aSize.Height() - 4;
1392cdf0e10cSrcweir                 Point aPos = aHiddenGB.GetPosPixel();
1393cdf0e10cSrcweir                 aPos.X() = aPos.X() + 2;
1394cdf0e10cSrcweir                 aPos.Y() = aPos.Y() + 2;
1395cdf0e10cSrcweir                 pTGInfo->m_pExtPage->SetPosSizePixel( aPos, aSize );
1396cdf0e10cSrcweir             }
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir             if ( pTGInfo->m_pExtPage )
1399cdf0e10cSrcweir             {
1400cdf0e10cSrcweir                 pTGInfo->m_pExtPage->Show();
1401cdf0e10cSrcweir                 pTGInfo->m_pExtPage->ActivatePage();
1402cdf0e10cSrcweir             }
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir             pCurrentPageEntry = pEntry;
1405cdf0e10cSrcweir         }
1406cdf0e10cSrcweir 	}
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir 	// restore lost focus, if necessary
1409cdf0e10cSrcweir 	Window* pFocusWin = Application::GetFocusWindow();
1410cdf0e10cSrcweir 	// if the focused window is not the options treebox and the old page has the focus
1411cdf0e10cSrcweir 	if ( pFocusWin && pFocusWin != pBox && pOldPage && pOldPage->HasChildPathFocus() )
1412cdf0e10cSrcweir 		// then set the focus to the new page or if we are on a group set the focus to the options treebox
1413cdf0e10cSrcweir 		pNewPage ? pNewPage->GrabFocus() : pBox->GrabFocus();
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir 	return 0;
1416cdf0e10cSrcweir }
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir /* -----------------11.02.99 15:51-------------------
1419cdf0e10cSrcweir  *
1420cdf0e10cSrcweir  * --------------------------------------------------*/
1421cdf0e10cSrcweir 
OfaPageResource()1422cdf0e10cSrcweir OfaPageResource::OfaPageResource() :
1423cdf0e10cSrcweir 	Resource(CUI_RES(RID_OFADLG_OPTIONS_TREE_PAGES)),
1424cdf0e10cSrcweir 	aGeneralDlgAry(CUI_RES(SID_GENERAL_OPTIONS)),
1425cdf0e10cSrcweir     aInetDlgAry(CUI_RES(SID_INET_DLG)),
1426cdf0e10cSrcweir     aLangDlgAry(CUI_RES(SID_LANGUAGE_OPTIONS)),
1427cdf0e10cSrcweir     aTextDlgAry(CUI_RES(SID_SW_EDITOPTIONS)),
1428cdf0e10cSrcweir 	aHTMLDlgAry(CUI_RES(SID_SW_ONLINEOPTIONS)),
1429cdf0e10cSrcweir 	aCalcDlgAry(CUI_RES(SID_SC_EDITOPTIONS)),
1430cdf0e10cSrcweir 	aStarMathDlgAry(CUI_RES(SID_SM_EDITOPTIONS)),
1431cdf0e10cSrcweir 	aImpressDlgAry(CUI_RES(SID_SD_EDITOPTIONS)),
1432cdf0e10cSrcweir 	aDrawDlgAry(CUI_RES(SID_SD_GRAPHIC_OPTIONS)),
1433cdf0e10cSrcweir 	aChartDlgAry(CUI_RES(SID_SCH_EDITOPTIONS)),
1434cdf0e10cSrcweir     aFilterDlgAry(CUI_RES(SID_FILTER_DLG)),
1435cdf0e10cSrcweir 	aDatasourcesDlgAry(CUI_RES(SID_SB_STARBASEOPTIONS))
1436cdf0e10cSrcweir {
1437cdf0e10cSrcweir 	FreeResource();
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir 
EnableSSO(void)1440cdf0e10cSrcweir sal_Bool EnableSSO( void )
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir 	// SSO must be enabled if the configuration manager bootstrap settings
1443cdf0e10cSrcweir 	// are configured as follows ...
1444cdf0e10cSrcweir 	//  CFG_Offline=false
1445cdf0e10cSrcweir 	//  CFG_ServerType=uno ( or unspecified )
1446cdf0e10cSrcweir 	//  CFG_BackendService=
1447cdf0e10cSrcweir 	//   com.sun.star.comp.configuration.backend.LdapSingleBackend
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir     rtl::OUString theIniFile;
1450cdf0e10cSrcweir 	osl_getExecutableFile( &theIniFile.pData );
1451cdf0e10cSrcweir 	theIniFile = theIniFile.copy( 0, theIniFile.lastIndexOf( '/' ) + 1 ) +
1452cdf0e10cSrcweir                  rtl::OUString::createFromAscii( SAL_CONFIGFILE( "configmgr" ) );
1453cdf0e10cSrcweir 	::rtl::Bootstrap theBootstrap( theIniFile );
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir     rtl::OUString theOfflineValue;
1456cdf0e10cSrcweir     rtl::OUString theDefaultOfflineValue = rtl::OUString::createFromAscii( "false" );
1457cdf0e10cSrcweir     theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_Offline" ),
1458cdf0e10cSrcweir 						  theOfflineValue,
1459cdf0e10cSrcweir 						  theDefaultOfflineValue );
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir     rtl::OUString theServerTypeValue;
1462cdf0e10cSrcweir     theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_ServerType" ),
1463cdf0e10cSrcweir 						  theServerTypeValue );
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir     rtl::OUString theBackendServiceTypeValue;
1466cdf0e10cSrcweir     theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_BackendService" ),
1467cdf0e10cSrcweir 						  theBackendServiceTypeValue );
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir 	sal_Bool bSSOEnabled =
1470cdf0e10cSrcweir 		( theOfflineValue == theDefaultOfflineValue						&&
1471cdf0e10cSrcweir 		  ( theServerTypeValue.getLength() == 0 ||
1472cdf0e10cSrcweir           theServerTypeValue == rtl::OUString::createFromAscii( "uno" ) ) &&
1473cdf0e10cSrcweir 		  theBackendServiceTypeValue ==
1474cdf0e10cSrcweir             rtl::OUString::createFromAscii(
1475cdf0e10cSrcweir 				"com.sun.star.comp.configuration.backend.LdapSingleBackend" ) );
1476cdf0e10cSrcweir 	if ( bSSOEnabled && GetSSOCreator() == 0 )
1477cdf0e10cSrcweir 	{
1478cdf0e10cSrcweir 		bSSOEnabled = sal_False;
1479cdf0e10cSrcweir 	}
1480cdf0e10cSrcweir 	return bSSOEnabled;
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir 
thisModule()1483cdf0e10cSrcweir extern "C" { static void SAL_CALL thisModule() {} }
1484cdf0e10cSrcweir 
GetSSOCreator(void)1485cdf0e10cSrcweir CreateTabPage GetSSOCreator( void )
1486cdf0e10cSrcweir {
1487cdf0e10cSrcweir 	static CreateTabPage theSymbol = 0;
1488cdf0e10cSrcweir 	if ( theSymbol == 0 )
1489cdf0e10cSrcweir 	{
1490cdf0e10cSrcweir 		osl::Module aModule;
1491cdf0e10cSrcweir         rtl::OUString theModuleName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "ssoopt" ) ) );
1492cdf0e10cSrcweir 		if( aModule.loadRelative(
1493cdf0e10cSrcweir                 &thisModule, theModuleName, SAL_LOADMODULE_DEFAULT ) )
1494cdf0e10cSrcweir 		{
1495cdf0e10cSrcweir             rtl::OUString theSymbolName( rtl::OUString::createFromAscii( "CreateSSOTabPage" ) );
1496cdf0e10cSrcweir 			theSymbol = reinterpret_cast<CreateTabPage>(aModule.getFunctionSymbol( theSymbolName ));
1497cdf0e10cSrcweir 		}
1498cdf0e10cSrcweir 	}
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir 	return theSymbol;
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir 
CreateItemSet(sal_uInt16 nId)1503cdf0e10cSrcweir SfxItemSet*	OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
1504cdf0e10cSrcweir {
1505cdf0e10cSrcweir     Reference< XPropertySet >  xProp( SvxGetLinguPropertySet() );
1506cdf0e10cSrcweir 	SfxItemSet*	pRet = 0;
1507cdf0e10cSrcweir 	switch(nId)
1508cdf0e10cSrcweir 	{
1509cdf0e10cSrcweir         case SID_GENERAL_OPTIONS:
1510cdf0e10cSrcweir 		{
1511cdf0e10cSrcweir 			pRet = new SfxItemSet(
1512cdf0e10cSrcweir 				SFX_APP()->GetPool(),
1513cdf0e10cSrcweir                 SID_ATTR_METRIC, SID_ATTR_SPELL,
1514cdf0e10cSrcweir                 SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK,
1515cdf0e10cSrcweir                 SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER,
1516cdf0e10cSrcweir                 SID_ATTR_YEAR2000, SID_ATTR_YEAR2000,
1517cdf0e10cSrcweir 				SID_HTML_MODE, SID_HTML_MODE,
1518cdf0e10cSrcweir                 0 );
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir             SfxItemSet aOptSet( SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1521cdf0e10cSrcweir             SFX_APP()->GetOptions(aOptSet);
1522cdf0e10cSrcweir             pRet->Put(aOptSet);
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir 			utl::MiscCfg	aMisc;
1525cdf0e10cSrcweir 			const SfxPoolItem* pItem;
1526cdf0e10cSrcweir             SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1527cdf0e10cSrcweir             if ( pViewFrame )
1528cdf0e10cSrcweir             {
1529cdf0e10cSrcweir                 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir                 // Sonstiges - Year2000
1532cdf0e10cSrcweir                 if( SFX_ITEM_AVAILABLE <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) )
1533cdf0e10cSrcweir                     pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, ((const SfxUInt16Item*)pItem)->GetValue() ) );
1534cdf0e10cSrcweir                 else
1535cdf0e10cSrcweir                     pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
1536cdf0e10cSrcweir             }
1537cdf0e10cSrcweir             else
1538cdf0e10cSrcweir                 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir 			// Sonstiges - Tabulator
1542cdf0e10cSrcweir             pRet->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning()));
1543cdf0e10cSrcweir 
1544cdf0e10cSrcweir 			sal_uInt16 nFlag = aMisc.IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0;
1545cdf0e10cSrcweir             nFlag  |= aMisc.IsPaperOrientationWarning()  ? SFX_PRINTER_CHG_ORIENTATION : 0;
1546cdf0e10cSrcweir 			pRet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlag ));
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir         }
1549cdf0e10cSrcweir 		break;
1550cdf0e10cSrcweir         case SID_LANGUAGE_OPTIONS :
1551cdf0e10cSrcweir         {
1552cdf0e10cSrcweir             pRet = new SfxItemSet(SFX_APP()->GetPool(),
1553cdf0e10cSrcweir                     SID_ATTR_LANGUAGE, SID_AUTOSPELL_CHECK,
1554cdf0e10cSrcweir                     SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
1555cdf0e10cSrcweir                     SID_OPT_LOCALE_CHANGED, SID_OPT_LOCALE_CHANGED,
1556cdf0e10cSrcweir                     SID_SET_DOCUMENT_LANGUAGE, SID_SET_DOCUMENT_LANGUAGE,
1557cdf0e10cSrcweir 					0 );
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir 			// fuer die Linguistik
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir             Reference< XSpellChecker1 >  xSpell = SvxGetSpellChecker();
1562cdf0e10cSrcweir 			pRet->Put(SfxSpellCheckItem( xSpell, SID_ATTR_SPELL ));
1563cdf0e10cSrcweir 			SfxHyphenRegionItem aHyphen( SID_ATTR_HYPHENREGION );
1564cdf0e10cSrcweir 
1565cdf0e10cSrcweir 			sal_Int16 	nMinLead  = 2,
1566cdf0e10cSrcweir 						nMinTrail = 2;
1567cdf0e10cSrcweir 			if (xProp.is())
1568cdf0e10cSrcweir 			{
1569cdf0e10cSrcweir 				xProp->getPropertyValue( String::CreateFromAscii(
1570cdf0e10cSrcweir 						UPN_HYPH_MIN_LEADING) ) >>= nMinLead;
1571cdf0e10cSrcweir 				xProp->getPropertyValue( String::CreateFromAscii(
1572cdf0e10cSrcweir 						UPN_HYPH_MIN_TRAILING) ) >>= nMinTrail;
1573cdf0e10cSrcweir 			}
1574cdf0e10cSrcweir 			aHyphen.GetMinLead()  = (sal_uInt8)nMinLead;
1575cdf0e10cSrcweir 			aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail;
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir 			const SfxPoolItem* pItem;
1578cdf0e10cSrcweir 			SfxPoolItem* pClone;
1579cdf0e10cSrcweir             SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1580cdf0e10cSrcweir             if ( pViewFrame )
1581cdf0e10cSrcweir             {
1582cdf0e10cSrcweir                 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1583cdf0e10cSrcweir                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
1584cdf0e10cSrcweir                     pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1585cdf0e10cSrcweir                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem))
1586cdf0e10cSrcweir                     pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CJK_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1587cdf0e10cSrcweir                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem))
1588cdf0e10cSrcweir                     pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CTL_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir 				pRet->Put(aHyphen);
1591cdf0e10cSrcweir                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem))
1592cdf0e10cSrcweir                 {
1593cdf0e10cSrcweir                     pClone = pItem->Clone();
1594cdf0e10cSrcweir                     pRet->Put(*pClone);
1595cdf0e10cSrcweir                     delete pClone;
1596cdf0e10cSrcweir                 }
1597cdf0e10cSrcweir                 else
1598cdf0e10cSrcweir                 {
1599cdf0e10cSrcweir                         sal_Bool bVal = sal_False;
1600cdf0e10cSrcweir                         if (xProp.is())
1601cdf0e10cSrcweir                         {
1602cdf0e10cSrcweir                             xProp->getPropertyValue( String::CreateFromAscii( UPN_IS_SPELL_AUTO) ) >>= bVal;
1603cdf0e10cSrcweir                         }
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir                         pRet->Put(SfxBoolItem(SID_AUTOSPELL_CHECK, bVal));
1606cdf0e10cSrcweir                 }
1607cdf0e10cSrcweir             }
1608cdf0e10cSrcweir             pRet->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE, bIsForSetDocumentLanguage ) );
1609cdf0e10cSrcweir         }
1610cdf0e10cSrcweir         break;
1611cdf0e10cSrcweir         case SID_INET_DLG :
1612cdf0e10cSrcweir 				pRet = new SfxItemSet( SFX_APP()->GetPool(),
1613cdf0e10cSrcweir 								SID_BASIC_ENABLED, SID_BASIC_ENABLED,
1614cdf0e10cSrcweir 				//SID_OPTIONS_START - ..END
1615369c5206SMathias Bauer 								SID_INET_EMAIL_NAME, SID_INET_PROXY_PORT,
1616cdf0e10cSrcweir 								SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1617cdf0e10cSrcweir 								SID_INET_SMTPSERVER, SID_INET_SMTPSERVER,
1618cdf0e10cSrcweir 								SID_INET_NOPROXY, SID_INET_SOCKS_PROXY_PORT,
1619cdf0e10cSrcweir 								SID_INET_DNS_AUTO, SID_INET_DNS_SERVER,
1620cdf0e10cSrcweir 								SID_SECURE_URL, SID_SECURE_URL,
1621cdf0e10cSrcweir 								0L );
1622cdf0e10cSrcweir 				SFX_APP()->GetOptions(*pRet);
1623cdf0e10cSrcweir 		break;
1624cdf0e10cSrcweir 		case SID_FILTER_DLG:
1625cdf0e10cSrcweir             pRet = new SfxItemSet( SFX_APP()->GetPool(),
1626cdf0e10cSrcweir             SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE,
1627cdf0e10cSrcweir             SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1628cdf0e10cSrcweir 			SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING,
1629cdf0e10cSrcweir             SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT,
1630cdf0e10cSrcweir             0 );
1631cdf0e10cSrcweir             SFX_APP()->GetOptions(*pRet);
1632cdf0e10cSrcweir             break;
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir 		case SID_SB_STARBASEOPTIONS:
1635cdf0e10cSrcweir             pRet = new SfxItemSet( SFX_APP()->GetPool(),
1636cdf0e10cSrcweir             SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER,
1637cdf0e10cSrcweir             0 );
1638cdf0e10cSrcweir 			::offapp::ConnectionPoolConfig::GetOptions(*pRet);
1639cdf0e10cSrcweir 			::svx::DbRegisteredNamesConfig::GetOptions(*pRet);
1640cdf0e10cSrcweir 			break;
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 		case SID_SCH_EDITOPTIONS:
1643cdf0e10cSrcweir 		{
1644cdf0e10cSrcweir 			SvxChartOptions aChartOpt;
1645cdf0e10cSrcweir             pRet = new SfxItemSet( SFX_APP()->GetPool(), SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS );
1646cdf0e10cSrcweir 			pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) );
1647cdf0e10cSrcweir 			break;
1648cdf0e10cSrcweir 		}
1649cdf0e10cSrcweir 	}
1650cdf0e10cSrcweir 	return pRet;
1651cdf0e10cSrcweir }
1652cdf0e10cSrcweir 
ApplyItemSet(sal_uInt16 nId,const SfxItemSet & rSet)1653cdf0e10cSrcweir void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir 	switch(nId)
1656cdf0e10cSrcweir 	{
1657cdf0e10cSrcweir 		case SID_GENERAL_OPTIONS:
1658cdf0e10cSrcweir 		{
1659cdf0e10cSrcweir 			utl::MiscCfg	aMisc;
1660cdf0e10cSrcweir 			const SfxPoolItem* pItem;
1661cdf0e10cSrcweir             SfxItemSet aOptSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1662cdf0e10cSrcweir             aOptSet.Put(rSet);
1663cdf0e10cSrcweir             if(aOptSet.Count())
1664cdf0e10cSrcweir                 SFX_APP()->SetOptions( aOptSet );
1665cdf0e10cSrcweir     		// Dispatcher neu holen, weil SetOptions() ggf. den Dispatcher zerst"ort hat
1666cdf0e10cSrcweir             SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1667cdf0e10cSrcweir // -------------------------------------------------------------------------
1668cdf0e10cSrcweir //			Year2000 auswerten
1669cdf0e10cSrcweir // -------------------------------------------------------------------------
1670cdf0e10cSrcweir             sal_uInt16 nY2K = USHRT_MAX;
1671cdf0e10cSrcweir             if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, sal_False, &pItem ) )
1672cdf0e10cSrcweir                 nY2K = ((const SfxUInt16Item*)pItem)->GetValue();
1673cdf0e10cSrcweir             if( USHRT_MAX != nY2K )
1674cdf0e10cSrcweir             {
1675cdf0e10cSrcweir                 if ( pViewFrame )
1676cdf0e10cSrcweir                 {
1677cdf0e10cSrcweir                     SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1678cdf0e10cSrcweir                     pDispatch->Execute( SID_ATTR_YEAR2000, SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1679cdf0e10cSrcweir                 }
1680cdf0e10cSrcweir                 aMisc.SetYear2000(nY2K);
1681cdf0e10cSrcweir             }
1682cdf0e10cSrcweir 
1683cdf0e10cSrcweir // -------------------------------------------------------------------------
1684cdf0e10cSrcweir //			Drucken auswerten
1685cdf0e10cSrcweir // -------------------------------------------------------------------------
1686cdf0e10cSrcweir 			if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, sal_False, &pItem))
1687cdf0e10cSrcweir 				aMisc.SetNotFoundWarning(((const SfxBoolItem*)pItem)->GetValue());
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir 			if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, sal_False, &pItem))
1690cdf0e10cSrcweir 			{
1691cdf0e10cSrcweir 				const SfxFlagItem* pFlag = (const SfxFlagItem*)pItem;
1692cdf0e10cSrcweir 				aMisc.SetPaperSizeWarning(0 != (pFlag->GetValue() &  SFX_PRINTER_CHG_SIZE ));
1693cdf0e10cSrcweir                 aMisc.SetPaperOrientationWarning(0 !=  (pFlag->GetValue() & SFX_PRINTER_CHG_ORIENTATION ));
1694cdf0e10cSrcweir 			}
1695cdf0e10cSrcweir // -------------------------------------------------------------------------
1696cdf0e10cSrcweir //			evaluate help options
1697cdf0e10cSrcweir // -------------------------------------------------------------------------
1698cdf0e10cSrcweir 			if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() )
1699cdf0e10cSrcweir 				SvtHelpOptions().IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
1700cdf0e10cSrcweir 			if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
1701cdf0e10cSrcweir 				SvtHelpOptions().IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
1702cdf0e10cSrcweir         }
1703cdf0e10cSrcweir 		break;
1704cdf0e10cSrcweir         case SID_LANGUAGE_OPTIONS :
1705cdf0e10cSrcweir         {
1706cdf0e10cSrcweir             OfaTreeOptionsDialog::ApplyLanguageOptions(rSet);
1707cdf0e10cSrcweir         }
1708cdf0e10cSrcweir         break;
1709cdf0e10cSrcweir 		case SID_INET_DLG :
1710cdf0e10cSrcweir         case SID_FILTER_DLG:
1711cdf0e10cSrcweir 			SFX_APP()->SetOptions( rSet );
1712cdf0e10cSrcweir 		break;
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir 		case SID_SB_STARBASEOPTIONS:
1715cdf0e10cSrcweir 			::offapp::ConnectionPoolConfig::SetOptions( rSet );
1716cdf0e10cSrcweir 			::svx::DbRegisteredNamesConfig::SetOptions(rSet);
1717cdf0e10cSrcweir 			break;
1718cdf0e10cSrcweir 
1719cdf0e10cSrcweir         case SID_SCH_EDITOPTIONS:
1720cdf0e10cSrcweir             // nothing to do. Chart options only apply to newly created charts
1721cdf0e10cSrcweir             break;
1722cdf0e10cSrcweir 
1723cdf0e10cSrcweir         default:
1724cdf0e10cSrcweir         {
1725cdf0e10cSrcweir             DBG_ERROR( "Unhandled option in ApplyItemSet" );
1726cdf0e10cSrcweir         }
1727cdf0e10cSrcweir         break;
1728cdf0e10cSrcweir 	}
1729cdf0e10cSrcweir 
1730cdf0e10cSrcweir }
ApplyLanguageOptions(const SfxItemSet & rSet)1731cdf0e10cSrcweir void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir     sal_Bool bSaveSpellCheck = sal_False;
1734cdf0e10cSrcweir     const SfxPoolItem* pItem;
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir     if ( SFX_ITEM_SET == rSet.GetItemState( SID_SPELL_MODIFIED, sal_False, &pItem ) )
1737cdf0e10cSrcweir     {
1738cdf0e10cSrcweir         bSaveSpellCheck = ( (const SfxBoolItem*)pItem )->GetValue();
1739cdf0e10cSrcweir     }
1740cdf0e10cSrcweir     Reference< XMultiServiceFactory >  xMgr( ::comphelper::getProcessServiceFactory() );
1741cdf0e10cSrcweir     Reference< XPropertySet >  xProp(
1742cdf0e10cSrcweir             xMgr->createInstance( ::rtl::OUString::createFromAscii(
1743cdf0e10cSrcweir                     "com.sun.star.linguistic2.LinguProperties") ),
1744cdf0e10cSrcweir             UNO_QUERY );
1745cdf0e10cSrcweir     if ( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, sal_False, &pItem ) )
1746cdf0e10cSrcweir     {
1747cdf0e10cSrcweir         const SfxHyphenRegionItem* pHyphenItem = (const SfxHyphenRegionItem*)pItem;
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir         if (xProp.is())
1750cdf0e10cSrcweir         {
1751cdf0e10cSrcweir             xProp->setPropertyValue(
1752cdf0e10cSrcweir                     String::CreateFromAscii(UPN_HYPH_MIN_LEADING),
1753cdf0e10cSrcweir                     makeAny((sal_Int16) pHyphenItem->GetMinLead()) );
1754cdf0e10cSrcweir             xProp->setPropertyValue(
1755cdf0e10cSrcweir                     String::CreateFromAscii(UPN_HYPH_MIN_TRAILING),
1756cdf0e10cSrcweir                     makeAny((sal_Int16) pHyphenItem->GetMinTrail()) );
1757cdf0e10cSrcweir         }
1758cdf0e10cSrcweir         bSaveSpellCheck = sal_True;
1759cdf0e10cSrcweir     }
1760cdf0e10cSrcweir 
1761cdf0e10cSrcweir     SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1762cdf0e10cSrcweir     if ( pViewFrame )
1763cdf0e10cSrcweir     {
1764cdf0e10cSrcweir         SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1765cdf0e10cSrcweir         pItem = 0;
1766cdf0e10cSrcweir         if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_LANGUAGE, sal_False, &pItem ))
1767cdf0e10cSrcweir         {
1768cdf0e10cSrcweir             pDispatch->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1769cdf0e10cSrcweir             bSaveSpellCheck = sal_True;
1770cdf0e10cSrcweir         }
1771cdf0e10cSrcweir         if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pItem ))
1772cdf0e10cSrcweir         {
1773cdf0e10cSrcweir             pDispatch->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1774cdf0e10cSrcweir             bSaveSpellCheck = sal_True;
1775cdf0e10cSrcweir         }
1776cdf0e10cSrcweir         if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pItem ))
1777cdf0e10cSrcweir         {
1778cdf0e10cSrcweir             pDispatch->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1779cdf0e10cSrcweir             bSaveSpellCheck = sal_True;
1780cdf0e10cSrcweir         }
1781cdf0e10cSrcweir 
1782cdf0e10cSrcweir         if( SFX_ITEM_SET == rSet.GetItemState(SID_AUTOSPELL_CHECK, sal_False, &pItem ))
1783cdf0e10cSrcweir         {
1784cdf0e10cSrcweir             sal_Bool bOnlineSpelling = ((const SfxBoolItem*)pItem)->GetValue();
1785cdf0e10cSrcweir             pDispatch->Execute(SID_AUTOSPELL_CHECK,
1786cdf0e10cSrcweir                 SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, pItem, 0L);
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir             if (xProp.is())
1789cdf0e10cSrcweir             {
1790cdf0e10cSrcweir                 xProp->setPropertyValue(
1791cdf0e10cSrcweir                         String::CreateFromAscii(UPN_IS_SPELL_AUTO),
1792cdf0e10cSrcweir                         makeAny(bOnlineSpelling) );
1793cdf0e10cSrcweir             }
1794cdf0e10cSrcweir         }
1795cdf0e10cSrcweir 
1796cdf0e10cSrcweir         if( bSaveSpellCheck )
1797cdf0e10cSrcweir         {
1798cdf0e10cSrcweir             //! the config item has changed since we modified the
1799cdf0e10cSrcweir             //! property set it uses
1800cdf0e10cSrcweir             pDispatch->Execute(SID_SPELLCHECKER_CHANGED, SFX_CALLMODE_ASYNCHRON);
1801cdf0e10cSrcweir         }
1802cdf0e10cSrcweir     }
1803cdf0e10cSrcweir 
1804cdf0e10cSrcweir     if( SFX_ITEM_SET == rSet.GetItemState(SID_OPT_LOCALE_CHANGED, sal_False, &pItem ))
1805cdf0e10cSrcweir     {
1806cdf0e10cSrcweir         SfxViewFrame* _pViewFrame = SfxViewFrame::GetFirst();
1807cdf0e10cSrcweir         while ( _pViewFrame )
1808cdf0e10cSrcweir         {
1809cdf0e10cSrcweir             _pViewFrame->GetDispatcher()->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1810cdf0e10cSrcweir             _pViewFrame = SfxViewFrame::GetNext( *_pViewFrame );
1811cdf0e10cSrcweir         }
1812cdf0e10cSrcweir     }
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir 
getCurrentFactory_Impl(const Reference<XFrame> & _xFrame)1815cdf0e10cSrcweir rtl::OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
1816cdf0e10cSrcweir {
1817cdf0e10cSrcweir     rtl::OUString sIdentifier;
1818cdf0e10cSrcweir     Reference < XFrame > xCurrentFrame( _xFrame );
1819cdf0e10cSrcweir     Reference < XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance(
1820cdf0e10cSrcweir         DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
1821cdf0e10cSrcweir     if ( !xCurrentFrame.is() )
1822cdf0e10cSrcweir     {
1823cdf0e10cSrcweir         Reference< XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
1824cdf0e10cSrcweir             DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
1825cdf0e10cSrcweir         if ( xDesktop.is() )
1826cdf0e10cSrcweir             xCurrentFrame = xDesktop->getCurrentFrame();
1827cdf0e10cSrcweir     }
1828cdf0e10cSrcweir 
1829cdf0e10cSrcweir     if ( xCurrentFrame.is() && xModuleManager.is() )
1830cdf0e10cSrcweir     {
1831cdf0e10cSrcweir         try
1832cdf0e10cSrcweir         {
1833cdf0e10cSrcweir             sIdentifier = xModuleManager->identify( xCurrentFrame );
1834cdf0e10cSrcweir         }
1835cdf0e10cSrcweir         catch ( ::com::sun::star::frame::UnknownModuleException& )
1836cdf0e10cSrcweir         {
1837cdf0e10cSrcweir             DBG_WARNING( "getActiveModule_Impl(): unknown module" );
1838cdf0e10cSrcweir         }
1839cdf0e10cSrcweir         catch ( Exception& )
1840cdf0e10cSrcweir         {
1841cdf0e10cSrcweir             DBG_ERRORFILE( "getActiveModule_Impl(): exception of XModuleManager::identify()" );
1842cdf0e10cSrcweir         }
1843cdf0e10cSrcweir     }
1844cdf0e10cSrcweir 
1845cdf0e10cSrcweir     return sIdentifier;
1846cdf0e10cSrcweir }
1847cdf0e10cSrcweir 
Initialize(const Reference<XFrame> & _xFrame)1848cdf0e10cSrcweir void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
1849cdf0e10cSrcweir {
1850cdf0e10cSrcweir 	OfaPageResource aDlgResource;
1851cdf0e10cSrcweir 	sal_uInt16 nGroup = 0;
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir     SvtOptionsDialogOptions aOptionsDlgOpt;
1854cdf0e10cSrcweir     sal_uInt16 i, nPageId;
1855cdf0e10cSrcweir 
1856cdf0e10cSrcweir     // %PRODUCTNAME options
1857cdf0e10cSrcweir     sal_Bool isSSOEnabled = EnableSSO();
1858cdf0e10cSrcweir     if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) )
1859cdf0e10cSrcweir     {
1860cdf0e10cSrcweir         ResStringArray& rGeneralArray = aDlgResource.GetGeneralArray();
1861cdf0e10cSrcweir         setGroupName( C2U("ProductName"), rGeneralArray.GetString(0) );
1862cdf0e10cSrcweir         nGroup = AddGroup( rGeneralArray.GetString(0), 0, 0, SID_GENERAL_OPTIONS );
1863cdf0e10cSrcweir         sal_uInt16 nEnd = static_cast< sal_uInt16 >( rGeneralArray.Count() );
1864cdf0e10cSrcweir         String sPageTitle;
1865cdf0e10cSrcweir 
1866cdf0e10cSrcweir         for ( i = 1; i < nEnd; ++i )
1867cdf0e10cSrcweir         {
1868cdf0e10cSrcweir             String sNewTitle = rGeneralArray.GetString(i);
1869cdf0e10cSrcweir             nPageId = (sal_uInt16)rGeneralArray.GetValue(i);
1870cdf0e10cSrcweir             if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1871cdf0e10cSrcweir                 continue;
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir             // Disable Online Update page if service not installed
1874cdf0e10cSrcweir             if( RID_SVXPAGE_ONLINEUPDATE == nPageId )
1875cdf0e10cSrcweir             {
1876cdf0e10cSrcweir                 const ::rtl::OUString sService = C2U("com.sun.star.setup.UpdateCheck");
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir                 try
1879cdf0e10cSrcweir                 {
1880cdf0e10cSrcweir                     Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1881cdf0e10cSrcweir                     Reference < XInterface > xService( xFactory->createInstance( sService ) );
1882cdf0e10cSrcweir 
1883cdf0e10cSrcweir                     if( ! xService.is() )
1884cdf0e10cSrcweir                         continue;
1885cdf0e10cSrcweir                 }
1886cdf0e10cSrcweir                 catch ( ::com::sun::star::loader::CannotActivateFactoryException& )
1887cdf0e10cSrcweir                 {
1888cdf0e10cSrcweir                     continue;
1889cdf0e10cSrcweir                 }
1890cdf0e10cSrcweir             }
1891cdf0e10cSrcweir             // Disable OOoImprovement page if not enabled
1892cdf0e10cSrcweir             if( RID_SVXPAGE_IMPROVEMENT == nPageId )
1893cdf0e10cSrcweir             {
1894cdf0e10cSrcweir                 continue;
1895cdf0e10cSrcweir             }
1896cdf0e10cSrcweir             if ( nPageId != RID_SVXPAGE_SSO || isSSOEnabled )
1897cdf0e10cSrcweir             {
1898cdf0e10cSrcweir                 AddTabPage( nPageId, sNewTitle, nGroup );
1899cdf0e10cSrcweir             }
1900cdf0e10cSrcweir         }
1901cdf0e10cSrcweir         // private iteration hack for Improvement Program
1902cdf0e10cSrcweir         // hack for OOo 3.1
1903cdf0e10cSrcweir         // should not be in found in any later release
1904cdf0e10cSrcweir         for(bool bOnce = false; bOnce==false; bOnce=true)
1905cdf0e10cSrcweir         {
1906cdf0e10cSrcweir             String sNewTitle = C2U("Improvement Program");
1907cdf0e10cSrcweir             {
1908cdf0e10cSrcweir                 SvxImprovementPage aTempTabPage(this);
1909cdf0e10cSrcweir                 sNewTitle = aTempTabPage.GetTitleText();
1910cdf0e10cSrcweir             }
1911cdf0e10cSrcweir             nPageId = RID_SVXPAGE_IMPROVEMENT;
1912cdf0e10cSrcweir             if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1913cdf0e10cSrcweir                 continue;
1914cdf0e10cSrcweir             // Disable OOoImprovement page if not enabled
1915cdf0e10cSrcweir             {
1916cdf0e10cSrcweir                 const ::rtl::OUString sService = C2U("com.sun.star.oooimprovement.CoreController");
1917cdf0e10cSrcweir                 try
1918cdf0e10cSrcweir                 {
1919cdf0e10cSrcweir                     Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1920cdf0e10cSrcweir                     Reference < ::com::sun::star::oooimprovement::XCoreController > xService( xFactory->createInstance( sService ), UNO_QUERY );
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir                     if( ! xService.is() )
1923cdf0e10cSrcweir                         continue;
1924cdf0e10cSrcweir                     if( ! xService->showBuiltinOptionsPage(1))
1925cdf0e10cSrcweir                         continue;
1926cdf0e10cSrcweir                 }
1927cdf0e10cSrcweir                 catch ( ::com::sun::star::loader::CannotActivateFactoryException& )
1928cdf0e10cSrcweir                 {
1929cdf0e10cSrcweir                     continue;
1930cdf0e10cSrcweir                 }
1931cdf0e10cSrcweir             }
1932cdf0e10cSrcweir             if ( nPageId != RID_SVXPAGE_SSO || isSSOEnabled )
1933cdf0e10cSrcweir             {
1934cdf0e10cSrcweir                 AddTabPage( nPageId, sNewTitle, nGroup );
1935cdf0e10cSrcweir             }
1936cdf0e10cSrcweir         }
1937cdf0e10cSrcweir     }
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir     // Load and Save options
1940cdf0e10cSrcweir     if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) )
1941cdf0e10cSrcweir     {
1942cdf0e10cSrcweir         ResStringArray& rFilterArray = aDlgResource.GetFilterArray();
1943cdf0e10cSrcweir         setGroupName( C2U("LoadSave"), rFilterArray.GetString(0) );
1944cdf0e10cSrcweir         nGroup = AddGroup( rFilterArray.GetString(0), 0, 0, SID_FILTER_DLG );
1945cdf0e10cSrcweir         for ( i = 1; i < rFilterArray.Count(); ++i )
1946cdf0e10cSrcweir         {
1947cdf0e10cSrcweir             nPageId = (sal_uInt16)rFilterArray.GetValue(i);
1948cdf0e10cSrcweir             if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1949cdf0e10cSrcweir                 AddTabPage( nPageId, rFilterArray.GetString(i), nGroup );
1950cdf0e10cSrcweir         }
1951cdf0e10cSrcweir     }
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir     // Language options
1954cdf0e10cSrcweir     SvtLanguageOptions aLanguageOptions;
1955cdf0e10cSrcweir     if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) )
1956cdf0e10cSrcweir     {
1957cdf0e10cSrcweir         ResStringArray& rLangArray = aDlgResource.GetLangArray();
1958cdf0e10cSrcweir         setGroupName( C2U("LanguageSettings"), rLangArray.GetString(0) );
1959cdf0e10cSrcweir         nGroup = AddGroup( rLangArray.GetString(0), 0, 0, SID_LANGUAGE_OPTIONS );
1960cdf0e10cSrcweir         for ( i = 1; i < rLangArray.Count(); ++i )
1961cdf0e10cSrcweir         {
1962cdf0e10cSrcweir             nPageId = (sal_uInt16)rLangArray.GetValue(i);
1963cdf0e10cSrcweir             if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1964cdf0e10cSrcweir                 continue;
1965cdf0e10cSrcweir             if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || aLanguageOptions.IsJapaneseFindEnabled() ) &&
1966cdf0e10cSrcweir                  ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId    || aLanguageOptions.IsAsianTypographyEnabled() ) &&
1967cdf0e10cSrcweir                  ( RID_SVXPAGE_OPTIONS_CTL != nPageId     || aLanguageOptions.IsCTLFontEnabled() ) )
1968cdf0e10cSrcweir                 AddTabPage( nPageId, rLangArray.GetString(i), nGroup );
1969cdf0e10cSrcweir         }
1970cdf0e10cSrcweir     }
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir 
1973cdf0e10cSrcweir     rtl::OUString aFactory = getCurrentFactory_Impl( _xFrame );
1974cdf0e10cSrcweir     rtl::OUString sTemp = GetModuleIdentifier( comphelper::getProcessServiceFactory(), _xFrame );
1975cdf0e10cSrcweir     DBG_ASSERT( sTemp == aFactory, "S H I T!!!" );
1976cdf0e10cSrcweir 
1977cdf0e10cSrcweir     // Writer and Writer/Web options
1978cdf0e10cSrcweir     sal_Bool bHasAnyFilter = sal_False;
1979cdf0e10cSrcweir     SvtModuleOptions aModuleOpt;
1980cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
1981cdf0e10cSrcweir     {
1982cdf0e10cSrcweir         // Textdokument
1983cdf0e10cSrcweir         bHasAnyFilter = sal_True;
1984cdf0e10cSrcweir         ResStringArray& rTextArray = aDlgResource.GetTextArray();
1985cdf0e10cSrcweir         if (   aFactory.equalsAscii( "com.sun.star.text.TextDocument" )
1986cdf0e10cSrcweir             || aFactory.equalsAscii( "com.sun.star.text.WebDocument" )
1987cdf0e10cSrcweir             || aFactory.equalsAscii( "com.sun.star.text.GlobalDocument" ) )
1988cdf0e10cSrcweir         {
1989cdf0e10cSrcweir             SfxModule* pSwMod = (*(SfxModule**) GetAppData(SHL_WRITER));
1990cdf0e10cSrcweir             if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS, aOptionsDlgOpt ) )
1991cdf0e10cSrcweir             {
1992cdf0e10cSrcweir                 if ( aFactory.equalsAscii( "com.sun.star.text.WebDocument" ) )
1993cdf0e10cSrcweir                     setGroupName( C2U("WriterWeb"), rTextArray.GetString(0) );
1994cdf0e10cSrcweir                 else
1995cdf0e10cSrcweir                     setGroupName( C2U("Writer"), rTextArray.GetString(0) );
1996cdf0e10cSrcweir                 nGroup = AddGroup(rTextArray.GetString(0), pSwMod, pSwMod, SID_SW_EDITOPTIONS );
1997cdf0e10cSrcweir                 for ( i = 1; i < rTextArray.Count(); ++i )
1998cdf0e10cSrcweir                 {
1999cdf0e10cSrcweir                     nPageId = (sal_uInt16)rTextArray.GetValue(i);
2000cdf0e10cSrcweir                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2001cdf0e10cSrcweir                         continue;
2002cdf0e10cSrcweir                     if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || aLanguageOptions.IsCJKFontEnabled() ) &&
2003cdf0e10cSrcweir                          ( RID_SW_TP_STD_FONT_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) &&
2004cdf0e10cSrcweir                          ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) )
2005cdf0e10cSrcweir                         AddTabPage( nPageId, rTextArray.GetString(i), nGroup );
2006cdf0e10cSrcweir                 }
2007cdf0e10cSrcweir #ifdef DBG_UTIL
2008cdf0e10cSrcweir                 AddTabPage( RID_SW_TP_OPTTEST_PAGE, String::CreateFromAscii("Interner Test"), nGroup );
2009cdf0e10cSrcweir #endif
2010cdf0e10cSrcweir             }
2011cdf0e10cSrcweir 
2012cdf0e10cSrcweir             // HTML-Dokument
2013cdf0e10cSrcweir             if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) )
2014cdf0e10cSrcweir             {
2015cdf0e10cSrcweir                 ResStringArray& rHTMLArray = aDlgResource.GetHTMLArray();
2016cdf0e10cSrcweir                 nGroup = AddGroup(rHTMLArray.GetString(0), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS );
2017cdf0e10cSrcweir                 for( i = 1; i < rHTMLArray.Count(); ++i )
2018cdf0e10cSrcweir                 {
2019cdf0e10cSrcweir                     nPageId = (sal_uInt16)rHTMLArray.GetValue(i);
2020cdf0e10cSrcweir                     if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2021cdf0e10cSrcweir                         AddTabPage( nPageId, rHTMLArray.GetString(i), nGroup );
2022cdf0e10cSrcweir                 }
2023cdf0e10cSrcweir #ifdef DBG_UTIL
2024cdf0e10cSrcweir                 AddTabPage( RID_SW_TP_OPTTEST_PAGE, String::CreateFromAscii("Interner Test"), nGroup );
2025cdf0e10cSrcweir #endif
2026cdf0e10cSrcweir             }
2027cdf0e10cSrcweir         }
2028cdf0e10cSrcweir     }
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir     // Calc options
2031cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
2032cdf0e10cSrcweir     {
2033cdf0e10cSrcweir         bHasAnyFilter = sal_True;
2034cdf0e10cSrcweir         if ( aFactory.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ))
2035cdf0e10cSrcweir         {
2036cdf0e10cSrcweir             if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS, aOptionsDlgOpt ) )
2037cdf0e10cSrcweir             {
2038cdf0e10cSrcweir                 ResStringArray& rCalcArray = aDlgResource.GetCalcArray();
2039cdf0e10cSrcweir                 SfxModule* pScMod = ( *( SfxModule** ) GetAppData( SHL_CALC ) );
2040cdf0e10cSrcweir                 setGroupName( C2U("Calc"), rCalcArray.GetString(0) );
2041cdf0e10cSrcweir                 nGroup = AddGroup( rCalcArray.GetString( 0 ), pScMod, pScMod, SID_SC_EDITOPTIONS );
2042cdf0e10cSrcweir                 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rCalcArray.Count() );
2043cdf0e10cSrcweir                 for ( i = 1; i < nCount; ++i )
2044cdf0e10cSrcweir                 {
2045cdf0e10cSrcweir                     nPageId = (sal_uInt16)rCalcArray.GetValue(i);
2046cdf0e10cSrcweir                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2047cdf0e10cSrcweir                         continue;
2048cdf0e10cSrcweir //                  if( bCTL || nId != RID_OFA_TP_INTERNATIONAL )
2049cdf0e10cSrcweir //                  #103755# if an international tabpage is need one day, this should be used again... ;-)
2050cdf0e10cSrcweir                     if ( nPageId != RID_OFA_TP_INTERNATIONAL )
2051cdf0e10cSrcweir                         AddTabPage( nPageId, rCalcArray.GetString( i ), nGroup );
2052cdf0e10cSrcweir                 }
2053cdf0e10cSrcweir             }
2054cdf0e10cSrcweir         }
2055cdf0e10cSrcweir     }
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir     // Impress options
2058cdf0e10cSrcweir     SfxModule* pSdMod = ( *( SfxModule** ) GetAppData( SHL_DRAW ) );
2059cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
2060cdf0e10cSrcweir     {
2061cdf0e10cSrcweir         bHasAnyFilter = sal_True;
2062cdf0e10cSrcweir         if ( aFactory.equalsAscii( "com.sun.star.presentation.PresentationDocument" ))
2063cdf0e10cSrcweir         {
2064cdf0e10cSrcweir             if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS, aOptionsDlgOpt ) )
2065cdf0e10cSrcweir             {
2066cdf0e10cSrcweir                 ResStringArray& rImpressArray = aDlgResource.GetImpressArray();
2067cdf0e10cSrcweir                 setGroupName( C2U("Impress"), rImpressArray.GetString(0) );
2068cdf0e10cSrcweir                 nGroup = AddGroup( rImpressArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_EDITOPTIONS );
2069cdf0e10cSrcweir                 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled();
2070cdf0e10cSrcweir                 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rImpressArray.Count() );
2071cdf0e10cSrcweir                 for ( i = 1; i < nCount; ++i )
2072cdf0e10cSrcweir                 {
2073cdf0e10cSrcweir                     nPageId = (sal_uInt16)rImpressArray.GetValue(i);
2074cdf0e10cSrcweir                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2075cdf0e10cSrcweir                         continue;
2076cdf0e10cSrcweir                     if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_IMPR )
2077cdf0e10cSrcweir                         AddTabPage( nPageId, rImpressArray.GetString(i), nGroup );
2078cdf0e10cSrcweir                 }
2079cdf0e10cSrcweir             }
2080cdf0e10cSrcweir         }
2081cdf0e10cSrcweir     }
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir     // Draw options
2084cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
2085cdf0e10cSrcweir     {
2086cdf0e10cSrcweir         if ( aFactory.equalsAscii( "com.sun.star.drawing.DrawingDocument" ))
2087cdf0e10cSrcweir         {
2088cdf0e10cSrcweir             if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS, aOptionsDlgOpt ) )
2089cdf0e10cSrcweir             {
2090cdf0e10cSrcweir                 ResStringArray& rDrawArray = aDlgResource.GetDrawArray();
2091cdf0e10cSrcweir                 setGroupName( C2U("Draw"), rDrawArray.GetString(0) );
2092cdf0e10cSrcweir                 nGroup = AddGroup( rDrawArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS );
2093cdf0e10cSrcweir                 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled();
2094cdf0e10cSrcweir                 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rDrawArray.Count() );
2095cdf0e10cSrcweir                 for ( i = 1; i < nCount; ++i )
2096cdf0e10cSrcweir                 {
2097cdf0e10cSrcweir                     nPageId = (sal_uInt16)rDrawArray.GetValue(i);
2098cdf0e10cSrcweir                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2099cdf0e10cSrcweir                         continue;
2100cdf0e10cSrcweir                     if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_SD )
2101cdf0e10cSrcweir                         AddTabPage( nPageId, rDrawArray.GetString(i), nGroup );
2102cdf0e10cSrcweir                 }
2103cdf0e10cSrcweir             }
2104cdf0e10cSrcweir         }
2105cdf0e10cSrcweir     }
2106cdf0e10cSrcweir 
2107cdf0e10cSrcweir     // Math options
2108cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
2109cdf0e10cSrcweir     {
2110cdf0e10cSrcweir         if ( aFactory.equalsAscii( "com.sun.star.formula.FormulaProperties" ))
2111cdf0e10cSrcweir         {
2112cdf0e10cSrcweir             if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS, aOptionsDlgOpt ) )
2113cdf0e10cSrcweir             {
2114cdf0e10cSrcweir                 ResStringArray& rStarMathArray = aDlgResource.GetStarMathArray();
2115cdf0e10cSrcweir                 SfxModule* pSmMod = (*(SfxModule**) GetAppData(SHL_SM));
2116cdf0e10cSrcweir                 setGroupName( C2U("Math"), rStarMathArray.GetString(0) );
2117cdf0e10cSrcweir                 nGroup = AddGroup(rStarMathArray.GetString(0), pSmMod, pSmMod, SID_SM_EDITOPTIONS );
2118cdf0e10cSrcweir                 for ( i = 1; i < rStarMathArray.Count(); ++i )
2119cdf0e10cSrcweir                 {
2120cdf0e10cSrcweir                     nPageId = (sal_uInt16)rStarMathArray.GetValue(i);
2121cdf0e10cSrcweir                     if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2122cdf0e10cSrcweir                         AddTabPage( nPageId, rStarMathArray.GetString(i), nGroup );
2123cdf0e10cSrcweir                 }
2124cdf0e10cSrcweir             }
2125cdf0e10cSrcweir         }
2126cdf0e10cSrcweir     }
2127cdf0e10cSrcweir 
2128cdf0e10cSrcweir     // Database - needed only if there is an application which integrates with databases
2129cdf0e10cSrcweir     if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) &&
2130cdf0e10cSrcweir         (   aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE )
2131cdf0e10cSrcweir         ||  aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER )
2132cdf0e10cSrcweir         ||  aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC )
2133cdf0e10cSrcweir         ) )
2134cdf0e10cSrcweir     {
2135cdf0e10cSrcweir         ResStringArray& rDSArray = aDlgResource.GetDatasourcesArray();
2136cdf0e10cSrcweir         setGroupName( C2U("Base"), rDSArray.GetString(0) );
2137cdf0e10cSrcweir         nGroup = AddGroup( rDSArray.GetString(0), 0, NULL, SID_SB_STARBASEOPTIONS );
2138cdf0e10cSrcweir         for ( i = 1; i < rDSArray.Count(); ++i )
2139cdf0e10cSrcweir         {
2140cdf0e10cSrcweir             nPageId = (sal_uInt16)rDSArray.GetValue(i);
2141cdf0e10cSrcweir             if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2142cdf0e10cSrcweir                 AddTabPage( nPageId, rDSArray.GetString(i), nGroup );
2143cdf0e10cSrcweir         }
2144cdf0e10cSrcweir     }
2145cdf0e10cSrcweir 
2146cdf0e10cSrcweir     // Chart options (always installed and active)
2147cdf0e10cSrcweir     if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) )
2148cdf0e10cSrcweir     {
2149cdf0e10cSrcweir         ResStringArray& rChartArray = aDlgResource.GetChartArray();
2150cdf0e10cSrcweir         setGroupName( C2U("Charts"), rChartArray.GetString(0) );
2151cdf0e10cSrcweir         nGroup = AddGroup( rChartArray.GetString(0), 0, 0, SID_SCH_EDITOPTIONS );
2152cdf0e10cSrcweir         for ( i = 1; i < rChartArray.Count(); ++i )
2153cdf0e10cSrcweir         {
2154cdf0e10cSrcweir             nPageId = (sal_uInt16)rChartArray.GetValue(i);
2155cdf0e10cSrcweir             if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2156cdf0e10cSrcweir                AddTabPage( nPageId, rChartArray.GetString(i), nGroup );
2157cdf0e10cSrcweir         }
2158cdf0e10cSrcweir     }
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir     // Internet options
2161cdf0e10cSrcweir     if ( !lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) )
2162cdf0e10cSrcweir     {
2163cdf0e10cSrcweir         ResStringArray& rInetArray = aDlgResource.GetInetArray();
2164cdf0e10cSrcweir         setGroupName( C2U("Internet"), rInetArray.GetString(0) );
2165cdf0e10cSrcweir         nGroup = AddGroup(rInetArray.GetString(0), 0, 0, SID_INET_DLG );
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir         for ( i = 1; i < rInetArray.Count(); ++i )
2168cdf0e10cSrcweir         {
2169cdf0e10cSrcweir             nPageId = (sal_uInt16)rInetArray.GetValue(i);
2170cdf0e10cSrcweir             if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2171cdf0e10cSrcweir                 continue;
2172cdf0e10cSrcweir #if defined WNT
2173cdf0e10cSrcweir             // Disable E-mail tab-page on Windows
2174cdf0e10cSrcweir             if ( nPageId == RID_SVXPAGE_INET_MAIL )
2175cdf0e10cSrcweir                 continue;
2176cdf0e10cSrcweir #endif
2177cdf0e10cSrcweir             AddTabPage( nPageId, rInetArray.GetString(i), nGroup );
2178cdf0e10cSrcweir         }
2179cdf0e10cSrcweir     }
2180cdf0e10cSrcweir 
2181cdf0e10cSrcweir /*!!!
2182cdf0e10cSrcweir     ResizeTreeLB();
2183cdf0e10cSrcweir     ActivateLastSelection();
2184cdf0e10cSrcweir  */
2185cdf0e10cSrcweir }
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir namespace
2188cdf0e10cSrcweir {
MoveControl(Control & _rCtrl,long _nDeltaPixel)2189cdf0e10cSrcweir 	void MoveControl( Control& _rCtrl, long _nDeltaPixel )
2190cdf0e10cSrcweir 	{
2191cdf0e10cSrcweir 		Point	aPt( _rCtrl.GetPosPixel() );
2192cdf0e10cSrcweir 		aPt.X() += _nDeltaPixel;
2193cdf0e10cSrcweir 		_rCtrl.SetPosPixel( aPt );
2194cdf0e10cSrcweir 	}
2195cdf0e10cSrcweir }
2196cdf0e10cSrcweir 
ResizeTreeLB(void)2197cdf0e10cSrcweir void OfaTreeOptionsDialog::ResizeTreeLB( void )
2198cdf0e10cSrcweir {
2199cdf0e10cSrcweir     const long  nMax = aHiddenGB.GetSizePixel().Width() * 42 / 100;
2200cdf0e10cSrcweir                                             // don't ask where 42 comes from... but it looks / feels ok ;-)
2201cdf0e10cSrcweir     long        nDelta = 50;                // min.
2202cdf0e10cSrcweir     sal_uInt16      nDepth = 0;
2203cdf0e10cSrcweir     const long  nIndent0 = PixelToLogic( Size( 28, 0 ) ).Width();
2204cdf0e10cSrcweir     const long  nIndent1 = PixelToLogic( Size( 52, 0 ) ).Width();
2205cdf0e10cSrcweir 
2206cdf0e10cSrcweir 	SvTreeList*			pTreeList = aTreeLB.GetModel();
2207cdf0e10cSrcweir 	DBG_ASSERT( pTreeList, "-OfaTreeOptionsDialog::ResizeTreeLB(): no model, no cookies!" );
2208cdf0e10cSrcweir 
2209cdf0e10cSrcweir 	SvListEntry*		pEntry = pTreeList->First();
2210cdf0e10cSrcweir 	while( pEntry )
2211cdf0e10cSrcweir 	{
2212cdf0e10cSrcweir         long n = aTreeLB.GetTextWidth( aTreeLB.GetEntryText( static_cast< SvLBoxEntry* >( pEntry ) ) );
2213cdf0e10cSrcweir 		n += ( nDepth == 0 )? nIndent0 : nIndent1;
2214cdf0e10cSrcweir 
2215cdf0e10cSrcweir 		if( n > nDelta )
2216cdf0e10cSrcweir 			nDelta = n;
2217cdf0e10cSrcweir 
2218cdf0e10cSrcweir 		pEntry = pTreeList->Next( pEntry, &nDepth );
2219cdf0e10cSrcweir 	}
2220cdf0e10cSrcweir 
2221cdf0e10cSrcweir 	nDelta = LogicToPixel( Size( nDelta + 3, 0 ) ).Width();			// + extra space [logic]
2222cdf0e10cSrcweir 	nDelta += GetSettings().GetStyleSettings().GetScrollBarSize();	// + scroll bar, in case it's needed
2223cdf0e10cSrcweir 
2224cdf0e10cSrcweir 	if( nDelta > nMax )
2225cdf0e10cSrcweir 		nDelta = nMax;
2226cdf0e10cSrcweir 
2227cdf0e10cSrcweir 	// starting resizing with this
2228cdf0e10cSrcweir 	Size			aSize( GetSizePixel() );
2229cdf0e10cSrcweir 	aSize.Width() += nDelta;
2230cdf0e10cSrcweir 	SetSizePixel( aSize );
2231cdf0e10cSrcweir 
2232cdf0e10cSrcweir 	// resize treelistbox
2233cdf0e10cSrcweir 	aSize = aTreeLB.GetSizePixel();
2234cdf0e10cSrcweir 	aSize.Width() += nDelta;
2235cdf0e10cSrcweir 	aTreeLB.SetSizePixel( aSize );
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir 	// ... and move depending controls
2238cdf0e10cSrcweir 	MoveControl( aOkPB, nDelta );
2239cdf0e10cSrcweir 	MoveControl( aCancelPB, nDelta );
2240cdf0e10cSrcweir 	MoveControl( aHelpPB, nDelta );
2241cdf0e10cSrcweir 	MoveControl( aBackPB, nDelta );
2242cdf0e10cSrcweir 	MoveControl( aHiddenGB, nDelta );
2243cdf0e10cSrcweir 	MoveControl( aPageTitleFT, nDelta );
2244cdf0e10cSrcweir 	MoveControl( aLine1FL, nDelta );
2245cdf0e10cSrcweir 	MoveControl( aHelpFT, nDelta );
2246cdf0e10cSrcweir 	MoveControl( aHelpImg, nDelta );
2247cdf0e10cSrcweir }
2248cdf0e10cSrcweir 
isNodeActive(OptionsNode * pNode,Module * pModule)2249cdf0e10cSrcweir bool isNodeActive( OptionsNode* pNode, Module* pModule )
2250cdf0e10cSrcweir {
2251cdf0e10cSrcweir     if ( pNode )
2252cdf0e10cSrcweir     {
2253cdf0e10cSrcweir         // Node for all modules actine?
2254cdf0e10cSrcweir         if ( pNode->m_bAllModules )
2255cdf0e10cSrcweir             return true;
2256cdf0e10cSrcweir 
2257cdf0e10cSrcweir         // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
2258cdf0e10cSrcweir         if ( getGroupName( pNode->m_sId, false ).Len() > 0 )
2259cdf0e10cSrcweir             return true;
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir         // no module -> not active
2262cdf0e10cSrcweir         if ( !pModule )
2263cdf0e10cSrcweir             return false;
2264cdf0e10cSrcweir 
2265cdf0e10cSrcweir         // search node in active module
2266cdf0e10cSrcweir         if ( pModule->m_bActive )
2267cdf0e10cSrcweir         {
2268cdf0e10cSrcweir             for ( sal_uInt32 j = 0; j < pModule->m_aNodeList.size(); ++j )
2269cdf0e10cSrcweir                 if ( pModule->m_aNodeList[j]->m_sId == pNode->m_sId )
2270cdf0e10cSrcweir                     return true;
2271cdf0e10cSrcweir         }
2272cdf0e10cSrcweir     }
2273cdf0e10cSrcweir     return false;
2274cdf0e10cSrcweir }
2275cdf0e10cSrcweir 
LoadExtensionOptions(const rtl::OUString & rExtensionId)2276cdf0e10cSrcweir void OfaTreeOptionsDialog::LoadExtensionOptions( const rtl::OUString& rExtensionId )
2277cdf0e10cSrcweir {
2278cdf0e10cSrcweir     Module* pModule = NULL;
2279cdf0e10cSrcweir     Reference< XMultiServiceFactory > xMSFac = comphelper::getProcessServiceFactory();
2280cdf0e10cSrcweir     // open optionsdialog.xcu
2281cdf0e10cSrcweir     Reference< XNameAccess > xRoot(
2282cdf0e10cSrcweir         ::comphelper::ConfigurationHelper::openConfig(
2283cdf0e10cSrcweir             xMSFac, C2U("org.openoffice.Office.OptionsDialog"),
2284cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::E_READONLY ), UNO_QUERY );
2285cdf0e10cSrcweir     DBG_ASSERT( xRoot.is(), "OfaTreeOptionsDialog::LoadExtensionOptions(): no config" );
2286cdf0e10cSrcweir     // when called by Tools - Options then load nodes of active module
2287cdf0e10cSrcweir     if ( rExtensionId.getLength() == 0 )
2288cdf0e10cSrcweir         pModule = LoadModule( GetModuleIdentifier( xMSFac, Reference< XFrame >() ), xRoot );
2289cdf0e10cSrcweir 
2290cdf0e10cSrcweir     VectorOfNodes aNodeList;
2291cdf0e10cSrcweir     LoadNodes( xRoot, pModule, rExtensionId, aNodeList );
2292cdf0e10cSrcweir     InsertNodes( aNodeList );
2293cdf0e10cSrcweir }
2294cdf0e10cSrcweir 
GetModuleIdentifier(const Reference<XMultiServiceFactory> & xMFac,const Reference<XFrame> & rFrame)2295cdf0e10cSrcweir rtl::OUString OfaTreeOptionsDialog::GetModuleIdentifier(
2296cdf0e10cSrcweir     const Reference< XMultiServiceFactory >& xMFac, const Reference< XFrame >& rFrame )
2297cdf0e10cSrcweir {
2298cdf0e10cSrcweir     rtl::OUString sModule;
2299cdf0e10cSrcweir     Reference < XFrame > xCurrentFrame( rFrame );
2300cdf0e10cSrcweir     Reference < XModuleManager > xModuleManager( xMFac->createInstance(
2301cdf0e10cSrcweir         C2U("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
2302cdf0e10cSrcweir 
2303cdf0e10cSrcweir     if ( !xCurrentFrame.is() )
2304cdf0e10cSrcweir     {
2305cdf0e10cSrcweir         Reference < XDesktop > xDesktop( xMFac->createInstance(
2306cdf0e10cSrcweir             C2U("com.sun.star.frame.Desktop") ), UNO_QUERY );
2307cdf0e10cSrcweir         if ( xDesktop.is() )
2308cdf0e10cSrcweir             xCurrentFrame = xDesktop->getCurrentFrame();
2309cdf0e10cSrcweir     }
2310cdf0e10cSrcweir 
2311cdf0e10cSrcweir     if ( xCurrentFrame.is() && xModuleManager.is() )
2312cdf0e10cSrcweir     {
2313cdf0e10cSrcweir         try
2314cdf0e10cSrcweir         {
2315cdf0e10cSrcweir             sModule = xModuleManager->identify( xCurrentFrame );
2316cdf0e10cSrcweir         }
2317cdf0e10cSrcweir         catch ( ::com::sun::star::frame::UnknownModuleException& )
2318cdf0e10cSrcweir         {
2319cdf0e10cSrcweir             DBG_WARNING( "OfaTreeOptionsDialog::GetModuleIdentifier(): unknown module" );
2320cdf0e10cSrcweir         }
2321cdf0e10cSrcweir         catch ( Exception& )
2322cdf0e10cSrcweir         {
2323cdf0e10cSrcweir             DBG_ERRORFILE( "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()" );
2324cdf0e10cSrcweir         }
2325cdf0e10cSrcweir     }
2326cdf0e10cSrcweir     return sModule;
2327cdf0e10cSrcweir }
2328cdf0e10cSrcweir 
LoadModule(const rtl::OUString & rModuleIdentifier,const Reference<XNameAccess> & xRoot)2329cdf0e10cSrcweir Module* OfaTreeOptionsDialog::LoadModule(
2330cdf0e10cSrcweir     const rtl::OUString& rModuleIdentifier, const Reference< XNameAccess >& xRoot )
2331cdf0e10cSrcweir {
2332cdf0e10cSrcweir     Module* pModule = NULL;
2333cdf0e10cSrcweir     Reference< XNameAccess > xSet;
2334cdf0e10cSrcweir 
2335cdf0e10cSrcweir     if ( xRoot->hasByName( C2U("Modules") ) )
2336cdf0e10cSrcweir     {
2337cdf0e10cSrcweir         xRoot->getByName( C2U("Modules") ) >>= xSet;
2338cdf0e10cSrcweir         if ( xSet.is() )
2339cdf0e10cSrcweir         {
2340cdf0e10cSrcweir             Sequence< rtl::OUString > seqNames = xSet->getElementNames();
2341cdf0e10cSrcweir             for ( int i = 0; i < seqNames.getLength(); ++i )
2342cdf0e10cSrcweir             {
2343cdf0e10cSrcweir                 rtl::OUString sModule( seqNames[i] );
2344cdf0e10cSrcweir                 if ( rModuleIdentifier == sModule )
2345cdf0e10cSrcweir                 {
2346cdf0e10cSrcweir                     // current active module found
2347cdf0e10cSrcweir                     pModule = new Module( sModule );
2348cdf0e10cSrcweir                     pModule->m_bActive = true;
2349cdf0e10cSrcweir 
2350cdf0e10cSrcweir                     Reference< XNameAccess > xModAccess;
2351cdf0e10cSrcweir                     xSet->getByName( seqNames[i] ) >>= xModAccess;
2352cdf0e10cSrcweir                     if ( xModAccess.is() )
2353cdf0e10cSrcweir                     {
2354cdf0e10cSrcweir                         // load the nodes of this module
2355cdf0e10cSrcweir                         Reference< XNameAccess > xNodeAccess;
2356cdf0e10cSrcweir                         xModAccess->getByName( C2U("Nodes") ) >>= xNodeAccess;
2357cdf0e10cSrcweir                         if ( xNodeAccess.is() )
2358cdf0e10cSrcweir                         {
2359cdf0e10cSrcweir                             Sequence< rtl::OUString > xTemp = xNodeAccess->getElementNames();
2360cdf0e10cSrcweir                             Reference< XNameAccess > xAccess;
2361cdf0e10cSrcweir                             sal_Int32 nIndex = -1;
2362cdf0e10cSrcweir                             for ( int x = 0; x < xTemp.getLength(); ++x )
2363cdf0e10cSrcweir                             {
2364cdf0e10cSrcweir                                 xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
2365cdf0e10cSrcweir                                 if ( xAccess.is() )
2366cdf0e10cSrcweir                                 {
2367cdf0e10cSrcweir                                     xAccess->getByName( C2U("Index") ) >>= nIndex;
2368cdf0e10cSrcweir                                     if ( nIndex < 0 )
2369cdf0e10cSrcweir                                         // append nodes with index < 0
2370cdf0e10cSrcweir                                         pModule->m_aNodeList.push_back(
2371cdf0e10cSrcweir                                             new OrderedEntry( nIndex, xTemp[x] ) );
2372cdf0e10cSrcweir                                     else
2373cdf0e10cSrcweir                                     {
2374cdf0e10cSrcweir                                         // search position of the node
2375cdf0e10cSrcweir                                         sal_uInt32 y = 0;
2376cdf0e10cSrcweir                                         for ( ; y < pModule->m_aNodeList.size(); ++y )
2377cdf0e10cSrcweir                                         {
2378cdf0e10cSrcweir                                             sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
2379cdf0e10cSrcweir                                             if ( nNodeIdx < 0 || nNodeIdx > nIndex )
2380cdf0e10cSrcweir                                                 break;
2381cdf0e10cSrcweir                                         }
2382cdf0e10cSrcweir                                         // and insert the node on this position
2383cdf0e10cSrcweir                                         pModule->m_aNodeList.insert(
2384cdf0e10cSrcweir                                             pModule->m_aNodeList.begin() + y,
2385cdf0e10cSrcweir                                             new OrderedEntry( nIndex, xTemp[x] ) );
2386cdf0e10cSrcweir                                     }
2387cdf0e10cSrcweir                                 }
2388cdf0e10cSrcweir                             }
2389cdf0e10cSrcweir                         }
2390cdf0e10cSrcweir                     }
2391cdf0e10cSrcweir                 }
2392cdf0e10cSrcweir             }
2393cdf0e10cSrcweir         }
2394cdf0e10cSrcweir     }
2395cdf0e10cSrcweir     return pModule;
2396cdf0e10cSrcweir }
2397cdf0e10cSrcweir 
LoadNodes(const Reference<XNameAccess> & xRoot,Module * pModule,const rtl::OUString & rExtensionId,VectorOfNodes & rOutNodeList)2398cdf0e10cSrcweir void OfaTreeOptionsDialog::LoadNodes(
2399cdf0e10cSrcweir     const Reference< XNameAccess >& xRoot, Module* pModule,
2400cdf0e10cSrcweir     const rtl::OUString& rExtensionId, VectorOfNodes& rOutNodeList )
2401cdf0e10cSrcweir {
2402cdf0e10cSrcweir     Reference< XNameAccess > xSet;
2403cdf0e10cSrcweir     if ( xRoot->hasByName( C2U("Nodes") ) )
2404cdf0e10cSrcweir     {
2405cdf0e10cSrcweir         xRoot->getByName( C2U("Nodes") ) >>= xSet;
2406cdf0e10cSrcweir         if ( xSet.is() )
2407cdf0e10cSrcweir         {
2408cdf0e10cSrcweir             VectorOfNodes aNodeList;
2409cdf0e10cSrcweir             Sequence< rtl::OUString > seqNames = xSet->getElementNames();
2410cdf0e10cSrcweir 
2411cdf0e10cSrcweir             for ( int i = 0; i < seqNames.getLength(); ++i )
2412cdf0e10cSrcweir             {
2413cdf0e10cSrcweir                 String sGroupName( seqNames[i] );
2414cdf0e10cSrcweir                 Reference< XNameAccess > xNodeAccess;
2415cdf0e10cSrcweir                 xSet->getByName( seqNames[i] ) >>= xNodeAccess;
2416cdf0e10cSrcweir 
2417cdf0e10cSrcweir                 if ( xNodeAccess.is() )
2418cdf0e10cSrcweir                 {
2419cdf0e10cSrcweir                     rtl::OUString sNodeId, sLabel, sPageURL, sGroupId;
2420cdf0e10cSrcweir                     bool bAllModules = false;
2421cdf0e10cSrcweir                     sal_Int32 nGroupIndex = 0;
2422cdf0e10cSrcweir 
2423cdf0e10cSrcweir                     sNodeId = seqNames[i];
2424cdf0e10cSrcweir                     xNodeAccess->getByName( C2U("Label") ) >>= sLabel;
2425cdf0e10cSrcweir                     xNodeAccess->getByName( C2U("OptionsPage") ) >>= sPageURL;
2426cdf0e10cSrcweir                     xNodeAccess->getByName( C2U("AllModules") ) >>= bAllModules;
2427cdf0e10cSrcweir                     xNodeAccess->getByName( C2U("GroupId") ) >>= sGroupId;
2428cdf0e10cSrcweir                     xNodeAccess->getByName( C2U("GroupIndex") ) >>= nGroupIndex;
2429cdf0e10cSrcweir 
2430cdf0e10cSrcweir                     if ( sLabel.getLength() == 0 )
2431cdf0e10cSrcweir                         sLabel = sGroupName;
2432cdf0e10cSrcweir                     String sTemp = getGroupName( sLabel, rExtensionId.getLength() > 0 );
2433cdf0e10cSrcweir                     if ( sTemp.Len() > 0 )
2434cdf0e10cSrcweir                         sLabel = sTemp;
2435cdf0e10cSrcweir                     OptionsNode* pNode =
2436cdf0e10cSrcweir                         new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex );
2437cdf0e10cSrcweir 
2438cdf0e10cSrcweir                     if ( !rExtensionId.getLength() && !isNodeActive( pNode, pModule ) )
2439cdf0e10cSrcweir                     {
2440cdf0e10cSrcweir                         delete pNode;
2441cdf0e10cSrcweir                         continue;
2442cdf0e10cSrcweir                     }
2443cdf0e10cSrcweir 
2444cdf0e10cSrcweir                     Reference< XNameAccess > xLeavesSet;
2445cdf0e10cSrcweir                     xNodeAccess->getByName( C2U( "Leaves" ) ) >>= xLeavesSet;
2446cdf0e10cSrcweir                     if ( xLeavesSet.is() )
2447cdf0e10cSrcweir                     {
2448cdf0e10cSrcweir                         Sequence< rtl::OUString > seqLeaves = xLeavesSet->getElementNames();
2449cdf0e10cSrcweir                         for ( int j = 0; j < seqLeaves.getLength(); ++j )
2450cdf0e10cSrcweir                         {
2451cdf0e10cSrcweir                             Reference< XNameAccess > xLeaveAccess;
2452cdf0e10cSrcweir                             xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir                             if ( xLeaveAccess.is() )
2455cdf0e10cSrcweir                             {
2456cdf0e10cSrcweir                                 rtl::OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
2457cdf0e10cSrcweir                                 sal_Int32 nLeafGrpIdx = 0;
2458cdf0e10cSrcweir 
2459cdf0e10cSrcweir                                 xLeaveAccess->getByName( C2U("Id") ) >>= sId;
2460cdf0e10cSrcweir                                 xLeaveAccess->getByName( C2U("Label") ) >>= sLeafLabel;
2461cdf0e10cSrcweir                                 xLeaveAccess->getByName( C2U("OptionsPage") ) >>= sLeafURL;
2462cdf0e10cSrcweir                                 xLeaveAccess->getByName( C2U("EventHandlerService") ) >>= sEventHdl;
2463cdf0e10cSrcweir                                 xLeaveAccess->getByName( C2U("GroupId") ) >>= sLeafGrpId;
2464cdf0e10cSrcweir                                 xLeaveAccess->getByName( C2U("GroupIndex") ) >>= nLeafGrpIdx;
2465cdf0e10cSrcweir 
2466cdf0e10cSrcweir                                 if ( !rExtensionId.getLength() || sId == rExtensionId )
2467cdf0e10cSrcweir                                 {
2468cdf0e10cSrcweir                                     OptionsLeaf* pLeaf = new OptionsLeaf(
2469cdf0e10cSrcweir                                         sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx );
2470cdf0e10cSrcweir 
2471cdf0e10cSrcweir                                     if ( sLeafGrpId.getLength() > 0 )
2472cdf0e10cSrcweir                                     {
2473cdf0e10cSrcweir                                         bool bAlreadyOpened = false;
2474cdf0e10cSrcweir                                         if ( pNode->m_aGroupedLeaves.size() > 0 )
2475cdf0e10cSrcweir                                         {
2476cdf0e10cSrcweir                                             for ( sal_uInt32 k = 0;
2477cdf0e10cSrcweir                                                     k < pNode->m_aGroupedLeaves.size(); ++k )
2478cdf0e10cSrcweir                                             {
2479cdf0e10cSrcweir                                                 if ( pNode->m_aGroupedLeaves[k].size() > 0 &&
2480cdf0e10cSrcweir                                                      pNode->m_aGroupedLeaves[k][0]->m_sGroupId
2481cdf0e10cSrcweir                                                         == sLeafGrpId )
2482cdf0e10cSrcweir                                                 {
2483cdf0e10cSrcweir                                                     sal_uInt32 l = 0;
2484cdf0e10cSrcweir                                                     for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l )
2485cdf0e10cSrcweir                                                     {
2486cdf0e10cSrcweir                                                         if ( pNode->m_aGroupedLeaves[k][l]->
2487cdf0e10cSrcweir                                                                 m_nGroupIndex >= nLeafGrpIdx )
2488cdf0e10cSrcweir                                                             break;
2489cdf0e10cSrcweir                                                     }
2490cdf0e10cSrcweir                                                     pNode->m_aGroupedLeaves[k].insert(
2491cdf0e10cSrcweir                                                         pNode->m_aGroupedLeaves[k].begin() + l, pLeaf );
2492cdf0e10cSrcweir                                                     bAlreadyOpened = true;
2493cdf0e10cSrcweir                                                     break;
2494cdf0e10cSrcweir                                                 }
2495cdf0e10cSrcweir                                             }
2496cdf0e10cSrcweir                                         }
2497cdf0e10cSrcweir                                         if ( !bAlreadyOpened )
2498cdf0e10cSrcweir                                         {
2499cdf0e10cSrcweir                                             VectorOfLeaves aGroupedLeaves;
2500cdf0e10cSrcweir                                             aGroupedLeaves.push_back( pLeaf );
2501cdf0e10cSrcweir                                             pNode->m_aGroupedLeaves.push_back( aGroupedLeaves );
2502cdf0e10cSrcweir                                         }
2503cdf0e10cSrcweir                                     }
2504cdf0e10cSrcweir                                     else
2505cdf0e10cSrcweir                                         pNode->m_aLeaves.push_back(
2506cdf0e10cSrcweir                                             new OptionsLeaf(
2507cdf0e10cSrcweir                                                 sId, sLeafLabel, sLeafURL,
2508cdf0e10cSrcweir                                                 sEventHdl, sLeafGrpId, nLeafGrpIdx ) );
2509cdf0e10cSrcweir                                 }
2510cdf0e10cSrcweir                             }
2511cdf0e10cSrcweir                         }
2512cdf0e10cSrcweir                     }
2513cdf0e10cSrcweir 
2514cdf0e10cSrcweir                     // do not insert nodes without leaves
2515cdf0e10cSrcweir                     if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2516cdf0e10cSrcweir                     {
2517cdf0e10cSrcweir                         pModule ? aNodeList.push_back( pNode ) : rOutNodeList.push_back( pNode );
2518cdf0e10cSrcweir                     }
2519cdf0e10cSrcweir                 }
2520cdf0e10cSrcweir             }
2521cdf0e10cSrcweir 
2522cdf0e10cSrcweir             if ( pModule && aNodeList.size() > 0 )
2523cdf0e10cSrcweir             {
2524cdf0e10cSrcweir                 sal_uInt32 i = 0, j = 0;
2525cdf0e10cSrcweir                 for ( ; i < pModule->m_aNodeList.size(); ++i )
2526cdf0e10cSrcweir                 {
2527cdf0e10cSrcweir                     rtl::OUString sNodeId = pModule->m_aNodeList[i]->m_sId;
2528cdf0e10cSrcweir                     for ( j = 0; j < aNodeList.size(); ++j )
2529cdf0e10cSrcweir                     {
2530cdf0e10cSrcweir                         OptionsNode* pNode = aNodeList[j];
2531cdf0e10cSrcweir                         if ( pNode->m_sId == sNodeId )
2532cdf0e10cSrcweir                         {
2533cdf0e10cSrcweir                             rOutNodeList.push_back( pNode );
2534cdf0e10cSrcweir                             aNodeList.erase( aNodeList.begin() + j );
2535cdf0e10cSrcweir                             break;
2536cdf0e10cSrcweir                         }
2537cdf0e10cSrcweir                     }
2538cdf0e10cSrcweir                 }
2539cdf0e10cSrcweir 
2540cdf0e10cSrcweir                 for ( i = 0; i < aNodeList.size(); ++i )
2541cdf0e10cSrcweir                     rOutNodeList.push_back( aNodeList[i] );
2542cdf0e10cSrcweir             }
2543cdf0e10cSrcweir         }
2544cdf0e10cSrcweir     }
2545cdf0e10cSrcweir }
2546cdf0e10cSrcweir 
lcl_getGroupId(const rtl::OUString & rGroupName,const SvTreeListBox & rTreeLB)2547cdf0e10cSrcweir sal_uInt16 lcl_getGroupId( const rtl::OUString& rGroupName, const SvTreeListBox& rTreeLB )
2548cdf0e10cSrcweir {
2549cdf0e10cSrcweir     String sGroupName( rGroupName );
2550cdf0e10cSrcweir     sal_uInt16 nRet = 0;
2551cdf0e10cSrcweir     SvLBoxEntry* pEntry = rTreeLB.First();
2552cdf0e10cSrcweir     while( pEntry )
2553cdf0e10cSrcweir     {
2554cdf0e10cSrcweir         if ( !rTreeLB.GetParent( pEntry ) )
2555cdf0e10cSrcweir         {
2556cdf0e10cSrcweir             String sTemp( rTreeLB.GetEntryText( pEntry ) );
2557cdf0e10cSrcweir             if ( sTemp == sGroupName )
2558cdf0e10cSrcweir                 return nRet;
2559cdf0e10cSrcweir             nRet++;
2560cdf0e10cSrcweir         }
2561cdf0e10cSrcweir         pEntry = rTreeLB.Next( pEntry );
2562cdf0e10cSrcweir     }
2563cdf0e10cSrcweir 
2564cdf0e10cSrcweir     return USHRT_MAX;
2565cdf0e10cSrcweir }
2566cdf0e10cSrcweir 
lcl_insertLeaf(OfaTreeOptionsDialog * pDlg,OptionsNode * pNode,OptionsLeaf * pLeaf,const SvTreeListBox & rTreeLB)2567cdf0e10cSrcweir void lcl_insertLeaf(
2568cdf0e10cSrcweir     OfaTreeOptionsDialog* pDlg, OptionsNode* pNode, OptionsLeaf* pLeaf, const SvTreeListBox& rTreeLB )
2569cdf0e10cSrcweir {
2570cdf0e10cSrcweir     sal_uInt16 nGrpId = lcl_getGroupId( pNode->m_sLabel, rTreeLB );
2571cdf0e10cSrcweir     if ( USHRT_MAX == nGrpId )
2572cdf0e10cSrcweir     {
2573cdf0e10cSrcweir         sal_uInt16 nNodeGrpId = getGroupNodeId( pNode->m_sId );
2574cdf0e10cSrcweir         nGrpId = pDlg->AddGroup( pNode->m_sLabel, NULL, NULL, nNodeGrpId );
2575cdf0e10cSrcweir         if ( pNode->m_sPageURL.getLength() > 0 )
2576cdf0e10cSrcweir         {
2577cdf0e10cSrcweir             SvLBoxEntry* pGrpEntry = rTreeLB.GetEntry( 0, nGrpId );
2578cdf0e10cSrcweir             DBG_ASSERT( pGrpEntry, "OfaTreeOptionsDialog::InsertNodes(): no group" );
2579cdf0e10cSrcweir             if ( pGrpEntry )
2580cdf0e10cSrcweir             {
2581cdf0e10cSrcweir                 OptionsGroupInfo* pGrpInfo =
2582cdf0e10cSrcweir                     static_cast<OptionsGroupInfo*>(pGrpEntry->GetUserData());
2583cdf0e10cSrcweir                 pGrpInfo->m_sPageURL = pNode->m_sPageURL;
2584cdf0e10cSrcweir             }
2585cdf0e10cSrcweir         }
2586cdf0e10cSrcweir     }
2587cdf0e10cSrcweir     OptionsPageInfo* pInfo = pDlg->AddTabPage( 0, pLeaf->m_sLabel, nGrpId );
2588cdf0e10cSrcweir     pInfo->m_sPageURL = pLeaf->m_sPageURL;
2589cdf0e10cSrcweir     pInfo->m_sEventHdl = pLeaf->m_sEventHdl;
2590cdf0e10cSrcweir }
2591cdf0e10cSrcweir 
InsertNodes(const VectorOfNodes & rNodeList)2592cdf0e10cSrcweir void  OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes& rNodeList )
2593cdf0e10cSrcweir {
2594cdf0e10cSrcweir     for ( sal_uInt32 i = 0; i < rNodeList.size(); ++i )
2595cdf0e10cSrcweir     {
2596cdf0e10cSrcweir         OptionsNode* pNode = rNodeList[i];
2597cdf0e10cSrcweir 
2598cdf0e10cSrcweir         if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2599cdf0e10cSrcweir         {
2600cdf0e10cSrcweir             sal_uInt32 j = 0;
2601cdf0e10cSrcweir             for ( ; j < pNode->m_aGroupedLeaves.size(); ++j )
2602cdf0e10cSrcweir             {
2603cdf0e10cSrcweir                 for ( sal_uInt32 k = 0; k < pNode->m_aGroupedLeaves[j].size(); ++k )
2604cdf0e10cSrcweir                 {
2605cdf0e10cSrcweir                     OptionsLeaf* pLeaf = pNode->m_aGroupedLeaves[j][k];
2606cdf0e10cSrcweir                     lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
2607cdf0e10cSrcweir                 }
2608cdf0e10cSrcweir             }
2609cdf0e10cSrcweir 
2610cdf0e10cSrcweir             for ( j = 0; j < pNode->m_aLeaves.size(); ++j )
2611cdf0e10cSrcweir             {
2612cdf0e10cSrcweir                 OptionsLeaf* pLeaf = pNode->m_aLeaves[j];
2613cdf0e10cSrcweir                 lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
2614cdf0e10cSrcweir             }
2615cdf0e10cSrcweir         }
2616cdf0e10cSrcweir     }
2617cdf0e10cSrcweir }
2618cdf0e10cSrcweir 
Execute()2619cdf0e10cSrcweir short OfaTreeOptionsDialog::Execute()
2620cdf0e10cSrcweir {
2621cdf0e10cSrcweir     ::std::auto_ptr< SvxDicListChgClamp > pClamp;
2622cdf0e10cSrcweir     if ( !bIsFromExtensionManager )
2623cdf0e10cSrcweir     {
2624cdf0e10cSrcweir         // collect all DictionaryList Events while the dialog is executed
2625cdf0e10cSrcweir         Reference<com::sun::star::linguistic2::XDictionaryList> xDictionaryList(SvxGetDictionaryList());
2626cdf0e10cSrcweir         pClamp = ::std::auto_ptr< SvxDicListChgClamp >( new SvxDicListChgClamp( xDictionaryList ) );
2627cdf0e10cSrcweir     }
2628cdf0e10cSrcweir 	short nRet = SfxModalDialog::Execute();
2629cdf0e10cSrcweir 
2630cdf0e10cSrcweir 	if( RET_OK == nRet )
2631cdf0e10cSrcweir 	{
2632cdf0e10cSrcweir 		ApplyItemSets();
2633cdf0e10cSrcweir 		if( GetColorTable() )
2634cdf0e10cSrcweir 		{
2635cdf0e10cSrcweir 			GetColorTable()->Save();
2636cdf0e10cSrcweir 
2637cdf0e10cSrcweir 			// notify current viewframe it it uses the same color table
2638cdf0e10cSrcweir 			if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
2639cdf0e10cSrcweir 			{
2640*c7be74b1SArmin Le Grand 				const SvxColorTableItem* pPtr = dynamic_cast< const SvxColorTableItem* >(
2641*c7be74b1SArmin Le Grand                     SfxViewFrame::Current()->GetDispatcher()->Execute(SID_GET_COLORTABLE, SFX_CALLMODE_SYNCHRON));
2642cdf0e10cSrcweir 				if( pPtr )
2643cdf0e10cSrcweir 				{
2644*c7be74b1SArmin Le Grand                     XColorListSharedPtr aColorTab = pPtr->GetColorTable();
2645cdf0e10cSrcweir 
2646*c7be74b1SArmin Le Grand                     if( aColorTab &&
2647*c7be74b1SArmin Le Grand                         aColorTab->GetPath() == GetColorTable()->GetPath() &&
2648*c7be74b1SArmin Le Grand                         aColorTab->GetName() == GetColorTable()->GetName() )
2649cdf0e10cSrcweir                         SfxObjectShell::Current()->PutItem( SvxColorTableItem( GetColorTable(), SID_COLOR_TABLE ) );
2650cdf0e10cSrcweir 				}
2651cdf0e10cSrcweir 			}
2652cdf0e10cSrcweir 		}
2653cdf0e10cSrcweir 
2654cdf0e10cSrcweir         utl::ConfigManager::GetConfigManager()->StoreConfigItems();
2655cdf0e10cSrcweir     }
2656cdf0e10cSrcweir 
2657cdf0e10cSrcweir 	return nRet;
2658cdf0e10cSrcweir }
2659cdf0e10cSrcweir 
2660cdf0e10cSrcweir // class ExtensionsTabPage -----------------------------------------------
2661cdf0e10cSrcweir 
ExtensionsTabPage(Window * pParent,WinBits nStyle,const rtl::OUString & rPageURL,const rtl::OUString & rEvtHdl,const Reference<awt::XContainerWindowProvider> & rProvider)2662cdf0e10cSrcweir ExtensionsTabPage::ExtensionsTabPage(
2663cdf0e10cSrcweir     Window* pParent, WinBits nStyle, const rtl::OUString& rPageURL,
2664cdf0e10cSrcweir     const rtl::OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) :
2665cdf0e10cSrcweir 
2666cdf0e10cSrcweir     TabPage( pParent, nStyle ),
2667cdf0e10cSrcweir 
2668cdf0e10cSrcweir     m_sPageURL          ( rPageURL ),
2669cdf0e10cSrcweir     m_sEventHdl         ( rEvtHdl ),
2670cdf0e10cSrcweir     m_xWinProvider      ( rProvider ),
2671cdf0e10cSrcweir     m_bIsWindowHidden   ( false )
2672cdf0e10cSrcweir 
2673cdf0e10cSrcweir {
2674cdf0e10cSrcweir }
2675cdf0e10cSrcweir 
2676cdf0e10cSrcweir // -----------------------------------------------------------------------
2677cdf0e10cSrcweir 
~ExtensionsTabPage()2678cdf0e10cSrcweir ExtensionsTabPage::~ExtensionsTabPage()
2679cdf0e10cSrcweir {
2680cdf0e10cSrcweir     Hide();
2681cdf0e10cSrcweir     DeactivatePage();
2682cdf0e10cSrcweir }
2683cdf0e10cSrcweir 
2684cdf0e10cSrcweir // -----------------------------------------------------------------------
2685cdf0e10cSrcweir 
CreateDialogWithHandler()2686cdf0e10cSrcweir void ExtensionsTabPage::CreateDialogWithHandler()
2687cdf0e10cSrcweir {
2688cdf0e10cSrcweir     try
2689cdf0e10cSrcweir     {
2690cdf0e10cSrcweir         bool bWithHandler = ( m_sEventHdl.getLength() > 0 );
2691cdf0e10cSrcweir         if ( bWithHandler )
2692cdf0e10cSrcweir         {
2693cdf0e10cSrcweir             Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
2694cdf0e10cSrcweir             m_xEventHdl = Reference< awt::XContainerWindowEventHandler >(
2695cdf0e10cSrcweir                 xFactory->createInstance( m_sEventHdl ), UNO_QUERY );
2696cdf0e10cSrcweir         }
2697cdf0e10cSrcweir 
2698cdf0e10cSrcweir         if ( !bWithHandler || m_xEventHdl.is() )
2699cdf0e10cSrcweir         {
2700cdf0e10cSrcweir             SetStyle( GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2701cdf0e10cSrcweir             Reference< awt::XWindowPeer > xParent( VCLUnoHelper::GetInterface( this ), UNO_QUERY );
2702cdf0e10cSrcweir             m_xPage = Reference < awt::XWindow >(
2703cdf0e10cSrcweir                 m_xWinProvider->createContainerWindow(
2704cdf0e10cSrcweir                     m_sPageURL, rtl::OUString(), xParent, m_xEventHdl ), UNO_QUERY );
2705cdf0e10cSrcweir 
2706cdf0e10cSrcweir             Reference< awt::XControl > xPageControl( m_xPage, UNO_QUERY );
2707cdf0e10cSrcweir             if ( xPageControl.is() )
2708cdf0e10cSrcweir             {
2709cdf0e10cSrcweir                 Reference< awt::XWindowPeer > xWinPeer( xPageControl->getPeer() );
2710cdf0e10cSrcweir                 if ( xWinPeer.is() )
2711cdf0e10cSrcweir                 {
2712cdf0e10cSrcweir                     Window* pWindow = VCLUnoHelper::GetWindow( xWinPeer );
2713cdf0e10cSrcweir                     if ( pWindow )
2714cdf0e10cSrcweir                         pWindow->SetStyle( pWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2715cdf0e10cSrcweir                 }
2716cdf0e10cSrcweir             }
2717cdf0e10cSrcweir         }
2718cdf0e10cSrcweir     }
2719cdf0e10cSrcweir     catch ( ::com::sun::star::lang::IllegalArgumentException& )
2720cdf0e10cSrcweir     {
2721cdf0e10cSrcweir         DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): illegal argument" );
2722cdf0e10cSrcweir     }
2723cdf0e10cSrcweir     catch ( Exception& )
2724cdf0e10cSrcweir     {
2725cdf0e10cSrcweir         DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler()" );
2726cdf0e10cSrcweir     }
2727cdf0e10cSrcweir }
2728cdf0e10cSrcweir 
2729cdf0e10cSrcweir // -----------------------------------------------------------------------
2730cdf0e10cSrcweir 
DispatchAction(const rtl::OUString & rAction)2731cdf0e10cSrcweir sal_Bool ExtensionsTabPage::DispatchAction( const rtl::OUString& rAction )
2732cdf0e10cSrcweir {
2733cdf0e10cSrcweir     sal_Bool bRet = sal_False;
2734cdf0e10cSrcweir     if ( m_xEventHdl.is() )
2735cdf0e10cSrcweir     {
2736cdf0e10cSrcweir         try
2737cdf0e10cSrcweir         {
2738cdf0e10cSrcweir             bRet = m_xEventHdl->callHandlerMethod( m_xPage, makeAny( rAction ), C2U("external_event") );
2739cdf0e10cSrcweir         }
2740cdf0e10cSrcweir         catch ( Exception& )
2741cdf0e10cSrcweir         {
2742cdf0e10cSrcweir             DBG_ERRORFILE( "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" );
2743cdf0e10cSrcweir         }
2744cdf0e10cSrcweir     }
2745cdf0e10cSrcweir     return bRet;
2746cdf0e10cSrcweir }
2747cdf0e10cSrcweir 
2748cdf0e10cSrcweir // -----------------------------------------------------------------------
2749cdf0e10cSrcweir 
ActivatePage()2750cdf0e10cSrcweir void ExtensionsTabPage::ActivatePage()
2751cdf0e10cSrcweir {
2752cdf0e10cSrcweir     TabPage::ActivatePage();
2753cdf0e10cSrcweir 
2754cdf0e10cSrcweir     if ( !m_xPage.is() )
2755cdf0e10cSrcweir     {
2756cdf0e10cSrcweir         CreateDialogWithHandler();
2757cdf0e10cSrcweir 
2758cdf0e10cSrcweir         if ( m_xPage.is() )
2759cdf0e10cSrcweir         {
2760cdf0e10cSrcweir             Point aPos = Point();
2761cdf0e10cSrcweir             Size aSize = GetSizePixel();
2762cdf0e10cSrcweir             m_xPage->setPosSize( aPos.X() + 1, aPos.Y() + 1,
2763cdf0e10cSrcweir                                  aSize.Width() - 2, aSize.Height() - 2, awt::PosSize::POSSIZE );
2764cdf0e10cSrcweir             if ( m_sEventHdl.getLength() > 0 )
2765cdf0e10cSrcweir                 DispatchAction( C2U("initialize") );
2766cdf0e10cSrcweir         }
2767cdf0e10cSrcweir     }
2768cdf0e10cSrcweir 
2769cdf0e10cSrcweir     if ( m_xPage.is() )
2770cdf0e10cSrcweir     {
2771cdf0e10cSrcweir         m_xPage->setVisible( sal_True );
2772cdf0e10cSrcweir         m_bIsWindowHidden = false;
2773cdf0e10cSrcweir     }
2774cdf0e10cSrcweir }
2775cdf0e10cSrcweir 
2776cdf0e10cSrcweir // -----------------------------------------------------------------------
2777cdf0e10cSrcweir 
DeactivatePage()2778cdf0e10cSrcweir void ExtensionsTabPage::DeactivatePage()
2779cdf0e10cSrcweir {
2780cdf0e10cSrcweir     TabPage::DeactivatePage();
2781cdf0e10cSrcweir 
2782cdf0e10cSrcweir     if ( m_xPage.is() )
2783cdf0e10cSrcweir         m_xPage->setVisible( sal_False );
2784cdf0e10cSrcweir }
2785cdf0e10cSrcweir 
2786cdf0e10cSrcweir // -----------------------------------------------------------------------
2787cdf0e10cSrcweir 
ResetPage()2788cdf0e10cSrcweir void ExtensionsTabPage::ResetPage()
2789cdf0e10cSrcweir {
2790cdf0e10cSrcweir     DispatchAction( C2U("back") );
2791cdf0e10cSrcweir     ActivatePage();
2792cdf0e10cSrcweir }
2793cdf0e10cSrcweir 
2794cdf0e10cSrcweir // -----------------------------------------------------------------------
2795cdf0e10cSrcweir 
SavePage()2796cdf0e10cSrcweir void ExtensionsTabPage::SavePage()
2797cdf0e10cSrcweir {
2798cdf0e10cSrcweir     DispatchAction( C2U("ok") );
2799cdf0e10cSrcweir }
2800