summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2011-01-10 16:45:42 +0100
committersb <sb@openoffice.org>2011-01-10 16:45:42 +0100
commit93f059dfb6d817afaff56694f242dba3a1897c3b (patch)
tree55af0681b8db3e7669b96d5a715999736889e82a /configmgr
parentd64c1529ace2ddf4060704a1a871c005156c5a81 (diff)
sb139: #i116391# for backwards compatibility, allow absolute paths in configmgr getByHierarchicalName et al
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/access.cxx100
1 files changed, 69 insertions, 31 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 933a414d331c..2548643c7ce1 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -1993,45 +1993,83 @@ rtl::Reference< ChildAccess > Access::getUnmodifiedChild(
}
rtl::Reference< ChildAccess > Access::getSubChild(rtl::OUString const & path) {
- rtl::OUString name;
- bool setElement;
- rtl::OUString templateName;
- sal_Int32 i = Data::parseSegment(
- path, 0, &name, &setElement, &templateName);
- if (i == -1 || (i != path.getLength() && path[i] != '/')) {
- return rtl::Reference< ChildAccess >();
- }
- rtl::Reference< ChildAccess > child(getChild(name));
- if (!child.is()) {
- return rtl::Reference< ChildAccess >();
- }
- if (setElement) {
- rtl::Reference< Node > p(getNode());
- switch (p->kind()) {
- case Node::KIND_LOCALIZED_PROPERTY:
- if (!Components::allLocales(getRootAccess()->getLocale()) ||
- templateName.getLength() != 0)
- {
+ sal_Int32 i = 0;
+ // For backwards compatibility, allow absolute paths where meaningful:
+ if (path.getLength() != 0 && path[0] == '/') {
+ ++i;
+ if (!getRootAccess().is()) {
+ return rtl::Reference< ChildAccess >();
+ }
+ Path abs(getAbsolutePath());
+ for (Path::iterator j(abs.begin()); j != abs.end(); ++j) {
+ rtl::OUString name1;
+ bool setElement1;
+ rtl::OUString templateName1;
+ i = Data::parseSegment(
+ path, i, &name1, &setElement1, &templateName1);
+ if (i == -1 || (i != path.getLength() && path[i] != '/')) {
return rtl::Reference< ChildAccess >();
}
- break;
- case Node::KIND_SET:
- if (templateName.getLength() != 0 &&
- !dynamic_cast< SetNode * >(p.get())->isValidTemplate(
- templateName))
+ rtl::OUString name2;
+ bool setElement2;
+ rtl::OUString templateName2;
+ Data::parseSegment(*j, 0, &name2, &setElement2, &templateName2);
+ if (name1 != name2 || setElement1 != setElement2 ||
+ (setElement1 &&
+ !Data::equalTemplateNames(templateName1, templateName2)))
{
return rtl::Reference< ChildAccess >();
}
- break;
- default:
+ if (i != path.getLength()) {
+ ++i;
+ }
+ }
+ }
+ for (rtl::Reference< Access > parent(this);;) {
+ rtl::OUString name;
+ bool setElement;
+ rtl::OUString templateName;
+ i = Data::parseSegment(path, i, &name, &setElement, &templateName);
+ if (i == -1 || (i != path.getLength() && path[i] != '/')) {
return rtl::Reference< ChildAccess >();
}
+ rtl::Reference< ChildAccess > child(parent->getChild(name));
+ if (!child.is()) {
+ return rtl::Reference< ChildAccess >();
+ }
+ if (setElement) {
+ rtl::Reference< Node > p(parent->getNode());
+ switch (p->kind()) {
+ case Node::KIND_LOCALIZED_PROPERTY:
+ if (!Components::allLocales(getRootAccess()->getLocale()) ||
+ templateName.getLength() != 0)
+ {
+ return rtl::Reference< ChildAccess >();
+ }
+ break;
+ case Node::KIND_SET:
+ if (templateName.getLength() != 0 &&
+ !dynamic_cast< SetNode * >(p.get())->isValidTemplate(
+ templateName))
+ {
+ return rtl::Reference< ChildAccess >();
+ }
+ break;
+ default:
+ return rtl::Reference< ChildAccess >();
+ }
+ }
+ // For backwards compatibility, ignore a final slash after non-value
+ // nodes:
+ if (child->isValue()) {
+ return i == path.getLength()
+ ? child : rtl::Reference< ChildAccess >();
+ } else if (i >= path.getLength() - 1) {
+ return child;
+ }
+ ++i;
+ parent = child.get();
}
- // For backwards compatibility, ignore a final slash after non-value nodes:
- return child->isValue()
- ? (i == path.getLength() ? child : rtl::Reference< ChildAccess >())
- : (i >= path.getLength() - 1
- ? child : child->getSubChild(path.copy(i + 1)));
}
bool Access::setChildProperty(