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