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 ()
 
::o3tl::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...
 
::o3tl::optional< SimpleLicenseAttributesgetSimpleLicenseAttributes () const
 returns the attributes of the simple-license element More...
 
OUString getLocalizedDisplayName () const
 returns the localized display name of the extensions. More...
 
::o3tl::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::o3tl::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, OUString const &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 checkBlacklist () const
 Check the extensions blacklist if additional extension meta data (e.g. More...
 

Static Private Member Functions

static SAL_DLLPRIVATE bool checkBlacklistVersion (const OUString &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 62 of file dp_descriptioninfoset.hxx.

Constructor & Destructor Documentation

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 315 of file dp_descriptioninfoset.cxx.

References dp_registry::backend::bundle::create(), m_element, and m_xpath.

dp_misc::DescriptionInfoset::~DescriptionInfoset ( )

Definition at line 328 of file dp_descriptioninfoset.cxx.

Member Function Documentation

void dp_misc::DescriptionInfoset::checkBlacklist ( ) const
private

Check the extensions blacklist if additional extension meta data (e.g.

dependencies) are defined for this extension and have to be taken into account.

Definition at line 347 of file dp_descriptioninfoset.cxx.

References args, checkBlacklistVersion(), getIdentifier(), getVersion(), i, comphelper::InitAnyPropertySequence(), m_context, m_element, m_xpath, and OUStringToOString().

Referenced by getDependencies().

bool dp_misc::DescriptionInfoset::checkBlacklistVersion ( const OUString &  currentversion,
css::uno::Sequence< OUString > const &  versions 
)
staticprivate

Helper method to compare the versions with the current version.

Definition at line 433 of file dp_descriptioninfoset.cxx.

References i.

Referenced by checkBlacklist().

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/-license-id) and the license-id attributes (/description/registration/simple-license/license-text/-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 742 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.

Returns
dependencies; will never be null

Definition at line 485 of file dp_descriptioninfoset.cxx.

References checkBlacklist(), 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 510 of file dp_descriptioninfoset.cxx.

References getUrls().

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

Return the identifier.

Returns
the identifier, or an empty optional if none is specified

Definition at line 330 of file dp_descriptioninfoset.cxx.

References getOptionalValue().

Referenced by checkBlacklist(), dp_gui::UpdateDialog::isIgnoredUpdate(), and dp_manager::PackageManagerImpl::synchronizeRemovedExtensions().

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 676 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 670 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 610 of file dp_descriptioninfoset.cxx.

References getLocalizedChild(), and m_xpath.

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

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 629 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 571 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 605 of file dp_descriptioninfoset.cxx.

References getLocalizedHREFAttrFromChild().

o3tl::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 524 of file dp_descriptioninfoset.cxx.

References getLocalizedHREFAttrFromChild().

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

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 334 of file dp_descriptioninfoset.cxx.

References m_element, m_xpath, and n.

Referenced by getSimpleLicenseAttributes(), getSupportedPlatforms(), and getVersion().

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

Definition at line 537 of file dp_descriptioninfoset.cxx.

References m_element, m_xpath, and n.

Referenced by getIdentifier(), and getSimpleLicenseAttributes().

o3tl::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 636 of file dp_descriptioninfoset.cxx.

References dp_misc::SimpleLicenseAttributes::acceptBy, getNodeValueFromExpression(), getOptionalValue(), m_element, m_xpath, n, dp_misc::SimpleLicenseAttributes::suppressIfRequired, and dp_misc::SimpleLicenseAttributes::suppressOnUpdate.

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 451 of file dp_descriptioninfoset.cxx.

References comphelper::containerToSequence(), getNodeValueFromExpression(), m_element, m_xpath, nIndex, 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.

Returns
download URLs

Definition at line 505 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.

Returns
update information URLs

Definition at line 500 of file dp_descriptioninfoset.cxx.

References getUrls().

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

Definition at line 553 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
bool dp_misc::DescriptionInfoset::hasDescription ( ) const
inline
css::uno::Reference< css::xml::dom::XNode > dp_misc::DescriptionInfoset::matchLanguageTag ( css::uno::Reference< css::xml::dom::XNode > const &  xParent,
OUString const &  rTag 
) const
private

Definition at line 712 of file dp_descriptioninfoset.cxx.

References m_xpath.

Referenced by getLocalizedChild().

Member Data Documentation

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

Definition at line 267 of file dp_descriptioninfoset.hxx.

Referenced by checkBlacklist().

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

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