Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <tools/shl.hxx>
30 : : #include <tools/config.hxx>
31 : : #include <vcl/msgbox.hxx>
32 : : #include <svl/intitem.hxx>
33 : : #include <svl/stritem.hxx>
34 : : #include <svl/eitem.hxx>
35 : : #include <svl/slstitm.hxx>
36 : : #include <sfx2/fcontnr.hxx>
37 : : #include <sfx2/dispatch.hxx>
38 : : #include <sfx2/docfilt.hxx>
39 : : #include <sfx2/viewsh.hxx>
40 : : #include <sfx2/sfxsids.hrc>
41 : : #include <sfx2/filedlghelper.hxx>
42 : : #include <svl/urihelper.hxx>
43 : : #include <svl/cntwids.hrc>
44 : : #include <sfx2/app.hxx>
45 : : #include <sfx2/objsh.hxx>
46 : : #include <unotools/bootstrap.hxx>
47 : : #include <vcl/help.hxx>
48 : : #include <sfx2/viewfrm.hxx>
49 : : #include <unotools/pathoptions.hxx>
50 : : #include <unotools/securityoptions.hxx>
51 : : #include <unotools/localfilehelper.hxx>
52 : : #include <unotools/extendedsecurityoptions.hxx>
53 : : #include <com/sun/star/uno/Sequence.hxx>
54 : :
55 : : #define _SVX_OPTINET2_CXX
56 : : #include <dialmgr.hxx>
57 : : #include "optinet2.hxx"
58 : : #include <svx/svxdlg.hxx>
59 : : #include <cuires.hrc>
60 : : #include "optinet2.hrc"
61 : : #include "helpid.hrc"
62 : : #include <svx/ofaitem.hxx>
63 : : #include <svx/htmlmode.hxx>
64 : : #include <svx/svxids.hrc> // slot ids, mostly for changetracking
65 : :
66 : : // for security TP
67 : : #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
68 : :
69 : : #ifdef UNX
70 : : #include <sys/stat.h>
71 : : #include <unistd.h>
72 : : #include <fcntl.h>
73 : : #include <pwd.h>
74 : : #include <sys/types.h>
75 : : #include <string.h>
76 : : #include <rtl/textenc.h>
77 : : #include <rtl/locale.h>
78 : : #include <osl/nlsupport.h>
79 : : #endif
80 : : #include <sal/types.h>
81 : : #include <sal/macros.h>
82 : : #include <rtl/ustring.hxx>
83 : : #include <osl/file.hxx>
84 : : #include <osl/process.h>
85 : : #include <com/sun/star/configuration/theDefaultProvider.hpp>
86 : : #include <com/sun/star/container/XNameReplace.hpp>
87 : : #include <com/sun/star/container/XNameAccess.hpp>
88 : : #include <com/sun/star/beans/NamedValue.hpp>
89 : : #include <com/sun/star/beans/XPropertySet.hpp>
90 : : #include <com/sun/star/beans/XPropertyState.hpp>
91 : : #include <com/sun/star/util/XChangesBatch.hpp>
92 : : #include <comphelper/processfactory.hxx>
93 : : #include <comphelper/string.hxx>
94 : :
95 : : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
96 : : #include "com/sun/star/task/XMasterPasswordHandling2.hpp"
97 : : #include "com/sun/star/task/XPasswordContainer.hpp"
98 : : #include "securityoptions.hxx"
99 : : #include "webconninfo.hxx"
100 : : #include "certpath.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 : : // static ----------------------------------------------------------------
108 : :
109 : : #define C2U(cChar) OUString::createFromAscii(cChar)
110 : :
111 : : #include <sal/config.h>
112 : :
113 : : // -----------------------------------------------------------------------
114 : :
115 : 0 : void SvxNoSpaceEdit::KeyInput( const KeyEvent& rKEvent )
116 : : {
117 [ # # ]: 0 : if ( bOnlyNumeric )
118 : : {
119 : 0 : const KeyCode& rKeyCode = rKEvent.GetKeyCode();
120 : 0 : sal_uInt16 nGroup = rKeyCode.GetGroup();
121 : 0 : sal_uInt16 nKey = rKeyCode.GetCode();
122 : : sal_Bool bValid = ( KEYGROUP_NUM == nGroup || KEYGROUP_CURSOR == nGroup ||
123 [ # # ][ # # ]: 0 : ( KEYGROUP_MISC == nGroup && ( nKey < KEY_ADD || nKey > KEY_EQUAL ) ) );
[ # # ][ # # ]
[ # # ]
124 [ # # ][ # # ]: 0 : if ( !bValid && ( rKeyCode.IsMod1() && (
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
125 : : KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) )
126 : : // Erase, Copy, Paste, Select All und Undo soll funktionieren
127 : 0 : bValid = sal_True;
128 : :
129 [ # # ]: 0 : if ( bValid )
130 : 0 : Edit::KeyInput(rKEvent);
131 : : }
132 [ # # ]: 0 : else if( rKEvent.GetKeyCode().GetCode() != KEY_SPACE )
133 : 0 : Edit::KeyInput(rKEvent);
134 : 0 : }
135 : :
136 : : // -----------------------------------------------------------------------
137 : :
138 : 0 : void SvxNoSpaceEdit::Modify()
139 : : {
140 : 0 : Edit::Modify();
141 : :
142 [ # # ]: 0 : if ( bOnlyNumeric )
143 : : {
144 [ # # ][ # # ]: 0 : rtl::OUString aValue = GetText();
[ # # ]
145 : :
146 [ # # ][ # # ]: 0 : if ( !comphelper::string::isdigitAsciiString(aValue) || (long)aValue.toInt32() > USHRT_MAX )
[ # # ][ # # ]
147 : : // the maximum value of a port number is USHRT_MAX
148 [ # # ][ # # ]: 0 : ErrorBox( this, CUI_RES( RID_SVXERR_OPT_PROXYPORTS ) ).Execute();
[ # # ][ # # ]
149 : : }
150 : 0 : }
151 : :
152 : : /********************************************************************/
153 : : /* */
154 : : /* SvxProxyTabPage */
155 : : /* */
156 : : /********************************************************************/
157 : :
158 : 0 : SvxProxyTabPage::SvxProxyTabPage(Window* pParent, const SfxItemSet& rSet ) :
159 : 0 : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_PROXY ), rSet ),
160 [ # # ]: 0 : aOptionGB (this, CUI_RES(GB_SETTINGS)),
161 : :
162 [ # # ]: 0 : aProxyModeFT (this, CUI_RES(FT_PROXYMODE)),
163 [ # # ]: 0 : aProxyModeLB (this, CUI_RES(LB_PROXYMODE)),
164 : :
165 [ # # ]: 0 : aHttpProxyFT (this, CUI_RES( FT_HTTP_PROXY )),
166 [ # # ]: 0 : aHttpProxyED (this, CUI_RES( ED_HTTP_PROXY )),
167 [ # # ]: 0 : aHttpPortFT (this, CUI_RES( FT_HTTP_PORT )),
168 [ # # ]: 0 : aHttpPortED (this, CUI_RES( ED_HTTP_PORT ), sal_True),
169 : :
170 [ # # ]: 0 : aHttpsProxyFT (this, CUI_RES( FT_HTTPS_PROXY )),
171 [ # # ]: 0 : aHttpsProxyED (this, CUI_RES( ED_HTTPS_PROXY )),
172 [ # # ]: 0 : aHttpsPortFT (this, CUI_RES( FT_HTTPS_PORT )),
173 [ # # ]: 0 : aHttpsPortED (this, CUI_RES( ED_HTTPS_PORT ), sal_True),
174 : :
175 [ # # ]: 0 : aFtpProxyFT (this, CUI_RES( FT_FTP_PROXY )),
176 [ # # ]: 0 : aFtpProxyED (this, CUI_RES( ED_FTP_PROXY )),
177 [ # # ]: 0 : aFtpPortFT (this, CUI_RES( FT_FTP_PORT )),
178 [ # # ]: 0 : aFtpPortED (this, CUI_RES( ED_FTP_PORT ), sal_True),
179 : :
180 [ # # ]: 0 : aNoProxyForFT (this, CUI_RES( FT_NOPROXYFOR )),
181 [ # # ]: 0 : aNoProxyForED (this, CUI_RES( ED_NOPROXYFOR )),
182 [ # # ]: 0 : aNoProxyDescFT (this, CUI_RES( ED_NOPROXYDESC )),
183 [ # # ]: 0 : sFromBrowser ( CUI_RES( ST_PROXY_FROM_BROWSER ) ),
184 : : aProxyModePN(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType")),
185 : : aHttpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName")),
186 : : aHttpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort")),
187 : : aHttpsProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyName")),
188 : : aHttpsPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPSProxyPort")),
189 : : aFtpProxyPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName")),
190 : : aFtpPortPN(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort")),
191 [ # # ][ # # ]: 0 : aNoProxyDescPN(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy"))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
192 : : {
193 [ # # ]: 0 : FreeResource();
194 : :
195 [ # # ]: 0 : aHttpPortED.SetMaxTextLen(5);
196 [ # # ]: 0 : aHttpsPortED.SetMaxTextLen(5);
197 [ # # ]: 0 : aFtpPortED.SetMaxTextLen(5);
198 [ # # ]: 0 : Link aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl );
199 : 0 : aHttpPortED.SetLoseFocusHdl( aLink );
200 : 0 : aHttpsPortED.SetLoseFocusHdl( aLink );
201 : 0 : aFtpPortED.SetLoseFocusHdl( aLink );
202 : :
203 [ # # ]: 0 : aProxyModeLB.SetSelectHdl(LINK( this, SvxProxyTabPage, ProxyHdl_Impl ));
204 : :
205 : : Reference< com::sun::star::lang::XMultiServiceFactory >
206 : : xConfigurationProvider(
207 : : configuration::theDefaultProvider::get(
208 [ # # ][ # # ]: 0 : comphelper::getProcessComponentContext() ) );
209 : :
210 [ # # ]: 0 : OUString aConfigRoot(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings" ) );
211 : :
212 : 0 : beans::NamedValue aProperty;
213 [ # # ]: 0 : aProperty.Name = OUString(RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
214 [ # # ]: 0 : aProperty.Value = makeAny( aConfigRoot );
215 : :
216 [ # # ]: 0 : Sequence< Any > aArgumentList( 1 );
217 [ # # ][ # # ]: 0 : aArgumentList[0] = makeAny( aProperty );
218 : :
219 [ # # ]: 0 : m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments( rtl::OUString(
220 : : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
221 [ # # ][ # # ]: 0 : aArgumentList );
[ # # ]
222 : :
223 [ # # ][ # # ]: 0 : ArrangeControls_Impl();
224 : 0 : }
225 : :
226 [ # # ][ # # ]: 0 : SvxProxyTabPage::~SvxProxyTabPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
227 : : {
228 [ # # ]: 0 : }
229 : :
230 : 0 : SfxTabPage* SvxProxyTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
231 : : {
232 [ # # ]: 0 : return new SvxProxyTabPage(pParent, rAttrSet);
233 : : }
234 : :
235 : 0 : void SvxProxyTabPage::ReadConfigData_Impl()
236 : : {
237 : : try {
238 [ # # ]: 0 : Reference< container::XNameAccess > xNameAccess(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
239 : :
240 : 0 : sal_Int32 nIntValue = 0;
241 : 0 : OUString aStringValue;
242 : :
243 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aProxyModePN) >>= nIntValue )
[ # # ]
244 : : {
245 [ # # ]: 0 : aProxyModeLB.SelectEntryPos( (sal_uInt16) nIntValue );
246 : : }
247 : :
248 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aHttpProxyPN) >>= aStringValue )
[ # # ]
249 : : {
250 [ # # ][ # # ]: 0 : aHttpProxyED.SetText( aStringValue );
[ # # ]
251 : : }
252 : :
253 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aHttpPortPN) >>= nIntValue )
[ # # ]
254 : : {
255 [ # # ][ # # ]: 0 : aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
[ # # ]
256 : : }
257 : :
258 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aHttpsProxyPN) >>= aStringValue )
[ # # ]
259 : : {
260 [ # # ][ # # ]: 0 : aHttpsProxyED.SetText( aStringValue );
[ # # ]
261 : : }
262 : :
263 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aHttpsPortPN) >>= nIntValue )
[ # # ]
264 : : {
265 [ # # ][ # # ]: 0 : aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
[ # # ]
266 : : }
267 : :
268 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aFtpProxyPN) >>= aStringValue )
[ # # ]
269 : : {
270 [ # # ][ # # ]: 0 : aFtpProxyED.SetText( aStringValue );
[ # # ]
271 : : }
272 : :
273 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aFtpPortPN) >>= nIntValue )
[ # # ]
274 : : {
275 [ # # ][ # # ]: 0 : aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
[ # # ]
276 : : }
277 : :
278 [ # # ][ # # ]: 0 : if( xNameAccess->getByName(aNoProxyDescPN) >>= aStringValue )
[ # # ]
279 : : {
280 [ # # ][ # # ]: 0 : aNoProxyForED.SetText( aStringValue );
[ # # ]
281 [ # # # # ]: 0 : }
282 : : }
283 : :
284 : 0 : catch (const container::NoSuchElementException&) {
285 : : OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: NoSuchElementException caught" );
286 : : }
287 : :
288 : 0 : catch (const com::sun::star::lang::WrappedTargetException &) {
289 : : OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: WrappedTargetException caught" );
290 : : }
291 : :
292 : 0 : catch (const RuntimeException &) {
293 : : OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: RuntimeException caught" );
294 : : }
295 : :
296 : 0 : }
297 : :
298 : 0 : void SvxProxyTabPage::ReadConfigDefaults_Impl()
299 : : {
300 : : try
301 : : {
302 [ # # ]: 0 : Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
303 : :
304 : 0 : sal_Int32 nIntValue = 0;
305 : 0 : OUString aStringValue;
306 : :
307 [ # # ][ # # ]: 0 : if( xPropertyState->getPropertyDefault(aHttpProxyPN) >>= aStringValue )
[ # # ]
308 : : {
309 [ # # ][ # # ]: 0 : aHttpProxyED.SetText( aStringValue );
[ # # ]
310 : : }
311 : :
312 [ # # ][ # # ]: 0 : if( xPropertyState->getPropertyDefault(aHttpPortPN) >>= nIntValue )
[ # # ]
313 : : {
314 [ # # ][ # # ]: 0 : aHttpPortED.SetText( String::CreateFromInt32( nIntValue ));
[ # # ]
315 : : }
316 : :
317 [ # # ][ # # ]: 0 : if( xPropertyState->getPropertyDefault(aHttpsProxyPN) >>= aStringValue )
[ # # ]
318 : : {
319 [ # # ][ # # ]: 0 : aHttpsProxyED.SetText( aStringValue );
[ # # ]
320 : : }
321 : :
322 [ # # ][ # # ]: 0 : if( xPropertyState->getPropertyDefault(aHttpsPortPN) >>= nIntValue )
[ # # ]
323 : : {
324 [ # # ][ # # ]: 0 : aHttpsPortED.SetText( String::CreateFromInt32( nIntValue ));
[ # # ]
325 : : }
326 : :
327 [ # # ][ # # ]: 0 : if( xPropertyState->getPropertyDefault(aFtpProxyPN) >>= aStringValue )
[ # # ]
328 : : {
329 [ # # ][ # # ]: 0 : aFtpProxyED.SetText( aStringValue );
[ # # ]
330 : : }
331 : :
332 [ # # ][ # # ]: 0 : if( xPropertyState->getPropertyDefault(aFtpPortPN) >>= nIntValue )
[ # # ]
333 : : {
334 [ # # ][ # # ]: 0 : aFtpPortED.SetText( String::CreateFromInt32( nIntValue ));
[ # # ]
335 : : }
336 : :
337 [ # # ][ # # ]: 0 : if( xPropertyState->getPropertyDefault(aNoProxyDescPN) >>= aStringValue )
[ # # ]
338 : : {
339 [ # # ][ # # ]: 0 : aNoProxyForED.SetText( aStringValue );
[ # # ]
340 [ # # # # ]: 0 : }
341 : : }
342 : 0 : catch (const beans::UnknownPropertyException &)
343 : : {
344 : : OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
345 : : }
346 : :
347 : 0 : catch (const com::sun::star::lang::WrappedTargetException &) {
348 : : OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
349 : : }
350 : :
351 : 0 : catch (const RuntimeException &)
352 : : {
353 : : OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
354 : : }
355 : 0 : }
356 : :
357 : 0 : void SvxProxyTabPage::RestoreConfigDefaults_Impl()
358 : : {
359 : : try
360 : : {
361 [ # # ]: 0 : Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
362 : :
363 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aProxyModePN);
364 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aHttpProxyPN);
365 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aHttpPortPN);
366 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aHttpsProxyPN);
367 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aHttpsPortPN);
368 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aFtpProxyPN);
369 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aFtpPortPN);
370 [ # # ][ # # ]: 0 : xPropertyState->setPropertyToDefault(aNoProxyDescPN);
371 : :
372 [ # # ]: 0 : Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
373 [ # # ][ # # ]: 0 : xChangesBatch->commitChanges();
[ # # # # ]
374 : : }
375 : :
376 : 0 : catch (const beans::UnknownPropertyException &)
377 : : {
378 : : OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" );
379 : : }
380 : :
381 : 0 : catch (const com::sun::star::lang::WrappedTargetException &) {
382 : : OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" );
383 : : }
384 : :
385 : 0 : catch (const RuntimeException &)
386 : : {
387 : : OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" );
388 : : }
389 : 0 : }
390 : :
391 : 0 : void SvxProxyTabPage::Reset(const SfxItemSet&)
392 : : {
393 : 0 : ReadConfigData_Impl();
394 : :
395 : 0 : aProxyModeLB.SaveValue();
396 : 0 : aHttpProxyED.SaveValue();
397 : 0 : aHttpPortED.SaveValue();
398 : 0 : aHttpsProxyED.SaveValue();
399 : 0 : aHttpsPortED.SaveValue();
400 : 0 : aFtpProxyED.SaveValue();
401 : 0 : aFtpPortED.SaveValue();
402 : 0 : aNoProxyForED.SaveValue();
403 : :
404 : 0 : EnableControls_Impl( aProxyModeLB.GetSelectEntryPos() == 2 );
405 : 0 : }
406 : :
407 : 0 : sal_Bool SvxProxyTabPage::FillItemSet(SfxItemSet& )
408 : : {
409 : 0 : sal_Bool bModified=sal_False;
410 : :
411 : : try {
412 [ # # ]: 0 : Reference< beans::XPropertySet > xPropertySet(m_xConfigurationUpdateAccess, UNO_QUERY_THROW );
413 : :
414 [ # # ]: 0 : sal_uInt16 nSelPos = aProxyModeLB.GetSelectEntryPos();
415 [ # # ]: 0 : if(aProxyModeLB.GetSavedValue() != nSelPos)
416 : : {
417 [ # # ]: 0 : if( nSelPos == 1 )
418 : : {
419 [ # # ]: 0 : RestoreConfigDefaults_Impl();
420 : 0 : return sal_True;
421 : : }
422 : :
423 [ # # ]: 0 : xPropertySet->setPropertyValue(aProxyModePN,
424 [ # # ][ # # ]: 0 : makeAny((sal_Int32) nSelPos));
425 : 0 : bModified = sal_True;
426 : : }
427 : :
428 [ # # ][ # # ]: 0 : if(aHttpProxyED.GetSavedValue() != aHttpProxyED.GetText())
[ # # ][ # # ]
429 : : {
430 [ # # ]: 0 : xPropertySet->setPropertyValue( aHttpProxyPN,
431 [ # # ][ # # ]: 0 : makeAny(rtl::OUString(aHttpProxyED.GetText())));
[ # # ][ # # ]
[ # # ]
432 : 0 : bModified = sal_True;
433 : : }
434 : :
435 [ # # ][ # # ]: 0 : if ( aHttpPortED.GetSavedValue() != aHttpPortED.GetText() )
[ # # ][ # # ]
436 : : {
437 [ # # ]: 0 : xPropertySet->setPropertyValue( aHttpPortPN,
438 [ # # ][ # # ]: 0 : makeAny(aHttpPortED.GetText().ToInt32()));
[ # # ][ # # ]
[ # # ]
439 : 0 : bModified = sal_True;
440 : : }
441 : :
442 [ # # ][ # # ]: 0 : if(aHttpsProxyED.GetSavedValue() != aHttpsProxyED.GetText())
[ # # ][ # # ]
443 : : {
444 [ # # ]: 0 : xPropertySet->setPropertyValue( aHttpsProxyPN,
445 [ # # ][ # # ]: 0 : makeAny(rtl::OUString(aHttpsProxyED.GetText())));
[ # # ][ # # ]
[ # # ]
446 : 0 : bModified = sal_True;
447 : : }
448 : :
449 [ # # ][ # # ]: 0 : if ( aHttpsPortED.GetSavedValue() != aHttpsPortED.GetText() )
[ # # ][ # # ]
450 : : {
451 [ # # ]: 0 : xPropertySet->setPropertyValue( aHttpsPortPN,
452 [ # # ][ # # ]: 0 : makeAny(aHttpsPortED.GetText().ToInt32()));
[ # # ][ # # ]
[ # # ]
453 : 0 : bModified = sal_True;
454 : : }
455 : :
456 [ # # ][ # # ]: 0 : if(aFtpProxyED.GetSavedValue() != aFtpProxyED.GetText())
[ # # ][ # # ]
457 : : {
458 [ # # ]: 0 : xPropertySet->setPropertyValue( aFtpProxyPN,
459 [ # # ][ # # ]: 0 : makeAny( rtl::OUString(aFtpProxyED.GetText())));
[ # # ][ # # ]
[ # # ]
460 : 0 : bModified = sal_True;
461 : : }
462 : :
463 [ # # ][ # # ]: 0 : if ( aFtpPortED.GetSavedValue() != aFtpPortED.GetText() )
[ # # ][ # # ]
464 : : {
465 [ # # ]: 0 : xPropertySet->setPropertyValue( aFtpPortPN,
466 [ # # ][ # # ]: 0 : makeAny(aFtpPortED.GetText().ToInt32()));
[ # # ][ # # ]
[ # # ]
467 : 0 : bModified = sal_True;
468 : : }
469 : :
470 [ # # ][ # # ]: 0 : if ( aNoProxyForED.GetSavedValue() != aNoProxyForED.GetText() )
[ # # ][ # # ]
471 : : {
472 [ # # ]: 0 : xPropertySet->setPropertyValue( aNoProxyDescPN,
473 [ # # ][ # # ]: 0 : makeAny( rtl::OUString(aNoProxyForED.GetText())));
[ # # ][ # # ]
[ # # ]
474 : 0 : bModified = sal_True;
475 : : }
476 : :
477 [ # # ]: 0 : Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
478 [ # # ][ # # ]: 0 : xChangesBatch->commitChanges();
[ # # ][ # #
# # # # ]
479 : : }
480 : :
481 : 0 : catch (const com::sun::star::lang::IllegalArgumentException &) {
482 : : OSL_TRACE( "SvxProxyTabPage::FillItemSet: IllegalArgumentException caught" );
483 : : }
484 : :
485 : 0 : catch (const beans::UnknownPropertyException &) {
486 : : OSL_TRACE( "SvxProxyTabPage::FillItemSet: UnknownPropertyException caught" );
487 : : }
488 : :
489 : 0 : catch (const beans::PropertyVetoException &) {
490 : : OSL_TRACE( "SvxProxyTabPage::FillItemSet: PropertyVetoException caught" );
491 : : }
492 : :
493 : 0 : catch (const com::sun::star::lang::WrappedTargetException &) {
494 : : OSL_TRACE( "SvxProxyTabPage::FillItemSet: WrappedTargetException caught" );
495 : : }
496 : :
497 : 0 : catch (const RuntimeException &) {
498 : : OSL_TRACE( "SvxProxyTabPage::FillItemSet: RuntimeException caught" );
499 : : }
500 : :
501 : 0 : return bModified;
502 : : }
503 : :
504 : 0 : void SvxProxyTabPage::ArrangeControls_Impl()
505 : : {
506 : : // calculate dynamic width of controls, to not cut-off translated strings #i71445#
507 [ # # ]: 0 : long nWidth = aProxyModeFT.GetCtrlTextWidth( aProxyModeFT.GetText() );
508 [ # # ]: 0 : long nTemp = aHttpProxyFT.GetCtrlTextWidth( aHttpProxyFT.GetText() );
509 [ # # ]: 0 : if ( nTemp > nWidth )
510 : 0 : nWidth = nTemp;
511 [ # # ]: 0 : nTemp = aHttpsProxyFT.GetCtrlTextWidth( aHttpsProxyFT.GetText() );
512 [ # # ]: 0 : if ( nTemp > nWidth )
513 : 0 : nWidth = nTemp;
514 [ # # ]: 0 : nTemp = aFtpProxyFT.GetCtrlTextWidth( aFtpProxyFT.GetText() );
515 [ # # ]: 0 : if ( nTemp > nWidth )
516 : 0 : nWidth = nTemp;
517 [ # # ]: 0 : nTemp = aNoProxyForFT.GetCtrlTextWidth( aNoProxyForFT.GetText() );
518 [ # # ]: 0 : if ( nTemp > nWidth )
519 : 0 : nWidth = nTemp;
520 : :
521 : 0 : nWidth += 10; // To be sure the length of the FixedText is enough on all platforms
522 : 0 : const long nFTWidth = aProxyModeFT.GetSizePixel().Width();
523 [ # # ]: 0 : if ( nWidth > nFTWidth )
524 : : {
525 [ # # ]: 0 : Size aNewSize = aProxyModeFT.GetSizePixel();
526 : 0 : aNewSize.Width() = nWidth;
527 : :
528 [ # # ]: 0 : aProxyModeFT.SetSizePixel( aNewSize );
529 [ # # ]: 0 : aHttpProxyFT.SetSizePixel( aNewSize );
530 [ # # ]: 0 : aHttpsProxyFT.SetSizePixel( aNewSize );
531 [ # # ]: 0 : aFtpProxyFT.SetSizePixel( aNewSize );
532 [ # # ]: 0 : aNoProxyForFT.SetSizePixel( aNewSize );
533 : :
534 : 0 : const long nDelta = nWidth - nFTWidth;
535 [ # # ]: 0 : Point aNewPos = aProxyModeLB.GetPosPixel();
536 : 0 : aNewPos.X() += nDelta;
537 : :
538 [ # # ]: 0 : aProxyModeLB.SetPosPixel( aNewPos );
539 : :
540 [ # # ]: 0 : aNewSize = aHttpProxyED.GetSizePixel();
541 : 0 : aNewSize.Width() -= nDelta;
542 : :
543 [ # # ]: 0 : aNewPos.Y() = aHttpProxyED.GetPosPixel().Y();
544 [ # # ]: 0 : aHttpProxyED.SetPosSizePixel( aNewPos, aNewSize );
545 [ # # ]: 0 : aNewPos.Y() = aHttpsProxyED.GetPosPixel().Y();
546 [ # # ]: 0 : aHttpsProxyED.SetPosSizePixel( aNewPos, aNewSize );
547 [ # # ]: 0 : aNewPos.Y() = aFtpProxyED.GetPosPixel().Y();
548 [ # # ]: 0 : aFtpProxyED.SetPosSizePixel( aNewPos, aNewSize );
549 [ # # ]: 0 : aNewPos.Y() = aNoProxyForED.GetPosPixel().Y();
550 [ # # ]: 0 : aNoProxyForED.SetPosSizePixel( aNewPos, aNewSize );
551 : : }
552 : 0 : }
553 : :
554 : 0 : void SvxProxyTabPage::EnableControls_Impl(sal_Bool bEnable)
555 : : {
556 : 0 : aHttpProxyFT.Enable(bEnable);
557 : 0 : aHttpProxyED.Enable(bEnable);
558 : 0 : aHttpPortFT.Enable(bEnable);
559 : 0 : aHttpPortED.Enable(bEnable);
560 : :
561 : 0 : aHttpsProxyFT.Enable(bEnable);
562 : 0 : aHttpsProxyED.Enable(bEnable);
563 : 0 : aHttpsPortFT.Enable(bEnable);
564 : 0 : aHttpsPortED.Enable(bEnable);
565 : :
566 : 0 : aFtpProxyFT.Enable(bEnable);
567 : 0 : aFtpProxyED.Enable(bEnable);
568 : 0 : aFtpPortFT.Enable(bEnable);
569 : 0 : aFtpPortED.Enable(bEnable);
570 : :
571 : 0 : aNoProxyForFT.Enable(bEnable);
572 : 0 : aNoProxyForED.Enable(bEnable);
573 : 0 : aNoProxyDescFT.Enable(bEnable);
574 : 0 : }
575 : :
576 : : // -----------------------------------------------------------------------
577 : :
578 : 0 : IMPL_LINK( SvxProxyTabPage, ProxyHdl_Impl, ListBox *, pBox )
579 : : {
580 : 0 : sal_uInt16 nPos = pBox->GetSelectEntryPos();
581 : :
582 : : // Restore original system values
583 [ # # ]: 0 : if( nPos == 1 )
584 : : {
585 : 0 : ReadConfigDefaults_Impl();
586 : : }
587 : :
588 : 0 : EnableControls_Impl(nPos == 2);
589 : 0 : return 0;
590 : : }
591 : :
592 : : // -----------------------------------------------------------------------
593 : :
594 : 0 : IMPL_LINK( SvxProxyTabPage, LoseFocusHdl_Impl, Edit *, pEdit )
595 : : {
596 [ # # ][ # # ]: 0 : rtl::OUString aValue = pEdit->GetText();
[ # # ]
597 : :
598 [ # # ][ # # ]: 0 : if ( !comphelper::string::isdigitAsciiString(aValue) || (long)aValue.toInt32() > USHRT_MAX )
[ # # ][ # # ]
599 [ # # ][ # # ]: 0 : pEdit->SetText( rtl::OUString('0') );
[ # # ]
600 : 0 : return 0;
601 : : }
602 : :
603 : :
604 : :
605 : : //#98647#----------------------------------------------
606 : 0 : void SvxScriptExecListBox::RequestHelp( const HelpEvent& rHEvt )
607 : : { // try to show tips just like as on toolbars
608 : 0 : sal_uInt16 nPos=LISTBOX_ENTRY_NOTFOUND;
609 [ # # ]: 0 : sal_uInt16 nTop = GetTopEntry();
610 [ # # ]: 0 : sal_uInt16 nCount = GetDisplayLineCount(); // Attention: Not GetLineCount()
611 [ # # ][ # # ]: 0 : Point aPt = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
612 [ # # ]: 0 : Rectangle aItemRect;
613 [ # # ]: 0 : if( nCount > 0 ) // if there're some entries, find it.
614 [ # # ]: 0 : for( nPos = nTop ; nPos <= nTop+nCount-1 ; nPos++ ) {
615 [ # # ]: 0 : aItemRect = GetBoundingRectangle(nPos);
616 [ # # ][ # # ]: 0 : if( aPt.Y() < aItemRect.Top() || aPt.Y() > aItemRect.Bottom() )
[ # # ]
617 : 0 : continue;
618 : : else
619 : 0 : break;
620 : : }
621 : : else // if not, nothing happens.
622 : 0 : return;
623 [ # # ]: 0 : String aHelpText;
624 [ # # ]: 0 : if( nPos <= nTop+nCount-1 ) // if find the matching entry, get its content.
625 [ # # ][ # # ]: 0 : aHelpText = GetEntry(nPos);
[ # # ]
626 [ # # ][ # # ]: 0 : if( aHelpText.Len() && GetTextWidth(aHelpText)<GetOutputSizePixel().Width() )
[ # # ][ # # ]
[ # # # # ]
627 [ # # ]: 0 : aHelpText.Erase(); // if the entry is quite short, clear the helping tip content.
628 [ # # ][ # # ]: 0 : aItemRect = Rectangle(Point(0,0),GetSizePixel());
629 [ # # ]: 0 : aPt = Point(OutputToScreenPixel( aItemRect.TopLeft() ));
630 : 0 : aItemRect.Left() = aPt.X();
631 : 0 : aItemRect.Top() = aPt.Y();
632 [ # # ][ # # ]: 0 : aPt = OutputToScreenPixel( aItemRect.BottomRight() );
633 : 0 : aItemRect.Right() = aPt.X();
634 : 0 : aItemRect.Bottom() = aPt.Y();
635 [ # # ]: 0 : if( rHEvt.GetMode() == HELPMODE_BALLOON )
636 [ # # ][ # # ]: 0 : Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
637 : : else
638 [ # # ][ # # ]: 0 : Help::ShowQuickHelp( this, aItemRect, aHelpText );
639 : : }
640 : :
641 : : /********************************************************************/
642 : : /* */
643 : : /* SvxSecurityTabPage */
644 : : /* */
645 : : /********************************************************************/
646 : :
647 : 0 : SvxSecurityTabPage::SvxSecurityTabPage( Window* pParent, const SfxItemSet& rSet )
648 : 0 : :SfxTabPage ( pParent, CUI_RES( RID_SVXPAGE_INET_SECURITY ), rSet )
649 : :
650 [ # # ]: 0 : ,maSecurityOptionsFL( this, CUI_RES( FL_SEC_SECURITYOPTIONS ) )
651 [ # # ]: 0 : ,maSecurityOptionsFI( this, CUI_RES( FI_SEC_SECURITYOPTIONS ) )
652 [ # # ]: 0 : ,maSecurityOptionsPB( this, CUI_RES( PB_SEC_SECURITYOPTIONS ) )
653 : :
654 [ # # ]: 0 : ,maPasswordsFL ( this, CUI_RES( FL_SEC_PASSWORDS ) )
655 [ # # ]: 0 : ,maSavePasswordsCB ( this, CUI_RES( CB_SEC_SAVEPASSWORDS ) )
656 [ # # ]: 0 : ,maShowConnectionsPB( this, CUI_RES( PB_SEC_CONNECTIONS ) )
657 [ # # ]: 0 : ,maMasterPasswordCB ( this, CUI_RES( CB_SEC_MASTERPASSWORD ) )
658 [ # # ]: 0 : ,maMasterPasswordFI ( this, CUI_RES( FI_SEC_MASTERPASSWORD ) )
659 [ # # ]: 0 : ,maMasterPasswordPB ( this, CUI_RES( PB_SEC_MASTERPASSWORD ) )
660 : :
661 [ # # ]: 0 : ,maMacroSecFL ( this, CUI_RES( FL_SEC_MACROSEC ) )
662 [ # # ]: 0 : ,maMacroSecFI ( this, CUI_RES( FI_SEC_MACROSEC ) )
663 [ # # ]: 0 : ,maMacroSecPB ( this, CUI_RES( PB_SEC_MACROSEC ) )
664 : :
665 [ # # ]: 0 : ,m_aCertPathFL ( this, CUI_RES( FL_SEC_CERTPATH ) )
666 [ # # ]: 0 : ,m_aCertPathFI ( this, CUI_RES( FI_SEC_CERTPATH ) )
667 [ # # ]: 0 : ,m_aCertPathPB ( this, CUI_RES( PB_SEC_CERTPATH ) )
668 : :
669 [ # # ]: 0 : ,mpSecOptions ( new SvtSecurityOptions )
670 : : ,mpSecOptDlg ( NULL )
671 : : ,mpCertPathDlg ( NULL )
672 : :
673 [ # # ][ # # ]: 0 : ,msPasswordStoringDeactivateStr( CUI_RES( STR_SEC_NOPASSWDSAVE ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
674 : :
675 : : {
676 [ # # ]: 0 : FreeResource();
677 : :
678 [ # # ]: 0 : InitControls();
679 : :
680 [ # # ]: 0 : maSecurityOptionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, SecurityOptionsHdl ) );
681 [ # # ]: 0 : maSavePasswordsCB.SetClickHdl( LINK( this, SvxSecurityTabPage, SavePasswordHdl ) );
682 [ # # ]: 0 : maMasterPasswordPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordHdl ) );
683 [ # # ]: 0 : maMasterPasswordCB.SetClickHdl( LINK( this, SvxSecurityTabPage, MasterPasswordCBHdl ) );
684 [ # # ]: 0 : maShowConnectionsPB.SetClickHdl( LINK( this, SvxSecurityTabPage, ShowPasswordsHdl ) );
685 [ # # ]: 0 : maMacroSecPB.SetClickHdl( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) );
686 [ # # ]: 0 : m_aCertPathPB.SetClickHdl( LINK( this, SvxSecurityTabPage, CertPathPBHdl ) );
687 : :
688 : 0 : ActivatePage( rSet );
689 : 0 : }
690 : :
691 [ # # ][ # # ]: 0 : SvxSecurityTabPage::~SvxSecurityTabPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
692 : : {
693 [ # # ][ # # ]: 0 : delete mpCertPathDlg;
694 : :
695 [ # # ][ # # ]: 0 : delete mpSecOptions;
696 [ # # ][ # # ]: 0 : delete mpSecOptDlg;
697 [ # # ]: 0 : }
698 : :
699 : 0 : IMPL_LINK_NOARG(SvxSecurityTabPage, SecurityOptionsHdl)
700 : : {
701 [ # # ]: 0 : if ( !mpSecOptDlg )
702 [ # # ]: 0 : mpSecOptDlg = new svx::SecurityOptionsDialog( this, mpSecOptions );
703 : 0 : mpSecOptDlg->Execute();
704 : 0 : return 0;
705 : : }
706 : :
707 : 0 : IMPL_LINK_NOARG(SvxSecurityTabPage, SavePasswordHdl)
708 : : {
709 : : try
710 : : {
711 : : Reference< task::XMasterPasswordHandling > xMasterPasswd(
712 [ # # ][ # # ]: 0 : comphelper::getProcessServiceFactory()->createInstance(
713 : 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
714 [ # # ][ # # ]: 0 : UNO_QUERY_THROW );
[ # # ]
715 : :
716 [ # # ][ # # ]: 0 : if ( maSavePasswordsCB.IsChecked() )
717 : : {
718 [ # # ][ # # ]: 0 : sal_Bool bOldValue = xMasterPasswd->allowPersistentStoring( sal_True );
719 [ # # ][ # # ]: 0 : xMasterPasswd->removeMasterPassword();
720 [ # # ][ # # ]: 0 : if ( xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
[ # # ]
721 : : {
722 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_True );
723 [ # # ]: 0 : maMasterPasswordCB.Check( sal_True );
724 [ # # ]: 0 : maMasterPasswordCB.Enable( sal_True );
725 [ # # ]: 0 : maMasterPasswordFI.Enable( sal_True );
726 [ # # ]: 0 : maShowConnectionsPB.Enable( sal_True );
727 : : }
728 : : else
729 : : {
730 [ # # ][ # # ]: 0 : xMasterPasswd->allowPersistentStoring( bOldValue );
731 [ # # ]: 0 : maSavePasswordsCB.Check( sal_False );
732 : : }
733 : : }
734 : : else
735 : : {
736 [ # # ]: 0 : QueryBox aQuery( this, WB_YES_NO|WB_DEF_NO, msPasswordStoringDeactivateStr );
737 [ # # ]: 0 : sal_uInt16 nRet = aQuery.Execute();
738 : :
739 [ # # ]: 0 : if( RET_YES == nRet )
740 : : {
741 [ # # ][ # # ]: 0 : xMasterPasswd->allowPersistentStoring( sal_False );
742 [ # # ]: 0 : maMasterPasswordCB.Check( sal_True );
743 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_False );
744 [ # # ]: 0 : maMasterPasswordCB.Enable( sal_False );
745 [ # # ]: 0 : maMasterPasswordFI.Enable( sal_False );
746 [ # # ]: 0 : maShowConnectionsPB.Enable( sal_False );
747 : : }
748 : : else
749 : : {
750 [ # # ]: 0 : maSavePasswordsCB.Check( sal_True );
751 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_True );
752 [ # # ]: 0 : maShowConnectionsPB.Enable( sal_True );
753 [ # # ]: 0 : }
754 : 0 : }
755 : : }
756 [ # # ]: 0 : catch (const Exception&)
757 : : {
758 [ # # # # ]: 0 : maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
759 : : }
760 : :
761 : 0 : return 0;
762 : : }
763 : :
764 : 0 : IMPL_LINK_NOARG(SvxSecurityTabPage, MasterPasswordHdl)
765 : : {
766 : : try
767 : : {
768 : : Reference< task::XMasterPasswordHandling > xMasterPasswd(
769 [ # # ][ # # ]: 0 : comphelper::getProcessServiceFactory()->createInstance(
770 : 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
771 [ # # ][ # # ]: 0 : UNO_QUERY );
[ # # ]
772 : :
773 [ # # ][ # # ]: 0 : if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() )
[ # # ][ # # ]
[ # # ]
774 [ # # ][ # # ]: 0 : xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() );
[ # # ]
775 : : }
776 : 0 : catch (const Exception&)
777 : : {}
778 : :
779 : 0 : return 0;
780 : : }
781 : :
782 : 0 : IMPL_LINK_NOARG(SvxSecurityTabPage, MasterPasswordCBHdl)
783 : : {
784 : : try
785 : : {
786 : : Reference< task::XMasterPasswordHandling2 > xMasterPasswd(
787 [ # # ][ # # ]: 0 : comphelper::getProcessServiceFactory()->createInstance(
788 : 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
789 [ # # ][ # # ]: 0 : UNO_QUERY_THROW );
[ # # ]
790 : :
791 [ # # ][ # # ]: 0 : if ( maMasterPasswordCB.IsChecked() )
792 : : {
793 [ # # ][ # # ]: 0 : if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->changeMasterPassword( Reference< task::XInteractionHandler >() ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
794 : : {
795 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_True );
796 [ # # ]: 0 : maMasterPasswordFI.Enable( sal_True );
797 : : }
798 : : else
799 : : {
800 [ # # ]: 0 : maMasterPasswordCB.Check( sal_False );
801 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_True );
802 [ # # ]: 0 : maMasterPasswordFI.Enable( sal_True );
803 : : }
804 : : }
805 : : else
806 : : {
807 [ # # ][ # # ]: 0 : if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->useDefaultMasterPassword( Reference< task::XInteractionHandler >() ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
808 : : {
809 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_False );
810 [ # # ]: 0 : maMasterPasswordFI.Enable( sal_False );
811 : : }
812 : : else
813 : : {
814 [ # # ]: 0 : maMasterPasswordCB.Check( sal_True );
815 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_True );
816 [ # # ]: 0 : maShowConnectionsPB.Enable( sal_True );
817 : : }
818 : 0 : }
819 : : }
820 [ # # ]: 0 : catch (const Exception&)
821 : : {
822 [ # # # # ]: 0 : maSavePasswordsCB.Check( !maSavePasswordsCB.IsChecked() );
823 : : }
824 : :
825 : 0 : return 0;
826 : : }
827 : :
828 : 0 : IMPL_LINK_NOARG(SvxSecurityTabPage, ShowPasswordsHdl)
829 : : {
830 : : try
831 : : {
832 : : Reference< task::XMasterPasswordHandling > xMasterPasswd(
833 [ # # ][ # # ]: 0 : comphelper::getProcessServiceFactory()->createInstance(
834 : 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
835 [ # # ][ # # ]: 0 : UNO_QUERY );
[ # # ]
836 : :
837 [ # # ][ # # ]: 0 : if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword( Reference< task::XInteractionHandler>() ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
838 : : {
839 [ # # ]: 0 : svx::WebConnectionInfoDialog aDlg( this );
840 [ # # ][ # # ]: 0 : aDlg.Execute();
841 [ # # ]: 0 : }
842 : : }
843 : 0 : catch (const Exception&)
844 : : {}
845 : 0 : return 0;
846 : : }
847 : :
848 : 0 : IMPL_LINK_NOARG(SvxSecurityTabPage, CertPathPBHdl)
849 : : {
850 [ # # ]: 0 : if (!mpCertPathDlg)
851 [ # # ][ # # ]: 0 : mpCertPathDlg = new CertPathDialog(this);
852 : :
853 [ # # ]: 0 : rtl::OUString sOrig = mpCertPathDlg->getDirectory();
854 [ # # ]: 0 : short nRet = mpCertPathDlg->Execute();
855 : :
856 [ # # ][ # # ]: 0 : if (nRet == RET_OK && sOrig != mpCertPathDlg->getDirectory())
[ # # ][ # # ]
[ # # # # ]
857 : : {
858 [ # # ][ # # ]: 0 : WarningBox aWarnBox(this, CUI_RES(RID_SVX_MSGBOX_OPTIONS_RESTART));
859 [ # # ][ # # ]: 0 : aWarnBox.Execute();
860 : : }
861 : :
862 : 0 : return 0;
863 : : }
864 : :
865 : 0 : IMPL_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl)
866 : : {
867 : : try
868 : : {
869 : : Reference< security::XDocumentDigitalSignatures > xD(
870 [ # # ][ # # ]: 0 : comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), UNO_QUERY );
[ # # ][ # # ]
[ # # ]
871 [ # # ]: 0 : if ( xD.is() )
872 [ # # ][ # # ]: 0 : xD->manageTrustedSources();
[ # # ]
873 : : }
874 : 0 : catch (const Exception& e)
875 : : {
876 : : OSL_FAIL(rtl::OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr());
877 : : (void)e;
878 : : }
879 : 0 : return 0;
880 : : }
881 : :
882 : :
883 : 0 : void SvxSecurityTabPage::InitControls()
884 : : {
885 : : // Hide all controls which belong to the macro security button in case the macro
886 : : // security settings managed by the macro security dialog opened via the button
887 : : // are all readonly or if the macros are disabled in general.
888 : : // @@@ Better would be to query the dialog whether it is 'useful' or not. Exposing
889 : : // macro security dialog implementations here, which is bad.
890 [ # # ][ # # ]: 0 : if ( mpSecOptions->IsMacroDisabled()
[ # # ][ # # ]
[ # # ][ # # ]
891 [ # # ]: 0 : || ( mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_SECLEVEL )
892 [ # # ]: 0 : && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS )
893 [ # # ]: 0 : && mpSecOptions->IsReadOnly( SvtSecurityOptions::E_SECUREURLS ) ) )
894 : : {
895 : : //Move these up
896 [ # # ][ # # ]: 0 : m_aCertPathFL.SetPosPixel(maMacroSecFL.GetPosPixel());
897 [ # # ][ # # ]: 0 : m_aCertPathFI.SetPosPixel(maMacroSecFI.GetPosPixel());
898 [ # # ][ # # ]: 0 : m_aCertPathPB.SetPosPixel(maMacroSecPB.GetPosPixel());
899 : :
900 : : //Hide these
901 [ # # ]: 0 : maMacroSecFL.Hide();
902 [ # # ]: 0 : maMacroSecFI.Hide();
903 [ # # ]: 0 : maMacroSecPB.Hide();
904 : : }
905 : :
906 : : // one button too small for its text?
907 : 0 : long nBtnTextWidth = 0;
908 : : Window* pButtons[] = { &maSecurityOptionsPB, &maMasterPasswordPB,
909 : 0 : &maShowConnectionsPB, &maMacroSecPB, &m_aCertPathPB };
910 : 0 : Window** pButton = pButtons;
911 : 0 : const sal_Int32 nBCount = SAL_N_ELEMENTS( pButtons );
912 [ # # ]: 0 : for (sal_Int32 i = 0; i < nBCount; ++i, ++pButton )
913 : : {
914 [ # # ][ # # ]: 0 : long nTemp = (*pButton)->GetCtrlTextWidth( (*pButton)->GetText() );
[ # # ]
915 [ # # ]: 0 : if ( nTemp > nBtnTextWidth )
916 : 0 : nBtnTextWidth = nTemp;
917 : : }
918 : :
919 : 0 : nBtnTextWidth = nBtnTextWidth * 115 / 100; // a little offset
920 [ # # ]: 0 : const long nButtonWidth = maSecurityOptionsPB.GetSizePixel().Width();
921 : 0 : const long nMaxWidth = nButtonWidth * 140 / 100;
922 [ # # ]: 0 : long nExtra = ( nBtnTextWidth > nMaxWidth ) ? nBtnTextWidth - nMaxWidth : 0;
923 [ # # ]: 0 : nBtnTextWidth = std::min( nBtnTextWidth, nMaxWidth );
924 : :
925 [ # # ]: 0 : if ( nBtnTextWidth > nButtonWidth )
926 : : {
927 : : // so make the buttons broader and its control in front of it smaller
928 : 0 : long nDelta = nBtnTextWidth - nButtonWidth;
929 : 0 : pButton = pButtons;
930 : :
931 [ # # ]: 0 : if ( nExtra > 0 )
932 : : {
933 [ # # ]: 0 : long nPos = (*pButton)->GetPosPixel().X() - nDelta;
934 [ # # ]: 0 : long nWidth = (*pButton)->GetSizePixel().Width() + nDelta;
935 : 0 : long nMaxExtra = GetOutputSizePixel().Width() - ( nPos + nWidth ) - 2;
936 [ # # ]: 0 : nExtra = ( nExtra < nMaxExtra ) ? nExtra : nMaxExtra;
937 : : }
938 : :
939 [ # # ]: 0 : for (sal_Int32 i = 0; i < nBCount; ++i, ++pButton )
940 : : {
941 [ # # ]: 0 : Point aNewPos = (*pButton)->GetPosPixel();
942 : 0 : aNewPos.X() -= nDelta;
943 [ # # ]: 0 : Size aNewSize = (*pButton)->GetSizePixel();
944 : 0 : aNewSize.Width() += ( nDelta + nExtra );
945 [ # # ]: 0 : (*pButton)->SetPosSizePixel( aNewPos, aNewSize );
946 : : }
947 : :
948 : : Window* pControls[] = { &maSecurityOptionsFI, &maSavePasswordsCB,
949 : 0 : &maMasterPasswordFI, &maMacroSecFI, &m_aCertPathFI };
950 : 0 : Window** pControl = pControls;
951 : 0 : const sal_Int32 nCCount = SAL_N_ELEMENTS( pControls );
952 [ # # ]: 0 : for (sal_Int32 i = 0; i < nCCount; ++i, ++pControl )
953 : : {
954 [ # # ]: 0 : Size aNewSize = (*pControl)->GetSizePixel();
955 : 0 : aNewSize.Width() -= nDelta;
956 [ # # ]: 0 : (*pControl)->SetSizePixel( aNewSize );
957 : : }
958 : : }
959 : :
960 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_False );
961 [ # # ]: 0 : maMasterPasswordCB.Enable( sal_False );
962 [ # # ]: 0 : maMasterPasswordCB.Check( sal_True );
963 [ # # ]: 0 : maMasterPasswordFI.Enable( sal_False );
964 [ # # ]: 0 : maShowConnectionsPB.Enable( sal_False );
965 : :
966 : : // initialize the password saving checkbox
967 : : try
968 : : {
969 : : Reference< task::XMasterPasswordHandling > xMasterPasswd(
970 [ # # ][ # # ]: 0 : comphelper::getProcessServiceFactory()->createInstance(
971 : 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
972 [ # # ][ # # ]: 0 : UNO_QUERY_THROW );
[ # # ]
973 : :
974 [ # # ][ # # ]: 0 : if ( xMasterPasswd->isPersistentStoringAllowed() )
[ # # ]
975 : : {
976 [ # # ]: 0 : maMasterPasswordCB.Enable( sal_True );
977 [ # # ]: 0 : maShowConnectionsPB.Enable( sal_True );
978 [ # # ]: 0 : maSavePasswordsCB.Check( sal_True );
979 : :
980 [ # # ]: 0 : Reference< task::XMasterPasswordHandling2 > xMasterPasswd2( xMasterPasswd, UNO_QUERY );
981 [ # # ][ # # ]: 0 : if ( xMasterPasswd2.is() && xMasterPasswd2->isDefaultMasterPasswordUsed() )
[ # # ][ # # ]
[ # # ]
982 [ # # ]: 0 : maMasterPasswordCB.Check( sal_False );
983 : : else
984 : : {
985 [ # # ]: 0 : maMasterPasswordPB.Enable( sal_True );
986 [ # # ]: 0 : maMasterPasswordCB.Check( sal_True );
987 [ # # ]: 0 : maMasterPasswordFI.Enable( sal_True );
988 : 0 : }
989 : 0 : }
990 : : }
991 [ # # # # ]: 0 : catch (const Exception&)
992 : : {
993 [ # # ]: 0 : maSavePasswordsCB.Enable( sal_False );
994 : : }
995 : :
996 : : #ifndef UNX
997 : : m_aCertPathFL.Hide();
998 : : m_aCertPathFI.Hide();
999 : : m_aCertPathPB.Hide();
1000 : : #endif
1001 : :
1002 : 0 : }
1003 : :
1004 : 0 : SfxTabPage* SvxSecurityTabPage::Create(Window* pParent, const SfxItemSet& rAttrSet )
1005 : : {
1006 [ # # ]: 0 : return new SvxSecurityTabPage(pParent, rAttrSet);
1007 : : }
1008 : :
1009 : 0 : void SvxSecurityTabPage::ActivatePage( const SfxItemSet& )
1010 : : {
1011 : 0 : }
1012 : :
1013 : 0 : int SvxSecurityTabPage::DeactivatePage( SfxItemSet* _pSet )
1014 : : {
1015 [ # # ]: 0 : if( _pSet )
1016 : 0 : FillItemSet( *_pSet );
1017 : 0 : return LEAVE_PAGE;
1018 : : }
1019 : :
1020 : : namespace
1021 : : {
1022 : 0 : bool CheckAndSave( SvtSecurityOptions& _rOpt, SvtSecurityOptions::EOption _eOpt, const bool _bIsChecked, bool& _rModfied )
1023 : : {
1024 : 0 : bool bModified = false;
1025 [ # # ]: 0 : if ( _rOpt.IsOptionEnabled( _eOpt ) )
1026 : : {
1027 : 0 : bModified = _rOpt.IsOptionSet( _eOpt ) != _bIsChecked;
1028 [ # # ]: 0 : if ( bModified )
1029 : : {
1030 : 0 : _rOpt.SetOption( _eOpt, _bIsChecked );
1031 : 0 : _rModfied = true;
1032 : : }
1033 : : }
1034 : :
1035 : 0 : return bModified;
1036 : : }
1037 : : }
1038 : :
1039 : 0 : sal_Bool SvxSecurityTabPage::FillItemSet( SfxItemSet& )
1040 : : {
1041 : 0 : bool bModified = false;
1042 : :
1043 [ # # ]: 0 : if ( mpSecOptDlg )
1044 : : {
1045 [ # # ][ # # ]: 0 : CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SAVEORSEND, mpSecOptDlg->IsSaveOrSendDocsChecked(), bModified );
1046 [ # # ][ # # ]: 0 : CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_SIGNING, mpSecOptDlg->IsSignDocsChecked(), bModified );
1047 [ # # ][ # # ]: 0 : CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_PRINT, mpSecOptDlg->IsPrintDocsChecked(), bModified );
1048 [ # # ][ # # ]: 0 : CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_CREATEPDF, mpSecOptDlg->IsCreatePdfChecked(), bModified );
1049 [ # # ][ # # ]: 0 : CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO, mpSecOptDlg->IsRemovePersInfoChecked(), bModified );
1050 [ # # ][ # # ]: 0 : CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD, mpSecOptDlg->IsRecommPasswdChecked(), bModified );
1051 [ # # ][ # # ]: 0 : CheckAndSave( *mpSecOptions, SvtSecurityOptions::E_CTRLCLICK_HYPERLINK, mpSecOptDlg->IsCtrlHyperlinkChecked(), bModified );
1052 : : }
1053 : :
1054 : 0 : return bModified;
1055 : : }
1056 : :
1057 : : /*--------------------------------------------------------------------*/
1058 : :
1059 : 0 : void SvxSecurityTabPage::Reset( const SfxItemSet& )
1060 : : {
1061 : 0 : }
1062 : :
1063 : 0 : MozPluginTabPage::MozPluginTabPage(Window* pParent, const SfxItemSet& rSet)
1064 : 0 : : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_INET_MOZPLUGIN ), rSet ),
1065 [ # # ]: 0 : aMSWordGB ( this, CUI_RES( GB_MOZPLUGIN ) ),
1066 [ # # ][ # # ]: 0 : aWBasicCodeCB ( this, CUI_RES( CB_MOZPLUGIN_CODE ) )
[ # # ][ # # ]
1067 : : {
1068 [ # # ]: 0 : FreeResource();
1069 : 0 : }
1070 : :
1071 [ # # ][ # # ]: 0 : MozPluginTabPage::~MozPluginTabPage()
1072 : : {
1073 [ # # ]: 0 : }
1074 : :
1075 : 0 : SfxTabPage* MozPluginTabPage::Create( Window* pParent,
1076 : : const SfxItemSet& rAttrSet )
1077 : : {
1078 [ # # ]: 0 : return new MozPluginTabPage( pParent, rAttrSet );
1079 : : }
1080 : 0 : sal_Bool MozPluginTabPage::FillItemSet( SfxItemSet& )
1081 : : {
1082 : 0 : sal_Bool hasInstall = isInstalled();
1083 : 0 : sal_Bool hasChecked = aWBasicCodeCB.IsChecked();
1084 [ # # ][ # # ]: 0 : if(hasInstall && (!hasChecked)){
1085 : : //try to uninstall
1086 : 0 : uninstallPlugin();
1087 : : }
1088 [ # # ][ # # ]: 0 : else if((!hasInstall) && hasChecked){
1089 : : //try to install
1090 : 0 : installPlugin();
1091 : : }
1092 : : else{
1093 : : // do nothing
1094 : : }
1095 : 0 : return sal_True;
1096 : : }
1097 : 0 : void MozPluginTabPage::Reset( const SfxItemSet& )
1098 : : {
1099 : 0 : aWBasicCodeCB.Check( isInstalled());
1100 : 0 : aWBasicCodeCB.SaveValue();
1101 : 0 : }
1102 : :
1103 : : #ifdef WNT
1104 : : extern "C" {
1105 : : int lc_isInstalled(const char* realFilePath);
1106 : : int lc_installPlugin(const char* realFilePath);
1107 : : int lc_uninstallPlugin(const char* realFilePath);
1108 : : }
1109 : : #endif
1110 : :
1111 : : #define NPP_PATH_MAX 2048
1112 : 0 : inline bool getDllURL(rtl::OString * path)
1113 : : {
1114 : : OSL_ASSERT(path != NULL);
1115 : 0 : ::rtl::OUString dirPath/*dllPath, */;
1116 [ # # ][ # # ]: 0 : if (osl_getExecutableFile(&dirPath.pData) != osl_Process_E_None) {
1117 : 0 : return false;
1118 : : }
1119 : 0 : dirPath = dirPath.copy(0, dirPath.lastIndexOf('/'));
1120 : 0 : ::rtl::OUString sysDirPath;
1121 [ # # ]: 0 : osl::FileBase::getSystemPathFromFileURL(dirPath, sysDirPath);
1122 [ # # ]: 0 : *path = OUStringToOString(sysDirPath, RTL_TEXTENCODING_ASCII_US);
1123 : 0 : return true;
1124 : : }
1125 : :
1126 : 0 : sal_Bool MozPluginTabPage::isInstalled()
1127 : : {
1128 : : #ifdef UNIX
1129 : : // get the real file referred by .so lnk file
1130 : 0 : char lnkFilePath[NPP_PATH_MAX] = {0};
1131 : 0 : char lnkReferFilePath[NPP_PATH_MAX] = {0};
1132 [ # # ]: 0 : char* pHome = getpwuid(getuid())->pw_dir;
1133 : 0 : strcat(lnkFilePath, pHome);
1134 : 0 : strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1135 : :
1136 : : struct stat sBuf;
1137 [ # # ]: 0 : if (0 > lstat(lnkFilePath, &sBuf))
1138 : 0 : return false;
1139 [ # # ]: 0 : if (!S_ISLNK(sBuf.st_mode))
1140 : 0 : return false;
1141 [ # # ]: 0 : if (0 >= readlink(lnkFilePath, lnkReferFilePath, NPP_PATH_MAX))
1142 : 0 : return false;
1143 : : // If the link is relative, then we regard it as non-standard
1144 [ # # ]: 0 : if (lnkReferFilePath[0] != '/')
1145 : 0 : return false;
1146 : :
1147 : : // get the real file path
1148 : 0 : char realFilePath[NPP_PATH_MAX] = {0};
1149 : 0 : ::rtl::OString tempString;
1150 [ # # ][ # # ]: 0 : if (!getDllURL(&tempString)) {
1151 : 0 : return false;
1152 : : }
1153 : 0 : strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1154 : 0 : strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
1155 : :
1156 [ # # ]: 0 : if (0 != strcmp(lnkReferFilePath, realFilePath))
1157 : 0 : return false;
1158 : 0 : return true;
1159 : : #endif
1160 : : #ifdef WNT
1161 : : // get the value from registry
1162 : : sal_Bool ret = true;
1163 : : ::rtl::OString tempString;
1164 : : char realFilePath[NPP_PATH_MAX] = {0};
1165 : : if (!getDllURL(&tempString)){
1166 : : return false;
1167 : : }
1168 : : strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1169 : : if(! lc_isInstalled(realFilePath))
1170 : : ret =true;
1171 : : else
1172 : : ret = false;
1173 : : return ret;
1174 : : #endif
1175 : : }
1176 : :
1177 : 0 : sal_Bool MozPluginTabPage::installPlugin()
1178 : : {
1179 : : #ifdef UNIX
1180 : : // get the real file referred by .so lnk file
1181 : 0 : char lnkFilePath[NPP_PATH_MAX] = {0};
1182 [ # # ]: 0 : char* pHome = getpwuid(getuid())->pw_dir;
1183 : 0 : strcat(lnkFilePath, pHome);
1184 : 0 : strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1185 : 0 : remove(lnkFilePath);
1186 : :
1187 : : // create the dirs if necessary
1188 : : struct stat buf;
1189 : 0 : char tmpDir[NPP_PATH_MAX] = {0};
1190 : 0 : sprintf(tmpDir, "%s/.mozilla", pHome);
1191 [ # # ]: 0 : if (0 > stat(lnkFilePath, &buf))
1192 : : {
1193 : 0 : mkdir(tmpDir, 0755);
1194 : 0 : strcat(tmpDir, "/plugins");
1195 : 0 : mkdir(tmpDir, 0755);
1196 : : }
1197 : :
1198 : : // get the real file path
1199 : 0 : char realFilePath[NPP_PATH_MAX] = {0};
1200 : 0 : ::rtl::OString tempString;
1201 [ # # ][ # # ]: 0 : if (!getDllURL(&tempString)) {
1202 : 0 : return false;
1203 : : }
1204 : 0 : strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1205 : 0 : strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION);
1206 : :
1207 : : // create the link
1208 [ # # ]: 0 : if (0 != symlink(realFilePath, lnkFilePath))
1209 : 0 : return false;
1210 : 0 : return true;
1211 : : #endif
1212 : : #ifdef WNT
1213 : : ::rtl::OString tempString;
1214 : : char realFilePath[NPP_PATH_MAX] = {0};
1215 : : if (!getDllURL(&tempString)) {
1216 : : return false;
1217 : : }
1218 : : strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1219 : : if( !lc_installPlugin(realFilePath))
1220 : : return true;
1221 : : else
1222 : : return false;
1223 : : #endif
1224 : : }
1225 : :
1226 : 0 : sal_Bool MozPluginTabPage::uninstallPlugin()
1227 : : {
1228 : : #ifdef UNIX
1229 : : // get the real file referred by .so lnk file
1230 : 0 : char lnkFilePath[NPP_PATH_MAX] = {0};
1231 [ # # ]: 0 : char* pHome = getpwuid(getuid())->pw_dir;
1232 : 0 : strcat(lnkFilePath, pHome);
1233 : 0 : strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION);
1234 : :
1235 [ # # ]: 0 : if(0 > remove(lnkFilePath))
1236 : 0 : return false;
1237 : 0 : return true;
1238 : : #endif
1239 : : #ifdef WNT
1240 : : ::rtl::OString tempString;
1241 : : char realFilePath[NPP_PATH_MAX] = {0};
1242 : : if (!getDllURL(&tempString)) {
1243 : : return false;
1244 : : }
1245 : : strncpy(realFilePath, tempString.getStr(), NPP_PATH_MAX);
1246 : : if(!lc_uninstallPlugin(realFilePath))
1247 : : return true;
1248 : : else
1249 : : return false;
1250 : : #endif
1251 : : }
1252 : :
1253 : : /* -------------------------------------------------------------------------*/
1254 : :
1255 : : class MailerProgramCfg_Impl : public utl::ConfigItem
1256 : : {
1257 : : friend class SvxEMailTabPage;
1258 : : // variables
1259 : : OUString sProgram;
1260 : : // readonly states
1261 : : sal_Bool bROProgram;
1262 : :
1263 : : const Sequence<OUString> GetPropertyNames();
1264 : : public:
1265 : : MailerProgramCfg_Impl();
1266 : : virtual ~MailerProgramCfg_Impl();
1267 : :
1268 : : virtual void Commit();
1269 : : virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames);
1270 : : };
1271 : :
1272 : : /* -------------------------------------------------------------------------*/
1273 : :
1274 : 0 : MailerProgramCfg_Impl::MailerProgramCfg_Impl() :
1275 : : utl::ConfigItem(C2U("Office.Common/ExternalMailer")),
1276 [ # # ]: 0 : bROProgram(sal_False)
1277 : : {
1278 [ # # ]: 0 : const Sequence< OUString > aNames = GetPropertyNames();
1279 [ # # ]: 0 : const Sequence< Any > aValues = GetProperties(aNames);
1280 [ # # ]: 0 : const Sequence< sal_Bool > aROStates = GetReadOnlyStates(aNames);
1281 : 0 : const Any* pValues = aValues.getConstArray();
1282 : 0 : const sal_Bool* pROStates = aROStates.getConstArray();
1283 [ # # ]: 0 : for(sal_Int32 nProp = 0; nProp < aValues.getLength(); nProp++)
1284 : : {
1285 [ # # ]: 0 : if(pValues[nProp].hasValue())
1286 : : {
1287 [ # # ]: 0 : switch(nProp)
1288 : : {
1289 : : case 0 :
1290 : : {
1291 : 0 : pValues[nProp] >>= sProgram;
1292 : 0 : bROProgram = pROStates[nProp];
1293 : : }
1294 : 0 : break;
1295 : : }
1296 : : }
1297 [ # # ][ # # ]: 0 : }
[ # # ]
1298 : 0 : }
1299 : :
1300 : : /* -------------------------------------------------------------------------*/
1301 : :
1302 : 0 : MailerProgramCfg_Impl::~MailerProgramCfg_Impl()
1303 : : {
1304 [ # # ]: 0 : }
1305 : :
1306 : : /* -------------------------------------------------------------------------*/
1307 : :
1308 : 0 : const Sequence<OUString> MailerProgramCfg_Impl::GetPropertyNames()
1309 : : {
1310 : 0 : Sequence<OUString> aRet(1);
1311 [ # # ]: 0 : OUString* pRet = aRet.getArray();
1312 : 0 : pRet[0] = C2U("Program");
1313 : 0 : return aRet;
1314 : : }
1315 : :
1316 : : /* -------------------------------------------------------------------------*/
1317 : :
1318 : 0 : void MailerProgramCfg_Impl::Commit()
1319 : : {
1320 [ # # ]: 0 : const Sequence< OUString > aOrgNames = GetPropertyNames();
1321 : 0 : sal_Int32 nOrgCount = aOrgNames.getLength();
1322 : :
1323 [ # # ]: 0 : Sequence< OUString > aNames(nOrgCount);
1324 [ # # ]: 0 : Sequence< Any > aValues(nOrgCount);
1325 : 0 : sal_Int32 nRealCount = 0;
1326 : :
1327 [ # # ]: 0 : for(int nProp = 0; nProp < nOrgCount; nProp++)
1328 : : {
1329 [ # # ]: 0 : switch(nProp)
1330 : : {
1331 : : case 0:
1332 : : {
1333 [ # # ]: 0 : if (!bROProgram)
1334 : : {
1335 [ # # ]: 0 : aNames[nRealCount] = aOrgNames[nProp];
1336 [ # # ][ # # ]: 0 : aValues[nRealCount] <<= sProgram;
1337 : 0 : ++nRealCount;
1338 : : }
1339 : : }
1340 : 0 : break;
1341 : : }
1342 : : }
1343 : :
1344 [ # # ]: 0 : aNames.realloc(nRealCount);
1345 [ # # ]: 0 : aValues.realloc(nRealCount);
1346 [ # # ][ # # ]: 0 : PutProperties(aNames, aValues);
[ # # ][ # # ]
1347 : 0 : }
1348 : :
1349 : 0 : void MailerProgramCfg_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
1350 : : {
1351 : 0 : }
1352 : :
1353 : : /* -------------------------------------------------------------------------*/
1354 : :
1355 : 0 : struct SvxEMailTabPage_Impl
1356 : : {
1357 : : MailerProgramCfg_Impl aMailConfig;
1358 : : };
1359 : :
1360 : 0 : SvxEMailTabPage::SvxEMailTabPage(Window* pParent, const SfxItemSet& rSet) :
1361 : 0 : SfxTabPage(pParent, CUI_RES( RID_SVXPAGE_INET_MAIL ), rSet),
1362 [ # # ]: 0 : aMailFL(this, CUI_RES(FL_MAIL )),
1363 [ # # ]: 0 : aMailerURLFI(this, CUI_RES(FI_MAILERURL )),
1364 [ # # ]: 0 : aMailerURLFT(this, CUI_RES(FT_MAILERURL )),
1365 [ # # ]: 0 : aMailerURLED(this, CUI_RES(ED_MAILERURL )),
1366 [ # # ]: 0 : aMailerURLPB(this, CUI_RES(PB_MAILERURL )),
1367 [ # # ]: 0 : m_sDefaultFilterName( CUI_RES(STR_DEFAULT_FILENAME )),
1368 [ # # ][ # # ]: 0 : pImpl(new SvxEMailTabPage_Impl)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1369 : : {
1370 [ # # ]: 0 : FreeResource();
1371 : :
1372 [ # # ]: 0 : aMailerURLPB.SetClickHdl( LINK( this, SvxEMailTabPage, FileDialogHdl_Impl ) );
1373 : :
1374 : : // FixedText not wide enough?
1375 [ # # ][ # # ]: 0 : long nTxtW = aMailerURLFT.GetCtrlTextWidth( aMailerURLFT.GetText() );
[ # # ]
1376 [ # # ]: 0 : long nCtrlW = aMailerURLFT.GetSizePixel().Width();
1377 [ # # ]: 0 : if ( nTxtW >= nCtrlW )
1378 : : {
1379 : 0 : long nDelta = Max( (long)10, nTxtW - nCtrlW );
1380 : : // so FixedText wider
1381 [ # # ]: 0 : Size aNewSz = aMailerURLFT.GetSizePixel();
1382 : 0 : aNewSz.Width() += nDelta;
1383 [ # # ]: 0 : aMailerURLFT.SetSizePixel( aNewSz );
1384 : : // and Edit smaller
1385 [ # # ]: 0 : aNewSz = aMailerURLED.GetSizePixel();
1386 : 0 : aNewSz.Width() -= nDelta;
1387 [ # # ]: 0 : Point aNewPt = aMailerURLED.GetPosPixel();
1388 : 0 : aNewPt.X() += nDelta;
1389 [ # # ]: 0 : aMailerURLED.SetPosSizePixel( aNewPt, aNewSz );
1390 : : }
1391 : 0 : }
1392 : :
1393 : : /* -------------------------------------------------------------------------*/
1394 : :
1395 [ # # ][ # # ]: 0 : SvxEMailTabPage::~SvxEMailTabPage()
[ # # ][ # # ]
[ # # ][ # # ]
1396 : : {
1397 [ # # ][ # # ]: 0 : delete pImpl;
1398 [ # # ]: 0 : }
1399 : :
1400 : : /* -------------------------------------------------------------------------*/
1401 : :
1402 : 0 : SfxTabPage* SvxEMailTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1403 : : {
1404 [ # # ]: 0 : return new SvxEMailTabPage(pParent, rAttrSet);
1405 : : }
1406 : :
1407 : : /* -------------------------------------------------------------------------*/
1408 : :
1409 : 0 : sal_Bool SvxEMailTabPage::FillItemSet( SfxItemSet& )
1410 : : {
1411 : 0 : sal_Bool bMailModified = sal_False;
1412 [ # # ][ # # ]: 0 : if(!pImpl->aMailConfig.bROProgram && aMailerURLED.GetSavedValue() != aMailerURLED.GetText())
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1413 : : {
1414 [ # # ]: 0 : pImpl->aMailConfig.sProgram = aMailerURLED.GetText();
1415 : 0 : bMailModified = sal_True;
1416 : : }
1417 [ # # ]: 0 : if ( bMailModified )
1418 : 0 : pImpl->aMailConfig.Commit();
1419 : :
1420 : 0 : return sal_False;
1421 : : }
1422 : :
1423 : : /* -------------------------------------------------------------------------*/
1424 : :
1425 : 0 : void SvxEMailTabPage::Reset( const SfxItemSet& )
1426 : : {
1427 : 0 : aMailerURLED.Enable(sal_True );
1428 : 0 : aMailerURLPB.Enable(sal_True );
1429 : :
1430 [ # # ]: 0 : if(pImpl->aMailConfig.bROProgram)
1431 : 0 : aMailerURLFI.Show();
1432 : :
1433 [ # # ]: 0 : aMailerURLED.SetText(pImpl->aMailConfig.sProgram);
1434 : 0 : aMailerURLED.SaveValue();
1435 : 0 : aMailerURLED.Enable(!pImpl->aMailConfig.bROProgram);
1436 : 0 : aMailerURLPB.Enable(!pImpl->aMailConfig.bROProgram);
1437 : 0 : aMailerURLFT.Enable(!pImpl->aMailConfig.bROProgram);
1438 : :
1439 : 0 : aMailFL.Enable(aMailerURLFT.IsEnabled() ||
1440 : 0 : aMailerURLED.IsEnabled() ||
1441 [ # # ]: 0 : aMailerURLPB.IsEnabled());
[ # # # # ]
1442 : 0 : }
1443 : :
1444 : : /* -------------------------------------------------------------------------*/
1445 : :
1446 : 0 : IMPL_LINK( SvxEMailTabPage, FileDialogHdl_Impl, PushButton*, pButton )
1447 : : {
1448 [ # # ][ # # ]: 0 : if ( &aMailerURLPB == pButton && !pImpl->aMailConfig.bROProgram )
1449 : : {
1450 : : FileDialogHelper aHelper(
1451 : : com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
1452 [ # # ]: 0 : 0 );
1453 [ # # ][ # # ]: 0 : rtl::OUString sPath = aMailerURLED.GetText();
[ # # ]
1454 [ # # ]: 0 : if ( sPath.isEmpty() )
1455 [ # # ]: 0 : sPath = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/usr/bin"));
1456 : :
1457 : 0 : rtl::OUString sUrl;
1458 [ # # ]: 0 : ::utl::LocalFileHelper::ConvertPhysicalNameToURL(sPath, sUrl);
1459 [ # # ][ # # ]: 0 : aHelper.SetDisplayDirectory(sUrl);
[ # # ]
1460 [ # # ][ # # ]: 0 : aHelper.AddFilter( m_sDefaultFilterName, rtl::OUString("*"));
[ # # ]
1461 : :
1462 [ # # ][ # # ]: 0 : if ( ERRCODE_NONE == aHelper.Execute() )
1463 : : {
1464 [ # # ][ # # ]: 0 : sUrl = aHelper.GetPath();
[ # # ]
1465 [ # # ]: 0 : ::utl::LocalFileHelper::ConvertURLToPhysicalName(sUrl, sPath);
1466 [ # # ][ # # ]: 0 : aMailerURLED.SetText(sPath);
[ # # ]
1467 [ # # ]: 0 : }
1468 : : }
1469 : 0 : return 0;
1470 : : }
1471 : :
1472 : : // -----------------------------------------------------------------------------
1473 : :
1474 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|