A bit of cleanup of the data pilot code.

Removed unnecessary // this is done by <who> on <date> type of comments.
Plus renamed some method names to be consistent with its neighboring
method naming conventions.

And some indentation hiccups.
This commit is contained in:
Kohei Yoshida 2010-11-12 15:29:10 -05:00
parent f125fb2f99
commit 85cb2e9044
8 changed files with 61 additions and 99 deletions

View file

@ -57,17 +57,11 @@ class ScDPDimension;
class ScDPCollection;
struct ScDPCacheCell;
struct ScQueryParam;
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
class ScDPItemData;
// End Comments
class Date;
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
class ScDPTableDataCache;
struct ScDPValueData;
// End Comments
// ----------------------------------------------------------------------------
class SC_DLLPUBLIC ScDPCacheTable
@ -76,18 +70,12 @@ public:
/** individual filter item used in SingleFilter and GroupFilter. */
struct FilterItem
{
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
String maString;
// End Comments
String maString;
double mfValue;
bool mbHasValue;
FilterItem();
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
bool match( const ScDPItemData& rCellData ) const;
// End Comments
bool match( const ScDPItemData& rCellData ) const;
};
/** interface class used for filtering of rows. */
@ -96,27 +84,19 @@ public:
public:
/** returns true if the matching condition is met for a single cell
value, or false otherwise. */
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
virtual bool match( const ScDPItemData& rCellData ) const = 0;
// End Comments
};
/** ordinary single-item filter. */
class SingleFilter : public FilterBase
{
public:
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
explicit SingleFilter(String aString, double fValue, bool bHasValue);
// End Comments
virtual ~SingleFilter(){}
virtual ~SingleFilter() {}
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
virtual bool match(const ScDPItemData& rCellData) const;
// End Comments
const String getMatchString();
virtual bool match(const ScDPItemData& rCellData) const;
const String& getMatchString();
double getMatchValue() const;
bool hasValue() const;
@ -130,20 +110,13 @@ public:
class GroupFilter : public FilterBase
{
public:
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
GroupFilter();
// End Comments
virtual ~GroupFilter(){}
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
virtual ~GroupFilter() {}
virtual bool match( const ScDPItemData& rCellData ) const;
// End Comments
void addMatchItem(const String& rStr, double fVal, bool bHasValue);
size_t getMatchItemCount() const;
private:
::std::vector<FilterItem> maItems;
};
@ -155,26 +128,23 @@ public:
Criterion();
};
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
ScDPCacheTable( ScDocument* pDoc,long nId );
// End Comments
ScDPCacheTable( ScDocument* pDoc, long nId );
~ScDPCacheTable();
sal_Int32 getRowSize() const;
sal_Int32 getColSize() const;
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
ScDPTableDataCache* GetCache() const;
ScDPTableDataCache* getCache() const;
/** Fill the internal table from the cell range provided. This function
assumes that the first row is the column header. */
assumes that the first row is the column header. */
void fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
bool bIgnoreEmptyRows, bool bRepeatIfEmpty );
/** Fill the internal table from database connection object. This function
assumes that the first row is the column header. */
void fillTable();
// End Comments
/** Check whether a specified row is active or not. When a row is active,
it is used in calculation of the results data. A row becomes inactive
@ -191,20 +161,17 @@ public:
const ScDPItemData* getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
void getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
String getFieldName( SCCOL nIndex) const;
//End Comments
/** Get the field index (i.e. column ID in the original data source) based
on the string value that corresponds with the column title. It returns
-1 if no field matching the string value exists. */
sal_Int32 getFieldIndex(const String& rStr) const;
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
/** Get the unique entries for a field specified by index. The caller must
make sure that the table is filled before calling function, or it will
get an empty collection. */
make sure that the table is filled before calling function, or it will
get an empty collection. */
const ::std::vector<SCROW>& getFieldEntries( sal_Int32 nColumn ) const;
// End Comments
/** Filter the table based on the specified criteria, and copy the
result to rTabData. This method is used, for example, to generate
a drill-down data table. */
@ -228,24 +195,18 @@ private:
*/
bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, const ::std::hash_set<sal_Int32>& rRepeatIfEmptyDims) const;
void getValueData(ScDocument* pDoc, const ScAddress& rPos, ScDPCacheCell& rCell);
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
void InitNoneCache( ScDocument* pDoc );
// End Comments
void initNoneCache( ScDocument* pDoc );
private:
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
/** unique field entires for each field (column). */
::std::vector< ::std::vector<SCROW> > maFieldEntries;
// End Comments
/** used to track visibility of rows. The first row below the header row
has the index of 0. */
::std::vector<bool> maRowsVisible;
// Wang Xu Ming -- 2009-8-17
// DataPilot Migration - Cache&&Performance
ScDPTableDataCache* mpCache;
ScDPTableDataCache* mpNoneCache;
// End Comments
};
#endif

