[Libreoffice-commits] .: 7 commits - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Feb 28 18:03:12 PST 2012
sc/inc/dpgroup.hxx | 20 -
sc/inc/dpitemdata.hxx | 2
sc/inc/dptablecache.hxx | 5
sc/source/core/data/dpgroup.cxx | 362 ++++++++++++++--------------
sc/source/core/data/dpitemdata.cxx | 18 -
sc/source/core/data/dptablecache.cxx | 82 ++++--
sc/source/filter/excel/xepivot.cxx | 34 +-
sc/source/filter/excel/xipivot.cxx | 40 +--
sc/source/filter/xml/XMLExportDataPilot.cxx | 22 -
sc/source/filter/xml/xmldpimp.cxx | 14 -
sc/source/ui/dbgui/dpgroupdlg.cxx | 52 ++--
sc/source/ui/dbgui/fieldwnd.cxx | 2
sc/source/ui/unoobj/dapiuno.cxx | 46 +--
sc/source/ui/view/cellsh1.cxx | 6
sc/source/ui/view/dbfunc3.cxx | 22 -
15 files changed, 375 insertions(+), 352 deletions(-)
New commits:
commit 9518535d2fa9f5d52fec548fc85df5a086ec4c1c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Feb 28 19:36:35 2012 -0500
Fixed incorrect truncation of text in field button.
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx
index f68dd87..a69b7a1 100644
--- a/sc/source/ui/dbgui/fieldwnd.cxx
+++ b/sc/source/ui/dbgui/fieldwnd.cxx
@@ -614,7 +614,7 @@ void ScDPFieldControlBase::DrawField(
do
{
sal_Int32 nCurrLen = (nMinLen + nMaxLen) / 2;
- rtl::OUStringBuffer aBuf(aText.copy(0, nCurrLen));
+ rtl::OUStringBuffer aBuf(rText.maText.copy(0, nCurrLen));
aBuf.appendAscii("...");
aText = aBuf.makeStringAndClear();
nLabelWidth = rDev.GetTextWidth( aText );
commit 6fc139f068de791604157b70d331ebb171fc1049
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Feb 28 16:11:53 2012 -0500
Properly prefixed members of ScDPNumGroupInfo.
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index 356df1c..f6be836 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -40,19 +40,17 @@
class ScDocument;
class SvNumberFormatter;
-//! API struct?
struct ScDPNumGroupInfo
{
- sal_Bool Enable;
- sal_Bool DateValues;
- sal_Bool AutoStart;
- sal_Bool AutoEnd;
- double Start;
- double End;
- double Step;
-
- ScDPNumGroupInfo() : Enable(false), DateValues(false), AutoStart(false), AutoEnd(false),
- Start(0.0), End(0.0), Step(0.0) {}
+ bool mbEnable:1;
+ bool mbDateValues:1;
+ bool mbAutoStart:1;
+ bool mbAutoEnd:1;
+ double mfStart;
+ double mfEnd;
+ double mfStep;
+
+ SC_DLLPUBLIC ScDPNumGroupInfo();
};
// ScDPDateGroupHelper is used as part of ScDPGroupDimension (additional dim.)
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 8df6e91..6fbb67b 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -73,6 +73,10 @@ const sal_uInt16 SC_DP_LEAPYEAR = 1648; // arbitrary leap year for date calc
const sal_Int32 SC_DP_DATE_FIRST = -1;
const sal_Int32 SC_DP_DATE_LAST = 10000;
+ScDPNumGroupInfo::ScDPNumGroupInfo() :
+ mbEnable(false), mbDateValues(false), mbAutoStart(false), mbAutoEnd(false),
+ mfStart(0.0), mfEnd(0.0), mfStep(0.0) {}
+
namespace {
sal_Bool lcl_Search( SCCOL nSourceDim, const ScDPCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
@@ -161,9 +165,9 @@ String lcl_GetNumGroupName( double fStartValue, const ScDPNumGroupInfo& rInfo,
{
OSL_ENSURE( cDecSeparator != 0, "cDecSeparator not initialized" );
- double fStep = rInfo.Step;
+ double fStep = rInfo.mfStep;
double fEndValue = fStartValue + fStep;
- if ( !bHasNonInteger && ( rInfo.DateValues || !rtl::math::approxEqual( fEndValue, rInfo.End ) ) )
+ if ( !bHasNonInteger && ( rInfo.mbDateValues || !rtl::math::approxEqual( fEndValue, rInfo.mfEnd ) ) )
{
// The second number of the group label is
// (first number + size - 1) if there are only integer numbers,
@@ -174,15 +178,15 @@ String lcl_GetNumGroupName( double fStartValue, const ScDPNumGroupInfo& rInfo,
fEndValue -= 1.0;
}
- if ( fEndValue > rInfo.End && !rInfo.AutoEnd )
+ if ( fEndValue > rInfo.mfEnd && !rInfo.mbAutoEnd )
{
// limit the last group to the end value
- fEndValue = rInfo.End;
+ fEndValue = rInfo.mfEnd;
}
rtl::OUStringBuffer aBuffer;
- if ( rInfo.DateValues )
+ if ( rInfo.mbDateValues )
{
lcl_AppendDateStr( aBuffer, fStartValue, pFormatter );
aBuffer.appendAscii( " - " ); // with spaces
@@ -225,26 +229,26 @@ String lcl_GetNumGroupForValue( double fValue, const ScDPNumGroupInfo& rInfo, bo
{
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
- if ( fValue < rInfo.Start && !rtl::math::approxEqual( fValue, rInfo.Start ) )
+ if ( fValue < rInfo.mfStart && !rtl::math::approxEqual( fValue, rInfo.mfStart ) )
{
- rGroupValue = rInfo.Start - rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.Start, true, cDecSeparator, rInfo.DateValues, pFormatter );
+ rGroupValue = rInfo.mfStart - rInfo.mfStep;
+ return lcl_GetSpecialNumGroupName( rInfo.mfStart, true, cDecSeparator, rInfo.mbDateValues, pFormatter );
}
- if ( fValue > rInfo.End && !rtl::math::approxEqual( fValue, rInfo.End ) )
+ if ( fValue > rInfo.mfEnd && !rtl::math::approxEqual( fValue, rInfo.mfEnd ) )
{
- rGroupValue = rInfo.End + rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
+ rGroupValue = rInfo.mfEnd + rInfo.mfStep;
+ return lcl_GetSpecialNumGroupName( rInfo.mfEnd, false, cDecSeparator, rInfo.mbDateValues, pFormatter );
}
- double fDiff = fValue - rInfo.Start;
- double fDiv = rtl::math::approxFloor( fDiff / rInfo.Step );
- double fGroupStart = rInfo.Start + fDiv * rInfo.Step;
+ double fDiff = fValue - rInfo.mfStart;
+ double fDiv = rtl::math::approxFloor( fDiff / rInfo.mfStep );
+ double fGroupStart = rInfo.mfStart + fDiv * rInfo.mfStep;
- if ( rtl::math::approxEqual( fGroupStart, rInfo.End ) &&
- !rtl::math::approxEqual( fGroupStart, rInfo.Start ) )
+ if ( rtl::math::approxEqual( fGroupStart, rInfo.mfEnd ) &&
+ !rtl::math::approxEqual( fGroupStart, rInfo.mfStart ) )
{
- if ( !rInfo.DateValues )
+ if ( !rInfo.mbDateValues )
{
// A group that would consist only of the end value is not created,
// instead the value is included in the last group before. So the
@@ -252,15 +256,15 @@ String lcl_GetNumGroupForValue( double fValue, const ScDPNumGroupInfo& rInfo, bo
// selected end value.
fDiv -= 1.0;
- fGroupStart = rInfo.Start + fDiv * rInfo.Step;
+ fGroupStart = rInfo.mfStart + fDiv * rInfo.mfStep;
}
else
{
// For date values, the end value is instead treated as above the limit
// if it would be a group of its own.
- rGroupValue = rInfo.End + rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
+ rGroupValue = rInfo.mfEnd + rInfo.mfStep;
+ return lcl_GetSpecialNumGroupName( rInfo.mfEnd, false, cDecSeparator, rInfo.mbDateValues, pFormatter );
}
}
@@ -314,10 +318,10 @@ bool ScDPGroupDateFilter::match( const ScDPItemData & rCellData ) const
// Start and end dates are inclusive. (An end date without a time value
// is included, while an end date with a time value is not.)
- if ( rCellData.GetValue() < mpNumInfo->Start && !approxEqual(rCellData.GetValue(), mpNumInfo->Start) )
+ if ( rCellData.GetValue() < mpNumInfo->mfStart && !approxEqual(rCellData.GetValue(), mpNumInfo->mfStart) )
return static_cast<sal_Int32>(mfMatchValue) == SC_DP_DATE_FIRST;
- if ( rCellData.GetValue() > mpNumInfo->End && !approxEqual(rCellData.GetValue(), mpNumInfo->End) )
+ if ( rCellData.GetValue() > mpNumInfo->mfEnd && !approxEqual(rCellData.GetValue(), mpNumInfo->mfEnd) )
return static_cast<sal_Int32>(mfMatchValue) == SC_DP_DATE_LAST;
if (mnDatePart == DataPilotFieldGroupBy::HOURS || mnDatePart == DataPilotFieldGroupBy::MINUTES ||
@@ -466,9 +470,9 @@ sal_Int32 lcl_GetDatePartValue( double fValue, sal_Int32 nDatePart, SvNumberForm
if ( pNumInfo )
{
- if ( fValue < pNumInfo->Start && !rtl::math::approxEqual( fValue, pNumInfo->Start ) )
+ if ( fValue < pNumInfo->mfStart && !rtl::math::approxEqual( fValue, pNumInfo->mfStart ) )
return SC_DP_DATE_FIRST;
- if ( fValue > pNumInfo->End && !rtl::math::approxEqual( fValue, pNumInfo->End ) )
+ if ( fValue > pNumInfo->mfEnd && !rtl::math::approxEqual( fValue, pNumInfo->mfEnd ) )
return SC_DP_DATE_LAST;
}
@@ -633,10 +637,10 @@ void ScDPDateGroupHelper::FillColumnEntries(
// For the start/end values, use the same date rounding as in ScDPNumGroupDimension::GetNumEntries
// (but not for the list of available years):
- if ( aNumInfo.AutoStart )
- const_cast<ScDPDateGroupHelper*>(this)->aNumInfo.Start = rtl::math::approxFloor( fSourceMin );
- if ( aNumInfo.AutoEnd )
- const_cast<ScDPDateGroupHelper*>(this)->aNumInfo.End = rtl::math::approxFloor( fSourceMax ) + 1;
+ if ( aNumInfo.mbAutoStart )
+ const_cast<ScDPDateGroupHelper*>(this)->aNumInfo.mfStart = rtl::math::approxFloor( fSourceMin );
+ if ( aNumInfo.mbAutoEnd )
+ const_cast<ScDPDateGroupHelper*>(this)->aNumInfo.mfEnd = rtl::math::approxFloor( fSourceMax ) + 1;
//! if not automatic, limit fSourceMin/fSourceMax for list of year values?
SvNumberFormatter* pFormatter = pCache->GetDoc()->GetFormatTable();
@@ -667,10 +671,10 @@ void ScDPDateGroupHelper::FillColumnEntries(
}
// add first/last entry (min/max)
- String aFirstName = lcl_GetSpecialDateName( aNumInfo.Start, true, pFormatter );
+ String aFirstName = lcl_GetSpecialDateName( aNumInfo.mfStart, true, pFormatter );
lcl_InsertValue<true>( nSourceDim, pCache, rEntries, aFirstName, SC_DP_DATE_FIRST, nDatePart );
- String aLastName = lcl_GetSpecialDateName( aNumInfo.End, false, pFormatter );
+ String aLastName = lcl_GetSpecialDateName( aNumInfo.mfEnd, false, pFormatter );
lcl_InsertValue<true>( nSourceDim, pCache, rEntries, aLastName, SC_DP_DATE_LAST, nDatePart );
}
@@ -894,7 +898,7 @@ void ScDPNumGroupDimension::MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_I
delete pDateHelper;
pDateHelper = new ScDPDateGroupHelper( rInfo, nPart );
- aGroupInfo.Enable = sal_True; //! or query both?
+ aGroupInfo.mbEnable = sal_True; //! or query both?
}
const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
@@ -917,9 +921,9 @@ const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
cDecSeparator = ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0);
// non-integer GroupInfo values count, too
- bHasNonInteger = ( !aGroupInfo.AutoStart && !IsInteger( aGroupInfo.Start ) ) ||
- ( !aGroupInfo.AutoEnd && !IsInteger( aGroupInfo.End ) ) ||
- !IsInteger( aGroupInfo.Step );
+ bHasNonInteger = ( !aGroupInfo.mbAutoStart && !IsInteger( aGroupInfo.mfStart ) ) ||
+ ( !aGroupInfo.mbAutoEnd && !IsInteger( aGroupInfo.mfEnd ) ) ||
+ !IsInteger( aGroupInfo.mfStep );
double fSourceMin = 0.0;
double fSourceMax = 0.0;
bool bFirst = true;
@@ -957,7 +961,7 @@ const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
}
}
- if ( aGroupInfo.DateValues )
+ if ( aGroupInfo.mbDateValues )
{
// special handling for dates: always integer, round down limits
bHasNonInteger = false;
@@ -965,15 +969,15 @@ const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
fSourceMax = rtl::math::approxFloor( fSourceMax ) + 1;
}
- if ( aGroupInfo.AutoStart )
- const_cast<ScDPNumGroupDimension*>(this)->aGroupInfo.Start = fSourceMin;
- if ( aGroupInfo.AutoEnd )
- const_cast<ScDPNumGroupDimension*>(this)->aGroupInfo.End = fSourceMax;
+ if ( aGroupInfo.mbAutoStart )
+ const_cast<ScDPNumGroupDimension*>(this)->aGroupInfo.mfStart = fSourceMin;
+ if ( aGroupInfo.mbAutoEnd )
+ const_cast<ScDPNumGroupDimension*>(this)->aGroupInfo.mfEnd = fSourceMax;
//! limit number of entries?
long nLoopCount = 0;
- double fLoop = aGroupInfo.Start;
+ double fLoop = aGroupInfo.mfStart;
// Use "less than" instead of "less or equal" for the loop - don't create a group
// that consists only of the end value. Instead, the end value is then included
@@ -981,24 +985,24 @@ const std::vector<SCROW>& ScDPNumGroupDimension::GetNumEntries(
// The first group has to be created nonetheless. GetNumGroupForValue has corresponding logic.
bool bFirstGroup = true;
- while ( bFirstGroup || ( fLoop < aGroupInfo.End && !rtl::math::approxEqual( fLoop, aGroupInfo.End ) ) )
+ while ( bFirstGroup || ( fLoop < aGroupInfo.mfEnd && !rtl::math::approxEqual( fLoop, aGroupInfo.mfEnd ) ) )
{
String aName = lcl_GetNumGroupName( fLoop, aGroupInfo, bHasNonInteger, cDecSeparator, pFormatter );
// create a numerical entry to ensure proper sorting
// (in FillMemberResults this needs special handling)
lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aName, fLoop );
++nLoopCount;
- fLoop = aGroupInfo.Start + nLoopCount * aGroupInfo.Step;
+ fLoop = aGroupInfo.mfStart + nLoopCount * aGroupInfo.mfStep;
bFirstGroup = false;
// ScDPItemData values are compared with approxEqual
}
- String aFirstName = lcl_GetSpecialNumGroupName( aGroupInfo.Start, true, cDecSeparator, aGroupInfo.DateValues, pFormatter );
- lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aFirstName, aGroupInfo.Start - aGroupInfo.Step );
+ String aFirstName = lcl_GetSpecialNumGroupName( aGroupInfo.mfStart, true, cDecSeparator, aGroupInfo.mbDateValues, pFormatter );
+ lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aFirstName, aGroupInfo.mfStart - aGroupInfo.mfStep );
- String aLastName = lcl_GetSpecialNumGroupName( aGroupInfo.End, false, cDecSeparator, aGroupInfo.DateValues, pFormatter );
- lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aLastName, aGroupInfo.End + aGroupInfo.Step );
+ String aLastName = lcl_GetSpecialNumGroupName( aGroupInfo.mfEnd, false, cDecSeparator, aGroupInfo.mbDateValues, pFormatter );
+ lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aLastName, aGroupInfo.mfEnd + aGroupInfo.mfStep );
}
}
return maMemberEntries;
@@ -1054,7 +1058,7 @@ long ScDPGroupTableData::GetColumnCount()
bool ScDPGroupTableData::IsNumGroupDimension( long nDimension ) const
{
- return ( nDimension < nSourceCount && pNumGroups[nDimension].GetInfo().Enable );
+ return ( nDimension < nSourceCount && pNumGroups[nDimension].GetInfo().mbEnable );
}
void ScDPGroupTableData::GetNumGroupInfo( long nDimension, ScDPNumGroupInfo& rInfo,
@@ -1420,7 +1424,7 @@ sal_Bool ScDPGroupTableData::IsNumOrDateGroup(long nDimension) const
if ( nDimension < nSourceCount )
{
- return pNumGroups[nDimension].GetInfo().Enable ||
+ return pNumGroups[nDimension].GetInfo().mbEnable ||
pNumGroups[nDimension].GetDateHelper();
}
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index e1a9ad1..234ecc0 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -229,12 +229,12 @@ XclExpPCField::XclExpPCField(
{
const ScDPNumGroupInfo& rNumInfo = pNumGroupDim->GetInfo();
const ScDPNumGroupInfo& rDateInfo = pNumGroupDim->GetDateInfo();
- OSL_ENSURE( !rNumInfo.Enable || !rDateInfo.Enable,
+ OSL_ENSURE( !rNumInfo.mbEnable || !rDateInfo.mbEnable,
"XclExpPCField::XclExpPCField - numeric and date grouping enabled" );
- if( rNumInfo.Enable )
+ if( rNumInfo.mbEnable )
InitNumGroupField( rDPObj, rNumInfo );
- else if( rDateInfo.Enable )
+ else if( rDateInfo.mbEnable )
InitDateGroupField( rDPObj, rDateInfo, pNumGroupDim->GetDatePart() );
}
}
@@ -261,7 +261,7 @@ XclExpPCField::XclExpPCField(
// add standard group info or date group info
const ScDPNumGroupInfo& rDateInfo = rGroupDim.GetDateInfo();
- if( rDateInfo.Enable && (rGroupDim.GetDatePart() != 0) )
+ if( rDateInfo.mbEnable && (rGroupDim.GetDatePart() != 0) )
InitDateGroupField( rDPObj, rDateInfo, rGroupDim.GetDatePart() );
else
InitStdGroupField( rBaseField, rGroupDim );
@@ -429,10 +429,10 @@ void XclExpPCField::InitStdGroupField( const XclExpPCField& rBaseField, const Sc
void XclExpPCField::InitNumGroupField( const ScDPObject& rDPObj, const ScDPNumGroupInfo& rNumInfo )
{
OSL_ENSURE( IsStandardField(), "XclExpPCField::InitNumGroupField - only for standard fields" );
- OSL_ENSURE( rNumInfo.Enable, "XclExpPCField::InitNumGroupField - numeric grouping not enabled" );
+ OSL_ENSURE( rNumInfo.mbEnable, "XclExpPCField::InitNumGroupField - numeric grouping not enabled" );
// new field type, date type, limit settings (min/max/step/auto)
- if( rNumInfo.DateValues )
+ if( rNumInfo.mbDateValues )
{
// special case: group by days with step count
meFieldType = EXC_PCFIELD_DATEGROUP;
@@ -453,7 +453,7 @@ void XclExpPCField::InitNumGroupField( const ScDPObject& rDPObj, const ScDPNumGr
void XclExpPCField::InitDateGroupField( const ScDPObject& rDPObj, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nDatePart )
{
OSL_ENSURE( IsStandardField() || IsStdGroupField(), "XclExpPCField::InitDateGroupField - only for standard fields" );
- OSL_ENSURE( rDateInfo.Enable, "XclExpPCField::InitDateGroupField - date grouping not enabled" );
+ OSL_ENSURE( rDateInfo.mbEnable, "XclExpPCField::InitDateGroupField - date grouping not enabled" );
// new field type
meFieldType = IsStandardField() ? EXC_PCFIELD_DATEGROUP : EXC_PCFIELD_DATECHILD;
@@ -561,20 +561,20 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
void XclExpPCField::SetNumGroupLimit( const ScDPNumGroupInfo& rNumInfo )
{
- ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN, rNumInfo.AutoStart );
- ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX, rNumInfo.AutoEnd );
- maNumGroupLimits.AppendNewRecord( new XclExpPCItem( rNumInfo.Start ) );
- maNumGroupLimits.AppendNewRecord( new XclExpPCItem( rNumInfo.End ) );
- maNumGroupLimits.AppendNewRecord( new XclExpPCItem( rNumInfo.Step ) );
+ ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN, rNumInfo.mbAutoStart );
+ ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX, rNumInfo.mbAutoEnd );
+ maNumGroupLimits.AppendNewRecord( new XclExpPCItem( rNumInfo.mfStart ) );
+ maNumGroupLimits.AppendNewRecord( new XclExpPCItem( rNumInfo.mfEnd ) );
+ maNumGroupLimits.AppendNewRecord( new XclExpPCItem( rNumInfo.mfStep ) );
}
void XclExpPCField::SetDateGroupLimit( const ScDPNumGroupInfo& rDateInfo, bool bUseStep )
{
- ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN, rDateInfo.AutoStart );
- ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX, rDateInfo.AutoEnd );
- maNumGroupLimits.AppendNewRecord( new XclExpPCItem( GetDateTimeFromDouble( rDateInfo.Start ) ) );
- maNumGroupLimits.AppendNewRecord( new XclExpPCItem( GetDateTimeFromDouble( rDateInfo.End ) ) );
- sal_Int16 nStep = bUseStep ? limit_cast< sal_Int16 >( rDateInfo.Step, 1, SAL_MAX_INT16 ) : 1;
+ ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN, rDateInfo.mbAutoStart );
+ ::set_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX, rDateInfo.mbAutoEnd );
+ maNumGroupLimits.AppendNewRecord( new XclExpPCItem( GetDateTimeFromDouble( rDateInfo.mfStart ) ) );
+ maNumGroupLimits.AppendNewRecord( new XclExpPCItem( GetDateTimeFromDouble( rDateInfo.mfEnd ) ) );
+ sal_Int16 nStep = bUseStep ? limit_cast< sal_Int16 >( rDateInfo.mfStep, 1, SAL_MAX_INT16 ) : 1;
maNumGroupLimits.AppendNewRecord( new XclExpPCItem( nStep ) );
}
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 0aff093..2d30efb 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -459,7 +459,7 @@ void XclImpPCField::ConvertDateGroupField( ScDPSaveData& rSaveData, const ScfStr
{
case EXC_PCFIELD_DATEGROUP:
{
- if( aDateInfo.DateValues )
+ if( aDateInfo.mbDateValues )
{
// special case for days only with step value - create numeric grouping
ScDPSaveNumGroupDimension aNumGroupDim( GetFieldName( rVisNames ), aDateInfo );
@@ -497,23 +497,23 @@ void XclImpPCField::ConvertDateGroupField( ScDPSaveData& rSaveData, const ScfStr
ScDPNumGroupInfo XclImpPCField::GetScNumGroupInfo() const
{
ScDPNumGroupInfo aNumInfo;
- aNumInfo.Enable = sal_True;
- aNumInfo.DateValues = false;
- aNumInfo.AutoStart = sal_True;
- aNumInfo.AutoEnd = sal_True;
+ aNumInfo.mbEnable = sal_True;
+ aNumInfo.mbDateValues = false;
+ aNumInfo.mbAutoStart = sal_True;
+ aNumInfo.mbAutoEnd = sal_True;
if( const double* pfMinValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_MIN ) )
{
- aNumInfo.Start = *pfMinValue;
- aNumInfo.AutoStart = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN );
+ aNumInfo.mfStart = *pfMinValue;
+ aNumInfo.mbAutoStart = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN );
}
if( const double* pfMaxValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_MAX ) )
{
- aNumInfo.End = *pfMaxValue;
- aNumInfo.AutoEnd = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX );
+ aNumInfo.mfEnd = *pfMaxValue;
+ aNumInfo.mbAutoEnd = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX );
}
if( const double* pfStepValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_STEP ) )
- aNumInfo.Step = *pfStepValue;
+ aNumInfo.mfStep = *pfStepValue;
return aNumInfo;
}
@@ -521,26 +521,26 @@ ScDPNumGroupInfo XclImpPCField::GetScNumGroupInfo() const
ScDPNumGroupInfo XclImpPCField::GetScDateGroupInfo() const
{
ScDPNumGroupInfo aDateInfo;
- aDateInfo.Enable = sal_True;
- aDateInfo.DateValues = false;
- aDateInfo.AutoStart = sal_True;
- aDateInfo.AutoEnd = sal_True;
+ aDateInfo.mbEnable = sal_True;
+ aDateInfo.mbDateValues = false;
+ aDateInfo.mbAutoStart = sal_True;
+ aDateInfo.mbAutoEnd = sal_True;
if( const DateTime* pMinDate = GetDateGroupLimit( EXC_SXFIELD_INDEX_MIN ) )
{
- aDateInfo.Start = GetDoubleFromDateTime( *pMinDate );
- aDateInfo.AutoStart = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN );
+ aDateInfo.mfStart = GetDoubleFromDateTime( *pMinDate );
+ aDateInfo.mbAutoStart = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMIN );
}
if( const DateTime* pMaxDate = GetDateGroupLimit( EXC_SXFIELD_INDEX_MAX ) )
{
- aDateInfo.End = GetDoubleFromDateTime( *pMaxDate );
- aDateInfo.AutoEnd = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX );
+ aDateInfo.mfEnd = GetDoubleFromDateTime( *pMaxDate );
+ aDateInfo.mbAutoEnd = ::get_flag( maNumGroupInfo.mnFlags, EXC_SXNUMGROUP_AUTOMAX );
}
// GetDateGroupStep() returns a value for date type "day" in single date groups only
if( const sal_Int16* pnStepValue = GetDateGroupStep() )
{
- aDateInfo.Step = *pnStepValue;
- aDateInfo.DateValues = sal_True;
+ aDateInfo.mfStep = *pnStepValue;
+ aDateInfo.mbDateValues = sal_True;
}
return aDateInfo;
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 4094a16..ade9d7d 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -558,49 +558,49 @@ void ScXMLExportDataPilot::WriteDatePart(sal_Int32 nPart)
void ScXMLExportDataPilot::WriteNumGroupInfo(const ScDPNumGroupInfo& rGroupInfo)
{
- OSL_ENSURE(rGroupInfo.Enable, "group dimension should be enabled");
- if (rGroupInfo.DateValues)
+ OSL_ENSURE(rGroupInfo.mbEnable, "group dimension should be enabled");
+ if (rGroupInfo.mbDateValues)
{
- if (rGroupInfo.AutoStart)
+ if (rGroupInfo.mbAutoStart)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_START, XML_AUTO);
else
{
rtl::OUStringBuffer sDate;
- rExport.GetMM100UnitConverter().convertDateTime(sDate, rGroupInfo.Start);
+ rExport.GetMM100UnitConverter().convertDateTime(sDate, rGroupInfo.mfStart);
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_START, sDate.makeStringAndClear());
}
- if (rGroupInfo.AutoEnd)
+ if (rGroupInfo.mbAutoEnd)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_END, XML_AUTO);
else
{
rtl::OUStringBuffer sDate;
- rExport.GetMM100UnitConverter().convertDateTime(sDate, rGroupInfo.End);
+ rExport.GetMM100UnitConverter().convertDateTime(sDate, rGroupInfo.mfEnd);
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_END, sDate.makeStringAndClear());
}
}
else
{
- if (rGroupInfo.AutoStart)
+ if (rGroupInfo.mbAutoStart)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_START, XML_AUTO);
else
{
- rtl::OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.Start,
+ rtl::OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfStart,
rtl_math_StringFormat_Automatic,
rtl_math_DecimalPlaces_Max, '.', true));
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_START, sValue);
}
- if (rGroupInfo.AutoEnd)
+ if (rGroupInfo.mbAutoEnd)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_END, XML_AUTO);
else
{
rtl::OUStringBuffer sDate;
- rtl::OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.End,
+ rtl::OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfEnd,
rtl_math_StringFormat_Automatic,
rtl_math_DecimalPlaces_Max, '.', true));
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_END, sValue);
}
}
- rtl::OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.Step,
+ rtl::OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfStep,
rtl_math_StringFormat_Automatic,
rtl_math_DecimalPlaces_Max, '.', true));
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_STEP, sValue);
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 86bf12b..ee8e3aa 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -1073,13 +1073,13 @@ void ScXMLDataPilotFieldContext::EndElement()
if (bIsGroupField)
{
ScDPNumGroupInfo aInfo;
- aInfo.Enable = sal_True;
- aInfo.DateValues = bDateValue;
- aInfo.AutoStart = bAutoStart;
- aInfo.AutoEnd = bAutoEnd;
- aInfo.Start = fStart;
- aInfo.End = fEnd;
- aInfo.Step = fStep;
+ aInfo.mbEnable = true;
+ aInfo.mbDateValues = bDateValue;
+ aInfo.mbAutoStart = bAutoStart;
+ aInfo.mbAutoEnd = bAutoEnd;
+ aInfo.mfStart = fStart;
+ aInfo.mfEnd = fEnd;
+ aInfo.mfStep = fStep;
if (!sGroupSource.isEmpty())
{
ScDPSaveGroupDimension aGroupDim(sGroupSource, sName);
diff --git a/sc/source/ui/dbgui/dpgroupdlg.cxx b/sc/source/ui/dbgui/dpgroupdlg.cxx
index 147e676..fc39e7f 100644
--- a/sc/source/ui/dbgui/dpgroupdlg.cxx
+++ b/sc/source/ui/dbgui/dpgroupdlg.cxx
@@ -177,9 +177,9 @@ ScDPNumGroupDlg::ScDPNumGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo
{
FreeResource();
- maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
- maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
- maEdBy.SetValue( (rInfo.Step <= 0.0) ? 1.0 : rInfo.Step );
+ maStartHelper.SetValue( rInfo.mbAutoStart, rInfo.mfStart );
+ maEndHelper.SetValue( rInfo.mbAutoEnd, rInfo.mfEnd );
+ maEdBy.SetValue( (rInfo.mfStep <= 0.0) ? 1.0 : rInfo.mfStep );
/* Set the initial focus, currently it is somewhere after calling all the radio
button click handlers. Now the first enabled editable control is focused. */
@@ -194,19 +194,19 @@ ScDPNumGroupDlg::ScDPNumGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo
ScDPNumGroupInfo ScDPNumGroupDlg::GetGroupInfo() const
{
ScDPNumGroupInfo aInfo;
- aInfo.Enable = sal_True;
- aInfo.DateValues = false;
- aInfo.AutoStart = maStartHelper.IsAuto();
- aInfo.AutoEnd = maEndHelper.IsAuto();
+ aInfo.mbEnable = sal_True;
+ aInfo.mbDateValues = false;
+ aInfo.mbAutoStart = maStartHelper.IsAuto();
+ aInfo.mbAutoEnd = maEndHelper.IsAuto();
// get values and silently auto-correct them, if they are not valid
// TODO: error messages in OK event?
- aInfo.Start = maStartHelper.GetValue();
- aInfo.End = maEndHelper.GetValue();
- if( !maEdBy.GetValue( aInfo.Step ) || (aInfo.Step <= 0.0) )
- aInfo.Step = 1.0;
- if( aInfo.End <= aInfo.Start )
- aInfo.End = aInfo.Start + aInfo.Step;
+ aInfo.mfStart = maStartHelper.GetValue();
+ aInfo.mfEnd = maEndHelper.GetValue();
+ if( !maEdBy.GetValue( aInfo.mfStep ) || (aInfo.mfStep <= 0.0) )
+ aInfo.mfStep = 1.0;
+ if( aInfo.mfEnd <= aInfo.mfStart )
+ aInfo.mfEnd = aInfo.mfStart + aInfo.mfStep;
return aInfo;
}
@@ -245,20 +245,20 @@ ScDPDateGroupDlg::ScDPDateGroupDlg( Window* pParent,
maEdStart.SetShowDateCentury( sal_True );
maEdEnd.SetShowDateCentury( sal_True );
- maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
- maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
+ maStartHelper.SetValue( rInfo.mbAutoStart, rInfo.mfStart );
+ maEndHelper.SetValue( rInfo.mbAutoEnd, rInfo.mfEnd );
if( nDatePart == 0 )
nDatePart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS;
for( sal_uLong nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx )
maLbUnits.CheckEntryPos( static_cast< sal_uInt16 >( nIdx ), (nDatePart & spnDateParts[ nIdx ]) != 0 );
- if( rInfo.DateValues )
+ if( rInfo.mbDateValues )
{
maRbNumDays.Check();
ClickHdl( &maRbNumDays );
- double fNumDays = rInfo.Step;
+ double fNumDays = rInfo.mfStep;
if( fNumDays < 1.0 )
fNumDays = 1.0;
else if( fNumDays > 32767.0 )
@@ -290,19 +290,19 @@ ScDPDateGroupDlg::ScDPDateGroupDlg( Window* pParent,
ScDPNumGroupInfo ScDPDateGroupDlg::GetGroupInfo() const
{
ScDPNumGroupInfo aInfo;
- aInfo.Enable = sal_True;
- aInfo.DateValues = maRbNumDays.IsChecked();
- aInfo.AutoStart = maStartHelper.IsAuto();
- aInfo.AutoEnd = maEndHelper.IsAuto();
+ aInfo.mbEnable = sal_True;
+ aInfo.mbDateValues = maRbNumDays.IsChecked();
+ aInfo.mbAutoStart = maStartHelper.IsAuto();
+ aInfo.mbAutoEnd = maEndHelper.IsAuto();
// get values and silently auto-correct them, if they are not valid
// TODO: error messages in OK event?
- aInfo.Start = maStartHelper.GetValue();
- aInfo.End = maEndHelper.GetValue();
+ aInfo.mfStart = maStartHelper.GetValue();
+ aInfo.mfEnd = maEndHelper.GetValue();
sal_Int64 nNumDays = maEdNumDays.GetValue();
- aInfo.Step = static_cast<double>( aInfo.DateValues ? nNumDays : 0L );
- if( aInfo.End <= aInfo.Start )
- aInfo.End = aInfo.Start + nNumDays;
+ aInfo.mfStep = static_cast<double>( aInfo.mbDateValues ? nNumDays : 0L );
+ if( aInfo.mfEnd <= aInfo.mfStart )
+ aInfo.mfEnd = aInfo.mfStart + nNumDays;
return aInfo;
}
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 7d9eea6..9ff4cb9 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -246,12 +246,12 @@ sal_uInt16 ScDataPilotConversion::FunctionBit( GeneralFunction eFunc )
void ScDataPilotConversion::FillGroupInfo( DataPilotFieldGroupInfo& rInfo, const ScDPNumGroupInfo& rGroupInfo )
{
- rInfo.HasDateValues = rGroupInfo.DateValues;
- rInfo.HasAutoStart = rGroupInfo.AutoStart;
- rInfo.Start = rGroupInfo.Start;
- rInfo.HasAutoEnd = rGroupInfo.AutoEnd;
- rInfo.End = rGroupInfo.End;
- rInfo.Step = rGroupInfo.Step;
+ rInfo.HasDateValues = rGroupInfo.mbDateValues;
+ rInfo.HasAutoStart = rGroupInfo.mbAutoStart;
+ rInfo.Start = rGroupInfo.mfStart;
+ rInfo.HasAutoEnd = rGroupInfo.mbAutoEnd;
+ rInfo.End = rGroupInfo.mfEnd;
+ rInfo.Step = rGroupInfo.mfStep;
}
//------------------------------------------------------------------------
@@ -2464,13 +2464,13 @@ void ScDataPilotFieldObj::setGroupInfo( const DataPilotFieldGroupInfo* pInfo )
if( pInfo && lclCheckMinMaxStep( *pInfo ) )
{
ScDPNumGroupInfo aInfo;
- aInfo.Enable = sal_True;
- aInfo.DateValues = pInfo->HasDateValues;
- aInfo.AutoStart = pInfo->HasAutoStart;
- aInfo.AutoEnd = pInfo->HasAutoEnd;
- aInfo.Start = pInfo->Start;
- aInfo.End = pInfo->End;
- aInfo.Step = pInfo->Step;
+ aInfo.mbEnable = sal_True;
+ aInfo.mbDateValues = pInfo->HasDateValues;
+ aInfo.mbAutoStart = pInfo->HasAutoStart;
+ aInfo.mbAutoEnd = pInfo->HasAutoEnd;
+ aInfo.mfStart = pInfo->Start;
+ aInfo.mfEnd = pInfo->End;
+ aInfo.mfStep = pInfo->Step;
Reference< XNamed > xNamed( pInfo->SourceField, UNO_QUERY );
if( xNamed.is() )
{
@@ -2746,13 +2746,13 @@ Reference < XDataPilotField > SAL_CALL ScDataPilotFieldObj::createDateGroup( con
if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
{
ScDPNumGroupInfo aInfo;
- aInfo.Enable = sal_True;
- aInfo.DateValues = (rInfo.GroupBy == DAYS) && (rInfo.Step >= 1.0);
- aInfo.AutoStart = rInfo.HasAutoStart;
- aInfo.AutoEnd = rInfo.HasAutoEnd;
- aInfo.Start = rInfo.Start;
- aInfo.End = rInfo.End;
- aInfo.Step = static_cast< sal_Int32 >( rInfo.Step );
+ aInfo.mbEnable = true;
+ aInfo.mbDateValues = (rInfo.GroupBy == DAYS) && (rInfo.Step >= 1.0);
+ aInfo.mbAutoStart = rInfo.HasAutoStart;
+ aInfo.mbAutoEnd = rInfo.HasAutoEnd;
+ aInfo.mfStart = rInfo.Start;
+ aInfo.mfEnd = rInfo.End;
+ aInfo.mfStep = static_cast< sal_Int32 >( rInfo.Step );
// create a local copy of the entire save data (will be written back below)
ScDPSaveData aSaveData = *pDPObj->GetSaveData();
@@ -2769,12 +2769,12 @@ Reference < XDataPilotField > SAL_CALL ScDataPilotFieldObj::createDateGroup( con
const ScDPSaveNumGroupDimension* pNumGroupDim = rDimData.GetNumGroupDim( aSrcDimName );
// do not group by dates, if named groups or numeric grouping is present
- bool bHasNamedGrouping = pGroupDim && !pGroupDim->GetDateInfo().Enable;
- bool bHasNumGrouping = pNumGroupDim && pNumGroupDim->GetInfo().Enable && !pNumGroupDim->GetInfo().DateValues && !pNumGroupDim->GetDateInfo().Enable;
+ bool bHasNamedGrouping = pGroupDim && !pGroupDim->GetDateInfo().mbEnable;
+ bool bHasNumGrouping = pNumGroupDim && pNumGroupDim->GetInfo().mbEnable && !pNumGroupDim->GetInfo().mbDateValues && !pNumGroupDim->GetDateInfo().mbEnable;
if( bHasNamedGrouping || bHasNumGrouping )
throw IllegalArgumentException();
- if( aInfo.DateValues ) // create day ranges grouping
+ if( aInfo.mbDateValues ) // create day ranges grouping
{
// first remove all named group dimensions
while( pGroupDim )
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index c7a8024..a1683b4 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -988,9 +988,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
{
ScDPNumGroupInfo aNumInfo;
- aNumInfo.Enable = sal_True;
- aNumInfo.AutoStart = sal_True;
- aNumInfo.AutoEnd = sal_True;
+ aNumInfo.mbEnable = true;
+ aNumInfo.mbAutoStart = true;
+ aNumInfo.mbAutoEnd = true;
sal_Int32 nParts = 0;
if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) )
{
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index ca1de03..127b950 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -836,7 +836,7 @@ bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32&
rOldInfo = pNumGroupDim->GetDateInfo();
bFound = sal_True;
}
- else if ( pNumGroupDim->GetInfo().DateValues )
+ else if ( pNumGroupDim->GetInfo().mbDateValues )
{
// Numerical grouping with DateValues flag is used for grouping
// of days with a "Number of days" value.
@@ -890,10 +890,10 @@ bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32&
{
bFound = sal_True;
// use currently selected value for automatic limits
- if( rOldInfo.AutoStart )
- rOldInfo.Start = pDoc->GetValue( aSelRange.aStart );
- if( rOldInfo.AutoEnd )
- rOldInfo.End = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.mbAutoStart )
+ rOldInfo.mfStart = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.mbAutoEnd )
+ rOldInfo.mfEnd = pDoc->GetValue( aSelRange.aStart );
}
}
}
@@ -959,10 +959,10 @@ bool ScDBFunc::HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo )
{
bFound = sal_True;
// use currently selected value for automatic limits
- if( rOldInfo.AutoStart )
- rOldInfo.Start = pDoc->GetValue( aSelRange.aStart );
- if( rOldInfo.AutoEnd )
- rOldInfo.End = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.mbAutoStart )
+ rOldInfo.mfStart = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.mbAutoEnd )
+ rOldInfo.mfEnd = pDoc->GetValue( aSelRange.aStart );
}
}
}
@@ -1047,13 +1047,13 @@ void ScDBFunc::DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nPar
// innermost part: create NumGroupDimension (replacing original values)
// Dimension name is left unchanged
- if ( (nParts == sheet::DataPilotFieldGroupBy::DAYS) && (rInfo.Step >= 1.0) )
+ if ( (nParts == sheet::DataPilotFieldGroupBy::DAYS) && (rInfo.mfStep >= 1.0) )
{
// only days, and a step value specified: use numerical grouping
// with DateValues flag, not date grouping
ScDPNumGroupInfo aNumInfo( rInfo );
- aNumInfo.DateValues = sal_True;
+ aNumInfo.mbDateValues = true;
ScDPSaveNumGroupDimension aNumGroupDim( aBaseDimName, aNumInfo );
pDimData->AddNumGroupDimension( aNumGroupDim );
commit 4a092a8de1c76612691979d0194a0346ed37cf02
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Feb 28 15:25:20 2012 -0500
Fix indentation.
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index bb66bf8..8df6e91 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -73,202 +73,202 @@ const sal_uInt16 SC_DP_LEAPYEAR = 1648; // arbitrary leap year for date calc
const sal_Int32 SC_DP_DATE_FIRST = -1;
const sal_Int32 SC_DP_DATE_LAST = 10000;
-// ============================================================================
-namespace
+namespace {
+
+sal_Bool lcl_Search( SCCOL nSourceDim, const ScDPCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
{
- sal_Bool lcl_Search( SCCOL nSourceDim, const ScDPCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
+ rIndex = vIdx.size();
+ sal_Bool bFound = false;
+ SCROW nLo = 0;
+ SCROW nHi = vIdx.size() - 1;
+ SCROW nIndex;
+ long nCompare;
+ while (nLo <= nHi)
{
- rIndex = vIdx.size();
- sal_Bool bFound = false;
- SCROW nLo = 0;
- SCROW nHi = vIdx.size() - 1;
- SCROW nIndex;
- long nCompare;
- while (nLo <= nHi)
- {
- nIndex = (nLo + nHi) / 2;
+ nIndex = (nLo + nHi) / 2;
- const ScDPItemData* pData = pCache->GetItemDataById( nSourceDim, vIdx[nIndex] );
- const ScDPItemData* pDataInsert = pCache->GetItemDataById( nSourceDim, nNew );
+ const ScDPItemData* pData = pCache->GetItemDataById( nSourceDim, vIdx[nIndex] );
+ const ScDPItemData* pDataInsert = pCache->GetItemDataById( nSourceDim, nNew );
- nCompare = ScDPItemData::Compare( *pData, *pDataInsert );
- if (nCompare < 0)
- nLo = nIndex + 1;
- else
+ nCompare = ScDPItemData::Compare( *pData, *pDataInsert );
+ if (nCompare < 0)
+ nLo = nIndex + 1;
+ else
+ {
+ nHi = nIndex - 1;
+ if (nCompare == 0)
{
- nHi = nIndex - 1;
- if (nCompare == 0)
- {
- bFound = sal_True;
- nLo = nIndex;
- }
+ bFound = sal_True;
+ nLo = nIndex;
}
}
- rIndex = nLo;
- return bFound;
}
+ rIndex = nLo;
+ return bFound;
+}
- void lcl_Insert( SCCOL nSourceDim, const ScDPCache* pCache , std::vector< SCROW >& vIdx, SCROW nNew )
- {
- SCROW nIndex = 0;
- if ( !lcl_Search( nSourceDim, pCache, vIdx, nNew ,nIndex ) )
- vIdx.insert( vIdx.begin()+nIndex, nNew );
- }
+void lcl_Insert( SCCOL nSourceDim, const ScDPCache* pCache , std::vector< SCROW >& vIdx, SCROW nNew )
+{
+ SCROW nIndex = 0;
+ if ( !lcl_Search( nSourceDim, pCache, vIdx, nNew ,nIndex ) )
+ vIdx.insert( vIdx.begin()+nIndex, nNew );
+}
- template<bool bUpdateData>
- SCROW lcl_InsertValue(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData);
+template<bool bUpdateData>
+SCROW lcl_InsertValue(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData);
- template<>
- SCROW lcl_InsertValue<false>(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
- {
- SCROW nNewID = pCache->GetAdditionalItemID(rData);
- lcl_Insert(nSourceDim, pCache, vIdx, nNewID);
- return nNewID;
- }
+template<>
+SCROW lcl_InsertValue<false>(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
+{
+ SCROW nNewID = pCache->GetAdditionalItemID(rData);
+ lcl_Insert(nSourceDim, pCache, vIdx, nNewID);
+ return nNewID;
+}
- template<>
- SCROW lcl_InsertValue<true>(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
- {
- SCROW nItemId = lcl_InsertValue<false>( nSourceDim, pCache, vIdx, rData );
+template<>
+SCROW lcl_InsertValue<true>(SCCOL nSourceDim, const ScDPCache* pCache, std::vector<SCROW>& vIdx, const ScDPItemData & rData)
+{
+ SCROW nItemId = lcl_InsertValue<false>( nSourceDim, pCache, vIdx, rData );
- if( const ScDPItemData *pData = pCache->GetItemDataById( nSourceDim, nItemId ) )
- const_cast<ScDPItemData&>(*pData) = rData;
+ if( const ScDPItemData *pData = pCache->GetItemDataById( nSourceDim, nItemId ) )
+ const_cast<ScDPItemData&>(*pData) = rData;
- return nItemId;
- }
+ return nItemId;
+}
+
+template<bool bUpdateData>
+void lcl_InsertValue ( SCCOL nSourceDim, const ScDPCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue )
+{
+ lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( rString, fValue, sal_True ) );
+}
+
+template<bool bUpdateData>
+void lcl_InsertValue ( SCCOL nSourceDim, const ScDPCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue, sal_Int32 nDatePart )
+{
+ lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( nDatePart, rString, fValue, ScDPItemData::MK_DATA|ScDPItemData::MK_VAL|ScDPItemData::MK_DATEPART ) );
+}
- template<bool bUpdateData>
- void lcl_InsertValue ( SCCOL nSourceDim, const ScDPCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue )
+void lcl_AppendDateStr( rtl::OUStringBuffer& rBuffer, double fValue, SvNumberFormatter* pFormatter )
+{
+ sal_uLong nFormat = pFormatter->GetStandardFormat( NUMBERFORMAT_DATE, ScGlobal::eLnge );
+ String aString;
+ pFormatter->GetInputLineString( fValue, nFormat, aString );
+ rBuffer.append( aString );
+}
+
+String lcl_GetNumGroupName( double fStartValue, const ScDPNumGroupInfo& rInfo,
+ bool bHasNonInteger, sal_Unicode cDecSeparator, SvNumberFormatter* pFormatter )
+{
+ OSL_ENSURE( cDecSeparator != 0, "cDecSeparator not initialized" );
+
+ double fStep = rInfo.Step;
+ double fEndValue = fStartValue + fStep;
+ if ( !bHasNonInteger && ( rInfo.DateValues || !rtl::math::approxEqual( fEndValue, rInfo.End ) ) )
{
- lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( rString, fValue, sal_True ) );
+ // The second number of the group label is
+ // (first number + size - 1) if there are only integer numbers,
+ // (first number + size) if any non-integer numbers are involved.
+ // Exception: The last group (containing the end value) is always
+ // shown as including the end value (but not for dates).
+
+ fEndValue -= 1.0;
}
- template<bool bUpdateData>
- void lcl_InsertValue ( SCCOL nSourceDim, const ScDPCache* pCache, std::vector< SCROW >& vIdx, const String& rString, const double& fValue, sal_Int32 nDatePart )
+ if ( fEndValue > rInfo.End && !rInfo.AutoEnd )
{
- lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( nDatePart, rString, fValue, ScDPItemData::MK_DATA|ScDPItemData::MK_VAL|ScDPItemData::MK_DATEPART ) );
+ // limit the last group to the end value
+
+ fEndValue = rInfo.End;
}
- void lcl_AppendDateStr( rtl::OUStringBuffer& rBuffer, double fValue, SvNumberFormatter* pFormatter )
+ rtl::OUStringBuffer aBuffer;
+ if ( rInfo.DateValues )
{
- sal_uLong nFormat = pFormatter->GetStandardFormat( NUMBERFORMAT_DATE, ScGlobal::eLnge );
- String aString;
- pFormatter->GetInputLineString( fValue, nFormat, aString );
- rBuffer.append( aString );
+ lcl_AppendDateStr( aBuffer, fStartValue, pFormatter );
+ aBuffer.appendAscii( " - " ); // with spaces
+ lcl_AppendDateStr( aBuffer, fEndValue, pFormatter );
}
-
- String lcl_GetNumGroupName( double fStartValue, const ScDPNumGroupInfo& rInfo,
- bool bHasNonInteger, sal_Unicode cDecSeparator, SvNumberFormatter* pFormatter )
+ else
{
- OSL_ENSURE( cDecSeparator != 0, "cDecSeparator not initialized" );
-
- double fStep = rInfo.Step;
- double fEndValue = fStartValue + fStep;
- if ( !bHasNonInteger && ( rInfo.DateValues || !rtl::math::approxEqual( fEndValue, rInfo.End ) ) )
- {
- // The second number of the group label is
- // (first number + size - 1) if there are only integer numbers,
- // (first number + size) if any non-integer numbers are involved.
- // Exception: The last group (containing the end value) is always
- // shown as including the end value (but not for dates).
+ rtl::math::doubleToUStringBuffer( aBuffer, fStartValue, rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, cDecSeparator, true );
+ aBuffer.append( (sal_Unicode) '-' );
+ rtl::math::doubleToUStringBuffer( aBuffer, fEndValue, rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, cDecSeparator, true );
+ }
- fEndValue -= 1.0;
- }
+ return aBuffer.makeStringAndClear();
+}
- if ( fEndValue > rInfo.End && !rInfo.AutoEnd )
- {
- // limit the last group to the end value
+String lcl_GetSpecialNumGroupName( double fValue, bool bFirst, sal_Unicode cDecSeparator,
+ bool bDateValues, SvNumberFormatter* pFormatter )
+{
+ OSL_ENSURE( cDecSeparator != 0, "cDecSeparator not initialized" );
- fEndValue = rInfo.End;
- }
+ rtl::OUStringBuffer aBuffer;
+ aBuffer.append((sal_Unicode)( bFirst ? '<' : '>' ));
+ if ( bDateValues )
+ lcl_AppendDateStr( aBuffer, fValue, pFormatter );
+ else
+ rtl::math::doubleToUStringBuffer( aBuffer, fValue, rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, cDecSeparator, true );
+ return aBuffer.makeStringAndClear();
+}
- rtl::OUStringBuffer aBuffer;
- if ( rInfo.DateValues )
- {
- lcl_AppendDateStr( aBuffer, fStartValue, pFormatter );
- aBuffer.appendAscii( " - " ); // with spaces
- lcl_AppendDateStr( aBuffer, fEndValue, pFormatter );
- }
- else
- {
- rtl::math::doubleToUStringBuffer( aBuffer, fStartValue, rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, cDecSeparator, true );
- aBuffer.append( (sal_Unicode) '-' );
- rtl::math::doubleToUStringBuffer( aBuffer, fEndValue, rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, cDecSeparator, true );
- }
+inline bool IsInteger( double fValue )
+{
+ return rtl::math::approxEqual( fValue, rtl::math::approxFloor(fValue) );
+}
- return aBuffer.makeStringAndClear();
- }
+String lcl_GetNumGroupForValue( double fValue, const ScDPNumGroupInfo& rInfo, bool bHasNonInteger,
+ sal_Unicode cDecSeparator, double& rGroupValue, ScDocument* pDoc )
+{
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
- String lcl_GetSpecialNumGroupName( double fValue, bool bFirst, sal_Unicode cDecSeparator,
- bool bDateValues, SvNumberFormatter* pFormatter )
+ if ( fValue < rInfo.Start && !rtl::math::approxEqual( fValue, rInfo.Start ) )
{
- OSL_ENSURE( cDecSeparator != 0, "cDecSeparator not initialized" );
-
- rtl::OUStringBuffer aBuffer;
- aBuffer.append((sal_Unicode)( bFirst ? '<' : '>' ));
- if ( bDateValues )
- lcl_AppendDateStr( aBuffer, fValue, pFormatter );
- else
- rtl::math::doubleToUStringBuffer( aBuffer, fValue, rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, cDecSeparator, true );
- return aBuffer.makeStringAndClear();
+ rGroupValue = rInfo.Start - rInfo.Step;
+ return lcl_GetSpecialNumGroupName( rInfo.Start, true, cDecSeparator, rInfo.DateValues, pFormatter );
}
- inline bool IsInteger( double fValue )
+ if ( fValue > rInfo.End && !rtl::math::approxEqual( fValue, rInfo.End ) )
{
- return rtl::math::approxEqual( fValue, rtl::math::approxFloor(fValue) );
+ rGroupValue = rInfo.End + rInfo.Step;
+ return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
}
- String lcl_GetNumGroupForValue( double fValue, const ScDPNumGroupInfo& rInfo, bool bHasNonInteger,
- sal_Unicode cDecSeparator, double& rGroupValue, ScDocument* pDoc )
- {
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ double fDiff = fValue - rInfo.Start;
+ double fDiv = rtl::math::approxFloor( fDiff / rInfo.Step );
+ double fGroupStart = rInfo.Start + fDiv * rInfo.Step;
- if ( fValue < rInfo.Start && !rtl::math::approxEqual( fValue, rInfo.Start ) )
+ if ( rtl::math::approxEqual( fGroupStart, rInfo.End ) &&
+ !rtl::math::approxEqual( fGroupStart, rInfo.Start ) )
+ {
+ if ( !rInfo.DateValues )
{
- rGroupValue = rInfo.Start - rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.Start, true, cDecSeparator, rInfo.DateValues, pFormatter );
- }
+ // A group that would consist only of the end value is not created,
+ // instead the value is included in the last group before. So the
+ // previous group is used if the calculated group start value is the
+ // selected end value.
- if ( fValue > rInfo.End && !rtl::math::approxEqual( fValue, rInfo.End ) )
+ fDiv -= 1.0;
+ fGroupStart = rInfo.Start + fDiv * rInfo.Step;
+ }
+ else
{
+ // For date values, the end value is instead treated as above the limit
+ // if it would be a group of its own.
+
rGroupValue = rInfo.End + rInfo.Step;
return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
}
+ }
- double fDiff = fValue - rInfo.Start;
- double fDiv = rtl::math::approxFloor( fDiff / rInfo.Step );
- double fGroupStart = rInfo.Start + fDiv * rInfo.Step;
-
- if ( rtl::math::approxEqual( fGroupStart, rInfo.End ) &&
- !rtl::math::approxEqual( fGroupStart, rInfo.Start ) )
- {
- if ( !rInfo.DateValues )
- {
- // A group that would consist only of the end value is not created,
- // instead the value is included in the last group before. So the
- // previous group is used if the calculated group start value is the
- // selected end value.
-
- fDiv -= 1.0;
- fGroupStart = rInfo.Start + fDiv * rInfo.Step;
- }
- else
- {
- // For date values, the end value is instead treated as above the limit
- // if it would be a group of its own.
-
- rGroupValue = rInfo.End + rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
- }
- }
+ rGroupValue = fGroupStart;
- rGroupValue = fGroupStart;
+ return lcl_GetNumGroupName( fGroupStart, rInfo, bHasNonInteger, cDecSeparator, pFormatter );
+}
- return lcl_GetNumGroupName( fGroupStart, rInfo, bHasNonInteger, cDecSeparator, pFormatter );
- }
}
class ScDPGroupDateFilter : public ScDPCacheTable::FilterBase
commit 884b73e91e1019c39868c53a67fc24164e1cd51b
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Feb 28 14:37:26 2012 -0500
Simplified it a bit.
diff --git a/sc/inc/dpitemdata.hxx b/sc/inc/dpitemdata.hxx
index d2c8bf4..16ebcd7 100644
--- a/sc/inc/dpitemdata.hxx
+++ b/sc/inc/dpitemdata.hxx
@@ -72,7 +72,7 @@ public:
ScDPItemData(sal_uLong nNF, const rtl::OUString & rS, double fV, sal_uInt8 bF);
ScDPItemData(const rtl::OUString& rS, double fV = 0.0, bool bHV = false,
const sal_uLong nNumFormat = 0, bool bData = true);
- ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab, bool bLabel);
+ ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab);
void SetString(const rtl::OUString& rS);
bool IsCaseInsEqual(const ScDPItemData& r) const;
diff --git a/sc/source/core/data/dpitemdata.cxx b/sc/source/core/data/dpitemdata.cxx
index 37ad394..7a90038 100644
--- a/sc/source/core/data/dpitemdata.cxx
+++ b/sc/source/core/data/dpitemdata.cxx
@@ -51,7 +51,7 @@ ScDPItemData::ScDPItemData(const rtl::OUString& rS, double fV, bool bHV, const s
{
}
-ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab, bool bLabel) :
+ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocTab) :
mnNumFormat( 0 ), mfValue(0.0), mbFlag( 0 )
{
rtl::OUString aDocStr = pDoc->GetString(nCol, nRow, nDocTab);
@@ -78,22 +78,8 @@ ScDPItemData::ScDPItemData(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nDocT
mnNumFormat = pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) );
isDate( nFormat ) ? ( mbFlag |= MK_DATE ) : (mbFlag &= ~MK_DATE);
}
- else if (bLabel || pDoc->HasData(nCol, nRow, nDocTab))
+ else if (pDoc->HasData(nCol, nRow, nDocTab))
{
- if (bLabel && aDocStr.isEmpty())
- {
- // 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);
}
}
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index b25bdf3..82e4cbd 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -276,6 +276,25 @@ private:
ScDocument* mpDoc;
};
+rtl::OUString createLabelString(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
+{
+ rtl::OUString aDocStr = pDoc->GetString(nCol, nRow, nTab);
+ if (aDocStr.isEmpty())
+ {
+ // 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();
+ }
+ return aDocStr;
+}
+
}
bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
@@ -316,9 +335,9 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
for (sal_uInt16 nCol = nStartCol; nCol <= nEndCol; ++nCol)
{
- AddLabel(ScDPItemData(pDoc, nCol, nStartRow, nDocTab, true).GetString());
+ AddLabel(createLabelString(pDoc, nCol, nStartRow, nDocTab));
for (SCROW nRow = nStartRow + 1; nRow <= nEndRow; ++nRow)
- AddData(nCol - nStartCol, new ScDPItemData(pDoc, nCol, nRow, nDocTab, false));
+ AddData(nCol - nStartCol, new ScDPItemData(pDoc, nCol, nRow, nDocTab));
}
return true;
}
commit daf87ab18a43999b6e1a133806d8f99cd0fbc314
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Feb 28 14:13:16 2012 -0500
AddLabel to take string as its argument.
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index 95d4d89..35ef47e 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -141,7 +141,7 @@ public:
~ScDPCache();
private:
- void AddLabel( ScDPItemData* pData);
+ void AddLabel(const rtl::OUString& rLabel);
bool AddData(long nDim, ScDPItemData* pData);
};
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 35936d9..b25bdf3 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -316,7 +316,7 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
for (sal_uInt16 nCol = nStartCol; nCol <= nEndCol; ++nCol)
{
- AddLabel(new ScDPItemData(pDoc, nCol, nStartRow, nDocTab, true));
+ AddLabel(ScDPItemData(pDoc, nCol, nStartRow, nDocTab, true).GetString());
for (SCROW nRow = nStartRow + 1; nRow <= nEndRow; ++nRow)
AddData(nCol - nStartCol, new ScDPItemData(pDoc, nCol, nRow, nDocTab, false));
}
@@ -363,9 +363,9 @@ bool ScDPCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowSet, const
for (sal_Int32 nCol = 0; nCol < mnColumnCount; ++nCol)
{
- String aColTitle = xMeta->getColumnLabel(nCol+1);
+ rtl::OUString aColTitle = xMeta->getColumnLabel(nCol+1);
aColTypes[nCol] = xMeta->getColumnType(nCol+1);
- AddLabel( new ScDPItemData( aColTitle) );
+ AddLabel(aColTitle);
}
// Now get the data rows.
@@ -653,9 +653,8 @@ public:
}
-void ScDPCache::AddLabel(ScDPItemData *pData)
+void ScDPCache::AddLabel(const rtl::OUString& rLabel)
{
- std::auto_ptr<ScDPItemData> p(pData);
OSL_ENSURE( IsValid(), " IsValid() == false " );
if ( maLabelNames.empty() )
@@ -665,7 +664,7 @@ void ScDPCache::AddLabel(ScDPItemData *pData)
LabelSet aExistingNames;
std::for_each(maLabelNames.begin(), maLabelNames.end(), InsertLabel(aExistingNames));
sal_Int32 nSuffix = 1;
- rtl::OUString aNewName = p->GetString();
+ rtl::OUString aNewName = rLabel;
while (true)
{
if (!aExistingNames.count(aNewName))
@@ -676,7 +675,7 @@ void ScDPCache::AddLabel(ScDPItemData *pData)
}
// Name already exists.
- rtl::OUStringBuffer aBuf(p->GetString());
+ rtl::OUStringBuffer aBuf(rLabel);
aBuf.append(++nSuffix);
aNewName = aBuf.makeStringAndClear();
}
commit 94b7deccb683fc407a90c3bb1f580ca47debaf33
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Feb 28 14:07:38 2012 -0500
We only use the string part. Let's make it more obvious.
Plus this will save some memory footprint.
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index 838499b..95d4d89 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -57,6 +57,7 @@ class SC_DLLPUBLIC ScDPCache : boost::noncopyable
public:
typedef ::boost::ptr_vector<ScDPItemData> DataListType;
typedef std::set<ScDPObject*> ObjectSetType;
+ typedef std::vector<rtl::OUString> LabelsType;
private:
typedef ::boost::ptr_vector<DataListType> DataGridType;
typedef ::boost::ptr_vector< ::std::vector<SCROW> > RowGridType;
@@ -94,7 +95,7 @@ private:
*/
mutable RowGridType maIndexOrder;
- DataListType maLabelNames; // Stores dimension names.
+ LabelsType maLabelNames; // Stores dimension names.
std::vector<bool> mbEmptyRow; // Keeps track of empty rows.
boost::scoped_ptr<ScDPItemDataPool> mpAdditionalData;
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index b54322e..35936d9 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -630,7 +630,7 @@ rtl::OUString ScDPCache::GetDimensionName( sal_uInt16 nColumn ) const
if ( static_cast<size_t>(nColumn+1) < maLabelNames.size() )
{
- return maLabelNames[nColumn+1].maString;
+ return maLabelNames[nColumn+1];
}
else
return rtl::OUString();
@@ -655,28 +655,28 @@ public:
void ScDPCache::AddLabel(ScDPItemData *pData)
{
+ std::auto_ptr<ScDPItemData> p(pData);
OSL_ENSURE( IsValid(), " IsValid() == false " );
if ( maLabelNames.empty() )
- maLabelNames.push_back( new ScDPItemData(ScGlobal::GetRscString(STR_PIVOT_DATA)) );
+ maLabelNames.push_back(ScGlobal::GetRscString(STR_PIVOT_DATA));
//reset name if needed
LabelSet aExistingNames;
std::for_each(maLabelNames.begin(), maLabelNames.end(), InsertLabel(aExistingNames));
sal_Int32 nSuffix = 1;
- rtl::OUString aNewName = pData->GetString();
+ rtl::OUString aNewName = p->GetString();
while (true)
{
if (!aExistingNames.count(aNewName))
{
// unique name found!
- pData->maString = aNewName;
- maLabelNames.push_back(pData);
+ maLabelNames.push_back(aNewName);
return;
}
// Name already exists.
- rtl::OUStringBuffer aBuf(pData->GetString());
+ rtl::OUStringBuffer aBuf(p->GetString());
aBuf.append(++nSuffix);
aNewName = aBuf.makeStringAndClear();
}
@@ -777,7 +777,7 @@ SCCOL ScDPCache::GetDimensionIndex(const rtl::OUString& sName) const
{
for (size_t i = 1; i < maLabelNames.size(); ++i)
{
- if (maLabelNames[i].GetString().equals(sName))
+ if (maLabelNames[i].equals(sName))
return (SCCOL)(i-1);
}
return -1;
commit 2c0c947a99f0c9e96e64a5d95ea31329eb0b1eee
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Feb 28 13:50:25 2012 -0500
Using hash set for this would be more appropriate.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 69f1bfa..b54322e 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -636,6 +636,23 @@ rtl::OUString ScDPCache::GetDimensionName( sal_uInt16 nColumn ) const
return rtl::OUString();
}
+namespace {
+
+typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> LabelSet;
+
+class InsertLabel : public std::unary_function<ScDPItemData, void>
+{
+ LabelSet& mrNames;
+public:
+ InsertLabel(LabelSet& rNames) : mrNames(rNames) {}
+ void operator() (const ScDPItemData& r)
+ {
+ mrNames.insert(r.GetString());
+ }
+};
+
+}
+
void ScDPCache::AddLabel(ScDPItemData *pData)
{
OSL_ENSURE( IsValid(), " IsValid() == false " );
@@ -644,26 +661,25 @@ void ScDPCache::AddLabel(ScDPItemData *pData)
maLabelNames.push_back( new ScDPItemData(ScGlobal::GetRscString(STR_PIVOT_DATA)) );
//reset name if needed
- String strNewName = pData->maString;
- bool bFound = false;
- long nIndex = 1;
- do
+ LabelSet aExistingNames;
+ std::for_each(maLabelNames.begin(), maLabelNames.end(), InsertLabel(aExistingNames));
+ sal_Int32 nSuffix = 1;
+ rtl::OUString aNewName = pData->GetString();
+ while (true)
{
- for ( long i= maLabelNames.size()-1; i>=0; i-- )
+ if (!aExistingNames.count(aNewName))
{
- if (maLabelNames[i].maString.equals(strNewName))
- {
- strNewName = pData->maString;
- strNewName += String::CreateFromInt32( ++nIndex );
- bFound = true;
- }
+ // unique name found!
+ pData->maString = aNewName;
+ maLabelNames.push_back(pData);
+ return;
}
- bFound = !bFound;
- }
- while ( !bFound );
- pData->maString = strNewName;
- maLabelNames.push_back( pData );
+ // Name already exists.
+ rtl::OUStringBuffer aBuf(pData->GetString());
+ aBuf.append(++nSuffix);
+ aNewName = aBuf.makeStringAndClear();
+ }
}
SCROW ScDPCache::GetItemDataId(sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty) const
More information about the Libreoffice-commits
mailing list