LibreOffice Module desktop (master) 1
|
Access to the content of an XML description
element.
More...
#include <dp_descriptioninfoset.hxx>
Public Member Functions | |
DescriptionInfoset (css::uno::Reference< css::uno::XComponentContext > const &context, css::uno::Reference< css::xml::dom::XNode > const &element) | |
Create an instance. More... | |
~DescriptionInfoset () | |
::std::optional< OUString > | getIdentifier () const |
Return the identifier. More... | |
OUString | getVersion () const |
Return the textual version representation. More... | |
css::uno::Sequence< OUString > | getSupportedPlatforms () const |
Returns a list of supported platforms. More... | |
std::pair< OUString, OUString > | getLocalizedPublisherNameAndURL () const |
Returns the localized publisher name and the corresponding URL. More... | |
OUString | getLocalizedReleaseNotesURL () const |
Returns the URL for the release notes corresponding to the office's locale. More... | |
OUString | getLocalizedLicenseURL () const |
returns the relative path to the license file. More... | |
::std::optional< SimpleLicenseAttributes > | getSimpleLicenseAttributes () const |
returns the attributes of the simple-license element More... | |
OUString | getLocalizedDisplayName () const |
returns the localized display name of the extensions. More... | |
::std::optional< OUString > | getLocalizedUpdateWebsiteURL () const |
returns the download website URL from the update information. More... | |
OUString | getLocalizedDescriptionURL () const |
returns the relative URL to the description. More... | |
css::uno::Reference< css::xml::dom::XNodeList > | getDependencies () const |
Return the dependencies. More... | |
css::uno::Sequence< OUString > | getUpdateInformationUrls () const |
Return the update information URLs. More... | |
css::uno::Sequence< OUString > | getUpdateDownloadUrls () const |
Return the download URLs from the update information. More... | |
OUString | getIconURL (bool bHighContrast) const |
Returns the URL for the icon image. More... | |
bool | hasDescription () const |
Private Member Functions | |
SAL_DLLPRIVATE ::std::optional< OUString > | getOptionalValue (OUString const &expression) const |
SAL_DLLPRIVATE css::uno::Sequence< OUString > | getUrls (OUString const &expression) const |
SAL_DLLPRIVATE css::uno::Reference< css::xml::dom::XNode > | getLocalizedChild (OUString const &sParent) const |
Retrieves a child element which as lang attribute which matches the office locale. More... | |
SAL_DLLPRIVATE css::uno::Reference< css::xml::dom::XNode > | matchLanguageTag (css::uno::Reference< css::xml::dom::XNode > const &xParent, std::u16string_view rTag) const |
SAL_DLLPRIVATE css::uno::Reference< css::xml::dom::XNode > | getChildWithDefaultLocale (css::uno::Reference< css::xml::dom::XNode > const &xParent) const |
If there is no child element with a locale matching the office locale, then we use the first child. More... | |
SAL_DLLPRIVATE OUString | getLocalizedHREFAttrFromChild (OUString const &sXPathParent, bool *out_bParentExists) const |
SAL_DLLPRIVATE OUString | getNodeValueFromExpression (OUString const &expression) const |
Gets the node value for a given expression. More... | |
SAL_DLLPRIVATE void | checkDenylist () const |
Check the extensions denylist if additional extension meta data (e.g. More... | |
Static Private Member Functions | |
static SAL_DLLPRIVATE bool | checkDenylistVersion (std::u16string_view currentversion, css::uno::Sequence< OUString > const &versions) |
Helper method to compare the versions with the current version. More... | |
Private Attributes | |
css::uno::Reference< css::uno::XComponentContext > | m_context |
css::uno::Reference< css::xml::dom::XNode > | m_element |
css::uno::Reference< css::xml::xpath::XXPathAPI > | m_xpath |
Access to the content of an XML description
element.
This works for description
elements in both the description.xml
file and online update information formats.
Definition at line 63 of file dp_descriptioninfoset.hxx.
dp_misc::DescriptionInfoset::DescriptionInfoset | ( | css::uno::Reference< css::uno::XComponentContext > const & | context, |
css::uno::Reference< css::xml::dom::XNode > const & | element | ||
) |
Create an instance.
context | a non-null component context |
element | a description element; may be null (equivalent to an element with no content) |
Definition at line 317 of file dp_descriptioninfoset.cxx.
References dp_registry::backend::bundle::create(), m_element, and m_xpath.
dp_misc::DescriptionInfoset::~DescriptionInfoset | ( | ) |
Definition at line 330 of file dp_descriptioninfoset.cxx.
|
private |
Check the extensions denylist if additional extension meta data (e.g.
dependencies) are defined for this extension and have to be taken into account.
Definition at line 349 of file dp_descriptioninfoset.cxx.
References args, checkDenylistVersion(), getIdentifier(), getVersion(), i, comphelper::InitAnyPropertySequence(), m_context, m_element, m_xpath, and OUStringToOString().
Referenced by getDependencies().
|
staticprivate |
Helper method to compare the versions with the current version.
Definition at line 436 of file dp_descriptioninfoset.cxx.
References i.
Referenced by checkDenylist().
|
private |
If there is no child element with a locale matching the office locale, then we use the first child.
In the case of the simple-license we also use the former default locale, which was determined by the default-license-id (/description/registration/simple-license/@default-license-id) and the license-id attributes (/description/registration/simple-license/license-text/@license-id). However, since OOo 2.4 we use also the first child as default for the license unless the two attributes are present.
Definition at line 743 of file dp_descriptioninfoset.cxx.
References m_xpath.
Referenced by getLocalizedChild().
css::uno::Reference< css::xml::dom::XNodeList > dp_misc::DescriptionInfoset::getDependencies | ( | ) | const |
Return the dependencies.
Definition at line 488 of file dp_descriptioninfoset.cxx.
References checkDenylist(), m_element, and m_xpath.
Referenced by dp_misc::Dependencies::check().
OUString dp_misc::DescriptionInfoset::getIconURL | ( | bool | bHighContrast | ) | const |
Returns the URL for the icon image.
Definition at line 513 of file dp_descriptioninfoset.cxx.
References getUrls().
std::optional< OUString > dp_misc::DescriptionInfoset::getIdentifier | ( | ) | const |
Return the identifier.
optional
if none is specified Definition at line 332 of file dp_descriptioninfoset.cxx.
References getOptionalValue().
Referenced by checkDenylist(), dp_gui::UpdateDialog::isIgnoredUpdate(), and dp_manager::PackageManagerImpl::synchronizeRemovedExtensions().
|
private |
Retrieves a child element which as lang attribute which matches the office locale.
Only top-level children are taken into account. It is also assumed that they are all of the same element type and have a lang attribute. The matching algorithm is according to RFC 3066, with the exception that only one variant is allowed.
parent | the expression used to obtain the parent of the localized children. It can be null. Then a null reference is returned. |
Definition at line 677 of file dp_descriptioninfoset.cxx.
References getChildWithDefaultLocale(), dp_misc::getOfficeLanguageTag(), m_element, m_xpath, and matchLanguageTag().
Referenced by getLocalizedDisplayName(), getLocalizedHREFAttrFromChild(), and getLocalizedPublisherNameAndURL().
OUString dp_misc::DescriptionInfoset::getLocalizedDescriptionURL | ( | ) | const |
returns the relative URL to the description.
The URL is relative to the root directory of the extensions.
Definition at line 671 of file dp_descriptioninfoset.cxx.
References getLocalizedHREFAttrFromChild().
OUString dp_misc::DescriptionInfoset::getLocalizedDisplayName | ( | ) | const |
returns the localized display name of the extensions.
In case there is no localized display-name then an empty string is returned.
Definition at line 612 of file dp_descriptioninfoset.cxx.
References getLocalizedChild(), and m_xpath.
|
private |
out_bParentExists | indicates if the element node specified in sXPathParent exists. |
Definition at line 777 of file dp_descriptioninfoset.cxx.
References getLocalizedChild(), and m_xpath.
Referenced by getLocalizedDescriptionURL(), getLocalizedLicenseURL(), getLocalizedReleaseNotesURL(), and getLocalizedUpdateWebsiteURL().
OUString dp_misc::DescriptionInfoset::getLocalizedLicenseURL | ( | ) | const |
returns the relative path to the license file.
In case there is no simple-license element then an empty string is returned.
Definition at line 630 of file dp_descriptioninfoset.cxx.
References getLocalizedHREFAttrFromChild().
std::pair< OUString, OUString > dp_misc::DescriptionInfoset::getLocalizedPublisherNameAndURL | ( | ) | const |
Returns the localized publisher name and the corresponding URL.
In case there is no publisher element then a pair of two empty strings is returned.
Definition at line 575 of file dp_descriptioninfoset.cxx.
References getLocalizedChild(), and m_xpath.
OUString dp_misc::DescriptionInfoset::getLocalizedReleaseNotesURL | ( | ) | const |
Returns the URL for the release notes corresponding to the office's locale.
In case there is no release-notes element then an empty string is returned.
Definition at line 607 of file dp_descriptioninfoset.cxx.
References getLocalizedHREFAttrFromChild().
std::optional< OUString > dp_misc::DescriptionInfoset::getLocalizedUpdateWebsiteURL | ( | ) | const |
returns the download website URL from the update information.
There can be multiple URLs where each is assigned to a particular locale. The function returns the URL which locale matches best the one used in the office.
The return value is an optional because it may be necessary to find out if there was a value provided or not. This is necessary to flag the extension in the update dialog properly as "browser based update". The return value will only then not be initialized if there is no <update-website>
. If the element exists, then it must have at least one child element containing a URL.
The <update-website>
and <update-download>
elements are mutually exclusive.
optional
if none is specified Definition at line 527 of file dp_descriptioninfoset.cxx.
References getLocalizedHREFAttrFromChild().
Referenced by dp_gui::UpdateDialog::Thread::prepareUpdateData().
|
private |
Gets the node value for a given expression.
The expression is used in m_xpath-selectSingleNode. The value of the returned node is return value of this function.
Definition at line 336 of file dp_descriptioninfoset.cxx.
References m_element, m_xpath, and n.
Referenced by getSimpleLicenseAttributes(), getSupportedPlatforms(), and getVersion().
|
private |
Definition at line 540 of file dp_descriptioninfoset.cxx.
References m_element, m_xpath, and n.
Referenced by getIdentifier(), and getSimpleLicenseAttributes().
std::optional< SimpleLicenseAttributes > dp_misc::DescriptionInfoset::getSimpleLicenseAttributes | ( | ) | const |
returns the attributes of the simple-license element
As long as there is a simple-license element, the function will return the structure. If it does not exist, then the optional object is uninitialized.
Definition at line 637 of file dp_descriptioninfoset.cxx.
References dp_misc::SimpleLicenseAttributes::acceptBy, o3tl::equalsIgnoreAsciiCase(), getNodeValueFromExpression(), getOptionalValue(), m_element, m_xpath, n, dp_misc::SimpleLicenseAttributes::suppressIfRequired, dp_misc::SimpleLicenseAttributes::suppressOnUpdate, o3tl::trim(), and u.
Referenced by dp_manager::ExtensionManager::doChecksForAddExtension().
css::uno::Sequence< OUString > dp_misc::DescriptionInfoset::getSupportedPlatforms | ( | ) | const |
Returns a list of supported platforms.
If the extension does not specify a platform by leaving out the platform element then we assume that the extension supports all platforms. In this case the returned sequence will have one element, which is "all". If the platform element is present but does not specify a platform then an empty sequence is returned. Examples for invalid platform elements:
<platform >, <platform value="" >, <platform value=",">
The value attribute can contain various platform tokens. They must be separated by commas.Each token will be stripped from leading and trailing white space (trim()).
Definition at line 454 of file dp_descriptioninfoset.cxx.
References comphelper::containerToSequence(), getNodeValueFromExpression(), o3tl::getToken(), m_element, m_xpath, nIndex, o3tl::trim(), and value.
css::uno::Sequence< OUString > dp_misc::DescriptionInfoset::getUpdateDownloadUrls | ( | ) | const |
Return the download URLs from the update information.
Because the <update-download>
and the <update-website>
elements are mutually exclusive one may need to determine exactly if the element was provided.
Definition at line 508 of file dp_descriptioninfoset.cxx.
References getUrls().
Referenced by dp_gui::UpdateInstallDialog::Thread::downloadExtensions().
css::uno::Sequence< OUString > dp_misc::DescriptionInfoset::getUpdateInformationUrls | ( | ) | const |
Return the update information URLs.
Definition at line 503 of file dp_descriptioninfoset.cxx.
References getUrls().
|
private |
Definition at line 556 of file dp_descriptioninfoset.cxx.
References i, m_element, m_xpath, and ns.
Referenced by getIconURL(), getUpdateDownloadUrls(), and getUpdateInformationUrls().
OUString dp_misc::DescriptionInfoset::getVersion | ( | ) | const |
Return the textual version representation.
Definition at line 449 of file dp_descriptioninfoset.cxx.
References getNodeValueFromExpression().
Referenced by checkDenylist(), dp_gui::UpdateDialog::isIgnoredUpdate(), dp_gui::UpdateDialog::notifyMenubar(), dp_gui::UpdateDialog::Thread::prepareUpdateData(), and dp_manager::PackageManagerImpl::synchronizeRemovedExtensions().
|
inline |
Definition at line 273 of file dp_descriptioninfoset.hxx.
References m_element.
Referenced by dp_manager::PackageManagerImpl::synchronizeRemovedExtensions().
|
private |
Definition at line 713 of file dp_descriptioninfoset.cxx.
References m_xpath.
Referenced by getLocalizedChild().
|
private |
Definition at line 268 of file dp_descriptioninfoset.hxx.
Referenced by checkDenylist().
|
private |
Definition at line 269 of file dp_descriptioninfoset.hxx.
Referenced by checkDenylist(), DescriptionInfoset(), getDependencies(), getLocalizedChild(), getNodeValueFromExpression(), getOptionalValue(), getSimpleLicenseAttributes(), getSupportedPlatforms(), getUrls(), and hasDescription().
|
private |
Definition at line 270 of file dp_descriptioninfoset.hxx.
Referenced by checkDenylist(), DescriptionInfoset(), getChildWithDefaultLocale(), getDependencies(), getLocalizedChild(), getLocalizedDisplayName(), getLocalizedHREFAttrFromChild(), getLocalizedPublisherNameAndURL(), getNodeValueFromExpression(), getOptionalValue(), getSimpleLicenseAttributes(), getSupportedPlatforms(), getUrls(), and matchLanguageTag().