26 #include <globstr.hrc>
31 #include <document.hxx>
36 #include <osl/diagnose.h>
37 #include <rtl/math.hxx>
44 #include <unordered_map>
46 #include <com/sun/star/sheet/DataResultFlags.hpp>
47 #include <com/sun/star/sheet/MemberResultFlags.hpp>
48 #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
49 #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
50 #include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
51 #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
52 #include <com/sun/star/sheet/GeneralFunction2.hpp>
57 using ::com::sun::star::uno::Sequence;
61 const char* aFuncStrIds[] =
79 bool lcl_SearchMember(
const std::vector<std::unique_ptr<ScDPResultMember>>&
list,
SCROW nOrder,
SCROW& rIndex)
87 nIndex = (nLo + nHi) / 2;
88 if (
list[nIndex]->GetOrder() < nOrder )
93 if (
list[nIndex]->GetOrder() == nOrder )
106 std::vector<ScDPResultFilter>& mrFilters;
108 explicit FilterStack(std::vector<ScDPResultFilter>& rFilters) : mrFilters(rFilters) {}
110 void pushDimName(
const OUString& rName,
bool bDataLayout)
112 mrFilters.emplace_back(rName, bDataLayout);
115 void pushDimValue(
const OUString& rValueName,
const OUString& rValue)
129 mrFilters.pop_back();
135 class ScDPRowMembersOrder
148 bool operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const;
151 class ScDPColMembersOrder
164 bool operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const;
177 bool bError1 = pAgg1 && pAgg1->
HasError();
178 bool bError2 = pAgg2 && pAgg2->
HasError();
191 return bAscending ? ( fVal1 < fVal2 ) : ( fVal1 > fVal2 );
203 bool bError1 = pAgg1 && pAgg1->
HasError();
204 bool bError2 = pAgg2 && pAgg2->
HasError();
222 return rtl::math::approxEqual( fVal1, fVal2 );
226 bool ScDPRowMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const
238 return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending );
241 bool ScDPColMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const
243 const ScDPDataMember* pDataMember1 = rDimension.GetMember(nIndex1);
244 const ScDPDataMember* pDataMember2 = rDimension.GetMember(nIndex2);
245 bool bHide1 = pDataMember1 && !pDataMember1->
IsVisible();
246 bool bHide2 = pDataMember2 && !pDataMember2->
IsVisible();
247 if ( bHide1 || bHide2 )
249 return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending );
253 mnSrcIndex(nSrcIndex), mnNameIndex(nNameIndex) {}
257 maMembers.emplace_back(nSourceIndex, nMember);
262 OSL_ENSURE(!
maMembers.empty(),
"ScDPInitState::RemoveMember: Attempt to remove member while empty.");
271 const OUString& rType,
const OUString& rName,
const ScDPAggData* pAggData,
277 pDoc->
SetString( nCol++, nRow, nTab, rType );
278 pDoc->
SetString( nCol++, nRow, nTab, rName );
293 for (
SCROW nRow = nStartRow; nRow < rPos.
Row(); nRow++)
295 aString = pDoc->
GetString(nCol, nRow, nTab);
296 if (!aString.isEmpty())
298 aString =
" " + aString;
299 pDoc->
SetString( nCol, nRow, nTab, aString );
308 pColResRoot(pColRoot), pRowResRoot(pRowRoot)
337 OSL_ENSURE(!
maColVisible.empty() && !
maColSorted.empty(),
"ScDPRunningTotalState::RemoveColIndex: array is already empty!");
353 OSL_ENSURE(!
maRowVisible.empty() && !
maRowSorted.empty(),
"ScDPRunningTotalState::RemoveRowIndex: array is already empty!");
444 OSL_FAIL(
"invalid function");
498 OSL_FAIL(
"invalid function");
503 double fResult = 0.0;
533 fResult = sqrt( fResult);
547 fResult = sqrt( fResult);
560 if ((nSize % 2) == 1)
568 OSL_FAIL(
"invalid function");
572 bool bEmpty = (
nCount == 0 );
587 if ( bEmpty || bError )
679 std::string aIndent(nIndent*2,
' ');
680 std::cout << aIndent <<
"* ";
684 std::cout <<
"not calculated";
686 std::cout <<
" [val=" <<
fVal <<
"; aux=" <<
fAux <<
"; count=" <<
nCount <<
"]" << std::endl;
691 bIsInColRoot( false )
701 OSL_ENSURE( nMeasure >= 0,
"GetColTotal: no measure" );
740 if ( nSequence && aSeq[0] != sheet::GeneralFunction2::AUTO )
749 if ( nFuncNo >= 0 && nFuncNo < nSequence )
772 std::vector<ScSubTotalFunc>& rFunctions, std::vector<sheet::DataPilotFieldReference>& rRefs,
773 std::vector<sheet::DataPilotFieldOrientation>& rRefOrient, std::vector<OUString>& rNames )
796 bDataAtCol = ( nOrient == sheet::DataPilotFieldOrientation_COLUMN );
797 bDataAtRow = ( nOrient == sheet::DataPilotFieldOrientation_ROW );
843 rbTotalResult =
false;
850 return ScResId(aFuncStrIds[eForceFunc]);
852 rbTotalResult =
true;
853 return ScResId(STR_TABLE_ERGEBNIS);
861 const std::optional<OUString> & pLayoutName = pDataDim->
GetLayoutName();
877 OSL_FAIL(
"GetMeasureDimensionName: negative");
924 if (nDim >= static_cast<tools::Long>(
maDimMembers.size()))
927 std::unique_ptr<ResultMembers> pResultMembers(
new ResultMembers());
935 tools::Long nSorted = rGlobalOrder.empty() ?
i : rGlobalOrder[
i];
940 pResultMembers->InsertMember(aNew);
950 pResultData( pData ),
951 aParentDimData( rParentDimData ),
952 bHasElements( false ),
953 bForceSubTotal( false ),
954 bHasHiddenDetails( false ),
955 bInitialized( false ),
956 bAutoHidden( false ),
964 pResultData( pData ),
965 bHasElements( false ),
966 bForceSubTotal( bForceSub ),
967 bHasHiddenDetails( false ),
968 bInitialized( false ),
969 bAutoHidden( false ),
983 return ScResId(STR_PIVOT_TOTAL);
999 return aItem.GetString();
1027 if (aMembers.size() < 2)
1030 vector<SCROW>::const_iterator itr = aMembers.begin();
1031 vector<SCROW> aChildMembers(++itr, aMembers.end());
1048 if (nPos >= ppDim.size())
1056 while ( nPos < ppDim.size() )
1058 if ( ppDim[nPos]->getIsDataLayoutDimension() )
1091 if ( rParams.
IsEnd( nPos ) )
1100 while ( !rParams.
IsEnd( nPos ) )
1111 pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState );
1130 pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState );
1142 nSubTotals -= nUserSubStart;
1149 if ( nSubTotals == 1 )
1162 if ( pParentLevel && pParentLevel->
IsAddEmpty() )
1174 nUserSubCount -= nUserSubStart;
1175 if ( nUserSubCount )
1180 nSize += nUserSubCount;
1182 return nSize + nExtraSpace;
1189 return 1 + nExtraSpace;
1217 if ( pMemberDesc && !pMemberDesc->
isVisible() )
1228 if ( pUserSubStart )
1235 else if ( pParentLevel )
1241 if ( nSequence && aSeq[0] != sheet::GeneralFunction2::AUTO )
1247 if ( pUserSubStart )
1257 const vector< SCROW >& aDataMembers,
const vector<ScDPValue>& aValues )
1262 pChildDimension->ProcessData( aChildMembers, pDataDim, aDataMembers, aValues );
1282 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
1291 pDataRoot->ProcessData( aDataMembers, aValues, aSubState );
1301 OUStringBuffer aNewStr;
1302 sal_Int32
n = rSubStr.getLength();
1303 bool bEscaped =
false;
1304 for (sal_Int32
i = 0;
i < n; ++
i)
1307 if (!bEscaped && c ==
'\\')
1313 if (!bEscaped && c ==
'?')
1314 aNewStr.append(rCaption);
1319 return aNewStr.makeStringAndClear();
1324 const OUString* pMemberName,
const OUString* pMemberCaption )
1329 if (!pSequences->hasElements())
1334 sheet::MemberResult* pArray = pSequences->getArray();
1335 OSL_ENSURE( rPos+nSize <= pSequences->
getLength(),
"bumm" );
1337 bool bIsNumeric =
false;
1339 rtl::math::setNan(&fValue);
1343 aName = *pMemberName;
1379 OUString aCaption = aName;
1383 const std::optional<OUString> & pLayoutName = pMemberDesc->
GetLayoutName();
1386 aCaption = *pLayoutName;
1391 if ( pMemberCaption )
1392 aCaption = *pMemberCaption;
1393 if (aCaption.isEmpty())
1394 aCaption =
ScResId(STR_EMPTYDATA);
1397 pArray[rPos].Flags |= sheet::MemberResultFlags::NUMERIC;
1399 pArray[rPos].Flags &= ~
sheet::MemberResultFlags::NUMERIC;
1402 if ( nSize && !bRoot )
1404 pArray[rPos].Name = aName;
1405 pArray[rPos].Caption = aCaption;
1406 pArray[rPos].Flags |= sheet::MemberResultFlags::HASMEMBER;
1407 pArray[rPos].Value = fValue;
1411 pArray[rPos+
i].
Flags |= sheet::MemberResultFlags::CONTINUE;
1419 pArray[rPos+
i].Name = aName;
1420 pArray[rPos+
i].Caption = aCaption;
1421 pArray[rPos+
i].Flags |= sheet::MemberResultFlags::HASMEMBER;
1422 pArray[rPos+
i].Value = fValue;
1428 if ( pParentLevel && pParentLevel->
IsAddEmpty() )
1431 bool bTitleLine =
false;
1464 rPos -= nSubSize * (nUserSubCount - nUserSubStart);
1465 rPos -= nExtraSpace;
1467 for (
tools::Long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
1469 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
1472 nMemberMeasure = nSubCount;
1478 bool bTotalResult =
false;
1486 const std::optional<OUString> & pSubtotalName = pParentDim->
GetSubtotalName();
1489 pArray[rPos].Flags &= ~
sheet::MemberResultFlags::GRANDTOTAL;
1495 if (pGrandTotalName)
1496 aSubStr = *pGrandTotalName;
1497 pArray[rPos].Flags |= sheet::MemberResultFlags::GRANDTOTAL;
1501 rtl::math::setNan(&fValue);
1502 pArray[rPos].Name = aName;
1503 pArray[rPos].Caption = aSubStr;
1504 pArray[rPos].Flags = ( pArray[rPos].Flags |
1505 ( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
1506 ~
sheet::MemberResultFlags::CONTINUE;
1507 pArray[rPos].Value = fValue;
1514 uno::Sequence<sheet::MemberResult>* pLayoutSeq = pSequences;
1525 sheet::MemberResult* pLayoutArray = pLayoutSeq->getArray();
1534 rPos += nExtraSpace;
1542 std::unique_ptr<FilterStack> pFilterStack;
1547 pFilterStack.reset(
new FilterStack(rFilterCxt.
maFilters));
1554 sal_Int32 nStartRow = rFilterCxt.
mnRow;
1557 if ( pParentLevel && pParentLevel->
IsAddEmpty() )
1560 bool bTitleLine =
false;
1572 sal_Int32 nOldRow = rFilterCxt.
mnRow;
1573 pChildDimension->FillDataResults(pRefMember, rFilterCxt, rSequence, nMeasure);
1574 rFilterCxt.
mnRow = nOldRow;
1584 if ( !nUserSubCount && bHasChild )
1589 if ( !nUserSubCount || !bHasChild )
1599 rFilterCxt.
mnRow -= nSubSize * ( nUserSubCount - nUserSubStart );
1600 rFilterCxt.
mnRow -= nExtraSpace;
1604 if ( bSubTotalInTitle )
1606 nMoveSubTotal = rFilterCxt.
mnRow - nStartRow;
1607 rFilterCxt.
mnRow = nStartRow;
1614 for (
tools::Long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
1616 if ( bHasChild && nUserSubCount > 1 )
1622 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
1625 nMemberMeasure = nSubCount;
1629 OSL_ENSURE( rFilterCxt.
mnRow < rSequence.getLength(),
"bumm" );
1630 rFilterCxt.
mnCol = 0;
1633 uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rFilterCxt.
mnRow];
1634 pDataRoot->FillDataRow(pRefMember, rFilterCxt, rSubSeq, nMemberMeasure, bHasChild, aSubState);
1636 rFilterCxt.
mnRow += 1;
1641 rFilterCxt.
mnRow += nSubSize * ( nUserSubCount - nUserSubStart );
1645 rFilterCxt.
mnRow += nExtraSpace;
1646 rFilterCxt.
mnRow += nMoveSubTotal;
1662 if (!nUserSubCount || !bHasChild)
1672 for (
tools::Long nUserPos = 0; nUserPos < nUserSubCount; ++nUserPos)
1674 if (bHasChild && nUserSubCount > 1)
1680 for (
tools::Long nSubCount = 0; nSubCount < nSubSize; ++nSubCount)
1683 nMemberMeasure = nSubCount;
1687 pDataRoot->UpdateDataRow(pRefMember, nMemberMeasure, bHasChild, aSubState);
1752 if ( !nUserSubCount || !bHasChild )
1762 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
1764 if ( bHasChild && nUserSubCount > 1 )
1770 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
1773 nMemberMeasure = nSubCount;
1779 pRefMember, nMemberMeasure, bHasChild, aSubState, rRunning, rTotals, *
this);
1787 pChildDimension->UpdateRunningTotals( pRefMember, nMeasure, rRunning, rTotals );
1791 #if DUMP_PIVOT_TABLE
1794 dumpRow(
"ScDPResultMember",
GetName(),
nullptr, pDoc, rPos);
1798 pDataRoot->DumpState( pRefMember, pDoc, rPos );
1803 indent(pDoc, nStartRow, rPos);
1808 std::string aIndent(nIndent*2,
' ');
1809 std::cout << aIndent <<
"-- result member '" <<
GetName() <<
"'" << std::endl;
1811 std::cout << aIndent <<
" column totals" << std::endl;
1820 std::cout << aIndent <<
" data root" << std::endl;
1838 pResultData( pData ),
1839 pResultMember( pRes )
1914 if (nSubPos == SC_SUBTOTALPOS_SKIP)
1923 size_t nCount = aValues.size();
1950 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
2001 OSL_ENSURE( nMeasure >= 0,
"GetAggData: no measure" );
2006 if (nSubPos == SC_SUBTOTALPOS_SKIP)
2019 OSL_ENSURE( nMeasure >= 0,
"GetConstAggData: no measure" );
2024 if (nSubPos == SC_SUBTOTALPOS_SKIP)
2041 uno::Sequence<sheet::DataResult>& rSequence,
tools::Long nMeasure,
bool bIsSubTotalRow,
2044 std::unique_ptr<FilterStack> pFilterStack;
2050 pFilterStack.reset(
new FilterStack(rFilterCxt.
maFilters));
2064 if ( pRefParentLevel && pRefParentLevel->
IsAddEmpty() )
2067 bool bTitleLine =
false;
2075 bool bHasChild = ( pRefChild != nullptr );
2085 pDataChild->
FillDataRow(pRefChild, rFilterCxt, rSequence, nMeasure, bIsSubTotalRow, rSubState);
2086 rFilterCxt.
mnCol = nOldCol;
2088 rFilterCxt.
mnCol +=
static_cast<sal_uInt16
>(pRefMember->
GetSize( nMeasure ));
2096 if ( !nUserSubCount && bHasChild )
2101 if ( !nUserSubCount || !bHasChild )
2113 rFilterCxt.
mnCol -= nSubSize * ( nUserSubCount - nUserSubStart );
2114 rFilterCxt.
mnCol -= nExtraSpace;
2118 if ( bSubTotalInTitle )
2120 nMoveSubTotal = rFilterCxt.
mnCol - nStartCol;
2121 rFilterCxt.
mnCol = nStartCol;
2124 for (
tools::Long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
2133 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
2136 nMemberMeasure = nSubCount;
2138 OSL_ENSURE( rFilterCxt.
mnCol < rSequence.getLength(),
"bumm" );
2139 sheet::DataResult& rRes = rSequence.getArray()[rFilterCxt.
mnCol];
2141 if (
HasData( nMemberMeasure, aLocalSubState ) )
2143 if (
HasError( nMemberMeasure, aLocalSubState ) )
2146 rRes.Flags |= sheet::DataResultFlags::ERROR;
2150 rRes.Value =
GetAggregate( nMemberMeasure, aLocalSubState );
2151 rRes.Flags |= sheet::DataResultFlags::HASDATA;
2155 if ( bHasChild || bIsSubTotalRow )
2156 rRes.Flags |= sheet::DataResultFlags::SUBTOTAL;
2159 rFilterCxt.
mnCol += 1;
2165 rFilterCxt.
mnCol += nExtraSpace;
2166 rFilterCxt.
mnCol += nMoveSubTotal;
2181 bool bHasChild = ( pRefChild != nullptr );
2188 if ( !nUserSubCount || !bHasChild )
2196 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
2205 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
2208 nMemberMeasure = nSubCount;
2217 sal_Int32 eRefType = aReferenceValue.ReferenceType;
2220 pAggData->
Calculate( eFunc, aLocalSubState );
2222 if ( eRefType == sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE ||
2223 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE ||
2224 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE )
2238 pDataChild->
UpdateDataRow( pRefChild, nMeasure, bIsSubTotalRow, rSubState );
2250 if ( pRefChild && pDataChild )
2263 if ( pRefChild && pDataChild )
2291 bool bHasChild = ( pRefChild != nullptr );
2297 if ( !nUserSubCount || !bHasChild )
2305 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
2314 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
2317 nMemberMeasure = nSubCount;
2325 sal_Int32 eRefType = aReferenceValue.ReferenceType;
2327 if ( eRefType == sheet::DataPilotFieldReferenceType::RUNNING_TOTAL ||
2328 eRefType == sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE ||
2329 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE ||
2330 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE )
2332 bool bRunningTotal = ( eRefType == sheet::DataPilotFieldReferenceType::RUNNING_TOTAL );
2334 ( aReferenceValue.ReferenceItemType != sheet::DataPilotFieldReferenceItemType::NAMED && !bRunningTotal );
2336 ( ( aReferenceValue.ReferenceItemType == sheet::DataPilotFieldReferenceItemType::PREVIOUS ) ? -1 : 1 ) : 0;
2343 OUString aRefFieldName = aReferenceValue.ReferenceField;
2347 bool bRefDimInCol = ( nRefOrient == sheet::DataPilotFieldOrientation_COLUMN );
2348 bool bRefDimInRow = ( nRefOrient == sheet::DataPilotFieldOrientation_ROW );
2351 sal_Int32 nRowPos = 0;
2352 sal_Int32 nColPos = 0;
2359 while ( pSelectDim && pSelectDim->
GetName() != aRefFieldName )
2362 if ( nIndex >= 0 && nIndex < pSelectDim->GetMemberCount() )
2365 pSelectDim =
nullptr;
2369 if ( pSelectDim && rRowSorted[nRowPos] < 0 )
2370 pSelectDim =
nullptr;
2376 while ( pSelectDim && pSelectDim->
GetName() != aRefFieldName )
2379 if ( nIndex >= 0 && nIndex < pSelectDim->GetMemberCount() )
2382 pSelectDim =
nullptr;
2386 if ( pSelectDim && rColSorted[nColPos] < 0 )
2387 pSelectDim =
nullptr;
2390 bool bNoDetailsInRef =
false;
2391 if ( pSelectDim && bRunningTotal )
2398 tools::Long nMyIndex = bRefDimInCol ? rColSorted[nColPos] : rRowSorted[nRowPos];
2399 if ( nMyIndex >= 0 && nMyIndex < pSelectDim->GetMemberCount() )
2404 pSelectDim =
nullptr;
2405 bNoDetailsInRef =
true;
2426 if ( bInnerNoDetails )
2428 pSelectDim =
nullptr;
2429 bNoDetailsInRef =
true;
2433 if ( !bRefDimInCol && !bRefDimInRow )
2434 bNoDetailsInRef =
true;
2438 if ( bRunningTotal )
2447 nColPos, rRunning );
2450 const sal_Int32* pRowSorted = rRowSorted.data();
2451 const sal_Int32* pColSorted = rColSorted.data();
2452 pRowSorted += nRowPos + 1;
2454 nullptr,
nullptr, pRowSorted, pColSorted);
2457 if ( pSelectMember )
2465 GetAggData( nMemberMeasure, aLocalSubState );
2478 else if (bNoDetailsInRef)
2489 OUString aRefItemName = aReferenceValue.ReferenceItemName;
2492 const OUString* pRefName =
nullptr;
2495 pRefPos = &aRefItemPos;
2497 pRefName = &aRefItemName;
2502 aRefItemPos.
nBasePos = rColVisible[nColPos];
2504 nColPos, rRunning );
2508 aRefItemPos.
nBasePos = rRowVisible[nRowPos];
2509 const sal_Int32* pRowSorted = rRowSorted.data();
2510 const sal_Int32* pColSorted = rColSorted.data();
2511 pRowSorted += nRowPos + 1;
2513 pRefPos, pRefName, pRowSorted, pColSorted);
2517 if ( pSelectMember ==
this &&
2518 eRefType != sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE )
2522 else if ( pSelectMember )
2524 const ScDPAggData* pOtherAggData = pSelectMember->
2526 OSL_ENSURE( pOtherAggData,
"no agg data" );
2527 if ( pOtherAggData )
2533 double fThisResult = pAggData->
GetResult();
2534 bool bError =
false;
2537 case sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE:
2538 fThisResult = fThisResult - fOtherResult;
2540 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE:
2541 if ( fOtherResult == 0.0 )
2544 fThisResult = fThisResult / fOtherResult;
2546 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
2547 if ( fOtherResult == 0.0 )
2550 fThisResult = ( fThisResult - fOtherResult ) / fOtherResult;
2553 OSL_FAIL(
"invalid calculation type");
2567 else if (bRelative && !bNoDetailsInRef)
2572 else if (bNoDetailsInRef)
2578 else if ( eRefType == sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE ||
2579 eRefType == sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE ||
2580 eRefType == sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE ||
2581 eRefType == sheet::DataPilotFieldReferenceType::INDEX )
2592 if ( bIsRoot && rTotals.
IsInColRoot() && pGrandTotalData )
2595 if ( bIsRoot && pRowTotalData )
2605 case sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE:
2606 case sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE:
2607 case sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE:
2610 if ( eRefType == sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE )
2611 nTotal = pRowTotalData ? pRowTotalData->
GetAuxiliary() : 0.0;
2612 else if ( eRefType == sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE )
2613 nTotal = pColTotalData ? pColTotalData->
GetAuxiliary() : 0.0;
2615 nTotal = pGrandTotalData ? pGrandTotalData->
GetAuxiliary() : 0.0;
2617 if ( nTotal == 0.0 )
2623 case sheet::DataPilotFieldReferenceType::INDEX:
2625 double nColTotal = pColTotalData ? pColTotalData->
GetAuxiliary() : 0.0;
2626 double nRowTotal = pRowTotalData ? pRowTotalData->
GetAuxiliary() : 0.0;
2627 double nGrandTotal = pGrandTotalData ? pGrandTotalData->
GetAuxiliary() : 0.0;
2628 if ( nRowTotal == 0.0 || nColTotal == 0.0 )
2632 ( pAggData->
GetResult() * nGrandTotal ) /
2633 ( nRowTotal * nColTotal ) );
2647 bIsSubTotalRow, rSubState, rRunning, rTotals, rRowParent );
2651 #if DUMP_PIVOT_TABLE
2659 if ( pDataChild && pRefChild )
2660 pDataChild->
DumpState( pRefChild, pDoc, rPos );
2662 indent(pDoc, nStartRow, rPos);
2667 std::string aIndent(nIndent*2,
' ');
2668 std::cout << aIndent <<
"-- data member '"
2671 pAgg->Dump(nIndent+1);
2683 class ScDPGroupCompare
2695 bool IsIncluded(
const ScDPMember& rMember ) {
return bIncludeAll || TestIncluded( rMember ); }
2696 bool TestIncluded(
const ScDPMember& rMember );
2702 pResultData( pData ),
2703 rInitState( rState ),
2704 nDimSource( nDimension )
2710 bIncludeAll = !( bIsBase || nGroupBase >= 0 );
2713 bool ScDPGroupCompare::TestIncluded(
const ScDPMember& rMember )
2715 bool bInclude =
true;
2722 const std::vector<ScDPInitState::Member>& rMemStates = rInitState.GetMembers();
2723 bInclude = std::all_of(rMemStates.begin(), rMemStates.end(),
2725 return (pResultData->GetGroupBase(rMem.mnSrcIndex) != nDimSource)
2726 || pResultData->IsInGroup(rMem.mnNameIndex, rMem.mnSrcIndex, aMemberData, nDimSource);
2729 else if ( nGroupBase >= 0 )
2736 const std::vector<ScDPInitState::Member>& rMemStates = rInitState.GetMembers();
2737 bInclude = std::all_of(rMemStates.begin(), rMemStates.end(),
2741 return (pResultData->GetGroupBase(rMem.mnSrcIndex) != nGroupBase)
2742 || pResultData->HasCommonElement(rMem.mnNameIndex, rMem.mnSrcIndex, aMemberData, nDimSource);
2750 pResultData( pData ),
2752 bIsDataLayout( false ),
2753 bSortByData( false ),
2754 bSortAscending( false ),
2756 bAutoTopItems( false ),
2757 bInitialized( false ),
2772 MemberHash::const_iterator aRes =
maMemberHash.find( iData );
2774 if ( aRes->second->IsNamedItem( iData ) )
2775 return aRes->second;
2776 OSL_FAIL(
"problem! hash result is not the same as IsNamedItem");
2781 for( i = 0; i < nCount ; i++ )
2785 return pResultMember;
2791 const vector<ScDPDimension*>& ppDim,
const vector<ScDPLevel*>& ppLev,
2794 if (nPos >= ppDim.size() || nPos >= ppLev.size())
2803 if (!pThisDim || !pThisLevel)
2813 const sheet::DataPilotFieldAutoShowInfo& rAutoInfo = pThisLevel->
GetAutoShow();
2814 if ( rAutoInfo.IsEnabled )
2817 bAutoTopItems = ( rAutoInfo.ShowItemsMode == sheet::DataPilotFieldShowItemsMode::FROM_TOP );
2823 const sheet::DataPilotFieldSortInfo& rSortInfo = pThisLevel->
GetSortInfo();
2824 if ( rSortInfo.Mode == sheet::DataPilotFieldSortMode::DATA )
2835 ScDPGroupCompare aCompare(
pResultData, rInitState, nDimSource );
2842 tools::Long nSorted = rGlobalOrder.empty() ?
i : rGlobalOrder[
i];
2845 if ( aCompare.IsIncluded( *pMember ) )
2851 pNew->
InitFrom( ppDim, ppLev, nPos+1, rInitState, bInitChild );
2861 if ( rParams.
IsEnd( nPos ) )
2863 if (nPos >= pItemData.size())
2865 SAL_WARN(
"sc.core",
"pos " << nPos <<
", but vector size is " << pItemData.size());
2868 SCROW rThisData = pItemData[nPos];
2872 if (!pThisDim || !pThisLevel)
2885 const sheet::DataPilotFieldAutoShowInfo& rAutoInfo = pThisLevel->
GetAutoShow();
2886 if ( rAutoInfo.IsEnabled )
2889 bAutoTopItems = ( rAutoInfo.ShowItemsMode == sheet::DataPilotFieldShowItemsMode::FROM_TOP );
2894 const sheet::DataPilotFieldSortInfo& rSortInfo = pThisLevel->
GetSortInfo();
2895 if ( rSortInfo.Mode == sheet::DataPilotFieldSortMode::DATA )
2905 if ( !bLateInitAllMembers )
2915 bool bNewAllMembers = (!rParams.
IsRow()) || nPos == 0 || bLateInitAllMembers;
2917 if (bNewAllMembers )
2924 ScDPGroupCompare aCompare(
pResultData, rInitState, nDimSource );
2929 tools::Long nSorted = rGlobalOrder.empty() ?
i : rGlobalOrder[
i];
2932 if ( aCompare.IsIncluded( *pMember ) )
2941 if ( bLateInitAllMembers )
2949 bool bAllChildren =
false;
2952 bAllChildren = !pResultMember->
IsNamedItem( rThisData );
2956 pResultMember->
LateInitFrom( rParams, pItemData, nPos+1, rInitState );
2963 if(
nullptr != pResultMember )
2966 pResultMember->
LateInitFrom( rParams, pItemData, nPos+1, rInitState );
2982 "DataLayout dimension twice?");
2989 for (
tools::Long nMem=0; nMem<nMemberCount; nMem++)
2997 if (aMembers.empty())
3001 if (
nullptr != pMember )
3003 #if OSL_DEBUG_LEVEL > 0
3004 SAL_INFO(
"sc.core",
"IsValidEntry: Member not found, DimNam = " <<
GetName());
3011 const vector< SCROW >& aDataMembers,
3012 const vector<ScDPValue>& aValues )
const
3014 if (aMembers.empty())
3018 if (
nullptr != pMember )
3020 vector<SCROW> aChildMembers;
3021 if (aMembers.size() > 1)
3023 vector<SCROW>::const_iterator itr = aMembers.begin();
3024 aChildMembers.insert(aChildMembers.begin(), ++itr, aMembers.end());
3026 pMember->
ProcessData( aChildMembers, pDataDim, aDataMembers, aValues );
3030 OSL_FAIL(
"ProcessData: Member not found");
3047 bool bTotalResult =
false;
3050 maMemberArray[0]->FillMemberResults( pSequences, nPos, nSorted,
false, &aMbrName, &aMbrCapt );
3054 pMember->
FillMemberResults( pSequences, nPos, nMeasure,
false,
nullptr,
nullptr );
3062 uno::Sequence< uno::Sequence<sheet::DataResult> >& rSequence,
tools::Long nMeasure)
const
3064 FilterStack aFilterStack(rFilterCxt.
maFilters);
3077 "DataLayout dimension twice?");
3079 nMemberMeasure = nSorted;
3085 pMember->
FillDataResults(pRefMember, rFilterCxt, rSequence, nMemberMeasure);
3099 "DataLayout dimension twice?");
3161 aAutoOrder.resize( nCount );
3163 for (nPos=0; nPos<nCount; nPos++)
3164 aAutoOrder[nPos] = nPos;
3167 ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
3174 bool bContinue =
true;
3178 if ( nIncluded < nCount )
3193 for (nPos = nIncluded; nPos < nCount; nPos++)
3229 "DataLayout dimension twice?");
3231 nMemberMeasure = nSorted;
3250 const sal_Int32* pRowIndexes,
const sal_Int32* pColIndexes )
const
3254 OSL_ENSURE( pRelativePos ==
nullptr || pName ==
nullptr,
"can't use position and name" );
3258 bool bFirstExisting = ( pRelativePos ==
nullptr && pName == nullptr );
3265 nMemberIndex = pRelativePos->
nBasePos + nDirection;
3267 OSL_ENSURE( nDirection == 1 || nDirection == -1,
"Direction must be 1 or -1" );
3276 while ( pRowMember && pRowMember->
GetName() != *
pName )
3279 if ( nMemberIndex < nMemberCount )
3282 pRowMember =
nullptr;
3286 bool bContinue =
true;
3287 while ( bContinue && nMemberIndex >= 0 && nMemberIndex < nMemberCount )
3293 const sal_Int32* pNextRowIndex = pRowIndexes;
3294 while ( *pNextRowIndex >= 0 && pRowMember )
3298 pRowMember = pRowChild->
GetMember( *pNextRowIndex );
3300 pRowMember =
nullptr;
3304 if ( pRowMember && pRelativePos )
3311 pRowMember =
nullptr;
3318 const sal_Int32* pNextColIndex = pColIndexes;
3319 while ( *pNextColIndex >= 0 && pColMember )
3323 pColMember = pColChild->
GetMember( *pNextColIndex );
3325 pColMember =
nullptr;
3331 bContinue = ( pColMember ==
nullptr && ( bFirstExisting || pRelativePos ) );
3332 nMemberIndex += nDirection;
3342 OSL_ENSURE( pRelativePos ==
nullptr || pName ==
nullptr,
"can't use position and name" );
3344 const sal_Int32* pColIndexes = rRunning.
GetColSorted().data();
3345 const sal_Int32* pRowIndexes = rRunning.
GetRowSorted().data();
3352 const sal_Int32* pNextRowIndex = pRowIndexes;
3353 while ( *pNextRowIndex >= 0 && pRowMember )
3357 pRowMember = pRowChild->
GetMember( *pNextRowIndex );
3359 pRowMember =
nullptr;
3370 const sal_Int32* pNextColIndex = pColIndexes;
3371 sal_Int32 nColSkipped = 0;
3372 while ( *pNextColIndex >= 0 && pColMember && nColSkipped < nRefDimPos )
3376 pColMember = pColChild->
GetMember( *pNextColIndex );
3378 pColMember =
nullptr;
3389 if ( pReferenceDim )
3393 bool bFirstExisting = ( pRelativePos ==
nullptr && pName == nullptr );
3396 pColMember =
nullptr;
3400 nMemberIndex = pRelativePos->
nBasePos + nDirection;
3409 while ( pColMember && pColMember->
GetName() != *
pName )
3412 if ( nMemberIndex < nReferenceCount )
3415 pColMember =
nullptr;
3419 bool bContinue =
true;
3420 while ( bContinue && nMemberIndex >= 0 && nMemberIndex < nReferenceCount )
3426 const sal_Int32* pNextColIndex = pColIndexes + nRefDimPos + 1;
3427 while ( *pNextColIndex >= 0 && pColMember )
3431 pColMember = pColChild->
GetMember( *pNextColIndex );
3433 pColMember =
nullptr;
3437 if ( pColMember && pRelativePos )
3444 pColMember =
nullptr;
3448 bContinue = ( pColMember ==
nullptr && ( bFirstExisting || pRelativePos ) );
3449 nMemberIndex += nDirection;
3453 pColMember =
nullptr;
3459 #if DUMP_PIVOT_TABLE
3463 dumpRow(
"ScDPResultDimension", aDimName,
nullptr, pDoc, rPos);
3471 pMember->
DumpState( pRefMember, pDoc, rPos );
3474 indent(pDoc, nStartRow, rPos);
3479 std::string aIndent(nIndent*2,
' ');
3480 std::cout << aIndent <<
"-- dimension '" <<
GetName() <<
"'" << std::endl;
3491 return maMemberArray.size();
3496 return maMemberArray[n].get();
3500 return maMemberArray[n].get();
3505 if ( !maMemberArray.empty() )
3506 return maMemberArray[0]->GetChildDimension();
3516 for (
const auto& rxMember : maMemberArray)
3529 pResultData( pData ),
3530 pResultDimension( nullptr ),
3531 bIsDataLayout( false )
3582 vector<SCROW> aChildDataMembers;
3583 if (aDataMembers.size() > 1)
3585 vector<SCROW>::const_iterator itr = aDataMembers.begin();
3586 aChildDataMembers.insert(aChildDataMembers.begin(), ++itr, aDataMembers.end());
3588 pMember->
ProcessData( aChildDataMembers, aValues, rSubState );
3593 OSL_FAIL(
"ProcessData: Member not found");
3598 uno::Sequence<sheet::DataResult>& rSequence,
tools::Long nMeasure,
bool bIsSubTotalRow,
3602 bool bDataLayout =
false;
3609 FilterStack aFilterStack(rFilterCxt.
maFilters);
3610 aFilterStack.pushDimName(aDimName, bDataLayout);
3612 OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3621 tools::Long nSorted = rMemberOrder.empty() ?
i : rMemberOrder[
i];
3627 "DataLayout dimension twice?");
3629 nMemberMeasure = nSorted;
3636 pDataMember->
FillDataRow(pRefMember, rFilterCxt, rSequence, nMemberMeasure, bIsSubTotalRow, rSubState);
3645 OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3656 "DataLayout dimension twice?");
3664 pDataMember->
UpdateDataRow( pRefMember, nMemberMeasure, bIsSubTotalRow, rSubState );
3677 OSL_ENSURE( rMemberOrder.empty(),
"sort twice?" );
3678 rMemberOrder.resize( nCount );
3683 ::std::sort( rMemberOrder.begin(), rMemberOrder.end(), aComp );
3688 OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3710 OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3731 aAutoOrder.resize( nCount );
3733 for (nPos=0; nPos<nCount; nPos++)
3734 aAutoOrder[nPos] = nPos;
3737 ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
3744 pDataMember1 =
nullptr;
3745 bool bContinue =
true;
3749 if ( nIncluded < nCount )
3753 pDataMember2 =
nullptr;
3765 for (nPos = nIncluded; nPos < nCount; nPos++)
3791 return rMemberOrder.empty() ? nUnsorted : rMemberOrder[nUnsorted];
3799 OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3807 tools::Long nSorted = rMemberOrder.empty() ?
i : rMemberOrder[
i];
3813 "DataLayout dimension twice?");
3815 nMemberMeasure = nSorted;
3828 pRefMember, nMemberMeasure, bIsSubTotalRow, rSubState, rRunning, rTotals, rRowParent);
3835 #if DUMP_PIVOT_TABLE
3838 OUString aDimName =
bIsDataLayout ? OUString(
"(data layout)") : OUString(
"(unknown)");
3839 dumpRow(
"ScDPDataDimension", aDimName,
nullptr, pDoc, rPos);
3848 pDataMember->
DumpState( pRefMember, pDoc, rPos );
3851 indent(pDoc, nStartRow, rPos);
3856 std::string aIndent(nIndent*2,
' ');
3857 std::cout << aIndent <<
"-- data dimension '"
3860 rxMember->Dump(nIndent+1);
3866 return maMembers.size();
3871 return maMembers[n].get();
3876 return maMembers[n].get();
3891 DimMemberType::iterator itr =
maDimensions.find(rDimName);
3894 pair<DimMemberType::iterator, bool> r =
maDimensions.emplace(
3904 rMem.insert(rMemberItem);
3909 typedef std::unordered_map<OUString, tools::Long> FieldNameMapType;
3913 for (sal_Int32
i = 0;
i < nColumnCount; ++
i)
3922 FieldNameMapType::const_iterator itrField = aFieldNames.find(rDimName);
3923 if (itrField == aFieldNames.end())
3929 aCri.
mpFilter = std::make_shared<ScDPFilteredCache::GroupFilter>();
3941 GetLevelsObject()->getByIndex(0)->GetMembersObject();
3943 rFilters.push_back(aCri);
3950 return static_cast<size_t>(::rtl::math::approxFloor(r.
GetValue()));
3956 const ScDPMember* pMemberDesc = GetDPMember();
3966 maMemberArray.emplace_back( pMember );
3968 maMemberHash.emplace( nDataIndex, pMember );
3975 if ( !lcl_SearchMember( maMemberArray, pMemberData->
mnOrder , nInsert ) )
3978 maMemberArray.emplace( maMemberArray.begin()+nInsert, pNew );
3981 maMemberHash.emplace( nDataIndex, pNew );
3984 return maMemberArray[ nInsert ].get();
3988 LateInitParams& rParams,
const std::vector<SCROW>& pItemData,
size_t nPos,
3991 if ( rParams.
IsEnd( nPos ) )
3995 SCROW nDataID = pItemData[nPos];
3997 if (!(pThisDim && pThisLevel))
4003 ResultMembers& rMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
4004 ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
4008 pResultMember = FindMember( nDataID );
4010 bInitialized =
true;
4012 if ( pResultMember ==
nullptr )
4015 if ( pMemberData && aCompare.IsIncluded( *( pMemberData->
mpMemberDesc ) ) )
4016 pResultMember = InsertMember( pMemberData );
4018 if ( pResultMember )
4021 pResultMember->
LateInitFrom(rParams, pItemData, nPos+1, rInitState);
4027 mnOrder(-1), mpParentDim(nullptr), mpParentLevel(nullptr), mpMemberDesc(nullptr) {}
4031 mnOrder(nIndex), mpParentDim(pDim), mpParentLevel(pLev), mpMemberDesc(pMember) {}
4037 if ( aRes->second.mpMemberDesc && aRes->second.mpMemberDesc->GetItemDataId()==nIndex )
4038 return &aRes->second;
4050 mbHasHideDetailsMember( false )
4058 const vector<ScDPDimension*>& ppDim,
const vector<ScDPLevel*>& ppLev,
bool bRow ) :
4062 mbInitChild( true ),
4063 mbAllChildren( false )
4073 return nPos >=
mppDim.size();
void SetAuxiliary(double fNew)
ScDPRelativePos(tools::Long nBase, tools::Long nDir)
bool IsOutlineLayout() const
void DoAutoShow(ScDPResultMember *pRefMember)
std::unique_ptr< ScDPDataMember > pDataRoot
MemberArray maMemberArray
function is determined automatically.
void SetInitAllChildren(bool b)
ScDPTableData * GetData()
const tools::Long SC_SUBTOTALPOS_AUTO
virtual bool HasCommonElement(const ScDPItemData &rFirstData, sal_Int32 nFirstIndex, const ScDPItemData &rSecondData, sal_Int32 nSecondIndex) const
const sal_Int64 SC_DPAGG_RESULT_EMPTY
std::unique_ptr< ScDPAggData > pChild
bool IsCalculated() const
bool IsAutoTopItems() const
void UpdateDataRow(const ScDPResultMember *pRefMember, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState)
bool HasCommonElement(SCROW nFirstDataId, tools::Long nFirstIndex, const ScDPItemData &rSecondData, tools::Long nSecondIndex) const
std::unique_ptr< ScDPResultDimension > pChildDimension
const std::optional< OUString > & GetGrandTotalName() const
ScDPDimension * GetDataDimension(sal_Int32 nIndex)
virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const
ScDPDimension * GetDim(size_t nPos) const
ScDPHierarchy * getByIndex(tools::Long nIndex) const
double getVarianceSample() const
const css::sheet::DataPilotFieldAutoShowInfo & GetAutoShow() const
void Update(const ScDPValue &rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState &rSubState)
static ScSubTotalFunc lcl_GetForceFunc(const ScDPLevel *pLevel, tools::Long nFuncNo)
const ScDPParentDimData * FindMember(SCROW nIndex) const
void InitFrom(const ::std::vector< ScDPDimension * > &ppDim, const ::std::vector< ScDPLevel * > &ppLev, size_t nPos, ScDPInitState &rInitState, bool bInitChild=true)
std::vector< css::sheet::DataPilotFieldOrientation > maMeasureRefOrients
void SetInitChild(bool b)
ScDPResultTree maFilterSet
tools::Long GetMemberCount() const
void InitFrom(const ScDPResultDimension *pDim)
sal_Int32 GetDimension() const
void CheckShowEmpty(bool bShow=false)
The term 'measure' here roughly equals "data dimension" ?
void SortMembers(ScDPResultMember *pRefMember)
OUString GetDataDimName(sal_Int32 nIndex)
void CheckShowEmpty(bool bShow=false)
ScDPParentDimData aParentDimData
static ScDPDataMember * GetColReferenceMember(const ScDPRelativePos *pMemberPos, const OUString *pName, sal_Int32 nRefDimPos, const ScDPRunningTotalState &rRunning)
std::vector< css::sheet::DataPilotFieldReference > maMeasureRefs
tools::Long nRowSubTotalFunc
void SetLateInit(bool bSet)
const ScDPResultData * pResultData
sal_Int32 getCount() const
std::vector< ScDPResultFilter > maFilters
const css::sheet::DataPilotFieldReference & GetMeasureRefVal(tools::Long nMeasure) const
Member names that are being processed for InitFrom/LateInitFrom (needed for initialization of grouped...
const ScDPResultDimension * pResultDimension
ScDPLevel * GetLevel(size_t nPos) const
ResultMembers & GetDimResultMembers(tools::Long nDim, const ScDPDimension *pDim, ScDPLevel *pLevel) const
const ScDPMember * GetDPMember() const
Ref.
bool IsNamedItem(SCROW nIndex) const
const ScDPDimension * mpParentDim
Ref.
void UpdateDataResults(const ScDPResultMember *pRefMember, tools::Long nMeasure) const
void DumpState(const ScDPResultMember *pRefMember, ScDocument *pDoc, ScAddress &rPos) const
ScDPMembers * GetMembersObject()
void ProcessData(const ::std::vector< SCROW > &aChildMembers, const ScDPResultDimension *pDataDim, const ::std::vector< SCROW > &aDataMembers, const ::std::vector< ScDPValue > &aValues)
Select subtotal information, passed down the dimensions.
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
void FillDataResults(const ScDPResultMember *pRefMember, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > &rSequence, tools::Long nMeasure) const
void UpdateRunningTotals(const ScDPResultDimension *pRefDim, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals, const ScDPResultMember &rRowParent) const
tools::Long GetSize(tools::Long nMeasure) const
void Dump(int nIndent) const
OUString GetMeasureString(tools::Long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool &rbTotalResult) const
void DoAutoShow(ScDPResultMember *pRefMember)
ScMemberSortOrder aMemberOrder
std::vector< Member > maMembers
tools::Long GetRowStartMeasure() const
exports com.sun.star. sheet
std::vector< sal_Int32 > IndexArray
tools::Long GetCountForMeasure(tools::Long nMeas) const
const ::std::vector< ScDPDimension * > & mppDim
std::unique_ptr< ScDPDataDimension > pChildDimension
Ref?
void add(const std::vector< ScDPResultFilter > &rFilter, double fVal)
Add a single value filter path.
ScDPDataDimension(const ScDPResultData *pData)
or ptr to IntDimension?
void Calculate(ScSubTotalFunc eFunc, const ScDPSubTotalState &rSubState)
ScDPResultMember * GetRowResRoot() const
ScDPAggData * GetColTotal(tools::Long nMeasure) const
double getVariancePopulation() const
ScDPResultMember(const ScDPResultData *pData, const ScDPParentDimData &rParentDimData)
const ScDPResultData * pResultData
bool mbHasHideDetailsMember
void FillMemberResults(css::uno::Sequence< css::sheet::MemberResult > *pSequences, tools::Long nStart, tools::Long nMeasure)
Test.
const std::optional< OUString > & GetSubtotalName() const
bool IsSortAscending() const
void AddRowIndex(sal_Int32 nVisible, tools::Long nSorted)
void FillVisibilityData(ScDPResultVisibilityData &rData) const
ScDPResultMember * GetColResRoot() const
bool IsNamedItem(SCROW nRow) const
tools::Long nColSubTotalFunc
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SortMembers(ScDPResultDimension *pRefDim)
void SortMembers(ScDPResultMember *pRefMember)
ScDPDimensions * GetDimensionsObject()
const ScDPSource & GetSource() const
static tools::Long lcl_GetSubTotalPos(const ScDPSubTotalState &rSubState)
multi-item (group) filter.
void SetDataLayoutOrientation(css::sheet::DataPilotFieldOrientation nOrient)
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
static bool SafeMult(double &fVal1, double fVal2)
sal_Int32 GetSortMeasure() const
void InitWithMembers(LateInitParams &rParams, const ::std::vector< SCROW > &pItemData, size_t nPos, ScDPInitState &rInitState)
sal_Int32 GetAutoMeasure() const
ScDPResultMember * FindMember(SCROW iData) const
virtual OUString SAL_CALL getName() override
const ScDPLevel * GetParentLevel() const
Ref.
void SetInColRoot(bool bSet)
static bool lcl_IsLess(const ScDPDataMember *pDataMember1, const ScDPDataMember *pDataMember2, tools::Long nMeasure, bool bAscending)
std::shared_ptr< FilterBase > mpFilter
bool getShowEmpty() const
tools::Long GetSortedIndex(tools::Long nUnsorted) const
ScDPResultMember * AddMember(const ScDPParentDimData &aData)
bool IsInGroup(SCROW nGroupDataId, tools::Long nGroupIndex, const ScDPItemData &rBaseData, tools::Long nBaseIndex) const
const ::std::vector< sal_Int32 > & GetGlobalOrder() const
bool HasHiddenDetails() const
ScDPResultMember * InsertMember(const ScDPParentDimData *pMemberData)
ScDPResultVisibilityData(ScDPSource *pSource)
void UpdateRunningTotals(const ScDPResultMember *pRefMember, tools::Long nMeasure, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals) const
void FillDataResults(const ScDPResultMember *pRefMember, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > &rSequence, tools::Long nMeasure) const
indexes when calculating running totals
constexpr OUStringLiteral aData
#define SAL_N_ELEMENTS(arr)
virtual bool IsInGroup(const ScDPItemData &rGroupData, sal_Int32 nGroupIndex, const ScDPItemData &rBaseData, sal_Int32 nBaseIndex) const
virtual bool IsBaseForGroup(sal_Int32 nDim) const
const OUString & GetName() const
void Dump(int nIndent) const
void FillVisibilityData(ScDPResultVisibilityData &rData) const
double GetAggregate(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
tools::Long GetSortedIndex(tools::Long nUnsorted) const
const ScDPDataMember * GetMember(tools::Long n) const
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Implements the Welford Online one-pass algorithm.
void addVisibleMember(const OUString &rDimName, const ScDPItemData &rMemberItem)
ScDPResultData(ScDPSource &rSrc)
bool IsHasHideDetailsMembers() const
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
ScDPResultDimension(const ScDPResultData *pData)
DimMemberType maDimensions
void UpdateDataRow(const ScDPResultDimension *pRefDim, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState) const
ScDPDimension * getByIndex(tools::Long nIndex) const
tools::Long GetAutoCount() const
void FillMemberResults(css::uno::Sequence< css::sheet::MemberResult > *pSequences, tools::Long &rPos, tools::Long nMeasure, bool bRoot, const OUString *pMemberName, const OUString *pMemberCaption)
std::vector< ScSubTotalFunc > maMeasureFuncs
keep things like measure lists here
virtual OUString getDimensionName(sal_Int32 nColumn)=0
void ProcessData(const ::std::vector< SCROW > &aChildMembers, const ::std::vector< ScDPValue > &aValues, const ScDPSubTotalState &rSubState)
static ScDPAggData * lcl_GetChildTotal(ScDPAggData *pFirst, tools::Long nMeasure)
tools::Long GetGroupBase(tools::Long nGroupDim) const
void AddMember(tools::Long nSourceIndex, SCROW nMember)
std::vector< std::unique_ptr< ScDPDataMember > > maMembers
static bool lcl_IsEqual(const ScDPDataMember *pDataMember1, const ScDPDataMember *pDataMember2, tools::Long nMeasure)
const ScDPItemData * GetItemDataById(sal_Int32 nDim, sal_Int32 nId)
void DoAutoShow(ScDPResultDimension *pRefDim)
bool bSortByData
or ptr to IntDimension?
std::unordered_set< ScDPItemData, MemberHash > VisibleMemberType
const css::sheet::DataPilotFieldSortInfo & GetSortInfo() const
css::sheet::DataPilotFieldOrientation GetMeasureRefOrient(tools::Long nMeasure) const
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void DumpState(const ScDPResultMember *pRefMember, ScDocument *pDoc, ScAddress &rPos) const
SCROW GetItemDataId() const
ScDPDataMember(const ScDPResultData *pData, const ScDPResultMember *pRes)
LateInitParams(const ::std::vector< ScDPDimension * > &ppDim, const ::std::vector< ScDPLevel * > &ppLev, bool bRow)
const ScMemberSortOrder & GetMemberOrder() const
OUString ScResId(const char *pId)
tools::Long GetSize(tools::Long nMeasure) const
void DoAutoShow(ScDPResultMember *pRefMember)
tools::Long GetMemberCount() const
double GetAuxiliary() const
bool HasHiddenDetails() const
void FillDataRow(const ScDPResultDimension *pRefDim, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::sheet::DataResult > &rSequence, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState) const
ScDPItemData FillItemData() const
css::uno::Sequence< sal_Int16 > getSubTotals() const
size_t operator()(const ScDPItemData &r) const
const ScDPDimension * GetParentDim() const
bool IsEnd(size_t nPos) const
bool IsSortByData() const
const ScDPResultMember * pResultMember
std::unordered_map< SCROW, ScDPParentDimData > maMemberHash
bool getShowDetails() const
~ScDPResultVisibilityData()
void addMatchItem(const ScDPItemData &rItem)
void fillFieldFilters(::std::vector< ScDPFilteredCache::Criterion > &rFilters) const
ScDPAggData * GetAggData(tools::Long nMeasure, const ScDPSubTotalState &rSubState)
const ScDPResultData * pResultData
void UpdateRunningTotals(const ScDPResultMember *pRefMember, tools::Long nMeasure, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals) const
std::vector< std::unique_ptr< ResultMembers > > maDimMembers
add "displayed values" settings
std::vector< double > mSortedValues
void Dump(int nIndent) const
const IndexArray & GetRowVisible() const
const ScDPMember * mpMemberDesc
Ref.
static bool SafePlus(double &fVal1, double fVal2)
void AddColIndex(sal_Int32 nVisible, tools::Long nSorted)
void SortMembers(ScDPResultMember *pRefMember)
OUString GetMeasureDimensionName(tools::Long nMeasure) const
const ScDPResultMember * GetMember(tools::Long n) const
void SetHasHideDetailsMembers(bool b)
Base class that abstracts different data source types of a datapilot table.
single filtering criterion.
void FillDataRow(const ScDPResultMember *pRefMember, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::sheet::DataResult > &rSequence, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState) const
const IndexArray & GetColVisible() const
bool IsNamedItem(SCROW nIndex) const
void ProcessData(const ::std::vector< SCROW > &aMembers, const ScDPResultDimension *pDataDim, const ::std::vector< SCROW > &aDataMembers, const ::std::vector< ScDPValue > &aValues) const
const IndexArray & GetRowSorted() const
void SetResult(double fNew)
bool IsValidEntry(const ::std::vector< SCROW > &aMembers) const
void DumpState(const ScDPResultMember *pRefMember, ScDocument *pDoc, ScAddress &rPos) const
void InitFrom(const ScDPResultDimension *pDim)
void InitFrom(const ::std::vector< ScDPDimension * > &ppDim, const ::std::vector< ScDPLevel * > &ppLev, size_t nPos, ScDPInitState &rInitState, bool bInitChild=true)
void SetMeasureData(std::vector< ScSubTotalFunc > &rFunctions, std::vector< css::sheet::DataPilotFieldReference > &rRefs, std::vector< css::sheet::DataPilotFieldOrientation > &rRefOrient, std::vector< OUString > &rNames)
const ScDPResultDimension * GetChildDimension() const
this will be removed!
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2, which causes some type-safety issues.
sal_uInt64 getCount() const
#define SAL_INFO(area, stream)
ScDPResultDimension * GetFirstChildDimension() const
tools::Long GetSortMeasure() const
This class collects visible members of each dimension and uses that information to create filtering c...
tools::Long nSortMeasure
or ptr to IntDimension?
void ProcessData(const ::std::vector< SCROW > &aDataMembers, const ::std::vector< ScDPValue > &aValues, const ScDPSubTotalState &rSubState)
tools::Long GetMeasureCount() const
bool IsDataLayout() const
const IndexArray & GetColSorted() const
void Dump(int nIndent) const
Sequence< sal_Int8 > aSeq
static SC_DLLPUBLIC OUString getDisplayedMeasureName(std::u16string_view rName, ScSubTotalFunc eFunc)
double getLength(const B2DPolygon &rCandidate)
ScDPAggData * GetRowTotal(tools::Long nMeasure)
tools::Long GetDim() const
ScDPRunningTotalState(ScDPResultMember *pColRoot, ScDPResultMember *pRowRoot)
array of sal_Int32 terminated by -1.
OUString GetNameStr(bool bLocaleIndependent) const
bool HasData(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
OUString GetFormattedString(sal_Int32 nDim, const ScDPItemData &rItem, bool bLocaleIndependent) const
void DumpState(const ScDPResultDimension *pRefDim, ScDocument *pDoc, ScAddress &rPos) const
bool GetInitAllChild() const
bool IsValidEntry(const ::std::vector< SCROW > &aMembers) const
ScDPDataMember * GetRowReferenceMember(const ScDPRelativePos *pMemberPos, const OUString *pName, const sal_Int32 *pRowIndexes, const sal_Int32 *pColIndexes) const
const tools::Long SC_SUBTOTALPOS_SKIP
bool getIsDataLayoutDimension() const
const ScDPAggData * GetExistingChild() const
#define SAL_WARN(area, stream)
tools::Long GetColStartMeasure() const
OUString GetString() const
void UpdateValues(const ::std::vector< ScDPValue > &aValues, const ScDPSubTotalState &rSubState)
void InsertMember(ScDPParentDimData const &rNew)
const ScDPDataDimension * GetChildDimension() const
this will be removed!
ScDPHierarchies * GetHierarchiesObject()
const char *const aFieldNames[]
void Dump(int nIndent) const
void UpdateRunningTotals(const ScDPResultMember *pRefMember, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals, const ScDPResultMember &rRowParent)
std::vector< OUString > maMeasureNames
OUString GetDisplayName(bool bLocaleIndependent) const
const std::optional< OUString > & GetLayoutName() const
const ScDPResultData * pResultData
bool IsSubTotalInTitle(tools::Long nMeasure) const
static OUString lcl_parseSubtotalName(const OUString &rSubStr, std::u16string_view rCaption)
Parse subtotal string and replace all occurrences of '?' with the caption string. ...
ScDPItemData FillItemData() const
void LateInitFrom(LateInitParams &rParams, const ::std::vector< SCROW > &pItemData, size_t nPos, ScDPInitState &rInitState)
bool GetInitChild() const
tools::Long GetSubTotalCount(tools::Long *pUserSubStart=nullptr) const
bool IsBaseForGroup(tools::Long nDim) const
Member(tools::Long nSrcIndex, SCROW nNameIndex)
bool IsNumOrDateGroup(tools::Long nDim) const
bool HasError(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
virtual bool IsNumOrDateGroup(sal_Int32 nDim) const
const sal_Int64 SC_DPAGG_RESULT_VALID
void LateInitFrom(LateInitParams &rParams, const ::std::vector< SCROW > &pItemData, size_t nPos, ScDPInitState &rInitState)
const sal_Int64 SC_DPAGG_EMPTY
separate header file?
static SC_DLLPUBLIC ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc)
tools::Long GetAutoMeasure() const
const ScDPAggData * GetConstAggData(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
ScDPMember * getByIndex(sal_Int32 nIndex) const
const sal_Int64 SC_DPAGG_RESULT_ERROR
ScSubTotalFunc GetMeasureFunction(tools::Long nMeasure) const
bool getRepeatItemLabels() const
::std::vector< sal_Int32 > ScMemberSortOrder
void UpdateDataResults(const ScDPResultMember *pRefMember, tools::Long nMeasure) const
virtual sal_Int32 GetColumnCount()=0
use (new) typed collection instead of ScStrCollection or separate Str and ValueCollection ...
const std::optional< OUString > & GetLayoutName() const
ScDPDataMember * GetDataRoot() const
ScDPAggData * GetGrandTotal(tools::Long nMeasure)