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