[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Dec 8 11:01:59 PST 2010


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

New commits:
commit 0634be519f45e746396e5696b88931ad73abcd12
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Dec 8 14:00:32 2010 -0500

    Avoid use of operator[] with std::map.

diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index bef17d7..3c188f7 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -2044,8 +2044,19 @@ XclImpChDataFormatRef* XclImpChSeries::GetDataFormatRef( sal_uInt16 nPointIdx )
 
 XclImpChTextRef* XclImpChSeries::GetDataLabelRef( sal_uInt16 nPointIdx )
 {
-    if( (nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS) || (nPointIdx < EXC_CHDATAFORMAT_MAXPOINTCOUNT) )
-        return &maLabels[ nPointIdx ];
+    if ((nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS) || (nPointIdx < EXC_CHDATAFORMAT_MAXPOINTCOUNT))
+    {
+        XclImpChTextMap::iterator itr = maLabels.find(nPointIdx);
+        if (itr == maLabels.end())
+        {
+            // No object exists at this point index position.  Insert a new one.
+            XclImpChTextRef p(new XclImpChText(GetChRoot()));
+            pair<XclImpChTextMap::iterator, bool> r =
+                maLabels.insert(XclImpChTextMap::value_type(nPointIdx, p));
+            itr = r.first;
+        }
+        return &itr->second;
+    }
     return 0;
 }
 


More information about the Libreoffice-commits mailing list