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 .
21 #include <vcl/window.hxx>
22 #include "printfun.hxx"
23 #include <markdata.hxx>
31 class SAL_DLLPUBLIC_RTTI ScPreview
: public vcl::Window
34 ScMarkData::MarkedTabsType maSelectedTabs
;
36 tools::Long nPageNo
; // Pages in document
37 sal_uInt16 nZoom
; // set Zoom
38 Point aOffset
; // positive
42 SCTAB nTabsTested
; // for how many sheets is nPages valid?
43 std::vector
<tools::Long
> nPages
;
44 std::vector
<tools::Long
> nFirstAttr
;
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
50 tools::Long nTotalPages
;
52 std::unique_ptr
<ScPreviewLocationData
> pLocationData
; // stores table layout for accessibility API
53 std::unique_ptr
<FmFormView
> pDrawView
;
56 ScDocShell
* pDocShell
;
57 ScPreviewShell
* pViewShell
;
60 bool bValid
:1; // the following values true
62 bool bLocationValid
:1;
65 bool bLeftRulerMove
:1;
66 bool bRightRulerMove
: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;
79 bool mbHasEmptyRangeTable
:1; /// we have at least one sheet with empty print range (print range set to '- none -').
82 std::vector
<tools::Long
> mvRight
;
83 tools::Long nLeftPosition
;
85 SCCOL nColNumberButtonDown
;
86 Point aButtonDownChangePoint
;
89 tools::Long nHeaderHeight
;
90 tools::Long nFooterHeight
;
95 void UpdateDrawView();
96 void DoPrint( ScPreviewLocationData
* pFillLocation
);
98 void InvalidateLocationData( SfxHintId nId
);
100 using Window::SetZoom
;
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
;
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
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: */