xref: /aoo4110/main/sc/inc/dpoutput.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_DPOUTPUT_HXX
25 #define SC_DPOUTPUT_HXX
26 
27 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
28 #include <com/sun/star/sheet/DataResult.hpp>
29 #include <com/sun/star/sheet/MemberResult.hpp>
30 #include <com/sun/star/sheet/GeneralFunction.hpp>
31 #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
32 
33 #include "global.hxx"
34 #include "address.hxx"
35 
36 #include "dpcachetable.hxx"
37 #include <vector>
38 
39 namespace com { namespace sun { namespace star { namespace sheet {
40     struct DataPilotFieldFilter;
41     struct DataPilotTablePositionData;
42 }}}}
43 
44 class Rectangle;
45 class SvStream;
46 class ScDocument;
47 class ScStrCollection;
48 
49 struct ScDPOutLevelData;
50 
51 
52 struct ScDPGetPivotDataField
53 {
54     String maFieldName;
55     com::sun::star::sheet::GeneralFunction meFunction;
56 
57     bool   mbValIsStr;
58     String maValStr;
59     double mnValNum;
60 
ScDPGetPivotDataFieldScDPGetPivotDataField61         ScDPGetPivotDataField() :
62             meFunction( com::sun::star::sheet::GeneralFunction_NONE ),
63             mbValIsStr( false ),
64             mnValNum( 0.0 )
65         {
66         }
67 };
68 
69 
70 
71 class ScDPOutput			//! name???
72 {
73 private:
74 	//!	use impl-object?
75 	ScDocument*				pDoc;
76 	com::sun::star::uno::Reference<
77 		com::sun::star::sheet::XDimensionsSupplier> xSource;
78 	ScAddress				aStartPos;
79 	sal_Bool					bDoFilter;
80 	ScDPOutLevelData*		pColFields;
81 	ScDPOutLevelData*		pRowFields;
82 	ScDPOutLevelData*		pPageFields;
83 	long					nColFieldCount;
84 	long					nRowFieldCount;
85 	long					nPageFieldCount;
86 	com::sun::star::uno::Sequence<
87 		com::sun::star::uno::Sequence<
88 			com::sun::star::sheet::DataResult> > aData;
89 	sal_Bool					bResultsError;
90     bool                    mbHasDataLayout;
91 	String					aDataDescription;
92 
93     // Number format related parameters
94 	sal_uInt32*					pColNumFmt;
95 	sal_uInt32*					pRowNumFmt;
96 	long					nColFmtCount;
97 	long					nRowFmtCount;
98     sal_uInt32                  nSingleNumFmt;
99 
100     // Output geometry related parameters
101 	sal_Bool					bSizesValid;
102 	sal_Bool					bSizeOverflow;
103 	long					nColCount;
104 	long					nRowCount;
105 	long					nHeaderSize;
106     bool                    mbHeaderLayout;  // sal_True : grid, sal_False : standard
107 	SCCOL					nTabStartCol;
108 	SCROW					nTabStartRow;
109 	SCCOL					nMemberStartCol;
110 	SCROW					nMemberStartRow;
111 	SCCOL					nDataStartCol;
112 	SCROW					nDataStartRow;
113 	SCCOL					nTabEndCol;
114 	SCROW					nTabEndRow;
115 
116 	void			DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
117 								const com::sun::star::sheet::DataResult& rData );
118 	void			HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
119 								const com::sun::star::sheet::MemberResult& rData,
120 								sal_Bool bColHeader, long nLevel );
121     void            FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption,
122                                bool bInTable, bool bPopup, bool bHasHiddenMember );
123 	void			CalcSizes();
124 
125     /** Query which sub-area of the table the cell is in. See
126         css.sheet.DataPilotTablePositionType for the interpretation of the
127         return value. */
128     sal_Int32       GetPositionType(const ScAddress& rPos);
129 
130 public:
131 					ScDPOutput( ScDocument* pD,
132 								const com::sun::star::uno::Reference<
133 									com::sun::star::sheet::XDimensionsSupplier>& xSrc,
134 								const ScAddress& rPos, sal_Bool bFilter );
135 					~ScDPOutput();
136 
137 	void			SetPosition( const ScAddress& rPos );
138 
139 	void			Output();			//! Refresh?
140     ScRange			GetOutputRange( sal_Int32 nRegionType = ::com::sun::star::sheet::DataPilotOutputRangeType::WHOLE );
141 	long			GetHeaderRows();
142 	sal_Bool			HasError();			// range overflow or exception from source
143 
144     void            GetPositionData(const ScAddress& rPos, ::com::sun::star::sheet::DataPilotTablePositionData& rPosData);
145 
146     /** Get filtering criteria based on the position of the cell within data
147         field region. */
148     bool            GetDataResultPositionData(::std::vector< ::com::sun::star::sheet::DataPilotFieldFilter >& rFilters, const ScAddress& rPos);
149 
150     sal_Bool            GetPivotData( ScDPGetPivotDataField& rTarget, /* returns result */
151                                   const std::vector< ScDPGetPivotDataField >& rFilters );
152 	long			GetHeaderDim( const ScAddress& rPos, sal_uInt16& rOrient );
153 	sal_Bool			GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft, sal_Bool bMouseTop,
154 									long nDragDim,
155 									Rectangle& rPosRect, sal_uInt16& rOrient, long& rDimPos );
156 	sal_Bool			IsFilterButton( const ScAddress& rPos );
157 
158     void            GetMemberResultNames( ScStrCollection& rNames, long nDimension );
159 
160     void            SetHeaderLayout(bool bUseGrid);
161     bool            GetHeaderLayout() const;
162 
163     static void     GetDataDimensionNames( String& rSourceName, String& rGivenName,
164                                            const com::sun::star::uno::Reference<
165                                                com::sun::star::uno::XInterface>& xDim );
166 };
167 
168 
169 #endif
170 
171