[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Dec 8 13:29:33 PST 2010


 sc/source/filter/excel/xichart.cxx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 2d7c40c11c745c3c8e63b6b90ee724038b574d9d
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Dec 8 16:29:12 2010 -0500

    More on killing use of operator[] with std::map.

diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 35de87d..04ce91f 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -3682,7 +3682,12 @@ void XclImpChChart::ReadChDefaultText( XclImpStream& rStrm )
     {
         XclImpChTextRef xText( new XclImpChText( GetChRoot() ) );
         xText->ReadRecordGroup( rStrm );
-        maDefTexts[ nTextId ] = xText;
+        XclImpChTextMap::iterator itr = maDefTexts.find(nTextId);
+        if (itr != maDefTexts.end())
+            // Remove existing element before inserting a new one.
+            maDefTexts.erase(itr);
+
+        maDefTexts.insert(XclImpChTextMap::value_type(nTextId, xText));
     }
 }
 
@@ -3729,7 +3734,9 @@ XclImpChTextRef XclImpChChart::GetDefaultText( XclChTextType eTextType ) const
         case EXC_CHTEXTTYPE_AXISLABEL:  nDefTextId = bBiff8 ? EXC_CHDEFTEXT_AXESSET : EXC_CHDEFTEXT_GLOBAL; break;
         case EXC_CHTEXTTYPE_DATALABEL:  nDefTextId = bBiff8 ? EXC_CHDEFTEXT_AXESSET : EXC_CHDEFTEXT_GLOBAL; break;
     }
-    return maDefTexts.get( nDefTextId );
+
+    XclImpChTextMap::const_iterator itr = maDefTexts.find(nDefTextId);
+    return itr == maDefTexts.end() ? XclImpChTextRef() : itr->second;
 }
 
 bool XclImpChChart::IsManualPlotArea() const


More information about the Libreoffice-commits mailing list