Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SC_SOURCE_UI_INC_PREVIEW_HXX
20 : #define INCLUDED_SC_SOURCE_UI_INC_PREVIEW_HXX
21 :
22 : #include <vcl/window.hxx>
23 : #include "printfun.hxx"
24 : #include "markdata.hxx"
25 :
26 : #include <vector>
27 :
28 : class ScDocShell;
29 : class ScPreviewShell;
30 : class FmFormView;
31 :
32 : class ScPreview : public vcl::Window
33 : {
34 : private:
35 : ScMarkData::MarkedTabsType maSelectedTabs;
36 : // set:
37 : long nPageNo; // Pages in document
38 : sal_uInt16 nZoom; // set Zoom
39 : Point aOffset; // positive
40 :
41 : // calculated:
42 : SCTAB nTabCount;
43 : SCTAB nTabsTested; // for how many sheets is nPages valid?
44 : std::vector<long> nPages;
45 : std::vector<long> nFirstAttr;
46 : SCTAB nTab; // Sheet
47 : long nTabPage; // Page of sheet
48 : long nTabStart; // First (real) page of the sheet
49 : long nDisplayStart; // same as above, relative to the start of counting
50 : Date aDate;
51 : tools::Time aTime;
52 : long nTotalPages;
53 : Size aPageSize; // for GetOptimalZoom
54 : ScPrintState aState;
55 : ScPreviewLocationData* pLocationData; // stores table layout for accessibility API
56 : FmFormView* pDrawView;
57 :
58 : // internal:
59 : ScDocShell* pDocShell;
60 : ScPreviewShell* pViewShell;
61 :
62 : bool bInGetState:1;
63 : bool bValid:1; // the following values true
64 : bool bStateValid:1;
65 : bool bLocationValid:1;
66 : bool bInPaint:1;
67 : bool bInSetZoom:1;
68 : bool bLeftRulerMove:1;
69 : bool bRightRulerMove:1;
70 : bool bTopRulerMove:1;
71 : bool bBottomRulerMove:1;
72 : bool bHeaderRulerMove:1;
73 : bool bFooterRulerMove:1;
74 : bool bLeftRulerChange:1;
75 : bool bRightRulerChange:1;
76 : bool bTopRulerChange:1;
77 : bool bBottomRulerChange:1;
78 : bool bHeaderRulerChange:1;
79 : bool bFooterRulerChange:1;
80 : bool bPageMargin:1;
81 : bool bColRulerMove:1;
82 : bool mbHasEmptyRangeTable:1; /// we have at least one sheet with empty print range (print range set to '- none -').
83 :
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();
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( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
107 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
108 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
109 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
110 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
111 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
112 :
113 : virtual void GetFocus() SAL_OVERRIDE;
114 : virtual void LoseFocus() SAL_OVERRIDE;
115 :
116 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
117 :
118 : public:
119 : ScPreview( vcl::Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh );
120 : virtual ~ScPreview();
121 : virtual void dispose() SAL_OVERRIDE;
122 :
123 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
124 :
125 : SC_DLLPUBLIC void DataChanged(bool bNewTime = false); // Instead of calling Invalidate
126 : void DoInvalidate();
127 :
128 : void SetXOffset( long nX );
129 : void SetYOffset( long nY );
130 : void SetZoom(sal_uInt16 nNewZoom);
131 : SC_DLLPUBLIC void SetPageNo( long nPage );
132 :
133 0 : bool GetPageMargins() const { return bPageMargin; }
134 0 : void SetPageMargins( bool bVal ) { bPageMargin = bVal; }
135 : void DrawInvert( long nDragPos, PointerStyle nFlags );
136 : void DragMove( long nDragMovePos, PointerStyle nFlags );
137 :
138 : const ScPreviewLocationData& GetLocationData();
139 :
140 : OUString GetPosString();
141 :
142 253 : long GetPageNo() const { return nPageNo; }
143 205 : sal_uInt16 GetZoom() const { return nZoom; }
144 40 : Point GetOffset() const { return aOffset; }
145 :
146 288 : SCTAB GetTab() { if (!bValid) { CalcPages(); RecalcPages(); } return nTab; }
147 253 : long GetTotalPages() { if (!bValid) { CalcPages(); RecalcPages(); } return nTotalPages; }
148 :
149 213 : bool AllTested() const { return bValid && nTabsTested >= nTabCount; }
150 :
151 : sal_uInt16 GetOptimalZoom(bool bWidthOnly);
152 : SC_DLLPUBLIC long GetFirstPage(SCTAB nTab);
153 :
154 0 : void CalcAll() { CalcPages(); }
155 406 : void SetInGetState(bool bSet) { bInGetState = bSet; }
156 :
157 : DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* );
158 : static void StaticInvalidate();
159 :
160 0 : FmFormView* GetDrawView() { return pDrawView; }
161 :
162 : SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData& rMark);
163 0 : const ScMarkData::MarkedTabsType& GetSelectedTabs() const { return maSelectedTabs; }
164 : };
165 :
166 : #endif
167 :
168 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|