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