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