25 #include <com/sun/star/uno/RuntimeException.hpp>
26 #include <rtl/ref.hxx>
27 #include <rtl/string.h>
28 #include <rtl/ustrbuf.hxx>
29 #include <rtl/ustring.h>
30 #include <rtl/ustring.hxx>
46 OUString
const & encoded, sal_Int32 begin, sal_Int32 end,
50 begin >= 0 && begin <= end && end <= encoded.getLength() &&
52 OUStringBuffer buf(end - begin);
53 while (begin != end) {
56 if (encoded.match(
"amp;", begin)) {
58 begin += RTL_CONSTASCII_LENGTH(
"amp;");
59 }
else if (encoded.match(
"quot;", begin)) {
61 begin += RTL_CONSTASCII_LENGTH(
"quot;");
62 }
else if (encoded.match(
"apos;", begin)) {
64 begin += RTL_CONSTASCII_LENGTH(
"apos;");
73 *decoded = buf.makeStringAndClear();
80 std::u16string_view templateName, OUString
const &
name)
82 if (templateName.empty()) {
85 OUStringBuffer buf(128);
86 buf.append(templateName);
89 for (sal_Int32
i = 0;
i < name.getLength(); ++
i) {
107 return buf.makeStringAndClear();
111 OUString
const & path, sal_Int32 index, OUString *
name,
112 bool * setElement, OUString * templateName)
115 index >= 0 && index <= path.getLength() && name !=
nullptr &&
116 setElement !=
nullptr);
118 while (i < path.getLength() && path[i] !=
'/' && path[i] !=
'[') {
121 if (i == path.getLength() || path[i] ==
'/') {
122 *name = path.copy(index, i - index);
126 if (templateName !=
nullptr) {
127 if (i - index == 1 && path[index] ==
'*') {
128 templateName->clear();
130 *templateName = path.copy(index, i - index);
133 if (++i == path.getLength()) {
137 if (del !=
'\'' && del !=
'"') {
140 sal_Int32 j = path.indexOf(del, i);
141 if (j == -1 || j + 1 == path.getLength() || path[j + 1] !=
']' ||
142 !decode(path, i, j, name))
151 OUString
const & component, OUString
const &
name)
153 if (component.indexOf(
':') != -1 || name.indexOf(
':') != -1) {
154 throw css::uno::RuntimeException(
155 "bad component/name pair containing colon " + component +
"/" +
158 return component +
":" +
name;
162 OUString
const & shortName, OUString
const & longName)
164 if (shortName.indexOf(
':') == -1) {
165 sal_Int32
i = longName.indexOf(
':') + 1;
168 rtl_ustr_compare_WithLength(
169 shortName.getStr(), shortName.getLength(),
170 longName.getStr() + i, longName.getLength() - i) ==
173 return shortName == longName;
180 OUString
const & pathRepresentation,
181 OUString * canonicRepresentation, std::vector<OUString> * path,
int * finalizedLayer)
184 if (pathRepresentation.isEmpty() || pathRepresentation[0] !=
'/') {
185 throw css::uno::RuntimeException(
186 "bad path " + pathRepresentation);
188 if (path !=
nullptr) {
191 if (pathRepresentation ==
"/") {
192 if (canonicRepresentation !=
nullptr) {
193 *canonicRepresentation = pathRepresentation;
195 if (finalizedLayer !=
nullptr) {
202 OUString templateName;
203 sal_Int32
n =
parseSegment(pathRepresentation, 1, &seg, &setElement,
nullptr);
204 if (n == -1 || setElement)
206 throw css::uno::RuntimeException(
207 "bad path " + pathRepresentation);
211 OUStringBuffer canonic(128);
218 if (canonicRepresentation !=
nullptr) {
222 if (path !=
nullptr) {
223 path->push_back(seg);
225 finalized = std::min(finalized,
p->getFinalized());
226 if (n != pathRepresentation.getLength() &&
227 pathRepresentation[n++] !=
'/')
229 throw css::uno::RuntimeException(
230 "bad path " + pathRepresentation);
233 if (n == pathRepresentation.getLength()) {
234 if (canonicRepresentation !=
nullptr) {
235 *canonicRepresentation = canonic.makeStringAndClear();
237 if (finalizedLayer !=
nullptr) {
238 *finalizedLayer = finalized;
243 templateName.clear();
245 pathRepresentation, n, &seg, &setElement, &templateName);
247 throw css::uno::RuntimeException(
248 "bad path " + pathRepresentation);
252 p =
p->getMember(seg);
254 switch (parent->kind()) {
256 if (!templateName.isEmpty()) {
257 throw css::uno::RuntimeException(
258 "bad path " + pathRepresentation);
262 if (!templateName.isEmpty() &&
263 !
static_cast< SetNode *
>(parent.get())->isValidTemplate(
266 throw css::uno::RuntimeException(
267 "bad path " + pathRepresentation);
271 throw css::uno::RuntimeException(
272 "bad path " + pathRepresentation);
274 if (!templateName.isEmpty() &&
p !=
nullptr) {
275 assert(!
p->getTemplateName().isEmpty());
277 throw css::uno::RuntimeException(
278 "bad path " + pathRepresentation);
286 int layer, OUString
const & fullName)
const
292 return root_->getMembers();
296 OUString
const & url,
int layer)
299 ExtensionXcuAdditions::iterator
i(
302 if (
i->second.is()) {
303 throw css::uno::RuntimeException(
304 "already added extension xcu " + url);
308 return &item->additions;
312 OUString
const & url)
324 "unknown Data::removeExtensionXcuAdditions(" << url <<
")");
iterator find(const OUString &aStr)
static OUString createSegment(std::u16string_view templateName, OUString const &name)
rtl::Reference< ExtensionXcu > removeExtensionXcuAdditions(OUString const &url)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
Additions * addExtensionXcuAdditions(OUString const &url, int layer)
static OUString fullTemplateName(OUString const &component, OUString const &name)
rtl::Reference< RootAccess > root_
std::vector< std::vector< OUString > > Additions
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)
#define SAL_INFO(area, stream)
static sal_Int32 parseSegment(OUString const &path, sal_Int32 index, OUString *name, bool *setElement, OUString *templateName)
rtl::Reference< Node > getTemplate(int layer, OUString const &fullName) const
NodeMapImpl::const_iterator const_iterator
rtl::Reference< Node > findNode(int layer, OUString const &name) const
rtl::Reference< Node > root_
ExtensionXcuAdditions extensionXcuAdditions_