xref: /AOO41X/main/cui/source/options/optinet2.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 
31*cdf0e10cSrcweir // include ---------------------------------------------------------------
32*cdf0e10cSrcweir #include <tools/shl.hxx>
33*cdf0e10cSrcweir #include <tools/config.hxx>
34*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35*cdf0e10cSrcweir #include <svl/intitem.hxx>
36*cdf0e10cSrcweir #include <svl/stritem.hxx>
37*cdf0e10cSrcweir #include <svl/eitem.hxx>
38*cdf0e10cSrcweir #include <svl/slstitm.hxx>
39*cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
40*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
41*cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
42*cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
43*cdf0e10cSrcweir #include <sfx2/sfxsids.hrc>
44*cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
45*cdf0e10cSrcweir #include <tools/inetdef.hxx>
46*cdf0e10cSrcweir #include <svl/urihelper.hxx>
47*cdf0e10cSrcweir #include <svl/cntwids.hrc>
48*cdf0e10cSrcweir #include <unotools/inetoptions.hxx>
49*cdf0e10cSrcweir #include <sfx2/app.hxx>
50*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
51*cdf0e10cSrcweir #include <unotools/bootstrap.hxx>
52*cdf0e10cSrcweir #include <vcl/help.hxx>
53*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
54*cdf0e10cSrcweir #include <tools/urlobj.hxx>
55*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
56*cdf0e10cSrcweir #include <unotools/securityoptions.hxx>
57*cdf0e10cSrcweir #include <unotools/javaoptions.hxx>
58*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
59*cdf0e10cSrcweir #include <unotools/extendedsecurityoptions.hxx>
60*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
61*cdf0e10cSrcweir #define _SVX_OPTINET2_CXX
62*cdf0e10cSrcweir #include <dialmgr.hxx>
63*cdf0e10cSrcweir #include "optinet2.hxx"
64*cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
65*cdf0e10cSrcweir #include <cuires.hrc>
66*cdf0e10cSrcweir #include "optinet2.hrc"
67*cdf0e10cSrcweir #include "helpid.hrc"
68*cdf0e10cSrcweir #include <svx/ofaitem.hxx>
69*cdf0e10cSrcweir #include <svx/htmlmode.hxx>
70*cdf0e10cSrcweir #include <svx/svxids.hrc> // slot ids, mostly for changetracking
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir // for security TP
73*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
74*cdf0e10cSrcweir #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir #ifdef UNX
77*cdf0e10cSrcweir #include <sys/types.h>
78*cdf0e10cSrcweir #include <sys/stat.h>
79*cdf0e10cSrcweir #include <unistd.h>
80*cdf0e10cSrcweir #include <fcntl.h>
81*cdf0e10cSrcweir #include <pwd.h>
82*cdf0e10cSrcweir #include <sys/types.h>
83*cdf0e10cSrcweir #include <string.h>
84*cdf0e10cSrcweir #include <rtl/textenc.h>
85*cdf0e10cSrcweir #include <rtl/locale.h>
86*cdf0e10cSrcweir #include <osl/nlsupport.h>
87*cdf0e10cSrcweir #endif
88*cdf0e10cSrcweir #include <sal/types.h>
89*cdf0e10cSrcweir #include <rtl/ustring.hxx>
90*cdf0e10cSrcweir #include <osl/file.hxx>
91*cdf0e10cSrcweir #include <osl/process.h>
92*cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp>
93*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
94*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
95*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
96*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
97*cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp>
98*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
101*cdf0e10cSrcweir #include "com/sun/star/task/XMasterPasswordHandling2.hpp"
102*cdf0e10cSrcweir #include "com/sun/star/task/XPasswordContainer.hpp"
103*cdf0e10cSrcweir #include "securityoptions.hxx"
104*cdf0e10cSrcweir #include "webconninfo.hxx"
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir using namespace ::com::sun::star;
107*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
108*cdf0e10cSrcweir using namespace ::sfx2;
109*cdf0e10cSrcweir using ::rtl::OUString;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir //CHINA001 copy from multipat.hxx begin
112*cdf0e10cSrcweir // define ----------------------------------------------------------------
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir // different delimiter for Unix (:) and Windows (;)
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir #ifdef UNX
117*cdf0e10cSrcweir #define CLASSPATH_DELIMITER	':'
118*cdf0e10cSrcweir #else
119*cdf0e10cSrcweir #define CLASSPATH_DELIMITER	';'
120*cdf0e10cSrcweir #endif
121*cdf0e10cSrcweir //CHINA001 copy from multipat.hxx end
122*cdf0e10cSrcweir // static ----------------------------------------------------------------
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar)
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir #define INET_SEARCH_TOKEN 	'"'
127*cdf0e10cSrcweir #define RET_ALL				((short)200)
128*cdf0e10cSrcweir #define CFG_READONLY_DEFAULT    FALSE
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir #include <sal/config.h>
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir SV_IMPL_PTRARR( SfxFilterPtrArr, SfxFilterPtr )
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir const char* SEARCHENGINE_INI	= "srcheng.ini";
135*cdf0e10cSrcweir const char* SEARCHENGINE_GROUP	= "SearchEngines-$(vlang)";
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir // -----------------------------------------------------------------------
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir void SvxNoSpaceEdit::KeyInput( const KeyEvent& rKEvent )
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir 	if ( bOnlyNumeric )
142*cdf0e10cSrcweir 	{
143*cdf0e10cSrcweir 		const KeyCode& rKeyCode = rKEvent.GetKeyCode();
144*cdf0e10cSrcweir 		sal_uInt16 nGroup = rKeyCode.GetGroup();
145*cdf0e10cSrcweir 		sal_uInt16 nKey = rKeyCode.GetCode();
146*cdf0e10cSrcweir 		sal_Bool bValid = ( KEYGROUP_NUM == nGroup || KEYGROUP_CURSOR == nGroup ||
147*cdf0e10cSrcweir 						( KEYGROUP_MISC == nGroup && ( nKey < KEY_ADD || nKey > KEY_EQUAL ) ) );
148*cdf0e10cSrcweir 		if ( !bValid && ( rKeyCode.IsMod1() && (
149*cdf0e10cSrcweir 			 KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) )
150*cdf0e10cSrcweir 			// Erase, Copy, Paste, Select All und Undo soll funktionieren
151*cdf0e10cSrcweir 			bValid = sal_True;
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 		if ( bValid )
154*cdf0e10cSrcweir 			Edit::KeyInput(rKEvent);
155*cdf0e10cSrcweir 	}
156*cdf0e10cSrcweir 	else if( rKEvent.GetKeyCode().GetCode() != KEY_SPACE )
157*cdf0e10cSrcweir 		Edit::KeyInput(rKEvent);
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir // -----------------------------------------------------------------------
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir void SvxNoSpaceEdit::Modify()
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir 	Edit::Modify();
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	if ( bOnlyNumeric )
167*cdf0e10cSrcweir 	{
168*cdf0e10cSrcweir 		XubString aValue = GetText();
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 		if ( !ByteString(::rtl::OUStringToOString(aValue,RTL_TEXTENCODING_UTF8)).IsNumericAscii() || (long)aValue.ToInt32() > USHRT_MAX )
171*cdf0e10cSrcweir 			// der H�chstwert einer Portnummer ist USHRT_MAX
172*cdf0e10cSrcweir 			ErrorBox( this, CUI_RES( RID_SVXERR_OPT_PROXYPORTS ) ).Execute();
173*cdf0e10cSrcweir 	}
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir /********************************************************************/
177*cdf0e10cSrcweir /********************************************************************/
178*cdf0e10cSrcweir /*                                                                  */
179*cdf0e10cSrcweir /* 	SvxProxyTabPage                                                 */
180*cdf0e10cSrcweir /*                                                                  */
181*cdf0e10cSrcweir /*                                                                  */
182*cdf0e10cSrcweir /********************************************************************/
183*cdf0e10cSrcweir /********************************************************************/
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir SvxProxyTabPage::SvxProxyTabPage(Window* pParent, const SfxItemSet& rSet ) :
186*cdf0e10cSrcweir 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_PROXY ), rSet ),
187*cdf0e10cSrcweir 	aOptionGB   (this, CUI_RES(GB_SETTINGS)),
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	aProxyModeFT  (this, CUI_RES(FT_PROXYMODE)),
190*cdf0e10cSrcweir 	aProxyModeLB  (this, CUI_RES(LB_PROXYMODE)),
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 	aHttpProxyFT      (this, CUI_RES( FT_HTTP_PROXY	  )),
193*cdf0e10cSrcweir 	aHttpProxyED      (this, CUI_RES( ED_HTTP_PROXY     )),
194*cdf0e10cSrcweir 	aHttpPortFT       (this, CUI_RES( FT_HTTP_PORT      )),
195*cdf0e10cSrcweir 	aHttpPortED       (this, CUI_RES( ED_HTTP_PORT      ), sal_True),
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     aHttpsProxyFT      (this, CUI_RES( FT_HTTPS_PROXY	  )),
198*cdf0e10cSrcweir 	aHttpsProxyED      (this, CUI_RES( ED_HTTPS_PROXY     )),
199*cdf0e10cSrcweir 	aHttpsPortFT       (this, CUI_RES( FT_HTTPS_PORT      )),
200*cdf0e10cSrcweir 	aHttpsPortED       (this, CUI_RES( ED_HTTPS_PORT      ), sal_True),
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	aFtpProxyFT       (this, CUI_RES( FT_FTP_PROXY      )),
203*cdf0e10cSrcweir 	aFtpProxyED       (this, CUI_RES( ED_FTP_PROXY      )),
204*cdf0e10cSrcweir 	aFtpPortFT        (this, CUI_RES( FT_FTP_PORT       )),
205*cdf0e10cSrcweir 	aFtpPortED        (this, CUI_RES( ED_FTP_PORT       ), sal_True),
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	aNoProxyForFT     (this, CUI_RES( FT_NOPROXYFOR     )),
208*cdf0e10cSrcweir 	aNoProxyForED     (this, CUI_RES( ED_NOPROXYFOR     )),
209*cdf0e10cSrcweir     aNoProxyDescFT    (this, CUI_RES( ED_NOPROXYDESC    )),
210*cdf0e10cSrcweir     sFromBrowser        (       CUI_RES( ST_PROXY_FROM_BROWSER ) ),
211*cdf0e10cSrcweir     aProxyModePN(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType")),
212*cdf0e10cSrcweir     aHttpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName")),
213*cdf0e10cSrcweir     aHttpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort")),
214*cdf0e10cSrcweir     aHttpsProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyName")),
215*cdf0e10cSrcweir     aHttpsPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyPort")),
216*cdf0e10cSrcweir 	aFtpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName")),
217*cdf0e10cSrcweir     aFtpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort")),
218*cdf0e10cSrcweir     aNoProxyDescPN(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy"))
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir 	FreeResource();
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 	aHttpPortED.SetMaxTextLen(5);
223*cdf0e10cSrcweir 	aHttpsPortED.SetMaxTextLen(5);
224*cdf0e10cSrcweir 	aFtpPortED.SetMaxTextLen(5);
225*cdf0e10cSrcweir 	Link aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl );
226*cdf0e10cSrcweir 	aHttpPortED.SetLoseFocusHdl( aLink );
227*cdf0e10cSrcweir 	aHttpsPortED.SetLoseFocusHdl( aLink );
228*cdf0e10cSrcweir 	aFtpPortED.SetLoseFocusHdl( aLink );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 	aProxyModeLB.SetSelectHdl(LINK( this, SvxProxyTabPage, ProxyHdl_Impl ));
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager(
233*cdf0e10cSrcweir         ::comphelper::getProcessServiceFactory());
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     if( xServiceManager.is() )
236*cdf0e10cSrcweir     {
237*cdf0e10cSrcweir         try
238*cdf0e10cSrcweir         {
239*cdf0e10cSrcweir             Reference< com::sun::star::lang::XMultiServiceFactory > xConfigurationProvider =
240*cdf0e10cSrcweir                 Reference< com::sun::star::lang::XMultiServiceFactory > ( xServiceManager->createInstance( rtl::OUString(
241*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
242*cdf0e10cSrcweir                 UNO_QUERY_THROW);
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir             OUString aConfigRoot(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings" ) );
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir             beans::PropertyValue aProperty;
247*cdf0e10cSrcweir             aProperty.Name  = OUString(RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
248*cdf0e10cSrcweir             aProperty.Value = makeAny( aConfigRoot );
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir             Sequence< Any > aArgumentList( 1 );
251*cdf0e10cSrcweir             aArgumentList[0] = makeAny( aProperty );
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir             m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments( rtl::OUString(
254*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
255*cdf0e10cSrcweir                     aArgumentList );
256*cdf0e10cSrcweir         }
257*cdf0e10cSrcweir         catch ( RuntimeException& )
258*cdf0e10cSrcweir         {
259*cdf0e10cSrcweir         }
260*cdf0e10cSrcweir     }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     ArrangeControls_Impl();
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir /*-----------------12.08.96 14.55-------------------
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir --------------------------------------------------*/
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir SvxProxyTabPage::~SvxProxyTabPage()
270*cdf0e10cSrcweir {
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir /*-----------------12.08.96 14.55-------------------
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir --------------------------------------------------*/
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir SfxTabPage*	SvxProxyTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir 	return new SvxProxyTabPage(pParent, rAttrSet);
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir /*-----------------02.09.04 14.55-------------------
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir --------------------------------------------------*/
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir void SvxProxyTabPage::ReadConfigData_Impl()
287*cdf0e10cSrcweir {
288*cdf0e10cSrcweir     try {
289*cdf0e10cSrcweir         Reference< container::XNameAccess > xNameAccess(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir         sal_Int32 nIntValue = 0;
292*cdf0e10cSrcweir         OUString  aStringValue;
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir         if( xNameAccess->getByName(aProxyModePN) >>= nIntValue )
295*cdf0e10cSrcweir         {
296*cdf0e10cSrcweir             aProxyModeLB.SelectEntryPos( (sal_uInt16) nIntValue );
297*cdf0e10cSrcweir         }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir         if( xNameAccess->getByName(aHttpProxyPN) >>= aStringValue )
300*cdf0e10cSrcweir         {
301*cdf0e10cSrcweir             aHttpProxyED.SetText( aStringValue );
302*cdf0e10cSrcweir         }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir         if( xNameAccess->getByName(aHttpPortPN) >>= nIntValue )
305*cdf0e10cSrcweir         {
306*cdf0e10cSrcweir             aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
307*cdf0e10cSrcweir         }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir         if( xNameAccess->getByName(aHttpsProxyPN) >>= aStringValue )
310*cdf0e10cSrcweir         {
311*cdf0e10cSrcweir             aHttpsProxyED.SetText( aStringValue );
312*cdf0e10cSrcweir         }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir         if( xNameAccess->getByName(aHttpsPortPN) >>= nIntValue )
315*cdf0e10cSrcweir         {
316*cdf0e10cSrcweir             aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
317*cdf0e10cSrcweir         }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir         if( xNameAccess->getByName(aFtpProxyPN) >>= aStringValue )
320*cdf0e10cSrcweir         {
321*cdf0e10cSrcweir             aFtpProxyED.SetText( aStringValue );
322*cdf0e10cSrcweir         }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir         if( xNameAccess->getByName(aFtpPortPN) >>= nIntValue )
325*cdf0e10cSrcweir         {
326*cdf0e10cSrcweir             aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
327*cdf0e10cSrcweir         }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir         if( xNameAccess->getByName(aNoProxyDescPN) >>= aStringValue )
330*cdf0e10cSrcweir         {
331*cdf0e10cSrcweir             aNoProxyForED.SetText( aStringValue );
332*cdf0e10cSrcweir         }
333*cdf0e10cSrcweir     }
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     catch(container::NoSuchElementException e) {
336*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: NoSuchElementException caught" );
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     catch(com::sun::star::lang::WrappedTargetException e) {
340*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: WrappedTargetException caught" );
341*cdf0e10cSrcweir     }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir     catch(RuntimeException e) {
344*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: RuntimeException caught" );
345*cdf0e10cSrcweir     }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir /*-----------------02.09.04 14.55-------------------
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir --------------------------------------------------*/
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir void SvxProxyTabPage::ReadConfigDefaults_Impl()
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir     try
356*cdf0e10cSrcweir     {
357*cdf0e10cSrcweir         Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         sal_Int32 nIntValue = 0;
360*cdf0e10cSrcweir         OUString  aStringValue;
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir         if( xPropertyState->getPropertyDefault(aHttpProxyPN) >>= aStringValue )
363*cdf0e10cSrcweir         {
364*cdf0e10cSrcweir             aHttpProxyED.SetText( aStringValue );
365*cdf0e10cSrcweir         }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir         if( xPropertyState->getPropertyDefault(aHttpPortPN) >>= nIntValue )
368*cdf0e10cSrcweir         {
369*cdf0e10cSrcweir             aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
370*cdf0e10cSrcweir         }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 		if( xPropertyState->getPropertyDefault(aHttpsProxyPN) >>= aStringValue )
373*cdf0e10cSrcweir         {
374*cdf0e10cSrcweir             aHttpsProxyED.SetText( aStringValue );
375*cdf0e10cSrcweir         }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir         if( xPropertyState->getPropertyDefault(aHttpsPortPN) >>= nIntValue )
378*cdf0e10cSrcweir         {
379*cdf0e10cSrcweir             aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
380*cdf0e10cSrcweir         }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir         if( xPropertyState->getPropertyDefault(aFtpProxyPN) >>= aStringValue )
383*cdf0e10cSrcweir         {
384*cdf0e10cSrcweir             aFtpProxyED.SetText( aStringValue );
385*cdf0e10cSrcweir         }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir         if( xPropertyState->getPropertyDefault(aFtpPortPN) >>= nIntValue )
388*cdf0e10cSrcweir         {
389*cdf0e10cSrcweir             aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
390*cdf0e10cSrcweir         }
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir         if( xPropertyState->getPropertyDefault(aNoProxyDescPN) >>= aStringValue )
393*cdf0e10cSrcweir         {
394*cdf0e10cSrcweir             aNoProxyForED.SetText( aStringValue );
395*cdf0e10cSrcweir         }
396*cdf0e10cSrcweir     }
397*cdf0e10cSrcweir     catch(beans::UnknownPropertyException e)
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
400*cdf0e10cSrcweir     }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir     catch(com::sun::star::lang::WrappedTargetException e) {
403*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     catch(RuntimeException e)
407*cdf0e10cSrcweir     {
408*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
409*cdf0e10cSrcweir     }
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir /*-----------------02.09.04 14.55-------------------
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir --------------------------------------------------*/
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir void SvxProxyTabPage::RestoreConfigDefaults_Impl()
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir     try
419*cdf0e10cSrcweir     {
420*cdf0e10cSrcweir         Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aProxyModePN);
423*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aHttpProxyPN);
424*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aHttpPortPN);
425*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aHttpsProxyPN);
426*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aHttpsPortPN);
427*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aFtpProxyPN);
428*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aFtpPortPN);
429*cdf0e10cSrcweir         xPropertyState->setPropertyToDefault(aNoProxyDescPN);
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir         Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
432*cdf0e10cSrcweir         xChangesBatch->commitChanges();
433*cdf0e10cSrcweir     }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir     catch(beans::UnknownPropertyException e)
436*cdf0e10cSrcweir     {
437*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
438*cdf0e10cSrcweir     }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir     catch(com::sun::star::lang::WrappedTargetException e) {
441*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
442*cdf0e10cSrcweir     }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir     catch(RuntimeException e)
445*cdf0e10cSrcweir     {
446*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
447*cdf0e10cSrcweir     }
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir /*-----------------12.08.96 14.55-------------------
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir --------------------------------------------------*/
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir void SvxProxyTabPage::Reset(const SfxItemSet&)
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir     ReadConfigData_Impl();
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     aProxyModeLB.SaveValue();
459*cdf0e10cSrcweir     aHttpProxyED.SaveValue();
460*cdf0e10cSrcweir     aHttpPortED.SaveValue();
461*cdf0e10cSrcweir     aHttpsProxyED.SaveValue();
462*cdf0e10cSrcweir     aHttpsPortED.SaveValue();
463*cdf0e10cSrcweir     aFtpProxyED.SaveValue();
464*cdf0e10cSrcweir     aFtpPortED.SaveValue();
465*cdf0e10cSrcweir     aNoProxyForED.SaveValue();
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir     EnableControls_Impl( aProxyModeLB.GetSelectEntryPos() == 2 );
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir /*-----------------12.08.96 16.34-------------------
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir --------------------------------------------------*/
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir sal_Bool SvxProxyTabPage::FillItemSet(SfxItemSet& )
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir     sal_Bool bModified=sal_False;
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir     try {
479*cdf0e10cSrcweir         Reference< beans::XPropertySet > xPropertySet(m_xConfigurationUpdateAccess, UNO_QUERY_THROW );
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir         sal_uInt16 nSelPos = aProxyModeLB.GetSelectEntryPos();
482*cdf0e10cSrcweir         if(aProxyModeLB.GetSavedValue() != nSelPos)
483*cdf0e10cSrcweir         {
484*cdf0e10cSrcweir             if( nSelPos == 1 )
485*cdf0e10cSrcweir             {
486*cdf0e10cSrcweir                 RestoreConfigDefaults_Impl();
487*cdf0e10cSrcweir                 return sal_True;
488*cdf0e10cSrcweir             }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir             xPropertySet->setPropertyValue(aProxyModePN,
491*cdf0e10cSrcweir                 makeAny((sal_Int32) nSelPos));
492*cdf0e10cSrcweir             bModified = sal_True;
493*cdf0e10cSrcweir         }
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir         if(aHttpProxyED.GetSavedValue() != aHttpProxyED.GetText())
496*cdf0e10cSrcweir         {
497*cdf0e10cSrcweir             xPropertySet->setPropertyValue( aHttpProxyPN,
498*cdf0e10cSrcweir                 makeAny(rtl::OUString(aHttpProxyED.GetText())));
499*cdf0e10cSrcweir             bModified = sal_True;
500*cdf0e10cSrcweir         }
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir         if ( aHttpPortED.GetSavedValue() != aHttpPortED.GetText() )
503*cdf0e10cSrcweir         {
504*cdf0e10cSrcweir             xPropertySet->setPropertyValue( aHttpPortPN,
505*cdf0e10cSrcweir                 makeAny(aHttpPortED.GetText().ToInt32()));
506*cdf0e10cSrcweir             bModified = sal_True;
507*cdf0e10cSrcweir         }
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 		if(aHttpsProxyED.GetSavedValue() != aHttpsProxyED.GetText())
510*cdf0e10cSrcweir         {
511*cdf0e10cSrcweir             xPropertySet->setPropertyValue( aHttpsProxyPN,
512*cdf0e10cSrcweir                 makeAny(rtl::OUString(aHttpsProxyED.GetText())));
513*cdf0e10cSrcweir             bModified = sal_True;
514*cdf0e10cSrcweir         }
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir         if ( aHttpsPortED.GetSavedValue() != aHttpsPortED.GetText() )
517*cdf0e10cSrcweir         {
518*cdf0e10cSrcweir             xPropertySet->setPropertyValue( aHttpsPortPN,
519*cdf0e10cSrcweir                 makeAny(aHttpsPortED.GetText().ToInt32()));
520*cdf0e10cSrcweir             bModified = sal_True;
521*cdf0e10cSrcweir         }
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir         if(aFtpProxyED.GetSavedValue() != aFtpProxyED.GetText())
524*cdf0e10cSrcweir         {
525*cdf0e10cSrcweir             xPropertySet->setPropertyValue( aFtpProxyPN,
526*cdf0e10cSrcweir                 makeAny( rtl::OUString(aFtpProxyED.GetText())));
527*cdf0e10cSrcweir             bModified = sal_True;
528*cdf0e10cSrcweir         }
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir         if ( aFtpPortED.GetSavedValue() != aFtpPortED.GetText() )
531*cdf0e10cSrcweir         {
532*cdf0e10cSrcweir             xPropertySet->setPropertyValue( aFtpPortPN,
533*cdf0e10cSrcweir                 makeAny(aFtpPortED.GetText().ToInt32()));
534*cdf0e10cSrcweir             bModified = sal_True;
535*cdf0e10cSrcweir         }
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir         if ( aNoProxyForED.GetSavedValue() != aNoProxyForED.GetText() )
538*cdf0e10cSrcweir         {
539*cdf0e10cSrcweir             xPropertySet->setPropertyValue( aNoProxyDescPN,
540*cdf0e10cSrcweir                 makeAny( rtl::OUString(aNoProxyForED.GetText())));
541*cdf0e10cSrcweir             bModified = sal_True;
542*cdf0e10cSrcweir         }
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir         Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
545*cdf0e10cSrcweir         xChangesBatch->commitChanges();
546*cdf0e10cSrcweir     }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir     catch(com::sun::star::lang::IllegalArgumentException e) {
549*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::FillItemSet: IllegalArgumentException caught" );
550*cdf0e10cSrcweir     }
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir     catch(beans::UnknownPropertyException e) {
553*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::FillItemSet: UnknownPropertyException caught" );
554*cdf0e10cSrcweir     }
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir     catch(beans::PropertyVetoException e) {
557*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::FillItemSet: PropertyVetoException caught" );
558*cdf0e10cSrcweir     }
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir     catch(com::sun::star::lang::WrappedTargetException e) {
561*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::FillItemSet: WrappedTargetException caught" );
562*cdf0e10cSrcweir     }
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir     catch(RuntimeException e) {
565*cdf0e10cSrcweir         OSL_TRACE( "SvxProxyTabPage::FillItemSet: RuntimeException caught" );
566*cdf0e10cSrcweir     }
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir     return bModified;
569*cdf0e10cSrcweir }
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir void SvxProxyTabPage::ArrangeControls_Impl()
572*cdf0e10cSrcweir {
573*cdf0e10cSrcweir     //-->Calculate dynamical width of controls, add buy wuy for i71445 Time: 2007.02.27
574*cdf0e10cSrcweir     long nWidth = aProxyModeFT.GetCtrlTextWidth( aProxyModeFT.GetText() );
575*cdf0e10cSrcweir     long nTemp = aHttpProxyFT.GetCtrlTextWidth( aHttpProxyFT.GetText() );
576*cdf0e10cSrcweir 	if ( nTemp > nWidth )
577*cdf0e10cSrcweir         nWidth = nTemp;
578*cdf0e10cSrcweir     nTemp = aHttpsProxyFT.GetCtrlTextWidth( aHttpsProxyFT.GetText() );
579*cdf0e10cSrcweir     if ( nTemp > nWidth )
580*cdf0e10cSrcweir         nWidth = nTemp;
581*cdf0e10cSrcweir     nTemp = aFtpProxyFT.GetCtrlTextWidth( aFtpProxyFT.GetText() );
582*cdf0e10cSrcweir     if ( nTemp > nWidth )
583*cdf0e10cSrcweir         nWidth = nTemp;
584*cdf0e10cSrcweir     nTemp = aNoProxyForFT.GetCtrlTextWidth( aNoProxyForFT.GetText() );
585*cdf0e10cSrcweir     if ( nTemp > nWidth )
586*cdf0e10cSrcweir         nWidth = nTemp;
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir     nWidth += 10; // To be sure the length of the FixedText is enough on all platforms
589*cdf0e10cSrcweir     const long nFTWidth = aProxyModeFT.GetSizePixel().Width();
590*cdf0e10cSrcweir     if ( nWidth > nFTWidth )
591*cdf0e10cSrcweir     {
592*cdf0e10cSrcweir         Size aNewSize = aProxyModeFT.GetSizePixel();
593*cdf0e10cSrcweir         aNewSize.Width() = nWidth;
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir         aProxyModeFT.SetSizePixel( aNewSize );
596*cdf0e10cSrcweir         aHttpProxyFT.SetSizePixel( aNewSize );
597*cdf0e10cSrcweir 		aHttpsProxyFT.SetSizePixel( aNewSize );
598*cdf0e10cSrcweir         aFtpProxyFT.SetSizePixel( aNewSize );
599*cdf0e10cSrcweir         aNoProxyForFT.SetSizePixel( aNewSize );
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir         const long nDelta = nWidth - nFTWidth;
602*cdf0e10cSrcweir         Point aNewPos = aProxyModeLB.GetPosPixel();
603*cdf0e10cSrcweir         aNewPos.X() += nDelta;
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir         aProxyModeLB.SetPosPixel( aNewPos );
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir         aNewSize = aHttpProxyED.GetSizePixel();
608*cdf0e10cSrcweir         aNewSize.Width() -= nDelta;
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir         aNewPos.Y() = aHttpProxyED.GetPosPixel().Y();
611*cdf0e10cSrcweir         aHttpProxyED.SetPosSizePixel( aNewPos, aNewSize );
612*cdf0e10cSrcweir 		aNewPos.Y() = aHttpsProxyED.GetPosPixel().Y();
613*cdf0e10cSrcweir         aHttpsProxyED.SetPosSizePixel( aNewPos, aNewSize );
614*cdf0e10cSrcweir         aNewPos.Y() = aFtpProxyED.GetPosPixel().Y();
615*cdf0e10cSrcweir         aFtpProxyED.SetPosSizePixel( aNewPos, aNewSize );
616*cdf0e10cSrcweir         aNewPos.Y() = aNoProxyForED.GetPosPixel().Y();
617*cdf0e10cSrcweir         aNoProxyForED.SetPosSizePixel( aNewPos, aNewSize );
618*cdf0e10cSrcweir     }
619*cdf0e10cSrcweir     //<--End buy wuy for i71445 Time: 2007.02.27
620*cdf0e10cSrcweir }
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir /*-----------------12.08.96 13.38-------------------
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir --------------------------------------------------*/
625*cdf0e10cSrcweir void SvxProxyTabPage::EnableControls_Impl(sal_Bool bEnable)
626*cdf0e10cSrcweir {
627*cdf0e10cSrcweir 	aHttpProxyFT.Enable(bEnable);
628*cdf0e10cSrcweir 	aHttpProxyED.Enable(bEnable);
629*cdf0e10cSrcweir 	aHttpPortFT.Enable(bEnable);
630*cdf0e10cSrcweir 	aHttpPortED.Enable(bEnable);
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir 	aHttpsProxyFT.Enable(bEnable);
633*cdf0e10cSrcweir 	aHttpsProxyED.Enable(bEnable);
634*cdf0e10cSrcweir 	aHttpsPortFT.Enable(bEnable);
635*cdf0e10cSrcweir 	aHttpsPortED.Enable(bEnable);
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 	aFtpProxyFT.Enable(bEnable);
638*cdf0e10cSrcweir 	aFtpProxyED.Enable(bEnable);
639*cdf0e10cSrcweir 	aFtpPortFT.Enable(bEnable);
640*cdf0e10cSrcweir 	aFtpPortED.Enable(bEnable);
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	aNoProxyForFT.Enable(bEnable);
643*cdf0e10cSrcweir 	aNoProxyForED.Enable(bEnable);
644*cdf0e10cSrcweir 	aNoProxyDescFT.Enable(bEnable);
645*cdf0e10cSrcweir }
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir // -----------------------------------------------------------------------
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir IMPL_LINK( SvxProxyTabPage, ProxyHdl_Impl, ListBox *, pBox )
650*cdf0e10cSrcweir {
651*cdf0e10cSrcweir     sal_uInt16 nPos = pBox->GetSelectEntryPos();
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir     // Restore original system values
654*cdf0e10cSrcweir     if( nPos == 1 )
655*cdf0e10cSrcweir     {
656*cdf0e10cSrcweir         ReadConfigDefaults_Impl();
657*cdf0e10cSrcweir     }
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir     EnableControls_Impl(nPos == 2);
660*cdf0e10cSrcweir     return 0;
661*cdf0e10cSrcweir }
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir // -----------------------------------------------------------------------
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir IMPL_LINK( SvxProxyTabPage, LoseFocusHdl_Impl, Edit *, pEdit )
666*cdf0e10cSrcweir {
667*cdf0e10cSrcweir 	XubString aValue = pEdit->GetText();
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir 	if ( !ByteString(::rtl::OUStringToOString(aValue,RTL_TEXTENCODING_UTF8)).IsNumericAscii() || (long)aValue.ToInt32() > USHRT_MAX )
670*cdf0e10cSrcweir 		pEdit->SetText( '0' );
671*cdf0e10cSrcweir 	return 0;
672*cdf0e10cSrcweir }
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir /********************************************************************/
676*cdf0e10cSrcweir /********************************************************************/
677*cdf0e10cSrcweir /*                                                                  */
678*cdf0e10cSrcweir /* 	SvxSearchTabPage                                                */
679*cdf0e10cSrcweir /*                                                                  */
680*cdf0e10cSrcweir /*                                                                  */
681*cdf0e10cSrcweir /********************************************************************/
682*cdf0e10cSrcweir /********************************************************************/
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir SvxSearchTabPage::SvxSearchTabPage(Window* pParent, const SfxItemSet& rSet ) :
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_SEARCH ), rSet ),
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 	aSearchGB		( this, CUI_RES( GB_SEARCH ) ),
689*cdf0e10cSrcweir 	aSearchLB		( this, CUI_RES( LB_SEARCH ) ),
690*cdf0e10cSrcweir 	aSearchNameFT	( this, CUI_RES( FT_SEARCH_NAME ) ),
691*cdf0e10cSrcweir 	aSearchNameED	( this, CUI_RES( ED_SEARCH_NAME ) ),
692*cdf0e10cSrcweir 	aSearchFT		( this, CUI_RES( FT_SEARCH ) ),
693*cdf0e10cSrcweir 	aAndRB			( this, CUI_RES( RB_AND ) ),
694*cdf0e10cSrcweir 	aOrRB			( this, CUI_RES( RB_OR ) ),
695*cdf0e10cSrcweir 	aExactRB		( this, CUI_RES( RB_EXACT ) ),
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir 	aURLFT			( this, CUI_RES( FT_URL ) ),
698*cdf0e10cSrcweir 	aURLED			( this, CUI_RES( ED_URL ) ),
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir 	aPostFixFT		( this, CUI_RES( FT_POSTFIX ) ),
701*cdf0e10cSrcweir 	aPostFixED		( this, CUI_RES( ED_POSTFIX ) ),
702*cdf0e10cSrcweir 	aSeparatorFT	( this, CUI_RES( FT_SEPARATOR ) ),
703*cdf0e10cSrcweir 	aSeparatorED	( this, CUI_RES( ED_SEPARATOR ) ),
704*cdf0e10cSrcweir 	aCaseFT			( this, CUI_RES( FT_CASE ) ),
705*cdf0e10cSrcweir 	aCaseED			( this, CUI_RES( ED_CASE ) ),
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir 	aNewPB			( this, CUI_RES( PB_NEW ) ),
708*cdf0e10cSrcweir 	aAddPB			( this, CUI_RES( PB_ADD ) ),
709*cdf0e10cSrcweir 	aChangePB		( this, CUI_RES( PB_CHANGE ) ),
710*cdf0e10cSrcweir     aDeletePB       ( this, CUI_RES( PB_DELETE ) ),
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 	sModifyMsg(CUI_RES(MSG_MODIFY))
713*cdf0e10cSrcweir {
714*cdf0e10cSrcweir 	FreeResource();
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir     SetExchangeSupport();
717*cdf0e10cSrcweir 	aCaseED.SelectEntryPos(0); // falls kein Eintrag vorhanden ist, kann es sonst "Arger geben
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 	aNewPB.SetClickHdl(LINK( this, SvxSearchTabPage, NewSearchHdl_Impl ) );
720*cdf0e10cSrcweir 	aAddPB.SetClickHdl(LINK( this, SvxSearchTabPage, AddSearchHdl_Impl ) );
721*cdf0e10cSrcweir 	aChangePB.SetClickHdl(LINK( this, SvxSearchTabPage, ChangeSearchHdl_Impl ) );
722*cdf0e10cSrcweir 	aDeletePB.SetClickHdl(LINK( this, SvxSearchTabPage, DeleteSearchHdl_Impl ) );
723*cdf0e10cSrcweir 	aSearchLB.SetSelectHdl(LINK( this, SvxSearchTabPage, SearchEntryHdl_Impl ) );
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir 	Link aLink = LINK( this, SvxSearchTabPage, SearchModifyHdl_Impl );
726*cdf0e10cSrcweir 	aSearchNameED.SetModifyHdl( aLink );
727*cdf0e10cSrcweir 	aURLED.SetModifyHdl( aLink );
728*cdf0e10cSrcweir 	aSeparatorED.SetModifyHdl( aLink );
729*cdf0e10cSrcweir 	aPostFixED.SetModifyHdl( aLink );
730*cdf0e10cSrcweir 	aCaseED.SetSelectHdl( aLink );
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir 	aLink = LINK( this, SvxSearchTabPage, SearchPartHdl_Impl );
733*cdf0e10cSrcweir 	aAndRB.SetClickHdl( aLink );
734*cdf0e10cSrcweir 	aOrRB.SetClickHdl( aLink );
735*cdf0e10cSrcweir 	aExactRB.SetClickHdl( aLink );
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir     InitControls_Impl();
738*cdf0e10cSrcweir }
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir // -----------------------------------------------------------------------
741*cdf0e10cSrcweir SvxSearchTabPage::~SvxSearchTabPage()
742*cdf0e10cSrcweir {
743*cdf0e10cSrcweir }
744*cdf0e10cSrcweir // -----------------------------------------------------------------------
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir SfxTabPage*	SvxSearchTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
747*cdf0e10cSrcweir {
748*cdf0e10cSrcweir 	return new SvxSearchTabPage(pParent, rAttrSet);
749*cdf0e10cSrcweir }
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir // -----------------------------------------------------------------------
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir void SvxSearchTabPage::Reset( const SfxItemSet& )
754*cdf0e10cSrcweir {
755*cdf0e10cSrcweir 	//The two lines below are moved here from the last part of this method by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
756*cdf0e10cSrcweir 	aChangePB.Disable();
757*cdf0e10cSrcweir 	aAddPB.Disable();
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir 	sal_uInt16 nCount = aSearchConfig.Count();
760*cdf0e10cSrcweir 	aSearchLB.Clear();  //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
761*cdf0e10cSrcweir     for(sal_uInt16 i = 0; i < nCount; i++)
762*cdf0e10cSrcweir     {
763*cdf0e10cSrcweir         const SvxSearchEngineData& rData = aSearchConfig.GetData(i);
764*cdf0e10cSrcweir         aSearchLB.InsertEntry(rData.sEngineName);
765*cdf0e10cSrcweir     }
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir 	if ( nCount )
768*cdf0e10cSrcweir 	{
769*cdf0e10cSrcweir 		aSearchLB.SelectEntryPos(0);
770*cdf0e10cSrcweir 		SearchEntryHdl_Impl( &aSearchLB );
771*cdf0e10cSrcweir 	}
772*cdf0e10cSrcweir 	else
773*cdf0e10cSrcweir 		aDeletePB.Disable();
774*cdf0e10cSrcweir }
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir // -----------------------------------------------------------------------
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir sal_Bool SvxSearchTabPage::FillItemSet( SfxItemSet&  )
779*cdf0e10cSrcweir {
780*cdf0e10cSrcweir     if(aSearchConfig.IsModified())
781*cdf0e10cSrcweir         aSearchConfig.Commit();
782*cdf0e10cSrcweir     return sal_True;
783*cdf0e10cSrcweir }
784*cdf0e10cSrcweir /*--------------------------------------------------------------------*/
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir void SvxSearchTabPage::ActivatePage( const SfxItemSet&  )
787*cdf0e10cSrcweir {
788*cdf0e10cSrcweir }
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir /*--------------------------------------------------------------------*/
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir int SvxSearchTabPage::DeactivatePage( SfxItemSet* _pSet )
793*cdf0e10cSrcweir {
794*cdf0e10cSrcweir 	//Modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
795*cdf0e10cSrcweir 	if(!ConfirmLeave(String()))
796*cdf0e10cSrcweir 		return KEEP_PAGE;
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir     if ( _pSet )
799*cdf0e10cSrcweir 		FillItemSet( *_pSet );
800*cdf0e10cSrcweir 	return LEAVE_PAGE;
801*cdf0e10cSrcweir }
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir // -----------------------------------------------------------------------
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
806*cdf0e10cSrcweir sal_Bool SvxSearchTabPage::ConfirmLeave( const String& rStringSelection)
807*cdf0e10cSrcweir {
808*cdf0e10cSrcweir     if(aChangePB.IsEnabled())
809*cdf0e10cSrcweir     {
810*cdf0e10cSrcweir         QueryBox aQuery(this, WB_YES_NO_CANCEL|WB_DEF_YES, sModifyMsg);
811*cdf0e10cSrcweir         sal_uInt16 nRet = aQuery.Execute();
812*cdf0e10cSrcweir         if(RET_CANCEL == nRet)
813*cdf0e10cSrcweir 		{
814*cdf0e10cSrcweir 			if(rStringSelection.Len())
815*cdf0e10cSrcweir 				aSearchLB.SelectEntry(sLastSelectedEntry);
816*cdf0e10cSrcweir             return sal_False;
817*cdf0e10cSrcweir 		}
818*cdf0e10cSrcweir         else if(RET_YES == nRet)
819*cdf0e10cSrcweir 		{
820*cdf0e10cSrcweir 			sal_uInt16 nEntryPos = aSearchLB.GetEntryPos( aSearchNameED.GetText() );
821*cdf0e10cSrcweir 			if ( nEntryPos != LISTBOX_ENTRY_NOTFOUND  )
822*cdf0e10cSrcweir 				aSearchLB.SelectEntryPos(nEntryPos);
823*cdf0e10cSrcweir 			else
824*cdf0e10cSrcweir 				aSearchLB.SetNoSelection();
825*cdf0e10cSrcweir             ChangeSearchHdl_Impl(0);
826*cdf0e10cSrcweir 			if(rStringSelection.Len())
827*cdf0e10cSrcweir 				aSearchLB.SelectEntry(rStringSelection);
828*cdf0e10cSrcweir 		}
829*cdf0e10cSrcweir 		else if(RET_NO == nRet)
830*cdf0e10cSrcweir 		{
831*cdf0e10cSrcweir 			aChangePB.Enable(sal_False);
832*cdf0e10cSrcweir 			aAddPB.Enable(sal_False);
833*cdf0e10cSrcweir 			SearchEntryHdl_Impl(&aSearchLB);
834*cdf0e10cSrcweir 		}
835*cdf0e10cSrcweir     }
836*cdf0e10cSrcweir 	if(aAddPB.IsEnabled())
837*cdf0e10cSrcweir 	{
838*cdf0e10cSrcweir 		QueryBox aQuery(this, WB_YES_NO_CANCEL|WB_DEF_YES, sModifyMsg);
839*cdf0e10cSrcweir 		sal_uInt16 nRet = aQuery.Execute();
840*cdf0e10cSrcweir 		if(RET_CANCEL == nRet)
841*cdf0e10cSrcweir 		{
842*cdf0e10cSrcweir 			aSearchLB.SetNoSelection();
843*cdf0e10cSrcweir 			return sal_False;
844*cdf0e10cSrcweir 		}
845*cdf0e10cSrcweir 		else if(RET_YES == nRet)
846*cdf0e10cSrcweir 		{
847*cdf0e10cSrcweir 			aSearchLB.SetNoSelection();
848*cdf0e10cSrcweir 			AddSearchHdl_Impl(0);
849*cdf0e10cSrcweir 			if(rStringSelection.Len())
850*cdf0e10cSrcweir 				aSearchLB.SelectEntry(rStringSelection);
851*cdf0e10cSrcweir 		}
852*cdf0e10cSrcweir 		else if(RET_NO == nRet)
853*cdf0e10cSrcweir 		{
854*cdf0e10cSrcweir 			aAddPB.Enable(sal_False);
855*cdf0e10cSrcweir 			aChangePB.Enable(sal_False);
856*cdf0e10cSrcweir 			NewSearchHdl_Impl(0);
857*cdf0e10cSrcweir 		}
858*cdf0e10cSrcweir 
859*cdf0e10cSrcweir 	}
860*cdf0e10cSrcweir 	return sal_True;
861*cdf0e10cSrcweir }
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir // -----------------------------------------------------------------------
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir void SvxSearchTabPage::InitControls_Impl()
866*cdf0e10cSrcweir {
867*cdf0e10cSrcweir     // detect longest label text
868*cdf0e10cSrcweir     sal_Int32 i = 0;
869*cdf0e10cSrcweir     long nLabelTextWidth = 0;
870*cdf0e10cSrcweir     Window* pLabels[] = { &aSearchNameFT, &aSearchFT, &aURLFT, &aPostFixFT, &aSeparatorFT, &aCaseFT };
871*cdf0e10cSrcweir     Window** pLabel = pLabels;
872*cdf0e10cSrcweir     const sal_Int32 nLabelCount = sizeof( pLabels ) / sizeof( pLabels[0] );
873*cdf0e10cSrcweir     for ( ; i < nLabelCount; ++i, ++pLabel )
874*cdf0e10cSrcweir     {
875*cdf0e10cSrcweir         long nTemp = (*pLabel)->GetCtrlTextWidth( (*pLabel)->GetText() );
876*cdf0e10cSrcweir         if ( nTemp > nLabelTextWidth )
877*cdf0e10cSrcweir             nLabelTextWidth = nTemp;
878*cdf0e10cSrcweir     }
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir     // resize all labels
881*cdf0e10cSrcweir     nLabelTextWidth = nLabelTextWidth * 120 / 100; // additional space looks better
882*cdf0e10cSrcweir     const long nLabelWidth = aSearchNameFT.GetSizePixel().Width();
883*cdf0e10cSrcweir     const long nDelta = nLabelWidth - nLabelTextWidth;
884*cdf0e10cSrcweir     pLabel = pLabels;
885*cdf0e10cSrcweir     for ( i = 0; i < nLabelCount; ++i, ++pLabel )
886*cdf0e10cSrcweir     {
887*cdf0e10cSrcweir         Size aNewSize = (*pLabel)->GetSizePixel();
888*cdf0e10cSrcweir         aNewSize.Width() += nDelta;
889*cdf0e10cSrcweir         (*pLabel)->SetSizePixel( aNewSize );
890*cdf0e10cSrcweir     }
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir     // resize and move the edits
893*cdf0e10cSrcweir     Window* pEdits[] = { &aSearchNameED, &aAndRB, &aOrRB,
894*cdf0e10cSrcweir         &aExactRB, &aURLED, &aPostFixED, &aSeparatorED, &aCaseED };
895*cdf0e10cSrcweir     Window** pEdit = pEdits;
896*cdf0e10cSrcweir     const sal_Int32 nCCount = sizeof( pEdits ) / sizeof( pEdits[ 0 ] );
897*cdf0e10cSrcweir     for ( i = 0; i < nCCount; ++i, ++pEdit )
898*cdf0e10cSrcweir     {
899*cdf0e10cSrcweir         Point aNewPos = (*pEdit)->GetPosPixel();
900*cdf0e10cSrcweir         aNewPos.X() -= nDelta;
901*cdf0e10cSrcweir         Size aNewSize = (*pEdit)->GetSizePixel();
902*cdf0e10cSrcweir         if ( (*pEdit) != &aSeparatorED && (*pEdit) != &aCaseED )
903*cdf0e10cSrcweir             aNewSize.Width() += nDelta;
904*cdf0e10cSrcweir         (*pEdit)->SetPosSizePixel( aNewPos, aNewSize );
905*cdf0e10cSrcweir     }
906*cdf0e10cSrcweir }
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir // -----------------------------------------------------------------------
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir IMPL_LINK( SvxSearchTabPage, NewSearchHdl_Impl, PushButton *, EMPTYARG )
911*cdf0e10cSrcweir {
912*cdf0e10cSrcweir 	//The 3 lines below is modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
913*cdf0e10cSrcweir 	SearchEntryHdl_Impl(&aSearchLB);
914*cdf0e10cSrcweir 	if(aChangePB.IsEnabled() || aAddPB.IsEnabled())
915*cdf0e10cSrcweir 		return 0;
916*cdf0e10cSrcweir 	aSearchNameED.SetText( String() );
917*cdf0e10cSrcweir 	aSearchLB.SetNoSelection();
918*cdf0e10cSrcweir     aCurrentSrchData = SvxSearchEngineData();
919*cdf0e10cSrcweir     aAndRB.Check( sal_True );
920*cdf0e10cSrcweir 	SearchEntryHdl_Impl( &aSearchLB );
921*cdf0e10cSrcweir 	SearchPartHdl_Impl( &aAndRB );
922*cdf0e10cSrcweir 	return 0;
923*cdf0e10cSrcweir }
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir // -----------------------------------------------------------------------
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir IMPL_LINK( SvxSearchTabPage, AddSearchHdl_Impl, PushButton *, EMPTYARG )
928*cdf0e10cSrcweir {
929*cdf0e10cSrcweir 	//The following two lines is added by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
930*cdf0e10cSrcweir 	aAddPB.Enable(sal_False);
931*cdf0e10cSrcweir     aChangePB.Enable(sal_False);
932*cdf0e10cSrcweir     aCurrentSrchData.sEngineName = aSearchNameED.GetText();
933*cdf0e10cSrcweir     aSearchConfig.SetData(aCurrentSrchData);
934*cdf0e10cSrcweir     aSearchLB.InsertEntry( aCurrentSrchData.sEngineName );
935*cdf0e10cSrcweir     aSearchLB.SelectEntry( aCurrentSrchData.sEngineName );
936*cdf0e10cSrcweir 	SearchEntryHdl_Impl( &aSearchLB );
937*cdf0e10cSrcweir 	return 0;
938*cdf0e10cSrcweir }
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir // -----------------------------------------------------------------------
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir IMPL_LINK( SvxSearchTabPage, ChangeSearchHdl_Impl, PushButton *, EMPTYARG )
943*cdf0e10cSrcweir {
944*cdf0e10cSrcweir 	//The following two lines is added by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
945*cdf0e10cSrcweir 	aChangePB.Enable(sal_False);
946*cdf0e10cSrcweir 	aAddPB.Enable(sal_False);
947*cdf0e10cSrcweir 	sal_uInt16 nPos = aSearchLB.GetSelectEntryPos();
948*cdf0e10cSrcweir 	if ( nPos != LISTBOX_ENTRY_NOTFOUND )
949*cdf0e10cSrcweir 	{
950*cdf0e10cSrcweir         String sEngine = aSearchLB.GetSelectEntry();
951*cdf0e10cSrcweir         aCurrentSrchData.sEngineName = sEngine;
952*cdf0e10cSrcweir         aSearchConfig.SetData(aCurrentSrchData);
953*cdf0e10cSrcweir         aSearchLB.SelectEntry(sEngine);
954*cdf0e10cSrcweir 		SearchEntryHdl_Impl(&aSearchLB);
955*cdf0e10cSrcweir 	}
956*cdf0e10cSrcweir 	else
957*cdf0e10cSrcweir 	{
958*cdf0e10cSrcweir 		SetUpdateMode(sal_False);
959*cdf0e10cSrcweir 		String sEntry = aSearchNameED.GetText();
960*cdf0e10cSrcweir 		// im AddHdl wird sLastSelectedEntry umgesetzt
961*cdf0e10cSrcweir 		String sTemp(sLastSelectedEntry);
962*cdf0e10cSrcweir 		AddSearchHdl_Impl(0);
963*cdf0e10cSrcweir 		aSearchLB.SelectEntry(sTemp);
964*cdf0e10cSrcweir 		DeleteSearchHdl_Impl(0);
965*cdf0e10cSrcweir 		aSearchLB.SelectEntry(sEntry);
966*cdf0e10cSrcweir 		SearchEntryHdl_Impl(&aSearchLB);
967*cdf0e10cSrcweir 		SetUpdateMode(sal_True);
968*cdf0e10cSrcweir 	}
969*cdf0e10cSrcweir 	return 0;
970*cdf0e10cSrcweir }
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir // -----------------------------------------------------------------------
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir IMPL_LINK( SvxSearchTabPage, DeleteSearchHdl_Impl, PushButton *, EMPTYARG)
975*cdf0e10cSrcweir {
976*cdf0e10cSrcweir 	aChangePB.Enable(sal_False);     //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
977*cdf0e10cSrcweir 	sal_uInt16 nPos = aSearchLB.GetSelectEntryPos();
978*cdf0e10cSrcweir 	DBG_ASSERT(nPos != LISTBOX_ENTRY_NOTFOUND, "kein Eintrag selektiert!");
979*cdf0e10cSrcweir     aSearchConfig.RemoveData(aSearchLB.GetSelectEntry());
980*cdf0e10cSrcweir     aSearchLB.RemoveEntry(nPos);
981*cdf0e10cSrcweir 	aSearchLB.SelectEntryPos(0);
982*cdf0e10cSrcweir 	SearchEntryHdl_Impl(&aSearchLB);
983*cdf0e10cSrcweir 	return 0;
984*cdf0e10cSrcweir }
985*cdf0e10cSrcweir 
986*cdf0e10cSrcweir // -----------------------------------------------------------------------
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir IMPL_LINK( SvxSearchTabPage, SearchEntryHdl_Impl, ListBox*, pBox )
989*cdf0e10cSrcweir {
990*cdf0e10cSrcweir 	sal_uInt16 nEntryPos = pBox->GetSelectEntryPos();
991*cdf0e10cSrcweir 	if ( nEntryPos != LISTBOX_ENTRY_NOTFOUND )
992*cdf0e10cSrcweir 	{
993*cdf0e10cSrcweir         String sSelection(pBox->GetSelectEntry());
994*cdf0e10cSrcweir 		//Modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
995*cdf0e10cSrcweir 		if(!ConfirmLeave(sSelection))
996*cdf0e10cSrcweir 			return 0;
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir 		const SvxSearchEngineData* pData = aSearchConfig.GetData(sSelection);
999*cdf0e10cSrcweir         DBG_ASSERT(pData, "SearchEngine not available");
1000*cdf0e10cSrcweir         if(pData)
1001*cdf0e10cSrcweir         {
1002*cdf0e10cSrcweir             aSearchNameED.SetText(sSelection);
1003*cdf0e10cSrcweir             sLastSelectedEntry = sSelection;
1004*cdf0e10cSrcweir             sal_Bool bAnd = aAndRB.IsChecked();
1005*cdf0e10cSrcweir             sal_Bool bOr = aOrRB.IsChecked();
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir             aURLED.SetText(bAnd ? pData->sAndPrefix : bOr ? pData->sOrPrefix : pData->sExactPrefix);
1008*cdf0e10cSrcweir             aSeparatorED.SetText( bAnd ? pData->sAndSeparator : bOr ? pData->sOrSeparator : pData->sExactSeparator);
1009*cdf0e10cSrcweir             aPostFixED.SetText(bAnd ? pData->sAndSuffix : bOr ? pData->sOrSuffix : pData->sExactSuffix );
1010*cdf0e10cSrcweir             sal_Int32 nCase = bAnd ? pData->nAndCaseMatch : bOr ? pData->nOrCaseMatch : pData->nExactCaseMatch;
1011*cdf0e10cSrcweir             aCaseED.SelectEntryPos( (sal_uInt16)nCase );
1012*cdf0e10cSrcweir             aCurrentSrchData = *pData;
1013*cdf0e10cSrcweir         }
1014*cdf0e10cSrcweir 		aDeletePB.Enable();
1015*cdf0e10cSrcweir 	}
1016*cdf0e10cSrcweir 	else
1017*cdf0e10cSrcweir 	{
1018*cdf0e10cSrcweir 		aDeletePB.Enable(sal_False);
1019*cdf0e10cSrcweir 		sLastSelectedEntry.Erase();
1020*cdf0e10cSrcweir 	}
1021*cdf0e10cSrcweir 	aChangePB.Enable(sal_False);
1022*cdf0e10cSrcweir 	aAddPB.Enable(sal_False);
1023*cdf0e10cSrcweir 	return 0;
1024*cdf0e10cSrcweir }
1025*cdf0e10cSrcweir 
1026*cdf0e10cSrcweir // -----------------------------------------------------------------------
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir IMPL_LINK( SvxSearchTabPage, SearchModifyHdl_Impl, SvxNoSpaceEdit*, pEdit )
1029*cdf0e10cSrcweir {
1030*cdf0e10cSrcweir 	if ( pEdit == &aSearchNameED )
1031*cdf0e10cSrcweir 	{
1032*cdf0e10cSrcweir 		sal_Bool bTextLen = ( 0 != pEdit->GetText().Len() );
1033*cdf0e10cSrcweir 		sal_Bool bFound = sal_False;
1034*cdf0e10cSrcweir 		if ( bTextLen )
1035*cdf0e10cSrcweir 		{
1036*cdf0e10cSrcweir 			sal_uInt16 nEntryPos = aSearchLB.GetEntryPos( pEdit->GetText() );
1037*cdf0e10cSrcweir 			bFound = ( nEntryPos != LISTBOX_ENTRY_NOTFOUND );
1038*cdf0e10cSrcweir 			if ( bFound )
1039*cdf0e10cSrcweir 				aSearchLB.SelectEntryPos(nEntryPos);
1040*cdf0e10cSrcweir 			else
1041*cdf0e10cSrcweir 				aSearchLB.SetNoSelection();
1042*cdf0e10cSrcweir 		}
1043*cdf0e10cSrcweir 		aChangePB.Enable( sLastSelectedEntry.Len() > 0 );
1044*cdf0e10cSrcweir 		aDeletePB.Enable(bFound);
1045*cdf0e10cSrcweir 		aAddPB.Enable(bTextLen && !bFound);
1046*cdf0e10cSrcweir 	}
1047*cdf0e10cSrcweir 	else
1048*cdf0e10cSrcweir 	{
1049*cdf0e10cSrcweir 		if ( aSearchLB.GetSelectEntryCount() && sLastSelectedEntry.Len() > 0 )
1050*cdf0e10cSrcweir 			aChangePB.Enable();
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir         if(aAndRB.IsChecked())
1053*cdf0e10cSrcweir         {
1054*cdf0e10cSrcweir             aCurrentSrchData.sAndPrefix = aURLED.GetText();
1055*cdf0e10cSrcweir             aCurrentSrchData.sAndSeparator = aSeparatorED.GetText();
1056*cdf0e10cSrcweir             aCurrentSrchData.sAndSuffix = aPostFixED.GetText();
1057*cdf0e10cSrcweir             aCurrentSrchData.nAndCaseMatch = aCaseED.GetSelectEntryPos();
1058*cdf0e10cSrcweir         }
1059*cdf0e10cSrcweir         else if(aOrRB.IsChecked())
1060*cdf0e10cSrcweir         {
1061*cdf0e10cSrcweir             aCurrentSrchData.sOrPrefix = aURLED.GetText();
1062*cdf0e10cSrcweir             aCurrentSrchData.sOrSeparator = aSeparatorED.GetText();
1063*cdf0e10cSrcweir             aCurrentSrchData.sOrSuffix = aPostFixED.GetText();
1064*cdf0e10cSrcweir             aCurrentSrchData.nOrCaseMatch = aCaseED.GetSelectEntryPos();
1065*cdf0e10cSrcweir         }
1066*cdf0e10cSrcweir         else
1067*cdf0e10cSrcweir         {
1068*cdf0e10cSrcweir             aCurrentSrchData.sExactPrefix = aURLED.GetText();
1069*cdf0e10cSrcweir             aCurrentSrchData.sExactSeparator = aSeparatorED.GetText();
1070*cdf0e10cSrcweir             aCurrentSrchData.sExactSuffix = aPostFixED.GetText();
1071*cdf0e10cSrcweir             aCurrentSrchData.nExactCaseMatch = aCaseED.GetSelectEntryPos();
1072*cdf0e10cSrcweir         }
1073*cdf0e10cSrcweir 	}
1074*cdf0e10cSrcweir 	return 0;
1075*cdf0e10cSrcweir }
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir // -----------------------------------------------------------------------
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir IMPL_LINK( SvxSearchTabPage, SearchPartHdl_Impl, RadioButton *, EMPTYARG )
1080*cdf0e10cSrcweir {
1081*cdf0e10cSrcweir     sal_Bool bAnd = aAndRB.IsChecked();
1082*cdf0e10cSrcweir     sal_Bool bOr = aOrRB.IsChecked();
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir     aURLED.SetText(bAnd ? aCurrentSrchData.sAndPrefix : bOr ? aCurrentSrchData.sOrPrefix : aCurrentSrchData.sExactPrefix);
1085*cdf0e10cSrcweir     aSeparatorED.SetText( bAnd ? aCurrentSrchData.sAndSeparator : bOr ? aCurrentSrchData.sOrSeparator : aCurrentSrchData.sExactSeparator);
1086*cdf0e10cSrcweir     aPostFixED.SetText(bAnd ? aCurrentSrchData.sAndSuffix : bOr ? aCurrentSrchData.sOrSuffix : aCurrentSrchData.sExactSuffix );
1087*cdf0e10cSrcweir     sal_Int32 nCase = bAnd ? aCurrentSrchData.nAndCaseMatch : bOr ? aCurrentSrchData.nOrCaseMatch : aCurrentSrchData.nExactCaseMatch;
1088*cdf0e10cSrcweir     aCaseED.SelectEntryPos( (sal_uInt16)nCase );
1089*cdf0e10cSrcweir 	return 0;
1090*cdf0e10cSrcweir }
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir //#98647#----------------------------------------------
1093*cdf0e10cSrcweir void SvxScriptExecListBox::RequestHelp( const HelpEvent& rHEvt )
1094*cdf0e10cSrcweir {   // try to show tips just like as on toolbars
1095*cdf0e10cSrcweir 	sal_uInt16 nPos=LISTBOX_ENTRY_NOTFOUND;
1096*cdf0e10cSrcweir 	sal_uInt16 nTop = GetTopEntry();
1097*cdf0e10cSrcweir 	sal_uInt16 nCount = GetDisplayLineCount(); // Attention: Not GetLineCount()
1098*cdf0e10cSrcweir 	Point aPt = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
1099*cdf0e10cSrcweir 	Rectangle aItemRect;
1100*cdf0e10cSrcweir 	if( nCount > 0 ) // if there're some entries, find it.
1101*cdf0e10cSrcweir  		for( nPos = nTop ; nPos <= nTop+nCount-1 ; nPos++ ) {
1102*cdf0e10cSrcweir 			aItemRect = GetBoundingRectangle(nPos);
1103*cdf0e10cSrcweir 			if( aPt.Y() < aItemRect.Top() || aPt.Y() > aItemRect.Bottom() )
1104*cdf0e10cSrcweir 				continue;
1105*cdf0e10cSrcweir 			else
1106*cdf0e10cSrcweir 				break;
1107*cdf0e10cSrcweir 		}
1108*cdf0e10cSrcweir  	else // if not, nothing happens.
1109*cdf0e10cSrcweir  		return;
1110*cdf0e10cSrcweir  	String aHelpText;
1111*cdf0e10cSrcweir  	if( nPos <= nTop+nCount-1 ) // if find the matching entry, get its content.
1112*cdf0e10cSrcweir  		aHelpText = GetEntry(nPos);
1113*cdf0e10cSrcweir 	if( aHelpText.Len() && GetTextWidth(aHelpText)<GetOutputSizePixel().Width() )
1114*cdf0e10cSrcweir 		aHelpText.Erase(); // if the entry is quite short, clear the helping tip content.
1115*cdf0e10cSrcweir 	aItemRect = Rectangle(Point(0,0),GetSizePixel());
1116*cdf0e10cSrcweir 	aPt = Point(OutputToScreenPixel( aItemRect.TopLeft() ));
1117*cdf0e10cSrcweir 	aItemRect.Left()   = aPt.X();
1118*cdf0e10cSrcweir 	aItemRect.Top()    = aPt.Y();
1119*cdf0e10cSrcweir 	aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1120*cdf0e10cSrcweir 	aItemRect.Right()  = aPt.X();
1121*cdf0e10cSrcweir 	aItemRect.Bottom() = aPt.Y();
1122*cdf0e10cSrcweir 	if( rHEvt.GetMode() == HELPMODE_BALLOON )
1123*cdf0e10cSrcweir 		Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
1124*cdf0e10cSrcweir 	else
1125*cdf0e10cSrcweir 		Help::ShowQuickHelp( this, aItemRect, aHelpText );
1126*cdf0e10cSrcweir }
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir /********************************************************************/
1129*cdf0e10cSrcweir /*                                                                  */
1130*cdf0e10cSrcweir /*  SvxSecurityTabPage                                             */
1131*cdf0e10cSrcweir /*                                                                  */
1132*cdf0e10cSrcweir /********************************************************************/
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir SvxSecurityTabPage::SvxSecurityTabPage( Window* pParent, const SfxItemSet& rSet )
1135*cdf0e10cSrcweir 	:SfxTabPage			( pParent, CUI_RES( RID_SVXPAGE_INET_SECURITY ), rSet )
1136*cdf0e10cSrcweir 
1137*cdf0e10cSrcweir     ,maSecurityOptionsFL( this, CUI_RES( FL_SEC_SECURITYOPTIONS ) )
1138*cdf0e10cSrcweir     ,maSecurityOptionsFI( this, CUI_RES( FI_SEC_SECURITYOPTIONS ) )
1139*cdf0e10cSrcweir     ,maSecurityOptionsPB( this, CUI_RES( PB_SEC_SECURITYOPTIONS ) )
1140*cdf0e10cSrcweir 
1141*cdf0e10cSrcweir     ,maPasswordsFL      ( this, CUI_RES( FL_SEC_PASSWORDS ) )
1142*cdf0e10cSrcweir     ,maSavePasswordsCB  ( this, CUI_RES( CB_SEC_SAVEPASSWORDS ) )
1143*cdf0e10cSrcweir     ,maShowConnectionsPB( this, CUI_RES( PB_SEC_CONNECTIONS ) )
1144*cdf0e10cSrcweir     ,maMasterPasswordCB ( this, CUI_RES( CB_SEC_MASTERPASSWORD ) )
1145*cdf0e10cSrcweir     ,maMasterPasswordFI ( this, CUI_RES( FI_SEC_MASTERPASSWORD ) )
1146*cdf0e10cSrcweir     ,maMasterPasswordPB ( this, CUI_RES( PB_SEC_MASTERPASSWORD ) )
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir     ,maMacroSecFL       ( this, CUI_RES( FL_SEC_MACROSEC ) )
1149*cdf0e10cSrcweir     ,maMacroSecFI       ( this, CUI_RES( FI_SEC_MACROSEC ) )
1150*cdf0e10cSrcweir     ,maMacroSecPB       ( this, CUI_RES( PB_SEC_MACROSEC ) )
1151*cdf0e10cSrcweir 
1152*cdf0e10cSrcweir     ,mpSecOptions       ( new SvtSecurityOptions )
1153*cdf0e10cSrcweir     ,mpSecOptDlg        ( NULL )
1154*cdf0e10cSrcweir 
1155*cdf0e10cSrcweir     ,msPasswordStoringDeactivateStr(    CUI_RES( STR_SEC_NOPASSWDSAVE ) )
1156*cdf0e10cSrcweir 
1157*cdf0e10cSrcweir {
1158*cdf0e10cSrcweir 	FreeResource();
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir     InitControls();
1161*cdf0e10cSrcweir 
1162*cdf0e10cSrcweir     maSecurityOptionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, SecurityOptionsHdl ) );
1163*cdf0e10cSrcweir     maSavePasswordsCB.SetClickHdl( LINK( this, SvxSecurityTabPage, SavePasswordHdl ) );
1164*cdf0e10cSrcweir     maMasterPasswordPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordHdl ) );
1165*cdf0e10cSrcweir     maMasterPasswordCB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordCBHdl ) );
1166*cdf0e10cSrcweir     maShowConnectionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, ShowPasswordsHdl ) );
1167*cdf0e10cSrcweir     maMacroSecPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) );
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir 	ActivatePage( rSet );
1170*cdf0e10cSrcweir }
1171*cdf0e10cSrcweir 
1172*cdf0e10cSrcweir SvxSecurityTabPage::~SvxSecurityTabPage()
1173*cdf0e10cSrcweir {
1174*cdf0e10cSrcweir 	delete mpSecOptions;
1175*cdf0e10cSrcweir     delete mpSecOptDlg;
1176*cdf0e10cSrcweir }
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir IMPL_LINK( SvxSecurityTabPage, SecurityOptionsHdl, PushButton*, EMPTYARG )
1179*cdf0e10cSrcweir {
1180*cdf0e10cSrcweir     if ( !mpSecOptDlg )
1181*cdf0e10cSrcweir         mpSecOptDlg = new svx::SecurityOptionsDialog( this, mpSecOptions );
1182*cdf0e10cSrcweir     mpSecOptDlg->Execute();
1183*cdf0e10cSrcweir     return 0;
1184*cdf0e10cSrcweir }
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir IMPL_LINK( SvxSecurityTabPage, SavePasswordHdl, void*, EMPTYARG )
1187*cdf0e10cSrcweir {
1188*cdf0e10cSrcweir     try
1189*cdf0e10cSrcweir     {
1190*cdf0e10cSrcweir         Reference< task::XMasterPasswordHandling > xMasterPasswd(
1191*cdf0e10cSrcweir             comphelper::getProcessServiceFactory()->createInstance(
1192*cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1193*cdf0e10cSrcweir             UNO_QUERY_THROW );
1194*cdf0e10cSrcweir 
1195*cdf0e10cSrcweir         if ( maSavePasswordsCB.IsChecked() )
1196*cdf0e10cSrcweir         {
1197*cdf0e10cSrcweir             sal_Bool bOldValue = xMasterPasswd->allowPersistentStoring( sal_True );
1198*cdf0e10cSrcweir             xMasterPasswd->removeMasterPassword();
1199*cdf0e10cSrcweir             if ( xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
1200*cdf0e10cSrcweir             {
1201*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_True );
1202*cdf0e10cSrcweir                 maMasterPasswordCB.Check( sal_True );
1203*cdf0e10cSrcweir                 maMasterPasswordCB.Enable( sal_True );
1204*cdf0e10cSrcweir                 maMasterPasswordFI.Enable( sal_True );
1205*cdf0e10cSrcweir                 maShowConnectionsPB.Enable( sal_True );
1206*cdf0e10cSrcweir             }
1207*cdf0e10cSrcweir             else
1208*cdf0e10cSrcweir             {
1209*cdf0e10cSrcweir                 xMasterPasswd->allowPersistentStoring( bOldValue );
1210*cdf0e10cSrcweir                 maSavePasswordsCB.Check( sal_False );
1211*cdf0e10cSrcweir             }
1212*cdf0e10cSrcweir         }
1213*cdf0e10cSrcweir         else
1214*cdf0e10cSrcweir         {
1215*cdf0e10cSrcweir             QueryBox aQuery( this, WB_YES_NO|WB_DEF_NO, msPasswordStoringDeactivateStr );
1216*cdf0e10cSrcweir             sal_uInt16 nRet = aQuery.Execute();
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir             if( RET_YES == nRet )
1219*cdf0e10cSrcweir             {
1220*cdf0e10cSrcweir                 xMasterPasswd->allowPersistentStoring( sal_False );
1221*cdf0e10cSrcweir                 maMasterPasswordCB.Check( sal_True );
1222*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_False );
1223*cdf0e10cSrcweir                 maMasterPasswordCB.Enable( sal_False );
1224*cdf0e10cSrcweir                 maMasterPasswordFI.Enable( sal_False );
1225*cdf0e10cSrcweir                 maShowConnectionsPB.Enable( sal_False );
1226*cdf0e10cSrcweir             }
1227*cdf0e10cSrcweir             else
1228*cdf0e10cSrcweir             {
1229*cdf0e10cSrcweir                 maSavePasswordsCB.Check( sal_True );
1230*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_True );
1231*cdf0e10cSrcweir                 maShowConnectionsPB.Enable( sal_True );
1232*cdf0e10cSrcweir             }
1233*cdf0e10cSrcweir         }
1234*cdf0e10cSrcweir     }
1235*cdf0e10cSrcweir     catch( Exception& )
1236*cdf0e10cSrcweir     {
1237*cdf0e10cSrcweir         maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
1238*cdf0e10cSrcweir     }
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir     return 0;
1241*cdf0e10cSrcweir }
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir IMPL_LINK( SvxSecurityTabPage, MasterPasswordHdl, PushButton*, EMPTYARG )
1244*cdf0e10cSrcweir {
1245*cdf0e10cSrcweir     try
1246*cdf0e10cSrcweir     {
1247*cdf0e10cSrcweir         Reference< task::XMasterPasswordHandling > xMasterPasswd(
1248*cdf0e10cSrcweir             comphelper::getProcessServiceFactory()->createInstance(
1249*cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1250*cdf0e10cSrcweir             UNO_QUERY );
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir         if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() )
1253*cdf0e10cSrcweir             xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() );
1254*cdf0e10cSrcweir     }
1255*cdf0e10cSrcweir     catch( Exception& )
1256*cdf0e10cSrcweir     {}
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir     return 0;
1259*cdf0e10cSrcweir }
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir IMPL_LINK( SvxSecurityTabPage, MasterPasswordCBHdl, void*, EMPTYARG )
1262*cdf0e10cSrcweir {
1263*cdf0e10cSrcweir     try
1264*cdf0e10cSrcweir     {
1265*cdf0e10cSrcweir         Reference< task::XMasterPasswordHandling2 > xMasterPasswd(
1266*cdf0e10cSrcweir             comphelper::getProcessServiceFactory()->createInstance(
1267*cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1268*cdf0e10cSrcweir             UNO_QUERY_THROW );
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir         if ( maMasterPasswordCB.IsChecked() )
1271*cdf0e10cSrcweir         {
1272*cdf0e10cSrcweir             if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
1273*cdf0e10cSrcweir             {
1274*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_True );
1275*cdf0e10cSrcweir                 maMasterPasswordFI.Enable( sal_True );
1276*cdf0e10cSrcweir             }
1277*cdf0e10cSrcweir             else
1278*cdf0e10cSrcweir             {
1279*cdf0e10cSrcweir                 maMasterPasswordCB.Check( sal_False );
1280*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_True );
1281*cdf0e10cSrcweir                 maMasterPasswordFI.Enable( sal_True );
1282*cdf0e10cSrcweir             }
1283*cdf0e10cSrcweir         }
1284*cdf0e10cSrcweir         else
1285*cdf0e10cSrcweir         {
1286*cdf0e10cSrcweir             if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->useDefaultMasterPassword( Reference< task::XInteractionHandler >() ) )
1287*cdf0e10cSrcweir             {
1288*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_False );
1289*cdf0e10cSrcweir                 maMasterPasswordFI.Enable( sal_False );
1290*cdf0e10cSrcweir             }
1291*cdf0e10cSrcweir             else
1292*cdf0e10cSrcweir             {
1293*cdf0e10cSrcweir                 maMasterPasswordCB.Check( sal_True );
1294*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_True );
1295*cdf0e10cSrcweir                 maShowConnectionsPB.Enable( sal_True );
1296*cdf0e10cSrcweir             }
1297*cdf0e10cSrcweir         }
1298*cdf0e10cSrcweir     }
1299*cdf0e10cSrcweir     catch( Exception& )
1300*cdf0e10cSrcweir     {
1301*cdf0e10cSrcweir         maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
1302*cdf0e10cSrcweir     }
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir     return 0;
1305*cdf0e10cSrcweir }
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir IMPL_LINK( SvxSecurityTabPage, ShowPasswordsHdl, PushButton*, EMPTYARG )
1308*cdf0e10cSrcweir {
1309*cdf0e10cSrcweir     try
1310*cdf0e10cSrcweir     {
1311*cdf0e10cSrcweir         Reference< task::XMasterPasswordHandling > xMasterPasswd(
1312*cdf0e10cSrcweir             comphelper::getProcessServiceFactory()->createInstance(
1313*cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1314*cdf0e10cSrcweir             UNO_QUERY );
1315*cdf0e10cSrcweir 
1316*cdf0e10cSrcweir         if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword( Reference< task::XInteractionHandler>() ) )
1317*cdf0e10cSrcweir         {
1318*cdf0e10cSrcweir             svx::WebConnectionInfoDialog aDlg( this );
1319*cdf0e10cSrcweir             aDlg.Execute();
1320*cdf0e10cSrcweir         }
1321*cdf0e10cSrcweir     }
1322*cdf0e10cSrcweir     catch( Exception& )
1323*cdf0e10cSrcweir     {}
1324*cdf0e10cSrcweir     return 0;
1325*cdf0e10cSrcweir }
1326*cdf0e10cSrcweir 
1327*cdf0e10cSrcweir IMPL_LINK( SvxSecurityTabPage, MacroSecPBHdl, void*, EMPTYARG )
1328*cdf0e10cSrcweir {
1329*cdf0e10cSrcweir 	Reference< security::XDocumentDigitalSignatures > xD(
1330*cdf0e10cSrcweir 		comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), UNO_QUERY );
1331*cdf0e10cSrcweir 	if ( xD.is() )
1332*cdf0e10cSrcweir 		xD->manageTrustedSources();
1333*cdf0e10cSrcweir 
1334*cdf0e10cSrcweir 	return 0;
1335*cdf0e10cSrcweir }
1336*cdf0e10cSrcweir 
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir void SvxSecurityTabPage::InitControls()
1339*cdf0e10cSrcweir {
1340*cdf0e10cSrcweir     // Hide all controls which belong to the macro security button in case the macro
1341*cdf0e10cSrcweir     // security settings managed by the macro security dialog opened via the button
1342*cdf0e10cSrcweir     // are all readonly or if the macros are disabled in general.
1343*cdf0e10cSrcweir     // @@@ Better would be to query the dialog whether it is 'useful' or not. Exposing
1344*cdf0e10cSrcweir     //     macro security dialog implementations here, which is bad.
1345*cdf0e10cSrcweir     if (    mpSecOptions->IsMacroDisabled()
1346*cdf0e10cSrcweir          || (    mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_SECLEVEL )
1347*cdf0e10cSrcweir               && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS )
1348*cdf0e10cSrcweir               && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_SECUREURLS ) ) )
1349*cdf0e10cSrcweir     {
1350*cdf0e10cSrcweir         maMacroSecFL.Hide();
1351*cdf0e10cSrcweir         maMacroSecFI.Hide();
1352*cdf0e10cSrcweir         maMacroSecPB.Hide();
1353*cdf0e10cSrcweir     }
1354*cdf0e10cSrcweir 
1355*cdf0e10cSrcweir     // one button too small for its text?
1356*cdf0e10cSrcweir     sal_Int32 i = 0;
1357*cdf0e10cSrcweir     long nBtnTextWidth = 0;
1358*cdf0e10cSrcweir     Window* pButtons[] = { &maSecurityOptionsPB, &maMasterPasswordPB,
1359*cdf0e10cSrcweir                            &maShowConnectionsPB, &maMacroSecPB };
1360*cdf0e10cSrcweir     Window** pButton = pButtons;
1361*cdf0e10cSrcweir     const sal_Int32 nBCount = sizeof( pButtons ) / sizeof( pButtons[ 0 ] );
1362*cdf0e10cSrcweir     for ( ; i < nBCount; ++i, ++pButton )
1363*cdf0e10cSrcweir     {
1364*cdf0e10cSrcweir         long nTemp = (*pButton)->GetCtrlTextWidth( (*pButton)->GetText() );
1365*cdf0e10cSrcweir         if ( nTemp > nBtnTextWidth )
1366*cdf0e10cSrcweir             nBtnTextWidth = nTemp;
1367*cdf0e10cSrcweir     }
1368*cdf0e10cSrcweir 
1369*cdf0e10cSrcweir     nBtnTextWidth = nBtnTextWidth * 115 / 100; // a little offset
1370*cdf0e10cSrcweir     const long nButtonWidth = maSecurityOptionsPB.GetSizePixel().Width();
1371*cdf0e10cSrcweir     const long nMaxWidth = nButtonWidth * 140 / 100;
1372*cdf0e10cSrcweir     long nExtra = ( nBtnTextWidth > nMaxWidth ) ? nBtnTextWidth - nMaxWidth : 0;
1373*cdf0e10cSrcweir     nBtnTextWidth = std::min( nBtnTextWidth, nMaxWidth );
1374*cdf0e10cSrcweir 
1375*cdf0e10cSrcweir     if ( nBtnTextWidth > nButtonWidth )
1376*cdf0e10cSrcweir     {
1377*cdf0e10cSrcweir         // so make the buttons broader and its control in front of it smaller
1378*cdf0e10cSrcweir         long nDelta = nBtnTextWidth - nButtonWidth;
1379*cdf0e10cSrcweir         pButton = pButtons;
1380*cdf0e10cSrcweir 
1381*cdf0e10cSrcweir         if ( nExtra > 0 )
1382*cdf0e10cSrcweir         {
1383*cdf0e10cSrcweir             long nPos = (*pButton)->GetPosPixel().X() - nDelta;
1384*cdf0e10cSrcweir             long nWidth = (*pButton)->GetSizePixel().Width() + nDelta;
1385*cdf0e10cSrcweir             long nMaxExtra = GetOutputSizePixel().Width() - ( nPos + nWidth ) - 2;
1386*cdf0e10cSrcweir             nExtra = ( nExtra < nMaxExtra ) ? nExtra : nMaxExtra;
1387*cdf0e10cSrcweir         }
1388*cdf0e10cSrcweir 
1389*cdf0e10cSrcweir         for ( i = 0; i < nBCount; ++i, ++pButton )
1390*cdf0e10cSrcweir         {
1391*cdf0e10cSrcweir             Point aNewPos = (*pButton)->GetPosPixel();
1392*cdf0e10cSrcweir             aNewPos.X() -= nDelta;
1393*cdf0e10cSrcweir             Size aNewSize = (*pButton)->GetSizePixel();
1394*cdf0e10cSrcweir             aNewSize.Width() += ( nDelta + nExtra );
1395*cdf0e10cSrcweir             (*pButton)->SetPosSizePixel( aNewPos, aNewSize );
1396*cdf0e10cSrcweir         }
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir         Window* pControls[] = { &maSecurityOptionsFI, &maSavePasswordsCB,
1399*cdf0e10cSrcweir                                 &maMasterPasswordFI, &maMacroSecFI };
1400*cdf0e10cSrcweir         Window** pControl = pControls;
1401*cdf0e10cSrcweir         const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[ 0 ] );
1402*cdf0e10cSrcweir         for ( i = 0; i < nCCount; ++i, ++pControl )
1403*cdf0e10cSrcweir         {
1404*cdf0e10cSrcweir             Size aNewSize = (*pControl)->GetSizePixel();
1405*cdf0e10cSrcweir             aNewSize.Width() -= nDelta;
1406*cdf0e10cSrcweir             (*pControl)->SetSizePixel( aNewSize );
1407*cdf0e10cSrcweir         }
1408*cdf0e10cSrcweir     }
1409*cdf0e10cSrcweir 
1410*cdf0e10cSrcweir     maMasterPasswordPB.Enable( sal_False );
1411*cdf0e10cSrcweir     maMasterPasswordCB.Enable( sal_False );
1412*cdf0e10cSrcweir     maMasterPasswordCB.Check( sal_True );
1413*cdf0e10cSrcweir     maMasterPasswordFI.Enable( sal_False );
1414*cdf0e10cSrcweir     maShowConnectionsPB.Enable( sal_False );
1415*cdf0e10cSrcweir 
1416*cdf0e10cSrcweir     // initialize the password saving checkbox
1417*cdf0e10cSrcweir     try
1418*cdf0e10cSrcweir     {
1419*cdf0e10cSrcweir         Reference< task::XMasterPasswordHandling > xMasterPasswd(
1420*cdf0e10cSrcweir             comphelper::getProcessServiceFactory()->createInstance(
1421*cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1422*cdf0e10cSrcweir             UNO_QUERY_THROW );
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir         if ( xMasterPasswd->isPersistentStoringAllowed() )
1425*cdf0e10cSrcweir         {
1426*cdf0e10cSrcweir             maMasterPasswordCB.Enable( sal_True );
1427*cdf0e10cSrcweir             maShowConnectionsPB.Enable( sal_True );
1428*cdf0e10cSrcweir             maSavePasswordsCB.Check( sal_True );
1429*cdf0e10cSrcweir 
1430*cdf0e10cSrcweir             Reference< task::XMasterPasswordHandling2 > xMasterPasswd2( xMasterPasswd, UNO_QUERY );
1431*cdf0e10cSrcweir             if ( xMasterPasswd2.is() && xMasterPasswd2->isDefaultMasterPasswordUsed() )
1432*cdf0e10cSrcweir                 maMasterPasswordCB.Check( sal_False );
1433*cdf0e10cSrcweir             else
1434*cdf0e10cSrcweir             {
1435*cdf0e10cSrcweir                 maMasterPasswordPB.Enable( sal_True );
1436*cdf0e10cSrcweir                 maMasterPasswordCB.Check( sal_True );
1437*cdf0e10cSrcweir                 maMasterPasswordFI.Enable( sal_True );
1438*cdf0e10cSrcweir             }
1439*cdf0e10cSrcweir         }
1440*cdf0e10cSrcweir     }
1441*cdf0e10cSrcweir     catch( Exception& )
1442*cdf0e10cSrcweir     {
1443*cdf0e10cSrcweir         maSavePasswordsCB.Enable( sal_False );
1444*cdf0e10cSrcweir     }
1445*cdf0e10cSrcweir 
1446*cdf0e10cSrcweir 
1447*cdf0e10cSrcweir }
1448*cdf0e10cSrcweir 
1449*cdf0e10cSrcweir SfxTabPage* SvxSecurityTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
1450*cdf0e10cSrcweir {
1451*cdf0e10cSrcweir 	return new SvxSecurityTabPage(pParent, rAttrSet);
1452*cdf0e10cSrcweir }
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir void SvxSecurityTabPage::ActivatePage( const SfxItemSet& )
1455*cdf0e10cSrcweir {
1456*cdf0e10cSrcweir }
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir int SvxSecurityTabPage::DeactivatePage( SfxItemSet* _pSet )
1459*cdf0e10cSrcweir {
1460*cdf0e10cSrcweir     if( _pSet )
1461*cdf0e10cSrcweir 		FillItemSet( *_pSet );
1462*cdf0e10cSrcweir 	return LEAVE_PAGE;
1463*cdf0e10cSrcweir }
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir namespace
1466*cdf0e10cSrcweir {
1467*cdf0e10cSrcweir     bool CheckAndSave( SvtSecurityOptions& _rOpt, SvtSecurityOptions::EOption _eOpt, const bool _bIsChecked, bool& _rModfied )
1468*cdf0e10cSrcweir 	{
1469*cdf0e10cSrcweir         bool bModified = false;
1470*cdf0e10cSrcweir         if ( _rOpt.IsOptionEnabled( _eOpt ) )
1471*cdf0e10cSrcweir 		{
1472*cdf0e10cSrcweir             bModified = _rOpt.IsOptionSet( _eOpt ) != _bIsChecked;
1473*cdf0e10cSrcweir             if ( bModified )
1474*cdf0e10cSrcweir 			{
1475*cdf0e10cSrcweir                 _rOpt.SetOption( _eOpt, _bIsChecked );
1476*cdf0e10cSrcweir 				_rModfied = true;
1477*cdf0e10cSrcweir 			}
1478*cdf0e10cSrcweir 		}
1479*cdf0e10cSrcweir 
1480*cdf0e10cSrcweir 		return bModified;
1481*cdf0e10cSrcweir 	}
1482*cdf0e10cSrcweir }
1483*cdf0e10cSrcweir 
1484*cdf0e10cSrcweir sal_Bool SvxSecurityTabPage::FillItemSet( SfxItemSet& )
1485*cdf0e10cSrcweir {
1486*cdf0e10cSrcweir 	bool bModified = false;
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir     if ( mpSecOptDlg )
1489*cdf0e10cSrcweir     {
1490*cdf0e10cSrcweir         CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SAVEORSEND, mpSecOptDlg->IsSaveOrSendDocsChecked(), bModified );
1491*cdf0e10cSrcweir         CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SIGNING, mpSecOptDlg->IsSignDocsChecked(), bModified );
1492*cdf0e10cSrcweir         CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_PRINT, mpSecOptDlg->IsPrintDocsChecked(), bModified );
1493*cdf0e10cSrcweir         CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_CREATEPDF, mpSecOptDlg->IsCreatePdfChecked(), bModified );
1494*cdf0e10cSrcweir         CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO, mpSecOptDlg->IsRemovePersInfoChecked(), bModified );
1495*cdf0e10cSrcweir         CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD, mpSecOptDlg->IsRecommPasswdChecked(), bModified );
1496*cdf0e10cSrcweir         CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_CTRLCLICK_HYPERLINK, mpSecOptDlg->IsCtrlHyperlinkChecked(), bModified );
1497*cdf0e10cSrcweir     }
1498*cdf0e10cSrcweir 
1499*cdf0e10cSrcweir 	return bModified;
1500*cdf0e10cSrcweir }
1501*cdf0e10cSrcweir 
1502*cdf0e10cSrcweir /*--------------------------------------------------------------------*/
1503*cdf0e10cSrcweir 
1504*cdf0e10cSrcweir void SvxSecurityTabPage::Reset( const SfxItemSet& )
1505*cdf0e10cSrcweir {
1506*cdf0e10cSrcweir 	SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
1507*cdf0e10cSrcweir 	if( pCurDocShell )
1508*cdf0e10cSrcweir 	{
1509*cdf0e10cSrcweir 	}
1510*cdf0e10cSrcweir }
1511*cdf0e10cSrcweir 
1512*cdf0e10cSrcweir //added by jmeng begin
1513*cdf0e10cSrcweir MozPluginTabPage::MozPluginTabPage(Window* pParent, const SfxItemSet& rSet)
1514*cdf0e10cSrcweir 	: SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_MOZPLUGIN ), rSet ),
1515*cdf0e10cSrcweir 	aMSWordGB		( this, CUI_RES( GB_MOZPLUGIN	    ) ),
1516*cdf0e10cSrcweir 	aWBasicCodeCB	( this, CUI_RES( CB_MOZPLUGIN_CODE ) )
1517*cdf0e10cSrcweir {
1518*cdf0e10cSrcweir 	FreeResource();
1519*cdf0e10cSrcweir }
1520*cdf0e10cSrcweir 
1521*cdf0e10cSrcweir MozPluginTabPage::~MozPluginTabPage()
1522*cdf0e10cSrcweir {
1523*cdf0e10cSrcweir }
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir SfxTabPage*	MozPluginTabPage::Create( Window* pParent,
1526*cdf0e10cSrcweir 										const SfxItemSet& rAttrSet )
1527*cdf0e10cSrcweir {
1528*cdf0e10cSrcweir 	return new MozPluginTabPage( pParent, rAttrSet );
1529*cdf0e10cSrcweir }
1530*cdf0e10cSrcweir sal_Bool MozPluginTabPage::FillItemSet( SfxItemSet& )
1531*cdf0e10cSrcweir {
1532*cdf0e10cSrcweir 	sal_Bool hasInstall = isInstalled();
1533*cdf0e10cSrcweir 	sal_Bool hasChecked = aWBasicCodeCB.IsChecked();
1534*cdf0e10cSrcweir 	if(hasInstall && (!hasChecked)){
1535*cdf0e10cSrcweir 		//try to uninstall
1536*cdf0e10cSrcweir 		uninstallPlugin();
1537*cdf0e10cSrcweir 	}
1538*cdf0e10cSrcweir 	else if((!hasInstall) && hasChecked){
1539*cdf0e10cSrcweir 		//try to install
1540*cdf0e10cSrcweir 		installPlugin();
1541*cdf0e10cSrcweir 	}
1542*cdf0e10cSrcweir 	else{
1543*cdf0e10cSrcweir 		// do nothing
1544*cdf0e10cSrcweir 	}
1545*cdf0e10cSrcweir 	return sal_True;
1546*cdf0e10cSrcweir }
1547*cdf0e10cSrcweir void MozPluginTabPage::Reset( const SfxItemSet& )
1548*cdf0e10cSrcweir {
1549*cdf0e10cSrcweir 		aWBasicCodeCB.Check( isInstalled());
1550*cdf0e10cSrcweir 		aWBasicCodeCB.SaveValue();
1551*cdf0e10cSrcweir }
1552*cdf0e10cSrcweir 
1553*cdf0e10cSrcweir #ifdef WNT
1554*cdf0e10cSrcweir extern "C" {
1555*cdf0e10cSrcweir 	int lc_isInstalled(const  char* realFilePath);
1556*cdf0e10cSrcweir 	int lc_installPlugin(const  char* realFilePath);
1557*cdf0e10cSrcweir 	int lc_uninstallPlugin(const  char* realFilePath);
1558*cdf0e10cSrcweir }
1559*cdf0e10cSrcweir #endif
1560*cdf0e10cSrcweir 
1561*cdf0e10cSrcweir #define NPP_PATH_MAX 2048
1562*cdf0e10cSrcweir inline bool getDllURL(rtl::OString * path)
1563*cdf0e10cSrcweir {
1564*cdf0e10cSrcweir     OSL_ASSERT(path != NULL);
1565*cdf0e10cSrcweir     ::rtl::OUString dirPath/*dllPath, */;
1566*cdf0e10cSrcweir     if (osl_getExecutableFile(&dirPath.pData) != osl_Process_E_None) {
1567*cdf0e10cSrcweir         return false;
1568*cdf0e10cSrcweir     }
1569*cdf0e10cSrcweir     dirPath = dirPath.copy(0, dirPath.lastIndexOf('/'));
1570*cdf0e10cSrcweir //    osl::FileBase::getAbsoluteFileURL(dirPath, libPath, dllPath);
1571*cdf0e10cSrcweir     ::rtl::OUString sysDirPath;
1572*cdf0e10cSrcweir 	osl::FileBase::getSystemPathFromFileURL(dirPath, sysDirPath);
1573*cdf0e10cSrcweir     *path = OUStringToOString(sysDirPath, RTL_TEXTENCODING_ASCII_US);
1574*cdf0e10cSrcweir     return true;
1575*cdf0e10cSrcweir }
1576*cdf0e10cSrcweir 
1577*cdf0e10cSrcweir sal_Bool MozPluginTabPage::isInstalled()
1578*cdf0e10cSrcweir {
1579*cdf0e10cSrcweir #ifdef UNIX
1580*cdf0e10cSrcweir     // get the real file referred by .so lnk file
1581*cdf0e10cSrcweir     char lnkFilePath[NPP_PATH_MAX] = {0};
1582*cdf0e10cSrcweir     char lnkReferFilePath[NPP_PATH_MAX] = {0};
1583*cdf0e10cSrcweir     char* pHome = getpwuid(getuid())->pw_dir;
1584*cdf0e10cSrcweir 	strcat(lnkFilePath, pHome);
1585*cdf0e10cSrcweir 	strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1586*cdf0e10cSrcweir 
1587*cdf0e10cSrcweir 	struct stat sBuf;
1588*cdf0e10cSrcweir 	if (0 > lstat(lnkFilePath, &sBuf))
1589*cdf0e10cSrcweir 	    return false;
1590*cdf0e10cSrcweir     if (!S_ISLNK(sBuf.st_mode))
1591*cdf0e10cSrcweir 		return false;
1592*cdf0e10cSrcweir     if (0 >= readlink(lnkFilePath, lnkReferFilePath, NPP_PATH_MAX))
1593*cdf0e10cSrcweir 		return false;
1594*cdf0e10cSrcweir     // If the link is relative, then we regard it as non-standard
1595*cdf0e10cSrcweir     if (lnkReferFilePath[0] != '/')
1596*cdf0e10cSrcweir         return false;
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir     // get the real file path
1599*cdf0e10cSrcweir     char realFilePath[NPP_PATH_MAX] = {0};
1600*cdf0e10cSrcweir     ::rtl::OString tempString;
1601*cdf0e10cSrcweir     if (!getDllURL(&tempString)) {
1602*cdf0e10cSrcweir         return false;
1603*cdf0e10cSrcweir     }
1604*cdf0e10cSrcweir     strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1605*cdf0e10cSrcweir 	strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
1606*cdf0e10cSrcweir 
1607*cdf0e10cSrcweir     if (0 != strcmp(lnkReferFilePath, realFilePath))
1608*cdf0e10cSrcweir         return false;
1609*cdf0e10cSrcweir     return true;
1610*cdf0e10cSrcweir #endif
1611*cdf0e10cSrcweir #ifdef WNT
1612*cdf0e10cSrcweir 	// get the value from registry
1613*cdf0e10cSrcweir 		sal_Bool ret = true;
1614*cdf0e10cSrcweir 	::rtl::OString tempString;
1615*cdf0e10cSrcweir 	char realFilePath[NPP_PATH_MAX] = {0};
1616*cdf0e10cSrcweir     if (!getDllURL(&tempString)){
1617*cdf0e10cSrcweir         return false;
1618*cdf0e10cSrcweir     }
1619*cdf0e10cSrcweir     strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1620*cdf0e10cSrcweir 	if(! lc_isInstalled(realFilePath))
1621*cdf0e10cSrcweir 		ret =true;
1622*cdf0e10cSrcweir 	else
1623*cdf0e10cSrcweir 		ret = false;
1624*cdf0e10cSrcweir 	return ret;
1625*cdf0e10cSrcweir #endif
1626*cdf0e10cSrcweir }
1627*cdf0e10cSrcweir 
1628*cdf0e10cSrcweir sal_Bool MozPluginTabPage::installPlugin()
1629*cdf0e10cSrcweir {
1630*cdf0e10cSrcweir #ifdef UNIX
1631*cdf0e10cSrcweir     // get the real file referred by .so lnk file
1632*cdf0e10cSrcweir     char lnkFilePath[NPP_PATH_MAX] = {0};
1633*cdf0e10cSrcweir     char* pHome = getpwuid(getuid())->pw_dir;
1634*cdf0e10cSrcweir 	strcat(lnkFilePath, pHome);
1635*cdf0e10cSrcweir     strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1636*cdf0e10cSrcweir     remove(lnkFilePath);
1637*cdf0e10cSrcweir 
1638*cdf0e10cSrcweir     // create the dirs if necessary
1639*cdf0e10cSrcweir     struct stat buf;
1640*cdf0e10cSrcweir     char tmpDir[NPP_PATH_MAX] = {0};
1641*cdf0e10cSrcweir     sprintf(tmpDir, "%s/.mozilla", pHome);
1642*cdf0e10cSrcweir     if (0 > stat(lnkFilePath, &buf))
1643*cdf0e10cSrcweir     {
1644*cdf0e10cSrcweir         mkdir(tmpDir, 0755);
1645*cdf0e10cSrcweir         strcat(tmpDir, "/plugins");
1646*cdf0e10cSrcweir         mkdir(tmpDir, 0755);
1647*cdf0e10cSrcweir     }
1648*cdf0e10cSrcweir 
1649*cdf0e10cSrcweir     // get the real file path
1650*cdf0e10cSrcweir     char realFilePath[NPP_PATH_MAX] = {0};
1651*cdf0e10cSrcweir     ::rtl::OString tempString;
1652*cdf0e10cSrcweir     if (!getDllURL(&tempString)) {
1653*cdf0e10cSrcweir         return false;
1654*cdf0e10cSrcweir     }
1655*cdf0e10cSrcweir     strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1656*cdf0e10cSrcweir 	strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
1657*cdf0e10cSrcweir 
1658*cdf0e10cSrcweir     // create the link
1659*cdf0e10cSrcweir     if (0 != symlink(realFilePath, lnkFilePath))
1660*cdf0e10cSrcweir         return false;
1661*cdf0e10cSrcweir     return true;
1662*cdf0e10cSrcweir #endif
1663*cdf0e10cSrcweir #ifdef WNT
1664*cdf0e10cSrcweir 	::rtl::OString tempString;
1665*cdf0e10cSrcweir 	char realFilePath[NPP_PATH_MAX] = {0};
1666*cdf0e10cSrcweir     if (!getDllURL(&tempString)) {
1667*cdf0e10cSrcweir         return false;
1668*cdf0e10cSrcweir     }
1669*cdf0e10cSrcweir     strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1670*cdf0e10cSrcweir 	if( !lc_installPlugin(realFilePath))
1671*cdf0e10cSrcweir 		return true;
1672*cdf0e10cSrcweir 	else
1673*cdf0e10cSrcweir 		return false;
1674*cdf0e10cSrcweir #endif
1675*cdf0e10cSrcweir }
1676*cdf0e10cSrcweir 
1677*cdf0e10cSrcweir sal_Bool MozPluginTabPage::uninstallPlugin()
1678*cdf0e10cSrcweir {
1679*cdf0e10cSrcweir #ifdef UNIX
1680*cdf0e10cSrcweir     // get the real file referred by .so lnk file
1681*cdf0e10cSrcweir     char lnkFilePath[NPP_PATH_MAX] = {0};
1682*cdf0e10cSrcweir     char* pHome = getpwuid(getuid())->pw_dir;
1683*cdf0e10cSrcweir 	strcat(lnkFilePath, pHome);
1684*cdf0e10cSrcweir 	strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1685*cdf0e10cSrcweir 
1686*cdf0e10cSrcweir 	if(0 > remove(lnkFilePath))
1687*cdf0e10cSrcweir 	    return false;
1688*cdf0e10cSrcweir 	return true;
1689*cdf0e10cSrcweir #endif
1690*cdf0e10cSrcweir #ifdef WNT
1691*cdf0e10cSrcweir 	::rtl::OString tempString;
1692*cdf0e10cSrcweir 	char realFilePath[NPP_PATH_MAX] = {0};
1693*cdf0e10cSrcweir     if (!getDllURL(&tempString)) {
1694*cdf0e10cSrcweir         return false;
1695*cdf0e10cSrcweir     }
1696*cdf0e10cSrcweir     strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1697*cdf0e10cSrcweir 	if(!lc_uninstallPlugin(realFilePath))
1698*cdf0e10cSrcweir 		return true;
1699*cdf0e10cSrcweir 	else
1700*cdf0e10cSrcweir 		return false;
1701*cdf0e10cSrcweir #endif
1702*cdf0e10cSrcweir }
1703*cdf0e10cSrcweir //added by jmeng end
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1706*cdf0e10cSrcweir 
1707*cdf0e10cSrcweir class MailerProgramCfg_Impl : public utl::ConfigItem
1708*cdf0e10cSrcweir {
1709*cdf0e10cSrcweir     friend class SvxEMailTabPage;
1710*cdf0e10cSrcweir     // variables
1711*cdf0e10cSrcweir     OUString sProgram;
1712*cdf0e10cSrcweir     // readonly states
1713*cdf0e10cSrcweir     sal_Bool bROProgram;
1714*cdf0e10cSrcweir 
1715*cdf0e10cSrcweir     const Sequence<OUString> GetPropertyNames();
1716*cdf0e10cSrcweir public:
1717*cdf0e10cSrcweir     MailerProgramCfg_Impl();
1718*cdf0e10cSrcweir     virtual ~MailerProgramCfg_Impl();
1719*cdf0e10cSrcweir 
1720*cdf0e10cSrcweir 	virtual void	Commit();
1721*cdf0e10cSrcweir 	virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames);
1722*cdf0e10cSrcweir };
1723*cdf0e10cSrcweir 
1724*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1725*cdf0e10cSrcweir 
1726*cdf0e10cSrcweir MailerProgramCfg_Impl::MailerProgramCfg_Impl() :
1727*cdf0e10cSrcweir     utl::ConfigItem(C2U("Office.Common/ExternalMailer")),
1728*cdf0e10cSrcweir     bROProgram(sal_False)
1729*cdf0e10cSrcweir {
1730*cdf0e10cSrcweir     const Sequence< OUString > aNames = GetPropertyNames();
1731*cdf0e10cSrcweir     const Sequence< Any > aValues = GetProperties(aNames);
1732*cdf0e10cSrcweir     const Sequence< sal_Bool > aROStates = GetReadOnlyStates(aNames);
1733*cdf0e10cSrcweir     const Any* pValues = aValues.getConstArray();
1734*cdf0e10cSrcweir     const sal_Bool* pROStates = aROStates.getConstArray();
1735*cdf0e10cSrcweir     for(sal_Int32 nProp = 0; nProp < aValues.getLength(); nProp++)
1736*cdf0e10cSrcweir     {
1737*cdf0e10cSrcweir         if(pValues[nProp].hasValue())
1738*cdf0e10cSrcweir         {
1739*cdf0e10cSrcweir             switch(nProp)
1740*cdf0e10cSrcweir             {
1741*cdf0e10cSrcweir                 case 0 :
1742*cdf0e10cSrcweir                 {
1743*cdf0e10cSrcweir                     pValues[nProp] >>= sProgram;
1744*cdf0e10cSrcweir                     bROProgram = pROStates[nProp];
1745*cdf0e10cSrcweir                 }
1746*cdf0e10cSrcweir                 break;
1747*cdf0e10cSrcweir             }
1748*cdf0e10cSrcweir         }
1749*cdf0e10cSrcweir     }
1750*cdf0e10cSrcweir }
1751*cdf0e10cSrcweir 
1752*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir MailerProgramCfg_Impl::~MailerProgramCfg_Impl()
1755*cdf0e10cSrcweir {
1756*cdf0e10cSrcweir }
1757*cdf0e10cSrcweir 
1758*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1759*cdf0e10cSrcweir 
1760*cdf0e10cSrcweir const Sequence<OUString> MailerProgramCfg_Impl::GetPropertyNames()
1761*cdf0e10cSrcweir {
1762*cdf0e10cSrcweir     Sequence<OUString> aRet(1);
1763*cdf0e10cSrcweir     OUString* pRet = aRet.getArray();
1764*cdf0e10cSrcweir     pRet[0] = C2U("Program");
1765*cdf0e10cSrcweir     return aRet;
1766*cdf0e10cSrcweir }
1767*cdf0e10cSrcweir 
1768*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1769*cdf0e10cSrcweir 
1770*cdf0e10cSrcweir void MailerProgramCfg_Impl::Commit()
1771*cdf0e10cSrcweir {
1772*cdf0e10cSrcweir     const Sequence< OUString > aOrgNames = GetPropertyNames();
1773*cdf0e10cSrcweir     sal_Int32 nOrgCount = aOrgNames.getLength();
1774*cdf0e10cSrcweir 
1775*cdf0e10cSrcweir     Sequence< OUString > aNames(nOrgCount);
1776*cdf0e10cSrcweir     Sequence< Any > aValues(nOrgCount);
1777*cdf0e10cSrcweir     sal_Int32 nRealCount = 0;
1778*cdf0e10cSrcweir 
1779*cdf0e10cSrcweir     for(int nProp = 0; nProp < nOrgCount; nProp++)
1780*cdf0e10cSrcweir     {
1781*cdf0e10cSrcweir 	switch(nProp)
1782*cdf0e10cSrcweir 	{
1783*cdf0e10cSrcweir             case  0:
1784*cdf0e10cSrcweir             {
1785*cdf0e10cSrcweir                 if (!bROProgram)
1786*cdf0e10cSrcweir                 {
1787*cdf0e10cSrcweir                     aNames[nRealCount] = aOrgNames[nProp];
1788*cdf0e10cSrcweir                     aValues[nRealCount] <<= sProgram;
1789*cdf0e10cSrcweir                     ++nRealCount;
1790*cdf0e10cSrcweir                 }
1791*cdf0e10cSrcweir             }
1792*cdf0e10cSrcweir             break;
1793*cdf0e10cSrcweir         }
1794*cdf0e10cSrcweir     }
1795*cdf0e10cSrcweir 
1796*cdf0e10cSrcweir     aNames.realloc(nRealCount);
1797*cdf0e10cSrcweir     aValues.realloc(nRealCount);
1798*cdf0e10cSrcweir     PutProperties(aNames, aValues);
1799*cdf0e10cSrcweir }
1800*cdf0e10cSrcweir 
1801*cdf0e10cSrcweir void MailerProgramCfg_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
1802*cdf0e10cSrcweir {
1803*cdf0e10cSrcweir }
1804*cdf0e10cSrcweir 
1805*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1806*cdf0e10cSrcweir 
1807*cdf0e10cSrcweir struct SvxEMailTabPage_Impl
1808*cdf0e10cSrcweir {
1809*cdf0e10cSrcweir     MailerProgramCfg_Impl aMailConfig;
1810*cdf0e10cSrcweir };
1811*cdf0e10cSrcweir 
1812*cdf0e10cSrcweir SvxEMailTabPage::SvxEMailTabPage(Window* pParent, const SfxItemSet& rSet) :
1813*cdf0e10cSrcweir     SfxTabPage(pParent, CUI_RES( RID_SVXPAGE_INET_MAIL ), rSet),
1814*cdf0e10cSrcweir     aMailFL(this,           CUI_RES(FL_MAIL           )),
1815*cdf0e10cSrcweir     aMailerURLFI(this,      CUI_RES(FI_MAILERURL      )),
1816*cdf0e10cSrcweir     aMailerURLFT(this,      CUI_RES(FT_MAILERURL      )),
1817*cdf0e10cSrcweir     aMailerURLED(this,      CUI_RES(ED_MAILERURL      )),
1818*cdf0e10cSrcweir     aMailerURLPB(this,      CUI_RES(PB_MAILERURL      )),
1819*cdf0e10cSrcweir     m_sDefaultFilterName(	CUI_RES(STR_DEFAULT_FILENAME		)),
1820*cdf0e10cSrcweir     pImpl(new SvxEMailTabPage_Impl)
1821*cdf0e10cSrcweir {
1822*cdf0e10cSrcweir     FreeResource();
1823*cdf0e10cSrcweir 
1824*cdf0e10cSrcweir     aMailerURLPB.SetClickHdl( LINK( this, SvxEMailTabPage, FileDialogHdl_Impl ) );
1825*cdf0e10cSrcweir 
1826*cdf0e10cSrcweir     // FixedText not wide enough?
1827*cdf0e10cSrcweir     long nTxtW = aMailerURLFT.GetCtrlTextWidth( aMailerURLFT.GetText() );
1828*cdf0e10cSrcweir     long nCtrlW = aMailerURLFT.GetSizePixel().Width();
1829*cdf0e10cSrcweir     if ( nTxtW >= nCtrlW )
1830*cdf0e10cSrcweir     {
1831*cdf0e10cSrcweir         long nDelta = Max( (long)10, nTxtW - nCtrlW );
1832*cdf0e10cSrcweir         // so FixedText wider
1833*cdf0e10cSrcweir         Size aNewSz = aMailerURLFT.GetSizePixel();
1834*cdf0e10cSrcweir         aNewSz.Width() += nDelta;
1835*cdf0e10cSrcweir         aMailerURLFT.SetSizePixel( aNewSz );
1836*cdf0e10cSrcweir         // and Edit smaller
1837*cdf0e10cSrcweir         aNewSz = aMailerURLED.GetSizePixel();
1838*cdf0e10cSrcweir         aNewSz.Width() -= nDelta;
1839*cdf0e10cSrcweir         Point aNewPt = aMailerURLED.GetPosPixel();
1840*cdf0e10cSrcweir         aNewPt.X() += nDelta;
1841*cdf0e10cSrcweir         aMailerURLED.SetPosSizePixel( aNewPt, aNewSz );
1842*cdf0e10cSrcweir     }
1843*cdf0e10cSrcweir }
1844*cdf0e10cSrcweir 
1845*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1846*cdf0e10cSrcweir 
1847*cdf0e10cSrcweir SvxEMailTabPage::~SvxEMailTabPage()
1848*cdf0e10cSrcweir {
1849*cdf0e10cSrcweir     delete pImpl;
1850*cdf0e10cSrcweir }
1851*cdf0e10cSrcweir 
1852*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1853*cdf0e10cSrcweir 
1854*cdf0e10cSrcweir SfxTabPage*  SvxEMailTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1855*cdf0e10cSrcweir {
1856*cdf0e10cSrcweir     return new SvxEMailTabPage(pParent, rAttrSet);
1857*cdf0e10cSrcweir }
1858*cdf0e10cSrcweir 
1859*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1860*cdf0e10cSrcweir 
1861*cdf0e10cSrcweir sal_Bool SvxEMailTabPage::FillItemSet( SfxItemSet& )
1862*cdf0e10cSrcweir {
1863*cdf0e10cSrcweir     sal_Bool bMailModified = sal_False;
1864*cdf0e10cSrcweir     if(!pImpl->aMailConfig.bROProgram && aMailerURLED.GetSavedValue() != aMailerURLED.GetText())
1865*cdf0e10cSrcweir     {
1866*cdf0e10cSrcweir         pImpl->aMailConfig.sProgram = aMailerURLED.GetText();
1867*cdf0e10cSrcweir         bMailModified = sal_True;
1868*cdf0e10cSrcweir     }
1869*cdf0e10cSrcweir     if ( bMailModified )
1870*cdf0e10cSrcweir         pImpl->aMailConfig.Commit();
1871*cdf0e10cSrcweir 
1872*cdf0e10cSrcweir     return sal_False;
1873*cdf0e10cSrcweir }
1874*cdf0e10cSrcweir 
1875*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1876*cdf0e10cSrcweir 
1877*cdf0e10cSrcweir void SvxEMailTabPage::Reset( const SfxItemSet& )
1878*cdf0e10cSrcweir {
1879*cdf0e10cSrcweir     aMailerURLED.Enable(sal_True );
1880*cdf0e10cSrcweir     aMailerURLPB.Enable(sal_True );
1881*cdf0e10cSrcweir 
1882*cdf0e10cSrcweir     if(pImpl->aMailConfig.bROProgram)
1883*cdf0e10cSrcweir         aMailerURLFI.Show();
1884*cdf0e10cSrcweir 
1885*cdf0e10cSrcweir     aMailerURLED.SetText(pImpl->aMailConfig.sProgram);
1886*cdf0e10cSrcweir     aMailerURLED.SaveValue();
1887*cdf0e10cSrcweir     aMailerURLED.Enable(!pImpl->aMailConfig.bROProgram);
1888*cdf0e10cSrcweir     aMailerURLPB.Enable(!pImpl->aMailConfig.bROProgram);
1889*cdf0e10cSrcweir     aMailerURLFT.Enable(!pImpl->aMailConfig.bROProgram);
1890*cdf0e10cSrcweir 
1891*cdf0e10cSrcweir     aMailFL.Enable(aMailerURLFT.IsEnabled() ||
1892*cdf0e10cSrcweir                    aMailerURLED.IsEnabled() ||
1893*cdf0e10cSrcweir                    aMailerURLPB.IsEnabled());
1894*cdf0e10cSrcweir }
1895*cdf0e10cSrcweir 
1896*cdf0e10cSrcweir /* -------------------------------------------------------------------------*/
1897*cdf0e10cSrcweir 
1898*cdf0e10cSrcweir IMPL_LINK(  SvxEMailTabPage, FileDialogHdl_Impl, PushButton*, pButton )
1899*cdf0e10cSrcweir {
1900*cdf0e10cSrcweir     if ( &aMailerURLPB == pButton && !pImpl->aMailConfig.bROProgram )
1901*cdf0e10cSrcweir     {
1902*cdf0e10cSrcweir         FileDialogHelper aHelper(
1903*cdf0e10cSrcweir             com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
1904*cdf0e10cSrcweir             WB_OPEN );
1905*cdf0e10cSrcweir         String sPath = aMailerURLED.GetText();
1906*cdf0e10cSrcweir         if ( !sPath.Len() )
1907*cdf0e10cSrcweir             sPath.AppendAscii("/usr/bin");
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir         String sUrl;
1910*cdf0e10cSrcweir         ::utl::LocalFileHelper::ConvertPhysicalNameToURL(sPath,sUrl);
1911*cdf0e10cSrcweir         aHelper.SetDisplayDirectory(sUrl);
1912*cdf0e10cSrcweir         aHelper.AddFilter( m_sDefaultFilterName, String::CreateFromAscii("*"));
1913*cdf0e10cSrcweir 
1914*cdf0e10cSrcweir         if ( ERRCODE_NONE == aHelper.Execute() )
1915*cdf0e10cSrcweir         {
1916*cdf0e10cSrcweir             sUrl = aHelper.GetPath();
1917*cdf0e10cSrcweir             ::utl::LocalFileHelper::ConvertURLToPhysicalName(sUrl,sPath);
1918*cdf0e10cSrcweir             aMailerURLED.SetText(sPath);
1919*cdf0e10cSrcweir         }
1920*cdf0e10cSrcweir     }
1921*cdf0e10cSrcweir     return 0;
1922*cdf0e10cSrcweir }
1923*cdf0e10cSrcweir 
1924*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1925