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