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