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