diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-26 21:02:24 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-27 11:54:52 +0200 |
commit | f7445e1014815a9eb02e2c22257bbce32dc43589 (patch) | |
tree | 537e4c221d6ce75329b4e86f42a2125136a4bab1 | |
parent | 34905a6e9e0c262b61e5969274b661692af44a46 (diff) |
tdf#75757 comphelper: avoid STL inheritance in SequenceAsHashMap
Change-Id: I5c7d107a05deb06749b4d04246ba183adfafb14d
Reviewed-on: https://gerrit.libreoffice.org/42829
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | comphelper/source/misc/sequenceashashmap.cxx | 1 | ||||
-rw-r--r-- | include/comphelper/sequenceashashmap.hxx | 85 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchvalue.cxx | 4 |
3 files changed, 75 insertions, 15 deletions
diff --git a/comphelper/source/misc/sequenceashashmap.cxx b/comphelper/source/misc/sequenceashashmap.cxx index 9c51ad19bf69..707512f42d21 100644 --- a/comphelper/source/misc/sequenceashashmap.cxx +++ b/comphelper/source/misc/sequenceashashmap.cxx @@ -26,7 +26,6 @@ namespace comphelper{ SequenceAsHashMap::SequenceAsHashMap() - : SequenceAsHashMapBase() { } diff --git a/include/comphelper/sequenceashashmap.hxx b/include/comphelper/sequenceashashmap.hxx index 270601af7c67..b4b2991948ae 100644 --- a/include/comphelper/sequenceashashmap.hxx +++ b/include/comphelper/sequenceashashmap.hxx @@ -40,14 +40,9 @@ namespace comphelper{ such name sequences very easy ... */ -struct SequenceAsHashMapBase : public std::unordered_map< - OUString , - css::uno::Any , - OUStringHash > -{ -}; +using SequenceAsHashMapBase = std::unordered_map<OUString, css::uno::Any, OUStringHash>; -class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAsHashMapBase +class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap { public: @@ -221,8 +216,8 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs TValueType getUnpackedValueOrDefault(const OUString& sKey , const TValueType& aDefault) const { - const_iterator pIt = find(sKey); - if (pIt == end()) + auto pIt = m_aMap.find(sKey); + if (pIt == m_aMap.end()) return aDefault; TValueType aValue = TValueType(); @@ -249,8 +244,8 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs */ css::uno::Any getValue(const OUString& sKey) const { - const_iterator pIt = find(sKey); - if (pIt == end()) + auto pIt = m_aMap.find(sKey); + if (pIt == m_aMap.end()) return css::uno::Any(); return pIt->second; @@ -281,7 +276,7 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs bool createItemIfMissing(const OUString& sKey , const TValueType& aValue) { - if (find(sKey) == end()) + if (m_aMap.find(sKey) == m_aMap.end()) { (*this)[sKey] = css::uno::toAny(aValue); return true; @@ -320,6 +315,72 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs the map containing all items for the update. */ void update(const SequenceAsHashMap& rSource); + + css::uno::Any& operator[](const OUString& rKey) + { + return m_aMap[rKey]; + } + + using iterator = SequenceAsHashMapBase::iterator; + using const_iterator = SequenceAsHashMapBase::const_iterator; + + void clear() + { + m_aMap.clear(); + } + + size_t size() const + { + return m_aMap.size(); + } + + bool empty() const + { + return m_aMap.empty(); + } + + iterator begin() + { + return m_aMap.begin(); + } + + const_iterator begin() const + { + return m_aMap.begin(); + } + + iterator end() + { + return m_aMap.end(); + } + + const_iterator end() const + { + return m_aMap.end(); + } + + iterator find(const OUString& rKey) + { + return m_aMap.find(rKey); + } + + const_iterator find(const OUString& rKey) const + { + return m_aMap.find(rKey); + } + + iterator erase(iterator it) + { + return m_aMap.erase(it); + } + + size_t erase(const OUString& rKey) + { + return m_aMap.erase(rKey); + } + +private: + SequenceAsHashMapBase m_aMap; }; } // namespace comphelper diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index 70d6cbf46f2f..bb803365a2f5 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -388,8 +388,8 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) return RTFError::OK; m_nCurrentEncoding = aRTFEncodings[i].codepage == 0 // Default (CP_ACP) - ? osl_getThreadTextEncoding() - : rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings[i].codepage); + ? osl_getThreadTextEncoding() + : rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings[i].codepage); m_aStates.top().nCurrentEncoding = m_nCurrentEncoding; } break; |