xref: /aoo41x/main/sc/source/ui/inc/prevloc.hxx (revision 38d50f7b)
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_PREVLOC_HXX
25 #define SC_PREVLOC_HXX
26 
27 #include "address.hxx"
28 #include <tools/list.hxx>
29 #include <vcl/mapmod.hxx>
30 #include <sal/types.h>
31 
32 
33 #define SC_PREVIEW_MAXRANGES	4
34 #define SC_PREVIEW_RANGE_EDGE   0
35 #define SC_PREVIEW_RANGE_REPCOL 1
36 #define SC_PREVIEW_RANGE_REPROW 2
37 #define SC_PREVIEW_RANGE_TAB    3
38 
39 class OutputDevice;
40 class String;
41 class Point;
42 class Rectangle;
43 class ScAddress;
44 class ScRange;
45 class ScDocument;
46 
47 struct ScPreviewColRowInfo
48 {
49 	sal_Bool	bIsHeader;
50 	SCCOLROW    nDocIndex;
51 	long	nPixelStart;
52 	long	nPixelEnd;
53 
SetScPreviewColRowInfo54 	void Set( sal_Bool bHeader, SCCOLROW nIndex, long nStart, long nEnd )
55 	{
56 		bIsHeader   = bHeader;
57 		nDocIndex   = nIndex;
58 		nPixelStart = nStart;
59 		nPixelEnd   = nEnd;
60 	}
61 };
62 
63 class ScPreviewTableInfo
64 {
65 	SCTAB					nTab;
66 	SCCOL					nCols;
67 	SCROW					nRows;
68 	ScPreviewColRowInfo*	pColInfo;
69 	ScPreviewColRowInfo*	pRowInfo;
70 
71 public:
72 			ScPreviewTableInfo();
73 			~ScPreviewTableInfo();
74 
GetTab() const75 	SCTAB						GetTab() const		{ return nTab; }
GetCols() const76 	SCCOL						GetCols() const		{ return nCols; }
GetRows() const77 	SCROW						GetRows() const		{ return nRows; }
GetColInfo() const78 	const ScPreviewColRowInfo*	GetColInfo() const	{ return pColInfo; }
GetRowInfo() const79 	const ScPreviewColRowInfo*	GetRowInfo() const	{ return pRowInfo; }
80 
81 	void	SetTab( SCTAB nNewTab );
82 	void	SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
83 	void	SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo );
84 	void	LimitToArea( const Rectangle& rPixelArea );
85 };
86 
87 
88 class ScPreviewLocationData
89 {
90     OutputDevice* pWindow;
91 	ScDocument*	pDoc;
92 	MapMode		aCellMapMode;
93 	MapMode		aDrawMapMode[SC_PREVIEW_MAXRANGES];
94 	Rectangle	aDrawRectangle[SC_PREVIEW_MAXRANGES];
95     	sal_uInt8   	aDrawRangeId[SC_PREVIEW_MAXRANGES];
96 	sal_uInt16		nDrawRanges;
97 	SCTAB		nPrintTab;
98 	List		aEntries;
99 
100 //UNUSED2008-05  ScAddress	GetCellFromRange( const Size& rOffsetPixel, const ScRange& rRange ) const;
101 	Rectangle	GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
102 
103 public:
104 			ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
105 			~ScPreviewLocationData();
106 
107 	void	SetCellMapMode( const MapMode& rMapMode );
108 	void	SetPrintTab( SCTAB nNew );
109 	void	Clear();
110 	void	AddCellRange( const Rectangle& rRect, const ScRange& rRange, sal_Bool bRepCol, sal_Bool bRepRow,
111 							const MapMode& rDrawMap );
112 	void	AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, sal_Bool bRepCol );
113 	void	AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, sal_Bool bRepRow );
114 	void	AddHeaderFooter( const Rectangle& rRect, sal_Bool bHeader, sal_Bool bLeft );
115 	void	AddNoteMark( const Rectangle& rRect, const ScAddress& rPos );
116 	void	AddNoteText( const Rectangle& rRect, const ScAddress& rPos );
117 
GetPrintTab() const118 	SCTAB	GetPrintTab() const		{ return nPrintTab; }
119 
120 	//	Get info on visible columns/rows in the visible area
121 	void	GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
122 
GetDrawRanges() const123 	sal_uInt16	GetDrawRanges() const	{ return nDrawRanges; }
124 	void	GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
125 
126 	sal_Bool	GetHeaderPosition( Rectangle& rHeaderRect ) const;
127 	sal_Bool	GetFooterPosition( Rectangle& rFooterRect ) const;
128 	sal_Bool	IsHeaderLeft() const;
129 	sal_Bool	IsFooterLeft() const;
130 
131 	long	GetNoteCountInRange( const Rectangle& rVisiblePixel, sal_Bool bNoteMarks ) const;
132 	sal_Bool	GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, sal_Bool bNoteMarks,
133 							ScAddress& rCellPos, Rectangle& rNoteRect ) const;
134     Rectangle GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, sal_Bool bNoteMarks,
135                             const ScAddress& aCellPos) const;
136 
137 	//	Check if any cells (including column/row headers) are in the visible area
138 	sal_Bool	HasCellsInRange( const Rectangle& rVisiblePixel ) const;
139 
140 	sal_Bool	GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const;
141 
142 	// returns the rectangle where the EditEngine draws the text of a Header Cell
143 	// if bColHeader is true it returns the rectangle of the header of the column in rCellPos
144 	// otherwise of the header of the row in rCellPos
145 	Rectangle GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, sal_Bool bColHeader) const;
146 	Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
147 
148     // Query the range and rectangle of the main (non-repeat) cell range.
149 	// Returns sal_False if not contained.
150     sal_Bool    GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const;
151 };
152 
153 #endif
154