LibreOffice Module desktop (master) 1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
dp_misc::DescriptionInfoset Class Reference

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< SimpleLicenseAttributesgetSimpleLicenseAttributes () 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DescriptionInfoset()

dp_misc::DescriptionInfoset::DescriptionInfoset ( css::uno::Reference< css::uno::XComponentContext > const &  context,
css::uno::Reference< css::xml::dom::XNode > const &  element 
)

Create an instance.

Parameters
contexta non-null component context
elementa 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.

◆ ~DescriptionInfoset()

dp_misc::DescriptionInfoset::~DescriptionInfoset ( )

Definition at line 330 of file dp_descriptioninfoset.cxx.

Member Function Documentation

◆ checkDenylist()

void dp_misc::DescriptionInfoset::checkDenylist ( ) const
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().

◆ checkDenylistVersion()

bool dp_misc::DescriptionInfoset::checkDenylistVersion ( std::u16string_view  currentversion,
css::uno::Sequence< OUString > const &  versions 
)
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().

◆ getChildWithDefaultLocale()

css::uno::Reference< css::xml::dom::XNode > dp_misc::DescriptionInfoset::getChildWithDefaultLocale ( css::uno::Reference< css::xml::dom::XNode > const &  xParent) const
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().

◆ getDependencies()

css::uno::Reference< css::xml::dom::XNodeList > dp_misc::DescriptionInfoset::getDependencies ( ) const

Return the dependencies.

Returns
dependencies; will never be null

Definition at line 488 of file dp_descriptioninfoset.cxx.

References checkDenylist(), m_element, and m_xpath.

Referenced by dp_misc::Dependencies::check().

◆ getIconURL()

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().

◆ getIdentifier()

std::optional< OUString > dp_misc::DescriptionInfoset::getIdentifier ( ) const

Return the identifier.

Returns
the identifier, or an empty 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().

◆ getLocalizedChild()

css::uno::Reference< css::xml::dom::XNode > dp_misc::DescriptionInfoset::getLocalizedChild ( OUString const &  sParent) const
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.

Parameters
parentthe 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().

◆ getLocalizedDescriptionURL()

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().

◆ getLocalizedDisplayName()

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.

◆ getLocalizedHREFAttrFromChild()

OUString dp_misc::DescriptionInfoset::getLocalizedHREFAttrFromChild ( OUString const &  sXPathParent,
bool *  out_bParentExists 
) const
private
Parameters
out_bParentExistsindicates 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().

◆ getLocalizedLicenseURL()

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().

◆ getLocalizedPublisherNameAndURL()

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.

◆ getLocalizedReleaseNotesURL()

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().

◆ getLocalizedUpdateWebsiteURL()

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.

Returns
the download website URL, or an empty optional if none is specified

Definition at line 527 of file dp_descriptioninfoset.cxx.

References getLocalizedHREFAttrFromChild().

Referenced by dp_gui::UpdateDialog::Thread::prepareUpdateData().

◆ getNodeValueFromExpression()

OUString dp_misc::DescriptionInfoset::getNodeValueFromExpression ( OUString const &  expression) const
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().

◆ getOptionalValue()

std::optional< OUString > dp_misc::DescriptionInfoset::getOptionalValue ( OUString const &  expression) const
private

Definition at line 540 of file dp_descriptioninfoset.cxx.

References m_element, m_xpath, and n.

Referenced by getIdentifier(), and getSimpleLicenseAttributes().

◆ 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().

◆ getSupportedPlatforms()

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.

◆ getUpdateDownloadUrls()

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.

Returns
download URLs

Definition at line 508 of file dp_descriptioninfoset.cxx.

References getUrls().

Referenced by dp_gui::UpdateInstallDialog::Thread::downloadExtensions().

◆ getUpdateInformationUrls()

css::uno::Sequence< OUString > dp_misc::DescriptionInfoset::getUpdateInformationUrls ( ) const

Return the update information URLs.

Returns
update information URLs

Definition at line 503 of file dp_descriptioninfoset.cxx.

References getUrls().

◆ getUrls()

css::uno::Sequence< OUString > dp_misc::DescriptionInfoset::getUrls ( OUString const &  expression) const
private

Definition at line 556 of file dp_descriptioninfoset.cxx.

References i, m_element, m_xpath, and ns.

Referenced by getIconURL(), getUpdateDownloadUrls(), and getUpdateInformationUrls().

◆ getVersion()

OUString dp_misc::DescriptionInfoset::getVersion ( ) const

◆ hasDescription()

bool dp_misc::DescriptionInfoset::hasDescription ( ) const
inline

◆ matchLanguageTag()

css::uno::Reference< css::xml::dom::XNode > dp_misc::DescriptionInfoset::matchLanguageTag ( css::uno::Reference< css::xml::dom::XNode > const &  xParent,
std::u16string_view  rTag 
) const
private

Definition at line 713 of file dp_descriptioninfoset.cxx.

References m_xpath.

Referenced by getLocalizedChild().

Member Data Documentation

◆ m_context

css::uno::Reference< css::uno::XComponentContext > dp_misc::DescriptionInfoset::m_context
private

Definition at line 268 of file dp_descriptioninfoset.hxx.

Referenced by checkDenylist().

◆ m_element

css::uno::Reference< css::xml::dom::XNode > dp_misc::DescriptionInfoset::m_element
private

◆ m_xpath

css::uno::Reference< css::xml::xpath::XXPathAPI > dp_misc::DescriptionInfoset::m_xpath
private

The documentation for this class was generated from the following files: