Kaydet (Commit) e75f8d8e authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

sc: clean-up pivot.hxx/pivot2.cxx

Change-Id: I88ed4da8dd2ca026eeea4a3fb267f4f9954c180a
üst 4f1f8b8e
...@@ -63,18 +63,18 @@ struct SC_DLLPUBLIC ScDPName ...@@ -63,18 +63,18 @@ struct SC_DLLPUBLIC ScDPName
struct ScDPLabelData struct ScDPLabelData
{ {
OUString maName; ///< Original name of the dimension. OUString maName; ///< Original name of the dimension.
OUString maLayoutName; ///< Layout name (display name) OUString maLayoutName; ///< Layout name (display name)
OUString maSubtotalName; OUString maSubtotalName;
SCCOL mnCol; ///< 0-based field index (not the source column index) SCCOL mnCol; ///< 0-based field index (not the source column index)
long mnOriginalDim; ///< original dimension index (>= 0 for duplicated dimension) long mnOriginalDim; ///< original dimension index (>= 0 for duplicated dimension)
sal_uInt16 mnFuncMask; ///< Page/Column/Row subtotal function. sal_uInt16 mnFuncMask; ///< Page/Column/Row subtotal function.
sal_Int32 mnUsedHier; ///< Used hierarchy. sal_Int32 mnUsedHier; ///< Used hierarchy.
sal_Int32 mnFlags; ///< Flags from the DataPilotSource dimension sal_Int32 mnFlags; ///< Flags from the DataPilotSource dimension
sal_uInt8 mnDupCount; sal_uInt8 mnDupCount;
bool mbShowAll:1; ///< true = Show all (also empty) results. bool mbShowAll:1; ///< true = Show all (also empty) results.
bool mbIsValue:1; ///< true = Sum or count in data field. bool mbIsValue:1; ///< true = Sum or count in data field.
bool mbDataLayout:1; bool mbDataLayout:1;
struct Member struct Member
{ {
...@@ -92,11 +92,11 @@ struct ScDPLabelData ...@@ -92,11 +92,11 @@ struct ScDPLabelData
*/ */
OUString SC_DLLPUBLIC getDisplayName() const; OUString SC_DLLPUBLIC getDisplayName() const;
}; };
::std::vector<Member> maMembers; std::vector<Member> maMembers;
::com::sun::star::uno::Sequence< OUString > maHiers; ///< Hierarchies. css::uno::Sequence<OUString> maHiers; ///< Hierarchies.
::com::sun::star::sheet::DataPilotFieldSortInfo maSortInfo; ///< Sorting info. css::sheet::DataPilotFieldSortInfo maSortInfo; ///< Sorting info.
::com::sun::star::sheet::DataPilotFieldLayoutInfo maLayoutInfo; ///< Layout info. css::sheet::DataPilotFieldLayoutInfo maLayoutInfo; ///< Layout info.
::com::sun::star::sheet::DataPilotFieldAutoShowInfo maShowInfo; ///< AutoShow info. css::sheet::DataPilotFieldAutoShowInfo maShowInfo; ///< AutoShow info.
ScDPLabelData(); ScDPLabelData();
...@@ -111,11 +111,12 @@ typedef boost::ptr_vector<ScDPLabelData> ScDPLabelDataVector; ...@@ -111,11 +111,12 @@ typedef boost::ptr_vector<ScDPLabelData> ScDPLabelDataVector;
struct ScPivotField struct ScPivotField
{ {
SCCOL nCol; ///< 0-based dimension index (not source column index) SCCOL nCol; ///< 0-based dimension index (not source column index)
long mnOriginalDim; ///< >= 0 for duplicated field. long mnOriginalDim; ///< >= 0 for duplicated field.
sal_uInt16 nFuncMask; sal_uInt16 nFuncMask;
sal_uInt8 mnDupCount; sal_uInt8 mnDupCount;
::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
css::sheet::DataPilotFieldReference maFieldRef;
explicit ScPivotField( SCCOL nNewCol = 0, sal_uInt16 nNewFuncMask = PIVOT_FUNC_NONE ); explicit ScPivotField( SCCOL nNewCol = 0, sal_uInt16 nNewFuncMask = PIVOT_FUNC_NONE );
ScPivotField( const ScPivotField& r ); ScPivotField( const ScPivotField& r );
...@@ -124,44 +125,46 @@ struct ScPivotField ...@@ -124,44 +125,46 @@ struct ScPivotField
bool operator==( const ScPivotField& r ) const; bool operator==( const ScPivotField& r ) const;
}; };
typedef ::std::vector< ScPivotField > ScPivotFieldVector; typedef std::vector< ScPivotField > ScPivotFieldVector;
struct ScPivotParam struct ScPivotParam
{ {
SCCOL nCol; ///< Cursor Position / SCCOL nCol; ///< Cursor Position /
SCROW nRow; ///< or start of destination area SCROW nRow; ///< or start of destination area
SCTAB nTab; SCTAB nTab;
ScDPLabelDataVector maLabelArray; ScDPLabelDataVector maLabelArray;
ScPivotFieldVector maPageFields; ScPivotFieldVector maPageFields;
ScPivotFieldVector maColFields; ScPivotFieldVector maColFields;
ScPivotFieldVector maRowFields; ScPivotFieldVector maRowFields;
ScPivotFieldVector maDataFields; ScPivotFieldVector maDataFields;
bool bIgnoreEmptyRows;
bool bDetectCategories; bool bIgnoreEmptyRows;
bool bMakeTotalCol; bool bDetectCategories;
bool bMakeTotalRow; bool bMakeTotalCol;
bool bMakeTotalRow;
ScPivotParam(); ScPivotParam();
ScPivotParam( const ScPivotParam& r ); ScPivotParam( const ScPivotParam& r );
~ScPivotParam(); ~ScPivotParam();
ScPivotParam& operator= ( const ScPivotParam& r ); ScPivotParam& operator= ( const ScPivotParam& r );
bool operator== ( const ScPivotParam& r ) const; bool operator== ( const ScPivotParam& r ) const;
void SetLabelData(const ScDPLabelDataVector& r); void SetLabelData(const ScDPLabelDataVector& r);
}; };
struct ScPivotFuncData struct ScPivotFuncData
{ {
SCCOL mnCol; SCCOL mnCol;
long mnOriginalDim; long mnOriginalDim;
sal_uInt16 mnFuncMask; sal_uInt16 mnFuncMask;
sal_uInt8 mnDupCount; sal_uInt8 mnDupCount;
::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
css::sheet::DataPilotFieldReference maFieldRef;
explicit ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask ); explicit ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask );
explicit ScPivotFuncData( explicit ScPivotFuncData( SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount, const css::sheet::DataPilotFieldReference& rFieldRef );
const ::com::sun::star::sheet::DataPilotFieldReference& rFieldRef );
bool operator== (const ScPivotFuncData& r) const; bool operator== (const ScPivotFuncData& r) const;
...@@ -170,7 +173,7 @@ struct ScPivotFuncData ...@@ -170,7 +173,7 @@ struct ScPivotFuncData
#endif #endif
}; };
typedef ::std::vector< ScPivotFuncData > ScPivotFuncDataVector; typedef std::vector<ScPivotFuncData> ScPivotFuncDataVector;
typedef std::vector<ScDPName> ScDPNameVec; typedef std::vector<ScDPName> ScDPNameVec;
#endif #endif
......
...@@ -43,10 +43,11 @@ using std::cout; ...@@ -43,10 +43,11 @@ using std::cout;
using std::endl; using std::endl;
#endif #endif
using ::com::sun::star::sheet::DataPilotFieldReference; using css::sheet::DataPilotFieldReference;
using ::std::vector; using std::vector;
namespace { namespace
{
bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference& right) bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference& right)
{ {
...@@ -56,20 +57,23 @@ bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference& ...@@ -56,20 +57,23 @@ bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference&
&& (left.ReferenceItemName == right.ReferenceItemName); && (left.ReferenceItemName == right.ReferenceItemName);
} }
} } // namespace
ScDPName::ScDPName() : mnDupCount(0) {} // ScDPName
ScDPName::ScDPName(const OUString& rName, const OUString& rLayoutName, sal_uInt8 nDupCount) : ScDPName::ScDPName() : mnDupCount(0)
maName(rName), maLayoutName(rLayoutName), mnDupCount(nDupCount) {} {}
ScDPName::ScDPName(const OUString& rName, const OUString& rLayoutName, sal_uInt8 nDupCount) :
maName(rName), maLayoutName(rLayoutName), mnDupCount(nDupCount)
{}
// ScDPLabelData
ScDPLabelData::Member::Member() : ScDPLabelData::Member::Member() :
mbVisible(true), mbVisible(true),
mbShowDetails(true) mbShowDetails(true)
{ {}
}
OUString ScDPLabelData::Member::getDisplayName() const OUString ScDPLabelData::Member::getDisplayName() const
{ {
...@@ -89,8 +93,7 @@ ScDPLabelData::ScDPLabelData() : ...@@ -89,8 +93,7 @@ ScDPLabelData::ScDPLabelData() :
mbShowAll(false), mbShowAll(false),
mbIsValue(false), mbIsValue(false),
mbDataLayout(false) mbDataLayout(false)
{ {}
}
OUString ScDPLabelData::getDisplayName() const OUString ScDPLabelData::getDisplayName() const
{ {
...@@ -100,20 +103,22 @@ OUString ScDPLabelData::getDisplayName() const ...@@ -100,20 +103,22 @@ OUString ScDPLabelData::getDisplayName() const
return maName; return maName;
} }
// ScPivotField
ScPivotField::ScPivotField(SCCOL nNewCol, sal_uInt16 nNewFuncMask) : ScPivotField::ScPivotField(SCCOL nNewCol, sal_uInt16 nNewFuncMask) :
nCol( nNewCol ), nCol(nNewCol),
mnOriginalDim(-1), mnOriginalDim(-1),
nFuncMask( nNewFuncMask ), nFuncMask(nNewFuncMask),
mnDupCount(0) mnDupCount(0)
{ {}
}
ScPivotField::ScPivotField( const ScPivotField& r ) : ScPivotField::ScPivotField( const ScPivotField& rPivotField ) :
nCol(r.nCol), nCol(rPivotField.nCol),
mnOriginalDim(r.mnOriginalDim), mnOriginalDim(rPivotField.mnOriginalDim),
nFuncMask(r.nFuncMask), nFuncMask(rPivotField.nFuncMask),
mnDupCount(r.mnDupCount), mnDupCount(rPivotField.mnDupCount),
maFieldRef(r.maFieldRef) {} maFieldRef(rPivotField.maFieldRef)
{}
long ScPivotField::getOriginalDim() const long ScPivotField::getOriginalDim() const
{ {
...@@ -128,12 +133,13 @@ bool ScPivotField::operator==( const ScPivotField& r ) const ...@@ -128,12 +133,13 @@ bool ScPivotField::operator==( const ScPivotField& r ) const
&& equals(maFieldRef, r.maFieldRef); && equals(maFieldRef, r.maFieldRef);
} }
ScPivotParam::ScPivotParam() // ScPivotParam
: nCol(0), nRow(0), nTab(0),
bIgnoreEmptyRows(false), bDetectCategories(false), ScPivotParam::ScPivotParam() :
bMakeTotalCol(true), bMakeTotalRow(true) nCol(0), nRow(0), nTab(0),
{ bIgnoreEmptyRows(false), bDetectCategories(false),
} bMakeTotalCol(true), bMakeTotalRow(true)
{}
ScPivotParam::ScPivotParam( const ScPivotParam& r ) ScPivotParam::ScPivotParam( const ScPivotParam& r )
: nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ), : nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ),
...@@ -150,83 +156,84 @@ ScPivotParam::ScPivotParam( const ScPivotParam& r ) ...@@ -150,83 +156,84 @@ ScPivotParam::ScPivotParam( const ScPivotParam& r )
} }
ScPivotParam::~ScPivotParam() ScPivotParam::~ScPivotParam()
{ {}
}
void ScPivotParam::SetLabelData(const ScDPLabelDataVector& r) void ScPivotParam::SetLabelData(const ScDPLabelDataVector& rVector)
{ {
ScDPLabelDataVector aNewArray; ScDPLabelDataVector aNewArray;
aNewArray.reserve(r.size()); aNewArray.reserve(rVector.size());
for (ScDPLabelDataVector::const_iterator itr = r.begin(), itrEnd = r.end(); ScDPLabelDataVector::const_iterator it;
itr != itrEnd; ++itr) for (it = rVector.begin(); it != rVector.end(); ++it)
aNewArray.push_back(new ScDPLabelData(*itr)); {
aNewArray.push_back(new ScDPLabelData(*it));
}
maLabelArray.swap(aNewArray); maLabelArray.swap(aNewArray);
} }
ScPivotParam& ScPivotParam::operator=( const ScPivotParam& r ) ScPivotParam& ScPivotParam::operator=( const ScPivotParam& rPivotParam )
{ {
nCol = r.nCol; nCol = rPivotParam.nCol;
nRow = r.nRow; nRow = rPivotParam.nRow;
nTab = r.nTab; nTab = rPivotParam.nTab;
bIgnoreEmptyRows = r.bIgnoreEmptyRows; bIgnoreEmptyRows = rPivotParam.bIgnoreEmptyRows;
bDetectCategories = r.bDetectCategories; bDetectCategories = rPivotParam.bDetectCategories;
bMakeTotalCol = r.bMakeTotalCol; bMakeTotalCol = rPivotParam.bMakeTotalCol;
bMakeTotalRow = r.bMakeTotalRow; bMakeTotalRow = rPivotParam.bMakeTotalRow;
maPageFields = r.maPageFields; maPageFields = rPivotParam.maPageFields;
maColFields = r.maColFields; maColFields = rPivotParam.maColFields;
maRowFields = r.maRowFields; maRowFields = rPivotParam.maRowFields;
maDataFields = r.maDataFields; maDataFields = rPivotParam.maDataFields;
SetLabelData(r.maLabelArray);
SetLabelData(rPivotParam.maLabelArray);
return *this; return *this;
} }
bool ScPivotParam::operator==( const ScPivotParam& r ) const bool ScPivotParam::operator==( const ScPivotParam& rPivotParam ) const
{ {
bool bEqual = (nCol == r.nCol) bool bEqual = (nCol == rPivotParam.nCol &&
&& (nRow == r.nRow) nRow == rPivotParam.nRow &&
&& (nTab == r.nTab) nTab == rPivotParam.nTab &&
&& (bIgnoreEmptyRows == r.bIgnoreEmptyRows) bIgnoreEmptyRows == rPivotParam.bIgnoreEmptyRows &&
&& (bDetectCategories == r.bDetectCategories) bDetectCategories == rPivotParam.bDetectCategories &&
&& (bMakeTotalCol == r.bMakeTotalCol) bMakeTotalCol == rPivotParam.bMakeTotalCol &&
&& (bMakeTotalRow == r.bMakeTotalRow) bMakeTotalRow == rPivotParam.bMakeTotalRow &&
&& (maLabelArray.size() == r.maLabelArray.size()) maLabelArray.size() == rPivotParam.maLabelArray.size() &&
&& maPageFields == r.maPageFields maPageFields == rPivotParam.maPageFields &&
&& maColFields == r.maColFields maColFields == rPivotParam.maColFields &&
&& maRowFields == r.maRowFields maRowFields == rPivotParam.maRowFields &&
&& maDataFields == r.maDataFields; maDataFields == rPivotParam.maDataFields);
return bEqual; return bEqual;
} }
// ScPivotFuncData
ScPivotFuncData::ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask ) : ScPivotFuncData::ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask ) :
mnCol( nCol ), mnCol( nCol ),
mnOriginalDim(-1), mnOriginalDim(-1),
mnFuncMask( nFuncMask ), mnFuncMask(nFuncMask),
mnDupCount(0) mnDupCount(0)
{ {}
}
ScPivotFuncData::ScPivotFuncData( ScPivotFuncData::ScPivotFuncData(SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask,
SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount, sal_uInt8 nDupCount, const DataPilotFieldReference& rFieldRef) :
const DataPilotFieldReference& rFieldRef) : mnCol(nCol),
mnCol( nCol ),
mnOriginalDim(nOriginalDim), mnOriginalDim(nOriginalDim),
mnFuncMask( nFuncMask ), mnFuncMask(nFuncMask),
mnDupCount(nDupCount), mnDupCount(nDupCount),
maFieldRef( rFieldRef ) maFieldRef(rFieldRef)
{ {}
}
bool ScPivotFuncData::operator== (const ScPivotFuncData& r) const bool ScPivotFuncData::operator== (const ScPivotFuncData& rFuncData) const
{ {
if (mnCol != r.mnCol || mnOriginalDim != r.mnOriginalDim || mnFuncMask != r.mnFuncMask || mnDupCount != r.mnDupCount) if (mnCol != rFuncData.mnCol ||
mnOriginalDim != rFuncData.mnOriginalDim ||
mnFuncMask != rFuncData.mnFuncMask ||
mnDupCount != rFuncData.mnDupCount)
{
return false; return false;
}
return equals(maFieldRef, r.maFieldRef); return equals(maFieldRef, rFuncData.maFieldRef);
} }
#if DEBUG_PIVOT_TABLE #if DEBUG_PIVOT_TABLE
...@@ -238,6 +245,4 @@ void ScPivotFuncData::Dump() const ...@@ -238,6 +245,4 @@ void ScPivotFuncData::Dump() const
} }
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment