masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / options / optinet2.cxx
blobb14312e4b9972654b5f4b0e3d4f6ce6b67664f8d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <tools/shl.hxx>
33 #include <tools/config.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <svl/intitem.hxx>
36 #include <svl/stritem.hxx>
37 #include <svl/eitem.hxx>
38 #include <svl/slstitm.hxx>
39 #include <sfx2/fcontnr.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <sfx2/docfilt.hxx>
42 #include <sfx2/viewsh.hxx>
43 #include <sfx2/sfxsids.hrc>
44 #include <sfx2/filedlghelper.hxx>
45 #include <tools/inetdef.hxx>
46 #include <svl/urihelper.hxx>
47 #include <svl/cntwids.hrc>
48 #include <unotools/inetoptions.hxx>
49 #include <sfx2/app.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <unotools/bootstrap.hxx>
52 #include <vcl/help.hxx>
53 #include <sfx2/viewfrm.hxx>
54 #include <tools/urlobj.hxx>
55 #include <unotools/pathoptions.hxx>
56 #include <unotools/securityoptions.hxx>
57 #include <unotools/javaoptions.hxx>
58 #include <unotools/localfilehelper.hxx>
59 #include <unotools/extendedsecurityoptions.hxx>
60 #include <com/sun/star/uno/Sequence.hxx>
61 #define _SVX_OPTINET2_CXX
62 #include <dialmgr.hxx>
63 #include "optinet2.hxx"
64 #include <svx/svxdlg.hxx> //CHINA001
65 #include <cuires.hrc>
66 #include "optinet2.hrc"
67 #include "helpid.hrc"
68 #include <svx/ofaitem.hxx>
69 #include <svx/htmlmode.hxx>
70 #include <svx/svxids.hrc> // slot ids, mostly for changetracking
72 // for security TP
73 #include <comphelper/processfactory.hxx>
74 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
76 #ifdef UNX
77 #include <sys/types.h>
78 #include <sys/stat.h>
79 #include <unistd.h>
80 #include <fcntl.h>
81 #include <pwd.h>
82 #include <sys/types.h>
83 #include <string.h>
84 #include <rtl/textenc.h>
85 #include <rtl/locale.h>
86 #include <osl/nlsupport.h>
87 #endif
88 #include <sal/types.h>
89 #include <rtl/ustring.hxx>
90 #include <osl/file.hxx>
91 #include <osl/process.h>
92 #include <com/sun/star/container/XNameReplace.hpp>
93 #include <com/sun/star/container/XNameAccess.hpp>
94 #include <com/sun/star/beans/PropertyValue.hpp>
95 #include <com/sun/star/beans/XPropertySet.hpp>
96 #include <com/sun/star/beans/XPropertyState.hpp>
97 #include <com/sun/star/util/XChangesBatch.hpp>
98 #include <comphelper/processfactory.hxx>
100 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
101 #include "com/sun/star/task/XMasterPasswordHandling2.hpp"
102 #include "com/sun/star/task/XPasswordContainer.hpp"
103 #include "securityoptions.hxx"
104 #include "webconninfo.hxx"
106 using namespace ::com::sun::star;
107 using namespace ::com::sun::star::uno;
108 using namespace ::sfx2;
109 using ::rtl::OUString;
111 //CHINA001 copy from multipat.hxx begin
112 // define ----------------------------------------------------------------
114 // different delimiter for Unix (:) and Windows (;)
116 #ifdef UNX
117 #define CLASSPATH_DELIMITER ':'
118 #else
119 #define CLASSPATH_DELIMITER ';'
120 #endif
121 //CHINA001 copy from multipat.hxx end
122 // static ----------------------------------------------------------------
124 #define C2U(cChar) OUString::createFromAscii(cChar)
126 #define INET_SEARCH_TOKEN '"'
127 #define RET_ALL ((short)200)
128 #define CFG_READONLY_DEFAULT FALSE
130 #include <sal/config.h>
132 SV_IMPL_PTRARR( SfxFilterPtrArr, SfxFilterPtr )
134 const char* SEARCHENGINE_INI = "srcheng.ini";
135 const char* SEARCHENGINE_GROUP = "SearchEngines-$(vlang)";
137 // -----------------------------------------------------------------------
139 void SvxNoSpaceEdit::KeyInput( const KeyEvent& rKEvent )
141 if ( bOnlyNumeric )
143 const KeyCode& rKeyCode = rKEvent.GetKeyCode();
144 sal_uInt16 nGroup = rKeyCode.GetGroup();
145 sal_uInt16 nKey = rKeyCode.GetCode();
146 sal_Bool bValid = ( KEYGROUP_NUM == nGroup || KEYGROUP_CURSOR == nGroup ||
147 ( KEYGROUP_MISC == nGroup && ( nKey < KEY_ADD || nKey > KEY_EQUAL ) ) );
148 if ( !bValid && ( rKeyCode.IsMod1() && (
149 KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) )
150 // Erase, Copy, Paste, Select All und Undo soll funktionieren
151 bValid = sal_True;
153 if ( bValid )
154 Edit::KeyInput(rKEvent);
156 else if( rKEvent.GetKeyCode().GetCode() != KEY_SPACE )
157 Edit::KeyInput(rKEvent);
160 // -----------------------------------------------------------------------
162 void SvxNoSpaceEdit::Modify()
164 Edit::Modify();
166 if ( bOnlyNumeric )
168 XubString aValue = GetText();
170 if ( !ByteString(::rtl::OUStringToOString(aValue,RTL_TEXTENCODING_UTF8)).IsNumericAscii() || (long)aValue.ToInt32() > USHRT_MAX )
171 // der H�chstwert einer Portnummer ist USHRT_MAX
172 ErrorBox( this, CUI_RES( RID_SVXERR_OPT_PROXYPORTS ) ).Execute();
176 /********************************************************************/
177 /********************************************************************/
178 /* */
179 /* SvxProxyTabPage */
180 /* */
181 /* */
182 /********************************************************************/
183 /********************************************************************/
185 SvxProxyTabPage::SvxProxyTabPage(Window* pParent, const SfxItemSet& rSet ) :
186 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_PROXY ), rSet ),
187 aOptionGB (this, CUI_RES(GB_SETTINGS)),
189 aProxyModeFT (this, CUI_RES(FT_PROXYMODE)),
190 aProxyModeLB (this, CUI_RES(LB_PROXYMODE)),
192 aHttpProxyFT (this, CUI_RES( FT_HTTP_PROXY )),
193 aHttpProxyED (this, CUI_RES( ED_HTTP_PROXY )),
194 aHttpPortFT (this, CUI_RES( FT_HTTP_PORT )),
195 aHttpPortED (this, CUI_RES( ED_HTTP_PORT ), sal_True),
197 aHttpsProxyFT (this, CUI_RES( FT_HTTPS_PROXY )),
198 aHttpsProxyED (this, CUI_RES( ED_HTTPS_PROXY )),
199 aHttpsPortFT (this, CUI_RES( FT_HTTPS_PORT )),
200 aHttpsPortED (this, CUI_RES( ED_HTTPS_PORT ), sal_True),
202 aFtpProxyFT (this, CUI_RES( FT_FTP_PROXY )),
203 aFtpProxyED (this, CUI_RES( ED_FTP_PROXY )),
204 aFtpPortFT (this, CUI_RES( FT_FTP_PORT )),
205 aFtpPortED (this, CUI_RES( ED_FTP_PORT ), sal_True),
207 aNoProxyForFT (this, CUI_RES( FT_NOPROXYFOR )),
208 aNoProxyForED (this, CUI_RES( ED_NOPROXYFOR )),
209 aNoProxyDescFT (this, CUI_RES( ED_NOPROXYDESC )),
210 sFromBrowser ( CUI_RES( ST_PROXY_FROM_BROWSER ) ),
211 aProxyModePN(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType")),
212 aHttpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName")),
213 aHttpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort")),
214 aHttpsProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyName")),
215 aHttpsPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyPort")),
216 aFtpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName")),
217 aFtpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort")),
218 aNoProxyDescPN(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy"))
220 FreeResource();
222 aHttpPortED.SetMaxTextLen(5);
223 aHttpsPortED.SetMaxTextLen(5);
224 aFtpPortED.SetMaxTextLen(5);
225 Link aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl );
226 aHttpPortED.SetLoseFocusHdl( aLink );
227 aHttpsPortED.SetLoseFocusHdl( aLink );
228 aFtpPortED.SetLoseFocusHdl( aLink );
230 aProxyModeLB.SetSelectHdl(LINK( this, SvxProxyTabPage, ProxyHdl_Impl ));
232 Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager(
233 ::comphelper::getProcessServiceFactory());
235 if( xServiceManager.is() )
239 Reference< com::sun::star::lang::XMultiServiceFactory > xConfigurationProvider =
240 Reference< com::sun::star::lang::XMultiServiceFactory > ( xServiceManager->createInstance( rtl::OUString(
241 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
242 UNO_QUERY_THROW);
244 OUString aConfigRoot(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings" ) );
246 beans::PropertyValue aProperty;
247 aProperty.Name = OUString(RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
248 aProperty.Value = makeAny( aConfigRoot );
250 Sequence< Any > aArgumentList( 1 );
251 aArgumentList[0] = makeAny( aProperty );
253 m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments( rtl::OUString(
254 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
255 aArgumentList );
257 catch ( RuntimeException& )
262 ArrangeControls_Impl();
265 /*-----------------12.08.96 14.55-------------------
267 --------------------------------------------------*/
269 SvxProxyTabPage::~SvxProxyTabPage()
273 /*-----------------12.08.96 14.55-------------------
275 --------------------------------------------------*/
277 SfxTabPage* SvxProxyTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
279 return new SvxProxyTabPage(pParent, rAttrSet);
282 /*-----------------02.09.04 14.55-------------------
284 --------------------------------------------------*/
286 void SvxProxyTabPage::ReadConfigData_Impl()
288 try {
289 Reference< container::XNameAccess > xNameAccess(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
291 sal_Int32 nIntValue = 0;
292 OUString aStringValue;
294 if( xNameAccess->getByName(aProxyModePN) >>= nIntValue )
296 aProxyModeLB.SelectEntryPos( (sal_uInt16) nIntValue );
299 if( xNameAccess->getByName(aHttpProxyPN) >>= aStringValue )
301 aHttpProxyED.SetText( aStringValue );
304 if( xNameAccess->getByName(aHttpPortPN) >>= nIntValue )
306 aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
309 if( xNameAccess->getByName(aHttpsProxyPN) >>= aStringValue )
311 aHttpsProxyED.SetText( aStringValue );
314 if( xNameAccess->getByName(aHttpsPortPN) >>= nIntValue )
316 aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
319 if( xNameAccess->getByName(aFtpProxyPN) >>= aStringValue )
321 aFtpProxyED.SetText( aStringValue );
324 if( xNameAccess->getByName(aFtpPortPN) >>= nIntValue )
326 aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
329 if( xNameAccess->getByName(aNoProxyDescPN) >>= aStringValue )
331 aNoProxyForED.SetText( aStringValue );
335 catch(container::NoSuchElementException e) {
336 OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: NoSuchElementException caught" );
339 catch(com::sun::star::lang::WrappedTargetException e) {
340 OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: WrappedTargetException caught" );
343 catch(RuntimeException e) {
344 OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: RuntimeException caught" );
349 /*-----------------02.09.04 14.55-------------------
351 --------------------------------------------------*/
353 void SvxProxyTabPage::ReadConfigDefaults_Impl()
357 Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
359 sal_Int32 nIntValue = 0;
360 OUString aStringValue;
362 if( xPropertyState->getPropertyDefault(aHttpProxyPN) >>= aStringValue )
364 aHttpProxyED.SetText( aStringValue );
367 if( xPropertyState->getPropertyDefault(aHttpPortPN) >>= nIntValue )
369 aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
372 if( xPropertyState->getPropertyDefault(aHttpsProxyPN) >>= aStringValue )
374 aHttpsProxyED.SetText( aStringValue );
377 if( xPropertyState->getPropertyDefault(aHttpsPortPN) >>= nIntValue )
379 aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
382 if( xPropertyState->getPropertyDefault(aFtpProxyPN) >>= aStringValue )
384 aFtpProxyED.SetText( aStringValue );
387 if( xPropertyState->getPropertyDefault(aFtpPortPN) >>= nIntValue )
389 aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
392 if( xPropertyState->getPropertyDefault(aNoProxyDescPN) >>= aStringValue )
394 aNoProxyForED.SetText( aStringValue );
397 catch(beans::UnknownPropertyException e)
399 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
402 catch(com::sun::star::lang::WrappedTargetException e) {
403 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
406 catch(RuntimeException e)
408 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
412 /*-----------------02.09.04 14.55-------------------
414 --------------------------------------------------*/
416 void SvxProxyTabPage::RestoreConfigDefaults_Impl()
420 Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
422 xPropertyState->setPropertyToDefault(aProxyModePN);
423 xPropertyState->setPropertyToDefault(aHttpProxyPN);
424 xPropertyState->setPropertyToDefault(aHttpPortPN);
425 xPropertyState->setPropertyToDefault(aHttpsProxyPN);
426 xPropertyState->setPropertyToDefault(aHttpsPortPN);
427 xPropertyState->setPropertyToDefault(aFtpProxyPN);
428 xPropertyState->setPropertyToDefault(aFtpPortPN);
429 xPropertyState->setPropertyToDefault(aNoProxyDescPN);
431 Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
432 xChangesBatch->commitChanges();
435 catch(beans::UnknownPropertyException e)
437 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
440 catch(com::sun::star::lang::WrappedTargetException e) {
441 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
444 catch(RuntimeException e)
446 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
450 /*-----------------12.08.96 14.55-------------------
452 --------------------------------------------------*/
454 void SvxProxyTabPage::Reset(const SfxItemSet&)
456 ReadConfigData_Impl();
458 aProxyModeLB.SaveValue();
459 aHttpProxyED.SaveValue();
460 aHttpPortED.SaveValue();
461 aHttpsProxyED.SaveValue();
462 aHttpsPortED.SaveValue();
463 aFtpProxyED.SaveValue();
464 aFtpPortED.SaveValue();
465 aNoProxyForED.SaveValue();
467 EnableControls_Impl( aProxyModeLB.GetSelectEntryPos() == 2 );
470 /*-----------------12.08.96 16.34-------------------
472 --------------------------------------------------*/
474 sal_Bool SvxProxyTabPage::FillItemSet(SfxItemSet& )
476 sal_Bool bModified=sal_False;
478 try {
479 Reference< beans::XPropertySet > xPropertySet(m_xConfigurationUpdateAccess, UNO_QUERY_THROW );
481 sal_uInt16 nSelPos = aProxyModeLB.GetSelectEntryPos();
482 if(aProxyModeLB.GetSavedValue() != nSelPos)
484 if( nSelPos == 1 )
486 RestoreConfigDefaults_Impl();
487 return sal_True;
490 xPropertySet->setPropertyValue(aProxyModePN,
491 makeAny((sal_Int32) nSelPos));
492 bModified = sal_True;
495 if(aHttpProxyED.GetSavedValue() != aHttpProxyED.GetText())
497 xPropertySet->setPropertyValue( aHttpProxyPN,
498 makeAny(rtl::OUString(aHttpProxyED.GetText())));
499 bModified = sal_True;
502 if ( aHttpPortED.GetSavedValue() != aHttpPortED.GetText() )
504 xPropertySet->setPropertyValue( aHttpPortPN,
505 makeAny(aHttpPortED.GetText().ToInt32()));
506 bModified = sal_True;
509 if(aHttpsProxyED.GetSavedValue() != aHttpsProxyED.GetText())
511 xPropertySet->setPropertyValue( aHttpsProxyPN,
512 makeAny(rtl::OUString(aHttpsProxyED.GetText())));
513 bModified = sal_True;
516 if ( aHttpsPortED.GetSavedValue() != aHttpsPortED.GetText() )
518 xPropertySet->setPropertyValue( aHttpsPortPN,
519 makeAny(aHttpsPortED.GetText().ToInt32()));
520 bModified = sal_True;
523 if(aFtpProxyED.GetSavedValue() != aFtpProxyED.GetText())
525 xPropertySet->setPropertyValue( aFtpProxyPN,
526 makeAny( rtl::OUString(aFtpProxyED.GetText())));
527 bModified = sal_True;
530 if ( aFtpPortED.GetSavedValue() != aFtpPortED.GetText() )
532 xPropertySet->setPropertyValue( aFtpPortPN,
533 makeAny(aFtpPortED.GetText().ToInt32()));
534 bModified = sal_True;
537 if ( aNoProxyForED.GetSavedValue() != aNoProxyForED.GetText() )
539 xPropertySet->setPropertyValue( aNoProxyDescPN,
540 makeAny( rtl::OUString(aNoProxyForED.GetText())));
541 bModified = sal_True;
544 Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
545 xChangesBatch->commitChanges();
548 catch(com::sun::star::lang::IllegalArgumentException e) {
549 OSL_TRACE( "SvxProxyTabPage::FillItemSet: IllegalArgumentException caught" );
552 catch(beans::UnknownPropertyException e) {
553 OSL_TRACE( "SvxProxyTabPage::FillItemSet: UnknownPropertyException caught" );
556 catch(beans::PropertyVetoException e) {
557 OSL_TRACE( "SvxProxyTabPage::FillItemSet: PropertyVetoException caught" );
560 catch(com::sun::star::lang::WrappedTargetException e) {
561 OSL_TRACE( "SvxProxyTabPage::FillItemSet: WrappedTargetException caught" );
564 catch(RuntimeException e) {
565 OSL_TRACE( "SvxProxyTabPage::FillItemSet: RuntimeException caught" );
568 return bModified;
571 void SvxProxyTabPage::ArrangeControls_Impl()
573 //-->Calculate dynamical width of controls, add buy wuy for i71445 Time: 2007.02.27
574 long nWidth = aProxyModeFT.GetCtrlTextWidth( aProxyModeFT.GetText() );
575 long nTemp = aHttpProxyFT.GetCtrlTextWidth( aHttpProxyFT.GetText() );
576 if ( nTemp > nWidth )
577 nWidth = nTemp;
578 nTemp = aHttpsProxyFT.GetCtrlTextWidth( aHttpsProxyFT.GetText() );
579 if ( nTemp > nWidth )
580 nWidth = nTemp;
581 nTemp = aFtpProxyFT.GetCtrlTextWidth( aFtpProxyFT.GetText() );
582 if ( nTemp > nWidth )
583 nWidth = nTemp;
584 nTemp = aNoProxyForFT.GetCtrlTextWidth( aNoProxyForFT.GetText() );
585 if ( nTemp > nWidth )
586 nWidth = nTemp;
588 nWidth += 10; // To be sure the length of the FixedText is enough on all platforms
589 const long nFTWidth = aProxyModeFT.GetSizePixel().Width();
590 if ( nWidth > nFTWidth )
592 Size aNewSize = aProxyModeFT.GetSizePixel();
593 aNewSize.Width() = nWidth;
595 aProxyModeFT.SetSizePixel( aNewSize );
596 aHttpProxyFT.SetSizePixel( aNewSize );
597 aHttpsProxyFT.SetSizePixel( aNewSize );
598 aFtpProxyFT.SetSizePixel( aNewSize );
599 aNoProxyForFT.SetSizePixel( aNewSize );
601 const long nDelta = nWidth - nFTWidth;
602 Point aNewPos = aProxyModeLB.GetPosPixel();
603 aNewPos.X() += nDelta;
605 aProxyModeLB.SetPosPixel( aNewPos );
607 aNewSize = aHttpProxyED.GetSizePixel();
608 aNewSize.Width() -= nDelta;
610 aNewPos.Y() = aHttpProxyED.GetPosPixel().Y();
611 aHttpProxyED.SetPosSizePixel( aNewPos, aNewSize );
612 aNewPos.Y() = aHttpsProxyED.GetPosPixel().Y();
613 aHttpsProxyED.SetPosSizePixel( aNewPos, aNewSize );
614 aNewPos.Y() = aFtpProxyED.GetPosPixel().Y();
615 aFtpProxyED.SetPosSizePixel( aNewPos, aNewSize );
616 aNewPos.Y() = aNoProxyForED.GetPosPixel().Y();
617 aNoProxyForED.SetPosSizePixel( aNewPos, aNewSize );
619 //<--End buy wuy for i71445 Time: 2007.02.27
622 /*-----------------12.08.96 13.38-------------------
624 --------------------------------------------------*/
625 void SvxProxyTabPage::EnableControls_Impl(sal_Bool bEnable)
627 aHttpProxyFT.Enable(bEnable);
628 aHttpProxyED.Enable(bEnable);
629 aHttpPortFT.Enable(bEnable);
630 aHttpPortED.Enable(bEnable);
632 aHttpsProxyFT.Enable(bEnable);
633 aHttpsProxyED.Enable(bEnable);
634 aHttpsPortFT.Enable(bEnable);
635 aHttpsPortED.Enable(bEnable);
637 aFtpProxyFT.Enable(bEnable);
638 aFtpProxyED.Enable(bEnable);
639 aFtpPortFT.Enable(bEnable);
640 aFtpPortED.Enable(bEnable);
642 aNoProxyForFT.Enable(bEnable);
643 aNoProxyForED.Enable(bEnable);
644 aNoProxyDescFT.Enable(bEnable);
647 // -----------------------------------------------------------------------
649 IMPL_LINK( SvxProxyTabPage, ProxyHdl_Impl, ListBox *, pBox )
651 sal_uInt16 nPos = pBox->GetSelectEntryPos();
653 // Restore original system values
654 if( nPos == 1 )
656 ReadConfigDefaults_Impl();
659 EnableControls_Impl(nPos == 2);
660 return 0;
663 // -----------------------------------------------------------------------
665 IMPL_LINK( SvxProxyTabPage, LoseFocusHdl_Impl, Edit *, pEdit )
667 XubString aValue = pEdit->GetText();
669 if ( !ByteString(::rtl::OUStringToOString(aValue,RTL_TEXTENCODING_UTF8)).IsNumericAscii() || (long)aValue.ToInt32() > USHRT_MAX )
670 pEdit->SetText( '0' );
671 return 0;
675 /********************************************************************/
676 /********************************************************************/
677 /* */
678 /* SvxSearchTabPage */
679 /* */
680 /* */
681 /********************************************************************/
682 /********************************************************************/
684 SvxSearchTabPage::SvxSearchTabPage(Window* pParent, const SfxItemSet& rSet ) :
686 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_SEARCH ), rSet ),
688 aSearchGB ( this, CUI_RES( GB_SEARCH ) ),
689 aSearchLB ( this, CUI_RES( LB_SEARCH ) ),
690 aSearchNameFT ( this, CUI_RES( FT_SEARCH_NAME ) ),
691 aSearchNameED ( this, CUI_RES( ED_SEARCH_NAME ) ),
692 aSearchFT ( this, CUI_RES( FT_SEARCH ) ),
693 aAndRB ( this, CUI_RES( RB_AND ) ),
694 aOrRB ( this, CUI_RES( RB_OR ) ),
695 aExactRB ( this, CUI_RES( RB_EXACT ) ),
697 aURLFT ( this, CUI_RES( FT_URL ) ),
698 aURLED ( this, CUI_RES( ED_URL ) ),
700 aPostFixFT ( this, CUI_RES( FT_POSTFIX ) ),
701 aPostFixED ( this, CUI_RES( ED_POSTFIX ) ),
702 aSeparatorFT ( this, CUI_RES( FT_SEPARATOR ) ),
703 aSeparatorED ( this, CUI_RES( ED_SEPARATOR ) ),
704 aCaseFT ( this, CUI_RES( FT_CASE ) ),
705 aCaseED ( this, CUI_RES( ED_CASE ) ),
707 aNewPB ( this, CUI_RES( PB_NEW ) ),
708 aAddPB ( this, CUI_RES( PB_ADD ) ),
709 aChangePB ( this, CUI_RES( PB_CHANGE ) ),
710 aDeletePB ( this, CUI_RES( PB_DELETE ) ),
712 sModifyMsg(CUI_RES(MSG_MODIFY))
714 FreeResource();
716 SetExchangeSupport();
717 aCaseED.SelectEntryPos(0); // falls kein Eintrag vorhanden ist, kann es sonst "Arger geben
719 aNewPB.SetClickHdl(LINK( this, SvxSearchTabPage, NewSearchHdl_Impl ) );
720 aAddPB.SetClickHdl(LINK( this, SvxSearchTabPage, AddSearchHdl_Impl ) );
721 aChangePB.SetClickHdl(LINK( this, SvxSearchTabPage, ChangeSearchHdl_Impl ) );
722 aDeletePB.SetClickHdl(LINK( this, SvxSearchTabPage, DeleteSearchHdl_Impl ) );
723 aSearchLB.SetSelectHdl(LINK( this, SvxSearchTabPage, SearchEntryHdl_Impl ) );
725 Link aLink = LINK( this, SvxSearchTabPage, SearchModifyHdl_Impl );
726 aSearchNameED.SetModifyHdl( aLink );
727 aURLED.SetModifyHdl( aLink );
728 aSeparatorED.SetModifyHdl( aLink );
729 aPostFixED.SetModifyHdl( aLink );
730 aCaseED.SetSelectHdl( aLink );
732 aLink = LINK( this, SvxSearchTabPage, SearchPartHdl_Impl );
733 aAndRB.SetClickHdl( aLink );
734 aOrRB.SetClickHdl( aLink );
735 aExactRB.SetClickHdl( aLink );
737 InitControls_Impl();
740 // -----------------------------------------------------------------------
741 SvxSearchTabPage::~SvxSearchTabPage()
744 // -----------------------------------------------------------------------
746 SfxTabPage* SvxSearchTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
748 return new SvxSearchTabPage(pParent, rAttrSet);
751 // -----------------------------------------------------------------------
753 void SvxSearchTabPage::Reset( const SfxItemSet& )
755 //The two lines below are moved here from the last part of this method by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
756 aChangePB.Disable();
757 aAddPB.Disable();
759 sal_uInt16 nCount = aSearchConfig.Count();
760 aSearchLB.Clear(); //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
761 for(sal_uInt16 i = 0; i < nCount; i++)
763 const SvxSearchEngineData& rData = aSearchConfig.GetData(i);
764 aSearchLB.InsertEntry(rData.sEngineName);
767 if ( nCount )
769 aSearchLB.SelectEntryPos(0);
770 SearchEntryHdl_Impl( &aSearchLB );
772 else
773 aDeletePB.Disable();
776 // -----------------------------------------------------------------------
778 sal_Bool SvxSearchTabPage::FillItemSet( SfxItemSet& )
780 if(aSearchConfig.IsModified())
781 aSearchConfig.Commit();
782 return sal_True;
784 /*--------------------------------------------------------------------*/
786 void SvxSearchTabPage::ActivatePage( const SfxItemSet& )
790 /*--------------------------------------------------------------------*/
792 int SvxSearchTabPage::DeactivatePage( SfxItemSet* _pSet )
794 //Modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
795 if(!ConfirmLeave(String()))
796 return KEEP_PAGE;
798 if ( _pSet )
799 FillItemSet( *_pSet );
800 return LEAVE_PAGE;
803 // -----------------------------------------------------------------------
805 //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
806 sal_Bool SvxSearchTabPage::ConfirmLeave( const String& rStringSelection)
808 if(aChangePB.IsEnabled())
810 QueryBox aQuery(this, WB_YES_NO_CANCEL|WB_DEF_YES, sModifyMsg);
811 sal_uInt16 nRet = aQuery.Execute();
812 if(RET_CANCEL == nRet)
814 if(rStringSelection.Len())
815 aSearchLB.SelectEntry(sLastSelectedEntry);
816 return sal_False;
818 else if(RET_YES == nRet)
820 sal_uInt16 nEntryPos = aSearchLB.GetEntryPos( aSearchNameED.GetText() );
821 if ( nEntryPos != LISTBOX_ENTRY_NOTFOUND )
822 aSearchLB.SelectEntryPos(nEntryPos);
823 else
824 aSearchLB.SetNoSelection();
825 ChangeSearchHdl_Impl(0);
826 if(rStringSelection.Len())
827 aSearchLB.SelectEntry(rStringSelection);
829 else if(RET_NO == nRet)
831 aChangePB.Enable(sal_False);
832 aAddPB.Enable(sal_False);
833 SearchEntryHdl_Impl(&aSearchLB);
836 if(aAddPB.IsEnabled())
838 QueryBox aQuery(this, WB_YES_NO_CANCEL|WB_DEF_YES, sModifyMsg);
839 sal_uInt16 nRet = aQuery.Execute();
840 if(RET_CANCEL == nRet)
842 aSearchLB.SetNoSelection();
843 return sal_False;
845 else if(RET_YES == nRet)
847 aSearchLB.SetNoSelection();
848 AddSearchHdl_Impl(0);
849 if(rStringSelection.Len())
850 aSearchLB.SelectEntry(rStringSelection);
852 else if(RET_NO == nRet)
854 aAddPB.Enable(sal_False);
855 aChangePB.Enable(sal_False);
856 NewSearchHdl_Impl(0);
860 return sal_True;
863 // -----------------------------------------------------------------------
865 void SvxSearchTabPage::InitControls_Impl()
867 // detect longest label text
868 sal_Int32 i = 0;
869 long nLabelTextWidth = 0;
870 Window* pLabels[] = { &aSearchNameFT, &aSearchFT, &aURLFT, &aPostFixFT, &aSeparatorFT, &aCaseFT };
871 Window** pLabel = pLabels;
872 const sal_Int32 nLabelCount = sizeof( pLabels ) / sizeof( pLabels[0] );
873 for ( ; i < nLabelCount; ++i, ++pLabel )
875 long nTemp = (*pLabel)->GetCtrlTextWidth( (*pLabel)->GetText() );
876 if ( nTemp > nLabelTextWidth )
877 nLabelTextWidth = nTemp;
880 // resize all labels
881 nLabelTextWidth = nLabelTextWidth * 120 / 100; // additional space looks better
882 const long nLabelWidth = aSearchNameFT.GetSizePixel().Width();
883 const long nDelta = nLabelWidth - nLabelTextWidth;
884 pLabel = pLabels;
885 for ( i = 0; i < nLabelCount; ++i, ++pLabel )
887 Size aNewSize = (*pLabel)->GetSizePixel();
888 aNewSize.Width() += nDelta;
889 (*pLabel)->SetSizePixel( aNewSize );
892 // resize and move the edits
893 Window* pEdits[] = { &aSearchNameED, &aAndRB, &aOrRB,
894 &aExactRB, &aURLED, &aPostFixED, &aSeparatorED, &aCaseED };
895 Window** pEdit = pEdits;
896 const sal_Int32 nCCount = sizeof( pEdits ) / sizeof( pEdits[ 0 ] );
897 for ( i = 0; i < nCCount; ++i, ++pEdit )
899 Point aNewPos = (*pEdit)->GetPosPixel();
900 aNewPos.X() -= nDelta;
901 Size aNewSize = (*pEdit)->GetSizePixel();
902 if ( (*pEdit) != &aSeparatorED && (*pEdit) != &aCaseED )
903 aNewSize.Width() += nDelta;
904 (*pEdit)->SetPosSizePixel( aNewPos, aNewSize );
908 // -----------------------------------------------------------------------
910 IMPL_LINK( SvxSearchTabPage, NewSearchHdl_Impl, PushButton *, EMPTYARG )
912 //The 3 lines below is modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
913 SearchEntryHdl_Impl(&aSearchLB);
914 if(aChangePB.IsEnabled() || aAddPB.IsEnabled())
915 return 0;
916 aSearchNameED.SetText( String() );
917 aSearchLB.SetNoSelection();
918 aCurrentSrchData = SvxSearchEngineData();
919 aAndRB.Check( sal_True );
920 SearchEntryHdl_Impl( &aSearchLB );
921 SearchPartHdl_Impl( &aAndRB );
922 return 0;
925 // -----------------------------------------------------------------------
927 IMPL_LINK( SvxSearchTabPage, AddSearchHdl_Impl, PushButton *, EMPTYARG )
929 //The following two lines is added by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
930 aAddPB.Enable(sal_False);
931 aChangePB.Enable(sal_False);
932 aCurrentSrchData.sEngineName = aSearchNameED.GetText();
933 aSearchConfig.SetData(aCurrentSrchData);
934 aSearchLB.InsertEntry( aCurrentSrchData.sEngineName );
935 aSearchLB.SelectEntry( aCurrentSrchData.sEngineName );
936 SearchEntryHdl_Impl( &aSearchLB );
937 return 0;
940 // -----------------------------------------------------------------------
942 IMPL_LINK( SvxSearchTabPage, ChangeSearchHdl_Impl, PushButton *, EMPTYARG )
944 //The following two lines is added by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
945 aChangePB.Enable(sal_False);
946 aAddPB.Enable(sal_False);
947 sal_uInt16 nPos = aSearchLB.GetSelectEntryPos();
948 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
950 String sEngine = aSearchLB.GetSelectEntry();
951 aCurrentSrchData.sEngineName = sEngine;
952 aSearchConfig.SetData(aCurrentSrchData);
953 aSearchLB.SelectEntry(sEngine);
954 SearchEntryHdl_Impl(&aSearchLB);
956 else
958 SetUpdateMode(sal_False);
959 String sEntry = aSearchNameED.GetText();
960 // im AddHdl wird sLastSelectedEntry umgesetzt
961 String sTemp(sLastSelectedEntry);
962 AddSearchHdl_Impl(0);
963 aSearchLB.SelectEntry(sTemp);
964 DeleteSearchHdl_Impl(0);
965 aSearchLB.SelectEntry(sEntry);
966 SearchEntryHdl_Impl(&aSearchLB);
967 SetUpdateMode(sal_True);
969 return 0;
972 // -----------------------------------------------------------------------
974 IMPL_LINK( SvxSearchTabPage, DeleteSearchHdl_Impl, PushButton *, EMPTYARG)
976 aChangePB.Enable(sal_False); //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
977 sal_uInt16 nPos = aSearchLB.GetSelectEntryPos();
978 DBG_ASSERT(nPos != LISTBOX_ENTRY_NOTFOUND, "kein Eintrag selektiert!");
979 aSearchConfig.RemoveData(aSearchLB.GetSelectEntry());
980 aSearchLB.RemoveEntry(nPos);
981 aSearchLB.SelectEntryPos(0);
982 SearchEntryHdl_Impl(&aSearchLB);
983 return 0;
986 // -----------------------------------------------------------------------
988 IMPL_LINK( SvxSearchTabPage, SearchEntryHdl_Impl, ListBox*, pBox )
990 sal_uInt16 nEntryPos = pBox->GetSelectEntryPos();
991 if ( nEntryPos != LISTBOX_ENTRY_NOTFOUND )
993 String sSelection(pBox->GetSelectEntry());
994 //Modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
995 if(!ConfirmLeave(sSelection))
996 return 0;
998 const SvxSearchEngineData* pData = aSearchConfig.GetData(sSelection);
999 DBG_ASSERT(pData, "SearchEngine not available");
1000 if(pData)
1002 aSearchNameED.SetText(sSelection);
1003 sLastSelectedEntry = sSelection;
1004 sal_Bool bAnd = aAndRB.IsChecked();
1005 sal_Bool bOr = aOrRB.IsChecked();
1007 aURLED.SetText(bAnd ? pData->sAndPrefix : bOr ? pData->sOrPrefix : pData->sExactPrefix);
1008 aSeparatorED.SetText( bAnd ? pData->sAndSeparator : bOr ? pData->sOrSeparator : pData->sExactSeparator);
1009 aPostFixED.SetText(bAnd ? pData->sAndSuffix : bOr ? pData->sOrSuffix : pData->sExactSuffix );
1010 sal_Int32 nCase = bAnd ? pData->nAndCaseMatch : bOr ? pData->nOrCaseMatch : pData->nExactCaseMatch;
1011 aCaseED.SelectEntryPos( (sal_uInt16)nCase );
1012 aCurrentSrchData = *pData;
1014 aDeletePB.Enable();
1016 else
1018 aDeletePB.Enable(sal_False);
1019 sLastSelectedEntry.Erase();
1021 aChangePB.Enable(sal_False);
1022 aAddPB.Enable(sal_False);
1023 return 0;
1026 // -----------------------------------------------------------------------
1028 IMPL_LINK( SvxSearchTabPage, SearchModifyHdl_Impl, SvxNoSpaceEdit*, pEdit )
1030 if ( pEdit == &aSearchNameED )
1032 sal_Bool bTextLen = ( 0 != pEdit->GetText().Len() );
1033 sal_Bool bFound = sal_False;
1034 if ( bTextLen )
1036 sal_uInt16 nEntryPos = aSearchLB.GetEntryPos( pEdit->GetText() );
1037 bFound = ( nEntryPos != LISTBOX_ENTRY_NOTFOUND );
1038 if ( bFound )
1039 aSearchLB.SelectEntryPos(nEntryPos);
1040 else
1041 aSearchLB.SetNoSelection();
1043 aChangePB.Enable( sLastSelectedEntry.Len() > 0 );
1044 aDeletePB.Enable(bFound);
1045 aAddPB.Enable(bTextLen && !bFound);
1047 else
1049 if ( aSearchLB.GetSelectEntryCount() && sLastSelectedEntry.Len() > 0 )
1050 aChangePB.Enable();
1052 if(aAndRB.IsChecked())
1054 aCurrentSrchData.sAndPrefix = aURLED.GetText();
1055 aCurrentSrchData.sAndSeparator = aSeparatorED.GetText();
1056 aCurrentSrchData.sAndSuffix = aPostFixED.GetText();
1057 aCurrentSrchData.nAndCaseMatch = aCaseED.GetSelectEntryPos();
1059 else if(aOrRB.IsChecked())
1061 aCurrentSrchData.sOrPrefix = aURLED.GetText();
1062 aCurrentSrchData.sOrSeparator = aSeparatorED.GetText();
1063 aCurrentSrchData.sOrSuffix = aPostFixED.GetText();
1064 aCurrentSrchData.nOrCaseMatch = aCaseED.GetSelectEntryPos();
1066 else
1068 aCurrentSrchData.sExactPrefix = aURLED.GetText();
1069 aCurrentSrchData.sExactSeparator = aSeparatorED.GetText();
1070 aCurrentSrchData.sExactSuffix = aPostFixED.GetText();
1071 aCurrentSrchData.nExactCaseMatch = aCaseED.GetSelectEntryPos();
1074 return 0;
1077 // -----------------------------------------------------------------------
1079 IMPL_LINK( SvxSearchTabPage, SearchPartHdl_Impl, RadioButton *, EMPTYARG )
1081 sal_Bool bAnd = aAndRB.IsChecked();
1082 sal_Bool bOr = aOrRB.IsChecked();
1084 aURLED.SetText(bAnd ? aCurrentSrchData.sAndPrefix : bOr ? aCurrentSrchData.sOrPrefix : aCurrentSrchData.sExactPrefix);
1085 aSeparatorED.SetText( bAnd ? aCurrentSrchData.sAndSeparator : bOr ? aCurrentSrchData.sOrSeparator : aCurrentSrchData.sExactSeparator);
1086 aPostFixED.SetText(bAnd ? aCurrentSrchData.sAndSuffix : bOr ? aCurrentSrchData.sOrSuffix : aCurrentSrchData.sExactSuffix );
1087 sal_Int32 nCase = bAnd ? aCurrentSrchData.nAndCaseMatch : bOr ? aCurrentSrchData.nOrCaseMatch : aCurrentSrchData.nExactCaseMatch;
1088 aCaseED.SelectEntryPos( (sal_uInt16)nCase );
1089 return 0;
1092 //#98647#----------------------------------------------
1093 void SvxScriptExecListBox::RequestHelp( const HelpEvent& rHEvt )
1094 { // try to show tips just like as on toolbars
1095 sal_uInt16 nPos=LISTBOX_ENTRY_NOTFOUND;
1096 sal_uInt16 nTop = GetTopEntry();
1097 sal_uInt16 nCount = GetDisplayLineCount(); // Attention: Not GetLineCount()
1098 Point aPt = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
1099 Rectangle aItemRect;
1100 if( nCount > 0 ) // if there're some entries, find it.
1101 for( nPos = nTop ; nPos <= nTop+nCount-1 ; nPos++ ) {
1102 aItemRect = GetBoundingRectangle(nPos);
1103 if( aPt.Y() < aItemRect.Top() || aPt.Y() > aItemRect.Bottom() )
1104 continue;
1105 else
1106 break;
1108 else // if not, nothing happens.
1109 return;
1110 String aHelpText;
1111 if( nPos <= nTop+nCount-1 ) // if find the matching entry, get its content.
1112 aHelpText = GetEntry(nPos);
1113 if( aHelpText.Len() && GetTextWidth(aHelpText)<GetOutputSizePixel().Width() )
1114 aHelpText.Erase(); // if the entry is quite short, clear the helping tip content.
1115 aItemRect = Rectangle(Point(0,0),GetSizePixel());
1116 aPt = Point(OutputToScreenPixel( aItemRect.TopLeft() ));
1117 aItemRect.Left() = aPt.X();
1118 aItemRect.Top() = aPt.Y();
1119 aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1120 aItemRect.Right() = aPt.X();
1121 aItemRect.Bottom() = aPt.Y();
1122 if( rHEvt.GetMode() == HELPMODE_BALLOON )
1123 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
1124 else
1125 Help::ShowQuickHelp( this, aItemRect, aHelpText );
1128 /********************************************************************/
1129 /* */
1130 /* SvxSecurityTabPage */
1131 /* */
1132 /********************************************************************/
1134 SvxSecurityTabPage::SvxSecurityTabPage( Window* pParent, const SfxItemSet& rSet )
1135 :SfxTabPage ( pParent, CUI_RES( RID_SVXPAGE_INET_SECURITY ), rSet )
1137 ,maSecurityOptionsFL( this, CUI_RES( FL_SEC_SECURITYOPTIONS ) )
1138 ,maSecurityOptionsFI( this, CUI_RES( FI_SEC_SECURITYOPTIONS ) )
1139 ,maSecurityOptionsPB( this, CUI_RES( PB_SEC_SECURITYOPTIONS ) )
1141 ,maPasswordsFL ( this, CUI_RES( FL_SEC_PASSWORDS ) )
1142 ,maSavePasswordsCB ( this, CUI_RES( CB_SEC_SAVEPASSWORDS ) )
1143 ,maShowConnectionsPB( this, CUI_RES( PB_SEC_CONNECTIONS ) )
1144 ,maMasterPasswordCB ( this, CUI_RES( CB_SEC_MASTERPASSWORD ) )
1145 ,maMasterPasswordFI ( this, CUI_RES( FI_SEC_MASTERPASSWORD ) )
1146 ,maMasterPasswordPB ( this, CUI_RES( PB_SEC_MASTERPASSWORD ) )
1148 ,maMacroSecFL ( this, CUI_RES( FL_SEC_MACROSEC ) )
1149 ,maMacroSecFI ( this, CUI_RES( FI_SEC_MACROSEC ) )
1150 ,maMacroSecPB ( this, CUI_RES( PB_SEC_MACROSEC ) )
1152 ,mpSecOptions ( new SvtSecurityOptions )
1153 ,mpSecOptDlg ( NULL )
1155 ,msPasswordStoringDeactivateStr( CUI_RES( STR_SEC_NOPASSWDSAVE ) )
1158 FreeResource();
1160 InitControls();
1162 maSecurityOptionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, SecurityOptionsHdl ) );
1163 maSavePasswordsCB.SetClickHdl( LINK( this, SvxSecurityTabPage, SavePasswordHdl ) );
1164 maMasterPasswordPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordHdl ) );
1165 maMasterPasswordCB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordCBHdl ) );
1166 maShowConnectionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, ShowPasswordsHdl ) );
1167 maMacroSecPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) );
1169 ActivatePage( rSet );
1172 SvxSecurityTabPage::~SvxSecurityTabPage()
1174 delete mpSecOptions;
1175 delete mpSecOptDlg;
1178 IMPL_LINK( SvxSecurityTabPage, SecurityOptionsHdl, PushButton*, EMPTYARG )
1180 if ( !mpSecOptDlg )
1181 mpSecOptDlg = new svx::SecurityOptionsDialog( this, mpSecOptions );
1182 mpSecOptDlg->Execute();
1183 return 0;
1186 IMPL_LINK( SvxSecurityTabPage, SavePasswordHdl, void*, EMPTYARG )
1190 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1191 comphelper::getProcessServiceFactory()->createInstance(
1192 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1193 UNO_QUERY_THROW );
1195 if ( maSavePasswordsCB.IsChecked() )
1197 sal_Bool bOldValue = xMasterPasswd->allowPersistentStoring( sal_True );
1198 xMasterPasswd->removeMasterPassword();
1199 if ( xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
1201 maMasterPasswordPB.Enable( sal_True );
1202 maMasterPasswordCB.Check( sal_True );
1203 maMasterPasswordCB.Enable( sal_True );
1204 maMasterPasswordFI.Enable( sal_True );
1205 maShowConnectionsPB.Enable( sal_True );
1207 else
1209 xMasterPasswd->allowPersistentStoring( bOldValue );
1210 maSavePasswordsCB.Check( sal_False );
1213 else
1215 QueryBox aQuery( this, WB_YES_NO|WB_DEF_NO, msPasswordStoringDeactivateStr );
1216 sal_uInt16 nRet = aQuery.Execute();
1218 if( RET_YES == nRet )
1220 xMasterPasswd->allowPersistentStoring( sal_False );
1221 maMasterPasswordCB.Check( sal_True );
1222 maMasterPasswordPB.Enable( sal_False );
1223 maMasterPasswordCB.Enable( sal_False );
1224 maMasterPasswordFI.Enable( sal_False );
1225 maShowConnectionsPB.Enable( sal_False );
1227 else
1229 maSavePasswordsCB.Check( sal_True );
1230 maMasterPasswordPB.Enable( sal_True );
1231 maShowConnectionsPB.Enable( sal_True );
1235 catch( Exception& )
1237 maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
1240 return 0;
1243 IMPL_LINK( SvxSecurityTabPage, MasterPasswordHdl, PushButton*, EMPTYARG )
1247 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1248 comphelper::getProcessServiceFactory()->createInstance(
1249 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1250 UNO_QUERY );
1252 if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() )
1253 xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() );
1255 catch( Exception& )
1258 return 0;
1261 IMPL_LINK( SvxSecurityTabPage, MasterPasswordCBHdl, void*, EMPTYARG )
1265 Reference< task::XMasterPasswordHandling2 > xMasterPasswd(
1266 comphelper::getProcessServiceFactory()->createInstance(
1267 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1268 UNO_QUERY_THROW );
1270 if ( maMasterPasswordCB.IsChecked() )
1272 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
1274 maMasterPasswordPB.Enable( sal_True );
1275 maMasterPasswordFI.Enable( sal_True );
1277 else
1279 maMasterPasswordCB.Check( sal_False );
1280 maMasterPasswordPB.Enable( sal_True );
1281 maMasterPasswordFI.Enable( sal_True );
1284 else
1286 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->useDefaultMasterPassword( Reference< task::XInteractionHandler >() ) )
1288 maMasterPasswordPB.Enable( sal_False );
1289 maMasterPasswordFI.Enable( sal_False );
1291 else
1293 maMasterPasswordCB.Check( sal_True );
1294 maMasterPasswordPB.Enable( sal_True );
1295 maShowConnectionsPB.Enable( sal_True );
1299 catch( Exception& )
1301 maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
1304 return 0;
1307 IMPL_LINK( SvxSecurityTabPage, ShowPasswordsHdl, PushButton*, EMPTYARG )
1311 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1312 comphelper::getProcessServiceFactory()->createInstance(
1313 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1314 UNO_QUERY );
1316 if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword( Reference< task::XInteractionHandler>() ) )
1318 svx::WebConnectionInfoDialog aDlg( this );
1319 aDlg.Execute();
1322 catch( Exception& )
1324 return 0;
1327 IMPL_LINK( SvxSecurityTabPage, MacroSecPBHdl, void*, EMPTYARG )
1329 Reference< security::XDocumentDigitalSignatures > xD(
1330 comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), UNO_QUERY );
1331 if ( xD.is() )
1332 xD->manageTrustedSources();
1334 return 0;
1338 void SvxSecurityTabPage::InitControls()
1340 // Hide all controls which belong to the macro security button in case the macro
1341 // security settings managed by the macro security dialog opened via the button
1342 // are all readonly or if the macros are disabled in general.
1343 // @@@ Better would be to query the dialog whether it is 'useful' or not. Exposing
1344 // macro security dialog implementations here, which is bad.
1345 if ( mpSecOptions->IsMacroDisabled()
1346 || ( mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_SECLEVEL )
1347 && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS )
1348 && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_SECUREURLS ) ) )
1350 maMacroSecFL.Hide();
1351 maMacroSecFI.Hide();
1352 maMacroSecPB.Hide();
1355 // one button too small for its text?
1356 sal_Int32 i = 0;
1357 long nBtnTextWidth = 0;
1358 Window* pButtons[] = { &maSecurityOptionsPB, &maMasterPasswordPB,
1359 &maShowConnectionsPB, &maMacroSecPB };
1360 Window** pButton = pButtons;
1361 const sal_Int32 nBCount = sizeof( pButtons ) / sizeof( pButtons[ 0 ] );
1362 for ( ; i < nBCount; ++i, ++pButton )
1364 long nTemp = (*pButton)->GetCtrlTextWidth( (*pButton)->GetText() );
1365 if ( nTemp > nBtnTextWidth )
1366 nBtnTextWidth = nTemp;
1369 nBtnTextWidth = nBtnTextWidth * 115 / 100; // a little offset
1370 const long nButtonWidth = maSecurityOptionsPB.GetSizePixel().Width();
1371 const long nMaxWidth = nButtonWidth * 140 / 100;
1372 long nExtra = ( nBtnTextWidth > nMaxWidth ) ? nBtnTextWidth - nMaxWidth : 0;
1373 nBtnTextWidth = std::min( nBtnTextWidth, nMaxWidth );
1375 if ( nBtnTextWidth > nButtonWidth )
1377 // so make the buttons broader and its control in front of it smaller
1378 long nDelta = nBtnTextWidth - nButtonWidth;
1379 pButton = pButtons;
1381 if ( nExtra > 0 )
1383 long nPos = (*pButton)->GetPosPixel().X() - nDelta;
1384 long nWidth = (*pButton)->GetSizePixel().Width() + nDelta;
1385 long nMaxExtra = GetOutputSizePixel().Width() - ( nPos + nWidth ) - 2;
1386 nExtra = ( nExtra < nMaxExtra ) ? nExtra : nMaxExtra;
1389 for ( i = 0; i < nBCount; ++i, ++pButton )
1391 Point aNewPos = (*pButton)->GetPosPixel();
1392 aNewPos.X() -= nDelta;
1393 Size aNewSize = (*pButton)->GetSizePixel();
1394 aNewSize.Width() += ( nDelta + nExtra );
1395 (*pButton)->SetPosSizePixel( aNewPos, aNewSize );
1398 Window* pControls[] = { &maSecurityOptionsFI, &maSavePasswordsCB,
1399 &maMasterPasswordFI, &maMacroSecFI };
1400 Window** pControl = pControls;
1401 const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[ 0 ] );
1402 for ( i = 0; i < nCCount; ++i, ++pControl )
1404 Size aNewSize = (*pControl)->GetSizePixel();
1405 aNewSize.Width() -= nDelta;
1406 (*pControl)->SetSizePixel( aNewSize );
1410 maMasterPasswordPB.Enable( sal_False );
1411 maMasterPasswordCB.Enable( sal_False );
1412 maMasterPasswordCB.Check( sal_True );
1413 maMasterPasswordFI.Enable( sal_False );
1414 maShowConnectionsPB.Enable( sal_False );
1416 // initialize the password saving checkbox
1419 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1420 comphelper::getProcessServiceFactory()->createInstance(
1421 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1422 UNO_QUERY_THROW );
1424 if ( xMasterPasswd->isPersistentStoringAllowed() )
1426 maMasterPasswordCB.Enable( sal_True );
1427 maShowConnectionsPB.Enable( sal_True );
1428 maSavePasswordsCB.Check( sal_True );
1430 Reference< task::XMasterPasswordHandling2 > xMasterPasswd2( xMasterPasswd, UNO_QUERY );
1431 if ( xMasterPasswd2.is() && xMasterPasswd2->isDefaultMasterPasswordUsed() )
1432 maMasterPasswordCB.Check( sal_False );
1433 else
1435 maMasterPasswordPB.Enable( sal_True );
1436 maMasterPasswordCB.Check( sal_True );
1437 maMasterPasswordFI.Enable( sal_True );
1441 catch( Exception& )
1443 maSavePasswordsCB.Enable( sal_False );
1449 SfxTabPage* SvxSecurityTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
1451 return new SvxSecurityTabPage(pParent, rAttrSet);
1454 void SvxSecurityTabPage::ActivatePage( const SfxItemSet& )
1458 int SvxSecurityTabPage::DeactivatePage( SfxItemSet* _pSet )
1460 if( _pSet )
1461 FillItemSet( *_pSet );
1462 return LEAVE_PAGE;
1465 namespace
1467 bool CheckAndSave( SvtSecurityOptions& _rOpt, SvtSecurityOptions::EOption _eOpt, const bool _bIsChecked, bool& _rModfied )
1469 bool bModified = false;
1470 if ( _rOpt.IsOptionEnabled( _eOpt ) )
1472 bModified = _rOpt.IsOptionSet( _eOpt ) != _bIsChecked;
1473 if ( bModified )
1475 _rOpt.SetOption( _eOpt, _bIsChecked );
1476 _rModfied = true;
1480 return bModified;
1484 sal_Bool SvxSecurityTabPage::FillItemSet( SfxItemSet& )
1486 bool bModified = false;
1488 if ( mpSecOptDlg )
1490 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SAVEORSEND, mpSecOptDlg->IsSaveOrSendDocsChecked(), bModified );
1491 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SIGNING, mpSecOptDlg->IsSignDocsChecked(), bModified );
1492 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_PRINT, mpSecOptDlg->IsPrintDocsChecked(), bModified );
1493 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_CREATEPDF, mpSecOptDlg->IsCreatePdfChecked(), bModified );
1494 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO, mpSecOptDlg->IsRemovePersInfoChecked(), bModified );
1495 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD, mpSecOptDlg->IsRecommPasswdChecked(), bModified );
1496 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_CTRLCLICK_HYPERLINK, mpSecOptDlg->IsCtrlHyperlinkChecked(), bModified );
1499 return bModified;
1502 /*--------------------------------------------------------------------*/
1504 void SvxSecurityTabPage::Reset( const SfxItemSet& )
1506 SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
1507 if( pCurDocShell )
1512 //added by jmeng begin
1513 MozPluginTabPage::MozPluginTabPage(Window* pParent, const SfxItemSet& rSet)
1514 : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_MOZPLUGIN ), rSet ),
1515 aMSWordGB ( this, CUI_RES( GB_MOZPLUGIN ) ),
1516 aWBasicCodeCB ( this, CUI_RES( CB_MOZPLUGIN_CODE ) )
1518 FreeResource();
1521 MozPluginTabPage::~MozPluginTabPage()
1525 SfxTabPage* MozPluginTabPage::Create( Window* pParent,
1526 const SfxItemSet& rAttrSet )
1528 return new MozPluginTabPage( pParent, rAttrSet );
1530 sal_Bool MozPluginTabPage::FillItemSet( SfxItemSet& )
1532 sal_Bool hasInstall = isInstalled();
1533 sal_Bool hasChecked = aWBasicCodeCB.IsChecked();
1534 if(hasInstall && (!hasChecked)){
1535 //try to uninstall
1536 uninstallPlugin();
1538 else if((!hasInstall) && hasChecked){
1539 //try to install
1540 installPlugin();
1542 else{
1543 // do nothing
1545 return sal_True;
1547 void MozPluginTabPage::Reset( const SfxItemSet& )
1549 aWBasicCodeCB.Check( isInstalled());
1550 aWBasicCodeCB.SaveValue();
1553 #ifdef WNT
1554 extern "C" {
1555 int lc_isInstalled(const char* realFilePath);
1556 int lc_installPlugin(const char* realFilePath);
1557 int lc_uninstallPlugin(const char* realFilePath);
1559 #endif
1561 #define NPP_PATH_MAX 2048
1562 inline bool getDllURL(rtl::OString * path)
1564 OSL_ASSERT(path != NULL);
1565 ::rtl::OUString dirPath/*dllPath, */;
1566 if (osl_getExecutableFile(&dirPath.pData) != osl_Process_E_None) {
1567 return false;
1569 dirPath = dirPath.copy(0, dirPath.lastIndexOf('/'));
1570 // osl::FileBase::getAbsoluteFileURL(dirPath, libPath, dllPath);
1571 ::rtl::OUString sysDirPath;
1572 osl::FileBase::getSystemPathFromFileURL(dirPath, sysDirPath);
1573 *path = OUStringToOString(sysDirPath, RTL_TEXTENCODING_ASCII_US);
1574 return true;
1577 sal_Bool MozPluginTabPage::isInstalled()
1579 #ifdef UNIX
1580 // get the real file referred by .so lnk file
1581 char lnkFilePath[NPP_PATH_MAX] = {0};
1582 char lnkReferFilePath[NPP_PATH_MAX] = {0};
1583 char* pHome = getpwuid(getuid())->pw_dir;
1584 strcat(lnkFilePath, pHome);
1585 strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1587 struct stat sBuf;
1588 if (0 > lstat(lnkFilePath, &sBuf))
1589 return false;
1590 if (!S_ISLNK(sBuf.st_mode))
1591 return false;
1592 if (0 >= readlink(lnkFilePath, lnkReferFilePath, NPP_PATH_MAX))
1593 return false;
1594 // If the link is relative, then we regard it as non-standard
1595 if (lnkReferFilePath[0] != '/')
1596 return false;
1598 // get the real file path
1599 char realFilePath[NPP_PATH_MAX] = {0};
1600 ::rtl::OString tempString;
1601 if (!getDllURL(&tempString)) {
1602 return false;
1604 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1605 strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
1607 if (0 != strcmp(lnkReferFilePath, realFilePath))
1608 return false;
1609 return true;
1610 #endif
1611 #ifdef WNT
1612 // get the value from registry
1613 sal_Bool ret = true;
1614 ::rtl::OString tempString;
1615 char realFilePath[NPP_PATH_MAX] = {0};
1616 if (!getDllURL(&tempString)){
1617 return false;
1619 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1620 if(! lc_isInstalled(realFilePath))
1621 ret =true;
1622 else
1623 ret = false;
1624 return ret;
1625 #endif
1628 sal_Bool MozPluginTabPage::installPlugin()
1630 #ifdef UNIX
1631 // get the real file referred by .so lnk file
1632 char lnkFilePath[NPP_PATH_MAX] = {0};
1633 char* pHome = getpwuid(getuid())->pw_dir;
1634 strcat(lnkFilePath, pHome);
1635 strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1636 remove(lnkFilePath);
1638 // create the dirs if necessary
1639 struct stat buf;
1640 char tmpDir[NPP_PATH_MAX] = {0};
1641 sprintf(tmpDir, "%s/.mozilla", pHome);
1642 if (0 > stat(lnkFilePath, &buf))
1644 mkdir(tmpDir, 0755);
1645 strcat(tmpDir, "/plugins");
1646 mkdir(tmpDir, 0755);
1649 // get the real file path
1650 char realFilePath[NPP_PATH_MAX] = {0};
1651 ::rtl::OString tempString;
1652 if (!getDllURL(&tempString)) {
1653 return false;
1655 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1656 strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
1658 // create the link
1659 if (0 != symlink(realFilePath, lnkFilePath))
1660 return false;
1661 return true;
1662 #endif
1663 #ifdef WNT
1664 ::rtl::OString tempString;
1665 char realFilePath[NPP_PATH_MAX] = {0};
1666 if (!getDllURL(&tempString)) {
1667 return false;
1669 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1670 if( !lc_installPlugin(realFilePath))
1671 return true;
1672 else
1673 return false;
1674 #endif
1677 sal_Bool MozPluginTabPage::uninstallPlugin()
1679 #ifdef UNIX
1680 // get the real file referred by .so lnk file
1681 char lnkFilePath[NPP_PATH_MAX] = {0};
1682 char* pHome = getpwuid(getuid())->pw_dir;
1683 strcat(lnkFilePath, pHome);
1684 strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1686 if(0 > remove(lnkFilePath))
1687 return false;
1688 return true;
1689 #endif
1690 #ifdef WNT
1691 ::rtl::OString tempString;
1692 char realFilePath[NPP_PATH_MAX] = {0};
1693 if (!getDllURL(&tempString)) {
1694 return false;
1696 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1697 if(!lc_uninstallPlugin(realFilePath))
1698 return true;
1699 else
1700 return false;
1701 #endif
1703 //added by jmeng end
1705 /* -------------------------------------------------------------------------*/
1707 class MailerProgramCfg_Impl : public utl::ConfigItem
1709 friend class SvxEMailTabPage;
1710 // variables
1711 OUString sProgram;
1712 // readonly states
1713 sal_Bool bROProgram;
1715 const Sequence<OUString> GetPropertyNames();
1716 public:
1717 MailerProgramCfg_Impl();
1718 virtual ~MailerProgramCfg_Impl();
1720 virtual void Commit();
1721 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames);
1724 /* -------------------------------------------------------------------------*/
1726 MailerProgramCfg_Impl::MailerProgramCfg_Impl() :
1727 utl::ConfigItem(C2U("Office.Common/ExternalMailer")),
1728 bROProgram(sal_False)
1730 const Sequence< OUString > aNames = GetPropertyNames();
1731 const Sequence< Any > aValues = GetProperties(aNames);
1732 const Sequence< sal_Bool > aROStates = GetReadOnlyStates(aNames);
1733 const Any* pValues = aValues.getConstArray();
1734 const sal_Bool* pROStates = aROStates.getConstArray();
1735 for(sal_Int32 nProp = 0; nProp < aValues.getLength(); nProp++)
1737 if(pValues[nProp].hasValue())
1739 switch(nProp)
1741 case 0 :
1743 pValues[nProp] >>= sProgram;
1744 bROProgram = pROStates[nProp];
1746 break;
1752 /* -------------------------------------------------------------------------*/
1754 MailerProgramCfg_Impl::~MailerProgramCfg_Impl()
1758 /* -------------------------------------------------------------------------*/
1760 const Sequence<OUString> MailerProgramCfg_Impl::GetPropertyNames()
1762 Sequence<OUString> aRet(1);
1763 OUString* pRet = aRet.getArray();
1764 pRet[0] = C2U("Program");
1765 return aRet;
1768 /* -------------------------------------------------------------------------*/
1770 void MailerProgramCfg_Impl::Commit()
1772 const Sequence< OUString > aOrgNames = GetPropertyNames();
1773 sal_Int32 nOrgCount = aOrgNames.getLength();
1775 Sequence< OUString > aNames(nOrgCount);
1776 Sequence< Any > aValues(nOrgCount);
1777 sal_Int32 nRealCount = 0;
1779 for(int nProp = 0; nProp < nOrgCount; nProp++)
1781 switch(nProp)
1783 case 0:
1785 if (!bROProgram)
1787 aNames[nRealCount] = aOrgNames[nProp];
1788 aValues[nRealCount] <<= sProgram;
1789 ++nRealCount;
1792 break;
1796 aNames.realloc(nRealCount);
1797 aValues.realloc(nRealCount);
1798 PutProperties(aNames, aValues);
1801 void MailerProgramCfg_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
1805 /* -------------------------------------------------------------------------*/
1807 struct SvxEMailTabPage_Impl
1809 MailerProgramCfg_Impl aMailConfig;
1812 SvxEMailTabPage::SvxEMailTabPage(Window* pParent, const SfxItemSet& rSet) :
1813 SfxTabPage(pParent, CUI_RES( RID_SVXPAGE_INET_MAIL ), rSet),
1814 aMailFL(this, CUI_RES(FL_MAIL )),
1815 aMailerURLFI(this, CUI_RES(FI_MAILERURL )),
1816 aMailerURLFT(this, CUI_RES(FT_MAILERURL )),
1817 aMailerURLED(this, CUI_RES(ED_MAILERURL )),
1818 aMailerURLPB(this, CUI_RES(PB_MAILERURL )),
1819 m_sDefaultFilterName( CUI_RES(STR_DEFAULT_FILENAME )),
1820 pImpl(new SvxEMailTabPage_Impl)
1822 FreeResource();
1824 aMailerURLPB.SetClickHdl( LINK( this, SvxEMailTabPage, FileDialogHdl_Impl ) );
1826 // FixedText not wide enough?
1827 long nTxtW = aMailerURLFT.GetCtrlTextWidth( aMailerURLFT.GetText() );
1828 long nCtrlW = aMailerURLFT.GetSizePixel().Width();
1829 if ( nTxtW >= nCtrlW )
1831 long nDelta = Max( (long)10, nTxtW - nCtrlW );
1832 // so FixedText wider
1833 Size aNewSz = aMailerURLFT.GetSizePixel();
1834 aNewSz.Width() += nDelta;
1835 aMailerURLFT.SetSizePixel( aNewSz );
1836 // and Edit smaller
1837 aNewSz = aMailerURLED.GetSizePixel();
1838 aNewSz.Width() -= nDelta;
1839 Point aNewPt = aMailerURLED.GetPosPixel();
1840 aNewPt.X() += nDelta;
1841 aMailerURLED.SetPosSizePixel( aNewPt, aNewSz );
1845 /* -------------------------------------------------------------------------*/
1847 SvxEMailTabPage::~SvxEMailTabPage()
1849 delete pImpl;
1852 /* -------------------------------------------------------------------------*/
1854 SfxTabPage* SvxEMailTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1856 return new SvxEMailTabPage(pParent, rAttrSet);
1859 /* -------------------------------------------------------------------------*/
1861 sal_Bool SvxEMailTabPage::FillItemSet( SfxItemSet& )
1863 sal_Bool bMailModified = sal_False;
1864 if(!pImpl->aMailConfig.bROProgram && aMailerURLED.GetSavedValue() != aMailerURLED.GetText())
1866 pImpl->aMailConfig.sProgram = aMailerURLED.GetText();
1867 bMailModified = sal_True;
1869 if ( bMailModified )
1870 pImpl->aMailConfig.Commit();
1872 return sal_False;
1875 /* -------------------------------------------------------------------------*/
1877 void SvxEMailTabPage::Reset( const SfxItemSet& )
1879 aMailerURLED.Enable(sal_True );
1880 aMailerURLPB.Enable(sal_True );
1882 if(pImpl->aMailConfig.bROProgram)
1883 aMailerURLFI.Show();
1885 aMailerURLED.SetText(pImpl->aMailConfig.sProgram);
1886 aMailerURLED.SaveValue();
1887 aMailerURLED.Enable(!pImpl->aMailConfig.bROProgram);
1888 aMailerURLPB.Enable(!pImpl->aMailConfig.bROProgram);
1889 aMailerURLFT.Enable(!pImpl->aMailConfig.bROProgram);
1891 aMailFL.Enable(aMailerURLFT.IsEnabled() ||
1892 aMailerURLED.IsEnabled() ||
1893 aMailerURLPB.IsEnabled());
1896 /* -------------------------------------------------------------------------*/
1898 IMPL_LINK( SvxEMailTabPage, FileDialogHdl_Impl, PushButton*, pButton )
1900 if ( &aMailerURLPB == pButton && !pImpl->aMailConfig.bROProgram )
1902 FileDialogHelper aHelper(
1903 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
1904 WB_OPEN );
1905 String sPath = aMailerURLED.GetText();
1906 if ( !sPath.Len() )
1907 sPath.AppendAscii("/usr/bin");
1909 String sUrl;
1910 ::utl::LocalFileHelper::ConvertPhysicalNameToURL(sPath,sUrl);
1911 aHelper.SetDisplayDirectory(sUrl);
1912 aHelper.AddFilter( m_sDefaultFilterName, String::CreateFromAscii("*"));
1914 if ( ERRCODE_NONE == aHelper.Execute() )
1916 sUrl = aHelper.GetPath();
1917 ::utl::LocalFileHelper::ConvertURLToPhysicalName(sUrl,sPath);
1918 aMailerURLED.SetText(sPath);
1921 return 0;
1924 // -----------------------------------------------------------------------------