Update ooo320-m1
[ooovba.git] / svx / source / cui / optinet2.cxx
blob2a74cc6761ef50eb63e1ed49f590104a22353ec2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optinet2.cxx,v $
10 * $Revision: 1.31 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
39 #include <tools/shl.hxx>
40 #include <tools/config.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <svtools/intitem.hxx>
43 #include <svtools/stritem.hxx>
44 #include <svtools/eitem.hxx>
45 #include <svtools/slstitm.hxx>
46 #include <sfx2/fcontnr.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include <sfx2/docfilt.hxx>
49 #include <sfx2/viewsh.hxx>
50 #include <sfx2/sfxsids.hrc>
51 #include <sfx2/filedlghelper.hxx>
52 #include <tools/inetdef.hxx>
53 #include <svtools/urihelper.hxx>
55 #ifndef _CNTWIDS_HRC
56 #include <svtools/cntwids.hrc>
57 #endif
58 #include <svtools/inetoptions.hxx>
59 #ifndef _SV_SVAPP_HXX
60 #include <sfx2/app.hxx>
61 #endif
62 #include <sfx2/objsh.hxx>
63 #include <unotools/bootstrap.hxx>
64 #include <vcl/help.hxx>
65 #include <sfx2/viewfrm.hxx>
66 #include <tools/urlobj.hxx>
67 #include <svtools/pathoptions.hxx>
68 #ifndef INCLUDED_SVTOOLS_SECURITIYOPTIONS_HXX
69 #include <svtools/securityoptions.hxx>
70 #endif
71 #ifndef _SVTOOLS_JAVAPTIONS_HXX
72 #include <svtools/javaoptions.hxx>
73 #endif
74 #include <unotools/localfilehelper.hxx>
75 #include <svtools/extendedsecurityoptions.hxx>
76 #include <com/sun/star/uno/Sequence.hxx>
77 #define _SVX_OPTINET2_CXX
78 #include <svx/dialmgr.hxx>
79 #include "optinet2.hxx"
80 //CHINA001 #ifndef _SVX_MULTIFIL_HXX
81 //CHINA001 #include "multifil.hxx"
82 //CHINA001 #endif
83 #include <svx/svxdlg.hxx> //CHINA001
84 #ifndef _SVX_DIALOGS_HRC
85 #include <svx/dialogs.hrc>
86 #endif
87 #ifndef _SVX_OPTINET_HRC
88 #include "optinet2.hrc"
89 #endif
90 #ifndef _SVX_HELPID_HRC
91 #include "helpid.hrc"
92 #endif
93 #include "ofaitem.hxx"
94 #include "htmlmode.hxx"
96 // for security TP
97 #include <comphelper/processfactory.hxx>
98 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
100 #ifdef UNX
101 #include <sys/types.h>
102 #include <sys/stat.h>
103 #include <unistd.h>
104 #include <fcntl.h>
105 #include <pwd.h>
106 #include <sys/types.h>
107 #include <string.h>
108 #include <rtl/textenc.h>
109 #include <rtl/locale.h>
110 #include <osl/nlsupport.h>
111 #endif
112 #include <sal/types.h>
113 #include <rtl/ustring.hxx>
114 #include <osl/file.hxx>
115 #include <osl/process.h>
116 #include <com/sun/star/container/XNameReplace.hpp>
117 #include <com/sun/star/container/XNameAccess.hpp>
118 #include <com/sun/star/beans/PropertyValue.hpp>
119 #include <com/sun/star/beans/XPropertySet.hpp>
120 #include <com/sun/star/beans/XPropertyState.hpp>
121 #include <com/sun/star/util/XChangesBatch.hpp>
122 #include <comphelper/processfactory.hxx>
124 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
125 #include "com/sun/star/task/XMasterPasswordHandling2.hpp"
126 #include "com/sun/star/task/XPasswordContainer.hpp"
127 #include "securityoptions.hxx"
128 #include "webconninfo.hxx"
130 using namespace ::com::sun::star;
131 using namespace ::com::sun::star::uno;
132 using namespace ::sfx2;
133 using ::rtl::OUString;
135 //CHINA001 copy from multipat.hxx begin
136 // define ----------------------------------------------------------------
138 // different delimiter for Unix (:) and Windows (;)
140 #ifdef UNX
141 #define CLASSPATH_DELIMITER ':'
142 #else
143 #define CLASSPATH_DELIMITER ';'
144 #endif
145 //CHINA001 copy from multipat.hxx end
146 // static ----------------------------------------------------------------
148 #define C2U(cChar) OUString::createFromAscii(cChar)
150 #define INET_SEARCH_TOKEN '"'
151 #define RET_ALL ((short)200)
152 #define CFG_READONLY_DEFAULT FALSE
154 #include <sal/config.h>
156 SV_IMPL_PTRARR( SfxFilterPtrArr, SfxFilterPtr )
158 const char* SEARCHENGINE_INI = "srcheng.ini";
159 const char* SEARCHENGINE_GROUP = "SearchEngines-$(vlang)";
161 // -----------------------------------------------------------------------
163 String lcl_MakeTabEntry(const SfxFilter* pFilter)
165 String sEntry(pFilter->GetMimeType());
166 sEntry += '\t';
167 sEntry += pFilter->GetWildcard().GetWildCard();
168 sEntry += '\t';
169 sEntry += pFilter->GetName();
170 #if defined(OS2)
171 sEntry += '\t';
172 sEntry += pFilter->GetTypeName();
173 #endif
174 return sEntry;
177 // -----------------------------------------------------------------------
179 BOOL IsJavaInstalled_Impl( /*!!!SfxIniManager* pIniMgr*/ )
181 BOOL bRet = FALSE;
182 /*!!! (pb) needs new implementation
183 String aIniEntry;
184 String aFullName = Config::GetConfigName( pIniMgr->Get( SFX_KEY_USERCONFIG_PATH ),
185 String::CreateFromAscii("java") );
186 INetURLObject aIniFileObj( aFullName, INET_PROT_FILE );
187 String aIniPath = aIniFileObj.getName();
188 if ( pIniMgr->SearchFile( aIniPath ) )
190 Config aJavaCfg( aIniPath );
191 aJavaCfg.SetGroup( "Java" );
192 ByteString sTemp = aJavaCfg.ReadKey( ByteString(::rtl::OUStringToOString(pIniMgr->GetKeyName( SFX_KEY_JAVA_SYSTEMCLASSPATH ),RTL_TEXTENCODING_UTF8)) );
193 String aJavaSystemClassPath = ::rtl::OStringToOUString(sTemp,RTL_TEXTENCODING_UTF8);
194 String aJavaRuntimeLib = ::rtl::OStringToOUString(aJavaCfg.ReadKey( "RuntimeLib" ),RTL_TEXTENCODING_UTF8);
195 if ( aJavaSystemClassPath.Len() && aJavaRuntimeLib.Len() )
196 bRet = TRUE;
199 return bRet;
202 // -----------------------------------------------------------------------
204 void SvxNoSpaceEdit::KeyInput( const KeyEvent& rKEvent )
206 if ( bOnlyNumeric )
208 const KeyCode& rKeyCode = rKEvent.GetKeyCode();
209 USHORT nGroup = rKeyCode.GetGroup();
210 USHORT nKey = rKeyCode.GetCode();
211 BOOL bValid = ( KEYGROUP_NUM == nGroup || KEYGROUP_CURSOR == nGroup ||
212 ( KEYGROUP_MISC == nGroup && ( nKey < KEY_ADD || nKey > KEY_EQUAL ) ) );
213 if ( !bValid && ( rKeyCode.IsMod1() && (
214 KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) )
215 // Erase, Copy, Paste, Select All und Undo soll funktionieren
216 bValid = TRUE;
218 if ( bValid )
219 Edit::KeyInput(rKEvent);
221 else if( rKEvent.GetKeyCode().GetCode() != KEY_SPACE )
222 Edit::KeyInput(rKEvent);
225 // -----------------------------------------------------------------------
227 void SvxNoSpaceEdit::Modify()
229 Edit::Modify();
231 if ( bOnlyNumeric )
233 XubString aValue = GetText();
235 if ( !ByteString(::rtl::OUStringToOString(aValue,RTL_TEXTENCODING_UTF8)).IsNumericAscii() || (long)aValue.ToInt32() > USHRT_MAX )
236 // der H�chstwert einer Portnummer ist USHRT_MAX
237 ErrorBox( this, SVX_RES( RID_SVXERR_OPT_PROXYPORTS ) ).Execute();
241 /********************************************************************/
242 /********************************************************************/
243 /* */
244 /* SvxProxyTabPage */
245 /* */
246 /* */
247 /********************************************************************/
248 /********************************************************************/
250 SvxProxyTabPage::SvxProxyTabPage(Window* pParent, const SfxItemSet& rSet ) :
251 SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_INET_PROXY ), rSet ),
252 aOptionGB (this, SVX_RES(GB_SETTINGS)),
254 aProxyModeFT (this, SVX_RES(FT_PROXYMODE)),
255 aProxyModeLB (this, SVX_RES(LB_PROXYMODE)),
257 aHttpProxyFT (this, SVX_RES( FT_HTTP_PROXY )),
258 aHttpProxyED (this, SVX_RES( ED_HTTP_PROXY )),
259 aHttpPortFT (this, SVX_RES( FT_HTTP_PORT )),
260 aHttpPortED (this, SVX_RES( ED_HTTP_PORT ), TRUE),
262 aHttpsProxyFT (this, SVX_RES( FT_HTTPS_PROXY )),
263 aHttpsProxyED (this, SVX_RES( ED_HTTPS_PROXY )),
264 aHttpsPortFT (this, SVX_RES( FT_HTTPS_PORT )),
265 aHttpsPortED (this, SVX_RES( ED_HTTPS_PORT ), TRUE),
267 aFtpProxyFT (this, SVX_RES( FT_FTP_PROXY )),
268 aFtpProxyED (this, SVX_RES( ED_FTP_PROXY )),
269 aFtpPortFT (this, SVX_RES( FT_FTP_PORT )),
270 aFtpPortED (this, SVX_RES( ED_FTP_PORT ), TRUE),
272 aNoProxyForFT (this, SVX_RES( FT_NOPROXYFOR )),
273 aNoProxyForED (this, SVX_RES( ED_NOPROXYFOR )),
274 aNoProxyDescFT (this, SVX_RES( ED_NOPROXYDESC )),
275 sFromBrowser ( SVX_RES( ST_PROXY_FROM_BROWSER ) ),
276 aProxyModePN(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType")),
277 aHttpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName")),
278 aHttpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort")),
279 aHttpsProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyName")),
280 aHttpsPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyPort")),
281 aFtpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName")),
282 aFtpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort")),
283 aNoProxyDescPN(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy"))
285 FreeResource();
287 aHttpPortED.SetMaxTextLen(5);
288 aHttpsPortED.SetMaxTextLen(5);
289 aFtpPortED.SetMaxTextLen(5);
290 Link aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl );
291 aHttpPortED.SetLoseFocusHdl( aLink );
292 aHttpsPortED.SetLoseFocusHdl( aLink );
293 aFtpPortED.SetLoseFocusHdl( aLink );
295 aProxyModeLB.SetSelectHdl(LINK( this, SvxProxyTabPage, ProxyHdl_Impl ));
297 Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager(
298 ::comphelper::getProcessServiceFactory());
300 if( xServiceManager.is() )
304 Reference< com::sun::star::lang::XMultiServiceFactory > xConfigurationProvider =
305 Reference< com::sun::star::lang::XMultiServiceFactory > ( xServiceManager->createInstance( rtl::OUString(
306 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
307 UNO_QUERY_THROW);
309 OUString aConfigRoot(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings" ) );
311 beans::PropertyValue aProperty;
312 aProperty.Name = OUString(RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
313 aProperty.Value = makeAny( aConfigRoot );
315 Sequence< Any > aArgumentList( 1 );
316 aArgumentList[0] = makeAny( aProperty );
318 m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments( rtl::OUString(
319 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
320 aArgumentList );
322 catch ( RuntimeException& )
327 ArrangeControls_Impl();
330 /*-----------------12.08.96 14.55-------------------
332 --------------------------------------------------*/
334 SvxProxyTabPage::~SvxProxyTabPage()
338 /*-----------------12.08.96 14.55-------------------
340 --------------------------------------------------*/
342 SfxTabPage* SvxProxyTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
344 return new SvxProxyTabPage(pParent, rAttrSet);
347 /*-----------------02.09.04 14.55-------------------
349 --------------------------------------------------*/
351 void SvxProxyTabPage::ReadConfigData_Impl()
353 try {
354 Reference< container::XNameAccess > xNameAccess(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
356 sal_Int32 nIntValue = 0;
357 OUString aStringValue;
359 if( xNameAccess->getByName(aProxyModePN) >>= nIntValue )
361 aProxyModeLB.SelectEntryPos( (USHORT) nIntValue );
364 if( xNameAccess->getByName(aHttpProxyPN) >>= aStringValue )
366 aHttpProxyED.SetText( aStringValue );
369 if( xNameAccess->getByName(aHttpPortPN) >>= nIntValue )
371 aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
374 if( xNameAccess->getByName(aHttpsProxyPN) >>= aStringValue )
376 aHttpsProxyED.SetText( aStringValue );
379 if( xNameAccess->getByName(aHttpsPortPN) >>= nIntValue )
381 aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
384 if( xNameAccess->getByName(aFtpProxyPN) >>= aStringValue )
386 aFtpProxyED.SetText( aStringValue );
389 if( xNameAccess->getByName(aFtpPortPN) >>= nIntValue )
391 aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
394 if( xNameAccess->getByName(aNoProxyDescPN) >>= aStringValue )
396 aNoProxyForED.SetText( aStringValue );
400 catch(container::NoSuchElementException e) {
401 OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: NoSuchElementException caught" );
404 catch(com::sun::star::lang::WrappedTargetException e) {
405 OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: WrappedTargetException caught" );
408 catch(RuntimeException e) {
409 OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: RuntimeException caught" );
414 /*-----------------02.09.04 14.55-------------------
416 --------------------------------------------------*/
418 void SvxProxyTabPage::ReadConfigDefaults_Impl()
422 Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
424 sal_Int32 nIntValue = 0;
425 OUString aStringValue;
427 if( xPropertyState->getPropertyDefault(aHttpProxyPN) >>= aStringValue )
429 aHttpProxyED.SetText( aStringValue );
432 if( xPropertyState->getPropertyDefault(aHttpPortPN) >>= nIntValue )
434 aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
437 if( xPropertyState->getPropertyDefault(aHttpsProxyPN) >>= aStringValue )
439 aHttpsProxyED.SetText( aStringValue );
442 if( xPropertyState->getPropertyDefault(aHttpsPortPN) >>= nIntValue )
444 aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
447 if( xPropertyState->getPropertyDefault(aFtpProxyPN) >>= aStringValue )
449 aFtpProxyED.SetText( aStringValue );
452 if( xPropertyState->getPropertyDefault(aFtpPortPN) >>= nIntValue )
454 aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
457 if( xPropertyState->getPropertyDefault(aNoProxyDescPN) >>= aStringValue )
459 aNoProxyForED.SetText( aStringValue );
462 catch(beans::UnknownPropertyException e)
464 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
467 catch(com::sun::star::lang::WrappedTargetException e) {
468 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
471 catch(RuntimeException e)
473 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
477 /*-----------------02.09.04 14.55-------------------
479 --------------------------------------------------*/
481 void SvxProxyTabPage::RestoreConfigDefaults_Impl()
485 Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
487 xPropertyState->setPropertyToDefault(aProxyModePN);
488 xPropertyState->setPropertyToDefault(aHttpProxyPN);
489 xPropertyState->setPropertyToDefault(aHttpPortPN);
490 xPropertyState->setPropertyToDefault(aHttpsProxyPN);
491 xPropertyState->setPropertyToDefault(aHttpsPortPN);
492 xPropertyState->setPropertyToDefault(aFtpProxyPN);
493 xPropertyState->setPropertyToDefault(aFtpPortPN);
494 xPropertyState->setPropertyToDefault(aNoProxyDescPN);
496 Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
497 xChangesBatch->commitChanges();
500 catch(beans::UnknownPropertyException e)
502 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
505 catch(com::sun::star::lang::WrappedTargetException e) {
506 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
509 catch(RuntimeException e)
511 OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
515 /*-----------------12.08.96 14.55-------------------
517 --------------------------------------------------*/
519 void SvxProxyTabPage::Reset(const SfxItemSet&)
521 ReadConfigData_Impl();
523 aProxyModeLB.SaveValue();
524 aHttpProxyED.SaveValue();
525 aHttpPortED.SaveValue();
526 aHttpsProxyED.SaveValue();
527 aHttpsPortED.SaveValue();
528 aFtpProxyED.SaveValue();
529 aFtpPortED.SaveValue();
530 aNoProxyForED.SaveValue();
532 EnableControls_Impl( aProxyModeLB.GetSelectEntryPos() == 2 );
535 /*-----------------12.08.96 16.34-------------------
537 --------------------------------------------------*/
539 BOOL SvxProxyTabPage::FillItemSet(SfxItemSet& )
541 BOOL bModified=FALSE;
543 try {
544 Reference< beans::XPropertySet > xPropertySet(m_xConfigurationUpdateAccess, UNO_QUERY_THROW );
546 USHORT nSelPos = aProxyModeLB.GetSelectEntryPos();
547 if(aProxyModeLB.GetSavedValue() != nSelPos)
549 if( nSelPos == 1 )
551 RestoreConfigDefaults_Impl();
552 return TRUE;
555 xPropertySet->setPropertyValue(aProxyModePN,
556 makeAny((sal_Int32) nSelPos));
557 bModified = TRUE;
560 if(aHttpProxyED.GetSavedValue() != aHttpProxyED.GetText())
562 xPropertySet->setPropertyValue( aHttpProxyPN,
563 makeAny(rtl::OUString(aHttpProxyED.GetText())));
564 bModified = TRUE;
567 if ( aHttpPortED.GetSavedValue() != aHttpPortED.GetText() )
569 xPropertySet->setPropertyValue( aHttpPortPN,
570 makeAny(aHttpPortED.GetText().ToInt32()));
571 bModified = TRUE;
574 if(aHttpsProxyED.GetSavedValue() != aHttpsProxyED.GetText())
576 xPropertySet->setPropertyValue( aHttpsProxyPN,
577 makeAny(rtl::OUString(aHttpsProxyED.GetText())));
578 bModified = TRUE;
581 if ( aHttpsPortED.GetSavedValue() != aHttpsPortED.GetText() )
583 xPropertySet->setPropertyValue( aHttpsPortPN,
584 makeAny(aHttpsPortED.GetText().ToInt32()));
585 bModified = TRUE;
588 if(aFtpProxyED.GetSavedValue() != aFtpProxyED.GetText())
590 xPropertySet->setPropertyValue( aFtpProxyPN,
591 makeAny( rtl::OUString(aFtpProxyED.GetText())));
592 bModified = TRUE;
595 if ( aFtpPortED.GetSavedValue() != aFtpPortED.GetText() )
597 xPropertySet->setPropertyValue( aFtpPortPN,
598 makeAny(aFtpPortED.GetText().ToInt32()));
599 bModified = TRUE;
602 if ( aNoProxyForED.GetSavedValue() != aNoProxyForED.GetText() )
604 xPropertySet->setPropertyValue( aNoProxyDescPN,
605 makeAny( rtl::OUString(aNoProxyForED.GetText())));
606 bModified = TRUE;
609 Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
610 xChangesBatch->commitChanges();
613 catch(com::sun::star::lang::IllegalArgumentException e) {
614 OSL_TRACE( "SvxProxyTabPage::FillItemSet: IllegalArgumentException caught" );
617 catch(beans::UnknownPropertyException e) {
618 OSL_TRACE( "SvxProxyTabPage::FillItemSet: UnknownPropertyException caught" );
621 catch(beans::PropertyVetoException e) {
622 OSL_TRACE( "SvxProxyTabPage::FillItemSet: PropertyVetoException caught" );
625 catch(com::sun::star::lang::WrappedTargetException e) {
626 OSL_TRACE( "SvxProxyTabPage::FillItemSet: WrappedTargetException caught" );
629 catch(RuntimeException e) {
630 OSL_TRACE( "SvxProxyTabPage::FillItemSet: RuntimeException caught" );
633 return bModified;
636 void SvxProxyTabPage::ArrangeControls_Impl()
638 //-->Calculate dynamical width of controls, add buy wuy for i71445 Time: 2007.02.27
639 long nWidth = aProxyModeFT.GetCtrlTextWidth( aProxyModeFT.GetText() );
640 long nTemp = aHttpProxyFT.GetCtrlTextWidth( aHttpProxyFT.GetText() );
641 if ( nTemp > nWidth )
642 nWidth = nTemp;
643 nTemp = aHttpsProxyFT.GetCtrlTextWidth( aHttpsProxyFT.GetText() );
644 if ( nTemp > nWidth )
645 nWidth = nTemp;
646 nTemp = aFtpProxyFT.GetCtrlTextWidth( aFtpProxyFT.GetText() );
647 if ( nTemp > nWidth )
648 nWidth = nTemp;
649 nTemp = aNoProxyForFT.GetCtrlTextWidth( aNoProxyForFT.GetText() );
650 if ( nTemp > nWidth )
651 nWidth = nTemp;
653 nWidth += 10; // To be sure the length of the FixedText is enough on all platforms
654 const long nFTWidth = aProxyModeFT.GetSizePixel().Width();
655 if ( nWidth > nFTWidth )
657 Size aNewSize = aProxyModeFT.GetSizePixel();
658 aNewSize.Width() = nWidth;
660 aProxyModeFT.SetSizePixel( aNewSize );
661 aHttpProxyFT.SetSizePixel( aNewSize );
662 aHttpsProxyFT.SetSizePixel( aNewSize );
663 aFtpProxyFT.SetSizePixel( aNewSize );
664 aNoProxyForFT.SetSizePixel( aNewSize );
666 const long nDelta = nWidth - nFTWidth;
667 Point aNewPos = aProxyModeLB.GetPosPixel();
668 aNewPos.X() += nDelta;
670 aProxyModeLB.SetPosPixel( aNewPos );
672 aNewSize = aHttpProxyED.GetSizePixel();
673 aNewSize.Width() -= nDelta;
675 aNewPos.Y() = aHttpProxyED.GetPosPixel().Y();
676 aHttpProxyED.SetPosSizePixel( aNewPos, aNewSize );
677 aNewPos.Y() = aHttpsProxyED.GetPosPixel().Y();
678 aHttpsProxyED.SetPosSizePixel( aNewPos, aNewSize );
679 aNewPos.Y() = aFtpProxyED.GetPosPixel().Y();
680 aFtpProxyED.SetPosSizePixel( aNewPos, aNewSize );
681 aNewPos.Y() = aNoProxyForED.GetPosPixel().Y();
682 aNoProxyForED.SetPosSizePixel( aNewPos, aNewSize );
684 //<--End buy wuy for i71445 Time: 2007.02.27
687 /*-----------------12.08.96 13.38-------------------
689 --------------------------------------------------*/
690 void SvxProxyTabPage::EnableControls_Impl(BOOL bEnable)
692 aHttpProxyFT.Enable(bEnable);
693 aHttpProxyED.Enable(bEnable);
694 aHttpPortFT.Enable(bEnable);
695 aHttpPortED.Enable(bEnable);
697 aHttpsProxyFT.Enable(bEnable);
698 aHttpsProxyED.Enable(bEnable);
699 aHttpsPortFT.Enable(bEnable);
700 aHttpsPortED.Enable(bEnable);
702 aFtpProxyFT.Enable(bEnable);
703 aFtpProxyED.Enable(bEnable);
704 aFtpPortFT.Enable(bEnable);
705 aFtpPortED.Enable(bEnable);
707 aNoProxyForFT.Enable(bEnable);
708 aNoProxyForED.Enable(bEnable);
709 aNoProxyDescFT.Enable(bEnable);
712 // -----------------------------------------------------------------------
714 IMPL_LINK( SvxProxyTabPage, ProxyHdl_Impl, ListBox *, pBox )
716 USHORT nPos = pBox->GetSelectEntryPos();
718 // Restore original system values
719 if( nPos == 1 )
721 ReadConfigDefaults_Impl();
724 EnableControls_Impl(nPos == 2);
725 return 0;
728 // -----------------------------------------------------------------------
730 IMPL_LINK( SvxProxyTabPage, LoseFocusHdl_Impl, Edit *, pEdit )
732 XubString aValue = pEdit->GetText();
734 if ( !ByteString(::rtl::OUStringToOString(aValue,RTL_TEXTENCODING_UTF8)).IsNumericAscii() || (long)aValue.ToInt32() > USHRT_MAX )
735 pEdit->SetText( '0' );
736 return 0;
740 /********************************************************************/
741 /********************************************************************/
742 /* */
743 /* SvxSearchTabPage */
744 /* */
745 /* */
746 /********************************************************************/
747 /********************************************************************/
749 SvxSearchTabPage::SvxSearchTabPage(Window* pParent, const SfxItemSet& rSet ) :
751 SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_INET_SEARCH ), rSet ),
753 aSearchGB ( this, SVX_RES( GB_SEARCH ) ),
754 aSearchLB ( this, SVX_RES( LB_SEARCH ) ),
755 aSearchNameFT ( this, SVX_RES( FT_SEARCH_NAME ) ),
756 aSearchNameED ( this, SVX_RES( ED_SEARCH_NAME ) ),
757 aSearchFT ( this, SVX_RES( FT_SEARCH ) ),
758 aAndRB ( this, SVX_RES( RB_AND ) ),
759 aOrRB ( this, SVX_RES( RB_OR ) ),
760 aExactRB ( this, SVX_RES( RB_EXACT ) ),
762 aURLFT ( this, SVX_RES( FT_URL ) ),
763 aURLED ( this, SVX_RES( ED_URL ) ),
765 aPostFixFT ( this, SVX_RES( FT_POSTFIX ) ),
766 aPostFixED ( this, SVX_RES( ED_POSTFIX ) ),
767 aSeparatorFT ( this, SVX_RES( FT_SEPARATOR ) ),
768 aSeparatorED ( this, SVX_RES( ED_SEPARATOR ) ),
769 aCaseFT ( this, SVX_RES( FT_CASE ) ),
770 aCaseED ( this, SVX_RES( ED_CASE ) ),
772 aNewPB ( this, SVX_RES( PB_NEW ) ),
773 aAddPB ( this, SVX_RES( PB_ADD ) ),
774 aChangePB ( this, SVX_RES( PB_CHANGE ) ),
775 aDeletePB ( this, SVX_RES( PB_DELETE ) ),
777 sModifyMsg(SVX_RES(MSG_MODIFY))
779 FreeResource();
781 SetExchangeSupport();
782 aCaseED.SelectEntryPos(0); // falls kein Eintrag vorhanden ist, kann es sonst "Arger geben
784 aNewPB.SetClickHdl(LINK( this, SvxSearchTabPage, NewSearchHdl_Impl ) );
785 aAddPB.SetClickHdl(LINK( this, SvxSearchTabPage, AddSearchHdl_Impl ) );
786 aChangePB.SetClickHdl(LINK( this, SvxSearchTabPage, ChangeSearchHdl_Impl ) );
787 aDeletePB.SetClickHdl(LINK( this, SvxSearchTabPage, DeleteSearchHdl_Impl ) );
788 aSearchLB.SetSelectHdl(LINK( this, SvxSearchTabPage, SearchEntryHdl_Impl ) );
790 Link aLink = LINK( this, SvxSearchTabPage, SearchModifyHdl_Impl );
791 aSearchNameED.SetModifyHdl( aLink );
792 aURLED.SetModifyHdl( aLink );
793 aSeparatorED.SetModifyHdl( aLink );
794 aPostFixED.SetModifyHdl( aLink );
795 aCaseED.SetSelectHdl( aLink );
797 aLink = LINK( this, SvxSearchTabPage, SearchPartHdl_Impl );
798 aAndRB.SetClickHdl( aLink );
799 aOrRB.SetClickHdl( aLink );
800 aExactRB.SetClickHdl( aLink );
802 InitControls_Impl();
805 // -----------------------------------------------------------------------
806 SvxSearchTabPage::~SvxSearchTabPage()
809 // -----------------------------------------------------------------------
811 SfxTabPage* SvxSearchTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
813 return new SvxSearchTabPage(pParent, rAttrSet);
816 // -----------------------------------------------------------------------
818 void SvxSearchTabPage::Reset( const SfxItemSet& )
820 //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)
821 aChangePB.Disable();
822 aAddPB.Disable();
824 sal_uInt16 nCount = aSearchConfig.Count();
825 aSearchLB.Clear(); //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
826 for(sal_uInt16 i = 0; i < nCount; i++)
828 const SvxSearchEngineData& rData = aSearchConfig.GetData(i);
829 aSearchLB.InsertEntry(rData.sEngineName);
832 if ( nCount )
834 aSearchLB.SelectEntryPos(0);
835 SearchEntryHdl_Impl( &aSearchLB );
837 else
838 aDeletePB.Disable();
841 // -----------------------------------------------------------------------
843 BOOL SvxSearchTabPage::FillItemSet( SfxItemSet& )
845 if(aSearchConfig.IsModified())
846 aSearchConfig.Commit();
847 return TRUE;
849 /*--------------------------------------------------------------------*/
851 void SvxSearchTabPage::ActivatePage( const SfxItemSet& )
855 /*--------------------------------------------------------------------*/
857 int SvxSearchTabPage::DeactivatePage( SfxItemSet* _pSet )
859 //Modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
860 if(!ConfirmLeave(String()))
861 return KEEP_PAGE;
863 if ( _pSet )
864 FillItemSet( *_pSet );
865 return LEAVE_PAGE;
868 // -----------------------------------------------------------------------
870 //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
871 BOOL SvxSearchTabPage::ConfirmLeave( const String& rStringSelection)
873 if(aChangePB.IsEnabled())
875 QueryBox aQuery(this, WB_YES_NO_CANCEL|WB_DEF_YES, sModifyMsg);
876 USHORT nRet = aQuery.Execute();
877 if(RET_CANCEL == nRet)
879 if(rStringSelection.Len())
880 aSearchLB.SelectEntry(sLastSelectedEntry);
881 return FALSE;
883 else if(RET_YES == nRet)
885 USHORT nEntryPos = aSearchLB.GetEntryPos( aSearchNameED.GetText() );
886 if ( nEntryPos != LISTBOX_ENTRY_NOTFOUND )
887 aSearchLB.SelectEntryPos(nEntryPos);
888 else
889 aSearchLB.SetNoSelection();
890 ChangeSearchHdl_Impl(0);
891 if(rStringSelection.Len())
892 aSearchLB.SelectEntry(rStringSelection);
894 else if(RET_NO == nRet)
896 aChangePB.Enable(FALSE);
897 aAddPB.Enable(FALSE);
898 SearchEntryHdl_Impl(&aSearchLB);
901 if(aAddPB.IsEnabled())
903 QueryBox aQuery(this, WB_YES_NO_CANCEL|WB_DEF_YES, sModifyMsg);
904 USHORT nRet = aQuery.Execute();
905 if(RET_CANCEL == nRet)
907 aSearchLB.SetNoSelection();
908 return FALSE;
910 else if(RET_YES == nRet)
912 aSearchLB.SetNoSelection();
913 AddSearchHdl_Impl(0);
914 if(rStringSelection.Len())
915 aSearchLB.SelectEntry(rStringSelection);
917 else if(RET_NO == nRet)
919 aAddPB.Enable(FALSE);
920 aChangePB.Enable(FALSE);
921 NewSearchHdl_Impl(0);
925 return TRUE;
928 // -----------------------------------------------------------------------
930 void SvxSearchTabPage::InitControls_Impl()
932 // detect longest label text
933 sal_Int32 i = 0;
934 long nLabelTextWidth = 0;
935 Window* pLabels[] = { &aSearchNameFT, &aSearchFT, &aURLFT, &aPostFixFT, &aSeparatorFT, &aCaseFT };
936 Window** pLabel = pLabels;
937 const sal_Int32 nLabelCount = sizeof( pLabels ) / sizeof( pLabels[0] );
938 for ( ; i < nLabelCount; ++i, ++pLabel )
940 long nTemp = (*pLabel)->GetCtrlTextWidth( (*pLabel)->GetText() );
941 if ( nTemp > nLabelTextWidth )
942 nLabelTextWidth = nTemp;
945 // resize all labels
946 nLabelTextWidth = nLabelTextWidth * 120 / 100; // additional space looks better
947 const long nLabelWidth = aSearchNameFT.GetSizePixel().Width();
948 const long nDelta = nLabelWidth - nLabelTextWidth;
949 pLabel = pLabels;
950 for ( i = 0; i < nLabelCount; ++i, ++pLabel )
952 Size aNewSize = (*pLabel)->GetSizePixel();
953 aNewSize.Width() += nDelta;
954 (*pLabel)->SetSizePixel( aNewSize );
957 // resize and move the edits
958 Window* pEdits[] = { &aSearchNameED, &aAndRB, &aOrRB,
959 &aExactRB, &aURLED, &aPostFixED, &aSeparatorED, &aCaseED };
960 Window** pEdit = pEdits;
961 const sal_Int32 nCCount = sizeof( pEdits ) / sizeof( pEdits[ 0 ] );
962 for ( i = 0; i < nCCount; ++i, ++pEdit )
964 Point aNewPos = (*pEdit)->GetPosPixel();
965 aNewPos.X() -= nDelta;
966 Size aNewSize = (*pEdit)->GetSizePixel();
967 if ( (*pEdit) != &aSeparatorED && (*pEdit) != &aCaseED )
968 aNewSize.Width() += nDelta;
969 (*pEdit)->SetPosSizePixel( aNewPos, aNewSize );
973 // -----------------------------------------------------------------------
975 IMPL_LINK( SvxSearchTabPage, NewSearchHdl_Impl, PushButton *, EMPTYARG )
977 //The 3 lines below is modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
978 SearchEntryHdl_Impl(&aSearchLB);
979 if(aChangePB.IsEnabled() || aAddPB.IsEnabled())
980 return 0;
981 aSearchNameED.SetText( String() );
982 aSearchLB.SetNoSelection();
983 aCurrentSrchData = SvxSearchEngineData();
984 aAndRB.Check( TRUE );
985 SearchEntryHdl_Impl( &aSearchLB );
986 SearchPartHdl_Impl( &aAndRB );
987 return 0;
990 // -----------------------------------------------------------------------
992 IMPL_LINK( SvxSearchTabPage, AddSearchHdl_Impl, PushButton *, EMPTYARG )
994 //The following two lines is added by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
995 aAddPB.Enable(FALSE);
996 aChangePB.Enable(FALSE);
997 aCurrentSrchData.sEngineName = aSearchNameED.GetText();
998 aSearchConfig.SetData(aCurrentSrchData);
999 aSearchLB.InsertEntry( aCurrentSrchData.sEngineName );
1000 aSearchLB.SelectEntry( aCurrentSrchData.sEngineName );
1001 SearchEntryHdl_Impl( &aSearchLB );
1002 return 0;
1005 // -----------------------------------------------------------------------
1007 IMPL_LINK( SvxSearchTabPage, ChangeSearchHdl_Impl, PushButton *, EMPTYARG )
1009 //The following two lines is added by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
1010 aChangePB.Enable(FALSE);
1011 aAddPB.Enable(FALSE);
1012 USHORT nPos = aSearchLB.GetSelectEntryPos();
1013 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
1015 String sEngine = aSearchLB.GetSelectEntry();
1016 aCurrentSrchData.sEngineName = sEngine;
1017 aSearchConfig.SetData(aCurrentSrchData);
1018 aSearchLB.SelectEntry(sEngine);
1019 SearchEntryHdl_Impl(&aSearchLB);
1021 else
1023 SetUpdateMode(FALSE);
1024 String sEntry = aSearchNameED.GetText();
1025 // im AddHdl wird sLastSelectedEntry umgesetzt
1026 String sTemp(sLastSelectedEntry);
1027 AddSearchHdl_Impl(0);
1028 aSearchLB.SelectEntry(sTemp);
1029 DeleteSearchHdl_Impl(0);
1030 aSearchLB.SelectEntry(sEntry);
1031 SearchEntryHdl_Impl(&aSearchLB);
1032 SetUpdateMode(TRUE);
1034 return 0;
1037 // -----------------------------------------------------------------------
1039 IMPL_LINK( SvxSearchTabPage, DeleteSearchHdl_Impl, PushButton *, EMPTYARG)
1041 aChangePB.Enable(FALSE); //add by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
1042 USHORT nPos = aSearchLB.GetSelectEntryPos();
1043 DBG_ASSERT(nPos != LISTBOX_ENTRY_NOTFOUND, "kein Eintrag selektiert!");
1044 aSearchConfig.RemoveData(aSearchLB.GetSelectEntry());
1045 aSearchLB.RemoveEntry(nPos);
1046 aSearchLB.SelectEntryPos(0);
1047 SearchEntryHdl_Impl(&aSearchLB);
1048 return 0;
1051 // -----------------------------------------------------------------------
1053 IMPL_LINK( SvxSearchTabPage, SearchEntryHdl_Impl, ListBox*, pBox )
1055 USHORT nEntryPos = pBox->GetSelectEntryPos();
1056 if ( nEntryPos != LISTBOX_ENTRY_NOTFOUND )
1058 String sSelection(pBox->GetSelectEntry());
1059 //Modified by BerryJia for fixing Bug102610 Time:2002-8-29 11:00 (China Standard Time GMT+08:00)
1060 if(!ConfirmLeave(sSelection))
1061 return 0;
1063 const SvxSearchEngineData* pData = aSearchConfig.GetData(sSelection);
1064 DBG_ASSERT(pData, "SearchEngine not available");
1065 if(pData)
1067 aSearchNameED.SetText(sSelection);
1068 sLastSelectedEntry = sSelection;
1069 sal_Bool bAnd = aAndRB.IsChecked();
1070 sal_Bool bOr = aOrRB.IsChecked();
1072 aURLED.SetText(bAnd ? pData->sAndPrefix : bOr ? pData->sOrPrefix : pData->sExactPrefix);
1073 aSeparatorED.SetText( bAnd ? pData->sAndSeparator : bOr ? pData->sOrSeparator : pData->sExactSeparator);
1074 aPostFixED.SetText(bAnd ? pData->sAndSuffix : bOr ? pData->sOrSuffix : pData->sExactSuffix );
1075 sal_Int32 nCase = bAnd ? pData->nAndCaseMatch : bOr ? pData->nOrCaseMatch : pData->nExactCaseMatch;
1076 aCaseED.SelectEntryPos( (USHORT)nCase );
1077 aCurrentSrchData = *pData;
1079 aDeletePB.Enable();
1081 else
1083 aDeletePB.Enable(FALSE);
1084 sLastSelectedEntry.Erase();
1086 aChangePB.Enable(FALSE);
1087 aAddPB.Enable(FALSE);
1088 return 0;
1091 // -----------------------------------------------------------------------
1093 IMPL_LINK( SvxSearchTabPage, SearchModifyHdl_Impl, SvxNoSpaceEdit*, pEdit )
1095 if ( pEdit == &aSearchNameED )
1097 BOOL bTextLen = ( 0 != pEdit->GetText().Len() );
1098 BOOL bFound = FALSE;
1099 if ( bTextLen )
1101 USHORT nEntryPos = aSearchLB.GetEntryPos( pEdit->GetText() );
1102 bFound = ( nEntryPos != LISTBOX_ENTRY_NOTFOUND );
1103 if ( bFound )
1104 aSearchLB.SelectEntryPos(nEntryPos);
1105 else
1106 aSearchLB.SetNoSelection();
1108 aChangePB.Enable( sLastSelectedEntry.Len() > 0 );
1109 aDeletePB.Enable(bFound);
1110 aAddPB.Enable(bTextLen && !bFound);
1112 else
1114 if ( aSearchLB.GetSelectEntryCount() && sLastSelectedEntry.Len() > 0 )
1115 aChangePB.Enable();
1117 if(aAndRB.IsChecked())
1119 aCurrentSrchData.sAndPrefix = aURLED.GetText();
1120 aCurrentSrchData.sAndSeparator = aSeparatorED.GetText();
1121 aCurrentSrchData.sAndSuffix = aPostFixED.GetText();
1122 aCurrentSrchData.nAndCaseMatch = aCaseED.GetSelectEntryPos();
1124 else if(aOrRB.IsChecked())
1126 aCurrentSrchData.sOrPrefix = aURLED.GetText();
1127 aCurrentSrchData.sOrSeparator = aSeparatorED.GetText();
1128 aCurrentSrchData.sOrSuffix = aPostFixED.GetText();
1129 aCurrentSrchData.nOrCaseMatch = aCaseED.GetSelectEntryPos();
1131 else
1133 aCurrentSrchData.sExactPrefix = aURLED.GetText();
1134 aCurrentSrchData.sExactSeparator = aSeparatorED.GetText();
1135 aCurrentSrchData.sExactSuffix = aPostFixED.GetText();
1136 aCurrentSrchData.nExactCaseMatch = aCaseED.GetSelectEntryPos();
1139 return 0;
1142 // -----------------------------------------------------------------------
1144 IMPL_LINK( SvxSearchTabPage, SearchPartHdl_Impl, RadioButton *, EMPTYARG )
1146 sal_Bool bAnd = aAndRB.IsChecked();
1147 sal_Bool bOr = aOrRB.IsChecked();
1149 aURLED.SetText(bAnd ? aCurrentSrchData.sAndPrefix : bOr ? aCurrentSrchData.sOrPrefix : aCurrentSrchData.sExactPrefix);
1150 aSeparatorED.SetText( bAnd ? aCurrentSrchData.sAndSeparator : bOr ? aCurrentSrchData.sOrSeparator : aCurrentSrchData.sExactSeparator);
1151 aPostFixED.SetText(bAnd ? aCurrentSrchData.sAndSuffix : bOr ? aCurrentSrchData.sOrSuffix : aCurrentSrchData.sExactSuffix );
1152 sal_Int32 nCase = bAnd ? aCurrentSrchData.nAndCaseMatch : bOr ? aCurrentSrchData.nOrCaseMatch : aCurrentSrchData.nExactCaseMatch;
1153 aCaseED.SelectEntryPos( (USHORT)nCase );
1154 return 0;
1157 // -----------------------------------------------------------------------
1159 /********************************************************************/
1160 /********************************************************************/
1161 /* */
1162 /* SvxOtherTabPage */
1163 /* */
1164 /********************************************************************/
1165 /********************************************************************/
1167 /*-----------------15.05.97 09:51-------------------
1169 --------------------------------------------------*/
1171 SvxPatternField::SvxPatternField( Window* pParent, const ResId& rResId ) :
1173 PatternField( pParent, rResId ),
1175 sMsg233 ( ResId( ST_MSG_233 ) ),
1176 sMsg255 ( ResId( ST_MSG_255 ) )
1179 FreeResource();
1180 SelectFixedFont();
1181 } */
1183 /*-----------------15.05.97 09:51-------------------
1185 --------------------------------------------------*/
1187 /*void SvxPatternField::KeyInput( const KeyEvent& rKEvt )
1189 PatternField::KeyInput( rKEvt );
1190 BOOL bDelete = ( rKEvt.GetKeyCode().GetCode() == KEY_DELETE );
1191 String sEntry( GetText() );
1192 sEntry[(USHORT)3] = '.';
1193 sEntry[(USHORT)7] = '.';
1194 sEntry[(USHORT)11] = '.';
1195 Selection aSelection( GetSelection() );
1196 String sPart( sEntry.GetToken( 0, '.' ) );
1197 USHORT i, nPart( sPart.EraseLeadingChars() );
1198 BOOL bSet = FALSE;
1200 if ( sPart.Len() && ( !nPart || nPart > 255 ) )
1202 // der erste Part darf nicht 0 und nicht gr"osser 255 sein
1203 String sMsg( sPart );
1204 sMsg += ' ';
1205 sMsg += sMsg233;
1206 InfoBox( this, sMsg ).Execute();
1208 if ( nPart == 0 )
1209 sPart = " 1";
1210 else
1211 sPart = "255";
1212 sEntry.SetToken( 0, '.', sPart );
1213 bSet = TRUE;
1216 for ( i = 1; i < 4; i++ )
1218 // die anderen Parts d"urfen nicht gr"osser 255 sein
1219 sPart = sEntry.GetToken( i, '.' );
1220 nPart = sPart.EraseLeadingChars();
1222 if ( nPart > 255 )
1224 String sMsg( sPart );
1225 sMsg += ' ';
1226 sMsg += sMsg255;
1227 InfoBox( this, sMsg ).Execute();
1229 if ( nPart == 0 )
1230 sPart = " 1";
1231 else
1232 sPart = "255";
1233 sEntry.SetToken( i, '.', sPart );
1234 bSet = TRUE;
1238 if ( bSet )
1240 SetText( sEntry );
1241 SetSelection( aSelection );
1245 // -----------------------------------------------------------------------
1246 #if 0
1247 long SvxPatternField::Notify( NotifyEvent& rNEvt )
1249 return PatternField::Notify( rNEvt );
1250 /*! long nHandled = 0;
1252 if ( rNEvt.GetType() == EVENT_KEYUP )
1254 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
1255 KeyInput( *pKEvt );
1256 nHandled = 1;
1258 return nHandled;*/
1260 #endif
1262 // class JavaScriptDisableQueryBox_Impl --------------------------------------
1264 class JavaScriptDisableQueryBox_Impl : public ModalDialog
1266 private:
1267 FixedImage aImage;
1268 FixedText aWarningFT;
1269 CheckBox aDisableCB;
1270 OKButton aYesBtn;
1271 CancelButton aNoBtn;
1273 public:
1274 JavaScriptDisableQueryBox_Impl( Window* pParent );
1276 BOOL IsWarningDisabled() const { return aDisableCB.IsChecked(); }
1279 JavaScriptDisableQueryBox_Impl::JavaScriptDisableQueryBox_Impl( Window* pParent ) :
1281 ModalDialog( pParent, SVX_RES( RID_SVXDLG_OPT_JAVASCRIPT_DISABLE ) ),
1283 aImage ( this, SVX_RES( IMG_JSCPT_WARNING ) ),
1284 aWarningFT ( this, SVX_RES( FT_JSCPT_WARNING ) ),
1285 aDisableCB ( this, SVX_RES( CB_JSCPT_DISABLE ) ),
1286 aYesBtn ( this, SVX_RES( BTN_JSCPT_YES ) ),
1287 aNoBtn ( this, SVX_RES( BTN_JSCPT_NO ) )
1290 FreeResource();
1292 aYesBtn.SetText( Button::GetStandardText( BUTTON_YES ) );
1293 aNoBtn.SetText( Button::GetStandardText( BUTTON_NO ) );
1294 aImage.SetImage( WarningBox::GetStandardImage() );
1297 //#98647#----------------------------------------------
1298 void SvxScriptExecListBox::RequestHelp( const HelpEvent& rHEvt )
1299 { // try to show tips just like as on toolbars
1300 USHORT nPos=LISTBOX_ENTRY_NOTFOUND;
1301 USHORT nTop = GetTopEntry();
1302 USHORT nCount = GetDisplayLineCount(); // Attention: Not GetLineCount()
1303 Point aPt = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
1304 Rectangle aItemRect;
1305 if( nCount > 0 ) // if there're some entries, find it.
1306 for( nPos = nTop ; nPos <= nTop+nCount-1 ; nPos++ ) {
1307 aItemRect = GetBoundingRectangle(nPos);
1308 if( aPt.Y() < aItemRect.Top() || aPt.Y() > aItemRect.Bottom() )
1309 continue;
1310 else
1311 break;
1313 else // if not, nothing happens.
1314 return;
1315 String aHelpText;
1316 if( nPos <= nTop+nCount-1 ) // if find the matching entry, get its content.
1317 aHelpText = GetEntry(nPos);
1318 if( aHelpText.Len() && GetTextWidth(aHelpText)<GetOutputSizePixel().Width() )
1319 aHelpText.Erase(); // if the entry is quite short, clear the helping tip content.
1320 aItemRect = Rectangle(Point(0,0),GetSizePixel());
1321 aPt = Point(OutputToScreenPixel( aItemRect.TopLeft() ));
1322 aItemRect.Left() = aPt.X();
1323 aItemRect.Top() = aPt.Y();
1324 aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1325 aItemRect.Right() = aPt.X();
1326 aItemRect.Bottom() = aPt.Y();
1327 if( rHEvt.GetMode() == HELPMODE_BALLOON )
1328 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
1329 else
1330 Help::ShowQuickHelp( this, aItemRect, aHelpText );
1333 /********************************************************************/
1334 /* */
1335 /* SvxSecurityTabPage */
1336 /* */
1337 /********************************************************************/
1339 SvxSecurityTabPage::SvxSecurityTabPage( Window* pParent, const SfxItemSet& rSet )
1340 :SfxTabPage ( pParent, SVX_RES( RID_SVXPAGE_INET_SECURITY ), rSet )
1342 ,maSecurityOptionsFL( this, SVX_RES( FL_SEC_SECURITYOPTIONS ) )
1343 ,maSecurityOptionsFI( this, SVX_RES( FI_SEC_SECURITYOPTIONS ) )
1344 ,maSecurityOptionsPB( this, SVX_RES( PB_SEC_SECURITYOPTIONS ) )
1346 ,maPasswordsFL ( this, SVX_RES( FL_SEC_PASSWORDS ) )
1347 ,maSavePasswordsCB ( this, SVX_RES( CB_SEC_SAVEPASSWORDS ) )
1348 ,maShowConnectionsPB( this, SVX_RES( PB_SEC_CONNECTIONS ) )
1349 ,maMasterPasswordCB ( this, SVX_RES( CB_SEC_MASTERPASSWORD ) )
1350 ,maMasterPasswordFI ( this, SVX_RES( FI_SEC_MASTERPASSWORD ) )
1351 ,maMasterPasswordPB ( this, SVX_RES( PB_SEC_MASTERPASSWORD ) )
1353 ,maMacroSecFL ( this, SVX_RES( FL_SEC_MACROSEC ) )
1354 ,maMacroSecFI ( this, SVX_RES( FI_SEC_MACROSEC ) )
1355 ,maMacroSecPB ( this, SVX_RES( PB_SEC_MACROSEC ) )
1356 ,maFilesharingFL ( this, SVX_RES( FL_SEC_FILESHARING ) )
1357 ,maRecommReadOnlyCB ( this, SVX_RES( CB_SEC_RECOMMREADONLY ) )
1358 ,maRecordChangesCB ( this, SVX_RES( CB_SEC_RECORDCHANGES ) )
1359 ,maProtectRecordsPB ( this, SVX_RES( PB_SEC_PROTRECORDS ) )
1361 ,mpSecOptions ( new SvtSecurityOptions )
1362 ,mpSecOptDlg ( NULL )
1363 ,meRedlingMode ( RL_NONE )
1365 ,msProtectRecordsStr( SVX_RES( STR_SEC_PROTRECORDS ) )
1366 ,msUnprotectRecordsStr( SVX_RES( STR_SEC_UNPROTRECORDS ) )
1367 ,msPasswordStoringDeactivateStr( SVX_RES( STR_SEC_NOPASSWDSAVE ) )
1370 FreeResource();
1372 InitControls();
1374 maSecurityOptionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, SecurityOptionsHdl ) );
1375 maSavePasswordsCB.SetClickHdl( LINK( this, SvxSecurityTabPage, SavePasswordHdl ) );
1376 maMasterPasswordPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordHdl ) );
1377 maMasterPasswordCB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordCBHdl ) );
1378 maShowConnectionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, ShowPasswordsHdl ) );
1379 maMacroSecPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) );
1380 maProtectRecordsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, ProtectRecordsPBHdl ) );
1381 maRecordChangesCB.SetClickHdl( LINK( this, SvxSecurityTabPage, RecordChangesCBHdl ) );
1383 ActivatePage( rSet );
1386 SvxSecurityTabPage::~SvxSecurityTabPage()
1388 delete mpSecOptions;
1389 delete mpSecOptDlg;
1392 IMPL_LINK( SvxSecurityTabPage, SecurityOptionsHdl, PushButton*, EMPTYARG )
1394 if ( !mpSecOptDlg )
1395 mpSecOptDlg = new svx::SecurityOptionsDialog( this, mpSecOptions );
1396 mpSecOptDlg->Execute();
1397 return 0;
1400 IMPL_LINK( SvxSecurityTabPage, SavePasswordHdl, void*, EMPTYARG )
1404 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1405 comphelper::getProcessServiceFactory()->createInstance(
1406 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1407 UNO_QUERY_THROW );
1409 if ( maSavePasswordsCB.IsChecked() )
1411 sal_Bool bOldValue = xMasterPasswd->allowPersistentStoring( sal_True );
1412 xMasterPasswd->removeMasterPassword();
1413 if ( xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
1415 maMasterPasswordPB.Enable( TRUE );
1416 maMasterPasswordCB.Check( TRUE );
1417 maMasterPasswordCB.Enable( TRUE );
1418 maMasterPasswordFI.Enable( TRUE );
1419 maShowConnectionsPB.Enable( TRUE );
1421 else
1423 xMasterPasswd->allowPersistentStoring( bOldValue );
1424 maSavePasswordsCB.Check( FALSE );
1427 else
1429 QueryBox aQuery( this, WB_YES_NO|WB_DEF_NO, msPasswordStoringDeactivateStr );
1430 USHORT nRet = aQuery.Execute();
1432 if( RET_YES == nRet )
1434 xMasterPasswd->allowPersistentStoring( sal_False );
1435 maMasterPasswordCB.Check( TRUE );
1436 maMasterPasswordPB.Enable( FALSE );
1437 maMasterPasswordCB.Enable( FALSE );
1438 maMasterPasswordFI.Enable( FALSE );
1439 maShowConnectionsPB.Enable( FALSE );
1441 else
1443 maSavePasswordsCB.Check( TRUE );
1444 maMasterPasswordPB.Enable( TRUE );
1445 maShowConnectionsPB.Enable( TRUE );
1449 catch( Exception& )
1451 maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
1454 return 0;
1457 IMPL_LINK( SvxSecurityTabPage, MasterPasswordHdl, PushButton*, EMPTYARG )
1461 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1462 comphelper::getProcessServiceFactory()->createInstance(
1463 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1464 UNO_QUERY );
1466 if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() )
1467 xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() );
1469 catch( Exception& )
1472 return 0;
1475 IMPL_LINK( SvxSecurityTabPage, MasterPasswordCBHdl, void*, EMPTYARG )
1479 Reference< task::XMasterPasswordHandling2 > xMasterPasswd(
1480 comphelper::getProcessServiceFactory()->createInstance(
1481 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1482 UNO_QUERY_THROW );
1484 if ( maMasterPasswordCB.IsChecked() )
1486 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
1488 maMasterPasswordPB.Enable( TRUE );
1489 maMasterPasswordFI.Enable( TRUE );
1491 else
1493 maMasterPasswordCB.Check( FALSE );
1494 maMasterPasswordPB.Enable( TRUE );
1495 maMasterPasswordFI.Enable( TRUE );
1498 else
1500 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->useDefaultMasterPassword( Reference< task::XInteractionHandler >() ) )
1502 maMasterPasswordPB.Enable( FALSE );
1503 maMasterPasswordFI.Enable( FALSE );
1505 else
1507 maMasterPasswordCB.Check( TRUE );
1508 maMasterPasswordPB.Enable( TRUE );
1509 maShowConnectionsPB.Enable( TRUE );
1513 catch( Exception& )
1515 maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
1518 return 0;
1521 IMPL_LINK( SvxSecurityTabPage, ShowPasswordsHdl, PushButton*, EMPTYARG )
1525 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1526 comphelper::getProcessServiceFactory()->createInstance(
1527 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1528 UNO_QUERY );
1530 if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword( Reference< task::XInteractionHandler>() ) )
1532 svx::WebConnectionInfoDialog aDlg( this );
1533 aDlg.Execute();
1536 catch( Exception& )
1538 return 0;
1541 IMPL_LINK( SvxSecurityTabPage, MacroSecPBHdl, void*, EMPTYARG )
1543 Reference< security::XDocumentDigitalSignatures > xD(
1544 comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), UNO_QUERY );
1545 if ( xD.is() )
1546 xD->manageTrustedSources();
1548 return 0;
1551 namespace
1553 enum RedlineFunc { RF_ON, RF_PROTECT };
1555 const SfxBoolItem* ExecuteRecordChangesFunc( SvxSecurityTabPage::RedliningMode _eMode, RedlineFunc _eFunc, BOOL _bVal, Window* _pParent = NULL )
1557 const SfxBoolItem* pRet = NULL;
1559 if( _eMode != SvxSecurityTabPage::RL_NONE )
1561 USHORT nSlot;
1562 if ( _eMode == SvxSecurityTabPage::RL_WRITER )
1563 nSlot = ( _eFunc == RF_ON )? FN_REDLINE_ON : FN_REDLINE_PROTECT;
1564 else
1565 nSlot = ( _eFunc == RF_ON )? FID_CHG_RECORD : SID_CHG_PROTECT;
1567 // execute
1568 SfxViewShell* pViewSh = SfxViewShell::Current();
1569 if( pViewSh )
1571 bool bNeedItem = ( _eMode == SvxSecurityTabPage::RL_WRITER || _eFunc != RF_ON );
1572 SfxBoolItem* pItem = bNeedItem ? new SfxBoolItem( nSlot, _bVal ) : NULL;
1573 SfxDispatcher* pDisp = pViewSh->GetDispatcher();
1574 if ( _pParent )
1576 OfaPtrItem aParentItem( SID_ATTR_PARENTWINDOW, _pParent );
1577 pRet = static_cast< const SfxBoolItem* >(
1578 pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, &aParentItem, pItem, 0L ) );
1580 else
1581 pRet = static_cast< const SfxBoolItem* >(
1582 pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, pItem, 0L ) );
1583 delete pItem;
1587 return pRet;
1590 bool QueryState( USHORT _nSlot, bool& _rValue )
1592 bool bRet = false;
1594 SfxViewShell* pViewSh = SfxViewShell::Current();
1595 if( pViewSh )
1597 const SfxPoolItem* pItem;
1598 SfxDispatcher* pDisp = pViewSh->GetDispatcher();
1599 bRet = SFX_ITEM_AVAILABLE <= pDisp->QueryState( _nSlot, pItem );
1600 if( bRet )
1601 _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue();
1604 return bRet;
1607 bool QueryRecordChangesProtectionState( SvxSecurityTabPage::RedliningMode _eMode, bool& _rValue )
1609 bool bRet = false;
1611 if( _eMode != SvxSecurityTabPage::RL_NONE )
1613 USHORT nSlot = ( _eMode == SvxSecurityTabPage::RL_WRITER )? FN_REDLINE_PROTECT : SID_CHG_PROTECT;
1614 bRet = QueryState( nSlot, _rValue );
1617 return bRet;
1620 bool QueryRecordChangesState( SvxSecurityTabPage::RedliningMode _eMode, bool& _rValue )
1622 bool bRet = false;
1624 if( _eMode != SvxSecurityTabPage::RL_NONE )
1626 USHORT nSlot = ( _eMode == SvxSecurityTabPage::RL_WRITER )? FN_REDLINE_ON : FID_CHG_RECORD;
1627 bRet = QueryState( nSlot, _rValue );
1630 return bRet;
1634 IMPL_LINK( SvxSecurityTabPage, RecordChangesCBHdl, void*, EMPTYARG )
1636 ExecuteRecordChangesFunc( meRedlingMode, RF_ON, maRecordChangesCB.IsChecked(), this );
1637 CheckRecordChangesState();
1638 return 0;
1641 IMPL_LINK( SvxSecurityTabPage, ProtectRecordsPBHdl, void*, EMPTYARG )
1643 bool bProt;
1644 QueryRecordChangesProtectionState( meRedlingMode, bProt );
1645 ExecuteRecordChangesFunc( meRedlingMode, RF_PROTECT, !bProt, this );
1646 CheckRecordChangesState();
1648 if ( QueryRecordChangesProtectionState( meRedlingMode, bProt ) )
1650 // RecordChangesCB is enabled if protection is off
1651 maRecordChangesCB.Enable( !bProt );
1652 // toggle text of button "Protect" <-> "Unprotect"
1653 String sNewText = bProt ? msUnprotectRecordsStr : msProtectRecordsStr;
1654 maProtectRecordsPB.SetText( sNewText );
1656 return 0;
1659 void SvxSecurityTabPage::CheckRecordChangesState( void )
1661 bool bVal;
1662 if( QueryRecordChangesState( meRedlingMode, bVal ) )
1664 maRecordChangesCB.Enable();
1665 maRecordChangesCB.Check( bVal );
1667 else
1668 maRecordChangesCB.Disable(); // because now we don't know the state!
1670 maProtectRecordsPB.Enable( QueryRecordChangesProtectionState( meRedlingMode, bVal ) );
1673 void SvxSecurityTabPage::InitControls()
1675 // Hide all controls which belong to the macro security button in case the macro
1676 // security settings managed by the macro security dialog opened via the button
1677 // are all readonly or if the macros are disabled in general.
1678 // @@@ Better would be to query the dialog whether it is 'useful' or not. Exposing
1679 // macro security dialog implementations here, which is bad.
1680 if ( mpSecOptions->IsMacroDisabled()
1681 || ( mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_SECLEVEL )
1682 && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS )
1683 && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_SECUREURLS ) ) )
1685 maMacroSecFL.Hide();
1686 maMacroSecFI.Hide();
1687 maMacroSecPB.Hide();
1689 // rearrange the following controls
1690 Point aNewPos = maFilesharingFL.GetPosPixel();
1691 long nDelta = aNewPos.Y() - maMacroSecFL.GetPosPixel().Y();
1693 Window* pWins[] =
1695 &maFilesharingFL, &maRecommReadOnlyCB, &maRecordChangesCB, &maProtectRecordsPB
1697 Window** pCurrent = pWins;
1698 const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
1699 for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
1701 aNewPos = (*pCurrent)->GetPosPixel();
1702 aNewPos.Y() -= nDelta;
1703 (*pCurrent)->SetPosPixel( aNewPos );
1707 // one button too small for its text?
1708 sal_Int32 i = 0;
1709 long nBtnTextWidth = 0;
1710 Window* pButtons[] = { &maSecurityOptionsPB, &maMasterPasswordPB,
1711 &maShowConnectionsPB, &maMacroSecPB, &maProtectRecordsPB };
1712 Window** pButton = pButtons;
1713 const sal_Int32 nBCount = sizeof( pButtons ) / sizeof( pButtons[ 0 ] );
1714 for ( ; i < nBCount; ++i, ++pButton )
1716 long nTemp = (*pButton)->GetCtrlTextWidth( (*pButton)->GetText() );
1717 if ( nTemp > nBtnTextWidth )
1718 nBtnTextWidth = nTemp;
1721 nBtnTextWidth = nBtnTextWidth * 115 / 100; // a little offset
1722 const long nButtonWidth = maSecurityOptionsPB.GetSizePixel().Width();
1723 const long nMaxWidth = nButtonWidth * 140 / 100;
1724 long nExtra = ( nBtnTextWidth > nMaxWidth ) ? nBtnTextWidth - nMaxWidth : 0;
1725 nBtnTextWidth = std::min( nBtnTextWidth, nMaxWidth );
1727 if ( nBtnTextWidth > nButtonWidth )
1729 // so make the buttons broader and its control in front of it smaller
1730 long nDelta = nBtnTextWidth - nButtonWidth;
1731 pButton = pButtons;
1733 if ( nExtra > 0 )
1735 long nPos = (*pButton)->GetPosPixel().X() - nDelta;
1736 long nWidth = (*pButton)->GetSizePixel().Width() + nDelta;
1737 long nMaxExtra = GetOutputSizePixel().Width() - ( nPos + nWidth ) - 2;
1738 nExtra = ( nExtra < nMaxExtra ) ? nExtra : nMaxExtra;
1741 for ( i = 0; i < nBCount; ++i, ++pButton )
1743 Point aNewPos = (*pButton)->GetPosPixel();
1744 aNewPos.X() -= nDelta;
1745 Size aNewSize = (*pButton)->GetSizePixel();
1746 aNewSize.Width() += ( nDelta + nExtra );
1747 (*pButton)->SetPosSizePixel( aNewPos, aNewSize );
1750 Window* pControls[] = { &maSecurityOptionsFI, &maSavePasswordsCB,
1751 &maMasterPasswordFI, &maMacroSecFI,
1752 &maRecommReadOnlyCB, &maRecordChangesCB };
1753 Window** pControl = pControls;
1754 const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[ 0 ] );
1755 for ( i = 0; i < nCCount; ++i, ++pControl )
1757 Size aNewSize = (*pControl)->GetSizePixel();
1758 aNewSize.Width() -= nDelta;
1759 (*pControl)->SetSizePixel( aNewSize );
1763 maMasterPasswordPB.Enable( FALSE );
1764 maMasterPasswordCB.Enable( FALSE );
1765 maMasterPasswordCB.Check( TRUE );
1766 maMasterPasswordFI.Enable( FALSE );
1767 maShowConnectionsPB.Enable( FALSE );
1769 // initialize the password saving checkbox
1772 Reference< task::XMasterPasswordHandling > xMasterPasswd(
1773 comphelper::getProcessServiceFactory()->createInstance(
1774 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
1775 UNO_QUERY_THROW );
1777 if ( xMasterPasswd->isPersistentStoringAllowed() )
1779 maMasterPasswordCB.Enable( TRUE );
1780 maShowConnectionsPB.Enable( TRUE );
1781 maSavePasswordsCB.Check( TRUE );
1783 Reference< task::XMasterPasswordHandling2 > xMasterPasswd2( xMasterPasswd, UNO_QUERY );
1784 if ( xMasterPasswd2.is() && xMasterPasswd2->isDefaultMasterPasswordUsed() )
1785 maMasterPasswordCB.Check( FALSE );
1786 else
1788 maMasterPasswordPB.Enable( TRUE );
1789 maMasterPasswordCB.Check( TRUE );
1790 maMasterPasswordFI.Enable( TRUE );
1794 catch( Exception& )
1796 maSavePasswordsCB.Enable( FALSE );
1802 SfxTabPage* SvxSecurityTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
1804 return new SvxSecurityTabPage(pParent, rAttrSet);
1807 void SvxSecurityTabPage::ActivatePage( const SfxItemSet& )
1811 int SvxSecurityTabPage::DeactivatePage( SfxItemSet* _pSet )
1813 if( _pSet )
1814 FillItemSet( *_pSet );
1815 return LEAVE_PAGE;
1818 namespace
1820 /* bool Enable( const SvtSecurityOptions& _rOpt, SvtSecurityOptions::EOption _eOpt, Control& _rCtrl, FixedImage& _rImg )
1822 bool b = _rOpt.IsOptionEnabled( _eOpt );
1823 _rCtrl.Enable( b );
1824 _Img.Show( !b );
1825 return b;
1828 bool EnableAndSet( const SvtSecurityOptions& _rOpt, SvtSecurityOptions::EOption _eOpt,
1829 CheckBox& _rCtrl, FixedImage& _rImg )
1831 // bool b = Enable( _rOpt, _eOpt, _rCtrl, _rImg );
1832 bool b = _rOpt.IsOptionEnabled( _eOpt );
1833 _rCtrl.Enable( b );
1834 _rImg.Show( !b );
1835 _rCtrl.Check( _rOpt.IsOptionSet( _eOpt ) );
1836 return b;
1839 bool CheckAndSave( SvtSecurityOptions& _rOpt, SvtSecurityOptions::EOption _eOpt, const bool _bIsChecked, bool& _rModfied )
1841 bool bModified = false;
1842 if ( _rOpt.IsOptionEnabled( _eOpt ) )
1844 bModified = _rOpt.IsOptionSet( _eOpt ) != _bIsChecked;
1845 if ( bModified )
1847 _rOpt.SetOption( _eOpt, _bIsChecked );
1848 _rModfied = true;
1852 return bModified;
1856 BOOL SvxSecurityTabPage::FillItemSet( SfxItemSet& )
1858 bool bModified = false;
1860 if ( mpSecOptDlg )
1862 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SAVEORSEND, mpSecOptDlg->IsSaveOrSendDocsChecked(), bModified );
1863 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SIGNING, mpSecOptDlg->IsSignDocsChecked(), bModified );
1864 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_PRINT, mpSecOptDlg->IsPrintDocsChecked(), bModified );
1865 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_CREATEPDF, mpSecOptDlg->IsCreatePdfChecked(), bModified );
1866 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO, mpSecOptDlg->IsRemovePersInfoChecked(), bModified );
1867 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD, mpSecOptDlg->IsRecommPasswdChecked(), bModified );
1868 CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_CTRLCLICK_HYPERLINK, mpSecOptDlg->IsCtrlHyperlinkChecked(), bModified );
1871 // document options
1872 SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
1873 if( pCurDocShell )
1875 if( pCurDocShell->HasSecurityOptOpenReadOnly() )
1876 pCurDocShell->SetSecurityOptOpenReadOnly( maRecommReadOnlyCB.IsChecked() );
1880 return bModified;
1883 /*--------------------------------------------------------------------*/
1885 void SvxSecurityTabPage::Reset( const SfxItemSet& )
1887 String sNewText = msProtectRecordsStr;
1888 SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
1889 if( pCurDocShell )
1891 bool bIsHTMLDoc = false;
1892 SfxViewShell* pViewSh = SfxViewShell::Current();
1893 if( pViewSh )
1895 const SfxPoolItem* pItem;
1896 SfxDispatcher* pDisp = pViewSh->GetDispatcher();
1897 if ( SFX_ITEM_AVAILABLE <= pDisp->QueryState( SID_HTML_MODE, pItem ) )
1899 USHORT nMode = static_cast< const SfxUInt16Item* >( pItem )->GetValue();
1900 bIsHTMLDoc = ( ( nMode & HTMLMODE_ON ) != 0 );
1904 sal_Bool bIsReadonly = pCurDocShell->IsReadOnly();
1905 if( pCurDocShell->HasSecurityOptOpenReadOnly() && !bIsHTMLDoc )
1907 maRecommReadOnlyCB.Check( pCurDocShell->IsSecurityOptOpenReadOnly() );
1908 maRecommReadOnlyCB.Enable( !bIsReadonly );
1910 else
1911 maRecommReadOnlyCB.Disable();
1913 bool bVal;
1914 if ( QueryRecordChangesState( RL_WRITER, bVal ) && !bIsHTMLDoc )
1915 meRedlingMode = RL_WRITER;
1916 else if( QueryRecordChangesState( RL_CALC, bVal ) )
1917 meRedlingMode = RL_CALC;
1918 else
1919 meRedlingMode = RL_NONE;
1921 if ( meRedlingMode != RL_NONE )
1923 maRecordChangesCB.Check( bVal );
1924 maRecordChangesCB.Enable( !bVal && !bIsReadonly );
1925 maProtectRecordsPB.Enable(
1926 QueryRecordChangesProtectionState( meRedlingMode, bVal ) && !bIsReadonly );
1927 // set the right text
1928 if ( bVal )
1929 sNewText = msUnprotectRecordsStr;
1931 else
1933 // only Writer and Calc support redlining
1934 maRecordChangesCB.Disable();
1935 maProtectRecordsPB.Disable();
1938 else
1939 { // no doc -> hide document settings
1940 maRecommReadOnlyCB.Disable();
1941 maRecordChangesCB.Disable();
1942 maProtectRecordsPB.Disable();
1945 maProtectRecordsPB.SetText( sNewText );
1948 //added by jmeng begin
1949 MozPluginTabPage::MozPluginTabPage(Window* pParent, const SfxItemSet& rSet)
1950 : SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_INET_MOZPLUGIN ), rSet ),
1951 aMSWordGB ( this, SVX_RES( GB_MOZPLUGIN ) ),
1952 aWBasicCodeCB ( this, SVX_RES( CB_MOZPLUGIN_CODE ) )
1954 FreeResource();
1957 MozPluginTabPage::~MozPluginTabPage()
1961 SfxTabPage* MozPluginTabPage::Create( Window* pParent,
1962 const SfxItemSet& rAttrSet )
1964 return new MozPluginTabPage( pParent, rAttrSet );
1966 BOOL MozPluginTabPage::FillItemSet( SfxItemSet& )
1968 BOOL hasInstall = isInstalled();
1969 BOOL hasChecked = aWBasicCodeCB.IsChecked();
1970 if(hasInstall && (!hasChecked)){
1971 //try to uninstall
1972 uninstallPlugin();
1974 else if((!hasInstall) && hasChecked){
1975 //try to install
1976 installPlugin();
1978 else{
1979 // do nothing
1981 return TRUE;
1983 void MozPluginTabPage::Reset( const SfxItemSet& )
1985 aWBasicCodeCB.Check( isInstalled());
1986 aWBasicCodeCB.SaveValue();
1989 #ifdef WNT
1990 extern "C" {
1991 int lc_isInstalled(const char* realFilePath);
1992 int lc_installPlugin(const char* realFilePath);
1993 int lc_uninstallPlugin(const char* realFilePath);
1995 #endif
1997 #define NPP_PATH_MAX 2048
1998 inline bool getDllURL(rtl::OString * path)
2000 OSL_ASSERT(path != NULL);
2001 ::rtl::OUString dirPath/*dllPath, */;
2002 if (osl_getExecutableFile(&dirPath.pData) != osl_Process_E_None) {
2003 return false;
2005 dirPath = dirPath.copy(0, dirPath.lastIndexOf('/'));
2006 // osl::FileBase::getAbsoluteFileURL(dirPath, libPath, dllPath);
2007 ::rtl::OUString sysDirPath;
2008 osl::FileBase::getSystemPathFromFileURL(dirPath, sysDirPath);
2009 *path = OUStringToOString(sysDirPath, RTL_TEXTENCODING_ASCII_US);
2010 return true;
2013 BOOL MozPluginTabPage::isInstalled()
2015 #ifdef UNIX
2016 // get the real file referred by .so lnk file
2017 char lnkFilePath[NPP_PATH_MAX] = {0};
2018 char lnkReferFilePath[NPP_PATH_MAX] = {0};
2019 char* pHome = getpwuid(getuid())->pw_dir;
2020 strcat(lnkFilePath, pHome);
2021 strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
2023 struct stat sBuf;
2024 if (0 > lstat(lnkFilePath, &sBuf))
2025 return false;
2026 if (!S_ISLNK(sBuf.st_mode))
2027 return false;
2028 if (0 >= readlink(lnkFilePath, lnkReferFilePath, NPP_PATH_MAX))
2029 return false;
2030 // If the link is relative, then we regard it as non-standard
2031 if (lnkReferFilePath[0] != '/')
2032 return false;
2034 // get the real file path
2035 char realFilePath[NPP_PATH_MAX] = {0};
2036 ::rtl::OString tempString;
2037 if (!getDllURL(&tempString)) {
2038 return false;
2040 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
2041 strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
2043 if (0 != strcmp(lnkReferFilePath, realFilePath))
2044 return false;
2045 return true;
2046 #endif
2047 #ifdef WNT
2048 // get the value from registry
2049 BOOL ret = true;
2050 ::rtl::OString tempString;
2051 char realFilePath[NPP_PATH_MAX] = {0};
2052 if (!getDllURL(&tempString)){
2053 return false;
2055 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
2056 if(! lc_isInstalled(realFilePath))
2057 ret =true;
2058 else
2059 ret = false;
2060 return ret;
2061 #endif
2064 BOOL MozPluginTabPage::installPlugin()
2066 #ifdef UNIX
2067 // get the real file referred by .so lnk file
2068 char lnkFilePath[NPP_PATH_MAX] = {0};
2069 char* pHome = getpwuid(getuid())->pw_dir;
2070 strcat(lnkFilePath, pHome);
2071 strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
2072 remove(lnkFilePath);
2074 // create the dirs if necessary
2075 struct stat buf;
2076 char tmpDir[NPP_PATH_MAX] = {0};
2077 sprintf(tmpDir, "%s/.mozilla", pHome);
2078 if (0 > stat(lnkFilePath, &buf))
2080 mkdir(tmpDir, 0755);
2081 strcat(tmpDir, "/plugins");
2082 mkdir(tmpDir, 0755);
2085 // get the real file path
2086 char realFilePath[NPP_PATH_MAX] = {0};
2087 ::rtl::OString tempString;
2088 if (!getDllURL(&tempString)) {
2089 return false;
2091 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
2092 strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
2094 // create the link
2095 if (0 != symlink(realFilePath, lnkFilePath))
2096 return false;
2097 return true;
2098 #endif
2099 #ifdef WNT
2100 ::rtl::OString tempString;
2101 char realFilePath[NPP_PATH_MAX] = {0};
2102 if (!getDllURL(&tempString)) {
2103 return false;
2105 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
2106 if( !lc_installPlugin(realFilePath))
2107 return true;
2108 else
2109 return false;
2110 #endif
2113 BOOL MozPluginTabPage::uninstallPlugin()
2115 #ifdef UNIX
2116 // get the real file referred by .so lnk file
2117 char lnkFilePath[NPP_PATH_MAX] = {0};
2118 char* pHome = getpwuid(getuid())->pw_dir;
2119 strcat(lnkFilePath, pHome);
2120 strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
2122 if(0 > remove(lnkFilePath))
2123 return false;
2124 return true;
2125 #endif
2126 #ifdef WNT
2127 ::rtl::OString tempString;
2128 char realFilePath[NPP_PATH_MAX] = {0};
2129 if (!getDllURL(&tempString)) {
2130 return false;
2132 strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
2133 if(!lc_uninstallPlugin(realFilePath))
2134 return true;
2135 else
2136 return false;
2137 #endif
2139 //added by jmeng end
2141 /* -------------------------------------------------------------------------*/
2143 class MailerProgramCfg_Impl : public utl::ConfigItem
2145 friend class SvxEMailTabPage;
2146 // variables
2147 OUString sProgram;
2148 // readonly states
2149 sal_Bool bROProgram;
2151 const Sequence<OUString> GetPropertyNames();
2152 public:
2153 MailerProgramCfg_Impl();
2154 virtual ~MailerProgramCfg_Impl();
2156 virtual void Commit();
2160 /* -------------------------------------------------------------------------*/
2162 MailerProgramCfg_Impl::MailerProgramCfg_Impl() :
2163 utl::ConfigItem(C2U("Office.Common/ExternalMailer")),
2164 bROProgram(sal_False)
2166 const Sequence< OUString > aNames = GetPropertyNames();
2167 const Sequence< Any > aValues = GetProperties(aNames);
2168 const Sequence< sal_Bool > aROStates = GetReadOnlyStates(aNames);
2169 const Any* pValues = aValues.getConstArray();
2170 const sal_Bool* pROStates = aROStates.getConstArray();
2171 for(sal_Int32 nProp = 0; nProp < aValues.getLength(); nProp++)
2173 if(pValues[nProp].hasValue())
2175 switch(nProp)
2177 case 0 :
2179 pValues[nProp] >>= sProgram;
2180 bROProgram = pROStates[nProp];
2182 break;
2188 /* -------------------------------------------------------------------------*/
2190 MailerProgramCfg_Impl::~MailerProgramCfg_Impl()
2194 /* -------------------------------------------------------------------------*/
2196 const Sequence<OUString> MailerProgramCfg_Impl::GetPropertyNames()
2198 Sequence<OUString> aRet(1);
2199 OUString* pRet = aRet.getArray();
2200 pRet[0] = C2U("Program");
2201 return aRet;
2204 /* -------------------------------------------------------------------------*/
2206 void MailerProgramCfg_Impl::Commit()
2208 const Sequence< OUString > aOrgNames = GetPropertyNames();
2209 sal_Int32 nOrgCount = aOrgNames.getLength();
2211 Sequence< OUString > aNames(nOrgCount);
2212 Sequence< Any > aValues(nOrgCount);
2213 sal_Int32 nRealCount = 0;
2215 for(int nProp = 0; nProp < nOrgCount; nProp++)
2217 switch(nProp)
2219 case 0:
2221 if (!bROProgram)
2223 aNames[nRealCount] = aOrgNames[nProp];
2224 aValues[nRealCount] <<= sProgram;
2225 ++nRealCount;
2228 break;
2232 aNames.realloc(nRealCount);
2233 aValues.realloc(nRealCount);
2234 PutProperties(aNames, aValues);
2237 /* -------------------------------------------------------------------------*/
2239 struct SvxEMailTabPage_Impl
2241 MailerProgramCfg_Impl aMailConfig;
2244 SvxEMailTabPage::SvxEMailTabPage(Window* pParent, const SfxItemSet& rSet) :
2245 SfxTabPage(pParent, SVX_RES( RID_SVXPAGE_INET_MAIL ), rSet),
2246 aMailFL(this, SVX_RES(FL_MAIL )),
2247 aMailerURLFI(this, SVX_RES(FI_MAILERURL )),
2248 aMailerURLFT(this, SVX_RES(FT_MAILERURL )),
2249 aMailerURLED(this, SVX_RES(ED_MAILERURL )),
2250 aMailerURLPB(this, SVX_RES(PB_MAILERURL )),
2251 m_sDefaultFilterName( SVX_RES(STR_DEFAULT_FILENAME )),
2252 pImpl(new SvxEMailTabPage_Impl)
2254 FreeResource();
2256 aMailerURLPB.SetClickHdl( LINK( this, SvxEMailTabPage, FileDialogHdl_Impl ) );
2258 // FixedText not wide enough?
2259 long nTxtW = aMailerURLFT.GetCtrlTextWidth( aMailerURLFT.GetText() );
2260 long nCtrlW = aMailerURLFT.GetSizePixel().Width();
2261 if ( nTxtW >= nCtrlW )
2263 long nDelta = Max( (long)10, nTxtW - nCtrlW );
2264 // so FixedText wider
2265 Size aNewSz = aMailerURLFT.GetSizePixel();
2266 aNewSz.Width() += nDelta;
2267 aMailerURLFT.SetSizePixel( aNewSz );
2268 // and Edit smaller
2269 aNewSz = aMailerURLED.GetSizePixel();
2270 aNewSz.Width() -= nDelta;
2271 Point aNewPt = aMailerURLED.GetPosPixel();
2272 aNewPt.X() += nDelta;
2273 aMailerURLED.SetPosSizePixel( aNewPt, aNewSz );
2277 /* -------------------------------------------------------------------------*/
2279 SvxEMailTabPage::~SvxEMailTabPage()
2281 delete pImpl;
2284 /* -------------------------------------------------------------------------*/
2286 SfxTabPage* SvxEMailTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
2288 return new SvxEMailTabPage(pParent, rAttrSet);
2291 /* -------------------------------------------------------------------------*/
2293 BOOL SvxEMailTabPage::FillItemSet( SfxItemSet& )
2295 BOOL bMailModified = FALSE;
2296 if(!pImpl->aMailConfig.bROProgram && aMailerURLED.GetSavedValue() != aMailerURLED.GetText())
2298 pImpl->aMailConfig.sProgram = aMailerURLED.GetText();
2299 bMailModified = TRUE;
2301 if ( bMailModified )
2302 pImpl->aMailConfig.Commit();
2304 return FALSE;
2307 /* -------------------------------------------------------------------------*/
2309 void SvxEMailTabPage::Reset( const SfxItemSet& )
2311 aMailerURLED.Enable(TRUE );
2312 aMailerURLPB.Enable(TRUE );
2314 if(pImpl->aMailConfig.bROProgram)
2315 aMailerURLFI.Show();
2317 aMailerURLED.SetText(pImpl->aMailConfig.sProgram);
2318 aMailerURLED.SaveValue();
2319 aMailerURLED.Enable(!pImpl->aMailConfig.bROProgram);
2320 aMailerURLPB.Enable(!pImpl->aMailConfig.bROProgram);
2321 aMailerURLFT.Enable(!pImpl->aMailConfig.bROProgram);
2323 aMailFL.Enable(aMailerURLFT.IsEnabled() ||
2324 aMailerURLED.IsEnabled() ||
2325 aMailerURLPB.IsEnabled());
2328 /* -------------------------------------------------------------------------*/
2330 IMPL_LINK( SvxEMailTabPage, FileDialogHdl_Impl, PushButton*, pButton )
2332 if ( &aMailerURLPB == pButton && !pImpl->aMailConfig.bROProgram )
2334 FileDialogHelper aHelper(
2335 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
2336 WB_OPEN );
2337 String sPath = aMailerURLED.GetText();
2338 if ( !sPath.Len() )
2339 sPath.AppendAscii("/usr/bin");
2341 String sUrl;
2342 ::utl::LocalFileHelper::ConvertPhysicalNameToURL(sPath,sUrl);
2343 aHelper.SetDisplayDirectory(sUrl);
2344 aHelper.AddFilter( m_sDefaultFilterName, String::CreateFromAscii("*"));
2346 if ( ERRCODE_NONE == aHelper.Execute() )
2348 sUrl = aHelper.GetPath();
2349 ::utl::LocalFileHelper::ConvertURLToPhysicalName(sUrl,sPath);
2350 aMailerURLED.SetText(sPath);
2353 return 0;
2356 // -----------------------------------------------------------------------------