[Libreoffice-commits] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Dec 8 11:56:10 PST 2010
sc/source/filter/excel/xichart.cxx | 17 +++++++++--------
sc/source/filter/inc/ftools.hxx | 32 +++++++++++++++++++++++++++++---
sc/source/filter/inc/xichart.hxx | 11 ++++++-----
3 files changed, 44 insertions(+), 16 deletions(-)
New commits:
commit d3a918eebcedcddf5ca139c04ecc833ac7305a51
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Wed Dec 8 14:22:49 2010 +0000
Replace one use of ScfRefMap
Signed-off-by: Kohei Yoshida <kyoshida at novell.com>
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 3c188f7..e047a31 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -2636,9 +2636,10 @@ bool XclImpChTypeGroup::HasVarPointFormat() const
bool XclImpChTypeGroup::HasConnectorLines() const
{
// existence of connector lines (only in stacked bar charts)
- bool bAnyStacked = maType.IsStacked() || maType.IsPercent();
- XclImpChLineFormatRef xConnLine = maChartLines.get( EXC_CHCHARTLINE_CONNECT );
- return bAnyStacked && (maTypeInfo.meTypeCateg == EXC_CHTYPECATEG_BAR) && xConnLine && xConnLine->HasLine();
+ if ( !(maType.IsStacked() || maType.IsPercent()) || (maTypeInfo.meTypeCateg != EXC_CHTYPECATEG_BAR) )
+ return false;
+ XclImpChLineFormatMap::const_iterator xConLine = maChartLines.find( EXC_CHCHARTLINE_CONNECT );
+ return ( xConLine != maChartLines.end() && xConLine->second->HasLine() );
}
const String& XclImpChTypeGroup::GetSingleSeriesTitle() const
@@ -2714,8 +2715,8 @@ void XclImpChTypeGroup::ReadChChartLine( XclImpStream& rStrm )
sal_uInt16 nLineId = rStrm.ReaduInt16();
if( (rStrm.GetNextRecId() == EXC_ID_CHLINEFORMAT) && rStrm.StartNextRecord() )
{
- XclImpChLineFormatRef xLineFmt( new XclImpChLineFormat );
- xLineFmt->ReadChLineFormat( rStrm );
+ XclImpChLineFormat xLineFmt;
+ xLineFmt.ReadChLineFormat( rStrm );
maChartLines[ nLineId ] = xLineFmt;
}
}
@@ -2817,11 +2818,11 @@ void XclImpChTypeGroup::CreateStockSeries( Reference< XChartType > xChartType, s
aTypeProp.SetBoolProperty( EXC_CHPROP_SHOWFIRST, HasDropBars() );
aTypeProp.SetBoolProperty( EXC_CHPROP_SHOWHIGHLOW, true );
// hi-lo line format
- XclImpChLineFormatRef xHiLoLine = maChartLines.get( EXC_CHCHARTLINE_HILO );
- if( xHiLoLine )
+ XclImpChLineFormatMap::const_iterator xHiLoLine = maChartLines.find( EXC_CHCHARTLINE_HILO );
+ if ( xHiLoLine != maChartLines.end() )
{
ScfPropertySet aSeriesProp( xDataSeries );
- xHiLoLine->Convert( GetChRoot(), aSeriesProp, EXC_CHOBJTYPE_HILOLINE );
+ xHiLoLine->second->Convert( GetChRoot(), aSeriesProp, EXC_CHOBJTYPE_HILOLINE );
}
// white dropbar format
XclImpChDropBarRef xUpBar = maDropBars.get( EXC_CHDROPBAR_UP );
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index c04ad3e..8e32707 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -139,7 +139,16 @@ void insert_value( Type& rnBitField, InsertType nValue, sal_uInt8 nStartBit, sal
// ============================================================================
-/** Template for a map of ref-counted objects with additional accessor functions. */
+/**
+ * Template for a map of ref-counted objects with additional accessor functions.
+ *
+ * Note that unlike <c>std::map</c> or ,c>boost::ptr_map</c> this map can be
+ * used for classes that do not have a default constructor.
+ *
+ * @tparam KeyType The key type used to access elements.
+ * @tparam ObjType The element type to be stored. Note that this is stored
+ * internally as <c>boost::shared_ptr<ObjType></c>
+ **/
template< typename KeyType, typename ObjType >
class ScfRefMap : public ::std::map< KeyType, boost::shared_ptr< ObjType > >
{
@@ -148,14 +157,31 @@ public:
typedef boost::shared_ptr< ObjType > ref_type;
typedef ::std::map< key_type, ref_type > map_type;
- /** Returns true, if the object accossiated to the passed key exists. */
+ /**
+ * Does a valid object with the passed key exist in the map?
+ *
+ * @param nKey The key to look for in the map.
+ * @return true if the key exists in the map and points to a valid instance
+ * of <c>ObjType<c>.
+ **/
inline bool has( key_type nKey ) const
{
typename map_type::const_iterator aIt = find( nKey );
return (aIt != this->end()) && aIt->second;
}
- /** Returns a reference to the object accossiated to the passed key, or 0 on error. */
+ /**
+ * Returns a reference to the object associated to the passed key.
+ *
+ * If the key does not exist in the map, a new (empty) instance of ref_type
+ * is created and returned.
+ *
+ * Note: This method differs from the behaviour of <c>std::map::operator[]</c>
+ * in that if a new instance is returned, it is NOT added to the map.
+ *
+ * @param nKey The key to look for in the map.
+ * @return The instance of <c>ref_type</c> corresponding to nKey or a new instance.
+ **/
inline ref_type get( key_type nKey ) const
{
typename map_type::const_iterator aIt = find( nKey );
diff --git a/sc/source/filter/inc/xichart.hxx b/sc/source/filter/inc/xichart.hxx
index 80ab799..54e8344 100644
--- a/sc/source/filter/inc/xichart.hxx
+++ b/sc/source/filter/inc/xichart.hxx
@@ -43,6 +43,7 @@
#include "xiescher.hxx"
#include "xistring.hxx"
#include <boost/shared_ptr.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
namespace com { namespace sun { namespace star {
namespace awt
@@ -1092,7 +1093,7 @@ private:
void ReadChDataFormat( XclImpStream& rStrm );
/** Returns true, if the chart type group contains a hi-lo line format. */
- inline bool HasHiLoLine() const { return maChartLines.has( EXC_CHCHARTLINE_HILO ); }
+ inline bool HasHiLoLine() const { return maChartLines.find( EXC_CHCHARTLINE_HILO ) != maChartLines.end(); }
/** Returns true, if the chart type group contains drop bar formats. */
inline bool HasDropBars() const { return !maDropBars.empty(); }
@@ -1105,10 +1106,10 @@ private:
void CreateStockSeries( XChartTypeRef xChartType, sal_Int32 nApiAxesSetIdx ) const;
private:
- typedef ::std::vector< XclImpChSeriesRef > XclImpChSeriesVec;
- typedef ScfRefMap< sal_uInt16, XclImpChDropBar > XclImpChDropBarMap;
- typedef ScfRefMap< sal_uInt16, XclImpChLineFormat > XclImpChLineFormatMap;
- typedef ::std::set< sal_uInt16 > UInt16Set;
+ typedef ::std::vector< XclImpChSeriesRef > XclImpChSeriesVec;
+ typedef ScfRefMap< sal_uInt16, XclImpChDropBar > XclImpChDropBarMap;
+ typedef boost::ptr_map< sal_uInt16, XclImpChLineFormat > XclImpChLineFormatMap;
+ typedef ::std::set< sal_uInt16 > UInt16Set;
XclChTypeGroup maData; /// Contents of the CHTYPEGROUP record.
XclImpChType maType; /// Chart type (e.g. CHBAR, CHLINE, ...).
More information about the Libreoffice-commits
mailing list