Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / viewsettings.hxx
blob2382f5b5411285dfd0ab6e1c1065fcd825baa975
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 .
20 #pragma once
22 #include <rangelst.hxx>
23 #include "stylesbuffer.hxx"
24 #include "worksheethelper.hxx"
25 #include "workbookhelper.hxx"
27 namespace oox::xls {
29 /** Contains all settings for a selection in a single pane of a sheet. */
30 struct PaneSelectionModel
32 ScAddress maActiveCell; /// Position of active cell (cursor).
33 ScRangeList maSelection; /// Selected cell ranges.
34 sal_Int32 mnActiveCellId; /// Index of active cell in selection list.
36 explicit PaneSelectionModel();
39 /** Contains all view settings for a single sheet. */
40 struct SheetViewModel
42 typedef RefMap< sal_Int32, PaneSelectionModel > PaneSelectionModelMap;
44 PaneSelectionModelMap maPaneSelMap; /// Selections of all panes.
45 Color maGridColor; /// Grid color.
46 ScAddress maFirstPos; /// First visible cell.
47 ScAddress maSecondPos; /// First visible cell in additional panes.
48 sal_Int32 mnWorkbookViewId; /// Index into list of workbookView elements.
49 sal_Int32 mnViewType; /// View type (normal, page break, layout).
50 sal_Int32 mnActivePaneId; /// Active pane (with cell cursor).
51 sal_Int32 mnPaneState; /// Pane state (frozen, split).
52 double mfSplitX; /// Split X position (twips), or number of frozen columns.
53 double mfSplitY; /// Split Y position (twips), or number of frozen rows.
54 sal_Int32 mnCurrentZoom; /// Zoom factor for current view.
55 sal_Int32 mnNormalZoom; /// Zoom factor for normal view.
56 sal_Int32 mnSheetLayoutZoom; /// Zoom factor for pagebreak preview.
57 sal_Int32 mnPageLayoutZoom; /// Zoom factor for page layout view.
58 bool mbSelected; /// True = sheet is selected.
59 bool mbRightToLeft; /// True = sheet in right-to-left mode.
60 bool mbDefGridColor; /// True = default grid color.
61 bool mbShowFormulas; /// True = show formulas instead of results.
62 bool mbShowGrid; /// True = show cell grid.
63 bool mbShowHeadings; /// True = show column/row headings.
64 bool mbShowZeros; /// True = show zero value zells.
65 bool mbShowOutline; /// True = show outlines.
66 bool mbZoomToFit; /// True = zoom chart sheet to fit window.
68 explicit SheetViewModel();
70 /** Returns true, if page break preview is active. */
71 bool isPageBreakPreview() const;
72 /** Returns the zoom in normal view (returns default, if current value is 0). */
73 sal_Int32 getNormalZoom() const;
74 /** Returns the zoom in pagebreak preview (returns default, if current value is 0). */
75 sal_Int32 getPageBreakZoom() const;
76 /** Returns the grid color as RGB value. */
77 ::Color getGridColor( const ::oox::core::FilterBase& rFilter ) const;
79 /** Returns the selection data of the active pane. */
80 const PaneSelectionModel* getActiveSelection() const;
81 /** Returns read/write access to the selection data of the specified pane. */
82 PaneSelectionModel& createPaneSelection( sal_Int32 nPaneId );
85 typedef std::shared_ptr< SheetViewModel > SheetViewModelRef;
87 class SheetViewSettings : public WorksheetHelper
89 public:
90 explicit SheetViewSettings( const WorksheetHelper& rHelper );
92 /** Imports the sheetView element containing sheet view settings. */
93 void importSheetView( const AttributeList& rAttribs );
94 /** Imports the pane element containing sheet pane settings. */
95 void importPane( const AttributeList& rAttribs );
96 /** Imports the selection element containing selection settings for a pane. */
97 void importSelection( const AttributeList& rAttribs );
98 /** Imports the sheetView element containing view settings of a chart sheet. */
99 void importChartSheetView( const AttributeList& rAttribs );
101 /** Imports the SHEETVIEW record containing sheet view settings. */
102 void importSheetView( SequenceInputStream& rStrm );
103 /** Imports the PANE record containing sheet pane settings. */
104 void importPane( SequenceInputStream& rStrm );
105 /** Imports the SELECTION record containing selection settings for a pane. */
106 void importSelection( SequenceInputStream& rStrm );
107 /** Imports the CHARTSHEETVIEW record containing view settings of a chart sheet. */
108 void importChartSheetView( SequenceInputStream& rStrm );
110 /** Converts all imported sheet view settings. */
111 void finalizeImport();
113 /** Returns true, if the sheet layout is set to right-to-left. */
114 bool isSheetRightToLeft() const;
116 private:
117 SheetViewModelRef createSheetView();
119 private:
120 typedef RefVector< SheetViewModel > SheetViewModelVec;
121 SheetViewModelVec maSheetViews;
124 /** Contains all view settings for the entire document. */
125 struct WorkbookViewModel
127 sal_Int32 mnWinX; /// X position of the workbook window (twips).
128 sal_Int32 mnWinY; /// Y position of the workbook window (twips).
129 sal_Int32 mnWinWidth; /// Width of the workbook window (twips).
130 sal_Int32 mnWinHeight; /// Height of the workbook window (twips).
131 sal_Int32 mnActiveSheet; /// Displayed (active) sheet.
132 sal_Int32 mnFirstVisSheet; /// First visible sheet in sheet tabbar.
133 sal_Int32 mnTabBarWidth; /// Width of sheet tabbar (1/1000 of window width).
134 sal_Int32 mnVisibility; /// Visibility state of workbook window.
135 bool mbShowTabBar; /// True = show sheet tabbar.
136 bool mbShowHorScroll; /// True = show horizontal sheet scrollbars.
137 bool mbShowVerScroll; /// True = show vertical sheet scrollbars.
138 bool mbMinimized; /// True = workbook window is minimized.
140 explicit WorkbookViewModel();
143 typedef std::shared_ptr< WorkbookViewModel > WorkbookViewModelRef;
145 class ViewSettings : public WorkbookHelper
147 public:
148 explicit ViewSettings( const WorkbookHelper& rHelper );
150 /** Imports the workbookView element containing workbook view settings. */
151 void importWorkbookView( const AttributeList& rAttribs );
152 /** Imports the oleSize element containing the visible size of the workbook. */
153 void importOleSize( const AttributeList& rAttribs );
154 /** Imports the WORKBOOKVIEW record containing workbook view settings. */
155 void importWorkbookView( SequenceInputStream& rStrm );
156 /** Imports the OLESIZE record containing the visible size of the workbook. */
157 void importOleSize( SequenceInputStream& rStrm );
159 /** Stores converted view settings for a specific worksheet. */
160 void setSheetViewSettings( sal_Int16 nSheet,
161 const SheetViewModelRef& rxSheetView,
162 const css::uno::Any& rProperties );
163 /** Stores the used area for a specific worksheet. */
164 void setSheetUsedArea( const ScRange& rUsedArea );
166 /** Converts all imported document view settings. */
167 void finalizeImport();
169 /** Returns the Calc index of the active sheet. */
170 sal_Int16 getActiveCalcSheet() const;
172 private:
173 WorkbookViewModel& createWorkbookView();
175 private:
176 typedef RefVector< WorkbookViewModel > WorkbookViewModelVec;
177 typedef RefMap< sal_Int16, SheetViewModel > SheetViewModelMap;
179 WorkbookViewModelVec maBookViews; /// Workbook view models.
180 SheetViewModelMap maSheetViews; /// Active view model for each sheet.
181 std::map< sal_Int16, css::uno::Any > maSheetProps; /// Converted property sequences for each sheet.
182 std::map< sal_Int16, ScRange > maSheetUsedAreas; /// Used area (cell range) of every sheet.
183 ScRange maOleSize; /// Visible area if this is an embedded OLE object.
184 bool mbValidOleSize; /// True = imported OLE size is a valid cell range.
187 } // namespace oox::xls
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */