xref: /aoo41x/main/sc/source/ui/inc/prevloc.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SC_PREVLOC_HXX
29*cdf0e10cSrcweir #define SC_PREVLOC_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "address.hxx"
32*cdf0e10cSrcweir #include <tools/list.hxx>
33*cdf0e10cSrcweir #include <vcl/mapmod.hxx>
34*cdf0e10cSrcweir #include <sal/types.h>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #define SC_PREVIEW_MAXRANGES	4
38*cdf0e10cSrcweir #define SC_PREVIEW_RANGE_EDGE   0
39*cdf0e10cSrcweir #define SC_PREVIEW_RANGE_REPCOL 1
40*cdf0e10cSrcweir #define SC_PREVIEW_RANGE_REPROW 2
41*cdf0e10cSrcweir #define SC_PREVIEW_RANGE_TAB    3
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir class OutputDevice;
44*cdf0e10cSrcweir class String;
45*cdf0e10cSrcweir class Point;
46*cdf0e10cSrcweir class Rectangle;
47*cdf0e10cSrcweir class ScAddress;
48*cdf0e10cSrcweir class ScRange;
49*cdf0e10cSrcweir class ScDocument;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir struct ScPreviewColRowInfo
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir 	sal_Bool	bIsHeader;
54*cdf0e10cSrcweir 	SCCOLROW    nDocIndex;
55*cdf0e10cSrcweir 	long	nPixelStart;
56*cdf0e10cSrcweir 	long	nPixelEnd;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 	void Set( sal_Bool bHeader, SCCOLROW nIndex, long nStart, long nEnd )
59*cdf0e10cSrcweir 	{
60*cdf0e10cSrcweir 		bIsHeader   = bHeader;
61*cdf0e10cSrcweir 		nDocIndex   = nIndex;
62*cdf0e10cSrcweir 		nPixelStart = nStart;
63*cdf0e10cSrcweir 		nPixelEnd   = nEnd;
64*cdf0e10cSrcweir 	}
65*cdf0e10cSrcweir };
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir class ScPreviewTableInfo
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir 	SCTAB					nTab;
70*cdf0e10cSrcweir 	SCCOL					nCols;
71*cdf0e10cSrcweir 	SCROW					nRows;
72*cdf0e10cSrcweir 	ScPreviewColRowInfo*	pColInfo;
73*cdf0e10cSrcweir 	ScPreviewColRowInfo*	pRowInfo;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir public:
76*cdf0e10cSrcweir 			ScPreviewTableInfo();
77*cdf0e10cSrcweir 			~ScPreviewTableInfo();
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 	SCTAB						GetTab() const		{ return nTab; }
80*cdf0e10cSrcweir 	SCCOL						GetCols() const		{ return nCols; }
81*cdf0e10cSrcweir 	SCROW						GetRows() const		{ return nRows; }
82*cdf0e10cSrcweir 	const ScPreviewColRowInfo*	GetColInfo() const	{ return pColInfo; }
83*cdf0e10cSrcweir 	const ScPreviewColRowInfo*	GetRowInfo() const	{ return pRowInfo; }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	void	SetTab( SCTAB nNewTab );
86*cdf0e10cSrcweir 	void	SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
87*cdf0e10cSrcweir 	void	SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo );
88*cdf0e10cSrcweir 	void	LimitToArea( const Rectangle& rPixelArea );
89*cdf0e10cSrcweir };
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir class ScPreviewLocationData
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir     OutputDevice* pWindow;
95*cdf0e10cSrcweir 	ScDocument*	pDoc;
96*cdf0e10cSrcweir 	MapMode		aCellMapMode;
97*cdf0e10cSrcweir 	MapMode		aDrawMapMode[SC_PREVIEW_MAXRANGES];
98*cdf0e10cSrcweir 	Rectangle	aDrawRectangle[SC_PREVIEW_MAXRANGES];
99*cdf0e10cSrcweir     	sal_uInt8   	aDrawRangeId[SC_PREVIEW_MAXRANGES];
100*cdf0e10cSrcweir 	sal_uInt16		nDrawRanges;
101*cdf0e10cSrcweir 	SCTAB		nPrintTab;
102*cdf0e10cSrcweir 	List		aEntries;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir //UNUSED2008-05  ScAddress	GetCellFromRange( const Size& rOffsetPixel, const ScRange& rRange ) const;
105*cdf0e10cSrcweir 	Rectangle	GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir public:
108*cdf0e10cSrcweir 			ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
109*cdf0e10cSrcweir 			~ScPreviewLocationData();
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	void	SetCellMapMode( const MapMode& rMapMode );
112*cdf0e10cSrcweir 	void	SetPrintTab( SCTAB nNew );
113*cdf0e10cSrcweir 	void	Clear();
114*cdf0e10cSrcweir 	void	AddCellRange( const Rectangle& rRect, const ScRange& rRange, sal_Bool bRepCol, sal_Bool bRepRow,
115*cdf0e10cSrcweir 							const MapMode& rDrawMap );
116*cdf0e10cSrcweir 	void	AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, sal_Bool bRepCol );
117*cdf0e10cSrcweir 	void	AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, sal_Bool bRepRow );
118*cdf0e10cSrcweir 	void	AddHeaderFooter( const Rectangle& rRect, sal_Bool bHeader, sal_Bool bLeft );
119*cdf0e10cSrcweir 	void	AddNoteMark( const Rectangle& rRect, const ScAddress& rPos );
120*cdf0e10cSrcweir 	void	AddNoteText( const Rectangle& rRect, const ScAddress& rPos );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	SCTAB	GetPrintTab() const		{ return nPrintTab; }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	//	Get info on visible columns/rows in the visible area
125*cdf0e10cSrcweir 	void	GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	sal_uInt16	GetDrawRanges() const	{ return nDrawRanges; }
128*cdf0e10cSrcweir 	void	GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	sal_Bool	GetHeaderPosition( Rectangle& rHeaderRect ) const;
131*cdf0e10cSrcweir 	sal_Bool	GetFooterPosition( Rectangle& rFooterRect ) const;
132*cdf0e10cSrcweir 	sal_Bool	IsHeaderLeft() const;
133*cdf0e10cSrcweir 	sal_Bool	IsFooterLeft() const;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	long	GetNoteCountInRange( const Rectangle& rVisiblePixel, sal_Bool bNoteMarks ) const;
136*cdf0e10cSrcweir 	sal_Bool	GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, sal_Bool bNoteMarks,
137*cdf0e10cSrcweir 							ScAddress& rCellPos, Rectangle& rNoteRect ) const;
138*cdf0e10cSrcweir     Rectangle GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, sal_Bool bNoteMarks,
139*cdf0e10cSrcweir                             const ScAddress& aCellPos) const;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	//	Check if any cells (including column/row headers) are in the visible area
142*cdf0e10cSrcweir 	sal_Bool	HasCellsInRange( const Rectangle& rVisiblePixel ) const;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	sal_Bool	GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	// returns the rectangle where the EditEngine draws the text of a Header Cell
147*cdf0e10cSrcweir 	// if bColHeader is true it returns the rectangle of the header of the column in rCellPos
148*cdf0e10cSrcweir 	// otherwise of the header of the row in rCellPos
149*cdf0e10cSrcweir 	Rectangle GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, sal_Bool bColHeader) const;
150*cdf0e10cSrcweir 	Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     // Query the range and rectangle of the main (non-repeat) cell range.
153*cdf0e10cSrcweir 	// Returns sal_False if not contained.
154*cdf0e10cSrcweir     sal_Bool    GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const;
155*cdf0e10cSrcweir };
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir #endif
158