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