1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datauno.cxx,v $
10 * $Revision: 1.30.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include <tools/debug.hxx>
37 #include <svtools/smplhint.hxx>
38 #include <svtools/zforlist.hxx>
41 #include <com/sun/star/awt/XBitmap.hpp>
42 #include <com/sun/star/util/SortField.hpp>
43 #include <com/sun/star/table/TableSortField.hpp>
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
45 #include <com/sun/star/table/TableOrientation.hpp>
46 #include <com/sun/star/table/CellRangeAddress.hpp>
47 #include <com/sun/star/sheet/DataImportMode.hpp>
48 #include <com/sun/star/sheet/FilterOperator2.hpp>
49 #include <com/sun/star/sheet/TableFilterField2.hpp>
51 #include "datauno.hxx"
52 #include "dapiuno.hxx"
53 #include "cellsuno.hxx"
54 #include "miscuno.hxx"
55 #include "targuno.hxx"
56 #include "rangeutl.hxx"
57 #include "dbcolect.hxx"
59 #include "dbdocfun.hxx"
60 #include "unoguard.hxx"
61 #include "unonames.hxx"
62 #include "globstr.hrc"
63 #ifndef SC_CONVUNO_HXX
64 #include "convuno.hxx"
68 #include "dpshttab.hxx"
69 #include <comphelper/extract.hxx>
70 #include <svx/dataaccessdescriptor.hxx>
72 using namespace com::sun::star
;
74 SV_IMPL_PTRARR( XDBRefreshListenerArr_Impl
, XDBRefreshListenerPtr
);
76 //------------------------------------------------------------------------
78 // alles ohne Which-ID, Map nur fuer PropertySetInfo
80 const SfxItemPropertyMapEntry
* lcl_GetSubTotalPropertyMap()
82 // some old property names are for 5.2 compatibility
84 static SfxItemPropertyMapEntry aSubTotalPropertyMap_Impl
[] =
86 {MAP_CHAR_LEN(SC_UNONAME_BINDFMT
), 0, &getBooleanCppuType(), 0, 0},
87 {MAP_CHAR_LEN(SC_UNONAME_CASE
), 0, &getBooleanCppuType(), 0, 0},
88 {MAP_CHAR_LEN(SC_UNONAME_ENABSORT
), 0, &getBooleanCppuType(), 0, 0},
89 {MAP_CHAR_LEN(SC_UNONAME_ENUSLIST
), 0, &getBooleanCppuType(), 0, 0},
90 {MAP_CHAR_LEN(SC_UNONAME_FORMATS
), 0, &getBooleanCppuType(), 0, 0},
91 {MAP_CHAR_LEN(SC_UNONAME_INSBRK
), 0, &getBooleanCppuType(), 0, 0},
92 {MAP_CHAR_LEN(SC_UNONAME_ISCASE
), 0, &getBooleanCppuType(), 0, 0},
93 {MAP_CHAR_LEN(SC_UNONAME_MAXFLD
), 0, &getCppuType((sal_Int32
*)0), beans::PropertyAttribute::READONLY
, 0},
94 {MAP_CHAR_LEN(SC_UNONAME_SORTASC
), 0, &getBooleanCppuType(), 0, 0},
95 {MAP_CHAR_LEN(SC_UNONAME_ULIST
), 0, &getBooleanCppuType(), 0, 0},
96 {MAP_CHAR_LEN(SC_UNONAME_UINDEX
), 0, &getCppuType((sal_Int32
*)0), 0, 0},
97 {MAP_CHAR_LEN(SC_UNONAME_USINDEX
), 0, &getCppuType((sal_Int32
*)0), 0, 0},
100 return aSubTotalPropertyMap_Impl
;
103 const SfxItemPropertyMapEntry
* lcl_GetFilterPropertyMap()
105 static SfxItemPropertyMapEntry aFilterPropertyMap_Impl
[] =
107 {MAP_CHAR_LEN(SC_UNONAME_CONTHDR
), 0, &getBooleanCppuType(), 0, 0},
108 {MAP_CHAR_LEN(SC_UNONAME_COPYOUT
), 0, &getBooleanCppuType(), 0, 0},
109 {MAP_CHAR_LEN(SC_UNONAME_ISCASE
), 0, &getBooleanCppuType(), 0, 0},
110 {MAP_CHAR_LEN(SC_UNONAME_MAXFLD
), 0, &getCppuType((sal_Int32
*)0), beans::PropertyAttribute::READONLY
, 0},
111 {MAP_CHAR_LEN(SC_UNONAME_ORIENT
), 0, &getCppuType((table::TableOrientation
*)0), 0, 0},
112 {MAP_CHAR_LEN(SC_UNONAME_OUTPOS
), 0, &getCppuType((table::CellAddress
*)0), 0, 0},
113 {MAP_CHAR_LEN(SC_UNONAME_SAVEOUT
), 0, &getBooleanCppuType(), 0, 0},
114 {MAP_CHAR_LEN(SC_UNONAME_SKIPDUP
), 0, &getBooleanCppuType(), 0, 0},
115 {MAP_CHAR_LEN(SC_UNONAME_USEREGEX
), 0, &getBooleanCppuType(), 0, 0},
118 return aFilterPropertyMap_Impl
;
121 const SfxItemPropertyMapEntry
* lcl_GetDBRangePropertyMap()
123 static SfxItemPropertyMapEntry aDBRangePropertyMap_Impl
[] =
125 {MAP_CHAR_LEN(SC_UNONAME_AUTOFLT
), 0, &getBooleanCppuType(), 0, 0},
126 {MAP_CHAR_LEN(SC_UNONAME_FLTCRT
), 0, &getCppuType((table::CellRangeAddress
*)0), 0, 0},
127 {MAP_CHAR_LEN(SC_UNONAME_FROMSELECT
),0, &getBooleanCppuType(), 0, 0},
128 {MAP_CHAR_LEN(SC_UNONAME_ISUSER
), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY
, 0 },
129 {MAP_CHAR_LEN(SC_UNONAME_KEEPFORM
), 0, &getBooleanCppuType(), 0, 0},
130 {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT
), 0, &getCppuType((uno::Reference
<awt::XBitmap
>*)0), beans::PropertyAttribute::READONLY
, 0 },
131 {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME
), 0, &getCppuType((rtl::OUString
*)0), beans::PropertyAttribute::READONLY
, 0 },
132 {MAP_CHAR_LEN(SC_UNONAME_MOVCELLS
), 0, &getBooleanCppuType(), 0, 0},
133 {MAP_CHAR_LEN(SC_UNONAME_REFPERIOD
), 0, &getCppuType((sal_Int32
*)0), 0, 0},
134 {MAP_CHAR_LEN(SC_UNONAME_STRIPDAT
), 0, &getBooleanCppuType(), 0, 0},
135 {MAP_CHAR_LEN(SC_UNONAME_TOKENINDEX
),0, &getCppuType((sal_Int32
*)0), beans::PropertyAttribute::READONLY
, 0 },
136 {MAP_CHAR_LEN(SC_UNONAME_USEFLTCRT
),0, &getBooleanCppuType(), 0, 0},
139 return aDBRangePropertyMap_Impl
;
143 //------------------------------------------------------------------------
145 #define SCDATABASERANGEOBJ_SERVICE "com.sun.star.sheet.DatabaseRange"
147 SC_SIMPLE_SERVICE_INFO( ScConsolidationDescriptor
, "ScConsolidationDescriptor", "com.sun.star.sheet.ConsolidationDescriptor" )
148 SC_SIMPLE_SERVICE_INFO( ScDatabaseRangesObj
, "ScDatabaseRangesObj", "com.sun.star.sheet.DatabaseRanges" )
149 SC_SIMPLE_SERVICE_INFO( ScFilterDescriptorBase
, "ScFilterDescriptorBase", "com.sun.star.sheet.SheetFilterDescriptor" )
150 SC_SIMPLE_SERVICE_INFO( ScSubTotalDescriptorBase
, "ScSubTotalDescriptorBase", "com.sun.star.sheet.SubTotalDescriptor" )
151 SC_SIMPLE_SERVICE_INFO( ScSubTotalFieldObj
, "ScSubTotalFieldObj", "com.sun.star.sheet.SubTotalField" )
154 //------------------------------------------------------------------------
157 ScSubTotalFunc
ScDataUnoConversion::GeneralToSubTotal( sheet::GeneralFunction eSummary
)
159 ScSubTotalFunc eSubTotal
;
162 case sheet::GeneralFunction_NONE
: eSubTotal
= SUBTOTAL_FUNC_NONE
; break;
163 case sheet::GeneralFunction_SUM
: eSubTotal
= SUBTOTAL_FUNC_SUM
; break;
164 case sheet::GeneralFunction_COUNT
: eSubTotal
= SUBTOTAL_FUNC_CNT2
; break;
165 case sheet::GeneralFunction_AVERAGE
: eSubTotal
= SUBTOTAL_FUNC_AVE
; break;
166 case sheet::GeneralFunction_MAX
: eSubTotal
= SUBTOTAL_FUNC_MAX
; break;
167 case sheet::GeneralFunction_MIN
: eSubTotal
= SUBTOTAL_FUNC_MIN
; break;
168 case sheet::GeneralFunction_PRODUCT
: eSubTotal
= SUBTOTAL_FUNC_PROD
; break;
169 case sheet::GeneralFunction_COUNTNUMS
: eSubTotal
= SUBTOTAL_FUNC_CNT
; break;
170 case sheet::GeneralFunction_STDEV
: eSubTotal
= SUBTOTAL_FUNC_STD
; break;
171 case sheet::GeneralFunction_STDEVP
: eSubTotal
= SUBTOTAL_FUNC_STDP
; break;
172 case sheet::GeneralFunction_VAR
: eSubTotal
= SUBTOTAL_FUNC_VAR
; break;
173 case sheet::GeneralFunction_VARP
: eSubTotal
= SUBTOTAL_FUNC_VARP
; break;
174 case sheet::GeneralFunction_AUTO
:
176 DBG_ERROR("GeneralToSubTotal: falscher enum");
177 eSubTotal
= SUBTOTAL_FUNC_NONE
;
183 sheet::GeneralFunction
ScDataUnoConversion::SubTotalToGeneral( ScSubTotalFunc eSubTotal
)
185 sheet::GeneralFunction eGeneral
;
188 case SUBTOTAL_FUNC_NONE
: eGeneral
= sheet::GeneralFunction_NONE
; break;
189 case SUBTOTAL_FUNC_AVE
: eGeneral
= sheet::GeneralFunction_AVERAGE
; break;
190 case SUBTOTAL_FUNC_CNT
: eGeneral
= sheet::GeneralFunction_COUNTNUMS
; break;
191 case SUBTOTAL_FUNC_CNT2
: eGeneral
= sheet::GeneralFunction_COUNT
; break;
192 case SUBTOTAL_FUNC_MAX
: eGeneral
= sheet::GeneralFunction_MAX
; break;
193 case SUBTOTAL_FUNC_MIN
: eGeneral
= sheet::GeneralFunction_MIN
; break;
194 case SUBTOTAL_FUNC_PROD
: eGeneral
= sheet::GeneralFunction_PRODUCT
; break;
195 case SUBTOTAL_FUNC_STD
: eGeneral
= sheet::GeneralFunction_STDEV
; break;
196 case SUBTOTAL_FUNC_STDP
: eGeneral
= sheet::GeneralFunction_STDEVP
; break;
197 case SUBTOTAL_FUNC_SUM
: eGeneral
= sheet::GeneralFunction_SUM
; break;
198 case SUBTOTAL_FUNC_VAR
: eGeneral
= sheet::GeneralFunction_VAR
; break;
199 case SUBTOTAL_FUNC_VARP
: eGeneral
= sheet::GeneralFunction_VARP
; break;
201 DBG_ERROR("SubTotalToGeneral: falscher enum");
202 eGeneral
= sheet::GeneralFunction_NONE
;
208 //------------------------------------------------------------------------
210 // ScImportDescriptor: alles static
212 long ScImportDescriptor::GetPropertyCount()
217 void ScImportDescriptor::FillProperties( uno::Sequence
<beans::PropertyValue
>& rSeq
, const ScImportParam
& rParam
)
219 DBG_ASSERT( rSeq
.getLength() == GetPropertyCount(), "falscher Count" );
221 beans::PropertyValue
* pArray
= rSeq
.getArray();
223 sheet::DataImportMode eMode
= sheet::DataImportMode_NONE
;
224 if ( rParam
.bImport
)
227 eMode
= sheet::DataImportMode_SQL
;
228 else if ( rParam
.nType
== ScDbQuery
)
229 eMode
= sheet::DataImportMode_QUERY
;
231 eMode
= sheet::DataImportMode_TABLE
; // Type ist immer ScDbQuery oder ScDbTable
234 ::svx::ODataAccessDescriptor aDescriptor
;
235 aDescriptor
.setDataSource(rParam
.aDBName
);
236 if (aDescriptor
.has( svx::daDataSource
))
238 pArray
[0].Name
= rtl::OUString::createFromAscii( SC_UNONAME_DBNAME
);
239 pArray
[0].Value
<<= rtl::OUString( rParam
.aDBName
);
241 else if (aDescriptor
.has( svx::daConnectionResource
))
243 pArray
[0].Name
= rtl::OUString::createFromAscii( SC_UNONAME_CONRES
);
244 pArray
[0].Value
<<= rtl::OUString( rParam
.aDBName
);
247 pArray
[1].Name
= rtl::OUString::createFromAscii( SC_UNONAME_SRCTYPE
);
248 pArray
[1].Value
<<= eMode
;
250 pArray
[2].Name
= rtl::OUString::createFromAscii( SC_UNONAME_SRCOBJ
);
251 pArray
[2].Value
<<= rtl::OUString( rParam
.aStatement
);
253 pArray
[3].Name
= rtl::OUString::createFromAscii( SC_UNONAME_ISNATIVE
);
254 ScUnoHelpFunctions::SetBoolInAny( pArray
[3].Value
, rParam
.bNative
);
257 void ScImportDescriptor::FillImportParam( ScImportParam
& rParam
, const uno::Sequence
<beans::PropertyValue
>& rSeq
)
259 rtl::OUString aStrVal
;
260 const beans::PropertyValue
* pPropArray
= rSeq
.getConstArray();
261 long nPropCount
= rSeq
.getLength();
262 for (long i
= 0; i
< nPropCount
; i
++)
264 const beans::PropertyValue
& rProp
= pPropArray
[i
];
265 String
aPropName(rProp
.Name
);
267 if (aPropName
.EqualsAscii( SC_UNONAME_ISNATIVE
))
268 rParam
.bNative
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
269 else if (aPropName
.EqualsAscii( SC_UNONAME_DBNAME
))
271 if ( rProp
.Value
>>= aStrVal
)
272 rParam
.aDBName
= String( aStrVal
);
274 else if (aPropName
.EqualsAscii( SC_UNONAME_CONRES
))
276 if ( rProp
.Value
>>= aStrVal
)
277 rParam
.aDBName
= String( aStrVal
);
279 else if (aPropName
.EqualsAscii( SC_UNONAME_SRCOBJ
))
281 if ( rProp
.Value
>>= aStrVal
)
282 rParam
.aStatement
= String( aStrVal
);
284 else if (aPropName
.EqualsAscii( SC_UNONAME_SRCTYPE
))
286 //! test for correct enum type?
287 sheet::DataImportMode eMode
= (sheet::DataImportMode
)
288 ScUnoHelpFunctions::GetEnumFromAny( rProp
.Value
);
291 case sheet::DataImportMode_NONE
:
292 rParam
.bImport
= FALSE
;
294 case sheet::DataImportMode_SQL
:
295 rParam
.bImport
= TRUE
;
298 case sheet::DataImportMode_TABLE
:
299 rParam
.bImport
= TRUE
;
301 rParam
.nType
= ScDbTable
;
303 case sheet::DataImportMode_QUERY
:
304 rParam
.bImport
= TRUE
;
306 rParam
.nType
= ScDbQuery
;
309 DBG_ERROR("falscher Mode");
310 rParam
.bImport
= FALSE
;
316 //------------------------------------------------------------------------
318 // ScSortDescriptor: alles static
320 //! SortAscending muss aus der SheetSortDescriptor service-Beschreibung raus
322 long ScSortDescriptor::GetPropertyCount()
324 return 9; // TableSortDescriptor and SheetSortDescriptor
327 void ScSortDescriptor::FillProperties( uno::Sequence
<beans::PropertyValue
>& rSeq
, const ScSortParam
& rParam
)
329 DBG_ASSERT( rSeq
.getLength() == GetPropertyCount(), "falscher Count" );
331 beans::PropertyValue
* pArray
= rSeq
.getArray();
333 // Uno-Werte zusammensuchen
335 table::CellAddress aOutPos
;
336 aOutPos
.Sheet
= rParam
.nDestTab
;
337 aOutPos
.Column
= rParam
.nDestCol
;
338 aOutPos
.Row
= rParam
.nDestRow
;
340 USHORT nSortCount
= 0;
341 while ( nSortCount
< MAXSORT
&& rParam
.bDoSort
[nSortCount
] )
344 uno::Sequence
<table::TableSortField
> aFields(nSortCount
);
347 table::TableSortField
* pFieldArray
= aFields
.getArray();
348 for (USHORT i
=0; i
<nSortCount
; i
++)
350 pFieldArray
[i
].Field
= rParam
.nField
[i
];
351 pFieldArray
[i
].IsAscending
= rParam
.bAscending
[i
];
352 pFieldArray
[i
].FieldType
= table::TableSortFieldType_AUTOMATIC
; // immer Automatic
353 pFieldArray
[i
].IsCaseSensitive
= rParam
.bCaseSens
;
354 pFieldArray
[i
].CollatorLocale
= rParam
.aCollatorLocale
;
355 pFieldArray
[i
].CollatorAlgorithm
= rtl::OUString( rParam
.aCollatorAlgorithm
);
361 pArray
[0].Name
= rtl::OUString::createFromAscii( SC_UNONAME_ISSORTCOLUMNS
);
362 pArray
[0].Value
= ::cppu::bool2any(!rParam
.bByRow
);
364 pArray
[1].Name
= rtl::OUString::createFromAscii( SC_UNONAME_CONTHDR
);
365 ScUnoHelpFunctions::SetBoolInAny( pArray
[1].Value
, rParam
.bHasHeader
);
367 pArray
[2].Name
= rtl::OUString::createFromAscii( SC_UNONAME_MAXFLD
);
368 pArray
[2].Value
<<= (sal_Int32
) MAXSORT
;
370 pArray
[3].Name
= rtl::OUString::createFromAscii( SC_UNONAME_SORTFLD
);
371 pArray
[3].Value
<<= aFields
;
373 pArray
[4].Name
= rtl::OUString::createFromAscii( SC_UNONAME_BINDFMT
);
374 ScUnoHelpFunctions::SetBoolInAny( pArray
[4].Value
, rParam
.bIncludePattern
);
376 pArray
[5].Name
= rtl::OUString::createFromAscii( SC_UNONAME_COPYOUT
);
377 ScUnoHelpFunctions::SetBoolInAny( pArray
[5].Value
, !rParam
.bInplace
);
379 pArray
[6].Name
= rtl::OUString::createFromAscii( SC_UNONAME_OUTPOS
);
380 pArray
[6].Value
<<= aOutPos
;
382 pArray
[7].Name
= rtl::OUString::createFromAscii( SC_UNONAME_ISULIST
);
383 ScUnoHelpFunctions::SetBoolInAny( pArray
[7].Value
, rParam
.bUserDef
);
385 pArray
[8].Name
= rtl::OUString::createFromAscii( SC_UNONAME_UINDEX
);
386 pArray
[8].Value
<<= (sal_Int32
) rParam
.nUserIndex
;
389 void ScSortDescriptor::FillSortParam( ScSortParam
& rParam
, const uno::Sequence
<beans::PropertyValue
>& rSeq
)
391 sal_Bool
bOldSortDescriptor(sal_False
);
392 sal_Bool
bNewSortDescriptor(sal_False
);
393 const beans::PropertyValue
* pPropArray
= rSeq
.getConstArray();
394 long nPropCount
= rSeq
.getLength();
395 for (long nProp
= 0; nProp
< nPropCount
; nProp
++)
397 const beans::PropertyValue
& rProp
= pPropArray
[nProp
];
398 String
aPropName(rProp
.Name
);
400 if (aPropName
.EqualsAscii( SC_UNONAME_ORIENT
))
402 bOldSortDescriptor
= sal_True
;
403 //! test for correct enum type?
404 table::TableOrientation eOrient
= (table::TableOrientation
)
405 ScUnoHelpFunctions::GetEnumFromAny( rProp
.Value
);
406 rParam
.bByRow
= ( eOrient
!= table::TableOrientation_COLUMNS
);
408 else if (aPropName
.EqualsAscii( SC_UNONAME_ISSORTCOLUMNS
))
410 bNewSortDescriptor
= sal_True
;
411 rParam
.bByRow
= !::cppu::any2bool(rProp
.Value
);
413 else if (aPropName
.EqualsAscii( SC_UNONAME_CONTHDR
))
414 rParam
.bHasHeader
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
415 else if (aPropName
.EqualsAscii( SC_UNONAME_MAXFLD
))
418 if ( (rProp
.Value
>>= nVal
) && nVal
> MAXSORT
)
420 //! specify exceptions
421 //! throw lang::IllegalArgumentException();
424 else if (aPropName
.EqualsAscii( SC_UNONAME_SORTFLD
))
426 uno::Sequence
<util::SortField
> aSeq
;
427 uno::Sequence
<table::TableSortField
> aNewSeq
;
428 if ( rProp
.Value
>>= aSeq
)
430 bOldSortDescriptor
= sal_True
;
431 INT32 nCount
= aSeq
.getLength();
433 if ( nCount
> MAXSORT
)
435 DBG_ERROR("Zu viele Sortierfelder");
438 const util::SortField
* pFieldArray
= aSeq
.getConstArray();
439 for (i
=0; i
<nCount
; i
++)
441 rParam
.nField
[i
] = (SCCOLROW
)pFieldArray
[i
].Field
;
442 rParam
.bAscending
[i
] = pFieldArray
[i
].SortAscending
;
444 // FieldType wird ignoriert
445 rParam
.bDoSort
[i
] = TRUE
;
447 for (i
=nCount
; i
<MAXSORT
; i
++)
448 rParam
.bDoSort
[i
] = FALSE
;
450 else if ( rProp
.Value
>>= aNewSeq
)
452 bNewSortDescriptor
= sal_True
;
453 INT32 nCount
= aNewSeq
.getLength();
455 if ( nCount
> MAXSORT
)
457 DBG_ERROR("Zu viele Sortierfelder");
460 const table::TableSortField
* pFieldArray
= aNewSeq
.getConstArray();
461 for (i
=0; i
<nCount
; i
++)
463 rParam
.nField
[i
] = (SCCOLROW
)pFieldArray
[i
].Field
;
464 rParam
.bAscending
[i
] = pFieldArray
[i
].IsAscending
;
466 // only one is possible, sometime we should make it possible to have different for every entry
467 rParam
.bCaseSens
= pFieldArray
[i
].IsCaseSensitive
;
468 rParam
.aCollatorLocale
= pFieldArray
[i
].CollatorLocale
;
469 rParam
.aCollatorAlgorithm
= pFieldArray
[i
].CollatorAlgorithm
;
471 // FieldType wird ignoriert
472 rParam
.bDoSort
[i
] = TRUE
;
474 for (i
=nCount
; i
<MAXSORT
; i
++)
475 rParam
.bDoSort
[i
] = FALSE
;
478 else if (aPropName
.EqualsAscii( SC_UNONAME_ISCASE
))
480 bOldSortDescriptor
= sal_True
;
481 rParam
.bCaseSens
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
483 else if (aPropName
.EqualsAscii( SC_UNONAME_BINDFMT
))
484 rParam
.bIncludePattern
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
485 else if (aPropName
.EqualsAscii( SC_UNONAME_COPYOUT
))
486 rParam
.bInplace
= !ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
487 else if (aPropName
.EqualsAscii( SC_UNONAME_OUTPOS
))
489 table::CellAddress aAddress
;
490 if ( rProp
.Value
>>= aAddress
)
492 rParam
.nDestTab
= aAddress
.Sheet
;
493 rParam
.nDestCol
= (SCCOL
)aAddress
.Column
;
494 rParam
.nDestRow
= (SCROW
)aAddress
.Row
;
497 else if (aPropName
.EqualsAscii( SC_UNONAME_ISULIST
))
498 rParam
.bUserDef
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
499 else if (aPropName
.EqualsAscii( SC_UNONAME_UINDEX
))
502 if ( rProp
.Value
>>= nVal
)
503 rParam
.nUserIndex
= (USHORT
)nVal
;
505 else if (aPropName
.EqualsAscii( SC_UNONAME_COLLLOC
))
507 bOldSortDescriptor
= sal_True
;
508 rProp
.Value
>>= rParam
.aCollatorLocale
;
510 else if (aPropName
.EqualsAscii( SC_UNONAME_COLLALG
))
512 bOldSortDescriptor
= sal_True
;
514 if ( rProp
.Value
>>= sStr
)
515 rParam
.aCollatorAlgorithm
= sStr
;
520 //------------------------------------------------------------------------
522 ScSubTotalFieldObj::ScSubTotalFieldObj( ScSubTotalDescriptorBase
* pDesc
, USHORT nP
) :
523 xRef( pDesc
), // Objekt festhalten
527 DBG_ASSERT(pDesc
, "ScSubTotalFieldObj: Parent ist 0");
530 ScSubTotalFieldObj::~ScSubTotalFieldObj()
536 sal_Int32 SAL_CALL
ScSubTotalFieldObj::getGroupColumn() throw(uno::RuntimeException
)
539 ScSubTotalParam aParam
;
540 rParent
.GetData(aParam
);
542 return aParam
.nField
[nPos
];
545 void SAL_CALL
ScSubTotalFieldObj::setGroupColumn( sal_Int32 nGroupColumn
) throw(uno::RuntimeException
)
548 ScSubTotalParam aParam
;
549 rParent
.GetData(aParam
);
551 aParam
.nField
[nPos
] = (SCCOL
)nGroupColumn
;
553 rParent
.PutData(aParam
);
556 uno::Sequence
<sheet::SubTotalColumn
> SAL_CALL
ScSubTotalFieldObj::getSubTotalColumns()
557 throw(uno::RuntimeException
)
560 ScSubTotalParam aParam
;
561 rParent
.GetData(aParam
);
563 SCCOL nCount
= aParam
.nSubTotals
[nPos
];
564 uno::Sequence
<sheet::SubTotalColumn
> aSeq(nCount
);
565 sheet::SubTotalColumn
* pAry
= aSeq
.getArray();
566 for (SCCOL i
=0; i
<nCount
; i
++)
568 pAry
[i
].Column
= aParam
.pSubTotals
[nPos
][i
];
569 pAry
[i
].Function
= ScDataUnoConversion::SubTotalToGeneral(
570 aParam
.pFunctions
[nPos
][i
] );
575 void SAL_CALL
ScSubTotalFieldObj::setSubTotalColumns(
576 const uno::Sequence
<sheet::SubTotalColumn
>& aSubTotalColumns
)
577 throw(uno::RuntimeException
)
580 ScSubTotalParam aParam
;
581 rParent
.GetData(aParam
);
583 UINT32 nColCount
= aSubTotalColumns
.getLength();
584 if ( nColCount
<= sal::static_int_cast
<UINT32
>(SCCOL_MAX
) )
586 SCCOL nCount
= static_cast<SCCOL
>(nColCount
);
587 aParam
.nSubTotals
[nPos
] = nCount
;
590 aParam
.pSubTotals
[nPos
] = new SCCOL
[nCount
];
591 aParam
.pFunctions
[nPos
] = new ScSubTotalFunc
[nCount
];
593 const sheet::SubTotalColumn
* pAry
= aSubTotalColumns
.getConstArray();
594 for (SCCOL i
=0; i
<nCount
; i
++)
596 aParam
.pSubTotals
[nPos
][i
] = static_cast<SCCOL
>(pAry
[i
].Column
);
597 aParam
.pFunctions
[nPos
][i
] =
598 ScDataUnoConversion::GeneralToSubTotal( pAry
[i
].Function
);
603 aParam
.pSubTotals
[nPos
] = NULL
;
604 aParam
.pFunctions
[nPos
] = NULL
;
607 //! sonst Exception oder so? (zuviele Spalten)
609 rParent
.PutData(aParam
);
612 //------------------------------------------------------------------------
614 ScSubTotalDescriptorBase::ScSubTotalDescriptorBase() :
615 aPropSet( lcl_GetSubTotalPropertyMap() )
619 ScSubTotalDescriptorBase::~ScSubTotalDescriptorBase()
623 // GetData/PutData hier nur wegen NewInstance-Krempel implementiert...
625 void ScSubTotalDescriptorBase::GetData( ScSubTotalParam
& /* rParam */ ) const
627 DBG_ERROR("ScSubTotalDescriptorBase::GetData soll nicht gerufen werden");
630 void ScSubTotalDescriptorBase::PutData( const ScSubTotalParam
& /* rParam */ )
632 DBG_ERROR("ScSubTotalDescriptorBase::PutData soll nicht gerufen werden");
635 // XSubTotalDesctiptor
637 ScSubTotalFieldObj
* ScSubTotalDescriptorBase::GetObjectByIndex_Impl(USHORT nIndex
)
639 if ( nIndex
< getCount() )
640 return new ScSubTotalFieldObj( this, nIndex
);
644 void SAL_CALL
ScSubTotalDescriptorBase::clear() throw(uno::RuntimeException
)
647 ScSubTotalParam aParam
;
650 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
651 aParam
.bGroupActive
[i
] = FALSE
;
653 //! Notify oder so fuer die Field-Objekte???
658 void SAL_CALL
ScSubTotalDescriptorBase::addNew(
659 const uno::Sequence
<sheet::SubTotalColumn
>& aSubTotalColumns
,
660 sal_Int32 nGroupColumn
) throw(uno::RuntimeException
)
663 ScSubTotalParam aParam
;
667 while ( nPos
< MAXSUBTOTAL
&& aParam
.bGroupActive
[nPos
] )
670 UINT32 nColCount
= aSubTotalColumns
.getLength();
672 if ( nPos
< MAXSUBTOTAL
&& nColCount
<= sal::static_int_cast
<UINT32
>(SCCOL_MAX
) )
674 aParam
.bGroupActive
[nPos
] = TRUE
;
675 aParam
.nField
[nPos
] = static_cast<SCCOL
>(nGroupColumn
);
677 delete aParam
.pSubTotals
[nPos
];
678 delete aParam
.pFunctions
[nPos
];
680 SCCOL nCount
= static_cast<SCCOL
>(nColCount
);
681 aParam
.nSubTotals
[nPos
] = nCount
;
684 aParam
.pSubTotals
[nPos
] = new SCCOL
[nCount
];
685 aParam
.pFunctions
[nPos
] = new ScSubTotalFunc
[nCount
];
687 const sheet::SubTotalColumn
* pAry
= aSubTotalColumns
.getConstArray();
688 for (SCCOL i
=0; i
<nCount
; i
++)
690 aParam
.pSubTotals
[nPos
][i
] = static_cast<SCCOL
>(pAry
[i
].Column
);
691 aParam
.pFunctions
[nPos
][i
] =
692 ScDataUnoConversion::GeneralToSubTotal( pAry
[i
].Function
);
697 aParam
.pSubTotals
[nPos
] = NULL
;
698 aParam
.pFunctions
[nPos
] = NULL
;
701 else // too many fields / columns
702 throw uno::RuntimeException(); // no other exceptions specified
707 // Flags/Einstellungen als Properties
709 // XEnumerationAccess
711 uno::Reference
<container::XEnumeration
> SAL_CALL
ScSubTotalDescriptorBase::createEnumeration()
712 throw(uno::RuntimeException
)
715 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SubTotalFieldsEnumeration")));
720 sal_Int32 SAL_CALL
ScSubTotalDescriptorBase::getCount() throw(uno::RuntimeException
)
723 ScSubTotalParam aParam
;
727 while ( nCount
< MAXSUBTOTAL
&& aParam
.bGroupActive
[nCount
] )
732 uno::Any SAL_CALL
ScSubTotalDescriptorBase::getByIndex( sal_Int32 nIndex
)
733 throw(lang::IndexOutOfBoundsException
,
734 lang::WrappedTargetException
, uno::RuntimeException
)
737 uno::Reference
<sheet::XSubTotalField
> xField(GetObjectByIndex_Impl((USHORT
)nIndex
));
739 return uno::makeAny(xField
);
741 throw lang::IndexOutOfBoundsException();
742 // return uno::Any();
745 uno::Type SAL_CALL
ScSubTotalDescriptorBase::getElementType() throw(uno::RuntimeException
)
748 return getCppuType((uno::Reference
<sheet::XSubTotalField
>*)0);
751 sal_Bool SAL_CALL
ScSubTotalDescriptorBase::hasElements() throw(uno::RuntimeException
)
754 return ( getCount() != 0 );
759 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScSubTotalDescriptorBase::getPropertySetInfo()
760 throw(uno::RuntimeException
)
763 static uno::Reference
<beans::XPropertySetInfo
> aRef(
764 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
768 void SAL_CALL
ScSubTotalDescriptorBase::setPropertyValue(
769 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
770 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
771 lang::IllegalArgumentException
, lang::WrappedTargetException
,
772 uno::RuntimeException
)
775 ScSubTotalParam aParam
;
778 String
aString(aPropertyName
);
780 // some old property names are for 5.2 compatibility
782 if (aString
.EqualsAscii( SC_UNONAME_CASE
) || aString
.EqualsAscii( SC_UNONAME_ISCASE
))
783 aParam
.bCaseSens
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
784 else if (aString
.EqualsAscii( SC_UNONAME_FORMATS
) || aString
.EqualsAscii( SC_UNONAME_BINDFMT
))
785 aParam
.bIncludePattern
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
786 else if (aString
.EqualsAscii( SC_UNONAME_ENABSORT
))
787 aParam
.bDoSort
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
788 else if (aString
.EqualsAscii( SC_UNONAME_SORTASC
))
789 aParam
.bAscending
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
790 else if (aString
.EqualsAscii( SC_UNONAME_INSBRK
))
791 aParam
.bPagebreak
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
792 else if (aString
.EqualsAscii( SC_UNONAME_ULIST
) || aString
.EqualsAscii( SC_UNONAME_ENUSLIST
))
793 aParam
.bUserDef
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
794 else if (aString
.EqualsAscii( SC_UNONAME_UINDEX
) || aString
.EqualsAscii( SC_UNONAME_USINDEX
))
797 if ( aValue
>>= nVal
)
798 aParam
.nUserIndex
= (USHORT
)nVal
;
800 else if (aString
.EqualsAscii( SC_UNONAME_MAXFLD
))
803 if ( (aValue
>>= nVal
) && nVal
> sal::static_int_cast
<sal_Int32
>(MAXSUBTOTAL
) )
805 throw lang::IllegalArgumentException();
812 uno::Any SAL_CALL
ScSubTotalDescriptorBase::getPropertyValue( const rtl::OUString
& aPropertyName
)
813 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
814 uno::RuntimeException
)
817 ScSubTotalParam aParam
;
820 String
aString(aPropertyName
);
823 // some old property names are for 5.2 compatibility
825 if (aString
.EqualsAscii( SC_UNONAME_CASE
) || aString
.EqualsAscii( SC_UNONAME_ISCASE
))
826 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bCaseSens
);
827 else if (aString
.EqualsAscii( SC_UNONAME_FORMATS
) || aString
.EqualsAscii( SC_UNONAME_BINDFMT
))
828 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bIncludePattern
);
829 else if (aString
.EqualsAscii( SC_UNONAME_ENABSORT
))
830 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bDoSort
);
831 else if (aString
.EqualsAscii( SC_UNONAME_SORTASC
))
832 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bAscending
);
833 else if (aString
.EqualsAscii( SC_UNONAME_INSBRK
))
834 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bPagebreak
);
835 else if (aString
.EqualsAscii( SC_UNONAME_ULIST
) || aString
.EqualsAscii( SC_UNONAME_ENUSLIST
))
836 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bUserDef
);
837 else if (aString
.EqualsAscii( SC_UNONAME_UINDEX
) || aString
.EqualsAscii( SC_UNONAME_USINDEX
))
838 aRet
<<= (sal_Int32
) aParam
.nUserIndex
;
839 else if (aString
.EqualsAscii( SC_UNONAME_MAXFLD
))
840 aRet
<<= (sal_Int32
) MAXSUBTOTAL
;
845 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSubTotalDescriptorBase
)
849 sal_Int64 SAL_CALL
ScSubTotalDescriptorBase::getSomething(
850 const uno::Sequence
<sal_Int8
>& rId
) throw(uno::RuntimeException
)
852 if ( rId
.getLength() == 16 &&
853 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
854 rId
.getConstArray(), 16 ) )
856 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
862 const uno::Sequence
<sal_Int8
>& ScSubTotalDescriptorBase::getUnoTunnelId()
864 static uno::Sequence
<sal_Int8
> * pSeq
= 0;
867 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
870 static uno::Sequence
< sal_Int8
> aSeq( 16 );
871 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
879 ScSubTotalDescriptorBase
* ScSubTotalDescriptorBase::getImplementation(
880 const uno::Reference
<sheet::XSubTotalDescriptor
> xObj
)
882 ScSubTotalDescriptorBase
* pRet
= NULL
;
883 uno::Reference
<lang::XUnoTunnel
> xUT( xObj
, uno::UNO_QUERY
);
885 pRet
= reinterpret_cast<ScSubTotalDescriptorBase
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething(getUnoTunnelId())));
889 //------------------------------------------------------------------------
891 ScSubTotalDescriptor::ScSubTotalDescriptor()
895 ScSubTotalDescriptor::~ScSubTotalDescriptor()
899 void ScSubTotalDescriptor::GetData( ScSubTotalParam
& rParam
) const
901 rParam
= aStoredParam
; // Abfrage fuer Interface
904 void ScSubTotalDescriptor::PutData( const ScSubTotalParam
& rParam
)
906 aStoredParam
= rParam
; // vom Interface gesetzt
909 void ScSubTotalDescriptor::SetParam( const ScSubTotalParam
& rNew
)
911 aStoredParam
= rNew
; // von aussen gesetzt
914 //------------------------------------------------------------------------
916 ScRangeSubTotalDescriptor::ScRangeSubTotalDescriptor(ScDatabaseRangeObj
* pPar
) :
923 ScRangeSubTotalDescriptor::~ScRangeSubTotalDescriptor()
929 void ScRangeSubTotalDescriptor::GetData( ScSubTotalParam
& rParam
) const
932 pParent
->GetSubTotalParam( rParam
);
935 void ScRangeSubTotalDescriptor::PutData( const ScSubTotalParam
& rParam
)
938 pParent
->SetSubTotalParam( rParam
);
941 //------------------------------------------------------------------------
943 ScConsolidationDescriptor::ScConsolidationDescriptor()
947 ScConsolidationDescriptor::~ScConsolidationDescriptor()
951 void ScConsolidationDescriptor::SetParam( const ScConsolidateParam
& rNew
)
956 // XConsolidationDescriptor
958 sheet::GeneralFunction SAL_CALL
ScConsolidationDescriptor::getFunction() throw(uno::RuntimeException
)
961 return ScDataUnoConversion::SubTotalToGeneral(aParam
.eFunction
);
964 void SAL_CALL
ScConsolidationDescriptor::setFunction( sheet::GeneralFunction nFunction
)
965 throw(uno::RuntimeException
)
968 aParam
.eFunction
= ScDataUnoConversion::GeneralToSubTotal(nFunction
);
971 uno::Sequence
<table::CellRangeAddress
> SAL_CALL
ScConsolidationDescriptor::getSources()
972 throw(uno::RuntimeException
)
975 USHORT nCount
= aParam
.nDataAreaCount
;
976 if (!aParam
.ppDataAreas
)
978 table::CellRangeAddress aRange
;
979 uno::Sequence
<table::CellRangeAddress
> aSeq(nCount
);
980 table::CellRangeAddress
* pAry
= aSeq
.getArray();
981 for (USHORT i
=0; i
<nCount
; i
++)
983 ScArea
* pArea
= aParam
.ppDataAreas
[i
];
986 aRange
.Sheet
= pArea
->nTab
;
987 aRange
.StartColumn
= pArea
->nColStart
;
988 aRange
.StartRow
= pArea
->nRowStart
;
989 aRange
.EndColumn
= pArea
->nColEnd
;
990 aRange
.EndRow
= pArea
->nRowEnd
;
997 void SAL_CALL
ScConsolidationDescriptor::setSources(
998 const uno::Sequence
<table::CellRangeAddress
>& aSources
)
999 throw(uno::RuntimeException
)
1002 USHORT nCount
= (USHORT
)aSources
.getLength();
1005 const table::CellRangeAddress
* pAry
= aSources
.getConstArray();
1006 ScArea
** pNew
= new ScArea
*[nCount
];
1008 for (i
=0; i
<nCount
; i
++)
1009 pNew
[i
] = new ScArea( pAry
[i
].Sheet
,
1010 static_cast<SCCOL
>(pAry
[i
].StartColumn
), pAry
[i
].StartRow
,
1011 static_cast<SCCOL
>(pAry
[i
].EndColumn
), pAry
[i
].EndRow
);
1013 aParam
.SetAreas( pNew
, nCount
); // kopiert alles
1015 for (i
=0; i
<nCount
; i
++)
1020 aParam
.ClearDataAreas();
1023 table::CellAddress SAL_CALL
ScConsolidationDescriptor::getStartOutputPosition()
1024 throw(uno::RuntimeException
)
1027 table::CellAddress aPos
;
1028 aPos
.Column
= aParam
.nCol
;
1029 aPos
.Row
= aParam
.nRow
;
1030 aPos
.Sheet
= aParam
.nTab
;
1034 void SAL_CALL
ScConsolidationDescriptor::setStartOutputPosition(
1035 const table::CellAddress
& aStartOutputPosition
)
1036 throw(uno::RuntimeException
)
1039 aParam
.nCol
= (SCCOL
)aStartOutputPosition
.Column
;
1040 aParam
.nRow
= (SCROW
)aStartOutputPosition
.Row
;
1041 aParam
.nTab
= aStartOutputPosition
.Sheet
;
1044 sal_Bool SAL_CALL
ScConsolidationDescriptor::getUseColumnHeaders() throw(uno::RuntimeException
)
1047 return aParam
.bByCol
;
1050 void SAL_CALL
ScConsolidationDescriptor::setUseColumnHeaders( sal_Bool bUseColumnHeaders
)
1051 throw(uno::RuntimeException
)
1054 aParam
.bByCol
= bUseColumnHeaders
;
1057 sal_Bool SAL_CALL
ScConsolidationDescriptor::getUseRowHeaders() throw(uno::RuntimeException
)
1060 return aParam
.bByRow
;
1063 void SAL_CALL
ScConsolidationDescriptor::setUseRowHeaders( sal_Bool bUseRowHeaders
)
1064 throw(uno::RuntimeException
)
1067 aParam
.bByRow
= bUseRowHeaders
;
1070 sal_Bool SAL_CALL
ScConsolidationDescriptor::getInsertLinks() throw(uno::RuntimeException
)
1073 return aParam
.bReferenceData
;
1076 void SAL_CALL
ScConsolidationDescriptor::setInsertLinks( sal_Bool bInsertLinks
)
1077 throw(uno::RuntimeException
)
1080 aParam
.bReferenceData
= bInsertLinks
;
1083 //------------------------------------------------------------------------
1085 ScFilterDescriptorBase::ScFilterDescriptorBase(ScDocShell
* pDocShell
) :
1086 aPropSet( lcl_GetFilterPropertyMap() ),
1090 pDocSh
->GetDocument()->AddUnoObject(*this);
1093 ScFilterDescriptorBase::~ScFilterDescriptorBase()
1096 pDocSh
->GetDocument()->RemoveUnoObject(*this);
1099 void ScFilterDescriptorBase::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1101 if ( rHint
.ISA( SfxSimpleHint
) )
1103 ULONG nId
= ((const SfxSimpleHint
&)rHint
).GetId();
1104 if ( nId
== SFX_HINT_DYING
)
1106 pDocSh
= NULL
; // invalid
1111 // XSheetFilterDescriptor and XSheetFilterDescriptor2
1113 uno::Sequence
<sheet::TableFilterField
> SAL_CALL
ScFilterDescriptorBase::getFilterFields()
1114 throw(uno::RuntimeException
)
1117 ScQueryParam aParam
;
1120 SCSIZE nEntries
= aParam
.GetEntryCount(); // allozierte Eintraege im Param
1121 SCSIZE nCount
= 0; // aktive
1122 while ( nCount
< nEntries
&&
1123 aParam
.GetEntry(nCount
).bDoQuery
)
1126 sheet::TableFilterField aField
;
1127 uno::Sequence
<sheet::TableFilterField
> aSeq(static_cast<sal_Int32
>(nCount
));
1128 sheet::TableFilterField
* pAry
= aSeq
.getArray();
1129 for (SCSIZE i
=0; i
<nCount
; i
++)
1131 const ScQueryEntry
& rEntry
= aParam
.GetEntry(i
);
1133 rtl::OUString aStringValue
;
1135 aStringValue
= *rEntry
.pStr
;
1137 aField
.Connection
= (rEntry
.eConnect
== SC_AND
) ? sheet::FilterConnection_AND
:
1138 sheet::FilterConnection_OR
;
1139 aField
.Field
= rEntry
.nField
;
1140 aField
.IsNumeric
= !rEntry
.bQueryByString
;
1141 aField
.StringValue
= aStringValue
;
1142 aField
.NumericValue
= rEntry
.nVal
;
1144 switch (rEntry
.eOp
) // ScQueryOp
1148 aField
.Operator
= sheet::FilterOperator_EQUAL
;
1149 if (!rEntry
.bQueryByString
&& *rEntry
.pStr
== EMPTY_STRING
)
1151 if (rEntry
.nVal
== SC_EMPTYFIELDS
)
1153 aField
.Operator
= sheet::FilterOperator_EMPTY
;
1154 aField
.NumericValue
= 0;
1156 else if (rEntry
.nVal
== SC_NONEMPTYFIELDS
)
1158 aField
.Operator
= sheet::FilterOperator_NOT_EMPTY
;
1159 aField
.NumericValue
= 0;
1164 case SC_LESS
: aField
.Operator
= sheet::FilterOperator_LESS
; break;
1165 case SC_GREATER
: aField
.Operator
= sheet::FilterOperator_GREATER
; break;
1166 case SC_LESS_EQUAL
: aField
.Operator
= sheet::FilterOperator_LESS_EQUAL
; break;
1167 case SC_GREATER_EQUAL
: aField
.Operator
= sheet::FilterOperator_GREATER_EQUAL
; break;
1168 case SC_NOT_EQUAL
: aField
.Operator
= sheet::FilterOperator_NOT_EQUAL
; break;
1169 case SC_TOPVAL
: aField
.Operator
= sheet::FilterOperator_TOP_VALUES
; break;
1170 case SC_BOTVAL
: aField
.Operator
= sheet::FilterOperator_BOTTOM_VALUES
; break;
1171 case SC_TOPPERC
: aField
.Operator
= sheet::FilterOperator_TOP_PERCENT
; break;
1172 case SC_BOTPERC
: aField
.Operator
= sheet::FilterOperator_BOTTOM_PERCENT
; break;
1174 DBG_ERROR("Falscher Filter-enum");
1175 aField
.Operator
= sheet::FilterOperator_EMPTY
;
1182 uno::Sequence
<sheet::TableFilterField2
> SAL_CALL
ScFilterDescriptorBase::getFilterFields2()
1183 throw(uno::RuntimeException
)
1186 ScQueryParam aParam
;
1189 SCSIZE nEntries
= aParam
.GetEntryCount(); // allozierte Eintraege im Param
1190 SCSIZE nCount
= 0; // aktive
1191 while ( nCount
< nEntries
&&
1192 aParam
.GetEntry(nCount
).bDoQuery
)
1195 sheet::TableFilterField2 aField
;
1196 uno::Sequence
<sheet::TableFilterField2
> aSeq(static_cast<sal_Int32
>(nCount
));
1197 sheet::TableFilterField2
* pAry
= aSeq
.getArray();
1198 for (SCSIZE i
=0; i
<nCount
; i
++)
1200 const ScQueryEntry
& rEntry
= aParam
.GetEntry(i
);
1202 rtl::OUString aStringValue
;
1204 aStringValue
= *rEntry
.pStr
;
1206 aField
.Connection
= (rEntry
.eConnect
== SC_AND
) ? sheet::FilterConnection_AND
: sheet::FilterConnection_OR
;
1207 aField
.Field
= rEntry
.nField
;
1208 aField
.IsNumeric
= !rEntry
.bQueryByString
;
1209 aField
.StringValue
= aStringValue
;
1210 aField
.NumericValue
= rEntry
.nVal
;
1212 switch (rEntry
.eOp
) // ScQueryOp
1216 aField
.Operator
= sheet::FilterOperator2::EQUAL
;
1217 if (!rEntry
.bQueryByString
&& *rEntry
.pStr
== EMPTY_STRING
)
1219 if (rEntry
.nVal
== SC_EMPTYFIELDS
)
1221 aField
.Operator
= sheet::FilterOperator2::EMPTY
;
1222 aField
.NumericValue
= 0;
1224 else if (rEntry
.nVal
== SC_NONEMPTYFIELDS
)
1226 aField
.Operator
= sheet::FilterOperator2::NOT_EMPTY
;
1227 aField
.NumericValue
= 0;
1232 case SC_LESS
: aField
.Operator
= sheet::FilterOperator2::LESS
; break;
1233 case SC_GREATER
: aField
.Operator
= sheet::FilterOperator2::GREATER
; break;
1234 case SC_LESS_EQUAL
: aField
.Operator
= sheet::FilterOperator2::LESS_EQUAL
; break;
1235 case SC_GREATER_EQUAL
: aField
.Operator
= sheet::FilterOperator2::GREATER_EQUAL
; break;
1236 case SC_NOT_EQUAL
: aField
.Operator
= sheet::FilterOperator2::NOT_EQUAL
; break;
1237 case SC_TOPVAL
: aField
.Operator
= sheet::FilterOperator2::TOP_VALUES
; break;
1238 case SC_BOTVAL
: aField
.Operator
= sheet::FilterOperator2::BOTTOM_VALUES
; break;
1239 case SC_TOPPERC
: aField
.Operator
= sheet::FilterOperator2::TOP_PERCENT
; break;
1240 case SC_BOTPERC
: aField
.Operator
= sheet::FilterOperator2::BOTTOM_PERCENT
; break;
1241 case SC_CONTAINS
: aField
.Operator
= sheet::FilterOperator2::CONTAINS
; break;
1242 case SC_DOES_NOT_CONTAIN
: aField
.Operator
= sheet::FilterOperator2::DOES_NOT_CONTAIN
; break;
1243 case SC_BEGINS_WITH
: aField
.Operator
= sheet::FilterOperator2::BEGINS_WITH
; break;
1244 case SC_DOES_NOT_BEGIN_WITH
: aField
.Operator
= sheet::FilterOperator2::DOES_NOT_BEGIN_WITH
; break;
1245 case SC_ENDS_WITH
: aField
.Operator
= sheet::FilterOperator2::ENDS_WITH
; break;
1246 case SC_DOES_NOT_END_WITH
: aField
.Operator
= sheet::FilterOperator2::DOES_NOT_END_WITH
; break;
1248 DBG_ERROR("Falscher Filter-enum");
1249 aField
.Operator
= sheet::FilterOperator2::EMPTY
;
1256 void SAL_CALL
ScFilterDescriptorBase::setFilterFields(
1257 const uno::Sequence
<sheet::TableFilterField
>& aFilterFields
)
1258 throw(uno::RuntimeException
)
1261 ScQueryParam aParam
;
1264 SCSIZE nCount
= static_cast<SCSIZE
>(aFilterFields
.getLength());
1265 DBG_ASSERT( nCount
<= MAXQUERY
, "setFilterFields: zu viele" );
1267 aParam
.Resize( nCount
);
1269 const sheet::TableFilterField
* pAry
= aFilterFields
.getConstArray();
1271 for (i
=0; i
<nCount
; i
++)
1273 ScQueryEntry
& rEntry
= aParam
.GetEntry(i
);
1275 rEntry
.pStr
= new String
; // sollte nicht sein (soll immer initialisiert sein)
1277 rEntry
.bDoQuery
= TRUE
;
1278 rEntry
.eConnect
= (pAry
[i
].Connection
== sheet::FilterConnection_AND
) ? SC_AND
: SC_OR
;
1279 rEntry
.nField
= pAry
[i
].Field
;
1280 rEntry
.bQueryByString
= !pAry
[i
].IsNumeric
;
1281 *rEntry
.pStr
= String( pAry
[i
].StringValue
);
1282 rEntry
.nVal
= pAry
[i
].NumericValue
;
1284 if (!rEntry
.bQueryByString
&& pDocSh
)
1286 pDocSh
->GetDocument()->GetFormatTable()->GetInputLineString(rEntry
.nVal
, 0, *rEntry
.pStr
);
1289 switch (pAry
[i
].Operator
) // FilterOperator
1291 case sheet::FilterOperator_EQUAL
: rEntry
.eOp
= SC_EQUAL
; break;
1292 case sheet::FilterOperator_LESS
: rEntry
.eOp
= SC_LESS
; break;
1293 case sheet::FilterOperator_GREATER
: rEntry
.eOp
= SC_GREATER
; break;
1294 case sheet::FilterOperator_LESS_EQUAL
: rEntry
.eOp
= SC_LESS_EQUAL
; break;
1295 case sheet::FilterOperator_GREATER_EQUAL
: rEntry
.eOp
= SC_GREATER_EQUAL
; break;
1296 case sheet::FilterOperator_NOT_EQUAL
: rEntry
.eOp
= SC_NOT_EQUAL
; break;
1297 case sheet::FilterOperator_TOP_VALUES
: rEntry
.eOp
= SC_TOPVAL
; break;
1298 case sheet::FilterOperator_BOTTOM_VALUES
: rEntry
.eOp
= SC_BOTVAL
; break;
1299 case sheet::FilterOperator_TOP_PERCENT
: rEntry
.eOp
= SC_TOPPERC
; break;
1300 case sheet::FilterOperator_BOTTOM_PERCENT
: rEntry
.eOp
= SC_BOTPERC
; break;
1301 case sheet::FilterOperator_EMPTY
:
1303 rEntry
.eOp
= SC_EQUAL
;
1304 rEntry
.nVal
= SC_EMPTYFIELDS
;
1305 rEntry
.bQueryByString
= FALSE
;
1306 *rEntry
.pStr
= EMPTY_STRING
;
1309 case sheet::FilterOperator_NOT_EMPTY
:
1311 rEntry
.eOp
= SC_EQUAL
;
1312 rEntry
.nVal
= SC_NONEMPTYFIELDS
;
1313 rEntry
.bQueryByString
= FALSE
;
1314 *rEntry
.pStr
= EMPTY_STRING
;
1318 DBG_ERROR("Falscher Query-enum");
1319 rEntry
.eOp
= SC_EQUAL
;
1323 SCSIZE nParamCount
= aParam
.GetEntryCount(); // Param wird nicht unter 8 resized
1324 for (i
=nCount
; i
<nParamCount
; i
++)
1325 aParam
.GetEntry(i
).bDoQuery
= FALSE
; // ueberzaehlige Felder zuruecksetzen
1330 void SAL_CALL
ScFilterDescriptorBase::setFilterFields2(
1331 const uno::Sequence
<sheet::TableFilterField2
>& aFilterFields
)
1332 throw(uno::RuntimeException
)
1335 ScQueryParam aParam
;
1338 SCSIZE nCount
= static_cast<SCSIZE
>(aFilterFields
.getLength());
1339 DBG_ASSERT( nCount
<= MAXQUERY
, "setFilterFields: zu viele" );
1341 aParam
.Resize( nCount
);
1343 const sheet::TableFilterField2
* pAry
= aFilterFields
.getConstArray();
1345 for (i
=0; i
<nCount
; i
++)
1347 ScQueryEntry
& rEntry
= aParam
.GetEntry(i
);
1349 rEntry
.pStr
= new String
; // sollte nicht sein (soll immer initialisiert sein)
1351 rEntry
.bDoQuery
= TRUE
;
1352 rEntry
.eConnect
= (pAry
[i
].Connection
== sheet::FilterConnection_AND
) ? SC_AND
: SC_OR
;
1353 rEntry
.nField
= pAry
[i
].Field
;
1354 rEntry
.bQueryByString
= !pAry
[i
].IsNumeric
;
1355 *rEntry
.pStr
= String( pAry
[i
].StringValue
);
1356 rEntry
.nVal
= pAry
[i
].NumericValue
;
1358 if (!rEntry
.bQueryByString
&& pDocSh
)
1360 pDocSh
->GetDocument()->GetFormatTable()->GetInputLineString(rEntry
.nVal
, 0, *rEntry
.pStr
);
1363 switch (pAry
[i
].Operator
) // FilterOperator
1365 case sheet::FilterOperator2::EQUAL
: rEntry
.eOp
= SC_EQUAL
; break;
1366 case sheet::FilterOperator2::LESS
: rEntry
.eOp
= SC_LESS
; break;
1367 case sheet::FilterOperator2::GREATER
: rEntry
.eOp
= SC_GREATER
; break;
1368 case sheet::FilterOperator2::LESS_EQUAL
: rEntry
.eOp
= SC_LESS_EQUAL
; break;
1369 case sheet::FilterOperator2::GREATER_EQUAL
: rEntry
.eOp
= SC_GREATER_EQUAL
; break;
1370 case sheet::FilterOperator2::NOT_EQUAL
: rEntry
.eOp
= SC_NOT_EQUAL
; break;
1371 case sheet::FilterOperator2::TOP_VALUES
: rEntry
.eOp
= SC_TOPVAL
; break;
1372 case sheet::FilterOperator2::BOTTOM_VALUES
: rEntry
.eOp
= SC_BOTVAL
; break;
1373 case sheet::FilterOperator2::TOP_PERCENT
: rEntry
.eOp
= SC_TOPPERC
; break;
1374 case sheet::FilterOperator2::BOTTOM_PERCENT
: rEntry
.eOp
= SC_BOTPERC
; break;
1375 case sheet::FilterOperator2::CONTAINS
: rEntry
.eOp
= SC_CONTAINS
; break;
1376 case sheet::FilterOperator2::DOES_NOT_CONTAIN
: rEntry
.eOp
= SC_DOES_NOT_CONTAIN
; break;
1377 case sheet::FilterOperator2::BEGINS_WITH
: rEntry
.eOp
= SC_BEGINS_WITH
; break;
1378 case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH
: rEntry
.eOp
= SC_DOES_NOT_BEGIN_WITH
;break;
1379 case sheet::FilterOperator2::ENDS_WITH
: rEntry
.eOp
= SC_ENDS_WITH
; break;
1380 case sheet::FilterOperator2::DOES_NOT_END_WITH
: rEntry
.eOp
= SC_DOES_NOT_END_WITH
; break;
1381 case sheet::FilterOperator2::EMPTY
:
1383 rEntry
.eOp
= SC_EQUAL
;
1384 rEntry
.nVal
= SC_EMPTYFIELDS
;
1385 rEntry
.bQueryByString
= FALSE
;
1386 *rEntry
.pStr
= EMPTY_STRING
;
1389 case sheet::FilterOperator2::NOT_EMPTY
:
1391 rEntry
.eOp
= SC_EQUAL
;
1392 rEntry
.nVal
= SC_NONEMPTYFIELDS
;
1393 rEntry
.bQueryByString
= FALSE
;
1394 *rEntry
.pStr
= EMPTY_STRING
;
1398 DBG_ERROR("Falscher Query-enum");
1399 rEntry
.eOp
= SC_EQUAL
;
1403 SCSIZE nParamCount
= aParam
.GetEntryCount(); // Param wird nicht unter 8 resized
1404 for (i
=nCount
; i
<nParamCount
; i
++)
1405 aParam
.GetEntry(i
).bDoQuery
= FALSE
; // ueberzaehlige Felder zuruecksetzen
1410 // Rest sind Properties
1414 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScFilterDescriptorBase::getPropertySetInfo()
1415 throw(uno::RuntimeException
)
1418 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1419 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
1423 void SAL_CALL
ScFilterDescriptorBase::setPropertyValue(
1424 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
1425 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1426 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1427 uno::RuntimeException
)
1430 ScQueryParam aParam
;
1433 String
aString(aPropertyName
);
1434 if (aString
.EqualsAscii( SC_UNONAME_CONTHDR
))
1435 aParam
.bHasHeader
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1436 else if (aString
.EqualsAscii( SC_UNONAME_COPYOUT
))
1437 aParam
.bInplace
= !(ScUnoHelpFunctions::GetBoolFromAny( aValue
));
1438 else if (aString
.EqualsAscii( SC_UNONAME_ISCASE
))
1439 aParam
.bCaseSens
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1440 else if (aString
.EqualsAscii( SC_UNONAME_MAXFLD
))
1443 if ( (aValue
>>= nVal
) && nVal
> sal::static_int_cast
<sal_Int32
>(MAXQUERY
) )
1445 throw lang::IllegalArgumentException();
1448 else if (aString
.EqualsAscii( SC_UNONAME_ORIENT
))
1450 //! test for correct enum type?
1451 table::TableOrientation eOrient
= (table::TableOrientation
)
1452 ScUnoHelpFunctions::GetEnumFromAny( aValue
);
1453 aParam
.bByRow
= ( eOrient
!= table::TableOrientation_COLUMNS
);
1455 else if (aString
.EqualsAscii( SC_UNONAME_OUTPOS
))
1457 table::CellAddress aAddress
;
1458 if ( aValue
>>= aAddress
)
1460 aParam
.nDestTab
= aAddress
.Sheet
;
1461 aParam
.nDestCol
= (SCCOL
)aAddress
.Column
;
1462 aParam
.nDestRow
= (SCROW
)aAddress
.Row
;
1465 else if (aString
.EqualsAscii( SC_UNONAME_SAVEOUT
))
1466 aParam
.bDestPers
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1467 else if (aString
.EqualsAscii( SC_UNONAME_SKIPDUP
))
1468 aParam
.bDuplicate
= !(ScUnoHelpFunctions::GetBoolFromAny( aValue
));
1469 else if (aString
.EqualsAscii( SC_UNONAME_USEREGEX
))
1470 aParam
.bRegExp
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1475 uno::Any SAL_CALL
ScFilterDescriptorBase::getPropertyValue( const rtl::OUString
& aPropertyName
)
1476 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1477 uno::RuntimeException
)
1480 ScQueryParam aParam
;
1483 String
aString(aPropertyName
);
1486 if (aString
.EqualsAscii( SC_UNONAME_CONTHDR
))
1487 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bHasHeader
);
1488 else if (aString
.EqualsAscii( SC_UNONAME_COPYOUT
))
1489 ScUnoHelpFunctions::SetBoolInAny( aRet
, !(aParam
.bInplace
) );
1490 else if (aString
.EqualsAscii( SC_UNONAME_ISCASE
))
1491 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bCaseSens
);
1492 else if (aString
.EqualsAscii( SC_UNONAME_MAXFLD
))
1493 aRet
<<= (sal_Int32
) MAXQUERY
;
1494 else if (aString
.EqualsAscii( SC_UNONAME_ORIENT
))
1496 table::TableOrientation eOrient
= aParam
.bByRow
? table::TableOrientation_ROWS
:
1497 table::TableOrientation_COLUMNS
;
1500 else if (aString
.EqualsAscii( SC_UNONAME_OUTPOS
))
1502 table::CellAddress aOutPos
;
1503 aOutPos
.Sheet
= aParam
.nDestTab
;
1504 aOutPos
.Column
= aParam
.nDestCol
;
1505 aOutPos
.Row
= aParam
.nDestRow
;
1508 else if (aString
.EqualsAscii( SC_UNONAME_SAVEOUT
))
1509 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bDestPers
);
1510 else if (aString
.EqualsAscii( SC_UNONAME_SKIPDUP
))
1511 ScUnoHelpFunctions::SetBoolInAny( aRet
, !(aParam
.bDuplicate
) );
1512 else if (aString
.EqualsAscii( SC_UNONAME_USEREGEX
))
1513 ScUnoHelpFunctions::SetBoolInAny( aRet
, aParam
.bRegExp
);
1518 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFilterDescriptorBase
)
1520 //------------------------------------------------------------------------
1522 ScFilterDescriptor::ScFilterDescriptor(ScDocShell
* pDocShell
)
1524 ScFilterDescriptorBase(pDocShell
)
1528 ScFilterDescriptor::~ScFilterDescriptor()
1532 void ScFilterDescriptor::GetData( ScQueryParam
& rParam
) const
1534 rParam
= aStoredParam
; // Abfrage fuer Interface
1537 void ScFilterDescriptor::PutData( const ScQueryParam
& rParam
)
1539 aStoredParam
= rParam
; // vom Interface gesetzt
1542 void ScFilterDescriptor::SetParam( const ScQueryParam
& rNew
)
1544 aStoredParam
= rNew
; // von aussen gesetzt
1547 //------------------------------------------------------------------------
1549 ScRangeFilterDescriptor::ScRangeFilterDescriptor(ScDocShell
* pDocShell
, ScDatabaseRangeObj
* pPar
) :
1550 ScFilterDescriptorBase(pDocShell
),
1557 ScRangeFilterDescriptor::~ScRangeFilterDescriptor()
1563 void ScRangeFilterDescriptor::GetData( ScQueryParam
& rParam
) const
1566 pParent
->GetQueryParam( rParam
);
1569 void ScRangeFilterDescriptor::PutData( const ScQueryParam
& rParam
)
1572 pParent
->SetQueryParam( rParam
);
1575 //------------------------------------------------------------------------
1577 ScDataPilotFilterDescriptor::ScDataPilotFilterDescriptor(ScDocShell
* pDocShell
, ScDataPilotDescriptorBase
* pPar
) :
1578 ScFilterDescriptorBase(pDocShell
),
1585 ScDataPilotFilterDescriptor::~ScDataPilotFilterDescriptor()
1591 void ScDataPilotFilterDescriptor::GetData( ScQueryParam
& rParam
) const
1595 ScDPObject
* pDPObj
= pParent
->GetDPObject();
1596 if (pDPObj
&& pDPObj
->IsSheetData())
1597 rParam
= pDPObj
->GetSheetDesc()->aQueryParam
;
1601 void ScDataPilotFilterDescriptor::PutData( const ScQueryParam
& rParam
)
1605 ScDPObject
* pDPObj
= pParent
->GetDPObject();
1608 ScSheetSourceDesc aSheetDesc
;
1609 if (pDPObj
->IsSheetData())
1610 aSheetDesc
= *pDPObj
->GetSheetDesc();
1611 aSheetDesc
.aQueryParam
= rParam
;
1612 pDPObj
->SetSheetDesc(aSheetDesc
);
1613 pParent
->SetDPObject(pDPObj
);
1618 //------------------------------------------------------------------------
1620 ScDatabaseRangeObj::ScDatabaseRangeObj(ScDocShell
* pDocSh
, const String
& rNm
) :
1621 pDocShell( pDocSh
),
1623 aPropSet( lcl_GetDBRangePropertyMap() )
1625 pDocShell
->GetDocument()->AddUnoObject(*this);
1628 ScDatabaseRangeObj::~ScDatabaseRangeObj()
1631 pDocShell
->GetDocument()->RemoveUnoObject(*this);
1634 void ScDatabaseRangeObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1637 if ( rHint
.ISA( SfxSimpleHint
) && ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
1638 pDocShell
= NULL
; // ungueltig geworden
1639 else if ( rHint
.ISA (ScDBRangeRefreshedHint
) )
1641 ScDBData
* pDBData
= GetDBData_Impl();
1642 const ScDBRangeRefreshedHint
& rRef
= (const ScDBRangeRefreshedHint
&)rHint
;
1643 ScImportParam aParam
;
1644 pDBData
->GetImportParam(aParam
);
1645 if (aParam
== rRef
.GetImportParam())
1652 ScDBData
* ScDatabaseRangeObj::GetDBData_Impl() const
1654 ScDBData
* pRet
= NULL
;
1657 ScDBCollection
* pNames
= pDocShell
->GetDocument()->GetDBCollection();
1661 if (pNames
->SearchName( aName
, nPos
))
1662 pRet
= (*pNames
)[nPos
];
1670 rtl::OUString SAL_CALL
ScDatabaseRangeObj::getName() throw(uno::RuntimeException
)
1676 void SAL_CALL
ScDatabaseRangeObj::setName( const rtl::OUString
& aNewName
)
1677 throw(uno::RuntimeException
)
1682 ScDBDocFunc
aFunc(*pDocShell
);
1683 String
aNewStr(aNewName
);
1684 BOOL bOk
= aFunc
.RenameDBRange( aName
, aNewStr
, TRUE
);
1692 table::CellRangeAddress SAL_CALL
ScDatabaseRangeObj::getDataArea() throw(uno::RuntimeException
)
1695 table::CellRangeAddress aAddress
;
1696 ScDBData
* pData
= GetDBData_Impl();
1700 pData
->GetArea(aRange
);
1701 aAddress
.Sheet
= aRange
.aStart
.Tab();
1702 aAddress
.StartColumn
= aRange
.aStart
.Col();
1703 aAddress
.StartRow
= aRange
.aStart
.Row();
1704 aAddress
.EndColumn
= aRange
.aEnd
.Col();
1705 aAddress
.EndRow
= aRange
.aEnd
.Row();
1710 void SAL_CALL
ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress
& aDataArea
)
1711 throw(uno::RuntimeException
)
1714 ScDBData
* pData
= GetDBData_Impl();
1715 if ( pDocShell
&& pData
)
1717 ScDBData
aNewData( *pData
);
1719 aNewData
.SetArea( aDataArea
.Sheet
, (SCCOL
)aDataArea
.StartColumn
, (SCROW
)aDataArea
.StartRow
,
1720 (SCCOL
)aDataArea
.EndColumn
, (SCROW
)aDataArea
.EndRow
);
1721 ScDBDocFunc
aFunc(*pDocShell
);
1722 aFunc
.ModifyDBData(aNewData
, TRUE
);
1726 uno::Sequence
<beans::PropertyValue
> SAL_CALL
ScDatabaseRangeObj::getSortDescriptor()
1727 throw(uno::RuntimeException
)
1731 const ScDBData
* pData
= GetDBData_Impl();
1734 pData
->GetSortParam(aParam
);
1736 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1738 pData
->GetArea(aDBRange
);
1739 SCCOLROW nFieldStart
= aParam
.bByRow
? static_cast<SCCOLROW
>(aDBRange
.aStart
.Col()) : static_cast<SCCOLROW
>(aDBRange
.aStart
.Row());
1740 for (USHORT i
=0; i
<MAXSORT
; i
++)
1741 if ( aParam
.bDoSort
[i
] && aParam
.nField
[i
] >= nFieldStart
)
1742 aParam
.nField
[i
] -= nFieldStart
;
1745 uno::Sequence
<beans::PropertyValue
> aSeq( ScSortDescriptor::GetPropertyCount() );
1746 ScSortDescriptor::FillProperties( aSeq
, aParam
);
1750 void ScDatabaseRangeObj::GetQueryParam(ScQueryParam
& rQueryParam
) const
1752 const ScDBData
* pData
= GetDBData_Impl();
1755 pData
->GetQueryParam(rQueryParam
);
1757 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1759 pData
->GetArea(aDBRange
);
1760 SCCOLROW nFieldStart
= rQueryParam
.bByRow
? static_cast<SCCOLROW
>(aDBRange
.aStart
.Col()) : static_cast<SCCOLROW
>(aDBRange
.aStart
.Row());
1761 SCSIZE nCount
= rQueryParam
.GetEntryCount();
1762 for (SCSIZE i
=0; i
<nCount
; i
++)
1764 ScQueryEntry
& rEntry
= rQueryParam
.GetEntry(i
);
1765 if (rEntry
.bDoQuery
&& rEntry
.nField
>= nFieldStart
)
1766 rEntry
.nField
-= nFieldStart
;
1771 void ScDatabaseRangeObj::SetQueryParam(const ScQueryParam
& rQueryParam
)
1773 const ScDBData
* pData
= GetDBData_Impl();
1776 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1777 ScQueryParam
aParam(rQueryParam
);
1779 pData
->GetArea(aDBRange
);
1780 SCCOLROW nFieldStart
= aParam
.bByRow
? static_cast<SCCOLROW
>(aDBRange
.aStart
.Col()) : static_cast<SCCOLROW
>(aDBRange
.aStart
.Row());
1782 SCSIZE nCount
= aParam
.GetEntryCount();
1783 for (SCSIZE i
=0; i
<nCount
; i
++)
1785 ScQueryEntry
& rEntry
= aParam
.GetEntry(i
);
1786 if (rEntry
.bDoQuery
)
1787 rEntry
.nField
+= nFieldStart
;
1790 ScDBData
aNewData( *pData
);
1791 aNewData
.SetQueryParam(aParam
);
1792 aNewData
.SetHeader(aParam
.bHasHeader
); // not in ScDBData::SetQueryParam
1793 ScDBDocFunc
aFunc(*pDocShell
);
1794 aFunc
.ModifyDBData(aNewData
, TRUE
);
1798 uno::Reference
<sheet::XSheetFilterDescriptor
> SAL_CALL
ScDatabaseRangeObj::getFilterDescriptor()
1799 throw(uno::RuntimeException
)
1802 return new ScRangeFilterDescriptor(pDocShell
, this);
1805 void ScDatabaseRangeObj::GetSubTotalParam(ScSubTotalParam
& rSubTotalParam
) const
1807 const ScDBData
* pData
= GetDBData_Impl();
1810 pData
->GetSubTotalParam(rSubTotalParam
);
1812 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1814 pData
->GetArea(aDBRange
);
1815 SCCOL nFieldStart
= aDBRange
.aStart
.Col();
1816 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
1818 if ( rSubTotalParam
.bGroupActive
[i
] )
1820 if ( rSubTotalParam
.nField
[i
] >= nFieldStart
)
1821 rSubTotalParam
.nField
[i
] = sal::static_int_cast
<SCCOL
>( rSubTotalParam
.nField
[i
] - nFieldStart
);
1822 for (SCCOL j
=0; j
<rSubTotalParam
.nSubTotals
[i
]; j
++)
1823 if ( rSubTotalParam
.pSubTotals
[i
][j
] >= nFieldStart
)
1824 rSubTotalParam
.pSubTotals
[i
][j
] =
1825 sal::static_int_cast
<SCCOL
>( rSubTotalParam
.pSubTotals
[i
][j
] - nFieldStart
);
1831 void ScDatabaseRangeObj::SetSubTotalParam(const ScSubTotalParam
& rSubTotalParam
)
1833 const ScDBData
* pData
= GetDBData_Impl();
1836 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1837 ScSubTotalParam
aParam(rSubTotalParam
);
1839 pData
->GetArea(aDBRange
);
1840 SCCOL nFieldStart
= aDBRange
.aStart
.Col();
1841 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
1843 if ( aParam
.bGroupActive
[i
] )
1845 aParam
.nField
[i
] = sal::static_int_cast
<SCCOL
>( aParam
.nField
[i
] + nFieldStart
);
1846 for (SCCOL j
=0; j
<aParam
.nSubTotals
[i
]; j
++)
1847 aParam
.pSubTotals
[i
][j
] = sal::static_int_cast
<SCCOL
>( aParam
.pSubTotals
[i
][j
] + nFieldStart
);
1851 ScDBData
aNewData( *pData
);
1852 aNewData
.SetSubTotalParam(aParam
);
1853 ScDBDocFunc
aFunc(*pDocShell
);
1854 aFunc
.ModifyDBData(aNewData
, TRUE
);
1858 uno::Reference
<sheet::XSubTotalDescriptor
> SAL_CALL
ScDatabaseRangeObj::getSubTotalDescriptor()
1859 throw(uno::RuntimeException
)
1862 return new ScRangeSubTotalDescriptor(this);
1865 uno::Sequence
<beans::PropertyValue
> SAL_CALL
ScDatabaseRangeObj::getImportDescriptor()
1866 throw(uno::RuntimeException
)
1869 ScImportParam aParam
;
1870 const ScDBData
* pData
= GetDBData_Impl();
1872 pData
->GetImportParam(aParam
);
1874 uno::Sequence
<beans::PropertyValue
> aSeq( ScImportDescriptor::GetPropertyCount() );
1875 ScImportDescriptor::FillProperties( aSeq
, aParam
);
1881 void SAL_CALL
ScDatabaseRangeObj::refresh() throw(uno::RuntimeException
)
1884 ScDBData
* pData
= GetDBData_Impl();
1885 if ( pDocShell
&& pData
)
1887 ScDBDocFunc
aFunc(*pDocShell
);
1889 // Import zu wiederholen?
1890 BOOL bContinue
= TRUE
;
1891 ScImportParam aImportParam
;
1892 pData
->GetImportParam( aImportParam
);
1893 if (aImportParam
.bImport
&& !pData
->HasImportSelection())
1898 pData
->GetArea( nTab
, nDummyCol
,nDummyRow
,nDummyCol
,nDummyRow
);
1899 uno::Reference
< sdbc::XResultSet
> xResultSet
;
1900 bContinue
= aFunc
.DoImport( nTab
, aImportParam
, xResultSet
, NULL
, TRUE
, FALSE
); //! Api-Flag als Parameter
1903 // interne Operationen (sort, query, subtotal) nur, wenn kein Fehler
1905 aFunc
.RepeatDB( pData
->GetName(), TRUE
, TRUE
);
1909 void SAL_CALL
ScDatabaseRangeObj::addRefreshListener(
1910 const uno::Reference
<util::XRefreshListener
>& xListener
)
1911 throw(uno::RuntimeException
)
1914 uno::Reference
<util::XRefreshListener
>* pObj
=
1915 new uno::Reference
<util::XRefreshListener
>( xListener
);
1916 aRefreshListeners
.Insert( pObj
, aRefreshListeners
.Count() );
1918 // hold one additional ref to keep this object alive as long as there are listeners
1919 if ( aRefreshListeners
.Count() == 1 )
1923 void SAL_CALL
ScDatabaseRangeObj::removeRefreshListener(
1924 const uno::Reference
<util::XRefreshListener
>& xListener
)
1925 throw(uno::RuntimeException
)
1928 USHORT nCount
= aRefreshListeners
.Count();
1929 for ( USHORT n
=nCount
; n
--; )
1931 uno::Reference
<util::XRefreshListener
>* pObj
= aRefreshListeners
[n
];
1932 if ( *pObj
== xListener
)
1934 aRefreshListeners
.DeleteAndDestroy( n
);
1935 if ( aRefreshListeners
.Count() == 0 )
1936 release(); // release ref for listeners
1942 void ScDatabaseRangeObj::Refreshed_Impl()
1944 lang::EventObject aEvent
;
1945 aEvent
.Source
= (cppu::OWeakObject
*)this;
1946 for ( USHORT n
=0; n
<aRefreshListeners
.Count(); n
++ )
1947 (*aRefreshListeners
[n
])->refreshed( aEvent
);
1952 uno::Reference
<table::XCellRange
> SAL_CALL
ScDatabaseRangeObj::getReferredCells()
1953 throw(uno::RuntimeException
)
1957 ScDBData
* pData
= GetDBData_Impl();
1960 //! static Funktion um ScCellObj/ScCellRangeObj zu erzeugen am ScCellRangeObj ???
1962 pData
->GetArea(aRange
);
1963 if ( aRange
.aStart
== aRange
.aEnd
)
1964 return new ScCellObj( pDocShell
, aRange
.aStart
);
1966 return new ScCellRangeObj( pDocShell
, aRange
);
1973 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScDatabaseRangeObj::getPropertySetInfo()
1974 throw(uno::RuntimeException
)
1977 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1978 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
1982 void SAL_CALL
ScDatabaseRangeObj::setPropertyValue(
1983 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
1984 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1985 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1986 uno::RuntimeException
)
1989 ScDBData
* pData
= GetDBData_Impl();
1990 if ( pDocShell
&& pData
)
1992 ScDBData
aNewData( *pData
);
1995 String
aString(aPropertyName
);
1996 if ( aString
.EqualsAscii( SC_UNONAME_KEEPFORM
) )
1997 aNewData
.SetKeepFmt( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1998 else if ( aString
.EqualsAscii( SC_UNONAME_MOVCELLS
) )
1999 aNewData
.SetDoSize( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
2000 else if ( aString
.EqualsAscii( SC_UNONAME_STRIPDAT
) )
2001 aNewData
.SetStripData( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
2002 else if (aString
.EqualsAscii( SC_UNONAME_AUTOFLT
))
2004 sal_Bool
bAutoFilter(ScUnoHelpFunctions::GetBoolFromAny( aValue
));
2005 aNewData
.SetAutoFilter(bAutoFilter
);
2007 aNewData
.GetArea(aRange
);
2008 ScDocument
* pDoc
= pDocShell
->GetDocument();
2009 if (bAutoFilter
&& pDoc
)
2010 pDoc
->ApplyFlagsTab( aRange
.aStart
.Col(), aRange
.aStart
.Row(),
2011 aRange
.aEnd
.Col(), aRange
.aStart
.Row(),
2012 aRange
.aStart
.Tab(), SC_MF_AUTO
);
2013 else if (!bAutoFilter
&& pDoc
)
2014 pDoc
->RemoveFlagsTab(aRange
.aStart
.Col(), aRange
.aStart
.Row(),
2015 aRange
.aEnd
.Col(), aRange
.aStart
.Row(),
2016 aRange
.aStart
.Tab(), SC_MF_AUTO
);
2017 ScRange
aPaintRange(aRange
.aStart
, aRange
.aEnd
);
2018 aPaintRange
.aEnd
.SetRow(aPaintRange
.aStart
.Row());
2019 pDocShell
->PostPaint(aPaintRange
, PAINT_GRID
);
2021 else if (aString
.EqualsAscii( SC_UNONAME_USEFLTCRT
))
2023 if (ScUnoHelpFunctions::GetBoolFromAny( aValue
))
2026 aNewData
.GetAdvancedQuerySource(aRange
);
2027 aNewData
.SetAdvancedQuerySource(&aRange
);
2030 aNewData
.SetAdvancedQuerySource(NULL
);
2032 else if (aString
.EqualsAscii( SC_UNONAME_FLTCRT
))
2034 table::CellRangeAddress aRange
;
2035 if (aValue
>>= aRange
)
2038 ScUnoConversion::FillScRange(aCoreRange
, aRange
);
2040 aNewData
.SetAdvancedQuerySource(&aCoreRange
);
2043 else if (aString
.EqualsAscii( SC_UNONAME_FROMSELECT
))
2045 aNewData
.SetImportSelection(::cppu::any2bool(aValue
));
2047 else if (aString
.EqualsAscii( SC_UNONAME_REFPERIOD
))
2049 sal_Int32 nRefresh
= 0;
2050 if (aValue
>>= nRefresh
)
2052 ScDocument
* pDoc
= pDocShell
->GetDocument();
2053 aNewData
.SetRefreshDelay(nRefresh
);
2054 if (pDoc
&& pDoc
->GetDBCollection())
2056 aNewData
.SetRefreshHandler( pDoc
->GetDBCollection()->GetRefreshHandler() );
2057 aNewData
.SetRefreshControl( pDoc
->GetRefreshTimerControlAddress() );
2061 else if (aString
.EqualsAscii( SC_UNONAME_CONRES
))
2069 ScDBDocFunc
aFunc(*pDocShell
);
2070 aFunc
.ModifyDBData(aNewData
, TRUE
);
2075 uno::Any SAL_CALL
ScDatabaseRangeObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
2076 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
2077 uno::RuntimeException
)
2081 ScDBData
* pData
= GetDBData_Impl();
2084 String
aString(aPropertyName
);
2085 if ( aString
.EqualsAscii( SC_UNONAME_KEEPFORM
) )
2086 ScUnoHelpFunctions::SetBoolInAny( aRet
, pData
->IsKeepFmt() );
2087 else if ( aString
.EqualsAscii( SC_UNONAME_MOVCELLS
) )
2088 ScUnoHelpFunctions::SetBoolInAny( aRet
, pData
->IsDoSize() );
2089 else if ( aString
.EqualsAscii( SC_UNONAME_STRIPDAT
) )
2090 ScUnoHelpFunctions::SetBoolInAny( aRet
, pData
->IsStripData() );
2091 else if ( aString
.EqualsAscii( SC_UNONAME_ISUSER
) )
2093 // all database ranges except "unnamed" are user defined
2094 ScUnoHelpFunctions::SetBoolInAny( aRet
,
2095 ( pData
->GetName() != ScGlobal::GetRscString(STR_DB_NONAME
) ) );
2097 else if ( aString
.EqualsAscii( SC_UNO_LINKDISPBIT
) )
2099 // no target bitmaps for individual entries (would be all equal)
2100 // ScLinkTargetTypeObj::SetLinkTargetBitmap( aRet, SC_LINKTARGETTYPE_DBAREA );
2102 else if ( aString
.EqualsAscii( SC_UNO_LINKDISPNAME
) )
2103 aRet
<<= rtl::OUString( aName
);
2104 else if (aString
.EqualsAscii( SC_UNONAME_AUTOFLT
))
2106 sal_Bool
bAutoFilter(GetDBData_Impl()->HasAutoFilter());
2108 ScUnoHelpFunctions::SetBoolInAny( aRet
, bAutoFilter
);
2110 else if (aString
.EqualsAscii( SC_UNONAME_USEFLTCRT
))
2113 sal_Bool
bIsAdvancedSource(GetDBData_Impl()->GetAdvancedQuerySource(aRange
));
2115 ScUnoHelpFunctions::SetBoolInAny( aRet
, bIsAdvancedSource
);
2117 else if (aString
.EqualsAscii( SC_UNONAME_FLTCRT
))
2119 table::CellRangeAddress aRange
;
2121 if (GetDBData_Impl()->GetAdvancedQuerySource(aCoreRange
))
2122 ScUnoConversion::FillApiRange(aRange
, aCoreRange
);
2126 else if (aString
.EqualsAscii( SC_UNONAME_FROMSELECT
))
2128 ScUnoHelpFunctions::SetBoolInAny( aRet
, GetDBData_Impl()->HasImportSelection() );
2130 else if (aString
.EqualsAscii( SC_UNONAME_REFPERIOD
))
2132 sal_Int32
nRefresh(GetDBData_Impl()->GetRefreshDelay());
2135 else if (aString
.EqualsAscii( SC_UNONAME_CONRES
))
2138 else if (aString
.EqualsAscii( SC_UNONAME_TOKENINDEX
))
2140 // get index for use in formula tokens (read-only)
2141 aRet
<<= static_cast<sal_Int32
>(GetDBData_Impl()->GetIndex());
2147 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDatabaseRangeObj
)
2151 rtl::OUString SAL_CALL
ScDatabaseRangeObj::getImplementationName() throw(uno::RuntimeException
)
2153 return rtl::OUString::createFromAscii( "ScDatabaseRangeObj" );
2156 sal_Bool SAL_CALL
ScDatabaseRangeObj::supportsService( const rtl::OUString
& rServiceName
)
2157 throw(uno::RuntimeException
)
2159 String
aServiceStr( rServiceName
);
2160 return aServiceStr
.EqualsAscii( SCDATABASERANGEOBJ_SERVICE
) ||
2161 aServiceStr
.EqualsAscii( SCLINKTARGET_SERVICE
);
2164 uno::Sequence
<rtl::OUString
> SAL_CALL
ScDatabaseRangeObj::getSupportedServiceNames()
2165 throw(uno::RuntimeException
)
2167 uno::Sequence
<rtl::OUString
> aRet(2);
2168 rtl::OUString
* pArray
= aRet
.getArray();
2169 pArray
[0] = rtl::OUString::createFromAscii( SCDATABASERANGEOBJ_SERVICE
);
2170 pArray
[1] = rtl::OUString::createFromAscii( SCLINKTARGET_SERVICE
);
2174 //------------------------------------------------------------------------
2176 ScDatabaseRangesObj::ScDatabaseRangesObj(ScDocShell
* pDocSh
) :
2179 pDocShell
->GetDocument()->AddUnoObject(*this);
2182 ScDatabaseRangesObj::~ScDatabaseRangesObj()
2185 pDocShell
->GetDocument()->RemoveUnoObject(*this);
2188 void ScDatabaseRangesObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
2190 // Referenz-Update interessiert hier nicht
2192 if ( rHint
.ISA( SfxSimpleHint
) &&
2193 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
2195 pDocShell
= NULL
; // ungueltig geworden
2201 ScDatabaseRangeObj
* ScDatabaseRangesObj::GetObjectByIndex_Impl(USHORT nIndex
)
2205 ScDBCollection
* pNames
= pDocShell
->GetDocument()->GetDBCollection();
2206 if (pNames
&& nIndex
< pNames
->GetCount())
2207 return new ScDatabaseRangeObj( pDocShell
, (*pNames
)[nIndex
]->GetName() );
2212 ScDatabaseRangeObj
* ScDatabaseRangesObj::GetObjectByName_Impl(const rtl::OUString
& aName
)
2214 if ( pDocShell
&& hasByName(aName
) )
2216 String
aString(aName
);
2217 return new ScDatabaseRangeObj( pDocShell
, aString
);
2223 void SAL_CALL
ScDatabaseRangesObj::addNewByName( const rtl::OUString
& aName
,
2224 const table::CellRangeAddress
& aRange
)
2225 throw(uno::RuntimeException
)
2231 ScDBDocFunc
aFunc(*pDocShell
);
2233 String
aString(aName
);
2234 ScRange
aNameRange( (SCCOL
)aRange
.StartColumn
, (SCROW
)aRange
.StartRow
, aRange
.Sheet
,
2235 (SCCOL
)aRange
.EndColumn
, (SCROW
)aRange
.EndRow
, aRange
.Sheet
);
2236 bDone
= aFunc
.AddDBRange( aString
, aNameRange
, TRUE
);
2239 throw uno::RuntimeException(); // no other exceptions specified
2242 void SAL_CALL
ScDatabaseRangesObj::removeByName( const rtl::OUString
& aName
)
2243 throw(uno::RuntimeException
)
2249 ScDBDocFunc
aFunc(*pDocShell
);
2250 String
aString(aName
);
2251 bDone
= aFunc
.DeleteDBRange( aString
, TRUE
);
2254 throw uno::RuntimeException(); // no other exceptions specified
2257 // XEnumerationAccess
2259 uno::Reference
<container::XEnumeration
> SAL_CALL
ScDatabaseRangesObj::createEnumeration()
2260 throw(uno::RuntimeException
)
2263 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DatabaseRangesEnumeration")));
2268 sal_Int32 SAL_CALL
ScDatabaseRangesObj::getCount() throw(uno::RuntimeException
)
2272 //! "unbenannt" weglassen ?
2276 ScDBCollection
* pNames
= pDocShell
->GetDocument()->GetDBCollection();
2278 return pNames
->GetCount();
2283 uno::Any SAL_CALL
ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex
)
2284 throw(lang::IndexOutOfBoundsException
,
2285 lang::WrappedTargetException
, uno::RuntimeException
)
2288 uno::Reference
<sheet::XDatabaseRange
> xRange(GetObjectByIndex_Impl((USHORT
)nIndex
));
2290 return uno::makeAny(xRange
);
2292 throw lang::IndexOutOfBoundsException();
2293 // return uno::Any();
2296 uno::Type SAL_CALL
ScDatabaseRangesObj::getElementType() throw(uno::RuntimeException
)
2299 return getCppuType((uno::Reference
<sheet::XDatabaseRange
>*)0);
2302 sal_Bool SAL_CALL
ScDatabaseRangesObj::hasElements() throw(uno::RuntimeException
)
2305 return ( getCount() != 0 );
2310 uno::Any SAL_CALL
ScDatabaseRangesObj::getByName( const rtl::OUString
& aName
)
2311 throw(container::NoSuchElementException
,
2312 lang::WrappedTargetException
, uno::RuntimeException
)
2315 uno::Reference
<sheet::XDatabaseRange
> xRange(GetObjectByName_Impl(aName
));
2317 return uno::makeAny(xRange
);
2319 throw container::NoSuchElementException();
2320 // return uno::Any();
2323 uno::Sequence
<rtl::OUString
> SAL_CALL
ScDatabaseRangesObj::getElementNames()
2324 throw(uno::RuntimeException
)
2328 //! "unbenannt" weglassen ?
2332 ScDBCollection
* pNames
= pDocShell
->GetDocument()->GetDBCollection();
2335 USHORT nCount
= pNames
->GetCount();
2337 uno::Sequence
<rtl::OUString
> aSeq(nCount
);
2338 rtl::OUString
* pAry
= aSeq
.getArray();
2339 for (USHORT i
=0; i
<nCount
; i
++)
2340 pAry
[i
] = (*pNames
)[i
]->GetName();
2345 return uno::Sequence
<rtl::OUString
>(0);
2348 sal_Bool SAL_CALL
ScDatabaseRangesObj::hasByName( const rtl::OUString
& aName
)
2349 throw(uno::RuntimeException
)
2353 //! "unbenannt" weglassen ?
2357 ScDBCollection
* pNames
= pDocShell
->GetDocument()->GetDBCollection();
2360 String
aString(aName
);
2362 if (pNames
->SearchName( aString
, nPos
))
2369 //------------------------------------------------------------------------