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