diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-12-13 22:16:31 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-12-13 22:16:31 +0100 |
commit | db4bc6812d69d960a558b89c18f08b17a2e38d27 (patch) | |
tree | 15d6547e929635baaffd9a4008a872e9d1c246e6 /configmgr | |
parent | 39cbce553da1834f78b77f48b2f1be9578d6cc05 (diff) |
Unified configmgr::Node::getMember{s,Map} again.
(With the insight that Data::components is RootNode::members.)
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/access.cxx | 41 | ||||
-rw-r--r-- | configmgr/source/components.cxx | 6 | ||||
-rw-r--r-- | configmgr/source/data.cxx | 7 | ||||
-rw-r--r-- | configmgr/source/data.hxx | 4 | ||||
-rw-r--r-- | configmgr/source/groupnode.cxx | 4 | ||||
-rw-r--r-- | configmgr/source/groupnode.hxx | 2 | ||||
-rw-r--r-- | configmgr/source/localizedpropertynode.cxx | 4 | ||||
-rw-r--r-- | configmgr/source/localizedpropertynode.hxx | 2 | ||||
-rw-r--r-- | configmgr/source/node.cxx | 18 | ||||
-rw-r--r-- | configmgr/source/node.hxx | 3 | ||||
-rw-r--r-- | configmgr/source/rootnode.cxx | 10 | ||||
-rw-r--r-- | configmgr/source/rootnode.hxx | 9 | ||||
-rw-r--r-- | configmgr/source/setnode.cxx | 4 | ||||
-rw-r--r-- | configmgr/source/setnode.hxx | 2 | ||||
-rw-r--r-- | configmgr/source/valueparser.cxx | 9 | ||||
-rw-r--r-- | configmgr/source/writemodfile.cxx | 3 | ||||
-rw-r--r-- | configmgr/source/xcsparser.cxx | 31 | ||||
-rw-r--r-- | configmgr/source/xcuparser.cxx | 50 |
18 files changed, 97 insertions, 112 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 7fc239cb9d5c..b6617b416c66 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -1607,31 +1607,28 @@ void Access::commitChildChanges( // children); clarify what exactly should happen here for // directly inserted children } - NodeMap * members = getNode()->getMemberMap(); - if (members != 0) { - NodeMap::iterator j(members->find(i->first)); - if (child.is()) { - // Inserted: - if (j != members->end()) { - childValid = childValid && - j->second->getFinalized() == Data::NO_LAYER; - if (childValid) { - child->getNode()->setMandatory( - j->second->getMandatory()); - } - } - if (childValid) { - (*members)[i->first] = child->getNode(); - } - } else { - // Removed: - childValid = childValid && j != members->end() && - j->second->getFinalized() == Data::NO_LAYER && - j->second->getMandatory() == Data::NO_LAYER; + NodeMap & members = getNode()->getMembers(); + NodeMap::iterator j(members.find(i->first)); + if (child.is()) { + // Inserted: + if (j != members.end()) { + childValid = childValid && + j->second->getFinalized() == Data::NO_LAYER; if (childValid) { - members->erase(j); + child->getNode()->setMandatory(j->second->getMandatory()); } } + if (childValid) { + members[i->first] = child->getNode(); + } + } else { + // Removed: + childValid = childValid && j != members.end() && + j->second->getFinalized() == Data::NO_LAYER && + j->second->getMandatory() == Data::NO_LAYER; + if (childValid) { + members.erase(j); + } } if (childValid && i->second.directlyModified) { Path path(getAbsolutePath()); diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 56c597593395..77f8c012e368 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -385,7 +385,7 @@ void Components::removeExtensionXcuFile( i != item->additions.rend(); ++i) { rtl::Reference< Node > parent; - NodeMap const * map = &data_.components; + NodeMap const * map = &data_.getComponents(); rtl::Reference< Node > node; for (Path::const_iterator j(i->begin()); j != i->end(); ++j) { parent = node; @@ -402,9 +402,7 @@ void Components::removeExtensionXcuFile( node->kind() == Node::KIND_GROUP || node->kind() == Node::KIND_SET); if (canRemoveFromLayer(item->layer, node)) { - NodeMap * members = parent->getMemberMap(); - assert(members != 0); - members->erase(i->back()); + parent->getMembers().erase(i->back()); data_.modifications.remove(*i); modifications->add(*i); } diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx index fcc42e97cecc..df7ce604b649 100644 --- a/configmgr/source/data.cxx +++ b/configmgr/source/data.cxx @@ -208,7 +208,7 @@ rtl::Reference< Node > Data::findNode( ? rtl::Reference< Node >() : i->second; } -Data::Data(): root_(new RootNode(components)) {} +Data::Data(): root_(new RootNode) {} rtl::Reference< Node > Data::resolvePathRepresentation( rtl::OUString const & pathRepresentation, @@ -244,6 +244,7 @@ rtl::Reference< Node > Data::resolvePathRepresentation( pathRepresentation), css::uno::Reference< css::uno::XInterface >()); } + NodeMap const & components = getComponents(); NodeMap::const_iterator i(components.find(seg)); rtl::OUStringBuffer canonic; rtl::Reference< Node > parent; @@ -340,6 +341,10 @@ rtl::Reference< Node > Data::getTemplate( return findNode(layer, templates, fullName); } +NodeMap & Data::getComponents() const { + return root_->getMembers(); +} + Additions * Data::addExtensionXcuAdditions( rtl::OUString const & url, int layer) { diff --git a/configmgr/source/data.hxx b/configmgr/source/data.hxx index 64980eef4056..b557ea1e817c 100644 --- a/configmgr/source/data.hxx +++ b/configmgr/source/data.hxx @@ -60,8 +60,6 @@ struct Data: private boost::noncopyable { NodeMap templates; - NodeMap components; - Modifications modifications; static rtl::OUString createSegment( @@ -91,6 +89,8 @@ struct Data: private boost::noncopyable { rtl::Reference< Node > getTemplate( int layer, rtl::OUString const & fullName) const; + NodeMap & getComponents() const; + Additions * addExtensionXcuAdditions( rtl::OUString const & url, int layer); diff --git a/configmgr/source/groupnode.cxx b/configmgr/source/groupnode.cxx index 09658567b4c3..5591acbe606d 100644 --- a/configmgr/source/groupnode.cxx +++ b/configmgr/source/groupnode.cxx @@ -48,8 +48,8 @@ rtl::Reference< Node > GroupNode::clone(bool keepTemplateName) const { return new GroupNode(*this, keepTemplateName); } -NodeMap * GroupNode::getMemberMap() { - return &members_; +NodeMap & GroupNode::getMembers() { + return members_; } rtl::OUString GroupNode::getTemplateName() const { diff --git a/configmgr/source/groupnode.hxx b/configmgr/source/groupnode.hxx index 1d14a9293a6b..02f1679998a2 100644 --- a/configmgr/source/groupnode.hxx +++ b/configmgr/source/groupnode.hxx @@ -45,7 +45,7 @@ public: virtual rtl::Reference< Node > clone(bool keepTemplateName) const; - virtual NodeMap * getMemberMap(); + virtual NodeMap & getMembers(); virtual rtl::OUString getTemplateName() const; diff --git a/configmgr/source/localizedpropertynode.cxx b/configmgr/source/localizedpropertynode.cxx index 196e57f6a6f9..270485835228 100644 --- a/configmgr/source/localizedpropertynode.cxx +++ b/configmgr/source/localizedpropertynode.cxx @@ -55,8 +55,8 @@ rtl::Reference< Node > LocalizedPropertyNode::clone(bool) const { return new LocalizedPropertyNode(*this); } -NodeMap * LocalizedPropertyNode::getMemberMap() { - return &members_; +NodeMap & LocalizedPropertyNode::getMembers() { + return members_; } Type LocalizedPropertyNode::getStaticType() const { diff --git a/configmgr/source/localizedpropertynode.hxx b/configmgr/source/localizedpropertynode.hxx index b49f375c43c2..bbe934e36bcd 100644 --- a/configmgr/source/localizedpropertynode.hxx +++ b/configmgr/source/localizedpropertynode.hxx @@ -50,7 +50,7 @@ public: virtual rtl::Reference< Node > clone(bool keepTemplateName) const; - virtual NodeMap * getMemberMap(); + virtual NodeMap & getMembers(); Type getStaticType() const; diff --git a/configmgr/source/node.cxx b/configmgr/source/node.cxx index b6480820aedc..773b9246d583 100644 --- a/configmgr/source/node.cxx +++ b/configmgr/source/node.cxx @@ -30,7 +30,11 @@ #include <cassert> +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XInterface.hpp" #include "rtl/ref.hxx" +#include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "data.hxx" @@ -39,15 +43,17 @@ namespace configmgr { -NodeMap const & Node::getMembers() const { - NodeMap * members = const_cast< Node * >(this)->getMemberMap(); - assert(members != 0); - return *members; +namespace { + +namespace css = com::sun::star; + } -NodeMap * Node::getMemberMap() { +NodeMap & Node::getMembers() { assert(false); - return 0; + throw css::uno::RuntimeException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("this cannot happen")), + css::uno::Reference< css::uno::XInterface >()); } rtl::OUString Node::getTemplateName() const { diff --git a/configmgr/source/node.hxx b/configmgr/source/node.hxx index 01aef18c7a6a..f46760855ff3 100644 --- a/configmgr/source/node.hxx +++ b/configmgr/source/node.hxx @@ -50,8 +50,7 @@ public: virtual rtl::Reference< Node > clone(bool keepTemplateName) const = 0; - virtual NodeMap const & getMembers() const; - virtual NodeMap * getMemberMap(); + virtual NodeMap & getMembers(); virtual rtl::OUString getTemplateName() const; virtual void setMandatory(int layer); diff --git a/configmgr/source/rootnode.cxx b/configmgr/source/rootnode.cxx index 3188ea1228dc..67741c78c7d4 100644 --- a/configmgr/source/rootnode.cxx +++ b/configmgr/source/rootnode.cxx @@ -38,9 +38,7 @@ namespace configmgr { -RootNode::RootNode(NodeMap const & members): - Node(Data::NO_LAYER), members_(members) -{} +RootNode::RootNode(): Node(Data::NO_LAYER) {} RootNode::~RootNode() {} @@ -53,14 +51,10 @@ rtl::Reference< Node > RootNode::clone(bool) const { return rtl::Reference< Node >(); } -NodeMap const & RootNode::getMembers() const { +NodeMap & RootNode::getMembers() { return members_; } -NodeMap * RootNode::getMemberMap() { - return 0; -} - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/configmgr/source/rootnode.hxx b/configmgr/source/rootnode.hxx index 97244e470737..4757643fc898 100644 --- a/configmgr/source/rootnode.hxx +++ b/configmgr/source/rootnode.hxx @@ -41,21 +41,18 @@ namespace configmgr { class RootNode: public Node { public: - RootNode(NodeMap const & members); + RootNode(); private: - RootNode(RootNode const & other); - virtual ~RootNode(); virtual Kind kind() const; virtual rtl::Reference< Node > clone(bool keepTemplateName) const; - virtual NodeMap const & getMembers() const; - virtual NodeMap * getMemberMap(); + virtual NodeMap & getMembers(); - NodeMap const & members_; + NodeMap members_; }; } diff --git a/configmgr/source/setnode.cxx b/configmgr/source/setnode.cxx index 214885fff66f..e2a8b2c888eb 100644 --- a/configmgr/source/setnode.cxx +++ b/configmgr/source/setnode.cxx @@ -73,8 +73,8 @@ rtl::Reference< Node > SetNode::clone(bool keepTemplateName) const { return new SetNode(*this, keepTemplateName); } -NodeMap * SetNode::getMemberMap() { - return &members_; +NodeMap & SetNode::getMembers() { + return members_; } rtl::OUString SetNode::getTemplateName() const { diff --git a/configmgr/source/setnode.hxx b/configmgr/source/setnode.hxx index 59bd2587a5ab..00bcab2a55a1 100644 --- a/configmgr/source/setnode.hxx +++ b/configmgr/source/setnode.hxx @@ -49,7 +49,7 @@ public: virtual rtl::Reference< Node > clone(bool keepTemplateName) const; - virtual NodeMap * getMemberMap(); + virtual NodeMap & getMembers(); virtual rtl::OUString getTemplateName() const; diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx index 105d9ef323b8..ab6104d25fc6 100644 --- a/configmgr/source/valueparser.cxx +++ b/configmgr/source/valueparser.cxx @@ -413,11 +413,10 @@ bool ValueParser::endElement() { break; case Node::KIND_LOCALIZED_PROPERTY: { - NodeMap * members = node_->getMemberMap(); - assert(members != 0); - NodeMap::iterator i(members->find(localizedName_)); - if (i == members->end()) { - members->insert( + NodeMap & members = node_->getMembers(); + NodeMap::iterator i(members.find(localizedName_)); + if (i == members.end()) { + members.insert( NodeMap::value_type( localizedName_, new LocalizedValueNode(layer_, value))); diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx index eb896fffbf34..966234281c69 100644 --- a/configmgr/source/writemodfile.cxx +++ b/configmgr/source/writemodfile.cxx @@ -586,7 +586,8 @@ void writeModFile( { writeModifications( components, tmp.handle, rtl::OUString(), rtl::Reference< Node >(), - j->first, Data::findNode(Data::NO_LAYER, data.components, j->first), + j->first, + Data::findNode(Data::NO_LAYER, data.getComponents(), j->first), j->second); } writeData(tmp.handle, RTL_CONSTASCII_STRINGPARAM("</oor:items>")); diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx index 66f3f2891713..ed83d3582b5b 100644 --- a/configmgr/source/xcsparser.cxx +++ b/configmgr/source/xcsparser.cxx @@ -82,15 +82,14 @@ void merge( for (NodeMap::const_iterator i2(update->getMembers().begin()); i2 != update->getMembers().end(); ++i2) { - NodeMap * members = original->getMemberMap(); - assert(members != 0); - NodeMap::iterator i1(members->find(i2->first)); - if (i1 == members->end()) { + NodeMap & members = original->getMembers(); + NodeMap::iterator i1(members.find(i2->first)); + if (i1 == members.end()) { if (i2->second->kind() == Node::KIND_PROPERTY && dynamic_cast< GroupNode * >( original.get())->isExtensible()) { - members->insert(*i2); + members.insert(*i2); } } else if (i2->second->kind() == i1->second->kind()) { merge(i1->second, i2->second); @@ -101,14 +100,13 @@ void merge( for (NodeMap::const_iterator i2(update->getMembers().begin()); i2 != update->getMembers().end(); ++i2) { - NodeMap * members = original->getMemberMap(); - assert(members != 0); - NodeMap::iterator i1(members->find(i2->first)); - if (i1 == members->end()) { + NodeMap & members = original->getMembers(); + NodeMap::iterator i1(members.find(i2->first)); + if (i1 == members.end()) { if (dynamic_cast< SetNode * >(original.get())-> isValidTemplate(i2->second->getTemplateName())) { - members->insert(*i2); + members.insert(*i2); } } else if (i2->second->kind() == i1->second->kind() && (i2->second->getTemplateName() == @@ -298,9 +296,10 @@ void XcsParser::endElement(xmlreader::XmlReader const & reader) { break; case STATE_COMPONENT: { - NodeMap::iterator i(data_.components.find(top.name)); - if (i == data_.components.end()) { - data_.components.insert( + NodeMap & components = data_.getComponents(); + NodeMap::iterator i(components.find(top.name)); + if (i == components.end()) { + components.insert( NodeMap::value_type(top.name, top.node)); } else { merge(i->second, top.node); @@ -316,10 +315,8 @@ void XcsParser::endElement(xmlreader::XmlReader const & reader) { css::uno::Reference< css::uno::XInterface >()); } } else { - NodeMap * members = elements_.top().node->getMemberMap(); - assert(members != 0); - if (!members->insert(NodeMap::value_type(top.name, top.node)). - second) + if (!elements_.top().node->getMembers().insert( + NodeMap::value_type(top.name, top.node)).second) { throw css::uno::RuntimeException( (rtl::OUString( diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index b05fe0e7e3c5..db599c0d5306 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -242,9 +242,7 @@ void XcuParser::endElement(xmlreader::XmlReader const &) { state_.pop(); if (insert.is()) { assert(!state_.empty() && state_.top().node.is()); - NodeMap * members = state_.top().node->getMemberMap(); - assert(members != 0); - (*members)[name] = insert; + state_.top().node->getMembers()[name] = insert; } if (pop && !path_.empty()) { path_.pop_back(); @@ -358,7 +356,7 @@ void XcuParser::handleComponentData(xmlreader::XmlReader & reader) { } rtl::Reference< Node > node( Data::findNode( - valueParser_.getLayer(), data_.components, componentName_)); + valueParser_.getLayer(), data_.getComponents(), componentName_)); if (!node.is()) { SAL_WARN( "configmgr", @@ -595,11 +593,9 @@ void XcuParser::handleLocpropValue( return; } } - NodeMap * members = locprop->getMemberMap(); - assert(members != 0); - NodeMap::iterator i(members->find(name)); - if (i != members->end() && i->second->getLayer() > valueParser_.getLayer()) - { + NodeMap & members = locprop->getMembers(); + NodeMap::iterator i(members.find(name)); + if (i != members.end() && i->second->getLayer() > valueParser_.getLayer()) { state_.push(State(true)); // ignored return; } @@ -616,8 +612,8 @@ void XcuParser::handleLocpropValue( { bool pop = false; if (nil) { - if (i == members->end()) { - (*members)[name] = new LocalizedValueNode( + if (i == members.end()) { + members[name] = new LocalizedValueNode( valueParser_.getLayer(), css::uno::Any()); } else { dynamic_cast< LocalizedValueNode * >( @@ -641,8 +637,8 @@ void XcuParser::handleLocpropValue( case OPERATION_REMOVE: //TODO: only allow if parent.op == OPERATION_FUSE //TODO: disallow removing when e.g. lang=""? - if (i != members->end()) { - members->erase(i); + if (i != members.end()) { + members.erase(i); } state_.push(State(true)); recordModification(false); @@ -708,10 +704,9 @@ void XcuParser::handleGroupProp( return; } } - NodeMap * members = group->getMemberMap(); - assert(members != 0); - NodeMap::iterator i(members->find(name)); - if (i == members->end()) { + NodeMap & members = group->getMembers(); + NodeMap::iterator i(members.find(name)); + if (i == members.end()) { handleUnknownGroupProp(reader, group, name, type, op, finalized); } else { switch (i->second->kind()) { @@ -822,9 +817,7 @@ void XcuParser::handlePlainGroupProp( reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } - NodeMap * members = group->getMemberMap(); - assert(members != 0); - members->erase(propertyIndex); + group->getMembers().erase(propertyIndex); state_.push(State(true)); // ignore children recordModification(false); break; @@ -1045,10 +1038,9 @@ void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) { } int finalizedLayer = finalized ? valueParser_.getLayer() : Data::NO_LAYER; int mandatoryLayer = mandatory ? valueParser_.getLayer() : Data::NO_LAYER; - NodeMap * members = set->getMemberMap(); - assert(members != 0); - NodeMap::iterator i(members->find(name)); - if (i != members->end()) { + NodeMap & members = set->getMembers(); + NodeMap::iterator i(members.find(name)); + if (i != members.end()) { finalizedLayer = std::min(finalizedLayer, i->second->getFinalized()); i->second->setFinalized(finalizedLayer); mandatoryLayer = std::min(mandatoryLayer, i->second->getMandatory()); @@ -1060,7 +1052,7 @@ void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) { } switch (op) { case OPERATION_MODIFY: - if (i == members->end()) { + if (i == members.end()) { SAL_WARN( "configmgr", "ignoring modify of unknown set member node \"" << name @@ -1083,11 +1075,11 @@ void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) { member->setFinalized(finalizedLayer); member->setMandatory(mandatoryLayer); state_.push(State(member, name, false)); - recordModification(i == members->end()); + recordModification(i == members.end()); } break; case OPERATION_FUSE: - if (i == members->end()) { + if (i == members.end()) { if (state_.top().locked || finalizedLayer < valueParser_.getLayer()) { state_.push(State(true)); // ignored @@ -1114,13 +1106,13 @@ void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) { // forget about user-layer removals that no longer remove anything // (so that paired additions/removals in the user layer do not grow // registrymodifications.xcu unbounded): - bool known = i != members->end(); + bool known = i != members.end(); if (known && !state_.top().locked && finalizedLayer >= valueParser_.getLayer() && (mandatoryLayer == Data::NO_LAYER || mandatoryLayer > valueParser_.getLayer())) { - members->erase(i); + members.erase(i); } state_.push(State(true)); if (known) { |