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
734// XUnoTunnel
735
737
739{
740}
741
743{
744}
745
747{
748 rParam = aStoredParam; // query for interface
749}
750
752{
753 aStoredParam = rParam; // set by the interface
754}
755
757{
758 aStoredParam = rNew; // set from outside
759}
760
762 mxParent(pPar)
763{
764}
765
767{
768}
769
771{
772 if (mxParent.is())
773 mxParent->GetSubTotalParam( rParam );
774}
775
777{
778 if (mxParent.is())
779 mxParent->SetSubTotalParam( rParam );
780}
781
783{
784}
785
787{
788}
789
791{
792 aParam = rNew;
793}
794
795// XConsolidationDescriptor
796
797sheet::GeneralFunction SAL_CALL ScConsolidationDescriptor::getFunction()
798{
799 SolarMutexGuard aGuard;
801}
802
803void SAL_CALL ScConsolidationDescriptor::setFunction( sheet::GeneralFunction nFunction )
804{
805 SolarMutexGuard aGuard;
807}
808
809uno::Sequence<table::CellRangeAddress> SAL_CALL ScConsolidationDescriptor::getSources()
810{
811 SolarMutexGuard aGuard;
812 sal_uInt16 nCount = aParam.nDataAreaCount;
813 if (!aParam.pDataAreas)
814 nCount = 0;
815 table::CellRangeAddress aRange;
816 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
817 table::CellRangeAddress* pAry = aSeq.getArray();
818 for (sal_uInt16 i=0; i<nCount; i++)
819 {
820 ScArea const & rArea = aParam.pDataAreas[i];
821 aRange.Sheet = rArea.nTab;
822 aRange.StartColumn = rArea.nColStart;
823 aRange.StartRow = rArea.nRowStart;
824 aRange.EndColumn = rArea.nColEnd;
825 aRange.EndRow = rArea.nRowEnd;
826 pAry[i] = aRange;
827 }
828 return aSeq;
829}
830
832 const uno::Sequence<table::CellRangeAddress>& aSources )
833{
834 SolarMutexGuard aGuard;
835 sal_uInt16 nCount = static_cast<sal_uInt16>(aSources.getLength());
836 if (nCount)
837 {
838 const table::CellRangeAddress* pAry = aSources.getConstArray();
839 std::unique_ptr<ScArea[]> pNew(new ScArea[nCount]);
840 sal_uInt16 i;
841 for (i=0; i<nCount; i++)
842 pNew[i] = ScArea( pAry[i].Sheet,
843 static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow,
844 static_cast<SCCOL>(pAry[i].EndColumn), pAry[i].EndRow );
845
846 aParam.SetAreas( std::move(pNew), nCount ); // copy everything
847 }
848 else
850}
851
853{
854 SolarMutexGuard aGuard;
855 table::CellAddress aPos;
856 aPos.Column = aParam.nCol;
857 aPos.Row = aParam.nRow;
858 aPos.Sheet = aParam.nTab;
859 return aPos;
860}
861
863 const table::CellAddress& aStartOutputPosition )
864{
865 SolarMutexGuard aGuard;
866 aParam.nCol = static_cast<SCCOL>(aStartOutputPosition.Column);
867 aParam.nRow = static_cast<SCROW>(aStartOutputPosition.Row);
868 aParam.nTab = aStartOutputPosition.Sheet;
869}
870
872{
873 SolarMutexGuard aGuard;
874 return aParam.bByCol;
875}
876
878{
879 SolarMutexGuard aGuard;
880 aParam.bByCol = bUseColumnHeaders;
881}
882
884{
885 SolarMutexGuard aGuard;
886 return aParam.bByRow;
887}
888
890{
891 SolarMutexGuard aGuard;
892 aParam.bByRow = bUseRowHeaders;
893}
894
896{
897 SolarMutexGuard aGuard;
898 return aParam.bReferenceData;
899}
900
902{
903 SolarMutexGuard aGuard;
904 aParam.bReferenceData = bInsertLinks;
905}
906
908 aPropSet( lcl_GetFilterPropertyMap() ),
909 pDocSh(pDocShell)
910{
911 if (pDocSh)
913}
914
916{
918
919 if (pDocSh)
921}
922
924{
925 if ( rHint.GetId() == SfxHintId::Dying )
926 {
927 pDocSh = nullptr; // invalid
928 }
929}
930
931// XSheetFilterDescriptor and XSheetFilterDescriptor2
932
933uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilterFields()
934{
935 SolarMutexGuard aGuard;
936 ScQueryParam aParam;
937 GetData(aParam);
938
939 SCSIZE nEntries = aParam.GetEntryCount(); // allocated entries in Param
940 SCSIZE nCount = 0; // active
941 while ( nCount < nEntries &&
942 aParam.GetEntry(nCount).bDoQuery )
943 ++nCount;
944
945 sheet::TableFilterField aField;
946 uno::Sequence<sheet::TableFilterField> aSeq(static_cast<sal_Int32>(nCount));
947 sheet::TableFilterField* pAry = aSeq.getArray();
948 for (SCSIZE i=0; i<nCount; i++)
949 {
950 const ScQueryEntry& rEntry = aParam.GetEntry(i);
951 if (rEntry.GetQueryItems().empty())
952 continue;
953
954 const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
955
956 aField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND :
957 sheet::FilterConnection_OR;
958 aField.Field = rEntry.nField;
959 aField.IsNumeric = rItem.meType != ScQueryEntry::ByString;
960 aField.StringValue = rItem.maString.getString();
961 aField.NumericValue = rItem.mfVal;
962
963 switch (rEntry.eOp) // ScQueryOp
964 {
965 case SC_EQUAL:
966 {
967 aField.Operator = sheet::FilterOperator_EQUAL;
968 if (rEntry.IsQueryByEmpty())
969 {
970 aField.Operator = sheet::FilterOperator_EMPTY;
971 aField.NumericValue = 0;
972 }
973 else if (rEntry.IsQueryByNonEmpty())
974 {
975 aField.Operator = sheet::FilterOperator_NOT_EMPTY;
976 aField.NumericValue = 0;
977 }
978 }
979 break;
980 case SC_LESS: aField.Operator = sheet::FilterOperator_LESS; break;
981 case SC_GREATER: aField.Operator = sheet::FilterOperator_GREATER; break;
982 case SC_LESS_EQUAL: aField.Operator = sheet::FilterOperator_LESS_EQUAL; break;
983 case SC_GREATER_EQUAL: aField.Operator = sheet::FilterOperator_GREATER_EQUAL; break;
984 case SC_NOT_EQUAL: aField.Operator = sheet::FilterOperator_NOT_EQUAL; break;
985 case SC_TOPVAL: aField.Operator = sheet::FilterOperator_TOP_VALUES; break;
986 case SC_BOTVAL: aField.Operator = sheet::FilterOperator_BOTTOM_VALUES; break;
987 case SC_TOPPERC: aField.Operator = sheet::FilterOperator_TOP_PERCENT; break;
988 case SC_BOTPERC: aField.Operator = sheet::FilterOperator_BOTTOM_PERCENT; break;
989 default:
990 OSL_FAIL("wrong filter enum");
991 aField.Operator = sheet::FilterOperator_EMPTY;
992 }
993 pAry[i] = aField;
994 }
995 return aSeq;
996}
997
998namespace {
999
1000template<typename T>
1001void convertQueryEntryToUno(const ScQueryEntry& rEntry, T& rField)
1002{
1003 rField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND : sheet::FilterConnection_OR;
1004 rField.Field = rEntry.nField;
1005
1006 switch (rEntry.eOp) // ScQueryOp
1007 {
1008 case SC_EQUAL: rField.Operator = sheet::FilterOperator2::EQUAL; break;
1009 case SC_LESS: rField.Operator = sheet::FilterOperator2::LESS; break;
1010 case SC_GREATER: rField.Operator = sheet::FilterOperator2::GREATER; break;
1011 case SC_LESS_EQUAL: rField.Operator = sheet::FilterOperator2::LESS_EQUAL; break;
1012 case SC_GREATER_EQUAL: rField.Operator = sheet::FilterOperator2::GREATER_EQUAL; break;
1013 case SC_NOT_EQUAL: rField.Operator = sheet::FilterOperator2::NOT_EQUAL; break;
1014 case SC_TOPVAL: rField.Operator = sheet::FilterOperator2::TOP_VALUES; break;
1015 case SC_BOTVAL: rField.Operator = sheet::FilterOperator2::BOTTOM_VALUES; break;
1016 case SC_TOPPERC: rField.Operator = sheet::FilterOperator2::TOP_PERCENT; break;
1017 case SC_BOTPERC: rField.Operator = sheet::FilterOperator2::BOTTOM_PERCENT; break;
1018 case SC_CONTAINS: rField.Operator = sheet::FilterOperator2::CONTAINS; break;
1019 case SC_DOES_NOT_CONTAIN: rField.Operator = sheet::FilterOperator2::DOES_NOT_CONTAIN; break;
1020 case SC_BEGINS_WITH: rField.Operator = sheet::FilterOperator2::BEGINS_WITH; break;
1021 case SC_DOES_NOT_BEGIN_WITH: rField.Operator = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH; break;
1022 case SC_ENDS_WITH: rField.Operator = sheet::FilterOperator2::ENDS_WITH; break;
1023 case SC_DOES_NOT_END_WITH: rField.Operator = sheet::FilterOperator2::DOES_NOT_END_WITH; break;
1024 default:
1025 OSL_FAIL("Unknown filter operator value.");
1026 rField.Operator = sheet::FilterOperator2::EMPTY;
1027 }
1028}
1029
1030template<typename T>
1031void convertUnoToQueryEntry(const T& rField, ScQueryEntry& rEntry)
1032{
1033 rEntry.bDoQuery = true;
1034 rEntry.eConnect = (rField.Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
1035 rEntry.nField = rField.Field;
1036
1037 switch (rField.Operator) // FilterOperator
1038 {
1039 case sheet::FilterOperator2::EQUAL: rEntry.eOp = SC_EQUAL; break;
1040 case sheet::FilterOperator2::LESS: rEntry.eOp = SC_LESS; break;
1041 case sheet::FilterOperator2::GREATER: rEntry.eOp = SC_GREATER; break;
1042 case sheet::FilterOperator2::LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break;
1043 case sheet::FilterOperator2::GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break;
1044 case sheet::FilterOperator2::NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break;
1045 case sheet::FilterOperator2::TOP_VALUES: rEntry.eOp = SC_TOPVAL; break;
1046 case sheet::FilterOperator2::BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break;
1047 case sheet::FilterOperator2::TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break;
1048 case sheet::FilterOperator2::BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break;
1049 case sheet::FilterOperator2::CONTAINS: rEntry.eOp = SC_CONTAINS; break;
1050 case sheet::FilterOperator2::DOES_NOT_CONTAIN: rEntry.eOp = SC_DOES_NOT_CONTAIN; break;
1051 case sheet::FilterOperator2::BEGINS_WITH: rEntry.eOp = SC_BEGINS_WITH; break;
1052 case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH: rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break;
1053 case sheet::FilterOperator2::ENDS_WITH: rEntry.eOp = SC_ENDS_WITH; break;
1054 case sheet::FilterOperator2::DOES_NOT_END_WITH: rEntry.eOp = SC_DOES_NOT_END_WITH; break;
1055 case sheet::FilterOperator2::EMPTY:
1056 rEntry.SetQueryByEmpty();
1057 break;
1058 case sheet::FilterOperator2::NOT_EMPTY:
1059 rEntry.SetQueryByNonEmpty();
1060 break;
1061 default:
1062 OSL_FAIL("Unknown filter operator type.");
1063 rEntry.eOp = SC_EQUAL;
1064 }
1065}
1066
1067void fillQueryParam(
1068 ScQueryParam& rParam, ScDocument* pDoc,
1069 const uno::Sequence<sheet::TableFilterField2>& aFilterFields)
1070{
1071 size_t nCount = static_cast<size_t>(aFilterFields.getLength());
1072 rParam.Resize(nCount);
1073
1074 const sheet::TableFilterField2* pAry = aFilterFields.getConstArray();
1076 for (size_t i = 0; i < nCount; ++i)
1077 {
1078 ScQueryEntry& rEntry = rParam.GetEntry(i);
1079 convertUnoToQueryEntry(pAry[i], rEntry);
1080
1081 if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY)
1082 {
1084 rItems.resize(1);
1085 ScQueryEntry::Item& rItem = rItems.front();
1086 rItem.meType = pAry[i].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
1087 rItem.mfVal = pAry[i].NumericValue;
1088 rItem.maString = rPool.intern(pAry[i].StringValue);
1089
1090 if (rItem.meType == ScQueryEntry::ByValue)
1091 {
1092 OUString aStr;
1093 pDoc->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
1094 rItem.maString = rPool.intern(aStr);
1095 }
1096 }
1097 }
1098
1099 size_t nParamCount = rParam.GetEntryCount(); // if below eight Param isn't resized
1100 for (size_t i = nCount; i < nParamCount; ++i)
1101 rParam.GetEntry(i).bDoQuery = false; // reset surplus fields
1102}
1103
1104void fillQueryParam(
1105 ScQueryParam& rParam, ScDocument* pDoc,
1106 const uno::Sequence<sheet::TableFilterField3>& aFilterFields)
1107{
1108 size_t nCount = static_cast<size_t>(aFilterFields.getLength());
1109 rParam.Resize(nCount);
1110
1112 const sheet::TableFilterField3* pAry = aFilterFields.getConstArray();
1113 for (size_t i = 0; i < nCount; ++i)
1114 {
1115 ScQueryEntry& rEntry = rParam.GetEntry(i);
1116 convertUnoToQueryEntry(pAry[i], rEntry);
1117
1118 if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY)
1119 {
1121 rItems.clear();
1122 const uno::Sequence<sheet::FilterFieldValue>& rVals = pAry[i].Values;
1123 for (const auto& rVal : rVals)
1124 {
1125 ScQueryEntry::Item aItem;
1126 switch (rVal.FilterType)
1127 {
1128 case FilterFieldType::NUMERIC:
1130 break;
1131 case FilterFieldType::STRING:
1133 break;
1136 break;
1137 case FilterFieldType::TEXT_COLOR:
1139 break;
1140 case FilterFieldType::BACKGROUND_COLOR:
1142 break;
1143 }
1144 aItem.mfVal = rVal.NumericValue;
1145 aItem.maString = rPool.intern(rVal.StringValue);
1146
1147 if (aItem.meType == ScQueryEntry::ByValue)
1148 {
1149 OUString aStr;
1150 pDoc->GetFormatTable()->GetInputLineString(aItem.mfVal, 0, aStr);
1151 aItem.maString = rPool.intern(aStr);
1152 }
1153 else if (aItem.meType == ScQueryEntry::ByTextColor
1155 {
1156 aItem.maColor = Color(ColorTransparency, rVal.ColorValue);
1157 }
1158
1159 // filter all dates starting with the given date filter YYYY or YYYY-MM and filter all datetimes
1160 // starting with the given datetime filter YYYY-MM-DD, YYYY-MM-DD HH, or YYYY-MM-DD HH:MM
1161 if( aItem.meType == ScQueryEntry::ByDate && aItem.maString.getLength() < 19 )
1162 {
1163 ScFilterEntries aFilterEntries;
1164 pDoc->GetFilterEntries(rEntry.nField, rParam.nRow1, rParam.nTab, aFilterEntries);
1165 for( const auto& rFilter : aFilterEntries )
1166 {
1167 if( rFilter.GetString().startsWith(rVal.StringValue) )
1168 {
1169 aItem.maString = rPool.intern(rFilter.GetString());
1170 rItems.push_back(aItem);
1171 }
1172 }
1173 }
1174 else
1175 {
1176 rItems.push_back(aItem);
1177 }
1178 }
1179 }
1180 }
1181
1182 size_t nParamCount = rParam.GetEntryCount(); // if below eight Param isn't resized
1183 for (size_t i = nCount; i < nParamCount; ++i)
1184 rParam.GetEntry(i).bDoQuery = false; // reset surplus fields
1185}
1186
1187}
1188
1189uno::Sequence<sheet::TableFilterField2> SAL_CALL ScFilterDescriptorBase::getFilterFields2()
1190{
1191 SolarMutexGuard aGuard;
1192 ScQueryParam aParam;
1193 GetData(aParam);
1194
1195 SCSIZE nEntries = aParam.GetEntryCount(); // allocated entries in Param
1196 SCSIZE nCount = 0; // active
1197 while ( nCount < nEntries &&
1198 aParam.GetEntry(nCount).bDoQuery )
1199 ++nCount;
1200
1201 sheet::TableFilterField2 aField;
1202 uno::Sequence<sheet::TableFilterField2> aSeq(static_cast<sal_Int32>(nCount));
1203 sheet::TableFilterField2* pAry = aSeq.getArray();
1204 for (SCSIZE i=0; i<nCount; i++)
1205 {
1206 const ScQueryEntry& rEntry = aParam.GetEntry(i);
1207 convertQueryEntryToUno(rEntry, aField);
1208
1209 bool bByEmpty = false;
1210 if (aField.Operator == sheet::FilterOperator2::EQUAL)
1211 {
1212 if (rEntry.IsQueryByEmpty())
1213 {
1214 aField.Operator = sheet::FilterOperator2::EMPTY;
1215 aField.NumericValue = 0;
1216 bByEmpty = true;
1217 }
1218 else if (rEntry.IsQueryByNonEmpty())
1219 {
1220 aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
1221 aField.NumericValue = 0;
1222 bByEmpty = true;
1223 }
1224 }
1225
1226 if (!bByEmpty && !rEntry.GetQueryItems().empty())
1227 {
1228 const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
1229 aField.IsNumeric = rItem.meType != ScQueryEntry::ByString;
1230 aField.StringValue = rItem.maString.getString();
1231 aField.NumericValue = rItem.mfVal;
1232 }
1233
1234 pAry[i] = aField;
1235 }
1236 return aSeq;
1237}
1238
1239uno::Sequence<sheet::TableFilterField3> SAL_CALL ScFilterDescriptorBase::getFilterFields3()
1240{
1241 SolarMutexGuard aGuard;
1242 ScQueryParam aParam;
1243 GetData(aParam);
1244
1245 SCSIZE nEntries = aParam.GetEntryCount(); // allocated entries in Param
1246 SCSIZE nCount = 0; // active
1247 while ( nCount < nEntries &&
1248 aParam.GetEntry(nCount).bDoQuery )
1249 ++nCount;
1250
1251 sheet::TableFilterField3 aField;
1252 uno::Sequence<sheet::TableFilterField3> aSeq(static_cast<sal_Int32>(nCount));
1253 sheet::TableFilterField3* pAry = aSeq.getArray();
1254 for (SCSIZE i = 0; i < nCount; ++i)
1255 {
1256 const ScQueryEntry& rEntry = aParam.GetEntry(i);
1257 convertQueryEntryToUno(rEntry, aField);
1258
1259 bool bByEmpty = false;
1260 if (aField.Operator == sheet::FilterOperator2::EQUAL)
1261 {
1262 if (rEntry.IsQueryByEmpty())
1263 {
1264 aField.Operator = sheet::FilterOperator2::EMPTY;
1265 aField.Values.realloc(1);
1266 aField.Values.getArray()[0].NumericValue = 0;
1267 bByEmpty = true;
1268 }
1269 else if (rEntry.IsQueryByNonEmpty())
1270 {
1271 aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
1272 aField.Values.realloc(1);
1273 aField.Values.getArray()[0].NumericValue = 0;
1274 bByEmpty = true;
1275 }
1276 }
1277
1278 if (!bByEmpty)
1279 {
1280 const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
1281 size_t nItemCount = rItems.size();
1282 aField.Values.realloc(nItemCount);
1283 auto pValues = aField.Values.getArray();
1284 size_t j = 0;
1285 for (const auto& rItem : rItems)
1286 {
1287 pValues[j].IsNumeric = rItem.meType != ScQueryEntry::ByString;
1288 pValues[j].StringValue = rItem.maString.getString();
1289 pValues[j].NumericValue = rItem.mfVal;
1290 ++j;
1291 }
1292 }
1293
1294 pAry[i] = aField;
1295 }
1296 return aSeq;
1297}
1298
1300 const uno::Sequence<sheet::TableFilterField>& aFilterFields )
1301{
1302 SolarMutexGuard aGuard;
1303 ScQueryParam aParam;
1304 GetData(aParam);
1305
1306 SCSIZE nCount = static_cast<SCSIZE>(aFilterFields.getLength());
1307 aParam.Resize( nCount );
1308
1309 ScDocument& rDoc = pDocSh->GetDocument();
1311 const sheet::TableFilterField* pAry = aFilterFields.getConstArray();
1312 SCSIZE i;
1313 for (i=0; i<nCount; i++)
1314 {
1315 ScQueryEntry& rEntry = aParam.GetEntry(i);
1317 rItems.resize(1);
1318 ScQueryEntry::Item& rItem = rItems.front();
1319 rEntry.bDoQuery = true;
1320 rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
1321 rEntry.nField = pAry[i].Field;
1322 rItem.meType = pAry[i].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
1323 rItem.mfVal = pAry[i].NumericValue;
1324 rItem.maString = rPool.intern(pAry[i].StringValue);
1325
1326 if (rItem.meType != ScQueryEntry::ByString)
1327 {
1328 OUString aStr;
1329 rDoc.GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
1330 rItem.maString = rPool.intern(aStr);
1331 }
1332
1333 switch (pAry[i].Operator) // FilterOperator
1334 {
1335 case sheet::FilterOperator_EQUAL: rEntry.eOp = SC_EQUAL; break;
1336 case sheet::FilterOperator_LESS: rEntry.eOp = SC_LESS; break;
1337 case sheet::FilterOperator_GREATER: rEntry.eOp = SC_GREATER; break;
1338 case sheet::FilterOperator_LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break;
1339 case sheet::FilterOperator_GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break;
1340 case sheet::FilterOperator_NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break;
1341 case sheet::FilterOperator_TOP_VALUES: rEntry.eOp = SC_TOPVAL; break;
1342 case sheet::FilterOperator_BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break;
1343 case sheet::FilterOperator_TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break;
1344 case sheet::FilterOperator_BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break;
1345 case sheet::FilterOperator_EMPTY:
1346 rEntry.SetQueryByEmpty();
1347 break;
1348 case sheet::FilterOperator_NOT_EMPTY:
1349 rEntry.SetQueryByNonEmpty();
1350 break;
1351 default:
1352 OSL_FAIL("Wrong query enum");
1353 rEntry.eOp = SC_EQUAL;
1354 }
1355 }
1356
1357 SCSIZE nParamCount = aParam.GetEntryCount(); // if below eight Param isn't resized
1358 for (i=nCount; i<nParamCount; i++)
1359 aParam.GetEntry(i).bDoQuery = false; // reset surplus fields
1360
1361 PutData(aParam);
1362}
1363
1365 const uno::Sequence<sheet::TableFilterField2>& aFilterFields )
1366{
1367 SolarMutexGuard aGuard;
1368 ScQueryParam aParam;
1369 GetData(aParam);
1370 fillQueryParam(aParam, &pDocSh->GetDocument(), aFilterFields);
1371 PutData(aParam);
1372}
1373
1375 const uno::Sequence<sheet::TableFilterField3>& aFilterFields )
1376{
1377 SolarMutexGuard aGuard;
1378 ScQueryParam aParam;
1379 GetData(aParam);
1380 fillQueryParam(aParam, &pDocSh->GetDocument(), aFilterFields);
1381 PutData(aParam);
1382}
1383
1384// Rest sind Properties
1385
1386// XPropertySet
1387
1388uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFilterDescriptorBase::getPropertySetInfo()
1389{
1390 SolarMutexGuard aGuard;
1391 static uno::Reference<beans::XPropertySetInfo> aRef(
1393 return aRef;
1394}
1395
1397 const OUString& aPropertyName, const uno::Any& aValue )
1398{
1399 SolarMutexGuard aGuard;
1400 ScQueryParam aParam;
1401 GetData(aParam);
1402
1403 if (aPropertyName == SC_UNONAME_CONTHDR)
1405 else if (aPropertyName == SC_UNONAME_COPYOUT)
1406 aParam.bInplace = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1407 else if (aPropertyName == SC_UNONAME_ISCASE)
1409 else if (aPropertyName == SC_UNONAME_MAXFLD)
1410 {
1411 // silently ignored
1412 }
1413 else if (aPropertyName == SC_UNONAME_ORIENT)
1414 {
1416 table::TableOrientation eOrient = static_cast<table::TableOrientation>(ScUnoHelpFunctions::GetEnumFromAny( aValue ));
1417 aParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
1418 }
1419 else if (aPropertyName == SC_UNONAME_OUTPOS)
1420 {
1421 table::CellAddress aAddress;
1422 if ( aValue >>= aAddress )
1423 {
1424 aParam.nDestTab = aAddress.Sheet;
1425 aParam.nDestCol = static_cast<SCCOL>(aAddress.Column);
1426 aParam.nDestRow = static_cast<SCROW>(aAddress.Row);
1427 }
1428 }
1429 else if (aPropertyName == SC_UNONAME_SAVEOUT)
1431 else if (aPropertyName == SC_UNONAME_SKIPDUP)
1432 aParam.bDuplicate = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1433 else if (aPropertyName == SC_UNONAME_USEREGEX)
1436
1437 PutData(aParam);
1438}
1439
1440uno::Any SAL_CALL ScFilterDescriptorBase::getPropertyValue( const OUString& aPropertyName )
1441{
1442 SolarMutexGuard aGuard;
1443 ScQueryParam aParam;
1444 GetData(aParam);
1445
1446 uno::Any aRet;
1447
1448 if (aPropertyName == SC_UNONAME_CONTHDR )
1449 aRet <<= aParam.bHasHeader;
1450 else if (aPropertyName == SC_UNONAME_COPYOUT )
1451 aRet <<= !(aParam.bInplace);
1452 else if (aPropertyName == SC_UNONAME_ISCASE )
1453 aRet <<= aParam.bCaseSens;
1454 else if (aPropertyName == SC_UNONAME_MAXFLD )
1455 aRet <<= static_cast<sal_Int32>(aParam.GetEntryCount());
1456 else if (aPropertyName == SC_UNONAME_ORIENT )
1457 {
1458 table::TableOrientation eOrient = aParam.bByRow ? table::TableOrientation_ROWS :
1459 table::TableOrientation_COLUMNS;
1460 aRet <<= eOrient;
1461 }
1462 else if (aPropertyName == SC_UNONAME_OUTPOS )
1463 {
1464 table::CellAddress aOutPos;
1465 aOutPos.Sheet = aParam.nDestTab;
1466 aOutPos.Column = aParam.nDestCol;
1467 aOutPos.Row = aParam.nDestRow;
1468 aRet <<= aOutPos;
1469 }
1470 else if (aPropertyName == SC_UNONAME_SAVEOUT )
1471 aRet <<= aParam.bDestPers;
1472 else if (aPropertyName == SC_UNONAME_SKIPDUP )
1473 aRet <<= !(aParam.bDuplicate);
1474 else if (aPropertyName == SC_UNONAME_USEREGEX )
1476
1477 return aRet;
1478}
1479
1481
1483 :
1484 ScFilterDescriptorBase(pDocShell)
1485{
1486}
1487
1489{
1490}
1491
1493{
1494 rParam = aStoredParam; // query for interface
1495}
1496
1498{
1499 aStoredParam = rParam; // set by the interface
1500}
1501
1503{
1504 aStoredParam = rNew; // set from outside
1505}
1506
1508 ScFilterDescriptorBase(pDocShell),
1509 mxParent(pPar)
1510{
1511}
1512
1514{
1515}
1516
1518{
1519 if (mxParent.is())
1520 mxParent->GetQueryParam( rParam );
1521}
1522
1524{
1525 if (mxParent.is())
1526 mxParent->SetQueryParam( rParam );
1527}
1528
1530 ScFilterDescriptorBase(pDocShell),
1531 mxParent(pPar)
1532{
1533}
1534
1536{
1537}
1538
1540{
1541 if (mxParent.is())
1542 {
1543 ScDPObject* pDPObj = mxParent->GetDPObject();
1544 if (pDPObj && pDPObj->IsSheetData())
1545 rParam = pDPObj->GetSheetDesc()->GetQueryParam();
1546 }
1547}
1548
1550{
1551 if (!mxParent.is())
1552 return;
1553
1554 ScDPObject* pDPObj = mxParent->GetDPObject();
1555 if (pDPObj)
1556 {
1557 ScSheetSourceDesc aSheetDesc(&mxParent->GetDocShell()->GetDocument());
1558 if (pDPObj->IsSheetData())
1559 aSheetDesc = *pDPObj->GetSheetDesc();
1560 aSheetDesc.SetQueryParam(rParam);
1561 pDPObj->SetSheetDesc(aSheetDesc);
1562 mxParent->SetDPObject(pDPObj);
1563 }
1564}
1565
1567 pDocShell( pDocSh ),
1568 aName(std::move( aNm )),
1569 aPropSet( lcl_GetDBRangePropertyMap() ),
1570 bIsUnnamed(false),
1571 aTab( 0 )
1572{
1574}
1575
1577 pDocShell( pDocSh ),
1579 aPropSet( lcl_GetDBRangePropertyMap() ),
1580 bIsUnnamed(true),
1581 aTab( nTab )
1582{
1584}
1585
1587{
1589
1590 if (pDocShell)
1592}
1593
1595{
1596
1597 if ( rHint.GetId() == SfxHintId::Dying )
1598 pDocShell = nullptr;
1599 else if ( auto pRefreshHint = dynamic_cast<const ScDBRangeRefreshedHint*>(&rHint) )
1600 {
1601 ScDBData* pDBData = GetDBData_Impl();
1602 ScImportParam aParam;
1603 pDBData->GetImportParam(aParam);
1604 if (aParam == pRefreshHint->GetImportParam())
1606 }
1607}
1608
1609// Help functions
1610
1612{
1613 ScDBData* pRet = nullptr;
1614 if (pDocShell)
1615 {
1616 if (bIsUnnamed)
1617 {
1619 }
1620 else
1621 {
1623 if (pNames)
1624 {
1626 if (p)
1627 pRet = p;
1628 }
1629 }
1630 }
1631 return pRet;
1632}
1633
1634// XNamed
1635
1637{
1638 SolarMutexGuard aGuard;
1639 return aName;
1640}
1641
1642void SAL_CALL ScDatabaseRangeObj::setName( const OUString& aNewName )
1643{
1644 SolarMutexGuard aGuard;
1645 if (pDocShell)
1646 {
1647 ScDBDocFunc aFunc(*pDocShell);
1648 bool bOk = aFunc.RenameDBRange( aName, aNewName );
1649 if (bOk)
1650 aName = aNewName;
1651 }
1652}
1653
1654// XDatabaseRange
1655
1656table::CellRangeAddress SAL_CALL ScDatabaseRangeObj::getDataArea()
1657{
1658 SolarMutexGuard aGuard;
1659 table::CellRangeAddress aAddress;
1661 if (pData)
1662 {
1663 ScRange aRange;
1664 pData->GetArea(aRange);
1665 aAddress.Sheet = aRange.aStart.Tab();
1666 aAddress.StartColumn = aRange.aStart.Col();
1667 aAddress.StartRow = aRange.aStart.Row();
1668 aAddress.EndColumn = aRange.aEnd.Col();
1669 aAddress.EndRow = aRange.aEnd.Row();
1670 }
1671 return aAddress;
1672}
1673
1674void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aDataArea )
1675{
1676 SolarMutexGuard aGuard;
1678 if ( pDocShell && pData )
1679 {
1680 ScDBData aNewData( *pData );
1682 aNewData.SetArea( aDataArea.Sheet, static_cast<SCCOL>(aDataArea.StartColumn), static_cast<SCROW>(aDataArea.StartRow),
1683 static_cast<SCCOL>(aDataArea.EndColumn), static_cast<SCROW>(aDataArea.EndRow) );
1684 ScDBDocFunc aFunc(*pDocShell);
1685 aFunc.ModifyDBData(aNewData);
1686 }
1687}
1688
1689uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getSortDescriptor()
1690{
1691 SolarMutexGuard aGuard;
1692 ScSortParam aParam;
1693 const ScDBData* pData = GetDBData_Impl();
1694 if (pData)
1695 {
1696 pData->GetSortParam(aParam);
1697
1698 // SortDescriptor contains the counted fields inside the area
1699 ScRange aDBRange;
1700 pData->GetArea(aDBRange);
1701 SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1702 for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
1703 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
1704 aParam.maKeyState[i].nField -= nFieldStart;
1705 }
1706
1707 uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
1709 return aSeq;
1710}
1711
1713{
1714 const ScDBData* pData = GetDBData_Impl();
1715 if (!pData)
1716 return;
1717
1718 pData->GetQueryParam(rQueryParam);
1719
1720 // FilterDescriptor contains the counted fields inside the area
1721 ScRange aDBRange;
1722 pData->GetArea(aDBRange);
1723 SCCOLROW nFieldStart = rQueryParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1724 SCSIZE nCount = rQueryParam.GetEntryCount();
1725 for (SCSIZE i=0; i<nCount; i++)
1726 {
1727 ScQueryEntry& rEntry = rQueryParam.GetEntry(i);
1728 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
1729 rEntry.nField -= nFieldStart;
1730 }
1731}
1732
1734{
1735 const ScDBData* pData = GetDBData_Impl();
1736 if (!pData)
1737 return;
1738
1739 // FilterDescriptor contains the counted fields inside the area
1740 ScQueryParam aParam(rQueryParam);
1741 ScRange aDBRange;
1742 pData->GetArea(aDBRange);
1743 SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1744
1745 SCSIZE nCount = aParam.GetEntryCount();
1746 for (SCSIZE i=0; i<nCount; i++)
1747 {
1748 ScQueryEntry& rEntry = aParam.GetEntry(i);
1749 if (rEntry.bDoQuery)
1750 rEntry.nField += nFieldStart;
1751 }
1752
1753 ScDBData aNewData( *pData );
1754 aNewData.SetQueryParam(aParam);
1755 aNewData.SetHeader(aParam.bHasHeader); // not in ScDBData::SetQueryParam
1756 ScDBDocFunc aFunc(*pDocShell);
1757 aFunc.ModifyDBData(aNewData);
1758}
1759
1760uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScDatabaseRangeObj::getFilterDescriptor()
1761{
1762 SolarMutexGuard aGuard;
1763 return new ScRangeFilterDescriptor(pDocShell, this);
1764}
1765
1767{
1768 const ScDBData* pData = GetDBData_Impl();
1769 if (!pData)
1770 return;
1771
1772 pData->GetSubTotalParam(rSubTotalParam);
1773
1774 // FilterDescriptor contains the counted fields inside the area
1775 ScRange aDBRange;
1776 pData->GetArea(aDBRange);
1777 SCCOL nFieldStart = aDBRange.aStart.Col();
1778 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
1779 {
1780 if ( rSubTotalParam.bGroupActive[i] )
1781 {
1782 if ( rSubTotalParam.nField[i] >= nFieldStart )
1783 rSubTotalParam.nField[i] = sal::static_int_cast<SCCOL>( rSubTotalParam.nField[i] - nFieldStart );
1784 for (SCCOL j=0; j<rSubTotalParam.nSubTotals[i]; j++)
1785 if ( rSubTotalParam.pSubTotals[i][j] >= nFieldStart )
1786 rSubTotalParam.pSubTotals[i][j] =
1787 sal::static_int_cast<SCCOL>( rSubTotalParam.pSubTotals[i][j] - nFieldStart );
1788 }
1789 }
1790}
1791
1793{
1794 const ScDBData* pData = GetDBData_Impl();
1795 if (!pData)
1796 return;
1797
1798 // FilterDescriptor contains the counted fields inside the area
1799 ScSubTotalParam aParam(rSubTotalParam);
1800 ScRange aDBRange;
1801 pData->GetArea(aDBRange);
1802 SCCOL nFieldStart = aDBRange.aStart.Col();
1803 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
1804 {
1805 if ( aParam.bGroupActive[i] )
1806 {
1807 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
1808 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
1809 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
1810 }
1811 }
1812
1813 ScDBData aNewData( *pData );
1814 aNewData.SetSubTotalParam(aParam);
1815 ScDBDocFunc aFunc(*pDocShell);
1816 aFunc.ModifyDBData(aNewData);
1817}
1818
1819uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScDatabaseRangeObj::getSubTotalDescriptor()
1820{
1821 SolarMutexGuard aGuard;
1822 return new ScRangeSubTotalDescriptor(this);
1823}
1824
1825uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getImportDescriptor()
1826{
1827 SolarMutexGuard aGuard;
1828 ScImportParam aParam;
1829 const ScDBData* pData = GetDBData_Impl();
1830 if (pData)
1831 pData->GetImportParam(aParam);
1832
1833 uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
1835 return aSeq;
1836}
1837
1838// XRefreshable
1839
1841{
1842 SolarMutexGuard aGuard;
1844 if ( !(pDocShell && pData) )
1845 return;
1846
1847 ScDBDocFunc aFunc(*pDocShell);
1848
1849 // repeat import?
1850 bool bContinue = true;
1851 ScImportParam aImportParam;
1852 pData->GetImportParam( aImportParam );
1853 if (aImportParam.bImport && !pData->HasImportSelection())
1854 {
1855 SCTAB nTab;
1856 SCCOL nDummyCol;
1857 SCROW nDummyRow;
1858 pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow );
1859 bContinue = aFunc.DoImport( nTab, aImportParam, nullptr );
1860 }
1861
1862 // if no error then internal operations (sort, query, subtotal)
1863 if (bContinue)
1864 aFunc.RepeatDB( pData->GetName(), true, bIsUnnamed, aTab );
1865}
1866
1868 const uno::Reference<util::XRefreshListener >& xListener )
1869{
1870 SolarMutexGuard aGuard;
1871 aRefreshListeners.emplace_back( xListener );
1872
1873 // hold one additional ref to keep this object alive as long as there are listeners
1874 if ( aRefreshListeners.size() == 1 )
1875 acquire();
1876}
1877
1879 const uno::Reference<util::XRefreshListener >& xListener )
1880{
1881 SolarMutexGuard aGuard;
1882 sal_uInt16 nCount = aRefreshListeners.size();
1883 for ( sal_uInt16 n=nCount; n--; )
1884 {
1885 uno::Reference<util::XRefreshListener>& rObj = aRefreshListeners[n];
1886 if ( rObj == xListener )
1887 {
1888 aRefreshListeners.erase( aRefreshListeners.begin() + n );
1889 if ( aRefreshListeners.empty() )
1890 release(); // release ref for listeners
1891 break;
1892 }
1893 }
1894}
1895
1897{
1898 lang::EventObject aEvent;
1899 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1900 for (uno::Reference<util::XRefreshListener> & xRefreshListener : aRefreshListeners)
1901 xRefreshListener->refreshed( aEvent );
1902}
1903
1904// XCellRangeSource
1905
1906uno::Reference<table::XCellRange> SAL_CALL ScDatabaseRangeObj::getReferredCells()
1907{
1908 SolarMutexGuard aGuard;
1910 if ( pData )
1911 {
1913 ScRange aRange;
1914
1915 pData->GetArea(aRange);
1916 if ( aRange.aStart == aRange.aEnd )
1917 return new ScCellObj( pDocShell, aRange.aStart );
1918 else
1919 return new ScCellRangeObj( pDocShell, aRange );
1920 }
1921 return nullptr;
1922}
1923
1924// XPropertySet
1925
1926uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDatabaseRangeObj::getPropertySetInfo()
1927{
1928 SolarMutexGuard aGuard;
1929 static uno::Reference<beans::XPropertySetInfo> aRef(
1931 return aRef;
1932}
1933
1935 const OUString& aPropertyName, const uno::Any& aValue )
1936{
1937 SolarMutexGuard aGuard;
1939 if ( !(pDocShell && pData) )
1940 return;
1941
1942 ScDBData aNewData( *pData );
1943 bool bDo = true;
1944
1945 if ( aPropertyName == SC_UNONAME_KEEPFORM )
1946 aNewData.SetKeepFmt( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1947 else if ( aPropertyName == SC_UNONAME_MOVCELLS )
1948 aNewData.SetDoSize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1949 else if ( aPropertyName == SC_UNONAME_STRIPDAT )
1951 else if (aPropertyName == SC_UNONAME_AUTOFLT )
1952 {
1953 bool bAutoFilter(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1954 aNewData.SetAutoFilter(bAutoFilter);
1955 ScRange aRange;
1956 aNewData.GetArea(aRange);
1957 ScDocument& rDoc = pDocShell->GetDocument();
1958 if (bAutoFilter)
1959 rDoc.ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
1960 aRange.aEnd.Col(), aRange.aStart.Row(),
1961 aRange.aStart.Tab(), ScMF::Auto );
1962 else if (!bAutoFilter)
1963 rDoc.RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(),
1964 aRange.aEnd.Col(), aRange.aStart.Row(),
1965 aRange.aStart.Tab(), ScMF::Auto );
1966 ScRange aPaintRange(aRange.aStart, aRange.aEnd);
1967 aPaintRange.aEnd.SetRow(aPaintRange.aStart.Row());
1969 }
1970 else if (aPropertyName == SC_UNONAME_USEFLTCRT )
1971 {
1973 {
1974 // only here to set bIsAdvanced in ScDBData
1975 ScRange aRange;
1976 (void)aNewData.GetAdvancedQuerySource(aRange);
1977 aNewData.SetAdvancedQuerySource(&aRange);
1978 }
1979 else
1980 aNewData.SetAdvancedQuerySource(nullptr);
1981 }
1982 else if (aPropertyName == SC_UNONAME_FLTCRT )
1983 {
1984 table::CellRangeAddress aRange;
1985 if (aValue >>= aRange)
1986 {
1987 ScRange aCoreRange;
1988 ScUnoConversion::FillScRange(aCoreRange, aRange);
1989
1990 aNewData.SetAdvancedQuerySource(&aCoreRange);
1991 }
1992 }
1993 else if (aPropertyName == SC_UNONAME_FROMSELECT )
1994 {
1995 aNewData.SetImportSelection(::cppu::any2bool(aValue));
1996 }
1997 else if (aPropertyName == SC_UNONAME_REFPERIOD )
1998 {
1999 sal_Int32 nRefresh = 0;
2000 if (aValue >>= nRefresh)
2001 {
2002 ScDocument& rDoc = pDocShell->GetDocument();
2003 aNewData.SetRefreshDelay(nRefresh);
2004 if (rDoc.GetDBCollection())
2005 {
2008 }
2009 }
2010 }
2011 else if (aPropertyName == SC_UNONAME_CONRES )
2012 {
2013 }
2014 else if ( aPropertyName == SC_UNONAME_TOTALSROW )
2015 aNewData.SetTotals( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
2016 else if ( aPropertyName == SC_UNONAME_CONTHDR )
2017 aNewData.SetHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
2018 else
2019 bDo = false;
2020
2021 if (bDo)
2022 {
2023 ScDBDocFunc aFunc(*pDocShell);
2024 aFunc.ModifyDBData(aNewData);
2025 }
2026}
2027
2028uno::Any SAL_CALL ScDatabaseRangeObj::getPropertyValue( const OUString& aPropertyName )
2029{
2030 SolarMutexGuard aGuard;
2031 uno::Any aRet;
2033 if ( pData )
2034 {
2035 if ( aPropertyName == SC_UNONAME_KEEPFORM )
2036 aRet <<= pData->IsKeepFmt();
2037 else if ( aPropertyName == SC_UNONAME_MOVCELLS )
2038 aRet <<= pData->IsDoSize();
2039 else if ( aPropertyName == SC_UNONAME_STRIPDAT )
2040 aRet <<= pData->IsStripData();
2041 else if ( aPropertyName == SC_UNONAME_ISUSER )
2042 {
2043 // all database ranges except "unnamed" are user defined
2044 aRet <<= (pData->GetName() != STR_DB_LOCAL_NONAME);
2045 }
2046 else if ( aPropertyName == SC_UNO_LINKDISPBIT )
2047 {
2048 // no target bitmaps for individual entries (would be all equal)
2049 // ScLinkTargetTypeObj::SetLinkTargetBitmap( aRet, SC_LINKTARGETTYPE_DBAREA );
2050 }
2051 else if ( aPropertyName == SC_UNO_LINKDISPNAME )
2052 aRet <<= aName;
2053 else if (aPropertyName == SC_UNONAME_AUTOFLT )
2054 {
2055 bool bAutoFilter(GetDBData_Impl()->HasAutoFilter());
2056
2057 aRet <<= bAutoFilter;
2058 }
2059 else if (aPropertyName == SC_UNONAME_USEFLTCRT )
2060 {
2061 ScRange aRange;
2062 bool bIsAdvancedSource(GetDBData_Impl()->GetAdvancedQuerySource(aRange));
2063
2064 aRet <<= bIsAdvancedSource;
2065 }
2066 else if (aPropertyName == SC_UNONAME_FLTCRT )
2067 {
2068 table::CellRangeAddress aRange;
2069 ScRange aCoreRange;
2070 if (GetDBData_Impl()->GetAdvancedQuerySource(aCoreRange))
2071 ScUnoConversion::FillApiRange(aRange, aCoreRange);
2072
2073 aRet <<= aRange;
2074 }
2075 else if (aPropertyName == SC_UNONAME_FROMSELECT )
2076 {
2077 aRet <<= GetDBData_Impl()->HasImportSelection();
2078 }
2079 else if (aPropertyName == SC_UNONAME_REFPERIOD )
2080 {
2081 sal_Int32 nRefresh(GetDBData_Impl()->GetRefreshDelaySeconds());
2082 aRet <<= nRefresh;
2083 }
2084 else if (aPropertyName == SC_UNONAME_CONRES )
2085 {
2086 }
2087 else if (aPropertyName == SC_UNONAME_TOKENINDEX )
2088 {
2089 // get index for use in formula tokens (read-only)
2090 aRet <<= static_cast<sal_Int32>(GetDBData_Impl()->GetIndex());
2091 }
2092 else if (aPropertyName == SC_UNONAME_TOTALSROW )
2093 {
2094 bool bTotals(GetDBData_Impl()->HasTotals());
2095
2096 aRet <<= bTotals;
2097 }
2098 else if (aPropertyName == SC_UNONAME_CONTHDR )
2099 {
2100 bool bHeader(GetDBData_Impl()->HasHeader());
2101
2102 aRet <<= bHeader;
2103 }
2104 }
2105 return aRet;
2106}
2107
2109
2110// XServiceInfo
2111OUString SAL_CALL ScDatabaseRangeObj::getImplementationName()
2112{
2113 return "ScDatabaseRangeObj";
2114}
2115
2116sal_Bool SAL_CALL ScDatabaseRangeObj::supportsService( const OUString& rServiceName )
2117{
2118 return cppu::supportsService(this, rServiceName);
2119}
2120
2121uno::Sequence<OUString> SAL_CALL ScDatabaseRangeObj::getSupportedServiceNames()
2122{
2123 return {"com.sun.star.sheet.DatabaseRange",
2125}
2126
2128 pDocShell( pDocSh )
2129{
2131}
2132
2134{
2136
2137 if (pDocShell)
2139}
2140
2142{
2143 // reference update does not matter here
2144
2145 if ( rHint.GetId() == SfxHintId::Dying )
2146 {
2147 pDocShell = nullptr;
2148 }
2149}
2150
2151// XDatabaseRanges
2152
2154{
2155 if (!pDocShell)
2156 return nullptr;
2157
2159 if (!pNames)
2160 return nullptr;
2161
2162 const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
2163 if (rDBs.empty() || nIndex >= rDBs.size())
2164 return nullptr;
2165
2167 ::std::advance(itr, nIndex); // boundary check is done above.
2168 return new ScDatabaseRangeObj(pDocShell, (*itr)->GetName());
2169}
2170
2172{
2173 if ( pDocShell && hasByName(aName) )
2174 {
2175 return new ScDatabaseRangeObj( pDocShell, aName );
2176 }
2177 return nullptr;
2178}
2179
2180void SAL_CALL ScDatabaseRangesObj::addNewByName( const OUString& aName,
2181 const table::CellRangeAddress& aRange )
2182{
2183 SolarMutexGuard aGuard;
2184 bool bDone = false;
2185 if (pDocShell)
2186 {
2187 ScDBDocFunc aFunc(*pDocShell);
2188
2189 ScRange aNameRange( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet,
2190 static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet );
2191 bDone = aFunc.AddDBRange( aName, aNameRange );
2192 }
2193 if (!bDone)
2194 throw uno::RuntimeException(); // no other exceptions specified
2195}
2196
2197void SAL_CALL ScDatabaseRangesObj::removeByName( const OUString& aName )
2198{
2199 SolarMutexGuard aGuard;
2200 bool bDone = false;
2201 if (pDocShell)
2202 {
2203 ScDBDocFunc aFunc(*pDocShell);
2204 bDone = aFunc.DeleteDBRange( aName );
2205 }
2206 if (!bDone)
2207 throw uno::RuntimeException(); // no other exceptions specified
2208}
2209
2210// XEnumerationAccess
2211
2212uno::Reference<container::XEnumeration> SAL_CALL ScDatabaseRangesObj::createEnumeration()
2213{
2214 SolarMutexGuard aGuard;
2215 return new ScIndexEnumeration(this, "com.sun.star.sheet.DatabaseRangesEnumeration");
2216}
2217
2218// XIndexAccess
2219
2221{
2222 SolarMutexGuard aGuard;
2223
2225
2226 if (pDocShell)
2227 {
2229 if (pNames)
2230 return static_cast<sal_Int32>(pNames->getNamedDBs().size());
2231 }
2232 return 0;
2233}
2234
2235uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex )
2236{
2237 SolarMutexGuard aGuard;
2238 if (nIndex < 0)
2239 throw lang::IndexOutOfBoundsException();
2240
2241 uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl(static_cast<size_t>(nIndex)));
2242 if (!xRange.is())
2243 throw lang::IndexOutOfBoundsException();
2244
2245 return uno::Any(xRange);
2246}
2247
2249{
2251}
2252
2254{
2255 SolarMutexGuard aGuard;
2256 return ( getCount() != 0 );
2257}
2258
2259// XNameAccess
2260
2261uno::Any SAL_CALL ScDatabaseRangesObj::getByName( const OUString& aName )
2262{
2263 SolarMutexGuard aGuard;
2264 uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByName_Impl(aName));
2265 if (!xRange.is())
2266 throw container::NoSuchElementException();
2267
2268 return uno::Any(xRange);
2269}
2270
2271uno::Sequence<OUString> SAL_CALL ScDatabaseRangesObj::getElementNames()
2272{
2273 SolarMutexGuard aGuard;
2274
2276
2277 if (pDocShell)
2278 {
2280 if (pNames)
2281 {
2282 const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
2283 uno::Sequence<OUString> aSeq(rDBs.size());
2284 auto aSeqRange = asNonConstRange(aSeq);
2285 size_t i = 0;
2286 for (const auto& rDB : rDBs)
2287 {
2288 aSeqRange[i] = rDB->GetName();
2289 ++i;
2290 }
2291
2292 return aSeq;
2293 }
2294 }
2295 return {};
2296}
2297
2298sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const OUString& aName )
2299{
2300 SolarMutexGuard aGuard;
2301
2303
2304 if (pDocShell)
2305 {
2307 if (pNames)
2308 return pNames->getNamedDBs().findByUpperName(ScGlobal::getCharClass().uppercase(aName)) != nullptr;
2309 }
2310 return false;
2311}
2312
2314 pDocShell( pDocSh )
2315{
2317}
2318
2320{
2322
2323 if (pDocShell)
2325}
2326
2328{
2329 // reference update does not matter here
2330
2331 if ( rHint.GetId() == SfxHintId::Dying )
2332 {
2333 pDocShell = nullptr;
2334 }
2335}
2336
2337// XUnnamedDatabaseRanges
2338
2339void ScUnnamedDatabaseRangesObj::setByTable( const table::CellRangeAddress& aRange )
2340{
2341 SolarMutexGuard aGuard;
2342 bool bDone = false;
2343 if (pDocShell)
2344 {
2345 if ( pDocShell->GetDocument().GetTableCount() <= aRange.Sheet )
2346 throw lang::IndexOutOfBoundsException();
2347
2348 ScDBDocFunc aFunc(*pDocShell);
2349 ScRange aUnnamedRange( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet,
2350 static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet );
2351 bDone = aFunc.AddDBRange( STR_DB_LOCAL_NONAME, aUnnamedRange );
2352 }
2353 if (!bDone)
2354 throw uno::RuntimeException(); // no other exceptions specified
2355}
2356
2358{
2359 SolarMutexGuard aGuard;
2360 if (!pDocShell)
2361 throw uno::RuntimeException();
2362
2363 if ( pDocShell->GetDocument().GetTableCount() <= nTab )
2364 throw lang::IndexOutOfBoundsException();
2365 uno::Reference<sheet::XDatabaseRange> xRange(
2366 new ScDatabaseRangeObj(pDocShell, static_cast<SCTAB>(nTab)));
2367 if (!xRange.is())
2368 throw container::NoSuchElementException();
2369
2370 return uno::Any(xRange);
2371}
2372
2374{
2375 SolarMutexGuard aGuard;
2376 if (pDocShell)
2377 {
2378 if (pDocShell->GetDocument().GetTableCount() <= nTab)
2379 throw lang::IndexOutOfBoundsException();
2380 if (pDocShell->GetDocument().GetAnonymousDBData(static_cast<SCTAB>(nTab)))
2381 return true;
2382 return false;
2383 }
2384 else
2385 return false;
2386}
2387
2388/* 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
WeakReference< XInterface > 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:645
virtual sal_Bool SAL_CALL getUseColumnHeaders() override
Definition: datauno.cxx:871
virtual css::table::CellAddress SAL_CALL getStartOutputPosition() override
Definition: datauno.cxx:852
virtual sal_Bool SAL_CALL getUseRowHeaders() override
Definition: datauno.cxx:883
ScConsolidateParam aParam
Definition: datauno.hxx:238
virtual ~ScConsolidationDescriptor() override
Definition: datauno.cxx:786
virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL getSources() override
Definition: datauno.cxx:809
virtual void SAL_CALL setUseRowHeaders(sal_Bool bUseRowHeaders) override
Definition: datauno.cxx:889
virtual sal_Bool SAL_CALL getInsertLinks() override
Definition: datauno.cxx:895
virtual void SAL_CALL setFunction(css::sheet::GeneralFunction nFunction) override
Definition: datauno.cxx:803
virtual void SAL_CALL setSources(const css::uno::Sequence< css::table::CellRangeAddress > &aSources) override
Definition: datauno.cxx:831
virtual void SAL_CALL setUseColumnHeaders(sal_Bool bUseColumnHeaders) override
Definition: datauno.cxx:877
virtual void SAL_CALL setInsertLinks(sal_Bool bInsertLinks) override
Definition: datauno.cxx:901
virtual void SAL_CALL setStartOutputPosition(const css::table::CellAddress &aStartOutputPosition) override
Definition: datauno.cxx:862
virtual css::sheet::GeneralFunction SAL_CALL getFunction() override
Definition: datauno.cxx:797
void SetParam(const ScConsolidateParam &rNew)
Definition: datauno.cxx:790
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:480
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:300
SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange &rSource) const
Definition: dbdata.cxx:457
void SetAutoFilter(bool bSet)
Definition: dbdata.hxx:213
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
Definition: dbdata.cxx:475
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:446
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:437
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:322
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:1529
virtual void GetData(ScQueryParam &rParam) const override
Definition: datauno.cxx:1539
virtual void PutData(const ScQueryParam &rParam) override
Definition: datauno.cxx:1549
virtual ~ScDataPilotFilterDescriptor() override
Definition: datauno.cxx:1535
rtl::Reference< ScDataPilotDescriptorBase > mxParent
Definition: datauno.hxx:382
static css::sheet::GeneralFunction SubTotalToGeneral(ScSubTotalFunc eSubTotal)
Definition: datauno.cxx:140
ScDocShell * pDocShell
Definition: datauno.hxx:403
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getImportDescriptor() override
Definition: datauno.cxx:1825
virtual css::uno::Reference< css::sheet::XSubTotalDescriptor > SAL_CALL getSubTotalDescriptor() override
Definition: datauno.cxx:1819
void SetQueryParam(const ScQueryParam &rQueryParam)
Definition: datauno.cxx:1733
ScDBData * GetDBData_Impl() const
Definition: datauno.cxx:1611
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getSortDescriptor() override
Definition: datauno.cxx:1689
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: datauno.cxx:2116
virtual void SAL_CALL setName(const OUString &aName) override
Definition: datauno.cxx:1642
std::vector< css::uno::Reference< css::util::XRefreshListener > > aRefreshListeners
Definition: datauno.hxx:407
void GetSubTotalParam(ScSubTotalParam &rSubTotalParam) const
Definition: datauno.cxx:1766
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: datauno.cxx:1934
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: datauno.cxx:1878
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
Definition: datauno.cxx:1792
virtual void SAL_CALL refresh() override
Definition: datauno.cxx:1840
virtual OUString SAL_CALL getName() override
Definition: datauno.cxx:1636
ScDatabaseRangeObj(ScDocShell *pDocSh, OUString aNm)
Definition: datauno.cxx:1566
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: datauno.cxx:1867
virtual ~ScDatabaseRangeObj() override
Definition: datauno.cxx:1586
virtual css::table::CellRangeAddress SAL_CALL getDataArea() override
Definition: datauno.cxx:1656
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: datauno.cxx:2121
SfxItemPropertySet aPropSet
Definition: datauno.hxx:405
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:1594
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: datauno.cxx:1926
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getReferredCells() override
Definition: datauno.cxx:1906
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: datauno.cxx:2028
void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: datauno.cxx:1712
virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL getFilterDescriptor() override
Definition: datauno.cxx:1760
virtual void SAL_CALL setDataArea(const css::table::CellRangeAddress &aDataArea) override
Definition: datauno.cxx:1674
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: datauno.cxx:2235
virtual ~ScDatabaseRangesObj() override
Definition: datauno.cxx:2133
ScDatabaseRangesObj(ScDocShell *pDocSh)
Definition: datauno.cxx:2127
virtual css::uno::Type SAL_CALL getElementType() override
Definition: datauno.cxx:2248
ScDocShell * pDocShell
Definition: datauno.hxx:489
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: datauno.cxx:2261
virtual void SAL_CALL addNewByName(const OUString &aName, const css::table::CellRangeAddress &aRange) override
Definition: datauno.cxx:2180
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: datauno.cxx:2298
rtl::Reference< ScDatabaseRangeObj > GetObjectByIndex_Impl(size_t nIndex)
Definition: datauno.cxx:2153
virtual sal_Bool SAL_CALL hasElements() override
Definition: datauno.cxx:2253
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: datauno.cxx:2212
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: datauno.cxx:2271
virtual sal_Int32 SAL_CALL getCount() override
Definition: datauno.cxx:2220
virtual void SAL_CALL removeByName(const OUString &aName) override
Definition: datauno.cxx:2197
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:2141
rtl::Reference< ScDatabaseRangeObj > GetObjectByName_Impl(const OUString &aName)
Definition: datauno.cxx:2171
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
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:5094
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
Definition: document.hxx:2515
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5083
void AddUnoObject(SfxListener &rObject)
Definition: documen3.cxx:907
void GetFilterEntries(SCCOL nCol, SCROW nRow, SCTAB nTab, ScFilterEntries &rFilterEntries)
Get a list of unique strings to use in filtering criteria.
Definition: documen3.cxx:1567
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:826
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:603
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
void RemoveUnoObject(SfxListener &rObject)
Definition: documen3.cxx:915
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
Definition: document.cxx:310
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
ScFilterDescriptorBase(ScDocShell *pDocShell)
Definition: datauno.cxx:907
ScDocShell * pDocSh
Definition: datauno.hxx:284
virtual void GetData(ScQueryParam &rParam) const =0
virtual void SAL_CALL setFilterFields3(const css::uno::Sequence< css::sheet::TableFilterField3 > &aFilterFields) override
Definition: datauno.cxx:1374
virtual ~ScFilterDescriptorBase() override
Definition: datauno.cxx:915
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:923
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: datauno.cxx:1388
virtual css::uno::Sequence< css::sheet::TableFilterField3 > SAL_CALL getFilterFields3() override
Definition: datauno.cxx:1239
virtual void SAL_CALL setFilterFields2(const css::uno::Sequence< css::sheet::TableFilterField2 > &aFilterFields) override
Definition: datauno.cxx:1364
SfxItemPropertySet aPropSet
Definition: datauno.hxx:283
virtual void PutData(const ScQueryParam &rParam)=0
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: datauno.cxx:1440
virtual css::uno::Sequence< css::sheet::TableFilterField2 > SAL_CALL getFilterFields2() override
Definition: datauno.cxx:1189
virtual css::uno::Sequence< css::sheet::TableFilterField > SAL_CALL getFilterFields() override
Definition: datauno.cxx:933
virtual void SAL_CALL setFilterFields(const css::uno::Sequence< css::sheet::TableFilterField > &aFilterFields) override
Definition: datauno.cxx:1299
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: datauno.cxx:1396
void SetParam(const ScQueryParam &rNew)
Definition: datauno.cxx:1502
virtual void PutData(const ScQueryParam &rParam) override
Definition: datauno.cxx:1497
ScQueryParam aStoredParam
Definition: datauno.hxx:346
virtual ~ScFilterDescriptor() override
Definition: datauno.cxx:1488
virtual void GetData(ScQueryParam &rParam) const override
Definition: datauno.cxx:1492
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1062
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:82
virtual void PutData(const ScQueryParam &rParam) override
Definition: datauno.cxx:1523
rtl::Reference< ScDatabaseRangeObj > mxParent
Definition: datauno.hxx:366
virtual void GetData(ScQueryParam &rParam) const override
Definition: datauno.cxx:1517
virtual ~ScRangeFilterDescriptor() override
Definition: datauno.cxx:1513
ScRangeFilterDescriptor(ScDocShell *pDocSh, ScDatabaseRangeObj *pPar)
Definition: datauno.cxx:1507
virtual void GetData(ScSubTotalParam &rParam) const override
Definition: datauno.cxx:770
virtual ~ScRangeSubTotalDescriptor() override
Definition: datauno.cxx:766
virtual void PutData(const ScSubTotalParam &rParam) override
Definition: datauno.cxx:776
rtl::Reference< ScDatabaseRangeObj > mxParent
Definition: datauno.hxx:196
ScRangeSubTotalDescriptor(ScDatabaseRangeObj *pPar)
Definition: datauno.cxx:761
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:97
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:117
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:742
virtual void PutData(const ScSubTotalParam &rParam) override
Definition: datauno.cxx:751
void SetParam(const ScSubTotalParam &rNew)
Definition: datauno.cxx:756
ScSubTotalParam aStoredParam
Definition: datauno.hxx:177
virtual void GetData(ScSubTotalParam &rParam) const override
Definition: datauno.cxx:746
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:213
rtl::Reference< ScSubTotalDescriptorBase > xParent
Definition: datauno.hxx:212
virtual sal_Int32 SAL_CALL getGroupColumn() override
Definition: datauno.cxx:456
ScUnnamedDatabaseRangesObj(ScDocShell *pDocSh)
Definition: datauno.cxx:2313
virtual css::uno::Any SAL_CALL getByTable(sal_Int32 nTab) override
Definition: datauno.cxx:2357
virtual sal_Bool SAL_CALL hasByTable(sal_Int32 nTab) override
Definition: datauno.cxx:2373
virtual void SAL_CALL setByTable(const css::table::CellRangeAddress &aRange) override
Definition: datauno.cxx:2339
virtual ~ScUnnamedDatabaseRangesObj() override
Definition: datauno.cxx:2319
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: datauno.cxx:2327
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
UNO3_GETIMPLEMENTATION_IMPL(ScSubTotalDescriptorBase)
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2,...
const SCSIZE MAXSUBTOTAL
Definition: global.hxx:82
@ SC_OR
Definition: global.hxx:855
@ SC_AND
Definition: global.hxx:854
ScSubTotalFunc
Definition: global.hxx:859
@ SUBTOTAL_FUNC_STDP
Definition: global.hxx:868
@ SUBTOTAL_FUNC_MAX
Definition: global.hxx:864
@ SUBTOTAL_FUNC_CNT2
Definition: global.hxx:863
@ SUBTOTAL_FUNC_AVE
Definition: global.hxx:861
@ SUBTOTAL_FUNC_VARP
Definition: global.hxx:871
@ SUBTOTAL_FUNC_VAR
Definition: global.hxx:870
@ SUBTOTAL_FUNC_NONE
Definition: global.hxx:860
@ SUBTOTAL_FUNC_SUM
Definition: global.hxx:869
@ SUBTOTAL_FUNC_STD
Definition: global.hxx:867
@ SUBTOTAL_FUNC_MIN
Definition: global.hxx:865
@ SUBTOTAL_FUNC_CNT
Definition: global.hxx:862
@ SUBTOTAL_FUNC_PROD
Definition: global.hxx:866
@ ScDbQuery
Definition: global.hxx:420
@ ScDbTable
Definition: global.hxx:419
@ SC_DOES_NOT_CONTAIN
Definition: global.hxx:845
@ SC_LESS_EQUAL
Definition: global.hxx:837
@ SC_LESS
Definition: global.hxx:835
@ SC_GREATER_EQUAL
Definition: global.hxx:838
@ SC_CONTAINS
Definition: global.hxx:844
@ SC_TOPPERC
Definition: global.hxx:842
@ SC_ENDS_WITH
Definition: global.hxx:848
@ SC_DOES_NOT_END_WITH
Definition: global.hxx:849
@ SC_BEGINS_WITH
Definition: global.hxx:846
@ SC_TOPVAL
Definition: global.hxx:840
@ SC_GREATER
Definition: global.hxx:836
@ SC_EQUAL
Definition: global.hxx:834
@ SC_BOTPERC
Definition: global.hxx:843
@ SC_NOT_EQUAL
Definition: global.hxx:839
@ SC_DOES_NOT_BEGIN_WITH
Definition: global.hxx:847
@ SC_BOTVAL
Definition: global.hxx:841
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:907
void ClearDataAreas()
Definition: global2.cxx:119
std::unique_ptr< ScArea[]> pDataAreas
Definition: global.hxx:908
ScSubTotalFunc eFunction
Definition: global.hxx:906
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:50
OUString aStatement
Definition: global.hxx:446
sal_uInt8 nType
Definition: global.hxx:449
OUString aDBName
Definition: global.hxx:445
bool bNative
Definition: global.hxx:447
bool bImport
Definition: global.hxx:444
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:117
SCROW nDestRow
Definition: sortparam.hxx:119
SCCOL nDestCol
Definition: sortparam.hxx:118
::std::vector< ScSortKeyState > maKeyState
Definition: sortparam.hxx:121
OUString aCollatorAlgorithm
Definition: sortparam.hxx:123
bool bHasHeader
Definition: sortparam.hxx:111
ScDataAreaExtras aDataAreaExtras
Definition: sortparam.hxx:109
css::lang::Locale aCollatorLocale
Definition: sortparam.hxx:122
sal_uInt16 nUserIndex
Definition: sortparam.hxx:110
sal_uInt16 GetSortKeyCount() const
Definition: sortparam.hxx:139
bool bCaseSens
Definition: sortparam.hxx:113
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:317
constexpr OUStringLiteral SC_UNONAME_TOKENINDEX
Definition: unonames.hxx:318
constexpr OUStringLiteral SC_UNONAME_OUTPOS
Definition: unonames.hxx:301
constexpr OUStringLiteral SC_UNONAME_SRCOBJ
Definition: unonames.hxx:291
constexpr OUStringLiteral SC_UNONAME_ORIENT
Definition: unonames.hxx:304
constexpr OUStringLiteral SC_UNONAME_COLLLOC
Definition: unonames.hxx:310
constexpr OUStringLiteral SC_UNONAME_CASE
Definition: unonames.hxx:279
constexpr OUStringLiteral SC_UNONAME_FORMATS
Definition: unonames.hxx:281
constexpr OUStringLiteral SC_UNONAME_SORTFLD
Definition: unonames.hxx:306
constexpr OUStringLiteral SC_UNONAME_USEREGEX
Definition: unonames.hxx:294
constexpr OUStringLiteral SC_UNONAME_TOTALSROW
Definition: unonames.hxx:320
constexpr OUStringLiteral SC_UNONAME_UINDEX
Definition: unonames.hxx:296
constexpr OUStringLiteral SC_UNONAME_COPYOUT
Definition: unonames.hxx:298
constexpr OUStringLiteral SC_UNONAME_ISNATIVE
Definition: unonames.hxx:286
constexpr OUStringLiteral SC_UNONAME_FROMSELECT
Definition: unonames.hxx:316
constexpr OUStringLiteral SC_UNONAME_STRIPDAT
Definition: unonames.hxx:293
constexpr OUStringLiteral SC_UNONAME_FLTCRT
Definition: unonames.hxx:313
constexpr OUStringLiteral SC_UNONAME_COLLALG
Definition: unonames.hxx:311
constexpr OUStringLiteral SC_UNONAME_AUTOFLT
Definition: unonames.hxx:312
constexpr OUStringLiteral SC_UNONAME_DBNAME
Definition: unonames.hxx:280
constexpr OUStringLiteral SC_UNONAME_ISUSER
Definition: unonames.hxx:285
constexpr OUStringLiteral SC_UNO_LINKDISPBIT
Definition: unonames.hxx:190
constexpr OUStringLiteral SC_UNONAME_SKIPDUP
Definition: unonames.hxx:290
constexpr OUStringLiteral SC_UNONAME_ISCASE
Definition: unonames.hxx:299
constexpr OUStringLiteral SC_UNONAME_ULIST
Definition: unonames.hxx:295
constexpr OUStringLiteral SC_UNONAME_SRCTYPE
Definition: unonames.hxx:292
constexpr OUStringLiteral SC_UNONAME_MAXFLD
Definition: unonames.hxx:303
constexpr OUStringLiteral SC_UNONAME_SORTASC
Definition: unonames.hxx:307
constexpr OUStringLiteral SC_UNONAME_INSBRK
Definition: unonames.hxx:282
constexpr OUStringLiteral SC_UNONAME_SAVEOUT
Definition: unonames.hxx:289
constexpr OUStringLiteral SC_UNONAME_REFPERIOD
Definition: unonames.hxx:370
constexpr OUStringLiteral SC_UNONAME_ENUSLIST
Definition: unonames.hxx:308
constexpr OUStringLiteral SC_UNONAME_BINDFMT
Definition: unonames.hxx:297
constexpr OUStringLiteral SC_UNONAME_ISSORTCOLUMNS
Definition: unonames.hxx:305
constexpr OUStringLiteral SC_UNONAME_USINDEX
Definition: unonames.hxx:309
constexpr OUStringLiteral SC_UNONAME_MOVCELLS
Definition: unonames.hxx:284
constexpr OUStringLiteral SC_UNO_LINKDISPNAME
Definition: unonames.hxx:191
constexpr OUStringLiteral SC_UNONAME_ISULIST
Definition: unonames.hxx:300
constexpr OUStringLiteral SC_UNONAME_KEEPFORM
Definition: unonames.hxx:283
constexpr OUStringLiteral SC_UNONAME_USEFLTCRT
Definition: unonames.hxx:314
constexpr OUStringLiteral SC_UNONAME_ENABSORT
Definition: unonames.hxx:315
constexpr OUStringLiteral SC_UNONAME_CONTHDR
Definition: unonames.hxx:302