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