xref: /AOO41X/main/sc/source/ui/inc/preview.hxx (revision 38d50f7b14e1cf975d8c6468d9633894cd59b523)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir #ifndef SC_PREVIEW_HXX
24cdf0e10cSrcweir #define SC_PREVIEW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vcl/window.hxx>
28cdf0e10cSrcweir #include "printfun.hxx"		// ScPrintState
29cdf0e10cSrcweir 
30cdf0e10cSrcweir class ScDocShell;
31cdf0e10cSrcweir class ScPreviewShell;
32cdf0e10cSrcweir class FmFormView;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class ScPreview : public Window
35cdf0e10cSrcweir {
36cdf0e10cSrcweir private:
37cdf0e10cSrcweir 										// eingestellt:
38cdf0e10cSrcweir 	long			nPageNo;			// Seite im Dokument
39cdf0e10cSrcweir 	sal_uInt16			nZoom;				// eingestellter Zoom
40cdf0e10cSrcweir 	Point			aOffset;			// positiv
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 										// berechnet:
43cdf0e10cSrcweir 	sal_Bool			bValid;				// folgende Werte gueltig
44cdf0e10cSrcweir 	SCTAB			nTabCount;
45cdf0e10cSrcweir 	SCTAB			nTabsTested;		// fuer wieviele Tabellen ist nPages gueltig?
46cdf0e10cSrcweir 	long			nPages[MAXTABCOUNT];
47cdf0e10cSrcweir 	long			nFirstAttr[MAXTABCOUNT];
48cdf0e10cSrcweir 	SCTAB			nTab;				// Tabelle
49cdf0e10cSrcweir 	long			nTabPage;			// Seite von Tabelle
50cdf0e10cSrcweir 	long			nTabStart;			// erste Seite der Tabelle (wirklich)
51cdf0e10cSrcweir 	long			nDisplayStart;		// dito, relativ zum Anfang der Zaehlung
52cdf0e10cSrcweir 	Date			aDate;
53cdf0e10cSrcweir 	Time			aTime;
54cdf0e10cSrcweir 	long			nTotalPages;
55cdf0e10cSrcweir 	Size			aPageSize;			// fuer GetOptimalZoom
56cdf0e10cSrcweir 	sal_Bool			bStateValid;
57cdf0e10cSrcweir 	sal_Bool			bLocationValid;
58cdf0e10cSrcweir 	ScPrintState	aState;
59cdf0e10cSrcweir 	ScPreviewLocationData* pLocationData;	// stores table layout for accessibility API
60cdf0e10cSrcweir 	FmFormView*		pDrawView;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 										// intern:
63cdf0e10cSrcweir     bool            bInPaint;
64cdf0e10cSrcweir     bool            bInSetZoom;
65cdf0e10cSrcweir 	sal_Bool		bInGetState;
66cdf0e10cSrcweir 	ScDocShell*		pDocShell;
67cdf0e10cSrcweir 	ScPreviewShell*	pViewShell;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     sal_Bool            bLeftRulerMove;
70cdf0e10cSrcweir     sal_Bool            bRightRulerMove;
71cdf0e10cSrcweir     sal_Bool            bTopRulerMove;
72cdf0e10cSrcweir     sal_Bool            bBottomRulerMove;
73cdf0e10cSrcweir     sal_Bool            bHeaderRulerMove;
74cdf0e10cSrcweir     sal_Bool            bFooterRulerMove;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     sal_Bool            bLeftRulerChange;
77cdf0e10cSrcweir     sal_Bool            bRightRulerChange;
78cdf0e10cSrcweir     sal_Bool            bTopRulerChange;
79cdf0e10cSrcweir     sal_Bool            bBottomRulerChange;
80cdf0e10cSrcweir     sal_Bool            bHeaderRulerChange;
81cdf0e10cSrcweir     sal_Bool            bFooterRulerChange;
82cdf0e10cSrcweir     sal_Bool            bPageMargin;
83cdf0e10cSrcweir     sal_Bool            bColRulerMove;
84cdf0e10cSrcweir     ScRange         aPageArea;
85cdf0e10cSrcweir     long            nRight[ MAXCOL+1 ];
86cdf0e10cSrcweir     long            nLeftPosition;
87cdf0e10cSrcweir     long            mnScale;
88cdf0e10cSrcweir     SCCOL           nColNumberButttonDown;
89cdf0e10cSrcweir     Point           aButtonDownChangePoint;
90cdf0e10cSrcweir     Point           aButtonDownPt;
91cdf0e10cSrcweir     Point           aButtonUpPt;
92cdf0e10cSrcweir     long            nHeaderHeight;
93cdf0e10cSrcweir     long            nFooterHeight;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	void	TestLastPage();
96cdf0e10cSrcweir 	void	CalcPages( SCTAB nToWhichTab );
97cdf0e10cSrcweir 	void	RecalcPages();
98cdf0e10cSrcweir 	void	UpdateDrawView();
99cdf0e10cSrcweir 	void	DoPrint( ScPreviewLocationData* pFillLocation );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	void	InvalidateLocationData( sal_uLong nId );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     using Window::SetZoom;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir protected:
106cdf0e10cSrcweir     virtual void   Paint( const Rectangle& rRect );
107cdf0e10cSrcweir     virtual void   Command( const CommandEvent& rCEvt );
108cdf0e10cSrcweir     virtual void   KeyInput( const KeyEvent& rKEvt );
109cdf0e10cSrcweir     virtual void   MouseMove( const MouseEvent& rMEvt );
110cdf0e10cSrcweir     virtual void   MouseButtonDown( const MouseEvent& rMEvt );
111cdf0e10cSrcweir     virtual void   MouseButtonUp( const MouseEvent& rMEvt );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     virtual void   GetFocus();
114cdf0e10cSrcweir     virtual void   LoseFocus();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir public:
119cdf0e10cSrcweir 			ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh );
120cdf0e10cSrcweir 			~ScPreview();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	virtual void DataChanged( const DataChangedEvent& rDCEvt );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	void	DataChanged(sal_Bool bNewTime = sal_False);				// statt Invalidate rufen
125cdf0e10cSrcweir 	void	DoInvalidate();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	void	SetXOffset( long nX );
128cdf0e10cSrcweir 	void	SetYOffset( long nY );
129cdf0e10cSrcweir 	void	SetZoom(sal_uInt16 nNewZoom);
130cdf0e10cSrcweir 	void	SetPageNo( long nPage );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     sal_Bool    GetPageMargins()const { return bPageMargin; }
133cdf0e10cSrcweir     void    SetPageMargins( sal_Bool bVal )  { bPageMargin = bVal; }
134cdf0e10cSrcweir     void    DrawInvert( long nDragPos, sal_uInt16 nFlags );
135cdf0e10cSrcweir     void    DragMove( long nDragMovePos, sal_uInt16 nFlags );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	const ScPreviewLocationData& GetLocationData();
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	String	GetPosString();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	long	GetPageNo() const	{ return nPageNo; }
143cdf0e10cSrcweir 	sal_uInt16	GetZoom() const		{ return nZoom; }
144cdf0e10cSrcweir 	Point	GetOffset() const	{ return aOffset; }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	SCTAB	GetTab()			{ if (!bValid) { CalcPages(0); RecalcPages(); } return nTab; }
147cdf0e10cSrcweir 	long	GetTotalPages()		{ if (!bValid) { CalcPages(0); RecalcPages(); } return nTotalPages; }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	sal_Bool	AllTested() const	{ return bValid && nTabsTested >= nTabCount; }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	sal_uInt16	GetOptimalZoom(sal_Bool bWidthOnly);
152cdf0e10cSrcweir 	long	GetFirstPage(SCTAB nTab);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	void	CalcAll()			{ CalcPages(MAXTAB); }
155cdf0e10cSrcweir 	void	SetInGetState(sal_Bool bSet) { bInGetState = bSet; }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* );
158cdf0e10cSrcweir 	static void StaticInvalidate();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     FmFormView* GetDrawView() { return pDrawView; }
161cdf0e10cSrcweir };
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 
165cdf0e10cSrcweir #endif
166