summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-09 14:41:25 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-09 15:25:09 -0500
commit692496aa2e9acbb4b428cd395dbeb2ec8c8abc1e (patch)
treeb078064e7ea74dda3d7462b6a9c85a8011cc1269 /sc/source
parent0ee411e6870f73ad6000ebb2502c777cabe30bea (diff)
Moved definitions of ScDPItemData where they belong.
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/dpglobal.cxx187
-rw-r--r--sc/source/core/data/dptablecache.cxx195
2 files changed, 191 insertions, 191 deletions
diff --git a/sc/source/core/data/dpglobal.cxx b/sc/source/core/data/dpglobal.cxx
index 3561eff7e7b4..142c84f98e5f 100644
--- a/sc/source/core/data/dpglobal.cxx
+++ b/sc/source/core/data/dpglobal.cxx
@@ -31,8 +31,193 @@
#include "dpglobal.hxx"
#include "document.hxx"
#include "dpobject.hxx"
+#include "cell.hxx"
+#include "globstr.hrc"
+#include "dptabdat.hxx"
-#include <stdio.h>
+bool ScDPItemData::isDate( sal_uLong nNumType )
+{
+ return ((nNumType & NUMBERFORMAT_DATE) != 0) ? 1 : 0;
+}
+
+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 ) ) )
+{
+}
+
+ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab, bool bLabel) :
+ nNumFormat( 0 ), fValue(0.0), mbFlag( 0 )
+{
+ String aDocStr;
+ pDoc->GetString( nCol, nRow, nDocTab, aDocStr );
+
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+
+ ScAddress aPos( nCol, nRow, nDocTab );
+ ScBaseCell* pCell = pDoc->GetCell( aPos );
+
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetErrCode() )
+ {
+ SetString ( aDocStr );
+ mbFlag |= MK_ERR;
+ }
+ else if ( pDoc->HasValueData( nCol, nRow, nDocTab ) )
+ {
+ double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nDocTab));
+ sal_uLong nFormat = NUMBERFORMAT_NUMBER;
+ if ( pFormatter )
+ nFormat = pFormatter->GetType( pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) ) );
+ aString = aDocStr;
+ fValue = fVal;
+ mbFlag |= MK_VAL|MK_DATA;
+ nNumFormat = pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) );
+ isDate( nFormat ) ? ( mbFlag |= MK_DATE ) : (mbFlag &= ~MK_DATE);
+ }
+ else if (bLabel || pDoc->HasData(nCol, nRow, nDocTab))
+ {
+ if (bLabel && !aDocStr.Len())
+ {
+ // Replace an empty label string with column name.
+ rtl::OUStringBuffer aBuf;
+ aBuf.append(ScGlobal::GetRscString(STR_COLUMN));
+ aBuf.append(sal_Unicode(' '));
+
+ ScAddress aColAddr(nCol, 0, 0);
+ rtl::OUString aColStr;
+ aColAddr.Format(aColStr, SCA_VALID_COL, NULL);
+ aBuf.append(aColStr);
+ aDocStr = aBuf.makeStringAndClear();
+ }
+
+ SetString(aDocStr);
+ }
+}
+
+bool ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const
+{
+ //! pass Transliteration?
+ //! inline?
+ return IsValue() ? ( r.IsValue() && rtl::math::approxEqual( fValue, r.fValue ) ) :
+ ( !r.IsValue() &&
+ ScGlobal::GetpTransliteration()->isEqual( aString, r.aString ) );
+}
+
+size_t ScDPItemData::Hash() const
+{
+ if ( IsValue() )
+ return (size_t) rtl::math::approxFloor( fValue );
+ 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() );
+}
+
+bool ScDPItemData::operator==( const ScDPItemData& r ) const
+{
+ if ( IsValue() )
+ {
+ if( (HasDatePart() != r.HasDatePart()) || (HasDatePart() && mnDatePart != r.mnDatePart) )
+ return false;
+
+ if ( IsDate() != r.IsDate() )
+ return false;
+ else if ( r.IsValue() )
+ return rtl::math::approxEqual( fValue, r.fValue );
+ else
+ return false;
+ }
+ else if ( r.IsValue() )
+ return false;
+ else
+ // need exact equality until we have a safe case insensitive string hash
+ return aString == r.aString;
+}
+
+sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA,
+ const ScDPItemData& rB )
+{
+ if ( rA.IsValue() )
+ {
+ if ( rB.IsValue() )
+ {
+ if ( rtl::math::approxEqual( rA.fValue, rB.fValue ) )
+ {
+ if ( rA.IsDate() == rB.IsDate() )
+ return 0;
+ else
+ return rA.IsDate() ? 1: -1;
+ }
+ else if ( rA.fValue < rB.fValue )
+ return -1;
+ else
+ return 1;
+ }
+ else
+ return -1; // values first
+ }
+ else if ( rB.IsValue() )
+ return 1; // values first
+ else
+ return ScGlobal::GetCollator()->compareString( rA.aString, rB.aString );
+}
+
+sal_uInt8 ScDPItemData::GetType() const
+{
+ if ( IsHasErr() )
+ return SC_VALTYPE_ERROR;
+ else if ( !IsHasData() )
+ return SC_VALTYPE_EMPTY;
+ else if ( IsValue())
+ return SC_VALTYPE_VALUE;
+ else
+ return SC_VALTYPE_STRING;
+}
+
+bool ScDPItemData::IsHasData() const
+{
+ return !!(mbFlag&MK_DATA);
+}
+
+bool ScDPItemData::IsHasErr() const
+{
+ return !!(mbFlag&MK_ERR);
+}
+
+bool ScDPItemData::IsValue() const
+{
+ return !!(mbFlag&MK_VAL);
+}
+
+String ScDPItemData::GetString() const
+{
+ return aString;
+}
+
+double ScDPItemData::GetValue() const
+{
+ return fValue;
+}
+
+bool ScDPItemData::HasStringData() const
+{
+ return IsHasData()&&!IsHasErr()&&!IsValue();
+}
+
+bool ScDPItemData::IsDate() const
+{
+ return !!(mbFlag&MK_DATE);
+}
+
+bool ScDPItemData::HasDatePart() const
+{
+ return !!(mbFlag&MK_DATEPART);
+}
+
+void ScDPItemData::SetDate( bool b )
+{
+ b ? ( mbFlag |= MK_DATE ) : ( mbFlag &= ~MK_DATE );
+}
namespace ScDPGlobal
{
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 6dd05e9b398a..fc73fb0f09ab 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -28,18 +28,16 @@
************************************************************************/
#include "dptablecache.hxx"
+
#include "document.hxx"
-#include "cell.hxx"
#include "queryentry.hxx"
-#include "globstr.hrc"
-
-#include <rtl/math.hxx>
#include "queryparam.hxx"
#include "dpglobal.hxx"
-#include "dptabdat.hxx"
#include "dpobject.hxx"
-
+#include "globstr.hrc"
#include "docoptio.hxx"
+
+#include <rtl/math.hxx>
#include <unotools/textsearch.hxx>
#include <com/sun/star/sdbc/DataType.hpp>
@@ -63,10 +61,6 @@ using ::std::auto_ptr;
namespace {
-bool isDate( sal_uLong nNumType )
-{
- return ((nNumType & NUMBERFORMAT_DATE) != 0) ? 1 : 0;
-}
/**
* Search for an item in the data array. If it's in the array, return its
@@ -184,185 +178,6 @@ ScDPItemData* lcl_GetItemValue(
}
-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 ) ) )
-{
-}
-
-ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab, bool bLabel) :
- nNumFormat( 0 ), fValue(0.0), mbFlag( 0 )
-{
- String aDocStr;
- pDoc->GetString( nCol, nRow, nDocTab, aDocStr );
-
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
-
- ScAddress aPos( nCol, nRow, nDocTab );
- ScBaseCell* pCell = pDoc->GetCell( aPos );
-
- if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetErrCode() )
- {
- SetString ( aDocStr );
- mbFlag |= MK_ERR;
- }
- else if ( pDoc->HasValueData( nCol, nRow, nDocTab ) )
- {
- double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nDocTab));
- sal_uLong nFormat = NUMBERFORMAT_NUMBER;
- if ( pFormatter )
- nFormat = pFormatter->GetType( pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) ) );
- aString = aDocStr;
- fValue = fVal;
- mbFlag |= MK_VAL|MK_DATA;
- nNumFormat = pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) );
- isDate( nFormat ) ? ( mbFlag |= MK_DATE ) : (mbFlag &= ~MK_DATE);
- }
- else if (bLabel || pDoc->HasData(nCol, nRow, nDocTab))
- {
- if (bLabel && !aDocStr.Len())
- {
- // Replace an empty label string with column name.
- rtl::OUStringBuffer aBuf;
- aBuf.append(ScGlobal::GetRscString(STR_COLUMN));
- aBuf.append(sal_Unicode(' '));
-
- ScAddress aColAddr(nCol, 0, 0);
- rtl::OUString aColStr;
- aColAddr.Format(aColStr, SCA_VALID_COL, NULL);
- aBuf.append(aColStr);
- aDocStr = aBuf.makeStringAndClear();
- }
-
- SetString(aDocStr);
- }
-}
-
-bool ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const
-{
- //! pass Transliteration?
- //! inline?
- return IsValue() ? ( r.IsValue() && rtl::math::approxEqual( fValue, r.fValue ) ) :
- ( !r.IsValue() &&
- ScGlobal::GetpTransliteration()->isEqual( aString, r.aString ) );
-}
-
-size_t ScDPItemData::Hash() const
-{
- if ( IsValue() )
- return (size_t) rtl::math::approxFloor( fValue );
- 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() );
-}
-
-bool ScDPItemData::operator==( const ScDPItemData& r ) const
-{
- if ( IsValue() )
- {
- if( (HasDatePart() != r.HasDatePart()) || (HasDatePart() && mnDatePart != r.mnDatePart) )
- return false;
-
- if ( IsDate() != r.IsDate() )
- return false;
- else if ( r.IsValue() )
- return rtl::math::approxEqual( fValue, r.fValue );
- else
- return false;
- }
- else if ( r.IsValue() )
- return false;
- else
- // need exact equality until we have a safe case insensitive string hash
- return aString == r.aString;
-}
-
-sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA,
- const ScDPItemData& rB )
-{
- if ( rA.IsValue() )
- {
- if ( rB.IsValue() )
- {
- if ( rtl::math::approxEqual( rA.fValue, rB.fValue ) )
- {
- if ( rA.IsDate() == rB.IsDate() )
- return 0;
- else
- return rA.IsDate() ? 1: -1;
- }
- else if ( rA.fValue < rB.fValue )
- return -1;
- else
- return 1;
- }
- else
- return -1; // values first
- }
- else if ( rB.IsValue() )
- return 1; // values first
- else
- return ScGlobal::GetCollator()->compareString( rA.aString, rB.aString );
-}
-
-sal_uInt8 ScDPItemData::GetType() const
-{
- if ( IsHasErr() )
- return SC_VALTYPE_ERROR;
- else if ( !IsHasData() )
- return SC_VALTYPE_EMPTY;
- else if ( IsValue())
- return SC_VALTYPE_VALUE;
- else
- return SC_VALTYPE_STRING;
-}
-
-bool ScDPItemData::IsHasData() const
-{
- return !!(mbFlag&MK_DATA);
-}
-
-bool ScDPItemData::IsHasErr() const
-{
- return !!(mbFlag&MK_ERR);
-}
-
-bool ScDPItemData::IsValue() const
-{
- return !!(mbFlag&MK_VAL);
-}
-
-String ScDPItemData::GetString() const
-{
- return aString;
-}
-
-double ScDPItemData::GetValue() const
-{
- return fValue;
-}
-
-bool ScDPItemData::HasStringData() const
-{
- return IsHasData()&&!IsHasErr()&&!IsValue();
-}
-
-bool ScDPItemData::IsDate() const
-{
- return !!(mbFlag&MK_DATE);
-}
-
-bool ScDPItemData::HasDatePart() const
-{
- return !!(mbFlag&MK_DATEPART);
-}
-
-void ScDPItemData::SetDate( bool b )
-{
- b ? ( mbFlag |= MK_DATE ) : ( mbFlag &= ~MK_DATE );
-}
-
// -----------------------------------------------------------------------
//class ScDPTableDataCache
//To cache the pivot table data source
@@ -780,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(isDate(GetNumType(pData->nNumFormat)));
+ pData->SetDate(ScDPItemData::isDate(GetNumType(pData->nNumFormat)));
SCROW nIndex = 0;
if (!hasItemInDimension(maTableDataValues[nDim], maGlobalOrder[nDim], *pData, nIndex))