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