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
27class ScDocShell;
28class ScPreviewShell;
29class FmFormView;
30
31class SAL_DLLPUBLIC_RTTI ScPreview : public vcl::Window
32{
33private:
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
60 bool bValid:1; // the following values true
63 bool bInPaint:1;
64 bool bInSetZoom: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
102protected:
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
115public:
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_DLLPRIVATE_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: */
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:45
std::vector< tools::Long > nFirstAttr
Definition: preview.hxx:44
tools::Long nFooterHeight
Definition: preview.hxx:90
bool bStateValid
Definition: preview.hxx:61
tools::Long nTotalPages
Definition: preview.hxx:50
bool bInSetZoom
Definition: preview.hxx:64
bool bColRulerMove
Definition: preview.hxx:78
ScPrintState aState
Definition: preview.hxx:51
std::vector< tools::Long > mvRight
Definition: preview.hxx:82
ScPreviewShell * pViewShell
Definition: preview.hxx:57
SCCOL nColNumberButtonDown
Definition: preview.hxx:85
bool bLocationValid
Definition: preview.hxx:62
bool bRightRulerChange
Definition: preview.hxx:72
tools::Long nHeaderHeight
Definition: preview.hxx:89
const Point & GetOffset() const
Definition: preview.hxx:141
bool GetPageMargins() const
Definition: preview.hxx:130
Point aButtonUpPt
Definition: preview.hxx:88
tools::Long mnScale
Definition: preview.hxx:84
bool bInPaint
Definition: preview.hxx:63
bool bHeaderRulerChange
Definition: preview.hxx:75
void SetPageMargins(bool bVal)
Definition: preview.hxx:131
bool mbHasEmptyRangeTable
Definition: preview.hxx:79
sal_uInt16 GetZoom() const
Definition: preview.hxx:140
bool bFooterRulerMove
Definition: preview.hxx:70
bool bLeftRulerChange
Definition: preview.hxx:71
std::unique_ptr< ScPreviewLocationData > pLocationData
Definition: preview.hxx:52
bool AllTested() const
Definition: preview.hxx:146
void CalcAll()
Definition: preview.hxx:151
std::vector< tools::Long > nPages
Definition: preview.hxx:43
tools::Long nLeftPosition
Definition: preview.hxx:83
Point aButtonDownChangePoint
Definition: preview.hxx:86
bool bLeftRulerMove
Definition: preview.hxx:65
ScDocShell * pDocShell
Definition: preview.hxx:56
bool bInGetState
Definition: preview.hxx:59
tools::Long GetTotalPages()
Definition: preview.hxx:144
void SetInGetState(bool bSet)
Definition: preview.hxx:152
FmFormView * GetDrawView()
Definition: preview.hxx:157
bool bRightRulerMove
Definition: preview.hxx:66
sal_uInt16 nZoom
Definition: preview.hxx:37
tools::Long GetPageNo() const
Definition: preview.hxx:139
bool bHeaderRulerMove
Definition: preview.hxx:69
std::unique_ptr< FmFormView > pDrawView
Definition: preview.hxx:53
Point aButtonDownPt
Definition: preview.hxx:87
Point aOffset
Definition: preview.hxx:38
SCTAB nTab
Definition: preview.hxx:45
bool bBottomRulerChange
Definition: preview.hxx:74
const ScMarkData::MarkedTabsType & GetSelectedTabs() const
Definition: preview.hxx:160
bool bBottomRulerMove
Definition: preview.hxx:68
bool bPageMargin
Definition: preview.hxx:77
bool bTopRulerChange
Definition: preview.hxx:73
DateTime aDateTime
Definition: preview.hxx:49
tools::Long nDisplayStart
Definition: preview.hxx:48
bool bValid
Definition: preview.hxx:60
SCTAB nTabCount
Definition: preview.hxx:41
bool bTopRulerMove
Definition: preview.hxx:67
tools::Long nPageNo
Definition: preview.hxx:36
tools::Long nTabStart
Definition: preview.hxx:47
SCTAB nTabsTested
Definition: preview.hxx:42
ScMarkData::MarkedTabsType maSelectedTabs
Definition: preview.hxx:34
SCTAB GetTab()
Definition: preview.hxx:143
bool bFooterRulerChange
Definition: preview.hxx:76
tools::Long nTabPage
Definition: preview.hxx:46
DECL_DLLPRIVATE_STATIC_LINK(ScPreview, InvalidateHdl, void *, void)
ScRange aPageArea
we have at least one sheet with empty print range (print range set to '- none -').
Definition: preview.hxx:81
virtual void dispose() override
virtual void GetFocus()
virtual void Command(const CommandEvent &rCEvt)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
virtual void MouseButtonUp(const MouseEvent &rMEvt)
virtual void KeyInput(const KeyEvent &rKEvt)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
void SetZoom(const Fraction &rZoom)
virtual void MouseMove(const MouseEvent &rMEvt)
virtual void DataChanged(const DataChangedEvent &rDCEvt)
virtual void LoseFocus()
SfxHintId
long Long
PointerStyle
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21