diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-09 14:58:06 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-09 15:25:09 -0500 |
commit | dc261fc0c4e7f4c29b142c53d4d4e65f8ff3a092 (patch) | |
tree | 0c6b1658de8b5dad530753ded9d3b524ddad27ce /sc | |
parent | Moved definitions of ScDPItemData where they belong. (diff) | |
download | core-dc261fc0c4e7f4c29b142c53d4d4e65f8ff3a092.tar.gz core-dc261fc0c4e7f4c29b142c53d4d4e65f8ff3a092.zip |
Cleaning up ScDPItemData a bit...
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/dpglobal.hxx | 26 | ||||
-rw-r--r-- | sc/inc/dptabsrc.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/dpglobal.cxx | 48 | ||||
-rw-r--r-- | sc/source/core/data/dptablecache.cxx | 14 |
4 files changed, 51 insertions, 38 deletions
diff --git a/sc/inc/dpglobal.hxx b/sc/inc/dpglobal.hxx index b5ce0190b7d3..992e17152bd2 100644 --- a/sc/inc/dpglobal.hxx +++ b/sc/inc/dpglobal.hxx @@ -87,37 +87,37 @@ public: private: union { - sal_uLong nNumFormat; + sal_uLong mnNumFormat; sal_Int32 mnDatePart; }; - String aString; - double fValue; + String maString; + double mfValue; sal_uInt8 mbFlag; friend class ScDPCache; public: - ScDPItemData() : nNumFormat( 0 ), fValue(0.0), mbFlag( 0 ){} - ScDPItemData( sal_uLong nNF, const String & rS, double fV, sal_uInt8 bF ):nNumFormat(nNF), aString(rS), fValue(fV), mbFlag( bF ){} - ScDPItemData( const String& rS, double fV = 0.0, bool bHV = false, const sal_uLong nNumFormat = 0 , bool bData = true) ; + ScDPItemData(); + ScDPItemData(sal_uLong nNF, const String & rS, double fV, sal_uInt8 bF); + ScDPItemData(const String& rS, double fV = 0.0, bool bHV = false, const sal_uLong nNumFormat = 0 , bool bData = true); ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab, bool bLabel); - void SetString( const String& rS ) { aString = rS; mbFlag &= ~(MK_VAL|MK_DATE); nNumFormat = 0; mbFlag |= MK_DATA; } - bool IsCaseInsEqual( const ScDPItemData& r ) const; + void SetString( const String& rS ); + bool IsCaseInsEqual(const ScDPItemData& r) const; - size_t Hash() const; + size_t Hash() const; // exact equality - bool operator==( const ScDPItemData& r ) const; + bool operator==( const ScDPItemData& r ) const; // case insensitive equality - static sal_Int32 Compare( const ScDPItemData& rA, const ScDPItemData& rB ); + static sal_Int32 Compare( const ScDPItemData& rA, const ScDPItemData& rB ); public: bool IsHasData() const ; bool IsHasErr() const ; bool IsValue() const; - String GetString() const ; - double GetValue() const ; + String GetString() const ; + double GetValue() const ; bool HasStringData() const ; bool IsDate() const; bool HasDatePart() const; diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx index c3b3031224c4..8a57d70d999a 100644 --- a/sc/inc/dptabsrc.hxx +++ b/sc/inc/dptabsrc.hxx @@ -60,7 +60,6 @@ #include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase6.hxx> -#include "dpglobal.hxx" #include "dptabdat.hxx" namespace com { namespace sun { namespace star { diff --git a/sc/source/core/data/dpglobal.cxx b/sc/source/core/data/dpglobal.cxx index 142c84f98e5f..cb210b1274ba 100644 --- a/sc/source/core/data/dpglobal.cxx +++ b/sc/source/core/data/dpglobal.cxx @@ -40,14 +40,20 @@ bool ScDPItemData::isDate( sal_uLong nNumType ) return ((nNumType & NUMBERFORMAT_DATE) != 0) ? 1 : 0; } +ScDPItemData::ScDPItemData() : + mnNumFormat( 0 ), mfValue(0.0), mbFlag(0) {} + +ScDPItemData::ScDPItemData(sal_uLong nNF, const String & rS, double fV, sal_uInt8 bF) : + mnNumFormat(nNF), maString(rS), mfValue(fV), mbFlag(bF) {} + ScDPItemData::ScDPItemData(const String& rS, double fV, bool bHV, const sal_uLong nNumFormatP, bool bData) : - nNumFormat( nNumFormatP ), aString(rS), fValue(fV), - mbFlag( (MK_VAL*!!bHV) | (MK_DATA*!!bData) | (MK_ERR*!!false) | (MK_DATE*!!isDate( nNumFormat ) ) ) + mnNumFormat( nNumFormatP ), maString(rS), mfValue(fV), + mbFlag( (MK_VAL*!!bHV) | (MK_DATA*!!bData) | (MK_ERR*!!false) | (MK_DATE*!!isDate( mnNumFormat ) ) ) { } ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab, bool bLabel) : - nNumFormat( 0 ), fValue(0.0), mbFlag( 0 ) + mnNumFormat( 0 ), mfValue(0.0), mbFlag( 0 ) { String aDocStr; pDoc->GetString( nCol, nRow, nDocTab, aDocStr ); @@ -68,10 +74,10 @@ ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocT sal_uLong nFormat = NUMBERFORMAT_NUMBER; if ( pFormatter ) nFormat = pFormatter->GetType( pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) ) ); - aString = aDocStr; - fValue = fVal; + maString = aDocStr; + mfValue = fVal; mbFlag |= MK_VAL|MK_DATA; - nNumFormat = pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) ); + mnNumFormat = pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) ); isDate( nFormat ) ? ( mbFlag |= MK_DATE ) : (mbFlag &= ~MK_DATE); } else if (bLabel || pDoc->HasData(nCol, nRow, nDocTab)) @@ -94,23 +100,31 @@ ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocT } } +void ScDPItemData::SetString( const String& rS ) +{ + maString = rS; + mbFlag &= ~(MK_VAL|MK_DATE); + mnNumFormat = 0; + mbFlag |= MK_DATA; +} + bool ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const { //! pass Transliteration? //! inline? - return IsValue() ? ( r.IsValue() && rtl::math::approxEqual( fValue, r.fValue ) ) : + return IsValue() ? ( r.IsValue() && rtl::math::approxEqual( mfValue, r.mfValue ) ) : ( !r.IsValue() && - ScGlobal::GetpTransliteration()->isEqual( aString, r.aString ) ); + ScGlobal::GetpTransliteration()->isEqual( maString, r.maString ) ); } size_t ScDPItemData::Hash() const { if ( IsValue() ) - return (size_t) rtl::math::approxFloor( fValue ); + return (size_t) rtl::math::approxFloor( mfValue ); else // If we do unicode safe case insensitive hash we can drop // ScDPItemData::operator== and use ::IsCasInsEqual - return rtl_ustr_hashCode_WithLength( aString.GetBuffer(), aString.Len() ); + return rtl_ustr_hashCode_WithLength( maString.GetBuffer(), maString.Len() ); } bool ScDPItemData::operator==( const ScDPItemData& r ) const @@ -123,7 +137,7 @@ bool ScDPItemData::operator==( const ScDPItemData& r ) const if ( IsDate() != r.IsDate() ) return false; else if ( r.IsValue() ) - return rtl::math::approxEqual( fValue, r.fValue ); + return rtl::math::approxEqual( mfValue, r.mfValue ); else return false; } @@ -131,7 +145,7 @@ bool ScDPItemData::operator==( const ScDPItemData& r ) const return false; else // need exact equality until we have a safe case insensitive string hash - return aString == r.aString; + return maString == r.maString; } sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA, @@ -141,14 +155,14 @@ sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA, { if ( rB.IsValue() ) { - if ( rtl::math::approxEqual( rA.fValue, rB.fValue ) ) + if ( rtl::math::approxEqual( rA.mfValue, rB.mfValue ) ) { if ( rA.IsDate() == rB.IsDate() ) return 0; else return rA.IsDate() ? 1: -1; } - else if ( rA.fValue < rB.fValue ) + else if ( rA.mfValue < rB.mfValue ) return -1; else return 1; @@ -159,7 +173,7 @@ sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA, else if ( rB.IsValue() ) return 1; // values first else - return ScGlobal::GetCollator()->compareString( rA.aString, rB.aString ); + return ScGlobal::GetCollator()->compareString( rA.maString, rB.maString ); } sal_uInt8 ScDPItemData::GetType() const @@ -191,12 +205,12 @@ bool ScDPItemData::IsValue() const String ScDPItemData::GetString() const { - return aString; + return maString; } double ScDPItemData::GetValue() const { - return fValue; + return mfValue; } bool ScDPItemData::HasStringData() const diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx index fc73fb0f09ab..e81d3a52f2f3 100644 --- a/sc/source/core/data/dptablecache.cxx +++ b/sc/source/core/data/dptablecache.cxx @@ -595,7 +595,7 @@ bool ScDPCache::AddData(long nDim, ScDPItemData* pData) // Wrap this instance with scoped pointer to ensure proper deletion. auto_ptr<ScDPItemData> p(pData); - pData->SetDate(ScDPItemData::isDate(GetNumType(pData->nNumFormat))); + pData->SetDate(ScDPItemData::isDate(GetNumType(pData->mnNumFormat))); SCROW nIndex = 0; if (!hasItemInDimension(maTableDataValues[nDim], maGlobalOrder[nDim], *pData, nIndex)) @@ -628,7 +628,7 @@ String ScDPCache::GetDimensionName( sal_uInt16 nColumn ) const if ( static_cast<size_t>(nColumn+1) < maLabelNames.size() ) { - return maLabelNames[nColumn+1].aString; + return maLabelNames[nColumn+1].maString; } else return String(); @@ -642,16 +642,16 @@ void ScDPCache::AddLabel(ScDPItemData *pData) maLabelNames.push_back( new ScDPItemData(ScGlobal::GetRscString(STR_PIVOT_DATA)) ); //reset name if needed - String strNewName = pData->aString; + String strNewName = pData->maString; bool bFound = false; long nIndex = 1; do { for ( long i= maLabelNames.size()-1; i>=0; i-- ) { - if( maLabelNames[i].aString == strNewName ) + if( maLabelNames[i].maString == strNewName ) { - strNewName = pData->aString; + strNewName = pData->maString; strNewName += String::CreateFromInt32( nIndex ); nIndex ++ ; bFound = true; @@ -661,7 +661,7 @@ void ScDPCache::AddLabel(ScDPItemData *pData) } while ( !bFound ); - pData->aString = strNewName; + pData->maString = strNewName; maLabelNames.push_back( pData ); } @@ -732,7 +732,7 @@ sal_uLong ScDPCache::GetNumberFormat( long nDim ) const nCount = 10; for (size_t i = 0; i < nCount; ++i) { - sal_uLong n = maTableDataValues[nDim][i].nNumFormat; + sal_uLong n = maTableDataValues[nDim][i].mnNumFormat; if (n) return n; } |