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;
|
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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -81,15 +81,19 @@ struct ScDPOutLevelData
|
|||||||
long nDimPos;
|
long nDimPos;
|
||||||
sal_uInt32 mnSrcNumFmt; /// Prevailing number format used in the source data.
|
sal_uInt32 mnSrcNumFmt; /// Prevailing number format used in the source data.
|
||||||
uno::Sequence<sheet::MemberResult> aResult;
|
uno::Sequence<sheet::MemberResult> aResult;
|
||||||
OUString maName; /// Name is the internal field name.
|
OUString maName; /// Name is the internal field name.
|
||||||
OUString maCaption; /// Caption is the name visible in the output table.
|
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 mbHasHiddenMember:1;
|
||||||
bool mbDataLayout:1;
|
bool mbDataLayout:1;
|
||||||
bool mbPageDim:1;
|
bool mbPageDim:1;
|
||||||
|
|
||||||
ScDPOutLevelData() :
|
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
|
bool operator<(const ScDPOutLevelData& r) const
|
||||||
{ return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) ||
|
{ 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);
|
bool bVisible = ScUnoHelpFunctions::GetBoolProperty(xMemPS, SC_UNO_DP_ISVISIBLE);
|
||||||
|
|
||||||
if (bVisible)
|
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()))
|
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,
|
OUString aCaption = ScUnoHelpFunctions::GetStringProperty( xPropSet,
|
||||||
SC_UNO_DP_LAYOUTNAME, aName );
|
SC_UNO_DP_LAYOUTNAME, aName );
|
||||||
|
|
||||||
|
/* TODO: any numeric value to obtain? */
|
||||||
|
double fValue;
|
||||||
|
rtl::math::setNan(&fValue);
|
||||||
|
|
||||||
bool bRowFieldHasMember = false;
|
bool bRowFieldHasMember = false;
|
||||||
switch ( eDimOrient )
|
switch ( eDimOrient )
|
||||||
{
|
{
|
||||||
@@ -613,6 +626,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
|
|||||||
pColFields[nColFieldCount].mnSrcNumFmt = nNumFmt;
|
pColFields[nColFieldCount].mnSrcNumFmt = nNumFmt;
|
||||||
pColFields[nColFieldCount].maName = aName;
|
pColFields[nColFieldCount].maName = aName;
|
||||||
pColFields[nColFieldCount].maCaption= aCaption;
|
pColFields[nColFieldCount].maCaption= aCaption;
|
||||||
|
pColFields[nColFieldCount].mfValue = fValue;
|
||||||
pColFields[nColFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
pColFields[nColFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
||||||
pColFields[nColFieldCount].mbDataLayout = bIsDataLayout;
|
pColFields[nColFieldCount].mbDataLayout = bIsDataLayout;
|
||||||
if (!lcl_MemberEmpty(pColFields[nColFieldCount].aResult))
|
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].mnSrcNumFmt = nNumFmt;
|
||||||
pRowFields[nRowFieldCount].maName = aName;
|
pRowFields[nRowFieldCount].maName = aName;
|
||||||
pRowFields[nRowFieldCount].maCaption= aCaption;
|
pRowFields[nRowFieldCount].maCaption= aCaption;
|
||||||
|
pRowFields[nRowFieldCount].mfValue = fValue;
|
||||||
pRowFields[nRowFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
pRowFields[nRowFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
||||||
pRowFields[nRowFieldCount].mbDataLayout = bIsDataLayout;
|
pRowFields[nRowFieldCount].mbDataLayout = bIsDataLayout;
|
||||||
if (!lcl_MemberEmpty(pRowFields[nRowFieldCount].aResult))
|
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].mnSrcNumFmt = nNumFmt;
|
||||||
pPageFields[nPageFieldCount].maName = aName;
|
pPageFields[nPageFieldCount].maName = aName;
|
||||||
pPageFields[nPageFieldCount].maCaption= aCaption;
|
pPageFields[nPageFieldCount].maCaption= aCaption;
|
||||||
|
pPageFields[nPageFieldCount].mfValue = fValue;
|
||||||
pPageFields[nPageFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
pPageFields[nPageFieldCount].mbHasHiddenMember = bHasHiddenMember;
|
||||||
pPageFields[nPageFieldCount].mbPageDim = true;
|
pPageFields[nPageFieldCount].mbPageDim = true;
|
||||||
// no check on results for page fields
|
// no check on results for page fields
|
||||||
@@ -790,13 +806,20 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
|
|||||||
if ( nFlags & sheet::MemberResultFlags::HASMEMBER )
|
if ( nFlags & sheet::MemberResultFlags::HASMEMBER )
|
||||||
{
|
{
|
||||||
bool bNumeric = (nFlags & sheet::MemberResultFlags::NUMERIC) != 0;
|
bool bNumeric = (nFlags & sheet::MemberResultFlags::NUMERIC) != 0;
|
||||||
ScSetStringParam aParam;
|
if (bNumeric && rtl::math::isFinite( rData.Value))
|
||||||
if (bNumeric)
|
{
|
||||||
aParam.setNumericInput();
|
pDoc->SetValue( nCol, nRow, nTab, rData.Value);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
aParam.setTextInput();
|
{
|
||||||
|
ScSetStringParam aParam;
|
||||||
|
if (bNumeric)
|
||||||
|
aParam.setNumericInput();
|
||||||
|
else
|
||||||
|
aParam.setTextInput();
|
||||||
|
|
||||||
pDoc->SetString(nCol, nRow, nTab, rData.Caption, &aParam);
|
pDoc->SetString(nCol, nRow, nTab, rData.Caption, &aParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
|
if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
|
||||||
|
@@ -1313,6 +1313,8 @@ void ScDPResultMember::FillMemberResults(
|
|||||||
OSL_ENSURE( rPos+nSize <= pSequences->getLength(), "bumm" );
|
OSL_ENSURE( rPos+nSize <= pSequences->getLength(), "bumm" );
|
||||||
|
|
||||||
bool bIsNumeric = false;
|
bool bIsNumeric = false;
|
||||||
|
double fValue;
|
||||||
|
rtl::math::setNan(&fValue);
|
||||||
OUString aName;
|
OUString aName;
|
||||||
if ( pMemberName ) // if pMemberName != NULL, use instead of real member name
|
if ( pMemberName ) // if pMemberName != NULL, use instead of real member name
|
||||||
{
|
{
|
||||||
@@ -1338,6 +1340,11 @@ void ScDPResultMember::FillMemberResults(
|
|||||||
|
|
||||||
ScDPItemData::Type eType = aItemData.GetType();
|
ScDPItemData::Type eType = aItemData.GetType();
|
||||||
bIsNumeric = eType == ScDPItemData::Value || eType == ScDPItemData::GroupValue;
|
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();
|
const ScDPDimension* pParentDim = GetParentDim();
|
||||||
@@ -1376,6 +1383,7 @@ void ScDPResultMember::FillMemberResults(
|
|||||||
pArray[rPos].Name = aName;
|
pArray[rPos].Name = aName;
|
||||||
pArray[rPos].Caption = aCaption;
|
pArray[rPos].Caption = aCaption;
|
||||||
pArray[rPos].Flags |= sheet::MemberResultFlags::HASMEMBER;
|
pArray[rPos].Flags |= sheet::MemberResultFlags::HASMEMBER;
|
||||||
|
pArray[rPos].Value = fValue;
|
||||||
|
|
||||||
// set "continue" flag (removed for subtotals later)
|
// set "continue" flag (removed for subtotals later)
|
||||||
for (long i=1; i<nSize; i++)
|
for (long i=1; i<nSize; i++)
|
||||||
@@ -1390,6 +1398,7 @@ void ScDPResultMember::FillMemberResults(
|
|||||||
pArray[rPos+i].Name = aName;
|
pArray[rPos+i].Name = aName;
|
||||||
pArray[rPos+i].Caption = aCaption;
|
pArray[rPos+i].Caption = aCaption;
|
||||||
pArray[rPos+i].Flags |= sheet::MemberResultFlags::HASMEMBER;
|
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].Name = aName;
|
||||||
pArray[rPos].Caption = aSubStr;
|
pArray[rPos].Caption = aSubStr;
|
||||||
pArray[rPos].Flags = ( pArray[rPos].Flags |
|
pArray[rPos].Flags = ( pArray[rPos].Flags |
|
||||||
( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
|
( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
|
||||||
~sheet::MemberResultFlags::CONTINUE;
|
~sheet::MemberResultFlags::CONTINUE;
|
||||||
|
pArray[rPos].Value = fValue;
|
||||||
|
|
||||||
if ( nMeasure == SC_DPMEASURE_ALL )
|
if ( nMeasure == SC_DPMEASURE_ALL )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user