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