xref: /aoo41x/main/sc/inc/dpoutput.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_DPOUTPUT_HXX
29 #define SC_DPOUTPUT_HXX
30 
31 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
32 #include <com/sun/star/sheet/DataResult.hpp>
33 #include <com/sun/star/sheet/MemberResult.hpp>
34 #include <com/sun/star/sheet/GeneralFunction.hpp>
35 #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
36 
37 #include "global.hxx"
38 #include "address.hxx"
39 
40 #include "dpcachetable.hxx"
41 #include <vector>
42 
43 namespace com { namespace sun { namespace star { namespace sheet {
44     struct DataPilotFieldFilter;
45     struct DataPilotTablePositionData;
46 }}}}
47 
48 class Rectangle;
49 class SvStream;
50 class ScDocument;
51 class ScStrCollection;
52 
53 struct ScDPOutLevelData;
54 
55 
56 struct ScDPGetPivotDataField
57 {
58     String maFieldName;
59     com::sun::star::sheet::GeneralFunction meFunction;
60 
61     bool   mbValIsStr;
62     String maValStr;
63     double mnValNum;
64 
65         ScDPGetPivotDataField() :
66             meFunction( com::sun::star::sheet::GeneralFunction_NONE ),
67             mbValIsStr( false ),
68             mnValNum( 0.0 )
69         {
70         }
71 };
72 
73 
74 
75 class ScDPOutput			//! name???
76 {
77 private:
78 	//!	use impl-object?
79 	ScDocument*				pDoc;
80 	com::sun::star::uno::Reference<
81 		com::sun::star::sheet::XDimensionsSupplier> xSource;
82 	ScAddress				aStartPos;
83 	sal_Bool					bDoFilter;
84 	ScDPOutLevelData*		pColFields;
85 	ScDPOutLevelData*		pRowFields;
86 	ScDPOutLevelData*		pPageFields;
87 	long					nColFieldCount;
88 	long					nRowFieldCount;
89 	long					nPageFieldCount;
90 	com::sun::star::uno::Sequence<
91 		com::sun::star::uno::Sequence<
92 			com::sun::star::sheet::DataResult> > aData;
93 	sal_Bool					bResultsError;
94     bool                    mbHasDataLayout;
95 	String					aDataDescription;
96 
97     // Number format related parameters
98 	sal_uInt32*					pColNumFmt;
99 	sal_uInt32*					pRowNumFmt;
100 	long					nColFmtCount;
101 	long					nRowFmtCount;
102     sal_uInt32                  nSingleNumFmt;
103 
104     // Output geometry related parameters
105 	sal_Bool					bSizesValid;
106 	sal_Bool					bSizeOverflow;
107 	long					nColCount;
108 	long					nRowCount;
109 	long					nHeaderSize;
110     bool                    mbHeaderLayout;  // sal_True : grid, sal_False : standard
111 	SCCOL					nTabStartCol;
112 	SCROW					nTabStartRow;
113 	SCCOL					nMemberStartCol;
114 	SCROW					nMemberStartRow;
115 	SCCOL					nDataStartCol;
116 	SCROW					nDataStartRow;
117 	SCCOL					nTabEndCol;
118 	SCROW					nTabEndRow;
119 
120 	void			DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
121 								const com::sun::star::sheet::DataResult& rData );
122 	void			HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
123 								const com::sun::star::sheet::MemberResult& rData,
124 								sal_Bool bColHeader, long nLevel );
125     void            FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption,
126                                bool bInTable, bool bPopup, bool bHasHiddenMember );
127 	void			CalcSizes();
128 
129     /** Query which sub-area of the table the cell is in. See
130         css.sheet.DataPilotTablePositionType for the interpretation of the
131         return value. */
132     sal_Int32       GetPositionType(const ScAddress& rPos);
133 
134 public:
135 					ScDPOutput( ScDocument* pD,
136 								const com::sun::star::uno::Reference<
137 									com::sun::star::sheet::XDimensionsSupplier>& xSrc,
138 								const ScAddress& rPos, sal_Bool bFilter );
139 					~ScDPOutput();
140 
141 	void			SetPosition( const ScAddress& rPos );
142 
143 	void			Output();			//! Refresh?
144     ScRange			GetOutputRange( sal_Int32 nRegionType = ::com::sun::star::sheet::DataPilotOutputRangeType::WHOLE );
145 	long			GetHeaderRows();
146 	sal_Bool			HasError();			// range overflow or exception from source
147 
148     void            GetPositionData(const ScAddress& rPos, ::com::sun::star::sheet::DataPilotTablePositionData& rPosData);
149 
150     /** Get filtering criteria based on the position of the cell within data
151         field region. */
152     bool            GetDataResultPositionData(::std::vector< ::com::sun::star::sheet::DataPilotFieldFilter >& rFilters, const ScAddress& rPos);
153 
154     sal_Bool            GetPivotData( ScDPGetPivotDataField& rTarget, /* returns result */
155                                   const std::vector< ScDPGetPivotDataField >& rFilters );
156 	long			GetHeaderDim( const ScAddress& rPos, sal_uInt16& rOrient );
157 	sal_Bool			GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft, sal_Bool bMouseTop,
158 									long nDragDim,
159 									Rectangle& rPosRect, sal_uInt16& rOrient, long& rDimPos );
160 	sal_Bool			IsFilterButton( const ScAddress& rPos );
161 
162     void            GetMemberResultNames( ScStrCollection& rNames, long nDimension );
163 
164     void            SetHeaderLayout(bool bUseGrid);
165     bool            GetHeaderLayout() const;
166 
167     static void     GetDataDimensionNames( String& rSourceName, String& rGivenName,
168                                            const com::sun::star::uno::Reference<
169                                                com::sun::star::uno::XInterface>& xDim );
170 };
171 
172 
173 #endif
174 
175