20#include <config_folders.h>
24#include <com/sun/star/uno/Reference.hxx>
25#include <com/sun/star/uno/Sequence.hxx>
26#include <com/sun/star/xml/dom/XElement.hpp>
27#include <com/sun/star/xml/dom/XNodeList.hpp>
28#include <osl/diagnose.h>
29#include <rtl/bootstrap.hxx>
30#include <rtl/ustring.hxx>
43char const namespaceLibreOffice[] =
44 "http://libreoffice.org/extensions/description/2011";
46constexpr OUStringLiteral namespaceOpenOfficeOrg =
47 u"http://openoffice.org/extensions/description/2006";
49char const minimalVersionLibreOffice[] =
"LibreOffice-minimal-version";
50char const maximalVersionLibreOffice[] =
"LibreOffice-maximal-version";
52constexpr OUStringLiteral minimalVersionOpenOfficeOrg =
53 u"OpenOffice.org-minimal-version";
55char const maximalVersionOpenOfficeOrg[] =
56 "OpenOffice.org-maximal-version";
58OUString getLibreOfficeMajorMinorMicro() {
62OUString getReferenceOpenOfficeOrgMajorMinor() {
69 ":Version:ReferenceOOoMajorMinor}");
70 rtl::Bootstrap::expandMacros(v);
75bool satisfiesMinimalVersion(
76 std::u16string_view actual, std::u16string_view specified)
81bool satisfiesMaximalVersion(
82 std::u16string_view actual, std::u16string_view specified)
87OUString produceErrorText(
88 OUString
const & reason, OUString
const & version)
90 return reason.replaceFirst(
"%VERSION",
92 ?
DpResId(RID_DEPLOYMENT_DEPENDENCIES_UNKNOWN)
100css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
102 css::uno::Reference< css::xml::dom::XNodeList > deps(
104 sal_Int32
n = deps->getLength();
105 css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
107 auto unsatisfiedRange = asNonConstRange(unsatisfied);
110 bool bIgnoreOoo =
false;
111 for (sal_Int32
i = 0;
i <
n; ++
i) {
112 css::uno::Reference< css::xml::dom::XElement > e(
113 deps->item(
i), css::uno::UNO_QUERY_THROW);
114 if ( e->getNamespaceURI() == namespaceLibreOffice && e->getTagName() == minimalVersionLibreOffice)
120 for (sal_Int32
i = 0;
i <
n; ++
i) {
121 css::uno::Reference< css::xml::dom::XElement > e(
122 deps->item(
i), css::uno::UNO_QUERY_THROW);
124 if ( e->getNamespaceURI() == namespaceOpenOfficeOrg && e->getTagName() == minimalVersionOpenOfficeOrg )
126 sat = bIgnoreOoo || satisfiesMinimalVersion(
127 getReferenceOpenOfficeOrgMajorMinor(),
128 e->getAttribute(
"value"));
129 }
else if ( e->getNamespaceURI() == namespaceOpenOfficeOrg && e->getTagName() == maximalVersionOpenOfficeOrg )
131 sat = bIgnoreOoo || satisfiesMaximalVersion(
132 getReferenceOpenOfficeOrgMajorMinor(),
133 e->getAttribute(
"value"));
134 }
else if (e->getNamespaceURI() == namespaceLibreOffice && e->getTagName() == minimalVersionLibreOffice )
136 sat = satisfiesMinimalVersion(
137 getLibreOfficeMajorMinorMicro(),
138 e->getAttribute(
"value"));
139 }
else if (e->getNamespaceURI() == namespaceLibreOffice && e->getTagName() == maximalVersionLibreOffice )
141 sat = satisfiesMaximalVersion(getLibreOfficeMajorMinorMicro(), e->getAttribute(
"value"));
142 }
else if (e->hasAttributeNS(namespaceOpenOfficeOrg,
143 minimalVersionOpenOfficeOrg))
145 sat = satisfiesMinimalVersion(
146 getReferenceOpenOfficeOrgMajorMinor(),
147 e->getAttributeNS(namespaceOpenOfficeOrg,
148 minimalVersionOpenOfficeOrg));
151 unsatisfiedRange[unsat++] = e;
154 unsatisfied.realloc(unsat);
159 css::uno::Reference< css::xml::dom::XElement >
const & dependency)
161 OSL_ASSERT(dependency.is());
162 if ( dependency->getNamespaceURI() == namespaceOpenOfficeOrg && dependency->getTagName() == minimalVersionOpenOfficeOrg )
164 return produceErrorText(
165 DpResId(RID_DEPLOYMENT_DEPENDENCIES_OOO_MIN),
166 dependency->getAttribute(
"value"));
167 }
else if (dependency->getNamespaceURI() == namespaceOpenOfficeOrg && dependency->getTagName() == maximalVersionOpenOfficeOrg )
169 return produceErrorText(
170 DpResId(RID_DEPLOYMENT_DEPENDENCIES_OOO_MAX),
171 dependency->getAttribute(
"value"));
172 }
else if (dependency->getNamespaceURI() == namespaceLibreOffice && dependency->getTagName() == minimalVersionLibreOffice )
174 return produceErrorText(
175 DpResId(RID_DEPLOYMENT_DEPENDENCIES_LO_MIN),
176 dependency->getAttribute(
"value"));
177 }
else if (dependency->getNamespaceURI() == namespaceLibreOffice && dependency->getTagName() == maximalVersionLibreOffice )
179 return produceErrorText(
180 DpResId(RID_DEPLOYMENT_DEPENDENCIES_LO_MAX),
181 dependency->getAttribute(
"value"));
182 }
else if (dependency->hasAttributeNS(namespaceOpenOfficeOrg,
183 minimalVersionOpenOfficeOrg))
185 return produceErrorText(
186 DpResId(RID_DEPLOYMENT_DEPENDENCIES_OOO_MIN),
187 dependency->getAttributeNS(namespaceOpenOfficeOrg,
188 minimalVersionOpenOfficeOrg));
190 return DpResId(RID_DEPLOYMENT_DEPENDENCIES_UNKNOWN);
Access to the content of an XML description element.
css::uno::Reference< css::xml::dom::XNodeList > getDependencies() const
Return the dependencies.
static OUString getAboutBoxProductVersion()
#define SAL_CONFIGFILE(name)
OUString DpResId(TranslateId aId)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getErrorText(css::uno::Reference< css::xml::dom::XElement > const &dependency)
Obtain the (human-readable) error message of a failed dependency.
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > check(dp_misc::DescriptionInfoset const &infoset)
Check for unsatisfied dependencies.
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order compareVersions(std::u16string_view version1, std::u16string_view version2)