diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-02 19:20:59 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-02 19:32:28 -0500 |
commit | 532b2f48185c9ee3f389f1a3fbdfffcf113c15c0 (patch) | |
tree | 896dc46717b963601188efd001830c7a130e0249 /sax/source | |
parent | 2130fd9d610bf12b09fe29bafd46a673b21e064d (diff) |
Add a means to check if a namespace exists.
Useful when we just need to check if the stream has a certain namespace
defined. Calling getNamespaceURL() may throw SAXException in such case.
Change-Id: Ib2b7b202492390158270d87bab95d1793c9d8a70
Diffstat (limited to 'sax/source')
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 9f60b72c2d5c..9535902f92d2 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -859,6 +859,24 @@ void FastSaxParser::produce( CallbackType aType ) } } +bool FastSaxParser::hasNamespaceURL( const OUString& rPrefix ) const +{ + const Entity& rEntity = getEntity(); + + if (rEntity.maNamespaceCount.empty()) + return false; + + OString aPrefix = OUStringToOString(rPrefix, RTL_TEXTENCODING_UTF8); + sal_uInt32 nNamespace = rEntity.maNamespaceCount.top(); + while (nNamespace--) + { + if (rEntity.maNamespaceDefines[nNamespace]->maPrefix == aPrefix) + return true; + } + + return false; +} + bool FastSaxParser::consume(EventList *pEventList) { Entity& rEntity = getEntity(); @@ -924,6 +942,11 @@ Entity& FastSaxParser::getEntity() return maEntities.top(); } +const Entity& FastSaxParser::getEntity() const +{ + return maEntities.top(); +} + // starts parsing with actual parser ! void FastSaxParser::parse() { |