diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2023-11-26 10:11:34 +0100 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2023-11-26 13:19:56 +0100 |
commit | 3ff66d4361c3394d8669f3a367f41d4bad9914e7 (patch) | |
tree | 44c7c040bfb9c81e73b5b270fb35ed948d0dd562 /configmgr | |
parent | 743e1188cc843e74b1b110675254a7d2329d1a2f (diff) |
Simplify implementation of getTypeByHierarchicalName
(Localized)PropertyType::getStaticType already provides the relevant information
Change-Id: I5aceb596ac4a2d111ebcb5ddef7ef74c80762047
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159969
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/access.cxx | 11 | ||||
-rw-r--r-- | configmgr/source/node.hxx | 6 | ||||
-rw-r--r-- | configmgr/source/xcsparser.cxx | 8 | ||||
-rw-r--r-- | configmgr/source/xcsparser.hxx | 1 |
4 files changed, 11 insertions, 15 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index c802f62494f0..371ebdc95b06 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -466,11 +466,16 @@ css::uno::Type Access::getTypeByHierarchicalName(OUString const & aName) throw css::container::NoSuchElementException( aName, getXWeak()); } - auto type = child->getNode()->getType(); - if (type == TYPE_ERROR) + auto const & p = child->getNode(); + switch (p->kind()) { + case Node::KIND_PROPERTY: + return mapType(static_cast<PropertyNode *>(p.get())->getStaticType()); + case Node::KIND_LOCALIZED_PROPERTY: + return mapType(static_cast<LocalizedPropertyNode *>(p.get())->getStaticType()); + default: throw css::util::InvalidStateException( aName, getXWeak()); - return mapType(child->getNode()->getType()); + } } sal_Bool Access::hasByHierarchicalName(OUString const & aName) diff --git a/configmgr/source/node.hxx b/configmgr/source/node.hxx index 68664e870e35..cce8e3d4abb3 100644 --- a/configmgr/source/node.hxx +++ b/configmgr/source/node.hxx @@ -27,8 +27,6 @@ #include <salhelper/simplereferenceobject.hxx> #include <xmlreader/span.hxx> -#include "type.hxx" - namespace configmgr { class NodeMap; @@ -58,9 +56,6 @@ public: void setDescription(OUString const& description) { description_ = description; }; OUString getDescription() { return description_; } - void setType(Type const& type) { type_ = type; }; - Type getType() { return type_; } - rtl::Reference< Node > getMember(OUString const & name); protected: @@ -72,7 +67,6 @@ private: int layer_; int finalized_; OUString description_; - Type type_ = TYPE_ERROR; }; } diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx index 50d7b9fa4791..e70ddac6a6c9 100644 --- a/configmgr/source/xcsparser.cxx +++ b/configmgr/source/xcsparser.cxx @@ -316,7 +316,6 @@ void XcsParser::endElement(xmlreader::XmlReader const & reader) { while (desc.indexOf(" ") != -1) desc = desc.replaceAll(" ", " "); top.node->setDescription(desc); - top.node->setType(type_); } if (elements_.empty()) { switch (state_) { @@ -478,7 +477,7 @@ void XcsParser::handleNodeRef(xmlreader::XmlReader & reader) { void XcsParser::handleProp(xmlreader::XmlReader & reader) { bool hasName = false; OUString name; - type_ = TYPE_ERROR; + valueParser_.type_ = TYPE_ERROR; bool localized = false; bool nillable = true; for (;;) { @@ -493,7 +492,7 @@ void XcsParser::handleProp(xmlreader::XmlReader & reader) { } else if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn == "type") { - type_ = xmldata::parseType( + valueParser_.type_ = xmldata::parseType( reader, reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn == "localized") @@ -509,11 +508,10 @@ void XcsParser::handleProp(xmlreader::XmlReader & reader) { throw css::uno::RuntimeException( "no prop name attribute in " + reader.getUrl()); } - if (type_ == TYPE_ERROR) { + if (valueParser_.type_ == TYPE_ERROR) { throw css::uno::RuntimeException( "no prop type attribute in " + reader.getUrl()); } - valueParser_.type_ = type_; elements_.push( Element( (localized diff --git a/configmgr/source/xcsparser.hxx b/configmgr/source/xcsparser.hxx index 6e8ff7d2367d..aedcccde1147 100644 --- a/configmgr/source/xcsparser.hxx +++ b/configmgr/source/xcsparser.hxx @@ -96,7 +96,6 @@ private: ElementStack elements_; bool bIsParsingInfo_; OUStringBuffer description_; - Type type_; }; } |