diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2015-07-15 20:41:18 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2015-07-15 22:28:42 -0500 |
commit | ec243f43411290bb7f56176e29cb92929dab2953 (patch) | |
tree | 78d1e3d4b0e86b1246f035ca60f94b29e5254f84 | |
parent | 578969c51cb7b012fb522d4296c8069a611de29d (diff) |
Revert "tools: replace boost::ptr_vector with std::unordered_map"
This reverts commit 218be53fe00aebed43df0b041de609b30f99ce95.
MacOSX breaker
-rw-r--r-- | desktop/source/deployment/manager/dp_manager.cxx | 5 | ||||
-rw-r--r-- | desktop/source/deployment/registry/component/dp_component.cxx | 22 | ||||
-rw-r--r-- | desktop/source/deployment/registry/package/dp_package.cxx | 11 | ||||
-rw-r--r-- | include/tools/inetmime.hxx | 148 | ||||
-rw-r--r-- | svl/qa/unit/test_INetContentType.cxx | 12 | ||||
-rw-r--r-- | svtools/source/svhtml/parhtml.cxx | 5 | ||||
-rw-r--r-- | tools/source/inet/inetmime.cxx | 29 |
7 files changed, 128 insertions, 104 deletions
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index d67f49610e87..3392b545faff 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -971,8 +971,9 @@ Reference<deployment::XPackage> PackageManagerImpl::getDeployedPackage_( INetContentTypeParameterList params; if (INetContentTypes::parse( data.mediaType, type, subType, ¶ms )) { - auto const iter = params.find(OString("platform")); - if (iter != params.end() && !platform_fits(iter->second.m_sValue)) + INetContentTypeParameter const * param = params.find( + OString("platform") ); + if (param != 0 && !platform_fits( param->m_sValue )) throw lang::IllegalArgumentException( getResourceString(RID_STR_NO_SUCH_PACKAGE) + id, static_cast<OWeakObject *>(this), diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 9b2a2a73179c..e17961f0bb9b 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -670,21 +670,21 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { // xxx todo: probe and evaluate component xml description - auto const iter = params.find(OString("platform")); - bool bPlatformFits(iter == params.end()); + INetContentTypeParameter const * param = params.find(OString("platform")); + bool bPlatformFits(param == 0); OUString aPlatform; if (!bPlatformFits) // platform is specified, we have to check { - aPlatform = iter->second.m_sValue; + aPlatform = param->m_sValue; bPlatformFits = platform_fits(aPlatform); } // If the package is being removed, do not care whether // platform fits. We won't be using it anyway. if (bPlatformFits || bRemoved) { - auto const iterType = params.find(OString("type")); - if (iterType != params.end()) + param = params.find(OString("type")); + if (param != 0) { - OUString const & value = iterType->second.m_sValue; + OUString const & value = param->m_sValue; if (value.equalsIgnoreAsciiCase("native")) { if (bPlatformFits) return new BackendImpl::ComponentPackageImpl( @@ -713,8 +713,8 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( } else if (subType.equalsIgnoreAsciiCase("vnd.sun.star.uno-components")) { - auto const iter = params.find(OString("platform")); - if (iter == params.end() || platform_fits(iter->second.m_sValue)) { + INetContentTypeParameter const * param = params.find(OString("platform")); + if (param == 0 || platform_fits( param->m_sValue )) { return new BackendImpl::ComponentsPackageImpl( this, url, name, m_xComponentsTypeInfo, bRemoved, identifier); @@ -722,9 +722,9 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( } else if (subType.equalsIgnoreAsciiCase( "vnd.sun.star.uno-typelibrary")) { - auto const iter = params.find(OString("type")); - if (iter != params.end()) { - OUString const & value = iter->second.m_sValue; + INetContentTypeParameter const * param = params.find(OString("type")); + if (param != 0) { + OUString const & value = param->m_sValue; if (value.equalsIgnoreAsciiCase("RDB")) { return new BackendImpl::TypelibraryPackageImpl( diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 2ce790d1e50d..db08cb9033e9 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -1473,8 +1473,8 @@ void BackendImpl::PackageImpl::scanBundle( if (! INetContentTypes::parse( mediaType, type, subType, ¶ms )) continue; - auto const iter = params.find("platform"); - if (iter != params.end() && !platform_fits(iter->second.m_sValue)) + INetContentTypeParameter const * param = params.find("platform"); + if (param != 0 && !platform_fits( param->m_sValue )) continue; const OUString url( makeURL( packageRootURL, fullPath ) ); @@ -1483,15 +1483,14 @@ void BackendImpl::PackageImpl::scanBundle( subType.equalsIgnoreAsciiCase( "vnd.sun.star.package-bundle-description")) { // check locale: - auto const iterLocale = params.find("locale"); - if (iterLocale == params.end()) - { + param = params.find("locale"); + if (param == 0) { if (descrFile.isEmpty()) descrFile = url; } else { // match best locale: - LanguageTag descrTag(iter->second.m_sValue); + LanguageTag descrTag( param->m_sValue); if (officeLocale.getLanguage() == descrTag.getLanguage()) { size_t nPenalty = nPenaltyMax; diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx index f1b2081bb6b2..57666605b2f0 100644 --- a/include/tools/inetmime.hxx +++ b/include/tools/inetmime.hxx @@ -19,6 +19,8 @@ #ifndef INCLUDED_TOOLS_INETMIME_HXX #define INCLUDED_TOOLS_INETMIME_HXX +#include <boost/ptr_container/ptr_vector.hpp> + #include <tools/toolsdllapi.h> #include <rtl/alloc.h> #include <rtl/character.hxx> @@ -29,81 +31,11 @@ #include <tools/debug.hxx> #include <tools/errcode.hxx> -#include <unordered_map> - class DateTime; +class INetContentTypeParameterList; class INetMIMECharsetList_Impl; class INetMIMEOutputSink; -struct INetContentTypeParameter -{ - /** The name of the attribute, in US-ASCII encoding and converted to lower - case. If a parameter value is split as described in RFC 2231, there - will only be one item for the complete parameter, with the attribute - name lacking any section suffix. - */ - const OString m_sAttribute; - - /** The optional character set specification (see RFC 2231), in US-ASCII - encoding and converted to lower case. - */ - const OString m_sCharset; - - /** The optional language specification (see RFC 2231), in US-ASCII - encoding and converted to lower case. - */ - const OString m_sLanguage; - - /** The attribute value. If the value is a quoted-string, it is - 'unpacked.' If a character set is specified, and the value can be - converted to Unicode, this is done. Also, if no character set is - specified, it is first tried to convert the value from UTF-8 encoding - to Unicode, and if that doesn't work (because the value is not in - UTF-8 encoding), it is converted from ISO-8859-1 encoding to Unicode - (which will always work). But if a character set is specified and the - value cannot be converted from that character set to Unicode, special - action is taken to produce a value that can possibly be transformed - back into its original form: Any 8-bit character from a non-encoded - part of the original value is directly converted to Unicode - (effectively handling it as if it was ISO-8859-1 encoded), and any - 8-bit character from an encoded part of the original value is mapped - to the range U+F800..U+F8FF at the top of the Corporate Use Subarea - within Unicode's Private Use Area (effectively adding 0xF800 to the - character's numeric value). - */ - const OUString m_sValue; - - /** This is true if the value is successfully converted to Unicode, and - false if the value is a special mixture of ISO-LATIN-1 characters and - characters from Unicode's Private Use Area. - */ - const bool m_bConverted; - - INetContentTypeParameter(const OString& rTheAttribute, - const OString& rTheCharset, const OString& rTheLanguage, - const OUString& rTheValue, bool bTheConverted) - : m_sAttribute(rTheAttribute) - , m_sCharset(rTheCharset) - , m_sLanguage(rTheLanguage) - , m_sValue(rTheValue) - , m_bConverted(bTheConverted) - { - } -}; - -struct OString_equalsIgnoreAsciiCase -{ - bool operator()(const OString& r1, const OString& r2) const - { - return r1.equalsIgnoreAsciiCase(r2); - } -}; - -// the key is the m_sAttribute again -typedef std::unordered_map<OString, INetContentTypeParameter, OStringHash, - OString_equalsIgnoreAsciiCase> INetContentTypeParameterList; - - class TOOLS_DLLPUBLIC INetMIME { public: @@ -1003,6 +935,80 @@ inline bool INetMIMEEncodedWordOutputSink::flush() return m_ePrevCoding != CODING_NONE; } +struct INetContentTypeParameter +{ + /** The name of the attribute, in US-ASCII encoding and converted to lower + case. If a parameter value is split as described in RFC 2231, there + will only be one item for the complete parameter, with the attribute + name lacking any section suffix. + */ + const OString m_sAttribute; + + /** The optional character set specification (see RFC 2231), in US-ASCII + encoding and converted to lower case. + */ + const OString m_sCharset; + + /** The optional language specification (see RFC 2231), in US-ASCII + encoding and converted to lower case. + */ + const OString m_sLanguage; + + /** The attribute value. If the value is a quoted-string, it is + 'unpacked.' If a character set is specified, and the value can be + converted to Unicode, this is done. Also, if no character set is + specified, it is first tried to convert the value from UTF-8 encoding + to Unicode, and if that doesn't work (because the value is not in + UTF-8 encoding), it is converted from ISO-8859-1 encoding to Unicode + (which will always work). But if a character set is specified and the + value cannot be converted from that character set to Unicode, special + action is taken to produce a value that can possibly be transformed + back into its original form: Any 8-bit character from a non-encoded + part of the original value is directly converted to Unicode + (effectively handling it as if it was ISO-8859-1 encoded), and any + 8-bit character from an encoded part of the original value is mapped + to the range U+F800..U+F8FF at the top of the Corporate Use Subarea + within Unicode's Private Use Area (effectively adding 0xF800 to the + character's numeric value). + */ + const OUString m_sValue; + + /** This is true if the value is successfully converted to Unicode, and + false if the value is a special mixture of ISO-LATIN-1 characters and + characters from Unicode's Private Use Area. + */ + const bool m_bConverted; + + INetContentTypeParameter(const OString& rTheAttribute, + const OString& rTheCharset, const OString& rTheLanguage, + const OUString& rTheValue, bool bTheConverted) + : m_sAttribute(rTheAttribute) + , m_sCharset(rTheCharset) + , m_sLanguage(rTheLanguage) + , m_sValue(rTheValue) + , m_bConverted(bTheConverted) + { + } +}; + +class TOOLS_DLLPUBLIC INetContentTypeParameterList +{ +public: + + void Clear(); + + void Append(INetContentTypeParameter *pParameter) + { + maEntries.push_back(pParameter); + } + + const INetContentTypeParameter * find(const OString& rAttribute) const; + +private: + + boost::ptr_vector<INetContentTypeParameter> maEntries; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/qa/unit/test_INetContentType.cxx b/svl/qa/unit/test_INetContentType.cxx index 68badb6745c6..b7aa71cd6e66 100644 --- a/svl/qa/unit/test_INetContentType.cxx +++ b/svl/qa/unit/test_INetContentType.cxx @@ -48,7 +48,8 @@ void Test::testBad() { CPPUNIT_ASSERT(!INetContentTypes::parse(in, t, s, &ps)); CPPUNIT_ASSERT(t.isEmpty()); CPPUNIT_ASSERT(s.isEmpty()); - CPPUNIT_ASSERT(ps.end() == ps.find("foo")); + CPPUNIT_ASSERT_EQUAL( + static_cast<INetContentTypeParameter const *>(0), ps.find("foo")); } void Test::testFull() { @@ -62,9 +63,9 @@ void Test::testFull() { CPPUNIT_ASSERT(INetContentTypes::parse(in, t, s, &ps)); CPPUNIT_ASSERT_EQUAL(OUString("foo"), t); CPPUNIT_ASSERT_EQUAL(OUString("bar"), s); - auto iter = ps.find("baz"); - CPPUNIT_ASSERT(iter != ps.end()); - CPPUNIT_ASSERT_EQUAL(OUString("boz"), iter->second.m_sValue); + INetContentTypeParameter const * p = ps.find("baz"); + CPPUNIT_ASSERT(p != 0); + CPPUNIT_ASSERT_EQUAL(OUString("boz"), p->m_sValue); } void Test::testFollow() { @@ -78,7 +79,8 @@ void Test::testFollow() { CPPUNIT_ASSERT(!INetContentTypes::parse(in, t, s)); CPPUNIT_ASSERT(t.isEmpty()); CPPUNIT_ASSERT(s.isEmpty()); - CPPUNIT_ASSERT(ps.end() == ps.find("baz")); + CPPUNIT_ASSERT_EQUAL( + static_cast<INetContentTypeParameter const *>(0), ps.find("baz")); } CPPUNIT_TEST_SUITE_REGISTRATION(Test); diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index 2627bc1ac9b9..0158436859c8 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -2092,10 +2092,9 @@ rtl_TextEncoding HTMLParser::GetEncodingByMIME( const OUString& rMime ) INetContentTypeParameterList aParameters; if (INetContentTypes::parse(rMime, sType, sSubType, &aParameters)) { - auto const iter = aParameters.find("charset"); - if (iter != aParameters.end()) + const INetContentTypeParameter * pCharset = aParameters.find("charset"); + if (pCharset != 0) { - const INetContentTypeParameter * pCharset = &iter->second; OString sValue(OUStringToOString(pCharset->m_sValue, RTL_TEXTENCODING_ASCII_US)); return GetExtendedCompatibilityTextEncoding( rtl_getTextEncodingFromMimeCharset( sValue.getStr() ) ); } diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx index 88e2cf9876db..bfb06b814dc5 100644 --- a/tools/source/inet/inetmime.cxx +++ b/tools/source/inet/inetmime.cxx @@ -257,7 +257,7 @@ bool parseParameters(ParameterList const & rInput, INetContentTypeParameterList * pOutput) { if (pOutput) - pOutput->clear(); + pOutput->Clear(); Parameter * pPrev = 0; for (Parameter * p = rInput.m_pList; p; p = p->m_pNext) @@ -335,14 +335,11 @@ bool parseParameters(ParameterList const & rInput, break; }; } - auto const ret = pOutput->insert(std::make_pair(p->m_aAttribute, - INetContentTypeParameter(p->m_aAttribute, + pOutput->Append(new INetContentTypeParameter(p->m_aAttribute, p->m_aCharset, p->m_aLanguage, aValue, - !bBadEncoding))); - SAL_INFO_IF(!ret.second, "tools", - "INetMIME: dropping duplicate parameter: " << p->m_aAttribute); + !bBadEncoding)); p = pNext; } return true; @@ -3741,4 +3738,24 @@ INetMIMEEncodedWordOutputSink::WriteUInt32(sal_uInt32 nChar) return *this; } +// INetContentTypeParameterList + +void INetContentTypeParameterList::Clear() +{ + maEntries.clear(); +} + +const INetContentTypeParameter * +INetContentTypeParameterList::find(const OString& rAttribute) const +{ + boost::ptr_vector<INetContentTypeParameter>::const_iterator iter; + for (iter = maEntries.begin(); iter != maEntries.end(); ++iter) + { + if (iter->m_sAttribute.equalsIgnoreAsciiCase(rAttribute)) + return &(*iter); + } + + return NULL; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |