/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// language flags namespace Lang
{ unsignedconst Others = 1; unsignedconst Russian = 2; unsignedconst Eastern = 4; unsignedconst US = 8; unsignedconst All = static_cast<unsigned>(-1);
}
// vRowInfo[] -- rows (text + one or more edit boxes) // The order is the same as in RowType above, which is up to down.
struct
{ // id of the lockimage
OUString pLockId; // id of the text
OUString pTextId; // language flags (see Lang above): // which language is this row for? unsigned nLangFlags;
} const vRowInfo[] =
{
{ u"lockcompanyft"_ustr, u"companyft"_ustr, Lang::All },
{ u"locknameft"_ustr, u"nameft"_ustr, Lang::All & ~Lang::Russian & ~Lang::Eastern },
{ u"lockrusnameft"_ustr, u"rusnameft"_ustr, Lang::Russian },
{ u"lockeastnameft"_ustr, u"eastnameft"_ustr, Lang::Eastern },
{ u"lockstreetft"_ustr, u"streetft"_ustr, Lang::All & ~Lang::Russian },
{ u"lockrusstreetft"_ustr,u"russtreetft"_ustr, Lang::Russian },
{ u"lockicityft"_ustr, u"icityft"_ustr, Lang::All & ~Lang::US },
{ u"lockcityft"_ustr, u"cityft"_ustr, Lang::US },
{ u"lockcountryft"_ustr, u"countryft"_ustr, Lang::All },
{ u"locktitleft"_ustr, u"titleft"_ustr, Lang::All },
{ u"lockphoneft"_ustr, u"phoneft"_ustr, Lang::All },
{ u"lockfaxft"_ustr, u"faxft"_ustr, Lang::All },
};
// vFieldInfo[] -- edit boxes // The order is up to down, and then left to right.
struct
{ // in which row?
RowType eRow; // id of the edit box
OUString pEditId; // id for SvtUserOptions in unotools/useroptions.hxx
UserOptToken nUserOptionsId; // id for settings the focus (defined in svx/optgenrl.hxx)
EditPosition nGrabFocusId;
} const vFieldInfo[] =
{ // Company
{ Row_Company, u"company"_ustr, UserOptToken::Company, EditPosition::COMPANY }, // Name
{ Row_Name, u"firstname"_ustr, UserOptToken::FirstName, EditPosition::FIRSTNAME },
{ Row_Name, u"lastname"_ustr, UserOptToken::LastName, EditPosition::LASTNAME },
{ Row_Name, u"shortname"_ustr, UserOptToken::ID, EditPosition::SHORTNAME }, // Name (russian)
{ Row_Name_Russian, u"ruslastname"_ustr, UserOptToken::LastName, EditPosition::LASTNAME },
{ Row_Name_Russian, u"rusfirstname"_ustr, UserOptToken::FirstName, EditPosition::FIRSTNAME },
{ Row_Name_Russian, u"rusfathersname"_ustr, UserOptToken::FathersName, EditPosition::UNKNOWN },
{ Row_Name_Russian, u"russhortname"_ustr, UserOptToken::ID, EditPosition::SHORTNAME }, // Name (eastern: reversed name ord
{ Row_Name_Eastern, u"eastlastname"_ustr, UserOptToken::LastName, EditPosition::LASTNAME },
{ Row_Name_Eastern, u"eastfirstname"_ustr, UserOptToken::FirstName, EditPosition::FIRSTNAME },
{ Row_Name_Eastern, u"eastshortname"_ustr, UserOptToken::ID, EditPosition::SHORTNAME }, // Street
{ Row_Street, u"street"_ustr, UserOptToken::Street, EditPosition::STREET }, // Street (russian)
{ Row_Street_Russian, u"russtreet"_ustr, UserOptToken::Street, EditPosition::STREET },
{ Row_Street_Russian, u"apartnum"_ustr, UserOptToken::Apartment, EditPosition::UNKNOWN }, // City
{ Row_City, u"izip"_ustr, UserOptToken::Zip, EditPosition::PLZ },
{ Row_City, u"icity"_ustr, UserOptToken::City, EditPosition::CITY }, // City (US)
{ Row_City_US, u"city"_ustr, UserOptToken::City, EditPosition::CITY },
{ Row_City_US, u"state"_ustr, UserOptToken::State, EditPosition::STATE },
{ Row_City_US, u"zip"_ustr, UserOptToken::Zip, EditPosition::PLZ }, // Country
{ Row_Country, u"country"_ustr, UserOptToken::Country, EditPosition::COUNTRY }, // Title/Position
{ Row_TitlePos, u"title"_ustr, UserOptToken::Title, EditPosition::TITLE },
{ Row_TitlePos, u"position"_ustr, UserOptToken::Position, EditPosition::POSITION }, // Phone
{ Row_Phone, u"home"_ustr, UserOptToken::TelephoneHome, EditPosition::TELPRIV },
{ Row_Phone, u"work"_ustr, UserOptToken::TelephoneWork, EditPosition::TELCOMPANY }, // Fax/Mail
{ Row_FaxMail, u"fax"_ustr, UserOptToken::Fax, EditPosition::FAX },
{ Row_FaxMail, u"email"_ustr, UserOptToken::Email, EditPosition::EMAIL },
};
} // namespace
// Row
struct SvxGeneralTabPage::Row
{ // row lockdown icon
std::unique_ptr<weld::Widget> xLockImg; // row label
std::unique_ptr<weld::Label> xLabel; // first and last field in the row (last is exclusive) unsigned nFirstField, nLastField;
struct SvxGeneralTabPage::Field
{ // which field is this? (in vFieldInfo[] above) unsigned iField; // edit box
std::unique_ptr<weld::Entry> xEdit;
std::unique_ptr<weld::Container> xParent;
public:
Field (std::unique_ptr<weld::Entry> xEdit_, unsigned iField_)
: iField(iField_)
, xEdit(std::move(xEdit_))
, xParent(xEdit->weld_parent())
{ //We want all widgets inside a container, so each row of the toplevel //grid has another container in it. To avoid adding spacing to these //empty grids they all default to invisible, so show them if their //children are visible
xParent->show();
xEdit->show();
}
};
SetExchangeSupport(); // this page needs ExchangeSupport
SetLinks();
}
SvxGeneralTabPage::~SvxGeneralTabPage()
{
}
// Initializes the titles and the edit boxes, // according to vRowInfo[] and vFieldInfo[] above. void SvxGeneralTabPage::InitControls ()
{ // which language bit do we use? (see Lang and vRowInfo[] above) unsigned LangBit;
LanguageType l = Application::GetSettings().GetUILanguageTag().getLanguageType(); if (l == LANGUAGE_ENGLISH_US)
LangBit = Lang::US; elseif (l == LANGUAGE_RUSSIAN)
LangBit = Lang::Russian; else
{ if (MsLangId::isFamilyNameFirst(l))
LangBit = Lang::Eastern; else
LangBit = Lang::Others;
}
// creating rows unsigned iField = 0; for (unsigned iRow = 0; iRow != nRowCount; ++iRow)
{
RowType const eRow = static_cast<RowType>(iRow); // is the row visible? if (!(vRowInfo[iRow].nLangFlags & LangBit)) continue; // creating row
vRows.push_back(std::make_shared<Row>(m_xBuilder->weld_widget(vRowInfo[iRow].pLockId),
m_xBuilder->weld_label(vRowInfo[iRow].pTextId)));
Row& rRow = *vRows.back(); // fields in the row staticunsignedconst nFieldCount = std::size(vFieldInfo); // skipping other (invisible) rows while (iField != nFieldCount && vFieldInfo[iField].eRow != eRow)
++iField; // fields in the row
rRow.nFirstField = vFields.size(); for ( ; iField != nFieldCount && vFieldInfo[iField].eRow == eRow; ++iField)
{ // creating edit field
vFields.push_back(std::make_shared<Field>(
m_xBuilder->weld_entry(vFieldInfo[iField].pEditId), iField)); // "short name" field? if (vFieldInfo[iField].nUserOptionsId == UserOptToken::ID)
{
nNameRow = vRows.size() - 1;
nShortNameField = vFields.size() - 1;
}
}
rRow.nLastField = vFields.size();
}
}
// ModifyHdl_Impl() // This handler updates the initials (short name) // when one of the name fields was updated.
IMPL_LINK( SvxGeneralTabPage, ModifyHdl_Impl, weld::Entry&, rEdit, void )
{ // short name field and row
Field& rShortName = *vFields[nShortNameField];
Row& rNameRow = *vRows[nNameRow]; // number of initials unsignedconst nInits = rNameRow.nLastField - rNameRow.nFirstField - 1; // which field was updated? (in rNameRow) unsigned nField = nInits; for (unsigned i = 0; i != nInits; ++i)
{ if (vFields[rNameRow.nFirstField + i]->xEdit.get() == &rEdit)
nField = i;
} // updating the initial if (!(nField < nInits && rShortName.xEdit->get_sensitive())) return;
OUString sShortName = rShortName.xEdit->get_text(); // clear short name if it contains more characters than the number of initials if (o3tl::make_unsigned(sShortName.getLength()) > nInits)
{
rShortName.xEdit->set_text(OUString());
} while (o3tl::make_unsigned(sShortName.getLength()) < nInits)
sShortName += " ";
OUString sName = rEdit.get_text();
OUString sLetter = sName.isEmpty()
? OUString(u' ') : sName.copy(0, 1);
rShortName.xEdit->set_text(sShortName.replaceAt(nField, 1, sLetter).trim());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.