summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-06-17 13:31:48 +0200
committerEike Rathke <erack@redhat.com>2016-06-17 13:38:40 +0200
commitdc6bf6c8ae94fd89f30e39d63dfe02fdb042e98d (patch)
treeeb8300b048767ed8070918c6d008d4b5186b6d43
parent011128aa9493a680c3e9da6d074f125a90ec455c (diff)
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::star::sheet::MemberResult Change-Id: Ia9e8ac47d0877bd4a59a69d5921ce4ea082e8a69
-rw-r--r--offapi/com/sun/star/sheet/MemberResult.idl9
-rw-r--r--sc/source/core/data/dpoutput.cxx43
-rw-r--r--sc/source/core/data/dptabres.cxx11
3 files changed, 53 insertions, 10 deletions
diff --git a/offapi/com/sun/star/sheet/MemberResult.idl b/offapi/com/sun/star/sheet/MemberResult.idl
index 8cb4c2247702..7de14f3169c3 100644
--- a/offapi/com/sun/star/sheet/MemberResult.idl
+++ b/offapi/com/sun/star/sheet/MemberResult.idl
@@ -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;
+
};
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 6b32a8478202..5d4550df61e2 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -81,15 +81,19 @@ struct ScDPOutLevelData
long nDimPos;
sal_uInt32 mnSrcNumFmt; /// Prevailing number format used in the source data.
uno::Sequence<sheet::MemberResult> aResult;
- OUString maName; /// Name is the internal field name.
- OUString maCaption; /// Caption is the name visible in the output table.
+ 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,13 +806,20 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
if ( nFlags & sheet::MemberResultFlags::HASMEMBER )
{
bool bNumeric = (nFlags & sheet::MemberResultFlags::NUMERIC) != 0;
- ScSetStringParam aParam;
- if (bNumeric)
- aParam.setNumericInput();
+ if (bNumeric && rtl::math::isFinite( rData.Value))
+ {
+ pDoc->SetValue( nCol, nRow, nTab, rData.Value);
+ }
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 )
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index af5ad122efd8..12a40ccef9a7 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -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 )
{