Resolves: tdf#91365 use underlying numeric value if available [API CHANGE]
... at least for setting the cell content. There are more places where
the numeric value could be transported but all Data Pilot pivot stuff is
based on text strings :-/
This appends a double Value member to com::sun:⭐:sheet::MemberResult
Change-Id: Ia9e8ac47d0877bd4a59a69d5921ce4ea082e8a69
This commit is contained in:
@@ -46,6 +46,15 @@ struct MemberResult
|
||||
*/
|
||||
long Flags;
|
||||
|
||||
|
||||
/** the underlying numeric value of the field <b>if</b> Flags
|
||||
indicate so by having
|
||||
com::sun::star::sheet::MemberResultFlags::NUMERIC set.
|
||||
|
||||
May be NaN if value is not available or unknown.
|
||||
*/
|
||||
double Value;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -83,13 +83,17 @@ struct ScDPOutLevelData
|
||||
uno::Sequence<sheet::MemberResult> aResult;
|
||||
OUString maName; /// Name is the internal field name.
|
||||
OUString maCaption; /// Caption is the name visible in the output table.
|
||||
double mfValue; /// Value is the underlying numeric value, if any, or NaN
|
||||
bool mbHasHiddenMember:1;
|
||||
bool mbDataLayout:1;
|
||||
bool mbPageDim:1;
|
||||
|
||||
ScDPOutLevelData() :
|
||||
nDim(-1), nHier(-1), nLevel(-1), nDimPos(-1), mnSrcNumFmt(0), mbHasHiddenMember(false), mbDataLayout(false), mbPageDim(false)
|
||||
{}
|
||||
nDim(-1), nHier(-1), nLevel(-1), nDimPos(-1), mnSrcNumFmt(0), mbHasHiddenMember(false), mbDataLayout(false),
|
||||
mbPageDim(false)
|
||||
{
|
||||
rtl::math::setNan(&mfValue);
|
||||
}
|
||||
|
||||
bool operator<(const ScDPOutLevelData& r) const
|
||||
{ return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) ||
|
||||
@@ -493,7 +497,12 @@ uno::Sequence<sheet::MemberResult> getVisiblePageMembersAsResults( const uno::Re
|
||||
bool bVisible = ScUnoHelpFunctions::GetBoolProperty(xMemPS, SC_UNO_DP_ISVISIBLE);
|
||||
|
||||
if (bVisible)
|
||||
aRes.push_back(sheet::MemberResult(rName, aCaption, 0));
|
||||
{
|
||||
/* TODO: any numeric value to obtain? */
|
||||
double fValue;
|
||||
rtl::math::setNan(&fValue);
|
||||
aRes.push_back(sheet::MemberResult(rName, aCaption, 0, fValue));
|
||||
}
|
||||
}
|
||||
|
||||
if (aNames.getLength() == static_cast<sal_Int32>(aRes.size()))
|
||||
@@ -601,6 +610,10 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
|
||||
OUString aCaption = ScUnoHelpFunctions::GetStringProperty( xPropSet,
|
||||
SC_UNO_DP_LAYOUTNAME, aName );
|
||||
|
||||
/* TODO: any numeric value to obtain? */
|
||||
double fValue;
|
||||
rtl::math::setNan(&fValue);
|
||||
|
||||
bool bRowFieldHasMember = false;
|
||||
switch ( eDimOrient )
|
||||
{
|
||||
@@ -613,6 +626,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
|
||||
pColFields[nColFieldCount].mnSrcNumFmt = nNumFmt;
|
||||
pColFields[nColFieldCount].maName = aName;
|
||||
pColFields[nColFieldCount].maCaption= aCaption;
|
||||
pColFields[nColFieldCount].mfValue = fValue;
|
||||
pColFields[nColFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
||||
pColFields[nColFieldCount].mbDataLayout = bIsDataLayout;
|
||||
if (!lcl_MemberEmpty(pColFields[nColFieldCount].aResult))
|
||||
@@ -627,6 +641,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
|
||||
pRowFields[nRowFieldCount].mnSrcNumFmt = nNumFmt;
|
||||
pRowFields[nRowFieldCount].maName = aName;
|
||||
pRowFields[nRowFieldCount].maCaption= aCaption;
|
||||
pRowFields[nRowFieldCount].mfValue = fValue;
|
||||
pRowFields[nRowFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
||||
pRowFields[nRowFieldCount].mbDataLayout = bIsDataLayout;
|
||||
if (!lcl_MemberEmpty(pRowFields[nRowFieldCount].aResult))
|
||||
@@ -644,6 +659,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
|
||||
pPageFields[nPageFieldCount].mnSrcNumFmt = nNumFmt;
|
||||
pPageFields[nPageFieldCount].maName = aName;
|
||||
pPageFields[nPageFieldCount].maCaption= aCaption;
|
||||
pPageFields[nPageFieldCount].mfValue = fValue;
|
||||
pPageFields[nPageFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
||||
pPageFields[nPageFieldCount].mbPageDim = true;
|
||||
// no check on results for page fields
|
||||
@@ -790,6 +806,12 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
if ( nFlags & sheet::MemberResultFlags::HASMEMBER )
|
||||
{
|
||||
bool bNumeric = (nFlags & sheet::MemberResultFlags::NUMERIC) != 0;
|
||||
if (bNumeric && rtl::math::isFinite( rData.Value))
|
||||
{
|
||||
pDoc->SetValue( nCol, nRow, nTab, rData.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScSetStringParam aParam;
|
||||
if (bNumeric)
|
||||
aParam.setNumericInput();
|
||||
@@ -798,6 +820,7 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
|
||||
pDoc->SetString(nCol, nRow, nTab, rData.Caption, &aParam);
|
||||
}
|
||||
}
|
||||
|
||||
if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
|
||||
{
|
||||
|
@@ -1313,6 +1313,8 @@ void ScDPResultMember::FillMemberResults(
|
||||
OSL_ENSURE( rPos+nSize <= pSequences->getLength(), "bumm" );
|
||||
|
||||
bool bIsNumeric = false;
|
||||
double fValue;
|
||||
rtl::math::setNan(&fValue);
|
||||
OUString aName;
|
||||
if ( pMemberName ) // if pMemberName != NULL, use instead of real member name
|
||||
{
|
||||
@@ -1338,6 +1340,11 @@ void ScDPResultMember::FillMemberResults(
|
||||
|
||||
ScDPItemData::Type eType = aItemData.GetType();
|
||||
bIsNumeric = eType == ScDPItemData::Value || eType == ScDPItemData::GroupValue;
|
||||
// IsValue() is not identical to bIsNumeric, i.e.
|
||||
// ScDPItemData::GroupValue is excluded and not stored in the double,
|
||||
// so even if the item is numeric the Value may be NaN.
|
||||
if (aItemData.IsValue())
|
||||
fValue = aItemData.GetValue();
|
||||
}
|
||||
|
||||
const ScDPDimension* pParentDim = GetParentDim();
|
||||
@@ -1376,6 +1383,7 @@ void ScDPResultMember::FillMemberResults(
|
||||
pArray[rPos].Name = aName;
|
||||
pArray[rPos].Caption = aCaption;
|
||||
pArray[rPos].Flags |= sheet::MemberResultFlags::HASMEMBER;
|
||||
pArray[rPos].Value = fValue;
|
||||
|
||||
// set "continue" flag (removed for subtotals later)
|
||||
for (long i=1; i<nSize; i++)
|
||||
@@ -1390,6 +1398,7 @@ void ScDPResultMember::FillMemberResults(
|
||||
pArray[rPos+i].Name = aName;
|
||||
pArray[rPos+i].Caption = aCaption;
|
||||
pArray[rPos+i].Flags |= sheet::MemberResultFlags::HASMEMBER;
|
||||
pArray[rPos+i].Value = fValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1467,11 +1476,13 @@ void ScDPResultMember::FillMemberResults(
|
||||
}
|
||||
}
|
||||
|
||||
rtl::math::setNan(&fValue); /* TODO: any numeric value to obtain? */
|
||||
pArray[rPos].Name = aName;
|
||||
pArray[rPos].Caption = aSubStr;
|
||||
pArray[rPos].Flags = ( pArray[rPos].Flags |
|
||||
( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
|
||||
~sheet::MemberResultFlags::CONTINUE;
|
||||
pArray[rPos].Value = fValue;
|
||||
|
||||
if ( nMeasure == SC_DPMEASURE_ALL )
|
||||
{
|
||||
|
Reference in New Issue
Block a user