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