26#include <com/sun/star/uno/RuntimeException.hpp>
28#include <rtl/string.h>
29#include <rtl/ustrbuf.hxx>
30#include <rtl/ustring.h>
31#include <rtl/ustring.hxx>
48 std::u16string_view encoded, std::size_t begin, std::size_t end,
52 begin <= end && end <= encoded.size() &&
54 OUStringBuffer buf(end - begin);
55 while (begin != end) {
60 begin += RTL_CONSTASCII_LENGTH(
"amp;");
63 begin += RTL_CONSTASCII_LENGTH(
"quot;");
66 begin += RTL_CONSTASCII_LENGTH(
"apos;");
75 *decoded = buf.makeStringAndClear();
82 std::u16string_view templateName, OUString
const &
name)
84 if (templateName.empty()) {
87 OUStringBuffer buf(128);
89 buf.append(OUString::Concat(templateName) +
"['");
90 for (sal_Int32
i = 0;
i <
name.getLength(); ++
i) {
100 buf.append(
"'");
108 return buf.makeStringAndClear();
112 OUString
const & path, sal_Int32 index, OUString *
name,
113 bool * setElement, OUString * templateName)
117 setElement !=
nullptr);
119 while (
i < path.getLength() && path[
i] !=
'/' && path[
i] !=
'[') {
122 if (
i == path.getLength() || path[
i] ==
'/') {
129 if (templateName !=
nullptr) {
130 templateName->clear();
134 if (templateName !=
nullptr) {
138 if (++
i == path.getLength()) {
142 if (del !=
'\'' && del !=
'"') {
145 sal_Int32 j = path.indexOf(del,
i);
146 if (j == -1 || j + 1 == path.getLength() || path[j + 1] !=
']' ||
147 !decode(path,
i, j,
name))
155 std::u16string_view component, std::u16string_view
name)
157 if (component.find(
':') != std::u16string_view::npos ||
name.find(
':') != std::u16string_view::npos) {
158 throw css::uno::RuntimeException(
159 OUString::Concat(
"bad component/name pair containing colon ") + component +
"/" +
162 return OUString::Concat(component) +
":" +
name;
166 OUString
const & shortName, OUString
const & longName)
168 if (shortName.indexOf(
':') == -1) {
169 sal_Int32
i = longName.indexOf(
':') + 1;
172 rtl_ustr_compare_WithLength(
173 shortName.getStr(), shortName.getLength(),
174 longName.getStr() +
i, longName.getLength() -
i) ==
177 return shortName == longName;
184 OUString
const & pathRepresentation,
185 OUString * canonicRepresentation, std::vector<OUString> * path,
int * finalizedLayer)
188 if (pathRepresentation.isEmpty() || pathRepresentation[0] !=
'/') {
189 throw css::uno::RuntimeException(
190 "bad path " + pathRepresentation);
192 if (path !=
nullptr) {
195 if (pathRepresentation ==
"/") {
196 if (canonicRepresentation !=
nullptr) {
197 *canonicRepresentation = pathRepresentation;
199 if (finalizedLayer !=
nullptr) {
206 OUString templateName;
207 sal_Int32
n =
parseSegment(pathRepresentation, 1, &seg, &setElement,
nullptr);
208 if (
n == -1 || setElement)
210 throw css::uno::RuntimeException(
211 "bad path " + pathRepresentation);
215 OUStringBuffer canonic(128);
222 if (canonicRepresentation !=
nullptr) {
225 if (path !=
nullptr) {
226 path->push_back(seg);
228 finalized = std::min(finalized,
p->getFinalized());
229 if (
n != pathRepresentation.getLength() &&
230 pathRepresentation[
n++] !=
'/')
232 throw css::uno::RuntimeException(
233 "bad path " + pathRepresentation);
236 if (
n == pathRepresentation.getLength()) {
237 if (canonicRepresentation !=
nullptr) {
238 *canonicRepresentation = canonic.makeStringAndClear();
240 if (finalizedLayer !=
nullptr) {
241 *finalizedLayer = finalized;
246 templateName.clear();
248 pathRepresentation,
n, &seg, &setElement, &templateName);
250 throw css::uno::RuntimeException(
251 "bad path " + pathRepresentation);
255 p =
p->getMember(seg);
257 switch (parent->kind()) {
259 if (!templateName.isEmpty()) {
260 throw css::uno::RuntimeException(
261 "bad path " + pathRepresentation);
265 if (!templateName.isEmpty() &&
269 throw css::uno::RuntimeException(
270 "bad path " + pathRepresentation);
274 throw css::uno::RuntimeException(
275 "bad path " + pathRepresentation);
277 if (!templateName.isEmpty() &&
p !=
nullptr) {
278 assert(!
p->getTemplateName().isEmpty());
280 throw css::uno::RuntimeException(
281 "bad path " + pathRepresentation);
289 int layer, OUString
const & fullName)
const
295 return root_->getMembers();
299 OUString
const & url,
int layer)
302 ExtensionXcuAdditions::iterator
i(
305 if (
i->second.is()) {
306 throw css::uno::RuntimeException(
307 "already added extension xcu " + url);
311 return &item->additions;
315 OUString
const & url)
327 "unknown Data::removeExtensionXcuAdditions(" << url <<
")");
NodeMapImpl::const_iterator const_iterator
rtl::Reference< Node > findNode(int layer, OUString const &name) const
iterator find(const OUString &aStr)
@ KIND_LOCALIZED_PROPERTY
bool isValidTemplate(OUString const &templateName) const
#define SAL_INFO(area, stream)
std::vector< std::vector< OUString > > Additions
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
enumrange< T >::Iterator begin(enumrange< T >)
rtl::Reference< RootAccess > root_
rtl::Reference< ExtensionXcu > removeExtensionXcuAdditions(OUString const &url)
static OUString fullTemplateName(std::u16string_view component, std::u16string_view name)
ExtensionXcuAdditions extensionXcuAdditions_
rtl::Reference< Node > root_
static sal_Int32 parseSegment(OUString const &path, sal_Int32 index, OUString *name, bool *setElement, OUString *templateName)
rtl::Reference< Node > resolvePathRepresentation(OUString const &pathRepresentation, OUString *canonicRepresentation, std::vector< OUString > *path, int *finalizedLayer) const
NodeMap & getComponents() const
static bool equalTemplateNames(OUString const &shortName, OUString const &longName)
Additions * addExtensionXcuAdditions(OUString const &url, int layer)
rtl::Reference< Node > getTemplate(int layer, OUString const &fullName) const
static OUString createSegment(std::u16string_view templateName, OUString const &name)