LibreOffice Module sc (master)  1
preview.hxx
Go to the documentation of this file.
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 SAL_DLLPUBLIC_RTTI ScPreview : public vcl::Window
33 {
34 private:
36  // set:
37  tools::Long nPageNo; // Pages in document
38  sal_uInt16 nZoom; // set Zoom
39  Point aOffset; // positive
40 
41  // calculated:
43  SCTAB nTabsTested; // for how many sheets is nPages valid?
44  std::vector<tools::Long> nPages;
45  std::vector<tools::Long> nFirstAttr;
46  SCTAB nTab; // Sheet
47  tools::Long nTabPage; // Page of sheet
48  tools::Long nTabStart; // First (real) page of the sheet
49  tools::Long nDisplayStart; // same as above, relative to the start of counting
53  std::unique_ptr<ScPreviewLocationData> pLocationData; // stores table layout for accessibility API
54  std::unique_ptr<FmFormView> pDrawView;
55 
56  // internal:
59 
60  bool bInGetState:1;
61  bool bValid:1; // the following values true
62  bool bStateValid:1;
63  bool bLocationValid:1;
64  bool bInPaint:1;
65  bool bInSetZoom:1;
66  bool bLeftRulerMove:1;
67  bool bRightRulerMove:1;
68  bool bTopRulerMove:1;
69  bool bBottomRulerMove:1;
70  bool bHeaderRulerMove:1;
71  bool bFooterRulerMove:1;
72  bool bLeftRulerChange:1;
73  bool bRightRulerChange:1;
74  bool bTopRulerChange:1;
75  bool bBottomRulerChange:1;
76  bool bHeaderRulerChange:1;
77  bool bFooterRulerChange:1;
78  bool bPageMargin:1;
79  bool bColRulerMove:1;
80  bool mbHasEmptyRangeTable:1;
81 
83  std::vector<tools::Long> mvRight;
92 
93  void TestLastPage();
94  void CalcPages();
95  void RecalcPages();
96  void UpdateDrawView();
97  void DoPrint( ScPreviewLocationData* pFillLocation );
98 
99  void InvalidateLocationData( SfxHintId nId );
100 
101  using Window::SetZoom;
102 
103 protected:
104  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
105  virtual void Command( const CommandEvent& rCEvt ) override;
106  virtual void KeyInput( const KeyEvent& rKEvt ) override;
107  virtual void MouseMove( const MouseEvent& rMEvt ) override;
108  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
109  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
110 
111  virtual void GetFocus() override;
112  virtual void LoseFocus() override;
113 
114  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
115 
116 public:
117  ScPreview( vcl::Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh );
118  virtual ~ScPreview() override;
119  virtual void dispose() override;
120 
121  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
122 
123  SC_DLLPUBLIC void DataChanged(bool bNewTime); // Instead of calling Invalidate
124  void DoInvalidate();
125 
126  void SetXOffset( tools::Long nX );
127  void SetYOffset( tools::Long nY );
128  void SetZoom(sal_uInt16 nNewZoom);
129  SC_DLLPUBLIC void SetPageNo( tools::Long nPage );
130 
131  bool GetPageMargins() const { return bPageMargin; }
132  void SetPageMargins( bool bVal ) { bPageMargin = bVal; }
133  void DrawInvert( tools::Long nDragPos, PointerStyle nFlags );
134  void DragMove( tools::Long nDragMovePos, PointerStyle nFlags );
135 
136  const ScPreviewLocationData& GetLocationData();
137 
138  OUString GetPosString();
139 
140  tools::Long GetPageNo() const { return nPageNo; }
141  sal_uInt16 GetZoom() const { return nZoom; }
142  const Point& GetOffset() const { return aOffset; }
143 
144  SCTAB GetTab() { if (!bValid) { CalcPages(); RecalcPages(); } return nTab; }
145  tools::Long GetTotalPages() { if (!bValid) { CalcPages(); RecalcPages(); } return nTotalPages; }
146 
147  bool AllTested() const { return bValid && nTabsTested >= nTabCount; }
148 
149  sal_uInt16 GetOptimalZoom(bool bWidthOnly);
150  SC_DLLPUBLIC tools::Long GetFirstPage(SCTAB nTab);
151 
152  void CalcAll() { CalcPages(); }
153  void SetInGetState(bool bSet) { bInGetState = bSet; }
154 
155  DECL_STATIC_LINK( ScPreview, InvalidateHdl, void*, void );
156  static void StaticInvalidate();
157 
158  FmFormView* GetDrawView() { return pDrawView.get(); }
159 
160  SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData& rMark);
161  const ScMarkData::MarkedTabsType& GetSelectedTabs() const { return maSelectedTabs; }
162 };
163 
164 #endif
165 
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Point aButtonUpPt
Definition: preview.hxx:89
Point aButtonDownPt
Definition: preview.hxx:88
ScRange aPageArea
we have at least one sheet with empty print range (print range set to '- none -').
Definition: preview.hxx:82
SfxHintId
Point aButtonDownChangePoint
Definition: preview.hxx:87
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
SCCOL nColNumberButtonDown
Definition: preview.hxx:86
SCTAB GetTab()
Definition: preview.hxx:144
virtual void MouseButtonDown(const MouseEvent &rMEvt)
long Long
void SetPageMargins(bool bVal)
Definition: preview.hxx:132
tools::Long mnScale
Definition: preview.hxx:85
virtual void dispose() override
virtual void MouseButtonUp(const MouseEvent &rMEvt)
tools::Long nDisplayStart
Definition: preview.hxx:49
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
ScMarkData::MarkedTabsType maSelectedTabs
Definition: preview.hxx:35
ScDocShell * pDocShell
Definition: preview.hxx:57
std::vector< tools::Long > mvRight
Definition: preview.hxx:83
void CalcAll()
Definition: preview.hxx:152
std::vector< tools::Long > nFirstAttr
Definition: preview.hxx:45
tools::Long GetPageNo() const
Definition: preview.hxx:140
std::unique_ptr< ScPreviewLocationData > pLocationData
Definition: preview.hxx:53
sal_Int16 SCCOL
Definition: types.hxx:22
tools::Long nLeftPosition
Definition: preview.hxx:84
void SetZoom(const Fraction &rZoom)
const ScMarkData::MarkedTabsType & GetSelectedTabs() const
Definition: preview.hxx:161
std::vector< tools::Long > nPages
Definition: preview.hxx:44
DateTime aDateTime
Definition: preview.hxx:50
tools::Long nTabPage
Definition: preview.hxx:47
virtual void LoseFocus()
tools::Long nHeaderHeight
Definition: preview.hxx:90
ScPrintState aState
Definition: preview.hxx:52
void SetInGetState(bool bSet)
Definition: preview.hxx:153
virtual void KeyInput(const KeyEvent &rKEvt)
sal_uInt16 GetZoom() const
Definition: preview.hxx:141
tools::Long nPageNo
Definition: preview.hxx:37
SCTAB nTabCount
Definition: preview.hxx:42
tools::Long nFooterHeight
Definition: preview.hxx:91
virtual void GetFocus()
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
bool AllTested() const
Definition: preview.hxx:147
SCTAB nTabsTested
Definition: preview.hxx:43
sal_uInt16 nZoom
Definition: preview.hxx:38
tools::Long nTotalPages
Definition: preview.hxx:51
PointerStyle
FmFormView * GetDrawView()
Definition: preview.hxx:158
tools::Long nTabStart
Definition: preview.hxx:48
bool GetPageMargins() const
Definition: preview.hxx:131
virtual void MouseMove(const MouseEvent &rMEvt)
tools::Long GetTotalPages()
Definition: preview.hxx:145
std::unique_ptr< FmFormView > pDrawView
Definition: preview.hxx:54
virtual void Command(const CommandEvent &rCEvt)
ScPreviewShell * pViewShell
Definition: preview.hxx:58
Point aOffset
Definition: preview.hxx:39
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:46
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
const Point & GetOffset() const
Definition: preview.hxx:142
sal_Int16 SCTAB
Definition: types.hxx:23
virtual void DataChanged(const DataChangedEvent &rDCEvt)
SCTAB nTab
Definition: preview.hxx:46