xref: /AOO41X/main/sc/source/ui/unoobj/datauno.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <tools/debug.hxx>
34*cdf0e10cSrcweir #include <svl/smplhint.hxx>
35*cdf0e10cSrcweir #include <svl/zforlist.hxx>
36*cdf0e10cSrcweir #include <rtl/uuid.h>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/util/SortField.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/table/TableSortField.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/table/TableOrientation.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/table/CellRangeAddress.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/sheet/DataImportMode.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/sheet/FilterOperator2.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/sheet/TableFilterField2.hpp>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include "datauno.hxx"
49*cdf0e10cSrcweir #include "dapiuno.hxx"
50*cdf0e10cSrcweir #include "cellsuno.hxx"
51*cdf0e10cSrcweir #include "miscuno.hxx"
52*cdf0e10cSrcweir #include "targuno.hxx"
53*cdf0e10cSrcweir #include "rangeutl.hxx"
54*cdf0e10cSrcweir #include "dbcolect.hxx"
55*cdf0e10cSrcweir #include "docsh.hxx"
56*cdf0e10cSrcweir #include "dbdocfun.hxx"
57*cdf0e10cSrcweir #include "unoguard.hxx"
58*cdf0e10cSrcweir #include "unonames.hxx"
59*cdf0e10cSrcweir #include "globstr.hrc"
60*cdf0e10cSrcweir #ifndef SC_CONVUNO_HXX
61*cdf0e10cSrcweir #include "convuno.hxx"
62*cdf0e10cSrcweir #include "hints.hxx"
63*cdf0e10cSrcweir #endif
64*cdf0e10cSrcweir #include "attrib.hxx"
65*cdf0e10cSrcweir #include "dpshttab.hxx"
66*cdf0e10cSrcweir #include <comphelper/extract.hxx>
67*cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx>
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir using namespace com::sun::star;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir SV_IMPL_PTRARR( XDBRefreshListenerArr_Impl, XDBRefreshListenerPtr );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir //------------------------------------------------------------------------
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir //	alles ohne Which-ID, Map nur fuer PropertySetInfo
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetSubTotalPropertyMap()
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir 	// some old property names are for 5.2 compatibility
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     static SfxItemPropertyMapEntry aSubTotalPropertyMap_Impl[] =
82*cdf0e10cSrcweir 	{
83*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_BINDFMT),  0,  &getBooleanCppuType(),       0, 0},
84*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_CASE),     0,  &getBooleanCppuType(),       0, 0},
85*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_ENABSORT), 0,  &getBooleanCppuType(),       0, 0},
86*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_ENUSLIST), 0,  &getBooleanCppuType(),       0, 0},
87*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_FORMATS),  0,  &getBooleanCppuType(),       0, 0},
88*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_INSBRK),   0,  &getBooleanCppuType(),       0, 0},
89*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_ISCASE),   0,  &getBooleanCppuType(),       0, 0},
90*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_MAXFLD),   0,  &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0},
91*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_SORTASC),  0,  &getBooleanCppuType(),       0, 0},
92*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_ULIST),    0,  &getBooleanCppuType(),       0, 0},
93*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_UINDEX),   0,  &getCppuType((sal_Int32*)0), 0, 0},
94*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_USINDEX),  0,  &getCppuType((sal_Int32*)0), 0, 0},
95*cdf0e10cSrcweir         {0,0,0,0,0,0}
96*cdf0e10cSrcweir 	};
97*cdf0e10cSrcweir 	return aSubTotalPropertyMap_Impl;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetFilterPropertyMap()
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir     static SfxItemPropertyMapEntry aFilterPropertyMap_Impl[] =
103*cdf0e10cSrcweir 	{
104*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_CONTHDR),  0,  &getBooleanCppuType(),                      0, 0},
105*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_COPYOUT),  0,  &getBooleanCppuType(),                      0, 0},
106*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_ISCASE),   0,  &getBooleanCppuType(),                      0, 0},
107*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_MAXFLD),   0,  &getCppuType((sal_Int32*)0),                beans::PropertyAttribute::READONLY, 0},
108*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_ORIENT),   0,  &getCppuType((table::TableOrientation*)0),  0, 0},
109*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_OUTPOS),   0,  &getCppuType((table::CellAddress*)0),       0, 0},
110*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_SAVEOUT),  0,  &getBooleanCppuType(),                      0, 0},
111*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_SKIPDUP),  0,  &getBooleanCppuType(),                      0, 0},
112*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_USEREGEX), 0,  &getBooleanCppuType(),                      0, 0},
113*cdf0e10cSrcweir         {0,0,0,0,0,0}
114*cdf0e10cSrcweir 	};
115*cdf0e10cSrcweir 	return aFilterPropertyMap_Impl;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetDBRangePropertyMap()
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir     static SfxItemPropertyMapEntry aDBRangePropertyMap_Impl[] =
121*cdf0e10cSrcweir 	{
122*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_AUTOFLT),  0,  &getBooleanCppuType(),                      0, 0},
123*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_FLTCRT),   0,  &getCppuType((table::CellRangeAddress*)0),  0, 0},
124*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_FROMSELECT),0, &getBooleanCppuType(),                      0, 0},
125*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_ISUSER),   0,  &getBooleanCppuType(),           beans::PropertyAttribute::READONLY, 0 },
126*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_KEEPFORM), 0,  &getBooleanCppuType(),                      0, 0},
127*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT),  0,  &getCppuType((uno::Reference<awt::XBitmap>*)0), beans::PropertyAttribute::READONLY, 0 },
128*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), 0,  &getCppuType((rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
129*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_MOVCELLS), 0,  &getBooleanCppuType(),                      0, 0},
130*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_REFPERIOD), 0, &getCppuType((sal_Int32*)0),                0, 0},
131*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_STRIPDAT), 0,  &getBooleanCppuType(),                      0, 0},
132*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_TOKENINDEX),0, &getCppuType((sal_Int32*)0),     beans::PropertyAttribute::READONLY, 0 },
133*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNONAME_USEFLTCRT),0,  &getBooleanCppuType(),                      0, 0},
134*cdf0e10cSrcweir         {0,0,0,0,0,0}
135*cdf0e10cSrcweir 	};
136*cdf0e10cSrcweir 	return aDBRangePropertyMap_Impl;
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir //------------------------------------------------------------------------
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir #define SCDATABASERANGEOBJ_SERVICE		"com.sun.star.sheet.DatabaseRange"
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScConsolidationDescriptor, "ScConsolidationDescriptor", "com.sun.star.sheet.ConsolidationDescriptor" )
145*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScDatabaseRangesObj, "ScDatabaseRangesObj", "com.sun.star.sheet.DatabaseRanges" )
146*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScFilterDescriptorBase, "ScFilterDescriptorBase", "com.sun.star.sheet.SheetFilterDescriptor" )
147*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScSubTotalDescriptorBase, "ScSubTotalDescriptorBase", "com.sun.star.sheet.SubTotalDescriptor" )
148*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScSubTotalFieldObj, "ScSubTotalFieldObj", "com.sun.star.sheet.SubTotalField" )
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir //------------------------------------------------------------------------
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir // static
154*cdf0e10cSrcweir ScSubTotalFunc ScDataUnoConversion::GeneralToSubTotal( sheet::GeneralFunction eSummary )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir 	ScSubTotalFunc eSubTotal;
157*cdf0e10cSrcweir 	switch (eSummary)
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		case sheet::GeneralFunction_NONE:		eSubTotal = SUBTOTAL_FUNC_NONE;	break;
160*cdf0e10cSrcweir 		case sheet::GeneralFunction_SUM:		eSubTotal = SUBTOTAL_FUNC_SUM;	break;
161*cdf0e10cSrcweir 		case sheet::GeneralFunction_COUNT:		eSubTotal = SUBTOTAL_FUNC_CNT2;	break;
162*cdf0e10cSrcweir 		case sheet::GeneralFunction_AVERAGE:	eSubTotal = SUBTOTAL_FUNC_AVE;	break;
163*cdf0e10cSrcweir 		case sheet::GeneralFunction_MAX:		eSubTotal = SUBTOTAL_FUNC_MAX;	break;
164*cdf0e10cSrcweir 		case sheet::GeneralFunction_MIN:		eSubTotal = SUBTOTAL_FUNC_MIN;	break;
165*cdf0e10cSrcweir 		case sheet::GeneralFunction_PRODUCT:	eSubTotal = SUBTOTAL_FUNC_PROD;	break;
166*cdf0e10cSrcweir 		case sheet::GeneralFunction_COUNTNUMS:	eSubTotal = SUBTOTAL_FUNC_CNT;	break;
167*cdf0e10cSrcweir 		case sheet::GeneralFunction_STDEV:		eSubTotal = SUBTOTAL_FUNC_STD;	break;
168*cdf0e10cSrcweir 		case sheet::GeneralFunction_STDEVP:		eSubTotal = SUBTOTAL_FUNC_STDP;	break;
169*cdf0e10cSrcweir 		case sheet::GeneralFunction_VAR:		eSubTotal = SUBTOTAL_FUNC_VAR;	break;
170*cdf0e10cSrcweir 		case sheet::GeneralFunction_VARP:		eSubTotal = SUBTOTAL_FUNC_VARP;	break;
171*cdf0e10cSrcweir 		case sheet::GeneralFunction_AUTO:
172*cdf0e10cSrcweir 		default:
173*cdf0e10cSrcweir 			DBG_ERROR("GeneralToSubTotal: falscher enum");
174*cdf0e10cSrcweir 			eSubTotal = SUBTOTAL_FUNC_NONE;
175*cdf0e10cSrcweir 	}
176*cdf0e10cSrcweir 	return eSubTotal;
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir // static
180*cdf0e10cSrcweir sheet::GeneralFunction	ScDataUnoConversion::SubTotalToGeneral( ScSubTotalFunc eSubTotal )
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir 	sheet::GeneralFunction eGeneral;
183*cdf0e10cSrcweir 	switch (eSubTotal)
184*cdf0e10cSrcweir 	{
185*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_NONE: eGeneral = sheet::GeneralFunction_NONE;	  break;
186*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_AVE:  eGeneral = sheet::GeneralFunction_AVERAGE;	  break;
187*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_CNT:  eGeneral = sheet::GeneralFunction_COUNTNUMS; break;
188*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_CNT2: eGeneral = sheet::GeneralFunction_COUNT;	  break;
189*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_MAX:  eGeneral = sheet::GeneralFunction_MAX;		  break;
190*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_MIN:  eGeneral = sheet::GeneralFunction_MIN;		  break;
191*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_PROD: eGeneral = sheet::GeneralFunction_PRODUCT;	  break;
192*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_STD:  eGeneral = sheet::GeneralFunction_STDEV;	  break;
193*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_STDP: eGeneral = sheet::GeneralFunction_STDEVP;	  break;
194*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_SUM:  eGeneral = sheet::GeneralFunction_SUM;		  break;
195*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_VAR:  eGeneral = sheet::GeneralFunction_VAR;		  break;
196*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_VARP: eGeneral = sheet::GeneralFunction_VARP;	  break;
197*cdf0e10cSrcweir 		default:
198*cdf0e10cSrcweir 			DBG_ERROR("SubTotalToGeneral: falscher enum");
199*cdf0e10cSrcweir 			eGeneral = sheet::GeneralFunction_NONE;
200*cdf0e10cSrcweir 			break;
201*cdf0e10cSrcweir 	}
202*cdf0e10cSrcweir 	return eGeneral;
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir //------------------------------------------------------------------------
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir //	ScImportDescriptor: alles static
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir long ScImportDescriptor::GetPropertyCount()
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir 	return 4;
212*cdf0e10cSrcweir }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir void ScImportDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScImportParam& rParam )
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir 	DBG_ASSERT( rSeq.getLength() == GetPropertyCount(), "falscher Count" );
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	beans::PropertyValue* pArray = rSeq.getArray();
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	sheet::DataImportMode eMode = sheet::DataImportMode_NONE;
221*cdf0e10cSrcweir 	if ( rParam.bImport )
222*cdf0e10cSrcweir 	{
223*cdf0e10cSrcweir 		if ( rParam.bSql )
224*cdf0e10cSrcweir 			eMode = sheet::DataImportMode_SQL;
225*cdf0e10cSrcweir 		else if ( rParam.nType == ScDbQuery )
226*cdf0e10cSrcweir 			eMode = sheet::DataImportMode_QUERY;
227*cdf0e10cSrcweir 		else
228*cdf0e10cSrcweir 			eMode = sheet::DataImportMode_TABLE;		// Type ist immer ScDbQuery oder ScDbTable
229*cdf0e10cSrcweir 	}
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir     ::svx::ODataAccessDescriptor aDescriptor;
232*cdf0e10cSrcweir 	aDescriptor.setDataSource(rParam.aDBName);
233*cdf0e10cSrcweir     if (aDescriptor.has( svx::daDataSource ))
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir 	    pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_DBNAME );
236*cdf0e10cSrcweir 	    pArray[0].Value <<= rtl::OUString( rParam.aDBName );
237*cdf0e10cSrcweir     }
238*cdf0e10cSrcweir     else if (aDescriptor.has( svx::daConnectionResource ))
239*cdf0e10cSrcweir     {
240*cdf0e10cSrcweir 	    pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_CONRES );
241*cdf0e10cSrcweir 	    pArray[0].Value <<= rtl::OUString( rParam.aDBName );
242*cdf0e10cSrcweir     }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_SRCTYPE );
245*cdf0e10cSrcweir 	pArray[1].Value <<= eMode;
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 	pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_SRCOBJ );
248*cdf0e10cSrcweir 	pArray[2].Value <<= rtl::OUString( rParam.aStatement );
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 	pArray[3].Name = rtl::OUString::createFromAscii( SC_UNONAME_ISNATIVE );
251*cdf0e10cSrcweir 	ScUnoHelpFunctions::SetBoolInAny( pArray[3].Value, rParam.bNative );
252*cdf0e10cSrcweir }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir void ScImportDescriptor::FillImportParam( ScImportParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir 	rtl::OUString aStrVal;
257*cdf0e10cSrcweir 	const beans::PropertyValue* pPropArray = rSeq.getConstArray();
258*cdf0e10cSrcweir 	long nPropCount = rSeq.getLength();
259*cdf0e10cSrcweir 	for (long i = 0; i < nPropCount; i++)
260*cdf0e10cSrcweir 	{
261*cdf0e10cSrcweir 		const beans::PropertyValue& rProp = pPropArray[i];
262*cdf0e10cSrcweir 		String aPropName(rProp.Name);
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 		if (aPropName.EqualsAscii( SC_UNONAME_ISNATIVE ))
265*cdf0e10cSrcweir 			rParam.bNative = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
266*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_DBNAME ))
267*cdf0e10cSrcweir 		{
268*cdf0e10cSrcweir 			if ( rProp.Value >>= aStrVal )
269*cdf0e10cSrcweir 				rParam.aDBName = String( aStrVal );
270*cdf0e10cSrcweir 		}
271*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_CONRES ))
272*cdf0e10cSrcweir 		{
273*cdf0e10cSrcweir 			if ( rProp.Value >>= aStrVal )
274*cdf0e10cSrcweir 				rParam.aDBName = String( aStrVal );
275*cdf0e10cSrcweir 		}
276*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_SRCOBJ ))
277*cdf0e10cSrcweir 		{
278*cdf0e10cSrcweir 			if ( rProp.Value >>= aStrVal )
279*cdf0e10cSrcweir 				rParam.aStatement = String( aStrVal );
280*cdf0e10cSrcweir 		}
281*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_SRCTYPE ))
282*cdf0e10cSrcweir 		{
283*cdf0e10cSrcweir 			//!	test for correct enum type?
284*cdf0e10cSrcweir 			sheet::DataImportMode eMode = (sheet::DataImportMode)
285*cdf0e10cSrcweir 								ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
286*cdf0e10cSrcweir 			switch (eMode)
287*cdf0e10cSrcweir 			{
288*cdf0e10cSrcweir 				case sheet::DataImportMode_NONE:
289*cdf0e10cSrcweir 					rParam.bImport = sal_False;
290*cdf0e10cSrcweir 					break;
291*cdf0e10cSrcweir 				case sheet::DataImportMode_SQL:
292*cdf0e10cSrcweir 					rParam.bImport = sal_True;
293*cdf0e10cSrcweir 					rParam.bSql    = sal_True;
294*cdf0e10cSrcweir 					break;
295*cdf0e10cSrcweir 				case sheet::DataImportMode_TABLE:
296*cdf0e10cSrcweir 					rParam.bImport = sal_True;
297*cdf0e10cSrcweir 					rParam.bSql    = sal_False;
298*cdf0e10cSrcweir 					rParam.nType   = ScDbTable;
299*cdf0e10cSrcweir 					break;
300*cdf0e10cSrcweir 				case sheet::DataImportMode_QUERY:
301*cdf0e10cSrcweir 					rParam.bImport = sal_True;
302*cdf0e10cSrcweir 					rParam.bSql    = sal_False;
303*cdf0e10cSrcweir 					rParam.nType   = ScDbQuery;
304*cdf0e10cSrcweir 					break;
305*cdf0e10cSrcweir 				default:
306*cdf0e10cSrcweir 					DBG_ERROR("falscher Mode");
307*cdf0e10cSrcweir 					rParam.bImport = sal_False;
308*cdf0e10cSrcweir 			}
309*cdf0e10cSrcweir 		}
310*cdf0e10cSrcweir 	}
311*cdf0e10cSrcweir }
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir //------------------------------------------------------------------------
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir //	ScSortDescriptor: alles static
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir //!	SortAscending muss aus der SheetSortDescriptor service-Beschreibung raus
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir long ScSortDescriptor::GetPropertyCount()
320*cdf0e10cSrcweir {
321*cdf0e10cSrcweir 	return 9;		// TableSortDescriptor and SheetSortDescriptor
322*cdf0e10cSrcweir }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir void ScSortDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScSortParam& rParam )
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir 	DBG_ASSERT( rSeq.getLength() == GetPropertyCount(), "falscher Count" );
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 	beans::PropertyValue* pArray = rSeq.getArray();
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 	//	Uno-Werte zusammensuchen
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir 	table::CellAddress aOutPos;
333*cdf0e10cSrcweir 	aOutPos.Sheet  = rParam.nDestTab;
334*cdf0e10cSrcweir 	aOutPos.Column = rParam.nDestCol;
335*cdf0e10cSrcweir 	aOutPos.Row    = rParam.nDestRow;
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	sal_uInt16 nSortCount = 0;
338*cdf0e10cSrcweir 	while ( nSortCount < MAXSORT && rParam.bDoSort[nSortCount] )
339*cdf0e10cSrcweir 		++nSortCount;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	uno::Sequence<table::TableSortField> aFields(nSortCount);
342*cdf0e10cSrcweir 	if (nSortCount)
343*cdf0e10cSrcweir 	{
344*cdf0e10cSrcweir 		table::TableSortField* pFieldArray = aFields.getArray();
345*cdf0e10cSrcweir 		for (sal_uInt16 i=0; i<nSortCount; i++)
346*cdf0e10cSrcweir 		{
347*cdf0e10cSrcweir 			pFieldArray[i].Field		 = rParam.nField[i];
348*cdf0e10cSrcweir 			pFieldArray[i].IsAscending   = rParam.bAscending[i];
349*cdf0e10cSrcweir 			pFieldArray[i].FieldType	 = table::TableSortFieldType_AUTOMATIC;		// immer Automatic
350*cdf0e10cSrcweir             pFieldArray[i].IsCaseSensitive = rParam.bCaseSens;
351*cdf0e10cSrcweir             pFieldArray[i].CollatorLocale = rParam.aCollatorLocale;
352*cdf0e10cSrcweir             pFieldArray[i].CollatorAlgorithm = rtl::OUString( rParam.aCollatorAlgorithm );
353*cdf0e10cSrcweir 		}
354*cdf0e10cSrcweir 	}
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 	//	Sequence fuellen
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 	pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_ISSORTCOLUMNS );
359*cdf0e10cSrcweir     pArray[0].Value = ::cppu::bool2any(!rParam.bByRow);
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 	pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_CONTHDR );
362*cdf0e10cSrcweir 	ScUnoHelpFunctions::SetBoolInAny( pArray[1].Value, rParam.bHasHeader );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_MAXFLD );
365*cdf0e10cSrcweir 	pArray[2].Value <<= (sal_Int32) MAXSORT;
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	pArray[3].Name = rtl::OUString::createFromAscii( SC_UNONAME_SORTFLD );
368*cdf0e10cSrcweir 	pArray[3].Value <<= aFields;
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir 	pArray[4].Name = rtl::OUString::createFromAscii( SC_UNONAME_BINDFMT );
371*cdf0e10cSrcweir 	ScUnoHelpFunctions::SetBoolInAny( pArray[4].Value, rParam.bIncludePattern );
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 	pArray[5].Name = rtl::OUString::createFromAscii( SC_UNONAME_COPYOUT );
374*cdf0e10cSrcweir 	ScUnoHelpFunctions::SetBoolInAny( pArray[5].Value, !rParam.bInplace );
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 	pArray[6].Name = rtl::OUString::createFromAscii( SC_UNONAME_OUTPOS );
377*cdf0e10cSrcweir 	pArray[6].Value <<= aOutPos;
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 	pArray[7].Name = rtl::OUString::createFromAscii( SC_UNONAME_ISULIST );
380*cdf0e10cSrcweir 	ScUnoHelpFunctions::SetBoolInAny( pArray[7].Value, rParam.bUserDef );
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	pArray[8].Name = rtl::OUString::createFromAscii( SC_UNONAME_UINDEX );
383*cdf0e10cSrcweir 	pArray[8].Value <<= (sal_Int32) rParam.nUserIndex;
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir void ScSortDescriptor::FillSortParam( ScSortParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
387*cdf0e10cSrcweir {
388*cdf0e10cSrcweir     sal_Bool bOldSortDescriptor(sal_False);
389*cdf0e10cSrcweir     sal_Bool bNewSortDescriptor(sal_False);
390*cdf0e10cSrcweir 	const beans::PropertyValue* pPropArray = rSeq.getConstArray();
391*cdf0e10cSrcweir 	long nPropCount = rSeq.getLength();
392*cdf0e10cSrcweir     for (long nProp = 0; nProp < nPropCount; nProp++)
393*cdf0e10cSrcweir 	{
394*cdf0e10cSrcweir         const beans::PropertyValue& rProp = pPropArray[nProp];
395*cdf0e10cSrcweir 		String aPropName(rProp.Name);
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 		if (aPropName.EqualsAscii( SC_UNONAME_ORIENT ))
398*cdf0e10cSrcweir 		{
399*cdf0e10cSrcweir             bOldSortDescriptor = sal_True;
400*cdf0e10cSrcweir 			//!	test for correct enum type?
401*cdf0e10cSrcweir 			table::TableOrientation eOrient = (table::TableOrientation)
402*cdf0e10cSrcweir 								ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
403*cdf0e10cSrcweir 			rParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
404*cdf0e10cSrcweir 		}
405*cdf0e10cSrcweir         else if (aPropName.EqualsAscii( SC_UNONAME_ISSORTCOLUMNS ))
406*cdf0e10cSrcweir         {
407*cdf0e10cSrcweir             bNewSortDescriptor = sal_True;
408*cdf0e10cSrcweir             rParam.bByRow = !::cppu::any2bool(rProp.Value);
409*cdf0e10cSrcweir         }
410*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_CONTHDR ))
411*cdf0e10cSrcweir 			rParam.bHasHeader = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
412*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_MAXFLD ))
413*cdf0e10cSrcweir 		{
414*cdf0e10cSrcweir 			sal_Int32 nVal;
415*cdf0e10cSrcweir 			if ( (rProp.Value >>= nVal) && nVal > MAXSORT )
416*cdf0e10cSrcweir 			{
417*cdf0e10cSrcweir 				//!	specify exceptions
418*cdf0e10cSrcweir 				//! throw lang::IllegalArgumentException();
419*cdf0e10cSrcweir 			}
420*cdf0e10cSrcweir 		}
421*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_SORTFLD ))
422*cdf0e10cSrcweir 		{
423*cdf0e10cSrcweir 			uno::Sequence<util::SortField> aSeq;
424*cdf0e10cSrcweir             uno::Sequence<table::TableSortField> aNewSeq;
425*cdf0e10cSrcweir 			if ( rProp.Value >>= aSeq )
426*cdf0e10cSrcweir 			{
427*cdf0e10cSrcweir                 bOldSortDescriptor = sal_True;
428*cdf0e10cSrcweir 				sal_Int32 nCount = aSeq.getLength();
429*cdf0e10cSrcweir 				sal_Int32 i;
430*cdf0e10cSrcweir 				if ( nCount > MAXSORT )
431*cdf0e10cSrcweir 				{
432*cdf0e10cSrcweir 					DBG_ERROR("Zu viele Sortierfelder");
433*cdf0e10cSrcweir 					nCount = MAXSORT;
434*cdf0e10cSrcweir 				}
435*cdf0e10cSrcweir 				const util::SortField* pFieldArray = aSeq.getConstArray();
436*cdf0e10cSrcweir 				for (i=0; i<nCount; i++)
437*cdf0e10cSrcweir 				{
438*cdf0e10cSrcweir 					rParam.nField[i]	 = (SCCOLROW)pFieldArray[i].Field;
439*cdf0e10cSrcweir 					rParam.bAscending[i] = pFieldArray[i].SortAscending;
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir                     // FieldType wird ignoriert
442*cdf0e10cSrcweir 					rParam.bDoSort[i] = sal_True;
443*cdf0e10cSrcweir 				}
444*cdf0e10cSrcweir 				for (i=nCount; i<MAXSORT; i++)
445*cdf0e10cSrcweir 					rParam.bDoSort[i] = sal_False;
446*cdf0e10cSrcweir 			}
447*cdf0e10cSrcweir 			else if ( rProp.Value >>= aNewSeq )
448*cdf0e10cSrcweir             {
449*cdf0e10cSrcweir                 bNewSortDescriptor = sal_True;
450*cdf0e10cSrcweir 				sal_Int32 nCount = aNewSeq.getLength();
451*cdf0e10cSrcweir 				sal_Int32 i;
452*cdf0e10cSrcweir 				if ( nCount > MAXSORT )
453*cdf0e10cSrcweir 				{
454*cdf0e10cSrcweir 					DBG_ERROR("Zu viele Sortierfelder");
455*cdf0e10cSrcweir 					nCount = MAXSORT;
456*cdf0e10cSrcweir 				}
457*cdf0e10cSrcweir 				const table::TableSortField* pFieldArray = aNewSeq.getConstArray();
458*cdf0e10cSrcweir 				for (i=0; i<nCount; i++)
459*cdf0e10cSrcweir 				{
460*cdf0e10cSrcweir 					rParam.nField[i]	 = (SCCOLROW)pFieldArray[i].Field;
461*cdf0e10cSrcweir 					rParam.bAscending[i] = pFieldArray[i].IsAscending;
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir                     // only one is possible, sometime we should make it possible to have different for every entry
464*cdf0e10cSrcweir 			        rParam.bCaseSens = pFieldArray[i].IsCaseSensitive;
465*cdf0e10cSrcweir 			        rParam.aCollatorLocale = pFieldArray[i].CollatorLocale;
466*cdf0e10cSrcweir 				    rParam.aCollatorAlgorithm = pFieldArray[i].CollatorAlgorithm;
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir                     // FieldType wird ignoriert
469*cdf0e10cSrcweir 					rParam.bDoSort[i] = sal_True;
470*cdf0e10cSrcweir 				}
471*cdf0e10cSrcweir 				for (i=nCount; i<MAXSORT; i++)
472*cdf0e10cSrcweir 					rParam.bDoSort[i] = sal_False;
473*cdf0e10cSrcweir             }
474*cdf0e10cSrcweir 		}
475*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_ISCASE ))
476*cdf0e10cSrcweir         {
477*cdf0e10cSrcweir             bOldSortDescriptor = sal_True;
478*cdf0e10cSrcweir 			rParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
479*cdf0e10cSrcweir         }
480*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_BINDFMT ))
481*cdf0e10cSrcweir 			rParam.bIncludePattern = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
482*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_COPYOUT ))
483*cdf0e10cSrcweir 			rParam.bInplace = !ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
484*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_OUTPOS ))
485*cdf0e10cSrcweir 		{
486*cdf0e10cSrcweir 			table::CellAddress aAddress;
487*cdf0e10cSrcweir 			if ( rProp.Value >>= aAddress )
488*cdf0e10cSrcweir 			{
489*cdf0e10cSrcweir 				rParam.nDestTab = aAddress.Sheet;
490*cdf0e10cSrcweir 				rParam.nDestCol = (SCCOL)aAddress.Column;
491*cdf0e10cSrcweir 				rParam.nDestRow = (SCROW)aAddress.Row;
492*cdf0e10cSrcweir 			}
493*cdf0e10cSrcweir 		}
494*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_ISULIST ))
495*cdf0e10cSrcweir 			rParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
496*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_UINDEX ))
497*cdf0e10cSrcweir 		{
498*cdf0e10cSrcweir 			sal_Int32 nVal = 0;
499*cdf0e10cSrcweir 			if ( rProp.Value >>= nVal )
500*cdf0e10cSrcweir 				rParam.nUserIndex = (sal_uInt16)nVal;
501*cdf0e10cSrcweir 		}
502*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_COLLLOC ))
503*cdf0e10cSrcweir 		{
504*cdf0e10cSrcweir             bOldSortDescriptor = sal_True;
505*cdf0e10cSrcweir 			rProp.Value >>= rParam.aCollatorLocale;
506*cdf0e10cSrcweir 		}
507*cdf0e10cSrcweir 		else if (aPropName.EqualsAscii( SC_UNONAME_COLLALG ))
508*cdf0e10cSrcweir 		{
509*cdf0e10cSrcweir             bOldSortDescriptor = sal_True;
510*cdf0e10cSrcweir 			rtl::OUString sStr;
511*cdf0e10cSrcweir 			if ( rProp.Value >>= sStr )
512*cdf0e10cSrcweir 				rParam.aCollatorAlgorithm = sStr;
513*cdf0e10cSrcweir 		}
514*cdf0e10cSrcweir 	}
515*cdf0e10cSrcweir }
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir //------------------------------------------------------------------------
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir ScSubTotalFieldObj::ScSubTotalFieldObj( ScSubTotalDescriptorBase* pDesc, sal_uInt16 nP ) :
520*cdf0e10cSrcweir 	xRef( pDesc ),			// Objekt festhalten
521*cdf0e10cSrcweir 	rParent( *pDesc ),
522*cdf0e10cSrcweir 	nPos( nP )
523*cdf0e10cSrcweir {
524*cdf0e10cSrcweir 	DBG_ASSERT(pDesc, "ScSubTotalFieldObj: Parent ist 0");
525*cdf0e10cSrcweir }
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir ScSubTotalFieldObj::~ScSubTotalFieldObj()
528*cdf0e10cSrcweir {
529*cdf0e10cSrcweir }
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir // XSubTotalField
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir sal_Int32 SAL_CALL ScSubTotalFieldObj::getGroupColumn() throw(uno::RuntimeException)
534*cdf0e10cSrcweir {
535*cdf0e10cSrcweir 	ScUnoGuard aGuard;
536*cdf0e10cSrcweir 	ScSubTotalParam aParam;
537*cdf0e10cSrcweir 	rParent.GetData(aParam);
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 	return aParam.nField[nPos];
540*cdf0e10cSrcweir }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir void SAL_CALL ScSubTotalFieldObj::setGroupColumn( sal_Int32 nGroupColumn ) throw(uno::RuntimeException)
543*cdf0e10cSrcweir {
544*cdf0e10cSrcweir 	ScUnoGuard aGuard;
545*cdf0e10cSrcweir 	ScSubTotalParam aParam;
546*cdf0e10cSrcweir 	rParent.GetData(aParam);
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 	aParam.nField[nPos] = (SCCOL)nGroupColumn;
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir 	rParent.PutData(aParam);
551*cdf0e10cSrcweir }
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir uno::Sequence<sheet::SubTotalColumn> SAL_CALL ScSubTotalFieldObj::getSubTotalColumns()
554*cdf0e10cSrcweir 												throw(uno::RuntimeException)
555*cdf0e10cSrcweir {
556*cdf0e10cSrcweir 	ScUnoGuard aGuard;
557*cdf0e10cSrcweir 	ScSubTotalParam aParam;
558*cdf0e10cSrcweir 	rParent.GetData(aParam);
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 	SCCOL nCount = aParam.nSubTotals[nPos];
561*cdf0e10cSrcweir 	uno::Sequence<sheet::SubTotalColumn> aSeq(nCount);
562*cdf0e10cSrcweir 	sheet::SubTotalColumn* pAry = aSeq.getArray();
563*cdf0e10cSrcweir 	for (SCCOL i=0; i<nCount; i++)
564*cdf0e10cSrcweir 	{
565*cdf0e10cSrcweir 		pAry[i].Column = aParam.pSubTotals[nPos][i];
566*cdf0e10cSrcweir 		pAry[i].Function = ScDataUnoConversion::SubTotalToGeneral(
567*cdf0e10cSrcweir 										aParam.pFunctions[nPos][i] );
568*cdf0e10cSrcweir 	}
569*cdf0e10cSrcweir 	return aSeq;
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir void SAL_CALL ScSubTotalFieldObj::setSubTotalColumns(
573*cdf0e10cSrcweir 							const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns )
574*cdf0e10cSrcweir 									throw(uno::RuntimeException)
575*cdf0e10cSrcweir {
576*cdf0e10cSrcweir 	ScUnoGuard aGuard;
577*cdf0e10cSrcweir 	ScSubTotalParam aParam;
578*cdf0e10cSrcweir 	rParent.GetData(aParam);
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir 	sal_uInt32 nColCount = aSubTotalColumns.getLength();
581*cdf0e10cSrcweir     if ( nColCount <= sal::static_int_cast<sal_uInt32>(SCCOL_MAX) )
582*cdf0e10cSrcweir 	{
583*cdf0e10cSrcweir 		SCCOL nCount = static_cast<SCCOL>(nColCount);
584*cdf0e10cSrcweir 		aParam.nSubTotals[nPos] = nCount;
585*cdf0e10cSrcweir 		if (nCount != 0)
586*cdf0e10cSrcweir 		{
587*cdf0e10cSrcweir 			aParam.pSubTotals[nPos] = new SCCOL[nCount];
588*cdf0e10cSrcweir 			aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 			const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
591*cdf0e10cSrcweir 			for (SCCOL i=0; i<nCount; i++)
592*cdf0e10cSrcweir 			{
593*cdf0e10cSrcweir 				aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
594*cdf0e10cSrcweir 				aParam.pFunctions[nPos][i] =
595*cdf0e10cSrcweir 							ScDataUnoConversion::GeneralToSubTotal( pAry[i].Function );
596*cdf0e10cSrcweir 			}
597*cdf0e10cSrcweir 		}
598*cdf0e10cSrcweir 		else
599*cdf0e10cSrcweir 		{
600*cdf0e10cSrcweir 			aParam.pSubTotals[nPos] = NULL;
601*cdf0e10cSrcweir 			aParam.pFunctions[nPos] = NULL;
602*cdf0e10cSrcweir 		}
603*cdf0e10cSrcweir 	}
604*cdf0e10cSrcweir 	//!	sonst Exception oder so? (zuviele Spalten)
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir 	rParent.PutData(aParam);
607*cdf0e10cSrcweir }
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir //------------------------------------------------------------------------
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir ScSubTotalDescriptorBase::ScSubTotalDescriptorBase() :
612*cdf0e10cSrcweir 	aPropSet( lcl_GetSubTotalPropertyMap() )
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir ScSubTotalDescriptorBase::~ScSubTotalDescriptorBase()
617*cdf0e10cSrcweir {
618*cdf0e10cSrcweir }
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir // GetData/PutData hier nur wegen NewInstance-Krempel implementiert...
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir void ScSubTotalDescriptorBase::GetData( ScSubTotalParam& /* rParam */ ) const
623*cdf0e10cSrcweir {
624*cdf0e10cSrcweir 	DBG_ERROR("ScSubTotalDescriptorBase::GetData soll nicht gerufen werden");
625*cdf0e10cSrcweir }
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir void ScSubTotalDescriptorBase::PutData( const ScSubTotalParam& /* rParam */ )
628*cdf0e10cSrcweir {
629*cdf0e10cSrcweir 	DBG_ERROR("ScSubTotalDescriptorBase::PutData soll nicht gerufen werden");
630*cdf0e10cSrcweir }
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir // XSubTotalDesctiptor
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir ScSubTotalFieldObj* ScSubTotalDescriptorBase::GetObjectByIndex_Impl(sal_uInt16 nIndex)
635*cdf0e10cSrcweir {
636*cdf0e10cSrcweir 	if ( nIndex < getCount() )
637*cdf0e10cSrcweir 		return new ScSubTotalFieldObj( this, nIndex );
638*cdf0e10cSrcweir 	return NULL;
639*cdf0e10cSrcweir }
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir void SAL_CALL ScSubTotalDescriptorBase::clear() throw(uno::RuntimeException)
642*cdf0e10cSrcweir {
643*cdf0e10cSrcweir 	ScUnoGuard aGuard;
644*cdf0e10cSrcweir 	ScSubTotalParam aParam;
645*cdf0e10cSrcweir 	GetData(aParam);
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
648*cdf0e10cSrcweir 		aParam.bGroupActive[i] = sal_False;
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 	//!	Notify oder so fuer die Field-Objekte???
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 	PutData(aParam);
653*cdf0e10cSrcweir }
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir void SAL_CALL ScSubTotalDescriptorBase::addNew(
656*cdf0e10cSrcweir 						const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns,
657*cdf0e10cSrcweir 						sal_Int32 nGroupColumn ) throw(uno::RuntimeException)
658*cdf0e10cSrcweir {
659*cdf0e10cSrcweir 	ScUnoGuard aGuard;
660*cdf0e10cSrcweir 	ScSubTotalParam aParam;
661*cdf0e10cSrcweir 	GetData(aParam);
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir 	sal_uInt16 nPos = 0;
664*cdf0e10cSrcweir 	while ( nPos < MAXSUBTOTAL && aParam.bGroupActive[nPos] )
665*cdf0e10cSrcweir 		++nPos;
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir 	sal_uInt32 nColCount = aSubTotalColumns.getLength();
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir     if ( nPos < MAXSUBTOTAL && nColCount <= sal::static_int_cast<sal_uInt32>(SCCOL_MAX) )
670*cdf0e10cSrcweir 	{
671*cdf0e10cSrcweir 		aParam.bGroupActive[nPos] = sal_True;
672*cdf0e10cSrcweir 		aParam.nField[nPos] = static_cast<SCCOL>(nGroupColumn);
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 		delete aParam.pSubTotals[nPos];
675*cdf0e10cSrcweir 		delete aParam.pFunctions[nPos];
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 		SCCOL nCount = static_cast<SCCOL>(nColCount);
678*cdf0e10cSrcweir 		aParam.nSubTotals[nPos] = nCount;
679*cdf0e10cSrcweir 		if (nCount != 0)
680*cdf0e10cSrcweir 		{
681*cdf0e10cSrcweir 			aParam.pSubTotals[nPos] = new SCCOL[nCount];
682*cdf0e10cSrcweir 			aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir 			const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
685*cdf0e10cSrcweir 			for (SCCOL i=0; i<nCount; i++)
686*cdf0e10cSrcweir 			{
687*cdf0e10cSrcweir 				aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
688*cdf0e10cSrcweir 				aParam.pFunctions[nPos][i] =
689*cdf0e10cSrcweir 							ScDataUnoConversion::GeneralToSubTotal( pAry[i].Function );
690*cdf0e10cSrcweir 			}
691*cdf0e10cSrcweir 		}
692*cdf0e10cSrcweir 		else
693*cdf0e10cSrcweir 		{
694*cdf0e10cSrcweir 			aParam.pSubTotals[nPos] = NULL;
695*cdf0e10cSrcweir 			aParam.pFunctions[nPos] = NULL;
696*cdf0e10cSrcweir 		}
697*cdf0e10cSrcweir 	}
698*cdf0e10cSrcweir 	else									// too many fields / columns
699*cdf0e10cSrcweir 		throw uno::RuntimeException();		// no other exceptions specified
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 	PutData(aParam);
702*cdf0e10cSrcweir }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir //	Flags/Einstellungen als Properties
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir // XEnumerationAccess
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScSubTotalDescriptorBase::createEnumeration()
709*cdf0e10cSrcweir 													throw(uno::RuntimeException)
710*cdf0e10cSrcweir {
711*cdf0e10cSrcweir 	ScUnoGuard aGuard;
712*cdf0e10cSrcweir     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SubTotalFieldsEnumeration")));
713*cdf0e10cSrcweir }
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir // XIndexAccess
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir sal_Int32 SAL_CALL ScSubTotalDescriptorBase::getCount() throw(uno::RuntimeException)
718*cdf0e10cSrcweir {
719*cdf0e10cSrcweir 	ScUnoGuard aGuard;
720*cdf0e10cSrcweir 	ScSubTotalParam aParam;
721*cdf0e10cSrcweir 	GetData(aParam);
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir 	sal_uInt16 nCount = 0;
724*cdf0e10cSrcweir 	while ( nCount < MAXSUBTOTAL && aParam.bGroupActive[nCount] )
725*cdf0e10cSrcweir 		++nCount;
726*cdf0e10cSrcweir 	return nCount;
727*cdf0e10cSrcweir }
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir uno::Any SAL_CALL ScSubTotalDescriptorBase::getByIndex( sal_Int32 nIndex )
730*cdf0e10cSrcweir 							throw(lang::IndexOutOfBoundsException,
731*cdf0e10cSrcweir 									lang::WrappedTargetException, uno::RuntimeException)
732*cdf0e10cSrcweir {
733*cdf0e10cSrcweir 	ScUnoGuard aGuard;
734*cdf0e10cSrcweir 	uno::Reference<sheet::XSubTotalField> xField(GetObjectByIndex_Impl((sal_uInt16)nIndex));
735*cdf0e10cSrcweir 	if (xField.is())
736*cdf0e10cSrcweir         return uno::makeAny(xField);
737*cdf0e10cSrcweir 	else
738*cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
739*cdf0e10cSrcweir //    return uno::Any();
740*cdf0e10cSrcweir }
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir uno::Type SAL_CALL ScSubTotalDescriptorBase::getElementType() throw(uno::RuntimeException)
743*cdf0e10cSrcweir {
744*cdf0e10cSrcweir 	ScUnoGuard aGuard;
745*cdf0e10cSrcweir 	return getCppuType((uno::Reference<sheet::XSubTotalField>*)0);
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir sal_Bool SAL_CALL ScSubTotalDescriptorBase::hasElements() throw(uno::RuntimeException)
749*cdf0e10cSrcweir {
750*cdf0e10cSrcweir 	ScUnoGuard aGuard;
751*cdf0e10cSrcweir 	return ( getCount() != 0 );
752*cdf0e10cSrcweir }
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir // XPropertySet
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSubTotalDescriptorBase::getPropertySetInfo()
757*cdf0e10cSrcweir 														throw(uno::RuntimeException)
758*cdf0e10cSrcweir {
759*cdf0e10cSrcweir 	ScUnoGuard aGuard;
760*cdf0e10cSrcweir 	static uno::Reference<beans::XPropertySetInfo> aRef(
761*cdf0e10cSrcweir 		new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
762*cdf0e10cSrcweir 	return aRef;
763*cdf0e10cSrcweir }
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir void SAL_CALL ScSubTotalDescriptorBase::setPropertyValue(
766*cdf0e10cSrcweir 						const rtl::OUString& aPropertyName, const uno::Any& aValue )
767*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, beans::PropertyVetoException,
768*cdf0e10cSrcweir 						lang::IllegalArgumentException, lang::WrappedTargetException,
769*cdf0e10cSrcweir 						uno::RuntimeException)
770*cdf0e10cSrcweir {
771*cdf0e10cSrcweir 	ScUnoGuard aGuard;
772*cdf0e10cSrcweir 	ScSubTotalParam aParam;
773*cdf0e10cSrcweir 	GetData(aParam);
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir 	String aString(aPropertyName);
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir 	// some old property names are for 5.2 compatibility
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir 	if (aString.EqualsAscii( SC_UNONAME_CASE ) || aString.EqualsAscii( SC_UNONAME_ISCASE ))
780*cdf0e10cSrcweir 		aParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( aValue );
781*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_FORMATS ) || aString.EqualsAscii( SC_UNONAME_BINDFMT ))
782*cdf0e10cSrcweir 		aParam.bIncludePattern = ScUnoHelpFunctions::GetBoolFromAny( aValue );
783*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ENABSORT ))
784*cdf0e10cSrcweir 		aParam.bDoSort = ScUnoHelpFunctions::GetBoolFromAny( aValue );
785*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_SORTASC ))
786*cdf0e10cSrcweir 		aParam.bAscending = ScUnoHelpFunctions::GetBoolFromAny( aValue );
787*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_INSBRK ))
788*cdf0e10cSrcweir 		aParam.bPagebreak = ScUnoHelpFunctions::GetBoolFromAny( aValue );
789*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ULIST ) || aString.EqualsAscii( SC_UNONAME_ENUSLIST ))
790*cdf0e10cSrcweir 		aParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( aValue );
791*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_UINDEX ) || aString.EqualsAscii( SC_UNONAME_USINDEX ))
792*cdf0e10cSrcweir 	{
793*cdf0e10cSrcweir 		sal_Int32 nVal = 0;
794*cdf0e10cSrcweir 		if ( aValue >>= nVal )
795*cdf0e10cSrcweir 			aParam.nUserIndex = (sal_uInt16)nVal;
796*cdf0e10cSrcweir 	}
797*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
798*cdf0e10cSrcweir 	{
799*cdf0e10cSrcweir 		sal_Int32 nVal = 0;
800*cdf0e10cSrcweir         if ( (aValue >>= nVal) && nVal > sal::static_int_cast<sal_Int32>(MAXSUBTOTAL) )
801*cdf0e10cSrcweir 		{
802*cdf0e10cSrcweir 			throw lang::IllegalArgumentException();
803*cdf0e10cSrcweir 		}
804*cdf0e10cSrcweir 	}
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir 	PutData(aParam);
807*cdf0e10cSrcweir }
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir uno::Any SAL_CALL ScSubTotalDescriptorBase::getPropertyValue( const rtl::OUString& aPropertyName )
810*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, lang::WrappedTargetException,
811*cdf0e10cSrcweir 						uno::RuntimeException)
812*cdf0e10cSrcweir {
813*cdf0e10cSrcweir 	ScUnoGuard aGuard;
814*cdf0e10cSrcweir 	ScSubTotalParam aParam;
815*cdf0e10cSrcweir 	GetData(aParam);
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir 	String aString(aPropertyName);
818*cdf0e10cSrcweir 	uno::Any aRet;
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir 	// some old property names are for 5.2 compatibility
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir 	if (aString.EqualsAscii( SC_UNONAME_CASE ) || aString.EqualsAscii( SC_UNONAME_ISCASE ))
823*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bCaseSens );
824*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_FORMATS ) || aString.EqualsAscii( SC_UNONAME_BINDFMT ))
825*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bIncludePattern );
826*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ENABSORT ))
827*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bDoSort );
828*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_SORTASC ))
829*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bAscending );
830*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_INSBRK ))
831*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bPagebreak );
832*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ULIST ) || aString.EqualsAscii( SC_UNONAME_ENUSLIST ))
833*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bUserDef );
834*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_UINDEX ) || aString.EqualsAscii( SC_UNONAME_USINDEX ))
835*cdf0e10cSrcweir 		aRet <<= (sal_Int32) aParam.nUserIndex;
836*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
837*cdf0e10cSrcweir 		aRet <<= (sal_Int32) MAXSUBTOTAL;
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir 	return aRet;
840*cdf0e10cSrcweir }
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSubTotalDescriptorBase )
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir // XUnoTunnel
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir sal_Int64 SAL_CALL ScSubTotalDescriptorBase::getSomething(
847*cdf0e10cSrcweir 				const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
848*cdf0e10cSrcweir {
849*cdf0e10cSrcweir 	if ( rId.getLength() == 16 &&
850*cdf0e10cSrcweir           0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
851*cdf0e10cSrcweir 									rId.getConstArray(), 16 ) )
852*cdf0e10cSrcweir 	{
853*cdf0e10cSrcweir         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
854*cdf0e10cSrcweir 	}
855*cdf0e10cSrcweir 	return 0;
856*cdf0e10cSrcweir }
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir // static
859*cdf0e10cSrcweir const uno::Sequence<sal_Int8>& ScSubTotalDescriptorBase::getUnoTunnelId()
860*cdf0e10cSrcweir {
861*cdf0e10cSrcweir 	static uno::Sequence<sal_Int8> * pSeq = 0;
862*cdf0e10cSrcweir 	if( !pSeq )
863*cdf0e10cSrcweir 	{
864*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
865*cdf0e10cSrcweir 		if( !pSeq )
866*cdf0e10cSrcweir 		{
867*cdf0e10cSrcweir 			static uno::Sequence< sal_Int8 > aSeq( 16 );
868*cdf0e10cSrcweir 			rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
869*cdf0e10cSrcweir 			pSeq = &aSeq;
870*cdf0e10cSrcweir 		}
871*cdf0e10cSrcweir 	}
872*cdf0e10cSrcweir 	return *pSeq;
873*cdf0e10cSrcweir }
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir // static
876*cdf0e10cSrcweir ScSubTotalDescriptorBase* ScSubTotalDescriptorBase::getImplementation(
877*cdf0e10cSrcweir 								const uno::Reference<sheet::XSubTotalDescriptor> xObj )
878*cdf0e10cSrcweir {
879*cdf0e10cSrcweir 	ScSubTotalDescriptorBase* pRet = NULL;
880*cdf0e10cSrcweir 	uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
881*cdf0e10cSrcweir 	if (xUT.is())
882*cdf0e10cSrcweir         pRet = reinterpret_cast<ScSubTotalDescriptorBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
883*cdf0e10cSrcweir 	return pRet;
884*cdf0e10cSrcweir }
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir //------------------------------------------------------------------------
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir ScSubTotalDescriptor::ScSubTotalDescriptor()
889*cdf0e10cSrcweir {
890*cdf0e10cSrcweir }
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir ScSubTotalDescriptor::~ScSubTotalDescriptor()
893*cdf0e10cSrcweir {
894*cdf0e10cSrcweir }
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir void ScSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
897*cdf0e10cSrcweir {
898*cdf0e10cSrcweir 	rParam = aStoredParam;			// Abfrage fuer Interface
899*cdf0e10cSrcweir }
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir void ScSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
902*cdf0e10cSrcweir {
903*cdf0e10cSrcweir 	aStoredParam = rParam;			// vom Interface gesetzt
904*cdf0e10cSrcweir }
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir void ScSubTotalDescriptor::SetParam( const ScSubTotalParam& rNew )
907*cdf0e10cSrcweir {
908*cdf0e10cSrcweir 	aStoredParam = rNew;			// von aussen gesetzt
909*cdf0e10cSrcweir }
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir //------------------------------------------------------------------------
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir ScRangeSubTotalDescriptor::ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar) :
914*cdf0e10cSrcweir 	pParent(pPar)
915*cdf0e10cSrcweir {
916*cdf0e10cSrcweir 	if (pParent)
917*cdf0e10cSrcweir 		pParent->acquire();
918*cdf0e10cSrcweir }
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir ScRangeSubTotalDescriptor::~ScRangeSubTotalDescriptor()
921*cdf0e10cSrcweir {
922*cdf0e10cSrcweir 	if (pParent)
923*cdf0e10cSrcweir 		pParent->release();
924*cdf0e10cSrcweir }
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir void ScRangeSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
927*cdf0e10cSrcweir {
928*cdf0e10cSrcweir 	if (pParent)
929*cdf0e10cSrcweir 		pParent->GetSubTotalParam( rParam );
930*cdf0e10cSrcweir }
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir void ScRangeSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
933*cdf0e10cSrcweir {
934*cdf0e10cSrcweir 	if (pParent)
935*cdf0e10cSrcweir 		pParent->SetSubTotalParam( rParam );
936*cdf0e10cSrcweir }
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir //------------------------------------------------------------------------
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir ScConsolidationDescriptor::ScConsolidationDescriptor()
941*cdf0e10cSrcweir {
942*cdf0e10cSrcweir }
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir ScConsolidationDescriptor::~ScConsolidationDescriptor()
945*cdf0e10cSrcweir {
946*cdf0e10cSrcweir }
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir void ScConsolidationDescriptor::SetParam( const ScConsolidateParam& rNew )
949*cdf0e10cSrcweir {
950*cdf0e10cSrcweir 	aParam = rNew;
951*cdf0e10cSrcweir }
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir // XConsolidationDescriptor
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir sheet::GeneralFunction SAL_CALL ScConsolidationDescriptor::getFunction() throw(uno::RuntimeException)
956*cdf0e10cSrcweir {
957*cdf0e10cSrcweir 	ScUnoGuard aGuard;
958*cdf0e10cSrcweir 	return ScDataUnoConversion::SubTotalToGeneral(aParam.eFunction);
959*cdf0e10cSrcweir }
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir void SAL_CALL ScConsolidationDescriptor::setFunction( sheet::GeneralFunction nFunction )
962*cdf0e10cSrcweir 													throw(uno::RuntimeException)
963*cdf0e10cSrcweir {
964*cdf0e10cSrcweir 	ScUnoGuard aGuard;
965*cdf0e10cSrcweir 	aParam.eFunction = ScDataUnoConversion::GeneralToSubTotal(nFunction);
966*cdf0e10cSrcweir }
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir uno::Sequence<table::CellRangeAddress> SAL_CALL ScConsolidationDescriptor::getSources()
969*cdf0e10cSrcweir 														throw(uno::RuntimeException)
970*cdf0e10cSrcweir {
971*cdf0e10cSrcweir 	ScUnoGuard aGuard;
972*cdf0e10cSrcweir 	sal_uInt16 nCount = aParam.nDataAreaCount;
973*cdf0e10cSrcweir 	if (!aParam.ppDataAreas)
974*cdf0e10cSrcweir 		nCount = 0;
975*cdf0e10cSrcweir 	table::CellRangeAddress aRange;
976*cdf0e10cSrcweir 	uno::Sequence<table::CellRangeAddress> aSeq(nCount);
977*cdf0e10cSrcweir 	table::CellRangeAddress* pAry = aSeq.getArray();
978*cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<nCount; i++)
979*cdf0e10cSrcweir 	{
980*cdf0e10cSrcweir 		ScArea* pArea = aParam.ppDataAreas[i];
981*cdf0e10cSrcweir 		if (pArea)
982*cdf0e10cSrcweir 		{
983*cdf0e10cSrcweir 			aRange.Sheet		= pArea->nTab;
984*cdf0e10cSrcweir 			aRange.StartColumn	= pArea->nColStart;
985*cdf0e10cSrcweir 			aRange.StartRow		= pArea->nRowStart;
986*cdf0e10cSrcweir 			aRange.EndColumn	= pArea->nColEnd;
987*cdf0e10cSrcweir 			aRange.EndRow		= pArea->nRowEnd;
988*cdf0e10cSrcweir 		}
989*cdf0e10cSrcweir 		pAry[i] = aRange;
990*cdf0e10cSrcweir 	}
991*cdf0e10cSrcweir 	return aSeq;
992*cdf0e10cSrcweir }
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir void SAL_CALL ScConsolidationDescriptor::setSources(
995*cdf0e10cSrcweir 					const uno::Sequence<table::CellRangeAddress>& aSources )
996*cdf0e10cSrcweir 												throw(uno::RuntimeException)
997*cdf0e10cSrcweir {
998*cdf0e10cSrcweir 	ScUnoGuard aGuard;
999*cdf0e10cSrcweir 	sal_uInt16 nCount = (sal_uInt16)aSources.getLength();
1000*cdf0e10cSrcweir 	if (nCount)
1001*cdf0e10cSrcweir 	{
1002*cdf0e10cSrcweir 		const table::CellRangeAddress* pAry = aSources.getConstArray();
1003*cdf0e10cSrcweir 		ScArea** pNew = new ScArea*[nCount];
1004*cdf0e10cSrcweir 		sal_uInt16 i;
1005*cdf0e10cSrcweir 		for (i=0; i<nCount; i++)
1006*cdf0e10cSrcweir 			pNew[i] = new ScArea( pAry[i].Sheet,
1007*cdf0e10cSrcweir                     static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow,
1008*cdf0e10cSrcweir                     static_cast<SCCOL>(pAry[i].EndColumn),   pAry[i].EndRow );
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir 		aParam.SetAreas( pNew, nCount );	// kopiert alles
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir 		for (i=0; i<nCount; i++)
1013*cdf0e10cSrcweir 			delete pNew[i];
1014*cdf0e10cSrcweir 		delete[] pNew;
1015*cdf0e10cSrcweir 	}
1016*cdf0e10cSrcweir 	else
1017*cdf0e10cSrcweir 		aParam.ClearDataAreas();
1018*cdf0e10cSrcweir }
1019*cdf0e10cSrcweir 
1020*cdf0e10cSrcweir table::CellAddress SAL_CALL ScConsolidationDescriptor::getStartOutputPosition()
1021*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1022*cdf0e10cSrcweir {
1023*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1024*cdf0e10cSrcweir 	table::CellAddress aPos;
1025*cdf0e10cSrcweir 	aPos.Column	= aParam.nCol;
1026*cdf0e10cSrcweir 	aPos.Row	= aParam.nRow;
1027*cdf0e10cSrcweir 	aPos.Sheet	= aParam.nTab;
1028*cdf0e10cSrcweir 	return aPos;
1029*cdf0e10cSrcweir }
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir void SAL_CALL ScConsolidationDescriptor::setStartOutputPosition(
1032*cdf0e10cSrcweir 								const table::CellAddress& aStartOutputPosition )
1033*cdf0e10cSrcweir 									throw(uno::RuntimeException)
1034*cdf0e10cSrcweir {
1035*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1036*cdf0e10cSrcweir 	aParam.nCol = (SCCOL)aStartOutputPosition.Column;
1037*cdf0e10cSrcweir 	aParam.nRow = (SCROW)aStartOutputPosition.Row;
1038*cdf0e10cSrcweir 	aParam.nTab = aStartOutputPosition.Sheet;
1039*cdf0e10cSrcweir }
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir sal_Bool SAL_CALL ScConsolidationDescriptor::getUseColumnHeaders() throw(uno::RuntimeException)
1042*cdf0e10cSrcweir {
1043*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1044*cdf0e10cSrcweir 	return aParam.bByCol;
1045*cdf0e10cSrcweir }
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir void SAL_CALL ScConsolidationDescriptor::setUseColumnHeaders( sal_Bool bUseColumnHeaders )
1048*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1049*cdf0e10cSrcweir {
1050*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1051*cdf0e10cSrcweir 	aParam.bByCol = bUseColumnHeaders;
1052*cdf0e10cSrcweir }
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir sal_Bool SAL_CALL ScConsolidationDescriptor::getUseRowHeaders() throw(uno::RuntimeException)
1055*cdf0e10cSrcweir {
1056*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1057*cdf0e10cSrcweir 	return aParam.bByRow;
1058*cdf0e10cSrcweir }
1059*cdf0e10cSrcweir 
1060*cdf0e10cSrcweir void SAL_CALL ScConsolidationDescriptor::setUseRowHeaders( sal_Bool bUseRowHeaders )
1061*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1062*cdf0e10cSrcweir {
1063*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1064*cdf0e10cSrcweir 	aParam.bByRow = bUseRowHeaders;
1065*cdf0e10cSrcweir }
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir sal_Bool SAL_CALL ScConsolidationDescriptor::getInsertLinks() throw(uno::RuntimeException)
1068*cdf0e10cSrcweir {
1069*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1070*cdf0e10cSrcweir 	return aParam.bReferenceData;
1071*cdf0e10cSrcweir }
1072*cdf0e10cSrcweir 
1073*cdf0e10cSrcweir void SAL_CALL ScConsolidationDescriptor::setInsertLinks( sal_Bool bInsertLinks )
1074*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1075*cdf0e10cSrcweir {
1076*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1077*cdf0e10cSrcweir 	aParam.bReferenceData = bInsertLinks;
1078*cdf0e10cSrcweir }
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir //------------------------------------------------------------------------
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir ScFilterDescriptorBase::ScFilterDescriptorBase(ScDocShell* pDocShell) :
1083*cdf0e10cSrcweir 	aPropSet( lcl_GetFilterPropertyMap() ),
1084*cdf0e10cSrcweir     pDocSh(pDocShell)
1085*cdf0e10cSrcweir {
1086*cdf0e10cSrcweir 	if (pDocSh)
1087*cdf0e10cSrcweir 		pDocSh->GetDocument()->AddUnoObject(*this);
1088*cdf0e10cSrcweir }
1089*cdf0e10cSrcweir 
1090*cdf0e10cSrcweir ScFilterDescriptorBase::~ScFilterDescriptorBase()
1091*cdf0e10cSrcweir {
1092*cdf0e10cSrcweir 	if (pDocSh)
1093*cdf0e10cSrcweir 		pDocSh->GetDocument()->RemoveUnoObject(*this);
1094*cdf0e10cSrcweir }
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir void ScFilterDescriptorBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
1097*cdf0e10cSrcweir {
1098*cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) )
1099*cdf0e10cSrcweir 	{
1100*cdf0e10cSrcweir 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1101*cdf0e10cSrcweir 		if ( nId == SFX_HINT_DYING )
1102*cdf0e10cSrcweir 		{
1103*cdf0e10cSrcweir 			pDocSh = NULL;			// invalid
1104*cdf0e10cSrcweir 		}
1105*cdf0e10cSrcweir 	}
1106*cdf0e10cSrcweir }
1107*cdf0e10cSrcweir 
1108*cdf0e10cSrcweir // XSheetFilterDescriptor and XSheetFilterDescriptor2
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilterFields()
1111*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1112*cdf0e10cSrcweir {
1113*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1114*cdf0e10cSrcweir 	ScQueryParam aParam;
1115*cdf0e10cSrcweir 	GetData(aParam);
1116*cdf0e10cSrcweir 
1117*cdf0e10cSrcweir 	SCSIZE nEntries = aParam.GetEntryCount();	// allozierte Eintraege im Param
1118*cdf0e10cSrcweir 	SCSIZE nCount = 0;							// aktive
1119*cdf0e10cSrcweir 	while ( nCount < nEntries &&
1120*cdf0e10cSrcweir 			aParam.GetEntry(nCount).bDoQuery )
1121*cdf0e10cSrcweir 		++nCount;
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir 	sheet::TableFilterField aField;
1124*cdf0e10cSrcweir 	uno::Sequence<sheet::TableFilterField> aSeq(static_cast<sal_Int32>(nCount));
1125*cdf0e10cSrcweir 	sheet::TableFilterField* pAry = aSeq.getArray();
1126*cdf0e10cSrcweir 	for (SCSIZE i=0; i<nCount; i++)
1127*cdf0e10cSrcweir 	{
1128*cdf0e10cSrcweir 		const ScQueryEntry& rEntry = aParam.GetEntry(i);
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir         rtl::OUString aStringValue;
1131*cdf0e10cSrcweir 		if (rEntry.pStr)
1132*cdf0e10cSrcweir 			aStringValue = *rEntry.pStr;
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir 		aField.Connection	 = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND :
1135*cdf0e10cSrcweir 															 sheet::FilterConnection_OR;
1136*cdf0e10cSrcweir 		aField.Field		 = rEntry.nField;
1137*cdf0e10cSrcweir 		aField.IsNumeric	 = !rEntry.bQueryByString;
1138*cdf0e10cSrcweir 		aField.StringValue	 = aStringValue;
1139*cdf0e10cSrcweir 		aField.NumericValue	 = rEntry.nVal;
1140*cdf0e10cSrcweir 
1141*cdf0e10cSrcweir 		switch (rEntry.eOp)				// ScQueryOp
1142*cdf0e10cSrcweir 		{
1143*cdf0e10cSrcweir 			case SC_EQUAL:
1144*cdf0e10cSrcweir                 {
1145*cdf0e10cSrcweir                     aField.Operator = sheet::FilterOperator_EQUAL;
1146*cdf0e10cSrcweir                     if (!rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING)
1147*cdf0e10cSrcweir                     {
1148*cdf0e10cSrcweir                         if (rEntry.nVal == SC_EMPTYFIELDS)
1149*cdf0e10cSrcweir                         {
1150*cdf0e10cSrcweir                             aField.Operator = sheet::FilterOperator_EMPTY;
1151*cdf0e10cSrcweir                             aField.NumericValue = 0;
1152*cdf0e10cSrcweir                         }
1153*cdf0e10cSrcweir                         else if (rEntry.nVal == SC_NONEMPTYFIELDS)
1154*cdf0e10cSrcweir                         {
1155*cdf0e10cSrcweir                             aField.Operator = sheet::FilterOperator_NOT_EMPTY;
1156*cdf0e10cSrcweir                             aField.NumericValue = 0;
1157*cdf0e10cSrcweir                         }
1158*cdf0e10cSrcweir                     }
1159*cdf0e10cSrcweir                 }
1160*cdf0e10cSrcweir                 break;
1161*cdf0e10cSrcweir 			case SC_LESS:			aField.Operator = sheet::FilterOperator_LESS;			  break;
1162*cdf0e10cSrcweir 			case SC_GREATER:		aField.Operator = sheet::FilterOperator_GREATER;		  break;
1163*cdf0e10cSrcweir 			case SC_LESS_EQUAL:		aField.Operator = sheet::FilterOperator_LESS_EQUAL;	  break;
1164*cdf0e10cSrcweir 			case SC_GREATER_EQUAL:	aField.Operator = sheet::FilterOperator_GREATER_EQUAL;  break;
1165*cdf0e10cSrcweir 			case SC_NOT_EQUAL:		aField.Operator = sheet::FilterOperator_NOT_EQUAL;	  break;
1166*cdf0e10cSrcweir 			case SC_TOPVAL:			aField.Operator = sheet::FilterOperator_TOP_VALUES;	  break;
1167*cdf0e10cSrcweir 			case SC_BOTVAL:			aField.Operator = sheet::FilterOperator_BOTTOM_VALUES;  break;
1168*cdf0e10cSrcweir 			case SC_TOPPERC:		aField.Operator = sheet::FilterOperator_TOP_PERCENT;	  break;
1169*cdf0e10cSrcweir 			case SC_BOTPERC:		aField.Operator = sheet::FilterOperator_BOTTOM_PERCENT; break;
1170*cdf0e10cSrcweir 			default:
1171*cdf0e10cSrcweir 				DBG_ERROR("Falscher Filter-enum");
1172*cdf0e10cSrcweir 				aField.Operator = sheet::FilterOperator_EMPTY;
1173*cdf0e10cSrcweir 		}
1174*cdf0e10cSrcweir 		pAry[i] = aField;
1175*cdf0e10cSrcweir 	}
1176*cdf0e10cSrcweir 	return aSeq;
1177*cdf0e10cSrcweir }
1178*cdf0e10cSrcweir 
1179*cdf0e10cSrcweir uno::Sequence<sheet::TableFilterField2> SAL_CALL ScFilterDescriptorBase::getFilterFields2()
1180*cdf0e10cSrcweir throw(uno::RuntimeException)
1181*cdf0e10cSrcweir {
1182*cdf0e10cSrcweir     ScUnoGuard aGuard;
1183*cdf0e10cSrcweir     ScQueryParam aParam;
1184*cdf0e10cSrcweir     GetData(aParam);
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir     SCSIZE nEntries = aParam.GetEntryCount();	// allozierte Eintraege im Param
1187*cdf0e10cSrcweir     SCSIZE nCount = 0;							// aktive
1188*cdf0e10cSrcweir     while ( nCount < nEntries &&
1189*cdf0e10cSrcweir         aParam.GetEntry(nCount).bDoQuery )
1190*cdf0e10cSrcweir         ++nCount;
1191*cdf0e10cSrcweir 
1192*cdf0e10cSrcweir     sheet::TableFilterField2 aField;
1193*cdf0e10cSrcweir     uno::Sequence<sheet::TableFilterField2> aSeq(static_cast<sal_Int32>(nCount));
1194*cdf0e10cSrcweir     sheet::TableFilterField2* pAry = aSeq.getArray();
1195*cdf0e10cSrcweir     for (SCSIZE i=0; i<nCount; i++)
1196*cdf0e10cSrcweir     {
1197*cdf0e10cSrcweir         const ScQueryEntry& rEntry = aParam.GetEntry(i);
1198*cdf0e10cSrcweir 
1199*cdf0e10cSrcweir         rtl::OUString aStringValue;
1200*cdf0e10cSrcweir         if (rEntry.pStr)
1201*cdf0e10cSrcweir             aStringValue = *rEntry.pStr;
1202*cdf0e10cSrcweir 
1203*cdf0e10cSrcweir         aField.Connection	 = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND : sheet::FilterConnection_OR;
1204*cdf0e10cSrcweir         aField.Field		 = rEntry.nField;
1205*cdf0e10cSrcweir         aField.IsNumeric	 = !rEntry.bQueryByString;
1206*cdf0e10cSrcweir         aField.StringValue	 = aStringValue;
1207*cdf0e10cSrcweir         aField.NumericValue	 = rEntry.nVal;
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir         switch (rEntry.eOp)				// ScQueryOp
1210*cdf0e10cSrcweir         {
1211*cdf0e10cSrcweir         case SC_EQUAL:
1212*cdf0e10cSrcweir             {
1213*cdf0e10cSrcweir                 aField.Operator = sheet::FilterOperator2::EQUAL;
1214*cdf0e10cSrcweir                 if (!rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING)
1215*cdf0e10cSrcweir                 {
1216*cdf0e10cSrcweir                     if (rEntry.nVal == SC_EMPTYFIELDS)
1217*cdf0e10cSrcweir                     {
1218*cdf0e10cSrcweir                         aField.Operator = sheet::FilterOperator2::EMPTY;
1219*cdf0e10cSrcweir                         aField.NumericValue = 0;
1220*cdf0e10cSrcweir                     }
1221*cdf0e10cSrcweir                     else if (rEntry.nVal == SC_NONEMPTYFIELDS)
1222*cdf0e10cSrcweir                     {
1223*cdf0e10cSrcweir                         aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
1224*cdf0e10cSrcweir                         aField.NumericValue = 0;
1225*cdf0e10cSrcweir                     }
1226*cdf0e10cSrcweir                 }
1227*cdf0e10cSrcweir             }
1228*cdf0e10cSrcweir             break;
1229*cdf0e10cSrcweir         case SC_LESS:			        aField.Operator = sheet::FilterOperator2::LESS;			        break;
1230*cdf0e10cSrcweir         case SC_GREATER:		        aField.Operator = sheet::FilterOperator2::GREATER;		        break;
1231*cdf0e10cSrcweir         case SC_LESS_EQUAL:		        aField.Operator = sheet::FilterOperator2::LESS_EQUAL;	        break;
1232*cdf0e10cSrcweir         case SC_GREATER_EQUAL:	        aField.Operator = sheet::FilterOperator2::GREATER_EQUAL;        break;
1233*cdf0e10cSrcweir         case SC_NOT_EQUAL:		        aField.Operator = sheet::FilterOperator2::NOT_EQUAL;	        break;
1234*cdf0e10cSrcweir         case SC_TOPVAL:			        aField.Operator = sheet::FilterOperator2::TOP_VALUES;	        break;
1235*cdf0e10cSrcweir         case SC_BOTVAL:			        aField.Operator = sheet::FilterOperator2::BOTTOM_VALUES;        break;
1236*cdf0e10cSrcweir         case SC_TOPPERC:		        aField.Operator = sheet::FilterOperator2::TOP_PERCENT;	        break;
1237*cdf0e10cSrcweir         case SC_BOTPERC:		        aField.Operator = sheet::FilterOperator2::BOTTOM_PERCENT;       break;
1238*cdf0e10cSrcweir         case SC_CONTAINS:               aField.Operator = sheet::FilterOperator2::CONTAINS;             break;
1239*cdf0e10cSrcweir         case SC_DOES_NOT_CONTAIN:       aField.Operator = sheet::FilterOperator2::DOES_NOT_CONTAIN;     break;
1240*cdf0e10cSrcweir         case SC_BEGINS_WITH:            aField.Operator = sheet::FilterOperator2::BEGINS_WITH;          break;
1241*cdf0e10cSrcweir         case SC_DOES_NOT_BEGIN_WITH:    aField.Operator = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH;  break;
1242*cdf0e10cSrcweir         case SC_ENDS_WITH:              aField.Operator = sheet::FilterOperator2::ENDS_WITH;            break;
1243*cdf0e10cSrcweir         case SC_DOES_NOT_END_WITH:      aField.Operator = sheet::FilterOperator2::DOES_NOT_END_WITH;    break;
1244*cdf0e10cSrcweir         default:
1245*cdf0e10cSrcweir             DBG_ERROR("Falscher Filter-enum");
1246*cdf0e10cSrcweir             aField.Operator = sheet::FilterOperator2::EMPTY;
1247*cdf0e10cSrcweir         }
1248*cdf0e10cSrcweir         pAry[i] = aField;
1249*cdf0e10cSrcweir     }
1250*cdf0e10cSrcweir     return aSeq;
1251*cdf0e10cSrcweir }
1252*cdf0e10cSrcweir 
1253*cdf0e10cSrcweir void SAL_CALL ScFilterDescriptorBase::setFilterFields(
1254*cdf0e10cSrcweir 				const uno::Sequence<sheet::TableFilterField>& aFilterFields )
1255*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1256*cdf0e10cSrcweir {
1257*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1258*cdf0e10cSrcweir 	ScQueryParam aParam;
1259*cdf0e10cSrcweir 	GetData(aParam);
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir 	SCSIZE nCount = static_cast<SCSIZE>(aFilterFields.getLength());
1262*cdf0e10cSrcweir 	DBG_ASSERT( nCount <= MAXQUERY, "setFilterFields: zu viele" );
1263*cdf0e10cSrcweir 
1264*cdf0e10cSrcweir 	aParam.Resize( nCount );
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir 	const sheet::TableFilterField* pAry = aFilterFields.getConstArray();
1267*cdf0e10cSrcweir 	SCSIZE i;
1268*cdf0e10cSrcweir 	for (i=0; i<nCount; i++)
1269*cdf0e10cSrcweir 	{
1270*cdf0e10cSrcweir 		ScQueryEntry& rEntry = aParam.GetEntry(i);
1271*cdf0e10cSrcweir 		if (!rEntry.pStr)
1272*cdf0e10cSrcweir 			rEntry.pStr = new String;		// sollte nicht sein (soll immer initialisiert sein)
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir 		rEntry.bDoQuery			= sal_True;
1275*cdf0e10cSrcweir 		rEntry.eConnect			= (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
1276*cdf0e10cSrcweir 		rEntry.nField			= pAry[i].Field;
1277*cdf0e10cSrcweir 		rEntry.bQueryByString	= !pAry[i].IsNumeric;
1278*cdf0e10cSrcweir 		*rEntry.pStr			= String( pAry[i].StringValue );
1279*cdf0e10cSrcweir 		rEntry.nVal				= pAry[i].NumericValue;
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir         if (!rEntry.bQueryByString && pDocSh)
1282*cdf0e10cSrcweir         {
1283*cdf0e10cSrcweir             pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, *rEntry.pStr);
1284*cdf0e10cSrcweir         }
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir 		switch (pAry[i].Operator)			// FilterOperator
1287*cdf0e10cSrcweir 		{
1288*cdf0e10cSrcweir 			case sheet::FilterOperator_EQUAL:			rEntry.eOp = SC_EQUAL;		 break;
1289*cdf0e10cSrcweir 			case sheet::FilterOperator_LESS:			rEntry.eOp = SC_LESS;			 break;
1290*cdf0e10cSrcweir 			case sheet::FilterOperator_GREATER:			rEntry.eOp = SC_GREATER;		 break;
1291*cdf0e10cSrcweir 			case sheet::FilterOperator_LESS_EQUAL:		rEntry.eOp = SC_LESS_EQUAL;	 break;
1292*cdf0e10cSrcweir 			case sheet::FilterOperator_GREATER_EQUAL:	rEntry.eOp = SC_GREATER_EQUAL; break;
1293*cdf0e10cSrcweir 			case sheet::FilterOperator_NOT_EQUAL:		rEntry.eOp = SC_NOT_EQUAL;	 break;
1294*cdf0e10cSrcweir 			case sheet::FilterOperator_TOP_VALUES:		rEntry.eOp = SC_TOPVAL;		 break;
1295*cdf0e10cSrcweir 			case sheet::FilterOperator_BOTTOM_VALUES:	rEntry.eOp = SC_BOTVAL;		 break;
1296*cdf0e10cSrcweir 			case sheet::FilterOperator_TOP_PERCENT:		rEntry.eOp = SC_TOPPERC;		 break;
1297*cdf0e10cSrcweir 			case sheet::FilterOperator_BOTTOM_PERCENT:	rEntry.eOp = SC_BOTPERC;		 break;
1298*cdf0e10cSrcweir 			case sheet::FilterOperator_EMPTY:
1299*cdf0e10cSrcweir                 {
1300*cdf0e10cSrcweir                     rEntry.eOp = SC_EQUAL;
1301*cdf0e10cSrcweir                     rEntry.nVal = SC_EMPTYFIELDS;
1302*cdf0e10cSrcweir                     rEntry.bQueryByString = sal_False;
1303*cdf0e10cSrcweir                     *rEntry.pStr = EMPTY_STRING;
1304*cdf0e10cSrcweir                 }
1305*cdf0e10cSrcweir                 break;
1306*cdf0e10cSrcweir 			case sheet::FilterOperator_NOT_EMPTY:
1307*cdf0e10cSrcweir                 {
1308*cdf0e10cSrcweir                     rEntry.eOp = SC_EQUAL;
1309*cdf0e10cSrcweir                     rEntry.nVal = SC_NONEMPTYFIELDS;
1310*cdf0e10cSrcweir                     rEntry.bQueryByString = sal_False;
1311*cdf0e10cSrcweir                     *rEntry.pStr = EMPTY_STRING;
1312*cdf0e10cSrcweir                 }
1313*cdf0e10cSrcweir                 break;
1314*cdf0e10cSrcweir 			default:
1315*cdf0e10cSrcweir 				DBG_ERROR("Falscher Query-enum");
1316*cdf0e10cSrcweir 				rEntry.eOp = SC_EQUAL;
1317*cdf0e10cSrcweir 		}
1318*cdf0e10cSrcweir     }
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir 	SCSIZE nParamCount = aParam.GetEntryCount();	// Param wird nicht unter 8 resized
1321*cdf0e10cSrcweir 	for (i=nCount; i<nParamCount; i++)
1322*cdf0e10cSrcweir 		aParam.GetEntry(i).bDoQuery = sal_False;		// ueberzaehlige Felder zuruecksetzen
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir 	PutData(aParam);
1325*cdf0e10cSrcweir }
1326*cdf0e10cSrcweir 
1327*cdf0e10cSrcweir void SAL_CALL ScFilterDescriptorBase::setFilterFields2(
1328*cdf0e10cSrcweir     const uno::Sequence<sheet::TableFilterField2>& aFilterFields )
1329*cdf0e10cSrcweir     throw(uno::RuntimeException)
1330*cdf0e10cSrcweir {
1331*cdf0e10cSrcweir     ScUnoGuard aGuard;
1332*cdf0e10cSrcweir     ScQueryParam aParam;
1333*cdf0e10cSrcweir     GetData(aParam);
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir     SCSIZE nCount = static_cast<SCSIZE>(aFilterFields.getLength());
1336*cdf0e10cSrcweir     DBG_ASSERT( nCount <= MAXQUERY, "setFilterFields: zu viele" );
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir     aParam.Resize( nCount );
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir     const sheet::TableFilterField2* pAry = aFilterFields.getConstArray();
1341*cdf0e10cSrcweir     SCSIZE i;
1342*cdf0e10cSrcweir     for (i=0; i<nCount; i++)
1343*cdf0e10cSrcweir     {
1344*cdf0e10cSrcweir         ScQueryEntry& rEntry = aParam.GetEntry(i);
1345*cdf0e10cSrcweir         if (!rEntry.pStr)
1346*cdf0e10cSrcweir             rEntry.pStr = new String;		// sollte nicht sein (soll immer initialisiert sein)
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir         rEntry.bDoQuery			= sal_True;
1349*cdf0e10cSrcweir         rEntry.eConnect			= (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
1350*cdf0e10cSrcweir         rEntry.nField			= pAry[i].Field;
1351*cdf0e10cSrcweir         rEntry.bQueryByString	= !pAry[i].IsNumeric;
1352*cdf0e10cSrcweir         *rEntry.pStr			= String( pAry[i].StringValue );
1353*cdf0e10cSrcweir         rEntry.nVal				= pAry[i].NumericValue;
1354*cdf0e10cSrcweir 
1355*cdf0e10cSrcweir         if (!rEntry.bQueryByString && pDocSh)
1356*cdf0e10cSrcweir         {
1357*cdf0e10cSrcweir             pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, *rEntry.pStr);
1358*cdf0e10cSrcweir         }
1359*cdf0e10cSrcweir 
1360*cdf0e10cSrcweir         switch (pAry[i].Operator)			// FilterOperator
1361*cdf0e10cSrcweir         {
1362*cdf0e10cSrcweir         case sheet::FilterOperator2::EQUAL:			        rEntry.eOp = SC_EQUAL;		        break;
1363*cdf0e10cSrcweir         case sheet::FilterOperator2::LESS:			        rEntry.eOp = SC_LESS;			    break;
1364*cdf0e10cSrcweir         case sheet::FilterOperator2::GREATER:			    rEntry.eOp = SC_GREATER;		    break;
1365*cdf0e10cSrcweir         case sheet::FilterOperator2::LESS_EQUAL:		    rEntry.eOp = SC_LESS_EQUAL;	        break;
1366*cdf0e10cSrcweir         case sheet::FilterOperator2::GREATER_EQUAL:	        rEntry.eOp = SC_GREATER_EQUAL;      break;
1367*cdf0e10cSrcweir         case sheet::FilterOperator2::NOT_EQUAL:		        rEntry.eOp = SC_NOT_EQUAL;	        break;
1368*cdf0e10cSrcweir         case sheet::FilterOperator2::TOP_VALUES:	    	rEntry.eOp = SC_TOPVAL;		        break;
1369*cdf0e10cSrcweir         case sheet::FilterOperator2::BOTTOM_VALUES:	        rEntry.eOp = SC_BOTVAL;		        break;
1370*cdf0e10cSrcweir         case sheet::FilterOperator2::TOP_PERCENT:		    rEntry.eOp = SC_TOPPERC;		    break;
1371*cdf0e10cSrcweir         case sheet::FilterOperator2::BOTTOM_PERCENT:	    rEntry.eOp = SC_BOTPERC;		    break;
1372*cdf0e10cSrcweir         case sheet::FilterOperator2::CONTAINS:		        rEntry.eOp = SC_CONTAINS;		    break;
1373*cdf0e10cSrcweir         case sheet::FilterOperator2::DOES_NOT_CONTAIN:		rEntry.eOp = SC_DOES_NOT_CONTAIN;   break;
1374*cdf0e10cSrcweir         case sheet::FilterOperator2::BEGINS_WITH:			rEntry.eOp = SC_BEGINS_WITH;		break;
1375*cdf0e10cSrcweir         case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH:	rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break;
1376*cdf0e10cSrcweir         case sheet::FilterOperator2::ENDS_WITH:			    rEntry.eOp = SC_ENDS_WITH;		    break;
1377*cdf0e10cSrcweir         case sheet::FilterOperator2::DOES_NOT_END_WITH:		rEntry.eOp = SC_DOES_NOT_END_WITH;	break;
1378*cdf0e10cSrcweir         case sheet::FilterOperator2::EMPTY:
1379*cdf0e10cSrcweir             {
1380*cdf0e10cSrcweir                 rEntry.eOp = SC_EQUAL;
1381*cdf0e10cSrcweir                 rEntry.nVal = SC_EMPTYFIELDS;
1382*cdf0e10cSrcweir                 rEntry.bQueryByString = sal_False;
1383*cdf0e10cSrcweir                 *rEntry.pStr = EMPTY_STRING;
1384*cdf0e10cSrcweir             }
1385*cdf0e10cSrcweir             break;
1386*cdf0e10cSrcweir         case sheet::FilterOperator2::NOT_EMPTY:
1387*cdf0e10cSrcweir             {
1388*cdf0e10cSrcweir                 rEntry.eOp = SC_EQUAL;
1389*cdf0e10cSrcweir                 rEntry.nVal = SC_NONEMPTYFIELDS;
1390*cdf0e10cSrcweir                 rEntry.bQueryByString = sal_False;
1391*cdf0e10cSrcweir                 *rEntry.pStr = EMPTY_STRING;
1392*cdf0e10cSrcweir             }
1393*cdf0e10cSrcweir             break;
1394*cdf0e10cSrcweir         default:
1395*cdf0e10cSrcweir             DBG_ERROR("Falscher Query-enum");
1396*cdf0e10cSrcweir             rEntry.eOp = SC_EQUAL;
1397*cdf0e10cSrcweir         }
1398*cdf0e10cSrcweir     }
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir     SCSIZE nParamCount = aParam.GetEntryCount();	// Param wird nicht unter 8 resized
1401*cdf0e10cSrcweir     for (i=nCount; i<nParamCount; i++)
1402*cdf0e10cSrcweir         aParam.GetEntry(i).bDoQuery = sal_False;		// ueberzaehlige Felder zuruecksetzen
1403*cdf0e10cSrcweir 
1404*cdf0e10cSrcweir     PutData(aParam);
1405*cdf0e10cSrcweir }
1406*cdf0e10cSrcweir 
1407*cdf0e10cSrcweir // Rest sind Properties
1408*cdf0e10cSrcweir 
1409*cdf0e10cSrcweir // XPropertySet
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFilterDescriptorBase::getPropertySetInfo()
1412*cdf0e10cSrcweir 														throw(uno::RuntimeException)
1413*cdf0e10cSrcweir {
1414*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1415*cdf0e10cSrcweir 	static uno::Reference<beans::XPropertySetInfo> aRef(
1416*cdf0e10cSrcweir 		new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
1417*cdf0e10cSrcweir 	return aRef;
1418*cdf0e10cSrcweir }
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir void SAL_CALL ScFilterDescriptorBase::setPropertyValue(
1421*cdf0e10cSrcweir 						const rtl::OUString& aPropertyName, const uno::Any& aValue )
1422*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1423*cdf0e10cSrcweir 						lang::IllegalArgumentException, lang::WrappedTargetException,
1424*cdf0e10cSrcweir 						uno::RuntimeException)
1425*cdf0e10cSrcweir {
1426*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1427*cdf0e10cSrcweir 	ScQueryParam aParam;
1428*cdf0e10cSrcweir 	GetData(aParam);
1429*cdf0e10cSrcweir 
1430*cdf0e10cSrcweir 	String aString(aPropertyName);
1431*cdf0e10cSrcweir 	if (aString.EqualsAscii( SC_UNONAME_CONTHDR ))
1432*cdf0e10cSrcweir 		aParam.bHasHeader = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1433*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_COPYOUT ))
1434*cdf0e10cSrcweir 		aParam.bInplace = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1435*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ISCASE ))
1436*cdf0e10cSrcweir 		aParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1437*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
1438*cdf0e10cSrcweir 	{
1439*cdf0e10cSrcweir 		sal_Int32 nVal = 0;
1440*cdf0e10cSrcweir         if ( (aValue >>= nVal) && nVal > sal::static_int_cast<sal_Int32>(MAXQUERY) )
1441*cdf0e10cSrcweir 		{
1442*cdf0e10cSrcweir 			throw lang::IllegalArgumentException();
1443*cdf0e10cSrcweir 		}
1444*cdf0e10cSrcweir 	}
1445*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ORIENT ))
1446*cdf0e10cSrcweir 	{
1447*cdf0e10cSrcweir 		//!	test for correct enum type?
1448*cdf0e10cSrcweir 		table::TableOrientation eOrient = (table::TableOrientation)
1449*cdf0e10cSrcweir 								ScUnoHelpFunctions::GetEnumFromAny( aValue );
1450*cdf0e10cSrcweir 		aParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
1451*cdf0e10cSrcweir 	}
1452*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_OUTPOS ))
1453*cdf0e10cSrcweir 	{
1454*cdf0e10cSrcweir 		table::CellAddress aAddress;
1455*cdf0e10cSrcweir 		if ( aValue >>= aAddress )
1456*cdf0e10cSrcweir 		{
1457*cdf0e10cSrcweir 			aParam.nDestTab = aAddress.Sheet;
1458*cdf0e10cSrcweir 			aParam.nDestCol = (SCCOL)aAddress.Column;
1459*cdf0e10cSrcweir 			aParam.nDestRow = (SCROW)aAddress.Row;
1460*cdf0e10cSrcweir 		}
1461*cdf0e10cSrcweir 	}
1462*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_SAVEOUT ))
1463*cdf0e10cSrcweir 		aParam.bDestPers = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1464*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_SKIPDUP ))
1465*cdf0e10cSrcweir 		aParam.bDuplicate = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
1466*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_USEREGEX ))
1467*cdf0e10cSrcweir 		aParam.bRegExp = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir 	PutData(aParam);
1470*cdf0e10cSrcweir }
1471*cdf0e10cSrcweir 
1472*cdf0e10cSrcweir uno::Any SAL_CALL ScFilterDescriptorBase::getPropertyValue( const rtl::OUString& aPropertyName )
1473*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1474*cdf0e10cSrcweir 						uno::RuntimeException)
1475*cdf0e10cSrcweir {
1476*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1477*cdf0e10cSrcweir 	ScQueryParam aParam;
1478*cdf0e10cSrcweir 	GetData(aParam);
1479*cdf0e10cSrcweir 
1480*cdf0e10cSrcweir 	String aString(aPropertyName);
1481*cdf0e10cSrcweir 	uno::Any aRet;
1482*cdf0e10cSrcweir 
1483*cdf0e10cSrcweir 	if (aString.EqualsAscii( SC_UNONAME_CONTHDR ))
1484*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bHasHeader );
1485*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_COPYOUT ))
1486*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, !(aParam.bInplace) );
1487*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ISCASE ))
1488*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bCaseSens );
1489*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
1490*cdf0e10cSrcweir 		aRet <<= (sal_Int32) MAXQUERY;
1491*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_ORIENT ))
1492*cdf0e10cSrcweir 	{
1493*cdf0e10cSrcweir 		table::TableOrientation eOrient = aParam.bByRow ? table::TableOrientation_ROWS :
1494*cdf0e10cSrcweir 														  table::TableOrientation_COLUMNS;
1495*cdf0e10cSrcweir 		aRet <<= eOrient;
1496*cdf0e10cSrcweir 	}
1497*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_OUTPOS ))
1498*cdf0e10cSrcweir 	{
1499*cdf0e10cSrcweir 		table::CellAddress aOutPos;
1500*cdf0e10cSrcweir 		aOutPos.Sheet  = aParam.nDestTab;
1501*cdf0e10cSrcweir 		aOutPos.Column = aParam.nDestCol;
1502*cdf0e10cSrcweir 		aOutPos.Row    = aParam.nDestRow;
1503*cdf0e10cSrcweir 		aRet <<= aOutPos;
1504*cdf0e10cSrcweir 	}
1505*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_SAVEOUT ))
1506*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bDestPers );
1507*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_SKIPDUP ))
1508*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, !(aParam.bDuplicate) );
1509*cdf0e10cSrcweir 	else if (aString.EqualsAscii( SC_UNONAME_USEREGEX ))
1510*cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bRegExp );
1511*cdf0e10cSrcweir 
1512*cdf0e10cSrcweir 	return aRet;
1513*cdf0e10cSrcweir }
1514*cdf0e10cSrcweir 
1515*cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFilterDescriptorBase )
1516*cdf0e10cSrcweir 
1517*cdf0e10cSrcweir //------------------------------------------------------------------------
1518*cdf0e10cSrcweir 
1519*cdf0e10cSrcweir ScFilterDescriptor::ScFilterDescriptor(ScDocShell* pDocShell)
1520*cdf0e10cSrcweir     :
1521*cdf0e10cSrcweir     ScFilterDescriptorBase(pDocShell)
1522*cdf0e10cSrcweir {
1523*cdf0e10cSrcweir }
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir ScFilterDescriptor::~ScFilterDescriptor()
1526*cdf0e10cSrcweir {
1527*cdf0e10cSrcweir }
1528*cdf0e10cSrcweir 
1529*cdf0e10cSrcweir void ScFilterDescriptor::GetData( ScQueryParam& rParam ) const
1530*cdf0e10cSrcweir {
1531*cdf0e10cSrcweir 	rParam = aStoredParam;			// Abfrage fuer Interface
1532*cdf0e10cSrcweir }
1533*cdf0e10cSrcweir 
1534*cdf0e10cSrcweir void ScFilterDescriptor::PutData( const ScQueryParam& rParam )
1535*cdf0e10cSrcweir {
1536*cdf0e10cSrcweir 	aStoredParam = rParam;			// vom Interface gesetzt
1537*cdf0e10cSrcweir }
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir void ScFilterDescriptor::SetParam( const ScQueryParam& rNew )
1540*cdf0e10cSrcweir {
1541*cdf0e10cSrcweir 	aStoredParam = rNew;			// von aussen gesetzt
1542*cdf0e10cSrcweir }
1543*cdf0e10cSrcweir 
1544*cdf0e10cSrcweir //------------------------------------------------------------------------
1545*cdf0e10cSrcweir 
1546*cdf0e10cSrcweir ScRangeFilterDescriptor::ScRangeFilterDescriptor(ScDocShell* pDocShell, ScDatabaseRangeObj* pPar) :
1547*cdf0e10cSrcweir     ScFilterDescriptorBase(pDocShell),
1548*cdf0e10cSrcweir 	pParent(pPar)
1549*cdf0e10cSrcweir {
1550*cdf0e10cSrcweir 	if (pParent)
1551*cdf0e10cSrcweir 		pParent->acquire();
1552*cdf0e10cSrcweir }
1553*cdf0e10cSrcweir 
1554*cdf0e10cSrcweir ScRangeFilterDescriptor::~ScRangeFilterDescriptor()
1555*cdf0e10cSrcweir {
1556*cdf0e10cSrcweir 	if (pParent)
1557*cdf0e10cSrcweir 		pParent->release();
1558*cdf0e10cSrcweir }
1559*cdf0e10cSrcweir 
1560*cdf0e10cSrcweir void ScRangeFilterDescriptor::GetData( ScQueryParam& rParam ) const
1561*cdf0e10cSrcweir {
1562*cdf0e10cSrcweir 	if (pParent)
1563*cdf0e10cSrcweir 		pParent->GetQueryParam( rParam );
1564*cdf0e10cSrcweir }
1565*cdf0e10cSrcweir 
1566*cdf0e10cSrcweir void ScRangeFilterDescriptor::PutData( const ScQueryParam& rParam )
1567*cdf0e10cSrcweir {
1568*cdf0e10cSrcweir 	if (pParent)
1569*cdf0e10cSrcweir 		pParent->SetQueryParam( rParam );
1570*cdf0e10cSrcweir }
1571*cdf0e10cSrcweir 
1572*cdf0e10cSrcweir //------------------------------------------------------------------------
1573*cdf0e10cSrcweir 
1574*cdf0e10cSrcweir ScDataPilotFilterDescriptor::ScDataPilotFilterDescriptor(ScDocShell* pDocShell, ScDataPilotDescriptorBase* pPar) :
1575*cdf0e10cSrcweir     ScFilterDescriptorBase(pDocShell),
1576*cdf0e10cSrcweir 	pParent(pPar)
1577*cdf0e10cSrcweir {
1578*cdf0e10cSrcweir 	if (pParent)
1579*cdf0e10cSrcweir 		pParent->acquire();
1580*cdf0e10cSrcweir }
1581*cdf0e10cSrcweir 
1582*cdf0e10cSrcweir ScDataPilotFilterDescriptor::~ScDataPilotFilterDescriptor()
1583*cdf0e10cSrcweir {
1584*cdf0e10cSrcweir 	if (pParent)
1585*cdf0e10cSrcweir 		pParent->release();
1586*cdf0e10cSrcweir }
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const
1589*cdf0e10cSrcweir {
1590*cdf0e10cSrcweir 	if (pParent)
1591*cdf0e10cSrcweir 	{
1592*cdf0e10cSrcweir 		ScDPObject* pDPObj = pParent->GetDPObject();
1593*cdf0e10cSrcweir 		if (pDPObj && pDPObj->IsSheetData())
1594*cdf0e10cSrcweir             rParam = pDPObj->GetSheetDesc()->aQueryParam;
1595*cdf0e10cSrcweir 	}
1596*cdf0e10cSrcweir }
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir void ScDataPilotFilterDescriptor::PutData( const ScQueryParam& rParam )
1599*cdf0e10cSrcweir {
1600*cdf0e10cSrcweir 	if (pParent)
1601*cdf0e10cSrcweir 	{
1602*cdf0e10cSrcweir 		ScDPObject* pDPObj = pParent->GetDPObject();
1603*cdf0e10cSrcweir         if (pDPObj)
1604*cdf0e10cSrcweir         {
1605*cdf0e10cSrcweir             ScSheetSourceDesc aSheetDesc;
1606*cdf0e10cSrcweir 	        if (pDPObj->IsSheetData())
1607*cdf0e10cSrcweir                 aSheetDesc = *pDPObj->GetSheetDesc();
1608*cdf0e10cSrcweir             aSheetDesc.aQueryParam = rParam;
1609*cdf0e10cSrcweir             pDPObj->SetSheetDesc(aSheetDesc);
1610*cdf0e10cSrcweir             pParent->SetDPObject(pDPObj);
1611*cdf0e10cSrcweir         }
1612*cdf0e10cSrcweir 	}
1613*cdf0e10cSrcweir }
1614*cdf0e10cSrcweir 
1615*cdf0e10cSrcweir //------------------------------------------------------------------------
1616*cdf0e10cSrcweir 
1617*cdf0e10cSrcweir ScDatabaseRangeObj::ScDatabaseRangeObj(ScDocShell* pDocSh, const String& rNm) :
1618*cdf0e10cSrcweir 	pDocShell( pDocSh ),
1619*cdf0e10cSrcweir 	aName( rNm ),
1620*cdf0e10cSrcweir 	aPropSet( lcl_GetDBRangePropertyMap() )
1621*cdf0e10cSrcweir {
1622*cdf0e10cSrcweir 	pDocShell->GetDocument()->AddUnoObject(*this);
1623*cdf0e10cSrcweir }
1624*cdf0e10cSrcweir 
1625*cdf0e10cSrcweir ScDatabaseRangeObj::~ScDatabaseRangeObj()
1626*cdf0e10cSrcweir {
1627*cdf0e10cSrcweir 	if (pDocShell)
1628*cdf0e10cSrcweir 		pDocShell->GetDocument()->RemoveUnoObject(*this);
1629*cdf0e10cSrcweir }
1630*cdf0e10cSrcweir 
1631*cdf0e10cSrcweir void ScDatabaseRangeObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
1632*cdf0e10cSrcweir {
1633*cdf0e10cSrcweir 
1634*cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
1635*cdf0e10cSrcweir 		pDocShell = NULL;		// ungueltig geworden
1636*cdf0e10cSrcweir     else if ( rHint.ISA (ScDBRangeRefreshedHint) )
1637*cdf0e10cSrcweir     {
1638*cdf0e10cSrcweir         ScDBData* pDBData = GetDBData_Impl();
1639*cdf0e10cSrcweir 		const ScDBRangeRefreshedHint& rRef = (const ScDBRangeRefreshedHint&)rHint;
1640*cdf0e10cSrcweir         ScImportParam aParam;
1641*cdf0e10cSrcweir         pDBData->GetImportParam(aParam);
1642*cdf0e10cSrcweir         if (aParam == rRef.GetImportParam())
1643*cdf0e10cSrcweir             Refreshed_Impl();
1644*cdf0e10cSrcweir     }
1645*cdf0e10cSrcweir }
1646*cdf0e10cSrcweir 
1647*cdf0e10cSrcweir // Hilfsfuntionen
1648*cdf0e10cSrcweir 
1649*cdf0e10cSrcweir ScDBData* ScDatabaseRangeObj::GetDBData_Impl() const
1650*cdf0e10cSrcweir {
1651*cdf0e10cSrcweir 	ScDBData* pRet = NULL;
1652*cdf0e10cSrcweir 	if (pDocShell)
1653*cdf0e10cSrcweir 	{
1654*cdf0e10cSrcweir 		ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
1655*cdf0e10cSrcweir 		if (pNames)
1656*cdf0e10cSrcweir 		{
1657*cdf0e10cSrcweir 			sal_uInt16 nPos = 0;
1658*cdf0e10cSrcweir 			if (pNames->SearchName( aName, nPos ))
1659*cdf0e10cSrcweir 				pRet = (*pNames)[nPos];
1660*cdf0e10cSrcweir 		}
1661*cdf0e10cSrcweir 	}
1662*cdf0e10cSrcweir 	return pRet;
1663*cdf0e10cSrcweir }
1664*cdf0e10cSrcweir 
1665*cdf0e10cSrcweir // XNamed
1666*cdf0e10cSrcweir 
1667*cdf0e10cSrcweir rtl::OUString SAL_CALL ScDatabaseRangeObj::getName() throw(uno::RuntimeException)
1668*cdf0e10cSrcweir {
1669*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1670*cdf0e10cSrcweir 	return aName;
1671*cdf0e10cSrcweir }
1672*cdf0e10cSrcweir 
1673*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangeObj::setName( const rtl::OUString& aNewName )
1674*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1675*cdf0e10cSrcweir {
1676*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1677*cdf0e10cSrcweir 	if (pDocShell)
1678*cdf0e10cSrcweir 	{
1679*cdf0e10cSrcweir 		ScDBDocFunc aFunc(*pDocShell);
1680*cdf0e10cSrcweir 		String aNewStr(aNewName);
1681*cdf0e10cSrcweir 		sal_Bool bOk = aFunc.RenameDBRange( aName, aNewStr, sal_True );
1682*cdf0e10cSrcweir 		if (bOk)
1683*cdf0e10cSrcweir 			aName = aNewStr;
1684*cdf0e10cSrcweir 	}
1685*cdf0e10cSrcweir }
1686*cdf0e10cSrcweir 
1687*cdf0e10cSrcweir // XDatabaseRange
1688*cdf0e10cSrcweir 
1689*cdf0e10cSrcweir table::CellRangeAddress SAL_CALL ScDatabaseRangeObj::getDataArea() throw(uno::RuntimeException)
1690*cdf0e10cSrcweir {
1691*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1692*cdf0e10cSrcweir 	table::CellRangeAddress aAddress;
1693*cdf0e10cSrcweir 	ScDBData* pData = GetDBData_Impl();
1694*cdf0e10cSrcweir 	if (pData)
1695*cdf0e10cSrcweir 	{
1696*cdf0e10cSrcweir 		ScRange aRange;
1697*cdf0e10cSrcweir 		pData->GetArea(aRange);
1698*cdf0e10cSrcweir 		aAddress.Sheet		 = aRange.aStart.Tab();
1699*cdf0e10cSrcweir 		aAddress.StartColumn = aRange.aStart.Col();
1700*cdf0e10cSrcweir 		aAddress.StartRow	 = aRange.aStart.Row();
1701*cdf0e10cSrcweir 		aAddress.EndColumn	 = aRange.aEnd.Col();
1702*cdf0e10cSrcweir 		aAddress.EndRow		 = aRange.aEnd.Row();
1703*cdf0e10cSrcweir 	}
1704*cdf0e10cSrcweir 	return aAddress;
1705*cdf0e10cSrcweir }
1706*cdf0e10cSrcweir 
1707*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aDataArea )
1708*cdf0e10cSrcweir 					    							throw(uno::RuntimeException)
1709*cdf0e10cSrcweir {
1710*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1711*cdf0e10cSrcweir 	ScDBData* pData = GetDBData_Impl();
1712*cdf0e10cSrcweir 	if ( pDocShell && pData )
1713*cdf0e10cSrcweir 	{
1714*cdf0e10cSrcweir 		ScDBData aNewData( *pData );
1715*cdf0e10cSrcweir 		//!	MoveTo ???
1716*cdf0e10cSrcweir 		aNewData.SetArea( aDataArea.Sheet, (SCCOL)aDataArea.StartColumn, (SCROW)aDataArea.StartRow,
1717*cdf0e10cSrcweir 										   (SCCOL)aDataArea.EndColumn, (SCROW)aDataArea.EndRow );
1718*cdf0e10cSrcweir 		ScDBDocFunc aFunc(*pDocShell);
1719*cdf0e10cSrcweir 		aFunc.ModifyDBData(aNewData, sal_True);
1720*cdf0e10cSrcweir 	}
1721*cdf0e10cSrcweir }
1722*cdf0e10cSrcweir 
1723*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getSortDescriptor()
1724*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1725*cdf0e10cSrcweir {
1726*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1727*cdf0e10cSrcweir 	ScSortParam aParam;
1728*cdf0e10cSrcweir 	const ScDBData* pData = GetDBData_Impl();
1729*cdf0e10cSrcweir 	if (pData)
1730*cdf0e10cSrcweir 	{
1731*cdf0e10cSrcweir 		pData->GetSortParam(aParam);
1732*cdf0e10cSrcweir 
1733*cdf0e10cSrcweir 		//	im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1734*cdf0e10cSrcweir 		ScRange aDBRange;
1735*cdf0e10cSrcweir 		pData->GetArea(aDBRange);
1736*cdf0e10cSrcweir 		SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1737*cdf0e10cSrcweir 		for (sal_uInt16 i=0; i<MAXSORT; i++)
1738*cdf0e10cSrcweir 			if ( aParam.bDoSort[i] && aParam.nField[i] >= nFieldStart )
1739*cdf0e10cSrcweir 				aParam.nField[i] -= nFieldStart;
1740*cdf0e10cSrcweir 	}
1741*cdf0e10cSrcweir 
1742*cdf0e10cSrcweir 	uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
1743*cdf0e10cSrcweir 	ScSortDescriptor::FillProperties( aSeq, aParam );
1744*cdf0e10cSrcweir 	return aSeq;
1745*cdf0e10cSrcweir }
1746*cdf0e10cSrcweir 
1747*cdf0e10cSrcweir void ScDatabaseRangeObj::GetQueryParam(ScQueryParam& rQueryParam) const
1748*cdf0e10cSrcweir {
1749*cdf0e10cSrcweir 	const ScDBData* pData = GetDBData_Impl();
1750*cdf0e10cSrcweir 	if (pData)
1751*cdf0e10cSrcweir 	{
1752*cdf0e10cSrcweir 		pData->GetQueryParam(rQueryParam);
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir 		//	im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1755*cdf0e10cSrcweir 		ScRange aDBRange;
1756*cdf0e10cSrcweir 		pData->GetArea(aDBRange);
1757*cdf0e10cSrcweir 		SCCOLROW nFieldStart = rQueryParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1758*cdf0e10cSrcweir 		SCSIZE nCount = rQueryParam.GetEntryCount();
1759*cdf0e10cSrcweir 		for (SCSIZE i=0; i<nCount; i++)
1760*cdf0e10cSrcweir 		{
1761*cdf0e10cSrcweir 			ScQueryEntry& rEntry = rQueryParam.GetEntry(i);
1762*cdf0e10cSrcweir 			if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
1763*cdf0e10cSrcweir 				rEntry.nField -= nFieldStart;
1764*cdf0e10cSrcweir 		}
1765*cdf0e10cSrcweir 	}
1766*cdf0e10cSrcweir }
1767*cdf0e10cSrcweir 
1768*cdf0e10cSrcweir void ScDatabaseRangeObj::SetQueryParam(const ScQueryParam& rQueryParam)
1769*cdf0e10cSrcweir {
1770*cdf0e10cSrcweir 	const ScDBData* pData = GetDBData_Impl();
1771*cdf0e10cSrcweir 	if (pData)
1772*cdf0e10cSrcweir 	{
1773*cdf0e10cSrcweir 		//	im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1774*cdf0e10cSrcweir 		ScQueryParam aParam(rQueryParam);
1775*cdf0e10cSrcweir 		ScRange aDBRange;
1776*cdf0e10cSrcweir 		pData->GetArea(aDBRange);
1777*cdf0e10cSrcweir 		SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
1778*cdf0e10cSrcweir 
1779*cdf0e10cSrcweir         SCSIZE nCount = aParam.GetEntryCount();
1780*cdf0e10cSrcweir         for (SCSIZE i=0; i<nCount; i++)
1781*cdf0e10cSrcweir         {
1782*cdf0e10cSrcweir                ScQueryEntry& rEntry = aParam.GetEntry(i);
1783*cdf0e10cSrcweir                if (rEntry.bDoQuery)
1784*cdf0e10cSrcweir                        rEntry.nField += nFieldStart;
1785*cdf0e10cSrcweir         }
1786*cdf0e10cSrcweir 
1787*cdf0e10cSrcweir         ScDBData aNewData( *pData );
1788*cdf0e10cSrcweir 		aNewData.SetQueryParam(aParam);
1789*cdf0e10cSrcweir 		aNewData.SetHeader(aParam.bHasHeader);		// not in ScDBData::SetQueryParam
1790*cdf0e10cSrcweir 		ScDBDocFunc aFunc(*pDocShell);
1791*cdf0e10cSrcweir 		aFunc.ModifyDBData(aNewData, sal_True);
1792*cdf0e10cSrcweir 	}
1793*cdf0e10cSrcweir }
1794*cdf0e10cSrcweir 
1795*cdf0e10cSrcweir uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScDatabaseRangeObj::getFilterDescriptor()
1796*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1797*cdf0e10cSrcweir {
1798*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1799*cdf0e10cSrcweir 	return new ScRangeFilterDescriptor(pDocShell, this);
1800*cdf0e10cSrcweir }
1801*cdf0e10cSrcweir 
1802*cdf0e10cSrcweir void ScDatabaseRangeObj::GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const
1803*cdf0e10cSrcweir {
1804*cdf0e10cSrcweir 	const ScDBData* pData = GetDBData_Impl();
1805*cdf0e10cSrcweir 	if (pData)
1806*cdf0e10cSrcweir 	{
1807*cdf0e10cSrcweir 		pData->GetSubTotalParam(rSubTotalParam);
1808*cdf0e10cSrcweir 
1809*cdf0e10cSrcweir 		//	im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1810*cdf0e10cSrcweir 		ScRange aDBRange;
1811*cdf0e10cSrcweir 		pData->GetArea(aDBRange);
1812*cdf0e10cSrcweir 		SCCOL nFieldStart = aDBRange.aStart.Col();
1813*cdf0e10cSrcweir 		for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
1814*cdf0e10cSrcweir 		{
1815*cdf0e10cSrcweir 			if ( rSubTotalParam.bGroupActive[i] )
1816*cdf0e10cSrcweir 			{
1817*cdf0e10cSrcweir 				if ( rSubTotalParam.nField[i] >= nFieldStart )
1818*cdf0e10cSrcweir                     rSubTotalParam.nField[i] = sal::static_int_cast<SCCOL>( rSubTotalParam.nField[i] - nFieldStart );
1819*cdf0e10cSrcweir 				for (SCCOL j=0; j<rSubTotalParam.nSubTotals[i]; j++)
1820*cdf0e10cSrcweir 					if ( rSubTotalParam.pSubTotals[i][j] >= nFieldStart )
1821*cdf0e10cSrcweir                         rSubTotalParam.pSubTotals[i][j] =
1822*cdf0e10cSrcweir                             sal::static_int_cast<SCCOL>( rSubTotalParam.pSubTotals[i][j] - nFieldStart );
1823*cdf0e10cSrcweir 			}
1824*cdf0e10cSrcweir 		}
1825*cdf0e10cSrcweir 	}
1826*cdf0e10cSrcweir }
1827*cdf0e10cSrcweir 
1828*cdf0e10cSrcweir void ScDatabaseRangeObj::SetSubTotalParam(const ScSubTotalParam& rSubTotalParam)
1829*cdf0e10cSrcweir {
1830*cdf0e10cSrcweir 	const ScDBData* pData = GetDBData_Impl();
1831*cdf0e10cSrcweir 	if (pData)
1832*cdf0e10cSrcweir 	{
1833*cdf0e10cSrcweir 		//	im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
1834*cdf0e10cSrcweir 		ScSubTotalParam aParam(rSubTotalParam);
1835*cdf0e10cSrcweir 		ScRange aDBRange;
1836*cdf0e10cSrcweir 		pData->GetArea(aDBRange);
1837*cdf0e10cSrcweir 		SCCOL nFieldStart = aDBRange.aStart.Col();
1838*cdf0e10cSrcweir 		for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
1839*cdf0e10cSrcweir 		{
1840*cdf0e10cSrcweir 			if ( aParam.bGroupActive[i] )
1841*cdf0e10cSrcweir 			{
1842*cdf0e10cSrcweir                 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
1843*cdf0e10cSrcweir 				for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
1844*cdf0e10cSrcweir                     aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
1845*cdf0e10cSrcweir 			}
1846*cdf0e10cSrcweir 		}
1847*cdf0e10cSrcweir 
1848*cdf0e10cSrcweir 		ScDBData aNewData( *pData );
1849*cdf0e10cSrcweir 		aNewData.SetSubTotalParam(aParam);
1850*cdf0e10cSrcweir 		ScDBDocFunc aFunc(*pDocShell);
1851*cdf0e10cSrcweir 		aFunc.ModifyDBData(aNewData, sal_True);
1852*cdf0e10cSrcweir 	}
1853*cdf0e10cSrcweir }
1854*cdf0e10cSrcweir 
1855*cdf0e10cSrcweir uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScDatabaseRangeObj::getSubTotalDescriptor()
1856*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1857*cdf0e10cSrcweir {
1858*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1859*cdf0e10cSrcweir 	return new ScRangeSubTotalDescriptor(this);
1860*cdf0e10cSrcweir }
1861*cdf0e10cSrcweir 
1862*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getImportDescriptor()
1863*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1864*cdf0e10cSrcweir {
1865*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1866*cdf0e10cSrcweir 	ScImportParam aParam;
1867*cdf0e10cSrcweir 	const ScDBData* pData = GetDBData_Impl();
1868*cdf0e10cSrcweir 	if (pData)
1869*cdf0e10cSrcweir 		pData->GetImportParam(aParam);
1870*cdf0e10cSrcweir 
1871*cdf0e10cSrcweir 	uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
1872*cdf0e10cSrcweir 	ScImportDescriptor::FillProperties( aSeq, aParam );
1873*cdf0e10cSrcweir 	return aSeq;
1874*cdf0e10cSrcweir }
1875*cdf0e10cSrcweir 
1876*cdf0e10cSrcweir // XRefreshable
1877*cdf0e10cSrcweir 
1878*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangeObj::refresh() throw(uno::RuntimeException)
1879*cdf0e10cSrcweir {
1880*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1881*cdf0e10cSrcweir 	ScDBData* pData = GetDBData_Impl();
1882*cdf0e10cSrcweir 	if ( pDocShell && pData )
1883*cdf0e10cSrcweir 	{
1884*cdf0e10cSrcweir 		ScDBDocFunc aFunc(*pDocShell);
1885*cdf0e10cSrcweir 
1886*cdf0e10cSrcweir 		// Import zu wiederholen?
1887*cdf0e10cSrcweir 		sal_Bool bContinue = sal_True;
1888*cdf0e10cSrcweir 		ScImportParam aImportParam;
1889*cdf0e10cSrcweir 		pData->GetImportParam( aImportParam );
1890*cdf0e10cSrcweir 		if (aImportParam.bImport && !pData->HasImportSelection())
1891*cdf0e10cSrcweir 		{
1892*cdf0e10cSrcweir             SCTAB nTab;
1893*cdf0e10cSrcweir             SCCOL nDummyCol;
1894*cdf0e10cSrcweir             SCROW nDummyRow;
1895*cdf0e10cSrcweir             pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow );
1896*cdf0e10cSrcweir             bContinue = aFunc.DoImport( nTab, aImportParam, NULL, sal_True );   //! Api-Flag as parameter
1897*cdf0e10cSrcweir 		}
1898*cdf0e10cSrcweir 
1899*cdf0e10cSrcweir 		// interne Operationen (sort, query, subtotal) nur, wenn kein Fehler
1900*cdf0e10cSrcweir 		if (bContinue)
1901*cdf0e10cSrcweir 			aFunc.RepeatDB( pData->GetName(), sal_True, sal_True );
1902*cdf0e10cSrcweir 	}
1903*cdf0e10cSrcweir }
1904*cdf0e10cSrcweir 
1905*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangeObj::addRefreshListener(
1906*cdf0e10cSrcweir 								const uno::Reference<util::XRefreshListener >& xListener )
1907*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1908*cdf0e10cSrcweir {
1909*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1910*cdf0e10cSrcweir 	uno::Reference<util::XRefreshListener>* pObj =
1911*cdf0e10cSrcweir 			new uno::Reference<util::XRefreshListener>( xListener );
1912*cdf0e10cSrcweir 	aRefreshListeners.Insert( pObj, aRefreshListeners.Count() );
1913*cdf0e10cSrcweir 
1914*cdf0e10cSrcweir 	//	hold one additional ref to keep this object alive as long as there are listeners
1915*cdf0e10cSrcweir 	if ( aRefreshListeners.Count() == 1 )
1916*cdf0e10cSrcweir 		acquire();
1917*cdf0e10cSrcweir }
1918*cdf0e10cSrcweir 
1919*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangeObj::removeRefreshListener(
1920*cdf0e10cSrcweir 								const uno::Reference<util::XRefreshListener >& xListener )
1921*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1922*cdf0e10cSrcweir {
1923*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1924*cdf0e10cSrcweir 	sal_uInt16 nCount = aRefreshListeners.Count();
1925*cdf0e10cSrcweir 	for ( sal_uInt16 n=nCount; n--; )
1926*cdf0e10cSrcweir 	{
1927*cdf0e10cSrcweir 		uno::Reference<util::XRefreshListener>* pObj = aRefreshListeners[n];
1928*cdf0e10cSrcweir 		if ( *pObj == xListener )
1929*cdf0e10cSrcweir 		{
1930*cdf0e10cSrcweir 			aRefreshListeners.DeleteAndDestroy( n );
1931*cdf0e10cSrcweir 			if ( aRefreshListeners.Count() == 0 )
1932*cdf0e10cSrcweir 				release();							// release ref for listeners
1933*cdf0e10cSrcweir 			break;
1934*cdf0e10cSrcweir 		}
1935*cdf0e10cSrcweir 	}
1936*cdf0e10cSrcweir }
1937*cdf0e10cSrcweir 
1938*cdf0e10cSrcweir void ScDatabaseRangeObj::Refreshed_Impl()
1939*cdf0e10cSrcweir {
1940*cdf0e10cSrcweir 	lang::EventObject aEvent;
1941*cdf0e10cSrcweir 	aEvent.Source = (cppu::OWeakObject*)this;
1942*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<aRefreshListeners.Count(); n++ )
1943*cdf0e10cSrcweir 		(*aRefreshListeners[n])->refreshed( aEvent );
1944*cdf0e10cSrcweir }
1945*cdf0e10cSrcweir 
1946*cdf0e10cSrcweir // XCellRangeSource
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir uno::Reference<table::XCellRange> SAL_CALL ScDatabaseRangeObj::getReferredCells()
1949*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1950*cdf0e10cSrcweir {
1951*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1952*cdf0e10cSrcweir 	ScRange aRange;
1953*cdf0e10cSrcweir 	ScDBData* pData = GetDBData_Impl();
1954*cdf0e10cSrcweir 	if ( pData )
1955*cdf0e10cSrcweir 	{
1956*cdf0e10cSrcweir 		//!	static Funktion um ScCellObj/ScCellRangeObj zu erzeugen am ScCellRangeObj ???
1957*cdf0e10cSrcweir 
1958*cdf0e10cSrcweir 		pData->GetArea(aRange);
1959*cdf0e10cSrcweir 		if ( aRange.aStart == aRange.aEnd )
1960*cdf0e10cSrcweir 			return new ScCellObj( pDocShell, aRange.aStart );
1961*cdf0e10cSrcweir 		else
1962*cdf0e10cSrcweir 			return new ScCellRangeObj( pDocShell, aRange );
1963*cdf0e10cSrcweir 	}
1964*cdf0e10cSrcweir 	return NULL;
1965*cdf0e10cSrcweir }
1966*cdf0e10cSrcweir 
1967*cdf0e10cSrcweir // XPropertySet
1968*cdf0e10cSrcweir 
1969*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDatabaseRangeObj::getPropertySetInfo()
1970*cdf0e10cSrcweir 														throw(uno::RuntimeException)
1971*cdf0e10cSrcweir {
1972*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1973*cdf0e10cSrcweir 	static uno::Reference<beans::XPropertySetInfo> aRef(
1974*cdf0e10cSrcweir 		new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
1975*cdf0e10cSrcweir 	return aRef;
1976*cdf0e10cSrcweir }
1977*cdf0e10cSrcweir 
1978*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangeObj::setPropertyValue(
1979*cdf0e10cSrcweir 						const rtl::OUString& aPropertyName, const uno::Any& aValue )
1980*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1981*cdf0e10cSrcweir 						lang::IllegalArgumentException, lang::WrappedTargetException,
1982*cdf0e10cSrcweir 						uno::RuntimeException)
1983*cdf0e10cSrcweir {
1984*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1985*cdf0e10cSrcweir 	ScDBData* pData = GetDBData_Impl();
1986*cdf0e10cSrcweir 	if ( pDocShell && pData )
1987*cdf0e10cSrcweir 	{
1988*cdf0e10cSrcweir 		ScDBData aNewData( *pData );
1989*cdf0e10cSrcweir 		sal_Bool bDo = sal_True;
1990*cdf0e10cSrcweir 
1991*cdf0e10cSrcweir 		String aString(aPropertyName);
1992*cdf0e10cSrcweir 		if ( aString.EqualsAscii( SC_UNONAME_KEEPFORM ) )
1993*cdf0e10cSrcweir 			aNewData.SetKeepFmt( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1994*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNONAME_MOVCELLS ) )
1995*cdf0e10cSrcweir 			aNewData.SetDoSize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1996*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNONAME_STRIPDAT ) )
1997*cdf0e10cSrcweir 			aNewData.SetStripData( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1998*cdf0e10cSrcweir 	    else if (aString.EqualsAscii( SC_UNONAME_AUTOFLT ))
1999*cdf0e10cSrcweir         {
2000*cdf0e10cSrcweir 		    sal_Bool bAutoFilter(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
2001*cdf0e10cSrcweir 	        aNewData.SetAutoFilter(bAutoFilter);
2002*cdf0e10cSrcweir             ScRange aRange;
2003*cdf0e10cSrcweir             aNewData.GetArea(aRange);
2004*cdf0e10cSrcweir             ScDocument* pDoc = pDocShell->GetDocument();
2005*cdf0e10cSrcweir 	        if (bAutoFilter && pDoc)
2006*cdf0e10cSrcweir 		        pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
2007*cdf0e10cSrcweir 								     aRange.aEnd.Col(), aRange.aStart.Row(),
2008*cdf0e10cSrcweir 								     aRange.aStart.Tab(), SC_MF_AUTO );
2009*cdf0e10cSrcweir             else  if (!bAutoFilter && pDoc)
2010*cdf0e10cSrcweir                 pDoc->RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(),
2011*cdf0e10cSrcweir 								     aRange.aEnd.Col(), aRange.aStart.Row(),
2012*cdf0e10cSrcweir 								     aRange.aStart.Tab(), SC_MF_AUTO );
2013*cdf0e10cSrcweir             ScRange aPaintRange(aRange.aStart, aRange.aEnd);
2014*cdf0e10cSrcweir             aPaintRange.aEnd.SetRow(aPaintRange.aStart.Row());
2015*cdf0e10cSrcweir             pDocShell->PostPaint(aPaintRange, PAINT_GRID);
2016*cdf0e10cSrcweir         }
2017*cdf0e10cSrcweir 	    else if (aString.EqualsAscii( SC_UNONAME_USEFLTCRT ))
2018*cdf0e10cSrcweir         {
2019*cdf0e10cSrcweir 		    if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
2020*cdf0e10cSrcweir             {
2021*cdf0e10cSrcweir                 ScRange aRange;
2022*cdf0e10cSrcweir                 aNewData.GetAdvancedQuerySource(aRange);
2023*cdf0e10cSrcweir                 aNewData.SetAdvancedQuerySource(&aRange);
2024*cdf0e10cSrcweir             }
2025*cdf0e10cSrcweir             else
2026*cdf0e10cSrcweir                 aNewData.SetAdvancedQuerySource(NULL);
2027*cdf0e10cSrcweir         }
2028*cdf0e10cSrcweir 	    else if (aString.EqualsAscii( SC_UNONAME_FLTCRT ))
2029*cdf0e10cSrcweir         {
2030*cdf0e10cSrcweir             table::CellRangeAddress aRange;
2031*cdf0e10cSrcweir             if (aValue >>= aRange)
2032*cdf0e10cSrcweir             {
2033*cdf0e10cSrcweir                 ScRange aCoreRange;
2034*cdf0e10cSrcweir                 ScUnoConversion::FillScRange(aCoreRange, aRange);
2035*cdf0e10cSrcweir 
2036*cdf0e10cSrcweir                 aNewData.SetAdvancedQuerySource(&aCoreRange);
2037*cdf0e10cSrcweir             }
2038*cdf0e10cSrcweir         }
2039*cdf0e10cSrcweir         else if (aString.EqualsAscii( SC_UNONAME_FROMSELECT ))
2040*cdf0e10cSrcweir         {
2041*cdf0e10cSrcweir             aNewData.SetImportSelection(::cppu::any2bool(aValue));
2042*cdf0e10cSrcweir         }
2043*cdf0e10cSrcweir 		else if (aString.EqualsAscii( SC_UNONAME_REFPERIOD ))
2044*cdf0e10cSrcweir 		{
2045*cdf0e10cSrcweir 		    sal_Int32 nRefresh = 0;
2046*cdf0e10cSrcweir 		    if (aValue >>= nRefresh)
2047*cdf0e10cSrcweir 		    {
2048*cdf0e10cSrcweir                 ScDocument* pDoc = pDocShell->GetDocument();
2049*cdf0e10cSrcweir 		        aNewData.SetRefreshDelay(nRefresh);
2050*cdf0e10cSrcweir                 if (pDoc && pDoc->GetDBCollection())
2051*cdf0e10cSrcweir                 {
2052*cdf0e10cSrcweir 				    aNewData.SetRefreshHandler( pDoc->GetDBCollection()->GetRefreshHandler() );
2053*cdf0e10cSrcweir 			        aNewData.SetRefreshControl( pDoc->GetRefreshTimerControlAddress() );
2054*cdf0e10cSrcweir                 }
2055*cdf0e10cSrcweir             }
2056*cdf0e10cSrcweir 		}
2057*cdf0e10cSrcweir         else if (aString.EqualsAscii( SC_UNONAME_CONRES ))
2058*cdf0e10cSrcweir         {
2059*cdf0e10cSrcweir         }
2060*cdf0e10cSrcweir 		else
2061*cdf0e10cSrcweir 			bDo = sal_False;
2062*cdf0e10cSrcweir 
2063*cdf0e10cSrcweir 		if (bDo)
2064*cdf0e10cSrcweir 		{
2065*cdf0e10cSrcweir 			ScDBDocFunc aFunc(*pDocShell);
2066*cdf0e10cSrcweir 			aFunc.ModifyDBData(aNewData, sal_True);
2067*cdf0e10cSrcweir 		}
2068*cdf0e10cSrcweir 	}
2069*cdf0e10cSrcweir }
2070*cdf0e10cSrcweir 
2071*cdf0e10cSrcweir uno::Any SAL_CALL ScDatabaseRangeObj::getPropertyValue( const rtl::OUString& aPropertyName )
2072*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2073*cdf0e10cSrcweir 						uno::RuntimeException)
2074*cdf0e10cSrcweir {
2075*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2076*cdf0e10cSrcweir 	uno::Any aRet;
2077*cdf0e10cSrcweir 	ScDBData* pData = GetDBData_Impl();
2078*cdf0e10cSrcweir 	if ( pData )
2079*cdf0e10cSrcweir 	{
2080*cdf0e10cSrcweir 		String aString(aPropertyName);
2081*cdf0e10cSrcweir 		if ( aString.EqualsAscii( SC_UNONAME_KEEPFORM ) )
2082*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsKeepFmt() );
2083*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNONAME_MOVCELLS ) )
2084*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsDoSize() );
2085*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNONAME_STRIPDAT ) )
2086*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsStripData() );
2087*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNONAME_ISUSER ) )
2088*cdf0e10cSrcweir 		{
2089*cdf0e10cSrcweir 			//	all database ranges except "unnamed" are user defined
2090*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet,
2091*cdf0e10cSrcweir 						( pData->GetName() != ScGlobal::GetRscString(STR_DB_NONAME) ) );
2092*cdf0e10cSrcweir 		}
2093*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_LINKDISPBIT ) )
2094*cdf0e10cSrcweir 		{
2095*cdf0e10cSrcweir 			//	no target bitmaps for individual entries (would be all equal)
2096*cdf0e10cSrcweir 			// ScLinkTargetTypeObj::SetLinkTargetBitmap( aRet, SC_LINKTARGETTYPE_DBAREA );
2097*cdf0e10cSrcweir 		}
2098*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_LINKDISPNAME ) )
2099*cdf0e10cSrcweir 			aRet <<= rtl::OUString( aName );
2100*cdf0e10cSrcweir 	    else if (aString.EqualsAscii( SC_UNONAME_AUTOFLT ))
2101*cdf0e10cSrcweir         {
2102*cdf0e10cSrcweir             sal_Bool bAutoFilter(GetDBData_Impl()->HasAutoFilter());
2103*cdf0e10cSrcweir 
2104*cdf0e10cSrcweir 		    ScUnoHelpFunctions::SetBoolInAny( aRet, bAutoFilter );
2105*cdf0e10cSrcweir         }
2106*cdf0e10cSrcweir 	    else if (aString.EqualsAscii( SC_UNONAME_USEFLTCRT ))
2107*cdf0e10cSrcweir         {
2108*cdf0e10cSrcweir             ScRange aRange;
2109*cdf0e10cSrcweir             sal_Bool bIsAdvancedSource(GetDBData_Impl()->GetAdvancedQuerySource(aRange));
2110*cdf0e10cSrcweir 
2111*cdf0e10cSrcweir 		    ScUnoHelpFunctions::SetBoolInAny( aRet, bIsAdvancedSource );
2112*cdf0e10cSrcweir         }
2113*cdf0e10cSrcweir 	    else if (aString.EqualsAscii( SC_UNONAME_FLTCRT ))
2114*cdf0e10cSrcweir         {
2115*cdf0e10cSrcweir             table::CellRangeAddress aRange;
2116*cdf0e10cSrcweir             ScRange aCoreRange;
2117*cdf0e10cSrcweir             if (GetDBData_Impl()->GetAdvancedQuerySource(aCoreRange))
2118*cdf0e10cSrcweir                 ScUnoConversion::FillApiRange(aRange, aCoreRange);
2119*cdf0e10cSrcweir 
2120*cdf0e10cSrcweir             aRet <<= aRange;
2121*cdf0e10cSrcweir         }
2122*cdf0e10cSrcweir         else if (aString.EqualsAscii( SC_UNONAME_FROMSELECT ))
2123*cdf0e10cSrcweir         {
2124*cdf0e10cSrcweir 		    ScUnoHelpFunctions::SetBoolInAny( aRet, GetDBData_Impl()->HasImportSelection() );
2125*cdf0e10cSrcweir         }
2126*cdf0e10cSrcweir 		else if (aString.EqualsAscii( SC_UNONAME_REFPERIOD ))
2127*cdf0e10cSrcweir 		{
2128*cdf0e10cSrcweir 		    sal_Int32 nRefresh(GetDBData_Impl()->GetRefreshDelay());
2129*cdf0e10cSrcweir 		    aRet <<= nRefresh;
2130*cdf0e10cSrcweir 		}
2131*cdf0e10cSrcweir         else if (aString.EqualsAscii( SC_UNONAME_CONRES ))
2132*cdf0e10cSrcweir         {
2133*cdf0e10cSrcweir         }
2134*cdf0e10cSrcweir         else if (aString.EqualsAscii( SC_UNONAME_TOKENINDEX ))
2135*cdf0e10cSrcweir         {
2136*cdf0e10cSrcweir             // get index for use in formula tokens (read-only)
2137*cdf0e10cSrcweir             aRet <<= static_cast<sal_Int32>(GetDBData_Impl()->GetIndex());
2138*cdf0e10cSrcweir         }
2139*cdf0e10cSrcweir 	}
2140*cdf0e10cSrcweir 	return aRet;
2141*cdf0e10cSrcweir }
2142*cdf0e10cSrcweir 
2143*cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDatabaseRangeObj )
2144*cdf0e10cSrcweir 
2145*cdf0e10cSrcweir // XServiceInfo
2146*cdf0e10cSrcweir 
2147*cdf0e10cSrcweir rtl::OUString SAL_CALL ScDatabaseRangeObj::getImplementationName() throw(uno::RuntimeException)
2148*cdf0e10cSrcweir {
2149*cdf0e10cSrcweir 	return rtl::OUString::createFromAscii( "ScDatabaseRangeObj" );
2150*cdf0e10cSrcweir }
2151*cdf0e10cSrcweir 
2152*cdf0e10cSrcweir sal_Bool SAL_CALL ScDatabaseRangeObj::supportsService( const rtl::OUString& rServiceName )
2153*cdf0e10cSrcweir 													throw(uno::RuntimeException)
2154*cdf0e10cSrcweir {
2155*cdf0e10cSrcweir 	String aServiceStr( rServiceName );
2156*cdf0e10cSrcweir 	return aServiceStr.EqualsAscii( SCDATABASERANGEOBJ_SERVICE ) ||
2157*cdf0e10cSrcweir 		   aServiceStr.EqualsAscii( SCLINKTARGET_SERVICE );
2158*cdf0e10cSrcweir }
2159*cdf0e10cSrcweir 
2160*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangeObj::getSupportedServiceNames()
2161*cdf0e10cSrcweir 													throw(uno::RuntimeException)
2162*cdf0e10cSrcweir {
2163*cdf0e10cSrcweir 	uno::Sequence<rtl::OUString> aRet(2);
2164*cdf0e10cSrcweir 	rtl::OUString* pArray = aRet.getArray();
2165*cdf0e10cSrcweir 	pArray[0] = rtl::OUString::createFromAscii( SCDATABASERANGEOBJ_SERVICE );
2166*cdf0e10cSrcweir 	pArray[1] = rtl::OUString::createFromAscii( SCLINKTARGET_SERVICE );
2167*cdf0e10cSrcweir 	return aRet;
2168*cdf0e10cSrcweir }
2169*cdf0e10cSrcweir 
2170*cdf0e10cSrcweir //------------------------------------------------------------------------
2171*cdf0e10cSrcweir 
2172*cdf0e10cSrcweir ScDatabaseRangesObj::ScDatabaseRangesObj(ScDocShell* pDocSh) :
2173*cdf0e10cSrcweir 	pDocShell( pDocSh )
2174*cdf0e10cSrcweir {
2175*cdf0e10cSrcweir 	pDocShell->GetDocument()->AddUnoObject(*this);
2176*cdf0e10cSrcweir }
2177*cdf0e10cSrcweir 
2178*cdf0e10cSrcweir ScDatabaseRangesObj::~ScDatabaseRangesObj()
2179*cdf0e10cSrcweir {
2180*cdf0e10cSrcweir 	if (pDocShell)
2181*cdf0e10cSrcweir 		pDocShell->GetDocument()->RemoveUnoObject(*this);
2182*cdf0e10cSrcweir }
2183*cdf0e10cSrcweir 
2184*cdf0e10cSrcweir void ScDatabaseRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
2185*cdf0e10cSrcweir {
2186*cdf0e10cSrcweir 	//	Referenz-Update interessiert hier nicht
2187*cdf0e10cSrcweir 
2188*cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) &&
2189*cdf0e10cSrcweir 			((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
2190*cdf0e10cSrcweir 	{
2191*cdf0e10cSrcweir 		pDocShell = NULL;		// ungueltig geworden
2192*cdf0e10cSrcweir 	}
2193*cdf0e10cSrcweir }
2194*cdf0e10cSrcweir 
2195*cdf0e10cSrcweir // XDatabaseRanges
2196*cdf0e10cSrcweir 
2197*cdf0e10cSrcweir ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
2198*cdf0e10cSrcweir {
2199*cdf0e10cSrcweir 	if (pDocShell)
2200*cdf0e10cSrcweir 	{
2201*cdf0e10cSrcweir 		ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
2202*cdf0e10cSrcweir 		if (pNames && nIndex < pNames->GetCount())
2203*cdf0e10cSrcweir 			return new ScDatabaseRangeObj( pDocShell, (*pNames)[nIndex]->GetName() );
2204*cdf0e10cSrcweir 	}
2205*cdf0e10cSrcweir 	return NULL;
2206*cdf0e10cSrcweir }
2207*cdf0e10cSrcweir 
2208*cdf0e10cSrcweir ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByName_Impl(const rtl::OUString& aName)
2209*cdf0e10cSrcweir {
2210*cdf0e10cSrcweir 	if ( pDocShell && hasByName(aName) )
2211*cdf0e10cSrcweir 	{
2212*cdf0e10cSrcweir 		String aString(aName);
2213*cdf0e10cSrcweir 		return new ScDatabaseRangeObj( pDocShell, aString );
2214*cdf0e10cSrcweir 	}
2215*cdf0e10cSrcweir 	return NULL;
2216*cdf0e10cSrcweir }
2217*cdf0e10cSrcweir 
2218*cdf0e10cSrcweir 
2219*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangesObj::addNewByName( const rtl::OUString& aName,
2220*cdf0e10cSrcweir 										const table::CellRangeAddress& aRange )
2221*cdf0e10cSrcweir 										throw(uno::RuntimeException)
2222*cdf0e10cSrcweir {
2223*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2224*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
2225*cdf0e10cSrcweir 	if (pDocShell)
2226*cdf0e10cSrcweir 	{
2227*cdf0e10cSrcweir 		ScDBDocFunc aFunc(*pDocShell);
2228*cdf0e10cSrcweir 
2229*cdf0e10cSrcweir 		String aString(aName);
2230*cdf0e10cSrcweir 		ScRange aNameRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
2231*cdf0e10cSrcweir 							(SCCOL)aRange.EndColumn,   (SCROW)aRange.EndRow,   aRange.Sheet );
2232*cdf0e10cSrcweir 		bDone = aFunc.AddDBRange( aString, aNameRange, sal_True );
2233*cdf0e10cSrcweir 	}
2234*cdf0e10cSrcweir 	if (!bDone)
2235*cdf0e10cSrcweir 		throw uno::RuntimeException();		// no other exceptions specified
2236*cdf0e10cSrcweir }
2237*cdf0e10cSrcweir 
2238*cdf0e10cSrcweir void SAL_CALL ScDatabaseRangesObj::removeByName( const rtl::OUString& aName )
2239*cdf0e10cSrcweir 										throw(uno::RuntimeException)
2240*cdf0e10cSrcweir {
2241*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2242*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
2243*cdf0e10cSrcweir 	if (pDocShell)
2244*cdf0e10cSrcweir 	{
2245*cdf0e10cSrcweir 		ScDBDocFunc aFunc(*pDocShell);
2246*cdf0e10cSrcweir 		String aString(aName);
2247*cdf0e10cSrcweir 		bDone = aFunc.DeleteDBRange( aString, sal_True );
2248*cdf0e10cSrcweir 	}
2249*cdf0e10cSrcweir 	if (!bDone)
2250*cdf0e10cSrcweir 		throw uno::RuntimeException();		// no other exceptions specified
2251*cdf0e10cSrcweir }
2252*cdf0e10cSrcweir 
2253*cdf0e10cSrcweir // XEnumerationAccess
2254*cdf0e10cSrcweir 
2255*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScDatabaseRangesObj::createEnumeration()
2256*cdf0e10cSrcweir 													throw(uno::RuntimeException)
2257*cdf0e10cSrcweir {
2258*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2259*cdf0e10cSrcweir     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DatabaseRangesEnumeration")));
2260*cdf0e10cSrcweir }
2261*cdf0e10cSrcweir 
2262*cdf0e10cSrcweir // XIndexAccess
2263*cdf0e10cSrcweir 
2264*cdf0e10cSrcweir sal_Int32 SAL_CALL ScDatabaseRangesObj::getCount() throw(uno::RuntimeException)
2265*cdf0e10cSrcweir {
2266*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2267*cdf0e10cSrcweir 
2268*cdf0e10cSrcweir 	//!	"unbenannt" weglassen ?
2269*cdf0e10cSrcweir 
2270*cdf0e10cSrcweir 	if (pDocShell)
2271*cdf0e10cSrcweir 	{
2272*cdf0e10cSrcweir 		ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
2273*cdf0e10cSrcweir 		if (pNames)
2274*cdf0e10cSrcweir 			return pNames->GetCount();
2275*cdf0e10cSrcweir 	}
2276*cdf0e10cSrcweir 	return 0;
2277*cdf0e10cSrcweir }
2278*cdf0e10cSrcweir 
2279*cdf0e10cSrcweir uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex )
2280*cdf0e10cSrcweir 							throw(lang::IndexOutOfBoundsException,
2281*cdf0e10cSrcweir 									lang::WrappedTargetException, uno::RuntimeException)
2282*cdf0e10cSrcweir {
2283*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2284*cdf0e10cSrcweir 	uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex));
2285*cdf0e10cSrcweir 	if (xRange.is())
2286*cdf0e10cSrcweir         return uno::makeAny(xRange);
2287*cdf0e10cSrcweir 	else
2288*cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
2289*cdf0e10cSrcweir //    return uno::Any();
2290*cdf0e10cSrcweir }
2291*cdf0e10cSrcweir 
2292*cdf0e10cSrcweir uno::Type SAL_CALL ScDatabaseRangesObj::getElementType() throw(uno::RuntimeException)
2293*cdf0e10cSrcweir {
2294*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2295*cdf0e10cSrcweir 	return getCppuType((uno::Reference<sheet::XDatabaseRange>*)0);
2296*cdf0e10cSrcweir }
2297*cdf0e10cSrcweir 
2298*cdf0e10cSrcweir sal_Bool SAL_CALL ScDatabaseRangesObj::hasElements() throw(uno::RuntimeException)
2299*cdf0e10cSrcweir {
2300*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2301*cdf0e10cSrcweir 	return ( getCount() != 0 );
2302*cdf0e10cSrcweir }
2303*cdf0e10cSrcweir 
2304*cdf0e10cSrcweir // XNameAccess
2305*cdf0e10cSrcweir 
2306*cdf0e10cSrcweir uno::Any SAL_CALL ScDatabaseRangesObj::getByName( const rtl::OUString& aName )
2307*cdf0e10cSrcweir 			throw(container::NoSuchElementException,
2308*cdf0e10cSrcweir 					lang::WrappedTargetException, uno::RuntimeException)
2309*cdf0e10cSrcweir {
2310*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2311*cdf0e10cSrcweir 	uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByName_Impl(aName));
2312*cdf0e10cSrcweir 	if (xRange.is())
2313*cdf0e10cSrcweir         return uno::makeAny(xRange);
2314*cdf0e10cSrcweir 	else
2315*cdf0e10cSrcweir 		throw container::NoSuchElementException();
2316*cdf0e10cSrcweir //    return uno::Any();
2317*cdf0e10cSrcweir }
2318*cdf0e10cSrcweir 
2319*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangesObj::getElementNames()
2320*cdf0e10cSrcweir 												throw(uno::RuntimeException)
2321*cdf0e10cSrcweir {
2322*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2323*cdf0e10cSrcweir 
2324*cdf0e10cSrcweir 	//!	"unbenannt" weglassen ?
2325*cdf0e10cSrcweir 
2326*cdf0e10cSrcweir 	if (pDocShell)
2327*cdf0e10cSrcweir 	{
2328*cdf0e10cSrcweir 		ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
2329*cdf0e10cSrcweir 		if (pNames)
2330*cdf0e10cSrcweir 		{
2331*cdf0e10cSrcweir 			sal_uInt16 nCount = pNames->GetCount();
2332*cdf0e10cSrcweir 			String aName;
2333*cdf0e10cSrcweir 			uno::Sequence<rtl::OUString> aSeq(nCount);
2334*cdf0e10cSrcweir 			rtl::OUString* pAry = aSeq.getArray();
2335*cdf0e10cSrcweir 			for (sal_uInt16 i=0; i<nCount; i++)
2336*cdf0e10cSrcweir 				pAry[i] = (*pNames)[i]->GetName();
2337*cdf0e10cSrcweir 
2338*cdf0e10cSrcweir 			return aSeq;
2339*cdf0e10cSrcweir 		}
2340*cdf0e10cSrcweir 	}
2341*cdf0e10cSrcweir 	return uno::Sequence<rtl::OUString>(0);
2342*cdf0e10cSrcweir }
2343*cdf0e10cSrcweir 
2344*cdf0e10cSrcweir sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const rtl::OUString& aName )
2345*cdf0e10cSrcweir 										throw(uno::RuntimeException)
2346*cdf0e10cSrcweir {
2347*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2348*cdf0e10cSrcweir 
2349*cdf0e10cSrcweir 	//!	"unbenannt" weglassen ?
2350*cdf0e10cSrcweir 
2351*cdf0e10cSrcweir 	if (pDocShell)
2352*cdf0e10cSrcweir 	{
2353*cdf0e10cSrcweir 		ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
2354*cdf0e10cSrcweir 		if (pNames)
2355*cdf0e10cSrcweir 		{
2356*cdf0e10cSrcweir 			String aString(aName);
2357*cdf0e10cSrcweir 			sal_uInt16 nPos = 0;
2358*cdf0e10cSrcweir 			if (pNames->SearchName( aString, nPos ))
2359*cdf0e10cSrcweir 				return sal_True;
2360*cdf0e10cSrcweir 		}
2361*cdf0e10cSrcweir 	}
2362*cdf0e10cSrcweir 	return sal_False;
2363*cdf0e10cSrcweir }
2364*cdf0e10cSrcweir 
2365*cdf0e10cSrcweir //------------------------------------------------------------------------
2366*cdf0e10cSrcweir 
2367*cdf0e10cSrcweir 
2368*cdf0e10cSrcweir 
2369*cdf0e10cSrcweir 
2370*cdf0e10cSrcweir 
2371