[Libreoffice-commits] core.git: 2 commits - desktop/source include/tools include/vcl svl/qa svtools/source tools/source vcl/source

Michael Stahl mstahl at redhat.com
Wed Jul 15 15:12:36 PDT 2015


 desktop/source/deployment/manager/dp_manager.cxx              |    5 
 desktop/source/deployment/registry/component/dp_component.cxx |   22 -
 desktop/source/deployment/registry/package/dp_package.cxx     |   11 
 include/tools/inetmime.hxx                                    |  148 ++++------
 include/vcl/btndlg.hxx                                        |    6 
 svl/qa/unit/test_INetContentType.cxx                          |   12 
 svtools/source/svhtml/parhtml.cxx                             |    5 
 tools/source/inet/inetmime.cxx                                |   29 -
 vcl/source/window/btndlg.cxx                                  |   51 +--
 9 files changed, 133 insertions(+), 156 deletions(-)

New commits:
commit 7068b56ba93470c9329e2537fa24b1b1a11487fa
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jul 15 23:43:38 2015 +0200

    vcl: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I11bd73ff134895d05c7ce054b5ef26829a3bf8c3

diff --git a/include/vcl/btndlg.hxx b/include/vcl/btndlg.hxx
index 5328084..33b86e9 100644
--- a/include/vcl/btndlg.hxx
+++ b/include/vcl/btndlg.hxx
@@ -20,11 +20,13 @@
 #ifndef INCLUDED_VCL_BTNDLG_HXX
 #define INCLUDED_VCL_BTNDLG_HXX
 
-#include <boost/ptr_container/ptr_vector.hpp>
 #include <vcl/dllapi.h>
 #include <vcl/dialog.hxx>
 #include <o3tl/typed_flags_set.hxx>
 
+#include <vector>
+#include <memory>
+
 struct ImplBtnDlgItem;
 class PushButton;
 
@@ -81,7 +83,7 @@ private:
                         ButtonDialog& operator=( const ButtonDialog& ) SAL_DELETED_FUNCTION;
 
 private:
-    boost::ptr_vector<ImplBtnDlgItem> maItemList;
+    std::vector<std::unique_ptr<ImplBtnDlgItem>> m_ItemList;
     Size                maPageSize;
     Size                maCtrlSize;
     long                mnButtonSize;
diff --git a/vcl/source/window/btndlg.cxx b/vcl/source/window/btndlg.cxx
index 6b141fe..ec98f89 100644
--- a/vcl/source/window/btndlg.cxx
+++ b/vcl/source/window/btndlg.cxx
@@ -24,8 +24,6 @@
 #include <vcl/button.hxx>
 #include <vcl/btndlg.hxx>
 
