diff options
author | sb <sb@openoffice.org> | 2010-08-26 17:11:05 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-08-26 17:11:05 +0200 |
commit | 4ea577d0efe22e5785c8ae72c86f517fd2cf9194 (patch) | |
tree | 4dc2b6c90b08dfa5a06073745132405a648eace6 /configmgr/source | |
parent | abccae0c72bb7ec1b813653b256fe34ffb047279 (diff) |
sb130: #i113096# previous configmgr::Components::removeExtensionXcuFile changes were still not good
Diffstat (limited to 'configmgr/source')
-rw-r--r-- | configmgr/source/components.cxx | 24 | ||||
-rw-r--r-- | configmgr/source/modifications.cxx | 21 | ||||
-rw-r--r-- | configmgr/source/modifications.hxx | 2 |
3 files changed, 36 insertions, 11 deletions
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index e76460de5b64..33b0eca3f65f 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -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(); } } diff --git a/configmgr/source/modifications.cxx b/configmgr/source/modifications.cxx index 2ad3b5ef8bd1..add18ceaa1ea 100644 --- a/configmgr/source/modifications.cxx +++ b/configmgr/source/modifications.cxx @@ -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_; } diff --git a/configmgr/source/modifications.hxx b/configmgr/source/modifications.hxx index e29a10150148..c28b1aadd192 100644 --- a/configmgr/source/modifications.hxx +++ b/configmgr/source/modifications.hxx @@ -54,6 +54,8 @@ public: void add(Path const & path); + void remove(Path const & path); + Node const & getRoot() const; private: |