sb139: #i116391# for backwards compatibility, allow absolute paths in configmgr getByHierarchicalName et al
This commit is contained in:
parent
d64c1529ac
commit
93f059dfb6
@ -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)
|
||||
{
|
||||
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:
|
||||
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 >();
|
||||
}
|
||||
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 >();
|
||||
}
|
||||
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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user