-typedef boost::ptr_vector<ImplBtnDlgItem>::iterator btn_iterator;
-typedef boost::ptr_vector<ImplBtnDlgItem>::const_iterator btn_const_iterator;
 
 struct ImplBtnDlgItem
 {
@@ -64,12 +62,12 @@ ButtonDialog::~ButtonDialog()
 
 void ButtonDialog::dispose()
 {
-    for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    for (auto & it : m_ItemList)
     {
         if ( it->mbOwnButton )
             it->mpPushButton.disposeAndClear();
     }
-    maItemList.clear();
+    m_ItemList.clear();
     Dialog::dispose();
 }
 
@@ -97,7 +95,7 @@ VclPtr<PushButton> ButtonDialog::ImplCreatePushButton( ButtonDialogFlags nBtnFla
 
 ImplBtnDlgItem* ButtonDialog::ImplGetItem( sal_uInt16 nId ) const
 {
-    for ( btn_const_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    for (auto & it : m_ItemList)
     {
         if (it->mnId == nId)
             return const_cast<ImplBtnDlgItem*>(&(*it));
@@ -116,7 +114,7 @@ long ButtonDialog::ImplGetButtonSize()
     long nSepSize = 0;
     maCtrlSize = Size( IMPL_MINSIZE_BUTTON_WIDTH, IMPL_MINSIZE_BUTTON_HEIGHT );
 
-    for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    for (auto & it : m_ItemList)
     {
         nSepSize += nLastSepSize;
 
@@ -140,7 +138,7 @@ long ButtonDialog::ImplGetButtonSize()
             nLastSepSize = IMPL_SEP_BUTTON_Y;
     }
 
-    long nButtonCount = maItemList.size();
+    size_t const nButtonCount = m_ItemList.size();
 
     if ( GetStyle() & WB_HORZ )
         mnButtonSize  = nSepSize + (nButtonCount*maCtrlSize.Width());
@@ -192,7 +190,7 @@ void ButtonDialog::ImplPosControls()
     }
 
     // Arrange PushButtons
-    for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    for (auto & it : m_ItemList)
     {
         if ( GetStyle() & WB_HORZ )
             nX += it->mnSepSize;
@@ -215,7 +213,7 @@ void ButtonDialog::ImplPosControls()
 
 IMPL_LINK( ButtonDialog, ImplClickHdl, PushButton*, pBtn )
 {
-    for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    for (auto & it : m_ItemList)
     {
         if ( it->mpPushButton == pBtn )
         {
@@ -237,7 +235,7 @@ void ButtonDialog::StateChanged( StateChangedType nType )
     if ( nType == StateChangedType::InitShow )
     {
         ImplPosControls();
-        for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+        for (auto & it : m_ItemList)
         {
             if ( it->mpPushButton && it->mbOwnButton )
                 it->mpPushButton->SetZOrder(0, ZOrderFlags::Last);
@@ -246,7 +244,7 @@ void ButtonDialog::StateChanged( StateChangedType nType )
         // Set focus on default button.
         if ( mnFocusButtonId != BUTTONDIALOG_BUTTON_NOTFOUND )
         {
-            for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+            for (auto & it : m_ItemList)
             {
                 if (it->mnId == mnFocusButtonId )
                 {
@@ -277,7 +275,7 @@ void ButtonDialog::AddButton( const OUString& rText, sal_uInt16 nId,
                               ButtonDialogFlags nBtnFlags, long nSepPixel )
 {
     // PageItem anlegen
-    ImplBtnDlgItem* pItem   = new ImplBtnDlgItem;
+    std::unique_ptr<ImplBtnDlgItem> pItem(new ImplBtnDlgItem);
     pItem->mnId             = nId;
     pItem->mbOwnButton      = true;
     pItem->mnSepSize        = nSepPixel;
@@ -286,7 +284,7 @@ void ButtonDialog::AddButton( const OUString& rText, sal_uInt16 nId,
     if (!rText.isEmpty())
         pItem->mpPushButton->SetText( rText );
 
-    maItemList.push_back(pItem);
+    m_ItemList.push_back(std::move(pItem));
 
     if ( nBtnFlags & ButtonDialogFlags::Focus )
         mnFocusButtonId = nId;
@@ -298,7 +296,7 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId,
                               ButtonDialogFlags nBtnFlags, long nSepPixel )
 {
     // PageItem anlegen
-    ImplBtnDlgItem* pItem   = new ImplBtnDlgItem;
+    std::unique_ptr<ImplBtnDlgItem> pItem(new ImplBtnDlgItem);
     pItem->mnId             = nId;
     pItem->mbOwnButton      = true;
     pItem->mnSepSize        = nSepPixel;
@@ -322,23 +320,24 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId,
     if ( nBtnFlags & ButtonDialogFlags::Focus )
         mnFocusButtonId = nId;
 
-    maItemList.push_back(pItem);
+    m_ItemList.push_back(std::move(pItem));
 
     mbFormat = true;
 }
 
 void ButtonDialog::RemoveButton( sal_uInt16 nId )
 {
-    for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    for (std::vector<std::unique_ptr<ImplBtnDlgItem>>::iterator it
+            = m_ItemList.begin(); it != m_ItemList.end(); ++it)
     {
-        if (it->mnId == nId)
+        if ((*it)->mnId == nId)
         {
-            it->mpPushButton->Hide();
-            if (it->mbOwnButton)
-                it->mpPushButton.disposeAndClear();
+            (*it)->mpPushButton->Hide();
+            if ((*it)->mbOwnButton)
+                (*it)->mpPushButton.disposeAndClear();
             else
-                it->mpPushButton.clear();
-            maItemList.erase(it);
+                (*it)->mpPushButton.clear();
+            m_ItemList.erase(it);
             return;
         }
     }
@@ -348,21 +347,21 @@ void ButtonDialog::RemoveButton( sal_uInt16 nId )
 
 void ButtonDialog::Clear()
 {
-    for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    for (auto & it : m_ItemList)
     {
         it->mpPushButton->Hide();
         if (it->mbOwnButton)
             it->mpPushButton.disposeAndClear();
     }
 
-    maItemList.clear();
+    m_ItemList.clear();
     mbFormat = true;
 }
 
 sal_uInt16 ButtonDialog::GetButtonId( sal_uInt16 nButton ) const
 {
-    if ( nButton < maItemList.size() )
-        return maItemList[nButton].mnId;
+    if ( nButton < m_ItemList.size() )
+        return m_ItemList[nButton]->mnId;
     else
         return BUTTONDIALOG_BUTTON_NOTFOUND;
 }
commit 218be53fe00aebed43df0b041de609b30f99ce95
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jul 15 23:17:20 2015 +0200

    tools: replace boost::ptr_vector with std::unordered_map
    
    Change-Id: I530c5f95dda9aa80654e3a2a20a2e236221e7305

diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index 3392b54..d67f496 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -971,9 +971,8 @@ Reference<deployment::XPackage> PackageManagerImpl::getDeployedPackage_(
         INetContentTypeParameterList params;
         if (INetContentTypes::parse( data.mediaType, type, subType, &params ))
         {
-            INetContentTypeParameter const * param = params.find(
-                OString("platform") );
-            if (param != 0 && !platform_fits( param->m_sValue ))
+            auto const iter = params.find(OString("platform"));
+            if (iter != params.end() && !platform_fits(iter->second.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 e17961f..9b2a2a7 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
 
-                INetContentTypeParameter const * param = params.find(OString("platform"));
-                bool bPlatformFits(param == 0);
+                auto const iter = params.find(OString("platform"));
+                bool bPlatformFits(iter == params.end());
                 OUString aPlatform;
                 if (!bPlatformFits) // platform is specified, we have to check
                 {
-                    aPlatform = param->m_sValue;
+                    aPlatform = iter->second.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) {
-                    param = params.find(OString("type"));
-                    if (param != 0)
+                    auto const iterType = params.find(OString("type"));
+                    if (iterType != params.end())
                     {
-                        OUString const & value = param->m_sValue;
+                        OUString const & value = iterType->second.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"))
             {
-                INetContentTypeParameter const * param = params.find(OString("platform"));
-                if (param == 0 || platform_fits( param->m_sValue )) {
+                auto const iter = params.find(OString("platform"));
+                if (iter == params.end() || platform_fits(iter->second.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"))
             {
-                INetContentTypeParameter const * param = params.find(OString("type"));
-                if (param != 0) {
-                    OUString const & value = param->m_sValue;
+                auto const iter = params.find(OString("type"));
+                if (iter != params.end()) {
+                    OUString const & value = iter->second.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 db08cb9..2ce790d 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, &params ))
             continue;
 
-        INetContentTypeParameter const * param = params.find("platform");
-        if (param != 0 && !platform_fits( param->m_sValue ))
+        auto const iter = params.find("platform");
+        if (iter != params.end() && !platform_fits(iter->second.m_sValue))
             continue;
         const OUString url( makeURL( packageRootURL, fullPath ) );
 
@@ -1483,14 +1483,15 @@ void BackendImpl::PackageImpl::scanBundle(
             subType.equalsIgnoreAsciiCase( "vnd.sun.star.package-bundle-description"))
         {
             // check locale:
-            param = params.find("locale");
-            if (param == 0) {
+            auto const iterLocale = params.find("locale");
+            if (iterLocale == params.end())
+            {
                 if (descrFile.isEmpty())
                     descrFile = url;
             }
             else {
                 // match best locale:
-                LanguageTag descrTag( param->m_sValue);
+                LanguageTag descrTag(iter->second.m_sValue);
                 if (officeLocale.getLanguage() == descrTag.getLanguage())
                 {
                     size_t nPenalty = nPenaltyMax;
diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 5766660..f1b2081 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -19,8 +19,6 @@
 #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>
@@ -31,11 +29,81 @@
 #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:
@@ -935,80 +1003,6 @@ 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 b7aa71c..68badb6 100644
--- a/svl/qa/unit/test_INetContentType.cxx
+++ b/svl/qa/unit/test_INetContentType.cxx
@@ -48,8 +48,7 @@ void Test::testBad() {
     CPPUNIT_ASSERT(!INetContentTypes::parse(in, t, s, &ps));
     CPPUNIT_ASSERT(t.isEmpty());
     CPPUNIT_ASSERT(s.isEmpty());
-    CPPUNIT_ASSERT_EQUAL(
-        static_cast<INetContentTypeParameter const *>(0), ps.find("foo"));
+    CPPUNIT_ASSERT(ps.end() == ps.find("foo"));
 }
 
 void Test::testFull() {
@@ -63,9 +62,9 @@ void Test::testFull() {
     CPPUNIT_ASSERT(INetContentTypes::parse(in, t, s, &ps));
     CPPUNIT_ASSERT_EQUAL(OUString("foo"), t);
     CPPUNIT_ASSERT_EQUAL(OUString("bar"), s);
-    INetContentTypeParameter const * p = ps.find("baz");
-    CPPUNIT_ASSERT(p != 0);
-    CPPUNIT_ASSERT_EQUAL(OUString("boz"), p->m_sValue);
+    auto iter = ps.find("baz");
+    CPPUNIT_ASSERT(iter != ps.end());
+    CPPUNIT_ASSERT_EQUAL(OUString("boz"), iter->second.m_sValue);
 }
 
 void Test::testFollow() {
@@ -79,8 +78,7 @@ void Test::testFollow() {
     CPPUNIT_ASSERT(!INetContentTypes::parse(in, t, s));
     CPPUNIT_ASSERT(t.isEmpty());
     CPPUNIT_ASSERT(s.isEmpty());
-    CPPUNIT_ASSERT_EQUAL(
-        static_cast<INetContentTypeParameter const *>(0), ps.find("baz"));
+    CPPUNIT_ASSERT(ps.end() == ps.find("baz"));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index 0158436..2627bc1 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -2092,9 +2092,10 @@ rtl_TextEncoding HTMLParser::GetEncodingByMIME( const OUString& rMime )
     INetContentTypeParameterList aParameters;
     if (INetContentTypes::parse(rMime, sType, sSubType, &aParameters))
     {
-        const INetContentTypeParameter * pCharset = aParameters.find("charset");
-        if (pCharset != 0)
+        auto const iter = aParameters.find("charset");
+        if (iter != aParameters.end())
         {
+            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 bfb06b8..88e2cf9 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,11 +335,14 @@ bool parseParameters(ParameterList const & rInput,
                         break;
                 };
             }
-            pOutput->Append(new INetContentTypeParameter(p->m_aAttribute,
+            auto const ret = pOutput->insert(std::make_pair(p->m_aAttribute,
+                                    INetContentTypeParameter(p->m_aAttribute,
                                                              p->m_aCharset,
                                                              p->m_aLanguage,
                                                              aValue,
-                                                             !bBadEncoding));
+                                                             !bBadEncoding)));
+            SAL_INFO_IF(!ret.second, "tools",
+                "INetMIME: dropping duplicate parameter: " << p->m_aAttribute);
             p = pNext;
         }
     return true;
@@ -3738,24 +3741,4 @@ 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: */


More information about the Libreoffice-commits mailing list