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);
88 buf.append(templateName);
91 for (sal_Int32
i = 0;
i <
name.getLength(); ++
i) {
101 buf.append(
"'");
109 return buf.makeStringAndClear();
113 OUString
const & path, sal_Int32 index, OUString *
name,
114 bool * setElement, OUString * templateName)
118 setElement !=
nullptr);
120 while (
i < path.getLength() && path[
i] !=
'/' && path[
i] !=
'[') {
123 if (
i == path.getLength() || path[
i] ==
'/') {
128 if (templateName !=
nullptr) {
130 templateName->clear();
135 if (++
i == path.getLength()) {
139 if (del !=
'\'' && del !=
'"') {
142 sal_Int32 j = path.indexOf(del,
i);
143 if (j == -1 || j + 1 == path.getLength() || path[j + 1] !=
']' ||
144 !decode(path,
i, j,
name))
153 std::u16string_view component, std::u16string_view
name)
155 if (component.find(
':') != std::u16string_view::npos ||
name.find(
':') != std::u16string_view::npos) {
156 throw css::uno::RuntimeException(
157 OUString::Concat(
"bad component/name pair containing colon ") + component +
"/" +
160 return OUString::Concat(component) +
":" +
name;
164 OUString
const & shortName, OUString
const & longName)
166 if (shortName.indexOf(
':') == -1) {
167 sal_Int32
i = longName.indexOf(
':') + 1;
170 rtl_ustr_compare_WithLength(
171 shortName.getStr(), shortName.getLength(),
172 longName.getStr() +
i, longName.getLength() -
i) ==
175 return shortName == longName;
182 OUString
const & pathRepresentation,
183 OUString * canonicRepresentation, std::vector<OUString> * path,
int * finalizedLayer)
186 if (pathRepresentation.isEmpty() || pathRepresentation[0] !=
'/') {
187 throw css::uno::RuntimeException(
188 "bad path " + pathRepresentation);
190 if (path !=
nullptr) {
193 if (pathRepresentation ==
"/") {
194 if (canonicRepresentation !=
nullptr) {
195 *canonicRepresentation = pathRepresentation;
197 if (finalizedLayer !=
nullptr) {
204 OUString templateName;
205 sal_Int32
n =
parseSegment(pathRepresentation, 1, &seg, &setElement,
nullptr);
206 if (
n == -1 || setElement)
208 throw css::uno::RuntimeException(
209 "bad path " + pathRepresentation);
213 OUStringBuffer canonic(128);
220 if (canonicRepresentation !=
nullptr) {
224 if (path !=
nullptr) {
225 path->push_back(seg);
227 finalized = std::min(finalized,
p->getFinalized());
228 if (
n != pathRepresentation.getLength() &&
229 pathRepresentation[
n++] !=
'/')
231 throw css::uno::RuntimeException(
232 "bad path " + pathRepresentation);
235 if (
n == pathRepresentation.getLength()) {
236 if (canonicRepresentation !=
nullptr) {
237 *canonicRepresentation = canonic.makeStringAndClear();
239 if (finalizedLayer !=
nullptr) {
240 *finalizedLayer = finalized;
245 templateName.clear();
247 pathRepresentation,
n, &seg, &setElement, &templateName);
249 throw css::uno::RuntimeException(
250 "bad path " + pathRepresentation);
254 p =
p->getMember(seg);
256 switch (parent->kind()) {
258 if (!templateName.isEmpty()) {
259 throw css::uno::RuntimeException(
260 "bad path " + pathRepresentation);
264 if (!templateName.isEmpty() &&
268 throw css::uno::RuntimeException(
269 "bad path " + pathRepresentation);
273 throw css::uno::RuntimeException(
274 "bad path " + pathRepresentation);
276 if (!templateName.isEmpty() &&
p !=
nullptr) {
277 assert(!
p->getTemplateName().isEmpty());
279 throw css::uno::RuntimeException(
280 "bad path " + pathRepresentation);
288 int layer, OUString
const & fullName)
const
294 return root_->getMembers();
298 OUString
const & url,
int layer)
301 ExtensionXcuAdditions::iterator
i(
304 if (
i->second.is()) {
305 throw css::uno::RuntimeException(
306 "already added extension xcu " + url);
310 return &item->additions;
314 OUString
const & url)
326 "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)