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 SC_PREVIEW_HXX
20 : #define SC_PREVIEW_HXX
21 :
22 :
23 : #include <vcl/window.hxx>
24 : #include "printfun.hxx"
25 : #include "markdata.hxx"
26 :
27 : #include <vector>
28 :
29 : class ScDocShell;
30 : class ScPreviewShell;
31 : class FmFormView;
32 :
33 : class ScPreview : public Window
34 : {
35 : private:
36 : ScMarkData::MarkedTabsType maSelectedTabs;
37 : // set:
38 : long nPageNo; // Pages in document
39 : sal_uInt16 nZoom; // set Zoom
40 : Point aOffset; // positive
41 :
42 : // calculated:
43 : SCTAB nTabCount;
44 : SCTAB nTabsTested; // for how many sheets is nPages valid?
45 : std::vector<long> nPages;
46 : std::vector<long> nFirstAttr;
47 : SCTAB nTab; // Sheet
48 : long nTabPage; // Page of sheet
49 : long nTabStart; // First (real) page of the sheet
50 : long nDisplayStart; // same as above, relative to the start of counting
51 : Date aDate;
52 : Time aTime;
53 : long nTotalPages;
54 : Size aPageSize; // for GetOptimalZoom
55 : ScPrintState aState;
56 : ScPreviewLocationData* pLocationData; // stores table layout for accessibility API
57 : FmFormView* pDrawView;
58 :
59 : // internal:
60 : ScDocShell* pDocShell;
61 : ScPreviewShell* pViewShell;
62 :
63 : bool bInGetState:1;
64 : bool bValid:1; // the following values true
65 : bool bStateValid:1;
66 : bool bLocationValid:1;
67 : bool bInPaint:1;
68 : bool bInSetZoom:1;
69 : bool bLeftRulerMove:1;
70 : bool bRightRulerMove:1;
71 : bool bTopRulerMove:1;
72 : bool bBottomRulerMove:1;
73 : bool bHeaderRulerMove:1;
74 : bool bFooterRulerMove:1;
75 : bool bLeftRulerChange:1;
76 : bool bRightRulerChange:1;
77 : bool bTopRulerChange:1;
78 : bool bBottomRulerChange:1;
79 : bool bHeaderRulerChange:1;
80 : bool bFooterRulerChange:1;
81 : bool bPageMargin:1;
82 : bool bColRulerMove:1;
83 : bool mbHasEmptyRangeTable:1; /// we have at least one sheet with empty print range (print range set to '- none -').
84 :
85 : ScRange aPageArea;
86 : long nRight[ MAXCOL+1 ];
87 : long nLeftPosition;
88 : long mnScale;
89 : SCCOL nColNumberButttonDown;
90 : Point aButtonDownChangePoint;
91 : Point aButtonDownPt;
92 : Point aButtonUpPt;
93 : long nHeaderHeight;
94 : long nFooterHeight;
95 :
96 : void TestLastPage();
97 : void CalcPages();
98 : void RecalcPages();
99 : void UpdateDrawView();
100 : void DoPrint( ScPreviewLocationData* pFillLocation );
101 :
102 : void InvalidateLocationData( sal_uLong nId );
103 :
104 : using Window::SetZoom;
105 :
106 : protected:
107 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
108 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
109 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
110 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
111 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
112 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
113 :
114 : virtual void GetFocus() SAL_OVERRIDE;
115 : virtual void LoseFocus() SAL_OVERRIDE;
116 :
117 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
118 :
119 : public:
120 : ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh );
121 : virtual ~ScPreview();
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, sal_uInt16 nFlags );
136 : void DragMove( long nDragMovePos, sal_uInt16 nFlags );
137 :
138 :
139 : const ScPreviewLocationData& GetLocationData();
140 :
141 : OUString GetPosString();
142 :
143 0 : long GetPageNo() const { return nPageNo; }
144 0 : sal_uInt16 GetZoom() const { return nZoom; }
145 0 : Point GetOffset() const { return aOffset; }
146 :
147 0 : SCTAB GetTab() { if (!bValid) { CalcPages(); RecalcPages(); } return nTab; }
148 0 : long GetTotalPages() { if (!bValid) { CalcPages(); RecalcPages(); } return nTotalPages; }
149 :
150 0 : bool AllTested() const { return bValid && nTabsTested >= nTabCount; }
151 :
152 : sal_uInt16 GetOptimalZoom(bool bWidthOnly);
153 : SC_DLLPUBLIC long GetFirstPage(SCTAB nTab);
154 :
155 0 : void CalcAll() { CalcPages(); }
156 0 : void SetInGetState(bool bSet) { bInGetState = bSet; }
157 :
158 : DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* );
159 : static void StaticInvalidate();
160 :
161 0 : FmFormView* GetDrawView() { return pDrawView; }
162 :
163 : virtual void SwitchView();
164 :
165 : SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData& rMark);
166 : SC_DLLPUBLIC const ScMarkData::MarkedTabsType& GetSelectedTabs() const;
167 : };
168 :
169 : #endif
170 :
171 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|