[Libreoffice-commits] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Dec 8 10:56:20 PST 2010
sc/source/filter/excel/xichart.cxx | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
New commits:
commit bb6cfc590f5c6313abbfed37ce0553bad5fbf549
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Dec 8 13:54:49 2010 -0500
Avoid using operator[] with std::map when inserting a new element.
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 219009a..bef17d7 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -135,6 +135,8 @@ using ::com::sun::star::chart2::data::XLabeledDataSequence;
using ::formula::FormulaToken;
using ::formula::StackVar;
+using ::boost::shared_ptr;
+using ::std::pair;
namespace cssc = ::com::sun::star::chart;
namespace cssc2 = ::com::sun::star::chart2;
@@ -2023,8 +2025,20 @@ XclImpChDataFormatRef* XclImpChSeries::GetDataFormatRef( sal_uInt16 nPointIdx )
{
if( nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS )
return &mxSeriesFmt;
- if( nPointIdx < EXC_CHDATAFORMAT_MAXPOINTCOUNT )
- return &maPointFmts[ nPointIdx ];
+
+ if (nPointIdx < EXC_CHDATAFORMAT_MAXPOINTCOUNT)
+ {
+ XclImpChDataFormatMap::iterator itr = maPointFmts.find(nPointIdx);
+ if (itr == maPointFmts.end())
+ {
+ // No object exists at this point index position. Insert a new one.
+ XclImpChDataFormatRef p(new XclImpChDataFormat(GetChRoot()));
+ pair<XclImpChDataFormatMap::iterator, bool> r =
+ maPointFmts.insert(XclImpChDataFormatMap::value_type(nPointIdx, p));
+ itr = r.first;
+ }
+ return &itr->second;
+ }
return 0;
}
More information about the Libreoffice-commits
mailing list