31#include <document.hxx>
36#include <osl/diagnose.h>
37#include <rtl/math.hxx>
45#include <unordered_map>
47#include <com/sun/star/sheet/DataResultFlags.hpp>
48#include <com/sun/star/sheet/MemberResultFlags.hpp>
49#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
50#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
51#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
52#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
53#include <com/sun/star/sheet/GeneralFunction2.hpp>
58using ::com::sun::star::uno::Sequence;
80bool lcl_SearchMember(
const std::vector<std::unique_ptr<ScDPResultMember>>& list,
SCROW nOrder,
SCROW& rIndex)
84 SCROW nHi = list.size() - 1;
89 if ( list[nIndex]->GetOrder() < nOrder )
94 if ( list[nIndex]->GetOrder() == nOrder )
107 std::vector<ScDPResultFilter>& mrFilters;
109 explicit FilterStack(std::vector<ScDPResultFilter>& rFilters) : mrFilters(rFilters) {}
111 void pushDimName(
const OUString& rName,
bool bDataLayout)
113 mrFilters.emplace_back(rName, bDataLayout);
116 void pushDimValue(
const OUString& rValueName,
const OUString& rValue)
130 mrFilters.pop_back();
136class ScDPRowMembersOrder
149 bool operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const;
152class ScDPColMembersOrder
165 bool operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const;
178 bool bError1 = pAgg1 && pAgg1->
HasError();
179 bool bError2 = pAgg2 && pAgg2->
HasError();
192 return bAscending ? ( fVal1 < fVal2 ) : ( fVal1 > fVal2 );
204 bool bError1 = pAgg1 && pAgg1->
HasError();
205 bool bError2 = pAgg2 && pAgg2->
HasError();
223 return rtl::math::approxEqual( fVal1, fVal2 );
227bool ScDPRowMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const
239 return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending );
242bool ScDPColMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
const
244 const ScDPDataMember* pDataMember1 = rDimension.GetMember(nIndex1);
245 const ScDPDataMember* pDataMember2 = rDimension.GetMember(nIndex2);
246 bool bHide1 = pDataMember1 && !pDataMember1->
IsVisible();
247 bool bHide2 = pDataMember2 && !pDataMember2->
IsVisible();
248 if ( bHide1 || bHide2 )
250 return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending );
254 mnSrcIndex(nSrcIndex), mnNameIndex(nNameIndex) {}
258 maMembers.emplace_back(nSourceIndex, nMember);
263 OSL_ENSURE(!
maMembers.empty(),
"ScDPInitState::RemoveMember: Attempt to remove member while empty.");
272 const OUString& rType,
const OUString& rName,
const ScDPAggData* pAggData,
278 pDoc->
SetString( nCol++, nRow, nTab, rType );
279 pDoc->
SetString( nCol++, nRow, nTab, rName );
294 for (
SCROW nRow = nStartRow; nRow < rPos.
Row(); nRow++)
296 aString = pDoc->
GetString(nCol, nRow, nTab);
297 if (!aString.isEmpty())
299 aString =
" " + aString;
300 pDoc->
SetString( nCol, nRow, nTab, aString );
309 pColResRoot(pColRoot), pRowResRoot(pRowRoot)
338 OSL_ENSURE(!
maColVisible.empty() && !
maColSorted.empty(),
"ScDPRunningTotalState::RemoveColIndex: array is already empty!");
354 OSL_ENSURE(!
maRowVisible.empty() && !
maRowSorted.empty(),
"ScDPRunningTotalState::RemoveRowIndex: array is already empty!");
445 OSL_FAIL(
"invalid function");
499 OSL_FAIL(
"invalid function");
504 double fResult = 0.0;
534 fResult = sqrt( fResult);
548 fResult = sqrt( fResult);
560 assert(nSize ==
static_cast<size_t>(
nCount));
561 if ((nSize % 2) == 1)
569 OSL_FAIL(
"invalid function");
573 bool bEmpty = (
nCount == 0 );
588 if ( bEmpty || bError )
602 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
609 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
616 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
623 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
630 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
637 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
648 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
656 assert(
IsCalculated() &&
"ScDPAggData not calculated" );
680 std::string aIndent(nIndent*2,
' ');
681 std::cout << aIndent <<
"* ";
685 std::cout <<
"not calculated";
687 std::cout <<
" [val=" <<
fVal <<
"; aux=" <<
fAux <<
"; count=" <<
nCount <<
"]" << std::endl;
692 bIsInColRoot( false )
702 OSL_ENSURE( nMeasure >= 0,
"GetColTotal: no measure" );
741 if ( nSequence &&
aSeq[0] != sheet::GeneralFunction2::AUTO )
750 if ( nFuncNo >= 0 && nFuncNo < nSequence )
773 std::vector<ScSubTotalFunc>& rFunctions, std::vector<sheet::DataPilotFieldReference>& rRefs,
774 std::vector<sheet::DataPilotFieldOrientation>& rRefOrient, std::vector<OUString>& rNames )
797 bDataAtCol = ( nOrient == sheet::DataPilotFieldOrientation_COLUMN );
798 bDataAtRow = ( nOrient == sheet::DataPilotFieldOrientation_ROW );
844 rbTotalResult =
false;
851 return ScResId(aFuncStrIds[eForceFunc]);
853 rbTotalResult =
true;
854 return ScResId(STR_TABLE_ERGEBNIS);
862 const std::optional<OUString> & pLayoutName = pDataDim->
GetLayoutName();
878 OSL_FAIL(
"GetMeasureDimensionName: negative");
928 std::unique_ptr<ResultMembers> pResultMembers(
new ResultMembers());
936 tools::Long nSorted = rGlobalOrder.empty() ?
i : rGlobalOrder[
i];
941 pResultMembers->InsertMember(aNew);
951 pResultData(
pData ),
952 aParentDimData( rParentDimData ),
953 bHasElements( false ),
954 bForceSubTotal( false ),
955 bHasHiddenDetails( false ),
956 bInitialized( false ),
957 bAutoHidden( false ),
965 pResultData(
pData ),
966 bHasElements( false ),
967 bForceSubTotal( bForceSub ),
968 bHasHiddenDetails( false ),
969 bInitialized( false ),
970 bAutoHidden( false ),
984 return ScResId(STR_PIVOT_TOTAL);
1028 if (aMembers.size() < 2)
1031 vector<SCROW>::const_iterator itr = aMembers.begin();
1032 vector<SCROW> aChildMembers(++itr, aMembers.end());
1049 if (
nPos >= ppDim.size())
1057 while (
nPos < ppDim.size() )
1059 if ( ppDim[
nPos]->getIsDataLayoutDimension() )
1143 nSubTotals -= nUserSubStart;
1150 if ( nSubTotals == 1 )
1163 if ( pParentLevel && pParentLevel->
IsAddEmpty() )
1175 nUserSubCount -= nUserSubStart;
1176 if ( nUserSubCount )
1181 nSize += nUserSubCount;
1183 return nSize + nExtraSpace;
1190 return 1 + nExtraSpace;
1218 if ( pMemberDesc && !pMemberDesc->
isVisible() )
1229 if ( pUserSubStart )
1236 else if ( pParentLevel )
1242 if ( nSequence &&
aSeq[0] != sheet::GeneralFunction2::AUTO )
1248 if ( pUserSubStart )
1258 const vector< SCROW >& aDataMembers,
const vector<ScDPValue>& aValues )
1263 pChildDimension->ProcessData( aChildMembers, pDataDim, aDataMembers, aValues );
1283 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
1292 pDataRoot->ProcessData( aDataMembers, aValues, aSubState );
1302 OUStringBuffer aNewStr;
1303 sal_Int32
n = rSubStr.size();
1304 bool bEscaped =
false;
1305 for (sal_Int32
i = 0;
i <
n; ++
i)
1308 if (!bEscaped && c ==
'\\')
1314 if (!bEscaped && c ==
'?')
1315 aNewStr.append(rCaption);
1320 return aNewStr.makeStringAndClear();
1325 const OUString* pMemberName,
const OUString* pMemberCaption )
1330 if (!pSequences->hasElements())
1335 sheet::MemberResult* pArray = pSequences->getArray();
1336 OSL_ENSURE( rPos+nSize <= pSequences->
getLength(),
"bumm" );
1338 bool bIsNumeric =
false;
1339 double fValue = std::numeric_limits<double>::quiet_NaN();
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;
1412 pArray[rPos+
i].Flags |= sheet::MemberResultFlags::CONTINUE;
1415 pArray[rPos +
i].Flags |= sheet::MemberResultFlags::NUMERIC;
1425 pArray[rPos+
i].Name =
aName;
1426 pArray[rPos+
i].Caption = aCaption;
1427 pArray[rPos+
i].Flags |= sheet::MemberResultFlags::HASMEMBER;
1428 pArray[rPos+
i].Value = fValue;
1434 if ( pParentLevel && pParentLevel->
IsAddEmpty() )
1437 bool bTitleLine =
false;
1470 rPos -= nSubSize * (nUserSubCount - nUserSubStart);
1471 rPos -= nExtraSpace;
1473 for (
tools::Long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
1475 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
1478 nMemberMeasure = nSubCount;
1484 bool bTotalResult =
false;
1492 const std::optional<OUString> & pSubtotalName = pParentDim->
GetSubtotalName();
1495 pArray[rPos].Flags &= ~sheet::MemberResultFlags::GRANDTOTAL;
1501 if (pGrandTotalName)
1502 aSubStr = *pGrandTotalName;
1503 pArray[rPos].Flags |= sheet::MemberResultFlags::GRANDTOTAL;
1507 fValue = std::numeric_limits<double>::quiet_NaN();
1508 pArray[rPos].Name =
aName;
1509 pArray[rPos].Caption = aSubStr;
1510 pArray[rPos].Flags = ( pArray[rPos].Flags |
1511 ( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
1512 ~sheet::MemberResultFlags::CONTINUE;
1513 pArray[rPos].Value = fValue;
1520 uno::Sequence<sheet::MemberResult>* pLayoutSeq = pSequences;
1531 sheet::MemberResult* pLayoutArray = pLayoutSeq->getArray();
1540 rPos += nExtraSpace;
1548 std::unique_ptr<FilterStack> pFilterStack;
1553 pFilterStack.reset(
new FilterStack(rFilterCxt.
maFilters));
1560 sal_Int32 nStartRow = rFilterCxt.
mnRow;
1563 if ( pParentLevel && pParentLevel->
IsAddEmpty() )
1566 bool bTitleLine =
false;
1578 sal_Int32 nOldRow = rFilterCxt.
mnRow;
1579 pChildDimension->FillDataResults(pRefMember, rFilterCxt, rSequence, nMeasure);
1580 rFilterCxt.
mnRow = nOldRow;
1590 if ( !nUserSubCount && bHasChild )
1595 if ( !nUserSubCount || !bHasChild )
1605 rFilterCxt.
mnRow -= nSubSize * ( nUserSubCount - nUserSubStart );
1606 rFilterCxt.
mnRow -= nExtraSpace;
1610 if ( bSubTotalInTitle )
1612 nMoveSubTotal = rFilterCxt.
mnRow - nStartRow;
1613 rFilterCxt.
mnRow = nStartRow;
1620 for (
tools::Long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
1622 if ( bHasChild && nUserSubCount > 1 )
1628 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
1631 nMemberMeasure = nSubCount;
1635 OSL_ENSURE( rFilterCxt.
mnRow < rSequence.getLength(),
"bumm" );
1636 rFilterCxt.
mnCol = 0;
1639 uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rFilterCxt.
mnRow];
1640 pDataRoot->FillDataRow(pRefMember, rFilterCxt, rSubSeq, nMemberMeasure, bHasChild, aSubState);
1642 rFilterCxt.
mnRow += 1;
1647 rFilterCxt.
mnRow += nSubSize * ( nUserSubCount - nUserSubStart );
1651 rFilterCxt.
mnRow += nExtraSpace;
1652 rFilterCxt.
mnRow += nMoveSubTotal;
1668 if (!nUserSubCount || !bHasChild)
1678 for (
tools::Long nUserPos = 0; nUserPos < nUserSubCount; ++nUserPos)
1680 if (bHasChild && nUserSubCount > 1)
1686 for (
tools::Long nSubCount = 0; nSubCount < nSubSize; ++nSubCount)
1689 nMemberMeasure = nSubCount;
1693 pDataRoot->UpdateDataRow(pRefMember, nMemberMeasure, bHasChild, aSubState);
1758 if ( !nUserSubCount || !bHasChild )
1768 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
1770 if ( bHasChild && nUserSubCount > 1 )
1776 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
1779 nMemberMeasure = nSubCount;
1785 pRefMember, nMemberMeasure, bHasChild, aSubState, rRunning, rTotals, *
this);
1793 pChildDimension->UpdateRunningTotals( pRefMember, nMeasure, rRunning, rTotals );
1800 dumpRow(
"ScDPResultMember",
GetName(),
nullptr, pDoc, rPos);
1804 pDataRoot->DumpState( pRefMember, pDoc, rPos );
1809 indent(pDoc, nStartRow, rPos);
1814 std::string aIndent(nIndent*2,
' ');
1815 std::cout << aIndent <<
"-- result member '" <<
GetName() <<
"'" << std::endl;
1817 std::cout << aIndent <<
" column totals" << std::endl;
1826 std::cout << aIndent <<
" data root" << std::endl;
1844 pResultData(
pData ),
1845 pResultMember( pRes )
1929 size_t nCount = aValues.size();
1956 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
2007 OSL_ENSURE( nMeasure >= 0,
"GetAggData: no measure" );
2025 OSL_ENSURE( nMeasure >= 0,
"GetConstAggData: no measure" );
2047 uno::Sequence<sheet::DataResult>& rSequence,
tools::Long nMeasure,
bool bIsSubTotalRow,
2050 std::unique_ptr<FilterStack> pFilterStack;
2056 pFilterStack.reset(
new FilterStack(rFilterCxt.
maFilters));
2070 if ( pRefParentLevel && pRefParentLevel->
IsAddEmpty() )
2073 bool bTitleLine =
false;
2081 bool bHasChild = ( pRefChild != nullptr );
2091 pDataChild->
FillDataRow(pRefChild, rFilterCxt, rSequence, nMeasure, bIsSubTotalRow, rSubState);
2092 rFilterCxt.
mnCol = nOldCol;
2094 rFilterCxt.
mnCol +=
static_cast<sal_uInt16
>(pRefMember->
GetSize( nMeasure ));
2102 if ( !nUserSubCount && bHasChild )
2107 if ( !nUserSubCount || !bHasChild )
2119 rFilterCxt.
mnCol -= nSubSize * ( nUserSubCount - nUserSubStart );
2120 rFilterCxt.
mnCol -= nExtraSpace;
2124 if ( bSubTotalInTitle )
2126 nMoveSubTotal = rFilterCxt.
mnCol - nStartCol;
2127 rFilterCxt.
mnCol = nStartCol;
2130 for (
tools::Long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
2139 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
2142 nMemberMeasure = nSubCount;
2144 OSL_ENSURE( rFilterCxt.
mnCol < rSequence.getLength(),
"bumm" );
2145 sheet::DataResult& rRes = rSequence.getArray()[rFilterCxt.
mnCol];
2147 if (
HasData( nMemberMeasure, aLocalSubState ) )
2149 if (
HasError( nMemberMeasure, aLocalSubState ) )
2152 rRes.Flags |= sheet::DataResultFlags::ERROR;
2156 rRes.Value =
GetAggregate( nMemberMeasure, aLocalSubState );
2157 rRes.Flags |= sheet::DataResultFlags::HASDATA;
2161 if ( bHasChild || bIsSubTotalRow )
2162 rRes.Flags |= sheet::DataResultFlags::SUBTOTAL;
2165 rFilterCxt.
mnCol += 1;
2171 rFilterCxt.
mnCol += nExtraSpace;
2172 rFilterCxt.
mnCol += nMoveSubTotal;
2187 bool bHasChild = ( pRefChild != nullptr );
2194 if ( !nUserSubCount || !bHasChild )
2202 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
2211 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
2214 nMemberMeasure = nSubCount;
2223 sal_Int32 eRefType = aReferenceValue.ReferenceType;
2226 pAggData->
Calculate( eFunc, aLocalSubState );
2228 if ( eRefType == sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE ||
2229 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE ||
2230 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE )
2244 pDataChild->
UpdateDataRow( pRefChild, nMeasure, bIsSubTotalRow, rSubState );
2256 if ( pRefChild && pDataChild )
2269 if ( pRefChild && pDataChild )
2297 bool bHasChild = ( pRefChild != nullptr );
2303 if ( !nUserSubCount || !bHasChild )
2311 for (
tools::Long nUserPos=0; nUserPos<nUserSubCount; nUserPos++)
2320 for (
tools::Long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
2323 nMemberMeasure = nSubCount;
2331 sal_Int32 eRefType = aReferenceValue.ReferenceType;
2333 if ( eRefType == sheet::DataPilotFieldReferenceType::RUNNING_TOTAL ||
2334 eRefType == sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE ||
2335 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE ||
2336 eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE )
2338 bool bRunningTotal = ( eRefType == sheet::DataPilotFieldReferenceType::RUNNING_TOTAL );
2340 ( aReferenceValue.ReferenceItemType != sheet::DataPilotFieldReferenceItemType::NAMED && !bRunningTotal );
2342 ( ( aReferenceValue.ReferenceItemType == sheet::DataPilotFieldReferenceItemType::PREVIOUS ) ? -1 : 1 ) : 0;
2349 OUString aRefFieldName = aReferenceValue.ReferenceField;
2353 bool bRefDimInCol = ( nRefOrient == sheet::DataPilotFieldOrientation_COLUMN );
2354 bool bRefDimInRow = ( nRefOrient == sheet::DataPilotFieldOrientation_ROW );
2357 sal_Int32 nRowPos = 0;
2358 sal_Int32 nColPos = 0;
2365 while ( pSelectDim && pSelectDim->
GetName() != aRefFieldName )
2368 if (
nIndex >= 0 && nIndex < pSelectDim->GetMemberCount() )
2371 pSelectDim =
nullptr;
2375 if ( pSelectDim && rRowSorted[nRowPos] < 0 )
2376 pSelectDim =
nullptr;
2382 while ( pSelectDim && pSelectDim->
GetName() != aRefFieldName )
2385 if (
nIndex >= 0 && nIndex < pSelectDim->GetMemberCount() )
2388 pSelectDim =
nullptr;
2392 if ( pSelectDim && rColSorted[nColPos] < 0 )
2393 pSelectDim =
nullptr;
2396 bool bNoDetailsInRef =
false;
2397 if ( pSelectDim && bRunningTotal )
2404 tools::Long nMyIndex = bRefDimInCol ? rColSorted[nColPos] : rRowSorted[nRowPos];
2405 if ( nMyIndex >= 0 && nMyIndex < pSelectDim->GetMemberCount() )
2410 pSelectDim =
nullptr;
2411 bNoDetailsInRef =
true;
2432 if ( bInnerNoDetails )
2434 pSelectDim =
nullptr;
2435 bNoDetailsInRef =
true;
2439 if ( !bRefDimInCol && !bRefDimInRow )
2440 bNoDetailsInRef =
true;
2444 if ( bRunningTotal )
2453 nColPos, rRunning );
2456 const sal_Int32* pRowSorted = rRowSorted.data();
2457 const sal_Int32* pColSorted = rColSorted.data();
2458 pRowSorted += nRowPos + 1;
2460 nullptr,
nullptr, pRowSorted, pColSorted);
2463 if ( pSelectMember )
2471 GetAggData( nMemberMeasure, aLocalSubState );
2484 else if (bNoDetailsInRef)
2495 OUString aRefItemName = aReferenceValue.ReferenceItemName;
2498 const OUString* pRefName =
nullptr;
2501 pRefPos = &aRefItemPos;
2503 pRefName = &aRefItemName;
2508 aRefItemPos.
nBasePos = rColVisible[nColPos];
2510 nColPos, rRunning );
2514 aRefItemPos.
nBasePos = rRowVisible[nRowPos];
2515 const sal_Int32* pRowSorted = rRowSorted.data();
2516 const sal_Int32* pColSorted = rColSorted.data();
2517 pRowSorted += nRowPos + 1;
2519 pRefPos, pRefName, pRowSorted, pColSorted);
2523 if ( pSelectMember ==
this &&
2524 eRefType != sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE )
2528 else if ( pSelectMember )
2530 const ScDPAggData* pOtherAggData = pSelectMember->
2532 OSL_ENSURE( pOtherAggData,
"no agg data" );
2533 if ( pOtherAggData )
2539 double fThisResult = pAggData->
GetResult();
2540 bool bError =
false;
2543 case sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE:
2544 fThisResult = fThisResult - fOtherResult;
2546 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE:
2547 if ( fOtherResult == 0.0 )
2550 fThisResult = fThisResult / fOtherResult;
2552 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
2553 if ( fOtherResult == 0.0 )
2556 fThisResult = ( fThisResult - fOtherResult ) / fOtherResult;
2559 OSL_FAIL(
"invalid calculation type");
2573 else if (bRelative && !bNoDetailsInRef)
2578 else if (bNoDetailsInRef)
2584 else if ( eRefType == sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE ||
2585 eRefType == sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE ||
2586 eRefType == sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE ||
2587 eRefType == sheet::DataPilotFieldReferenceType::INDEX )
2598 if ( bIsRoot && rTotals.
IsInColRoot() && pGrandTotalData )
2601 if ( bIsRoot && pRowTotalData )
2611 case sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE:
2612 case sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE:
2613 case sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE:
2616 if ( eRefType == sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE )
2617 nTotal = pRowTotalData ? pRowTotalData->
GetAuxiliary() : 0.0;
2618 else if ( eRefType == sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE )
2619 nTotal = pColTotalData ? pColTotalData->
GetAuxiliary() : 0.0;
2621 nTotal = pGrandTotalData ? pGrandTotalData->
GetAuxiliary() : 0.0;
2623 if ( nTotal == 0.0 )
2629 case sheet::DataPilotFieldReferenceType::INDEX:
2631 double nColTotal = pColTotalData ? pColTotalData->
GetAuxiliary() : 0.0;
2632 double nRowTotal = pRowTotalData ? pRowTotalData->
GetAuxiliary() : 0.0;
2633 double nGrandTotal = pGrandTotalData ? pGrandTotalData->
GetAuxiliary() : 0.0;
2634 if ( nRowTotal == 0.0 || nColTotal == 0.0 )
2638 ( pAggData->
GetResult() * nGrandTotal ) /
2639 ( nRowTotal * nColTotal ) );
2653 bIsSubTotalRow, rSubState, rRunning, rTotals, rRowParent );
2665 if ( pDataChild && pRefChild )
2666 pDataChild->
DumpState( pRefChild, pDoc, rPos );
2668 indent(pDoc, nStartRow, rPos);
2673 std::string aIndent(nIndent*2,
' ');
2674 std::cout << aIndent <<
"-- data member '"
2677 pAgg->Dump(nIndent+1);
2689class ScDPGroupCompare
2701 bool IsIncluded(
const ScDPMember& rMember ) {
return bIncludeAll || TestIncluded( rMember ); }
2702 bool TestIncluded(
const ScDPMember& rMember );
2708 pResultData(
pData ),
2709 rInitState( rState ),
2710 nDimSource( nDimension )
2716 bIncludeAll = !( bIsBase || nGroupBase >= 0 );
2719bool ScDPGroupCompare::TestIncluded(
const ScDPMember& rMember )
2721 bool bInclude =
true;
2728 const std::vector<ScDPInitState::Member>& rMemStates = rInitState.GetMembers();
2729 bInclude = std::all_of(rMemStates.begin(), rMemStates.end(),
2731 return (pResultData->GetGroupBase(rMem.mnSrcIndex) != nDimSource)
2732 || pResultData->IsInGroup(rMem.mnNameIndex, rMem.mnSrcIndex, aMemberData, nDimSource);
2735 else if ( nGroupBase >= 0 )
2742 const std::vector<ScDPInitState::Member>& rMemStates = rInitState.GetMembers();
2743 bInclude = std::all_of(rMemStates.begin(), rMemStates.end(),
2747 return (pResultData->GetGroupBase(rMem.mnSrcIndex) != nGroupBase)
2748 || pResultData->HasCommonElement(rMem.mnNameIndex, rMem.mnSrcIndex, aMemberData, nDimSource);
2756 pResultData(
pData ),
2758 bIsDataLayout( false ),
2759 bSortByData( false ),
2760 bSortAscending( false ),
2762 bAutoTopItems( false ),
2763 bInitialized( false ),
2781 MemberHash::const_iterator aRes =
maMemberHash.find( iData );
2783 if ( aRes->second->IsNamedItem( iData ) )
2784 return aRes->second;
2785 OSL_FAIL(
"problem! hash result is not the same as IsNamedItem");
2794 return pResultMember;
2800 const vector<ScDPDimension*>& ppDim,
const vector<ScDPLevel*>& ppLev,
2803 if (
nPos >= ppDim.size() ||
nPos >= ppLev.size())
2812 if (!pThisDim || !pThisLevel)
2822 const sheet::DataPilotFieldAutoShowInfo& rAutoInfo = pThisLevel->
GetAutoShow();
2823 if ( rAutoInfo.IsEnabled )
2826 bAutoTopItems = ( rAutoInfo.ShowItemsMode == sheet::DataPilotFieldShowItemsMode::FROM_TOP );
2832 const sheet::DataPilotFieldSortInfo& rSortInfo = pThisLevel->
GetSortInfo();
2833 if ( rSortInfo.Mode == sheet::DataPilotFieldSortMode::DATA )
2844 ScDPGroupCompare aCompare(
pResultData, rInitState, nDimSource );
2851 tools::Long nSorted = rGlobalOrder.empty() ?
i : rGlobalOrder[
i];
2854 if ( aCompare.IsIncluded( *pMember ) )
2860 pNew->
InitFrom( ppDim, ppLev,
nPos+1, rInitState, bInitChild );
2872 if (
nPos >= pItemData.size())
2874 SAL_WARN(
"sc.core",
"pos " <<
nPos <<
", but vector size is " << pItemData.size());
2881 if (!pThisDim || !pThisLevel)
2894 const sheet::DataPilotFieldAutoShowInfo& rAutoInfo = pThisLevel->
GetAutoShow();
2895 if ( rAutoInfo.IsEnabled )
2898 bAutoTopItems = ( rAutoInfo.ShowItemsMode == sheet::DataPilotFieldShowItemsMode::FROM_TOP );
2903 const sheet::DataPilotFieldSortInfo& rSortInfo = pThisLevel->
GetSortInfo();
2904 if ( rSortInfo.Mode == sheet::DataPilotFieldSortMode::DATA )
2914 if ( !bLateInitAllMembers )
2924 bool bNewAllMembers = (!rParams.
IsRow()) ||
nPos == 0 || bLateInitAllMembers;
2926 if (bNewAllMembers )
2933 ScDPGroupCompare aCompare(
pResultData, rInitState, nDimSource );
2938 tools::Long nSorted = rGlobalOrder.empty() ?
i : rGlobalOrder[
i];
2941 if ( aCompare.IsIncluded( *pMember ) )
2950 if ( bLateInitAllMembers )
2958 bool bAllChildren =
false;
2961 bAllChildren = !pResultMember->
IsNamedItem( rThisData );
2972 if(
nullptr != pResultMember )
2994 "DataLayout dimension twice?");
3001 for (
tools::Long nMem=0; nMem<nMemberCount; nMem++)
3009 if (aMembers.empty())
3013 if (
nullptr != pMember )
3015#if OSL_DEBUG_LEVEL > 0
3016 SAL_INFO(
"sc.core",
"IsValidEntry: Member not found, DimNam = " <<
GetName());
3023 const vector< SCROW >& aDataMembers,
3024 const vector<ScDPValue>& aValues )
const
3026 if (aMembers.empty())
3030 if (
nullptr != pMember )
3032 vector<SCROW> aChildMembers;
3033 if (aMembers.size() > 1)
3035 vector<SCROW>::const_iterator itr = aMembers.begin();
3036 aChildMembers.insert(aChildMembers.begin(), ++itr, aMembers.end());
3038 pMember->
ProcessData( aChildMembers, pDataDim, aDataMembers, aValues );
3042 OSL_FAIL(
"ProcessData: Member not found");
3059 bool bTotalResult =
false;
3062 maMemberArray[0]->FillMemberResults( pSequences,
nPos, nSorted,
false, &aMbrName, &aMbrCapt );
3074 uno::Sequence< uno::Sequence<sheet::DataResult> >& rSequence,
tools::Long nMeasure)
const
3076 FilterStack aFilterStack(rFilterCxt.
maFilters);
3089 "DataLayout dimension twice?");
3091 nMemberMeasure = nSorted;
3097 pMember->
FillDataResults(pRefMember, rFilterCxt, rSequence, nMemberMeasure);
3111 "DataLayout dimension twice?");
3173 aAutoOrder.resize(
nCount );
3179 ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
3186 bool bContinue =
true;
3190 if ( nIncluded <
nCount )
3241 "DataLayout dimension twice?");
3243 nMemberMeasure = nSorted;
3262 const sal_Int32* pRowIndexes,
const sal_Int32* pColIndexes )
const
3266 OSL_ENSURE( pRelativePos ==
nullptr ||
pName ==
nullptr,
"can't use position and name" );
3270 bool bFirstExisting = ( pRelativePos ==
nullptr &&
pName == nullptr );
3277 nMemberIndex = pRelativePos->
nBasePos + nDirection;
3279 OSL_ENSURE( nDirection == 1 || nDirection == -1,
"Direction must be 1 or -1" );
3288 while ( pRowMember && pRowMember->
GetName() != *
pName )
3291 if ( nMemberIndex < nMemberCount )
3294 pRowMember =
nullptr;
3298 bool bContinue =
true;
3299 while ( bContinue && nMemberIndex >= 0 && nMemberIndex < nMemberCount )
3305 const sal_Int32* pNextRowIndex = pRowIndexes;
3306 while ( *pNextRowIndex >= 0 && pRowMember )
3310 pRowMember = pRowChild->
GetMember( *pNextRowIndex );
3312 pRowMember =
nullptr;
3316 if ( pRowMember && pRelativePos )
3323 pRowMember =
nullptr;
3330 const sal_Int32* pNextColIndex = pColIndexes;
3331 while ( *pNextColIndex >= 0 && pColMember )
3335 pColMember = pColChild->
GetMember( *pNextColIndex );
3337 pColMember =
nullptr;
3343 bContinue = ( pColMember ==
nullptr && ( bFirstExisting || pRelativePos ) );
3344 nMemberIndex += nDirection;
3354 OSL_ENSURE( pRelativePos ==
nullptr ||
pName ==
nullptr,
"can't use position and name" );
3356 const sal_Int32* pColIndexes = rRunning.
GetColSorted().data();
3357 const sal_Int32* pRowIndexes = rRunning.
GetRowSorted().data();
3364 const sal_Int32* pNextRowIndex = pRowIndexes;
3365 while ( *pNextRowIndex >= 0 && pRowMember )
3369 pRowMember = pRowChild->
GetMember( *pNextRowIndex );
3371 pRowMember =
nullptr;
3382 const sal_Int32* pNextColIndex = pColIndexes;
3383 sal_Int32 nColSkipped = 0;
3384 while ( *pNextColIndex >= 0 && pColMember && nColSkipped < nRefDimPos )
3388 pColMember = pColChild->
GetMember( *pNextColIndex );
3390 pColMember =
nullptr;
3401 if ( pReferenceDim )
3405 bool bFirstExisting = ( pRelativePos ==
nullptr &&
pName == nullptr );
3408 pColMember =
nullptr;
3412 nMemberIndex = pRelativePos->
nBasePos + nDirection;
3421 while ( pColMember && pColMember->
GetName() != *
pName )
3424 if ( nMemberIndex < nReferenceCount )
3427 pColMember =
nullptr;
3431 bool bContinue =
true;
3432 while ( bContinue && nMemberIndex >= 0 && nMemberIndex < nReferenceCount )
3438 const sal_Int32* pNextColIndex = pColIndexes + nRefDimPos + 1;
3439 while ( *pNextColIndex >= 0 && pColMember )
3443 pColMember = pColChild->
GetMember( *pNextColIndex );
3445 pColMember =
nullptr;
3449 if ( pColMember && pRelativePos )
3456 pColMember =
nullptr;
3460 bContinue = ( pColMember ==
nullptr && ( bFirstExisting || pRelativePos ) );
3461 nMemberIndex += nDirection;
3465 pColMember =
nullptr;
3475 dumpRow(
"ScDPResultDimension", aDimName,
nullptr, pDoc, rPos);
3483 pMember->
DumpState( pRefMember, pDoc, rPos );
3486 indent(pDoc, nStartRow, rPos);
3491 std::string aIndent(nIndent*2,
' ');
3492 std::cout << aIndent <<
"-- dimension '" <<
GetName() <<
"'" << std::endl;
3541 pResultData(
pData ),
3542 pResultDimension( nullptr ),
3543 bIsDataLayout( false )
3594 vector<SCROW> aChildDataMembers;
3595 if (aDataMembers.size() > 1)
3597 vector<SCROW>::const_iterator itr = aDataMembers.begin();
3598 aChildDataMembers.insert(aChildDataMembers.begin(), ++itr, aDataMembers.end());
3600 pMember->
ProcessData( aChildDataMembers, aValues, rSubState );
3605 OSL_FAIL(
"ProcessData: Member not found");
3610 uno::Sequence<sheet::DataResult>& rSequence,
tools::Long nMeasure,
bool bIsSubTotalRow,
3614 bool bDataLayout =
false;
3621 FilterStack aFilterStack(rFilterCxt.
maFilters);
3622 aFilterStack.pushDimName(aDimName, bDataLayout);
3624 OSL_ENSURE( pRefDim &&
static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3633 tools::Long nSorted = rMemberOrder.empty() ?
i : rMemberOrder[
i];
3639 "DataLayout dimension twice?");
3641 nMemberMeasure = nSorted;
3648 pDataMember->
FillDataRow(pRefMember, rFilterCxt, rSequence, nMemberMeasure, bIsSubTotalRow, rSubState);
3657 OSL_ENSURE( pRefDim &&
static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3668 "DataLayout dimension twice?");
3676 pDataMember->
UpdateDataRow( pRefMember, nMemberMeasure, bIsSubTotalRow, rSubState );
3689 OSL_ENSURE( rMemberOrder.empty(),
"sort twice?" );
3690 rMemberOrder.resize(
nCount );
3695 ::std::sort( rMemberOrder.begin(), rMemberOrder.end(), aComp );
3700 OSL_ENSURE( pRefDim &&
static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3722 OSL_ENSURE( pRefDim &&
static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3743 aAutoOrder.resize(
nCount );
3749 ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
3756 pDataMember1 =
nullptr;
3757 bool bContinue =
true;
3761 if ( nIncluded <
nCount )
3765 pDataMember2 =
nullptr;
3803 return rMemberOrder.empty() ? nUnsorted : rMemberOrder[nUnsorted];
3811 OSL_ENSURE( pRefDim &&
static_cast<size_t>(pRefDim->
GetMemberCount()) ==
maMembers.size(),
"dimensions don't match" );
3819 tools::Long nSorted = rMemberOrder.empty() ?
i : rMemberOrder[
i];
3825 "DataLayout dimension twice?");
3827 nMemberMeasure = nSorted;
3840 pRefMember, nMemberMeasure, bIsSubTotalRow, rSubState, rRunning, rTotals, rRowParent);
3850 OUString aDimName =
bIsDataLayout ? OUString(
"(data layout)") : OUString(
"(unknown)");
3851 dumpRow(
"ScDPDataDimension", aDimName,
nullptr, pDoc, rPos);
3860 pDataMember->
DumpState( pRefMember, pDoc, rPos );
3863 indent(pDoc, nStartRow, rPos);
3868 std::string aIndent(nIndent*2,
' ');
3869 std::cout << aIndent <<
"-- data dimension '"
3872 rxMember->Dump(nIndent+1);
3903 DimMemberType::iterator itr =
maDimensions.find(rDimName);
3906 pair<DimMemberType::iterator, bool> r =
maDimensions.emplace(
3916 rMem.insert(rMemberItem);
3921 typedef std::unordered_map<OUString, tools::Long> FieldNameMapType;
3924 sal_Int32 nColumnCount =
pData->GetColumnCount();
3925 for (sal_Int32
i = 0;
i < nColumnCount; ++
i)
3934 FieldNameMapType::const_iterator itrField =
aFieldNames.find(rDimName);
3941 aCri.
mpFilter = std::make_shared<ScDPFilteredCache::GroupFilter>();
3953 GetLevelsObject()->getByIndex(0)->GetMembersObject();
3955 rFilters.push_back(aCri);
3962 return static_cast<size_t>(::rtl::math::approxFloor(r.
GetValue()));
3968 const ScDPMember* pMemberDesc = GetDPMember();
3978 maMemberArray.emplace_back( pMember );
3980 maMemberHash.emplace( nDataIndex, pMember );
3987 if ( !lcl_SearchMember( maMemberArray, pMemberData->
mnOrder , nInsert ) )
3990 maMemberArray.emplace( maMemberArray.begin()+nInsert, pNew );
3993 maMemberHash.emplace( nDataIndex, pNew );
3996 return maMemberArray[ nInsert ].get();
4000 LateInitParams& rParams,
const std::vector<SCROW>& pItemData,
size_t nPos,
4009 if (!(pThisDim && pThisLevel))
4015 ResultMembers& rMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
4016 ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
4020 pResultMember = FindMember( nDataID );
4022 bInitialized =
true;
4024 if ( pResultMember ==
nullptr )
4027 if ( pMemberData && aCompare.IsIncluded( *( pMemberData->
mpMemberDesc ) ) )
4028 pResultMember = InsertMember( pMemberData );
4030 if ( pResultMember )
4039 mnOrder(-1), mpParentDim(nullptr), mpParentLevel(nullptr), mpMemberDesc(nullptr) {}
4043 mnOrder(
nIndex), mpParentDim(pDim), mpParentLevel(pLev), mpMemberDesc(pMember) {}
4049 if ( aRes->second.mpMemberDesc && aRes->second.mpMemberDesc->GetItemDataId()==
nIndex )
4050 return &aRes->second;
4062 mbHasHideDetailsMember( false )
4070 const vector<ScDPDimension*>& ppDim,
const vector<ScDPLevel*>& ppLev,
bool bRow ) :
4074 mbInitChild( true ),
4075 mbAllChildren( false )
const char *const aFieldNames[]
bool IsEnd(size_t nPos) const
void SetInitChild(bool b)
LateInitParams(const ::std::vector< ScDPDimension * > &ppDim, const ::std::vector< ScDPLevel * > &ppLev, bool bRow)
bool GetInitChild() const
const ::std::vector< ScDPDimension * > & mppDim
ScDPDimension * GetDim(size_t nPos) const
void SetInitAllChildren(bool b)
ScDPLevel * GetLevel(size_t nPos) const
bool GetInitAllChild() const
bool mbHasHideDetailsMember
std::unordered_map< SCROW, ScDPParentDimData > maMemberHash
void SetHasHideDetailsMembers(bool b)
const ScDPParentDimData * FindMember(SCROW nIndex) const
bool IsHasHideDetailsMembers() const
void InsertMember(ScDPParentDimData const &rNew)
bool IsCalculated() const
std::vector< double > mSortedValues
void Update(const ScDPValue &rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState &rSubState)
const ScDPAggData * GetExistingChild() const
void Dump(int nIndent) const
std::unique_ptr< ScDPAggData > pChild
void Calculate(ScSubTotalFunc eFunc, const ScDPSubTotalState &rSubState)
double GetAuxiliary() const
void SetAuxiliary(double fNew)
void SetResult(double fNew)
void UpdateDataRow(const ScDPResultDimension *pRefDim, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState) const
const ScDPResultData * pResultData
void DoAutoShow(ScDPResultDimension *pRefDim)
tools::Long GetSortedIndex(tools::Long nUnsorted) const
ScDPDataDimension(const ScDPResultData *pData)
or ptr to IntDimension?
void UpdateRunningTotals(const ScDPResultDimension *pRefDim, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals, const ScDPResultMember &rRowParent) const
const ScDPResultDimension * pResultDimension
std::vector< std::unique_ptr< ScDPDataMember > > maMembers
void SortMembers(ScDPResultDimension *pRefDim)
void ProcessData(const ::std::vector< SCROW > &aDataMembers, const ::std::vector< ScDPValue > &aValues, const ScDPSubTotalState &rSubState)
void DumpState(const ScDPResultDimension *pRefDim, ScDocument *pDoc, ScAddress &rPos) const
void Dump(int nIndent) const
tools::Long GetMemberCount() const
const ScDPDataMember * GetMember(tools::Long n) const
void FillDataRow(const ScDPResultDimension *pRefDim, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::sheet::DataResult > &rSequence, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState) const
void InitFrom(const ScDPResultDimension *pDim)
void UpdateValues(const ::std::vector< ScDPValue > &aValues, const ScDPSubTotalState &rSubState)
void Dump(int nIndent) const
const ScDPResultMember * pResultMember
ScDPAggData * GetAggData(tools::Long nMeasure, const ScDPSubTotalState &rSubState)
void SortMembers(ScDPResultMember *pRefMember)
bool HasHiddenDetails() const
void InitFrom(const ScDPResultDimension *pDim)
ScDPDataMember(const ScDPResultData *pData, const ScDPResultMember *pRes)
void UpdateRunningTotals(const ScDPResultMember *pRefMember, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals, const ScDPResultMember &rRowParent)
bool HasError(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
void UpdateDataRow(const ScDPResultMember *pRefMember, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState)
void ProcessData(const ::std::vector< SCROW > &aChildMembers, const ::std::vector< ScDPValue > &aValues, const ScDPSubTotalState &rSubState)
void DumpState(const ScDPResultMember *pRefMember, ScDocument *pDoc, ScAddress &rPos) const
void DoAutoShow(ScDPResultMember *pRefMember)
double GetAggregate(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
const ScDPDataDimension * GetChildDimension() const
this will be removed!
bool IsNamedItem(SCROW nRow) const
const ScDPResultData * pResultData
bool HasData(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
std::unique_ptr< ScDPDataDimension > pChildDimension
Ref?
const ScDPAggData * GetConstAggData(tools::Long nMeasure, const ScDPSubTotalState &rSubState) const
void FillDataRow(const ScDPResultMember *pRefMember, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::sheet::DataResult > &rSequence, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState &rSubState) const
ScDPHierarchies * GetHierarchiesObject()
const std::optional< OUString > & GetLayoutName() const
virtual OUString SAL_CALL getName() override
bool getIsDataLayoutDimension() const
sal_Int32 GetDimension() const
const std::optional< OUString > & GetSubtotalName() const
ScDPDimension * getByIndex(tools::Long nIndex) const
multi-item (group) filter.
void addMatchItem(const ScDPItemData &rItem)
size_t getMatchItemCount() const
ScDPHierarchy * getByIndex(tools::Long nIndex) const
Member names that are being processed for InitFrom/LateInitFrom (needed for initialization of grouped...
void AddMember(tools::Long nSourceIndex, SCROW nMember)
std::vector< Member > maMembers
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
OUString GetString() const
ScDPMembers * GetMembersObject()
const css::sheet::DataPilotFieldAutoShowInfo & GetAutoShow() const
sal_Int32 GetAutoMeasure() const
const css::sheet::DataPilotFieldSortInfo & GetSortInfo() const
sal_Int32 GetSortMeasure() const
const ::std::vector< sal_Int32 > & GetGlobalOrder() const
bool getShowEmpty() const
css::uno::Sequence< sal_Int16 > getSubTotals() const
bool IsOutlineLayout() const
bool getRepeatItemLabels() const
bool getShowDetails() const
SCROW GetItemDataId() const
bool IsNamedItem(SCROW nIndex) const
tools::Long GetDim() const
ScDPItemData FillItemData() const
OUString GetNameStr(bool bLocaleIndependent) const
const std::optional< OUString > & GetLayoutName() const
sal_Int32 getCount() const
ScDPMember * getByIndex(sal_Int32 nIndex) const
The term 'measure' here roughly equals "data dimension" ?
void SetDataLayoutOrientation(css::sheet::DataPilotFieldOrientation nOrient)
bool IsNumOrDateGroup(tools::Long nDim) const
tools::Long GetGroupBase(tools::Long nGroupDim) const
css::sheet::DataPilotFieldOrientation GetMeasureRefOrient(tools::Long nMeasure) const
void SetMeasureData(std::vector< ScSubTotalFunc > &rFunctions, std::vector< css::sheet::DataPilotFieldReference > &rRefs, std::vector< css::sheet::DataPilotFieldOrientation > &rRefOrient, std::vector< OUString > &rNames)
ScSubTotalFunc GetMeasureFunction(tools::Long nMeasure) const
std::vector< css::sheet::DataPilotFieldReference > maMeasureRefs
ScDPResultData(ScDPSource &rSrc)
const css::sheet::DataPilotFieldReference & GetMeasureRefVal(tools::Long nMeasure) const
tools::Long GetCountForMeasure(tools::Long nMeas) const
void SetLateInit(bool bSet)
OUString GetMeasureString(tools::Long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool &rbTotalResult) const
tools::Long GetRowStartMeasure() const
OUString GetMeasureDimensionName(tools::Long nMeasure) const
std::vector< ScSubTotalFunc > maMeasureFuncs
keep things like measure lists here
tools::Long GetMeasureCount() const
std::vector< std::unique_ptr< ResultMembers > > maDimMembers
add "displayed values" settings
bool HasCommonElement(SCROW nFirstDataId, tools::Long nFirstIndex, const ScDPItemData &rSecondData, tools::Long nSecondIndex) const
std::vector< OUString > maMeasureNames
tools::Long GetColStartMeasure() const
std::vector< css::sheet::DataPilotFieldOrientation > maMeasureRefOrients
bool IsInGroup(SCROW nGroupDataId, tools::Long nGroupIndex, const ScDPItemData &rBaseData, tools::Long nBaseIndex) const
const ScDPSource & GetSource() const
bool IsBaseForGroup(tools::Long nDim) const
ResultMembers & GetDimResultMembers(tools::Long nDim, const ScDPDimension *pDim, ScDPLevel *pLevel) const
tools::Long GetMemberCount() const
void FillVisibilityData(ScDPResultVisibilityData &rData) const
void InitWithMembers(LateInitParams &rParams, const ::std::vector< SCROW > &pItemData, size_t nPos, ScDPInitState &rInitState)
void SortMembers(ScDPResultMember *pRefMember)
void LateInitFrom(LateInitParams &rParams, const ::std::vector< SCROW > &pItemData, size_t nPos, ScDPInitState &rInitState)
bool IsValidEntry(const ::std::vector< SCROW > &aMembers) const
tools::Long GetSortMeasure() const
void DoAutoShow(ScDPResultMember *pRefMember)
bool IsSortAscending() const
void UpdateRunningTotals(const ScDPResultMember *pRefMember, tools::Long nMeasure, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals) const
void UpdateDataResults(const ScDPResultMember *pRefMember, tools::Long nMeasure) const
ScDPDataMember * GetRowReferenceMember(const ScDPRelativePos *pMemberPos, const OUString *pName, const sal_Int32 *pRowIndexes, const sal_Int32 *pColIndexes) const
void Dump(int nIndent) const
ScDPResultDimension * GetFirstChildDimension() const
ScDPResultMember * InsertMember(const ScDPParentDimData *pMemberData)
const ScMemberSortOrder & GetMemberOrder() const
MemberArray maMemberArray
ScDPResultMember * FindMember(SCROW iData) const
ScDPResultDimension(const ScDPResultData *pData)
void CheckShowEmpty(bool bShow=false)
void DumpState(const ScDPResultMember *pRefMember, ScDocument *pDoc, ScAddress &rPos) const
bool IsDataLayout() const
bool IsAutoTopItems() const
void FillMemberResults(css::uno::Sequence< css::sheet::MemberResult > *pSequences, tools::Long nStart, tools::Long nMeasure)
Test.
tools::Long GetAutoCount() const
tools::Long nSortMeasure
or ptr to IntDimension?
ScDPResultMember * AddMember(const ScDPParentDimData &aData)
tools::Long GetAutoMeasure() const
bool bSortByData
or ptr to IntDimension?
static ScDPDataMember * GetColReferenceMember(const ScDPRelativePos *pMemberPos, const OUString *pName, sal_Int32 nRefDimPos, const ScDPRunningTotalState &rRunning)
tools::Long GetSortedIndex(tools::Long nUnsorted) const
void ProcessData(const ::std::vector< SCROW > &aMembers, const ScDPResultDimension *pDataDim, const ::std::vector< SCROW > &aDataMembers, const ::std::vector< ScDPValue > &aValues) const
const ScDPResultMember * GetMember(tools::Long n) const
const ScDPResultData * pResultData
tools::Long GetSize(tools::Long nMeasure) const
void InitFrom(const ::std::vector< ScDPDimension * > &ppDim, const ::std::vector< ScDPLevel * > &ppLev, size_t nPos, ScDPInitState &rInitState, bool bInitChild=true)
bool IsSortByData() const
const OUString & GetName() const
void FillDataResults(const ScDPResultMember *pRefMember, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > &rSequence, tools::Long nMeasure) const
ScMemberSortOrder aMemberOrder
void ProcessData(const ::std::vector< SCROW > &aChildMembers, const ScDPResultDimension *pDataDim, const ::std::vector< SCROW > &aDataMembers, const ::std::vector< ScDPValue > &aValues)
void LateInitFrom(LateInitParams &rParams, const ::std::vector< SCROW > &pItemData, size_t nPos, ScDPInitState &rInitState)
const ScDPMember * GetDPMember() const
Ref.
const ScDPLevel * GetParentLevel() const
Ref.
std::unique_ptr< ScDPResultDimension > pChildDimension
void UpdateDataResults(const ScDPResultMember *pRefMember, tools::Long nMeasure) const
ScDPResultMember(const ScDPResultData *pData, const ScDPParentDimData &rParentDimData)
const ScDPResultData * pResultData
void FillDataResults(const ScDPResultMember *pRefMember, ScDPResultFilterContext &rFilterCxt, css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > &rSequence, tools::Long nMeasure) const
void InitFrom(const ::std::vector< ScDPDimension * > &ppDim, const ::std::vector< ScDPLevel * > &ppLev, size_t nPos, ScDPInitState &rInitState, bool bInitChild=true)
bool HasHiddenDetails() const
tools::Long GetSubTotalCount(tools::Long *pUserSubStart=nullptr) const
void CheckShowEmpty(bool bShow=false)
const ScDPDimension * GetParentDim() const
void Dump(int nIndent) const
void DoAutoShow(ScDPResultMember *pRefMember)
bool IsNamedItem(SCROW nIndex) const
const ScDPResultDimension * GetChildDimension() const
this will be removed!
void FillVisibilityData(ScDPResultVisibilityData &rData) const
bool IsSubTotalInTitle(tools::Long nMeasure) const
OUString GetDisplayName(bool bLocaleIndependent) const
ScDPItemData FillItemData() const
void FillMemberResults(css::uno::Sequence< css::sheet::MemberResult > *pSequences, tools::Long &rPos, tools::Long nMeasure, bool bRoot, const OUString *pMemberName, const OUString *pMemberCaption)
ScDPParentDimData aParentDimData
ScDPDataMember * GetDataRoot() const
void UpdateRunningTotals(const ScDPResultMember *pRefMember, tools::Long nMeasure, ScDPRunningTotalState &rRunning, ScDPRowTotals &rTotals) const
tools::Long GetSize(tools::Long nMeasure) const
ScDPAggData * GetColTotal(tools::Long nMeasure) const
void SortMembers(ScDPResultMember *pRefMember)
std::unique_ptr< ScDPDataMember > pDataRoot
void DumpState(const ScDPResultMember *pRefMember, ScDocument *pDoc, ScAddress &rPos) const
bool IsValidEntry(const ::std::vector< SCROW > &aMembers) const
void add(const std::vector< ScDPResultFilter > &rFilter, double fVal)
Add a single value filter path.
This class collects visible members of each dimension and uses that information to create filtering c...
~ScDPResultVisibilityData()
ScDPResultVisibilityData(ScDPSource *pSource)
void fillFieldFilters(::std::vector< ScDPFilteredCache::Criterion > &rFilters) const
void addVisibleMember(const OUString &rDimName, const ScDPItemData &rMemberItem)
DimMemberType maDimensions
std::unordered_set< ScDPItemData, MemberHash > VisibleMemberType
ScDPAggData * GetGrandTotal(tools::Long nMeasure)
void SetInColRoot(bool bSet)
ScDPAggData * GetRowTotal(tools::Long nMeasure)
indexes when calculating running totals
ScDPRunningTotalState(ScDPResultMember *pColRoot, ScDPResultMember *pRowRoot)
array of sal_Int32 terminated by -1.
void AddRowIndex(sal_Int32 nVisible, tools::Long nSorted)
std::vector< sal_Int32 > IndexArray
ScDPResultMember * GetRowResRoot() const
const IndexArray & GetRowVisible() const
const IndexArray & GetRowSorted() const
const IndexArray & GetColVisible() const
void AddColIndex(sal_Int32 nVisible, tools::Long nSorted)
const IndexArray & GetColSorted() const
ScDPResultMember * GetColResRoot() const
ScDPDimensions * GetDimensionsObject()
ScDPTableData * GetData()
OUString GetDataDimName(sal_Int32 nIndex)
const std::optional< OUString > & GetGrandTotalName() const
const ScDPItemData * GetItemDataById(sal_Int32 nDim, sal_Int32 nId)
ScDPDimension * GetDataDimension(sal_Int32 nIndex)
Base class that abstracts different data source types of a datapilot table.
virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const
virtual bool IsNumOrDateGroup(sal_Int32 nDim) const
virtual bool HasCommonElement(const ScDPItemData &rFirstData, sal_Int32 nFirstIndex, const ScDPItemData &rSecondData, sal_Int32 nSecondIndex) const
OUString GetFormattedString(sal_Int32 nDim, const ScDPItemData &rItem, bool bLocaleIndependent) const
virtual bool IsInGroup(const ScDPItemData &rGroupData, sal_Int32 nGroupIndex, const ScDPItemData &rBaseData, sal_Int32 nBaseIndex) const
virtual bool IsBaseForGroup(sal_Int32 nDim) const
static SC_DLLPUBLIC ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc)
static SC_DLLPUBLIC OUString getDisplayedMeasureName(const OUString &rName, ScSubTotalFunc eFunc)
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
static bool SafePlus(double &fVal1, double fVal2)
static bool SafeMult(double &fVal1, double fVal2)
Implements the Welford Online one-pass algorithm.
double getVariancePopulation() const
sal_uInt64 getCount() const
double getVarianceSample() const
static tools::Long lcl_GetSubTotalPos(const ScDPSubTotalState &rSubState)
const tools::Long SC_SUBTOTALPOS_AUTO
static ScDPAggData * lcl_GetChildTotal(ScDPAggData *pFirst, tools::Long nMeasure)
static bool lcl_IsEqual(const ScDPDataMember *pDataMember1, const ScDPDataMember *pDataMember2, tools::Long nMeasure)
static bool lcl_IsLess(const ScDPDataMember *pDataMember1, const ScDPDataMember *pDataMember2, tools::Long nMeasure, bool bAscending)
static ScSubTotalFunc lcl_GetForceFunc(const ScDPLevel *pLevel, tools::Long nFuncNo)
static OUString lcl_parseSubtotalName(std::u16string_view rSubStr, std::u16string_view rCaption)
Parse subtotal string and replace all occurrences of '?' with the caption string.
const tools::Long SC_SUBTOTALPOS_SKIP
::std::vector< sal_Int32 > ScMemberSortOrder
const sal_Int64 SC_DPAGG_RESULT_VALID
const sal_Int64 SC_DPAGG_RESULT_EMPTY
const sal_Int64 SC_DPAGG_RESULT_ERROR
const sal_Int64 SC_DPAGG_EMPTY
separate header file?
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2,...
@ AUTO
function is determined automatically.
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
double getLength(const B2DPolygon &rCandidate)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString ScResId(TranslateId aId)
single filtering criterion.
std::shared_ptr< FilterBase > mpFilter
Member(tools::Long nSrcIndex, SCROW nNameIndex)
const ScDPDimension * mpParentDim
Ref.
const ScDPMember * mpMemberDesc
Ref.
ScDPRelativePos(tools::Long nBase, tools::Long nDir)
std::vector< ScDPResultFilter > maFilters
ScDPResultTree maFilterSet
size_t operator()(const ScDPItemData &r) const
Select subtotal information, passed down the dimensions.
tools::Long nColSubTotalFunc
tools::Long nRowSubTotalFunc