24#include <officecfg/Inet.hxx>
25#include <officecfg/Office/Common.hxx>
26#include <officecfg/Office/Security.hxx>
31#include <com/sun/star/uno/Sequence.hxx>
38#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
39#include <com/sun/star/task/InteractionHandler.hpp>
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>
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>
64using namespace ::
sfx2;
68bool isValidPort(OUString
const & value) {
72 auto const n =
value.toUInt64();
80 return std::u16string_view(value).find_first_not_of(u
'0') == std::u16string_view::npos;
87 if (!isValidPort(rEdit.get_text()))
90 VclMessageType::Warning, VclButtonsType::Ok,
91 CuiResId(RID_CUISTR_OPT_PROXYPORTS)));
107 OUStringBuffer sAllowed;
108 for (sal_Int32
i = 0, nLen = rTest.getLength();
i < nLen; ++
i)
110 if (rTest[
i] >=
'0' && rTest[
i] <=
'9')
111 sAllowed.append(rTest[
i]);
113 rTest = sAllowed.makeStringAndClear();
119 rTest = rTest.replaceAll(
" ",
"");
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"))
164 Reference< css::lang::XMultiServiceFactory >
165 xConfigurationProvider(
166 configuration::theDefaultProvider::get(
169 beans::NamedValue aProperty;
170 aProperty.Name =
"nodepath";
171 aProperty.Value <<= OUString(
"org.openoffice.Inet/Settings" );
173 Sequence< Any > aArgumentList{
Any(aProperty) };
176 "com.sun.star.configuration.ConfigurationUpdateAccess",
186 return std::make_unique<SvxProxyTabPage>(pPage, pController, *rAttrSet);
191 sal_Int32 nIntValue = 0;
193 std::optional<sal_Int32>
x(officecfg::Inet::Settings::ooInetProxyType::get());
200 m_xHttpProxyED->set_text( officecfg::Inet::Settings::ooInetHTTPProxyName::get() );
201 x = officecfg::Inet::Settings::ooInetHTTPProxyPort::get();
210 m_xHttpsProxyED->set_text( officecfg::Inet::Settings::ooInetHTTPSProxyName::get() );
211 x = officecfg::Inet::Settings::ooInetHTTPSProxyPort::get();
220 m_xFtpProxyED->set_text( officecfg::Inet::Settings::ooInetFTPProxyName::get() );
221 x = officecfg::Inet::Settings::ooInetFTPProxyPort::get();
230 m_xNoProxyForED->set_text( officecfg::Inet::Settings::ooInetNoProxy::get() );
239 sal_Int32 nIntValue = 0;
240 OUString aStringValue;
242 if( xPropertyState->getPropertyDefault(
g_aHttpProxyPN) >>= aStringValue )
247 if( xPropertyState->getPropertyDefault(
g_aHttpPortPN) >>= nIntValue )
252 if( xPropertyState->getPropertyDefault(
g_aHttpsProxyPN) >>= aStringValue )
257 if( xPropertyState->getPropertyDefault(
g_aHttpsPortPN) >>= nIntValue )
262 if( xPropertyState->getPropertyDefault(
g_aFtpProxyPN) >>= aStringValue )
267 if( xPropertyState->getPropertyDefault(
g_aFtpPortPN) >>= nIntValue )
277 catch (
const beans::UnknownPropertyException &)
281 catch (
const css::lang::WrappedTargetException &)
307 xChangesBatch->commitChanges();
309 catch (
const beans::UnknownPropertyException &)
313 catch (
const css::lang::WrappedTargetException &)
341 bool bModified =
false;
402 xChangesBatch->commitChanges();
404 catch (
const css::lang::IllegalArgumentException &) {
407 catch (
const beans::UnknownPropertyException &) {
410 catch (
const beans::PropertyVetoException &) {
413 catch (
const css::lang::WrappedTargetException &) {
425 m_xProxyModeLB->set_sensitive(!officecfg::Inet::Settings::ooInetNoProxy::isReadOnly());
429 const bool bHTTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyName::isReadOnly();
430 const bool bHTTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyPort::isReadOnly();
436 const bool bHTTPSProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyName::isReadOnly();
437 const bool bHTTPSProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyPort::isReadOnly();
443 const bool bFTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyName::isReadOnly();
444 const bool bFTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyPort::isReadOnly();
450 const bool bInetNoProxyEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetNoProxy::isReadOnly();
458 sal_Int32
nPos = rBox.get_active();
463 ReadConfigDefaults_Impl();
466 EnableControls_Impl();
472 if (pEdit && !isValidPort(pEdit->
get_text()))
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 , m_xCertMgrPathLB(m_xBuilder->weld_button(
"browse"))
497 , m_xParameterEdit(m_xBuilder->weld_entry(
"parameterfield"))
503 if (aPrefSize.
Width() > nMaxWidth)
530 FileDialogHelper
aHelper(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
531 FileDialogFlags::NONE,
nullptr);
532 OUString sPath = m_xParameterEdit->get_text();
537 osl::FileBase::getFileURLFromSystemPath(sPath, sUrl);
538 aHelper.SetDisplayDirectory(sUrl);
543 if (osl::FileBase::getSystemPathFromFileURL(sUrl, sPath) != osl::FileBase::E_None)
547 m_xParameterEdit->set_text(sPath);
549 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
551 OUString sCurCertMgr = m_xParameterEdit->get_text();
552 officecfg::Office::Common::Security::Scripting::CertMgrPath::set(sCurCertMgr, pBatch);
555 catch (
const uno::Exception&)
576 Reference< task::XPasswordContainer2 > xMasterPasswd(
579 if ( m_xSavePasswordsCB->get_active() )
581 bool bOldValue = xMasterPasswd->allowPersistentStoring(
true );
582 xMasterPasswd->removeMasterPassword();
585 GetDialogController()->getDialog()->GetXWindow()));
587 if ( xMasterPasswd->changeMasterPassword(xTmpHandler) )
589 m_xMasterPasswordPB->set_sensitive(
true);
590 m_xMasterPasswordCB->set_active(
true);
591 m_xMasterPasswordCB->set_sensitive(
true);
592 m_xMasterPasswordFT->set_sensitive(
true);
593 m_xShowConnectionsPB->set_sensitive(
true);
597 xMasterPasswd->allowPersistentStoring( bOldValue );
598 m_xSavePasswordsCB->set_active(
false );
604 VclMessageType::Question, VclButtonsType::YesNo,
605 m_sPasswordStoringDeactivateStr));
606 xQueryBox->set_default_response(
RET_NO);
608 sal_uInt16 nRet = xQueryBox->run();
612 xMasterPasswd->allowPersistentStoring(
false );
613 m_xMasterPasswordCB->set_active(
true);
614 m_xMasterPasswordPB->set_sensitive(
false );
615 m_xMasterPasswordCB->set_sensitive(
false );
616 m_xMasterPasswordFT->set_sensitive(
false );
617 m_xShowConnectionsPB->set_sensitive(
false );
621 m_xSavePasswordsCB->set_active(
true);
622 m_xMasterPasswordPB->set_sensitive(
true);
623 m_xShowConnectionsPB->set_sensitive(
true);
629 m_xSavePasswordsCB->set_active( !m_xSavePasswordsCB->get_active() );
637 Reference< task::XPasswordContainer2 > xMasterPasswd(
640 if ( xMasterPasswd->isPersistentStoringAllowed() )
643 GetDialogController()->getDialog()->GetXWindow()));
644 xMasterPasswd->changeMasterPassword(xTmpHandler);
655 Reference< task::XPasswordContainer2 > xMasterPasswd(
659 GetDialogController()->getDialog()->GetXWindow()));
661 if ( m_xMasterPasswordCB->get_active() )
663 if (xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->changeMasterPassword(xTmpHandler))
665 m_xMasterPasswordPB->set_sensitive(
true);
666 m_xMasterPasswordFT->set_sensitive(
true);
670 m_xMasterPasswordCB->set_active(
false );
671 m_xMasterPasswordPB->set_sensitive(
true);
672 m_xMasterPasswordFT->set_sensitive(
true);
677 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->useDefaultMasterPassword(xTmpHandler) )
679 m_xMasterPasswordPB->set_sensitive(
false );
680 m_xMasterPasswordFT->set_sensitive(
false );
684 m_xMasterPasswordCB->set_active(
true);
685 m_xMasterPasswordPB->set_sensitive(
true);
686 m_xShowConnectionsPB->set_sensitive(
true);
692 m_xSavePasswordsCB->set_active( !m_xSavePasswordsCB->get_active() );
700 Reference< task::XPasswordContainer2 > xMasterPasswd(
704 GetDialogController()->getDialog()->GetXWindow()));
706 if ( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword(xTmpHandler) )
720 mpCertPathDlg->Init();
722 if (mpCertPathDlg->run() ==
RET_OK && !mpCertPathDlg->isActiveServicePath())
726 GetDialogController()->response(
RET_OK);
742 Reference< security::XDocumentDigitalSignatures > xD(
744 xD->setParentWindow(GetDialogController()->getDialog()->GetXWindow());
745 xD->manageTrustedSources();
768 Reference< task::XPasswordContainer2 > xMasterPasswd(
771 if ( xMasterPasswd->isPersistentStoringAllowed() )
777 if ( xMasterPasswd->isDefaultMasterPasswordUsed() )
794 OUString sCurCertMgr = officecfg::Office::Common::Security::Scripting::CertMgrPath::get();
796 if (!sCurCertMgr.isEmpty())
799 catch (
const uno::Exception&)
806 return std::make_unique<SvxSecurityTabPage>(pPage, pController, *rAttrSet);
817 return DeactivateRC::LeavePage;
824 bool bModified =
false;
841 bool bModified =
false;
855 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
860 officecfg::Office::Common::Security::Scripting::CertMgrPath::set(sCurCertMgr, pBatch);
876 sProgram(officecfg::Office::Common::ExternalMailer::Program::
get()),
878 officecfg::Office::Common::ExternalMailer::Program::isReadOnly()),
880 officecfg::Office::
Security::HiddenContent::RemoveHiddenContent::
get()),
882 officecfg::Office::
Security::HiddenContent::RemoveHiddenContent::isReadOnly())
892 :
SfxTabPage( pPage, pController,
"cui/ui/optemailpage.ui",
"OptEmailPage", &
rSet)
894 , m_xMailContainer(m_xBuilder->weld_container(
"program"))
895 , m_xMailerURLFI(m_xBuilder->weld_image(
"lockemail"))
896 , m_xMailerURLED(m_xBuilder->weld_entry(
"url"))
897 , m_xMailerURLPB(m_xBuilder->weld_button(
"browse"))
898 , m_xSuppressHiddenContainer(m_xBuilder->weld_container(
"suppressHiddenCont"))
899 , m_xSuppressHiddenFI(m_xBuilder->weld_image(
"lockSuppressHidden"))
900 , m_xSuppressHidden(m_xBuilder->weld_check_button(
"suppressHidden"))
901 , m_xDefaultFilterFT(m_xBuilder->weld_label(
"browsetitle"))
917 return std::make_unique<SvxEMailTabPage>(pPage, pController, *rAttrSet);
924 std::shared_ptr<comphelper::ConfigurationChanges> batch(
929 officecfg::Office::Common::ExternalMailer::Program::set(
930 pImpl->sProgram, batch);
932 if (!
pImpl->bROHideContent
936 officecfg::Office::Security::HiddenContent::RemoveHiddenContent::set(
937 pImpl->bHideContent, batch);
950 if (
pImpl->bROProgram)
958 if (
pImpl->bROHideContent)
970 if (pImpl->bROProgram)
973 FileDialogHelper
aHelper(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE,
GetFrameWeld());
974 OUString sPath = m_xMailerURLED->get_text();
975 if ( sPath.isEmpty() )
979 osl::FileBase::getFileURLFromSystemPath(sPath, sUrl);
980 aHelper.SetDisplayDirectory(sUrl);
981 aHelper.AddFilter( m_sDefaultFilterName,
"*");
986 if (osl::FileBase::getSystemPathFromFileURL(sUrl, sPath)
987 != osl::FileBase::E_None)
991 m_xMailerURLED->set_text(sPath);
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
constexpr tools::Long Width() const
std::unique_ptr< weld::Label > m_xDefaultFilterFT
std::unique_ptr< weld::Button > m_xMailerURLPB
SvxEMailTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< weld::Container > m_xSuppressHiddenContainer
std::unique_ptr< SvxEMailTabPage_Impl > pImpl
virtual ~SvxEMailTabPage() override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Container > m_xMailContainer
std::unique_ptr< weld::CheckButton > m_xSuppressHidden
virtual bool FillItemSet(SfxItemSet *rSet) override
virtual void Reset(const SfxItemSet *rSet) override
OUString m_sDefaultFilterName
std::unique_ptr< weld::Image > m_xSuppressHiddenFI
std::unique_ptr< weld::Entry > m_xMailerURLED
std::unique_ptr< weld::Image > m_xMailerURLFI
void RestoreConfigDefaults_Impl()
SvxProxyTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Entry > m_xFtpProxyED
std::unique_ptr< weld::Label > m_xHttpsProxyFT
void ReadConfigDefaults_Impl()
std::unique_ptr< weld::Entry > m_xHttpPortED
virtual bool FillItemSet(SfxItemSet *rSet) override
virtual ~SvxProxyTabPage() override
virtual void Reset(const SfxItemSet *rSet) override
void ReadConfigData_Impl()
std::unique_ptr< weld::Label > m_xHttpPortFT
std::unique_ptr< weld::Label > m_xNoProxyForFT
std::unique_ptr< weld::ComboBox > m_xProxyModeLB
std::unique_ptr< weld::Entry > m_xHttpsProxyED
css::uno::Reference< css::uno::XInterface > m_xConfigurationUpdateAccess
void EnableControls_Impl()
std::unique_ptr< weld::Label > m_xHttpProxyFT
std::unique_ptr< weld::Entry > m_xHttpProxyED
std::unique_ptr< weld::Entry > m_xHttpsPortED
std::unique_ptr< weld::Entry > m_xNoProxyForED
std::unique_ptr< weld::Entry > m_xFtpPortED
std::unique_ptr< weld::Label > m_xNoProxyDescFT
std::unique_ptr< weld::Label > m_xFtpPortFT
std::unique_ptr< weld::Label > m_xHttpsPortFT
std::unique_ptr< weld::Label > m_xFtpProxyFT
std::unique_ptr< weld::CheckButton > m_xSavePasswordsCB
virtual void ActivatePage(const SfxItemSet &rSet) override
std::unique_ptr< weld::Button > m_xShowConnectionsPB
virtual ~SvxSecurityTabPage() override
std::unique_ptr< weld::Button > m_xCertMgrPathLB
std::unique_ptr< weld::Button > m_xTSAURLsPB
std::unique_ptr< weld::Button > m_xMasterPasswordPB
std::unique_ptr< weld::Button > m_xCertPathPB
virtual bool FillItemSet(SfxItemSet *rSet) override
virtual void Reset(const SfxItemSet *rSet) override
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
std::unique_ptr< svx::SecurityOptionsDialog > m_xSecOptDlg
SvxSecurityTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< weld::CheckButton > m_xMasterPasswordCB
std::unique_ptr< weld::Button > m_xMacroSecPB
std::unique_ptr< weld::Label > m_xMasterPasswordFT
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Button > m_xSecurityOptionsPB
OUString m_sPasswordStoringDeactivateStr
std::unique_ptr< weld::Container > m_xCertFrame
std::unique_ptr< weld::Entry > m_xParameterEdit
std::unique_ptr< weld::Label > m_xNoPasswordSaveFT
static std::shared_ptr< ConfigurationChanges > create()
virtual void set_text(const OUString &rText)=0
virtual OUString get_text() const=0
OUString CuiResId(TranslateId aKey)
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define LINK(Instance, Class, Member)
bool IsReadOnly(EOption eOption)
@ DocWarnRemovePersonalInfo
@ DocWarnRecommendPassword
@ BlockUntrustedRefererLinks
void SetOption(EOption eOption, bool bValue)
bool IsOptionSet(EOption eOption)
bool isdigitAsciiString(std::string_view rString)
Reference< XComponentContext > getProcessComponentContext()
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
IMPL_LINK_NOARG(SvxSecurityTabPage, CertMgrPBHdl, weld::Button &, void)
constexpr OUStringLiteral g_aHttpsPortPN
IMPL_LINK(SvxProxyTabPage, PortChangedHdl, weld::Entry &, rEdit, void)
constexpr OUStringLiteral g_aProxyModePN
constexpr OUStringLiteral g_aNoProxyDescPN
constexpr OUStringLiteral g_aHttpPortPN
constexpr OUStringLiteral g_aFtpPortPN
constexpr OUStringLiteral g_aHttpsProxyPN
constexpr OUStringLiteral g_aFtpProxyPN
constexpr OUStringLiteral g_aHttpProxyPN
IMPL_STATIC_LINK(SvxProxyTabPage, NumberOnlyTextFilterHdl, OUString &, rTest, bool)