1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright IBM Corporation 2009.
6 * Copyright 2009 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * $RCSfile: dpglobal.hxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
31 // Wang Xu Ming - DataPilot migration
32 // Buffer&&Performance
34 #ifndef _SC_DPGLOBAL_HXX
35 #define _SC_DPGLOBAL_HXX
39 #include <tools/gen.hxx>
40 #include <tools/debug.hxx>
43 #include <com/sun/star/container/XNamed.hpp>
44 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
46 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
47 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
48 #include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
49 #include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
50 #include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
51 #include <com/sun/star/sheet/DataPilotTableResultData.hpp>
52 #include <com/sun/star/sheet/DataResultFlags.hpp>
53 #include <com/sun/star/sheet/GeneralFunction.hpp>
54 #include <com/sun/star/sheet/MemberResultFlags.hpp>
55 #include <com/sun/star/sheet/TableFilterField.hpp>
56 #include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
57 #include <com/sun/star/sheet/XDataPilotResults.hpp>
58 #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
59 #include <com/sun/star/sheet/XLevelsSupplier.hpp>
62 // moved from fieldwnd.hxx, see also SC_DAPI_MAXFIELDS
63 #define MAX_LABELS 256
65 #define MAX_PAGEFIELDS 10 // maximum count of fields for page area
67 #define PIVOT_MAXFUNC 11
68 #define PIVOT_FUNC_NONE 0x0000
69 #define PIVOT_FUNC_SUM 0x0001
70 #define PIVOT_FUNC_COUNT 0x0002
71 #define PIVOT_FUNC_AVERAGE 0x0004
72 #define PIVOT_FUNC_MAX 0x0008
73 #define PIVOT_FUNC_MIN 0x0010
74 #define PIVOT_FUNC_PRODUCT 0x0020
75 #define PIVOT_FUNC_COUNT_NUM 0x0040
76 #define PIVOT_FUNC_STD_DEV 0x0080
77 #define PIVOT_FUNC_STD_DEVP 0x0100
78 #define PIVOT_FUNC_STD_VAR 0x0200
79 #define PIVOT_FUNC_STD_VARP 0x0400
80 #define PIVOT_FUNC_AUTO 0x1000
82 #define DATA_RENAME_SEPARATOR "_"
83 #define __MAX_NUM_LEN 64
84 #define __DECIMALPLACE 18
86 #define DP_PROP_COLUMNGRAND "ColumnGrand"
87 #define DP_PROP_FUNCTION "Function"
88 #define DP_PROP_IGNOREEMPTY "IgnoreEmptyRows"
89 #define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension"
90 #define DP_PROP_ISVISIBLE "IsVisible"
91 #define DP_PROP_ORIENTATION "Orientation"
92 #define DP_PROP_REPEATIFEMPTY "RepeatIfEmpty"
93 #define DP_PROP_ROWGRAND "RowGrand"
94 #define DP_PROP_SHOWDETAILS "ShowDetails"
95 #define DP_PROP_SHOWEMPTY "ShowEmpty"
96 #define DP_PROP_SUBTOTALS "SubTotals"
97 #define DP_PROP_USEDHIERARCHY "UsedHierarchy"
98 #define DP_PROP_FILTER "Filter"
99 #define DP_PROP_POSITION "Position"
101 #define DBG_TRACESTR( x ) \
103 ByteString aTemp( x , RTL_TEXTENCODING_UTF8 ); \
104 DBG_TRACE( aTemp.GetBuffer() );\
110 class SC_DLLPUBLIC ScDPItemData
113 enum { MK_VAL
= 0x01, MK_DATA
= MK_VAL
<<1, MK_ERR
= MK_DATA
<<1, MK_DATE
= MK_ERR
<<1, MK_DATEPART
= MK_DATE
<<1 };
118 sal_Int32 mnDatePart
;
124 //BOOL bHasValue: 1 ;
128 friend class ScDPTableDataCache
;
130 ScDPItemData() : nNumFormat( 0 ), fValue(0.0), mbFlag( 0 ){}
131 ScDPItemData( ULONG nNF
, const String
& rS
, double fV
, BYTE bF
):nNumFormat(nNF
), aString(rS
), fValue(fV
), mbFlag( bF
){}
132 ScDPItemData( const String
& rS
, double fV
= 0.0, BOOL bHV
= FALSE
, const ULONG nNumFormat
= 0 , BOOL bData
= TRUE
) ;
133 ScDPItemData( ScDocument
* pDoc
, SCROW nRow
, USHORT nCol
, USHORT nDocTab
);
135 void SetString( const String
& rS
) { aString
= rS
; mbFlag
&= ~(MK_VAL
|MK_DATE
); nNumFormat
= 0; mbFlag
|= MK_DATA
; }
136 // void SetValue ( double value , ULONG nNumFormat = 0 ) { bHasValue = TRUE; nNumFormat = 0;bHasData = TRUE; bDate = FALSE; fValue = value ;}
137 BOOL
IsCaseInsEqual( const ScDPItemData
& r
) const;
142 BOOL
operator==( const ScDPItemData
& r
) const;
143 // case insensitive equality
144 static sal_Int32
Compare( const ScDPItemData
& rA
, const ScDPItemData
& rB
);
151 BOOL
IsHasData() const ;
152 BOOL
IsHasErr() const ;
153 BOOL
IsValue() const;
154 String
GetString() const ;
155 double GetValue() const ;
156 ULONG
GetNumFormat() const ;
157 BOOL
HasStringData() const ;
159 BOOL
HasDatePart() const;
160 void SetDate( BOOL b
) ;
162 TypedStrData
* CreateTypeString( );
163 sal_uInt8
GetType() const;
164 BYTE
& GetFlag() throw() { return mbFlag
; }
165 const BYTE
& GetFlag() const throw() { return const_cast<ScDPItemData
*>(this)->GetFlag(); }
168 class SC_DLLPUBLIC ScDPItemDataPool
172 ScDPItemDataPool(void);
173 ScDPItemDataPool(const ScDPItemDataPool
& r
);
175 virtual ~ScDPItemDataPool(void);
176 virtual const ScDPItemData
* getData( sal_Int32 nId
);
177 virtual sal_Int32
getDataId( const ScDPItemData
& aData
);
178 virtual sal_Int32
insertData( const ScDPItemData
& aData
);
180 struct DataHashFunc
: public std::unary_function
< const ScDPItemData
&, size_t >
182 size_t operator() (const ScDPItemData
&rData
) const { return rData
.Hash(); }
185 typedef ::std::hash_multimap
< ScDPItemData
, sal_Int32
, DataHashFunc
> DataHash
;
187 ::std::vector
< ScDPItemData
> maItems
;
193 class ScTabViewShell
;
196 // used for core data
197 String
GetFieldFuncString( const String
& rSourceName
, USHORT
&rFuncMask
, BOOL bIsValue
);
198 String
GetFuncString( const String
&rString
, const USHORT nIndex
);
199 com::sun::star::uno::Reference
<com::sun::star::container::XNameAccess
> DP_GetMembers( const com::sun::star::uno::Reference
<
200 com::sun::star::sheet::XDimensionsSupplier
>&rSrc
, long nField
);
202 String
operator + ( const String
& rL
, const String
&rR
);
203 Rectangle
operator *( const Rectangle
&rLeft
, const std::pair
<double,double> & rRight
);
204 // used for DataPilot Panel
205 ScDPInfoWnd
* GetDPInfoWnd( ScTabViewShell
*pViewShell
);
206 bool ChkDPTableOverlap( ScDocument
*pDestDoc
, std::list
<ScDPObject
> & rClipboard
, SCCOL nClipStartCol
, SCROW nClipStartRow
, SCCOL nStartCol
, SCROW nStartRow
, SCTAB nStartTab
, USHORT nEndTab
, BOOL bExcludeClip
= FALSE
);