sb130: #i113096# previous configmgr::Components::removeExtensionXcuFile changes were still not good
This commit is contained in:
parent
abccae0c72
commit
4ea577d0ef
@ -120,26 +120,26 @@ rtl::OUString expand(rtl::OUString const & str) {
|
||||
return s;
|
||||
}
|
||||
|
||||
bool hasOnlyEmptySets(rtl::Reference< Node > const & node) {
|
||||
bool canRemoveFromLayer(int layer, rtl::Reference< Node > const & node) {
|
||||
OSL_ASSERT(node.is());
|
||||
if (node->getLayer() > layer && node->getLayer() < Data::NO_LAYER) {
|
||||
return false;
|
||||
}
|
||||
switch (node->kind()) {
|
||||
default: // Node::KIND_LOCALIZED_VALUE
|
||||
OSL_ASSERT(false);
|
||||
// fall through
|
||||
case Node::KIND_PROPERTY:
|
||||
case Node::KIND_LOCALIZED_PROPERTY:
|
||||
return true;
|
||||
case Node::KIND_GROUP:
|
||||
for (NodeMap::iterator i(node->getMembers().begin());
|
||||
i != node->getMembers().end(); ++i)
|
||||
{
|
||||
if (!hasOnlyEmptySets(i->second)) {
|
||||
if (!canRemoveFromLayer(layer, i->second)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case Node::KIND_SET:
|
||||
return node->getMembers().empty();
|
||||
default: // Node::KIND_PROPERTY, Node::KIND_LOCALIZED_VALUE
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +282,8 @@ void Components::removeExtensionXcuFile(
|
||||
// be removed. However, not enough information is recorded in the in-memory
|
||||
// data structures to do so. So, as a workaround, all those set elements
|
||||
// that were freshly added by the xcu and have afterwards been left
|
||||
// unchanged are removed (and nothing else). The heuristic to determine
|
||||
// unchanged or have only had their properties changed in the user layer are
|
||||
// removed (and nothing else). The heuristic to determine
|
||||
// whether a node has been left unchanged is to check the layer ID (as
|
||||
// usual) and additionally to check that the node does not recursively
|
||||
// contain any non-empty sets (multiple extension xcu files are merged into
|
||||
@ -302,7 +303,7 @@ void Components::removeExtensionXcuFile(
|
||||
rtl::Reference< Node > node;
|
||||
for (Path::const_iterator j(i->begin()); j != i->end(); ++j) {
|
||||
parent = node;
|
||||
node = Data::findNode(item->layer, *map, *j);
|
||||
node = Data::findNode(Data::NO_LAYER, *map, *j);
|
||||
if (!node.is()) {
|
||||
break;
|
||||
}
|
||||
@ -314,14 +315,15 @@ void Components::removeExtensionXcuFile(
|
||||
OSL_ASSERT(
|
||||
node->kind() == Node::KIND_GROUP ||
|
||||
node->kind() == Node::KIND_SET);
|
||||
if (hasOnlyEmptySets(node)) {
|
||||
if (canRemoveFromLayer(item->layer, node)) {
|
||||
parent->getMembers().erase(i->back());
|
||||
addModification(*i);
|
||||
data_.modifications.remove(*i);
|
||||
modifications->add(*i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
writeModifications();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,27 @@ void Modifications::add(Path const & path) {
|
||||
p->children.clear();
|
||||
}
|
||||
|
||||
void Modifications::remove(Path const & path) {
|
||||
OSL_ASSERT(!path.empty());
|
||||
Node * p = &root_;
|
||||
for (Path::const_iterator i(path.begin());;) {
|
||||
Node::Children::iterator j(p->children.find(*i));
|
||||
if (j == p->children.end()) {
|
||||
break;
|
||||
}
|
||||
if (++i == path.end()) {
|
||||
p->children.erase(j);
|
||||
if (p->children.empty()) {
|
||||
Path parent(path);
|
||||
parent.pop_back();
|
||||
remove(parent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
p = &j->second;
|
||||
}
|
||||
}
|
||||
|
||||
Modifications::Node const & Modifications::getRoot() const {
|
||||
return root_;
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
|
||||
void add(Path const & path);
|
||||
|
||||
void remove(Path const & path);
|
||||
|
||||
Node const & getRoot() const;
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user