LibreOffice Module sc (master)  1
dptabsrc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <dptabsrc.hxx>
21 
22 #include <algorithm>
23 #include <set>
24 #include <unordered_set>
25 #include <vector>
26 
27 #include <comphelper/sequence.hxx>
28 #include <o3tl/any.hxx>
29 #include <o3tl/safeint.hxx>
30 #include <osl/diagnose.h>
31 #include <rtl/math.hxx>
32 #include <sal/log.hxx>
33 #include <svl/itemprop.hxx>
34 #include <vcl/svapp.hxx>
35 
36 #include <dpcache.hxx>
37 #include <dptabres.hxx>
38 #include <dptabdat.hxx>
39 #include <global.hxx>
40 #include <miscuno.hxx>
41 #include <unonames.hxx>
42 #include <dpitemdata.hxx>
43 #include <dputil.hxx>
44 #include <dpresfilter.hxx>
45 #include <calcmacros.hxx>
46 #include <generalfunction.hxx>
47 
48 #include <com/sun/star/beans/PropertyAttribute.hpp>
49 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
50 #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
51 #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
52 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
53 #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
54 #include <com/sun/star/sheet/GeneralFunction2.hpp>
55 #include <com/sun/star/sheet/TableFilterField.hpp>
56 
58 #include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
59 
60 using namespace com::sun::star;
61 using ::std::vector;
62 using ::com::sun::star::uno::Sequence;
63 using ::com::sun::star::uno::Any;
64 using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo;
65 
66 #define SC_MINCOUNT_LIMIT 1000000
67 
68 SC_SIMPLE_SERVICE_INFO( ScDPSource, "ScDPSource", "com.sun.star.sheet.DataPilotSource" )
69 SC_SIMPLE_SERVICE_INFO( ScDPDimensions, "ScDPDimensions", "com.sun.star.sheet.DataPilotSourceDimensions" )
70 SC_SIMPLE_SERVICE_INFO( ScDPDimension, "ScDPDimension", "com.sun.star.sheet.DataPilotSourceDimension" )
71 
72 // Typos are on purpose here, quote from Eike Rathke (see https://gerrit.libreoffice.org/c/core/+/101116):
73 // "The typo is exactly why the SC_SIMPLE_SERVICE_INFO_COMPAT() lists both service names,
74 // the old with the typo and the new corrected one. Correcting the typo in the old name
75 // will make all extensions fail that use it. This is not to be changed."
77  "com.sun.star.sheet.DataPilotSourceHierarchies", "com.sun.star.sheet.DataPilotSourceHierarcies" )
79  "com.sun.star.sheet.DataPilotSourceHierarchy", "com.sun.star.sheet.DataPilotSourceHierarcy" )
80 
81 SC_SIMPLE_SERVICE_INFO( ScDPLevels, "ScDPLevels", "com.sun.star.sheet.DataPilotSourceLevels" )
82 SC_SIMPLE_SERVICE_INFO( ScDPLevel, "ScDPLevel", "com.sun.star.sheet.DataPilotSourceLevel" )
83 SC_SIMPLE_SERVICE_INFO( ScDPMembers, "ScDPMembers", "com.sun.star.sheet.DataPilotSourceMembers" )
84 SC_SIMPLE_SERVICE_INFO( ScDPMember, "ScDPMember", "com.sun.star.sheet.DataPilotSourceMember" )
85 
86 // property maps for PropertySetInfo
87 // DataDescription / NumberFormat are internal
88 
89 //TODO: move to a header?
90 static bool lcl_GetBoolFromAny( const uno::Any& aAny )
91 {
92  auto b = o3tl::tryAccess<bool>(aAny);
93  return b && *b;
94 }
95 
97  pData( pD ),
98  bColumnGrand( true ), // default is true
99  bRowGrand( true ),
100  bIgnoreEmptyRows( false ),
101  bRepeatIfEmpty( false ),
102  nDupCount( 0 ),
103  bResultOverflow( false ),
104  bPageFiltered( false )
105 {
107 }
108 
110 {
111  // free lists
112 
113  pColResults.reset();
114  pRowResults.reset();
115 
116  pColResRoot.reset();
117  pRowResRoot.reset();
118  pResData.reset();
119 }
120 
121 const std::optional<OUString> & ScDPSource::GetGrandTotalName() const
122 {
123  return mpGrandTotalName;
124 }
125 
126 sheet::DataPilotFieldOrientation ScDPSource::GetOrientation(long nColumn)
127 {
128  if (std::find(maColDims.begin(), maColDims.end(), nColumn) != maColDims.end())
129  return sheet::DataPilotFieldOrientation_COLUMN;
130 
131  if (std::find(maRowDims.begin(), maRowDims.end(), nColumn) != maRowDims.end())
132  return sheet::DataPilotFieldOrientation_ROW;
133 
134  if (std::find(maDataDims.begin(), maDataDims.end(), nColumn) != maDataDims.end())
135  return sheet::DataPilotFieldOrientation_DATA;
136 
137  if (std::find(maPageDims.begin(), maPageDims.end(), nColumn) != maPageDims.end())
138  return sheet::DataPilotFieldOrientation_PAGE;
139 
140  return sheet::DataPilotFieldOrientation_HIDDEN;
141 }
142 
144 {
145  return maDataDims.size();
146 }
147 
149 {
150  if (nIndex < 0 || o3tl::make_unsigned(nIndex) >= maDataDims.size())
151  return nullptr;
152 
153  long nDimIndex = maDataDims[nIndex];
154  return GetDimensionsObject()->getByIndex(nDimIndex);
155 }
156 
157 OUString ScDPSource::GetDataDimName(long nIndex)
158 {
159  OUString aRet;
160  ScDPDimension* pDim = GetDataDimension(nIndex);
161  if (pDim)
162  aRet = pDim->getName();
163  return aRet;
164 }
165 
166 long ScDPSource::GetPosition(long nColumn)
167 {
168  std::vector<long>::const_iterator it, itBeg = maColDims.begin(), itEnd = maColDims.end();
169  it = std::find(itBeg, itEnd, nColumn);
170  if (it != itEnd)
171  return std::distance(itBeg, it);
172 
173  itBeg = maRowDims.begin();
174  itEnd = maRowDims.end();
175  it = std::find(itBeg, itEnd, nColumn);
176  if (it != itEnd)
177  return std::distance(itBeg, it);
178 
179  itBeg = maDataDims.begin();
180  itEnd = maDataDims.end();
181  it = std::find(itBeg, itEnd, nColumn);
182  if (it != itEnd)
183  return std::distance(itBeg, it);
184 
185  itBeg = maPageDims.begin();
186  itEnd = maPageDims.end();
187  it = std::find(itBeg, itEnd, nColumn);
188  if (it != itEnd)
189  return std::distance(itBeg, it);
190 
191  return 0;
192 }
193 
194 namespace {
195 
196 bool testSubTotal( bool& rAllowed, long nColumn, const std::vector<long>& rDims, ScDPSource* pSource )
197 {
198  rAllowed = true;
199  std::vector<long>::const_iterator it = rDims.begin(), itEnd = rDims.end();
200  for (; it != itEnd; ++it)
201  {
202  if (*it != nColumn)
203  continue;
204 
205  if ( pSource->IsDataLayoutDimension(nColumn) )
206  {
207  // no subtotals for data layout dim, no matter where
208  rAllowed = false;
209  return true;
210  }
211 
212  // no subtotals if no other dim but data layout follows
213  ++it;
214  if (it != itEnd && pSource->IsDataLayoutDimension(*it))
215  ++it;
216  if (it == itEnd)
217  rAllowed = false;
218 
219  return true; // found
220  }
221 
222  return false;
223 }
224 
225 void removeDim( long nRemove, std::vector<long>& rDims )
226 {
227  std::vector<long>::iterator it = std::find(rDims.begin(), rDims.end(), nRemove);
228  if (it != rDims.end())
229  rDims.erase(it);
230 }
231 
232 }
233 
234 bool ScDPSource::SubTotalAllowed(long nColumn)
235 {
236  //TODO: cache this at ScDPResultData
237  bool bAllowed = true;
238  if ( testSubTotal(bAllowed, nColumn, maColDims, this) )
239  return bAllowed;
240  if ( testSubTotal(bAllowed, nColumn, maRowDims, this) )
241  return bAllowed;
242  return bAllowed;
243 }
244 
245 void ScDPSource::SetOrientation(long nColumn, sheet::DataPilotFieldOrientation nNew)
246 {
247  //TODO: change to no-op if new orientation is equal to old?
248 
249  // remove from old list
250  removeDim(nColumn, maColDims);
251  removeDim(nColumn, maRowDims);
252  removeDim(nColumn, maDataDims);
253  removeDim(nColumn, maPageDims);
254 
255  // add to new list
256  switch (nNew)
257  {
258  case sheet::DataPilotFieldOrientation_COLUMN:
259  maColDims.push_back(nColumn);
260  break;
261  case sheet::DataPilotFieldOrientation_ROW:
262  maRowDims.push_back(nColumn);
263  break;
264  case sheet::DataPilotFieldOrientation_DATA:
265  maDataDims.push_back(nColumn);
266  break;
267  case sheet::DataPilotFieldOrientation_PAGE:
268  maPageDims.push_back(nColumn);
269  break;
270  // DataPilot Migration - Cache&&Performance
271  case sheet::DataPilotFieldOrientation_HIDDEN:
272  break;
273  default:
274  OSL_FAIL( "ScDPSource::SetOrientation: unexpected orientation" );
275  break;
276  }
277 }
278 
280 {
281  return nDim == pData->GetColumnCount();
282 }
283 
284 sheet::DataPilotFieldOrientation ScDPSource::GetDataLayoutOrientation()
285 {
287 }
288 
290 {
291  return pData->IsDateDimension(nDim);
292 }
293 
295 {
296  if (!pDimensions.is())
297  {
298  pDimensions = new ScDPDimensions(this);
299  }
300  return pDimensions.get();
301 }
302 
303 uno::Reference<container::XNameAccess> SAL_CALL ScDPSource::getDimensions()
304 {
305  return GetDimensionsObject();
306 }
307 
308 void ScDPSource::SetDupCount( long nNew )
309 {
310  nDupCount = nNew;
311 }
312 
313 ScDPDimension* ScDPSource::AddDuplicated(const OUString& rNewName)
314 {
315  OSL_ENSURE( pDimensions.is(), "AddDuplicated without dimensions?" );
316 
317  // re-use
318 
319  long nOldDimCount = pDimensions->getCount();
320  for (long i=0; i<nOldDimCount; i++)
321  {
322  ScDPDimension* pDim = pDimensions->getByIndex(i);
323  if (pDim && pDim->getName() == rNewName)
324  {
325  //TODO: test if pDim is a duplicate of source
326  return pDim;
327  }
328  }
329 
330  SetDupCount( nDupCount + 1 );
331  pDimensions->CountChanged(); // uses nDupCount
332 
333  return pDimensions->getByIndex( pDimensions->getCount() - 1 );
334 }
335 
337 {
338  // original source dimension or data layout dimension?
339  if ( nDim <= pData->GetColumnCount() )
340  return nDim;
341 
342  if ( nDim < pDimensions->getCount() )
343  {
344  ScDPDimension* pDimObj = pDimensions->getByIndex( nDim );
345  if ( pDimObj )
346  {
347  long nSource = pDimObj->GetSourceDim();
348  if ( nSource >= 0 )
349  return nSource;
350  }
351  }
352 
353  OSL_FAIL("GetSourceDim: wrong dim");
354  return nDim;
355 }
356 
357 uno::Sequence< uno::Sequence<sheet::DataResult> > SAL_CALL ScDPSource::getResults()
358 {
359  CreateRes_Impl(); // create pColResRoot and pRowResRoot
360 
361  if ( bResultOverflow ) // set in CreateRes_Impl
362  {
363  // no results available
364  throw uno::RuntimeException();
365  }
366 
367  long nColCount = pColResRoot->GetSize(pResData->GetColStartMeasure());
368  long nRowCount = pRowResRoot->GetSize(pResData->GetRowStartMeasure());
369 
370  // allocate full sequence
371  //TODO: leave out empty rows???
372 
373  uno::Sequence< uno::Sequence<sheet::DataResult> > aSeq( nRowCount );
374  uno::Sequence<sheet::DataResult>* pRowAry = aSeq.getArray();
375  for (long nRow = 0; nRow < nRowCount; nRow++)
376  {
377  uno::Sequence<sheet::DataResult> aColSeq( nColCount );
378  // use default values of DataResult
379  pRowAry[nRow] = aColSeq;
380  }
381 
382  ScDPResultFilterContext aFilterCxt;
383  pRowResRoot->FillDataResults(
384  pColResRoot.get(), aFilterCxt, aSeq, pResData->GetRowStartMeasure());
385 
386  maResFilterSet.swap(aFilterCxt.maFilterSet); // Keep this data for GETPIVOTDATA.
387 
388  return aSeq;
389 }
390 
391 uno::Sequence<double> ScDPSource::getFilteredResults(
392  const uno::Sequence<sheet::DataPilotFieldFilter>& aFilters )
393 {
394  if (maResFilterSet.empty())
395  getResults(); // Build result tree first.
396 
397  // Get result values from the tree.
398  const ScDPResultTree::ValuesType* pVals = maResFilterSet.getResults(aFilters);
399  if (pVals && !pVals->empty())
400  {
401  size_t n = pVals->size();
402  uno::Sequence<double> aRet(n);
403  for (size_t i = 0; i < n; ++i)
404  aRet[i] = (*pVals)[i];
405 
406  return aRet;
407  }
408 
409  if (aFilters.getLength() == 1)
410  {
411  // Try to get result from the leaf nodes.
412  double fVal = maResFilterSet.getLeafResult(aFilters[0]);
413  if (!std::isnan(fVal))
414  {
415  uno::Sequence<double> aRet(1);
416  aRet[0] = fVal;
417  return aRet;
418  }
419  }
420 
421  return uno::Sequence<double>();
422 }
423 
424 void SAL_CALL ScDPSource::refresh()
425 {
426  disposeData();
427 }
428 
429 void SAL_CALL ScDPSource::addRefreshListener( const uno::Reference<util::XRefreshListener >& )
430 {
431  OSL_FAIL("not implemented"); //TODO: exception?
432 }
433 
434 void SAL_CALL ScDPSource::removeRefreshListener( const uno::Reference<util::XRefreshListener >& )
435 {
436  OSL_FAIL("not implemented"); //TODO: exception?
437 }
438 
439 Sequence< Sequence<Any> > SAL_CALL ScDPSource::getDrillDownData(const Sequence<sheet::DataPilotFieldFilter>& aFilters)
440 {
441  long nColumnCount = GetData()->GetColumnCount();
442 
443  vector<ScDPFilteredCache::Criterion> aFilterCriteria;
444  for (const sheet::DataPilotFieldFilter& rFilter : aFilters)
445  {
446  const OUString& aFieldName = rFilter.FieldName;
447  for (long nCol = 0; nCol < nColumnCount; ++nCol)
448  {
449  if (aFieldName == pData->getDimensionName(nCol))
450  {
451  ScDPDimension* pDim = GetDimensionsObject()->getByIndex( nCol );
452  ScDPMembers* pMembers = pDim->GetHierarchiesObject()->getByIndex(0)->
453  GetLevelsObject()->getByIndex(0)->GetMembersObject();
454  sal_Int32 nIndex = pMembers->GetIndexFromName( rFilter.MatchValueName );
455  if ( nIndex >= 0 )
456  {
457  ScDPItemData aItem(pMembers->getByIndex(nIndex)->FillItemData());
458  aFilterCriteria.emplace_back( );
459  aFilterCriteria.back().mnFieldIndex = nCol;
460  aFilterCriteria.back().mpFilter =
461  std::make_shared<ScDPFilteredCache::SingleFilter>(aItem);
462  }
463  }
464  }
465  }
466 
467  // Take into account the visibilities of field members.
468  ScDPResultVisibilityData aResVisData(this);
469  pRowResRoot->FillVisibilityData(aResVisData);
470  pColResRoot->FillVisibilityData(aResVisData);
471  aResVisData.fillFieldFilters(aFilterCriteria);
472 
473  Sequence< Sequence<Any> > aTabData;
474  std::unordered_set<sal_Int32> aCatDims;
475  GetCategoryDimensionIndices(aCatDims);
476  pData->GetDrillDownData(aFilterCriteria, aCatDims, aTabData);
477  return aTabData;
478 }
479 
481 {
482  CreateRes_Impl(); // create pResData
483 
484  OUString aRet;
485  if ( pResData->GetMeasureCount() == 1 )
486  {
487  bool bTotalResult = false;
488  aRet = pResData->GetMeasureString(0, true, SUBTOTAL_FUNC_NONE, bTotalResult);
489  }
490 
491  // empty for more than one measure
492 
493  return aRet;
494 }
495 
497 {
498  bIgnoreEmptyRows = bSet;
500 }
501 
503 {
504  bRepeatIfEmpty = bSet;
506 }
507 
509 {
511 
512  if ( pResData )
513  {
514  // reset all data...
515 
516  pColResRoot.reset();
517  pRowResRoot.reset();
518  pResData.reset();
519  pColResults.reset();
520  pRowResults.reset();
521  aColLevelList.clear();
522  aRowLevelList.clear();
523  }
524 
525  pDimensions.clear(); // settings have to be applied (from SaveData) again!
526  SetDupCount( 0 );
527 
528  maColDims.clear();
529  maRowDims.clear();
530  maDataDims.clear();
531  maPageDims.clear();
532 
533  pData->DisposeData(); // cached entries etc.
534  bPageFiltered = false;
535  bResultOverflow = false;
536 }
537 
538 static long lcl_CountMinMembers(const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLevel, long nLevels )
539 {
540  // Calculate the product of the member count for those consecutive levels that
541  // have the "show all" flag, one following level, and the data layout dimension.
542 
543  long nTotal = 1;
544  long nDataCount = 1;
545  bool bWasShowAll = true;
546  long nPos = nLevels;
547  while ( nPos > 0 )
548  {
549  --nPos;
550 
551  if ( nPos+1 < nLevels && ppDim[nPos] == ppDim[nPos+1] )
552  {
553  OSL_FAIL("lcl_CountMinMembers: multiple levels from one dimension not implemented");
554  return 0;
555  }
556 
557  bool bDo = false;
558  if ( ppDim[nPos]->getIsDataLayoutDimension() )
559  {
560  // data layout dim doesn't interfere with "show all" flags
561  nDataCount = ppLevel[nPos]->GetMembersObject()->getCount();
562  if ( nDataCount == 0 )
563  nDataCount = 1;
564  }
565  else if ( bWasShowAll ) // "show all" set for all following levels?
566  {
567  bDo = true;
568  if ( !ppLevel[nPos]->getShowEmpty() )
569  {
570  // this level is counted, following ones are not
571  bWasShowAll = false;
572  }
573  }
574  if ( bDo )
575  {
576  long nThisCount = ppLevel[nPos]->GetMembersObject()->getMinMembers();
577  if ( nThisCount == 0 )
578  {
579  nTotal = 1; // empty level -> start counting from here
580  //TODO: start with visible elements in this level?
581  }
582  else
583  {
584  if ( nTotal >= LONG_MAX / nThisCount )
585  return LONG_MAX; // overflow
586  nTotal *= nThisCount;
587  }
588  }
589  }
590 
591  // always include data layout dim, even after restarting
592  if ( nTotal >= LONG_MAX / nDataCount )
593  return LONG_MAX; // overflow
594  nTotal *= nDataCount;
595 
596  return nTotal;
597 }
598 
599 void ScDPSource::FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &rHasAutoShow)
600 {
601  const std::vector<long>& rDims = bIsRow ? maRowDims : maColDims;
602  for (const auto& rDimIndex : rDims)
603  {
604  ScDPDimension* pDim = GetDimensionsObject()->getByIndex(rDimIndex);
605  long nHierarchy = ScDPDimension::getUsedHierarchy();
606  if ( nHierarchy >= ScDPHierarchies::getCount() )
607  nHierarchy = 0;
608  ScDPLevels* pLevels = pDim->GetHierarchiesObject()->getByIndex(nHierarchy)->GetLevelsObject();
609  long nCount = pLevels->getCount();
610 
611  //TODO: Test
612  if (pDim->getIsDataLayoutDimension() && maDataDims.size() < 2)
613  nCount = 0;
614  //TODO: Test
615 
616  for (long j = 0; j < nCount; ++j)
617  {
618  ScDPLevel* pLevel = pLevels->getByIndex(j);
619  pLevel->EvaluateSortOrder();
620 
621  // no layout flags for column fields, only for row fields
622  pLevel->SetEnableLayout( bIsRow );
623 
624  if ( pLevel->GetAutoShow().IsEnabled )
625  rHasAutoShow = true;
626 
627  if (bIsRow)
628  {
629  rInfo.aRowLevelDims.push_back(rDimIndex);
630  rInfo.aRowDims.push_back(pDim);
631  rInfo.aRowLevels.push_back(pLevel);
632  }
633  else
634  {
635  rInfo.aColLevelDims.push_back(rDimIndex);
636  rInfo.aColDims.push_back(pDim);
637  rInfo.aColLevels.push_back(pLevel);
638  }
639 
640  pLevel->GetMembersObject(); // initialize for groups
641  }
642  }
643 }
644 
645 namespace {
646 
647 class CategoryDimInserter
648 {
649  ScDPSource& mrSource;
650  std::unordered_set<sal_Int32>& mrCatDims;
651 public:
652  CategoryDimInserter(ScDPSource& rSource, std::unordered_set<sal_Int32>& rCatDims) :
653  mrSource(rSource),
654  mrCatDims(rCatDims) {}
655 
656  void operator() (long nDim)
657  {
658  if (!mrSource.IsDataLayoutDimension(nDim))
659  mrCatDims.insert(nDim);
660  }
661 };
662 
663 }
664 
665 void ScDPSource::GetCategoryDimensionIndices(std::unordered_set<sal_Int32>& rCatDims)
666 {
667  std::unordered_set<sal_Int32> aCatDims;
668 
669  CategoryDimInserter aInserter(*this, aCatDims);
670  std::for_each(maColDims.begin(), maColDims.end(), aInserter);
671  std::for_each(maRowDims.begin(), maRowDims.end(), aInserter);
672  std::for_each(maPageDims.begin(), maPageDims.end(), aInserter);
673 
674  rCatDims.swap(aCatDims);
675 }
676 
678 {
679  // #i117661# Repeated calls to ScDPFilteredCache::filterByPageDimension
680  // are invalid because rows are only hidden, never shown again. If
681  // FilterCacheByPageDimensions is called again, the cache table must
682  // be re-initialized. Currently, CreateRes_Impl always uses a fresh cache
683  // because ScDBDocFunc::DataPilotUpdate calls InvalidateData.
684 
685  if (bPageFiltered)
686  {
687  SAL_WARN( "sc.core","tried to apply page field filters several times");
688 
689  pData->DisposeData();
690  pData->CreateCacheTable(); // re-initialize the cache table
691  bPageFiltered = false;
692  }
693 
694  // filter table by page dimensions.
695  vector<ScDPFilteredCache::Criterion> aCriteria;
696  for (const auto& rDimIndex : maPageDims)
697  {
698  ScDPDimension* pDim = GetDimensionsObject()->getByIndex(rDimIndex);
699  long nField = pDim->GetDimension();
700 
701  ScDPMembers* pMems = pDim->GetHierarchiesObject()->getByIndex(0)->
702  GetLevelsObject()->getByIndex(0)->GetMembersObject();
703 
704  long nMemCount = pMems->getCount();
706  aFilter.mnFieldIndex = static_cast<sal_Int32>(nField);
707  aFilter.mpFilter = std::make_shared<ScDPFilteredCache::GroupFilter>();
708  ScDPFilteredCache::GroupFilter* pGrpFilter =
709  static_cast<ScDPFilteredCache::GroupFilter*>(aFilter.mpFilter.get());
710  for (long j = 0; j < nMemCount; ++j)
711  {
712  ScDPMember* pMem = pMems->getByIndex(j);
713  if (pMem->isVisible())
714  {
716  pGrpFilter->addMatchItem(aData);
717  }
718  }
719  if (pGrpFilter->getMatchItemCount() < o3tl::make_unsigned(nMemCount))
720  // there is at least one invisible item. Add this filter criterion to the mix.
721  aCriteria.push_back(aFilter);
722 
723  if (!pDim->HasSelectedPage())
724  continue;
725 
726  const ScDPItemData& rData = pDim->GetSelectedData();
727  aCriteria.emplace_back();
728  ScDPFilteredCache::Criterion& r = aCriteria.back();
729  r.mnFieldIndex = static_cast<sal_Int32>(nField);
730  r.mpFilter = std::make_shared<ScDPFilteredCache::SingleFilter>(rData);
731  }
732  if (!aCriteria.empty())
733  {
734  std::unordered_set<sal_Int32> aCatDims;
735  GetCategoryDimensionIndices(aCatDims);
736  pData->FilterCacheTable(aCriteria, aCatDims);
737  bPageFiltered = true;
738  }
739 }
740 
742 {
743  if (pResData)
744  return;
745 
746  sheet::DataPilotFieldOrientation nDataOrient = GetDataLayoutOrientation();
747  if (maDataDims.size() > 1 && ( nDataOrient != sheet::DataPilotFieldOrientation_COLUMN &&
748  nDataOrient != sheet::DataPilotFieldOrientation_ROW ) )
749  {
750  // if more than one data dimension, data layout orientation must be set
751  SetOrientation( pData->GetColumnCount(), sheet::DataPilotFieldOrientation_ROW );
752  nDataOrient = sheet::DataPilotFieldOrientation_ROW;
753  }
754 
755  // TODO: Aggregate pDataNames, pDataRefValues, nDataRefOrient, and
756  // eDataFunctions into a structure and use vector instead of static
757  // or pointer arrays.
758  vector<OUString> aDataNames;
759  vector<sheet::DataPilotFieldReference> aDataRefValues;
760  vector<ScSubTotalFunc> aDataFunctions;
761  vector<sheet::DataPilotFieldOrientation> aDataRefOrient;
762 
764 
765  // LateInit (initialize only those rows/children that are used) can be used unless
766  // any data dimension needs reference values from column/row dimensions
767  bool bLateInit = true;
768 
769  // Go through all data dimensions (i.e. fields) and build their meta data
770  // so that they can be passed on to ScDPResultData instance later.
771  // TODO: aggregate all of data dimension info into a structure.
772  for (const long nDimIndex : maDataDims)
773  {
774  // Get function for each data field.
775  ScDPDimension* pDim = GetDimensionsObject()->getByIndex(nDimIndex);
776  ScGeneralFunction eUser = pDim->getFunction();
777  if (eUser == ScGeneralFunction::AUTO)
778  {
779  //TODO: test for numeric data
780  eUser = ScGeneralFunction::SUM;
781  }
782 
783  // Map UNO's enum to internal enum ScSubTotalFunc.
784  aDataFunctions.push_back(ScDPUtil::toSubTotalFunc(eUser));
785 
786  // Get reference field/item information.
787  aDataRefValues.push_back(pDim->GetReferenceValue());
788  sheet::DataPilotFieldOrientation nDataRefOrient = sheet::DataPilotFieldOrientation_HIDDEN; // default if not used
789  sal_Int32 eRefType = aDataRefValues.back().ReferenceType;
790  if ( eRefType == sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE ||
791  eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE ||
792  eRefType == sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE ||
793  eRefType == sheet::DataPilotFieldReferenceType::RUNNING_TOTAL )
794  {
795  long nColumn = comphelper::findValue(
796  GetDimensionsObject()->getElementNames(), aDataRefValues.back().ReferenceField);
797  if ( nColumn >= 0 )
798  {
799  nDataRefOrient = GetOrientation(nColumn);
800  // need fully initialized results to find reference values
801  // (both in column or row dimensions), so updated values or
802  // differences to 0 can be displayed even for empty results.
803  bLateInit = false;
804  }
805  }
806 
807  aDataRefOrient.push_back(nDataRefOrient);
808 
809  aDataNames.push_back(pDim->getName());
810 
811  //TODO: modify user visible strings as in ScDPResultData::GetMeasureString instead!
812 
813  aDataNames.back() = ScDPUtil::getSourceDimensionName(aDataNames.back());
814 
815  //TODO: if the name is overridden by user, a flag must be set
816  //TODO: so the user defined name replaces the function string and field name.
817 
818  //TODO: the complete name (function and field) must be stored at the dimension
819 
820  long nSource = pDim->GetSourceDim();
821  if (nSource >= 0)
822  aInfo.aDataSrcCols.push_back(nSource);
823  else
824  aInfo.aDataSrcCols.push_back(nDimIndex);
825  }
826 
827  pResData.reset( new ScDPResultData(*this) );
828  pResData->SetMeasureData(aDataFunctions, aDataRefValues, aDataRefOrient, aDataNames);
829  pResData->SetDataLayoutOrientation(nDataOrient);
830  pResData->SetLateInit( bLateInit );
831 
832  bool bHasAutoShow = false;
833 
834  ScDPInitState aInitState;
835 
836  // Page field selections restrict the members shown in related fields
837  // (both in column and row fields). aInitState is filled with the page
838  // field selections, they are kept across the data iterator loop.
839 
840  for (const auto& rDimIndex : maPageDims)
841  {
842  ScDPDimension* pDim = GetDimensionsObject()->getByIndex(rDimIndex);
843  if ( pDim->HasSelectedPage() )
844  aInitState.AddMember(rDimIndex, GetCache()->GetIdByItemData(rDimIndex, pDim->GetSelectedData()));
845  }
846 
847  // Show grand total columns only when the option is set *and* there is at
848  // least one column field. Same for the grand total rows.
849  sheet::DataPilotFieldOrientation nDataLayoutOrient = GetDataLayoutOrientation();
850  long nColDimCount2 = maColDims.size() - (nDataLayoutOrient == sheet::DataPilotFieldOrientation_COLUMN ? 1 : 0);
851  long nRowDimCount2 = maRowDims.size() - (nDataLayoutOrient == sheet::DataPilotFieldOrientation_ROW ? 1 : 0);
852  bool bShowColGrand = bColumnGrand && nColDimCount2 > 0;
853  bool bShowRowGrand = bRowGrand && nRowDimCount2 > 0;
854  pColResRoot.reset( new ScDPResultMember(pResData.get(), bShowColGrand) );
855  pRowResRoot.reset( new ScDPResultMember(pResData.get(), bShowRowGrand) );
856 
857  FillCalcInfo(false, aInfo, bHasAutoShow);
858  long nColLevelCount = aInfo.aColLevels.size();
859 
860  pColResRoot->InitFrom( aInfo.aColDims, aInfo.aColLevels, 0, aInitState );
861  pColResRoot->SetHasElements();
862 
863  FillCalcInfo(true, aInfo, bHasAutoShow);
864  long nRowLevelCount = aInfo.aRowLevels.size();
865 
866  if ( nRowLevelCount > 0 )
867  {
868  // disable layout flags for the innermost row field (level)
869  aInfo.aRowLevels[nRowLevelCount-1]->SetEnableLayout( false );
870  }
871 
872  pRowResRoot->InitFrom( aInfo.aRowDims, aInfo.aRowLevels, 0, aInitState );
873  pRowResRoot->SetHasElements();
874 
875  // initialize members object also for all page dimensions (needed for numeric groups)
876  for (const auto& rDimIndex : maPageDims)
877  {
878  ScDPDimension* pDim = GetDimensionsObject()->getByIndex(rDimIndex);
879  long nHierarchy = ScDPDimension::getUsedHierarchy();
880  if ( nHierarchy >= ScDPHierarchies::getCount() )
881  nHierarchy = 0;
882 
883  ScDPLevels* pLevels = pDim->GetHierarchiesObject()->getByIndex(nHierarchy)->GetLevelsObject();
884  long nCount = pLevels->getCount();
885  for (long j=0; j<nCount; j++)
886  pLevels->getByIndex(j)->GetMembersObject(); // initialize for groups
887  }
888 
889  // pre-check: calculate minimum number of result columns / rows from
890  // levels that have the "show all" flag set
891 
892  long nMinColMembers = lcl_CountMinMembers( aInfo.aColDims, aInfo.aColLevels, nColLevelCount );
893  long nMinRowMembers = lcl_CountMinMembers( aInfo.aRowDims, aInfo.aRowLevels, nRowLevelCount );
894 
895  if ( nMinColMembers > MAXCOLCOUNT/*SC_MINCOUNT_LIMIT*/ || nMinRowMembers > SC_MINCOUNT_LIMIT )
896  {
897  // resulting table is too big -> abort before calculating
898  // (this relies on late init, so no members are allocated in InitFrom above)
899 
900  bResultOverflow = true;
901  return;
902  }
903 
905 
906  aInfo.aPageDims = maPageDims;
907  aInfo.pInitState = &aInitState;
908  aInfo.pColRoot = pColResRoot.get();
909  aInfo.pRowRoot = pRowResRoot.get();
910  pData->CalcResults(aInfo, false);
911 
912  pColResRoot->CheckShowEmpty();
913  pRowResRoot->CheckShowEmpty();
914 
915  // With all data processed, calculate the final results:
916 
917  // UpdateDataResults calculates all original results from the collected values,
918  // and stores them as reference values if needed.
919  pRowResRoot->UpdateDataResults( pColResRoot.get(), pResData->GetRowStartMeasure() );
920 
921  if ( bHasAutoShow ) // do the double calculation only if AutoShow is used
922  {
923  // Find the desired members and set bAutoHidden flag for the others
924  pRowResRoot->DoAutoShow( pColResRoot.get() );
925 
926  // Reset all results to empty, so they can be built again with data for the
927  // desired members only.
928  pColResRoot->ResetResults();
929  pRowResRoot->ResetResults();
930  pData->CalcResults(aInfo, true);
931 
932  // Call UpdateDataResults again, with the new (limited) values.
933  pRowResRoot->UpdateDataResults( pColResRoot.get(), pResData->GetRowStartMeasure() );
934  }
935 
936  // SortMembers does the sorting by a result dimension, using the original results,
937  // but not running totals etc.
938  pRowResRoot->SortMembers( pColResRoot.get() );
939 
940  // UpdateRunningTotals calculates running totals along column/row dimensions,
941  // differences from other members (named or relative), and column/row percentages
942  // or index values.
943  // Running totals and relative differences need to be done using the sorted values.
944  // Column/row percentages and index values must be done after sorting, because the
945  // results may no longer be in the right order (row total for percentage of row is
946  // always 1).
947  ScDPRunningTotalState aRunning( pColResRoot.get(), pRowResRoot.get() );
948  ScDPRowTotals aTotals;
949  pRowResRoot->UpdateRunningTotals( pColResRoot.get(), pResData->GetRowStartMeasure(), aRunning, aTotals );
950 
951 #if DUMP_PIVOT_TABLE
952  DumpResults();
953 #endif
954 }
955 
956 void ScDPSource::FillLevelList( sheet::DataPilotFieldOrientation nOrientation, std::vector<ScDPLevel*> &rList )
957 {
958  rList.clear();
959 
960  std::vector<long>* pDimIndex = nullptr;
961  switch (nOrientation)
962  {
963  case sheet::DataPilotFieldOrientation_COLUMN:
964  pDimIndex = &maColDims;
965  break;
966  case sheet::DataPilotFieldOrientation_ROW:
967  pDimIndex = &maRowDims;
968  break;
969  case sheet::DataPilotFieldOrientation_DATA:
970  pDimIndex = &maDataDims;
971  break;
972  case sheet::DataPilotFieldOrientation_PAGE:
973  pDimIndex = &maPageDims;
974  break;
975  default:
976  OSL_FAIL( "ScDPSource::FillLevelList: unexpected orientation" );
977  break;
978  }
979  if (!pDimIndex)
980  {
981  OSL_FAIL("invalid orientation");
982  return;
983  }
984 
986  for (const auto& rIndex : *pDimIndex)
987  {
988  ScDPDimension* pDim = pDims->getByIndex(rIndex);
989  OSL_ENSURE( pDim->getOrientation() == nOrientation, "orientations are wrong" );
990 
991  ScDPHierarchies* pHiers = pDim->GetHierarchiesObject();
992  long nHierarchy = ScDPDimension::getUsedHierarchy();
993  if ( nHierarchy >= ScDPHierarchies::getCount() )
994  nHierarchy = 0;
995  ScDPHierarchy* pHier = pHiers->getByIndex(nHierarchy);
996  ScDPLevels* pLevels = pHier->GetLevelsObject();
997  long nLevCount = pLevels->getCount();
998  for (long nLev=0; nLev<nLevCount; nLev++)
999  {
1000  ScDPLevel* pLevel = pLevels->getByIndex(nLev);
1001  rList.push_back(pLevel);
1002  }
1003  }
1004 }
1005 
1007 {
1008  if ( pColResults || pRowResults )
1009  return;
1010 
1011  CreateRes_Impl();
1012 
1013  if ( bResultOverflow ) // set in CreateRes_Impl
1014  {
1015  // no results available -> abort (leave empty)
1016  // exception is thrown in ScDPSource::getResults
1017  return;
1018  }
1019 
1020  FillLevelList( sheet::DataPilotFieldOrientation_COLUMN, aColLevelList );
1021  long nColLevelCount = aColLevelList.size();
1022  if (nColLevelCount)
1023  {
1024  long nColDimSize = pColResRoot->GetSize(pResData->GetColStartMeasure());
1025  pColResults.reset(new uno::Sequence<sheet::MemberResult>[nColLevelCount]);
1026  for (long i=0; i<nColLevelCount; i++)
1027  pColResults[i].realloc(nColDimSize);
1028 
1029  long nPos = 0;
1030  pColResRoot->FillMemberResults( pColResults.get(), nPos, pResData->GetColStartMeasure(),
1031  true, nullptr, nullptr );
1032  }
1033 
1034  FillLevelList( sheet::DataPilotFieldOrientation_ROW, aRowLevelList );
1035  long nRowLevelCount = aRowLevelList.size();
1036  if (nRowLevelCount)
1037  {
1038  long nRowDimSize = pRowResRoot->GetSize(pResData->GetRowStartMeasure());
1039  pRowResults.reset( new uno::Sequence<sheet::MemberResult>[nRowLevelCount] );
1040  for (long i=0; i<nRowLevelCount; i++)
1041  pRowResults[i].realloc(nRowDimSize);
1042 
1043  long nPos = 0;
1044  pRowResRoot->FillMemberResults( pRowResults.get(), nPos, pResData->GetRowStartMeasure(),
1045  true, nullptr, nullptr );
1046  }
1047 }
1048 
1049 const uno::Sequence<sheet::MemberResult>* ScDPSource::GetMemberResults( const ScDPLevel* pLevel )
1050 {
1052 
1053  long i = 0;
1054  long nColCount = aColLevelList.size();
1055  for (i=0; i<nColCount; i++)
1056  {
1057  ScDPLevel* pColLevel = aColLevelList[i];
1058  if ( pColLevel == pLevel )
1059  return &pColResults[i];
1060  }
1061  long nRowCount = aRowLevelList.size();
1062  for (i=0; i<nRowCount; i++)
1063  {
1064  ScDPLevel* pRowLevel = aRowLevelList[i];
1065  if ( pRowLevel == pLevel )
1066  return &pRowResults[i];
1067  }
1068  return nullptr;
1069 }
1070 
1071 // XPropertySet
1072 
1073 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPSource::getPropertySetInfo()
1074 {
1075  SolarMutexGuard aGuard;
1076  using beans::PropertyAttribute::READONLY;
1077 
1078  static const SfxItemPropertyMapEntry aDPSourceMap_Impl[] =
1079  {
1080  { u"" SC_UNO_DP_COLGRAND, 0, cppu::UnoType<bool>::get(), 0, 0 },
1081  { u"" SC_UNO_DP_DATADESC, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0 },
1082  { u"" SC_UNO_DP_IGNOREEMPTY, 0, cppu::UnoType<bool>::get(), 0, 0 }, // for sheet data only
1083  { u"" SC_UNO_DP_REPEATEMPTY, 0, cppu::UnoType<bool>::get(), 0, 0 }, // for sheet data only
1084  { u"" SC_UNO_DP_ROWGRAND, 0, cppu::UnoType<bool>::get(), 0, 0 },
1089  { u"", 0, css::uno::Type(), 0, 0 }
1090  };
1091  static uno::Reference<beans::XPropertySetInfo> aRef =
1092  new SfxItemPropertySetInfo( aDPSourceMap_Impl );
1093  return aRef;
1094 }
1095 
1096 void SAL_CALL ScDPSource::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
1097 {
1098  if (aPropertyName == SC_UNO_DP_COLGRAND)
1099  bColumnGrand = lcl_GetBoolFromAny(aValue);
1100  else if (aPropertyName == SC_UNO_DP_ROWGRAND)
1101  bRowGrand = lcl_GetBoolFromAny(aValue);
1102  else if (aPropertyName == SC_UNO_DP_IGNOREEMPTY)
1104  else if (aPropertyName == SC_UNO_DP_REPEATEMPTY)
1105  setRepeatIfEmpty( lcl_GetBoolFromAny( aValue ) );
1106  else if (aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME)
1107  {
1108  OUString aName;
1109  if (aValue >>= aName)
1110  mpGrandTotalName = aName;
1111  }
1112  else
1113  {
1114  OSL_FAIL("unknown property");
1115  //TODO: THROW( UnknownPropertyException() );
1116  }
1117 }
1118 
1119 uno::Any SAL_CALL ScDPSource::getPropertyValue( const OUString& aPropertyName )
1120 {
1121  uno::Any aRet;
1122  if ( aPropertyName == SC_UNO_DP_COLGRAND )
1123  aRet <<= bColumnGrand;
1124  else if ( aPropertyName == SC_UNO_DP_ROWGRAND )
1125  aRet <<= bRowGrand;
1126  else if ( aPropertyName == SC_UNO_DP_IGNOREEMPTY )
1127  aRet <<= bIgnoreEmptyRows;
1128  else if ( aPropertyName == SC_UNO_DP_REPEATEMPTY )
1129  aRet <<= bRepeatIfEmpty;
1130  else if ( aPropertyName == SC_UNO_DP_DATADESC ) // read-only
1131  aRet <<= getDataDescription();
1132  else if ( aPropertyName == SC_UNO_DP_ROWFIELDCOUNT ) // read-only
1133  aRet <<= static_cast<sal_Int32>(maRowDims.size());
1134  else if ( aPropertyName == SC_UNO_DP_COLUMNFIELDCOUNT ) // read-only
1135  aRet <<= static_cast<sal_Int32>(maColDims.size());
1136  else if ( aPropertyName == SC_UNO_DP_DATAFIELDCOUNT ) // read-only
1137  aRet <<= static_cast<sal_Int32>(maDataDims.size());
1138  else if (aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME)
1139  {
1140  if (mpGrandTotalName)
1141  aRet <<= *mpGrandTotalName;
1142  }
1143  else
1144  {
1145  OSL_FAIL("unknown property");
1146  //TODO: THROW( UnknownPropertyException() );
1147  }
1148  return aRet;
1149 }
1150 
1151 #if DUMP_PIVOT_TABLE
1152 void ScDPSource::DumpResults() const
1153 {
1154  std::cout << "+++++ column root" << std::endl;
1155  pColResRoot->Dump(1);
1156  std::cout << "+++++ row root" << std::endl;
1157  pRowResRoot->Dump(1);
1158 }
1159 #endif
1160 
1162 
1164  pSource( pSrc )
1165 {
1166  //TODO: hold pSource
1167 
1168  // include data layout dimension and duplicated dimensions
1169  nDimCount = pSource->GetData()->GetColumnCount() + 1 + pSource->GetDupCount();
1170 }
1171 
1173 {
1174  //TODO: release pSource
1175 }
1176 
1178 {
1179  // include data layout dimension and duplicated dimensions
1180  long nNewCount = pSource->GetData()->GetColumnCount() + 1 + pSource->GetDupCount();
1181  if ( ppDims )
1182  {
1183  long i;
1184  long nCopy = std::min( nNewCount, nDimCount );
1186 
1187  for (i=0; i<nCopy; i++) // copy existing dims
1188  ppNew[i] = ppDims[i];
1189  for (i=nCopy; i<nNewCount; i++) // clear additional pointers
1190  ppNew[i] = nullptr;
1191 
1192  ppDims.reset( ppNew );
1193  }
1194  nDimCount = nNewCount;
1195 }
1196 
1197 // very simple XNameAccess implementation using getCount/getByIndex
1198 
1199 uno::Any SAL_CALL ScDPDimensions::getByName( const OUString& aName )
1200 {
1201  long nCount = getCount();
1202  for (long i=0; i<nCount; i++)
1203  if ( getByIndex(i)->getName() == aName )
1204  {
1205  uno::Reference<container::XNamed> xNamed = getByIndex(i);
1206  uno::Any aRet;
1207  aRet <<= xNamed;
1208  return aRet;
1209  }
1210 
1211  throw container::NoSuchElementException();
1212 // return uno::Any();
1213 }
1214 
1215 uno::Sequence<OUString> SAL_CALL ScDPDimensions::getElementNames()
1216 {
1217  long nCount = getCount();
1218  uno::Sequence<OUString> aSeq(nCount);
1219  OUString* pArr = aSeq.getArray();
1220  for (long i=0; i<nCount; i++)
1221  pArr[i] = getByIndex(i)->getName();
1222  return aSeq;
1223 }
1224 
1225 sal_Bool SAL_CALL ScDPDimensions::hasByName( const OUString& aName )
1226 {
1227  long nCount = getCount();
1228  for (long i=0; i<nCount; i++)
1229  if ( getByIndex(i)->getName() == aName )
1230  return true;
1231  return false;
1232 }
1233 
1235 {
1237 }
1238 
1240 {
1241  return ( getCount() > 0 );
1242 }
1243 
1244 // end of XNameAccess implementation
1245 
1247 {
1248  // in tabular data, every column of source data is a dimension
1249 
1250  return nDimCount;
1251 }
1252 
1254 {
1255  if ( nIndex >= 0 && nIndex < nDimCount )
1256  {
1257  if ( !ppDims )
1258  {
1259  const_cast<ScDPDimensions*>(this)->ppDims.reset(new rtl::Reference<ScDPDimension>[nDimCount] );
1260  for (long i=0; i<nDimCount; i++)
1261  ppDims[i] = nullptr;
1262  }
1263  if ( !ppDims[nIndex].is() )
1264  {
1265  ppDims[nIndex] = new ScDPDimension( pSource, nIndex );
1266  }
1267 
1268  return ppDims[nIndex].get();
1269  }
1270 
1271  return nullptr; //TODO: exception?
1272 }
1273 
1275  pSource( pSrc ),
1276  nDim( nD ),
1277  nFunction( ScGeneralFunction::SUM ), // sum is default
1278  nSourceDim( -1 ),
1279  bHasSelectedPage( false ),
1280  mbHasHiddenMember(false)
1281 {
1282  //TODO: hold pSource
1283 }
1284 
1286 {
1287  //TODO: release pSource
1288 }
1289 
1291 {
1292  if (!mxHierarchies.is())
1293  {
1294  mxHierarchies = new ScDPHierarchies( pSource, nDim );
1295  }
1296  return mxHierarchies.get();
1297 }
1298 
1299 const std::optional<OUString> & ScDPDimension::GetLayoutName() const
1300 {
1301  return mpLayoutName;
1302 }
1303 
1304 const std::optional<OUString> & ScDPDimension::GetSubtotalName() const
1305 {
1306  return mpSubtotalName;
1307 }
1308 
1309 uno::Reference<container::XNameAccess> SAL_CALL ScDPDimension::getHierarchies()
1310 {
1311  return GetHierarchiesObject();
1312 }
1313 
1314 OUString SAL_CALL ScDPDimension::getName()
1315 {
1316  if (!aName.isEmpty())
1317  return aName;
1318  else
1319  return pSource->GetData()->getDimensionName( nDim );
1320 }
1321 
1322 void SAL_CALL ScDPDimension::setName( const OUString& rNewName )
1323 {
1324  // used after cloning
1325  aName = rNewName;
1326 }
1327 
1328 sheet::DataPilotFieldOrientation ScDPDimension::getOrientation() const
1329 {
1330  return pSource->GetOrientation( nDim );
1331 }
1332 
1334 {
1335  return pSource->GetData()->getIsDataLayoutDimension( nDim );
1336 }
1337 
1339 {
1340  nFunction = nNew;
1341 }
1342 
1344 {
1345  OSL_ENSURE( nSourceDim < 0, "recursive duplicate - not implemented" );
1346 
1347  //TODO: set new name here, or temporary name ???
1348  OUString aNewName = aName;
1349 
1350  ScDPDimension* pNew = pSource->AddDuplicated( aNewName );
1351 
1352  pNew->aName = aNewName; //TODO: here or in source?
1353  pNew->nSourceDim = nDim; //TODO: recursive?
1354 
1355  return pNew;
1356 }
1357 
1358 uno::Reference<util::XCloneable> SAL_CALL ScDPDimension::createClone()
1359 {
1360  return CreateCloneObject();
1361 }
1362 
1364 {
1365  if ( !pSelectedData )
1366  {
1367  // find the named member to initialize pSelectedData from it, with name and value
1368 
1369  long nLevel = 0;
1370 
1371  long nHierarchy = getUsedHierarchy();
1372  if ( nHierarchy >= ScDPHierarchies::getCount() )
1373  nHierarchy = 0;
1374  ScDPLevels* pLevels = GetHierarchiesObject()->getByIndex(nHierarchy)->GetLevelsObject();
1375  long nLevCount = pLevels->getCount();
1376  if ( nLevel < nLevCount )
1377  {
1378  ScDPMembers* pMembers = pLevels->getByIndex(nLevel)->GetMembersObject();
1379 
1380  //TODO: merge with ScDPMembers::getByName
1381  long nCount = pMembers->getCount();
1382  for (long i=0; i<nCount && !pSelectedData; i++)
1383  {
1384  ScDPMember* pMember = pMembers->getByIndex(i);
1385  if (aSelectedPage == pMember->GetNameStr(false))
1386  {
1387  pSelectedData.reset( new ScDPItemData(pMember->FillItemData()) );
1388  }
1389  }
1390  }
1391 
1392  if ( !pSelectedData )
1393  pSelectedData.reset( new ScDPItemData(aSelectedPage) ); // default - name only
1394  }
1395 
1396  return *pSelectedData;
1397 }
1398 
1399 // XPropertySet
1400 
1401 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetInfo()
1402 {
1403  SolarMutexGuard aGuard;
1404 
1405  static const SfxItemPropertyMapEntry aDPDimensionMap_Impl[] =
1406  {
1408  { u"" SC_UNO_DP_FLAGS, 0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0 },
1411  { u"" SC_UNO_DP_ISDATALAYOUT, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0 },
1412  { u"" SC_UNO_DP_NUMBERFO, 0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0 },
1414  { u"" SC_UNO_DP_ORIGINAL, 0, cppu::UnoType<container::XNamed>::get(), beans::PropertyAttribute::READONLY, 0 },
1422  { u"", 0, css::uno::Type(), 0, 0 }
1423  };
1424  static uno::Reference<beans::XPropertySetInfo> aRef =
1425  new SfxItemPropertySetInfo( aDPDimensionMap_Impl );
1426  return aRef;
1427 }
1428 
1429 void SAL_CALL ScDPDimension::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
1430 {
1431  if ( aPropertyName == SC_UNO_DP_USEDHIERARCHY )
1432  {
1433  // #i52547# don't use the incomplete date hierarchy implementation - ignore the call
1434  }
1435  else if ( aPropertyName == SC_UNO_DP_ORIENTATION )
1436  {
1437  sheet::DataPilotFieldOrientation eEnum;
1438  if (aValue >>= eEnum)
1439  pSource->SetOrientation( nDim, eEnum );
1440  }
1441  else if ( aPropertyName == SC_UNO_DP_FUNCTION )
1442  {
1443  sheet::GeneralFunction eEnum;
1444  if (aValue >>= eEnum)
1445  setFunction( static_cast<ScGeneralFunction>(eEnum) );
1446  }
1447  else if ( aPropertyName == SC_UNO_DP_FUNCTION2 )
1448  {
1449  sal_Int16 eEnum;
1450  if (aValue >>= eEnum)
1451  setFunction( static_cast<ScGeneralFunction>(eEnum) );
1452  }
1453  else if ( aPropertyName == SC_UNO_DP_REFVALUE )
1454  aValue >>= aReferenceValue;
1455  else if ( aPropertyName == SC_UNO_DP_FILTER )
1456  {
1457  bool bDone = false;
1458  uno::Sequence<sheet::TableFilterField> aSeq;
1459  if (aValue >>= aSeq)
1460  {
1461  sal_Int32 nLength = aSeq.getLength();
1462  if ( nLength == 0 )
1463  {
1464  aSelectedPage.clear();
1465  bHasSelectedPage = false;
1466  bDone = true;
1467  }
1468  else if ( nLength == 1 )
1469  {
1470  const sheet::TableFilterField& rField = aSeq[0];
1471  if ( rField.Field == 0 && rField.Operator == sheet::FilterOperator_EQUAL && !rField.IsNumeric )
1472  {
1473  aSelectedPage = rField.StringValue;
1474  bHasSelectedPage = true;
1475  bDone = true;
1476  }
1477  }
1478  }
1479  if ( !bDone )
1480  {
1481  OSL_FAIL("Filter property is not a single string");
1482  throw lang::IllegalArgumentException();
1483  }
1484  pSelectedData.reset(); // invalid after changing aSelectedPage
1485  }
1486  else if (aPropertyName == SC_UNO_DP_LAYOUTNAME)
1487  {
1488  OUString aTmpName;
1489  if (aValue >>= aTmpName)
1490  mpLayoutName = aTmpName;
1491  }
1492  else if (aPropertyName == SC_UNO_DP_FIELD_SUBTOTALNAME)
1493  {
1494  OUString aTmpName;
1495  if (aValue >>= aTmpName)
1496  mpSubtotalName = aTmpName;
1497  }
1498  else if (aPropertyName == SC_UNO_DP_HAS_HIDDEN_MEMBER)
1499  {
1500  bool b = false;
1501  aValue >>= b;
1502  mbHasHiddenMember = b;
1503  }
1504  else
1505  {
1506  OSL_FAIL("unknown property");
1507  //TODO: THROW( UnknownPropertyException() );
1508  }
1509 }
1510 
1511 uno::Any SAL_CALL ScDPDimension::getPropertyValue( const OUString& aPropertyName )
1512 {
1513  uno::Any aRet;
1514  if ( aPropertyName == SC_UNO_DP_POSITION )
1515  aRet <<= static_cast<sal_Int32>(pSource->GetPosition( nDim ));
1516  else if ( aPropertyName == SC_UNO_DP_USEDHIERARCHY )
1517  aRet <<= static_cast<sal_Int32>(getUsedHierarchy());
1518  else if ( aPropertyName == SC_UNO_DP_ORIENTATION )
1519  {
1520  sheet::DataPilotFieldOrientation eVal = getOrientation();
1521  aRet <<= eVal;
1522  }
1523  else if ( aPropertyName == SC_UNO_DP_FUNCTION )
1524  {
1525  ScGeneralFunction nVal = getFunction();
1526  if (nVal == ScGeneralFunction::MEDIAN)
1527  nVal = ScGeneralFunction::NONE;
1528  const int nValAsInt = static_cast<int>(nVal);
1529  assert(nValAsInt >= int(css::sheet::GeneralFunction_NONE) &&
1530  nValAsInt <= int(css::sheet::GeneralFunction_VARP));
1531  aRet <<= static_cast<sheet::GeneralFunction>(nValAsInt);
1532  }
1533  else if ( aPropertyName == SC_UNO_DP_FUNCTION2 )
1534  {
1535  ScGeneralFunction eVal = getFunction();
1536  aRet <<= static_cast<sal_Int16>(eVal);
1537  }
1538  else if ( aPropertyName == SC_UNO_DP_REFVALUE )
1539  aRet <<= aReferenceValue;
1540  else if ( aPropertyName == SC_UNO_DP_ISDATALAYOUT ) // read-only properties
1541  aRet <<= getIsDataLayoutDimension();
1542  else if ( aPropertyName == SC_UNO_DP_NUMBERFO )
1543  {
1544  sal_Int32 nFormat = 0;
1545  ScGeneralFunction eFunc = getFunction();
1546  // #i63745# don't use source format for "count"
1547  if ( eFunc != ScGeneralFunction::COUNT && eFunc != ScGeneralFunction::COUNTNUMS )
1548  nFormat = pSource->GetData()->GetNumberFormat( ( nSourceDim >= 0 ) ? nSourceDim : nDim );
1549 
1550  switch ( aReferenceValue.ReferenceType )
1551  {
1552  case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE:
1553  case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
1554  case sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE:
1555  case sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE:
1556  case sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE:
1557  nFormat = pSource->GetData()->GetNumberFormatByIdx( NF_PERCENT_DEC2 );
1558  break;
1559  case sheet::DataPilotFieldReferenceType::INDEX:
1560  nFormat = pSource->GetData()->GetNumberFormatByIdx( NF_NUMBER_SYSTEM );
1561  break;
1562  default:
1563  break;
1564  }
1565 
1566  aRet <<= nFormat;
1567  }
1568  else if ( aPropertyName == SC_UNO_DP_ORIGINAL )
1569  {
1570  uno::Reference<container::XNamed> xOriginal;
1571  if (nSourceDim >= 0)
1572  xOriginal = pSource->GetDimensionsObject()->getByIndex(nSourceDim);
1573  aRet <<= xOriginal;
1574  }
1575  else if (aPropertyName == SC_UNO_DP_ORIGINAL_POS)
1576  {
1577  sal_Int32 nPos = static_cast<sal_Int32>(nSourceDim);
1578  aRet <<= nPos;
1579  }
1580  else if ( aPropertyName == SC_UNO_DP_FILTER )
1581  {
1582  if ( bHasSelectedPage )
1583  {
1584  // single filter field: first field equal to selected string
1585  sheet::TableFilterField aField( sheet::FilterConnection_AND, 0,
1586  sheet::FilterOperator_EQUAL, false, 0.0, aSelectedPage );
1587  aRet <<= uno::Sequence<sheet::TableFilterField>( &aField, 1 );
1588  }
1589  else
1590  aRet <<= uno::Sequence<sheet::TableFilterField>(0);
1591  }
1592  else if (aPropertyName == SC_UNO_DP_LAYOUTNAME)
1593  aRet <<= mpLayoutName ? *mpLayoutName : OUString();
1594  else if (aPropertyName == SC_UNO_DP_FIELD_SUBTOTALNAME)
1595  aRet <<= mpSubtotalName ? *mpSubtotalName : OUString();
1596  else if (aPropertyName == SC_UNO_DP_HAS_HIDDEN_MEMBER)
1597  aRet <<= mbHasHiddenMember;
1598  else if (aPropertyName == SC_UNO_DP_FLAGS)
1599  {
1600  aRet <<= sal_Int32(0); // tabular data: all orientations are possible
1601  }
1602  else
1603  {
1604  OSL_FAIL("unknown property");
1605  //TODO: THROW( UnknownPropertyException() );
1606  }
1607  return aRet;
1608 }
1609 
1611 
1613  pSource( pSrc ),
1614  nDim( nD )
1615 {
1616  //TODO: hold pSource
1617 }
1618 
1620 {
1621  //TODO: release pSource
1622 }
1623 
1624 // very simple XNameAccess implementation using getCount/getByIndex
1625 
1626 uno::Any SAL_CALL ScDPHierarchies::getByName( const OUString& aName )
1627 {
1628  long nCount = getCount();
1629  for (long i=0; i<nCount; i++)
1630  if ( getByIndex(i)->getName() == aName )
1631  {
1632  uno::Reference<container::XNamed> xNamed = getByIndex(i);
1633  uno::Any aRet;
1634  aRet <<= xNamed;
1635  return aRet;
1636  }
1637 
1638  throw container::NoSuchElementException();
1639 }
1640 
1641 uno::Sequence<OUString> SAL_CALL ScDPHierarchies::getElementNames()
1642 {
1643  long nCount = getCount();
1644  uno::Sequence<OUString> aSeq(nCount);
1645  OUString* pArr = aSeq.getArray();
1646  for (long i=0; i<nCount; i++)
1647  pArr[i] = getByIndex(i)->getName();
1648  return aSeq;
1649 }
1650 
1651 sal_Bool SAL_CALL ScDPHierarchies::hasByName( const OUString& aName )
1652 {
1653  long nCount = getCount();
1654  for (long i=0; i<nCount; i++)
1655  if ( getByIndex(i)->getName() == aName )
1656  return true;
1657  return false;
1658 }
1659 
1661 {
1663 }
1664 
1666 {
1667  return ( getCount() > 0 );
1668 }
1669 
1670 // end of XNameAccess implementation
1671 
1673 {
1674  return nHierCount;
1675 }
1676 
1678 {
1679  // pass hierarchy index to new object in case the implementation
1680  // will be extended to more than one hierarchy
1681 
1682  if ( nIndex >= 0 && nIndex < nHierCount )
1683  {
1684  if ( !ppHiers )
1685  {
1686  const_cast<ScDPHierarchies*>(this)->ppHiers.reset( new rtl::Reference<ScDPHierarchy>[nHierCount] );
1687  for (long i=0; i<nHierCount; i++)
1688  ppHiers[i] = nullptr;
1689  }
1690  if ( !ppHiers[nIndex].is() )
1691  {
1692  ppHiers[nIndex] = new ScDPHierarchy( pSource, nDim, nIndex );
1693  }
1694 
1695  return ppHiers[nIndex].get();
1696  }
1697 
1698  return nullptr; //TODO: exception?
1699 }
1700 
1701 ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) :
1702  pSource( pSrc ),
1703  nDim( nD ),
1704  nHier( nH )
1705 {
1706  //TODO: hold pSource
1707 }
1708 
1710 {
1711  //TODO: release pSource
1712 }
1713 
1715 {
1716  if (!mxLevels.is())
1717  {
1718  mxLevels = new ScDPLevels( pSource, nDim, nHier );
1719  }
1720  return mxLevels.get();
1721 }
1722 
1723 uno::Reference<container::XNameAccess> SAL_CALL ScDPHierarchy::getLevels()
1724 {
1725  return GetLevelsObject();
1726 }
1727 
1728 OUString SAL_CALL ScDPHierarchy::getName()
1729 {
1730  OUString aRet; //TODO: globstr-ID !!!!
1731  switch (nHier)
1732  {
1734  aRet = "flat";
1735  break; //TODO: name ???????
1737  aRet = "Quarter";
1738  break; //TODO: name ???????
1740  aRet = "Week";
1741  break; //TODO: name ???????
1742  default:
1743  OSL_FAIL( "ScDPHierarchy::getName: unexpected hierarchy" );
1744  break;
1745  }
1746  return aRet;
1747 }
1748 
1749 void SAL_CALL ScDPHierarchy::setName( const OUString& /* rNewName */ )
1750 {
1751  OSL_FAIL("not implemented"); //TODO: exception?
1752 }
1753 
1754 ScDPLevels::ScDPLevels( ScDPSource* pSrc, long nD, long nH ) :
1755  pSource( pSrc ),
1756  nDim( nD ),
1757  nHier( nH )
1758 {
1759  //TODO: hold pSource
1760 
1761  // text columns have only one level
1762 
1763  long nSrcDim = pSource->GetSourceDim( nDim );
1764  if ( pSource->IsDateDimension( nSrcDim ) )
1765  {
1766  switch ( nHier )
1767  {
1771  default:
1772  OSL_FAIL("wrong hierarchy");
1773  nLevCount = 0;
1774  }
1775  }
1776  else
1777  nLevCount = 1;
1778 }
1779 
1781 {
1782  //TODO: release pSource
1783 }
1784 
1785 // very simple XNameAccess implementation using getCount/getByIndex
1786 
1787 uno::Any SAL_CALL ScDPLevels::getByName( const OUString& aName )
1788 {
1789  long nCount = getCount();
1790  for (long i=0; i<nCount; i++)
1791  if ( getByIndex(i)->getName() == aName )
1792  {
1793  uno::Reference<container::XNamed> xNamed = getByIndex(i);
1794  uno::Any aRet;
1795  aRet <<= xNamed;
1796  return aRet;
1797  }
1798 
1799  throw container::NoSuchElementException();
1800 }
1801 
1802 uno::Sequence<OUString> SAL_CALL ScDPLevels::getElementNames()
1803 {
1804  long nCount = getCount();
1805  uno::Sequence<OUString> aSeq(nCount);
1806  OUString* pArr = aSeq.getArray();
1807  for (long i=0; i<nCount; i++)
1808  pArr[i] = getByIndex(i)->getName();
1809  return aSeq;
1810 }
1811 
1812 sal_Bool SAL_CALL ScDPLevels::hasByName( const OUString& aName )
1813 {
1814  long nCount = getCount();
1815  for (long i=0; i<nCount; i++)
1816  if ( getByIndex(i)->getName() == aName )
1817  return true;
1818  return false;
1819 }
1820 
1822 {
1824 }
1825 
1827 {
1828  return ( getCount() > 0 );
1829 }
1830 
1831 // end of XNameAccess implementation
1832 
1834 {
1835  return nLevCount;
1836 }
1837 
1839 {
1840  if ( nIndex >= 0 && nIndex < nLevCount )
1841  {
1842  if ( !ppLevs )
1843  {
1844  const_cast<ScDPLevels*>(this)->ppLevs.reset(new rtl::Reference<ScDPLevel>[nLevCount] );
1845  for (long i=0; i<nLevCount; i++)
1846  ppLevs[i] = nullptr;
1847  }
1848  if ( !ppLevs[nIndex].is() )
1849  {
1850  ppLevs[nIndex] = new ScDPLevel( pSource, nDim, nHier, nIndex );
1851  }
1852 
1853  return ppLevs[nIndex].get();
1854  }
1855 
1856  return nullptr; //TODO: exception?
1857 }
1858 
1859 namespace {
1860 
1861 class ScDPGlobalMembersOrder
1862 {
1863  ScDPLevel& rLevel;
1864  bool bAscending;
1865 
1866 public:
1867  ScDPGlobalMembersOrder( ScDPLevel& rLev, bool bAsc ) :
1868  rLevel(rLev),
1869  bAscending(bAsc)
1870  {}
1871 
1872  bool operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 ) const;
1873 };
1874 
1875 }
1876 
1877 bool ScDPGlobalMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 ) const
1878 {
1879  sal_Int32 nCompare = 0;
1880  // seems that some ::std::sort() implementations pass the same index twice
1881  if( nIndex1 != nIndex2 )
1882  {
1883  ScDPMembers* pMembers = rLevel.GetMembersObject();
1884  ScDPMember* pMember1 = pMembers->getByIndex(nIndex1);
1885  ScDPMember* pMember2 = pMembers->getByIndex(nIndex2);
1886  nCompare = pMember1->Compare( *pMember2 );
1887  }
1888  return bAscending ? (nCompare < 0) : (nCompare > 0);
1889 }
1890 
1891 ScDPLevel::ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL ) :
1892  pSource( pSrc ),
1893  nDim( nD ),
1894  nHier( nH ),
1895  nLev( nL ),
1896  aSortInfo( EMPTY_OUSTRING, true, sheet::DataPilotFieldSortMode::NAME ), // default: sort by name
1897  nSortMeasure( 0 ),
1898  nAutoMeasure( 0 ),
1899  bShowEmpty( false ),
1900  bEnableLayout( false ),
1901  bRepeatItemLabels( false )
1902 {
1903  //TODO: hold pSource
1904  // aSubTotals is empty
1905 }
1906 
1908 {
1909  //TODO: release pSource
1910 }
1911 
1913 {
1914  switch (aSortInfo.Mode)
1915  {
1916  case sheet::DataPilotFieldSortMode::DATA:
1917  {
1918  // find index of measure (index among data dimensions)
1919 
1920  long nMeasureCount = pSource->GetDataDimensionCount();
1921  for (long nMeasure=0; nMeasure<nMeasureCount; nMeasure++)
1922  {
1923  if (pSource->GetDataDimName(nMeasure) == aSortInfo.Field)
1924  {
1925  nSortMeasure = nMeasure;
1926  break;
1927  }
1928  }
1929 
1930  //TODO: error if not found?
1931  }
1932  break;
1933  case sheet::DataPilotFieldSortMode::MANUAL:
1934  case sheet::DataPilotFieldSortMode::NAME:
1935  {
1936  ScDPMembers* pLocalMembers = GetMembersObject();
1937  long nCount = pLocalMembers->getCount();
1938 
1939  aGlobalOrder.resize( nCount );
1940  for (long nPos=0; nPos<nCount; nPos++)
1941  aGlobalOrder[nPos] = nPos;
1942 
1943  // allow manual or name (manual is always ascending)
1944  bool bAscending = ( aSortInfo.Mode == sheet::DataPilotFieldSortMode::MANUAL || aSortInfo.IsAscending );
1945  ScDPGlobalMembersOrder aComp( *this, bAscending );
1946  ::std::sort( aGlobalOrder.begin(), aGlobalOrder.end(), aComp );
1947  }
1948  break;
1949  }
1950 
1951  if ( !aAutoShowInfo.IsEnabled )
1952  return;
1953 
1954  // find index of measure (index among data dimensions)
1955 
1956  long nMeasureCount = pSource->GetDataDimensionCount();
1957  for (long nMeasure=0; nMeasure<nMeasureCount; nMeasure++)
1958  {
1959  if (pSource->GetDataDimName(nMeasure) == aAutoShowInfo.DataField)
1960  {
1961  nAutoMeasure = nMeasure;
1962  break;
1963  }
1964  }
1965 
1966  //TODO: error if not found?
1967 }
1968 
1970 {
1971  bEnableLayout = bSet;
1972 }
1973 
1975 {
1976  if (!mxMembers.is())
1977  {
1978  mxMembers = new ScDPMembers( pSource, nDim, nHier, nLev );
1979  }
1980  return mxMembers.get();
1981 }
1982 
1983 uno::Reference<sheet::XMembersAccess> SAL_CALL ScDPLevel::getMembers()
1984 {
1985  return GetMembersObject();
1986 }
1987 
1988 uno::Sequence<sheet::MemberResult> SAL_CALL ScDPLevel::getResults()
1989 {
1990  const uno::Sequence<sheet::MemberResult>* pRes = pSource->GetMemberResults( this );
1991  if (pRes)
1992  return *pRes;
1993 
1994  return uno::Sequence<sheet::MemberResult>(0); //TODO: Error?
1995 }
1996 
1997 OUString SAL_CALL ScDPLevel::getName()
1998 {
1999  long nSrcDim = pSource->GetSourceDim( nDim );
2000  if ( pSource->IsDateDimension( nSrcDim ) )
2001  {
2002  OUString aRet; //TODO: globstr-ID !!!!
2003 
2005  {
2006  switch ( nLev )
2007  {
2008  case SC_DAPI_LEVEL_YEAR:
2009  aRet = "Year";
2010  break;
2011  case SC_DAPI_LEVEL_QUARTER:
2012  aRet = "Quarter";
2013  break;
2014  case SC_DAPI_LEVEL_MONTH:
2015  aRet = "Month";
2016  break;
2017  case SC_DAPI_LEVEL_DAY:
2018  aRet = "Day";
2019  break;
2020  default:
2021  OSL_FAIL( "ScDPLevel::getName: unexpected level" );
2022  break;
2023  }
2024  }
2025  else if ( nHier == SC_DAPI_HIERARCHY_WEEK )
2026  {
2027  switch ( nLev )
2028  {
2029  case SC_DAPI_LEVEL_YEAR:
2030  aRet = "Year";
2031  break;
2032  case SC_DAPI_LEVEL_WEEK:
2033  aRet = "Week";
2034  break;
2035  case SC_DAPI_LEVEL_WEEKDAY:
2036  aRet = "Weekday";
2037  break;
2038  default:
2039  OSL_FAIL( "ScDPLevel::getName: unexpected level" );
2040  break;
2041  }
2042  }
2043  if (!aRet.isEmpty())
2044  return aRet;
2045  }
2046 
2047  ScDPDimension* pDim = pSource->GetDimensionsObject()->getByIndex(nSrcDim);
2048  if (!pDim)
2049  return OUString();
2050 
2051  return pDim->getName();
2052 }
2053 
2054 void SAL_CALL ScDPLevel::setName( const OUString& /* rNewName */ )
2055 {
2056  OSL_FAIL("not implemented"); //TODO: exception?
2057 }
2058 
2059 uno::Sequence<sal_Int16> ScDPLevel::getSubTotals() const
2060 {
2061  //TODO: separate functions for settings and evaluation?
2062 
2063  long nSrcDim = pSource->GetSourceDim( nDim );
2064  if ( !pSource->SubTotalAllowed( nSrcDim ) )
2065  return uno::Sequence<sal_Int16>(0);
2066 
2067  return aSubTotals;
2068 }
2069 
2070 // XPropertySet
2071 
2072 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPLevel::getPropertySetInfo()
2073 {
2074  SolarMutexGuard aGuard;
2075 
2076  static const SfxItemPropertyMapEntry aDPLevelMap_Impl[] =
2077  {
2078  //TODO: change type of AutoShow/Layout/Sorting to API struct when available
2086  { u"", 0, css::uno::Type(), 0, 0 }
2087  };
2088  static uno::Reference<beans::XPropertySetInfo> aRef =
2089  new SfxItemPropertySetInfo( aDPLevelMap_Impl );
2090  return aRef;
2091 }
2092 
2093 void SAL_CALL ScDPLevel::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
2094 {
2095  if ( aPropertyName == SC_UNO_DP_SHOWEMPTY )
2096  bShowEmpty = lcl_GetBoolFromAny(aValue);
2097  else if ( aPropertyName == SC_UNO_DP_REPEATITEMLABELS )
2099  else if ( aPropertyName == SC_UNO_DP_SUBTOTAL )
2100  {
2101  uno::Sequence<sheet::GeneralFunction> aSeq;
2102  aValue >>= aSeq;
2103  aSubTotals.realloc(aSeq.getLength());
2104  std::transform(aSeq.begin(), aSeq.end(), aSubTotals.begin(),
2105  [](const sheet::GeneralFunction& rFunc) -> sal_Int16 {
2106  return static_cast<sal_Int16>(rFunc); });
2107  }
2108  else if ( aPropertyName == SC_UNO_DP_SUBTOTAL2 )
2109  aValue >>= aSubTotals;
2110  else if ( aPropertyName == SC_UNO_DP_SORTING )
2111  aValue >>= aSortInfo;
2112  else if ( aPropertyName == SC_UNO_DP_AUTOSHOW )
2113  aValue >>= aAutoShowInfo;
2114  else if ( aPropertyName == SC_UNO_DP_LAYOUT )
2115  aValue >>= aLayoutInfo;
2116  else
2117  {
2118  OSL_FAIL("unknown property");
2119  }
2120 }
2121 
2122 uno::Any SAL_CALL ScDPLevel::getPropertyValue( const OUString& aPropertyName )
2123 {
2124  uno::Any aRet;
2125  if ( aPropertyName == SC_UNO_DP_SHOWEMPTY )
2126  aRet <<= bShowEmpty;
2127  else if ( aPropertyName == SC_UNO_DP_REPEATITEMLABELS )
2128  aRet <<= bRepeatItemLabels;
2129  else if ( aPropertyName == SC_UNO_DP_SUBTOTAL )
2130  {
2131  const uno::Sequence<sal_Int16> aSeq = getSubTotals();
2132  uno::Sequence<sheet::GeneralFunction> aNewSeq;
2133  aNewSeq.realloc(aSeq.getLength());
2134  std::transform(aSeq.begin(), aSeq.end(), aNewSeq.begin(),
2135  [](const sal_Int16 nFunc) -> sheet::GeneralFunction {
2136  if (nFunc == sheet::GeneralFunction2::MEDIAN)
2137  return sheet::GeneralFunction_NONE;
2138  return static_cast<sheet::GeneralFunction>(nFunc);
2139  });
2140 
2141  aRet <<= aNewSeq;
2142  }
2143  else if ( aPropertyName == SC_UNO_DP_SUBTOTAL2 )
2144  {
2145  uno::Sequence<sal_Int16> aSeq = getSubTotals(); //TODO: avoid extra copy?
2146  aRet <<= aSeq;
2147  }
2148  else if ( aPropertyName == SC_UNO_DP_SORTING )
2149  aRet <<= aSortInfo;
2150  else if ( aPropertyName == SC_UNO_DP_AUTOSHOW )
2151  aRet <<= aAutoShowInfo;
2152  else if ( aPropertyName == SC_UNO_DP_LAYOUT )
2153  aRet <<= aLayoutInfo;
2154  else if (aPropertyName == SC_UNO_DP_LAYOUTNAME)
2155  {
2156  // read only property
2157  long nSrcDim = pSource->GetSourceDim(nDim);
2158  ScDPDimension* pDim = pSource->GetDimensionsObject()->getByIndex(nSrcDim);
2159  if (!pDim)
2160  return aRet;
2161 
2162  const std::optional<OUString> & pLayoutName = pDim->GetLayoutName();
2163  if (!pLayoutName)
2164  return aRet;
2165 
2166  aRet <<= *pLayoutName;
2167  }
2168  else
2169  {
2170  OSL_FAIL("unknown property");
2171  }
2172  return aRet;
2173 }
2174 
2176 
2177 ScDPMembers::ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL ) :
2178  pSource( pSrc ),
2179  nDim( nD ),
2180  nHier( nH ),
2181  nLev( nL )
2182 {
2183  //TODO: hold pSource
2184 
2185  long nSrcDim = pSource->GetSourceDim( nDim );
2186  if ( pSource->IsDataLayoutDimension(nSrcDim) )
2187  nMbrCount = pSource->GetDataDimensionCount();
2188  else if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) )
2189  {
2190  nMbrCount = 0;
2191  if ( nHier == SC_DAPI_HIERARCHY_QUARTER )
2192  {
2193  switch (nLev)
2194  {
2195  case SC_DAPI_LEVEL_YEAR:
2196  {
2197  const ScDPItemData* pLastNumData = nullptr;
2198  for ( SCROW n = 0; n < static_cast<SCROW>(pSource->GetData()->GetColumnEntries(nDim).size()); n-- )
2199  {
2200  const ScDPItemData* pData = GetSrcItemDataByIndex( n );
2201  if ( pData && pData->HasStringData() )
2202  break;
2203  else
2204  pLastNumData = pData;
2205  }
2206 
2207  if ( pLastNumData )
2208  {
2209  const ScDPItemData* pFirstData = GetSrcItemDataByIndex( 0 );
2210  double fFirstVal = pFirstData->GetValue();
2211  double fLastVal = pLastNumData->GetValue();
2212 
2213  long nFirstYear = pSource->GetData()->GetDatePart(
2214  static_cast<long>(::rtl::math::approxFloor( fFirstVal )),
2215  nHier, nLev );
2216  long nLastYear = pSource->GetData()->GetDatePart(
2217  static_cast<long>(::rtl::math::approxFloor( fLastVal )),
2218  nHier, nLev );
2219 
2220  nMbrCount = nLastYear + 1 - nFirstYear;
2221  }
2222  else
2223  nMbrCount = 0; // no values
2224  }
2225  break;
2226  case SC_DAPI_LEVEL_QUARTER: nMbrCount = 4; break;
2227  case SC_DAPI_LEVEL_MONTH: nMbrCount = 12; break;
2228  case SC_DAPI_LEVEL_DAY: nMbrCount = 31; break;
2229  default:
2230  OSL_FAIL( "ScDPMembers::ScDPMembers: unexpected level" );
2231  break;
2232  }
2233  }
2234  else if ( nHier == SC_DAPI_HIERARCHY_WEEK )
2235  {
2236  switch (nLev)
2237  {
2238  case SC_DAPI_LEVEL_YEAR: nMbrCount = 1; break; //TODO: get years from source
2239  case SC_DAPI_LEVEL_WEEK: nMbrCount = 53; break;
2240  case SC_DAPI_LEVEL_WEEKDAY: nMbrCount = 7; break;
2241  default:
2242  OSL_FAIL( "ScDPMembers::ScDPMembers: unexpected level" );
2243  break;
2244  }
2245  }
2246  }
2247  else
2248  nMbrCount = pSource->GetData()->GetMembersCount( nSrcDim );
2249 }
2250 
2252 {
2253 }
2254 
2255 // XNameAccess implementation using getCount/getByIndex
2256 
2257 sal_Int32 ScDPMembers::GetIndexFromName( const OUString& rName ) const
2258 {
2259  if ( aHashMap.empty() )
2260  {
2261  // store the index for each name
2262 
2263  sal_Int32 nCount = getCount();
2264  for (sal_Int32 i=0; i<nCount; i++)
2265  aHashMap[ getByIndex(i)->getName() ] = i;
2266  }
2267 
2268  ScDPMembersHashMap::const_iterator aIter = aHashMap.find( rName );
2269  if ( aIter != aHashMap.end() )
2270  return aIter->second; // found index
2271  else
2272  return -1; // not found
2273 }
2274 
2275 uno::Any SAL_CALL ScDPMembers::getByName( const OUString& aName )
2276 {
2277  sal_Int32 nIndex = GetIndexFromName( aName );
2278  if ( nIndex >= 0 )
2279  {
2280  uno::Reference<container::XNamed> xNamed = getByIndex(nIndex);
2281  uno::Any aRet;
2282  aRet <<= xNamed;
2283  return aRet;
2284  }
2285 
2286  throw container::NoSuchElementException();
2287 }
2288 
2289 uno::Sequence<OUString> SAL_CALL ScDPMembers::getElementNames()
2290 {
2291  return getElementNames( false );
2292 }
2293 
2294 sal_Bool SAL_CALL ScDPMembers::hasByName( const OUString& aName )
2295 {
2296  return ( GetIndexFromName( aName ) >= 0 );
2297 }
2298 
2300 {
2302 }
2303 
2305 {
2306  return ( getCount() > 0 );
2307 }
2308 
2309 // end of XNameAccess implementation
2310 
2311 // XMembersAccess implementation
2312 
2313 uno::Sequence<OUString> SAL_CALL ScDPMembers::getLocaleIndependentElementNames()
2314 {
2315  return getElementNames( true );
2316 }
2317 
2318 // end of XMembersAccess implementation
2319 
2320 uno::Sequence<OUString> ScDPMembers::getElementNames( bool bLocaleIndependent ) const
2321 {
2322  // Return list of names in sorted order,
2323  // so it's displayed in that order in the field options dialog.
2324  // Sorting is done at the level object (parent of this).
2325 
2326  ScDPLevel* pLevel = pSource->GetDimensionsObject()->getByIndex(nDim)->
2327  GetHierarchiesObject()->getByIndex(nHier)->GetLevelsObject()->getByIndex(nLev);
2328  pLevel->EvaluateSortOrder();
2329  const std::vector<sal_Int32>& rGlobalOrder = pLevel->GetGlobalOrder();
2330  bool bSort = !rGlobalOrder.empty();
2331 
2332  long nCount = getCount();
2333  uno::Sequence<OUString> aSeq(nCount);
2334  OUString* pArr = aSeq.getArray();
2335  for (long i=0; i<nCount; i++)
2336  pArr[i] = getByIndex(bSort ? rGlobalOrder[i] : i)->GetNameStr( bLocaleIndependent);
2337  return aSeq;
2338 }
2339 
2341 {
2342  // used in lcl_CountMinMembers
2343 
2344  long nVisCount = 0;
2345  if (!maMembers.empty())
2346  {
2347  nVisCount = std::count_if(maMembers.begin(), maMembers.end(), [](const rtl::Reference<ScDPMember>& pMbr) {
2348  // count only visible with details (default is true for both)
2349  return !pMbr || (pMbr->isVisible() && pMbr->getShowDetails()); });
2350  }
2351  else
2352  nVisCount = nMbrCount; // default for all
2353 
2354  return nVisCount;
2355 }
2356 
2358 {
2359  // result of GetColumnEntries must not change between ScDPMembers ctor
2360  // and all calls to getByIndex
2361 
2362  if ( nIndex >= 0 && nIndex < nMbrCount )
2363  {
2364  if (maMembers.empty())
2365  maMembers.resize(nMbrCount);
2366 
2367  if (!maMembers[nIndex])
2368  {
2370  long nSrcDim = pSource->GetSourceDim( nDim );
2371  if ( pSource->IsDataLayoutDimension(nSrcDim) )
2372  {
2373  // empty name (never shown, not used for lookup)
2374  pNew.set(new ScDPMember(pSource, nDim, nHier, nLev, 0));
2375  }
2376  else if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) )
2377  {
2378  sal_Int32 nGroupBy = 0;
2379  sal_Int32 nVal = 0;
2380  OUString aName;
2381 
2382  if ( nLev == SC_DAPI_LEVEL_YEAR ) // YEAR is in both hierarchies
2383  {
2384  //TODO: cache year range here!
2385 
2386  double fFirstVal = pSource->GetData()->GetMemberByIndex( nSrcDim, 0 )->GetValue();
2387  long nFirstYear = pSource->GetData()->GetDatePart(
2388  static_cast<long>(::rtl::math::approxFloor( fFirstVal )),
2389  nHier, nLev );
2390 
2391  nVal = nFirstYear + nIndex;
2392  }
2394  {
2395  nVal = nIndex; // DayOfWeek is 0-based
2397  css::i18n::CalendarDisplayIndex::DAY,
2398  sal::static_int_cast<sal_Int16>(nVal), 0 );
2399  }
2401  {
2402  nVal = nIndex; // Month is 0-based
2404  css::i18n::CalendarDisplayIndex::MONTH,
2405  sal::static_int_cast<sal_Int16>(nVal), 0 );
2406  }
2407  else
2408  nVal = nIndex + 1; // Quarter, Day, Week are 1-based
2409 
2410  switch (nLev)
2411  {
2412  case SC_DAPI_LEVEL_YEAR:
2413  nGroupBy = sheet::DataPilotFieldGroupBy::YEARS;
2414  break;
2415  case SC_DAPI_LEVEL_QUARTER:
2416  case SC_DAPI_LEVEL_WEEK:
2417  nGroupBy = sheet::DataPilotFieldGroupBy::QUARTERS;
2418  break;
2419  case SC_DAPI_LEVEL_MONTH:
2420  case SC_DAPI_LEVEL_WEEKDAY:
2421  nGroupBy = sheet::DataPilotFieldGroupBy::MONTHS;
2422  break;
2423  case SC_DAPI_LEVEL_DAY:
2424  nGroupBy = sheet::DataPilotFieldGroupBy::DAYS;
2425  break;
2426  default:
2427  ;
2428  }
2429  if (aName.isEmpty())
2430  aName = OUString::number(nVal);
2431 
2432  ScDPItemData aData(nGroupBy, nVal);
2433  SCROW nId = pSource->GetCache()->GetIdByItemData(nDim, aData);
2434  pNew.set(new ScDPMember(pSource, nDim, nHier, nLev, nId));
2435  }
2436  else
2437  {
2438  const std::vector<SCROW>& memberIndexs = pSource->GetData()->GetColumnEntries(nSrcDim);
2439  pNew.set(new ScDPMember(pSource, nDim, nHier, nLev, memberIndexs[nIndex]));
2440  }
2441  maMembers[nIndex] = pNew;
2442  }
2443 
2444  return maMembers[nIndex].get();
2445  }
2446 
2447  return nullptr; //TODO: exception?
2448 }
2449 
2451  ScDPSource* pSrc, long nD, long nH, long nL, SCROW nIndex) :
2452  pSource( pSrc ),
2453  nDim( nD ),
2454  nHier( nH ),
2455  nLev( nL ),
2456  mnDataId( nIndex ),
2457  nPosition( -1 ),
2458  bVisible( true ),
2459  bShowDet( true )
2460 {
2461  //TODO: hold pSource
2462 }
2463 
2465 {
2466  //TODO: release pSource
2467 }
2468 
2469 bool ScDPMember::IsNamedItem(SCROW nIndex) const
2470 {
2471  long nSrcDim = pSource->GetSourceDim( nDim );
2472  if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) )
2473  {
2474  const ScDPItemData* pData = pSource->GetCache()->GetItemDataById(nDim, nIndex);
2475  if (pData->IsValue())
2476  {
2477  long nComp = pSource->GetData()->GetDatePart(
2478  static_cast<long>(::rtl::math::approxFloor( pData->GetValue() )),
2479  nHier, nLev );
2480  // fValue is converted from integer, so simple comparison works
2481  const ScDPItemData* pData2 = GetItemData();
2482  return pData2 && nComp == pData2->GetValue();
2483  }
2484  }
2485 
2486  return nIndex == mnDataId;
2487 }
2488 
2489 sal_Int32 ScDPMember::Compare( const ScDPMember& rOther ) const
2490 {
2491  if ( nPosition >= 0 )
2492  {
2493  if ( rOther.nPosition >= 0 )
2494  {
2495  OSL_ENSURE( nPosition != rOther.nPosition, "same position for two members" );
2496  return ( nPosition < rOther.nPosition ) ? -1 : 1;
2497  }
2498  else
2499  {
2500  // only this has a position - members with specified positions come before those without
2501  return -1;
2502  }
2503  }
2504  else if ( rOther.nPosition >= 0 )
2505  {
2506  // only rOther has a position
2507  return 1;
2508  }
2509 
2510  // no positions set - compare names
2511  return pSource->GetData()->Compare( pSource->GetSourceDim(nDim),mnDataId,rOther.GetItemDataId());
2512 }
2513 
2515 {
2516  //TODO: handle date hierarchy...
2517 
2518  const ScDPItemData* pData = GetItemData();
2519  return (pData ? *pData : ScDPItemData());
2520 }
2521 
2522 const std::optional<OUString> & ScDPMember::GetLayoutName() const
2523 {
2524  return mpLayoutName;
2525 }
2526 
2527 OUString ScDPMember::GetNameStr( bool bLocaleIndependent ) const
2528 {
2529  const ScDPItemData* pData = GetItemData();
2530  if (pData)
2531  return pSource->GetData()->GetFormattedString(nDim, *pData, bLocaleIndependent);
2532  return OUString();
2533 }
2534 
2535 OUString SAL_CALL ScDPMember::getName()
2536 {
2537  return GetNameStr( false );
2538 }
2539 
2540 void SAL_CALL ScDPMember::setName( const OUString& /* rNewName */ )
2541 {
2542  OSL_FAIL("not implemented"); //TODO: exception?
2543 }
2544 
2545 // XPropertySet
2546 
2547 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPMember::getPropertySetInfo()
2548 {
2549  SolarMutexGuard aGuard;
2550 
2551  static const SfxItemPropertyMapEntry aDPMemberMap_Impl[] =
2552  {
2557  { u"", 0, css::uno::Type(), 0, 0 }
2558  };
2559  static uno::Reference<beans::XPropertySetInfo> aRef =
2560  new SfxItemPropertySetInfo( aDPMemberMap_Impl );
2561  return aRef;
2562 }
2563 
2564 void SAL_CALL ScDPMember::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
2565 {
2566  if ( aPropertyName == SC_UNO_DP_ISVISIBLE )
2567  bVisible = lcl_GetBoolFromAny(aValue);
2568  else if ( aPropertyName == SC_UNO_DP_SHOWDETAILS )
2569  bShowDet = lcl_GetBoolFromAny(aValue);
2570  else if ( aPropertyName == SC_UNO_DP_POSITION )
2571  aValue >>= nPosition;
2572  else if (aPropertyName == SC_UNO_DP_LAYOUTNAME)
2573  {
2574  OUString aName;
2575  if (aValue >>= aName)
2576  mpLayoutName = aName;
2577  }
2578  else
2579  {
2580  OSL_FAIL("unknown property");
2581  }
2582 }
2583 
2584 uno::Any SAL_CALL ScDPMember::getPropertyValue( const OUString& aPropertyName )
2585 {
2586  uno::Any aRet;
2587  if ( aPropertyName == SC_UNO_DP_ISVISIBLE )
2588  aRet <<= bVisible;
2589  else if ( aPropertyName == SC_UNO_DP_SHOWDETAILS )
2590  aRet <<= bShowDet;
2591  else if ( aPropertyName == SC_UNO_DP_POSITION )
2592  aRet <<= nPosition;
2593  else if (aPropertyName == SC_UNO_DP_LAYOUTNAME)
2594  aRet <<= mpLayoutName ? *mpLayoutName : OUString();
2595  else
2596  {
2597  OSL_FAIL("unknown property");
2598  }
2599  return aRet;
2600 }
2601 
2603 
2604 const ScDPCache* ScDPSource::GetCache()
2605 {
2606  OSL_ENSURE( GetData() , "empty ScDPTableData pointer");
2607  return ( GetData()!=nullptr ) ? &GetData()->GetCacheTable().getCache() : nullptr ;
2608 }
2609 
2611 {
2612  const ScDPItemData* pData = pSource->GetItemDataById(nDim, mnDataId);
2613  SAL_WARN_IF( !pData, "sc.core", "ScDPMember::GetItemData: what data? nDim " << nDim << ", mnDataId " << mnDataId);
2614  return pData;
2615 }
2616 
2617 const ScDPItemData* ScDPSource::GetItemDataById(long nDim, long nId)
2618 {
2619  return GetData()->GetMemberById(nDim, nId);
2620 }
2621 
2623 {
2624  const std::vector< SCROW >& memberIds = pSource->GetData()->GetColumnEntries( nDim );
2625  if ( nIndex >= static_cast<long>(memberIds.size()) || nIndex < 0 )
2626  return nullptr;
2627  SCROW nId = memberIds[ nIndex ];
2628  return pSource->GetItemDataById( nDim, nId );
2629 }
2630 
2631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void DumpResults() const
OUString getDataDescription()
Definition: dptabsrc.cxx:480
const int nColCount
void SetDupCount(long nNew)
Definition: dptabsrc.cxx:308
virtual const ScDPItemData * GetMemberById(long nDim, long nId)
Definition: dptabdat.cxx:258
#define SC_UNO_DP_LAYOUT
Definition: unonames.hxx:620
com sun star sheet DataPilotSourceHierarchy
Definition: dptabsrc.cxx:78
ScDPDimension * GetDataDimension(long nIndex)
Definition: dptabsrc.cxx:148
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: dptabsrc.cxx:2547
bool SubTotalAllowed(long nColumn)
Definition: dptabsrc.cxx:234
virtual long GetMembersCount(long nDim)
Definition: dptabdat.cxx:241
#define SC_UNO_DP_FIELD_SUBTOTALNAME
Definition: unonames.hxx:612
function is determined automatically.
double getLeafResult(const css::sheet::DataPilotFieldFilter &rFilter) const
ScDPTableData * GetData()
Definition: dptabsrc.hxx:144
virtual ~ScDPMember() override
Definition: dptabsrc.cxx:2464
#define SC_UNO_DP_IGNOREEMPTY
Definition: unonames.hxx:604
sal_Int32 nIndex
ScDPMember * getByIndex(long nIndex) const
Definition: dptabsrc.cxx:2357
bool bVisible
void SetEnableLayout(bool bSet)
Definition: dptabsrc.cxx:1969
long nDim
Definition: dptabsrc.hxx:452
rtl::Reference< ScDPHierarchies > mxHierarchies
Definition: dptabsrc.hxx:268
#define EMPTY_OUSTRING
Definition: global.hxx:214
void FillLevelList(css::sheet::DataPilotFieldOrientation nOrientation, std::vector< ScDPLevel * > &rList)
Definition: dptabsrc.cxx:956
const std::optional< OUString > & GetGrandTotalName() const
Definition: dptabsrc.cxx:121
sal_Int32 nPosition
Definition: dptabsrc.hxx:609
long GetSourceDim(long nDim)
Definition: dptabsrc.cxx:336
ScDPHierarchy(ScDPSource *pSrc, long nD, long nH)
Definition: dptabsrc.cxx:1701
virtual ~ScDPLevel() override
Definition: dptabsrc.cxx:1907
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dptabsrc.cxx:1802
::std::vector< long > aColLevelDims
Definition: dptabdat.hxx:71
const css::sheet::DataPilotFieldAutoShowInfo & GetAutoShow() const
Definition: dptabsrc.hxx:512
#define SC_UNO_DP_REFVALUE
Definition: unonames.hxx:617
ScDPLevels * GetLevelsObject()
Definition: dptabsrc.cxx:1714
const char aData[]
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dptabsrc.cxx:1651
void EvaluateSortOrder()
Definition: dptabsrc.cxx:1912
virtual sal_Bool SAL_CALL hasElements() override
Definition: dptabsrc.cxx:1239
void swap(ScDPResultTree &rOther)
std::unique_ptr< ContentProperties > pData
ScGeneralFunction nFunction
Definition: dptabsrc.hxx:269
ScDPDimension(ScDPSource *pSrc, long nD)
Definition: dptabsrc.cxx:1274
ScDPResultTree maFilterSet
void setFunction(ScGeneralFunction nNew)
Definition: dptabsrc.cxx:1338
std::optional< OUString > mpLayoutName
Definition: dptabsrc.hxx:271
std::optional< OUString > mpGrandTotalName
Definition: dptabsrc.hxx:112
ScDPLevel * getByIndex(long nIndex) const
Definition: dptabsrc.cxx:1838
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
The term 'measure' here roughly equals "data dimension" ?
Definition: dptabres.hxx:273
com sun star sheet com sun star sheet static DataPilotSourceHierarcy bool lcl_GetBoolFromAny(const uno::Any &aAny)
Definition: dptabsrc.cxx:90
std::unique_ptr< ScDPResultMember > pRowResRoot
Definition: dptabsrc.hxx:104
ScDPTableData * pData
Definition: dptabsrc.hxx:84
OUString aName
Definition: dptabsrc.hxx:270
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: dptabsrc.cxx:2122
bool mbHasHiddenMember
Definition: dptabsrc.hxx:280
virtual void SAL_CALL refresh() override
Definition: dptabsrc.cxx:424
ScDPHierarchy * getByIndex(long nIndex) const
Definition: dptabsrc.cxx:1677
long getCount() const
Definition: dptabsrc.cxx:1246
#define SC_UNO_DP_COLGRAND
Definition: unonames.hxx:587
#define SC_UNO_DP_SORTING
Definition: unonames.hxx:618
ScDPLevels(ScDPSource *pSrc, long nD, long nH)
Definition: dptabsrc.cxx:1754
sal_Int64 n
virtual void CalcResults(CalcInfo &rInfo, bool bAutoShow)=0
const css::sheet::DataPilotFieldReference & GetReferenceValue() const
Definition: dptabsrc.hxx:340
const ScDPCache * GetCache()
Definition: dptabsrc.cxx:2604
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: dptabsrc.cxx:1119
virtual long GetColumnCount()=0
use (new) typed collection instead of ScStrCollection or separate Str and ValueCollection ...
Member names that are being processed for InitFrom/LateInitFrom (needed for initialization of grouped...
Definition: dptabres.hxx:56
sal_Int16 nId
const ContentProperties & rData
virtual void GetDrillDownData(const std::vector< ScDPFilteredCache::Criterion > &rCriteria, const std::unordered_set< sal_Int32 > &rCatDims, css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &rData)=0
void GetCategoryDimensionIndices(std::unordered_set< sal_Int32 > &rCatDims)
Compile a list of dimension indices that are either, column, row or page dimensions (i...
Definition: dptabsrc.cxx:665
ScDPMembers * GetMembersObject()
Definition: dptabsrc.cxx:1974
std::unique_ptr< css::uno::Sequence< css::sheet::MemberResult >[]> pColResults
Definition: dptabsrc.hxx:105
void SetOrientation(long nColumn, css::sheet::DataPilotFieldOrientation nNew)
Definition: dptabsrc.cxx:245
#define SC_MINCOUNT_LIMIT
Definition: dptabsrc.cxx:66
numerical values are counted.
#define SC_UNO_DP_REPEATEMPTY
Definition: unonames.hxx:605
#define SC_UNO_DP_FUNCTION
Definition: unonames.hxx:594
#define SC_UNO_DP_POSITION
Definition: unonames.hxx:593
sum of all numerical values is calculated.
std::vector< long > maDataDims
Definition: dptabsrc.hxx:90
long nMbrCount
Definition: dptabsrc.hxx:557
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dptabsrc.cxx:1641
bool bPageFiltered
Definition: dptabsrc.hxx:110
const SCCOL MAXCOLCOUNT
Definition: address.hxx:64
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:47
css::sheet::DataPilotFieldLayoutInfo aLayoutInfo
Definition: dptabsrc.hxx:459
#define SC_UNO_DP_FILTER
Definition: unonames.hxx:597
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: dptabsrc.cxx:2093
virtual sal_Bool SAL_CALL hasElements() override
Definition: dptabsrc.cxx:2304
int nDimCount
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dptabsrc.cxx:1322
const css::uno::Sequence< css::sheet::MemberResult > * GetMemberResults(const ScDPLevel *pLevel)
Definition: dptabsrc.cxx:1049
static long lcl_CountMinMembers(const vector< ScDPDimension * > &ppDim, const vector< ScDPLevel * > &ppLevel, long nLevels)
Definition: dptabsrc.cxx:538
#define SC_UNO_DP_GRANDTOTAL_NAME
Definition: unonames.hxx:613
const ValuesType * getResults(const css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters) const
const ScDPItemData & GetSelectedData()
Definition: dptabsrc.cxx:1363
ScDPDimension * AddDuplicated(const OUString &rNewName)
move to ScDPResultData
Definition: dptabsrc.cxx:313
::std::vector< ScDPDimension * > aColDims
Definition: dptabdat.hxx:72
NF_PERCENT_DEC2
long getMinMembers() const
Definition: dptabsrc.cxx:2340
long nHier
Definition: dptabsrc.hxx:603
virtual OUString getDimensionName(long nColumn)=0
exports com.sun.star. sheet
#define SC_UNO_DP_ORIGINAL
Definition: unonames.hxx:589
const ScDPItemData * GetSrcItemDataByIndex(SCROW nIndex)
Definition: dptabsrc.cxx:2622
NAME
std::vector< long > maRowDims
Definition: dptabsrc.hxx:89
#define SC_UNO_DP_LAYOUTNAME
Definition: unonames.hxx:611
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dptabsrc.cxx:1225
rtl::Reference< ScDPDimensions > pDimensions
Definition: dptabsrc.hxx:85
::std::vector< sal_Int32 > aGlobalOrder
Definition: dptabsrc.hxx:461
const ScDPItemData * GetItemDataById(long nDim, long nId)
Definition: dptabsrc.cxx:2617
#define SC_UNO_DP_SUBTOTAL
Definition: unonames.hxx:598
const std::optional< OUString > & GetSubtotalName() const
Definition: dptabsrc.cxx:1304
virtual OUString SAL_CALL getName() override
Definition: dptabsrc.cxx:1997
long getCount() const
Definition: dptabsrc.hxx:582
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: dptabsrc.cxx:2564
bool HasSelectedPage() const
Definition: dptabsrc.hxx:337
virtual ~ScDPHierarchy() override
Definition: dptabsrc.cxx:1709
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
MembersType maMembers
Definition: dptabsrc.hxx:558
std::optional< OUString > mpSubtotalName
Definition: dptabsrc.hxx:272
ScDPDimensions * GetDimensionsObject()
Definition: dptabsrc.cxx:294
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: dptabsrc.cxx:1096
ScDPSource(ScDPTableData *pD)
Definition: dptabsrc.cxx:96
bool bRowGrand
Definition: dptabsrc.hxx:95
multi-item (group) filter.
ScGeneralFunction getFunction() const
Definition: dptabsrc.hxx:333
int nCount
virtual void CreateCacheTable()=0
SCROW mnDataId
Definition: dptabsrc.hxx:606
ScDPDimension * getByIndex(long nIndex) const
Definition: dptabsrc.cxx:1253
long GetDimension() const
Definition: dptabsrc.hxx:288
ScDPDimension * CreateCloneObject()
Definition: dptabsrc.cxx:1343
virtual bool getIsDataLayoutDimension(long nColumn)=0
virtual OUString SAL_CALL getName() override
Definition: dptabsrc.cxx:1314
virtual ~ScDPDimension() override
Definition: dptabsrc.cxx:1285
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dptabsrc.cxx:2299
virtual ~ScDPDimensions() override
Definition: dptabsrc.cxx:1172
std::shared_ptr< FilterBase > mpFilter
virtual void SetEmptyFlags(bool bIgnoreEmptyRows, bool bRepeatIfEmpty)=0
const ScDPItemData * GetMemberByIndex(long nDim, long nIndex)
Definition: dptabdat.cxx:248
#define SC_UNO_DP_ROWFIELDCOUNT
Definition: unonames.hxx:608
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getDimensions() override
Definition: dptabsrc.cxx:303
long nLevCount
Definition: dptabsrc.hxx:417
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dptabsrc.cxx:2289
const ::std::vector< sal_Int32 > & GetGlobalOrder() const
Definition: dptabsrc.hxx:517
css::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo
Definition: dptabsrc.hxx:458
#define SC_UNO_DP_REPEATITEMLABELS
Definition: unonames.hxx:601
void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo &rInfo, bool &bHasAutoShow)
Definition: dptabsrc.cxx:599
::std::vector< ScDPLevel * > aColLevels
Definition: dptabdat.hxx:73
long GetDatePart(long nDateVal, long nHierarchy, long nLevel)
Definition: dptabdat.cxx:57
indexes when calculating running totals
Definition: dptabres.hxx:105
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dptabsrc.cxx:2540
#define SC_DAPI_QUARTER_LEVELS
Definition: dptabdat.hxx:36
::std::vector< long > aRowLevelDims
Definition: dptabdat.hxx:74
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dptabsrc.cxx:2294
::std::vector< ScDPDimension * > aRowDims
Definition: dptabdat.hxx:75
bool bShowDet
Definition: dptabsrc.hxx:611
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dptabsrc.cxx:1749
css::sheet::DataPilotFieldOrientation GetDataLayoutOrientation()
Definition: dptabsrc.cxx:284
std::optional< OUString > mpLayoutName
Definition: dptabsrc.hxx:607
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLevels() override
Definition: dptabsrc.cxx:1723
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dptabsrc.cxx:1626
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:29
#define SC_UNO_DP_FUNCTION2
Definition: unonames.hxx:595
virtual ~ScDPLevels() override
Definition: dptabsrc.cxx:1780
SC_SIMPLE_SERVICE_INFO_COMPAT(ScDPHierarchies,"ScDPHierarchies","com.sun.star.sheet.DataPilotSourceHierarchies","com.sun.star.sheet.DataPilotSourceHierarcies") SC_SIMPLE_SERVICE_INFO_COMPAT(ScDPHierarchy
virtual void DisposeData()=0
std::unique_ptr< rtl::Reference< ScDPLevel >[]> ppLevs
Definition: dptabsrc.hxx:419
int i
This structure stores dimension information used when calculating results.
Definition: dptabdat.hxx:69
virtual ~ScDPHierarchies() override
Definition: dptabsrc.cxx:1619
#define SC_DAPI_HIERARCHY_WEEK
Definition: dptabdat.hxx:33
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: dptabsrc.cxx:2072
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dptabsrc.cxx:1234
long nLev
Definition: dptabsrc.hxx:454
#define SC_DAPI_LEVEL_YEAR
Definition: dptabdat.hxx:39
std::unique_ptr< ScDPResultMember > pColResRoot
Definition: dptabsrc.hxx:103
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dptabsrc.cxx:2275
std::unique_ptr< rtl::Reference< ScDPHierarchy >[]> ppHiers
Definition: dptabsrc.hxx:354
static SC_DLLPUBLIC OUString getSourceDimensionName(const OUString &rName)
Definition: dputil.cxx:64
sal_uInt32 GetNumberFormatByIdx(NfIndexTableOffset)
Definition: dpshttab.cxx:138
#define SC_DAPI_LEVEL_QUARTER
Definition: dptabdat.hxx:40
virtual OUString SAL_CALL getName() override
Definition: dptabsrc.cxx:2535
std::unique_ptr< css::uno::Sequence< css::sheet::MemberResult >[]> pRowResults
Definition: dptabsrc.hxx:106
#define SC_DAPI_LEVEL_DAY
Definition: dptabdat.hxx:42
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
#define SC_DAPI_WEEK_LEVELS
Definition: dptabdat.hxx:37
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dptabsrc.cxx:1199
virtual long Compare(long nDim, long nDataId1, long nDataId2)
Definition: dptabdat.cxx:274
SCROW GetItemDataId() const
Definition: dptabsrc.hxx:622
float u
unsigned char sal_Bool
bool bEnableLayout
Definition: dptabsrc.hxx:465
std::vector< long > maColDims
Definition: dptabsrc.hxx:88
#define SC_DAPI_LEVEL_MONTH
Definition: dptabdat.hxx:41
void FilterCacheByPageDimensions()
Set visibilities of individual rows in the cache table based on the page field data.
Definition: dptabsrc.cxx:677
ScDPResultMember * pColRoot
Definition: dptabdat.hxx:81
void FillMemberResults()
Definition: dptabsrc.cxx:1006
void setIgnoreEmptyRows(bool bSet)
???
Definition: dptabsrc.cxx:496
css::uno::Type const & get()
#define SC_DAPI_HIERARCHY_FLAT
Definition: dptabdat.hxx:31
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
Definition: miscuno.hxx:64
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: dptabsrc.cxx:434
#define SC_UNO_DP_AUTOSHOW
Definition: unonames.hxx:619
#define SC_UNO_DP_COLUMNFIELDCOUNT
Definition: unonames.hxx:609
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: dptabsrc.cxx:1429
ScDPItemData FillItemData() const
Definition: dptabsrc.cxx:2514
css::uno::Sequence< sal_Int16 > getSubTotals() const
Definition: dptabsrc.cxx:2059
ScDPLevel(ScDPSource *pSrc, long nD, long nH, long nL)
Definition: dptabsrc.cxx:1891
css::sheet::DataPilotFieldReference aReferenceValue
Definition: dptabsrc.hxx:275
virtual OUString SAL_CALL getName() override
Definition: dptabsrc.cxx:1728
#define SC_UNO_DP_HAS_HIDDEN_MEMBER
Definition: unonames.hxx:614
long getCount() const
Definition: dptabsrc.cxx:1833
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dptabsrc.cxx:1787
virtual bool IsDateDimension(long nDim)=0
long nHier
Definition: dptabsrc.hxx:453
void fillFieldFilters(::std::vector< ScDPFilteredCache::Criterion > &rFilters) const
Definition: dptabres.cxx:3907
const long LONG_MAX
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dptabsrc.cxx:1812
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
Definition: miscuno.hxx:73
#define SC_DAPI_LEVEL_WEEKDAY
Definition: dptabdat.hxx:44
NF_NUMBER_SYSTEM
css::sheet::DataPilotFieldSortInfo aSortInfo
Definition: dptabsrc.hxx:457
OUString getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) const
#define SC_UNO_DP_ROWGRAND
Definition: unonames.hxx:588
OUString GetDataDimName(long nIndex)
Definition: dptabsrc.cxx:157
std::vector< double > ValuesType
Definition: dpresfilter.hxx:53
#define SC_UNO_DP_DATAFIELDCOUNT
Definition: unonames.hxx:610
#define SC_UNO_DP_FLAGS
Definition: unonames.hxx:615
SCROW GetIdByItemData(long nDim, const ScDPItemData &rItem) const
Definition: dpcache.cxx:1124
#define SC_UNO_DP_ORIENTATION
Definition: unonames.hxx:592
median of all numerical values is calculated.
::std::vector< long > aPageDims
Definition: dptabdat.hxx:77
#define SC_UNO_DP_ORIGINAL_POS
Definition: unonames.hxx:590
bool empty() const
long GetPosition(long nColumn)
Definition: dptabsrc.cxx:166
#define SC_UNO_DP_SHOWEMPTY
Definition: unonames.hxx:600
std::unique_ptr< rtl::Reference< ScDPDimension >[]> ppDims
Definition: dptabsrc.hxx:233
std::vector< ScDPLevel * > aColLevelList
Definition: dptabsrc.hxx:107
virtual css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > SAL_CALL getResults() override
Definition: dptabsrc.cxx:357
Base class that abstracts different data source types of a datapilot table.
Definition: dptabdat.hxx:56
sal_Int32 SCROW
Definition: types.hxx:18
void setRepeatIfEmpty(bool bSet)
Definition: dptabsrc.cxx:502
virtual css::uno::Sequence< double > SAL_CALL getFilteredResults(const css::uno::Sequence< css::sheet::DataPilotFieldFilter > &aFilters) override
Definition: dptabsrc.cxx:391
rtl::Reference< ScDPMembers > mxMembers
Definition: dptabsrc.hxx:455
single filtering criterion.
std::vector< long > maPageDims
Definition: dptabsrc.hxx:91
bool bRepeatItemLabels
Definition: dptabsrc.hxx:466
bool IsNamedItem(SCROW nIndex) const
Definition: dptabsrc.cxx:2469
static CalendarWrapper * GetCalendar()
Definition: global.cxx:1019
sal_Int32 Compare(const ScDPMember &rOther) const
Definition: dptabsrc.cxx:2489
bool bRepeatIfEmpty
Definition: dptabsrc.hxx:97
std::vector< ScDPLevel * > aRowLevelList
Definition: dptabsrc.hxx:108
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: dptabsrc.cxx:1401
bool bShowEmpty
Definition: dptabsrc.hxx:464
ScDPInitState * pInitState
Definition: dptabdat.hxx:80
#define SC_UNO_DP_USEDHIERARCHY
Definition: unonames.hxx:596
#define SAL_WARN_IF(condition, area, stream)
sal_Int32 GetIndexFromName(const OUString &rName) const
Definition: dptabsrc.cxx:2257
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dptabsrc.cxx:2054
#define SC_UNO_DP_DATADESC
Definition: unonames.hxx:606
virtual sal_Bool SAL_CALL hasElements() override
Definition: dptabsrc.cxx:1665
virtual css::uno::Sequence< OUString > SAL_CALL getLocaleIndependentElementNames() override
Definition: dptabsrc.cxx:2313
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2, which causes some type-safety issues.
OUString aName
bool bResultOverflow
Definition: dptabsrc.hxx:109
bool IsDataLayoutDimension(long nDim)
Definition: dptabsrc.cxx:279
This class collects visible members of each dimension and uses that information to create filtering c...
Definition: dptabres.hxx:650
#define SC_UNO_DP_ISVISIBLE
Definition: unonames.hxx:602
OUString GetFormattedString(long nDim, const ScDPItemData &rItem, bool bLocaleIndependent) const
Definition: dptabdat.cxx:51
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dptabsrc.cxx:1821
all values, including non-numerical values, are counted.
bool HasStringData() const
Definition: dpitemdata.cxx:366
nothing is calculated.
static long getCount()
Definition: dptabsrc.cxx:1672
virtual ~ScDPMembers() override
Definition: dptabsrc.cxx:2251
virtual sal_uInt32 GetNumberFormat(long nDim)
Definition: dptabdat.cxx:107
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: dptabsrc.cxx:2584
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: dptabsrc.cxx:1073
virtual void FilterCacheTable(const std::vector< ScDPFilteredCache::Criterion > &rCriteria, const std::unordered_set< sal_Int32 > &rDataDims)=0
ScDPResultTree maResFilterSet
Definition: dptabsrc.hxx:92
double GetValue() const
Definition: dpitemdata.cxx:347
Sequence< sal_Int8 > aSeq
virtual sal_Bool SAL_CALL hasElements() override
Definition: dptabsrc.cxx:1826
virtual css::uno::Reference< css::sheet::XMembersAccess > SAL_CALL getMembers() override
Definition: dptabsrc.cxx:1983
bool bColumnGrand
Definition: dptabsrc.hxx:94
OUString GetNameStr(bool bLocaleIndependent) const
Definition: dptabsrc.cxx:2527
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: dptabsrc.cxx:429
bool IsValue() const
Definition: dpitemdata.cxx:322
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dptabsrc.cxx:1215
::std::vector< ScDPLevel * > aRowLevels
Definition: dptabdat.hxx:76
virtual ~ScDPSource() override
Definition: dptabsrc.cxx:109
css::uno::Sequence< sal_Int16 > aSubTotals
Definition: dptabsrc.hxx:456
virtual const std::vector< SCROW > & GetColumnEntries(long nColumn)
Definition: dptabdat.cxx:263
bool getIsDataLayoutDimension() const
Definition: dptabsrc.cxx:1333
::std::vector< long > aDataSrcCols
Definition: dptabdat.hxx:78
#define SC_DAPI_LEVEL_WEEK
Definition: dptabdat.hxx:43
#define SAL_WARN(area, stream)
ScDPResultMember * pRowRoot
Definition: dptabdat.hxx:82
bool IsDateDimension(long nDim)
Definition: dptabsrc.cxx:289
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: dptabsrc.cxx:1511
long nHier
Definition: dptabsrc.hxx:416
long nAutoMeasure
Definition: dptabsrc.hxx:463
bool bIgnoreEmptyRows
Definition: dptabsrc.hxx:96
#define SC_UNO_DP_SHOWDETAILS
Definition: unonames.hxx:603
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
sal_Int32 nLength
#define SC_DAPI_FLAT_LEVELS
Definition: dptabdat.hxx:35
#define SC_UNO_DP_ISDATALAYOUT
Definition: unonames.hxx:591
static long getUsedHierarchy()
Definition: dptabsrc.hxx:335
const ScDPItemData * GetItemDataById(long nDim, SCROW nId) const
Definition: dpcache.cxx:985
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dptabsrc.cxx:1660
ScDPHierarchies * GetHierarchiesObject()
Definition: dptabsrc.cxx:1290
std::unique_ptr< ScDPItemData > pSelectedData
Definition: dptabsrc.hxx:279
rtl::Reference< ScDPLevels > mxLevels
Definition: dptabsrc.hxx:387
long GetDupCount() const
Definition: dptabsrc.hxx:169
const std::optional< OUString > & GetLayoutName() const
Definition: dptabsrc.cxx:2522
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDrillDownData(const css::uno::Sequence< css::sheet::DataPilotFieldFilter > &aFilters) override
Definition: dptabsrc.cxx:439
void CountChanged()
Definition: dptabsrc.cxx:1177
ScDPHierarchy
Definition: dptabsrc.cxx:78
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: dptabsrc.cxx:1358
void disposeData()
Definition: dptabsrc.cxx:508
#define SC_DAPI_HIERARCHY_QUARTER
Definition: dptabdat.hxx:32
bool bHasSelectedPage
Definition: dptabsrc.hxx:276
ScDPMembersHashMap aHashMap
Definition: dptabsrc.hxx:559
#define SC_UNO_DP_SUBTOTAL2
Definition: unonames.hxx:599
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getHierarchies() override
Definition: dptabsrc.cxx:1309
long GetSourceDim() const
Definition: dptabsrc.hxx:289
#define SC_UNO_DP_NUMBERFO
Definition: unonames.hxx:607
void AddMember(long nSourceIndex, SCROW nMember)
Definition: dptabres.cxx:255
long nDupCount
Definition: dptabsrc.hxx:99
void CreateRes_Impl()
Definition: dptabsrc.cxx:741
css::sheet::DataPilotFieldOrientation getOrientation() const
Definition: dptabsrc.cxx:1328
const ScDPItemData * GetItemData() const
Definition: dptabsrc.cxx:2610
bool bVisible
Definition: dptabsrc.hxx:610
sal_uInt16 nPos
static SC_DLLPUBLIC ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc)
Definition: dputil.cxx:405
long nSortMeasure
Definition: dptabsrc.hxx:462
ScDPMember(ScDPSource *pSrc, long nD, long nH, long nL, SCROW nIndex)
Definition: dptabsrc.cxx:2450
css::sheet::DataPilotFieldOrientation GetOrientation(long nColumn)
Definition: dptabsrc.cxx:126
OUString aSelectedPage
Definition: dptabsrc.hxx:277
const bool READONLY
static const long nHierCount
Definition: dptabsrc.hxx:352
std::unique_ptr< ScDPResultData > pResData
Definition: dptabsrc.hxx:102
long GetDataDimensionCount() const
Definition: dptabsrc.cxx:143
bool isVisible() const
Definition: dptabsrc.hxx:655
const std::optional< OUString > & GetLayoutName() const
Definition: dptabsrc.cxx:1299
virtual css::uno::Sequence< css::sheet::MemberResult > SAL_CALL getResults() override
Definition: dptabsrc.cxx:1988