View file

@ -101,7 +101,7 @@ bool ScDPCacheTable::SingleFilter::match( const ScDPItemData& rCellData ) const
return maItem.match(rCellData);
}
const String ScDPCacheTable::SingleFilter::getMatchString()
const String& ScDPCacheTable::SingleFilter::getMatchString()
{
return maItem.maString;
}
@ -166,7 +166,7 @@ ScDPCacheTable::ScDPCacheTable( ScDocument* pDoc,long nId ) :
mpCache = pDoc->GetDPObjectCache( nId );
else
{ //create a temp cache object
InitNoneCache( NULL );
initNoneCache( NULL );
}
}
@ -176,19 +176,19 @@ ScDPCacheTable::~ScDPCacheTable()
sal_Int32 ScDPCacheTable::getRowSize() const
{
return GetCache()->GetRowCount();
return getCache()->GetRowCount();
}
sal_Int32 ScDPCacheTable::getColSize() const
{
return GetCache()->GetColumnCount();
return getCache()->GetColumnCount();
}
void ScDPCacheTable::fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
bool bIgnoreEmptyRows, bool bRepeatIfEmpty )
{
if ( mpCache == NULL )
InitNoneCache( NULL );
initNoneCache( NULL );
//check cache
const SCROW nRowCount = getRowSize();
const SCCOL nColCount = (SCCOL) getColSize();
@ -206,23 +206,23 @@ void ScDPCacheTable::fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
// Data rows
for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
{
SCROW nMemCount = GetCache()->GetDimMemberCount( nCol );
SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
if ( nMemCount )
{
std::vector< SCROW > pAdded( nMemCount, -1 );
for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
{
SCROW nIndex = GetCache()->GetItemDataId( nCol, nRow, bRepeatIfEmpty );
SCROW nOrder = GetCache()->GetOrder( nCol, nIndex );
SCROW nIndex = getCache()->GetItemDataId( nCol, nRow, bRepeatIfEmpty );
SCROW nOrder = getCache()->GetOrder( nCol, nIndex );
if ( nCol == 0 )
maRowsVisible.push_back(false);
if ( lcl_HasQueryEntry(rQuery) &&
!GetCache()->ValidQuery( nRow , rQuery, pSpecial ) )
!getCache()->ValidQuery( nRow , rQuery, pSpecial ) )
continue;
if ( bIgnoreEmptyRows && GetCache()->IsRowEmpty( nRow ) )
if ( bIgnoreEmptyRows && getCache()->IsRowEmpty( nRow ) )
continue;
// Insert a new row into cache table.
if ( nCol == 0 )
@ -243,7 +243,7 @@ void ScDPCacheTable::fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
void ScDPCacheTable::fillTable()
{
if ( mpCache == NULL )
InitNoneCache( NULL );
initNoneCache( NULL );
//check cache
const SCROW nRowCount = getRowSize();
const SCCOL nColCount = (SCCOL) getColSize();
@ -261,15 +261,15 @@ void ScDPCacheTable::fillTable()
// Data rows
for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
{
SCROW nMemCount = GetCache()->GetDimMemberCount( nCol );
SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
if ( nMemCount )
{
std::vector< SCROW > pAdded( nMemCount, -1 );
for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
{
SCROW nIndex = GetCache()->GetItemDataId( nCol, nRow, false );
SCROW nOrder = GetCache()->GetOrder( nCol, nIndex );
SCROW nIndex = getCache()->GetItemDataId( nCol, nRow, false );
SCROW nOrder = getCache()->GetOrder( nCol, nIndex );
if ( nCol == 0 )
maRowsVisible.push_back(true);
@ -312,8 +312,8 @@ void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, c
const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
{
SCROW nId= GetCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
return GetCache()->GetItemDataById( nCol, nId );
SCROW nId= getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
return getCache()->GetItemDataById( nCol, nId );
}
void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
@ -330,12 +330,12 @@ void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, boo
}
String ScDPCacheTable::getFieldName(SCCOL nIndex) const
{
return (GetCache()->GetDimensionName( nIndex ));
return (getCache()->GetDimensionName( nIndex ));
}
sal_Int32 ScDPCacheTable::getFieldIndex(const String& rStr) const
{
return GetCache()->GetDimensionIndex( rStr );
return getCache()->GetDimensionIndex( rStr );
}
const ::std::vector<SCROW>& ScDPCacheTable::getFieldEntries( sal_Int32 nColumn ) const
@ -452,7 +452,7 @@ bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCr
}
void ScDPCacheTable::InitNoneCache( ScDocument* pDoc )
void ScDPCacheTable::initNoneCache( ScDocument* pDoc )
{
mpCache = NULL;
if ( mpNoneCache )
@ -460,7 +460,7 @@ void ScDPCacheTable::InitNoneCache( ScDocument* pDoc )
mpNoneCache = new ScDPTableDataCache( pDoc );
}
ScDPTableDataCache* ScDPCacheTable::GetCache() const
ScDPTableDataCache* ScDPCacheTable::getCache() const
{
if ( mpCache )
return mpCache;

View file

@ -797,13 +797,13 @@ const std::vector< SCROW >& ScDPGroupDimension::GetColumnEntries( const ScDPCac
{
if ( pDateHelper )
{
pDateHelper->FillColumnEntries( (SCCOL)GetSourceDim(), rCacheTable.GetCache(), maMemberEntries, rOriginal );
pDateHelper->FillColumnEntries( (SCCOL)GetSourceDim(), rCacheTable.getCache(), maMemberEntries, rOriginal );
}
else
{
for (size_t i =0; i < rOriginal.size( ); i ++)
{
const ScDPItemData* pItemData = rCacheTable.GetCache()->GetItemDataById( (SCCOL)GetSourceDim(), rOriginal[i] );
const ScDPItemData* pItemData = rCacheTable.getCache()->GetItemDataById( (SCCOL)GetSourceDim(), rOriginal[i] );
if ( !pItemData || !GetGroupForData( *pItemData ) )
{
// not in any group -> add as its own group
@ -814,8 +814,8 @@ const std::vector< SCROW >& ScDPGroupDimension::GetColumnEntries( const ScDPCac
long nCount = aItems.size();
for (long i=0; i<nCount; i++)
{
SCROW nNew = rCacheTable.GetCache()->GetAdditionalItemID( aItems[i].GetName() );
lcl_Insert ( (SCCOL)GetSourceDim(), rCacheTable.GetCache(), maMemberEntries, nNew );
SCROW nNew = rCacheTable.getCache()->GetAdditionalItemID( aItems[i].GetName() );
lcl_Insert ( (SCCOL)GetSourceDim(), rCacheTable.getCache(), maMemberEntries, nNew );
}
}
}
@ -1112,7 +1112,7 @@ const std::vector< SCROW >& ScDPGroupTableData::GetColumnEntries( long nColumn
{
// dimension number is unchanged for numerical groups
const std::vector< SCROW >& rOriginal = pSourceData->GetColumnEntries( nColumn );
return pNumGroups[nColumn].GetNumEntries( (SCCOL)nColumn, GetCacheTable().GetCache(), rOriginal );
return pNumGroups[nColumn].GetNumEntries( (SCCOL)nColumn, GetCacheTable().getCache(), rOriginal );
}
return pSourceData->GetColumnEntries( nColumn );
@ -1359,7 +1359,7 @@ void ScDPGroupTableData::FillGroupValues( /*ScDPItemData* pItemData*/ SCROW* pIt
{
long nGroupedColumns = aGroups.size();
ScDPTableDataCache* pCache = GetCacheTable().GetCache();
ScDPTableDataCache* pCache = GetCacheTable().getCache();
for (long nDim=0; nDim<nCount; nDim++)
{
const ScDPDateGroupHelper* pDateHelper = NULL;
@ -1402,7 +1402,7 @@ void ScDPGroupTableData::FillGroupValues( /*ScDPItemData* pItemData*/ SCROW* pIt
if ( pDateHelper )
{
const ScDPItemData* pData = GetCacheTable().GetCache()->GetItemDataById( (SCCOL)nSourceDim, pItemDataIndex[nDim]);
const ScDPItemData* pData = GetCacheTable().getCache()->GetItemDataById( (SCCOL)nSourceDim, pItemDataIndex[nDim]);
if ( pData ->IsValue() )
{
sal_Int32 nPartValue = lcl_GetDatePartValue(
@ -1412,7 +1412,7 @@ void ScDPGroupTableData::FillGroupValues( /*ScDPItemData* pItemData*/ SCROW* pIt
// DataPilot Migration - Cache&&Performance
//String aName = lcl_GetDateGroupName( pDateHelper, nPartValue, pDoc->GetFormatTable() );
ScDPItemData aItemData( pDateHelper->GetDatePart(), String(), nPartValue, ScDPItemData::MK_DATA|ScDPItemData::MK_VAL|ScDPItemData::MK_DATEPART );
pItemDataIndex[nDim] = GetCacheTable().GetCache()->GetAdditionalItemID( aItemData );
pItemDataIndex[nDim] = GetCacheTable().getCache()->GetAdditionalItemID( aItemData );
// End Comments
}
}

View file

@ -146,7 +146,7 @@ BOOL ScSheetDPData::IsDateDimension(long nDim)
}
else
{
return aCacheTable.GetCache()->IsDateDimension( nDim);
return aCacheTable.getCache()->IsDateDimension( nDim);
}
}
@ -164,7 +164,7 @@ ULONG ScSheetDPData::GetNumberFormat(long nDim)
}
else
{
return GetCacheTable().GetCache()->GetNumberFormat( nDim );
return GetCacheTable().getCache()->GetNumberFormat( nDim );
}
}
UINT32 ScDPTableData::GetNumberFormatByIdx( NfIndexTableOffset eIdx )

View file

@ -170,7 +170,7 @@ void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTab
// page dimensions
GetItemData(rCacheTable, nRow, rInfo.aPageDims, rData.aPageData);
long nCacheColumnCount = rCacheTable.GetCache()->GetColumnCount();
long nCacheColumnCount = rCacheTable.getCache()->GetColumnCount();
sal_Int32 n = rInfo.aDataSrcCols.size();
for (sal_Int32 i = 0; i < n; ++i)
{
@ -255,10 +255,10 @@ void ScDPTableData::GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRo
}
nDim = GetSourceDim( nDim );
if ( nDim >= rCacheTable.GetCache()->GetColumnCount() )
if ( nDim >= rCacheTable.getCache()->GetColumnCount() )
continue;
SCROW nId= rCacheTable.GetCache()->GetItemDataId( static_cast<SCCOL>(nDim), static_cast<SCROW>(nRow), IsRepeatIfEmpty());
SCROW nId= rCacheTable.getCache()->GetItemDataId( static_cast<SCCOL>(nDim), static_cast<SCROW>(nRow), IsRepeatIfEmpty());
rItemData.push_back( nId );
}
@ -287,18 +287,18 @@ const ScDPItemData* ScDPTableData::GetMemberByIndex( long nDim, long nIndex )
const ::std::vector<SCROW>& nMembers = GetCacheTable().getFieldEntries( nDim );
return GetCacheTable().GetCache()->GetItemDataById( (SCCOL) nDim, (SCROW)nMembers[nIndex] );
return GetCacheTable().getCache()->GetItemDataById( (SCCOL) nDim, (SCROW)nMembers[nIndex] );
}
const ScDPItemData* ScDPTableData::GetMemberById( long nDim, long nId)
{
return GetCacheTable().GetCache()->GetItemDataById( (SCCOL) nDim, (SCROW)nId);
return GetCacheTable().getCache()->GetItemDataById( (SCCOL) nDim, (SCROW)nId);
}
SCROW ScDPTableData::GetIdOfItemData( long nDim, const ScDPItemData& rData )
{
return GetCacheTable().GetCache()->GetIdByItemData((SCCOL) nDim, rData );
return GetCacheTable().getCache()->GetIdByItemData((SCCOL) nDim, rData );
}
const std::vector< SCROW >& ScDPTableData::GetColumnEntries( long nColumn )
@ -317,8 +317,8 @@ long ScDPTableData::GetSourceDim( long nDim )
if ( getIsDataLayoutDimension(nDim) )
return 0;
long n1 = GetCacheTable().GetCache()->GetOrder( nDim, nDataId1);
long n2 = GetCacheTable().GetCache()->GetOrder( nDim, nDataId2);
long n1 = GetCacheTable().getCache()->GetOrder( nDim, nDataId1);
long n2 = GetCacheTable().getCache()->GetOrder( nDim, nDataId2);
if ( n1 > n2 )
return 1;
else if ( n1 == n2 )

View file

@ -2866,7 +2866,7 @@ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPMember )
ScDPTableDataCache* ScDPSource::GetCache()
{
DBG_ASSERT( GetData() , "empty ScDPTableData pointer");
return ( GetData()!=NULL) ? GetData()->GetCacheTable().GetCache() : NULL ;
return ( GetData()!=NULL) ? GetData()->GetCacheTable().getCache() : NULL ;
}
const ScDPItemData& ScDPMember::GetItemData() const

View file

@ -546,7 +546,7 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
ScDPNumGroupDimension aTmpDim( rNumInfo );
if( nDatePart != 0 )
aTmpDim.MakeDateHelper( rNumInfo, nDatePart );
const std::vector< SCROW > aMemberIds = aTmpDim.GetNumEntries( static_cast< SCCOL >( GetBaseFieldIndex() ), aDPData.GetCacheTable().GetCache(), aOrignial );
const std::vector< SCROW > aMemberIds = aTmpDim.GetNumEntries( static_cast< SCCOL >( GetBaseFieldIndex() ), aDPData.GetCacheTable().getCache(), aOrignial );
for ( size_t nIdx = 0 ; nIdx < aMemberIds.size(); nIdx++ )
{
const ScDPItemData* pData = aDPData.GetMemberById( static_cast< long >( GetBaseFieldIndex() ) , aMemberIds[ nIdx] );

View file

@ -194,6 +194,7 @@ static const sal_Char __FAR_DATA pFilterRtf[] = "Rich Text Format (StarCal
SFX_IMPL_INTERFACE(ScDocShell,SfxObjectShell, ScResId(SCSTR_DOCSHELL))
{
fprintf(stdout, "SFX_IMPL_INTERFACE: SID_HYPERLINK_INSERT = %d\n", SID_HYPERLINK_INSERT);
SFX_CHILDWINDOW_REGISTRATION( SID_HYPERLINK_INSERT );
}