LibreOffice Module cui (master) 1
optinet2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <string_view>
23
24#include <officecfg/Inet.hxx>
25#include <officecfg/Office/Common.hxx>
26#include <officecfg/Office/Security.hxx>
27#include <vcl/weld.hxx>
29#include <vcl/svapp.hxx>
31#include <com/sun/star/uno/Sequence.hxx>
33
34#include <dialmgr.hxx>
35#include "optinet2.hxx"
36#include <strings.hrc>
37
38#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
39#include <com/sun/star/task/InteractionHandler.hpp>
40
41#include <sal/types.h>
42#include <rtl/ustring.hxx>
43#include <osl/file.hxx>
44#include <com/sun/star/configuration/theDefaultProvider.hpp>
45#include <com/sun/star/beans/NamedValue.hpp>
46#include <com/sun/star/beans/XPropertySet.hpp>
47#include <com/sun/star/beans/XPropertyState.hpp>
48#include <com/sun/star/util/XChangesBatch.hpp>
50#include <comphelper/string.hxx>
51
52#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
53#include <com/sun/star/task/PasswordContainer.hpp>
54#include <com/sun/star/task/XPasswordContainer2.hpp>
55#include "securityoptions.hxx"
56#include "webconninfo.hxx"
57#include "certpath.hxx"
58#include "tsaurls.hxx"
59
61
62using namespace ::com::sun::star;
63using namespace ::com::sun::star::uno;
64using namespace ::sfx2;
65
66namespace {
67
68bool isValidPort(OUString const & value) {
70 return false;
71 }
72 auto const n = value.toUInt64();
73 if (n > 65535) {
74 return false;
75 }
76 if (n != 0) {
77 return true;
78 }
79 // Overflow in OUString::toUInt64 returns 0, so need to check value contains only zeroes:
80 return std::u16string_view(value).find_first_not_of(u'0') == std::u16string_view::npos;
81}
82
83}
84
85IMPL_LINK(SvxProxyTabPage, PortChangedHdl, weld::Entry&, rEdit, void)
86{
87 if (!isValidPort(rEdit.get_text()))
88 {
89 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
90 VclMessageType::Warning, VclButtonsType::Ok,
91 CuiResId(RID_CUISTR_OPT_PROXYPORTS)));
92 xErrorBox->run();
93 }
94}
95
96constexpr OUStringLiteral g_aProxyModePN = u"ooInetProxyType";
97constexpr OUStringLiteral g_aHttpProxyPN = u"ooInetHTTPProxyName";
98constexpr OUStringLiteral g_aHttpPortPN = u"ooInetHTTPProxyPort";
99constexpr OUStringLiteral g_aHttpsProxyPN = u"ooInetHTTPSProxyName";
100constexpr OUStringLiteral g_aHttpsPortPN = u"ooInetHTTPSProxyPort";
101constexpr OUStringLiteral g_aFtpProxyPN = u"ooInetFTPProxyName";
102constexpr OUStringLiteral g_aFtpPortPN = u"ooInetFTPProxyPort";
103constexpr OUStringLiteral g_aNoProxyDescPN = u"ooInetNoProxy";
104
105IMPL_STATIC_LINK(SvxProxyTabPage, NumberOnlyTextFilterHdl, OUString&, rTest, bool)
106{
107 OUStringBuffer sAllowed;
108 for (sal_Int32 i = 0, nLen = rTest.getLength(); i < nLen; ++i)
109 {
110 if (rTest[i] >= '0' && rTest[i] <= '9')
111 sAllowed.append(rTest[i]);
112 }
113 rTest = sAllowed.makeStringAndClear();
114 return true;
115}
116
117IMPL_STATIC_LINK(SvxProxyTabPage, NoSpaceTextFilterHdl, OUString&, rTest, bool)
118{
119 rTest = rTest.replaceAll(" ", "");
120 return true;
121}
122
123/********************************************************************/
124/* */
125/* SvxProxyTabPage */
126/* */
127/********************************************************************/
129 : SfxTabPage(pPage, pController, "cui/ui/optproxypage.ui", "OptProxyPage", &rSet)
130 , m_xProxyModeLB(m_xBuilder->weld_combo_box("proxymode"))
131 , m_xHttpProxyFT(m_xBuilder->weld_label("httpft"))
132 , m_xHttpProxyED(m_xBuilder->weld_entry("http"))
133 , m_xHttpPortFT(m_xBuilder->weld_label("httpportft"))
134 , m_xHttpPortED(m_xBuilder->weld_entry("httpport"))
135 , m_xHttpsProxyFT(m_xBuilder->weld_label("httpsft"))
136 , m_xHttpsProxyED(m_xBuilder->weld_entry("https"))
137 , m_xHttpsPortFT(m_xBuilder->weld_label("httpsportft"))
138 , m_xHttpsPortED(m_xBuilder->weld_entry("httpsport"))
139 , m_xFtpProxyFT(m_xBuilder->weld_label("ftpft"))
140 , m_xFtpProxyED(m_xBuilder->weld_entry("ftp"))
141 , m_xFtpPortFT(m_xBuilder->weld_label("ftpportft"))
142 , m_xFtpPortED(m_xBuilder->weld_entry("ftpport"))
143 , m_xNoProxyForFT(m_xBuilder->weld_label("noproxyft"))
144 , m_xNoProxyForED(m_xBuilder->weld_entry("noproxy"))
145 , m_xNoProxyDescFT(m_xBuilder->weld_label("noproxydesc"))
146{
147 m_xHttpProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl));
148 m_xHttpPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl));
149 m_xHttpPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl));
150 m_xHttpsProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl));
151 m_xHttpsPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl));
152 m_xHttpsPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl));
153 m_xFtpProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl));
154 m_xFtpPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl));
155 m_xFtpPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl));
156
157 Link<weld::Widget&,void> aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl );
158 m_xHttpPortED->connect_focus_out( aLink );
159 m_xHttpsPortED->connect_focus_out( aLink );
160 m_xFtpPortED->connect_focus_out( aLink );
161
162 m_xProxyModeLB->connect_changed(LINK( this, SvxProxyTabPage, ProxyHdl_Impl ));
163
164 Reference< css::lang::XMultiServiceFactory >
165 xConfigurationProvider(
166 configuration::theDefaultProvider::get(
168
169 beans::NamedValue aProperty;
170 aProperty.Name = "nodepath";
171 aProperty.Value <<= OUString( "org.openoffice.Inet/Settings" );
172
173 Sequence< Any > aArgumentList{ Any(aProperty) };
174
175 m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments(
176 "com.sun.star.configuration.ConfigurationUpdateAccess",
177 aArgumentList );
178}
179
181{
182}
183
184std::unique_ptr<SfxTabPage> SvxProxyTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
185{
186 return std::make_unique<SvxProxyTabPage>(pPage, pController, *rAttrSet);
187}
188
190{
191 sal_Int32 nIntValue = 0;
192
193 std::optional<sal_Int32> x(officecfg::Inet::Settings::ooInetProxyType::get());
194 if (x)
195 {
196 nIntValue = *x;
197 m_xProxyModeLB->set_active(nIntValue);
198 }
199
200 m_xHttpProxyED->set_text( officecfg::Inet::Settings::ooInetHTTPProxyName::get() );
201 x = officecfg::Inet::Settings::ooInetHTTPProxyPort::get();
202 if (x)
203 {
204 nIntValue = *x;
205 m_xHttpPortED->set_text( OUString::number( nIntValue ));
206 }
207 else
208 m_xHttpPortED->set_text( "" );
209
210 m_xHttpsProxyED->set_text( officecfg::Inet::Settings::ooInetHTTPSProxyName::get() );
211 x = officecfg::Inet::Settings::ooInetHTTPSProxyPort::get();
212 if (x)
213 {
214 nIntValue = *x;
215 m_xHttpsPortED->set_text( OUString::number( nIntValue ));
216 }
217 else
218 m_xHttpsPortED->set_text( "" );
219
220 m_xFtpProxyED->set_text( officecfg::Inet::Settings::ooInetFTPProxyName::get() );
221 x = officecfg::Inet::Settings::ooInetFTPProxyPort::get();
222 if (x)
223 {
224 nIntValue = *x;
225 m_xFtpPortED->set_text( OUString::number( nIntValue ));
226 }
227 else
228 m_xFtpPortED->set_text( "" );
229
230 m_xNoProxyForED->set_text( officecfg::Inet::Settings::ooInetNoProxy::get() );
231}
232
234{
235 try
236 {
237 Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
238
239 sal_Int32 nIntValue = 0;
240 OUString aStringValue;
241
242 if( xPropertyState->getPropertyDefault(g_aHttpProxyPN) >>= aStringValue )
243 {
244 m_xHttpProxyED->set_text( aStringValue );
245 }
246
247 if( xPropertyState->getPropertyDefault(g_aHttpPortPN) >>= nIntValue )
248 {
249 m_xHttpPortED->set_text( OUString::number( nIntValue ));
250 }
251
252 if( xPropertyState->getPropertyDefault(g_aHttpsProxyPN) >>= aStringValue )
253 {
254 m_xHttpsProxyED->set_text( aStringValue );
255 }
256
257 if( xPropertyState->getPropertyDefault(g_aHttpsPortPN) >>= nIntValue )
258 {
259 m_xHttpsPortED->set_text( OUString::number( nIntValue ));
260 }
261
262 if( xPropertyState->getPropertyDefault(g_aFtpProxyPN) >>= aStringValue )
263 {
264 m_xFtpProxyED->set_text( aStringValue );
265 }
266
267 if( xPropertyState->getPropertyDefault(g_aFtpPortPN) >>= nIntValue )
268 {
269 m_xFtpPortED->set_text( OUString::number( nIntValue ));
270 }
271
272 if( xPropertyState->getPropertyDefault(g_aNoProxyDescPN) >>= aStringValue )
273 {
274 m_xNoProxyForED->set_text( aStringValue );
275 }
276 }
277 catch (const beans::UnknownPropertyException &)
278 {
279 TOOLS_WARN_EXCEPTION("cui.options", "" );
280 }
281 catch (const css::lang::WrappedTargetException &)
282 {
283 TOOLS_WARN_EXCEPTION("cui.options", "" );
284 }
285 catch (const RuntimeException &)
286 {
287 TOOLS_WARN_EXCEPTION("cui.options", "" );
288 }
289}
290
292{
293 try
294 {
295 Reference< beans::XPropertyState > xPropertyState(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
296
297 xPropertyState->setPropertyToDefault(g_aProxyModePN);
298 xPropertyState->setPropertyToDefault(g_aHttpProxyPN);
299 xPropertyState->setPropertyToDefault(g_aHttpPortPN);
300 xPropertyState->setPropertyToDefault(g_aHttpsProxyPN);
301 xPropertyState->setPropertyToDefault(g_aHttpsPortPN);
302 xPropertyState->setPropertyToDefault(g_aFtpProxyPN);
303 xPropertyState->setPropertyToDefault(g_aFtpPortPN);
304 xPropertyState->setPropertyToDefault(g_aNoProxyDescPN);
305
306 Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
307 xChangesBatch->commitChanges();
308 }
309 catch (const beans::UnknownPropertyException &)
310 {
311 TOOLS_WARN_EXCEPTION("cui.options", "" );
312 }
313 catch (const css::lang::WrappedTargetException &)
314 {
315 TOOLS_WARN_EXCEPTION("cui.options", "" );
316 }
317 catch (const RuntimeException &)
318 {
319 TOOLS_WARN_EXCEPTION("cui.options", "" );
320 }
321}
322
324{
326
327 m_xProxyModeLB->save_value();
328 m_xHttpProxyED->save_value();
329 m_xHttpPortED->save_value();
330 m_xHttpsProxyED->save_value();
331 m_xHttpsPortED->save_value();
332 m_xFtpProxyED->save_value();
333 m_xFtpPortED->save_value();
334 m_xNoProxyForED->save_value();
335
337}
338
340{
341 bool bModified = false;
342
343 try {
345
346 sal_Int32 nSelPos = m_xProxyModeLB->get_active();
347 if(m_xProxyModeLB->get_value_changed_from_saved())
348 {
349 if( nSelPos == 1 )
350 {
352 return true;
353 }
354
355 xPropertySet->setPropertyValue(g_aProxyModePN, Any(nSelPos));
356 bModified = true;
357 }
358
359 if(m_xHttpProxyED->get_value_changed_from_saved())
360 {
361 xPropertySet->setPropertyValue( g_aHttpProxyPN, Any(m_xHttpProxyED->get_text()));
362 bModified = true;
363 }
364
365 if ( m_xHttpPortED->get_value_changed_from_saved())
366 {
367 xPropertySet->setPropertyValue( g_aHttpPortPN, Any(m_xHttpPortED->get_text().toInt32()));
368 bModified = true;
369 }
370
371 if( m_xHttpsProxyED->get_value_changed_from_saved() )
372 {
373 xPropertySet->setPropertyValue( g_aHttpsProxyPN, Any(m_xHttpsProxyED->get_text()) );
374 bModified = true;
375 }
376
377 if ( m_xHttpsPortED->get_value_changed_from_saved() )
378 {
379 xPropertySet->setPropertyValue( g_aHttpsPortPN, Any(m_xHttpsPortED->get_text().toInt32()) );
380 bModified = true;
381 }
382
383 if( m_xFtpProxyED->get_value_changed_from_saved())
384 {
385 xPropertySet->setPropertyValue( g_aFtpProxyPN, Any(m_xFtpProxyED->get_text()) );
386 bModified = true;
387 }
388
389 if ( m_xFtpPortED->get_value_changed_from_saved() )
390 {
391 xPropertySet->setPropertyValue( g_aFtpPortPN, Any(m_xFtpPortED->get_text().toInt32()));
392 bModified = true;
393 }
394
395 if ( m_xNoProxyForED->get_value_changed_from_saved() )
396 {
397 xPropertySet->setPropertyValue( g_aNoProxyDescPN, Any( m_xNoProxyForED->get_text()));
398 bModified = true;
399 }
400
401 Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW);
402 xChangesBatch->commitChanges();
403 }
404 catch (const css::lang::IllegalArgumentException &) {
405 TOOLS_WARN_EXCEPTION("cui.options", "" );
406 }
407 catch (const beans::UnknownPropertyException &) {
408 TOOLS_WARN_EXCEPTION("cui.options", "" );
409 }
410 catch (const beans::PropertyVetoException &) {
411 TOOLS_WARN_EXCEPTION("cui.options", "" );
412 }
413 catch (const css::lang::WrappedTargetException &) {
414 TOOLS_WARN_EXCEPTION("cui.options", "" );
415 }
416 catch (const RuntimeException &) {
417 TOOLS_WARN_EXCEPTION("cui.options", "" );
418 }
419
420 return bModified;
421}
422
424{
425 m_xProxyModeLB->set_sensitive(!officecfg::Inet::Settings::ooInetNoProxy::isReadOnly());
426
427 const bool bManualConfig = m_xProxyModeLB->get_active() == 2;
428
429 const bool bHTTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyName::isReadOnly();
430 const bool bHTTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyPort::isReadOnly();
431 m_xHttpProxyFT->set_sensitive(bHTTPProxyNameEnabled);
432 m_xHttpProxyED->set_sensitive(bHTTPProxyNameEnabled);
433 m_xHttpPortFT->set_sensitive(bHTTPProxyPortEnabled);
434 m_xHttpPortED->set_sensitive(bHTTPProxyPortEnabled);
435
436 const bool bHTTPSProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyName::isReadOnly();
437 const bool bHTTPSProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyPort::isReadOnly();
438 m_xHttpsProxyFT->set_sensitive(bHTTPSProxyNameEnabled);
439 m_xHttpsProxyED->set_sensitive(bHTTPSProxyNameEnabled);
440 m_xHttpsPortFT->set_sensitive(bHTTPSProxyPortEnabled);
441 m_xHttpsPortED->set_sensitive(bHTTPSProxyPortEnabled);
442
443 const bool bFTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyName::isReadOnly();
444 const bool bFTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyPort::isReadOnly();
445 m_xFtpProxyFT->set_sensitive(bFTPProxyNameEnabled);
446 m_xFtpProxyED->set_sensitive(bFTPProxyNameEnabled);
447 m_xFtpPortFT->set_sensitive(bFTPProxyPortEnabled);
448 m_xFtpPortED->set_sensitive(bFTPProxyPortEnabled);
449
450 const bool bInetNoProxyEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetNoProxy::isReadOnly();
451 m_xNoProxyForFT->set_sensitive(bInetNoProxyEnabled);
452 m_xNoProxyForED->set_sensitive(bInetNoProxyEnabled);
453 m_xNoProxyDescFT->set_sensitive(bInetNoProxyEnabled);
454}
455
456IMPL_LINK(SvxProxyTabPage, ProxyHdl_Impl, weld::ComboBox&, rBox, void)
457{
458 sal_Int32 nPos = rBox.get_active();
459
460 // Restore original system values
461 if( nPos == 1 )
462 {
463 ReadConfigDefaults_Impl();
464 }
465
466 EnableControls_Impl();
467}
468
469IMPL_STATIC_LINK(SvxProxyTabPage, LoseFocusHdl_Impl, weld::Widget&, rControl, void)
470{
471 weld::Entry* pEdit = dynamic_cast<weld::Entry*>(&rControl);
472 if (pEdit && !isValidPort(pEdit->get_text()))
473 pEdit->set_text(OUString('0'));
474}
475
476/********************************************************************/
477/* */
478/* SvxSecurityTabPage */
479/* */
480/********************************************************************/
482 : SfxTabPage(pPage, pController, "cui/ui/optsecuritypage.ui", "OptSecurityPage", &rSet)
483 , m_xSecurityOptionsPB(m_xBuilder->weld_button("options"))
484 , m_xSavePasswordsCB(m_xBuilder->weld_check_button("savepassword"))
485 , m_xShowConnectionsPB(m_xBuilder->weld_button("connections"))
486 , m_xMasterPasswordCB(m_xBuilder->weld_check_button("usemasterpassword"))
487 , m_xMasterPasswordFT(m_xBuilder->weld_label("masterpasswordtext"))
488 , m_xMasterPasswordPB(m_xBuilder->weld_button("masterpassword"))
489 , m_xMacroSecFrame(m_xBuilder->weld_container("macrosecurity"))
490 , m_xMacroSecPB(m_xBuilder->weld_button("macro"))
491 , m_xCertFrame(m_xBuilder->weld_container("certificatepath"))
492 , m_xCertPathPB(m_xBuilder->weld_button("cert"))
493 , m_xTSAURLsFrame(m_xBuilder->weld_container("tsaurls"))
494 , m_xTSAURLsPB(m_xBuilder->weld_button("tsas"))
495 , m_xNoPasswordSaveFT(m_xBuilder->weld_label("nopasswordsave"))
496{
497 //fdo#65595, we need height-for-width support here, but for now we can
498 //bodge it
499 Size aPrefSize(m_xSavePasswordsCB->get_preferred_size());
500 int nMaxWidth = m_xSavePasswordsCB->get_approximate_digit_width() * 40;
501 if (aPrefSize.Width() > nMaxWidth)
502 {
503 m_xSavePasswordsCB->set_label_wrap(true);
504 m_xSavePasswordsCB->set_size_request(nMaxWidth, -1);
505 }
506
508
509 InitControls();
510
511 m_xSecurityOptionsPB->connect_clicked( LINK( this, SvxSecurityTabPage, SecurityOptionsHdl ) );
512 m_xSavePasswordsCB->connect_toggled( LINK( this, SvxSecurityTabPage, SavePasswordHdl ) );
513 m_xMasterPasswordPB->connect_clicked( LINK( this, SvxSecurityTabPage, MasterPasswordHdl ) );
514 m_xMasterPasswordCB->connect_toggled( LINK( this, SvxSecurityTabPage, MasterPasswordCBHdl ) );
515 m_xShowConnectionsPB->connect_clicked( LINK( this, SvxSecurityTabPage, ShowPasswordsHdl ) );
516 m_xMacroSecPB->connect_clicked( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) );
517 m_xCertPathPB->connect_clicked( LINK( this, SvxSecurityTabPage, CertPathPBHdl ) );
518 m_xTSAURLsPB->connect_clicked( LINK( this, SvxSecurityTabPage, TSAURLsPBHdl ) );
519
521}
522
524{
525}
526
528{
529 if (!m_xSecOptDlg)
530 m_xSecOptDlg.reset(new svx::SecurityOptionsDialog(GetFrameWeld()));
531 m_xSecOptDlg->run();
532}
533
535{
536 try
537 {
538 Reference< task::XPasswordContainer2 > xMasterPasswd(
539 task::PasswordContainer::create(comphelper::getProcessComponentContext()));
540
541 if ( m_xSavePasswordsCB->get_active() )
542 {
543 bool bOldValue = xMasterPasswd->allowPersistentStoring( true );
544 xMasterPasswd->removeMasterPassword();
545
546 uno::Reference<task::XInteractionHandler> xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(),
547 GetDialogController()->getDialog()->GetXWindow()));
548
549 if ( xMasterPasswd->changeMasterPassword(xTmpHandler) )
550 {
551 m_xMasterPasswordPB->set_sensitive(true);
552 m_xMasterPasswordCB->set_active(true);
553 m_xMasterPasswordCB->set_sensitive(true);
554 m_xMasterPasswordFT->set_sensitive(true);
555 m_xShowConnectionsPB->set_sensitive(true);
556 }
557 else
558 {
559 xMasterPasswd->allowPersistentStoring( bOldValue );
560 m_xSavePasswordsCB->set_active( false );
561 }
562 }
563 else
564 {
565 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
566 VclMessageType::Question, VclButtonsType::YesNo,
567 m_sPasswordStoringDeactivateStr));
568 xQueryBox->set_default_response(RET_NO);
569
570 sal_uInt16 nRet = xQueryBox->run();
571
572 if( RET_YES == nRet )
573 {
574 xMasterPasswd->allowPersistentStoring( false );
575 m_xMasterPasswordCB->set_active(true);
576 m_xMasterPasswordPB->set_sensitive( false );
577 m_xMasterPasswordCB->set_sensitive( false );
578 m_xMasterPasswordFT->set_sensitive( false );
579 m_xShowConnectionsPB->set_sensitive( false );
580 }
581 else
582 {
583 m_xSavePasswordsCB->set_active(true);
584 m_xMasterPasswordPB->set_sensitive(true);
585 m_xShowConnectionsPB->set_sensitive(true);
586 }
587 }
588 }
589 catch (const Exception&)
590 {
591 m_xSavePasswordsCB->set_active( !m_xSavePasswordsCB->get_active() );
592 }
593}
594
596{
597 try
598 {
599 Reference< task::XPasswordContainer2 > xMasterPasswd(
600 task::PasswordContainer::create(comphelper::getProcessComponentContext()));
601
602 if ( xMasterPasswd->isPersistentStoringAllowed() )
603 {
604 uno::Reference<task::XInteractionHandler> xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(),
605 GetDialogController()->getDialog()->GetXWindow()));
606 xMasterPasswd->changeMasterPassword(xTmpHandler);
607 }
608 }
609 catch (const Exception&)
610 {}
611}
612
614{
615 try
616 {
617 Reference< task::XPasswordContainer2 > xMasterPasswd(
618 task::PasswordContainer::create(comphelper::getProcessComponentContext()));
619
620 uno::Reference<task::XInteractionHandler> xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(),
621 GetDialogController()->getDialog()->GetXWindow()));
622
623 if ( m_xMasterPasswordCB->get_active() )
624 {
625 if (xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->changeMasterPassword(xTmpHandler))
626 {
627 m_xMasterPasswordPB->set_sensitive(true);
628 m_xMasterPasswordFT->set_sensitive(true);
629 }
630 else
631 {
632 m_xMasterPasswordCB->set_active( false );
633 m_xMasterPasswordPB->set_sensitive(true);
634 m_xMasterPasswordFT->set_sensitive(true);
635 }
636 }
637 else
638 {
639 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->useDefaultMasterPassword(xTmpHandler) )
640 {
641 m_xMasterPasswordPB->set_sensitive( false );
642 m_xMasterPasswordFT->set_sensitive( false );
643 }
644 else
645 {
646 m_xMasterPasswordCB->set_active(true);
647 m_xMasterPasswordPB->set_sensitive(true);
648 m_xShowConnectionsPB->set_sensitive(true);
649 }
650 }
651 }
652 catch (const Exception&)
653 {
654 m_xSavePasswordsCB->set_active( !m_xSavePasswordsCB->get_active() );
655 }
656}
657
659{
660 try
661 {
662 Reference< task::XPasswordContainer2 > xMasterPasswd(
663 task::PasswordContainer::create(comphelper::getProcessComponentContext()));
664
665 uno::Reference<task::XInteractionHandler> xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(),
666 GetDialogController()->getDialog()->GetXWindow()));
667
668 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword(xTmpHandler) )
669 {
671 aDlg.run();
672 }
673 }
674 catch (const Exception&)
675 {}
676}
677
679{
680 if (!mpCertPathDlg)
681 mpCertPathDlg.reset(new CertPathDialog(GetFrameWeld()));
682 mpCertPathDlg->Init();
683
684 if (mpCertPathDlg->run() == RET_OK && !mpCertPathDlg->isActiveServicePath())
685 {
686 SolarMutexGuard aGuard;
688 GetDialogController()->response(RET_OK);
689 }
690}
691
693{
694 // Unlike the mpCertPathDlg, we *don't* keep the same dialog object around between
695 // invocations. Seems clearer to my little brain that way.
696 TSAURLsDialog aTSAURLsDlg(GetFrameWeld());
697 aTSAURLsDlg.run();
698}
699
701{
702 try
703 {
704 Reference< security::XDocumentDigitalSignatures > xD(
705 security::DocumentDigitalSignatures::createDefault(comphelper::getProcessComponentContext() ) );
706 xD->setParentWindow(GetDialogController()->getDialog()->GetXWindow());
707 xD->manageTrustedSources();
708 }
709 catch (const Exception&)
710 {
711 TOOLS_WARN_EXCEPTION( "cui.options", "");
712 }
713}
714
716{
717#ifndef UNX
718 m_xCertFrame->hide();
719#endif
720
721 m_xMasterPasswordPB->set_sensitive( false );
722 m_xMasterPasswordCB->set_sensitive( false );
723 m_xMasterPasswordCB->set_active(true);
724 m_xMasterPasswordFT->set_sensitive( false );
725 m_xShowConnectionsPB->set_sensitive( false );
726
727 // initialize the password saving checkbox
728 try
729 {
730 Reference< task::XPasswordContainer2 > xMasterPasswd(
731 task::PasswordContainer::create(comphelper::getProcessComponentContext()));
732
733 if ( xMasterPasswd->isPersistentStoringAllowed() )
734 {
735 m_xMasterPasswordCB->set_sensitive(true);
736 m_xShowConnectionsPB->set_sensitive(true);
737 m_xSavePasswordsCB->set_active(true);
738
739 if ( xMasterPasswd->isDefaultMasterPasswordUsed() )
740 m_xMasterPasswordCB->set_active( false );
741 else
742 {
743 m_xMasterPasswordPB->set_sensitive(true);
744 m_xMasterPasswordCB->set_active(true);
745 m_xMasterPasswordFT->set_sensitive(true);
746 }
747 }
748 }
749 catch (const Exception&)
750 {
751 m_xSavePasswordsCB->set_sensitive( false );
752 }
753}
754
755std::unique_ptr<SfxTabPage> SvxSecurityTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
756{
757 return std::make_unique<SvxSecurityTabPage>(pPage, pController, *rAttrSet);
758}
759
761{
762}
763
765{
766 if( _pSet )
767 FillItemSet( _pSet );
768 return DeactivateRC::LeavePage;
769}
770
771namespace
772{
773 bool CheckAndSave( SvtSecurityOptions::EOption _eOpt, const bool _bIsChecked, bool& _rModified )
774 {
775 bool bModified = false;
776 if ( !SvtSecurityOptions::IsReadOnly( _eOpt ) )
777 {
778 bModified = SvtSecurityOptions::IsOptionSet( _eOpt ) != _bIsChecked;
779 if ( bModified )
780 {
781 SvtSecurityOptions::SetOption( _eOpt, _bIsChecked );
782 _rModified = true;
783 }
784 }
785
786 return bModified;
787 }
788}
789
791{
792 bool bModified = false;
793
794 if (m_xSecOptDlg)
795 {
796 CheckAndSave( SvtSecurityOptions::EOption::DocWarnSaveOrSend, m_xSecOptDlg->IsSaveOrSendDocsChecked(), bModified );
797 CheckAndSave( SvtSecurityOptions::EOption::DocWarnSigning, m_xSecOptDlg->IsSignDocsChecked(), bModified );
798 CheckAndSave( SvtSecurityOptions::EOption::DocWarnPrint, m_xSecOptDlg->IsPrintDocsChecked(), bModified );
799 CheckAndSave( SvtSecurityOptions::EOption::DocWarnCreatePdf, m_xSecOptDlg->IsCreatePdfChecked(), bModified );
800 CheckAndSave( SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo, m_xSecOptDlg->IsRemovePersInfoChecked(), bModified );
801 CheckAndSave( SvtSecurityOptions::EOption::DocWarnRecommendPassword, m_xSecOptDlg->IsRecommPasswdChecked(), bModified );
802 CheckAndSave( SvtSecurityOptions::EOption::CtrlClickHyperlink, m_xSecOptDlg->IsCtrlHyperlinkChecked(), bModified );
803 CheckAndSave( SvtSecurityOptions::EOption::BlockUntrustedRefererLinks, m_xSecOptDlg->IsBlockUntrustedRefererLinksChecked(), bModified );
804 }
805
806 return bModified;
807}
808
809/*--------------------------------------------------------------------*/
810
812{
813}
814
816{
818 sProgram(officecfg::Office::Common::ExternalMailer::Program::get()),
820 officecfg::Office::Common::ExternalMailer::Program::isReadOnly()),
822 officecfg::Office::Security::HiddenContent::RemoveHiddenContent::get()),
824 officecfg::Office::Security::HiddenContent::RemoveHiddenContent::isReadOnly())
825 {}
826
827 OUString sProgram;
831};
832
834 : SfxTabPage( pPage, pController, "cui/ui/optemailpage.ui", "OptEmailPage", &rSet)
835 , pImpl(new SvxEMailTabPage_Impl)
836 , m_xMailContainer(m_xBuilder->weld_container("program"))
837 , m_xMailerURLFI(m_xBuilder->weld_image("lockemail"))
838 , m_xMailerURLED(m_xBuilder->weld_entry("url"))
839 , m_xMailerURLPB(m_xBuilder->weld_button("browse"))
840 , m_xSuppressHiddenContainer(m_xBuilder->weld_container("suppressHiddenCont"))
841 , m_xSuppressHiddenFI(m_xBuilder->weld_image("lockSuppressHidden"))
842 , m_xSuppressHidden(m_xBuilder->weld_check_button("suppressHidden"))
843 , m_xDefaultFilterFT(m_xBuilder->weld_label("browsetitle"))
844{
846 m_xMailerURLPB->connect_clicked( LINK( this, SvxEMailTabPage, FileDialogHdl_Impl ) );
847}
848
849/* -------------------------------------------------------------------------*/
850
852{
853}
854
855/* -------------------------------------------------------------------------*/
856
857std::unique_ptr<SfxTabPage> SvxEMailTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
858{
859 return std::make_unique<SvxEMailTabPage>(pPage, pController, *rAttrSet);
860}
861
862/* -------------------------------------------------------------------------*/
863
865{
866 std::shared_ptr<comphelper::ConfigurationChanges> batch(
868 if (!pImpl->bROProgram && m_xMailerURLED->get_value_changed_from_saved())
869 {
870 pImpl->sProgram = m_xMailerURLED->get_text();
871 officecfg::Office::Common::ExternalMailer::Program::set(
872 pImpl->sProgram, batch);
873 }
874 if (!pImpl->bROHideContent
875 && pImpl->bHideContent != m_xSuppressHidden->get_active())
876 {
877 pImpl->bHideContent = m_xSuppressHidden->get_active();
878 officecfg::Office::Security::HiddenContent::RemoveHiddenContent::set(
879 pImpl->bHideContent, batch);
880 }
881 batch->commit();
882 return false;
883}
884
885/* -------------------------------------------------------------------------*/
886
888{
889 m_xMailerURLED->set_sensitive(true);
890 m_xMailerURLPB->set_sensitive(true);
891
892 if (pImpl->bROProgram)
893 m_xMailerURLFI->show();
894
895 m_xMailerURLED->set_text(pImpl->sProgram);
896 m_xMailerURLED->save_value();
897
898 m_xMailContainer->set_sensitive(!pImpl->bROProgram);
899
900 if (pImpl->bROHideContent)
901 m_xSuppressHiddenFI->show();
902
903 m_xSuppressHidden->set_active(pImpl->bHideContent);
904
905 m_xSuppressHiddenContainer->set_sensitive(!pImpl->bROHideContent);
906}
907
908/* -------------------------------------------------------------------------*/
909
910IMPL_LINK_NOARG(SvxEMailTabPage, FileDialogHdl_Impl, weld::Button&, void)
911{
912 if (pImpl->bROProgram)
913 return;
914
915 FileDialogHelper aHelper(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, GetFrameWeld());
916 OUString sPath = m_xMailerURLED->get_text();
917 if ( sPath.isEmpty() )
918 sPath = "/usr/bin";
919
920 OUString sUrl;
921 osl::FileBase::getFileURLFromSystemPath(sPath, sUrl);
922 aHelper.SetDisplayDirectory(sUrl);
923 aHelper.AddFilter( m_sDefaultFilterName, "*");
924
925 if ( ERRCODE_NONE == aHelper.Execute() )
926 {
927 sUrl = aHelper.GetPath();
928 if (osl::FileBase::getSystemPathFromFileURL(sUrl, sPath)
929 != osl::FileBase::E_None)
930 {
931 sPath.clear();
932 }
933 m_xMailerURLED->set_text(sPath);
934 }
935}
936
937
938/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
constexpr tools::Long Width() const
std::unique_ptr< weld::Label > m_xDefaultFilterFT
Definition: optinet2.hxx:144
std::unique_ptr< weld::Button > m_xMailerURLPB
Definition: optinet2.hxx:140
SvxEMailTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optinet2.cxx:833
std::unique_ptr< weld::Container > m_xSuppressHiddenContainer
Definition: optinet2.hxx:141
std::unique_ptr< SvxEMailTabPage_Impl > pImpl
Definition: optinet2.hxx:135
virtual ~SvxEMailTabPage() override
Definition: optinet2.cxx:851
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optinet2.cxx:857
std::unique_ptr< weld::Container > m_xMailContainer
Definition: optinet2.hxx:137
std::unique_ptr< weld::CheckButton > m_xSuppressHidden
Definition: optinet2.hxx:143
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optinet2.cxx:864
virtual void Reset(const SfxItemSet *rSet) override
Definition: optinet2.cxx:887
OUString m_sDefaultFilterName
Definition: optinet2.hxx:133
std::unique_ptr< weld::Image > m_xSuppressHiddenFI
Definition: optinet2.hxx:142
std::unique_ptr< weld::Entry > m_xMailerURLED
Definition: optinet2.hxx:139
std::unique_ptr< weld::Image > m_xMailerURLFI
Definition: optinet2.hxx:138
void RestoreConfigDefaults_Impl()
Definition: optinet2.cxx:291
SvxProxyTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optinet2.cxx:128
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optinet2.cxx:184
std::unique_ptr< weld::Entry > m_xFtpProxyED
Definition: optinet2.hxx:46
std::unique_ptr< weld::Label > m_xHttpsProxyFT
Definition: optinet2.hxx:40
void ReadConfigDefaults_Impl()
Definition: optinet2.cxx:233
std::unique_ptr< weld::Entry > m_xHttpPortED
Definition: optinet2.hxx:38
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optinet2.cxx:339
virtual ~SvxProxyTabPage() override
Definition: optinet2.cxx:180
virtual void Reset(const SfxItemSet *rSet) override
Definition: optinet2.cxx:323
void ReadConfigData_Impl()
Definition: optinet2.cxx:189
std::unique_ptr< weld::Label > m_xHttpPortFT
Definition: optinet2.hxx:37
std::unique_ptr< weld::Label > m_xNoProxyForFT
Definition: optinet2.hxx:50
std::unique_ptr< weld::ComboBox > m_xProxyModeLB
Definition: optinet2.hxx:33
std::unique_ptr< weld::Entry > m_xHttpsProxyED
Definition: optinet2.hxx:41
css::uno::Reference< css::uno::XInterface > m_xConfigurationUpdateAccess
Definition: optinet2.hxx:54
void EnableControls_Impl()
Definition: optinet2.cxx:423
std::unique_ptr< weld::Label > m_xHttpProxyFT
Definition: optinet2.hxx:35
std::unique_ptr< weld::Entry > m_xHttpProxyED
Definition: optinet2.hxx:36
std::unique_ptr< weld::Entry > m_xHttpsPortED
Definition: optinet2.hxx:43
std::unique_ptr< weld::Entry > m_xNoProxyForED
Definition: optinet2.hxx:51
std::unique_ptr< weld::Entry > m_xFtpPortED
Definition: optinet2.hxx:48
std::unique_ptr< weld::Label > m_xNoProxyDescFT
Definition: optinet2.hxx:52
std::unique_ptr< weld::Label > m_xFtpPortFT
Definition: optinet2.hxx:47
std::unique_ptr< weld::Label > m_xHttpsPortFT
Definition: optinet2.hxx:42
std::unique_ptr< weld::Label > m_xFtpProxyFT
Definition: optinet2.hxx:45
std::unique_ptr< weld::CheckButton > m_xSavePasswordsCB
Definition: optinet2.hxx:89
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: optinet2.cxx:760
std::unique_ptr< weld::Button > m_xShowConnectionsPB
Definition: optinet2.hxx:90
virtual ~SvxSecurityTabPage() override
Definition: optinet2.cxx:523
std::unique_ptr< weld::Button > m_xTSAURLsPB
Definition: optinet2.hxx:103
std::unique_ptr< weld::Button > m_xMasterPasswordPB
Definition: optinet2.hxx:94
std::unique_ptr< weld::Button > m_xCertPathPB
Definition: optinet2.hxx:100
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optinet2.cxx:790
virtual void Reset(const SfxItemSet *rSet) override
Definition: optinet2.cxx:811
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: optinet2.cxx:764
std::unique_ptr< svx::SecurityOptionsDialog > m_xSecOptDlg
Definition: optinet2.hxx:81
SvxSecurityTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optinet2.cxx:481
std::unique_ptr< weld::CheckButton > m_xMasterPasswordCB
Definition: optinet2.hxx:92
std::unique_ptr< weld::Button > m_xMacroSecPB
Definition: optinet2.hxx:97
std::unique_ptr< weld::Label > m_xMasterPasswordFT
Definition: optinet2.hxx:93
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optinet2.cxx:755
std::unique_ptr< weld::Button > m_xSecurityOptionsPB
Definition: optinet2.hxx:87
OUString m_sPasswordStoringDeactivateStr
Definition: optinet2.hxx:85
std::unique_ptr< weld::Container > m_xCertFrame
Definition: optinet2.hxx:99
std::unique_ptr< weld::Label > m_xNoPasswordSaveFT
Definition: optinet2.hxx:105
static std::shared_ptr< ConfigurationChanges > create()
virtual short run()
virtual void set_text(const OUString &rText)=0
virtual OUString get_text() const=0
Any value
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
float u
float x
#define ERRCODE_NONE
Any aHelper
sal_Int64 n
sal_uInt16 nPos
bool IsReadOnly(EOption eOption)
void SetOption(EOption eOption, bool bValue)
bool IsOptionSet(EOption eOption)
@ Exception
bool isdigitAsciiString(std::string_view rString)
Reference< XComponentContext > getProcessComponentContext()
int i
RESTART_REASON_ADDING_PATH
SVT_DLLPUBLIC bool executeRestartDialog(css::uno::Reference< css::uno::XComponentContext > const &context, weld::Window *parent, RestartReason reason)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
constexpr OUStringLiteral g_aHttpsPortPN
Definition: optinet2.cxx:100
IMPL_LINK_NOARG(SvxSecurityTabPage, SecurityOptionsHdl, weld::Button &, void)
Definition: optinet2.cxx:527
IMPL_LINK(SvxProxyTabPage, PortChangedHdl, weld::Entry &, rEdit, void)
Definition: optinet2.cxx:85
constexpr OUStringLiteral g_aProxyModePN
Definition: optinet2.cxx:96
constexpr OUStringLiteral g_aNoProxyDescPN
Definition: optinet2.cxx:103
constexpr OUStringLiteral g_aHttpPortPN
Definition: optinet2.cxx:98
constexpr OUStringLiteral g_aFtpPortPN
Definition: optinet2.cxx:102
constexpr OUStringLiteral g_aHttpsProxyPN
Definition: optinet2.cxx:99
constexpr OUStringLiteral g_aFtpProxyPN
Definition: optinet2.cxx:101
constexpr OUStringLiteral g_aHttpProxyPN
Definition: optinet2.cxx:97
IMPL_STATIC_LINK(SvxProxyTabPage, NumberOnlyTextFilterHdl, OUString &, rTest, bool)
Definition: optinet2.cxx:105
static SfxItemSet & rSet
DeactivateRC
RET_OK
RET_NO
RET_YES