tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / preview.hxx
blob606454d992ba175dc2f965c026b1955fcdc3a3a8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <vcl/window.hxx>
22 #include "printfun.hxx"
23 #include <markdata.hxx>
25 #include <vector>
27 class ScDocShell;
28 class ScPreviewShell;
29 class FmFormView;
31 class SAL_DLLPUBLIC_RTTI ScPreview : public vcl::Window
33 private:
34 ScMarkData::MarkedTabsType maSelectedTabs;
35 // set:
36 tools::Long nPageNo; // Pages in document
37 sal_uInt16 nZoom; // set Zoom
38 Point aOffset; // positive
40 // calculated:
41 SCTAB nTabCount;
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
49 DateTime aDateTime;
50 tools::Long nTotalPages;
51 ScPrintState aState;
52 std::unique_ptr<ScPreviewLocationData> pLocationData; // stores table layout for accessibility API
53 std::unique_ptr<FmFormView> pDrawView;
55 // internal:
56 ScDocShell* pDocShell;
57 ScPreviewShell* pViewShell;
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; /// we have at least one sheet with empty print range (print range set to '- none -').
81 ScRange aPageArea;
82 std::vector<tools::Long> mvRight;
83 tools::Long nLeftPosition;
84 tools::Long mnScale;
85 SCCOL nColNumberButtonDown;
86 Point aButtonDownChangePoint;
87 Point aButtonDownPt;
88 Point aButtonUpPt;
89 tools::Long nHeaderHeight;
90 tools::Long nFooterHeight;
92 void TestLastPage();
93 void CalcPages();
94 void RecalcPages();
95 void UpdateDrawView();
96 void DoPrint( ScPreviewLocationData* pFillLocation );
98 void InvalidateLocationData( SfxHintId nId );
100 using Window::SetZoom;
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;
110 virtual void GetFocus() override;
111 virtual void LoseFocus() override;
113 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
115 public:
116 ScPreview( vcl::Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh );
117 virtual ~ScPreview() override;
118 virtual void dispose() override;
120 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
122 SC_DLLPUBLIC void DataChanged(bool bNewTime); // Instead of calling Invalidate
123 void DoInvalidate();
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 );
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 );
135 const ScPreviewLocationData& GetLocationData();
137 OUString GetPosString();
139 tools::Long GetPageNo() const { return nPageNo; }
140 sal_uInt16 GetZoom() const { return nZoom; }
141 const Point& GetOffset() const { return aOffset; }
143 SCTAB GetTab() { if (!bValid) { CalcPages(); RecalcPages(); } return nTab; }
144 tools::Long GetTotalPages() { if (!bValid) { CalcPages(); RecalcPages(); } return nTotalPages; }
146 bool AllTested() const { return bValid && nTabsTested >= nTabCount; }
148 sal_uInt16 GetOptimalZoom(bool bWidthOnly);
149 SC_DLLPUBLIC tools::Long GetFirstPage(SCTAB nTab);
151 void CalcAll() { CalcPages(); }
152 void SetInGetState(bool bSet) { bInGetState = bSet; }
154 DECL_DLLPRIVATE_STATIC_LINK( ScPreview, InvalidateHdl, void*, void );
155 static void StaticInvalidate();
157 FmFormView* GetDrawView() { return pDrawView.get(); }
159 SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData& rMark);
160 const ScMarkData::MarkedTabsType& GetSelectedTabs() const { return maSelectedTabs; }
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */