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