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