merge the formfield patch from ooo-build
[ooovba.git] / oox / inc / oox / xls / viewsettings.hxx
blob6ba7c0620b6605e28b91751997109974d816df63
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewsettings.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef OOX_XLS_VIEWSETTINGS_HXX
32 #define OOX_XLS_VIEWSETTINGS_HXX
34 #include <com/sun/star/table/CellAddress.hpp>
35 #include <com/sun/star/table/CellRangeAddress.hpp>
36 #include "oox/helper/containerhelper.hxx"
37 #include "oox/xls/addressconverter.hxx"
38 #include "oox/xls/stylesbuffer.hxx"
39 #include "oox/xls/worksheethelper.hxx"
41 namespace oox {
42 namespace xls {
44 // ============================================================================
46 /** Contains all settings for a selection in a single pane of a sheet. */
47 struct PaneSelectionModel
49 ::com::sun::star::table::CellAddress maActiveCell; /// Position of active cell (cursor).
50 ApiCellRangeList maSelection; /// Selected cell ranges.
51 sal_Int32 mnActiveCellId; /// Index of active cell in selection list.
53 explicit PaneSelectionModel();
56 // ----------------------------------------------------------------------------
58 /** Contains all view settings for a single sheet. */
59 struct SheetViewModel
61 typedef RefMap< sal_Int32, PaneSelectionModel > PaneSelectionModelMap;
63 PaneSelectionModelMap maPaneSelMap; /// Selections of all panes.
64 Color maGridColor; /// Grid color.
65 ::com::sun::star::table::CellAddress maFirstPos; /// First visible cell.
66 ::com::sun::star::table::CellAddress maSecondPos; /// First visible cell in additional panes.
67 sal_Int32 mnWorkbookViewId; /// Index into list of workbookView elements.
68 sal_Int32 mnViewType; /// View type (normal, page break, layout).
69 sal_Int32 mnActivePaneId; /// Active pane (with cell cursor).
70 sal_Int32 mnPaneState; /// Pane state (frozen, split).
71 double mfSplitX; /// Split X position (twips), or number of frozen columns.
72 double mfSplitY; /// Split Y position (twips), or number of frozen rows.
73 sal_Int32 mnCurrentZoom; /// Zoom factor for current view.
74 sal_Int32 mnNormalZoom; /// Zoom factor for normal view.
75 sal_Int32 mnSheetLayoutZoom; /// Zoom factor for pagebreak preview.
76 sal_Int32 mnPageLayoutZoom; /// Zoom factor for page layout view.
77 bool mbSelected; /// True = sheet is selected.
78 bool mbRightToLeft; /// True = sheet in right-to-left mode.
79 bool mbDefGridColor; /// True = default grid color.
80 bool mbShowFormulas; /// True = show formulas instead of results.
81 bool mbShowGrid; /// True = show cell grid.
82 bool mbShowHeadings; /// True = show column/row headings.
83 bool mbShowZeros; /// True = show zero value zells.
84 bool mbShowOutline; /// True = show outlines.
85 bool mbZoomToFit; /// True = zoom chart sheet to fit window.
86 Color maTabColor; /// Sheet tab color. (TODO: Move to sheet settings later.)
88 explicit SheetViewModel();
90 /** Returns true, if page break preview is active. */
91 bool isPageBreakPreview() const;
92 /** Returns the zoom in normal view (returns default, if current value is 0). */
93 sal_Int32 getNormalZoom() const;
94 /** Returns the zoom in pagebreak preview (returns default, if current value is 0). */
95 sal_Int32 getPageBreakZoom() const;
96 /** Returns the grid color as RGB value. */
97 sal_Int32 getGridColor( const ::oox::core::FilterBase& rFilter ) const;
99 /** Returns the selection data, if available, otherwise 0. */
100 const PaneSelectionModel* getPaneSelection( sal_Int32 nPaneId ) const;
101 /** Returns the selection data of the active pane. */
102 const PaneSelectionModel* getActiveSelection() const;
103 /** Returns read/write access to the selection data of the specified pane. */
104 PaneSelectionModel& createPaneSelection( sal_Int32 nPaneId );
107 typedef ::boost::shared_ptr< SheetViewModel > SheetViewModelRef;
109 // ----------------------------------------------------------------------------
111 class SheetViewSettings : public WorksheetHelper
113 public:
114 explicit SheetViewSettings( const WorksheetHelper& rHelper );
116 /** Imports the sheetView element containing sheet view settings. */
117 void importSheetView( const AttributeList& rAttribs );
118 /** Imports the tabcolor element containing tab color settings. */
119 void importTabColor( const AttributeList& rAttribs );
120 /** Imports the pane element containing sheet pane settings. */
121 void importPane( const AttributeList& rAttribs );
122 /** Imports the selection element containing selection settings for a pane. */
123 void importSelection( const AttributeList& rAttribs );
124 /** Imports the sheetView element containing view settings of a chart sheet. */
125 void importChartSheetView( const AttributeList& rAttribs );
127 /** Imports the SHEETVIEW record containing sheet view settings. */
128 void importSheetView( RecordInputStream& rStrm );
129 /** Imports the PANE record containing sheet pane settings. */
130 void importPane( RecordInputStream& rStrm );
131 /** Imports the SELECTION record containing selection settings for a pane. */
132 void importSelection( RecordInputStream& rStrm );
133 /** Imports the CHARTSHEETVIEW record containing view settings of a chart sheet. */
134 void importChartSheetView( RecordInputStream& rStrm );
136 /** Imports the WINDOW2 record containing sheet view settings. */
137 void importWindow2( BiffInputStream& rStrm );
138 /** Imports the PANE record containing sheet pane settings. */
139 void importPane( BiffInputStream& rStrm );
140 /** Imports the SCL record containing sheet zoom settings. */
141 void importScl( BiffInputStream& rStrm );
142 /** Imports the SELECTION record containing selection settings for a pane. */
143 void importSelection( BiffInputStream& rStrm );
145 /** Converts all imported sheet view settings. */
146 void finalizeImport();
148 private:
149 SheetViewModelRef createSheetView();
151 private:
152 typedef RefVector< SheetViewModel > SheetViewModelVec;
153 SheetViewModelVec maSheetViews;
156 // ============================================================================
158 /** Contains all view settings for the entire document. */
159 struct WorkbookViewModel
161 sal_Int32 mnWinX; /// X position of the workbook window (twips).
162 sal_Int32 mnWinY; /// Y position of the workbook window (twips).
163 sal_Int32 mnWinWidth; /// Width of the workbook window (twips).
164 sal_Int32 mnWinHeight; /// Height of the workbook window (twips).
165 sal_Int32 mnActiveSheet; /// Displayed (active) sheet.
166 sal_Int32 mnFirstVisSheet; /// First visible sheet in sheet tabbar.
167 sal_Int32 mnTabBarWidth; /// Width of sheet tabbar (1/1000 of window width).
168 sal_Int32 mnVisibility; /// Visibility state of workbook window.
169 bool mbShowTabBar; /// True = show sheet tabbar.
170 bool mbShowHorScroll; /// True = show horizontal sheet scrollbars.
171 bool mbShowVerScroll; /// True = show vertical sheet scrollbars.
172 bool mbMinimized; /// True = workbook window is minimized.
174 explicit WorkbookViewModel();
177 typedef ::boost::shared_ptr< WorkbookViewModel > WorkbookViewModelRef;
179 // ----------------------------------------------------------------------------
181 class ViewSettings : public WorkbookHelper
183 public:
184 explicit ViewSettings( const WorkbookHelper& rHelper );
186 /** Imports the workbookView element containing workbook view settings. */
187 void importWorkbookView( const AttributeList& rAttribs );
188 /** Imports the WORKBOOKVIEW record containing workbook view settings. */
189 void importWorkbookView( RecordInputStream& rStrm );
190 /** Imports the WINDOW1 record containing workbook view settings. */
191 void importWindow1( BiffInputStream& rStrm );
193 /** Stores converted view settings for a specific worksheet. */
194 void setSheetViewSettings( sal_Int16 nSheet,
195 const SheetViewModelRef& rxSheetView,
196 const ::com::sun::star::uno::Any& rProperties );
198 /** Converts all imported document view settings. */
199 void finalizeImport();
201 /** Returns the Calc index of the active sheet. */
202 sal_Int16 getActiveCalcSheet() const;
204 private:
205 WorkbookViewModel& createWorkbookView();
207 private:
208 typedef RefVector< WorkbookViewModel > WorkbookViewModelVec;
209 typedef RefMap< sal_Int16, SheetViewModel > SheetViewModelMap;
210 typedef ::std::map< sal_Int16, ::com::sun::star::uno::Any > SheetPropertiesMap;
212 WorkbookViewModelVec maBookViews; /// Workbook view models.
213 SheetViewModelMap maSheetViews; /// Active view model for each sheet.
214 SheetPropertiesMap maSheetProps; /// Converted property sequences for each sheet.
217 // ============================================================================
219 } // namespace xls
220 } // namespace oox
222 #endif