diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-13 17:36:17 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-13 18:03:09 -0500 |
commit | 0d22c49de2633ba540c00038633c60af172cc516 (patch) | |
tree | b77d9953557f43624fdb131e3779dafc76f28d04 | |
parent | c2aaa83660316b9c0ad01017ba3cee71a89176c5 (diff) |
Switch integer constants to enum & prefix data members with 'm'.
Change-Id: I13374e160bb369f64fc6e661c43db5da657cbfd9
-rw-r--r-- | sc/Library_sc.mk | 1 | ||||
-rw-r--r-- | sc/inc/dpglobal.hxx | 12 | ||||
-rw-r--r-- | sc/inc/dpitemdata.hxx | 3 | ||||
-rw-r--r-- | sc/inc/dptabdat.hxx | 18 | ||||
-rw-r--r-- | sc/source/core/data/dpfilteredcache.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/dpglobal.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/data/dpitemdata.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/dptabres.cxx | 26 |
8 files changed, 56 insertions, 40 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index d205b4a6bb1a..b72deec24ce5 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -122,6 +122,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/core/data/document \ sc/source/core/data/dpdimsave \ sc/source/core/data/dpfilteredcache \ + sc/source/core/data/dpglobal \ sc/source/core/data/dpgroup \ sc/source/core/data/dpitemdata \ sc/source/core/data/dpnumgroupinfo \ diff --git a/sc/inc/dpglobal.hxx b/sc/inc/dpglobal.hxx index fe94b3294069..6fffc643ba3a 100644 --- a/sc/inc/dpglobal.hxx +++ b/sc/inc/dpglobal.hxx @@ -35,6 +35,18 @@ #define PIVOT_FUNC_STD_VARP 0x0400 #define PIVOT_FUNC_AUTO 0x1000 +struct ScDPValueData +{ + enum Type { Empty = 0, Value, String, Error }; + + double mfValue; + Type meType; + + ScDPValueData(); + + void Set( double fV, Type eT ); +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpitemdata.hxx b/sc/inc/dpitemdata.hxx index f44bc3ab8836..bd33607a0fbe 100644 --- a/sc/inc/dpitemdata.hxx +++ b/sc/inc/dpitemdata.hxx @@ -36,6 +36,7 @@ #include "tools/solar.h" #include "rtl/ustring.hxx" #include "dpmacros.hxx" +#include "dpglobal.hxx" /** * When assigning a string value, you can also assign an interned string @@ -109,7 +110,7 @@ public: GroupValueAttr GetGroupValue() const; bool HasStringData() const ; - sal_uInt8 GetCellType() const; + ScDPValueData::Type GetCellType() const; #if DEBUG_PIVOT_TABLE void Dump(const char* msg) const; diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx index 6742f58e41f0..7c6dd33efbec 100644 --- a/sc/inc/dptabdat.hxx +++ b/sc/inc/dptabdat.hxx @@ -54,24 +54,6 @@ namespace com { namespace sun { namespace star { namespace sheet { #define SC_DAPI_LEVEL_WEEK 4 #define SC_DAPI_LEVEL_WEEKDAY 5 - -// -// base class ScDPTableData to allow implementation with tabular data -// by deriving only of this -// -#define SC_VALTYPE_EMPTY 0 -#define SC_VALTYPE_VALUE 1 -#define SC_VALTYPE_STRING 2 -#define SC_VALTYPE_ERROR 3 - -struct ScDPValueData -{ - double fValue; - sal_uInt8 nType; - - void Set( double fV, sal_uInt8 nT ) { fValue = fV; nType = nT; } -}; - class ScDPResultMember; class ScDPDimension; class ScDPLevel; diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx index e3231ce6410f..acb253d70bc8 100644 --- a/sc/source/core/data/dpfilteredcache.cxx +++ b/sc/source/core/data/dpfilteredcache.cxx @@ -284,11 +284,11 @@ void ScDPFilteredCache::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, if (pData) { - rVal.fValue = pData->IsValue() ? pData->GetValue() : 0.0; - rVal.nType = pData->GetCellType(); + rVal.mfValue = pData->IsValue() ? pData->GetValue() : 0.0; + rVal.meType = pData->GetCellType(); } else - rVal.Set(0.0, SC_VALTYPE_EMPTY); + rVal.Set(0.0, ScDPValueData::Empty); } rtl::OUString ScDPFilteredCache::getFieldName(SCCOL nIndex) const diff --git a/sc/source/core/data/dpglobal.cxx b/sc/source/core/data/dpglobal.cxx new file mode 100644 index 000000000000..3e690b27d06f --- /dev/null +++ b/sc/source/core/data/dpglobal.cxx @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "dpglobal.hxx" + +ScDPValueData::ScDPValueData() : mfValue(0.0), meType(String) {} + +void ScDPValueData::Set( double fV, Type eT ) +{ + mfValue = fV; + meType = eT; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/dpitemdata.cxx b/sc/source/core/data/dpitemdata.cxx index 85a6917dda86..9cac3e1093b5 100644 --- a/sc/source/core/data/dpitemdata.cxx +++ b/sc/source/core/data/dpitemdata.cxx @@ -267,21 +267,21 @@ ScDPItemData& ScDPItemData::operator= (const ScDPItemData& r) return *this; } -sal_uInt8 ScDPItemData::GetCellType() const +ScDPValueData::Type ScDPItemData::GetCellType() const { switch (meType) { case Error: - return SC_VALTYPE_ERROR; + return ScDPValueData::Error; case Empty: - return SC_VALTYPE_EMPTY; + return ScDPValueData::Empty; case Value: - return SC_VALTYPE_VALUE; + return ScDPValueData::Value; default: ; } - return SC_VALTYPE_STRING; + return ScDPValueData::String; } #if DEBUG_PIVOT_TABLE diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index e5e3e9293a8c..974e94321fff 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -367,7 +367,7 @@ void ScDPAggData::Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, cons if (nCount<0) // error? return; // nothing more... - if ( rNext.nType == SC_VALTYPE_EMPTY ) + if (rNext.meType == ScDPValueData::Empty) return; if ( rSubState.eColForce != SUBTOTAL_FUNC_NONE && rSubState.eRowForce != SUBTOTAL_FUNC_NONE && @@ -381,12 +381,12 @@ void ScDPAggData::Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, cons if ( eFunc != SUBTOTAL_FUNC_CNT2 ) // CNT2 counts everything, incl. strings and errors { - if ( rNext.nType == SC_VALTYPE_ERROR ) + if (rNext.meType == ScDPValueData::Error) { nCount = -1; // -1 for error (not for CNT2) return; } - if ( rNext.nType == SC_VALTYPE_STRING ) + if (rNext.meType == ScDPValueData::String) return; // ignore } @@ -396,13 +396,13 @@ void ScDPAggData::Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, cons { case SUBTOTAL_FUNC_SUM: case SUBTOTAL_FUNC_AVE: - if ( !SubTotal::SafePlus( fVal, rNext.fValue ) ) + if ( !SubTotal::SafePlus( fVal, rNext.mfValue ) ) nCount = -1; // -1 for error break; case SUBTOTAL_FUNC_PROD: if ( nCount == 1 ) // copy first value (fVal is initialized to 0) - fVal = rNext.fValue; - else if ( !SubTotal::SafeMult( fVal, rNext.fValue ) ) + fVal = rNext.mfValue; + else if ( !SubTotal::SafeMult( fVal, rNext.mfValue ) ) nCount = -1; // -1 for error break; case SUBTOTAL_FUNC_CNT: @@ -410,12 +410,12 @@ void ScDPAggData::Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, cons // nothing more than incrementing nCount break; case SUBTOTAL_FUNC_MAX: - if ( nCount == 1 || rNext.fValue > fVal ) - fVal = rNext.fValue; + if ( nCount == 1 || rNext.mfValue > fVal ) + fVal = rNext.mfValue; break; case SUBTOTAL_FUNC_MIN: - if ( nCount == 1 || rNext.fValue < fVal ) - fVal = rNext.fValue; + if ( nCount == 1 || rNext.mfValue < fVal ) + fVal = rNext.mfValue; break; case SUBTOTAL_FUNC_STD: case SUBTOTAL_FUNC_STDP: @@ -423,10 +423,10 @@ void ScDPAggData::Update( const ScDPValueData& rNext, ScSubTotalFunc eFunc, cons case SUBTOTAL_FUNC_VARP: { // fAux is used to sum up squares - if ( !SubTotal::SafePlus( fVal, rNext.fValue ) ) + if ( !SubTotal::SafePlus( fVal, rNext.mfValue ) ) nCount = -1; // -1 for error - double fAdd = rNext.fValue; - if ( !SubTotal::SafeMult( fAdd, rNext.fValue ) || + double fAdd = rNext.mfValue; + if ( !SubTotal::SafeMult( fAdd, rNext.mfValue ) || !SubTotal::SafePlus( fAux, fAdd ) ) nCount = -1; // -1 for error } |