LibreOffice Module sc (master)  1
datauno.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 <datauno.hxx>
21 
22 #include <svl/hint.hxx>
23 #include <svl/zforlist.hxx>
24 #include <svl/sharedstringpool.hxx>
25 #include <vcl/svapp.hxx>
26 #include <unotools/charclass.hxx>
27 #include <osl/diagnose.h>
28 
29 #include <com/sun/star/awt/XBitmap.hpp>
30 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
31 #include <com/sun/star/util/SortField.hpp>
32 #include <com/sun/star/table/TableSortField.hpp>
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <com/sun/star/table/TableOrientation.hpp>
35 #include <com/sun/star/table/CellRangeAddress.hpp>
36 #include <com/sun/star/sheet/DataImportMode.hpp>
37 #include <com/sun/star/sheet/FilterOperator2.hpp>
38 #include <com/sun/star/sheet/TableFilterField2.hpp>
39 
40 #include <dapiuno.hxx>
41 #include <cellsuno.hxx>
42 #include <miscuno.hxx>
43 #include <targuno.hxx>
44 #include <rangeutl.hxx>
45 #include <dbdata.hxx>
46 #include <docsh.hxx>
47 #include <dbdocfun.hxx>
48 #include <unonames.hxx>
49 #include <globalnames.hxx>
50 #include <convuno.hxx>
51 #include <hints.hxx>
52 #include <attrib.hxx>
53 #include <dpshttab.hxx>
54 #include <queryentry.hxx>
55 #include <dputil.hxx>
56 #include <sortparam.hxx>
57 #include <dpobject.hxx>
58 
59 #include <comphelper/extract.hxx>
62 
63 #include <memory>
64 
65 using namespace com::sun::star;
66 
67 // everything without Which-ID, map only for PropertySetInfo
68 
70 {
71  // some old property names are for 5.2 compatibility
72 
73  static const SfxItemPropertyMapEntry aSubTotalPropertyMap_Impl[] =
74  {
82  {u"" SC_UNONAME_MAXFLD, 0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0},
87  { u"", 0, css::uno::Type(), 0, 0 }
88  };
89  return aSubTotalPropertyMap_Impl;
90 }
91 
93 {
94  static const SfxItemPropertyMapEntry aFilterPropertyMap_Impl[] =
95  {
99  {u"" SC_UNONAME_MAXFLD, 0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0},
105  { u"", 0, css::uno::Type(), 0, 0 }
106  };
107  return aFilterPropertyMap_Impl;
108 }
109 
111 {
112  static const SfxItemPropertyMapEntry aDBRangePropertyMap_Impl[] =
113  {
117  {u"" SC_UNONAME_ISUSER, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0 },
119  {u"" SC_UNO_LINKDISPBIT, 0, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0 },
120  {u"" SC_UNO_LINKDISPNAME, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0 },
124  {u"" SC_UNONAME_TOKENINDEX,0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0 },
128  { u"", 0, css::uno::Type(), 0, 0 }
129  };
130  return aDBRangePropertyMap_Impl;
131 }
132 
133 SC_SIMPLE_SERVICE_INFO( ScConsolidationDescriptor, "ScConsolidationDescriptor", "com.sun.star.sheet.ConsolidationDescriptor" )
134 SC_SIMPLE_SERVICE_INFO( ScDatabaseRangesObj, "ScDatabaseRangesObj", "com.sun.star.sheet.DatabaseRanges" )
135 SC_SIMPLE_SERVICE_INFO( ScFilterDescriptorBase, "ScFilterDescriptorBase", "com.sun.star.sheet.SheetFilterDescriptor" )
136 SC_SIMPLE_SERVICE_INFO( ScSubTotalDescriptorBase, "ScSubTotalDescriptorBase", "com.sun.star.sheet.SubTotalDescriptor" )
137 SC_SIMPLE_SERVICE_INFO( ScSubTotalFieldObj, "ScSubTotalFieldObj", "com.sun.star.sheet.SubTotalField" )
138 
139 sheet::GeneralFunction ScDataUnoConversion::SubTotalToGeneral( ScSubTotalFunc eSubTotal )
140 {
141  sheet::GeneralFunction eGeneral;
142  switch (eSubTotal)
143  {
144  case SUBTOTAL_FUNC_NONE: eGeneral = sheet::GeneralFunction_NONE; break;
145  case SUBTOTAL_FUNC_AVE: eGeneral = sheet::GeneralFunction_AVERAGE; break;
146  case SUBTOTAL_FUNC_CNT: eGeneral = sheet::GeneralFunction_COUNTNUMS; break;
147  case SUBTOTAL_FUNC_CNT2: eGeneral = sheet::GeneralFunction_COUNT; break;
148  case SUBTOTAL_FUNC_MAX: eGeneral = sheet::GeneralFunction_MAX; break;
149  case SUBTOTAL_FUNC_MIN: eGeneral = sheet::GeneralFunction_MIN; break;
150  case SUBTOTAL_FUNC_PROD: eGeneral = sheet::GeneralFunction_PRODUCT; break;
151  case SUBTOTAL_FUNC_STD: eGeneral = sheet::GeneralFunction_STDEV; break;
152  case SUBTOTAL_FUNC_STDP: eGeneral = sheet::GeneralFunction_STDEVP; break;
153  case SUBTOTAL_FUNC_SUM: eGeneral = sheet::GeneralFunction_SUM; break;
154  case SUBTOTAL_FUNC_VAR: eGeneral = sheet::GeneralFunction_VAR; break;
155  case SUBTOTAL_FUNC_VARP: eGeneral = sheet::GeneralFunction_VARP; break;
156  default:
157  OSL_FAIL("SubTotalToGeneral: wrong enum");
158  eGeneral = sheet::GeneralFunction_NONE;
159  break;
160  }
161  return eGeneral;
162 }
163 
164 void ScImportDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScImportParam& rParam )
165 {
166  OSL_ENSURE( rSeq.getLength() == GetPropertyCount(), "wrong Count" );
167 
168  beans::PropertyValue* pArray = rSeq.getArray();
169 
170  sheet::DataImportMode eMode = sheet::DataImportMode_NONE;
171  if ( rParam.bImport )
172  {
173  if ( rParam.bSql )
174  eMode = sheet::DataImportMode_SQL;
175  else if ( rParam.nType == ScDbQuery )
176  eMode = sheet::DataImportMode_QUERY;
177  else
178  eMode = sheet::DataImportMode_TABLE; // type always ScDbQuery or ScDbTable
179  }
180 
181  svx::ODataAccessDescriptor aDescriptor;
182  aDescriptor.setDataSource(rParam.aDBName);
184  {
185  pArray[0].Name = SC_UNONAME_DBNAME;
186  pArray[0].Value <<= rParam.aDBName;
187  }
189  {
190  pArray[0].Name = SC_UNONAME_CONRES;
191  pArray[0].Value <<= rParam.aDBName;
192  }
193 
194  pArray[1].Name = SC_UNONAME_SRCTYPE;
195  pArray[1].Value <<= eMode;
196 
197  pArray[2].Name = SC_UNONAME_SRCOBJ;
198  pArray[2].Value <<= rParam.aStatement;
199 
200  pArray[3].Name = SC_UNONAME_ISNATIVE;
201  pArray[3].Value <<= rParam.bNative;
202 }
203 
204 void ScImportDescriptor::FillImportParam( ScImportParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
205 {
206  OUString aStrVal;
207  for (const beans::PropertyValue& rProp : rSeq)
208  {
209  OUString aPropName(rProp.Name);
210 
211  if (aPropName == SC_UNONAME_ISNATIVE)
212  rParam.bNative = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
213  else if (aPropName == SC_UNONAME_DBNAME)
214  {
215  if ( rProp.Value >>= aStrVal )
216  rParam.aDBName = aStrVal;
217  }
218  else if (aPropName == SC_UNONAME_CONRES)
219  {
220  if ( rProp.Value >>= aStrVal )
221  rParam.aDBName = aStrVal;
222  }
223  else if (aPropName == SC_UNONAME_SRCOBJ)
224  {
225  if ( rProp.Value >>= aStrVal )
226  rParam.aStatement = aStrVal;
227  }
228  else if (aPropName == SC_UNONAME_SRCTYPE)
229  {
231  sheet::DataImportMode eMode = static_cast<sheet::DataImportMode>(ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ));
232  switch (eMode)
233  {
234  case sheet::DataImportMode_NONE:
235  rParam.bImport = false;
236  break;
237  case sheet::DataImportMode_SQL:
238  rParam.bImport = true;
239  rParam.bSql = true;
240  break;
241  case sheet::DataImportMode_TABLE:
242  rParam.bImport = true;
243  rParam.bSql = false;
244  rParam.nType = ScDbTable;
245  break;
246  case sheet::DataImportMode_QUERY:
247  rParam.bImport = true;
248  rParam.bSql = false;
249  rParam.nType = ScDbQuery;
250  break;
251  default:
252  OSL_FAIL("wrong mode");
253  rParam.bImport = false;
254  }
255  }
256  }
257 }
258 
259 void ScSortDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScSortParam& rParam )
260 {
261  OSL_ENSURE( rSeq.getLength() == GetPropertyCount(), "wrong count" );
262 
263  beans::PropertyValue* pArray = rSeq.getArray();
264 
265  // gather Uno values together
266 
267  table::CellAddress aOutPos;
268  aOutPos.Sheet = rParam.nDestTab;
269  aOutPos.Column = rParam.nDestCol;
270  aOutPos.Row = rParam.nDestRow;
271 
272  sal_uInt16 nSortCount = 0;
273  while ( nSortCount < rParam.GetSortKeyCount() && rParam.maKeyState[nSortCount].bDoSort )
274  ++nSortCount;
275 
276  uno::Sequence<table::TableSortField> aFields(nSortCount);
277  if (nSortCount)
278  {
279  table::TableSortField* pFieldArray = aFields.getArray();
280  for (sal_uInt16 i=0; i<nSortCount; i++)
281  {
282  pFieldArray[i].Field = rParam.maKeyState[i].nField;
283  pFieldArray[i].IsAscending = rParam.maKeyState[i].bAscending;
284  pFieldArray[i].FieldType = table::TableSortFieldType_AUTOMATIC; // always automatic
285  pFieldArray[i].IsCaseSensitive = rParam.bCaseSens;
286  pFieldArray[i].CollatorLocale = rParam.aCollatorLocale;
287  pFieldArray[i].CollatorAlgorithm = rParam.aCollatorAlgorithm;
288  }
289  }
290 
291  // fill the sequence
292 
293  pArray[0].Name = SC_UNONAME_ISSORTCOLUMNS;
294  pArray[0].Value <<= !rParam.bByRow;
295 
296  pArray[1].Name = SC_UNONAME_CONTHDR;
297  pArray[1].Value <<= rParam.bHasHeader;
298 
299  pArray[2].Name = SC_UNONAME_MAXFLD;
300  pArray[2].Value <<= static_cast<sal_Int32>( rParam.GetSortKeyCount() );
301 
302  pArray[3].Name = SC_UNONAME_SORTFLD;
303  pArray[3].Value <<= aFields;
304 
305  pArray[4].Name = SC_UNONAME_BINDFMT;
306  pArray[4].Value <<= rParam.bIncludePattern;
307 
308  pArray[5].Name = SC_UNONAME_COPYOUT;
309  pArray[5].Value <<= !rParam.bInplace;
310 
311  pArray[6].Name = SC_UNONAME_OUTPOS;
312  pArray[6].Value <<= aOutPos;
313 
314  pArray[7].Name = SC_UNONAME_ISULIST;
315  pArray[7].Value <<= rParam.bUserDef;
316 
317  pArray[8].Name = SC_UNONAME_UINDEX;
318  pArray[8].Value <<= static_cast<sal_Int32>( rParam.nUserIndex );
319 }
320 
321 void ScSortDescriptor::FillSortParam( ScSortParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
322 {
323  sal_Int16 nSortSize = rParam.GetSortKeyCount();
324 
325  for (const beans::PropertyValue& rProp : rSeq)
326  {
327  OUString aPropName(rProp.Name);
328 
329  if (aPropName == SC_UNONAME_ORIENT)
330  {
332  table::TableOrientation eOrient = static_cast<table::TableOrientation>(ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ));
333  rParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
334  }
335  else if (aPropName == SC_UNONAME_ISSORTCOLUMNS)
336  {
337  rParam.bByRow = !::cppu::any2bool(rProp.Value);
338  }
339  else if (aPropName == SC_UNONAME_CONTHDR)
340  rParam.bHasHeader = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
341  else if (aPropName == SC_UNONAME_MAXFLD)
342  {
343  sal_Int32 nVal;
344  if ( (rProp.Value >>= nVal) && nVal > nSortSize )
345  {
348  }
349  }
350  else if (aPropName == SC_UNONAME_SORTFLD)
351  {
352  uno::Sequence<util::SortField> aSeq;
353  uno::Sequence<table::TableSortField> aNewSeq;
354  if ( rProp.Value >>= aSeq )
355  {
356  sal_Int32 nCount = aSeq.getLength();
357  sal_Int32 i;
358  if ( nCount > static_cast<sal_Int32>( rParam.GetSortKeyCount() ) )
359  {
360  nCount = nSortSize;
361  rParam.maKeyState.resize(nCount);
362  }
363  const util::SortField* pFieldArray = aSeq.getConstArray();
364  for (i=0; i<nCount; i++)
365  {
366  rParam.maKeyState[i].nField = static_cast<SCCOLROW>( pFieldArray[i].Field );
367  rParam.maKeyState[i].bAscending = pFieldArray[i].SortAscending;
368 
369  // FieldType is ignored
370  rParam.maKeyState[i].bDoSort = true;
371  }
372  for (i=nCount; i<nSortSize; i++)
373  rParam.maKeyState[i].bDoSort = false;
374  }
375  else if ( rProp.Value >>= aNewSeq )
376  {
377  sal_Int32 nCount = aNewSeq.getLength();
378  sal_Int32 i;
379  if ( nCount > nSortSize )
380  {
381  nCount = nSortSize;
382  rParam.maKeyState.resize(nCount);
383  }
384  const table::TableSortField* pFieldArray = aNewSeq.getConstArray();
385  for (i=0; i<nCount; i++)
386  {
387  rParam.maKeyState[i].nField = static_cast<SCCOLROW>( pFieldArray[i].Field );
388  rParam.maKeyState[i].bAscending = pFieldArray[i].IsAscending;
389 
390  // only one is possible, sometime we should make it possible to have different for every entry
391  rParam.bCaseSens = pFieldArray[i].IsCaseSensitive;
392  rParam.aCollatorLocale = pFieldArray[i].CollatorLocale;
393  rParam.aCollatorAlgorithm = pFieldArray[i].CollatorAlgorithm;
394 
395  // FieldType is ignored
396  rParam.maKeyState[i].bDoSort = true;
397  }
398  for (i=nCount; i<nSortSize; i++)
399  rParam.maKeyState[i].bDoSort = false;
400  }
401  }
402  else if (aPropName == SC_UNONAME_ISCASE)
403  {
404  rParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
405  }
406  else if (aPropName == SC_UNONAME_BINDFMT)
407  rParam.bIncludePattern = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
408  else if (aPropName == SC_UNONAME_COPYOUT)
409  rParam.bInplace = !ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
410  else if (aPropName == SC_UNONAME_OUTPOS)
411  {
412  table::CellAddress aAddress;
413  if ( rProp.Value >>= aAddress )
414  {
415  rParam.nDestTab = aAddress.Sheet;
416  rParam.nDestCol = static_cast<SCCOL>(aAddress.Column);
417  rParam.nDestRow = static_cast<SCROW>(aAddress.Row);
418  }
419  }
420  else if (aPropName == SC_UNONAME_ISULIST)
421  rParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
422  else if (aPropName == SC_UNONAME_UINDEX)
423  {
424  sal_Int32 nVal = 0;
425  if ( rProp.Value >>= nVal )
426  rParam.nUserIndex = static_cast<sal_uInt16>(nVal);
427  }
428  else if (aPropName == SC_UNONAME_COLLLOC)
429  {
430  rProp.Value >>= rParam.aCollatorLocale;
431  }
432  else if (aPropName == SC_UNONAME_COLLALG)
433  {
434  OUString sStr;
435  if ( rProp.Value >>= sStr )
436  rParam.aCollatorAlgorithm = sStr;
437  }
438  }
439 }
440 
442  xParent( pDesc ),
443  nPos( nP )
444 {
445  OSL_ENSURE(pDesc, "ScSubTotalFieldObj: Parent is 0");
446 }
447 
449 {
450 }
451 
452 // XSubTotalField
453 
455 {
456  SolarMutexGuard aGuard;
457  ScSubTotalParam aParam;
458  xParent->GetData(aParam);
459 
460  return aParam.nField[nPos];
461 }
462 
463 void SAL_CALL ScSubTotalFieldObj::setGroupColumn( sal_Int32 nGroupColumn )
464 {
465  SolarMutexGuard aGuard;
466  ScSubTotalParam aParam;
467  xParent->GetData(aParam);
468 
469  aParam.nField[nPos] = static_cast<SCCOL>(nGroupColumn);
470 
471  xParent->PutData(aParam);
472 }
473 
474 uno::Sequence<sheet::SubTotalColumn> SAL_CALL ScSubTotalFieldObj::getSubTotalColumns()
475 {
476  SolarMutexGuard aGuard;
477  ScSubTotalParam aParam;
478  xParent->GetData(aParam);
479 
480  SCCOL nCount = aParam.nSubTotals[nPos];
481  uno::Sequence<sheet::SubTotalColumn> aSeq(nCount);
482  sheet::SubTotalColumn* pAry = aSeq.getArray();
483  for (SCCOL i=0; i<nCount; i++)
484  {
485  pAry[i].Column = aParam.pSubTotals[nPos][i];
486  pAry[i].Function = ScDataUnoConversion::SubTotalToGeneral(
487  aParam.pFunctions[nPos][i] );
488  }
489  return aSeq;
490 }
491 
493  const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns )
494 {
495  SolarMutexGuard aGuard;
496  ScSubTotalParam aParam;
497  xParent->GetData(aParam);
498 
499  sal_uInt32 nColCount = aSubTotalColumns.getLength();
500  if ( nColCount <= sal::static_int_cast<sal_uInt32>(SCCOL_MAX) )
501  {
502  SCCOL nCount = static_cast<SCCOL>(nColCount);
503  aParam.nSubTotals[nPos] = nCount;
504  if (nCount != 0)
505  {
506  aParam.pSubTotals[nPos] = new SCCOL[nCount];
507  aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
508 
509  const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
510  for (SCCOL i=0; i<nCount; i++)
511  {
512  aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
513  aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc(static_cast<ScGeneralFunction>(pAry[i].Function));
514  }
515  }
516  else
517  {
518  aParam.pSubTotals[nPos] = nullptr;
519  aParam.pFunctions[nPos] = nullptr;
520  }
521  }
523 
524  xParent->PutData(aParam);
525 }
526 
528  aPropSet( lcl_GetSubTotalPropertyMap() )
529 {
530 }
531 
533 {
534 }
535 
536 // XSubTotalDescriptor
537 
539 {
540  if ( nIndex < getCount() )
541  return new ScSubTotalFieldObj( this, nIndex );
542  return nullptr;
543 }
544 
546 {
547  SolarMutexGuard aGuard;
548  ScSubTotalParam aParam;
549  GetData(aParam);
550 
551  for (bool & rn : aParam.bGroupActive)
552  rn = false;
553 
555 
556  PutData(aParam);
557 }
558 
560  const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns,
561  sal_Int32 nGroupColumn )
562 {
563  SolarMutexGuard aGuard;
564  ScSubTotalParam aParam;
565  GetData(aParam);
566 
567  sal_uInt16 nPos = 0;
568  while ( nPos < MAXSUBTOTAL && aParam.bGroupActive[nPos] )
569  ++nPos;
570 
571  sal_uInt32 nColCount = aSubTotalColumns.getLength();
572 
573  if ( nPos >= MAXSUBTOTAL || nColCount > sal::static_int_cast<sal_uInt32>(SCCOL_MAX) )
574  // too many fields / columns
575  throw uno::RuntimeException(); // no other exceptions specified
576 
577  aParam.bGroupActive[nPos] = true;
578  aParam.nField[nPos] = static_cast<SCCOL>(nGroupColumn);
579 
580  delete aParam.pSubTotals[nPos];
581  delete aParam.pFunctions[nPos];
582 
583  SCCOL nCount = static_cast<SCCOL>(nColCount);
584  aParam.nSubTotals[nPos] = nCount;
585  if (nCount != 0)
586  {
587  aParam.pSubTotals[nPos] = new SCCOL[nCount];
588  aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
589 
590  const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
591  for (SCCOL i=0; i<nCount; i++)
592  {
593  aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
594  aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc(static_cast<ScGeneralFunction>(pAry[i].Function));
595  }
596  }
597  else
598  {
599  aParam.pSubTotals[nPos] = nullptr;
600  aParam.pFunctions[nPos] = nullptr;
601  }
602 
603  PutData(aParam);
604 }
605 
606 // flags/settings as properties
607 
608 // XEnumerationAccess
609 
610 uno::Reference<container::XEnumeration> SAL_CALL ScSubTotalDescriptorBase::createEnumeration()
611 {
612  SolarMutexGuard aGuard;
613  return new ScIndexEnumeration(this, "com.sun.star.sheet.SubTotalFieldsEnumeration");
614 }
615 
616 // XIndexAccess
617 
619 {
620  SolarMutexGuard aGuard;
621  ScSubTotalParam aParam;
622  GetData(aParam);
623 
624  sal_uInt16 nCount = 0;
625  while ( nCount < MAXSUBTOTAL && aParam.bGroupActive[nCount] )
626  ++nCount;
627  return nCount;
628 }
629 
630 uno::Any SAL_CALL ScSubTotalDescriptorBase::getByIndex( sal_Int32 nIndex )
631 {
632  SolarMutexGuard aGuard;
633  uno::Reference<sheet::XSubTotalField> xField(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex)));
634  if (!xField.is())
635  throw lang::IndexOutOfBoundsException();
636 
637  return uno::makeAny(xField);
638 }
639 
641 {
642  SolarMutexGuard aGuard;
644 }
645 
647 {
648  SolarMutexGuard aGuard;
649  return ( getCount() != 0 );
650 }
651 
652 // XPropertySet
653 
654 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSubTotalDescriptorBase::getPropertySetInfo()
655 {
656  SolarMutexGuard aGuard;
657  static uno::Reference<beans::XPropertySetInfo> aRef(
659  return aRef;
660 }
661 
663  const OUString& aPropertyName, const uno::Any& aValue )
664 {
665  SolarMutexGuard aGuard;
666  ScSubTotalParam aParam;
667  GetData(aParam);
668 
669  // some old property names are for 5.2 compatibility
670 
671  if (aPropertyName == SC_UNONAME_CASE || aPropertyName == SC_UNONAME_ISCASE )
673  else if (aPropertyName == SC_UNONAME_FORMATS || aPropertyName == SC_UNONAME_BINDFMT )
675  else if (aPropertyName == SC_UNONAME_ENABSORT )
676  aParam.bDoSort = ScUnoHelpFunctions::GetBoolFromAny( aValue );
677  else if (aPropertyName == SC_UNONAME_SORTASC )
679  else if (aPropertyName == SC_UNONAME_INSBRK )
681  else if (aPropertyName == SC_UNONAME_ULIST || aPropertyName == SC_UNONAME_ENUSLIST )
682  aParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( aValue );
683  else if (aPropertyName == SC_UNONAME_UINDEX || aPropertyName == SC_UNONAME_USINDEX )
684  {
685  sal_Int32 nVal = 0;
686  if ( aValue >>= nVal )
687  aParam.nUserIndex = static_cast<sal_uInt16>(nVal);
688  }
689  else if (aPropertyName == SC_UNONAME_MAXFLD )
690  {
691  sal_Int32 nVal = 0;
692  if ( (aValue >>= nVal) && nVal > sal::static_int_cast<sal_Int32>(MAXSUBTOTAL) )
693  {
694  throw lang::IllegalArgumentException();
695  }
696  }
697 
698  PutData(aParam);
699 }
700 
701 uno::Any SAL_CALL ScSubTotalDescriptorBase::getPropertyValue( const OUString& aPropertyName )
702 {
703  SolarMutexGuard aGuard;
704  ScSubTotalParam aParam;
705  GetData(aParam);
706 
707  uno::Any aRet;
708 
709  // some old property names are for 5.2 compatibility
710 
711  if (aPropertyName == SC_UNONAME_CASE || aPropertyName == SC_UNONAME_ISCASE )
712  aRet <<= aParam.bCaseSens;
713  else if (aPropertyName == SC_UNONAME_FORMATS || aPropertyName == SC_UNONAME_BINDFMT )
714  aRet <<= aParam.bIncludePattern;
715  else if (aPropertyName == SC_UNONAME_ENABSORT )
716  aRet <<= aParam.bDoSort;
717  else if (aPropertyName == SC_UNONAME_SORTASC )
718  aRet <<= aParam.bAscending;
719  else if (aPropertyName == SC_UNONAME_INSBRK )
720  aRet <<= aParam.bPagebreak;
721  else if (aPropertyName == SC_UNONAME_ULIST || aPropertyName == SC_UNONAME_ENUSLIST )
722  aRet <<= aParam.bUserDef;
723  else if (aPropertyName == SC_UNONAME_UINDEX || aPropertyName == SC_UNONAME_USINDEX )
724  aRet <<= static_cast<sal_Int32>(aParam.nUserIndex);
725  else if (aPropertyName == SC_UNONAME_MAXFLD )
726  aRet <<= sal_Int32(MAXSUBTOTAL);
727 
728  return aRet;
729 }
730 
732 
733 // XUnoTunnel
734 
736 
738 {
739 }
740 
742 {
743 }
744 
746 {
747  rParam = aStoredParam; // query for interface
748 }
749 
751 {
752  aStoredParam = rParam; // set by the interface
753 }
754 
756 {
757  aStoredParam = rNew; // set from outside
758 }
759 
761  mxParent(pPar)
762 {
763 }
764 
766 {
767 }
768 
770 {
771  if (mxParent.is())
772  mxParent->GetSubTotalParam( rParam );
773 }
774 
776 {
777  if (mxParent.is())
778  mxParent->SetSubTotalParam( rParam );
779 }
780 
782 {
783 }
784 
786 {
787 }
788 
790 {
791  aParam = rNew;
792 }
793 
794 // XConsolidationDescriptor
795 
796 sheet::GeneralFunction SAL_CALL ScConsolidationDescriptor::getFunction()
797 {
798  SolarMutexGuard aGuard;
800 }
801 
802 void SAL_CALL ScConsolidationDescriptor::setFunction( sheet::GeneralFunction nFunction )
803 {
804  SolarMutexGuard aGuard;
805  aParam.eFunction = ScDPUtil::toSubTotalFunc(static_cast<ScGeneralFunction>(nFunction));
806 }
807 
808 uno::Sequence<table::CellRangeAddress> SAL_CALL ScConsolidationDescriptor::getSources()
809 {
810  SolarMutexGuard aGuard;
811  sal_uInt16 nCount = aParam.nDataAreaCount;
812  if (!aParam.pDataAreas)
813  nCount = 0;
814  table::CellRangeAddress aRange;
815  uno::Sequence<table::CellRangeAddress> aSeq(nCount);
816  table::CellRangeAddress* pAry = aSeq.getArray();
817  for (sal_uInt16 i=0; i<nCount; i++)
818  {
819  ScArea const & rArea = aParam.pDataAreas[i];
820  aRange.Sheet = rArea.nTab;
821  aRange.StartColumn = rArea.nColStart;
822  aRange.StartRow = rArea.nRowStart;
823  aRange.EndColumn = rArea.nColEnd;
824  aRange.EndRow = rArea.nRowEnd;
825  pAry[i] = aRange;
826  }
827  return aSeq;
828 }
829 
831  const uno::Sequence<table::CellRangeAddress>& aSources )
832 {
833  SolarMutexGuard aGuard;
834  sal_uInt16 nCount = static_cast<sal_uInt16>(aSources.getLength());
835  if (nCount)
836  {
837  const table::CellRangeAddress* pAry = aSources.getConstArray();
838  std::unique_ptr<ScArea[]> pNew(new ScArea[nCount]);
839  sal_uInt16 i;
840  for (i=0; i<nCount; i++)
841  pNew[i] = ScArea( pAry[i].Sheet,
842  static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow,
843  static_cast<SCCOL>(pAry[i].EndColumn), pAry[i].EndRow );
844 
845  aParam.SetAreas( std::move(pNew), nCount ); // copy everything
846  }
847  else
849 }
850 
852 {
853  SolarMutexGuard aGuard;
854  table::CellAddress aPos;
855  aPos.Column = aParam.nCol;
856  aPos.Row = aParam.nRow;
857  aPos.Sheet = aParam.nTab;
858  return aPos;
859 }
860 
862  const table::CellAddress& aStartOutputPosition )
863 {
864  SolarMutexGuard aGuard;
865  aParam.nCol = static_cast<SCCOL>(aStartOutputPosition.Column);
866  aParam.nRow = static_cast<SCROW>(aStartOutputPosition.Row);
867  aParam.nTab = aStartOutputPosition.Sheet;
868 }
869 
871 {
872  SolarMutexGuard aGuard;
873  return aParam.bByCol;
874 }
875 
877 {
878  SolarMutexGuard aGuard;
879  aParam.bByCol = bUseColumnHeaders;
880 }
881 
883 {
884  SolarMutexGuard aGuard;
885  return aParam.bByRow;
886 }
887 
889 {
890  SolarMutexGuard aGuard;
891  aParam.bByRow = bUseRowHeaders;
892 }
893 
895 {
896  SolarMutexGuard aGuard;
897  return aParam.bReferenceData;
898 }
899 
901 {
902  SolarMutexGuard aGuard;
903  aParam.bReferenceData = bInsertLinks;
904 }
905 
907  aPropSet( lcl_GetFilterPropertyMap() ),
908  pDocSh(pDocShell)
909 {
910  if (pDocSh)
911  pDocSh->GetDocument().AddUnoObject(*this);
912 }
913 
915 {
916  SolarMutexGuard g;
917 
918  if (pDocSh)
920 }
921 
923 {
924  if ( rHint.GetId() == SfxHintId::Dying )
925  {
926  pDocSh = nullptr; // invalid
927  }
928 }
929 
930 // XSheetFilterDescriptor and XSheetFilterDescriptor2
931 
932 uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilterFields()
933 {
934  SolarMutexGuard aGuard;
935  ScQueryParam aParam;
936  GetData(aParam);
937 
938  SCSIZE nEntries = aParam.GetEntryCount(); // allocated entries in Param
939  SCSIZE nCount = 0; // active
940  while ( nCount < nEntries &&
941  aParam.GetEntry(nCount).bDoQuery )
942  ++nCount;
943 
944  sheet::TableFilterField aField;
945  uno::Sequence<sheet::TableFilterField> aSeq(static_cast<sal_Int32>(nCount));
946  sheet::TableFilterField* pAry = aSeq.getArray();
947  for (SCSIZE i=0; i<nCount; i++)
948  {
949  const ScQueryEntry& rEntry = aParam.GetEntry(i);
950  if (rEntry.GetQueryItems().empty())
951  continue;
952 
953  const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
954 
955  aField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND :
956  sheet::FilterConnection_OR;
957  aField.Field = rEntry.nField;
958  aField.IsNumeric = rItem.meType != ScQueryEntry::ByString;
959  aField.StringValue = rItem.maString.getString();
960  aField.NumericValue = rItem.mfVal;
961 
962  switch (rEntry.eOp) // ScQueryOp
963  {
964  case SC_EQUAL:
965  {
966  aField.Operator = sheet::FilterOperator_EQUAL;
967  if (rEntry.IsQueryByEmpty())
968  {
969  aField.Operator = sheet::FilterOperator_EMPTY;
970  aField.NumericValue = 0;
971  }
972  else if (rEntry.IsQueryByNonEmpty())
973  {
974  aField.Operator = sheet::FilterOperator_NOT_EMPTY;
975  aField.NumericValue = 0;
976  }
977  }
978  break;
979  case SC_LESS: aField.Operator = sheet::FilterOperator_LESS; break;
980  case SC_GREATER: aField.Operator = sheet::FilterOperator_GREATER; break;
981  case SC_LESS_EQUAL: aField.Operator = sheet::FilterOperator_LESS_EQUAL; break;
982  case SC_GREATER_EQUAL: aField.Operator = sheet::FilterOperator_GREATER_EQUAL; break;
983  case SC_NOT_EQUAL: aField.Operator = sheet::FilterOperator_NOT_EQUAL; break;
984  case SC_TOPVAL: aField.Operator = sheet::FilterOperator_TOP_VALUES; break;
985  case SC_BOTVAL: aField.Operator = sheet::FilterOperator_BOTTOM_VALUES; break;
986  case SC_TOPPERC: aField.Operator = sheet::FilterOperator_TOP_PERCENT; break;
987  case SC_BOTPERC: aField.Operator = sheet::FilterOperator_BOTTOM_PERCENT; break;
988  default:
989  OSL_FAIL("wrong filter enum");
990  aField.Operator = sheet::FilterOperator_EMPTY;
991  }
992  pAry[i] = aField;
993  }
994  return aSeq;
995 }
996 
997 namespace {
998 
999 template<typename T>
1000 void convertQueryEntryToUno(const ScQueryEntry& rEntry, T& rField)
1001 {
1002  rField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND : sheet::FilterConnection_OR;
1003  rField.Field = rEntry.nField;
1004 
1005  switch (rEntry.eOp) // ScQueryOp
1006  {
1007  case SC_EQUAL: rField.Operator = sheet::FilterOperator2::EQUAL; break;
1008  case SC_LESS: rField.Operator = sheet::FilterOperator2::LESS; break;
1009  case SC_GREATER: rField.Operator = sheet::FilterOperator2::GREATER; break;
1010  case SC_LESS_EQUAL: rField.Operator = sheet::FilterOperator2::LESS_EQUAL; break;
1011  case SC_GREATER_EQUAL: rField.Operator = sheet::FilterOperator2::GREATER_EQUAL; break;
1012  case SC_NOT_EQUAL: rField.Operator = sheet::FilterOperator2::NOT_EQUAL; break;
1013  case SC_TOPVAL: rField.Operator = sheet::FilterOperator2::TOP_VALUES; break;
1014  case SC_BOTVAL: rField.Operator = sheet::FilterOperator2::BOTTOM_VALUES; break;
1015  case SC_TOPPERC: rField.Operator = sheet::FilterOperator2::TOP_PERCENT; break;
1016  case SC_BOTPERC: rField.Operator = sheet::FilterOperator2::BOTTOM_PERCENT; break;
1017  case SC_CONTAINS: rField.Operator = sheet::FilterOperator2::CONTAINS; break;
1018  case SC_DOES_NOT_CONTAIN: rField.Operator = sheet::FilterOperator2::DOES_NOT_CONTAIN; break;
1019  case SC_BEGINS_WITH: rField.Operator = sheet::FilterOperator2::BEGINS_WITH; break;
1020  case SC_DOES_NOT_BEGIN_WITH: rField.Operator = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH; break;
1021  case SC_ENDS_WITH: rField.Operator = sheet::FilterOperator2::ENDS_WITH; break;
1022  case SC_DOES_NOT_END_WITH: rField.Operator = sheet::FilterOperator2::DOES_NOT_END_WITH; break;
1023  default:
1024  OSL_FAIL("Unknown filter operator value.");
1025  rField.Operator = sheet::FilterOperator2::EMPTY;
1026  }
1027 }
1028 
1029 template<typename T>
1030 void convertUnoToQueryEntry(const T& rField, ScQueryEntry& rEntry)
1031 {
1032  rEntry.bDoQuery = true;
1033  rEntry.eConnect = (rField.Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
1034  rEntry.nField = rField.Field;
1035 
1036  switch (rField.Operator) // FilterOperator
1037  {
1038  case sheet::FilterOperator2::EQUAL: rEntry.eOp = SC_EQUAL; break;
1039  case sheet::FilterOperator2::LESS: rEntry.eOp = SC_LESS; break;
1040  case sheet::FilterOperator2::GREATER: rEntry.eOp = SC_GREATER; break;
1041  case sheet::FilterOperator2::LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break;
1042  case sheet::FilterOperator2::GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break;
1043  case sheet::FilterOperator2::NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break;
1044  case sheet::FilterOperator2::TOP_VALUES: rEntry.eOp = SC_TOPVAL; break;
1045  case sheet::FilterOperator2::BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break;
1046  case sheet::FilterOperator2::TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break;
1047  case sheet::FilterOperator2::BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break;
1048  case sheet::FilterOperator2::CONTAINS: rEntry.eOp = SC_CONTAINS; break;
1049  case sheet::FilterOperator2::DOES_NOT_CONTAIN: rEntry.eOp = SC_DOES_NOT_CONTAIN; break;
1050  case sheet::FilterOperator2::BEGINS_WITH: rEntry.eOp = SC_BEGINS_WITH; break;
1051  case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH: rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break;
1052  case sheet::FilterOperator2::ENDS_WITH: rEntry.eOp = SC_ENDS_WITH; break;
1053  case sheet::FilterOperator2::DOES_NOT_END_WITH: rEntry.eOp = SC_DOES_NOT_END_WITH; break;
1054  case sheet::FilterOperator2::EMPTY:
1055  rEntry.SetQueryByEmpty();
1056  break;
1057  case sheet::FilterOperator2::NOT_EMPTY:
1058  rEntry.SetQueryByNonEmpty();
1059  break;
1060  default:
1061  OSL_FAIL("Unknown filter operator type.");
1062  rEntry.eOp = SC_EQUAL;
1063  }
1064 }
1065 
1066 void fillQueryParam(
1067  ScQueryParam& rParam, ScDocument* pDoc,
1068  const uno::Sequence<sheet::TableFilterField2>& aFilterFields)
1069 {
1070  size_t nCount = static_cast<size_t>(aFilterFields.getLength());
1071  rParam.Resize(nCount);
1072 
1073  const sheet::TableFilterField2* pAry = aFilterFields.getConstArray();
1074  svl::SharedStringPool& rPool = pDoc->GetSharedStringPool();
1075  for (size_t i = 0; i < nCount; ++i)
1076  {
1077  ScQueryEntry& rEntry = rParam.GetEntry(i);
1078  convertUnoToQueryEntry(pAry[i], rEntry);
1079 
1080  if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY)
1081  {
1082  ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
1083  rItems.resize(1);
1084  ScQueryEntry::Item& rItem = rItems.front();
1085  rItem.meType = pAry[i].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
1086  rItem.mfVal = pAry[i].NumericValue;
1087  rItem.maString = rPool.intern(pAry[i].StringValue);
1088 
1089  if (rItem.meType == ScQueryEntry::ByValue)
1090  {
1091  OUString aStr;
1092  pDoc->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
1093  rItem.maString = rPool.intern(aStr);
1094  }
1095  }
1096  }
1097 
1098  size_t nParamCount = rParam.GetEntryCount(); // if below eight Param isn't resized
1099  for (size_t i = nCount; i < nParamCount; ++i)
1100  rParam.GetEntry(i).bDoQuery = false; // reset surplus fields
1101 }
1102 
1103 void fillQueryParam(
1104  ScQueryParam& rParam, ScDocument* pDoc,
1105  const uno::Sequence<sheet::TableFilterField3>& aFilterFields)
1106 {
1107  size_t nCount = static_cast<size_t>(aFilterFields.getLength());
1108  rParam.Resize(nCount);
1109 
1110  svl::SharedStringPool& rPool = pDoc->GetSharedStringPool();
1111  const sheet::TableFilterField3* pAry = aFilterFields.getConstArray();
1112  for (size_t i = 0; i < nCount; ++i)
1113  {
1114  ScQueryEntry& rEntry = rParam.GetEntry(i);
1115  convertUnoToQueryEntry(pAry[i], rEntry);
1116 
1117  if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY)
1118  {
1119  ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
1120  rItems.clear();
1121  const uno::Sequence<sheet::FilterFieldValue>& rVals = pAry[i].Values;
1122  for (const auto& rVal : rVals)
1123  {
1124  ScQueryEntry::Item aItem;
1125  aItem.meType = rVal.IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
1126  aItem.mfVal = rVal.NumericValue;
1127  aItem.maString = rPool.intern(rVal.StringValue);
1128 
1129  if (aItem.meType == ScQueryEntry::ByValue)
1130  {
1131  OUString aStr;
1132  pDoc->GetFormatTable()->GetInputLineString(aItem.mfVal, 0, aStr);
1133  aItem.maString = rPool.intern(aStr);
1134  }
1135 
1136  rItems.push_back(aItem);
1137  }
1138  }
1139  }
1140 
1141  size_t nParamCount = rParam.GetEntryCount(); // if below eight Param isn't resized
1142  for (size_t i = nCount; i < nParamCount; ++i)
1143  rParam.GetEntry(i).bDoQuery = false; // reset surplus fields
1144 }
1145 
1146 }
1147 
1148 uno::Sequence<sheet::TableFilterField2> SAL_CALL ScFilterDescriptorBase::getFilterFields2()
1149 {
1150  SolarMutexGuard aGuard;
1151  ScQueryParam aParam;
1152  GetData(aParam);
1153 
1154  SCSIZE nEntries = aParam.GetEntryCount(); // allocated entries in Param
1155  SCSIZE nCount = 0; // active
1156  while ( nCount < nEntries &&
1157  aParam.GetEntry(nCount).bDoQuery )
1158  ++nCount;
1159 
1160  sheet::TableFilterField2 aField;
1161  uno::Sequence<sheet::TableFilterField2> aSeq(static_cast<sal_Int32>(nCount));
1162  sheet::TableFilterField2* pAry = aSeq.getArray();
1163  for (SCSIZE i=0; i<nCount; i++)
1164  {
1165  const ScQueryEntry& rEntry = aParam.GetEntry(i);
1166  convertQueryEntryToUno(rEntry, aField);
1167 
1168  bool bByEmpty = false;
1169  if (aField.Operator == sheet::FilterOperator2::EQUAL)
1170  {
1171  if (rEntry.IsQueryByEmpty())
1172  {
1173  aField.Operator = sheet::FilterOperator2::EMPTY;
1174  aField.NumericValue = 0;
1175  bByEmpty = true;
1176  }
1177  else if (rEntry.IsQueryByNonEmpty())
1178  {
1179  aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
1180  aField.NumericValue = 0;
1181  bByEmpty = true;
1182  }
1183  }
1184 
1185  if (!bByEmpty && !rEntry.GetQueryItems().empty())
1186  {
1187  const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
1188  aField.IsNumeric = rItem.meType != ScQueryEntry::ByString;
1189  aField.StringValue = rItem.maString.getString();
1190  aField.NumericValue = rItem.mfVal;
1191  }
1192 
1193  pAry[i] = aField;
1194  }
1195  return aSeq;
1196 }
1197 
1198 uno::Sequence<sheet::TableFilterField3> SAL_CALL ScFilterDescriptorBase::getFilterFields3()
1199 {
1200  SolarMutexGuard aGuard;
1201  ScQueryParam aParam;
1202  GetData(aParam);
1203 
1204  SCSIZE nEntries = aParam.GetEntryCount(); // allocated entries in Param
1205  SCSIZE nCount = 0; // active
1206  while ( nCount < nEntries &&
1207  aParam.GetEntry(nCount).bDoQuery )
1208  ++nCount;
1209 
1210  sheet::TableFilterField3 aField;
1211  uno::Sequence<sheet::TableFilterField3> aSeq(static_cast<sal_Int32>(nCount));
1212  sheet::TableFilterField3* pAry = aSeq.getArray();
1213  for (SCSIZE i = 0; i < nCount; ++i)
1214  {
1215  const ScQueryEntry& rEntry = aParam.GetEntry(i);
1216  convertQueryEntryToUno(rEntry, aField);
1217 
1218  bool bByEmpty = false;
1219  if (aField.Operator == sheet::FilterOperator2::EQUAL)
1220  {
1221  if (rEntry.IsQueryByEmpty())
1222  {
1223  aField.Operator = sheet::FilterOperator2::EMPTY;
1224  aField.Values.realloc(1);
1225  aField.Values[0].NumericValue = 0;
1226  bByEmpty = true;
1227  }
1228  else if (rEntry.IsQueryByNonEmpty())
1229  {
1230  aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
1231  aField.Values.realloc(1);
1232  aField.Values[0].NumericValue = 0;
1233  bByEmpty = true;
1234  }
1235  }
1236 
1237  if (!bByEmpty)
1238  {
1239  const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
1240  size_t nItemCount = rItems.size();
1241  aField.Values.realloc(nItemCount);
1242  size_t j = 0;
1243  for (const auto& rItem : rItems)
1244  {
1245  aField.Values[j].IsNumeric = rItem.meType != ScQueryEntry::ByString;
1246  aField.Values[j].StringValue = rItem.maString.getString();
1247  aField.Values[j].NumericValue = rItem.mfVal;
1248  ++j;
1249  }
1250  }
1251 
1252  pAry[i] = aField;
1253  }
1254  return aSeq;
1255 }
1256 
1258  const uno::Sequence<sheet::TableFilterField>& aFilterFields )
1259 {
1260  SolarMutexGuard aGuard;
1261  ScQueryParam aParam;
1262  GetData(aParam);
1263 
1264  SCSIZE nCount = static_cast<SCSIZE>(aFilterFields.getLength());
1265  aParam.Resize( nCount );
1266 
1267  ScDocument& rDoc = pDocSh->GetDocument();
1269  const sheet::TableFilterField* pAry = aFilterFields.getConstArray();
1270  SCSIZE i;
1271  for (i=0; i<nCount; i++)
1272  {
1273  ScQueryEntry& rEntry = aParam.GetEntry(i);
1274  ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
1275  rItems.resize(1);
1276  ScQueryEntry::Item& rItem = rItems.front();
1277  rEntry.bDoQuery = true;
1278  rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
1279  rEntry.nField = pAry[i].Field;
1280  rItem.meType = pAry[i].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
1281  rItem.mfVal = pAry[i].NumericValue;
1282  rItem.maString = rPool.intern(pAry[i].StringValue);
1283 
1284  if (rItem.meType != ScQueryEntry::ByString)
1285  {
1286  OUString aStr;
1287  rDoc.GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
1288  rItem.maString = rPool.intern(aStr);
1289  }
1290 
1291  switch (pAry[i].Operator) // FilterOperator
1292  {
1293  case sheet::FilterOperator_EQUAL: rEntry.eOp = SC_EQUAL; break;
1294  case sheet::FilterOperator_LESS: rEntry.eOp = SC_LESS; break;
1295  case sheet::FilterOperator_GREATER: rEntry.eOp = SC_GREATER; break;
1296  case sheet::FilterOperator_LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break;
1297  case sheet::FilterOperator_GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break;
1298  case sheet::FilterOperator_NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break;
1299  case sheet::FilterOperator_TOP_VALUES: rEntry.eOp = SC_TOPVAL; break;
1300  case sheet::FilterOperator_BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break;
1301  case sheet::FilterOperator_TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break;
1302  case sheet::FilterOperator_BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break;
1303  case sheet::FilterOperator_EMPTY:
1304  rEntry.SetQueryByEmpty();
1305  break;
1306  case sheet::FilterOperator_NOT_EMPTY:
1307  rEntry.SetQueryByNonEmpty();
1308  break;
1309  default:
1310  OSL_FAIL("Wrong query enum");
1311  rEntry.eOp = SC_EQUAL;
1312  }
1313  }
1314 
1315  SCSIZE nParamCount = aParam.GetEntryCount(); // if below eight Param isn't resized
1316  for (i=nCount; i<nParamCount; i++)
1317  aParam.GetEntry(i).bDoQuery = false; // reset surplus fields
1318 
1319  PutData(aParam);
1320 }
1321 
1323  const uno::Sequence<sheet::TableFilterField2>& aFilterFields )
1324 {
1325  SolarMutexGuard aGuard;
1326  ScQueryParam aParam;
1327  GetData(aParam);
1328  fillQueryParam(aParam, &pDocSh->GetDocument(), aFilterFields);
1329  PutData(aParam);
1330 }
1331 
1333  const uno::Sequence<sheet::TableFilterField3>& aFilterFields )
1334 {
1335  SolarMutexGuard aGuard;
1336  ScQueryParam aParam;
1337  GetData(aParam);
1338  fillQueryParam(aParam, &pDocSh->GetDocument(), aFilterFields);
1339  PutData(aParam);
1340 }
1341 
1342 // Rest sind Properties
1343 
1344 // XPropertySet
1345 
1346 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFilterDescriptorBase::getPropertySetInfo()
1347 {
1348  SolarMutexGuard aGuard;
1349  static uno::Reference<beans::XPropertySetInfo> aRef(
1351  return aRef;
1352 }
1353 
1355  const OUString& aPropertyName, const uno::Any& aValue )
1356 {
1357  SolarMutexGuard aGuard;
1358  ScQueryParam aParam;
1359  GetData(aParam);
1360 
1361  if (aPropertyName == SC_UNONAME_CONTHDR)
1363  else if (aPropertyName == SC_UNONAME_COPYOUT)
1364  aParam.bInplace = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1365  else if (aPropertyName == SC_UNONAME_ISCASE)
1366  aParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1367  else if (aPropertyName == SC_UNONAME_MAXFLD)
1368  {
1369  // silently ignored
1370  }
1371  else if (aPropertyName == SC_UNONAME_ORIENT)
1372  {
1374  table::TableOrientation eOrient = static_cast<table::TableOrientation>(ScUnoHelpFunctions::GetEnumFromAny( aValue ));
1375  aParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
1376  }
1377  else if (aPropertyName == SC_UNONAME_OUTPOS)
1378  {
1379  table::CellAddress aAddress;
1380  if ( aValue >>= aAddress )
1381  {
1382  aParam.nDestTab = aAddress.Sheet;
1383  aParam.nDestCol = static_cast<SCCOL>(aAddress.Column);
1384  aParam.nDestRow = static_cast<SCROW>(aAddress.Row);
1385  }
1386  }
1387  else if (aPropertyName == SC_UNONAME_SAVEOUT)
1388  aParam.bDestPers = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1389  else if (aPropertyName == SC_UNONAME_SKIPDUP)
1390  aParam.bDuplicate = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1391  else if (aPropertyName == SC_UNONAME_USEREGEX)
1394 
1395  PutData(aParam);
1396 }
1397 
1398 uno::Any SAL_CALL ScFilterDescriptorBase::getPropertyValue( const OUString& aPropertyName )
1399 {
1400  SolarMutexGuard aGuard;
1401  ScQueryParam aParam;
1402  GetData(aParam);
1403 
1404  uno::Any aRet;
1405 
1406  if (aPropertyName == SC_UNONAME_CONTHDR )
1407  aRet <<= aParam.bHasHeader;
1408  else if (aPropertyName == SC_UNONAME_COPYOUT )
1409  aRet <<= !(aParam.bInplace);
1410  else if (aPropertyName == SC_UNONAME_ISCASE )
1411  aRet <<= aParam.bCaseSens;
1412  else if (aPropertyName == SC_UNONAME_MAXFLD )
1413  aRet <<= static_cast<sal_Int32>(aParam.GetEntryCount());
1414  else if (aPropertyName == SC_UNONAME_ORIENT )
1415  {
1416  table::TableOrientation eOrient = aParam.bByRow ? table::TableOrientation_ROWS :
1417  table::TableOrientation_COLUMNS;
1418  aRet <<= eOrient;
1419  }
1420  else if (aPropertyName == SC_UNONAME_OUTPOS )
1421  {
1422  table::CellAddress aOutPos;
1423  aOutPos.Sheet = aParam.nDestTab;
1424  aOutPos.Column = aParam.nDestCol;
1425  aOutPos.Row = aParam.nDestRow;
1426  aRet <<= aOutPos;
1427  }
1428  else if (aPropertyName == SC_UNONAME_SAVEOUT )
1429  aRet <<= aParam.bDestPers;
1430  else if (aPropertyName == SC_UNONAME_SKIPDUP )
1431  aRet <<= !(aParam.bDuplicate);
1432  else if (aPropertyName == SC_UNONAME_USEREGEX )
1434 
1435  return aRet;
1436 }
1437 
1439 
1441  :
1442  ScFilterDescriptorBase(pDocShell)
1443 {
1444 }
1445 
1447 {
1448 }
1449 
1451 {
1452  rParam = aStoredParam; // query for interface
1453 }
1454 
1456 {
1457  aStoredParam = rParam; // set by the interface
1458 }
1459 
1461 {
1462  aStoredParam = rNew; // set from outside
1463 }
1464 
1466  ScFilterDescriptorBase(pDocShell),
1467  mxParent(pPar)
1468 {
1469 }
1470 
1472 {
1473 }
1474 
1476 {
1477  if (mxParent.is())
1478  mxParent->GetQueryParam( rParam );
1479 }
1480 
1482 {
1483  if (mxParent.is())
1484  mxParent->SetQueryParam( rParam );
1485 }
1486 
1488  ScFilterDescriptorBase(pDocShell),
1489  mxParent(pPar)
1490 {
1491 }
1492 
1494 {
1495 }
1496 
1498 {
1499  if (mxParent.is())
1500  {
1501  ScDPObject* pDPObj = mxParent->GetDPObject();
1502  if (pDPObj && pDPObj->IsSheetData())
1503  rParam = pDPObj->GetSheetDesc()->GetQueryParam();
1504  }
1505 }
1506 
1508 {
1509  if (!mxParent.is())
1510  return;
1511 
1512  ScDPObject* pDPObj = mxParent->GetDPObject();
1513  if (pDPObj)
1514  {
1515  ScSheetSourceDesc aSheetDesc(&mxParent->GetDocShell()->GetDocument());
1516  if (pDPObj->IsSheetData())
1517  aSheetDesc = *pDPObj->GetSheetDesc();
1518  aSheetDesc.SetQueryParam(rParam);
1519  pDPObj->SetSheetDesc(aSheetDesc);
1520  mxParent->SetDPObject(pDPObj);
1521  }
1522 }
1523 
1525  pDocShell( pDocSh ),
1526  aName( rNm ),
1527  aPropSet( lcl_GetDBRangePropertyMap() ),
1528  bIsUnnamed(false),
1529  aTab( 0 )
1530 {
1532 }
1533 
1535  pDocShell( pDocSh ),
1537  aPropSet( lcl_GetDBRangePropertyMap() ),
1538  bIsUnnamed(true),
1539  aTab( nTab )
1540 {
1542 }
1543 
1545 {
1546  SolarMutexGuard g;
1547 
1548  if (pDocShell)
1550 }
1551 
1553 {
1554 
1555  if ( rHint.GetId() == SfxHintId::Dying )
1556  pDocShell = nullptr;
1557  else if ( auto pRefreshHint = dynamic_cast<const ScDBRangeRefreshedHint*>(&rHint) )
1558  {
1559  ScDBData* pDBData = GetDBData_Impl();
1560  ScImportParam aParam;
1561  pDBData->GetImportParam(aParam);
1562  if (aParam == pRefreshHint->GetImportParam())
1563  Refreshed_Impl();
1564  }
1565 }
1566 
1567 // Help functions
1568 
1570 {
1571  ScDBData* pRet = nullptr;
1572  if (pDocShell)
1573  {
1574  if (bIsUnnamed)
1575  {
1577  }
1578  else
1579  {
1581  if (pNames)
1582  {
1584  if (p)
1585  pRet = p;
1586  }
1587  }
1588  }
1589  return pRet;
1590 }
1591 
1592 // XNamed
1593 
1594 OUString SAL_CALL ScDatabaseRangeObj::getName()
1595 {
1596  SolarMutexGuard aGuard;
1597  return aName;
1598 }
1599 
1600 void SAL_CALL ScDatabaseRangeObj::setName( const OUString& aNewName )
1601 {
1602  SolarMutexGuard aGuard;
1603  if (pDocShell)
1604  {
1605  ScDBDocFunc aFunc(*pDocShell);
1606  bool bOk = aFunc.RenameDBRange( aName, aNewName );
1607  if (bOk)
1608  aName = aNewName;
1609  }
1610 }
1611 
1612 // XDatabaseRange
1613 
1614 table::CellRangeAddress SAL_CALL ScDatabaseRangeObj::getDataArea()
1615 {
1616  SolarMutexGuard aGuard;
1617  table::CellRangeAddress aAddress;
1619  if (pData)
1620  {
1621  ScRange aRange;
1622  pData->GetArea(aRange);
1623  aAddress.Sheet = aRange.aStart.Tab();
1624  aAddress.StartColumn = aRange.aStart.Col();
1625  aAddress.StartRow = aRange.aStart.Row();
1626  aAddress.EndColumn = aRange.aEnd.Col();
1627  aAddress.EndRow = aRange.aEnd.Row();
1628  }
1629  return aAddress;
1630 }
1631 
1632 void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aDataArea )
1633 {
1634  SolarMutexGuard aGuard;
1636  if ( pDocShell && pData )
1637  {
1638  ScDBData aNewData( *pData );
1640  aNewData.SetArea( aDataArea.Sheet, static_cast<SCCOL>(aDataArea.StartColumn), static_cast<SCROW>(aDataArea.StartRow),
1641  static_cast<SCCOL>(aDataArea.EndColumn), static_cast<SCROW>(aDataArea.EndRow) );
1642  ScDBDocFunc aFunc(*pDocShell);
1643  aFunc.ModifyDBData(aNewData);
1644  }
1645 }
1646 
1647 uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getSortDescriptor()
1648 {
1649  SolarMutexGuard aGuard;
1650  ScSortParam aParam;
1651  const ScDBData* pData = GetDBData_Impl();
1652  if (pData)
1653  {
1654  pData->GetSortParam(aParam);
1655 
1656  // SortDescriptor contains the counted fields inside the area
1657  ScRange aDBRange;
1658  pData->GetArea(aDBRange);
1659  SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1660  for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
1661  if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
1662  aParam.maKeyState[i].nField -= nFieldStart;
1663  }
1664 
1665  uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
1666  ScSortDescriptor::FillProperties( aSeq, aParam );
1667  return aSeq;
1668 }
1669 
1671 {
1672  const ScDBData* pData = GetDBData_Impl();
1673  if (!pData)
1674  return;
1675 
1676  pData->GetQueryParam(rQueryParam);
1677 
1678  // FilterDescriptor contains the counted fields inside the area
1679  ScRange aDBRange;
1680  pData->GetArea(aDBRange);
1681  SCCOLROW nFieldStart = rQueryParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1682  SCSIZE nCount = rQueryParam.GetEntryCount();
1683  for (SCSIZE i=0; i<nCount; i++)
1684  {
1685  ScQueryEntry& rEntry = rQueryParam.GetEntry(i);
1686  if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
1687  rEntry.nField -= nFieldStart;
1688  }
1689 }
1690 
1692 {
1693  const ScDBData* pData = GetDBData_Impl();
1694  if (!pData)
1695  return;
1696 
1697  // FilterDescriptor contains the counted fields inside the area
1698  ScQueryParam aParam(rQueryParam);
1699  ScRange aDBRange;
1700  pData->GetArea(aDBRange);
1701  SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1702 
1703  SCSIZE nCount = aParam.GetEntryCount();
1704  for (SCSIZE i=0; i<nCount; i++)
1705  {
1706  ScQueryEntry& rEntry = aParam.GetEntry(i);
1707  if (rEntry.bDoQuery)
1708  rEntry.nField += nFieldStart;
1709  }
1710 
1711  ScDBData aNewData( *pData );
1712  aNewData.SetQueryParam(aParam);
1713  aNewData.SetHeader(aParam.bHasHeader); // not in ScDBData::SetQueryParam
1714  ScDBDocFunc aFunc(*pDocShell);
1715  aFunc.ModifyDBData(aNewData);
1716 }
1717 
1718 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScDatabaseRangeObj::getFilterDescriptor()
1719 {
1720  SolarMutexGuard aGuard;
1721  return new ScRangeFilterDescriptor(pDocShell, this);
1722 }
1723 
1725 {
1726  const ScDBData* pData = GetDBData_Impl();
1727  if (!pData)
1728  return;
1729 
1730  pData->GetSubTotalParam(rSubTotalParam);
1731 
1732  // FilterDescriptor contains the counted fields inside the area
1733  ScRange aDBRange;
1734  pData->GetArea(aDBRange);
1735  SCCOL nFieldStart = aDBRange.aStart.Col();
1736  for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
1737  {
1738  if ( rSubTotalParam.bGroupActive[i] )
1739  {
1740  if ( rSubTotalParam.nField[i] >= nFieldStart )
1741  rSubTotalParam.nField[i] = sal::static_int_cast<SCCOL>( rSubTotalParam.nField[i] - nFieldStart );
1742  for (SCCOL j=0; j<rSubTotalParam.nSubTotals[i]; j++)
1743  if ( rSubTotalParam.pSubTotals[i][j] >= nFieldStart )
1744  rSubTotalParam.pSubTotals[i][j] =
1745  sal::static_int_cast<SCCOL>( rSubTotalParam.pSubTotals[i][j] - nFieldStart );
1746  }
1747  }
1748 }
1749 
1751 {
1752  const ScDBData* pData = GetDBData_Impl();
1753  if (!pData)
1754  return;
1755 
1756  // FilterDescriptor contains the counted fields inside the area
1757  ScSubTotalParam aParam(rSubTotalParam);
1758  ScRange aDBRange;
1759  pData->GetArea(aDBRange);
1760  SCCOL nFieldStart = aDBRange.aStart.Col();
1761  for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
1762  {
1763  if ( aParam.bGroupActive[i] )
1764  {
1765  aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
1766  for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
1767  aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
1768  }
1769  }
1770 
1771  ScDBData aNewData( *pData );
1772  aNewData.SetSubTotalParam(aParam);
1773  ScDBDocFunc aFunc(*pDocShell);
1774  aFunc.ModifyDBData(aNewData);
1775 }
1776 
1777 uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScDatabaseRangeObj::getSubTotalDescriptor()
1778 {
1779  SolarMutexGuard aGuard;
1780  return new ScRangeSubTotalDescriptor(this);
1781 }
1782 
1783 uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getImportDescriptor()
1784 {
1785  SolarMutexGuard aGuard;
1786  ScImportParam aParam;
1787  const ScDBData* pData = GetDBData_Impl();
1788  if (pData)
1789  pData->GetImportParam(aParam);
1790 
1791  uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
1792  ScImportDescriptor::FillProperties( aSeq, aParam );
1793  return aSeq;
1794 }
1795 
1796 // XRefreshable
1797 
1799 {
1800  SolarMutexGuard aGuard;
1802  if ( !(pDocShell && pData) )
1803  return;
1804 
1805  ScDBDocFunc aFunc(*pDocShell);
1806 
1807  // repeat import?
1808  bool bContinue = true;
1809  ScImportParam aImportParam;
1810  pData->GetImportParam( aImportParam );
1811  if (aImportParam.bImport && !pData->HasImportSelection())
1812  {
1813  SCTAB nTab;
1814  SCCOL nDummyCol;
1815  SCROW nDummyRow;
1816  pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow );
1817  bContinue = aFunc.DoImport( nTab, aImportParam, nullptr );
1818  }
1819 
1820  // if no error then internal operations (sort, query, subtotal)
1821  if (bContinue)
1822  aFunc.RepeatDB( pData->GetName(), true, bIsUnnamed, aTab );
1823 }
1824 
1826  const uno::Reference<util::XRefreshListener >& xListener )
1827 {
1828  SolarMutexGuard aGuard;
1829  aRefreshListeners.emplace_back( xListener );
1830 
1831  // hold one additional ref to keep this object alive as long as there are listeners
1832  if ( aRefreshListeners.size() == 1 )
1833  acquire();
1834 }
1835 
1837  const uno::Reference<util::XRefreshListener >& xListener )
1838 {
1839  SolarMutexGuard aGuard;
1840  sal_uInt16 nCount = aRefreshListeners.size();
1841  for ( sal_uInt16 n=nCount; n--; )
1842  {
1843  uno::Reference<util::XRefreshListener>& rObj = aRefreshListeners[n];
1844  if ( rObj == xListener )
1845  {
1846  aRefreshListeners.erase( aRefreshListeners.begin() + n );
1847  if ( aRefreshListeners.empty() )
1848  release(); // release ref for listeners
1849  break;
1850  }
1851  }
1852 }
1853 
1855 {
1856  lang::EventObject aEvent;
1857  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1858  for (uno::Reference<util::XRefreshListener> & xRefreshListener : aRefreshListeners)
1859  xRefreshListener->refreshed( aEvent );
1860 }
1861 
1862 // XCellRangeSource
1863 
1864 uno::Reference<table::XCellRange> SAL_CALL ScDatabaseRangeObj::getReferredCells()
1865 {
1866  SolarMutexGuard aGuard;
1868  if ( pData )
1869  {
1871  ScRange aRange;
1872 
1873  pData->GetArea(aRange);
1874  if ( aRange.aStart == aRange.aEnd )
1875  return new ScCellObj( pDocShell, aRange.aStart );
1876  else
1877  return new ScCellRangeObj( pDocShell, aRange );
1878  }
1879  return nullptr;
1880 }
1881 
1882 // XPropertySet
1883 
1884 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDatabaseRangeObj::getPropertySetInfo()
1885 {
1886  SolarMutexGuard aGuard;
1887  static uno::Reference<beans::XPropertySetInfo> aRef(
1889  return aRef;
1890 }
1891 
1893  const OUString& aPropertyName, const uno::Any& aValue )
1894 {
1895  SolarMutexGuard aGuard;
1897  if ( !(pDocShell && pData) )
1898  return;
1899 
1900  ScDBData aNewData( *pData );
1901  bool bDo = true;
1902 
1903  if ( aPropertyName == SC_UNONAME_KEEPFORM )
1904  aNewData.SetKeepFmt( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1905  else if ( aPropertyName == SC_UNONAME_MOVCELLS )
1906  aNewData.SetDoSize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1907  else if ( aPropertyName == SC_UNONAME_STRIPDAT )
1908  aNewData.SetStripData( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1909  else if (aPropertyName == SC_UNONAME_AUTOFLT )
1910  {
1911  bool bAutoFilter(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1912  aNewData.SetAutoFilter(bAutoFilter);
1913  ScRange aRange;
1914  aNewData.GetArea(aRange);
1915  ScDocument& rDoc = pDocShell->GetDocument();
1916  if (bAutoFilter)
1917  rDoc.ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
1918  aRange.aEnd.Col(), aRange.aStart.Row(),
1919  aRange.aStart.Tab(), ScMF::Auto );
1920  else if (!bAutoFilter)
1921  rDoc.RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(),
1922  aRange.aEnd.Col(), aRange.aStart.Row(),
1923  aRange.aStart.Tab(), ScMF::Auto );
1924  ScRange aPaintRange(aRange.aStart, aRange.aEnd);
1925  aPaintRange.aEnd.SetRow(aPaintRange.aStart.Row());
1926  pDocShell->PostPaint(aPaintRange, PaintPartFlags::Grid);
1927  }
1928  else if (aPropertyName == SC_UNONAME_USEFLTCRT )
1929  {
1930  if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
1931  {
1932  // only here to set bIsAdvanced in ScDBData
1933  ScRange aRange;
1934  (void)aNewData.GetAdvancedQuerySource(aRange);
1935  aNewData.SetAdvancedQuerySource(&aRange);
1936  }
1937  else
1938  aNewData.SetAdvancedQuerySource(nullptr);
1939  }
1940  else if (aPropertyName == SC_UNONAME_FLTCRT )
1941  {
1942  table::CellRangeAddress aRange;
1943  if (aValue >>= aRange)
1944  {
1945  ScRange aCoreRange;
1946  ScUnoConversion::FillScRange(aCoreRange, aRange);
1947 
1948  aNewData.SetAdvancedQuerySource(&aCoreRange);
1949  }
1950  }
1951  else if (aPropertyName == SC_UNONAME_FROMSELECT )
1952  {
1953  aNewData.SetImportSelection(::cppu::any2bool(aValue));
1954  }
1955  else if (aPropertyName == SC_UNONAME_REFPERIOD )
1956  {
1957  sal_Int32 nRefresh = 0;
1958  if (aValue >>= nRefresh)
1959  {
1960  ScDocument& rDoc = pDocShell->GetDocument();
1961  aNewData.SetRefreshDelay(nRefresh);
1962  if (rDoc.GetDBCollection())
1963  {
1964  aNewData.SetRefreshHandler( rDoc.GetDBCollection()->GetRefreshHandler() );
1966  }
1967  }
1968  }
1969  else if (aPropertyName == SC_UNONAME_CONRES )
1970  {
1971  }
1972  else if ( aPropertyName == SC_UNONAME_TOTALSROW )
1973  aNewData.SetTotals( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1974  else if ( aPropertyName == SC_UNONAME_CONTHDR )
1975  aNewData.SetHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1976  else
1977  bDo = false;
1978 
1979  if (bDo)
1980  {
1981  ScDBDocFunc aFunc(*pDocShell);
1982  aFunc.ModifyDBData(aNewData);
1983  }
1984 }
1985 
1986 uno::Any SAL_CALL ScDatabaseRangeObj::getPropertyValue( const OUString& aPropertyName )
1987 {
1988  SolarMutexGuard aGuard;
1989  uno::Any aRet;
1991  if ( pData )
1992  {
1993  if ( aPropertyName == SC_UNONAME_KEEPFORM )
1994  aRet <<= pData->IsKeepFmt();
1995  else if ( aPropertyName == SC_UNONAME_MOVCELLS )
1996  aRet <<= pData->IsDoSize();
1997  else if ( aPropertyName == SC_UNONAME_STRIPDAT )
1998  aRet <<= pData->IsStripData();
1999  else if ( aPropertyName == SC_UNONAME_ISUSER )
2000  {
2001  // all database ranges except "unnamed" are user defined
2002  aRet <<= (pData->GetName() != STR_DB_LOCAL_NONAME);
2003  }
2004  else if ( aPropertyName == SC_UNO_LINKDISPBIT )
2005  {
2006  // no target bitmaps for individual entries (would be all equal)
2007  // ScLinkTargetTypeObj::SetLinkTargetBitmap( aRet, SC_LINKTARGETTYPE_DBAREA );
2008  }
2009  else if ( aPropertyName == SC_UNO_LINKDISPNAME )
2010  aRet <<= aName;
2011  else if (aPropertyName == SC_UNONAME_AUTOFLT )
2012  {
2013  bool bAutoFilter(GetDBData_Impl()->HasAutoFilter());
2014 
2015  aRet <<= bAutoFilter;
2016  }
2017  else if (aPropertyName == SC_UNONAME_USEFLTCRT )
2018  {
2019  ScRange aRange;
2020  bool bIsAdvancedSource(GetDBData_Impl()->GetAdvancedQuerySource(aRange));
2021 
2022  aRet <<= bIsAdvancedSource;
2023  }
2024  else if (aPropertyName == SC_UNONAME_FLTCRT )
2025  {
2026  table::CellRangeAddress aRange;
2027  ScRange aCoreRange;
2028  if (GetDBData_Impl()->GetAdvancedQuerySource(aCoreRange))
2029  ScUnoConversion::FillApiRange(aRange, aCoreRange);
2030 
2031  aRet <<= aRange;
2032  }
2033  else if (aPropertyName == SC_UNONAME_FROMSELECT )
2034  {
2035  aRet <<= GetDBData_Impl()->HasImportSelection();
2036  }
2037  else if (aPropertyName == SC_UNONAME_REFPERIOD )
2038  {
2039  sal_Int32 nRefresh(GetDBData_Impl()->GetRefreshDelay());
2040  aRet <<= nRefresh;
2041  }
2042  else if (aPropertyName == SC_UNONAME_CONRES )
2043  {
2044  }
2045  else if (aPropertyName == SC_UNONAME_TOKENINDEX )
2046  {
2047  // get index for use in formula tokens (read-only)
2048  aRet <<= static_cast<sal_Int32>(GetDBData_Impl()->GetIndex());
2049  }
2050  else if (aPropertyName == SC_UNONAME_TOTALSROW )
2051  {
2052  bool bTotals(GetDBData_Impl()->HasTotals());
2053 
2054  aRet <<= bTotals;
2055  }
2056  else if (aPropertyName == SC_UNONAME_CONTHDR )
2057  {
2058  bool bHeader(GetDBData_Impl()->HasHeader());
2059 
2060  aRet <<= bHeader;
2061  }
2062  }
2063  return aRet;
2064 }
2065 
2067 
2068 // XServiceInfo
2069 OUString SAL_CALL ScDatabaseRangeObj::getImplementationName()
2070 {
2071  return "ScDatabaseRangeObj";
2072 }
2073 
2074 sal_Bool SAL_CALL ScDatabaseRangeObj::supportsService( const OUString& rServiceName )
2075 {
2076  return cppu::supportsService(this, rServiceName);
2077 }
2078 
2079 uno::Sequence<OUString> SAL_CALL ScDatabaseRangeObj::getSupportedServiceNames()
2080 {
2081  return {"com.sun.star.sheet.DatabaseRange",
2083 }
2084 
2086  pDocShell( pDocSh )
2087 {
2089 }
2090 
2092 {
2093  SolarMutexGuard g;
2094 
2095  if (pDocShell)
2097 }
2098 
2100 {
2101  // reference update does not matter here
2102 
2103  if ( rHint.GetId() == SfxHintId::Dying )
2104  {
2105  pDocShell = nullptr;
2106  }
2107 }
2108 
2109 // XDatabaseRanges
2110 
2112 {
2113  if (!pDocShell)
2114  return nullptr;
2115 
2117  if (!pNames)
2118  return nullptr;
2119 
2120  const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
2121  if (rDBs.empty() || nIndex >= rDBs.size())
2122  return nullptr;
2123 
2125  ::std::advance(itr, nIndex); // boundary check is done above.
2126  return new ScDatabaseRangeObj(pDocShell, (*itr)->GetName());
2127 }
2128 
2130 {
2131  if ( pDocShell && hasByName(aName) )
2132  {
2133  return new ScDatabaseRangeObj( pDocShell, aName );
2134  }
2135  return nullptr;
2136 }
2137 
2138 void SAL_CALL ScDatabaseRangesObj::addNewByName( const OUString& aName,
2139  const table::CellRangeAddress& aRange )
2140 {
2141  SolarMutexGuard aGuard;
2142  bool bDone = false;
2143  if (pDocShell)
2144  {
2145  ScDBDocFunc aFunc(*pDocShell);
2146 
2147  ScRange aNameRange( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet,
2148  static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet );
2149  bDone = aFunc.AddDBRange( aName, aNameRange );
2150  }
2151  if (!bDone)
2152  throw uno::RuntimeException(); // no other exceptions specified
2153 }
2154 
2155 void SAL_CALL ScDatabaseRangesObj::removeByName( const OUString& aName )
2156 {
2157  SolarMutexGuard aGuard;
2158  bool bDone = false;
2159  if (pDocShell)
2160  {
2161  ScDBDocFunc aFunc(*pDocShell);
2162  bDone = aFunc.DeleteDBRange( aName );
2163  }
2164  if (!bDone)
2165  throw uno::RuntimeException(); // no other exceptions specified
2166 }
2167 
2168 // XEnumerationAccess
2169 
2170 uno::Reference<container::XEnumeration> SAL_CALL ScDatabaseRangesObj::createEnumeration()
2171 {
2172  SolarMutexGuard aGuard;
2173  return new ScIndexEnumeration(this, "com.sun.star.sheet.DatabaseRangesEnumeration");
2174 }
2175 
2176 // XIndexAccess
2177 
2178 sal_Int32 SAL_CALL ScDatabaseRangesObj::getCount()
2179 {
2180  SolarMutexGuard aGuard;
2181 
2183 
2184  if (pDocShell)
2185  {
2187  if (pNames)
2188  return static_cast<sal_Int32>(pNames->getNamedDBs().size());
2189  }
2190  return 0;
2191 }
2192 
2193 uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex )
2194 {
2195  SolarMutexGuard aGuard;
2196  if (nIndex < 0)
2197  throw lang::IndexOutOfBoundsException();
2198 
2199  uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl(static_cast<size_t>(nIndex)));
2200  if (!xRange.is())
2201  throw lang::IndexOutOfBoundsException();
2202 
2203  return uno::makeAny(xRange);
2204 }
2205 
2207 {
2208  SolarMutexGuard aGuard;
2210 }
2211 
2213 {
2214  SolarMutexGuard aGuard;
2215  return ( getCount() != 0 );
2216 }
2217 
2218 // XNameAccess
2219 
2220 uno::Any SAL_CALL ScDatabaseRangesObj::getByName( const OUString& aName )
2221 {
2222  SolarMutexGuard aGuard;
2223  uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByName_Impl(aName));
2224  if (!xRange.is())
2225  throw container::NoSuchElementException();
2226 
2227  return uno::makeAny(xRange);
2228 }
2229 
2230 uno::Sequence<OUString> SAL_CALL ScDatabaseRangesObj::getElementNames()
2231 {
2232  SolarMutexGuard aGuard;
2233 
2235 
2236  if (pDocShell)
2237  {
2239  if (pNames)
2240  {
2241  const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
2242  uno::Sequence<OUString> aSeq(rDBs.size());
2243  size_t i = 0;
2244  for (const auto& rDB : rDBs)
2245  {
2246  aSeq[i] = rDB->GetName();
2247  ++i;
2248  }
2249 
2250  return aSeq;
2251  }
2252  }
2253  return uno::Sequence<OUString>(0);
2254 }
2255 
2256 sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const OUString& aName )
2257 {
2258  SolarMutexGuard aGuard;
2259 
2261 
2262  if (pDocShell)
2263  {
2265  if (pNames)
2266  return pNames->getNamedDBs().findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aName)) != nullptr;
2267  }
2268  return false;
2269 }
2270 
2272  pDocShell( pDocSh )
2273 {
2275 }
2276 
2278 {
2279  SolarMutexGuard g;
2280 
2281  if (pDocShell)
2283 }
2284 
2286 {
2287  // reference update does not matter here
2288 
2289  if ( rHint.GetId() == SfxHintId::Dying )
2290  {
2291  pDocShell = nullptr;
2292  }
2293 }
2294 
2295 // XUnnamedDatabaseRanges
2296 
2297 void ScUnnamedDatabaseRangesObj::setByTable( const table::CellRangeAddress& aRange )
2298 {
2299  SolarMutexGuard aGuard;
2300  bool bDone = false;
2301  if (pDocShell)
2302  {
2303  if ( pDocShell->GetDocument().GetTableCount() <= aRange.Sheet )
2304  throw lang::IndexOutOfBoundsException();
2305 
2306  ScDBDocFunc aFunc(*pDocShell);
2307  ScRange aUnnamedRange( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet,
2308  static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet );
2309  bDone = aFunc.AddDBRange( STR_DB_LOCAL_NONAME, aUnnamedRange );
2310  }
2311  if (!bDone)
2312  throw uno::RuntimeException(); // no other exceptions specified
2313 }
2314 
2316 {
2317  SolarMutexGuard aGuard;
2318  if (!pDocShell)
2319  throw uno::RuntimeException();
2320 
2321  if ( pDocShell->GetDocument().GetTableCount() <= nTab )
2322  throw lang::IndexOutOfBoundsException();
2323  uno::Reference<sheet::XDatabaseRange> xRange(
2324  new ScDatabaseRangeObj(pDocShell, static_cast<SCTAB>(nTab)));
2325  if (!xRange.is())
2326  throw container::NoSuchElementException();
2327 
2328  return uno::makeAny(xRange);
2329 }
2330 
2332 {
2333  SolarMutexGuard aGuard;
2334  if (pDocShell)
2335  {
2336  if (pDocShell->GetDocument().GetTableCount() <= nTab)
2337  throw lang::IndexOutOfBoundsException();
2338  if (pDocShell->GetDocument().GetAnonymousDBData(static_cast<SCTAB>(nTab)))
2339  return true;
2340  return false;
2341  }
2342  else
2343  return false;
2344 }
2345 
2346 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScDocShell * pDocShell
Definition: datauno.hxx:404
static void FillProperties(css::uno::Sequence< css::beans::PropertyValue > &rSeq, const ScSortParam &rParam)
Definition: datauno.cxx:259
::std::vector< ScSortKeyState > maKeyState
Definition: sortparam.hxx:61
bool bGroupActive[MAXSUBTOTAL]
active groups
const int nColCount
sal_uInt16 nUserIndex
Definition: sortparam.hxx:47
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:922
#define SC_UNONAME_SRCTYPE
Definition: unonames.hxx:291
virtual sal_Bool SAL_CALL getUseColumnHeaders() override
Definition: datauno.cxx:870
const Link< Timer *, void > & GetRefreshHandler() const
Definition: dbdata.hxx:338
SCCOL nColEnd
Definition: rangeutl.hxx:242
#define SC_UNONAME_CONTHDR
Definition: unonames.hxx:301
void SetQueryByEmpty()
Definition: queryentry.cxx:74
SCCOL nColStart
Definition: rangeutl.hxx:240
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:816
SfxItemPropertySet aPropSet
Definition: datauno.hxx:118
OUString getString() const
SCCOL nField[MAXSUBTOTAL]
associated field
virtual css::uno::Sequence< css::sheet::TableFilterField2 > SAL_CALL getFilterFields2() override
Definition: datauno.cxx:1148
std::vector< css::uno::Reference< css::util::XRefreshListener > > aRefreshListeners
Definition: datauno.hxx:408
ScAddress aStart
Definition: address.hxx:500
virtual void SAL_CALL setSources(const css::uno::Sequence< css::table::CellRangeAddress > &aSources) override
Definition: datauno.cxx:830
bool bUserDef
sort user defined
static sal_Int32 GetEnumFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:160
SharedString intern(const OUString &rStr)
#define SC_UNONAME_COPYOUT
Definition: unonames.hxx:297
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:563
virtual void GetData(ScQueryParam &rParam) const =0
virtual void GetData(ScQueryParam &rParam) const override
Definition: datauno.cxx:1450
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: datauno.cxx:2079
static void FillProperties(css::uno::Sequence< css::beans::PropertyValue > &rSeq, const ScImportParam &rParam)
Definition: datauno.cxx:164
SCROW nRowStart
Definition: rangeutl.hxx:241
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
Definition: document.cxx:307
SCROW Row() const
Definition: address.hxx:262
virtual void SAL_CALL refresh() override
Definition: datauno.cxx:1798
SfxItemPropertySet aPropSet
Definition: datauno.hxx:284
ScDatabaseRangeObj * GetObjectByName_Impl(const OUString &aName)
Definition: datauno.cxx:2129
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
Definition: document.hxx:2418
void SetImportSelection(bool bSet)
Definition: dbdata.hxx:202
void setDataSource(const OUString &_sDataSourceNameOrLocation)
OUString aDBName
Definition: global.hxx:455
virtual void PutData(const ScSubTotalParam &rParam)=0
std::unique_ptr< ContentProperties > pData
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: datauno.cxx:630
css::lang::Locale aCollatorLocale
Definition: sortparam.hxx:62
virtual css::uno::Type SAL_CALL getElementType() override
Definition: datauno.cxx:2206
SCCOL nDestCol
Definition: sortparam.hxx:58
virtual void SAL_CALL addNew(const css::uno::Sequence< css::sheet::SubTotalColumn > &aSubTotalColumns, sal_Int32 nGroupColumn) override
Definition: datauno.cxx:559
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: datauno.cxx:1398
SC_DLLPUBLIC void GetSortParam(ScSortParam &rSortParam) const
Definition: dbdata.cxx:387
void GetSubTotalParam(ScSubTotalParam &rSubTotalParam) const
Definition: datauno.cxx:1724
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: datauno.cxx:2230
virtual css::uno::Type SAL_CALL getElementType() override
Definition: datauno.cxx:640
#define SCLINKTARGET_SERVICE
Definition: targuno.hxx:42
sal_uInt16 char char * pDesc
Definition: callform.cxx:58
virtual ~ScSubTotalDescriptor() override
Definition: datauno.cxx:741
virtual ~ScFilterDescriptor() override
Definition: datauno.cxx:1446
void SetRefreshDelay(sal_uLong nSeconds)
#define STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:13
WeakReference< XInterface > mxParent
virtual css::uno::Reference< css::sheet::XSubTotalDescriptor > SAL_CALL getSubTotalDescriptor() override
Definition: datauno.cxx:1777
const SCCOL SCCOL_MAX
Definition: address.hxx:57
virtual void SAL_CALL setGroupColumn(sal_Int32 nGroupColumn) override
Definition: datauno.cxx:463
void SetDoSize(bool bSet)
Definition: dbdata.hxx:137
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5012
ScRangeFilterDescriptor(ScDocShell *pDocSh, ScDatabaseRangeObj *pPar)
Definition: datauno.cxx:1465
sal_Int64 n
QueryItemsType & GetQueryItems()
Definition: queryentry.hxx:65
bool DoImport(SCTAB nTab, const ScImportParam &rParam, const svx::ODataAccessDescriptor *pDescriptor)
Definition: dbdocimp.cxx:120
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: datauno.cxx:2256
#define SC_UNONAME_DBNAME
Definition: unonames.hxx:279
void SetAreas(std::unique_ptr< ScArea[]> pAreas, sal_uInt16 nCount)
Definition: global2.cxx:181
#define SC_UNONAME_ULIST
Definition: unonames.hxx:294
virtual void GetData(ScSubTotalParam &rParam) const override
Definition: datauno.cxx:745
sal_uInt16 nDataAreaCount
Definition: global.hxx:893
SfxItemPropertySet aPropSet
Definition: datauno.hxx:406
SCCOLROW nField
Definition: queryentry.hxx:51
ScAddress aEnd
Definition: address.hxx:501
bool bDoSort
presort
#define SC_UNONAME_USEREGEX
Definition: unonames.hxx:293
virtual css::uno::Any SAL_CALL getByTable(sal_Int32 nTab) override
Definition: datauno.cxx:2315
std::unique_ptr< ScArea[]> pDataAreas
Definition: global.hxx:894
virtual ~ScUnnamedDatabaseRangesObj() override
Definition: datauno.cxx:2277
bool IsQueryByEmpty() const
Definition: queryentry.cxx:84
bool bPagebreak
page break at change of group
void SetKeepFmt(bool bSet)
Definition: dbdata.hxx:139
virtual css::uno::Sequence< css::sheet::TableFilterField > SAL_CALL getFilterFields() override
Definition: datauno.cxx:932
ScQueryParam aStoredParam
Definition: datauno.hxx:347
virtual ~ScRangeSubTotalDescriptor() override
Definition: datauno.cxx:765
void SetQueryParam(const ScQueryParam &rParam)
Definition: dpshttab.cxx:269
bool IsDoSize() const
Definition: dbdata.hxx:136
SfxHintId GetId() const
virtual void SAL_CALL setFilterFields3(const css::uno::Sequence< css::sheet::TableFilterField3 > &aFilterFields) override
Definition: datauno.cxx:1332
bool bUserDef
Definition: sortparam.hxx:54
virtual ~ScConsolidationDescriptor() override
Definition: datauno.cxx:785
#define SC_UNONAME_ISSORTCOLUMNS
Definition: unonames.hxx:304
void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: datauno.cxx:1670
#define SC_UNONAME_FORMATS
Definition: unonames.hxx:280
#define SC_UNONAME_OUTPOS
Definition: unonames.hxx:300
virtual css::sheet::GeneralFunction SAL_CALL getFunction() override
Definition: datauno.cxx:796
sal_uInt16 nPos
Definition: datauno.hxx:214
#define SC_UNONAME_MAXFLD
Definition: unonames.hxx:302
char sal_uInt16 & nParamCount
Definition: callform.cxx:54
sal_uInt16 nUserIndex
index into list
#define SC_UNONAME_MOVCELLS
Definition: unonames.hxx:283
bool RepeatDB(const OUString &rDBName, bool bApi, bool bIsUnnamed, SCTAB aTab=0)
Definition: dbdocfun.cxx:282
virtual void SAL_CALL setName(const OUString &aName) override
Definition: datauno.cxx:1600
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
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:314
ScUnnamedDatabaseRangesObj(ScDocShell *pDocSh)
Definition: datauno.cxx:2271
static long GetPropertyCount()
Definition: datauno.hxx:83
virtual OUString SAL_CALL getName() override
Definition: datauno.cxx:1594
#define SC_UNONAME_KEEPFORM
Definition: unonames.hxx:282
UNO3_GETIMPLEMENTATION_IMPL(ScSubTotalDescriptorBase)
#define SC_UNONAME_BINDFMT
Definition: unonames.hxx:296
int nCount
virtual void SAL_CALL setInsertLinks(sal_Bool bInsertLinks) override
Definition: datauno.cxx:900
SC_DLLPUBLIC SCSIZE GetEntryCount() const
Definition: queryparam.cxx:119
virtual sal_Int32 SAL_CALL getCount() override
Definition: datauno.cxx:2178
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SCROW nRowEnd
Definition: rangeutl.hxx:243
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
Definition: queryparam.cxx:124
Mode eMode
SCTAB Tab() const
Definition: address.hxx:271
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
Definition: dbdata.cxx:423
ScDocShell * pDocShell
Definition: datauno.hxx:490
void SetRow(SCROW nRowP)
Definition: address.hxx:275
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:1552
virtual ~ScDatabaseRangesObj() override
Definition: datauno.cxx:2091
virtual void PutData(const ScQueryParam &rParam) override
Definition: datauno.cxx:1455
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: datauno.cxx:2193
#define SC_UNONAME_UINDEX
Definition: unonames.hxx:295
const OUString & GetName() const
#define SC_UNONAME_CONRES
Definition: unonames.hxx:316
bool DeleteDBRange(const OUString &rName)
Definition: dbdocfun.cxx:117
virtual sal_Bool SAL_CALL hasElements() override
Definition: datauno.cxx:646
void SetSheetDesc(const ScSheetSourceDesc &rDesc)
Definition: dpobject.cxx:414
ScSubTotalFieldObj(ScSubTotalDescriptorBase *pDesc, sal_uInt16 nP)
Definition: datauno.cxx:441
sal_uInt16 GetIndex() const
Definition: dbdata.hxx:135
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getSortDescriptor() override
Definition: datauno.cxx:1647
void ClearDataAreas()
Definition: global2.cxx:116
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:2099
ScRangeSubTotalDescriptor(ScDatabaseRangeObj *pPar)
Definition: datauno.cxx:760
virtual sal_Bool SAL_CALL getInsertLinks() override
Definition: datauno.cxx:894
SCCOL * pSubTotals[MAXSUBTOTAL]
array of columns to be calculated
#define SC_UNONAME_USEFLTCRT
Definition: unonames.hxx:313
const ScQueryParam & GetQueryParam() const
Definition: dpshttab.hxx:63
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:323
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: datauno.cxx:1892
OUString aStatement
Definition: global.hxx:456
virtual ~ScFilterDescriptorBase() override
Definition: datauno.cxx:914
static const SfxItemPropertyMapEntry * lcl_GetSubTotalPropertyMap()
Definition: datauno.cxx:69
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
virtual void PutData(const ScQueryParam &rParam) override
Definition: datauno.cxx:1507
void SetRefreshHandler(const Link< Timer *, void > &rLink)
ScSubTotalFunc * pFunctions[MAXSUBTOTAL]
array of associated functions
SCCOL nSubTotals[MAXSUBTOTAL]
number of SubTotals
int i
virtual void SAL_CALL clear() override
Definition: datauno.cxx:545
#define SC_UNONAME_ENUSLIST
Definition: unonames.hxx:307
bool IsQueryByNonEmpty() const
Definition: queryentry.cxx:106
ScFilterDescriptorBase(ScDocShell *pDocShell)
Definition: datauno.cxx:906
bool RenameDBRange(const OUString &rOld, const OUString &rNew)
Definition: dbdocfun.cxx:153
sal_Int16 SCCOL
Definition: types.hxx:22
virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL getSources() override
Definition: datauno.cxx:808
SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange *pSource)
Definition: dbdata.cxx:432
bool IsSheetData() const
Definition: dpobject.cxx:484
static long GetPropertyCount()
SortAscending needs to get out of the SheetSortDescriptor service description.
Definition: datauno.hxx:98
bool bNative
Definition: global.hxx:457
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: datauno.cxx:1884
void Resize(size_t nNew)
Definition: queryparam.cxx:204
float u
unsigned char sal_Bool
#define SC_UNONAME_FROMSELECT
Definition: unonames.hxx:315
virtual void SAL_CALL setUseColumnHeaders(sal_Bool bUseColumnHeaders) override
Definition: datauno.cxx:876
const OUString & GetName() const
Definition: dbdata.hxx:122
const SfxItemPropertyMap & getPropertyMap() const
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:466
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:2285
ScSubTotalParam aStoredParam
Definition: datauno.hxx:178
#define SC_UNONAME_AUTOFLT
Definition: unonames.hxx:311
bool IsKeepFmt() const
Definition: dbdata.hxx:138
void SetQueryParam(const ScQueryParam &rQueryParam)
Definition: datauno.cxx:1691
bool bCaseSens
Definition: sortparam.hxx:50
css::uno::Type const & get()
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
Definition: miscuno.hxx:64
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: datauno.cxx:610
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: datauno.cxx:1346
#define SC_UNONAME_USINDEX
Definition: unonames.hxx:308
void GetInputLineString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &rOutString)
#define SC_UNONAME_TOTALSROW
Definition: unonames.hxx:319
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:99
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:301
size_t size() const
Definition: dbdata.cxx:1191
void SetHeader(bool bHasH)
Definition: dbdata.hxx:131
bool IsStripData() const
Definition: dbdata.hxx:140
svl::SharedString maString
Definition: queryentry.hxx:41
static void FillSortParam(ScSortParam &rParam, const css::uno::Sequence< css::beans::PropertyValue > &rSeq)
Definition: datauno.cxx:321
static css::sheet::GeneralFunction SubTotalToGeneral(ScSubTotalFunc eSubTotal)
Definition: datauno.cxx:139
#define SC_UNONAME_SRCOBJ
Definition: unonames.hxx:290
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
Definition: miscuno.hxx:73
SCCOL Col() const
Definition: address.hxx:267
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: datauno.cxx:1986
rtl::Reference< ScDatabaseRangeObj > mxParent
Definition: datauno.hxx:367
void GetSubTotalParam(ScSubTotalParam &rSubTotalParam) const
Definition: dbdata.cxx:449
ScDBData * findByUpperName(const OUString &rName)
Definition: dbdata.cxx:1145
void SetStripData(bool bSet)
Definition: dbdata.hxx:141
void AddUnoObject(SfxListener &rObject)
Definition: documen3.cxx:893
ScDataPilotFilterDescriptor(ScDocShell *pDocSh, ScDataPilotDescriptorBase *pPar)
Definition: datauno.cxx:1487
#define SC_UNONAME_ISCASE
Definition: unonames.hxx:298
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
Definition: datauno.cxx:1750
virtual sal_Int32 SAL_CALL getGroupColumn() override
Definition: datauno.cxx:454
ScSubTotalFieldObj * GetObjectByIndex_Impl(sal_uInt16 nIndex)
Definition: datauno.cxx:538
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: datauno.cxx:654
virtual css::table::CellAddress SAL_CALL getStartOutputPosition() override
Definition: datauno.cxx:851
Stores global named database ranges.
Definition: dbdata.hxx:235
virtual css::table::CellRangeAddress SAL_CALL getDataArea() override
Definition: datauno.cxx:1614
sal_Int32 SCROW
Definition: types.hxx:18
virtual void SAL_CALL setStartOutputPosition(const css::table::CellAddress &aStartOutputPosition) override
Definition: datauno.cxx:861
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: datauno.cxx:701
virtual void PutData(const ScQueryParam &rParam) override
Definition: datauno.cxx:1481
virtual void SAL_CALL setByTable(const css::table::CellRangeAddress &aRange) override
Definition: datauno.cxx:2297
virtual css::uno::Sequence< css::sheet::SubTotalColumn > SAL_CALL getSubTotalColumns() override
Definition: datauno.cxx:474
#define SC_UNONAME_ORIENT
Definition: unonames.hxx:303
#define SC_UNONAME_ISULIST
Definition: unonames.hxx:299
rtl::Reference< ScDatabaseRangeObj > mxParent
Definition: datauno.hxx:197
virtual void SAL_CALL setFilterFields2(const css::uno::Sequence< css::sheet::TableFilterField2 > &aFilterFields) override
Definition: datauno.cxx:1322
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: datauno.cxx:2170
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: datauno.cxx:2074
bool bInplace
Definition: sortparam.hxx:56
bool has(DataAccessDescriptorProperty _eWhich) const
bool bHasHeader
Definition: sortparam.hxx:48
ScDatabaseRangesObj(ScDocShell *pDocSh)
Definition: datauno.cxx:2085
static void FillImportParam(ScImportParam &rParam, const css::uno::Sequence< css::beans::PropertyValue > &rSeq)
Definition: datauno.cxx:204
virtual void SAL_CALL setDataArea(const css::table::CellRangeAddress &aDataArea) override
Definition: datauno.cxx:1632
virtual ~ScDatabaseRangeObj() override
Definition: datauno.cxx:1544
sal_uInt8 nType
Definition: global.hxx:459
ScConsolidateParam aParam
Definition: datauno.hxx:239
ScDocShell * pDocSh
Definition: datauno.hxx:285
ScDBData * GetDBData_Impl() const
Definition: datauno.cxx:1569
void SetRefreshControl(std::unique_ptr< ScRefreshTimerControl > const *pp)
void SetParam(const ScQueryParam &rNew)
Definition: datauno.cxx:1460
virtual ~ScRangeFilterDescriptor() override
Definition: datauno.cxx:1471
sal_uInt16 GetSortKeyCount() const
Definition: sortparam.hxx:79
OUString aName
#define SC_UNO_LINKDISPBIT
Definition: unonames.hxx:189
virtual void SAL_CALL setFunction(css::sheet::GeneralFunction nFunction) override
Definition: datauno.cxx:802
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getReferredCells() override
Definition: datauno.cxx:1864
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: datauno.cxx:1836
virtual ~ScSubTotalFieldObj() override
Definition: datauno.cxx:448
static const SfxItemPropertyMapEntry * lcl_GetFilterPropertyMap()
Definition: datauno.cxx:92
#define SC_UNONAME_ISNATIVE
Definition: unonames.hxx:285
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5023
ScSubTotalFunc eFunction
Definition: global.hxx:892
bool bIncludePattern
sort formats
really derive cell from range?
Definition: cellsuno.hxx:628
const ScSheetSourceDesc * GetSheetDesc() const
Definition: dpobject.hxx:156
DBsType::const_iterator const_iterator
Definition: dbdata.hxx:251
void RemoveUnoObject(SfxListener &rObject)
Definition: documen3.cxx:901
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getImportDescriptor() override
Definition: datauno.cxx:1783
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
Definition: global.cxx:1010
void * p
bool empty() const
Definition: dbdata.cxx:1186
#define SC_UNONAME_ISUSER
Definition: unonames.hxx:284
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
virtual void SAL_CALL removeByName(const OUString &aName) override
Definition: datauno.cxx:2155
SC_DLLPUBLIC void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: dbdata.cxx:410
bool HasImportSelection() const
Definition: dbdata.hxx:201
void SetTotals(bool bTotals)
Definition: dbdata.hxx:133
ScQueryConnect eConnect
Definition: queryentry.hxx:53
OUString aCollatorAlgorithm
Definition: sortparam.hxx:63
bool bImport
Definition: global.hxx:454
#define SC_UNONAME_ENABSORT
Definition: unonames.hxx:314
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:315
virtual void SAL_CALL setSubTotalColumns(const css::uno::Sequence< css::sheet::SubTotalColumn > &aSubTotalColumns) override
Definition: datauno.cxx:492
std::vector< Item > QueryItemsType
Definition: queryentry.hxx:48
ScDatabaseRangeObj(ScDocShell *pDocSh, const OUString &rNm)
Definition: datauno.cxx:1524
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
Definition: dbdata.cxx:461
#define SC_UNONAME_SORTASC
Definition: unonames.hxx:306
static void FillApiRange(css::table::CellRangeAddress &rApiRange, const ScRange &rScRange)
Definition: convuno.hxx:88
SCTAB nTab
Definition: rangeutl.hxx:239
void SetParam(const ScSubTotalParam &rNew)
Definition: datauno.cxx:755
virtual sal_Bool SAL_CALL hasElements() override
Definition: datauno.cxx:2212
void ModifyDBData(const ScDBData &rNewData)
Definition: dbdocfun.cxx:200
SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange &rSource) const
Definition: dbdata.cxx:443
SCROW nDestRow
Definition: sortparam.hxx:59
#define SC_UNONAME_SORTFLD
Definition: unonames.hxx:305
virtual void PutData(const ScSubTotalParam &rParam) override
Definition: datauno.cxx:750
virtual sal_Bool SAL_CALL getUseRowHeaders() override
Definition: datauno.cxx:882
virtual void PutData(const ScSubTotalParam &rParam) override
Definition: datauno.cxx:775
virtual ~ScSubTotalDescriptorBase() override
Definition: datauno.cxx:532
virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL getFilterDescriptor() override
Definition: datauno.cxx:1718
ScDatabaseRangeObj * GetObjectByIndex_Impl(size_t nIndex)
Definition: datauno.cxx:2111
virtual void GetData(ScSubTotalParam &rParam) const =0
virtual void GetData(ScSubTotalParam &rParam) const override
Definition: datauno.cxx:769
ScSubTotalFunc
Definition: global.hxx:844
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:138
bool bIncludePattern
Definition: sortparam.hxx:55
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: datauno.cxx:1825
#define SC_UNONAME_CASE
Definition: unonames.hxx:278
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
Definition: convuno.hxx:80
bool AddDBRange(const OUString &rName, const ScRange &rRange)
Definition: dbdocfun.cxx:64
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: datauno.cxx:662
#define SC_UNONAME_FLTCRT
Definition: unonames.hxx:312
virtual css::uno::Sequence< css::sheet::TableFilterField3 > SAL_CALL getFilterFields3() override
Definition: datauno.cxx:1198
ScQueryOp eOp
Definition: queryentry.hxx:52
virtual sal_Int32 SAL_CALL getCount() override
Definition: datauno.cxx:618
void SetParam(const ScConsolidateParam &rNew)
Definition: datauno.cxx:789
#define SC_UNO_LINKDISPNAME
Definition: unonames.hxx:190
static const SfxItemPropertyMapEntry * lcl_GetDBRangePropertyMap()
Definition: datauno.cxx:110
virtual void SAL_CALL addNewByName(const OUString &aName, const css::table::CellRangeAddress &aRange) override
Definition: datauno.cxx:2138
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:39
virtual ~ScDataPilotFilterDescriptor() override
Definition: datauno.cxx:1493
virtual void GetData(ScQueryParam &rParam) const override
Definition: datauno.cxx:1475
aStr
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: datauno.cxx:1354
rtl::Reference< ScSubTotalDescriptorBase > xParent
Definition: datauno.hxx:213
#define SC_UNONAME_SAVEOUT
Definition: unonames.hxx:288
virtual void PutData(const ScQueryParam &rParam)=0
#define SC_UNONAME_INSBRK
Definition: unonames.hxx:281
virtual void SAL_CALL setFilterFields(const css::uno::Sequence< css::sheet::TableFilterField > &aFilterFields) override
Definition: datauno.cxx:1257
bool bAscending
sort ascending
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:33
#define SC_UNONAME_COLLALG
Definition: unonames.hxx:310
void SetQueryByNonEmpty()
Definition: queryentry.cxx:96
#define SC_UNONAME_COLLLOC
Definition: unonames.hxx:309
AnyEventRef aEvent
utl::SearchParam::SearchType eSearchType
Definition: queryparam.hxx:44
virtual void SAL_CALL setUseRowHeaders(sal_Bool bUseRowHeaders) override
Definition: datauno.cxx:888
#define SC_UNONAME_SKIPDUP
Definition: unonames.hxx:289
rtl::Reference< ScDataPilotDescriptorBase > mxParent
Definition: datauno.hxx:383
#define SC_UNONAME_TOKENINDEX
Definition: unonames.hxx:317
sal_uInt16 nPos
static SC_DLLPUBLIC ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc)
Definition: dputil.cxx:405
sal_Int16 SCTAB
Definition: types.hxx:23
void SetAutoFilter(bool bSet)
Definition: dbdata.hxx:205
bool any2bool(const css::uno::Any &rAny)
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: datauno.cxx:2220
const SCSIZE MAXSUBTOTAL
Definition: global.hxx:78
virtual void GetData(ScQueryParam &rParam) const override
Definition: datauno.cxx:1497
virtual sal_Bool SAL_CALL hasByTable(sal_Int32 nTab) override
Definition: datauno.cxx:2331
#define SC_UNONAME_REFPERIOD
Definition: unonames.hxx:369
SCTAB nDestTab
Definition: sortparam.hxx:57
#define SC_UNONAME_STRIPDAT
Definition: unonames.hxx:292
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo