summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-17 14:36:02 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-22 14:02:02 -0500
commit1f4ce4ed9f8e9e47e866dc7a7a5d1ad292a4d78c (patch)
treedb6b4571f67ed5ea2f7358ac7e5216e2a7f4c9d9 /sc
parentString and bool conversion. (diff)
downloadcore-1f4ce4ed9f8e9e47e866dc7a7a5d1ad292a4d78c.tar.gz
core-1f4ce4ed9f8e9e47e866dc7a7a5d1ad292a4d78c.zip
Some cleanups.
* No source column offset since we only store 0-based field index everywhere now. * No more function count since each pivot field can only have one function.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/pivot.hxx6
-rw-r--r--sc/source/core/data/dpobject.cxx32
-rw-r--r--sc/source/core/data/dpsave.cxx7
-rw-r--r--sc/source/core/data/pivot2.cxx4
4 files changed, 22 insertions, 27 deletions
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index aa857c1431f6..7d173e9b591a 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -73,9 +73,8 @@ struct ScDPLabelData;
struct PivotField
{
- SCsCOL nCol;
+ SCsCOL nCol; /// 0-based dimension index (not source column index)
sal_uInt16 nFuncMask;
- sal_uInt16 nFuncCount;
sal_uInt8 mnDupCount;
::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
@@ -129,8 +128,9 @@ struct ScDPLabelData
{
::rtl::OUString maName; /// Original name of the dimension.
::rtl::OUString maLayoutName; /// Layout name (display name)
- SCCOL mnCol;
+ SCCOL mnCol; /// 0-based field index (not the source column index)
sal_uInt16 mnFuncMask; /// Page/Column/Row subtotal function.
+ sal_uInt8 mnDupCount;
sal_Int32 mnUsedHier; /// Used hierarchy.
sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension
bool mbShowAll; /// true = Show all (also empty) results.
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index f9e9345cf4b6..fb4c2eb40f5c 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1736,7 +1736,7 @@ public:
void lcl_FillOldFields(
vector<PivotField>& rFields,
const uno::Reference<sheet::XDimensionsSupplier>& xSource,
- sal_uInt16 nOrient, SCCOL nColAdd, bool bAddData )
+ sal_uInt16 nOrient, bool bAddData )
{
vector<PivotField> aFields;
@@ -1814,11 +1814,11 @@ void lcl_FillOldFields(
{
// this dimension is cloned.
- SCsCOL nCompCol; // column ID of the original dimension.
+ SCsCOL nCompCol; // ID of the original dimension.
if ( bDataLayout )
nCompCol = PIVOT_DATA_FIELD;
else
- nCompCol = static_cast<SCsCOL>(nDupSource)+nColAdd; //! seek source column from name
+ nCompCol = static_cast<SCsCOL>(nDupSource); //! seek source column from name
vector<PivotField>::iterator it = std::find_if(aFields.begin(), aFields.end(), FindByColumn(nCompCol, nMask));
if (it != aFields.end())
@@ -1833,12 +1833,11 @@ void lcl_FillOldFields(
bDataFound = true;
}
else if (nDupSource >= 0)
- rField.nCol = static_cast<SCsCOL>(nDupSource)+nColAdd; //! seek from name
+ rField.nCol = static_cast<SCsCOL>(nDupSource); //! seek from name
else
- rField.nCol = static_cast<SCsCOL>(nDim)+nColAdd; //! seek source column from name
+ rField.nCol = static_cast<SCsCOL>(nDim); //! seek source column from name
rField.nFuncMask = nMask;
- rField.nFuncCount = lcl_CountBits(nMask);
rField.mnDupCount = nDupCount;
long nPos = ScUnoHelpFunctions::GetLongProperty(
xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_POSITION)));
@@ -1892,17 +1891,15 @@ bool ScDPObject::FillOldParam(ScPivotParam& rParam) const
rParam.nTab = aOutRange.aStart.Tab();
// ppLabelArr / nLabels is not changed
- SCCOL nSrcColOffset = 0;
-
bool bAddData = ( lcl_GetDataGetOrientation( xSource ) == sheet::DataPilotFieldOrientation_HIDDEN );
lcl_FillOldFields(
- rParam.maPageFields, xSource, sheet::DataPilotFieldOrientation_PAGE, nSrcColOffset, false);
+ rParam.maPageFields, xSource, sheet::DataPilotFieldOrientation_PAGE, false);
lcl_FillOldFields(
- rParam.maColFields, xSource, sheet::DataPilotFieldOrientation_COLUMN, nSrcColOffset, bAddData);
+ rParam.maColFields, xSource, sheet::DataPilotFieldOrientation_COLUMN, bAddData);
lcl_FillOldFields(
- rParam.maRowFields, xSource, sheet::DataPilotFieldOrientation_ROW, nSrcColOffset, false);
+ rParam.maRowFields, xSource, sheet::DataPilotFieldOrientation_ROW, false);
lcl_FillOldFields(
- rParam.maDataFields, xSource, sheet::DataPilotFieldOrientation_DATA, nSrcColOffset, false);
+ rParam.maDataFields, xSource, sheet::DataPilotFieldOrientation_DATA, false);
uno::Reference<beans::XPropertySet> xProp( xSource, uno::UNO_QUERY );
if (xProp.is())
@@ -1982,15 +1979,15 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xDimsName );
- long nDimCount = xDims->getCount();
+ sal_Int32 nDimCount = xDims->getCount();
if ( nDimCount > SC_DP_MAX_FIELDS )
nDimCount = SC_DP_MAX_FIELDS;
if (!nDimCount)
return false;
- for (long nDim=0; nDim < nDimCount; nDim++)
+ for (sal_Int32 nDim = 0; nDim < nDimCount; ++nDim)
{
- String aFieldName;
+ rtl::OUString aFieldName;
uno::Reference<uno::XInterface> xIntDim =
ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
@@ -2005,8 +2002,7 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
try
{
- aFieldName = String( xDimName->getName() );
-
+ aFieldName = xDimName->getName();
uno::Any aOrigAny = xDimProp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL)) );
uno::Reference<uno::XInterface> xIntOrig;
@@ -2020,7 +2016,7 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty(
xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_LAYOUTNAME)), OUString());
- if ( aFieldName.Len() && !bData && !bDuplicated )
+ if (!aFieldName.isEmpty() && !bData)
{
SCsCOL nCol = static_cast< SCsCOL >( nDim ); //! ???
bool bIsValue = true; //! check
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 2c2378358496..9f0f31ca8cd3 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -1098,6 +1098,10 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
lcl_ResetOrient( xSource );
+ uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
+ uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
+ long nIntCount = xIntDims->getCount();
+
boost::ptr_vector<ScDPSaveDimension>::iterator iter = aDimList.begin();
for (long i = 0; iter != aDimList.end(); ++iter, ++i)
{
@@ -1109,9 +1113,6 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
//! getByName for ScDPSource, including DataLayoutDimension !!!!!!!!
- uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
- uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
- long nIntCount = xIntDims->getCount();
bool bFound = false;
for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
{
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index 111b716d9209..7678f9442466 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -96,6 +96,7 @@ ScDPLabelData::ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsVal
maName( rName ),
mnCol( nCol ),
mnFuncMask( PIVOT_FUNC_NONE ),
+ mnDupCount(0),
mnUsedHier( 0 ),
mnFlags( 0 ),
mbShowAll( false ),
@@ -114,7 +115,6 @@ OUString ScDPLabelData::getDisplayName() const
PivotField::PivotField( SCsCOL nNewCol, sal_uInt16 nNewFuncMask ) :
nCol( nNewCol ),
nFuncMask( nNewFuncMask ),
- nFuncCount( 0 ),
mnDupCount(0)
{
}
@@ -122,7 +122,6 @@ PivotField::PivotField( SCsCOL nNewCol, sal_uInt16 nNewFuncMask ) :
PivotField::PivotField( const PivotField& r ) :
nCol(r.nCol),
nFuncMask(r.nFuncMask),
- nFuncCount(r.nFuncCount),
mnDupCount(r.mnDupCount),
maFieldRef(r.maFieldRef) {}
@@ -130,7 +129,6 @@ bool PivotField::operator==( const PivotField& r ) const
{
return (nCol == r.nCol)
&& (nFuncMask == r.nFuncMask)
- && (nFuncCount == r.nFuncCount)
&& (mnDupCount == r.mnDupCount)
&& equals(maFieldRef, r.maFieldRef);
}