1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dapiuno.cxx,v $
10 * $Revision: 1.21.30.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include <svtools/smplhint.hxx>
39 #include "dapiuno.hxx"
40 #include "datauno.hxx"
41 #include "miscuno.hxx"
43 #include "tabvwsh.hxx"
45 #include "rangeutl.hxx"
46 #include "unoguard.hxx"
47 #include "dpobject.hxx"
48 #include "dpshttab.hxx"
50 #include "dbdocfun.hxx"
51 #include "unonames.hxx"
52 #include "dpgroup.hxx"
53 #include "dpdimsave.hxx"
54 #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
55 #include <com/sun/star/sheet/XLevelsSupplier.hpp>
56 #include <com/sun/star/sheet/XMembersSupplier.hpp>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
59 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
60 #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
61 #include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
63 #include <comphelper/extract.hxx>
65 using namespace com::sun::star
;
67 using ::com::sun::star::lang::IllegalArgumentException
;
68 using ::com::sun::star::sheet::DataPilotFieldFilter
;
69 using ::com::sun::star::sheet::DataPilotTablePositionData
;
70 using ::com::sun::star::uno::Sequence
;
71 using ::com::sun::star::table::CellAddress
;
72 using ::com::sun::star::table::CellRangeAddress
;
73 using ::com::sun::star::uno::RuntimeException
;
74 using ::com::sun::star::uno::Any
;
76 //------------------------------------------------------------------------
78 const SfxItemPropertyMap
* lcl_GetDataPilotDescriptorBaseMap()
80 static SfxItemPropertyMap aDataPilotDescriptorBaseMap_Impl
[] =
82 {MAP_CHAR_LEN(SC_UNO_COLGRAND
), 0, &getBooleanCppuType(), 0, 0 },
83 {MAP_CHAR_LEN(SC_UNO_DRILLDOWN
),0, &getBooleanCppuType(), 0, 0 },
84 {MAP_CHAR_LEN(SC_UNO_IGNEMPROWS
),0, &getBooleanCppuType(), 0, 0 },
85 {MAP_CHAR_LEN(SC_UNO_RPTEMPTY
), 0, &getBooleanCppuType(), 0, 0 },
86 {MAP_CHAR_LEN(SC_UNO_ROWGRAND
), 0, &getBooleanCppuType(), 0, 0 },
87 {MAP_CHAR_LEN(SC_UNO_SHOWFILT
), 0, &getBooleanCppuType(), 0, 0 },
90 return aDataPilotDescriptorBaseMap_Impl
;
93 //------------------------------------------------------------------------
95 const SfxItemPropertyMap
* lcl_GetDataPilotFieldMap()
97 static SfxItemPropertyMap aDataPilotFieldMap_Impl
[] =
99 {MAP_CHAR_LEN(SC_UNONAME_AUTOSHOW
), 0, &getCppuType((sheet::DataPilotFieldAutoShowInfo
*)0),0 | beans::PropertyAttribute::MAYBEVOID
, 0 },
100 {MAP_CHAR_LEN(SC_UNONAME_FUNCTION
), 0, &getCppuType((sheet::GeneralFunction
*)0), 0, 0 },
101 {MAP_CHAR_LEN(SC_UNONAME_GROUPINFO
), 0, &getCppuType((sheet::DataPilotFieldGroupInfo
*)0), 0 | beans::PropertyAttribute::MAYBEVOID
, 0 },
102 {MAP_CHAR_LEN(SC_UNONAME_HASAUTOSHOW
), 0, &getBooleanCppuType(), 0, 0 },
103 {MAP_CHAR_LEN(SC_UNONAME_HASLAYOUTINFO
),0, &getBooleanCppuType(), 0, 0 },
104 {MAP_CHAR_LEN(SC_UNONAME_HASREFERENCE
), 0, &getBooleanCppuType(), 0, 0 },
105 {MAP_CHAR_LEN(SC_UNONAME_HASSORTINFO
), 0, &getBooleanCppuType(), 0, 0 },
106 {MAP_CHAR_LEN(SC_UNONAME_ISGROUP
), 0, &getBooleanCppuType(), 0, 0 },
107 {MAP_CHAR_LEN(SC_UNONAME_LAYOUTINFO
), 0, &getCppuType((sheet::DataPilotFieldLayoutInfo
*)0), 0 | beans::PropertyAttribute::MAYBEVOID
, 0 },
108 {MAP_CHAR_LEN(SC_UNONAME_ORIENT
), 0, &getCppuType((sheet::DataPilotFieldOrientation
*)0), 0 | beans::PropertyAttribute::MAYBEVOID
, 0 },
109 {MAP_CHAR_LEN(SC_UNONAME_REFERENCE
), 0, &getCppuType((sheet::DataPilotFieldReference
*)0), 0 | beans::PropertyAttribute::MAYBEVOID
, 0 },
110 {MAP_CHAR_LEN(SC_UNONAME_SELPAGE
), 0, &getCppuType((rtl::OUString
*)0), 0, 0 },
111 {MAP_CHAR_LEN(SC_UNONAME_SHOWEMPTY
), 0, &getBooleanCppuType(), 0, 0 },
112 {MAP_CHAR_LEN(SC_UNONAME_SORTINFO
), 0, &getCppuType((sheet::DataPilotFieldSortInfo
*)0), 0 | beans::PropertyAttribute::MAYBEVOID
, 0 },
113 {MAP_CHAR_LEN(SC_UNONAME_USESELPAGE
), 0, &getBooleanCppuType(), 0, 0 },
116 return aDataPilotFieldMap_Impl
;
119 const SfxItemPropertyMap
* lcl_GetDataPilotItemMap()
121 static SfxItemPropertyMap aDataPilotItemMap_Impl
[] =
123 {MAP_CHAR_LEN(SC_UNONAME_ISHIDDEN
), 0, &getBooleanCppuType(), 0, 0 },
124 {MAP_CHAR_LEN(SC_UNONAME_POS
), 0, &getCppuType((sal_Int32
*)0), 0, 0 },
125 {MAP_CHAR_LEN(SC_UNONAME_SHOWDETAIL
), 0, &getBooleanCppuType(), 0, 0 },
128 return aDataPilotItemMap_Impl
;
131 //------------------------------------------------------------------------
133 SC_SIMPLE_SERVICE_INFO( ScDataPilotDescriptor
, "ScDataPilotDescriptor", "stardiv::one::sheet::DataPilotDescriptor" )
134 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldObj
, "ScDataPilotFieldObj", "com.sun.star.sheet.DataPilotField" )
135 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldsObj
, "ScDataPilotFieldsObj", "com.sun.star.sheet.DataPilotFields" )
136 SC_SIMPLE_SERVICE_INFO( ScDataPilotTableObj
, "ScDataPilotTableObj", "com.sun.star.sheet.DataPilotTable" )
137 SC_SIMPLE_SERVICE_INFO( ScDataPilotTablesObj
, "ScDataPilotTablesObj", "com.sun.star.sheet.DataPilotTables" )
138 SC_SIMPLE_SERVICE_INFO( ScDataPilotItemsObj
, "ScDataPilotItemsObj", "com.sun.star.sheet.DataPilotItems" )
139 SC_SIMPLE_SERVICE_INFO( ScDataPilotItemObj
, "ScDataPilotItemObj", "com.sun.star.sheet.DataPilotItem" )
141 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupsObj
, "ScDataPilotFieldGroupsObj", "com.sun.star.sheet.DataPilotFieldGroups" )
142 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupObj
, "ScDataPilotFieldGroupObj", "com.sun.star.sheet.DataPilotFieldGroup" )
143 SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupItemObj
, "ScDataPilotFieldGroupItemObj", "com.sun.star.sheet.DataPilotFieldGroupItem" )
145 //------------------------------------------------------------------------
147 //! irgendwann ueberall die neuen enum-Werte benutzen
148 #define DATA_PILOT_HIDDEN sheet::DataPilotFieldOrientation_HIDDEN
149 #define DATA_PILOT_COLUMN sheet::DataPilotFieldOrientation_COLUMN
150 #define DATA_PILOT_ROW sheet::DataPilotFieldOrientation_ROW
151 #define DATA_PILOT_PAGE sheet::DataPilotFieldOrientation_PAGE
152 #define DATA_PILOT_DATA sheet::DataPilotFieldOrientation_DATA
154 //------------------------------------------------------------------------
156 // name that is used in the API for the data layout field
157 #define SC_DATALAYOUT_NAME "Data"
159 //------------------------------------------------------------------------
161 sheet::GeneralFunction
ScDataPilotConversion::FirstFunc( USHORT nBits
)
163 if ( nBits
& PIVOT_FUNC_SUM
) return sheet::GeneralFunction_SUM
;
164 if ( nBits
& PIVOT_FUNC_COUNT
) return sheet::GeneralFunction_COUNT
;
165 if ( nBits
& PIVOT_FUNC_AVERAGE
) return sheet::GeneralFunction_AVERAGE
;
166 if ( nBits
& PIVOT_FUNC_MAX
) return sheet::GeneralFunction_MAX
;
167 if ( nBits
& PIVOT_FUNC_MIN
) return sheet::GeneralFunction_MIN
;
168 if ( nBits
& PIVOT_FUNC_PRODUCT
) return sheet::GeneralFunction_PRODUCT
;
169 if ( nBits
& PIVOT_FUNC_COUNT_NUM
) return sheet::GeneralFunction_COUNTNUMS
;
170 if ( nBits
& PIVOT_FUNC_STD_DEV
) return sheet::GeneralFunction_STDEV
;
171 if ( nBits
& PIVOT_FUNC_STD_DEVP
) return sheet::GeneralFunction_STDEVP
;
172 if ( nBits
& PIVOT_FUNC_STD_VAR
) return sheet::GeneralFunction_VAR
;
173 if ( nBits
& PIVOT_FUNC_STD_VARP
) return sheet::GeneralFunction_VARP
;
174 if ( nBits
& PIVOT_FUNC_AUTO
) return sheet::GeneralFunction_AUTO
;
175 return sheet::GeneralFunction_NONE
;
178 USHORT
ScDataPilotConversion::FunctionBit( sheet::GeneralFunction eFunc
)
180 USHORT nRet
= PIVOT_FUNC_NONE
; // 0
183 case sheet::GeneralFunction_SUM
: nRet
= PIVOT_FUNC_SUM
; break;
184 case sheet::GeneralFunction_COUNT
: nRet
= PIVOT_FUNC_COUNT
; break;
185 case sheet::GeneralFunction_AVERAGE
: nRet
= PIVOT_FUNC_AVERAGE
; break;
186 case sheet::GeneralFunction_MAX
: nRet
= PIVOT_FUNC_MAX
; break;
187 case sheet::GeneralFunction_MIN
: nRet
= PIVOT_FUNC_MIN
; break;
188 case sheet::GeneralFunction_PRODUCT
: nRet
= PIVOT_FUNC_PRODUCT
; break;
189 case sheet::GeneralFunction_COUNTNUMS
: nRet
= PIVOT_FUNC_COUNT_NUM
; break;
190 case sheet::GeneralFunction_STDEV
: nRet
= PIVOT_FUNC_STD_DEV
; break;
191 case sheet::GeneralFunction_STDEVP
: nRet
= PIVOT_FUNC_STD_DEVP
; break;
192 case sheet::GeneralFunction_VAR
: nRet
= PIVOT_FUNC_STD_VAR
; break;
193 case sheet::GeneralFunction_VARP
: nRet
= PIVOT_FUNC_STD_VARP
; break;
194 case sheet::GeneralFunction_AUTO
: nRet
= PIVOT_FUNC_AUTO
; break;
197 // added to avoid warnings
203 //------------------------------------------------------------------------
205 ScDPObject
* lcl_GetDPObject( ScDocShell
* pDocShell
, SCTAB nTab
, const String
& rName
)
209 ScDocument
* pDoc
= pDocShell
->GetDocument();
210 ScDPCollection
* pColl
= pDoc
->GetDPCollection();
213 USHORT nCount
= pColl
->GetCount();
214 for (USHORT i
=0; i
<nCount
; i
++)
216 ScDPObject
* pDPObj
= (*pColl
)[i
];
217 if ( pDPObj
->IsSheetData() &&
218 pDPObj
->GetOutRange().aStart
.Tab() == nTab
&&
219 pDPObj
->GetName() == rName
)
224 return NULL
; // nicht gefunden
227 String
lcl_CreatePivotName( ScDocShell
* pDocShell
)
231 ScDocument
* pDoc
= pDocShell
->GetDocument();
232 ScDPCollection
* pColl
= pDoc
->GetDPCollection();
234 return pColl
->CreateNewName();
236 return String(); // sollte nicht vorkommen
239 sal_Int32
lcl_GetObjectIndex( ScDPObject
* pDPObj
, const ScFieldIdentifier
& rIdent
)
241 // used for items - nRepeat in identifier can be ignored
245 sal_Int32 nCount
= pDPObj
->GetDimCount();
246 for ( sal_Int32 nDim
= 0; nDim
< nCount
; nDim
++ )
248 BOOL bIsDataLayout
= FALSE
;
249 String
aDimName( pDPObj
->GetDimName( nDim
, bIsDataLayout
) );
250 if ( rIdent
.bDataLayoutField
? bIsDataLayout
: ( aDimName
== rIdent
.sFieldName
) )
257 BOOL
lcl_GetMembers( ScDataPilotDescriptorBase
* pParent
, const ScFieldIdentifier
& rIdent
, uno::Reference
<container::XNameAccess
>& xMembers
)
259 ScDPObject
* pDPObj(pParent
->GetDPObject());
260 sal_Int32 nObjIndex
= lcl_GetObjectIndex( pDPObj
, rIdent
);
261 return pDPObj
&& pDPObj
->GetMembersNA( nObjIndex
, xMembers
);
264 //------------------------------------------------------------------------
266 ScDataPilotTablesObj::ScDataPilotTablesObj(ScDocShell
* pDocSh
, SCTAB nT
) :
270 pDocShell
->GetDocument()->AddUnoObject(*this);
273 ScDataPilotTablesObj::~ScDataPilotTablesObj()
276 pDocShell
->GetDocument()->RemoveUnoObject(*this);
279 void ScDataPilotTablesObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
283 if ( rHint
.ISA( SfxSimpleHint
) &&
284 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
286 pDocShell
= NULL
; // ungueltig geworden
292 ScDataPilotTableObj
* ScDataPilotTablesObj::GetObjectByIndex_Impl(SCSIZE nIndex
)
296 ScDocument
* pDoc
= pDocShell
->GetDocument();
297 ScDPCollection
* pColl
= pDoc
->GetDPCollection();
300 // count tables on this sheet
301 // api only handles sheet data at this time
302 //! allow all data sources!!!
304 USHORT nCount
= pColl
->GetCount();
305 for (USHORT i
=0; i
<nCount
; i
++)
307 ScDPObject
* pDPObj
= (*pColl
)[i
];
308 if ( pDPObj
->IsSheetData() && pDPObj
->GetOutRange().aStart
.Tab() == nTab
)
310 if ( nFound
== nIndex
)
312 String aName
= pDPObj
->GetName();
313 return new ScDataPilotTableObj( pDocShell
, nTab
, aName
);
323 ScDataPilotTableObj
* ScDataPilotTablesObj::GetObjectByName_Impl(const rtl::OUString
& aName
)
325 if (hasByName(aName
))
327 String
aNamStr(aName
);
328 return new ScDataPilotTableObj( pDocShell
, nTab
, aNamStr
);
333 uno::Reference
<sheet::XDataPilotDescriptor
> SAL_CALL
ScDataPilotTablesObj::createDataPilotDescriptor()
334 throw(uno::RuntimeException
)
338 return new ScDataPilotDescriptor(pDocShell
);
342 bool lcl_IsDuplicated( const uno::Reference
<beans::XPropertySet
> xDimProps
)
348 uno::Any aAny
= xDimProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ORIGINAL
)));
349 uno::Reference
<container::XNamed
> xOriginal( aAny
, uno::UNO_QUERY
);
350 if ( xOriginal
.is() )
353 catch(uno::Exception
&)
360 rtl::OUString
lcl_GetOriginalName( const uno::Reference
<container::XNamed
> xDim
)
362 uno::Reference
<container::XNamed
> xOriginal
;
364 uno::Reference
<beans::XPropertySet
> xDimProps( xDim
, uno::UNO_QUERY
);
365 if ( xDimProps
.is() )
369 uno::Any aAny
= xDimProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ORIGINAL
)));
372 catch(uno::Exception
&)
377 if ( !xOriginal
.is() )
380 return xOriginal
->getName();
383 void SAL_CALL
ScDataPilotTablesObj::insertNewByName( const rtl::OUString
& aNewName
,
384 const table::CellAddress
& aOutputAddress
,
385 const uno::Reference
<sheet::XDataPilotDescriptor
>& xDescriptor
)
386 throw(uno::RuntimeException
)
389 if (!xDescriptor
.is()) return;
391 // inserting with already existing name?
392 if ( aNewName
.getLength() && hasByName( aNewName
) )
393 throw uno::RuntimeException(); // no other exceptions specified
396 ScDataPilotDescriptorBase
* pImp
= ScDataPilotDescriptorBase::getImplementation( xDescriptor
);
397 if ( pDocShell
&& pImp
)
399 ScDPObject
* pNewObj
= pImp
->GetDPObject();
403 ScRange
aOutputRange((SCCOL
)aOutputAddress
.Column
, (SCROW
)aOutputAddress
.Row
, (SCTAB
)aOutputAddress
.Sheet
,
404 (SCCOL
)aOutputAddress
.Column
, (SCROW
)aOutputAddress
.Row
, (SCTAB
)aOutputAddress
.Sheet
);
405 pNewObj
->SetOutRange(aOutputRange
);
406 String aName
= aNewName
;
408 aName
= lcl_CreatePivotName( pDocShell
);
409 pNewObj
->SetName(aName
);
410 String aTag
= xDescriptor
->getTag();
411 pNewObj
->SetTag(aTag
);
413 // todo: handle double fields (for more information see ScDPObject
415 ScDBDocFunc
aFunc(*pDocShell
);
416 bDone
= aFunc
.DataPilotUpdate( NULL
, pNewObj
, TRUE
, TRUE
);
421 throw uno::RuntimeException(); // no other exceptions specified
424 void SAL_CALL
ScDataPilotTablesObj::removeByName( const rtl::OUString
& aName
)
425 throw(uno::RuntimeException
)
428 String
aNameStr(aName
);
429 ScDPObject
* pDPObj
= lcl_GetDPObject( pDocShell
, nTab
, aNameStr
);
430 if (pDPObj
&& pDocShell
)
432 ScDBDocFunc
aFunc(*pDocShell
);
433 aFunc
.DataPilotUpdate( pDPObj
, NULL
, TRUE
, TRUE
); // remove - incl. undo etc.
436 throw uno::RuntimeException(); // no other exceptions specified
439 // XEnumerationAccess
441 uno::Reference
<container::XEnumeration
> SAL_CALL
ScDataPilotTablesObj::createEnumeration()
442 throw(uno::RuntimeException
)
445 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotTablesEnumeration")));
450 sal_Int32 SAL_CALL
ScDataPilotTablesObj::getCount() throw(uno::RuntimeException
)
455 ScDocument
* pDoc
= pDocShell
->GetDocument();
456 ScDPCollection
* pColl
= pDoc
->GetDPCollection();
459 // count tables on this sheet
460 // api only handles sheet data at this time
461 //! allow all data sources!!!
464 USHORT nCount
= pColl
->GetCount();
465 for (USHORT i
=0; i
<nCount
; i
++)
467 ScDPObject
* pDPObj
= (*pColl
)[i
];
468 if ( pDPObj
->IsSheetData() && pDPObj
->GetOutRange().aStart
.Tab() == nTab
)
478 uno::Any SAL_CALL
ScDataPilotTablesObj::getByIndex( sal_Int32 nIndex
)
479 throw(lang::IndexOutOfBoundsException
,
480 lang::WrappedTargetException
, uno::RuntimeException
)
483 uno::Reference
<sheet::XDataPilotTable2
> xTable(GetObjectByIndex_Impl(static_cast<SCSIZE
>(nIndex
)));
485 return uno::makeAny(xTable
);
487 throw lang::IndexOutOfBoundsException();
488 // return uno::Any();
491 uno::Type SAL_CALL
ScDataPilotTablesObj::getElementType() throw(uno::RuntimeException
)
494 return getCppuType((uno::Reference
<sheet::XDataPilotTable2
>*)0);
497 sal_Bool SAL_CALL
ScDataPilotTablesObj::hasElements() throw(uno::RuntimeException
)
500 return ( getCount() != 0 );
505 uno::Any SAL_CALL
ScDataPilotTablesObj::getByName( const rtl::OUString
& aName
)
506 throw(container::NoSuchElementException
,
507 lang::WrappedTargetException
, uno::RuntimeException
)
510 uno::Reference
<sheet::XDataPilotTable2
> xTable(GetObjectByName_Impl(aName
));
512 return uno::makeAny(xTable
);
514 throw container::NoSuchElementException();
515 // return uno::Any();
518 uno::Sequence
<rtl::OUString
> SAL_CALL
ScDataPilotTablesObj::getElementNames()
519 throw(uno::RuntimeException
)
524 ScDocument
* pDoc
= pDocShell
->GetDocument();
525 ScDPCollection
* pColl
= pDoc
->GetDPCollection();
528 // count tables on this sheet
529 // api only handles sheet data at this time
530 //! allow all data sources!!!
533 USHORT nCount
= pColl
->GetCount();
535 for (i
=0; i
<nCount
; i
++)
537 ScDPObject
* pDPObj
= (*pColl
)[i
];
538 if ( pDPObj
->IsSheetData() && pDPObj
->GetOutRange().aStart
.Tab() == nTab
)
543 uno::Sequence
<rtl::OUString
> aSeq(nFound
);
544 rtl::OUString
* pAry
= aSeq
.getArray();
545 for (i
=0; i
<nCount
; i
++)
547 ScDPObject
* pDPObj
= (*pColl
)[i
];
548 if ( pDPObj
->IsSheetData() && pDPObj
->GetOutRange().aStart
.Tab() == nTab
)
549 pAry
[nPos
++] = pDPObj
->GetName();
555 return uno::Sequence
<rtl::OUString
>(0);
558 sal_Bool SAL_CALL
ScDataPilotTablesObj::hasByName( const rtl::OUString
& aName
)
559 throw(uno::RuntimeException
)
564 ScDocument
* pDoc
= pDocShell
->GetDocument();
565 ScDPCollection
* pColl
= pDoc
->GetDPCollection();
568 String
aNamStr(aName
);
569 USHORT nCount
= pColl
->GetCount();
570 for (USHORT i
=0; i
<nCount
; i
++)
572 // api only handles sheet data at this time
573 //! allow all data sources!!!
575 ScDPObject
* pDPObj
= (*pColl
)[i
];
576 if ( pDPObj
->IsSheetData() &&
577 pDPObj
->GetOutRange().aStart
.Tab() == nTab
&&
578 pDPObj
->GetName() == aNamStr
)
586 //------------------------------------------------------------------------
588 ScDataPilotDescriptorBase::ScDataPilotDescriptorBase(ScDocShell
* pDocSh
) :
589 aPropSet( lcl_GetDataPilotDescriptorBaseMap() ),
592 pDocShell
->GetDocument()->AddUnoObject(*this);
595 ScDataPilotDescriptorBase::~ScDataPilotDescriptorBase()
598 pDocShell
->GetDocument()->RemoveUnoObject(*this);
601 uno::Any SAL_CALL
ScDataPilotDescriptorBase::queryInterface( const uno::Type
& rType
)
602 throw(uno::RuntimeException
)
604 SC_QUERYINTERFACE( sheet::XDataPilotDescriptor
)
605 SC_QUERYINTERFACE( beans::XPropertySet
)
606 SC_QUERYINTERFACE( container::XNamed
) // base of XDataPilotDescriptor
607 SC_QUERYINTERFACE( lang::XUnoTunnel
)
608 SC_QUERYINTERFACE( lang::XTypeProvider
)
609 SC_QUERYINTERFACE( lang::XServiceInfo
)
611 return OWeakObject::queryInterface( rType
);
614 void SAL_CALL
ScDataPilotDescriptorBase::acquire() throw()
616 OWeakObject::acquire();
619 void SAL_CALL
ScDataPilotDescriptorBase::release() throw()
621 OWeakObject::release();
624 uno::Sequence
<uno::Type
> SAL_CALL
ScDataPilotDescriptorBase::getTypes()
625 throw(uno::RuntimeException
)
627 static uno::Sequence
<uno::Type
> aTypes
;
628 if ( aTypes
.getLength() == 0 )
631 uno::Type
* pPtr
= aTypes
.getArray();
632 pPtr
[0] = getCppuType((const uno::Reference
<sheet::XDataPilotDescriptor
>*)0);
633 pPtr
[1] = getCppuType((const uno::Reference
<beans::XPropertySet
>*)0);
634 pPtr
[2] = getCppuType((const uno::Reference
<lang::XUnoTunnel
>*)0);
635 pPtr
[3] = getCppuType((const uno::Reference
<lang::XTypeProvider
>*)0);
636 pPtr
[4] = getCppuType((const uno::Reference
<lang::XServiceInfo
>*)0);
641 uno::Sequence
<sal_Int8
> SAL_CALL
ScDataPilotDescriptorBase::getImplementationId()
642 throw(uno::RuntimeException
)
644 static uno::Sequence
< sal_Int8
> aId
;
645 if( aId
.getLength() == 0 )
648 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
653 void ScDataPilotDescriptorBase::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
657 if ( rHint
.ISA( SfxSimpleHint
) &&
658 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
660 pDocShell
= NULL
; // ungueltig geworden
664 // XDataPilotDescriptor
666 table::CellRangeAddress SAL_CALL
ScDataPilotDescriptorBase::getSourceRange()
667 throw(uno::RuntimeException
)
671 table::CellRangeAddress aRet
;
673 ScDPObject
* pDPObject(GetDPObject());
674 if (pDPObject
&& pDPObject
->IsSheetData())
676 const ScSheetSourceDesc
* pSheetDesc
= pDPObject
->GetSheetDesc();
677 aRet
.StartColumn
= pSheetDesc
->aSourceRange
.aStart
.Col();
678 aRet
.EndColumn
= pSheetDesc
->aSourceRange
.aEnd
.Col();
679 aRet
.StartRow
= pSheetDesc
->aSourceRange
.aStart
.Row();
680 aRet
.EndRow
= pSheetDesc
->aSourceRange
.aEnd
.Row();
681 aRet
.Sheet
= pSheetDesc
->aSourceRange
.aStart
.Tab();
684 throw uno::RuntimeException();
689 void SAL_CALL
ScDataPilotDescriptorBase::setSourceRange(
690 const table::CellRangeAddress
& aSourceRange
)
691 throw(uno::RuntimeException
)
695 ScDPObject
* pDPObject
= GetDPObject();
698 ScSheetSourceDesc aSheetDesc
;
699 if (pDPObject
->IsSheetData())
700 aSheetDesc
= *(pDPObject
->GetSheetDesc());
701 aSheetDesc
.aSourceRange
.aStart
.SetCol((SCCOL
)aSourceRange
.StartColumn
);
702 aSheetDesc
.aSourceRange
.aEnd
.SetCol((SCCOL
)aSourceRange
.EndColumn
);
703 aSheetDesc
.aSourceRange
.aStart
.SetRow((SCROW
)aSourceRange
.StartRow
);
704 aSheetDesc
.aSourceRange
.aEnd
.SetRow((SCROW
)aSourceRange
.EndRow
);
705 aSheetDesc
.aSourceRange
.aStart
.SetTab((SCTAB
)aSourceRange
.Sheet
);
706 pDPObject
->SetSheetDesc(aSheetDesc
);
707 SetDPObject(pDPObject
);
710 throw uno::RuntimeException();
713 uno::Reference
<sheet::XSheetFilterDescriptor
> SAL_CALL
ScDataPilotDescriptorBase::getFilterDescriptor()
714 throw(uno::RuntimeException
)
717 return new ScDataPilotFilterDescriptor( pDocShell
, this );
720 uno::Reference
<container::XIndexAccess
> SAL_CALL
ScDataPilotDescriptorBase::getDataPilotFields()
721 throw(uno::RuntimeException
)
724 return new ScDataPilotFieldsObj( this, SC_FIELDORIENT_ALL
);
727 uno::Reference
<container::XIndexAccess
> SAL_CALL
ScDataPilotDescriptorBase::getColumnFields()
728 throw(uno::RuntimeException
)
731 return new ScDataPilotFieldsObj( this, DATA_PILOT_COLUMN
);
734 uno::Reference
<container::XIndexAccess
> SAL_CALL
ScDataPilotDescriptorBase::getRowFields()
735 throw(uno::RuntimeException
)
738 return new ScDataPilotFieldsObj( this, DATA_PILOT_ROW
);
741 uno::Reference
<container::XIndexAccess
> SAL_CALL
ScDataPilotDescriptorBase::getPageFields()
742 throw(uno::RuntimeException
)
745 return new ScDataPilotFieldsObj( this, DATA_PILOT_PAGE
);
748 uno::Reference
<container::XIndexAccess
> SAL_CALL
ScDataPilotDescriptorBase::getDataFields()
749 throw(uno::RuntimeException
)
752 return new ScDataPilotFieldsObj( this, DATA_PILOT_DATA
);
755 uno::Reference
<container::XIndexAccess
> SAL_CALL
ScDataPilotDescriptorBase::getHiddenFields()
756 throw(uno::RuntimeException
)
759 return new ScDataPilotFieldsObj( this, DATA_PILOT_HIDDEN
);
763 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
ScDataPilotDescriptorBase::getPropertySetInfo( )
764 throw(uno::RuntimeException
)
767 static uno::Reference
<beans::XPropertySetInfo
> aRef
=
768 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() );
772 void SAL_CALL
ScDataPilotDescriptorBase::setPropertyValue( const ::rtl::OUString
& aPropertyName
,
773 const ::com::sun::star::uno::Any
& aValue
)
774 throw(beans::UnknownPropertyException
,
775 beans::PropertyVetoException
,
776 lang::IllegalArgumentException
,
777 lang::WrappedTargetException
,
778 uno::RuntimeException
)
781 ScDPObject
* pDPObject
= GetDPObject();
784 ScDPSaveData
* pOldData
= pDPObject
->GetSaveData();
785 DBG_ASSERT(pOldData
, "Here should be a SaveData");
788 ScDPSaveData
aNewData( *pOldData
);
790 String aNameString
= aPropertyName
;
791 if ( aNameString
.EqualsAscii( SC_UNO_COLGRAND
) )
793 aNewData
.SetColumnGrand(::cppu::any2bool( aValue
));
795 else if ( aNameString
.EqualsAscii( SC_UNO_IGNEMPROWS
) )
797 aNewData
.SetIgnoreEmptyRows(::cppu::any2bool( aValue
));
799 else if ( aNameString
.EqualsAscii( SC_UNO_RPTEMPTY
) )
801 aNewData
.SetRepeatIfEmpty(::cppu::any2bool( aValue
));
803 else if ( aNameString
.EqualsAscii( SC_UNO_ROWGRAND
) )
805 aNewData
.SetRowGrand(::cppu::any2bool( aValue
));
807 else if ( aNameString
.EqualsAscii( SC_UNO_SHOWFILT
) )
809 aNewData
.SetFilterButton(::cppu::any2bool( aValue
));
811 else if ( aNameString
.EqualsAscii( SC_UNO_DRILLDOWN
) )
813 aNewData
.SetDrillDown(::cppu::any2bool( aValue
));
816 throw beans::UnknownPropertyException();
818 pDPObject
->SetSaveData( aNewData
);
821 SetDPObject(pDPObject
);
825 uno::Any SAL_CALL
ScDataPilotDescriptorBase::getPropertyValue(const ::rtl::OUString
& aPropertyName
)
826 throw(beans::UnknownPropertyException
,
827 lang::WrappedTargetException
,
828 uno::RuntimeException
)
833 ScDPObject
* pDPObject(GetDPObject());
836 ScDPSaveData
* pOldData
= pDPObject
->GetSaveData();
837 DBG_ASSERT(pOldData
, "Here should be a SaveData");
840 ScDPSaveData
aNewData( *pOldData
);
842 String aNameString
= aPropertyName
;
843 if ( aNameString
.EqualsAscii( SC_UNO_COLGRAND
) )
845 aRet
= ::cppu::bool2any( aNewData
.GetColumnGrand() );
847 else if ( aNameString
.EqualsAscii( SC_UNO_IGNEMPROWS
) )
849 aRet
= ::cppu::bool2any( aNewData
.GetIgnoreEmptyRows() );
851 else if ( aNameString
.EqualsAscii( SC_UNO_RPTEMPTY
) )
853 aRet
= ::cppu::bool2any( aNewData
.GetRepeatIfEmpty() );
855 else if ( aNameString
.EqualsAscii( SC_UNO_ROWGRAND
) )
857 aRet
= ::cppu::bool2any( aNewData
.GetRowGrand() );
859 else if ( aNameString
.EqualsAscii( SC_UNO_SHOWFILT
) )
861 aRet
= ::cppu::bool2any( aNewData
.GetFilterButton() );
863 else if ( aNameString
.EqualsAscii( SC_UNO_DRILLDOWN
) )
865 aRet
= ::cppu::bool2any( aNewData
.GetDrillDown() );
868 throw beans::UnknownPropertyException();
875 void SAL_CALL
ScDataPilotDescriptorBase::addPropertyChangeListener( const ::rtl::OUString
& /* aPropertyName */,
876 const uno::Reference
<beans::XPropertyChangeListener
>& /* xListener */ )
877 throw(beans::UnknownPropertyException
,
878 lang::WrappedTargetException
,
879 uno::RuntimeException
)
883 void SAL_CALL
ScDataPilotDescriptorBase::removePropertyChangeListener( const ::rtl::OUString
& /* aPropertyName */,
884 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */ )
885 throw(beans::UnknownPropertyException
,
886 lang::WrappedTargetException
,
887 uno::RuntimeException
)
891 void SAL_CALL
ScDataPilotDescriptorBase::addVetoableChangeListener( const ::rtl::OUString
& /* PropertyName */,
892 const uno::Reference
<beans::XVetoableChangeListener
>& /* aListener */ )
893 throw(beans::UnknownPropertyException
,
894 lang::WrappedTargetException
,
895 uno::RuntimeException
)
899 void SAL_CALL
ScDataPilotDescriptorBase::removeVetoableChangeListener( const ::rtl::OUString
& /* PropertyName */,
900 const uno::Reference
<beans::XVetoableChangeListener
>& /* aListener */ )
901 throw(beans::UnknownPropertyException
,
902 lang::WrappedTargetException
,
903 uno::RuntimeException
)
909 sal_Int64 SAL_CALL
ScDataPilotDescriptorBase::getSomething(
910 const uno::Sequence
<sal_Int8
>& rId
) throw(uno::RuntimeException
)
912 if ( rId
.getLength() == 16 &&
913 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
914 rId
.getConstArray(), 16 ) )
916 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
922 const uno::Sequence
<sal_Int8
>& ScDataPilotDescriptorBase::getUnoTunnelId()
924 static uno::Sequence
<sal_Int8
> * pSeq
= 0;
927 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
930 static uno::Sequence
< sal_Int8
> aSeq( 16 );
931 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
939 ScDataPilotDescriptorBase
* ScDataPilotDescriptorBase::getImplementation(
940 const uno::Reference
<sheet::XDataPilotDescriptor
> xObj
)
942 ScDataPilotDescriptorBase
* pRet
= NULL
;
943 uno::Reference
<lang::XUnoTunnel
> xUT( xObj
, uno::UNO_QUERY
);
945 pRet
= reinterpret_cast<ScDataPilotDescriptorBase
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething(getUnoTunnelId())));
949 //------------------------------------------------------------------------
951 ScDataPilotTableObj::ScDataPilotTableObj(ScDocShell
* pDocSh
, SCTAB nT
, const String
& rN
) :
952 ScDataPilotDescriptorBase( pDocSh
),
958 ScDataPilotTableObj::~ScDataPilotTableObj()
962 uno::Any SAL_CALL
ScDataPilotTableObj::queryInterface( const uno::Type
& rType
)
963 throw(uno::RuntimeException
)
965 // since we manually do resolve the query for XDataPilotTable2
966 // we also need to do the same for XDataPilotTable
967 SC_QUERYINTERFACE( sheet::XDataPilotTable
)
968 SC_QUERYINTERFACE( sheet::XDataPilotTable2
)
970 return ScDataPilotDescriptorBase::queryInterface( rType
);
973 void SAL_CALL
ScDataPilotTableObj::acquire() throw()
975 ScDataPilotDescriptorBase::acquire();
978 void SAL_CALL
ScDataPilotTableObj::release() throw()
980 ScDataPilotDescriptorBase::release();
983 uno::Sequence
<uno::Type
> SAL_CALL
ScDataPilotTableObj::getTypes()
984 throw(uno::RuntimeException
)
986 static uno::Sequence
<uno::Type
> aTypes
;
987 if ( aTypes
.getLength() == 0 )
989 uno::Sequence
<uno::Type
> aParentTypes(ScDataPilotDescriptorBase::getTypes());
990 long nParentLen
= aParentTypes
.getLength();
991 const uno::Type
* pParentPtr
= aParentTypes
.getConstArray();
993 aTypes
.realloc( nParentLen
+ 1 );
994 uno::Type
* pPtr
= aTypes
.getArray();
995 pPtr
[nParentLen
+ 0] = getCppuType((const uno::Reference
<sheet::XDataPilotTable2
>*)0);
997 for (long i
=0; i
<nParentLen
; i
++)
998 pPtr
[i
] = pParentPtr
[i
]; // parent types first
1003 uno::Sequence
<sal_Int8
> SAL_CALL
ScDataPilotTableObj::getImplementationId()
1004 throw(uno::RuntimeException
)
1006 static uno::Sequence
< sal_Int8
> aId
;
1007 if( aId
.getLength() == 0 )
1010 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
1016 ScDPObject
* ScDataPilotTableObj::GetDPObject() const
1018 return lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1021 void ScDataPilotTableObj::SetDPObject( ScDPObject
* pDPObject
)
1023 ScDocShell
* pDocSh
= GetDocShell();
1024 ScDPObject
* pDPObj
= lcl_GetDPObject(pDocSh
, nTab
, aName
);
1025 if ( pDPObj
&& pDocSh
)
1027 ScDBDocFunc
aFunc(*pDocSh
);
1028 aFunc
.DataPilotUpdate( pDPObj
, pDPObject
, TRUE
, TRUE
);
1032 // "rest of XDataPilotDescriptor"
1034 rtl::OUString SAL_CALL
ScDataPilotTableObj::getName() throw(uno::RuntimeException
)
1037 ScDPObject
* pDPObj
= lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1039 return pDPObj
->GetName();
1040 return rtl::OUString();
1043 void SAL_CALL
ScDataPilotTableObj::setName( const rtl::OUString
& aNewName
)
1044 throw(uno::RuntimeException
)
1047 ScDPObject
* pDPObj
= lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1050 //! test for existing names !!!
1052 String
aString(aNewName
);
1053 pDPObj
->SetName( aString
); //! Undo - DBDocFunc ???
1056 // DataPilotUpdate would do too much (output table is not changed)
1057 GetDocShell()->SetDocumentModified();
1061 rtl::OUString SAL_CALL
ScDataPilotTableObj::getTag() throw(uno::RuntimeException
)
1064 ScDPObject
* pDPObj
= lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1066 return pDPObj
->GetTag();
1067 return rtl::OUString();
1070 void SAL_CALL
ScDataPilotTableObj::setTag( const ::rtl::OUString
& aNewTag
)
1071 throw(uno::RuntimeException
)
1074 ScDPObject
* pDPObj
= lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1077 String
aString(aNewTag
);
1078 pDPObj
->SetTag( aString
); //! Undo - DBDocFunc ???
1080 // DataPilotUpdate would do too much (output table is not changed)
1081 GetDocShell()->SetDocumentModified();
1087 table::CellRangeAddress SAL_CALL
ScDataPilotTableObj::getOutputRange()
1088 throw(uno::RuntimeException
)
1091 table::CellRangeAddress aRet
;
1092 ScDPObject
* pDPObj
= lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1095 ScRange
aRange(pDPObj
->GetOutRange());
1096 aRet
.Sheet
= aRange
.aStart
.Tab();
1097 aRet
.StartColumn
= aRange
.aStart
.Col();
1098 aRet
.StartRow
= aRange
.aStart
.Row();
1099 aRet
.EndColumn
= aRange
.aEnd
.Col();
1100 aRet
.EndRow
= aRange
.aEnd
.Row();
1105 void SAL_CALL
ScDataPilotTableObj::refresh() throw(uno::RuntimeException
)
1108 ScDPObject
* pDPObj
= lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1111 ScDPObject
* pNew
= new ScDPObject(*pDPObj
);
1112 ScDBDocFunc
aFunc(*GetDocShell());
1113 aFunc
.DataPilotUpdate( pDPObj
, pNew
, TRUE
, TRUE
);
1114 delete pNew
; // DataPilotUpdate copies settings from "new" object
1118 Sequence
< Sequence
<Any
> > SAL_CALL
ScDataPilotTableObj::getDrillDownData(const CellAddress
& aAddr
)
1119 throw (RuntimeException
)
1122 Sequence
< Sequence
<Any
> > aTabData
;
1123 ScAddress
aAddr2(static_cast<SCCOL
>(aAddr
.Column
), static_cast<SCROW
>(aAddr
.Row
), aAddr
.Sheet
);
1124 ScDPObject
* pObj
= GetDPObject();
1126 throw RuntimeException();
1128 pObj
->GetDrillDownData(aAddr2
, aTabData
);
1132 DataPilotTablePositionData SAL_CALL
ScDataPilotTableObj::getPositionData(const CellAddress
& aAddr
)
1133 throw (RuntimeException
)
1136 DataPilotTablePositionData aPosData
;
1137 ScAddress
aAddr2(static_cast<SCCOL
>(aAddr
.Column
), static_cast<SCROW
>(aAddr
.Row
), aAddr
.Sheet
);
1138 ScDPObject
* pObj
= GetDPObject();
1140 throw RuntimeException();
1142 pObj
->GetPositionData(aAddr2
, aPosData
);
1146 void SAL_CALL
ScDataPilotTableObj::insertDrillDownSheet(const CellAddress
& aAddr
)
1147 throw (RuntimeException
)
1150 ScDPObject
* pDPObj
= GetDPObject();
1152 throw RuntimeException();
1154 Sequence
<DataPilotFieldFilter
> aFilters
;
1155 pDPObj
->GetDataFieldPositionData(
1156 ScAddress(static_cast<SCCOL
>(aAddr
.Column
), static_cast<SCROW
>(aAddr
.Row
), aAddr
.Sheet
), aFilters
);
1157 GetDocShell()->GetBestViewShell()->ShowDataPilotSourceData(*pDPObj
, aFilters
);
1160 CellRangeAddress SAL_CALL
ScDataPilotTableObj::getOutputRangeByType( sal_Int32 nType
)
1161 throw (IllegalArgumentException
, RuntimeException
)
1164 if (nType
< 0 || nType
> ::com::sun::star::sheet::DataPilotOutputRangeType::RESULT
)
1165 throw IllegalArgumentException();
1167 table::CellRangeAddress aRet
;
1168 ScDPObject
* pDPObj
= lcl_GetDPObject(GetDocShell(), nTab
, aName
);
1172 const ScRange aRange
= pDPObj
->GetOutputRangeByType(nType
);
1173 aRet
.Sheet
= aRange
.aStart
.Tab();
1174 aRet
.StartColumn
= aRange
.aStart
.Col();
1175 aRet
.StartRow
= aRange
.aStart
.Row();
1176 aRet
.EndColumn
= aRange
.aEnd
.Col();
1177 aRet
.EndRow
= aRange
.aEnd
.Row();
1182 //------------------------------------------------------------------------
1184 ScDataPilotDescriptor::ScDataPilotDescriptor(ScDocShell
* pDocSh
) :
1185 ScDataPilotDescriptorBase( pDocSh
),
1186 mpDPObject(new ScDPObject(pDocSh
? pDocSh
->GetDocument() : NULL
) )
1188 mpDPObject
->SetAlive(sal_True
);
1189 ScDPSaveData aSaveData
;
1190 // set defaults like in ScPivotParam constructor
1191 aSaveData
.SetColumnGrand( sal_True
);
1192 aSaveData
.SetRowGrand( sal_True
);
1193 aSaveData
.SetIgnoreEmptyRows( sal_False
);
1194 aSaveData
.SetRepeatIfEmpty( sal_False
);
1195 mpDPObject
->SetSaveData(aSaveData
);
1196 ScSheetSourceDesc aSheetDesc
;
1197 mpDPObject
->SetSheetDesc(aSheetDesc
);
1198 mpDPObject
->GetSource();
1201 ScDataPilotDescriptor::~ScDataPilotDescriptor()
1206 ScDPObject
* ScDataPilotDescriptor::GetDPObject() const
1211 void ScDataPilotDescriptor::SetDPObject( ScDPObject
* pDPObject
)
1213 if (mpDPObject
!= pDPObject
)
1216 mpDPObject
= pDPObject
;
1217 DBG_ERROR("replace DPObject should not happen");
1221 // "rest of XDataPilotDescriptor"
1223 rtl::OUString SAL_CALL
ScDataPilotDescriptor::getName() throw(uno::RuntimeException
)
1226 return mpDPObject
->GetName();
1229 void SAL_CALL
ScDataPilotDescriptor::setName( const rtl::OUString
& aNewName
)
1230 throw(uno::RuntimeException
)
1233 mpDPObject
->SetName( aNewName
);
1236 rtl::OUString SAL_CALL
ScDataPilotDescriptor::getTag() throw(uno::RuntimeException
)
1239 return mpDPObject
->GetTag();
1242 void SAL_CALL
ScDataPilotDescriptor::setTag( const ::rtl::OUString
& aNewTag
)
1243 throw(uno::RuntimeException
)
1246 mpDPObject
->SetTag( aNewTag
);
1249 //------------------------------------------------------------------------
1251 ScDataPilotFieldsObj::ScDataPilotFieldsObj(ScDataPilotDescriptorBase
* pPar
, USHORT nTy
) :
1258 ScDataPilotFieldsObj::~ScDataPilotFieldsObj()
1263 BOOL
lcl_GetDim(ScDPObject
* pDPObj
, const ScFieldIdentifier
& rIdent
, ScDPSaveDimension
*& rpDim
)
1266 ScDPSaveData
* pSave
= pDPObj
->GetSaveData();
1269 if ( rIdent
.bDataLayoutField
)
1271 rpDim
= pSave
->GetDataLayoutDimension();
1274 else if ( rIdent
.nRepeat
== 0 )
1276 rpDim
= pSave
->GetDimensionByName( rIdent
.sFieldName
);
1281 // count all dimensions with the given name
1283 String
aNameStr( rIdent
.sFieldName
);
1284 const List
& rDimensions
= pSave
->GetDimensions();
1285 sal_Int32 nDimCount
= rDimensions
.Count();
1286 sal_Int32 nFound
= 0;
1287 for ( sal_Int32 nDim
= 0; nDim
< nDimCount
&& !bRet
; nDim
++ )
1289 ScDPSaveDimension
* pOneDim
= static_cast<ScDPSaveDimension
*>(rDimensions
.GetObject(nDim
));
1290 if ( !pOneDim
->IsDataLayout() && pOneDim
->GetName() == aNameStr
)
1292 if ( nFound
== rIdent
.nRepeat
)
1306 SCSIZE
lcl_GetFieldCount( const com::sun::star::uno::Reference
<com::sun::star::sheet::XDimensionsSupplier
>& rSource
, USHORT nType
)
1310 uno::Reference
<container::XNameAccess
> xDimsName(rSource
->getDimensions());
1311 uno::Reference
<container::XIndexAccess
> xIntDims(new ScNameToIndexAccess( xDimsName
));
1312 sal_Int32 nIntCount
= xIntDims
->getCount();
1313 if (nType
!= SC_FIELDORIENT_ALL
)
1315 // all fields of the specified orientation, including duplicated
1317 uno::Reference
<beans::XPropertySet
> xDim
;
1318 sheet::DataPilotFieldOrientation aOrient
;
1319 for (sal_Int32 i
= 0; i
< nIntCount
; ++i
)
1321 xDim
.set(xIntDims
->getByIndex(i
), uno::UNO_QUERY
);
1324 xDim
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ORIENTAT
))) >>= aOrient
;
1325 if (aOrient
== nType
)
1332 // count all non-duplicated fields
1334 uno::Reference
<beans::XPropertySet
> xDim
;
1335 for (sal_Int32 i
= 0; i
< nIntCount
; ++i
)
1337 xDim
.set(xIntDims
->getByIndex(i
), uno::UNO_QUERY
);
1338 if ( xDim
.is() && !lcl_IsDuplicated( xDim
) )
1346 BOOL
lcl_GetFieldDataByIndex( const com::sun::star::uno::Reference
<com::sun::star::sheet::XDimensionsSupplier
>& rSource
,
1347 USHORT nType
, SCSIZE nIndex
, ScFieldIdentifier
& rField
)
1351 sal_Int32 nDimIndex
= 0;
1353 uno::Reference
<container::XNameAccess
> xDimsName(rSource
->getDimensions());
1354 uno::Reference
<container::XIndexAccess
> xIntDims(new ScNameToIndexAccess( xDimsName
));
1355 sal_Int32 nIntCount
= xIntDims
->getCount();
1356 uno::Reference
<beans::XPropertySet
> xDim
;
1357 if (nType
!= SC_FIELDORIENT_ALL
)
1359 sheet::DataPilotFieldOrientation aOrient
;
1361 while (i
< nIntCount
&& !bOk
)
1363 xDim
.set(xIntDims
->getByIndex(i
), uno::UNO_QUERY
);
1366 xDim
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ORIENTAT
))) >>= aOrient
;
1367 if (aOrient
== nType
)
1384 while (i
< nIntCount
&& !bOk
)
1386 xDim
.set(xIntDims
->getByIndex(i
), uno::UNO_QUERY
);
1387 if ( xDim
.is() && !lcl_IsDuplicated( xDim
) )
1403 xDim
.set( xIntDims
->getByIndex(nDimIndex
), uno::UNO_QUERY
);
1404 uno::Reference
<container::XNamed
> xDimName( xDim
, uno::UNO_QUERY
);
1405 if ( xDimName
.is() )
1407 rtl::OUString
sOriginalName( lcl_GetOriginalName( xDimName
) );
1408 rField
.sFieldName
= sOriginalName
;
1409 rField
.bDataLayoutField
= ScUnoHelpFunctions::GetBoolProperty( xDim
,
1410 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ISDATALA
)) );
1412 sal_Int32 nRepeat
= 0;
1413 if ( nType
!= SC_FIELDORIENT_ALL
&& lcl_IsDuplicated( xDim
) )
1415 // find the repeat count
1416 // (this relies on the original dimension always being before the duplicates)
1418 uno::Reference
<container::XNamed
> xPrevName
;
1419 for (sal_Int32 i
= 0; i
< nDimIndex
; ++i
)
1421 xPrevName
.set( xIntDims
->getByIndex(i
), uno::UNO_QUERY
);
1422 if ( xPrevName
.is() && lcl_GetOriginalName( xPrevName
) == sOriginalName
)
1426 rField
.nRepeat
= nRepeat
;
1435 BOOL
lcl_GetFieldDataByName( ScDPObject
* pDPObj
, USHORT
/* nType */, const rtl::OUString
& sName
, ScFieldIdentifier
& rField
)
1437 // "By name" is always the first match.
1438 // The name "Data" always refers to the data layout field.
1439 rField
.sFieldName
= sName
;
1440 rField
.bDataLayoutField
= sName
.equalsAscii( SC_DATALAYOUT_NAME
);
1443 pDPObj
->GetSource(); // IsDimNameInUse doesn't update source data
1445 // check if the named field exists (not for data layout)
1446 return ( rField
.bDataLayoutField
|| pDPObj
->IsDimNameInUse( sName
) );
1451 ScDataPilotFieldObj
* ScDataPilotFieldsObj::GetObjectByIndex_Impl(SCSIZE nIndex
) const
1453 ScDPObject
* pObj
= pParent
->GetDPObject();
1458 ScFieldIdentifier aSourceIdent
;
1459 BOOL bOk
= lcl_GetFieldDataByIndex( pObj
->GetSource(), nType
, nIndex
, aSourceIdent
);
1462 return new ScDataPilotFieldObj( pParent
, nType
, aSourceIdent
);
1468 ScDataPilotFieldObj
* ScDataPilotFieldsObj::GetObjectByName_Impl(const rtl::OUString
& aName
) const
1470 ScDPObject
* pDPObj(pParent
->GetDPObject());
1473 ScFieldIdentifier aSourceIdent
;
1474 if (lcl_GetFieldDataByName( pDPObj
, nType
, aName
, aSourceIdent
))
1476 return new ScDataPilotFieldObj( pParent
, nType
, aSourceIdent
);
1482 // XEnumerationAccess
1484 uno::Reference
<container::XEnumeration
> SAL_CALL
ScDataPilotFieldsObj::createEnumeration()
1485 throw(uno::RuntimeException
)
1488 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotFieldsEnumeration")));
1493 sal_Int32 SAL_CALL
ScDataPilotFieldsObj::getCount() throw(uno::RuntimeException
)
1497 ScDPObject
* pDPObj(pParent
->GetDPObject());
1499 return pDPObj
? static_cast<sal_Int32
>(lcl_GetFieldCount( pDPObj
->GetSource(), nType
)) : 0;
1502 uno::Any SAL_CALL
ScDataPilotFieldsObj::getByIndex( sal_Int32 nIndex
)
1503 throw(lang::IndexOutOfBoundsException
,
1504 lang::WrappedTargetException
, uno::RuntimeException
)
1507 uno::Reference
<beans::XPropertySet
> xField(GetObjectByIndex_Impl(static_cast<SCSIZE
>(nIndex
)));
1509 return uno::makeAny(xField
);
1511 throw lang::IndexOutOfBoundsException();
1514 uno::Type SAL_CALL
ScDataPilotFieldsObj::getElementType() throw(uno::RuntimeException
)
1517 return getCppuType((uno::Reference
<beans::XPropertySet
>*)0);
1520 sal_Bool SAL_CALL
ScDataPilotFieldsObj::hasElements() throw(uno::RuntimeException
)
1523 return ( getCount() != 0 );
1526 uno::Any SAL_CALL
ScDataPilotFieldsObj::getByName( const rtl::OUString
& aName
)
1527 throw(container::NoSuchElementException
,
1528 lang::WrappedTargetException
, uno::RuntimeException
)
1531 uno::Reference
<beans::XPropertySet
> xField(GetObjectByName_Impl(aName
));
1533 return uno::makeAny(xField
);
1535 throw container::NoSuchElementException();
1538 uno::Sequence
<rtl::OUString
> SAL_CALL
ScDataPilotFieldsObj::getElementNames()
1539 throw(uno::RuntimeException
)
1544 ScDPObject
* pDPObj(pParent
->GetDPObject());
1548 uno::Sequence
<rtl::OUString
> aSeq(static_cast<sal_Int32
>(lcl_GetFieldCount(pDPObj
->GetSource(), nType
)));
1549 rtl::OUString
* pAry
= aSeq
.getArray();
1550 const List
& rDimensions
= pDPObj
->GetSaveData()->GetDimensions();
1551 sal_Int32 nDimCount
= rDimensions
.Count();
1552 for (sal_Int32 nDim
= 0; nDim
< nDimCount
; nDim
++)
1554 ScDPSaveDimension
* pDim
= (ScDPSaveDimension
*)rDimensions
.GetObject(nDim
);
1555 if(pDim
->GetOrientation() == nType
)
1557 *pAry
= pDim
->GetName();
1563 return uno::Sequence
<rtl::OUString
>();
1566 sal_Bool SAL_CALL
ScDataPilotFieldsObj::hasByName( const rtl::OUString
& aName
)
1567 throw(uno::RuntimeException
)
1571 return GetObjectByName_Impl(aName
) != NULL
;
1574 //------------------------------------------------------------------------
1576 ScDataPilotFieldObj::ScDataPilotFieldObj( ScDataPilotDescriptorBase
* pPar
,
1577 USHORT nST
, const ScFieldIdentifier
& rIdent
) :
1578 aPropSet( lcl_GetDataPilotFieldMap() ),
1581 aSourceIdent( rIdent
),
1582 nLastFunc( sheet::GeneralFunction_NONE
)
1587 ScDataPilotFieldObj::~ScDataPilotFieldObj()
1594 rtl::OUString SAL_CALL
ScDataPilotFieldObj::getName() throw(uno::RuntimeException
)
1599 ScDPObject
* pDPObj(pParent
->GetDPObject());
1602 ScDPSaveDimension
* pDim
= NULL
;
1603 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1605 if (pDim
->IsDataLayout())
1606 return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(SC_DATALAYOUT_NAME
));
1609 const rtl::OUString
* pLayoutName
= pDim
->GetLayoutName();
1611 sRet
= *pLayoutName
;
1613 sRet
= pDim
->GetName();
1620 void SAL_CALL
ScDataPilotFieldObj::setName( const rtl::OUString
& aNewName
)
1621 throw(uno::RuntimeException
)
1625 ScDPObject
* pDPObj(pParent
->GetDPObject());
1628 ScDPSaveDimension
* pDim
= NULL
;
1629 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1631 if (!pDim
->IsDataLayout())
1633 String
aName(aNewName
);
1634 pDim
->SetLayoutName(aName
);
1635 pParent
->SetDPObject(pDPObj
);
1643 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScDataPilotFieldObj::getPropertySetInfo()
1644 throw(uno::RuntimeException
)
1647 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1648 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
1652 void SAL_CALL
ScDataPilotFieldObj::setPropertyValue(
1653 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
1654 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1655 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1656 uno::RuntimeException
)
1659 String
aNameString(aPropertyName
);
1660 if ( aNameString
.EqualsAscii( SC_UNONAME_FUNCTION
) )
1662 //! test for correct enum type?
1663 sheet::GeneralFunction eFunction
= (sheet::GeneralFunction
)
1664 ScUnoHelpFunctions::GetEnumFromAny( aValue
);
1665 setFunction( eFunction
);
1667 else if ( aNameString
.EqualsAscii( SC_UNONAME_ORIENT
) )
1669 //! test for correct enum type?
1670 sheet::DataPilotFieldOrientation eOrient
= (sheet::DataPilotFieldOrientation
)
1671 ScUnoHelpFunctions::GetEnumFromAny( aValue
);
1672 setOrientation( eOrient
);
1674 else if ( aNameString
.EqualsAscii( SC_UNONAME_SELPAGE
) )
1676 rtl::OUString sCurrentPage
;
1677 if (aValue
>>= sCurrentPage
)
1678 setCurrentPage(sCurrentPage
);
1680 else if ( aNameString
.EqualsAscii( SC_UNONAME_USESELPAGE
) )
1682 setUseCurrentPage(cppu::any2bool(aValue
));
1684 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASAUTOSHOW
) )
1686 if (!cppu::any2bool(aValue
))
1687 setAutoShowInfo(NULL
);
1689 else if ( aNameString
.EqualsAscii( SC_UNONAME_AUTOSHOW
) )
1691 sheet::DataPilotFieldAutoShowInfo aInfo
;
1692 if (aValue
>>= aInfo
)
1693 setAutoShowInfo(&aInfo
);
1695 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASLAYOUTINFO
) )
1697 if (!cppu::any2bool(aValue
))
1698 setLayoutInfo(NULL
);
1700 else if ( aNameString
.EqualsAscii( SC_UNONAME_LAYOUTINFO
) )
1702 sheet::DataPilotFieldLayoutInfo aInfo
;
1703 if (aValue
>>= aInfo
)
1704 setLayoutInfo(&aInfo
);
1706 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASREFERENCE
) )
1708 if (!cppu::any2bool(aValue
))
1711 else if ( aNameString
.EqualsAscii( SC_UNONAME_REFERENCE
) )
1713 sheet::DataPilotFieldReference aRef
;
1714 if (aValue
>>= aRef
)
1715 setReference(&aRef
);
1717 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASSORTINFO
) )
1719 if (!cppu::any2bool(aValue
))
1722 else if ( aNameString
.EqualsAscii( SC_UNONAME_SORTINFO
) )
1724 sheet::DataPilotFieldSortInfo aInfo
;
1725 if (aValue
>>= aInfo
)
1726 setSortInfo(&aInfo
);
1728 else if ( aNameString
.EqualsAscii( SC_UNONAME_ISGROUP
) )
1730 if (!cppu::any2bool(aValue
))
1733 else if ( aNameString
.EqualsAscii( SC_UNONAME_GROUPINFO
) )
1735 sheet::DataPilotFieldGroupInfo aInfo
;
1736 if (aValue
>>= aInfo
)
1737 setGroupInfo(&aInfo
);
1739 else if ( aNameString
.EqualsAscii( SC_UNONAME_SHOWEMPTY
) )
1741 setShowEmpty(cppu::any2bool(aValue
));
1745 uno::Any SAL_CALL
ScDataPilotFieldObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
1746 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1747 uno::RuntimeException
)
1750 String
aNameString(aPropertyName
);
1753 if ( aNameString
.EqualsAscii( SC_UNONAME_FUNCTION
) )
1754 aRet
<<= getFunction();
1755 else if ( aNameString
.EqualsAscii( SC_UNONAME_ORIENT
) )
1756 aRet
<<= getOrientation();
1757 else if ( aNameString
.EqualsAscii( SC_UNONAME_SELPAGE
) )
1758 aRet
<<= getCurrentPage();
1759 else if ( aNameString
.EqualsAscii( SC_UNONAME_USESELPAGE
) )
1760 aRet
<<= getUseCurrentPage();
1761 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASAUTOSHOW
) )
1762 aRet
= ::cppu::bool2any(getAutoShowInfo() != NULL
);
1763 else if ( aNameString
.EqualsAscii( SC_UNONAME_AUTOSHOW
) )
1765 const sheet::DataPilotFieldAutoShowInfo
* pInfo
= getAutoShowInfo();
1767 aRet
<<= sheet::DataPilotFieldAutoShowInfo(*pInfo
);
1769 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASLAYOUTINFO
) )
1770 aRet
= ::cppu::bool2any(getLayoutInfo() != NULL
);
1771 else if ( aNameString
.EqualsAscii( SC_UNONAME_LAYOUTINFO
) )
1773 const sheet::DataPilotFieldLayoutInfo
* pInfo
= getLayoutInfo();
1775 aRet
<<= sheet::DataPilotFieldLayoutInfo(*pInfo
);
1777 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASREFERENCE
) )
1778 aRet
= ::cppu::bool2any(getReference() != NULL
);
1779 else if ( aNameString
.EqualsAscii( SC_UNONAME_REFERENCE
) )
1781 const sheet::DataPilotFieldReference
* pRef
= getReference();
1783 aRet
<<= sheet::DataPilotFieldReference(*pRef
);
1785 else if ( aNameString
.EqualsAscii( SC_UNONAME_HASSORTINFO
) )
1786 aRet
= ::cppu::bool2any(getSortInfo() != NULL
);
1787 else if ( aNameString
.EqualsAscii( SC_UNONAME_SORTINFO
) )
1789 const sheet::DataPilotFieldSortInfo
* pInfo
= getSortInfo();
1791 aRet
<<= sheet::DataPilotFieldSortInfo(*pInfo
);
1793 else if ( aNameString
.EqualsAscii( SC_UNONAME_ISGROUP
) )
1794 aRet
= ::cppu::bool2any(hasGroupInfo());
1795 else if ( aNameString
.EqualsAscii( SC_UNONAME_GROUPINFO
) )
1797 aRet
<<= getGroupInfo();
1799 else if ( aNameString
.EqualsAscii( SC_UNONAME_SHOWEMPTY
) )
1800 aRet
<<= getShowEmpty();
1807 uno::Reference
<container::XIndexAccess
> SAL_CALL
ScDataPilotFieldObj::getItems()
1808 throw (uno::RuntimeException
)
1811 xItems
.set(new ScDataPilotItemsObj(pParent
, aSourceIdent
));
1815 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDataPilotFieldObj
)
1817 sheet::DataPilotFieldOrientation
ScDataPilotFieldObj::getOrientation(void) const
1819 sheet::DataPilotFieldOrientation eOrient
= DATA_PILOT_HIDDEN
;
1821 ScDPObject
* pDPObj(pParent
->GetDPObject());
1824 ScDPSaveDimension
* pDim
= NULL
;
1825 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1826 eOrient
= (sheet::DataPilotFieldOrientation
)pDim
->GetOrientation();
1832 void ScDataPilotFieldObj::setOrientation(sheet::DataPilotFieldOrientation eNew
)
1834 if ( eNew
== nSourceType
)
1837 ScDPObject
* pDPObj(pParent
->GetDPObject());
1840 ScDPSaveDimension
* pDim
= NULL
;
1841 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1843 if ( nSourceType
== SC_FIELDORIENT_ALL
&& pDim
->GetOrientation() != DATA_PILOT_HIDDEN
&&
1844 !aSourceIdent
.bDataLayoutField
&& eNew
== DATA_PILOT_DATA
)
1846 // If the field was taken from getDataPilotFields, don't reset the orientation
1847 // for an existing use, create a duplicated field instead (for "Data" orientation only)
1849 ScDPSaveDimension
* pNewDim
= NULL
;
1850 ScDPSaveData
* pSave
= pDPObj
->GetSaveData();
1852 // look for existing duplicate with orientation "hidden"
1854 String
aNameStr( aSourceIdent
.sFieldName
);
1855 const List
& rDimensions
= pSave
->GetDimensions();
1856 sal_Int32 nDimCount
= rDimensions
.Count();
1857 sal_Int32 nFound
= 0;
1858 for ( sal_Int32 nDim
= 0; nDim
< nDimCount
&& !pNewDim
; nDim
++ )
1860 ScDPSaveDimension
* pOneDim
= static_cast<ScDPSaveDimension
*>(rDimensions
.GetObject(nDim
));
1861 if ( !pOneDim
->IsDataLayout() && pOneDim
->GetName() == aNameStr
)
1863 if ( pOneDim
->GetOrientation() == DATA_PILOT_HIDDEN
)
1864 pNewDim
= pOneDim
; // use this one
1866 ++nFound
; // count existing non-hidden occurences
1870 if ( !pNewDim
) // if none found, create a new duplicated dimension
1871 pNewDim
= &pSave
->DuplicateDimension( *pDim
);
1873 aSourceIdent
.nRepeat
= nFound
; // keep accessing the new one
1877 pDim
->SetOrientation(sal::static_int_cast
<USHORT
>(eNew
));
1878 pParent
->SetDPObject(pDPObj
);
1880 nSourceType
= sal::static_int_cast
<USHORT
>(eNew
); // modifying the same object's orientation again doesn't create another duplicate
1885 sheet::GeneralFunction
ScDataPilotFieldObj::getFunction(void) const
1887 sheet::GeneralFunction eRet
= sheet::GeneralFunction_NONE
;
1891 ScDPObject
* pDPObj(pParent
->GetDPObject());
1894 ScDPSaveDimension
* pDim
= NULL
;
1895 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1897 if ( pDim
->GetOrientation() != DATA_PILOT_DATA
)
1899 // for non-data fields, property Function is the subtotals
1900 long nSubCount
= pDim
->GetSubTotalsCount();
1901 if ( nSubCount
> 0 )
1902 eRet
= (sheet::GeneralFunction
)pDim
->GetSubTotalFunc(0); // always use the first one
1906 eRet
= (sheet::GeneralFunction
)pDim
->GetFunction();
1913 void ScDataPilotFieldObj::setFunction(sheet::GeneralFunction eNewFunc
)
1916 ScDPObject
* pDPObj(pParent
->GetDPObject());
1919 ScDPSaveDimension
* pDim
= NULL
;
1920 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1922 if ( pDim
->GetOrientation() != DATA_PILOT_DATA
)
1924 // for non-data fields, property Function is the subtotals
1925 if ( eNewFunc
== sheet::GeneralFunction_NONE
)
1926 pDim
->SetSubTotals( 0, NULL
);
1929 USHORT nFunc
= sal::static_int_cast
<USHORT
>( eNewFunc
);
1930 pDim
->SetSubTotals( 1, &nFunc
);
1934 pDim
->SetFunction( sal::static_int_cast
<USHORT
>( eNewFunc
) );
1935 pParent
->SetDPObject(pDPObj
);
1940 rtl::OUString
ScDataPilotFieldObj::getCurrentPage() const
1944 ScDPObject
* pDPObj(pParent
->GetDPObject());
1947 ScDPSaveDimension
* pDim
= NULL
;
1948 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1949 if (pDim
->HasCurrentPage())
1950 sRet
= pDim
->GetCurrentPage();
1956 void ScDataPilotFieldObj::setCurrentPage(const rtl::OUString
& sPage
)
1958 ScDPObject
* pDPObj(pParent
->GetDPObject());
1961 ScDPSaveDimension
* pDim
= NULL
;
1962 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1965 pDim
->SetCurrentPage(&sCur
);
1966 pParent
->SetDPObject(pDPObj
);
1971 sal_Bool
ScDataPilotFieldObj::getUseCurrentPage() const
1973 sal_Bool bRet
= sal_False
;
1975 ScDPObject
* pDPObj(pParent
->GetDPObject());
1978 ScDPSaveDimension
* pDim
= NULL
;
1979 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1980 bRet
= pDim
->HasCurrentPage();
1986 void ScDataPilotFieldObj::setUseCurrentPage(sal_Bool bUse
)
1988 ScDPObject
* pDPObj(pParent
->GetDPObject());
1991 ScDPSaveDimension
* pDim
= NULL
;
1992 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
1997 pDim
->SetCurrentPage(&sCur
);
2000 pDim
->SetCurrentPage(NULL
);
2001 pParent
->SetDPObject(pDPObj
);
2006 const sheet::DataPilotFieldAutoShowInfo
* ScDataPilotFieldObj::getAutoShowInfo()
2008 ScDPObject
* pDPObj(pParent
->GetDPObject());
2011 ScDPSaveDimension
* pDim
= NULL
;
2012 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2013 return pDim
->GetAutoShowInfo();
2018 void ScDataPilotFieldObj::setAutoShowInfo(const sheet::DataPilotFieldAutoShowInfo
* pInfo
)
2020 ScDPObject
* pDPObj(pParent
->GetDPObject());
2023 ScDPSaveDimension
* pDim
= NULL
;
2024 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2026 pDim
->SetAutoShowInfo(pInfo
);
2027 pParent
->SetDPObject(pDPObj
);
2032 const sheet::DataPilotFieldLayoutInfo
* ScDataPilotFieldObj::getLayoutInfo()
2034 ScDPObject
* pDPObj(pParent
->GetDPObject());
2037 ScDPSaveDimension
* pDim
= NULL
;
2038 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2039 return pDim
->GetLayoutInfo();
2045 void ScDataPilotFieldObj::setLayoutInfo(const sheet::DataPilotFieldLayoutInfo
* pInfo
)
2047 ScDPObject
* pDPObj(pParent
->GetDPObject());
2050 ScDPSaveDimension
* pDim
= NULL
;
2051 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2053 pDim
->SetLayoutInfo(pInfo
);
2054 pParent
->SetDPObject(pDPObj
);
2059 const sheet::DataPilotFieldReference
* ScDataPilotFieldObj::getReference()
2061 ScDPObject
* pDPObj(pParent
->GetDPObject());
2064 ScDPSaveDimension
* pDim
= NULL
;
2065 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2066 return pDim
->GetReferenceValue();
2072 void ScDataPilotFieldObj::setReference(const sheet::DataPilotFieldReference
* pInfo
)
2074 ScDPObject
* pDPObj(pParent
->GetDPObject());
2077 ScDPSaveDimension
* pDim
= NULL
;
2078 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2080 pDim
->SetReferenceValue(pInfo
);
2081 pParent
->SetDPObject(pDPObj
);
2086 const sheet::DataPilotFieldSortInfo
* ScDataPilotFieldObj::getSortInfo()
2088 ScDPObject
* pDPObj(pParent
->GetDPObject());
2091 ScDPSaveDimension
* pDim
= NULL
;
2092 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2093 return pDim
->GetSortInfo();
2099 void ScDataPilotFieldObj::setSortInfo(const sheet::DataPilotFieldSortInfo
* pInfo
)
2101 ScDPObject
* pDPObj(pParent
->GetDPObject());
2104 ScDPSaveDimension
* pDim
= NULL
;
2105 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2107 pDim
->SetSortInfo(pInfo
);
2108 pParent
->SetDPObject(pDPObj
);
2113 sal_Bool
ScDataPilotFieldObj::getShowEmpty() const
2115 sal_Bool bRet
= sal_False
;
2117 ScDPObject
* pDPObj(pParent
->GetDPObject());
2120 ScDPSaveDimension
* pDim
= NULL
;
2121 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2122 bRet
= pDim
->GetShowEmpty();
2128 void ScDataPilotFieldObj::setShowEmpty(sal_Bool bShow
)
2130 ScDPObject
* pDPObj(pParent
->GetDPObject());
2133 ScDPSaveDimension
* pDim
= NULL
;
2134 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2136 pDim
->SetShowEmpty(bShow
);
2137 pParent
->SetDPObject(pDPObj
);
2142 void ScDataPilotFieldObj::SetGroupInfo(const ScDPNumGroupInfo
& rGroupInfo
,
2143 sheet::DataPilotFieldGroupInfo
& rInfo
)
2145 rInfo
.HasDateValues
= rGroupInfo
.DateValues
;
2146 rInfo
.HasAutoStart
= rGroupInfo
.AutoStart
;
2147 rInfo
.Start
= rGroupInfo
.Start
;
2148 rInfo
.HasAutoEnd
= rGroupInfo
.AutoEnd
;
2149 rInfo
.End
= rGroupInfo
.End
;
2150 rInfo
.Step
= rGroupInfo
.Step
;
2153 void ScDataPilotFieldObj::FillGroupInfo(const ScDPSaveGroupDimension
* pGroupDim
,
2154 const ScDPSaveNumGroupDimension
* pNumGroupDim
, sheet::DataPilotFieldGroupInfo
& rInfo
)
2156 if (pGroupDim
|| pNumGroupDim
)
2160 rInfo
.GroupBy
= pGroupDim
->GetDatePart();
2163 uno::Reference
<container::XNameAccess
> xFields(pParent
->getDataPilotFields(), uno::UNO_QUERY
);
2166 rInfo
.SourceField
.set(xFields
->getByName(pGroupDim
->GetSourceDimName()), uno::UNO_QUERY
);
2169 SetGroupInfo(pGroupDim
->GetDateInfo(), rInfo
);
2170 if (!pGroupDim
->GetDatePart())
2172 ScFieldGroups aGroups
;
2173 sal_Int32 nCount
= pGroupDim
->GetGroupCount();
2174 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
2176 const ScDPSaveGroupItem
* pGroup
= pGroupDim
->GetGroupByIndex( i
);
2179 ScFieldGroup aGroup
;
2180 aGroup
.sName
= pGroup
->GetGroupName();
2181 sal_Int32 nElemCount
= pGroup
->GetElementCount();
2182 for(sal_Int32 j
= 0; j
< nElemCount
; ++j
)
2184 const String
* pElem
= pGroup
->GetElementByIndex( j
);
2187 aGroup
.aMembers
.push_back(*pElem
);
2190 aGroups
.push_back(aGroup
);
2193 rInfo
.Groups
= new ScDataPilotFieldGroupsObj(aGroups
);
2198 if (pNumGroupDim
->GetDatePart())
2200 rInfo
.GroupBy
= pNumGroupDim
->GetDatePart();
2201 SetGroupInfo(pNumGroupDim
->GetDateInfo(), rInfo
);
2205 SetGroupInfo(pNumGroupDim
->GetInfo(), rInfo
);
2211 sal_Bool
ScDataPilotFieldObj::hasGroupInfo()
2213 sal_Bool bRet
= sal_False
;
2214 ScDPObject
* pDPObj(pParent
->GetDPObject());
2217 ScDPSaveDimension
* pDim
= NULL
;
2218 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2220 const ScDPSaveData
* pDPSave
= pDPObj
->GetSaveData();
2221 const ScDPDimensionSaveData
* pDimData
= pDPSave
->GetExistingDimensionData();
2224 bRet
= (pDimData
->GetNamedGroupDim(pDim
->GetName()) || pDimData
->GetNumGroupDim(pDim
->GetName()));
2231 sheet::DataPilotFieldGroupInfo
ScDataPilotFieldObj::getGroupInfo()
2233 sheet::DataPilotFieldGroupInfo aInfo
;
2235 ScDPObject
* pDPObj(pParent
->GetDPObject());
2238 ScDPSaveDimension
* pDim
= NULL
;
2239 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2241 const ScDPSaveData
* pDPSave
= pDPObj
->GetSaveData();
2242 const ScDPDimensionSaveData
* pDimData
= pDPSave
->GetExistingDimensionData();
2245 FillGroupInfo(pDimData
->GetNamedGroupDim(pDim
->GetName()),
2246 pDimData
->GetNumGroupDim(pDim
->GetName()), aInfo
);
2254 void ScDataPilotFieldObj::setGroupInfo(const sheet::DataPilotFieldGroupInfo
* pInfo
)
2256 ScDPObject
* pDPObj(pParent
->GetDPObject());
2259 ScDPSaveDimension
* pDim
= NULL
;
2260 if (lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2262 ScDPSaveData
* pSaveData
= pDPObj
->GetSaveData();
2265 ScDPNumGroupInfo aInfo
;
2266 aInfo
.Enable
= sal_True
;
2267 aInfo
.DateValues
= pInfo
->HasDateValues
;
2268 aInfo
.AutoStart
= pInfo
->HasAutoStart
;
2269 aInfo
.AutoEnd
= pInfo
->HasAutoEnd
;
2270 aInfo
.Start
= pInfo
->Start
;
2271 aInfo
.End
= pInfo
->End
;
2272 aInfo
.Step
= pInfo
->Step
;
2273 uno::Reference
<container::XNamed
> xNamed(pInfo
->SourceField
, uno::UNO_QUERY
);
2276 ScDPSaveGroupDimension
aGroupDim(xNamed
->getName(), getName());
2278 aGroupDim
.SetDateInfo(aInfo
, pInfo
->GroupBy
);
2281 uno::Reference
<container::XIndexAccess
> xIndex(pInfo
->Groups
, uno::UNO_QUERY
);
2284 sal_Int32
nCount(xIndex
->getCount());
2285 for(sal_Int32 i
= 0; i
< nCount
; i
++)
2287 uno::Reference
<container::XNamed
> xGroupNamed(xIndex
->getByIndex(i
), uno::UNO_QUERY
);
2288 if (xGroupNamed
.is())
2290 ScDPSaveGroupItem
aItem(xGroupNamed
->getName());
2291 uno::Reference
<container::XIndexAccess
> xGroupIndex(xGroupNamed
, uno::UNO_QUERY
);
2292 if (xGroupIndex
.is())
2294 sal_Int32
nItemCount(xGroupIndex
->getCount());
2295 for (sal_Int32 j
= 0; j
< nItemCount
; ++j
)
2297 uno::Reference
<container::XNamed
> xItemNamed(xGroupIndex
->getByIndex(j
), uno::UNO_QUERY
);
2298 if (xItemNamed
.is())
2299 aItem
.AddElement(xItemNamed
->getName());
2302 aGroupDim
.AddGroupItem(aItem
);
2307 ScDPDimensionSaveData aDimSaveData
;
2309 aDimSaveData
.AddGroupDimension(aGroupDim
);
2310 pSaveData
->SetDimensionData(&aDimSaveData
);
2314 ScDPDimensionSaveData
* pDimData
= pSaveData
->GetDimensionData(); // created if not there
2316 ScDPSaveNumGroupDimension
* pExisting
= pDimData
->GetNumGroupDimAcc( getName() );
2320 pExisting
->SetDateInfo(aInfo
, pInfo
->GroupBy
);
2321 // modify existing group dimension
2322 pExisting
->SetGroupInfo( aInfo
);
2326 // create new group dimension
2327 ScDPSaveNumGroupDimension
aNumGroupDim( getName(), aInfo
);
2329 aNumGroupDim
.SetDateInfo(aInfo
, pInfo
->GroupBy
);
2330 pDimData
->AddNumGroupDimension( aNumGroupDim
);
2333 // pSaveData->SetDimensionData(pDimData); not neccessary
2338 pSaveData
->SetDimensionData(NULL
);
2340 pDPObj
->SetSaveData(*pSaveData
);
2341 pParent
->SetDPObject(pDPObj
);
2346 sal_Bool
ScDataPilotFieldObj::HasString(const uno::Sequence
< ::rtl::OUString
>& rItems
, const rtl::OUString
& aString
)
2348 sal_Bool bRet
= sal_False
;
2350 sal_Int32
nCount(rItems
.getLength());
2352 while (nItem
< nCount
&& !bRet
)
2354 bRet
= rItems
[nItem
] == aString
;
2361 // XDataPilotFieldGrouping
2362 uno::Reference
< sheet::XDataPilotField
> SAL_CALL
2363 ScDataPilotFieldObj::createNameGroup(const uno::Sequence
< rtl::OUString
>& rItems
)
2364 throw (::com::sun::star::uno::RuntimeException
, lang::IllegalArgumentException
)
2368 uno::Reference
< sheet::XDataPilotField
> xRet
;
2369 rtl::OUString sNewDim
;
2371 if (!rItems
.getLength())
2372 throw lang::IllegalArgumentException();
2374 ScDPObject
* pDPObj(pParent
->GetDPObject());
2377 ScDPSaveDimension
* pDim
= NULL
;
2378 if ( rItems
.getLength() > 0 && lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2380 String
aDimName (pDim
->GetName());
2382 ScDPSaveData
aSaveData(*pDPObj
->GetSaveData());
2383 ScDPDimensionSaveData
* pDimData
= aSaveData
.GetDimensionData(); // created if not there
2385 // find original base
2386 String
aBaseDimName( aDimName
);
2387 const ScDPSaveGroupDimension
* pBaseGroupDim
= pDimData
->GetNamedGroupDim( aDimName
);
2388 if ( pBaseGroupDim
)
2390 // any entry's SourceDimName is the original base
2391 aBaseDimName
= pBaseGroupDim
->GetSourceDimName();
2394 // find existing group dimension
2395 // (using the selected dim, can be intermediate group dim)
2396 ScDPSaveGroupDimension
* pGroupDimension
= pDimData
->GetGroupDimAccForBase( aDimName
);
2398 // remove the selected items from their groups
2399 // (empty groups are removed, too)
2400 sal_Int32 nEntryCount
= rItems
.getLength();
2402 if ( pGroupDimension
)
2404 for (nEntry
=0; nEntry
<nEntryCount
; nEntry
++)
2406 String
aEntryName(rItems
[nEntry
]);
2407 if ( pBaseGroupDim
)
2409 // for each selected (intermediate) group, remove all its items
2410 // (same logic as for adding, below)
2411 const ScDPSaveGroupItem
* pBaseGroup
= pBaseGroupDim
->GetNamedGroup( aEntryName
);
2413 pBaseGroup
->RemoveElementsFromGroups( *pGroupDimension
); // remove all elements
2415 pGroupDimension
->RemoveFromGroups( aEntryName
);
2418 pGroupDimension
->RemoveFromGroups( aEntryName
);
2422 ScDPSaveGroupDimension
* pNewGroupDim
= NULL
;
2423 if ( !pGroupDimension
)
2425 // create a new group dimension
2426 String aGroupDimName
= pDimData
->CreateGroupDimName( aBaseDimName
, *pDPObj
, false, NULL
);
2427 pNewGroupDim
= new ScDPSaveGroupDimension( aBaseDimName
, aGroupDimName
);
2428 sNewDim
= aGroupDimName
;
2430 pGroupDimension
= pNewGroupDim
; // make changes to the new dim if none existed
2432 if ( pBaseGroupDim
)
2434 // If it's a higher-order group dimension, pre-allocate groups for all
2435 // non-selected original groups, so the individual base members aren't
2436 // used for automatic groups (this would make the original groups hard
2438 //! Also do this when removing groups?
2439 //! Handle this case dynamically with automatic groups?
2441 long nGroupCount
= pBaseGroupDim
->GetGroupCount();
2442 for ( long nGroup
= 0; nGroup
< nGroupCount
; nGroup
++ )
2444 const ScDPSaveGroupItem
* pBaseGroup
= pBaseGroupDim
->GetGroupByIndex( nGroup
);
2446 StrData
aStrData( pBaseGroup
->GetGroupName() );
2447 if ( !HasString(rItems
, aStrData
.GetString()) ) //! ignore case?
2449 // add an additional group for each item that is not in the selection
2450 ScDPSaveGroupItem
aGroup( pBaseGroup
->GetGroupName() );
2451 aGroup
.AddElementsFromGroup( *pBaseGroup
);
2452 pGroupDimension
->AddGroupItem( aGroup
);
2457 String aGroupDimName
= pGroupDimension
->GetGroupDimName();
2459 //! localized prefix string
2460 String aGroupName
= pGroupDimension
->CreateGroupName( String::CreateFromAscii("Group") );
2461 ScDPSaveGroupItem
aGroup( aGroupName
);
2462 uno::Reference
<container::XNameAccess
> xMembers
;
2463 if (!lcl_GetMembers(pParent
, aSourceIdent
, xMembers
))
2465 delete pNewGroupDim
;
2466 throw uno::RuntimeException();
2469 for (nEntry
=0; nEntry
<nEntryCount
; nEntry
++)
2471 String
aEntryName(rItems
[nEntry
]);
2473 if (!xMembers
->hasByName(aEntryName
))
2475 delete pNewGroupDim
;
2476 throw lang::IllegalArgumentException();
2479 if ( pBaseGroupDim
)
2481 // for each selected (intermediate) group, add all its items
2482 const ScDPSaveGroupItem
* pBaseGroup
= pBaseGroupDim
->GetNamedGroup( aEntryName
);
2484 aGroup
.AddElementsFromGroup( *pBaseGroup
);
2486 aGroup
.AddElement( aEntryName
); // no group found -> automatic group, add the item itself
2489 aGroup
.AddElement( aEntryName
); // no group dimension, add all items directly
2492 pGroupDimension
->AddGroupItem( aGroup
);
2496 pDimData
->AddGroupDimension( *pNewGroupDim
);
2497 delete pNewGroupDim
; // AddGroupDimension copies the object
2498 // don't access pGroupDimension after here
2500 pGroupDimension
= pNewGroupDim
= NULL
;
2503 ScDPSaveDimension
* pSaveDimension
= aSaveData
.GetDimensionByName( aGroupDimName
);
2504 if ( pSaveDimension
->GetOrientation() == sheet::DataPilotFieldOrientation_HIDDEN
)
2506 ScDPSaveDimension
* pOldDimension
= aSaveData
.GetDimensionByName( aDimName
);
2507 pSaveDimension
->SetOrientation( pOldDimension
->GetOrientation() );
2508 long nPosition
= 0; //! before (immediate) base
2509 aSaveData
.SetPosition( pSaveDimension
, nPosition
);
2513 pDPObj
->SetSaveData( aSaveData
);
2514 pParent
->SetDPObject(pDPObj
);
2518 if (sNewDim
.getLength())
2520 uno::Reference
< container::XNameAccess
> xFields(pParent
->getDataPilotFields(), uno::UNO_QUERY
);
2523 xRet
.set(xFields
->getByName(sNewDim
), uno::UNO_QUERY
);
2524 DBG_ASSERT(xRet
.is(), "there is a name, so there should be also a field");
2531 String
lcl_GetDateByName( sal_Int32 nGroupBy
)
2533 String aRet
; //! globstr-ID
2536 //! use translated strings from globstr.src
2537 case com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS
: aRet
= String::CreateFromAscii("Seconds"); break;
2538 case com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES
: aRet
= String::CreateFromAscii("Minutes"); break;
2539 case com::sun::star::sheet::DataPilotFieldGroupBy::HOURS
: aRet
= String::CreateFromAscii("Hours"); break;
2540 case com::sun::star::sheet::DataPilotFieldGroupBy::DAYS
: aRet
= String::CreateFromAscii("Days"); break;
2541 case com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS
: aRet
= String::CreateFromAscii("Months"); break;
2542 case com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS
: aRet
= String::CreateFromAscii("Quarters"); break;
2543 case com::sun::star::sheet::DataPilotFieldGroupBy::YEARS
: aRet
= String::CreateFromAscii("Years"); break;
2545 DBG_ERROR("invalid date part");
2550 uno::Reference
< sheet::XDataPilotField
> SAL_CALL
2551 ScDataPilotFieldObj::createDateGroup(const sheet::DataPilotFieldGroupInfo
& rInfo
)
2552 throw (::com::sun::star::uno::RuntimeException
, lang::IllegalArgumentException
)
2556 if (!rInfo
.HasDateValues
)
2557 throw lang::IllegalArgumentException();
2559 uno::Reference
< sheet::XDataPilotField
> xRet
;
2561 ScDPObject
* pDPObj(pParent
->GetDPObject());
2564 ScDPSaveDimension
* pDim
= NULL
;
2565 if ( lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
2567 ScDPNumGroupInfo aInfo
;
2568 aInfo
.DateValues
= rInfo
.HasDateValues
;
2569 aInfo
.AutoStart
= rInfo
.HasAutoStart
;
2570 aInfo
.Start
= rInfo
.Start
;
2571 aInfo
.AutoEnd
= rInfo
.HasAutoEnd
;
2572 aInfo
.End
= rInfo
.End
;
2573 aInfo
.Step
= rInfo
.Step
;
2575 String
aDimName (pDim
->GetName());
2577 ScDPSaveData
aData( *pDPObj
->GetSaveData() );
2578 ScDPDimensionSaveData
* pDimData
= aData
.GetDimensionData(); // created if not there
2580 // find original base
2581 String
aBaseDimName( aDimName
);
2582 const ScDPSaveGroupDimension
* pBaseGroupDim
= pDimData
->GetNamedGroupDim( aDimName
);
2583 if ( pBaseGroupDim
)
2585 // any entry's SourceDimName is the original base
2586 aBaseDimName
= pBaseGroupDim
->GetSourceDimName();
2589 if ( rInfo
.GroupBy
)
2591 // create date group dimensions
2593 sal_Bool
bFirst(sal_False
);
2594 if (!pBaseGroupDim
) // it's the base Dim
2596 // test whether there is already grouping
2597 const ScDPSaveNumGroupDimension
* pNumGroupDim
= pDimData
->GetNumGroupDim(pDim
->GetName());
2600 if (!pNumGroupDim
->GetDateInfo().DateValues
)
2607 ScDPNumGroupInfo aEmpty
;
2610 // innermost part: create NumGroupDimension (replacing original values)
2611 // Dimension name is left unchanged
2613 if ( rInfo
.GroupBy
== com::sun::star::sheet::DataPilotFieldGroupBy::DAYS
&& rInfo
.Step
!= 0.0 )
2615 // only days, and a step value specified: use numerical grouping
2616 // with DateValues flag, not date grouping
2618 ScDPNumGroupInfo
aNumInfo( aInfo
);
2619 aNumInfo
.DateValues
= sal_True
;
2621 ScDPSaveNumGroupDimension
aNumGroupDim( aBaseDimName
, aNumInfo
);
2622 pDimData
->AddNumGroupDimension( aNumGroupDim
);
2626 ScDPSaveNumGroupDimension
aNumGroupDim( aBaseDimName
, aEmpty
);
2627 aNumGroupDim
.SetDateInfo( aInfo
, rInfo
.GroupBy
);
2628 pDimData
->AddNumGroupDimension( aNumGroupDim
);
2633 // additional parts: create GroupDimension (shown as additional dimensions)
2635 String aPartName
= lcl_GetDateByName( rInfo
.GroupBy
);
2637 String aGroupDimName
= pDimData
->CreateGroupDimName(
2638 aPartName
, *pDPObj
, true, NULL
);
2639 ScDPSaveGroupDimension
aGroupDim( aBaseDimName
, aGroupDimName
);
2640 aGroupDim
.SetDateInfo( aInfo
, rInfo
.GroupBy
);
2641 pDimData
->AddGroupDimension( aGroupDim
);
2644 ScDPSaveDimension
* pSaveDimension
= aData
.GetDimensionByName( aGroupDimName
);
2645 if ( pSaveDimension
->GetOrientation() == sheet::DataPilotFieldOrientation_HIDDEN
)
2647 ScDPSaveDimension
* pOldDimension
= aData
.GetDimensionByName( aBaseDimName
);
2648 pSaveDimension
->SetOrientation( pOldDimension
->GetOrientation() );
2649 long nPosition
= 0; //! before (immediate) base
2650 aData
.SetPosition( pSaveDimension
, nPosition
);
2656 pDPObj
->SetSaveData( aData
);
2657 pParent
->SetDPObject(pDPObj
);
2663 //------------------------------------------------------------------------
2665 ScDataPilotFieldGroupsObj::ScDataPilotFieldGroupsObj(const ScFieldGroups
& rGroups
) :
2670 ScDataPilotFieldGroupsObj::~ScDataPilotFieldGroupsObj()
2676 uno::Any SAL_CALL
ScDataPilotFieldGroupsObj::getByName( const rtl::OUString
& aName
)
2677 throw(container::NoSuchElementException
,
2678 lang::WrappedTargetException
, uno::RuntimeException
)
2682 ScFieldGroups::const_iterator
aItr(aGroups
.begin());
2683 ScFieldGroups::const_iterator
aEndItr(aGroups
.end());
2684 sal_Bool
bFound(sal_False
);
2685 while (!bFound
&& aItr
!= aEndItr
)
2687 if (aItr
->sName
== aName
)
2693 return uno::makeAny(uno::Reference
< container::XNameAccess
> (new ScDataPilotFieldGroupObj(*aItr
)));
2695 throw container::NoSuchElementException();
2697 // return uno::Any();
2700 uno::Sequence
<rtl::OUString
> SAL_CALL
ScDataPilotFieldGroupsObj::getElementNames()
2701 throw(uno::RuntimeException
)
2706 uno::Sequence
<rtl::OUString
> aSeq(aGroups
.size());
2707 ScFieldGroups::const_iterator
aItr(aGroups
.begin());
2708 ScFieldGroups::const_iterator
aEndItr(aGroups
.end());
2710 while (aItr
!= aEndItr
)
2712 aSeq
[i
] = aItr
->sName
;
2719 sal_Bool SAL_CALL
ScDataPilotFieldGroupsObj::hasByName( const rtl::OUString
& aName
)
2720 throw(uno::RuntimeException
)
2724 ScFieldGroups::const_iterator
aItr(aGroups
.begin());
2725 ScFieldGroups::const_iterator
aEndItr(aGroups
.end());
2726 sal_Bool
bFound(sal_False
);
2727 while (!bFound
&& aItr
!= aEndItr
)
2729 if (aItr
->sName
== aName
)
2739 void SAL_CALL
ScDataPilotFieldGroupsObj::replaceByName( const ::rtl::OUString
& aName
,
2740 const uno::Any
& aElement
)
2741 throw (lang::IllegalArgumentException
,
2742 container::NoSuchElementException
,
2743 lang::WrappedTargetException
,
2744 uno::RuntimeException
)
2748 ScFieldGroups::iterator
aItr(aGroups
.begin());
2749 ScFieldGroups::iterator
aEndItr(aGroups
.end());
2750 sal_Bool
bFound(sal_False
);
2751 while (!bFound
&& aItr
!= aEndItr
)
2753 if (aItr
->sName
== aName
)
2760 uno::Reference
<container::XNamed
> xNamed(aElement
, uno::UNO_QUERY
);
2763 ScFieldGroup aGroup
;
2764 aGroup
.sName
= xNamed
->getName();
2765 uno::Reference
<container::XIndexAccess
> xIndex(xNamed
, uno::UNO_QUERY
);
2768 sal_Int32
nCount(xIndex
->getCount());
2769 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
2771 uno::Reference
<container::XNamed
> xItem(xIndex
->getByIndex(i
), uno::UNO_QUERY
);
2773 aGroup
.aMembers
.push_back(xNamed
->getName());
2775 throw lang::IllegalArgumentException();
2779 throw lang::IllegalArgumentException();
2781 aGroups
.erase(aItr
);
2782 aGroups
.push_back(aGroup
);
2785 throw lang::IllegalArgumentException();
2788 throw container::NoSuchElementException();
2792 void SAL_CALL
ScDataPilotFieldGroupsObj::insertByName( const ::rtl::OUString
& aName
,
2793 const uno::Any
& aElement
)
2794 throw (lang::IllegalArgumentException
,
2795 container::ElementExistException
,
2796 lang::WrappedTargetException
,
2797 uno::RuntimeException
)
2801 ScFieldGroups::const_iterator
aItr(aGroups
.begin());
2802 ScFieldGroups::const_iterator
aEndItr(aGroups
.end());
2803 sal_Bool
bFound(sal_False
);
2804 while (!bFound
&& aItr
!= aEndItr
)
2806 if (aItr
->sName
== aName
)
2813 uno::Reference
<container::XNamed
> xNamed(aElement
, uno::UNO_QUERY
);
2816 ScFieldGroup aGroup
;
2817 aGroup
.sName
= xNamed
->getName();
2818 uno::Reference
<container::XIndexAccess
> xIndex(xNamed
, uno::UNO_QUERY
);
2821 sal_Int32
nCount(xIndex
->getCount());
2822 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
2824 uno::Reference
<container::XNamed
> xItem(xIndex
->getByIndex(i
), uno::UNO_QUERY
);
2826 aGroup
.aMembers
.push_back(xNamed
->getName());
2828 throw lang::IllegalArgumentException();
2832 throw lang::IllegalArgumentException();
2834 aGroups
.push_back(aGroup
);
2837 throw lang::IllegalArgumentException();
2840 throw container::ElementExistException();
2843 void SAL_CALL
ScDataPilotFieldGroupsObj::removeByName( const ::rtl::OUString
& aName
)
2844 throw (container::NoSuchElementException
,
2845 lang::WrappedTargetException
,
2846 uno::RuntimeException
)
2850 ScFieldGroups::iterator
aItr(aGroups
.begin());
2851 ScFieldGroups::iterator
aEndItr(aGroups
.end());
2852 sal_Bool
bFound(sal_False
);
2853 while (!bFound
&& aItr
!= aEndItr
)
2855 if (aItr
->sName
== aName
)
2861 aGroups
.erase(aItr
);
2863 throw container::NoSuchElementException();
2866 // XEnumerationAccess
2868 uno::Reference
<container::XEnumeration
> SAL_CALL
ScDataPilotFieldGroupsObj::createEnumeration()
2869 throw(uno::RuntimeException
)
2872 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotFieldGroupsEnumeration")));
2877 sal_Int32 SAL_CALL
ScDataPilotFieldGroupsObj::getCount() throw(uno::RuntimeException
)
2880 return aGroups
.size();
2883 uno::Any SAL_CALL
ScDataPilotFieldGroupsObj::getByIndex( sal_Int32 nIndex
)
2884 throw(lang::IndexOutOfBoundsException
,
2885 lang::WrappedTargetException
, uno::RuntimeException
)
2888 if (nIndex
>= 0 && nIndex
< sal::static_int_cast
<sal_Int32
>(aGroups
.size()))
2889 return uno::makeAny(uno::Reference
< container::XNameAccess
> (new ScDataPilotFieldGroupObj(aGroups
[nIndex
])));
2891 throw lang::IndexOutOfBoundsException();
2894 uno::Type SAL_CALL
ScDataPilotFieldGroupsObj::getElementType() throw(uno::RuntimeException
)
2897 return getCppuType((uno::Reference
<container::XNameAccess
>*)0);
2900 sal_Bool SAL_CALL
ScDataPilotFieldGroupsObj::hasElements() throw(uno::RuntimeException
)
2903 return ( !aGroups
.empty() );
2906 //------------------------------------------------------------------------
2908 ScDataPilotFieldGroupObj::ScDataPilotFieldGroupObj(const ScFieldGroup
& rGroup
) :
2913 ScDataPilotFieldGroupObj::~ScDataPilotFieldGroupObj()
2919 uno::Any SAL_CALL
ScDataPilotFieldGroupObj::getByName( const rtl::OUString
& aName
)
2920 throw(container::NoSuchElementException
,
2921 lang::WrappedTargetException
, uno::RuntimeException
)
2925 std::vector
< rtl::OUString
>::const_iterator
aItr(aGroup
.aMembers
.begin());
2926 std::vector
< rtl::OUString
>::const_iterator
aEndItr(aGroup
.aMembers
.end());
2927 sal_Bool
bFound(sal_False
);
2928 while (!bFound
&& aItr
!= aEndItr
)
2936 return uno::makeAny(uno::Reference
< container::XNamed
> (new ScDataPilotFieldGroupItemObj(*aItr
)));
2941 uno::Sequence
<rtl::OUString
> SAL_CALL
ScDataPilotFieldGroupObj::getElementNames()
2942 throw(uno::RuntimeException
)
2947 uno::Sequence
<rtl::OUString
> aSeq(aGroup
.aMembers
.size());
2948 std::vector
< rtl::OUString
>::const_iterator
aItr(aGroup
.aMembers
.begin());
2949 std::vector
< rtl::OUString
>::const_iterator
aEndItr(aGroup
.aMembers
.end());
2951 while (aItr
!= aEndItr
)
2960 sal_Bool SAL_CALL
ScDataPilotFieldGroupObj::hasByName( const rtl::OUString
& aName
)
2961 throw(uno::RuntimeException
)
2965 std::vector
< rtl::OUString
>::const_iterator
aItr(aGroup
.aMembers
.begin());
2966 std::vector
< rtl::OUString
>::const_iterator
aEndItr(aGroup
.aMembers
.end());
2967 sal_Bool
bFound(sal_False
);
2968 while (!bFound
&& aItr
!= aEndItr
)
2980 void SAL_CALL
ScDataPilotFieldGroupObj::replaceByName( const ::rtl::OUString
& aName
,
2981 const uno::Any
& aElement
)
2982 throw (lang::IllegalArgumentException
,
2983 container::NoSuchElementException
,
2984 lang::WrappedTargetException
,
2985 uno::RuntimeException
)
2989 std::vector
<rtl::OUString
>::iterator
aItr(aGroup
.aMembers
.begin());
2990 std::vector
<rtl::OUString
>::iterator
aEndItr(aGroup
.aMembers
.end());
2991 sal_Bool
bFound(sal_False
);
2992 while (!bFound
&& aItr
!= aEndItr
)
3001 uno::Reference
<container::XNamed
> xNamed(aElement
, uno::UNO_QUERY
);
3004 aGroup
.aMembers
.erase(aItr
);
3005 aGroup
.aMembers
.push_back(xNamed
->getName());
3008 throw lang::IllegalArgumentException();
3011 throw container::NoSuchElementException();
3015 void SAL_CALL
ScDataPilotFieldGroupObj::insertByName( const ::rtl::OUString
& aName
,
3016 const uno::Any
& aElement
)
3017 throw (lang::IllegalArgumentException
,
3018 container::ElementExistException
,
3019 lang::WrappedTargetException
,
3020 uno::RuntimeException
)
3024 std::vector
<rtl::OUString
>::iterator
aItr(aGroup
.aMembers
.begin());
3025 std::vector
<rtl::OUString
>::iterator
aEndItr(aGroup
.aMembers
.end());
3026 sal_Bool
bFound(sal_False
);
3027 while (!bFound
&& aItr
!= aEndItr
)
3036 uno::Reference
<container::XNamed
> xNamed(aElement
, uno::UNO_QUERY
);
3039 if (aName
== xNamed
->getName())
3040 aGroup
.aMembers
.push_back(aName
);
3042 throw lang::IllegalArgumentException();
3045 throw lang::IllegalArgumentException();
3048 throw container::ElementExistException();
3051 void SAL_CALL
ScDataPilotFieldGroupObj::removeByName( const ::rtl::OUString
& aName
)
3052 throw (container::NoSuchElementException
,
3053 lang::WrappedTargetException
,
3054 uno::RuntimeException
)
3058 std::vector
<rtl::OUString
>::iterator
aItr(aGroup
.aMembers
.begin());
3059 std::vector
<rtl::OUString
>::iterator
aEndItr(aGroup
.aMembers
.end());
3060 sal_Bool
bFound(sal_False
);
3061 while (!bFound
&& aItr
!= aEndItr
)
3069 aGroup
.aMembers
.erase(aItr
);
3071 throw container::NoSuchElementException();
3074 // XEnumerationAccess
3076 uno::Reference
<container::XEnumeration
> SAL_CALL
ScDataPilotFieldGroupObj::createEnumeration()
3077 throw(uno::RuntimeException
)
3080 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotFieldGroupEnumeration")));
3085 sal_Int32 SAL_CALL
ScDataPilotFieldGroupObj::getCount() throw(uno::RuntimeException
)
3088 return aGroup
.aMembers
.size();
3091 uno::Any SAL_CALL
ScDataPilotFieldGroupObj::getByIndex( sal_Int32 nIndex
)
3092 throw(lang::IndexOutOfBoundsException
,
3093 lang::WrappedTargetException
, uno::RuntimeException
)
3096 if (nIndex
>= 0 && nIndex
< sal::static_int_cast
<sal_Int32
>(aGroup
.aMembers
.size()))
3097 return uno::makeAny(uno::Reference
< container::XNamed
> (new ScDataPilotFieldGroupItemObj(aGroup
.aMembers
[nIndex
])));
3099 throw lang::IndexOutOfBoundsException();
3102 uno::Type SAL_CALL
ScDataPilotFieldGroupObj::getElementType() throw(uno::RuntimeException
)
3105 return getCppuType((uno::Reference
<container::XNamed
>*)0);
3108 sal_Bool SAL_CALL
ScDataPilotFieldGroupObj::hasElements() throw(uno::RuntimeException
)
3111 return ( !aGroup
.aMembers
.empty() );
3115 ::rtl::OUString SAL_CALL
ScDataPilotFieldGroupObj::getName() throw(::com::sun::star::uno::RuntimeException
)
3119 return aGroup
.sName
;
3122 void SAL_CALL
ScDataPilotFieldGroupObj::setName( const ::rtl::OUString
& aName
)
3123 throw(::com::sun::star::uno::RuntimeException
)
3127 aGroup
.sName
= aName
;
3130 //------------------------------------------------------------------------
3132 ScDataPilotFieldGroupItemObj::ScDataPilotFieldGroupItemObj(const rtl::OUString
& rName
)
3137 ScDataPilotFieldGroupItemObj::~ScDataPilotFieldGroupItemObj()
3142 ::rtl::OUString SAL_CALL
ScDataPilotFieldGroupItemObj::getName() throw(::com::sun::star::uno::RuntimeException
)
3149 void SAL_CALL
ScDataPilotFieldGroupItemObj::setName( const ::rtl::OUString
& aName
)
3150 throw(::com::sun::star::uno::RuntimeException
)
3157 //------------------------------------------------------------------------
3159 ScDataPilotItemsObj::ScDataPilotItemsObj(ScDataPilotDescriptorBase
* pPar
, const ScFieldIdentifier
& rIdent
) :
3161 aSourceIdent( rIdent
)
3166 ScDataPilotItemsObj::~ScDataPilotItemsObj()
3171 SCSIZE
lcl_GetItemCount( ScDataPilotDescriptorBase
* pParent
, const ScFieldIdentifier
& rIdent
)
3175 uno::Reference
<container::XNameAccess
> xMembers
;
3176 if (lcl_GetMembers(pParent
, rIdent
, xMembers
))
3178 uno::Reference
<container::XIndexAccess
> xMembersIndex(new ScNameToIndexAccess( xMembers
));
3179 nRet
= static_cast<SCSIZE
>(xMembersIndex
->getCount());
3187 ScDataPilotItemObj
* ScDataPilotItemsObj::GetObjectByIndex_Impl(SCSIZE nIndex
) const
3190 if (nIndex
< lcl_GetItemCount(pParent
, aSourceIdent
))
3191 return new ScDataPilotItemObj( pParent
, aSourceIdent
, nIndex
);
3198 uno::Any SAL_CALL
ScDataPilotItemsObj::getByName( const rtl::OUString
& aName
)
3199 throw(container::NoSuchElementException
,
3200 lang::WrappedTargetException
, uno::RuntimeException
)
3205 uno::Reference
<container::XNameAccess
> xMembers
;
3206 if (lcl_GetMembers(pParent
, aSourceIdent
, xMembers
))
3208 uno::Reference
<container::XIndexAccess
> xMembersIndex(new ScNameToIndexAccess( xMembers
));
3209 sal_Int32 nCount
= xMembersIndex
->getCount();
3210 sal_Bool
bFound(sal_False
);
3211 sal_Int32 nItem
= 0;
3212 while (nItem
< nCount
&& !bFound
)
3214 uno::Reference
<container::XNamed
> xMember(xMembersIndex
->getByIndex(nItem
), uno::UNO_QUERY
);
3215 if (xMember
.is() && aName
== xMember
->getName())
3216 return uno::makeAny(uno::Reference
<beans::XPropertySet
> (GetObjectByIndex_Impl(static_cast<SCSIZE
>(nItem
))));
3221 throw container::NoSuchElementException();
3228 uno::Sequence
<rtl::OUString
> SAL_CALL
ScDataPilotItemsObj::getElementNames()
3229 throw(uno::RuntimeException
)
3234 uno::Sequence
<rtl::OUString
> aSeq
;
3235 if( ScDPObject
* pDPObj
= pParent
->GetDPObject() )
3237 sal_Int32 nObjIndex
= lcl_GetObjectIndex( pDPObj
, aSourceIdent
);
3238 pDPObj
->GetMembers( nObjIndex
, aSeq
);
3243 sal_Bool SAL_CALL
ScDataPilotItemsObj::hasByName( const rtl::OUString
& aName
)
3244 throw(uno::RuntimeException
)
3248 sal_Bool
bFound(sal_False
);
3250 uno::Reference
<container::XNameAccess
> xMembers
;
3251 if (lcl_GetMembers(pParent
, aSourceIdent
, xMembers
))
3253 uno::Reference
<container::XIndexAccess
> xMembersIndex(new ScNameToIndexAccess( xMembers
));
3254 sal_Int32 nCount
= xMembersIndex
->getCount();
3255 sal_Int32 nItem
= 0;
3256 while (nItem
< nCount
&& !bFound
)
3258 uno::Reference
<container::XNamed
> xMember(xMembersIndex
->getByIndex(nItem
), uno::UNO_QUERY
);
3259 if (xMember
.is() && aName
== xMember
->getName())
3270 // XEnumerationAccess
3272 uno::Reference
<container::XEnumeration
> SAL_CALL
ScDataPilotItemsObj::createEnumeration()
3273 throw(uno::RuntimeException
)
3276 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotItemsEnumeration")));
3281 sal_Int32 SAL_CALL
ScDataPilotItemsObj::getCount() throw(uno::RuntimeException
)
3285 return static_cast<sal_Int32
>(lcl_GetItemCount( pParent
, aSourceIdent
));
3288 uno::Any SAL_CALL
ScDataPilotItemsObj::getByIndex( sal_Int32 nIndex
)
3289 throw(lang::IndexOutOfBoundsException
,
3290 lang::WrappedTargetException
, uno::RuntimeException
)
3293 uno::Reference
<beans::XPropertySet
> xItem(GetObjectByIndex_Impl(static_cast<SCSIZE
>(nIndex
)));
3295 return uno::makeAny(xItem
);
3297 throw lang::IndexOutOfBoundsException();
3300 uno::Type SAL_CALL
ScDataPilotItemsObj::getElementType() throw(uno::RuntimeException
)
3303 return getCppuType((uno::Reference
<beans::XPropertySet
>*)0);
3306 sal_Bool SAL_CALL
ScDataPilotItemsObj::hasElements() throw(uno::RuntimeException
)
3309 return ( getCount() != 0 );
3312 //------------------------------------------------------------------------
3314 ScDataPilotItemObj::ScDataPilotItemObj(ScDataPilotDescriptorBase
* pPar
, const ScFieldIdentifier
& rIdent
, SCSIZE nI
)
3315 : aPropSet( lcl_GetDataPilotItemMap() ),
3317 aSourceIdent(rIdent
),
3323 ScDataPilotItemObj::~ScDataPilotItemObj()
3329 ::rtl::OUString SAL_CALL
ScDataPilotItemObj::getName() throw(::com::sun::star::uno::RuntimeException
)
3333 ScDPObject
* pDPObj(pParent
->GetDPObject());
3336 uno::Reference
<container::XNameAccess
> xMembers
;
3337 if (lcl_GetMembers(pParent
, aSourceIdent
, xMembers
))
3339 uno::Reference
<container::XIndexAccess
> xMembersIndex(new ScNameToIndexAccess( xMembers
));
3340 sal_Int32 nCount
= xMembersIndex
->getCount();
3341 if (nIndex
< static_cast<SCSIZE
>(nCount
))
3343 uno::Reference
<container::XNamed
> xMember(xMembersIndex
->getByIndex(static_cast<sal_Int32
>(nIndex
)), uno::UNO_QUERY
);
3344 sRet
= xMember
->getName();
3351 void SAL_CALL
ScDataPilotItemObj::setName( const ::rtl::OUString
& /* aName */ )
3352 throw(::com::sun::star::uno::RuntimeException
)
3357 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
3358 SAL_CALL
ScDataPilotItemObj::getPropertySetInfo( )
3359 throw(::com::sun::star::uno::RuntimeException
)
3362 static uno::Reference
<beans::XPropertySetInfo
> aRef
=
3363 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() );
3367 void SAL_CALL
ScDataPilotItemObj::setPropertyValue( const ::rtl::OUString
& aPropertyName
,
3368 const ::com::sun::star::uno::Any
& aValue
)
3369 throw(::com::sun::star::beans::UnknownPropertyException
,
3370 ::com::sun::star::beans::PropertyVetoException
,
3371 ::com::sun::star::lang::IllegalArgumentException
,
3372 ::com::sun::star::lang::WrappedTargetException
,
3373 ::com::sun::star::uno::RuntimeException
)
3376 String aNameString
= aPropertyName
;
3378 ScDPObject
* pDPObj(pParent
->GetDPObject());
3381 uno::Reference
<container::XNameAccess
> xMembers
;
3382 ScDPSaveDimension
* pDim
= NULL
;
3383 if (lcl_GetMembers(pParent
, aSourceIdent
, xMembers
) && lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
3385 uno::Reference
<container::XIndexAccess
> xMembersIndex(new ScNameToIndexAccess( xMembers
));
3386 sal_Int32 nCount
= xMembersIndex
->getCount();
3387 if (nIndex
< static_cast<SCSIZE
>(nCount
) )
3389 uno::Reference
<container::XNamed
> xMember(xMembersIndex
->getByIndex(static_cast<sal_Int32
>(nIndex
)), uno::UNO_QUERY
);
3390 String
sName(xMember
->getName());
3391 ScDPSaveMember
* pMember
= pDim
->GetMemberByName(sName
);
3394 bool bGetNewIndex
= false;
3395 if ( aNameString
.EqualsAscii( SC_UNONAME_SHOWDETAIL
) )
3396 pMember
->SetShowDetails(cppu::any2bool(aValue
));
3397 else if ( aNameString
.EqualsAscii( SC_UNONAME_ISHIDDEN
) )
3398 pMember
->SetIsVisible(!cppu::any2bool(aValue
));
3399 else if ( aNameString
.EqualsAscii( SC_UNONAME_POS
) )
3401 sal_Int32 nNewPos
= 0;
3402 if ( ( aValue
>>= nNewPos
) && nNewPos
>= 0 && nNewPos
< nCount
)
3404 pDim
->SetMemberPosition( sName
, nNewPos
);
3405 // get new effective index (depends on sorting mode, which isn't modified)
3406 bGetNewIndex
= true;
3409 throw lang::IllegalArgumentException();
3411 pParent
->SetDPObject(pDPObj
);
3413 if ( bGetNewIndex
) // after SetDPObject, get the new index
3415 rtl::OUString
aOUName( sName
);
3416 uno::Sequence
<rtl::OUString
> aItemNames
= xMembers
->getElementNames();
3417 sal_Int32 nItemCount
= aItemNames
.getLength();
3418 for (sal_Int32 nItem
=0; nItem
<nItemCount
; ++nItem
)
3419 if (aItemNames
[nItem
] == aOUName
)
3428 ::com::sun::star::uno::Any SAL_CALL
ScDataPilotItemObj::getPropertyValue(
3429 const ::rtl::OUString
& aPropertyName
)
3430 throw(::com::sun::star::beans::UnknownPropertyException
,
3431 ::com::sun::star::lang::WrappedTargetException
,
3432 ::com::sun::star::uno::RuntimeException
)
3436 String aNameString
= aPropertyName
;
3438 ScDPObject
* pDPObj(pParent
->GetDPObject());
3441 uno::Reference
<container::XNameAccess
> xMembers
;
3442 ScDPSaveDimension
* pDim
= NULL
;
3443 if (lcl_GetMembers(pParent
, aSourceIdent
, xMembers
) && lcl_GetDim(pDPObj
, aSourceIdent
, pDim
))
3445 uno::Reference
<container::XIndexAccess
> xMembersIndex(new ScNameToIndexAccess( xMembers
));
3446 sal_Int32 nCount
= xMembersIndex
->getCount();
3447 if (nIndex
< static_cast<SCSIZE
>(nCount
) )
3449 uno::Reference
<container::XNamed
> xMember(xMembersIndex
->getByIndex(static_cast<sal_Int32
>(nIndex
)), uno::UNO_QUERY
);
3450 String
sName(xMember
->getName());
3451 ScDPSaveMember
* pMember
= pDim
->GetExistingMemberByName(sName
);
3452 if ( aNameString
.EqualsAscii( SC_UNONAME_SHOWDETAIL
) )
3454 if (pMember
&& pMember
->HasShowDetails())
3456 aRet
= cppu::bool2any(pMember
->GetShowDetails());
3460 uno::Reference
<beans::XPropertySet
> xMemberProps(xMember
, uno::UNO_QUERY
);
3461 if(xMemberProps
.is())
3463 aRet
= xMemberProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWDETA
)));
3466 aRet
= cppu::bool2any(sal_True
);
3469 else if ( aNameString
.EqualsAscii( SC_UNONAME_ISHIDDEN
) )
3471 if (pMember
&& pMember
->HasIsVisible())
3473 aRet
= cppu::bool2any(!pMember
->GetIsVisible());
3477 uno::Reference
<beans::XPropertySet
> xMemberProps(xMember
, uno::UNO_QUERY
);
3478 if(xMemberProps
.is())
3480 aRet
= cppu::bool2any(!cppu::any2bool(xMemberProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ISVISIBL
)))));
3483 aRet
= cppu::bool2any(sal_False
);
3486 else if ( aNameString
.EqualsAscii( SC_UNONAME_POS
) )
3488 aRet
<<= static_cast<sal_Int32
>( nIndex
);
3496 void SAL_CALL
ScDataPilotItemObj::addPropertyChangeListener( const ::rtl::OUString
& /* aPropertyName */,
3497 const ::com::sun::star::uno::Reference
<
3498 ::com::sun::star::beans::XPropertyChangeListener
>& /* xListener */ )
3499 throw(::com::sun::star::beans::UnknownPropertyException
,
3500 ::com::sun::star::lang::WrappedTargetException
,
3501 ::com::sun::star::uno::RuntimeException
)
3505 void SAL_CALL
ScDataPilotItemObj::removePropertyChangeListener( const ::rtl::OUString
& /* aPropertyName */,
3506 const ::com::sun::star::uno::Reference
<
3507 ::com::sun::star::beans::XPropertyChangeListener
>& /* aListener */ )
3508 throw(::com::sun::star::beans::UnknownPropertyException
,
3509 ::com::sun::star::lang::WrappedTargetException
,
3510 ::com::sun::star::uno::RuntimeException
)
3514 void SAL_CALL
ScDataPilotItemObj::addVetoableChangeListener( const ::rtl::OUString
& /* PropertyName */,
3515 const ::com::sun::star::uno::Reference
<
3516 ::com::sun::star::beans::XVetoableChangeListener
>& /* aListener */ )
3517 throw(::com::sun::star::beans::UnknownPropertyException
,
3518 ::com::sun::star::lang::WrappedTargetException
,
3519 ::com::sun::star::uno::RuntimeException
)
3523 void SAL_CALL
ScDataPilotItemObj::removeVetoableChangeListener( const ::rtl::OUString
& /* PropertyName */,
3524 const ::com::sun::star::uno::Reference
<
3525 ::com::sun::star::beans::XVetoableChangeListener
>& /* aListener */ )
3526 throw(::com::sun::star::beans::UnknownPropertyException
,
3527 ::com::sun::star::lang::WrappedTargetException
,
3528 ::com::sun::star::uno::RuntimeException
)
3532 //------------------------------------------------------------------------