xref: /AOO41X/main/sc/source/ui/inc/preview.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #ifndef SC_PREVIEW_HXX
28*cdf0e10cSrcweir #define SC_PREVIEW_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <vcl/window.hxx>
32*cdf0e10cSrcweir #include "printfun.hxx"		// ScPrintState
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir class ScDocShell;
35*cdf0e10cSrcweir class ScPreviewShell;
36*cdf0e10cSrcweir class FmFormView;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir class ScPreview : public Window
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir private:
41*cdf0e10cSrcweir 										// eingestellt:
42*cdf0e10cSrcweir 	long			nPageNo;			// Seite im Dokument
43*cdf0e10cSrcweir 	sal_uInt16			nZoom;				// eingestellter Zoom
44*cdf0e10cSrcweir 	Point			aOffset;			// positiv
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 										// berechnet:
47*cdf0e10cSrcweir 	sal_Bool			bValid;				// folgende Werte gueltig
48*cdf0e10cSrcweir 	SCTAB			nTabCount;
49*cdf0e10cSrcweir 	SCTAB			nTabsTested;		// fuer wieviele Tabellen ist nPages gueltig?
50*cdf0e10cSrcweir 	long			nPages[MAXTABCOUNT];
51*cdf0e10cSrcweir 	long			nFirstAttr[MAXTABCOUNT];
52*cdf0e10cSrcweir 	SCTAB			nTab;				// Tabelle
53*cdf0e10cSrcweir 	long			nTabPage;			// Seite von Tabelle
54*cdf0e10cSrcweir 	long			nTabStart;			// erste Seite der Tabelle (wirklich)
55*cdf0e10cSrcweir 	long			nDisplayStart;		// dito, relativ zum Anfang der Zaehlung
56*cdf0e10cSrcweir 	Date			aDate;
57*cdf0e10cSrcweir 	Time			aTime;
58*cdf0e10cSrcweir 	long			nTotalPages;
59*cdf0e10cSrcweir 	Size			aPageSize;			// fuer GetOptimalZoom
60*cdf0e10cSrcweir 	sal_Bool			bStateValid;
61*cdf0e10cSrcweir 	sal_Bool			bLocationValid;
62*cdf0e10cSrcweir 	ScPrintState	aState;
63*cdf0e10cSrcweir 	ScPreviewLocationData* pLocationData;	// stores table layout for accessibility API
64*cdf0e10cSrcweir 	FmFormView*		pDrawView;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 										// intern:
67*cdf0e10cSrcweir     bool            bInPaint;
68*cdf0e10cSrcweir     bool            bInSetZoom;
69*cdf0e10cSrcweir 	sal_Bool		bInGetState;
70*cdf0e10cSrcweir 	ScDocShell*		pDocShell;
71*cdf0e10cSrcweir 	ScPreviewShell*	pViewShell;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     sal_Bool            bLeftRulerMove;
74*cdf0e10cSrcweir     sal_Bool            bRightRulerMove;
75*cdf0e10cSrcweir     sal_Bool            bTopRulerMove;
76*cdf0e10cSrcweir     sal_Bool            bBottomRulerMove;
77*cdf0e10cSrcweir     sal_Bool            bHeaderRulerMove;
78*cdf0e10cSrcweir     sal_Bool            bFooterRulerMove;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     sal_Bool            bLeftRulerChange;
81*cdf0e10cSrcweir     sal_Bool            bRightRulerChange;
82*cdf0e10cSrcweir     sal_Bool            bTopRulerChange;
83*cdf0e10cSrcweir     sal_Bool            bBottomRulerChange;
84*cdf0e10cSrcweir     sal_Bool            bHeaderRulerChange;
85*cdf0e10cSrcweir     sal_Bool            bFooterRulerChange;
86*cdf0e10cSrcweir     sal_Bool            bPageMargin;
87*cdf0e10cSrcweir     sal_Bool            bColRulerMove;
88*cdf0e10cSrcweir     ScRange         aPageArea;
89*cdf0e10cSrcweir     long            nRight[ MAXCOL+1 ];
90*cdf0e10cSrcweir     long            nLeftPosition;
91*cdf0e10cSrcweir     long            mnScale;
92*cdf0e10cSrcweir     SCCOL           nColNumberButttonDown;
93*cdf0e10cSrcweir     Point           aButtonDownChangePoint;
94*cdf0e10cSrcweir     Point           aButtonDownPt;
95*cdf0e10cSrcweir     Point           aButtonUpPt;
96*cdf0e10cSrcweir     long            nHeaderHeight;
97*cdf0e10cSrcweir     long            nFooterHeight;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	void	TestLastPage();
100*cdf0e10cSrcweir 	void	CalcPages( SCTAB nToWhichTab );
101*cdf0e10cSrcweir 	void	RecalcPages();
102*cdf0e10cSrcweir 	void	UpdateDrawView();
103*cdf0e10cSrcweir 	void	DoPrint( ScPreviewLocationData* pFillLocation );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	void	InvalidateLocationData( sal_uLong nId );
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     using Window::SetZoom;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir protected:
110*cdf0e10cSrcweir     virtual void   Paint( const Rectangle& rRect );
111*cdf0e10cSrcweir     virtual void   Command( const CommandEvent& rCEvt );
112*cdf0e10cSrcweir     virtual void   KeyInput( const KeyEvent& rKEvt );
113*cdf0e10cSrcweir     virtual void   MouseMove( const MouseEvent& rMEvt );
114*cdf0e10cSrcweir     virtual void   MouseButtonDown( const MouseEvent& rMEvt );
115*cdf0e10cSrcweir     virtual void   MouseButtonUp( const MouseEvent& rMEvt );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     virtual void   GetFocus();
118*cdf0e10cSrcweir     virtual void   LoseFocus();
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir public:
123*cdf0e10cSrcweir 			ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh );
124*cdf0e10cSrcweir 			~ScPreview();
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	virtual void DataChanged( const DataChangedEvent& rDCEvt );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	void	DataChanged(sal_Bool bNewTime = sal_False);				// statt Invalidate rufen
129*cdf0e10cSrcweir 	void	DoInvalidate();
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	void	SetXOffset( long nX );
132*cdf0e10cSrcweir 	void	SetYOffset( long nY );
133*cdf0e10cSrcweir 	void	SetZoom(sal_uInt16 nNewZoom);
134*cdf0e10cSrcweir 	void	SetPageNo( long nPage );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     sal_Bool    GetPageMargins()const { return bPageMargin; }
137*cdf0e10cSrcweir     void    SetPageMargins( sal_Bool bVal )  { bPageMargin = bVal; }
138*cdf0e10cSrcweir     void    DrawInvert( long nDragPos, sal_uInt16 nFlags );
139*cdf0e10cSrcweir     void    DragMove( long nDragMovePos, sal_uInt16 nFlags );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	const ScPreviewLocationData& GetLocationData();
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	String	GetPosString();
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	long	GetPageNo() const	{ return nPageNo; }
147*cdf0e10cSrcweir 	sal_uInt16	GetZoom() const		{ return nZoom; }
148*cdf0e10cSrcweir 	Point	GetOffset() const	{ return aOffset; }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	SCTAB	GetTab()			{ if (!bValid) { CalcPages(0); RecalcPages(); } return nTab; }
151*cdf0e10cSrcweir 	long	GetTotalPages()		{ if (!bValid) { CalcPages(0); RecalcPages(); } return nTotalPages; }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	sal_Bool	AllTested() const	{ return bValid && nTabsTested >= nTabCount; }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	sal_uInt16	GetOptimalZoom(sal_Bool bWidthOnly);
156*cdf0e10cSrcweir 	long	GetFirstPage(SCTAB nTab);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	void	CalcAll()			{ CalcPages(MAXTAB); }
159*cdf0e10cSrcweir 	void	SetInGetState(sal_Bool bSet) { bInGetState = bSet; }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 	DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* );
162*cdf0e10cSrcweir 	static void StaticInvalidate();
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     FmFormView* GetDrawView() { return pDrawView; }
165*cdf0e10cSrcweir };
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir #endif
170