1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SC_SOURCE_UI_INC_PREVIEW_HXX
20 #define INCLUDED_SC_SOURCE_UI_INC_PREVIEW_HXX
22 #include <vcl/window.hxx>
23 #include "printfun.hxx"
24 #include <markdata.hxx>
32 class SAL_DLLPUBLIC_RTTI ScPreview
: public vcl::Window
35 ScMarkData::MarkedTabsType maSelectedTabs
;
37 tools::Long nPageNo
; // Pages in document
38 sal_uInt16 nZoom
; // set Zoom
39 Point aOffset
; // positive
43 SCTAB nTabsTested
; // for how many sheets is nPages valid?
44 std::vector
<tools::Long
> nPages
;
45 std::vector
<tools::Long
> nFirstAttr
;
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
51 tools::Long nTotalPages
;
53 std::unique_ptr
<ScPreviewLocationData
> pLocationData
; // stores table layout for accessibility API
54 std::unique_ptr
<FmFormView
> pDrawView
;
57 ScDocShell
* pDocShell
;
58 ScPreviewShell
* pViewShell
;
61 bool bValid
:1; // the following values true
63 bool bLocationValid
:1;
66 bool bLeftRulerMove
:1;
67 bool bRightRulerMove
: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;
80 bool mbHasEmptyRangeTable
:1; /// we have at least one sheet with empty print range (print range set to '- none -').
83 std::vector
<tools::Long
> mvRight
;
84 tools::Long nLeftPosition
;
86 SCCOL nColNumberButtonDown
;
87 Point aButtonDownChangePoint
;
90 tools::Long nHeaderHeight
;
91 tools::Long nFooterHeight
;
96 void UpdateDrawView();
97 void DoPrint( ScPreviewLocationData
* pFillLocation
);
99 void InvalidateLocationData( SfxHintId nId
);
101 using Window::SetZoom
;
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
;
111 virtual void GetFocus() override
;
112 virtual void LoseFocus() override
;
114 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() override
;
117 ScPreview( vcl::Window
* pParent
, ScDocShell
* pDocSh
, ScPreviewShell
* pViewSh
);
118 virtual ~ScPreview() override
;
119 virtual void dispose() override
;
121 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
123 SC_DLLPUBLIC
void DataChanged(bool bNewTime
); // Instead of calling Invalidate
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
);
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
);
136 const ScPreviewLocationData
& GetLocationData();
138 OUString
GetPosString();
140 tools::Long
GetPageNo() const { return nPageNo
; }
141 sal_uInt16
GetZoom() const { return nZoom
; }
142 const Point
& GetOffset() const { return aOffset
; }
144 SCTAB
GetTab() { if (!bValid
) { CalcPages(); RecalcPages(); } return nTab
; }
145 tools::Long
GetTotalPages() { if (!bValid
) { CalcPages(); RecalcPages(); } return nTotalPages
; }
147 bool AllTested() const { return bValid
&& nTabsTested
>= nTabCount
; }
149 sal_uInt16
GetOptimalZoom(bool bWidthOnly
);
150 SC_DLLPUBLIC
tools::Long
GetFirstPage(SCTAB nTab
);
152 void CalcAll() { CalcPages(); }
153 void SetInGetState(bool bSet
) { bInGetState
= bSet
; }
155 DECL_STATIC_LINK( ScPreview
, InvalidateHdl
, void*, void );
156 static void StaticInvalidate();
158 FmFormView
* GetDrawView() { return pDrawView
.get(); }
160 SC_DLLPUBLIC
void SetSelectedTabs(const ScMarkData
& rMark
);
161 const ScMarkData::MarkedTabsType
& GetSelectedTabs() const { return maSelectedTabs
; }
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */