23#include <config_gpgme.h>
25# include <com/sun/star/xml/crypto/GPGSEInitializer.hpp>
26# include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
36#include <officecfg/Office/Common.hxx>
39#include <svx/svxids.hrc>
69 unsigned const Others = 1;
70 unsigned const Russian = 2;
71 unsigned const Eastern = 4;
72 unsigned const US = 8;
73 unsigned const All =
static_cast<unsigned>(-1);
90 {
"companyft", Lang::All },
91 {
"nameft", Lang::All &
~Lang::Russian &
~Lang::Eastern },
92 {
"rusnameft", Lang::Russian },
93 {
"eastnameft", Lang::Eastern },
94 {
"streetft", Lang::All &
~Lang::Russian },
95 {
"russtreetft", Lang::Russian },
96 {
"icityft", Lang::All &
~Lang::US },
97 {
"cityft", Lang::US },
98 {
"countryft", Lang::All },
99 {
"titleft", Lang::All },
100 {
"phoneft", Lang::All },
101 {
"faxft", Lang::All },
122 { Row_Company,
"company", UserOptToken::Company, EditPosition::COMPANY },
124 { Row_Name,
"firstname", UserOptToken::FirstName, EditPosition::FIRSTNAME },
125 { Row_Name,
"lastname", UserOptToken::LastName, EditPosition::LASTNAME },
126 { Row_Name,
"shortname", UserOptToken::ID, EditPosition::SHORTNAME },
128 { Row_Name_Russian,
"ruslastname", UserOptToken::LastName, EditPosition::LASTNAME },
129 { Row_Name_Russian,
"rusfirstname", UserOptToken::FirstName, EditPosition::FIRSTNAME },
130 { Row_Name_Russian,
"rusfathersname", UserOptToken::FathersName, EditPosition::UNKNOWN },
131 { Row_Name_Russian,
"russhortname", UserOptToken::ID, EditPosition::SHORTNAME },
133 { Row_Name_Eastern,
"eastlastname", UserOptToken::LastName, EditPosition::LASTNAME },
134 { Row_Name_Eastern,
"eastfirstname", UserOptToken::FirstName, EditPosition::FIRSTNAME },
135 { Row_Name_Eastern,
"eastshortname", UserOptToken::ID, EditPosition::SHORTNAME },
137 { Row_Street,
"street", UserOptToken::Street, EditPosition::STREET },
139 { Row_Street_Russian,
"russtreet", UserOptToken::Street, EditPosition::STREET },
140 { Row_Street_Russian,
"apartnum", UserOptToken::Apartment, EditPosition::UNKNOWN },
142 { Row_City,
"izip", UserOptToken::Zip, EditPosition::PLZ },
143 { Row_City,
"icity", UserOptToken::City, EditPosition::CITY },
145 { Row_City_US,
"city", UserOptToken::City, EditPosition::CITY },
146 { Row_City_US,
"state", UserOptToken::State, EditPosition::STATE },
147 { Row_City_US,
"zip", UserOptToken::Zip, EditPosition::PLZ },
149 { Row_Country,
"country", UserOptToken::Country, EditPosition::COUNTRY },
151 { Row_TitlePos,
"title", UserOptToken::Title, EditPosition::TITLE },
152 { Row_TitlePos,
"position", UserOptToken::Position, EditPosition::POSITION },
154 { Row_Phone,
"home", UserOptToken::TelephoneHome, EditPosition::TELPRIV },
155 { Row_Phone,
"work", UserOptToken::TelephoneWork, EditPosition::TELCOMPANY },
157 { Row_FaxMail,
"fax", UserOptToken::Fax, EditPosition::FAX },
158 { Row_FaxMail,
"email", UserOptToken::Email, EditPosition::EMAIL },
175 explicit Row (std::unique_ptr<weld::Label> xLabel_)
196 Field (std::unique_ptr<weld::Entry> xEdit_,
unsigned iField_)
211 :
SfxTabPage(pPage, pController,
"cui/ui/optuserpage.ui",
"OptUserPage", &rCoreSet)
212 , m_xUseDataCB(m_xBuilder->weld_check_button(
"usefordocprop"))
213 , m_xCryptoFrame(m_xBuilder->weld_widget(
"cryptography"))
214 , m_xSigningKeyLB(m_xBuilder->weld_combo_box(
"signingkey"))
215 , m_xEncryptionKeyLB(m_xBuilder->weld_combo_box(
"encryptionkey"))
216 , m_xEncryptToSelfCB(m_xBuilder->weld_check_button(
"encrypttoself"))
219#if HAVE_FEATURE_GPGME
243 LangBit = Lang::Russian;
247 LangBit = Lang::Eastern;
249 LangBit = Lang::Others;
254 for (
unsigned iRow = 0; iRow != nRowCount; ++iRow)
256 RowType
const eRow =
static_cast<RowType
>(iRow);
258 if (!(vRowInfo[iRow].nLangFlags & LangBit))
261 vRows.push_back(std::make_shared<Row>(
262 m_xBuilder->weld_label(vRowInfo[iRow].pTextId)));
265 static unsigned const nFieldCount = std::size(vFieldInfo);
267 while (iField != nFieldCount && vFieldInfo[iField].eRow != eRow)
271 for ( ; iField != nFieldCount && vFieldInfo[iField].eRow == eRow; ++iField)
274 vFields.push_back(std::make_shared<Field>(
275 m_xBuilder->weld_entry(vFieldInfo[iField].pEditId), iField));
277 if (vFieldInfo[iField].nUserOptionsId == UserOptToken::ID)
289#if HAVE_FEATURE_GPGME
302 if (xCertificates.hasElements())
304 for (
auto& xCert : asNonConstRange(xCertificates))
314 if (nPrefWidth > nMaxWidth)
323 catch ( uno::Exception
const & )
335 vFields[
i]->xEdit->connect_changed(aLink);
341 return std::make_unique<SvxGeneralTabPage>( pPage, pController, *rAttrSet );
350 bool bModified =
false;
352 if (
m_xUseDataCB->get_active() != officecfg::Office::Common::Save::Document::UseUserData::get())
355 officecfg::Office::Common::Save::Document::UseUserData::set(
m_xUseDataCB->get_active(), xChanges);
369 if (nField != EditPosition::UNKNOWN)
372 if (nField == vFieldInfo[
i->iField].nGrabFocusId)
373 i->xEdit->grab_focus();
376 vFields.front()->xEdit->grab_focus();
379 m_xUseDataCB->set_active(officecfg::Office::Common::Save::Document::UseUserData::get());
389 Field& rShortName = *vFields[nShortNameField];
390 Row& rNameRow = *vRows[nNameRow];
392 unsigned const nInits = rNameRow.nLastField - rNameRow.nFirstField - 1;
394 unsigned nField = nInits;
395 for (
unsigned i = 0;
i != nInits; ++
i)
397 if (vFields[rNameRow.nFirstField +
i]->xEdit.get() == &rEdit)
401 if (!(nField < nInits && rShortName.xEdit->get_sensitive()))
404 OUString sShortName = rShortName.xEdit->get_text();
408 rShortName.xEdit->set_text(OUString());
412 OUString
sName = rEdit.get_text();
413 OUString sLetter =
sName.isEmpty()
414 ? OUString(
u' ') :
sName.copy(0, 1);
415 rShortName.xEdit->set_text(sShortName.replaceAt(nField, 1, sLetter).trim());
425 vFieldInfo[
i->iField].nUserOptionsId,
430 bool bModified =
false;
433 if (
i->xEdit->get_value_changed_from_saved())
440#if HAVE_FEATURE_GPGME
446 aUserOpt.
SetToken( UserOptToken::SigningKey, aSK );
447 aUserOpt.
SetToken( UserOptToken::EncryptionKey, aEK );
463 for (
auto const &
i:
vRows)
467 bool bEnableLabel =
false;
476 rField.
xEdit->set_sensitive(bEnableEdit);
477 bEnableLabel = bEnableLabel || bEnableEdit;
479 rRow.
xLabel->set_sensitive(bEnableLabel);
484 i->xEdit->save_value();
486#if HAVE_FEATURE_GPGME
487 OUString aSK = aUserOpt.
GetToken(UserOptToken::SigningKey);
491 OUString aEK = aUserOpt.
GetToken(UserOptToken::EncryptionKey);
504 return DeactivateRC::LeavePage;
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
LanguageType getLanguageType(bool bResolveSystem=true) const
static bool isFamilyNameFirst(LanguageType nLang)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetExchangeSupport()
bool IsTokenReadonly(UserOptToken nToken) const
bool GetEncryptToSelf() const
OUString GetToken(UserOptToken nToken) const
void SetBoolValue(UserOptToken nToken, bool bNewValue)
void SetToken(UserOptToken nToken, OUString const &rNewToken)
std::vector< std::shared_ptr< Row > > vRows
virtual ~SvxGeneralTabPage() override
std::vector< std::shared_ptr< Field > > vFields
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::CheckButton > m_xEncryptToSelfCB
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::CheckButton > m_xUseDataCB
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
SvxGeneralTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< weld::Widget > m_xCryptoFrame
std::unique_ptr< weld::ComboBox > m_xSigningKeyLB
std::unique_ptr< weld::ComboBox > m_xEncryptionKeyLB
virtual bool FillItemSet(SfxItemSet *rSet) override
static std::shared_ptr< ConfigurationChanges > create()
#define LANGUAGE_ENGLISH_US
#define LINK(Instance, Class, Member)
OString strip(const OString &rIn, char c)
Reference< XComponentContext > getProcessComponentContext()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
IMPL_LINK(SvxGeneralTabPage, ModifyHdl_Impl, weld::Entry &, rEdit, void)
Field(std::unique_ptr< weld::Entry > xEdit_, unsigned iField_)
std::unique_ptr< weld::Entry > xEdit
std::unique_ptr< weld::Container > xParent
Row(std::unique_ptr< weld::Label > xLabel_)
std::unique_ptr< weld::Label > xLabel