LibreOffice Module sc (master)  1
dapiuno.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 <algorithm>
21 #include <cmath>
22 
23 #include <svl/hint.hxx>
24 #include <vcl/svapp.hxx>
25 #include <sal/log.hxx>
26 
27 #include <dapiuno.hxx>
28 #include <datauno.hxx>
29 #include <miscuno.hxx>
30 #include <convuno.hxx>
31 #include <docsh.hxx>
32 #include <tabvwsh.hxx>
33 #include <rangeutl.hxx>
34 #include <dpobject.hxx>
35 #include <dpshttab.hxx>
36 #include <dpsdbtab.hxx>
37 #include <dpsave.hxx>
38 #include <dbdocfun.hxx>
39 #include <unonames.hxx>
40 #include <dpdimsave.hxx>
41 #include <hints.hxx>
42 #include <dputil.hxx>
43 #include <globstr.hrc>
44 #include <scresid.hxx>
45 #include <generalfunction.hxx>
46 
47 #include <com/sun/star/container/XNameAccess.hpp>
48 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
49 #include <com/sun/star/lang/IllegalArgumentException.hpp>
50 #include <com/sun/star/lang/NullPointerException.hpp>
51 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
52 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
53 #include <com/sun/star/sheet/XLevelsSupplier.hpp>
54 #include <com/sun/star/sheet/XMembersAccess.hpp>
55 #include <com/sun/star/beans/PropertyAttribute.hpp>
56 #include <com/sun/star/sheet/DataImportMode.hpp>
57 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
58 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
59 #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
60 #include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
61 #include <com/sun/star/sheet/GeneralFunction2.hpp>
62 
63 #include <comphelper/extract.hxx>
65 #include <comphelper/sequence.hxx>
67 #include <cppuhelper/exc_hlp.hxx>
68 
69 using namespace com::sun::star;
70 using namespace com::sun::star::sheet;
71 
72 using ::com::sun::star::uno::Any;
73 using ::com::sun::star::uno::Exception;
74 using ::com::sun::star::uno::Reference;
75 using ::com::sun::star::uno::RuntimeException;
76 using ::com::sun::star::uno::Sequence;
77 using ::com::sun::star::uno::UNO_QUERY;
78 using ::com::sun::star::uno::UNO_QUERY_THROW;
79 
80 using ::com::sun::star::container::ElementExistException;
81 using ::com::sun::star::container::NoSuchElementException;
82 using ::com::sun::star::container::XEnumeration;
83 using ::com::sun::star::container::XIndexAccess;
84 using ::com::sun::star::container::XNameAccess;
85 using ::com::sun::star::container::XNamed;
86 
87 using ::com::sun::star::beans::UnknownPropertyException;
88 using ::com::sun::star::beans::XPropertyChangeListener;
89 using ::com::sun::star::beans::XPropertySet;
90 using ::com::sun::star::beans::XPropertySetInfo;
91 using ::com::sun::star::beans::XVetoableChangeListener;
92 
93 using ::com::sun::star::lang::IllegalArgumentException;
94 using ::com::sun::star::lang::IndexOutOfBoundsException;
95 using ::com::sun::star::lang::NullPointerException;
96 
97 using ::com::sun::star::table::CellAddress;
98 using ::com::sun::star::table::CellRangeAddress;
99 
100 namespace {
101 
102 const SfxItemPropertyMapEntry* lcl_GetDataPilotDescriptorBaseMap()
103 {
104  static const SfxItemPropertyMapEntry aDataPilotDescriptorBaseMap_Impl[] =
105  {
108  { SC_UNO_DP_GRANDTOTAL_NAME,0,cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
116  { u"", 0, css::uno::Type(), 0, 0 }
117  };
118  return aDataPilotDescriptorBaseMap_Impl;
119 }
120 
121 const SfxItemPropertyMapEntry* lcl_GetDataPilotFieldMap()
122 {
123  using namespace ::com::sun::star::beans::PropertyAttribute;
124  static const SfxItemPropertyMapEntry aDataPilotFieldMap_Impl[] =
125  {
145  { u"", 0, css::uno::Type(), 0, 0 }
146  };
147  return aDataPilotFieldMap_Impl;
148 }
149 
150 const SfxItemPropertyMapEntry* lcl_GetDataPilotItemMap()
151 {
152  static const SfxItemPropertyMapEntry aDataPilotItemMap_Impl[] =
153  {
157  { u"", 0, css::uno::Type(), 0, 0 }
158  };
159  return aDataPilotItemMap_Impl;
160 }
161 
162 bool lclCheckValidDouble( double fValue, bool bAuto )
163 {
164  return bAuto || std::isfinite( fValue );
165 }
166 
167 bool lclCheckMinMaxStep( const DataPilotFieldGroupInfo& rInfo )
168 {
169  return
170  lclCheckValidDouble( rInfo.Start, rInfo.HasAutoStart ) &&
171  lclCheckValidDouble( rInfo.End, rInfo.HasAutoEnd ) &&
172  (rInfo.HasAutoStart || rInfo.HasAutoEnd || (rInfo.Start <= rInfo.End)) &&
173  lclCheckValidDouble( rInfo.Step, false ) &&
174  (0.0 <= rInfo.Step);
175 }
176 
177 } // namespace
178 
179 SC_SIMPLE_SERVICE_INFO( ScDataPilotDescriptor, "ScDataPilotDescriptor", "stardiv::one::sheet::DataPilotDescriptor" )
180 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldObj, "ScDataPilotFieldObj", "com.sun.star.sheet.DataPilotField" )
181 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldsObj, "ScDataPilotFieldsObj", "com.sun.star.sheet.DataPilotFields" )
182 SC_SIMPLE_SERVICE_INFO( ScDataPilotTableObj, "ScDataPilotTableObj", "com.sun.star.sheet.DataPilotTable" )
183 SC_SIMPLE_SERVICE_INFO( ScDataPilotTablesObj, "ScDataPilotTablesObj", "com.sun.star.sheet.DataPilotTables" )
184 SC_SIMPLE_SERVICE_INFO( ScDataPilotItemsObj, "ScDataPilotItemsObj", "com.sun.star.sheet.DataPilotItems" )
185 SC_SIMPLE_SERVICE_INFO( ScDataPilotItemObj, "ScDataPilotItemObj", "com.sun.star.sheet.DataPilotItem" )
186 
187 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupsObj, "ScDataPilotFieldGroupsObj", "com.sun.star.sheet.DataPilotFieldGroups" )
188 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupObj, "ScDataPilotFieldGroupObj", "com.sun.star.sheet.DataPilotFieldGroup" )
189 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupItemObj, "ScDataPilotFieldGroupItemObj", "com.sun.star.sheet.DataPilotFieldGroupItem" )
190 
191 // name that is used in the API for the data layout field
192 constexpr OUStringLiteral SC_DATALAYOUT_NAME = u"Data";
193 
195 {
196  if ( nBits & PivotFunc::Sum ) return ScGeneralFunction::SUM;
197  if ( nBits & PivotFunc::Count ) return ScGeneralFunction::COUNT;
198  if ( nBits & PivotFunc::Average ) return ScGeneralFunction::AVERAGE;
199  if ( nBits & PivotFunc::Median ) return ScGeneralFunction::MEDIAN;
200  if ( nBits & PivotFunc::Max ) return ScGeneralFunction::MAX;
201  if ( nBits & PivotFunc::Min ) return ScGeneralFunction::MIN;
202  if ( nBits & PivotFunc::Product ) return ScGeneralFunction::PRODUCT;
204  if ( nBits & PivotFunc::StdDev ) return ScGeneralFunction::STDEV;
205  if ( nBits & PivotFunc::StdDevP ) return ScGeneralFunction::STDEVP;
206  if ( nBits & PivotFunc::StdVar ) return ScGeneralFunction::VAR;
207  if ( nBits & PivotFunc::StdVarP ) return ScGeneralFunction::VARP;
208  if ( nBits & PivotFunc::Auto ) return ScGeneralFunction::AUTO;
210 }
211 
213 {
214  PivotFunc nRet = PivotFunc::NONE; // 0
215  switch (eFunc)
216  {
217  case GeneralFunction2::SUM: nRet = PivotFunc::Sum; break;
218  case GeneralFunction2::COUNT: nRet = PivotFunc::Count; break;
219  case GeneralFunction2::AVERAGE: nRet = PivotFunc::Average; break;
220  case GeneralFunction2::MEDIAN: nRet = PivotFunc::Median; break;
221  case GeneralFunction2::MAX: nRet = PivotFunc::Max; break;
222  case GeneralFunction2::MIN: nRet = PivotFunc::Min; break;
223  case GeneralFunction2::PRODUCT: nRet = PivotFunc::Product; break;
224  case GeneralFunction2::COUNTNUMS: nRet = PivotFunc::CountNum; break;
225  case GeneralFunction2::STDEV: nRet = PivotFunc::StdDev; break;
226  case GeneralFunction2::STDEVP: nRet = PivotFunc::StdDevP; break;
227  case GeneralFunction2::VAR: nRet = PivotFunc::StdVar; break;
228  case GeneralFunction2::VARP: nRet = PivotFunc::StdVarP; break;
229  case GeneralFunction2::AUTO: nRet = PivotFunc::Auto; break;
230  default:
231  {
232  assert(false);
233  }
234  }
235  return nRet;
236 }
237 
238 void ScDataPilotConversion::FillGroupInfo( DataPilotFieldGroupInfo& rInfo, const ScDPNumGroupInfo& rGroupInfo )
239 {
240  rInfo.HasDateValues = rGroupInfo.mbDateValues;
241  rInfo.HasAutoStart = rGroupInfo.mbAutoStart;
242  rInfo.Start = rGroupInfo.mfStart;
243  rInfo.HasAutoEnd = rGroupInfo.mbAutoEnd;
244  rInfo.End = rGroupInfo.mfEnd;
245  rInfo.Step = rGroupInfo.mfStep;
246 }
247 
248 static ScDPObject* lcl_GetDPObject( ScDocShell* pDocShell, SCTAB nTab, std::u16string_view rName )
249 {
250  if (pDocShell)
251  {
252  ScDocument& rDoc = pDocShell->GetDocument();
253  ScDPCollection* pColl = rDoc.GetDPCollection();
254  if ( pColl )
255  {
256  size_t nCount = pColl->GetCount();
257  for (size_t i=0; i<nCount; ++i)
258  {
259  ScDPObject& rDPObj = (*pColl)[i];
260  if ( rDPObj.GetOutRange().aStart.Tab() == nTab &&
261  rDPObj.GetName() == rName )
262  return &rDPObj;
263  }
264  }
265  }
266  return nullptr; // not found
267 }
268 
269 static OUString lcl_CreatePivotName( ScDocShell* pDocShell )
270 {
271  if (pDocShell)
272  {
273  ScDocument& rDoc = pDocShell->GetDocument();
274  ScDPCollection* pColl = rDoc.GetDPCollection();
275  if ( pColl )
276  return pColl->CreateNewName();
277  }
278  return OUString(); // shouldn't happen
279 }
280 
281 static sal_Int32 lcl_GetObjectIndex( ScDPObject* pDPObj, const ScFieldIdentifier& rFieldId )
282 {
283  // used for items - nRepeat in identifier can be ignored
284  if ( pDPObj )
285  {
286  sal_Int32 nCount = pDPObj->GetDimCount();
287  for ( sal_Int32 nDim = 0; nDim < nCount; ++nDim )
288  {
289  bool bIsDataLayout = false;
290  OUString aDimName( pDPObj->GetDimName( nDim, bIsDataLayout ) );
291  if ( rFieldId.mbDataLayout ? bIsDataLayout : (aDimName == rFieldId.maFieldName) )
292  return nDim;
293  }
294  }
295  return -1; // none
296 }
297 
299  pDocShell( &rDocSh ),
300  nTab( nT )
301 {
303 }
304 
306 {
307  SolarMutexGuard g;
308 
309  if (pDocShell)
311 }
312 
314 {
316 
317  if ( rHint.GetId() == SfxHintId::Dying )
318  {
319  pDocShell = nullptr; // became invalid
320  }
321 }
322 
323 // XDataPilotTables
324 
326 {
327  if (pDocShell)
328  {
329  ScDocument& rDoc = pDocShell->GetDocument();
330  ScDPCollection* pColl = rDoc.GetDPCollection();
331  if ( pColl )
332  {
333  // count tables on this sheet
334  sal_Int32 nFound = 0;
335  size_t nCount = pColl->GetCount();
336  for (size_t i=0; i<nCount; ++i)
337  {
338  ScDPObject& rDPObj = (*pColl)[i];
339  if ( rDPObj.GetOutRange().aStart.Tab() == nTab )
340  {
341  if ( nFound == nIndex )
342  {
343  return new ScDataPilotTableObj(*pDocShell, nTab, rDPObj.GetName());
344  }
345  ++nFound;
346  }
347  }
348  }
349  }
350  return nullptr;
351 }
352 
354 {
355  if (hasByName(rName))
356  return new ScDataPilotTableObj(*pDocShell, nTab, rName);
357  return nullptr;
358 }
359 
360 Reference<XDataPilotDescriptor> SAL_CALL ScDataPilotTablesObj::createDataPilotDescriptor()
361 {
362  SolarMutexGuard aGuard;
363  if (pDocShell)
364  return new ScDataPilotDescriptor(*pDocShell);
365  return nullptr;
366 }
367 
368 static bool lcl_IsDuplicated(const Reference<XPropertySet>& rDimProps)
369 {
370  try
371  {
372  Any aAny = rDimProps->getPropertyValue( SC_UNO_DP_ORIGINAL );
373  Reference< XNamed > xOriginal( aAny, UNO_QUERY );
374  return xOriginal.is();
375  }
376  catch( Exception& )
377  {
378  }
379  return false;
380 }
381 
382 static OUString lcl_GetOriginalName(const Reference< XNamed >& rDim)
383 {
384  Reference< XNamed > xOriginal;
385 
386  Reference< XPropertySet > xDimProps(rDim, UNO_QUERY);
387  if ( xDimProps.is() )
388  {
389  try
390  {
391  Any aAny = xDimProps->getPropertyValue(SC_UNO_DP_ORIGINAL);
392  aAny >>= xOriginal;
393  }
394  catch( Exception& )
395  {
396  }
397  }
398 
399  if ( !xOriginal.is() )
400  xOriginal = rDim;
401 
402  return xOriginal->getName();
403 }
404 
405 void SAL_CALL ScDataPilotTablesObj::insertNewByName( const OUString& aNewName,
406  const CellAddress& aOutputAddress,
407  const Reference<XDataPilotDescriptor>& xDescriptor )
408 {
409  SolarMutexGuard aGuard;
410  if (!xDescriptor.is()) return;
411 
412  if ( !aNewName.isEmpty() && hasByName( aNewName ) )
413  throw IllegalArgumentException("Name \"" + aNewName + "\" already exists", static_cast<cppu::OWeakObject*>(this), 0);
414 
415  if (!pDocShell)
416  throw RuntimeException("DocShell is null", static_cast<cppu::OWeakObject*>(this));
417 
418  auto pImp = comphelper::getFromUnoTunnel<ScDataPilotDescriptorBase>( xDescriptor );
419  if (!pImp)
420  throw RuntimeException("Failed to get ScDataPilotDescriptor", static_cast<cppu::OWeakObject*>(this));
421 
422  ScDPObject* pNewObj = pImp->GetDPObject();
423  if (!pNewObj)
424  throw RuntimeException("Failed to get DPObject", static_cast<cppu::OWeakObject*>(this));
425 
426  ScRange aOutputRange(static_cast<SCCOL>(aOutputAddress.Column), static_cast<SCROW>(aOutputAddress.Row), static_cast<SCTAB>(aOutputAddress.Sheet),
427  static_cast<SCCOL>(aOutputAddress.Column), static_cast<SCROW>(aOutputAddress.Row), static_cast<SCTAB>(aOutputAddress.Sheet));
428  pNewObj->SetOutRange(aOutputRange);
429  OUString aName = aNewName;
430  if (aName.isEmpty())
431  aName = lcl_CreatePivotName( pDocShell );
432  pNewObj->SetName(aName);
433  OUString aTag = xDescriptor->getTag();
434  pNewObj->SetTag(aTag);
435 
436  // todo: handle double fields (for more information see ScDPObject)
437 
438  ScDBDocFunc aFunc(*pDocShell);
439  if (!aFunc.CreatePivotTable(*pNewObj, true, true))
440  throw RuntimeException("Failed to create pivot table", static_cast<cppu::OWeakObject*>(this));
441 }
442 
443 void SAL_CALL ScDataPilotTablesObj::removeByName( const OUString& aName )
444 {
445  SolarMutexGuard aGuard;
446  ScDPObject* pDPObj = lcl_GetDPObject( pDocShell, nTab, aName );
447  if (!pDPObj || !pDocShell)
448  throw RuntimeException(); // no other exceptions specified
449 
450  ScDBDocFunc aFunc(*pDocShell);
451  aFunc.RemovePivotTable(*pDPObj, true, true); // remove - incl. undo etc.
452 
453 }
454 
455 // XEnumerationAccess
456 
457 Reference< XEnumeration > SAL_CALL ScDataPilotTablesObj::createEnumeration()
458 {
459  SolarMutexGuard aGuard;
460  return new ScIndexEnumeration(this, "com.sun.star.sheet.DataPilotTablesEnumeration");
461 }
462 
463 // XIndexAccess
464 
465 sal_Int32 SAL_CALL ScDataPilotTablesObj::getCount()
466 {
467  SolarMutexGuard aGuard;
468  if ( pDocShell )
469  {
470  ScDocument& rDoc = pDocShell->GetDocument();
471  ScDPCollection* pColl = rDoc.GetDPCollection();
472  if ( pColl )
473  {
474  // count tables on this sheet
475 
476  sal_uInt16 nFound = 0;
477  size_t nCount = pColl->GetCount();
478  for (size_t i=0; i<nCount; ++i)
479  {
480  ScDPObject& rDPObj = (*pColl)[i];
481  if ( rDPObj.GetOutRange().aStart.Tab() == nTab )
482  ++nFound;
483  }
484  return nFound;
485  }
486  }
487 
488  return 0;
489 }
490 
491 Any SAL_CALL ScDataPilotTablesObj::getByIndex( sal_Int32 nIndex )
492 {
493  SolarMutexGuard aGuard;
494  Reference<XDataPilotTable2> xTable(GetObjectByIndex_Impl(nIndex));
495  if (!xTable.is())
496  throw IndexOutOfBoundsException();
497  return Any( xTable );
498 }
499 
501 {
503 }
504 
506 {
507  SolarMutexGuard aGuard;
508  return ( getCount() != 0 );
509 }
510 
511 // XNameAccess
512 
513 Any SAL_CALL ScDataPilotTablesObj::getByName( const OUString& aName )
514 {
515  SolarMutexGuard aGuard;
516  Reference<XDataPilotTable2> xTable(GetObjectByName_Impl(aName));
517  if (!xTable.is())
518  throw NoSuchElementException();
519  return Any( xTable );
520 }
521 
523 {
524  SolarMutexGuard aGuard;
525  if (pDocShell)
526  {
527  ScDocument& rDoc = pDocShell->GetDocument();
528  ScDPCollection* pColl = rDoc.GetDPCollection();
529  if ( pColl )
530  {
531  // count tables on this sheet
532 
533  sal_uInt16 nFound = 0;
534  size_t nCount = pColl->GetCount();
535  size_t i;
536  for (i=0; i<nCount; ++i)
537  {
538  ScDPObject& rDPObj = (*pColl)[i];
539  if ( rDPObj.GetOutRange().aStart.Tab() == nTab )
540  ++nFound;
541  }
542 
543  sal_uInt16 nPos = 0;
544  Sequence<OUString> aSeq(nFound);
545  OUString* pAry = aSeq.getArray();
546  for (i=0; i<nCount; ++i)
547  {
548  ScDPObject& rDPObj = (*pColl)[i];
549  if ( rDPObj.GetOutRange().aStart.Tab() == nTab )
550  pAry[nPos++] = rDPObj.GetName();
551  }
552 
553  return aSeq;
554  }
555  }
556  return {};
557 }
558 
559 sal_Bool SAL_CALL ScDataPilotTablesObj::hasByName( const OUString& aName )
560 {
561  SolarMutexGuard aGuard;
562  if (pDocShell)
563  {
564  ScDocument& rDoc = pDocShell->GetDocument();
565  ScDPCollection* pColl = rDoc.GetDPCollection();
566  if ( pColl )
567  {
568  size_t nCount = pColl->GetCount();
569  for (size_t i=0; i<nCount; ++i)
570  {
571  ScDPObject& rDPObj = (*pColl)[i];
572  if ( rDPObj.GetOutRange().aStart.Tab() == nTab &&
573  rDPObj.GetName() == aName )
574  return true;
575  }
576  }
577  }
578  return false;
579 }
580 
582  maPropSet( lcl_GetDataPilotDescriptorBaseMap() ),
583  pDocShell( &rDocSh )
584 {
586 }
587 
589 {
590  SolarMutexGuard g;
591 
592  if (pDocShell)
594 }
595 
597 {
599 
600  if ( rHint.GetId() == SfxHintId::Dying )
601  {
602  pDocShell = nullptr; // became invalid
603  }
604 }
605 
606 // XDataPilotDescriptor
607 
608 CellRangeAddress SAL_CALL ScDataPilotDescriptorBase::getSourceRange()
609 {
610  SolarMutexGuard aGuard;
611 
612  ScDPObject* pDPObject(GetDPObject());
613  if (!pDPObject)
614  throw RuntimeException("Failed to get DPObject", static_cast<cppu::OWeakObject*>(this));
615 
616  CellRangeAddress aRet;
617  if (pDPObject->IsSheetData())
619  return aRet;
620 }
621 
622 void SAL_CALL ScDataPilotDescriptorBase::setSourceRange( const CellRangeAddress& aSourceRange )
623 {
624  SolarMutexGuard aGuard;
625 
626  ScDPObject* pDPObject = GetDPObject();
627  if (!pDPObject)
628  throw RuntimeException("Failed to get DPObject", static_cast<cppu::OWeakObject*>(this));
629 
630  ScSheetSourceDesc aSheetDesc(&pDocShell->GetDocument());
631  if (pDPObject->IsSheetData())
632  aSheetDesc = *pDPObject->GetSheetDesc();
633 
634  ScRange aRange;
635  ScUnoConversion::FillScRange(aRange, aSourceRange);
636  aSheetDesc.SetSourceRange(aRange);
637  pDPObject->SetSheetDesc( aSheetDesc );
638  SetDPObject( pDPObject );
639 }
640 
641 Reference<XSheetFilterDescriptor> SAL_CALL ScDataPilotDescriptorBase::getFilterDescriptor()
642 {
643  SolarMutexGuard aGuard;
644  return new ScDataPilotFilterDescriptor( pDocShell, this );
645 }
646 
647 Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getDataPilotFields()
648 {
649  SolarMutexGuard aGuard;
650  return new ScDataPilotFieldsObj( *this );
651 }
652 
653 Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getColumnFields()
654 {
655  SolarMutexGuard aGuard;
656  return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_COLUMN );
657 }
658 
659 Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getRowFields()
660 {
661  SolarMutexGuard aGuard;
662  return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_ROW );
663 }
664 
665 Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getPageFields()
666 {
667  SolarMutexGuard aGuard;
668  return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_PAGE );
669 }
670 
671 Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getDataFields()
672 {
673  SolarMutexGuard aGuard;
674  return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_DATA );
675 }
676 
677 Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getHiddenFields()
678 {
679  SolarMutexGuard aGuard;
680  return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_HIDDEN );
681 }
682 
683 // XPropertySet
684 Reference< XPropertySetInfo > SAL_CALL ScDataPilotDescriptorBase::getPropertySetInfo( )
685 {
686  SolarMutexGuard aGuard;
687  static Reference<XPropertySetInfo> aRef =
689  return aRef;
690 }
691 
692 void SAL_CALL ScDataPilotDescriptorBase::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
693 {
694  SolarMutexGuard aGuard;
695  ScDPObject* pDPObject = GetDPObject();
696  if (!pDPObject)
697  return;
698 
699  ScDPSaveData* pOldData = pDPObject->GetSaveData();
700  OSL_ENSURE(pOldData, "Here should be a SaveData");
701  if ( pOldData )
702  {
703  ScDPSaveData aNewData( *pOldData );
704 
705  if ( aPropertyName == SC_UNO_DP_COLGRAND )
706  {
707  aNewData.SetColumnGrand(::cppu::any2bool( aValue ));
708  }
709  else if ( aPropertyName == SC_UNO_DP_IGNORE_EMPTYROWS )
710  {
711  aNewData.SetIgnoreEmptyRows(::cppu::any2bool( aValue ));
712  }
713  else if ( aPropertyName == SC_UNO_DP_REPEATEMPTY )
714  {
715  aNewData.SetRepeatIfEmpty(::cppu::any2bool( aValue ));
716  }
717  else if ( aPropertyName == SC_UNO_DP_ROWGRAND )
718  {
719  aNewData.SetRowGrand(::cppu::any2bool( aValue ));
720  }
721  else if ( aPropertyName == SC_UNO_DP_SHOWFILTER )
722  {
723  aNewData.SetFilterButton(::cppu::any2bool( aValue ));
724  }
725  else if ( aPropertyName == SC_UNO_DP_DRILLDOWN )
726  {
727  aNewData.SetDrillDown(::cppu::any2bool( aValue ));
728  }
729  else if ( aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME )
730  {
731  OUString aStrVal;
732  if ( aValue >>= aStrVal )
733  aNewData.SetGrandTotalName(aStrVal);
734  }
735  else if ( aPropertyName == SC_UNO_DP_IMPORTDESC )
736  {
737  uno::Sequence<beans::PropertyValue> aArgSeq;
738  if ( aValue >>= aArgSeq )
739  {
740  ScImportSourceDesc aImportDesc(&pDocShell->GetDocument());
741 
742  const ScImportSourceDesc* pOldDesc = pDPObject->GetImportSourceDesc();
743  if (pOldDesc)
744  aImportDesc = *pOldDesc;
745 
746  ScImportParam aParam;
747  ScImportDescriptor::FillImportParam( aParam, aArgSeq );
748 
749  sheet::DataImportMode nNewType = sheet::DataImportMode_NONE;
750  if ( aParam.bImport )
751  {
752  if ( aParam.bSql )
753  nNewType = sheet::DataImportMode_SQL;
754  else if ( aParam.nType == ScDbQuery )
755  nNewType = sheet::DataImportMode_QUERY;
756  else
757  nNewType = sheet::DataImportMode_TABLE;
758  }
759  aImportDesc.nType = nNewType;
760  aImportDesc.aDBName = aParam.aDBName;
761  aImportDesc.aObject = aParam.aStatement;
762  aImportDesc.bNative = aParam.bNative;
763 
764  pDPObject->SetImportDesc( aImportDesc );
765  }
766  }
767  else if ( aPropertyName == SC_UNO_DP_SOURCESERVICE )
768  {
769  OUString aStrVal;
770  if ( aValue >>= aStrVal )
771  {
772  ScDPServiceDesc aServiceDesc("", "", "", "", "");
773 
774  const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
775  if (pOldDesc)
776  aServiceDesc = *pOldDesc;
777 
778  aServiceDesc.aServiceName = aStrVal;
779 
780  pDPObject->SetServiceData( aServiceDesc );
781  }
782  }
783  else if ( aPropertyName == SC_UNO_DP_SERVICEARG )
784  {
785  uno::Sequence<beans::PropertyValue> aArgSeq;
786  if ( aValue >>= aArgSeq )
787  {
788  ScDPServiceDesc aServiceDesc("", "", "", "", "");
789 
790  const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
791  if (pOldDesc)
792  aServiceDesc = *pOldDesc;
793 
794  OUString aStrVal;
795  for (const beans::PropertyValue& rProp : std::as_const(aArgSeq))
796  {
797  OUString aPropName(rProp.Name);
798 
799  if (aPropName == SC_UNO_DP_SOURCENAME)
800  {
801  if ( rProp.Value >>= aStrVal )
802  aServiceDesc.aParSource = aStrVal;
803  }
804  else if (aPropName == SC_UNO_DP_OBJECTNAME)
805  {
806  if ( rProp.Value >>= aStrVal )
807  aServiceDesc.aParName = aStrVal;
808  }
809  else if (aPropName == SC_UNO_DP_USERNAME)
810  {
811  if ( rProp.Value >>= aStrVal )
812  aServiceDesc.aParUser = aStrVal;
813  }
814  else if (aPropName == SC_UNO_DP_PASSWORD)
815  {
816  if ( rProp.Value >>= aStrVal )
817  aServiceDesc.aParPass = aStrVal;
818  }
819  }
820 
821  pDPObject->SetServiceData( aServiceDesc );
822  }
823  }
824  else
825  throw UnknownPropertyException(aPropertyName);
826 
827  pDPObject->SetSaveData( aNewData );
828  }
829 
830  SetDPObject(pDPObject);
831 }
832 
833 Any SAL_CALL ScDataPilotDescriptorBase::getPropertyValue( const OUString& aPropertyName )
834 {
835  SolarMutexGuard aGuard;
836  Any aRet;
837 
838  ScDPObject* pDPObject(GetDPObject());
839  if (pDPObject)
840  {
841  ScDPSaveData* pOldData = pDPObject->GetSaveData();
842  OSL_ENSURE(pOldData, "Here should be a SaveData");
843  if ( pOldData )
844  {
845  ScDPSaveData aNewData( *pOldData );
846 
847  if ( aPropertyName == SC_UNO_DP_COLGRAND )
848  {
849  aRet <<= aNewData.GetColumnGrand();
850  }
851  else if ( aPropertyName == SC_UNO_DP_IGNORE_EMPTYROWS )
852  {
853  aRet <<= aNewData.GetIgnoreEmptyRows();
854  }
855  else if ( aPropertyName == SC_UNO_DP_REPEATEMPTY )
856  {
857  aRet <<= aNewData.GetRepeatIfEmpty();
858  }
859  else if ( aPropertyName == SC_UNO_DP_ROWGRAND )
860  {
861  aRet <<= aNewData.GetRowGrand();
862  }
863  else if ( aPropertyName == SC_UNO_DP_SHOWFILTER )
864  {
865  aRet <<= aNewData.GetFilterButton();
866  }
867  else if ( aPropertyName == SC_UNO_DP_DRILLDOWN )
868  {
869  aRet <<= aNewData.GetDrillDown();
870  }
871  else if ( aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME )
872  {
873  const std::optional<OUString> & pGrandTotalName = aNewData.GetGrandTotalName();
874  if (pGrandTotalName)
875  aRet <<= *pGrandTotalName; // same behavior as in ScDPSource
876  }
877  else if ( aPropertyName == SC_UNO_DP_IMPORTDESC )
878  {
879  const ScImportSourceDesc* pImportDesc = pDPObject->GetImportSourceDesc();
880  if ( pImportDesc )
881  {
882  // fill ScImportParam so ScImportDescriptor::FillProperties can be used
883  ScImportParam aParam;
884  aParam.bImport = ( pImportDesc->nType != sheet::DataImportMode_NONE );
885  aParam.aDBName = pImportDesc->aDBName;
886  aParam.aStatement = pImportDesc->aObject;
887  aParam.bNative = pImportDesc->bNative;
888  aParam.bSql = ( pImportDesc->nType == sheet::DataImportMode_SQL );
889  aParam.nType = static_cast<sal_uInt8>(( pImportDesc->nType == sheet::DataImportMode_QUERY ) ? ScDbQuery : ScDbTable);
890 
891  uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
892  ScImportDescriptor::FillProperties( aSeq, aParam );
893  aRet <<= aSeq;
894  }
895  else
896  {
897  // empty sequence
898  uno::Sequence<beans::PropertyValue> aEmpty(0);
899  aRet <<= aEmpty;
900  }
901  }
902  else if ( aPropertyName == SC_UNO_DP_SOURCESERVICE )
903  {
904  OUString aServiceName;
905  const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
906  if (pServiceDesc)
907  aServiceName = pServiceDesc->aServiceName;
908  aRet <<= aServiceName; // empty string if no ServiceDesc set
909  }
910  else if ( aPropertyName == SC_UNO_DP_SERVICEARG )
911  {
912  const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
913  if (pServiceDesc)
914  {
915  uno::Sequence<beans::PropertyValue> aSeq( comphelper::InitPropertySequence({
916  { SC_UNO_DP_SOURCENAME, Any(pServiceDesc->aParSource) },
917  { SC_UNO_DP_OBJECTNAME, Any(pServiceDesc->aParName) },
918  { SC_UNO_DP_USERNAME, Any(pServiceDesc->aParUser) },
919  { SC_UNO_DP_PASSWORD, Any(pServiceDesc->aParPass) }
920  }));
921  aRet <<= aSeq;
922  }
923  else
924  {
925  // empty sequence
926  uno::Sequence<beans::PropertyValue> aEmpty;
927  aRet <<= aEmpty;
928  }
929  }
930  else
931  throw UnknownPropertyException(aPropertyName);
932  }
933  }
934 
935  return aRet;
936 }
937 
939  const OUString& /* aPropertyName */, const Reference<XPropertyChangeListener >& /* xListener */ )
940 {
941 }
942 
944  const OUString& /* aPropertyName */, const Reference<XPropertyChangeListener >& /* aListener */ )
945 {
946 }
947 
949  const OUString& /* PropertyName */, const Reference<XVetoableChangeListener >& /* aListener */ )
950 {
951 }
952 
954  const OUString& /* PropertyName */, const Reference<XVetoableChangeListener >& /* aListener */ )
955 {
956 }
957 
958 // XDataPilotDataLayoutFieldSupplier
959 
960 Reference< XDataPilotField > SAL_CALL ScDataPilotDescriptorBase::getDataLayoutField()
961 {
962  SolarMutexGuard aGuard;
963  if( ScDPObject* pDPObject = GetDPObject() )
964  {
965  if( ScDPSaveData* pSaveData = pDPObject->GetSaveData() )
966  {
967  if( pSaveData->GetDataLayoutDimension() )
968  {
969  ScFieldIdentifier aFieldId( SC_DATALAYOUT_NAME, true );
970  return new ScDataPilotFieldObj( *this, aFieldId );
971  }
972  }
973  }
974  return nullptr;
975 }
976 
977 // XUnoTunnel
978 
980  const Sequence<sal_Int8 >& rId )
981 {
982  return comphelper::getSomethingImpl(rId, this);
983 }
984 
985 const Sequence<sal_Int8>& ScDataPilotDescriptorBase::getUnoTunnelId()
986 {
987  static const comphelper::UnoIdInit theScDataPilotDescriptorBaseUnoTunnelId;
988  return theScDataPilotDescriptorBaseUnoTunnelId.getSeq();
989 }
990 
992  ScDataPilotDescriptorBase( rDocSh ),
993  nTab( nT ),
994  aName( rN ),
995  aModifyListeners( 0 )
996 {
997 }
998 
1000 {
1001 }
1002 
1004 {
1005  // since we manually do resolve the query for XDataPilotTable2
1006  // we also need to do the same for XDataPilotTable
1007  SC_QUERYINTERFACE( XDataPilotTable )
1008  SC_QUERYINTERFACE( XDataPilotTable2 )
1009  SC_QUERYINTERFACE( XModifyBroadcaster )
1010 
1011  return ScDataPilotDescriptorBase::queryInterface( rType );
1012 }
1013 
1014 void SAL_CALL ScDataPilotTableObj::acquire() noexcept
1015 {
1016  ScDataPilotDescriptorBase::acquire();
1017 }
1018 
1019 void SAL_CALL ScDataPilotTableObj::release() noexcept
1020 {
1021  ScDataPilotDescriptorBase::release();
1022 }
1023 
1024 Sequence< uno::Type > SAL_CALL ScDataPilotTableObj::getTypes()
1025 {
1027  ScDataPilotDescriptorBase::getTypes(),
1028  Sequence< uno::Type >
1029  {
1032  } );
1033 }
1034 
1035 Sequence<sal_Int8> SAL_CALL ScDataPilotTableObj::getImplementationId()
1036 {
1037  return css::uno::Sequence<sal_Int8>();
1038 }
1039 
1041 {
1042  return lcl_GetDPObject(GetDocShell(), nTab, aName);
1043 }
1044 
1046 {
1047  ScDocShell* pDocSh = GetDocShell();
1048  ScDPObject* pDPObj = lcl_GetDPObject(pDocSh, nTab, aName);
1049  if ( pDPObj && pDocSh )
1050  {
1051  ScDBDocFunc aFunc(*pDocSh);
1052  aFunc.DataPilotUpdate( pDPObj, pDPObject, true, true );
1053  }
1054 }
1055 
1056 // "rest of XDataPilotDescriptor"
1057 
1058 OUString SAL_CALL ScDataPilotTableObj::getName()
1059 {
1060  SolarMutexGuard aGuard;
1062  if (pDPObj)
1063  return pDPObj->GetName();
1064  return OUString();
1065 }
1066 
1067 void SAL_CALL ScDataPilotTableObj::setName( const OUString& aNewName )
1068 {
1069  SolarMutexGuard aGuard;
1071  if (pDPObj)
1072  {
1074 
1075  pDPObj->SetName( aNewName );
1076  aName = aNewName;
1077 
1078  // DataPilotUpdate would do too much (output table is not changed)
1080  }
1081 }
1082 
1083 OUString SAL_CALL ScDataPilotTableObj::getTag()
1084 {
1085  SolarMutexGuard aGuard;
1087  if (pDPObj)
1088  return pDPObj->GetTag();
1089  return OUString();
1090 }
1091 
1092 void SAL_CALL ScDataPilotTableObj::setTag( const OUString& aNewTag )
1093 {
1094  SolarMutexGuard aGuard;
1096  if (pDPObj)
1097  {
1098  pDPObj->SetTag( aNewTag );
1099 
1100  // DataPilotUpdate would do too much (output table is not changed)
1102  }
1103 }
1104 
1105 // XDataPilotTable
1106 
1107 CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRange()
1108 {
1109  SolarMutexGuard aGuard;
1110  CellRangeAddress aRet;
1112  if (pDPObj)
1113  {
1114  ScRange aRange(pDPObj->GetOutRange());
1115  aRet.Sheet = aRange.aStart.Tab();
1116  aRet.StartColumn = aRange.aStart.Col();
1117  aRet.StartRow = aRange.aStart.Row();
1118  aRet.EndColumn = aRange.aEnd.Col();
1119  aRet.EndRow = aRange.aEnd.Row();
1120  }
1121  return aRet;
1122 }
1123 
1125 {
1126  SolarMutexGuard aGuard;
1128  if (pDPObj)
1129  {
1130  ScDBDocFunc aFunc(*GetDocShell());
1131  aFunc.RefreshPivotTables(pDPObj, true);
1132  }
1133 }
1134 
1135 Sequence< Sequence<Any> > SAL_CALL ScDataPilotTableObj::getDrillDownData(const CellAddress& aAddr)
1136 {
1137  SolarMutexGuard aGuard;
1138  Sequence< Sequence<Any> > aTabData;
1139  ScAddress aAddr2(static_cast<SCCOL>(aAddr.Column), static_cast<SCROW>(aAddr.Row), aAddr.Sheet);
1140  ScDPObject* pObj = GetDPObject();
1141  if (!pObj)
1142  throw RuntimeException("Failed to get DPObject", static_cast<cppu::OWeakObject*>(this));
1143 
1144  pObj->GetDrillDownData(aAddr2, aTabData);
1145  return aTabData;
1146 }
1147 
1148 DataPilotTablePositionData SAL_CALL ScDataPilotTableObj::getPositionData(const CellAddress& aAddr)
1149 {
1150  SolarMutexGuard aGuard;
1151  DataPilotTablePositionData aPosData;
1152  ScAddress aAddr2(static_cast<SCCOL>(aAddr.Column), static_cast<SCROW>(aAddr.Row), aAddr.Sheet);
1153  ScDPObject* pObj = GetDPObject();
1154  if (!pObj)
1155  throw RuntimeException("Failed to get DPObject", static_cast<cppu::OWeakObject*>(this));
1156 
1157  pObj->GetPositionData(aAddr2, aPosData);
1158  return aPosData;
1159 }
1160 
1161 void SAL_CALL ScDataPilotTableObj::insertDrillDownSheet(const CellAddress& aAddr)
1162 {
1163  SolarMutexGuard aGuard;
1164  ScDPObject* pDPObj = GetDPObject();
1165  if (!pDPObj)
1166  throw RuntimeException("Failed to get DPObject", static_cast<cppu::OWeakObject*>(this));
1168  if (!pViewSh)
1169  throw RuntimeException("Failed to get ViewShell", static_cast<cppu::OWeakObject*>(this));
1170 
1171  Sequence<DataPilotFieldFilter> aFilters;
1172  pDPObj->GetDataFieldPositionData(
1173  ScAddress(static_cast<SCCOL>(aAddr.Column), static_cast<SCROW>(aAddr.Row), aAddr.Sheet), aFilters);
1174  pViewSh->ShowDataPilotSourceData(*pDPObj, aFilters);
1175 }
1176 
1177 CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRangeByType( sal_Int32 nType )
1178 {
1179  SolarMutexGuard aGuard;
1180  if (nType < 0 || nType > DataPilotOutputRangeType::RESULT)
1181  throw IllegalArgumentException("nType must be between 0 and " +
1182  OUString::number(DataPilotOutputRangeType::RESULT) + ", got " + OUString::number(nType),
1183  static_cast<cppu::OWeakObject*>(this), 0);
1184 
1185  CellRangeAddress aRet;
1186  if (ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName))
1187  ScUnoConversion::FillApiRange( aRet, pDPObj->GetOutputRangeByType( nType ) );
1188  return aRet;
1189 }
1190 
1191 void SAL_CALL ScDataPilotTableObj::addModifyListener( const uno::Reference<util::XModifyListener>& aListener )
1192 {
1193  SolarMutexGuard aGuard;
1194 
1195  aModifyListeners.emplace_back( aListener );
1196 
1197  if ( aModifyListeners.size() == 1 )
1198  {
1199  acquire(); // don't lose this object (one ref for all listeners)
1200  }
1201 }
1202 
1203 void SAL_CALL ScDataPilotTableObj::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
1204 {
1205  SolarMutexGuard aGuard;
1206 
1207  rtl::Reference<ScDataPilotTableObj> xSelfHold(this); // in case the listeners have the last ref
1208 
1209  sal_uInt16 nCount = aModifyListeners.size();
1210  for ( sal_uInt16 n=nCount; n--; )
1211  {
1212  uno::Reference<util::XModifyListener>& rObj = aModifyListeners[n];
1213  if ( rObj == aListener )
1214  {
1215  aModifyListeners.erase( aModifyListeners.begin() + n );
1216 
1217  if ( aModifyListeners.empty() )
1218  {
1219  release(); // release the ref for the listeners
1220  }
1221 
1222  break;
1223  }
1224  }
1225 }
1226 
1228 {
1229  if ( auto pDataPilotHint = dynamic_cast<const ScDataPilotModifiedHint*>(&rHint) )
1230  {
1231  if (pDataPilotHint->GetName() == aName)
1232  Refreshed_Impl();
1233  }
1234  else if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) )
1235  {
1236  ScRange aRange( 0, 0, nTab );
1237  ScRangeList aRanges( aRange );
1238  if ( aRanges.UpdateReference( pRefHint->GetMode(), &GetDocShell()->GetDocument(), pRefHint->GetRange(),
1239  pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ) &&
1240  aRanges.size() == 1 )
1241  {
1242  nTab = aRanges.front().aStart.Tab();
1243  }
1244  }
1245 
1246  ScDataPilotDescriptorBase::Notify( rBC, rHint );
1247 }
1248 
1250 {
1251  lang::EventObject aEvent;
1252  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1253 
1254  // the EventObject holds a Ref to this object until after the listener calls
1255 
1256  ScDocument& rDoc = GetDocShell()->GetDocument();
1257  for (const uno::Reference<util::XModifyListener> & xModifyListener : aModifyListeners)
1258  rDoc.AddUnoListenerCall( xModifyListener, aEvent );
1259 }
1260 
1262  ScDataPilotDescriptorBase( rDocSh ),
1263  mpDPObject(new ScDPObject(&rDocSh.GetDocument()))
1264 {
1265  ScDPSaveData aSaveData;
1266  // set defaults like in ScPivotParam constructor
1267  aSaveData.SetColumnGrand( true );
1268  aSaveData.SetRowGrand( true );
1269  aSaveData.SetIgnoreEmptyRows( false );
1270  aSaveData.SetRepeatIfEmpty( false );
1271  mpDPObject->SetSaveData(aSaveData);
1272  ScSheetSourceDesc aSheetDesc(&rDocSh.GetDocument());
1273  mpDPObject->SetSheetDesc(aSheetDesc);
1274 }
1275 
1277 {
1278 }
1279 
1281 {
1282  return mpDPObject.get();
1283 }
1284 
1286 {
1287  if (mpDPObject.get() != pDPObject)
1288  {
1289  mpDPObject.reset( pDPObject );
1290  OSL_FAIL("replace DPObject should not happen");
1291  }
1292 }
1293 
1294 // "rest of XDataPilotDescriptor"
1295 
1297 {
1298  SolarMutexGuard aGuard;
1299  return mpDPObject->GetName();
1300 }
1301 
1302 void SAL_CALL ScDataPilotDescriptor::setName( const OUString& aNewName )
1303 {
1304  SolarMutexGuard aGuard;
1305  mpDPObject->SetName( aNewName );
1306 }
1307 
1309 {
1310  SolarMutexGuard aGuard;
1311  return mpDPObject->GetTag();
1312 }
1313 
1314 void SAL_CALL ScDataPilotDescriptor::setTag( const OUString& aNewTag )
1315 {
1316  SolarMutexGuard aGuard;
1317  mpDPObject->SetTag( aNewTag );
1318 }
1319 
1321  mxParent( &rParent )
1322 {
1323 }
1324 
1326  mxParent( &rParent ),
1327  maFieldId( rFieldId )
1328 {
1329 }
1330 
1332 {
1333 }
1334 
1336 {
1337  return mxParent->GetDPObject();
1338 }
1339 
1341 {
1342  mxParent->SetDPObject( pDPObject );
1343 }
1344 
1346 {
1347  if( ScDPObject* pDPObj = GetDPObject() )
1348  {
1349  if( ppDPObject ) *ppDPObject = pDPObj;
1350  if( ScDPSaveData* pSaveData = pDPObj->GetSaveData() )
1351  {
1352  if( maFieldId.mbDataLayout )
1353  return pSaveData->GetDataLayoutDimension();
1354 
1355  if( maFieldId.mnFieldIdx == 0 )
1356  return pSaveData->GetDimensionByName( maFieldId.maFieldName );
1357 
1358  // find dimension with specified index (search in duplicated dimensions)
1359  const ScDPSaveData::DimsType& rDims = pSaveData->GetDimensions();
1360 
1361  sal_Int32 nFoundIdx = 0;
1362  for (auto const& it : rDims)
1363  {
1364  if (it->IsDataLayout())
1365  continue;
1366 
1367  OUString aSrcName = ScDPUtil::getSourceDimensionName(it->GetName());
1368  if (aSrcName == maFieldId.maFieldName)
1369  {
1370  if( nFoundIdx == maFieldId.mnFieldIdx )
1371  return it.get();
1372  ++nFoundIdx;
1373  }
1374  }
1375  }
1376  }
1377  return nullptr;
1378 }
1379 
1381 {
1382  sal_Int32 nRet = 0;
1383  Reference<XNameAccess> xMembersNA = GetMembers();
1384  if (xMembersNA.is())
1385  {
1386  Reference< XIndexAccess > xMembersIA( new ScNameToIndexAccess( xMembersNA ) );
1387  nRet = xMembersIA->getCount();
1388  }
1389  return nRet;
1390 }
1391 
1392 Reference< XMembersAccess > ScDataPilotChildObjBase::GetMembers() const
1393 {
1394  Reference< XMembersAccess > xMembersNA;
1395  if( ScDPObject* pDPObj = GetDPObject() )
1396  pDPObj->GetMembersNA( lcl_GetObjectIndex( pDPObj, maFieldId ), xMembersNA );
1397  return xMembersNA;
1398 }
1399 
1401 {
1402  return mxParent->GetDocShell();
1403 }
1404 
1406  ScDataPilotChildObjBase( rParent )
1407 {
1408 }
1409 
1410 ScDataPilotFieldsObj::ScDataPilotFieldsObj( ScDataPilotDescriptorBase& rParent, DataPilotFieldOrientation eOrient ) :
1411  ScDataPilotChildObjBase( rParent ),
1412  maOrient( eOrient )
1413 {
1414 }
1415 
1417 {
1418 }
1419 
1420 static sal_Int32 lcl_GetFieldCount( const Reference<XDimensionsSupplier>& rSource, const Any& rOrient )
1421 {
1422  if (!rSource.is())
1423  throw NullPointerException();
1424 
1425  sal_Int32 nRet = 0;
1426 
1427  Reference<XNameAccess> xDimsName(rSource->getDimensions());
1428  Reference<XIndexAccess> xIntDims(new ScNameToIndexAccess( xDimsName ));
1429  sal_Int32 nIntCount = xIntDims->getCount();
1430  for (sal_Int32 i = 0; i < nIntCount; ++i)
1431  {
1432  Reference<XPropertySet> xDim(xIntDims->getByIndex(i), UNO_QUERY);
1433  const bool bMatch = xDim
1434  && (rOrient.hasValue()
1435  // all fields of the specified orientation, including duplicated
1436  ? (xDim->getPropertyValue(SC_UNO_DP_ORIENTATION) == rOrient)
1437  // count all non-duplicated fields
1438  : !lcl_IsDuplicated(xDim));
1439  if (bMatch)
1440  ++nRet;
1441  }
1442 
1443  return nRet;
1444 }
1445 
1446 static bool lcl_GetFieldDataByIndex( const Reference<XDimensionsSupplier>& rSource,
1447  const Any& rOrient, SCSIZE nIndex, ScFieldIdentifier& rFieldId )
1448 {
1449  if (!rSource.is())
1450  throw NullPointerException();
1451 
1452  bool bOk = false;
1453  SCSIZE nPos = 0;
1454  sal_Int32 nDimIndex = 0;
1455 
1456  Reference<XNameAccess> xDimsName(rSource->getDimensions());
1457  Reference<XIndexAccess> xIntDims(new ScNameToIndexAccess( xDimsName ));
1458  sal_Int32 nIntCount = xIntDims->getCount();
1460  for (sal_Int32 i = 0; i < nIntCount; ++i)
1461  {
1462  xDim.set(xIntDims->getByIndex(i), UNO_QUERY);
1463  const bool bMatch = xDim
1464  && (rOrient.hasValue()
1465  ? (xDim->getPropertyValue(SC_UNO_DP_ORIENTATION) == rOrient)
1466  : !lcl_IsDuplicated(xDim));
1467  if (bMatch)
1468  {
1469  if (nPos == nIndex)
1470  {
1471  bOk = true;
1472  nDimIndex = i;
1473  break;
1474  }
1475  else
1476  ++nPos;
1477  }
1478  }
1479 
1480  if ( bOk )
1481  {
1482  xDim.set( xIntDims->getByIndex(nDimIndex), UNO_QUERY );
1483  Reference<XNamed> xDimName( xDim, UNO_QUERY );
1484  if ( xDimName.is() )
1485  {
1486  OUString sOriginalName( lcl_GetOriginalName( xDimName ) );
1487  rFieldId.maFieldName = sOriginalName;
1490 
1491  sal_Int32 nRepeat = 0;
1492  if ( rOrient.hasValue() && lcl_IsDuplicated( xDim ) )
1493  {
1494  // find the repeat count
1495  // (this relies on the original dimension always being before the duplicates)
1496 
1497  Reference<XNamed> xPrevName;
1498  for (sal_Int32 i = 0; i < nDimIndex; ++i)
1499  {
1500  xPrevName.set( xIntDims->getByIndex(i), UNO_QUERY );
1501  if ( xPrevName.is() && lcl_GetOriginalName( xPrevName ) == sOriginalName )
1502  ++nRepeat;
1503  }
1504  }
1505  rFieldId.mnFieldIdx = nRepeat;
1506  }
1507  else
1508  bOk = false;
1509  }
1510 
1511  return bOk;
1512 }
1513 
1514 static bool lcl_GetFieldDataByName( ScDPObject* pDPObj, const OUString& rFieldName, ScFieldIdentifier& rFieldId )
1515 {
1516  // "By name" is always the first match.
1517  // The name "Data" always refers to the data layout field.
1518  rFieldId.maFieldName = rFieldName;
1519  rFieldId.mnFieldIdx = 0;
1520  rFieldId.mbDataLayout = rFieldName == SC_DATALAYOUT_NAME;
1521 
1522  pDPObj->GetSource(); // IsDimNameInUse doesn't update source data
1523 
1524  // check if the named field exists (not for data layout)
1525  return rFieldId.mbDataLayout || pDPObj->IsDimNameInUse( rFieldName );
1526 }
1527 
1528 // XDataPilotFields
1529 
1531 {
1532  if (ScDPObject* pObj = GetDPObject())
1533  {
1534  ScFieldIdentifier aFieldId;
1535  if (lcl_GetFieldDataByIndex( pObj->GetSource(), maOrient, nIndex, aFieldId ))
1536  return new ScDataPilotFieldObj( *mxParent, aFieldId, maOrient );
1537  }
1538  return nullptr;
1539 }
1540 
1542 {
1543  if (ScDPObject* pDPObj = GetDPObject())
1544  {
1545  ScFieldIdentifier aFieldId;
1546  if (lcl_GetFieldDataByName( pDPObj, aName, aFieldId ))
1547  return new ScDataPilotFieldObj( *mxParent, aFieldId, maOrient );
1548  }
1549  return nullptr;
1550 }
1551 
1552 // XEnumerationAccess
1553 
1554 Reference<XEnumeration> SAL_CALL ScDataPilotFieldsObj::createEnumeration()
1555 {
1556  SolarMutexGuard aGuard;
1557  return new ScIndexEnumeration(this, "com.sun.star.sheet.DataPilotFieldsEnumeration");
1558 }
1559 
1560 // XIndexAccess
1561 
1563 {
1564  SolarMutexGuard aGuard;
1565  ScDPObject* pDPObj = GetDPObject();
1566  return pDPObj ? lcl_GetFieldCount( pDPObj->GetSource(), maOrient ) : 0;
1567 }
1568 
1569 Any SAL_CALL ScDataPilotFieldsObj::getByIndex( sal_Int32 nIndex )
1570 {
1571  SolarMutexGuard aGuard;
1573  if (!xField.is())
1574  throw IndexOutOfBoundsException();
1575  return Any( xField );
1576 }
1577 
1578 // XElementAccess
1579 
1581 {
1583 }
1584 
1586 {
1587  SolarMutexGuard aGuard;
1588  return ( getCount() != 0 );
1589 }
1590 
1591 // XNameAccess
1592 
1593 Any SAL_CALL ScDataPilotFieldsObj::getByName( const OUString& aName )
1594 {
1595  SolarMutexGuard aGuard;
1597  if (!xField.is())
1598  throw NoSuchElementException();
1599  return Any( xField );
1600 }
1601 
1603 {
1604  SolarMutexGuard aGuard;
1605  if (ScDPObject* pDPObj = GetDPObject())
1606  {
1607  Sequence< OUString > aSeq( lcl_GetFieldCount( pDPObj->GetSource(), maOrient ) );
1608  OUString* pAry = aSeq.getArray();
1609 
1610  const ScDPSaveData::DimsType& rDimensions = pDPObj->GetSaveData()->GetDimensions();
1611  for (auto const& it : rDimensions)
1612  {
1613  if(maOrient.hasValue() && (it->GetOrientation() == maOrient.get< DataPilotFieldOrientation >()))
1614  {
1615  *pAry = it->GetName();
1616  ++pAry;
1617  }
1618  }
1619  return aSeq;
1620  }
1621  return Sequence<OUString>();
1622 }
1623 
1624 sal_Bool SAL_CALL ScDataPilotFieldsObj::hasByName( const OUString& aName )
1625 {
1626  SolarMutexGuard aGuard;
1627 
1628  return GetObjectByName_Impl(aName) != nullptr;
1629 }
1630 
1632  ScDataPilotDescriptorBase& rParent, const ScFieldIdentifier& rFieldId ) :
1633  ScDataPilotChildObjBase( rParent, rFieldId ),
1634  maPropSet( lcl_GetDataPilotFieldMap() )
1635 {
1636 }
1637 
1639  const ScFieldIdentifier& rFieldId, const Any& rOrient ) :
1640  ScDataPilotChildObjBase( rParent, rFieldId ),
1641  maPropSet( lcl_GetDataPilotFieldMap() ),
1642  maOrient( rOrient )
1643 {
1644 }
1645 
1647 {
1648 }
1649 
1650 // XNamed
1651 
1652 OUString SAL_CALL ScDataPilotFieldObj::getName()
1653 {
1654  SolarMutexGuard aGuard;
1655  OUString aName;
1656  if( ScDPSaveDimension* pDim = GetDPDimension() )
1657  {
1658  if( pDim->IsDataLayout() )
1659  aName = SC_DATALAYOUT_NAME;
1660  else
1661  {
1662  const std::optional<OUString> & pLayoutName = pDim->GetLayoutName();
1663  if (pLayoutName)
1664  aName = *pLayoutName;
1665  else
1666  aName = pDim->GetName();
1667  }
1668  }
1669  return aName;
1670 }
1671 
1672 void SAL_CALL ScDataPilotFieldObj::setName(const OUString& rName)
1673 {
1674  SolarMutexGuard aGuard;
1675  ScDPObject* pDPObj = nullptr;
1676  ScDPSaveDimension* pDim = GetDPDimension( &pDPObj );
1677  if( pDim && !pDim->IsDataLayout() )
1678  {
1679  pDim->SetLayoutName(rName);
1680  SetDPObject( pDPObj );
1681  }
1682 }
1683 
1684 // XPropertySet
1685 
1686 Reference<XPropertySetInfo> SAL_CALL ScDataPilotFieldObj::getPropertySetInfo()
1687 {
1688  SolarMutexGuard aGuard;
1689  static Reference<XPropertySetInfo> aRef(
1691  return aRef;
1692 }
1693 
1694 void SAL_CALL ScDataPilotFieldObj::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
1695 {
1696  SolarMutexGuard aGuard;
1697  if ( aPropertyName == SC_UNONAME_FUNCTION )
1698  {
1699  // #i109350# use GetEnumFromAny because it also allows sal_Int32
1700  ScGeneralFunction eFunction = static_cast<ScGeneralFunction>(ScUnoHelpFunctions::GetEnumFromAny( aValue ));
1701  setFunction( eFunction );
1702  }
1703  else if ( aPropertyName == SC_UNONAME_FUNCTION2 )
1704  {
1705  ScGeneralFunction eFunction = static_cast<ScGeneralFunction>(ScUnoHelpFunctions::GetInt16FromAny( aValue ));
1706  setFunction( eFunction );
1707  }
1708  else if ( aPropertyName == SC_UNONAME_SUBTOTALS )
1709  {
1710  uno::Sequence<sheet::GeneralFunction> aSeq;
1711  if( aValue >>= aSeq)
1712  {
1713  std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength());
1714  std::transform(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.begin(),
1715  [](const sheet::GeneralFunction& rValue) -> ScGeneralFunction {
1716  const int nValAsInt = static_cast<int>(rValue);
1717  return static_cast<ScGeneralFunction>(nValAsInt);
1718  });
1719  setSubtotals( aSubTotals );
1720  }
1721  }
1722  else if ( aPropertyName == SC_UNONAME_SUBTOTALS2 )
1723  {
1724  Sequence< sal_Int16 > aSeq;
1725  if( aValue >>= aSeq )
1726  {
1727  std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength());
1728  std::transform(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.begin(),
1729  [](sal_Int16 nValue) -> ScGeneralFunction { return static_cast<ScGeneralFunction>(nValue); });
1730  setSubtotals( aSubTotals );
1731  }
1732  }
1733  else if ( aPropertyName == SC_UNONAME_ORIENT )
1734  {
1736  DataPilotFieldOrientation eOrient = static_cast<DataPilotFieldOrientation>(ScUnoHelpFunctions::GetEnumFromAny( aValue ));
1737  setOrientation( eOrient );
1738  }
1739  else if ( aPropertyName == SC_UNONAME_SELPAGE )
1740  {
1741  OUString sCurrentPage;
1742  if (aValue >>= sCurrentPage)
1743  setCurrentPage(sCurrentPage);
1744  }
1745  else if ( aPropertyName == SC_UNONAME_USESELPAGE )
1746  {
1748  }
1749  else if ( aPropertyName == SC_UNONAME_HASAUTOSHOW )
1750  {
1751  if (!cppu::any2bool(aValue))
1752  setAutoShowInfo(nullptr);
1753  }
1754  else if ( aPropertyName == SC_UNONAME_AUTOSHOW )
1755  {
1756  DataPilotFieldAutoShowInfo aInfo;
1757  if (aValue >>= aInfo)
1758  setAutoShowInfo(&aInfo);
1759  }
1760  else if ( aPropertyName == SC_UNONAME_HASLAYOUTINFO )
1761  {
1762  if (!cppu::any2bool(aValue))
1763  setLayoutInfo(nullptr);
1764  }
1765  else if ( aPropertyName == SC_UNONAME_LAYOUTINFO )
1766  {
1767  DataPilotFieldLayoutInfo aInfo;
1768  if (aValue >>= aInfo)
1769  setLayoutInfo(&aInfo);
1770  }
1771  else if ( aPropertyName == SC_UNONAME_HASREFERENCE )
1772  {
1773  if (!cppu::any2bool(aValue))
1774  setReference(nullptr);
1775  }
1776  else if ( aPropertyName == SC_UNONAME_REFERENCE )
1777  {
1778  DataPilotFieldReference aRef;
1779  if (aValue >>= aRef)
1780  setReference(&aRef);
1781  }
1782  else if ( aPropertyName == SC_UNONAME_HASSORTINFO )
1783  {
1784  if (!cppu::any2bool(aValue))
1785  setSortInfo(nullptr);
1786  }
1787  else if ( aPropertyName == SC_UNONAME_SORTINFO )
1788  {
1789  DataPilotFieldSortInfo aInfo;
1790  if (aValue >>= aInfo)
1791  setSortInfo(&aInfo);
1792  }
1793  else if ( aPropertyName == SC_UNONAME_ISGROUP )
1794  {
1795  if (!cppu::any2bool(aValue))
1796  setGroupInfo(nullptr);
1797  }
1798  else if ( aPropertyName == SC_UNONAME_GROUPINFO )
1799  {
1800  DataPilotFieldGroupInfo aInfo;
1801  if (aValue >>= aInfo)
1802  setGroupInfo(&aInfo);
1803  }
1804  else if ( aPropertyName == SC_UNONAME_SHOWEMPTY )
1805  {
1806  setShowEmpty(cppu::any2bool(aValue));
1807  }
1808  else if ( aPropertyName == SC_UNONAME_REPEATITEMLABELS )
1809  {
1811  }
1812  else if (aPropertyName == SC_UNONAME_NAME)
1813  {
1814  OUString sName;
1815  if (aValue >>= sName)
1816  setName(sName);
1817  }
1818 }
1819 
1820 Any SAL_CALL ScDataPilotFieldObj::getPropertyValue( const OUString& aPropertyName )
1821 {
1822  SolarMutexGuard aGuard;
1823  Any aRet;
1824 
1825  if ( aPropertyName == SC_UNONAME_FUNCTION )
1826  {
1827  sheet::GeneralFunction eVal;
1828  sal_Int16 nFunction = getFunction();
1829  if (nFunction == sheet::GeneralFunction2::MEDIAN)
1830  {
1831  eVal = sheet::GeneralFunction_NONE;
1832  }
1833  else
1834  {
1835  eVal = static_cast<sheet::GeneralFunction>(nFunction);
1836  }
1837  aRet <<= eVal;
1838  }
1839  else if ( aPropertyName == SC_UNONAME_FUNCTION2 )
1840  aRet <<= getFunction();
1841  else if ( aPropertyName == SC_UNONAME_SUBTOTALS )
1842  {
1843  const uno::Sequence<sal_Int16> aSeq = getSubtotals();
1844  uno::Sequence<sheet::GeneralFunction> aNewSeq(aSeq.getLength());
1845  std::transform(aSeq.begin(), aSeq.end(), aNewSeq.getArray(),
1846  [](sal_Int16 nFunc) -> sheet::GeneralFunction {
1847  if (nFunc == sheet::GeneralFunction2::MEDIAN)
1848  return sheet::GeneralFunction_NONE;
1849  return static_cast<sheet::GeneralFunction>(nFunc);
1850  });
1851  aRet <<= aNewSeq;
1852  }
1853  else if ( aPropertyName == SC_UNONAME_SUBTOTALS2 )
1854  {
1855  aRet <<= getSubtotals();
1856  }
1857  else if ( aPropertyName == SC_UNONAME_ORIENT )
1858  aRet <<= getOrientation();
1859  else if ( aPropertyName == SC_UNONAME_SELPAGE )
1860  aRet <<= OUString();
1861  else if ( aPropertyName == SC_UNONAME_USESELPAGE )
1862  aRet <<= false;
1863  else if ( aPropertyName == SC_UNONAME_HASAUTOSHOW )
1864  aRet <<= (getAutoShowInfo() != nullptr);
1865  else if ( aPropertyName == SC_UNONAME_AUTOSHOW )
1866  {
1867  const DataPilotFieldAutoShowInfo* pInfo = getAutoShowInfo();
1868  if (pInfo)
1869  aRet <<= *pInfo;
1870  }
1871  else if ( aPropertyName == SC_UNONAME_HASLAYOUTINFO )
1872  aRet <<= (getLayoutInfo() != nullptr);
1873  else if ( aPropertyName == SC_UNONAME_LAYOUTINFO )
1874  {
1875  const DataPilotFieldLayoutInfo* pInfo = getLayoutInfo();
1876  if (pInfo)
1877  aRet <<= *pInfo;
1878  }
1879  else if ( aPropertyName == SC_UNONAME_HASREFERENCE )
1880  aRet <<= (getReference() != nullptr);
1881  else if ( aPropertyName == SC_UNONAME_REFERENCE )
1882  {
1883  const DataPilotFieldReference* pRef = getReference();
1884  if (pRef)
1885  aRet <<= *pRef;
1886  }
1887  else if ( aPropertyName == SC_UNONAME_HASSORTINFO )
1888  aRet <<= (getSortInfo() != nullptr);
1889  else if ( aPropertyName == SC_UNONAME_SORTINFO )
1890  {
1891  const DataPilotFieldSortInfo* pInfo = getSortInfo();
1892  if (pInfo)
1893  aRet <<= *pInfo;
1894  }
1895  else if ( aPropertyName == SC_UNONAME_ISGROUP )
1896  aRet <<= hasGroupInfo();
1897  else if ( aPropertyName == SC_UNONAME_GROUPINFO )
1898  {
1899  aRet <<= getGroupInfo();
1900  }
1901  else if ( aPropertyName == SC_UNONAME_SHOWEMPTY )
1902  aRet <<= getShowEmpty();
1903  else if ( aPropertyName == SC_UNONAME_REPEATITEMLABELS )
1904  aRet <<= getRepeatItemLabels();
1905  else if (aPropertyName == SC_UNONAME_NAME)
1906  aRet <<= getName();
1907 
1908  return aRet;
1909 }
1910 
1911 // XDatePilotField
1912 
1913 Reference<XIndexAccess> SAL_CALL ScDataPilotFieldObj::getItems()
1914 {
1915  SolarMutexGuard aGuard;
1916  if (!mxItems.is())
1918  return mxItems;
1919 }
1920 
1922 
1923 DataPilotFieldOrientation ScDataPilotFieldObj::getOrientation() const
1924 {
1925  SolarMutexGuard aGuard;
1926  ScDPSaveDimension* pDim = GetDPDimension();
1927  return pDim ? pDim->GetOrientation() : DataPilotFieldOrientation_HIDDEN;
1928 }
1929 
1930 void ScDataPilotFieldObj::setOrientation(DataPilotFieldOrientation eNew)
1931 {
1932  SolarMutexGuard aGuard;
1933  if (maOrient.hasValue() && (eNew == maOrient.get< DataPilotFieldOrientation >()))
1934  return;
1935 
1936  ScDPObject* pDPObj = nullptr;
1937  ScDPSaveDimension* pDim = GetDPDimension( &pDPObj );
1938  if(!pDim)
1939  return;
1940 
1941  ScDPSaveData* pSaveData = pDPObj->GetSaveData();
1942 
1943  /* If the field was taken from getDataPilotFields(), don't reset the
1944  orientation for an existing use, but create a duplicated field
1945  instead (for "Data" orientation only). */
1946  if ( !maOrient.hasValue() && !maFieldId.mbDataLayout &&
1947  (pDim->GetOrientation() != DataPilotFieldOrientation_HIDDEN) &&
1948  (eNew == DataPilotFieldOrientation_DATA) )
1949  {
1950 
1951  ScDPSaveDimension* pNewDim = nullptr;
1952 
1953  // look for existing duplicate with orientation "hidden"
1954 
1955  sal_Int32 nFound = 0;
1956  const ScDPSaveData::DimsType& rDimensions = pSaveData->GetDimensions();
1957  for (auto const& it : rDimensions)
1958  {
1959  if ( !it->IsDataLayout() && (it->GetName() == maFieldId.maFieldName) )
1960  {
1961  if ( it->GetOrientation() == DataPilotFieldOrientation_HIDDEN )
1962  {
1963  pNewDim = it.get(); // use this one
1964  break;
1965  }
1966  else
1967  ++nFound; // count existing non-hidden occurrences
1968  }
1969  }
1970 
1971  if ( !pNewDim ) // if none found, create a new duplicated dimension
1972  pNewDim = &pSaveData->DuplicateDimension( *pDim );
1973 
1974  maFieldId.mnFieldIdx = nFound; // keep accessing the new one
1975  pDim = pNewDim;
1976  }
1977 
1978  pDim->SetOrientation(eNew);
1979 
1980  // move changed field behind all other fields (make it the last field in dimension)
1981  pSaveData->SetPosition( pDim, pSaveData->GetDimensions().size() );
1982 
1983  SetDPObject( pDPObj );
1984 
1985  maOrient <<= eNew; // modifying the same object's orientation again doesn't create another duplicate
1986 }
1987 
1989 {
1990  SolarMutexGuard aGuard;
1991  sal_Int16 eRet = GeneralFunction2::NONE;
1992  if( ScDPSaveDimension* pDim = GetDPDimension() )
1993  {
1994  if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
1995  {
1996  // for non-data fields, property Function is the subtotals
1997  tools::Long nSubCount = pDim->GetSubTotalsCount();
1998  if ( nSubCount > 0 )
1999  eRet = static_cast<sal_Int16>(pDim->GetSubTotalFunc(0)); // always use the first one
2000  // else keep NONE
2001  }
2002  else
2003  eRet = static_cast<sal_Int16>(pDim->GetFunction());
2004  }
2005  return eRet;
2006 }
2007 
2009 {
2010  SolarMutexGuard aGuard;
2011  ScDPObject* pDPObj = nullptr;
2012  ScDPSaveDimension* pDim = GetDPDimension( &pDPObj );
2013  if(!pDim)
2014  return;
2015 
2016  if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
2017  {
2018  // for non-data fields, property Function is the subtotals
2019  std::vector<ScGeneralFunction> nSubTotalFuncs;
2020  if ( eNewFunc != ScGeneralFunction::NONE )
2021  {
2022  nSubTotalFuncs.push_back( eNewFunc );
2023  }
2024  pDim->SetSubTotals( std::move(nSubTotalFuncs) );
2025  }
2026  else
2027  pDim->SetFunction( eNewFunc );
2028  SetDPObject( pDPObj );
2029 }
2030 
2031 Sequence< sal_Int16 > ScDataPilotFieldObj::getSubtotals() const
2032 {
2033  SolarMutexGuard aGuard;
2034  Sequence< sal_Int16 > aRet;
2035  if( ScDPSaveDimension* pDim = GetDPDimension() )
2036  {
2037  if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
2038  {
2039  // for non-data fields, property Functions is the sequence of subtotals
2040  sal_Int32 nCount = static_cast< sal_Int32 >( pDim->GetSubTotalsCount() );
2041  if ( nCount > 0 )
2042  {
2043  aRet.realloc( nCount );
2044  auto pRet = aRet.getArray();
2045  for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
2046  pRet[ nIdx ] = static_cast<sal_Int16>(pDim->GetSubTotalFunc( nIdx ));
2047  }
2048  }
2049  }
2050  return aRet;
2051 }
2052 
2053 void ScDataPilotFieldObj::setSubtotals( const std::vector< ScGeneralFunction >& rSubtotals )
2054 {
2055  SolarMutexGuard aGuard;
2056  ScDPObject* pDPObj = nullptr;
2057  ScDPSaveDimension* pDim = GetDPDimension( &pDPObj );
2058  if(!pDim)
2059  return;
2060 
2061  if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
2062  {
2063  sal_Int32 nCount = rSubtotals.size();
2064  if( nCount == 1 )
2065  {
2066  // count 1: all values are allowed (including NONE and AUTO)
2067  std::vector<ScGeneralFunction> nTmpFuncs;
2068  if( rSubtotals[ 0 ] != ScGeneralFunction::NONE )
2069  {
2070  nTmpFuncs.push_back( rSubtotals[ 0 ] );
2071  }
2072  pDim->SetSubTotals( std::move(nTmpFuncs) );
2073  }
2074  else if( nCount > 1 )
2075  {
2076  // set multiple functions, ignore NONE and AUTO in this case
2077  ::std::vector< ScGeneralFunction > aSubt;
2078  for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
2079  {
2080  ScGeneralFunction eFunc = rSubtotals[ nIdx ];
2081  if( (eFunc != ScGeneralFunction::NONE) && (eFunc != ScGeneralFunction::AUTO) )
2082  {
2083  // do not insert functions twice
2084  if( ::std::find( aSubt.begin(), aSubt.end(), eFunc ) == aSubt.end() )
2085  aSubt.push_back( eFunc );
2086  }
2087  }
2088  // set values from vector to ScDPSaveDimension
2089  pDim->SetSubTotals( std::move(aSubt) );
2090  }
2091  }
2092  SetDPObject( pDPObj );
2093 }
2094 
2095 void ScDataPilotFieldObj::setCurrentPage( const OUString& rPage )
2096 {
2097  SolarMutexGuard aGuard;
2098  ScDPObject* pDPObj = nullptr;
2099  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2100  {
2101  pDim->SetCurrentPage( &rPage );
2102  SetDPObject( pDPObj );
2103  }
2104 }
2105 
2107 {
2108  SolarMutexGuard aGuard;
2109  ScDPObject* pDPObj = nullptr;
2110  ScDPSaveDimension* pDim = GetDPDimension( &pDPObj );
2111  if(!pDim)
2112  return;
2113 
2114  if( bUse )
2115  {
2116  /* It is somehow useless to set the property "HasSelectedPage" to
2117  true, because it is still needed to set an explicit page name. */
2118  const OUString aPage;
2119  pDim->SetCurrentPage( &aPage );
2120  }
2121  else
2122  pDim->SetCurrentPage( nullptr );
2123  SetDPObject( pDPObj );
2124 }
2125 
2126 const DataPilotFieldAutoShowInfo* ScDataPilotFieldObj::getAutoShowInfo() const
2127 {
2128  SolarMutexGuard aGuard;
2130  return pDim ? pDim->GetAutoShowInfo() : nullptr;
2131 }
2132 
2133 void ScDataPilotFieldObj::setAutoShowInfo( const DataPilotFieldAutoShowInfo* pInfo )
2134 {
2135  SolarMutexGuard aGuard;
2136  ScDPObject* pDPObj = nullptr;
2137  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2138  {
2139  pDim->SetAutoShowInfo( pInfo );
2140  SetDPObject( pDPObj );
2141  }
2142 }
2143 
2144 const DataPilotFieldLayoutInfo* ScDataPilotFieldObj::getLayoutInfo() const
2145 {
2146  SolarMutexGuard aGuard;
2148  return pDim ? pDim->GetLayoutInfo() : nullptr;
2149 }
2150 
2151 void ScDataPilotFieldObj::setLayoutInfo( const DataPilotFieldLayoutInfo* pInfo )
2152 {
2153  SolarMutexGuard aGuard;
2154  ScDPObject* pDPObj = nullptr;
2155  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2156  {
2157  pDim->SetLayoutInfo( pInfo );
2158  SetDPObject( pDPObj );
2159  }
2160 }
2161 
2162 const DataPilotFieldReference* ScDataPilotFieldObj::getReference() const
2163 {
2164  SolarMutexGuard aGuard;
2166  return pDim ? pDim->GetReferenceValue() : nullptr;
2167 }
2168 
2169 void ScDataPilotFieldObj::setReference( const DataPilotFieldReference* pInfo )
2170 {
2171  SolarMutexGuard aGuard;
2172  ScDPObject* pDPObj = nullptr;
2173  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2174  {
2175  pDim->SetReferenceValue( pInfo );
2176  SetDPObject( pDPObj );
2177  }
2178 }
2179 
2180 const DataPilotFieldSortInfo* ScDataPilotFieldObj::getSortInfo() const
2181 {
2182  SolarMutexGuard aGuard;
2184  return pDim ? pDim->GetSortInfo() : nullptr;
2185 }
2186 
2187 void ScDataPilotFieldObj::setSortInfo( const DataPilotFieldSortInfo* pInfo )
2188 {
2189  SolarMutexGuard aGuard;
2190  ScDPObject* pDPObj = nullptr;
2191  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2192  {
2193  pDim->SetSortInfo( pInfo );
2194  SetDPObject( pDPObj );
2195  }
2196 }
2197 
2199 {
2200  SolarMutexGuard aGuard;
2202  return pDim && pDim->GetShowEmpty();
2203 }
2204 
2206 {
2207  SolarMutexGuard aGuard;
2208  ScDPObject* pDPObj = nullptr;
2209  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2210  {
2211  pDim->SetShowEmpty( bShow );
2212  SetDPObject( pDPObj );
2213  }
2214 }
2215 
2217 {
2218  SolarMutexGuard aGuard;
2220  return pDim && pDim->GetRepeatItemLabels();
2221 }
2222 
2224 {
2225  SolarMutexGuard aGuard;
2226  ScDPObject* pDPObj = nullptr;
2227  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2228  {
2229  pDim->SetRepeatItemLabels( bShow );
2230  SetDPObject( pDPObj );
2231  }
2232 }
2233 
2235 {
2236  SolarMutexGuard aGuard;
2237  ScDPObject* pDPObj = nullptr;
2238  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2239  if( const ScDPDimensionSaveData* pDimData = pDPObj->GetSaveData()->GetExistingDimensionData() )
2240  return pDimData->GetNamedGroupDim( pDim->GetName() ) || pDimData->GetNumGroupDim( pDim->GetName() );
2241  return false;
2242 }
2243 
2244 DataPilotFieldGroupInfo ScDataPilotFieldObj::getGroupInfo()
2245 {
2246  SolarMutexGuard aGuard;
2247  DataPilotFieldGroupInfo aInfo;
2248  ScDPObject* pDPObj = nullptr;
2249  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2250  {
2251  if( const ScDPDimensionSaveData* pDimData = pDPObj->GetSaveData()->GetExistingDimensionData() )
2252  {
2253  if( const ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDim( pDim->GetName() ) )
2254  {
2255  // grouped by ...
2256  aInfo.GroupBy = pGroupDim->GetDatePart();
2257 
2258  // find source field
2259  try
2260  {
2261  Reference< XNameAccess > xFields( mxParent->getDataPilotFields(), UNO_QUERY_THROW );
2262  aInfo.SourceField.set( xFields->getByName( pGroupDim->GetSourceDimName() ), UNO_QUERY );
2263  }
2264  catch( Exception& )
2265  {
2266  }
2267 
2268  ScDataPilotConversion::FillGroupInfo( aInfo, pGroupDim->GetDateInfo() );
2269  if( pGroupDim->GetDatePart() == 0 )
2270  {
2271  // fill vector of group and group member information
2272  ScFieldGroups aGroups;
2273  for( sal_Int32 nIdx = 0, nCount = pGroupDim->GetGroupCount(); nIdx < nCount; ++nIdx )
2274  {
2275  const ScDPSaveGroupItem& rGroup = pGroupDim->GetGroupByIndex( nIdx );
2276  ScFieldGroup aGroup;
2277  aGroup.maName = rGroup.GetGroupName();
2278  for( sal_Int32 nMemIdx = 0, nMemCount = rGroup.GetElementCount(); nMemIdx < nMemCount; ++nMemIdx )
2279  if (const OUString* pMem = rGroup.GetElementByIndex(nMemIdx))
2280  aGroup.maMembers.push_back( *pMem );
2281  aGroups.push_back( aGroup );
2282  }
2283  aInfo.Groups = new ScDataPilotFieldGroupsObj( std::move(aGroups) );
2284  }
2285  }
2286  else if( const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( pDim->GetName() ) )
2287  {
2288  if (pNumGroupDim->GetDatePart())
2289  {
2290  ScDataPilotConversion::FillGroupInfo( aInfo, pNumGroupDim->GetDateInfo() );
2291  aInfo.GroupBy = pNumGroupDim->GetDatePart();
2292  }
2293  else
2294  {
2295  ScDataPilotConversion::FillGroupInfo( aInfo, pNumGroupDim->GetInfo() );
2296  }
2297  }
2298  }
2299  }
2300  return aInfo;
2301 }
2302 
2303 void ScDataPilotFieldObj::setGroupInfo( const DataPilotFieldGroupInfo* pInfo )
2304 {
2305  SolarMutexGuard aGuard;
2306  ScDPObject* pDPObj = nullptr;
2307  if( /*ScDPSaveDimension* pDim =*/ !GetDPDimension( &pDPObj ) )
2308  return;
2309 
2310  ScDPSaveData* pSaveData = pDPObj->GetSaveData();
2311  if( pInfo && lclCheckMinMaxStep( *pInfo ) )
2312  {
2313  ScDPNumGroupInfo aInfo;
2314  aInfo.mbEnable = true;
2315  aInfo.mbDateValues = pInfo->HasDateValues;
2316  aInfo.mbAutoStart = pInfo->HasAutoStart;
2317  aInfo.mbAutoEnd = pInfo->HasAutoEnd;
2318  aInfo.mfStart = pInfo->Start;
2319  aInfo.mfEnd = pInfo->End;
2320  aInfo.mfStep = pInfo->Step;
2321  Reference< XNamed > xNamed( pInfo->SourceField, UNO_QUERY );
2322  if( xNamed.is() )
2323  {
2324  ScDPSaveGroupDimension aGroupDim( xNamed->getName(), getName() );
2325  if( pInfo->GroupBy )
2326  aGroupDim.SetDateInfo(aInfo, pInfo->GroupBy);
2327  else
2328  {
2329  Reference<XIndexAccess> xIndex(pInfo->Groups, UNO_QUERY);
2330  if (xIndex.is())
2331  {
2332  sal_Int32 nCount(xIndex->getCount());
2333  for(sal_Int32 i = 0; i < nCount; i++)
2334  {
2335  Reference<XNamed> xGroupNamed(xIndex->getByIndex(i), UNO_QUERY);
2336  if (xGroupNamed.is())
2337  {
2338  ScDPSaveGroupItem aItem(xGroupNamed->getName());
2339  Reference<XIndexAccess> xGroupIndex(xGroupNamed, UNO_QUERY);
2340  if (xGroupIndex.is())
2341  {
2342  sal_Int32 nItemCount(xGroupIndex->getCount());
2343  for (sal_Int32 j = 0; j < nItemCount; ++j)
2344  {
2345  Reference<XNamed> xItemNamed(xGroupIndex->getByIndex(j), UNO_QUERY);
2346  if (xItemNamed.is())
2347  aItem.AddElement(xItemNamed->getName());
2348  }
2349  }
2350  aGroupDim.AddGroupItem(aItem);
2351  }
2352  }
2353  }
2354  }
2355 
2356  // get dimension savedata or create new if none
2357  ScDPDimensionSaveData& rDimSaveData = *pSaveData->GetDimensionData();
2358  rDimSaveData.ReplaceGroupDimension( aGroupDim );
2359  }
2360  else // no source field in group info -> numeric group
2361  {
2362  ScDPDimensionSaveData* pDimData = pSaveData->GetDimensionData(); // created if not there
2363 
2364  ScDPSaveNumGroupDimension* pExisting = pDimData->GetNumGroupDimAcc( getName() );
2365  if ( pExisting )
2366  {
2367  if (pInfo->GroupBy)
2368  pExisting->SetDateInfo(aInfo, pInfo->GroupBy);
2369  // modify existing group dimension
2370  pExisting->SetGroupInfo( aInfo );
2371  }
2372  else if (pInfo->GroupBy)
2373  {
2374  // create new group dimension
2375  ScDPSaveNumGroupDimension aNumGroupDim( getName(), aInfo, pInfo->GroupBy );
2376  pDimData->AddNumGroupDimension( aNumGroupDim );
2377  }
2378  else
2379  {
2380  // create new group dimension
2381  ScDPSaveNumGroupDimension aNumGroupDim( getName(), aInfo );
2382  pDimData->AddNumGroupDimension( aNumGroupDim );
2383  }
2384  }
2385  }
2386  else // null passed as argument
2387  {
2388  pSaveData->SetDimensionData( nullptr );
2389  }
2390 
2391  pDPObj->SetSaveData( *pSaveData );
2392  SetDPObject( pDPObj );
2393 }
2394 
2395 // XDataPilotFieldGrouping
2396 Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( const Sequence< OUString >& rItems )
2397 {
2398  SolarMutexGuard aGuard;
2399 
2400  if( !rItems.hasElements() )
2401  throw IllegalArgumentException("rItems is empty", static_cast<cppu::OWeakObject*>(this), 0);
2402 
2403  Reference< XMembersAccess > xMembers = GetMembers();
2404  if (!xMembers.is())
2405  {
2406  SAL_WARN("sc.ui", "Cannot access members of the field object.");
2407  throw RuntimeException("Cannot access members of the field object", static_cast<cppu::OWeakObject*>(this));
2408  }
2409 
2410  for (const OUString& aEntryName : rItems)
2411  {
2412  if (!xMembers->hasByName(aEntryName))
2413  {
2414  SAL_WARN("sc.ui", "There is no member with that name: " + aEntryName + ".");
2415  throw IllegalArgumentException("There is no member with name \"" + aEntryName + "\"", static_cast<cppu::OWeakObject*>(this), 0);
2416  }
2417  }
2418 
2419  Reference< XDataPilotField > xRet;
2420  OUString sNewDim;
2421  ScDPObject* pDPObj = nullptr;
2422  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2423  {
2424  const OUString& aDimName = pDim->GetName();
2425 
2426  ScDPSaveData aSaveData = *pDPObj->GetSaveData();
2427  ScDPDimensionSaveData* pDimData = aSaveData.GetDimensionData(); // created if not there
2428 
2429  // find original base
2430  OUString aBaseDimName( aDimName );
2431  const ScDPSaveGroupDimension* pBaseGroupDim = pDimData->GetNamedGroupDim( aDimName );
2432  if ( pBaseGroupDim )
2433  {
2434  // any entry's SourceDimName is the original base
2435  aBaseDimName = pBaseGroupDim->GetSourceDimName();
2436  }
2437 
2438  // find existing group dimension
2439  // (using the selected dim, can be intermediate group dim)
2440  ScDPSaveGroupDimension* pGroupDimension = pDimData->GetGroupDimAccForBase( aDimName );
2441 
2442  // remove the selected items from their groups
2443  // (empty groups are removed, too)
2444  if ( pGroupDimension )
2445  {
2446  for (const OUString& aEntryName : rItems)
2447  {
2448  if ( pBaseGroupDim )
2449  {
2450  // for each selected (intermediate) group, remove all its items
2451  // (same logic as for adding, below)
2452  const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
2453  if ( pBaseGroup )
2454  pBaseGroup->RemoveElementsFromGroups( *pGroupDimension ); // remove all elements
2455  else
2456  pGroupDimension->RemoveFromGroups( aEntryName );
2457  }
2458  else
2459  pGroupDimension->RemoveFromGroups( aEntryName );
2460  }
2461  }
2462 
2463  std::unique_ptr<ScDPSaveGroupDimension> pNewGroupDim;
2464  if ( !pGroupDimension )
2465  {
2466  // create a new group dimension
2467  sNewDim = pDimData->CreateGroupDimName( aBaseDimName, *pDPObj, false, nullptr );
2468  pNewGroupDim.reset(new ScDPSaveGroupDimension( aBaseDimName, sNewDim ));
2469 
2470  pGroupDimension = pNewGroupDim.get(); // make changes to the new dim if none existed
2471 
2472  if ( pBaseGroupDim )
2473  {
2474  // If it's a higher-order group dimension, pre-allocate groups for all
2475  // non-selected original groups, so the individual base members aren't
2476  // used for automatic groups (this would make the original groups hard
2477  // to find).
2480 
2481  tools::Long nGroupCount = pBaseGroupDim->GetGroupCount();
2482  for ( tools::Long nGroup = 0; nGroup < nGroupCount; nGroup++ )
2483  {
2484  const ScDPSaveGroupItem& rBaseGroup = pBaseGroupDim->GetGroupByIndex( nGroup );
2485 
2486  if (comphelper::findValue(rItems, rBaseGroup.GetGroupName()) == -1)
2487  {
2488  // add an additional group for each item that is not in the selection
2489  ScDPSaveGroupItem aGroup( rBaseGroup.GetGroupName() );
2490  aGroup.AddElementsFromGroup( rBaseGroup );
2491  pGroupDimension->AddGroupItem( aGroup );
2492  }
2493  }
2494  }
2495  }
2496  OUString aGroupDimName = pGroupDimension->GetGroupDimName();
2497 
2498  OUString aGroupName = pGroupDimension->CreateGroupName( ScResId(STR_PIVOT_GROUP) );
2499  ScDPSaveGroupItem aGroup( aGroupName );
2500  for (const OUString& aEntryName : rItems)
2501  {
2502  if ( pBaseGroupDim )
2503  {
2504  // for each selected (intermediate) group, add all its items
2505  const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
2506  if ( pBaseGroup )
2507  aGroup.AddElementsFromGroup( *pBaseGroup );
2508  else
2509  aGroup.AddElement( aEntryName ); // no group found -> automatic group, add the item itself
2510  }
2511  else
2512  aGroup.AddElement( aEntryName ); // no group dimension, add all items directly
2513  }
2514 
2515  pGroupDimension->AddGroupItem( aGroup );
2516 
2517  if ( pNewGroupDim )
2518  {
2519  pDimData->AddGroupDimension( *pNewGroupDim );
2520  pNewGroupDim.reset(); // AddGroupDimension copies the object
2521  // don't access pGroupDimension after here
2522  }
2523  pGroupDimension = nullptr;
2524 
2525  // set orientation
2526  ScDPSaveDimension* pSaveDimension = aSaveData.GetDimensionByName( aGroupDimName );
2527  if ( pSaveDimension->GetOrientation() == DataPilotFieldOrientation_HIDDEN )
2528  {
2529  ScDPSaveDimension* pOldDimension = aSaveData.GetDimensionByName( aDimName );
2530  pSaveDimension->SetOrientation( pOldDimension->GetOrientation() );
2531  aSaveData.SetPosition( pSaveDimension, 0 );
2532  }
2533 
2534  // apply changes
2535  pDPObj->SetSaveData( aSaveData );
2537  }
2538 
2539  // if new grouping field has been created (on first group), return it
2540  if( !sNewDim.isEmpty() )
2541  {
2542  Reference< XNameAccess > xFields(mxParent->getDataPilotFields(), UNO_QUERY);
2543  if (xFields.is())
2544  {
2545  try
2546  {
2547  xRet.set(xFields->getByName(sNewDim), UNO_QUERY);
2548  SAL_WARN_IF(!xRet.is(), "sc.ui", "there is a name, so there should be also a field");
2549  }
2550  catch (const container::NoSuchElementException&)
2551  {
2552  css::uno::Any anyEx = cppu::getCaughtException();
2553  SAL_WARN("sc.ui", "Cannot find field with that name: " + sNewDim + ".");
2554  // Avoid throwing exception that's not specified in the method signature.
2555  throw css::lang::WrappedTargetRuntimeException(
2556  "Cannot find field with name \"" + sNewDim + "\"",
2557  static_cast<cppu::OWeakObject*>(this), anyEx );
2558  }
2559  }
2560  }
2561  return xRet;
2562 }
2563 
2564 Reference < XDataPilotField > SAL_CALL ScDataPilotFieldObj::createDateGroup( const DataPilotFieldGroupInfo& rInfo )
2565 {
2566  SolarMutexGuard aGuard;
2567  using namespace ::com::sun::star::sheet::DataPilotFieldGroupBy;
2568 
2569  if( !rInfo.HasDateValues )
2570  throw IllegalArgumentException("HasDateValues is not set", static_cast<cppu::OWeakObject*>(this), 0);
2571  if( !lclCheckMinMaxStep( rInfo ) )
2572  throw IllegalArgumentException("min/max/step", static_cast<cppu::OWeakObject*>(this), 0);
2573 
2574  // only a single date flag is allowed
2575  if( (rInfo.GroupBy == 0) || (rInfo.GroupBy > YEARS) || ((rInfo.GroupBy & (rInfo.GroupBy - 1)) != 0) )
2576  throw IllegalArgumentException("Invalid GroupBy value: " + OUString::number(rInfo.GroupBy), static_cast<cppu::OWeakObject*>(this), 0);
2577 
2578  // step must be zero, if something else than DAYS is specified
2579  if( rInfo.Step >= ((rInfo.GroupBy == DAYS) ? 32768.0 : 1.0) )
2580  throw IllegalArgumentException("Invalid step value: " + OUString::number(rInfo.Step), static_cast<cppu::OWeakObject*>(this), 0);
2581 
2582  OUString aGroupDimName;
2583  ScDPObject* pDPObj = nullptr;
2584  if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
2585  {
2586  ScDPNumGroupInfo aInfo;
2587  aInfo.mbEnable = true;
2588  aInfo.mbDateValues = (rInfo.GroupBy == DAYS) && (rInfo.Step >= 1.0);
2589  aInfo.mbAutoStart = rInfo.HasAutoStart;
2590  aInfo.mbAutoEnd = rInfo.HasAutoEnd;
2591  aInfo.mfStart = rInfo.Start;
2592  aInfo.mfEnd = rInfo.End;
2593  aInfo.mfStep = std::trunc( rInfo.Step );
2594 
2595  // create a local copy of the entire save data (will be written back below)
2596  ScDPSaveData aSaveData = *pDPObj->GetSaveData();
2597  // get or create dimension save data
2598  ScDPDimensionSaveData& rDimData = *aSaveData.GetDimensionData();
2599 
2600  // find source dimension name
2601  const OUString& rDimName = pDim->GetName();
2602  const ScDPSaveGroupDimension* pGroupDim = rDimData.GetNamedGroupDim( rDimName );
2603  OUString aSrcDimName = pGroupDim ? pGroupDim->GetSourceDimName() : rDimName;
2604 
2605  // find a group dimension for the base field, or get numeric grouping
2606  pGroupDim = rDimData.GetFirstNamedGroupDim( aSrcDimName );
2607  const ScDPSaveNumGroupDimension* pNumGroupDim = rDimData.GetNumGroupDim( aSrcDimName );
2608 
2609  // do not group by dates, if named groups or numeric grouping is present
2610  bool bHasNamedGrouping = pGroupDim && !pGroupDim->GetDateInfo().mbEnable;
2611  bool bHasNumGrouping = pNumGroupDim && pNumGroupDim->GetInfo().mbEnable && !pNumGroupDim->GetInfo().mbDateValues && !pNumGroupDim->GetDateInfo().mbEnable;
2612  if( bHasNamedGrouping || bHasNumGrouping )
2613  throw IllegalArgumentException();
2614 
2615  if( aInfo.mbDateValues ) // create day ranges grouping
2616  {
2617  // first remove all named group dimensions
2618  while( pGroupDim )
2619  {
2620  OUString aGroupDimName2 = pGroupDim->GetGroupDimName();
2621  // find next group dimension before deleting this group
2622  pGroupDim = rDimData.GetNextNamedGroupDim( aGroupDimName2 );
2623  // remove from dimension save data
2624  rDimData.RemoveGroupDimension( aGroupDimName2 );
2625  // also remove save data settings for the dimension that no longer exists
2626  aSaveData.RemoveDimensionByName( aGroupDimName2 );
2627  }
2628  // create or replace the number grouping dimension
2629  ScDPSaveNumGroupDimension aNumGroupDim( aSrcDimName, aInfo );
2630  rDimData.ReplaceNumGroupDimension( aNumGroupDim );
2631  }
2632  else // create date grouping
2633  {
2634  // collect all existing date flags
2635  sal_Int32 nDateParts = rDimData.CollectDateParts( aSrcDimName );
2636  if( nDateParts == 0 )
2637  {
2638  // insert numeric group dimension, if no date groups exist yet (or replace day range grouping)
2639  ScDPSaveNumGroupDimension aNumGroupDim( aSrcDimName, aInfo, rInfo.GroupBy );
2640  rDimData.ReplaceNumGroupDimension( aNumGroupDim );
2641  }
2642  else if( (nDateParts & rInfo.GroupBy) == 0 ) // do nothing if date field exists already
2643  {
2644  // create new named group dimension for additional date groups
2645  aGroupDimName = rDimData.CreateDateGroupDimName( rInfo.GroupBy, *pDPObj, true, nullptr );
2646  ScDPSaveGroupDimension aGroupDim( aSrcDimName, aGroupDimName, aInfo, rInfo.GroupBy );
2647  rDimData.AddGroupDimension( aGroupDim );
2648 
2649  // set orientation of new named group dimension
2650  ScDPSaveDimension& rSaveDim = *aSaveData.GetDimensionByName( aGroupDimName );
2651  if( rSaveDim.GetOrientation() == DataPilotFieldOrientation_HIDDEN )
2652  {
2653  ScDPSaveDimension& rOldDim = *aSaveData.GetDimensionByName( aSrcDimName );
2654  rSaveDim.SetOrientation( rOldDim.GetOrientation() );
2655  aSaveData.SetPosition( &rSaveDim, 0 );
2656  }
2657  }
2658  }
2659 
2660  // apply changes
2661  pDPObj->SetSaveData( aSaveData );
2663  }
2664 
2665  // return the UNO object of the new dimension, after writing back saved data
2666  Reference< XDataPilotField > xRet;
2667  if( !aGroupDimName.isEmpty() )
2668  try
2669  {
2670  Reference< XNameAccess > xFields( mxParent->getDataPilotFields(), UNO_QUERY_THROW );
2671  xRet.set( xFields->getByName( aGroupDimName ), UNO_QUERY );
2672  }
2673  catch( Exception& )
2674  {
2675  }
2676  return xRet;
2677 }
2678 
2679 namespace {
2680 
2681 bool lclExtractGroupMembers( ScFieldGroupMembers& rMembers, const Any& rElement )
2682 {
2683  // allow empty value to create a new group
2684  if( !rElement.hasValue() )
2685  return true;
2686 
2687  // try to extract a simple sequence of strings
2689  if( rElement >>= aSeq )
2690  {
2691  if( aSeq.hasElements() )
2692  rMembers.insert( rMembers.end(), std::cbegin(aSeq), std::cend(aSeq) );
2693  return true;
2694  }
2695 
2696  // try to use XIndexAccess providing objects that support XNamed
2697  Reference< XIndexAccess > xItemsIA( rElement, UNO_QUERY );
2698  if( xItemsIA.is() )
2699  {
2700  for( sal_Int32 nIdx = 0, nCount = xItemsIA->getCount(); nIdx < nCount; ++nIdx )
2701  {
2702  try // getByIndex() should not throw, but we cannot be sure
2703  {
2704  Reference< XNamed > xItemName( xItemsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
2705  rMembers.push_back( xItemName->getName() );
2706  }
2707  catch( Exception& )
2708  {
2709  // ignore exceptions, go ahead with next element in the array
2710  }
2711  }
2712  return true;
2713  }
2714 
2715  // nothing valid inside the Any -> return false
2716  return false;
2717 }
2718 
2719 } // namespace
2720 
2722  maGroups( std::move(rGroups) )
2723 {
2724 }
2725 
2727 {
2728 }
2729 
2730 // XNameAccess
2731 
2732 Any SAL_CALL ScDataPilotFieldGroupsObj::getByName( const OUString& rName )
2733 {
2734  SolarMutexGuard aGuard;
2735  if( implFindByName( rName ) == maGroups.end() )
2736  throw NoSuchElementException();
2737  return Any( Reference< XNameAccess >( new ScDataPilotFieldGroupObj( *this, rName ) ) );
2738 }
2739 
2741 {
2742  SolarMutexGuard aGuard;
2743  Sequence< OUString > aSeq;
2744  if( !maGroups.empty() )
2745  {
2746  aSeq.realloc( static_cast< sal_Int32 >( maGroups.size() ) );
2747  OUString* pName = aSeq.getArray();
2748  for( const auto& rGroup : maGroups )
2749  {
2750  *pName = rGroup.maName;
2751  ++pName;
2752  }
2753  }
2754  return aSeq;
2755 }
2756 
2757 sal_Bool SAL_CALL ScDataPilotFieldGroupsObj::hasByName( const OUString& rName )
2758 {
2759  SolarMutexGuard aGuard;
2760  return implFindByName( rName ) != maGroups.end();
2761 }
2762 
2763 // XNameReplace
2764 
2765 void SAL_CALL ScDataPilotFieldGroupsObj::replaceByName( const OUString& rName, const Any& rElement )
2766 {
2767  SolarMutexGuard aGuard;
2768 
2769  if( rName.isEmpty() )
2770  throw IllegalArgumentException("Name is empty", static_cast<cppu::OWeakObject*>(this), 0);
2771 
2772  ScFieldGroups::iterator aIt = implFindByName( rName );
2773  if( aIt == maGroups.end() )
2774  throw NoSuchElementException("Name \"" + rName + "\" not found", static_cast<cppu::OWeakObject*>(this));
2775 
2776  // read all item names provided by the passed object
2777  ScFieldGroupMembers aMembers;
2778  if( !lclExtractGroupMembers( aMembers, rElement ) )
2779  throw IllegalArgumentException("Invalid element object", static_cast<cppu::OWeakObject*>(this), 0);
2780 
2781  // copy and forget, faster than vector assignment
2782  aIt->maMembers.swap( aMembers );
2783 }
2784 
2785 // XNameContainer
2786 
2787 void SAL_CALL ScDataPilotFieldGroupsObj::insertByName( const OUString& rName, const Any& rElement )
2788 {
2789  SolarMutexGuard aGuard;
2790 
2791  if( rName.isEmpty() )
2792  throw IllegalArgumentException("Name is empty", static_cast<cppu::OWeakObject*>(this), 0);
2793 
2794  ScFieldGroups::iterator aIt = implFindByName( rName );
2795  if( aIt != maGroups.end() )
2796  throw ElementExistException("Name \"" + rName + "\" already exists", static_cast<cppu::OWeakObject*>(this));
2797 
2798  // read all item names provided by the passed object
2799  ScFieldGroupMembers aMembers;
2800  if( !lclExtractGroupMembers( aMembers, rElement ) )
2801  throw IllegalArgumentException("Invalid element object", static_cast<cppu::OWeakObject*>(this), 0);
2802 
2803  // create the new entry if no error has been occurred
2804  maGroups.emplace_back();
2805  ScFieldGroup& rGroup = maGroups.back();
2806  rGroup.maName = rName;
2807  rGroup.maMembers.swap( aMembers );
2808 }
2809 
2810 void SAL_CALL ScDataPilotFieldGroupsObj::removeByName( const OUString& rName )
2811 {
2812  SolarMutexGuard aGuard;
2813 
2814  if( rName.isEmpty() )
2815  throw IllegalArgumentException("Name is empty", static_cast<cppu::OWeakObject*>(this), 0);
2816 
2817  ScFieldGroups::iterator aIt = implFindByName( rName );
2818  if( aIt == maGroups.end() )
2819  throw NoSuchElementException("Name \"" + rName + "\" not found", static_cast<cppu::OWeakObject*>(this));
2820 
2821  maGroups.erase( aIt );
2822 }
2823 
2824 // XIndexAccess
2825 
2827 {
2828  SolarMutexGuard aGuard;
2829  return static_cast< sal_Int32 >( maGroups.size() );
2830 }
2831 
2832 Any SAL_CALL ScDataPilotFieldGroupsObj::getByIndex( sal_Int32 nIndex )
2833 {
2834  SolarMutexGuard aGuard;
2835  if ((nIndex < 0) || (nIndex >= static_cast< sal_Int32 >( maGroups.size() )))
2836  throw IndexOutOfBoundsException();
2837  return Any( Reference< XNameAccess >( new ScDataPilotFieldGroupObj( *this, maGroups[ nIndex ].maName ) ) );
2838 }
2839 
2840 // XEnumerationAccess
2841 
2842 Reference<XEnumeration> SAL_CALL ScDataPilotFieldGroupsObj::createEnumeration()
2843 {
2844  SolarMutexGuard aGuard;
2845  return new ScIndexEnumeration( this, "com.sun.star.sheet.DataPilotFieldGroupsEnumeration" );
2846 }
2847 
2848 // XElementAccess
2849 
2851 {
2853 }
2854 
2856 {
2857  SolarMutexGuard aGuard;
2858  return !maGroups.empty();
2859 }
2860 
2861 // implementation
2862 
2864 {
2865  SolarMutexGuard aGuard;
2866  ScFieldGroups::iterator aIt = implFindByName( rName );
2867  if( aIt == maGroups.end() )
2868  throw RuntimeException("Field Group with name \"" + rName + "\" not found", static_cast<cppu::OWeakObject*>(this));
2869  return *aIt;
2870 }
2871 
2872 void ScDataPilotFieldGroupsObj::renameFieldGroup( const OUString& rOldName, const OUString& rNewName )
2873 {
2874  SolarMutexGuard aGuard;
2875  ScFieldGroups::iterator aOldIt = implFindByName( rOldName );
2876  ScFieldGroups::iterator aNewIt = implFindByName( rNewName );
2877  if( aOldIt == maGroups.end() )
2878  throw RuntimeException("Field Group with name \"" + rOldName + "\" not found", static_cast<cppu::OWeakObject*>(this));
2879  // new name must not exist yet
2880  if( (aNewIt != maGroups.end()) && (aNewIt != aOldIt) )
2881  throw RuntimeException("Field Group with name \"" + rOldName + "\" already exists", static_cast<cppu::OWeakObject*>(this));
2882  aOldIt->maName = rNewName;
2883 }
2884 
2885 ScFieldGroups::iterator ScDataPilotFieldGroupsObj::implFindByName( const OUString& rName )
2886 {
2887  return std::find_if(maGroups.begin(), maGroups.end(),
2888  [&rName](const ScFieldGroup& rGroup) { return rGroup.maName == rName; });
2889 }
2890 
2891 namespace {
2892 
2893 OUString lclExtractMember( const Any& rElement )
2894 {
2895  if( rElement.has< OUString >() )
2896  return rElement.get< OUString >();
2897 
2898  Reference< XNamed > xNamed( rElement, UNO_QUERY );
2899  if( xNamed.is() )
2900  return xNamed->getName();
2901 
2902  return OUString();
2903 }
2904 
2905 } // namespace
2906 
2908  mxParent( &rParent ),
2909  maGroupName( rGroupName )
2910 {
2911 }
2912 
2914 {
2915 }
2916 
2917 // XNameAccess
2918 
2919 Any SAL_CALL ScDataPilotFieldGroupObj::getByName( const OUString& rName )
2920 {
2921  SolarMutexGuard aGuard;
2922  ScFieldGroupMembers& rMembers = mxParent->getFieldGroup( maGroupName ).maMembers;
2923  ScFieldGroupMembers::iterator aIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
2924  if( aIt == rMembers.end() )
2925  throw NoSuchElementException("Name \"" + rName + "\" not found", static_cast<cppu::OWeakObject*>(this));
2926  return Any( Reference< XNamed >( new ScDataPilotFieldGroupItemObj( *this, *aIt ) ) );
2927 }
2928 
2930 {
2931  SolarMutexGuard aGuard;
2932  return ::comphelper::containerToSequence( mxParent->getFieldGroup( maGroupName ).maMembers );
2933 }
2934 
2935 sal_Bool SAL_CALL ScDataPilotFieldGroupObj::hasByName( const OUString& rName )
2936 {
2937  SolarMutexGuard aGuard;
2938  ScFieldGroupMembers& rMembers = mxParent->getFieldGroup( maGroupName ).maMembers;
2939  return ::std::find( rMembers.begin(), rMembers.end(), rName ) != rMembers.end();
2940 }
2941 
2942 // XNameReplace
2943 
2944 void SAL_CALL ScDataPilotFieldGroupObj::replaceByName( const OUString& rName, const Any& rElement )
2945 {
2946  SolarMutexGuard aGuard;
2947 
2948  // it should be possible to quickly rename an item -> accept string or XNamed
2949  OUString aNewName = lclExtractMember( rElement );
2950  if( rName.isEmpty() || aNewName.isEmpty() )
2951  throw IllegalArgumentException("Name is empty", static_cast<cppu::OWeakObject*>(this), 0);
2952  if( rName == aNewName )
2953  return;
2954 
2955  ScFieldGroupMembers& rMembers = mxParent->getFieldGroup( maGroupName ).maMembers;
2956  ScFieldGroupMembers::iterator aOldIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
2957  ScFieldGroupMembers::iterator aNewIt = ::std::find( rMembers.begin(), rMembers.end(), aNewName );
2958  if( aOldIt == rMembers.end() )
2959  throw NoSuchElementException("Name \"" + rName + "\" not found", static_cast<cppu::OWeakObject*>(this));
2960  if( aNewIt != rMembers.end() )
2961  throw IllegalArgumentException("Name \"" + rName + "\" already exists", static_cast<cppu::OWeakObject*>(this), 0);
2962  *aOldIt = aNewName;
2963 }
2964 
2965 // XNameContainer
2966 
2967 void SAL_CALL ScDataPilotFieldGroupObj::insertByName( const OUString& rName, const Any& /*rElement*/ )
2968 {
2969  SolarMutexGuard aGuard;
2970 
2971  // we will ignore the passed element and just try to insert the name
2972  if( rName.isEmpty() )
2973  throw IllegalArgumentException("Name is empty", static_cast<cppu::OWeakObject*>(this), 0);
2974 
2975  ScFieldGroupMembers& rMembers = mxParent->getFieldGroup( maGroupName ).maMembers;
2976  ScFieldGroupMembers::iterator aIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
2977  if( aIt != rMembers.end() )
2978  throw IllegalArgumentException("Name \"" + rName + "\" already exists", static_cast<cppu::OWeakObject*>(this), 0);
2979  rMembers.push_back( rName );
2980 }
2981 
2982 void SAL_CALL ScDataPilotFieldGroupObj::removeByName( const OUString& rName )
2983 {
2984  SolarMutexGuard aGuard;
2985 
2986  if( rName.isEmpty() )
2987  throw IllegalArgumentException("Name is empty", static_cast<cppu::OWeakObject*>(this), 0);
2988  ScFieldGroupMembers& rMembers = mxParent->getFieldGroup( maGroupName ).maMembers;
2989  ScFieldGroupMembers::iterator aIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
2990  if( aIt == rMembers.end() )
2991  throw NoSuchElementException("Name \"" + rName + "\" not found", static_cast<cppu::OWeakObject*>(this));
2992  rMembers.erase( aIt );
2993 }
2994 
2995 // XIndexAccess
2996 
2998 {
2999  SolarMutexGuard aGuard;
3000  return static_cast< sal_Int32 >( mxParent->getFieldGroup( maGroupName ).maMembers.size() );
3001 }
3002 
3003 Any SAL_CALL ScDataPilotFieldGroupObj::getByIndex( sal_Int32 nIndex )
3004 {
3005  SolarMutexGuard aGuard;
3006  ScFieldGroupMembers& rMembers = mxParent->getFieldGroup( maGroupName ).maMembers;
3007  if ((nIndex < 0) || (nIndex >= static_cast< sal_Int32 >( rMembers.size() )))
3008  throw IndexOutOfBoundsException();
3009  return Any( Reference< XNamed >( new ScDataPilotFieldGroupItemObj( *this, rMembers[ nIndex ] ) ) );
3010 }
3011 
3012 // XEnumerationAccess
3013 
3014 Reference< XEnumeration > SAL_CALL ScDataPilotFieldGroupObj::createEnumeration()
3015 {
3016  SolarMutexGuard aGuard;
3017  return new ScIndexEnumeration( this, "com.sun.star.sheet.DataPilotFieldGroupEnumeration" );
3018 }
3019 
3020 // XElementAccess
3021 
3023 {
3024  return cppu::UnoType<XNamed>::get();
3025 }
3026 
3028 {
3029  SolarMutexGuard aGuard;
3030  return !mxParent->getFieldGroup( maGroupName ).maMembers.empty();
3031 }
3032 
3033 // XNamed
3034 
3036 {
3037  SolarMutexGuard aGuard;
3038  return maGroupName;
3039 }
3040 
3041 void SAL_CALL ScDataPilotFieldGroupObj::setName( const OUString& rName )
3042 {
3043  SolarMutexGuard aGuard;
3044  mxParent->renameFieldGroup( maGroupName, rName );
3045  // if call to renameFieldGroup() did not throw, remember the new name
3046  maGroupName = rName;
3047 }
3048 
3050  mxParent( &rParent ),
3051  maName( rName )
3052 {
3053 }
3054 
3056 {
3057 }
3058 
3059 // XNamed
3060 
3062 {
3063  SolarMutexGuard aGuard;
3064  return maName;
3065 }
3066 
3067 void SAL_CALL ScDataPilotFieldGroupItemObj::setName( const OUString& rName )
3068 {
3069  SolarMutexGuard aGuard;
3070  mxParent->replaceByName( maName, Any( rName ) );
3071  // if call to replaceByName() did not throw, remember the new name
3072  maName = rName;
3073 }
3074 
3076  ScDataPilotChildObjBase( rParent, rFieldId )
3077 {
3078 }
3079 
3081 {
3082 }
3083 
3084 // XDataPilotItems
3085 
3087 {
3088  return ((0 <= nIndex) && (nIndex < GetMemberCount())) ?
3089  new ScDataPilotItemObj( *mxParent, maFieldId, nIndex ) : nullptr;
3090 }
3091 
3092 // XNameAccess
3093 
3094 Any SAL_CALL ScDataPilotItemsObj::getByName( const OUString& aName )
3095 {
3096  SolarMutexGuard aGuard;
3097  Reference<XNameAccess> xMembers = GetMembers();
3098  if (xMembers.is())
3099  {
3100  Reference<XIndexAccess> xMembersIndex(new ScNameToIndexAccess( xMembers ));
3101  sal_Int32 nCount = xMembersIndex->getCount();
3102  sal_Int32 nItem = 0;
3103  while (nItem < nCount)
3104  {
3105  Reference<XNamed> xMember(xMembersIndex->getByIndex(nItem), UNO_QUERY);
3106  if (xMember.is() && (aName == xMember->getName()))
3107  {
3108  return Any( Reference< XPropertySet >( GetObjectByIndex_Impl( nItem ) ) );
3109  }
3110  ++nItem;
3111  }
3112  throw NoSuchElementException("Name \"" + aName + "\" not found", static_cast<cppu::OWeakObject*>(this));
3113  }
3114  return Any();
3115 }
3116 
3118 {
3119  SolarMutexGuard aGuard;
3120  Sequence< OUString > aSeq;
3121  if( ScDPObject* pDPObj = GetDPObject() )
3122  pDPObj->GetMemberNames( lcl_GetObjectIndex( pDPObj, maFieldId ), aSeq );
3123  return aSeq;
3124 }
3125 
3126 sal_Bool SAL_CALL ScDataPilotItemsObj::hasByName( const OUString& aName )
3127 {
3128  SolarMutexGuard aGuard;
3129  bool bFound = false;
3130  Reference<XNameAccess> xMembers = GetMembers();
3131  if (xMembers.is())
3132  {
3133  Reference<XIndexAccess> xMembersIndex(new ScNameToIndexAccess( xMembers ));
3134  sal_Int32 nCount = xMembersIndex->getCount();
3135  sal_Int32 nItem = 0;
3136  while (nItem < nCount && !bFound )
3137  {
3138  Reference<XNamed> xMember(xMembersIndex->getByIndex(nItem), UNO_QUERY);
3139  if (xMember.is() && aName == xMember->getName())
3140  bFound = true;
3141  else
3142  nItem++;
3143  }
3144  }
3145  return bFound;
3146 }
3147 
3148 // XEnumerationAccess
3149 
3150 Reference<XEnumeration> SAL_CALL ScDataPilotItemsObj::createEnumeration()
3151 {
3152  SolarMutexGuard aGuard;
3153  return new ScIndexEnumeration(this, "com.sun.star.sheet.DataPilotItemsEnumeration");
3154 }
3155 
3156 // XIndexAccess
3157 
3158 sal_Int32 SAL_CALL ScDataPilotItemsObj::getCount()
3159 {
3160  SolarMutexGuard aGuard;
3161  return GetMemberCount();
3162 }
3163 
3164 Any SAL_CALL ScDataPilotItemsObj::getByIndex( sal_Int32 nIndex )
3165 {
3166  SolarMutexGuard aGuard;
3168  if (!xItem.is())
3169  throw IndexOutOfBoundsException();
3170  return Any( xItem );
3171 }
3172 
3174 {
3176 }
3177 
3179 {
3180  SolarMutexGuard aGuard;
3181  return ( getCount() != 0 );
3182 }
3183 
3185  ScDataPilotChildObjBase( rParent, rFieldId ),
3186  maPropSet( lcl_GetDataPilotItemMap() ),
3187  mnIndex( nIndex )
3188 {
3189 }
3190 
3192 {
3193 }
3194 
3195  // XNamed
3196 OUString SAL_CALL ScDataPilotItemObj::getName()
3197 {
3198  SolarMutexGuard aGuard;
3199  OUString sRet;
3200  Reference<XNameAccess> xMembers = GetMembers();
3201  if (xMembers.is())
3202  {
3203  Reference<XIndexAccess> xMembersIndex(new ScNameToIndexAccess( xMembers ));
3204  sal_Int32 nCount = xMembersIndex->getCount();
3205  if (mnIndex < nCount)
3206  {
3207  Reference<XNamed> xMember(xMembersIndex->getByIndex(mnIndex), UNO_QUERY);
3208  sRet = xMember->getName();
3209  }
3210  }
3211  return sRet;
3212 }
3213 
3214 void SAL_CALL ScDataPilotItemObj::setName( const OUString& /* aName */ )
3215 {
3216 }
3217 
3218  // XPropertySet
3219 Reference< XPropertySetInfo >
3221 {
3222  SolarMutexGuard aGuard;
3223  static Reference<XPropertySetInfo> aRef =
3225  return aRef;
3226 }
3227 
3228 void SAL_CALL ScDataPilotItemObj::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
3229 {
3230  SolarMutexGuard aGuard;
3231  ScDPObject* pDPObj = nullptr;
3232  ScDPSaveDimension* pDim = GetDPDimension( &pDPObj );
3233  if(!pDim)
3234  return;
3235 
3236  Reference<XNameAccess> xMembers = GetMembers();
3237  if( !xMembers.is() )
3238  return;
3239 
3240  Reference<XIndexAccess> xMembersIndex( new ScNameToIndexAccess( xMembers ) );
3241  sal_Int32 nCount = xMembersIndex->getCount();
3242  if( mnIndex >= nCount )
3243  return;
3244 
3245  Reference<XNamed> xMember(xMembersIndex->getByIndex(mnIndex), UNO_QUERY);
3246  OUString sName(xMember->getName());
3247  ScDPSaveMember* pMember = pDim->GetMemberByName(sName);
3248  if (!pMember)
3249  return;
3250 
3251  bool bGetNewIndex = false;
3252  if ( aPropertyName == SC_UNONAME_SHOWDETAIL )
3253  pMember->SetShowDetails(cppu::any2bool(aValue));
3254  else if ( aPropertyName == SC_UNONAME_ISHIDDEN )
3255  pMember->SetIsVisible(!cppu::any2bool(aValue));
3256  else if ( aPropertyName == SC_UNONAME_POS )
3257  {
3258  sal_Int32 nNewPos = 0;
3259  if ( !( aValue >>= nNewPos ) || nNewPos < 0 || nNewPos >= nCount )
3260  throw IllegalArgumentException();
3261 
3262  pDim->SetMemberPosition( sName, nNewPos );
3263  // get new effective index (depends on sorting mode, which isn't modified)
3264  bGetNewIndex = true;
3265 
3266  }
3267  SetDPObject( pDPObj );
3268 
3269  if ( bGetNewIndex ) // after SetDPObject, get the new index
3270  {
3271  Sequence< OUString > aItemNames = xMembers->getElementNames();
3272  sal_Int32 nItemCount = aItemNames.getLength();
3273  for (sal_Int32 nItem=0; nItem<nItemCount; ++nItem)
3274  if (aItemNames[nItem] == sName)
3275  mnIndex = nItem;
3276  }
3277 }
3278 
3279 Any SAL_CALL ScDataPilotItemObj::getPropertyValue( const OUString& aPropertyName )
3280 {
3281  SolarMutexGuard aGuard;
3282  Any aRet;
3283  if( ScDPSaveDimension* pDim = GetDPDimension() )
3284  {
3285  Reference< XNameAccess > xMembers = GetMembers();
3286  if( xMembers.is() )
3287  {
3288  Reference< XIndexAccess > xMembersIndex( new ScNameToIndexAccess( xMembers ) );
3289  sal_Int32 nCount = xMembersIndex->getCount();
3290  if( mnIndex < nCount )
3291  {
3292  Reference< XNamed > xMember( xMembersIndex->getByIndex( mnIndex ), UNO_QUERY );
3293  OUString sName( xMember->getName() );
3294  ScDPSaveMember* pMember = pDim->GetExistingMemberByName( sName );
3295  if ( aPropertyName == SC_UNONAME_SHOWDETAIL )
3296  {
3297  if (pMember && pMember->HasShowDetails())
3298  {
3299  aRet <<= pMember->GetShowDetails();
3300  }
3301  else
3302  {
3303  Reference< XPropertySet > xMemberProps( xMember, UNO_QUERY );
3304  if( xMemberProps.is() )
3305  aRet = xMemberProps->getPropertyValue( SC_UNO_DP_SHOWDETAILS );
3306  else
3307  aRet <<= true;
3308  }
3309  }
3310  else if ( aPropertyName == SC_UNONAME_ISHIDDEN )
3311  {
3312  if (pMember && pMember->HasIsVisible())
3313  {
3314  aRet <<= !pMember->GetIsVisible();
3315  }
3316  else
3317  {
3318  Reference< XPropertySet > xMemberProps( xMember, UNO_QUERY );
3319  if( xMemberProps.is() )
3320  aRet <<= !cppu::any2bool( xMemberProps->getPropertyValue( SC_UNO_DP_ISVISIBLE ) );
3321  else
3322  aRet <<= false;
3323  }
3324  }
3325  else if ( aPropertyName == SC_UNONAME_POS )
3326  {
3327  aRet <<= mnIndex;
3328  }
3329  }
3330  }
3331  }
3332  return aRet;
3333 }
3334 
3336  const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
3337 {
3338 }
3339 
3341  const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
3342 {
3343 }
3344 
3346  const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
3347 {
3348 }
3349 
3351  const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
3352 {
3353 }
3354 
3355 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static OUString lcl_CreatePivotName(ScDocShell *pDocShell)
Definition: dapiuno.cxx:269
constexpr OUStringLiteral SC_DATALAYOUT_NAME
Definition: dapiuno.cxx:192
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dapiuno.cxx:513
virtual void SAL_CALL insertDrillDownSheet(const css::table::CellAddress &aAddr) override
Definition: dapiuno.cxx:1161
ScDocShell * pDocShell
Definition: dapiuno.hxx:86
SC_DLLPUBLIC void SetRepeatIfEmpty(bool bSet)
Definition: dpsave.cxx:999
#define SC_UNONAME_LAYOUTINFO
Definition: unonames.hxx:268
const ScDPDimensionSaveData * GetExistingDimensionData() const
Definition: dpsave.hxx:348
const OUString & GetGroupDimName() const
Definition: dpdimsave.hxx:107
css::uno::Any maOrient
Definition: dapiuno.hxx:472
virtual sal_Bool SAL_CALL hasElements() override
Definition: dapiuno.cxx:1585
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: dapiuno.cxx:2982
bool UpdateReference(UpdateRefMode, const ScDocument *, const ScRange &rWhere, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: rangelst.cxx:357
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getDataPilotFields() override
Definition: dapiuno.cxx:647
function is determined automatically.
bool IsDimNameInUse(std::u16string_view rName) const
Definition: dpobject.cxx:1173
bool GetRowGrand() const
Definition: dpsave.hxx:326
virtual css::table::CellRangeAddress SAL_CALL getOutputRangeByType(sal_Int32 nType) override
Definition: dapiuno.cxx:1177
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: dapiuno.cxx:1820
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: dapiuno.cxx:3150
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: dapiuno.cxx:3335
void ReplaceNumGroupDimension(const ScDPSaveNumGroupDimension &rGroupDim)
Definition: dpdimsave.cxx:596
ScAddress aStart
Definition: address.hxx:497
static sal_Int32 GetEnumFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:160
void ShowDataPilotSourceData(ScDPObject &rDPObj, const css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters)
Definition: dbfunc3.cxx:2032
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:163
static bool lcl_GetFieldDataByIndex(const Reference< XDimensionsSupplier > &rSource, const Any &rOrient, SCSIZE nIndex, ScFieldIdentifier &rFieldId)
Definition: dapiuno.cxx:1446
ScDPSaveMember * GetMemberByName(const OUString &rName)
Get a member object by its name.
Definition: dpsave.cxx:457
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
ScDataPilotChildObjBase(ScDataPilotDescriptorBase &rParent)
Definition: dapiuno.cxx:1320
SC_DLLPUBLIC size_t GetCount() const
Definition: dpobject.cxx:3679
static void FillProperties(css::uno::Sequence< css::beans::PropertyValue > &rSeq, const ScImportParam &rParam)
Definition: datauno.cxx:167
void SetOrientation(css::sheet::DataPilotFieldOrientation nNew)
Definition: dpsave.cxx:318
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: dapiuno.cxx:938
#define SC_UNO_DP_SERVICEARG
Definition: unonames.hxx:635
std::unique_ptr< ScDPObject > mpDPObject
Definition: dapiuno.hxx:207
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: dapiuno.cxx:3014
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: dapiuno.cxx:1686
SC_DLLPUBLIC const std::optional< OUString > & GetGrandTotalName() const
Definition: dpsave.cxx:771
OUString aDBName
Definition: global.hxx:444
rtl::Reference< ScDataPilotFieldObj > GetObjectByName_Impl(const OUString &rName) const
Definition: dapiuno.cxx:1541
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dapiuno.cxx:3067
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getPageFields() override
Definition: dapiuno.cxx:665
css::sheet::DataPilotFieldOrientation GetOrientation() const
Definition: dpsave.hxx:202
virtual css::uno::Reference< css::sheet::XDataPilotDescriptor > SAL_CALL createDataPilotDescriptor() override
Definition: dapiuno.cxx:360
virtual sal_Int32 SAL_CALL getCount() override
Definition: dapiuno.cxx:2997
void AddNumGroupDimension(const ScDPSaveNumGroupDimension &rGroupDim)
Definition: dpdimsave.cxx:588
const css::sheet::DataPilotFieldAutoShowInfo * getAutoShowInfo() const
Definition: dapiuno.cxx:2126
virtual sal_Int32 SAL_CALL getCount() override
Definition: dapiuno.cxx:465
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
virtual OUString SAL_CALL getName() override
Definition: dapiuno.cxx:3196
OUString aParPass
Definition: dpobject.hxx:75
virtual OUString SAL_CALL getName() override
Definition: dapiuno.cxx:1296
tools::Long GetDimCount()
Definition: dpobject.cxx:1275
virtual sal_Int32 SAL_CALL getCount() override
Definition: dapiuno.cxx:3158
virtual ~ScDataPilotDescriptor() override
Definition: dapiuno.cxx:1276
long Long
void setReference(const css::sheet::DataPilotFieldReference *pInfo)
Definition: dapiuno.cxx:2169
css::sheet::DataPilotFieldGroupInfo getGroupInfo()
Definition: dapiuno.cxx:2244
void GetDrillDownData(const ScAddress &rPos, css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &rTableData)
Definition: dpobject.cxx:1158
void AddGroupDimension(const ScDPSaveGroupDimension &rGroupDim)
Definition: dpdimsave.cxx:562
const css::sheet::DataPilotFieldLayoutInfo * GetLayoutInfo() const
Definition: dpsave.hxx:194
#define SC_UNONAME_REFERENCE
Definition: unonames.hxx:262
WeakReference< XInterface > mxParent
SC_DLLPUBLIC ScDPDimensionSaveData * GetDimensionData()
Definition: dpsave.cxx:1196
#define SC_UNO_DP_COLGRAND
Definition: unonames.hxx:594
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dapiuno.cxx:2850
Classes to save Data Pilot settings that create new dimensions (fields).
Definition: dpdimsave.hxx:46
const OUString & GetGroupName() const
Definition: dpdimsave.hxx:65
rtl::Reference< ScDataPilotFieldGroupObj > mxParent
Definition: dapiuno.hxx:629
sal_Int64 n
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:365
sal_Int32 mnFieldIdx
Source field name.
Definition: dapiuno.hxx:290
ScFieldGroup & getFieldGroup(const OUString &rName)
Definition: dapiuno.cxx:2863
void SetOutRange(const ScRange &rRange)
Definition: dpobject.cxx:401
const OUString & GetSourceDimName() const
Definition: dpdimsave.hxx:108
void RemoveGroupDimension(const OUString &rGroupDimName)
Definition: dpdimsave.cxx:580
#define SC_UNO_DP_PASSWORD
Definition: unonames.hxx:641
void SetSubTotals(std::vector< ScGeneralFunction > &&rFuncs)
Definition: dpsave.cxx:323
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: dapiuno.cxx:3003
void SetDocumentModified()
Definition: docsh.cxx:2959
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dapiuno.cxx:2757
virtual OUString SAL_CALL getName() override
Definition: dapiuno.cxx:3061
css::sheet::DataPilotFieldOrientation getOrientation() const
Definition: dapiuno.cxx:1923
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: dapiuno.cxx:692
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dapiuno.cxx:522
virtual ScDPObject * GetDPObject() const override
Definition: dapiuno.cxx:1280
ScFieldGroups maGroups
Definition: dapiuno.hxx:547
numerical values are counted.
#define SC_UNO_DP_REPEATEMPTY
Definition: unonames.hxx:612
ScDPObject * GetDPObject() const
Returns the wrapped DataPilot object (calls GetDPObject() at parent).
Definition: dapiuno.cxx:1335
sum of all numerical values is calculated.
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dapiuno.cxx:2935
DataPilotTables collection per sheet.
Definition: dapiuno.hxx:78
bool IsDataLayout() const
Definition: dpsave.hxx:142
ScDataPilotTablesObj(ScDocShell &rDocSh, SCTAB nT)
Definition: dapiuno.cxx:298
void SetImportDesc(const ScImportSourceDesc &rDesc)
Definition: dpobject.cxx:438
SC_DLLPUBLIC ScRange GetRange(SCTAB nTab, const tools::Rectangle &rMMRect, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1805
void SetDPObject(ScDPObject *pDPObject)
Sets the passed DataPilot object (calls SetDPObject() at parent).
Definition: dapiuno.cxx:1340
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: dapiuno.cxx:979
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: dapiuno.cxx:3220
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dapiuno.cxx:1672
virtual css::sheet::DataPilotTablePositionData SAL_CALL getPositionData(const css::table::CellAddress &aAddr) override
Definition: dapiuno.cxx:1148
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:153
#define SC_UNO_DP_IGNORE_EMPTYROWS
Definition: unonames.hxx:630
OUString aParSource
Definition: dpobject.hxx:72
#define SC_UNO_DP_GRANDTOTAL_NAME
Definition: unonames.hxx:620
#define SC_UNONAME_GROUPINFO
Definition: unonames.hxx:270
void setOrientation(css::sheet::DataPilotFieldOrientation Orientation)
Definition: dapiuno.cxx:1930
SfxHintId GetId() const
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: dapiuno.cxx:833
product of all numerical values is calculated.
virtual css::uno::Reference< css::sheet::XDataPilotField > SAL_CALL getDataLayoutField() override
Definition: dapiuno.cxx:960
virtual ~ScDataPilotDescriptorBase() override
Definition: dapiuno.cxx:588
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: dapiuno.cxx:313
void setShowEmpty(bool bShow)
Definition: dapiuno.cxx:2205
#define SC_UNO_DP_ORIGINAL
Definition: unonames.hxx:596
static void FillGroupInfo(css::sheet::DataPilotFieldGroupInfo &rInfo, const ScDPNumGroupInfo &rGroupInfo)
Definition: dapiuno.cxx:238
OUString CreateGroupDimName(const OUString &rSourceName, const ScDPObject &rObject, bool bAllowSource, const ::std::vector< OUString > *pDeletedNames)
Definition: dpdimsave.cxx:710
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dapiuno.cxx:2929
OUString CreateNewName() const
Create a new name that's not yet used by any existing data pilot objects.
Definition: dpobject.cxx:3705
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: dapiuno.cxx:2765
const OUString & GetTag() const
Definition: dpobject.hxx:169
sal_Int32 GetMemberCount() const
Returns the number of members for the field described by maFieldId.
Definition: dapiuno.cxx:1380
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: dapiuno.cxx:2832
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: dapiuno.cxx:3228
const ScDPSaveGroupDimension * GetNamedGroupDim(const OUString &rGroupDimName) const
Definition: dpdimsave.cxx:635
virtual OUString SAL_CALL getTag() override
Definition: dapiuno.cxx:1308
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getRowFields() override
Definition: dapiuno.cxx:659
void RefreshPivotTables(const ScDPObject *pDPObj, bool bApi)
Reload the referenced pivot cache, and refresh all pivot tables that reference the cache...
Definition: dbdocfun.cxx:1666
OUString maName
Definition: dapiuno.hxx:479
bool getShowEmpty() const
Definition: dapiuno.cxx:2198
const ScRange & GetOutRange() const
Definition: dpobject.cxx:409
ScDPSaveGroupDimension * GetGroupDimAccForBase(const OUString &rBaseDimName)
Definition: dpdimsave.cxx:655
virtual ~ScDataPilotFieldGroupItemObj() override
Definition: dapiuno.cxx:3055
#define SC_UNONAME_USESELPAGE
Definition: unonames.hxx:260
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
Any SAL_CALL getCaughtException()
::std::vector< ScFieldGroup > ScFieldGroups
Definition: dapiuno.hxx:483
void RemoveDimensionByName(const OUString &rName)
Definition: dpsave.cxx:899
bool RemovePivotTable(const ScDPObject &rDPObj, bool bRecord, bool bApi)
Definition: dbdocfun.cxx:1399
void setSubtotals(const std::vector< ScGeneralFunction > &rFunctions)
Definition: dapiuno.cxx:2053
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dapiuno.cxx:1624
int nCount
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: dapiuno.cxx:943
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: dapiuno.cxx:1191
SCTAB Tab() const
Definition: address.hxx:283
variance is calculated based on the entire population.
void AddElementsFromGroup(const ScDPSaveGroupItem &rGroup)
Definition: dpdimsave.cxx:49
void SetMemberPosition(const OUString &rName, sal_Int32 nNewPos)
Definition: dpsave.cxx:469
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
Definition: dpshttab.cxx:230
PivotFunc
Definition: dpglobal.hxx:24
ScDataPilotDescriptor(ScDocShell &rDocSh)
Definition: dapiuno.cxx:1261
ScDataPilotFieldGroupItemObj(ScDataPilotFieldGroupObj &rParent, const OUString &rName)
Definition: dapiuno.cxx:3049
ScDocShell * pDocShell
Definition: dapiuno.hxx:141
void ReplaceGroupDimension(const ScDPSaveGroupDimension &rGroupDim)
Definition: dpdimsave.cxx:570
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dapiuno.cxx:2919
virtual void SAL_CALL acquire() noexcept override
Definition: dapiuno.cxx:1014
bool GetIgnoreEmptyRows() const
Definition: dpsave.hxx:330
void SetSheetDesc(const ScSheetSourceDesc &rDesc)
Definition: dpobject.cxx:414
bool mbDataLayout
Field index (if several fields with same name exist).
Definition: dapiuno.hxx:291
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::uno::Reference< css::container::XIndexAccess > mxItems
Definition: dapiuno.hxx:470
void SetGroupInfo(const ScDPNumGroupInfo &rNew)
Definition: dpdimsave.cxx:524
size_t GetElementCount() const
Definition: dpdimsave.cxx:71
css::uno::Sequence< sal_Int16 > getSubtotals() const
Definition: dapiuno.cxx:2031
const char * sName
void SetFunction(ScGeneralFunction nNew)
Definition: dpsave.cxx:344
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
Definition: dputil.cxx:66
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dapiuno.cxx:2740
#define SC_QUERYINTERFACE(x)
Definition: miscuno.hxx:86
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: dapiuno.cxx:457
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: dapiuno.cxx:2967
bool GetRepeatItemLabels() const
Definition: dpsave.hxx:161
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: dapiuno.cxx:1554
maximum value of all numerical values is calculated.
#define SC_UNO_DP_SOURCENAME
Definition: unonames.hxx:638
virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL getFilterDescriptor() override
Definition: dapiuno.cxx:641
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dapiuno.cxx:3094
const css::uno::Sequence< sal_Int8 > & getSeq() const
void SetName(const OUString &rNew)
Definition: dpobject.cxx:489
void SetLayoutName(const OUString &rName)
Definition: dpsave.cxx:380
OUString aParUser
Definition: dpobject.hxx:74
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDrillDownData(const css::table::CellAddress &aAddr) override
Definition: dapiuno.cxx:1135
void setSortInfo(const css::sheet::DataPilotFieldSortInfo *pInfo)
Definition: dapiuno.cxx:2187
void setRepeatItemLabels(bool bShow)
Definition: dapiuno.cxx:2223
static PivotFunc FunctionBit(sal_Int16 eFunc)
Definition: dapiuno.cxx:212
tools::Long GetGroupCount() const
Definition: dpdimsave.cxx:198
bool GetDrillDown() const
Definition: dpsave.hxx:342
#define SC_UNO_DP_IMPORTDESC
Definition: unonames.hxx:633
standard deviation is calculated based on the entire population.
Collection of all DataPilot fields, or of all fields from a specific dimension.
Definition: dapiuno.hxx:341
OUString aStatement
Definition: global.hxx:445
rtl::Reference< ScDataPilotDescriptorBase > mxParent
Definition: dapiuno.hxx:324
sal_uInt16 char * pName
Definition: callform.cxx:57
virtual css::uno::Reference< css::sheet::XDataPilotField > SAL_CALL createDateGroup(const css::sheet::DataPilotFieldGroupInfo &rInfo) override
Definition: dapiuno.cxx:2564
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dapiuno.cxx:2732
virtual sal_Bool SAL_CALL hasElements() override
Definition: dapiuno.cxx:2855
ScDataPilotItemObj(ScDataPilotDescriptorBase &rParent, const ScFieldIdentifier &rFieldId, sal_Int32 nIndex)
Definition: dapiuno.cxx:3184
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getDataFields() override
Definition: dapiuno.cxx:671
const ScDPSaveGroupItem & GetGroupByIndex(tools::Long nIndex) const
Definition: dpdimsave.cxx:203
const css::sheet::DataPilotFieldSortInfo * GetSortInfo() const
Definition: dpsave.hxx:186
void setCurrentPage(const OUString &sPage)
Definition: dapiuno.cxx:2095
bool getRepeatItemLabels() const
Definition: dapiuno.cxx:2216
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: dapiuno.cxx:3345
void SetCurrentPage(const OUString *pPage)
Definition: dpsave.cxx:427
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dapiuno.cxx:3214
SC_DLLPUBLIC void SetDimensionData(const ScDPDimensionSaveData *pNew)
Definition: dpsave.cxx:1203
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dapiuno.cxx:1580
ScDocShell * GetDocShell() const
Definition: dapiuno.cxx:1400
static bool lcl_IsDuplicated(const Reference< XPropertySet > &rDimProps)
Definition: dapiuno.cxx:368
const OUString * GetElementByIndex(size_t nIndex) const
Definition: dpdimsave.cxx:76
int i
static bool lcl_GetFieldDataByName(ScDPObject *pDPObj, const OUString &rFieldName, ScFieldIdentifier &rFieldId)
Definition: dapiuno.cxx:1514
Represents a group dimension that introduces a new hierarchy for an existing dimension.
Definition: dpdimsave.hxx:135
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: dapiuno.cxx:2787
static tools::Long GetPropertyCount()
Definition: datauno.hxx:82
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dapiuno.cxx:500
average of all numerical values is calculated.
css::uno::Reference< css::sheet::XDimensionsSupplier > const & GetSource()
Definition: dpobject.cxx:515
virtual css::table::CellRangeAddress SAL_CALL getOutputRange() override
Definition: dapiuno.cxx:1107
virtual ~ScDataPilotItemObj() override
Definition: dapiuno.cxx:3191
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: dapiuno.cxx:1593
virtual ~ScDataPilotFieldObj() override
Definition: dapiuno.cxx:1646
const ScDPSaveGroupDimension * GetNextNamedGroupDim(const OUString &rGroupDimName) const
Definition: dpdimsave.cxx:645
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: dapiuno.cxx:684
bool DataPilotUpdate(ScDPObject *pOldObj, const ScDPObject *pNewObj, bool bRecord, bool bApi, bool bAllowMove=false)
Definition: dbdocfun.cxx:1297
ScFieldIdentifier maFieldId
Definition: dapiuno.hxx:325
#define SC_UNONAME_AUTOSHOW
Definition: unonames.hxx:264
void SetSaveData(const ScDPSaveData &rData)
Definition: dpobject.cxx:386
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: dapiuno.cxx:1569
virtual ~ScDataPilotItemsObj() override
Definition: dapiuno.cxx:3080
static sal_Int32 lcl_GetFieldCount(const Reference< XDimensionsSupplier > &rSource, const Any &rOrient)
Definition: dapiuno.cxx:1420
ScDataPilotFieldGroupObj(ScDataPilotFieldGroupsObj &rParent, const OUString &rGroupName)
Definition: dapiuno.cxx:2907
const OUString & GetName() const
Definition: dpobject.hxx:167
#define SC_UNO_DP_DRILLDOWN
Definition: unonames.hxx:631
bool IsSheetData() const
Definition: dpobject.cxx:484
virtual sal_Bool SAL_CALL hasElements() override
Definition: dapiuno.cxx:3027
ScDPSaveNumGroupDimension * GetNumGroupDimAcc(const OUString &rGroupDimName)
Definition: dpdimsave.cxx:686
#define SC_UNONAME_FUNCTION
Definition: unonames.hxx:255
bool GetRepeatIfEmpty() const
Definition: dpsave.hxx:334
Implementation of a single DataPilot field.
Definition: dapiuno.hxx:394
SfxItemPropertySet maPropSet
Definition: dapiuno.hxx:471
size_t size() const
Definition: rangelst.hxx:89
static bool GetBoolProperty(const css::uno::Reference< css::beans::XPropertySet > &xProp, const OUString &rName, bool bDefault=false)
Definition: miscuno.cxx:35
void SetTag(const OUString &rNew)
Definition: dpobject.cxx:494
bool bNative
Definition: global.hxx:446
#define SC_UNONAME_SHOWDETAIL
Definition: unonames.hxx:275
float u
unsigned char sal_Bool
virtual ~ScDataPilotChildObjBase()
Definition: dapiuno.cxx:1331
const SfxItemPropertyMap & getPropertyMap() const
virtual void SAL_CALL setSourceRange(const css::table::CellRangeAddress &aSourceRange) override
Definition: dapiuno.cxx:622
const int COUNT
Definition: sheetevents.cxx:56
XModifyListenerArr_Impl aModifyListeners
Definition: dapiuno.hxx:235
virtual void SAL_CALL setTag(const OUString &aTag) override
Definition: dapiuno.cxx:1314
ScFieldGroupMembers maMembers
Definition: dapiuno.hxx:480
#define SC_UNONAME_SHOWEMPTY
Definition: unonames.hxx:271
rtl::Reference< ScDataPilotTableObj > GetObjectByName_Impl(const OUString &aName)
Definition: dapiuno.cxx:353
const css::sheet::DataPilotFieldLayoutInfo * getLayoutInfo() const
Definition: dapiuno.cxx:2144
virtual sal_Bool SAL_CALL hasElements() override
Definition: dapiuno.cxx:3178
#define SC_UNONAME_HASSORTINFO
Definition: unonames.hxx:265
#define SC_UNONAME_SELPAGE
Definition: unonames.hxx:259
ScDPSaveData * GetSaveData() const
Definition: dpobject.hxx:141
OUString aPropName
#define SC_UNONAME_ISHIDDEN
Definition: unonames.hxx:276
SC_DLLPUBLIC void SetIgnoreEmptyRows(bool bSet)
Definition: dpsave.cxx:994
const ScImportSourceDesc * GetImportSourceDesc() const
Definition: dpobject.hxx:157
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:111
css::uno::Type const & get()
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
Definition: miscuno.hxx:63
virtual ~ScDataPilotFieldGroupObj() override
Definition: dapiuno.cxx:2913
virtual ~ScDataPilotFieldGroupsObj() override
Definition: dapiuno.cxx:2726
const ScDPServiceDesc * GetDPServiceDesc() const
Definition: dpobject.hxx:158
virtual sal_Bool SAL_CALL hasElements() override
Definition: dapiuno.cxx:505
const ScDPSaveGroupDimension * GetFirstNamedGroupDim(const OUString &rBaseDimName) const
Definition: dpdimsave.cxx:640
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dapiuno.cxx:559
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: dapiuno.cxx:953
rtl::Reference< ScDataPilotFieldGroupsObj > mxParent
Definition: dapiuno.hxx:602
ScDataPilotItemsObj(ScDataPilotDescriptorBase &rParent, const ScFieldIdentifier &rFieldId)
Definition: dapiuno.cxx:3075
SC_DLLPUBLIC void SetFilterButton(bool bSet)
Definition: dpsave.cxx:1004
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
ScDPSaveDimension * DuplicateDimension(std::u16string_view rName)
Definition: dpsave.cxx:886
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: dapiuno.cxx:2810
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: dapiuno.cxx:3350
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: dapiuno.cxx:1035
virtual void SetDPObject(ScDPObject *pDPObj) override
Definition: dapiuno.cxx:1045
rtl::Reference< ScDataPilotTableObj > GetObjectByIndex_Impl(sal_Int32 nIndex)
Definition: dapiuno.cxx:325
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: dapiuno.cxx:1024
ScDocShell * GetDocShell() const
Definition: dapiuno.hxx:149
Implementation of all grouped items in a DataPilot field.
Definition: dapiuno.hxx:500
virtual void SAL_CALL setTag(const OUString &aTag) override
Definition: dapiuno.cxx:1092
OUString aDBName
Definition: dpsdbtab.hxx:35
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: dapiuno.cxx:1003
const css::sheet::DataPilotFieldSortInfo * getSortInfo() const
Definition: dapiuno.cxx:2180
static sal_Int16 GetInt16FromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:144
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
Definition: miscuno.hxx:72
const css::sheet::DataPilotFieldReference * getReference() const
Definition: dapiuno.cxx:2162
bool GetDataFieldPositionData(const ScAddress &rPos, css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters)
Definition: dpobject.cxx:1140
bool GetFilterButton() const
Definition: dpsave.hxx:338
rtl::Reference< ScDataPilotFieldObj > GetObjectByIndex_Impl(sal_Int32 nIndex) const
Definition: dapiuno.cxx:1530
void SetPosition(ScDPSaveDimension *pDim, tools::Long nNew)
Definition: dpsave.cxx:956
css::sheet::DataImportMode nType
Definition: dpsdbtab.hxx:37
SC_DLLPUBLIC void SetShowDetails(bool bSet)
Definition: dpsave.cxx:106
OUString aObject
Definition: dpsdbtab.hxx:36
void AddUnoObject(SfxListener &rObject)
Definition: documen3.cxx:901
#define SC_UNO_DP_ROWGRAND
Definition: unonames.hxx:595
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: dapiuno.cxx:491
#define SC_UNO_DP_ORIENTATION
Definition: unonames.hxx:599
css::uno::Any maOrient
Definition: dapiuno.hxx:380
bool GetColumnGrand() const
Definition: dpsave.hxx:322
median of all numerical values is calculated.
static SC_DLLPUBLIC const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: dapiuno.cxx:985
virtual void SAL_CALL release() noexcept override
Definition: dapiuno.cxx:1019
SC_DLLPUBLIC void SetGrandTotalName(const OUString &rName)
Definition: dpsave.cxx:766
OUString GetDimName(tools::Long nDim, bool &rIsDataLayout, sal_Int32 *pFlags=nullptr)
Definition: dpobject.cxx:1197
void setGroupInfo(const css::sheet::DataPilotFieldGroupInfo *pInfo)
Definition: dapiuno.cxx:2303
SC_DLLPUBLIC void SetDrillDown(bool bSet)
Definition: dpsave.cxx:1009
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: dapiuno.cxx:3126
#define SC_UNONAME_SORTINFO
Definition: unonames.hxx:266
virtual css::table::CellRangeAddress SAL_CALL getSourceRange() override
Definition: dapiuno.cxx:608
#define SC_UNONAME_POS
Definition: unonames.hxx:160
ScFieldGroups::iterator implFindByName(const OUString &rName)
Definition: dapiuno.cxx:2885
#define SC_UNONAME_HASAUTOSHOW
Definition: unonames.hxx:263
#define SC_UNONAME_SUBTOTALS2
Definition: unonames.hxx:258
virtual css::uno::Reference< css::sheet::XDataPilotField > SAL_CALL createNameGroup(const css::uno::Sequence< OUString > &aItems) override
Definition: dapiuno.cxx:2396
#define SC_UNONAME_SUBTOTALS
Definition: unonames.hxx:257
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: dapiuno.cxx:596
#define SC_UNONAME_ORIENT
Definition: unonames.hxx:304
bool GetShowDetails() const
Definition: dpsave.hxx:76
SfxItemPropertySet maPropSet
Definition: dapiuno.hxx:140
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dapiuno.cxx:1602
virtual OUString SAL_CALL getName() override
Definition: dapiuno.cxx:1652
const DimsType & GetDimensions() const
Definition: dpsave.hxx:270
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: dapiuno.cxx:1694
static void FillImportParam(ScImportParam &rParam, const css::uno::Sequence< css::beans::PropertyValue > &rSeq)
Definition: datauno.cxx:207
void RemoveElementsFromGroups(ScDPSaveGroupDimension &rDimension) const
remove this group's elements from their groups in rDimension (rDimension must be a different dimensio...
Definition: dpdimsave.cxx:86
sal_uInt8 nType
Definition: global.hxx:448
#define SC_UNO_DP_USERNAME
Definition: unonames.hxx:640
::std::vector< OUString > ScFieldGroupMembers
Definition: dapiuno.hxx:475
#define SAL_WARN_IF(condition, area, stream)
unsigned char sal_uInt8
OUString aParName
Definition: dpobject.hxx:73
virtual ~ScDataPilotTablesObj() override
Definition: dapiuno.cxx:305
OUString aServiceName
Definition: dpobject.hxx:71
sal_Int64 getSomethingImpl(const css::uno::Sequence< sal_Int8 > &rId, T *pThis, FallbackToGetSomethingOf< Base >={})
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: dapiuno.cxx:3279
ScDataPilotItemObj * GetObjectByIndex_Impl(sal_Int32 nIndex) const
Definition: dapiuno.cxx:3086
bool GetShowEmpty() const
Definition: dpsave.hxx:157
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: dapiuno.cxx:1227
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: dapiuno.cxx:1203
void SetServiceData(const ScDPServiceDesc &rDesc)
Definition: dpobject.cxx:451
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2, which causes some type-safety issues.
OUString maName
void RemoveFromGroups(const OUString &rItemName)
Definition: dpdimsave.cxx:209
OUString aName
virtual void SAL_CALL removeByName(const OUString &aName) override
Definition: dapiuno.cxx:443
#define SC_UNO_DP_ISVISIBLE
Definition: unonames.hxx:609
std::vector< std::unique_ptr< ScDPSaveDimension > > DimsType
Definition: dpsave.hxx:238
#define SC_UNONAME_NAME
Definition: unonames.hxx:232
virtual void SetDPObject(ScDPObject *pDPObj)=0
variance is calculated based on a sample.
ScDataPilotFieldGroupsObj(ScFieldGroups &&rGroups)
Definition: dapiuno.cxx:2721
all values, including non-numerical values, are counted.
const ScSheetSourceDesc * GetSheetDesc() const
Definition: dpobject.hxx:156
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID...
Definition: dpdimsave.hxx:90
static OUString lcl_GetOriginalName(const Reference< XNamed > &rDim)
Definition: dapiuno.cxx:382
nothing is calculated.
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: dapiuno.cxx:2842
void RemoveUnoObject(SfxListener &rObject)
Definition: documen3.cxx:909
virtual ScDPObject * GetDPObject() const =0
void setFunction(ScGeneralFunction Function)
Definition: dapiuno.cxx:2008
void AddElement(const OUString &rName)
Definition: dpdimsave.cxx:44
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dapiuno.cxx:3041
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
const ScDPSaveGroupItem * GetNamedGroup(const OUString &rGroupName) const
Definition: dpdimsave.cxx:181
ScDataPilotFieldsObj(ScDataPilotDescriptorBase &rParent)
Definition: dapiuno.cxx:1405
const css::sheet::DataPilotFieldAutoShowInfo * GetAutoShowInfo() const
Definition: dpsave.hxx:190
void SetDateInfo(const ScDPNumGroupInfo &rInfo, sal_Int32 nPart)
Definition: dpdimsave.cxx:529
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: dapiuno.cxx:2944
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: dapiuno.cxx:3164
virtual ~ScDataPilotFieldsObj() override
Definition: dapiuno.cxx:1416
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dapiuno.cxx:3022
void setAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo *pInfo)
Definition: dapiuno.cxx:2133
virtual sal_Int32 SAL_CALL getCount() override
Definition: dapiuno.cxx:2826
sal_Int32 CollectDateParts(const OUString &rBaseDimName) const
Definition: dpdimsave.cxx:697
virtual OUString SAL_CALL getTag() override
Definition: dapiuno.cxx:1083
bool bImport
Definition: global.hxx:443
SC_DLLPUBLIC void SetColumnGrand(bool bSet)
Definition: dpsave.cxx:984
css::uno::Reference< css::sheet::XMembersAccess > GetMembers() const
Returns the collection of members for the field described by maFieldId.
Definition: dapiuno.cxx:1392
virtual sal_Int32 SAL_CALL getCount() override
Definition: dapiuno.cxx:1562
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getHiddenFields() override
Definition: dapiuno.cxx:677
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getItems() override
Definition: dapiuno.cxx:1913
minimum value of all numerical values is calculated.
#define SC_UNONAME_FUNCTION2
Definition: unonames.hxx:256
#define SC_UNO_DP_SOURCESERVICE
Definition: unonames.hxx:634
char aEntryName[20]
#define SC_UNO_DP_SHOWFILTER
Definition: unonames.hxx:632
standard deviation is calculated based on a sample.
const ScDPNumGroupInfo & GetInfo() const
Definition: dpdimsave.hxx:150
SC_DLLPUBLIC void SetRowGrand(bool bSet)
Definition: dpsave.cxx:989
void AddUnoListenerCall(const css::uno::Reference< css::util::XModifyListener > &rListener, const css::lang::EventObject &rEvent)
Definition: documen3.cxx:980
virtual css::uno::Type SAL_CALL getElementType() override
Definition: dapiuno.cxx:3173
ScRange & front()
Definition: rangelst.hxx:92
static void FillApiRange(css::table::CellRangeAddress &rApiRange, const ScRange &rScRange)
Definition: convuno.hxx:87
virtual void SAL_CALL insertNewByName(const OUString &aName, const css::table::CellAddress &aOutputAddress, const css::uno::Reference< css::sheet::XDataPilotDescriptor > &xDescriptor) override
Definition: dapiuno.cxx:405
OUString CreateDateGroupDimName(sal_Int32 nDatePart, const ScDPObject &rObject, bool bAllowSource, const ::std::vector< OUString > *pDeletedNames)
Definition: dpdimsave.cxx:771
#define SAL_WARN(area, stream)
static sal_Int32 lcl_GetObjectIndex(ScDPObject *pDPObj, const ScFieldIdentifier &rFieldId)
Definition: dapiuno.cxx:281
virtual void SAL_CALL refresh() override
Definition: dapiuno.cxx:1124
virtual OUString SAL_CALL getName() override
Definition: dapiuno.cxx:3035
#define SC_UNO_DP_SHOWDETAILS
Definition: unonames.hxx:610
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2608
#define SC_UNO_DP_ISDATALAYOUT
Definition: unonames.hxx:598
const ScDPSaveNumGroupDimension * GetNumGroupDim(const OUString &rGroupDimName) const
Definition: dpdimsave.cxx:650
#define SC_UNONAME_HASREFERENCE
Definition: unonames.hxx:261
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dapiuno.cxx:1067
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getColumnFields() override
Definition: dapiuno.cxx:653
void setUseCurrentPage(bool bUse)
Definition: dapiuno.cxx:2106
int mnIndex
#define SC_UNO_DP_OBJECTNAME
Definition: unonames.hxx:639
void RefreshPivotTableGroups(ScDPObject *pDPObj)
Refresh the group dimensions of all pivot tables referencing the same cache.
Definition: dbdocfun.cxx:1684
SfxItemPropertySet maPropSet
Definition: dapiuno.hxx:718
static ScDPObject * lcl_GetDPObject(ScDocShell *pDocShell, SCTAB nTab, std::u16string_view rName)
Definition: dapiuno.cxx:248
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
Definition: convuno.hxx:79
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: dapiuno.cxx:3117
Base class of all implementation objects based on a DataPilot descriptor or DataPilot table object...
Definition: dapiuno.hxx:302
bool hasGroupInfo() const
Definition: dapiuno.cxx:2234
virtual void SAL_CALL setName(const OUString &aName) override
Definition: dapiuno.cxx:1302
#define SC_UNONAME_HASLAYOUTINFO
Definition: unonames.hxx:267
virtual ~ScDataPilotTableObj() override
Definition: dapiuno.cxx:999
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:39
void setLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo *pInfo)
Definition: dapiuno.cxx:2151
ScDataPilotFieldObj(ScDataPilotDescriptorBase &rParent, const ScFieldIdentifier &rIdent)
Definition: dapiuno.cxx:1631
virtual OUString SAL_CALL getName() override
Definition: dapiuno.cxx:1058
void AddGroupItem(const ScDPSaveGroupItem &rItem)
Definition: dpdimsave.cxx:147
SC_DLLPUBLIC ScDPSaveDimension * GetDimensionByName(const OUString &rName)
Get a dimension object by its name.
Definition: dpsave.cxx:835
AnyEventRef aEvent
#define SC_UNONAME_ISGROUP
Definition: unonames.hxx:269
ScDPSaveDimension * GetDPDimension(ScDPObject **ppDPObject=nullptr) const
Returns the DataPilot dimension object related to the field described by maFieldId.
Definition: dapiuno.cxx:1345
ScDataPilotTableObj(ScDocShell &rDocSh, SCTAB nT, const OUString &rN)
Definition: dapiuno.cxx:991
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: dapiuno.cxx:948
void renameFieldGroup(const OUString &rOldName, const OUString &rNewName)
Definition: dapiuno.cxx:2872
const css::sheet::DataPilotFieldReference * GetReferenceValue() const
Definition: dpsave.hxx:181
sal_uInt16 nPos
sal_Int16 getFunction() const
Definition: dapiuno.cxx:1988
sal_Int16 SCTAB
Definition: types.hxx:22
void SetDateInfo(const ScDPNumGroupInfo &rInfo, sal_Int32 nPart)
Definition: dpdimsave.cxx:141
OUString CreateGroupName(std::u16string_view rPrefix)
Definition: dpdimsave.cxx:152
#define SC_UNONAME_REPEATITEMLABELS
Definition: unonames.hxx:272
bool any2bool(const css::uno::Any &rAny)
sal_Int16 nValue
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: dapiuno.cxx:3340
virtual void SetDPObject(ScDPObject *pDPObj) override
Definition: dapiuno.cxx:1285
virtual ScDPObject * GetDPObject() const override
Definition: dapiuno.cxx:1040
void GetPositionData(const ScAddress &rPos, css::sheet::DataPilotTablePositionData &rPosData)
Definition: dpobject.cxx:1134
bool CreatePivotTable(const ScDPObject &rDPObj, bool bRecord, bool bApi)
Definition: dbdocfun.cxx:1481
sal_Int32 mnIndex
Definition: dapiuno.hxx:719
ScDataPilotDescriptorBase(ScDocShell &rDocSh)
Definition: dapiuno.cxx:581
OUString maFieldName
Definition: dapiuno.hxx:289