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