Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef OOX_XLS_VIEWSETTINGS_HXX
21 : #define OOX_XLS_VIEWSETTINGS_HXX
22 :
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"
28 :
29 : namespace oox {
30 : namespace xls {
31 :
32 : // ============================================================================
33 :
34 : /** Contains all settings for a selection in a single pane of a sheet. */
35 21 : struct PaneSelectionModel
36 : {
37 : ::com::sun::star::table::CellAddress maActiveCell; /// Position of active cell (cursor).
38 : ApiCellRangeList maSelection; /// Selected cell ranges.
39 : sal_Int32 mnActiveCellId; /// Index of active cell in selection list.
40 :
41 : explicit PaneSelectionModel();
42 : };
43 :
44 : // ----------------------------------------------------------------------------
45 :
46 : /** Contains all view settings for a single sheet. */
47 25 : struct SheetViewModel
48 : {
49 : typedef RefMap< sal_Int32, PaneSelectionModel > PaneSelectionModelMap;
50 :
51 : PaneSelectionModelMap maPaneSelMap; /// Selections of all panes.
52 : Color maGridColor; /// Grid color.
53 : ::com::sun::star::table::CellAddress maFirstPos; /// First visible cell.
54 : ::com::sun::star::table::CellAddress maSecondPos; /// First visible cell in additional panes.
55 : sal_Int32 mnWorkbookViewId; /// Index into list of workbookView elements.
56 : sal_Int32 mnViewType; /// View type (normal, page break, layout).
57 : sal_Int32 mnActivePaneId; /// Active pane (with cell cursor).
58 : sal_Int32 mnPaneState; /// Pane state (frozen, split).
59 : double mfSplitX; /// Split X position (twips), or number of frozen columns.
60 : double mfSplitY; /// Split Y position (twips), or number of frozen rows.
61 : sal_Int32 mnCurrentZoom; /// Zoom factor for current view.
62 : sal_Int32 mnNormalZoom; /// Zoom factor for normal view.
63 : sal_Int32 mnSheetLayoutZoom; /// Zoom factor for pagebreak preview.
64 : sal_Int32 mnPageLayoutZoom; /// Zoom factor for page layout view.
65 : bool mbSelected; /// True = sheet is selected.
66 : bool mbRightToLeft; /// True = sheet in right-to-left mode.
67 : bool mbDefGridColor; /// True = default grid color.
68 : bool mbShowFormulas; /// True = show formulas instead of results.
69 : bool mbShowGrid; /// True = show cell grid.
70 : bool mbShowHeadings; /// True = show column/row headings.
71 : bool mbShowZeros; /// True = show zero value zells.
72 : bool mbShowOutline; /// True = show outlines.
73 : bool mbZoomToFit; /// True = zoom chart sheet to fit window.
74 :
75 : explicit SheetViewModel();
76 :
77 : /** Returns true, if page break preview is active. */
78 : bool isPageBreakPreview() const;
79 : /** Returns the zoom in normal view (returns default, if current value is 0). */
80 : sal_Int32 getNormalZoom() const;
81 : /** Returns the zoom in pagebreak preview (returns default, if current value is 0). */
82 : sal_Int32 getPageBreakZoom() const;
83 : /** Returns the grid color as RGB value. */
84 : sal_Int32 getGridColor( const ::oox::core::FilterBase& rFilter ) const;
85 :
86 : /** Returns the selection data, if available, otherwise 0. */
87 : const PaneSelectionModel* getPaneSelection( sal_Int32 nPaneId ) const;
88 : /** Returns the selection data of the active pane. */
89 : const PaneSelectionModel* getActiveSelection() const;
90 : /** Returns read/write access to the selection data of the specified pane. */
91 : PaneSelectionModel& createPaneSelection( sal_Int32 nPaneId );
92 : };
93 :
94 : typedef ::boost::shared_ptr< SheetViewModel > SheetViewModelRef;
95 :
96 : // ----------------------------------------------------------------------------
97 :
98 25 : class SheetViewSettings : public WorksheetHelper
99 : {
100 : public:
101 : explicit SheetViewSettings( const WorksheetHelper& rHelper );
102 :
103 : /** Imports the sheetView element containing sheet view settings. */
104 : void importSheetView( const AttributeList& rAttribs );
105 : /** Imports the pane element containing sheet pane settings. */
106 : void importPane( const AttributeList& rAttribs );
107 : /** Imports the selection element containing selection settings for a pane. */
108 : void importSelection( const AttributeList& rAttribs );
109 : /** Imports the sheetView element containing view settings of a chart sheet. */
110 : void importChartSheetView( const AttributeList& rAttribs );
111 :
112 : /** Imports the SHEETVIEW record containing sheet view settings. */
113 : void importSheetView( SequenceInputStream& rStrm );
114 : /** Imports the PANE record containing sheet pane settings. */
115 : void importPane( SequenceInputStream& rStrm );
116 : /** Imports the SELECTION record containing selection settings for a pane. */
117 : void importSelection( SequenceInputStream& rStrm );
118 : /** Imports the CHARTSHEETVIEW record containing view settings of a chart sheet. */
119 : void importChartSheetView( SequenceInputStream& rStrm );
120 :
121 : /** Converts all imported sheet view settings. */
122 : void finalizeImport();
123 :
124 : /** Returns true, if the sheet layout is set to right-to-left. */
125 : bool isSheetRightToLeft() const;
126 :
127 : private:
128 : SheetViewModelRef createSheetView();
129 :
130 : private:
131 : typedef RefVector< SheetViewModel > SheetViewModelVec;
132 : SheetViewModelVec maSheetViews;
133 : };
134 :
135 : // ============================================================================
136 :
137 : /** Contains all view settings for the entire document. */
138 : struct WorkbookViewModel
139 : {
140 : sal_Int32 mnWinX; /// X position of the workbook window (twips).
141 : sal_Int32 mnWinY; /// Y position of the workbook window (twips).
142 : sal_Int32 mnWinWidth; /// Width of the workbook window (twips).
143 : sal_Int32 mnWinHeight; /// Height of the workbook window (twips).
144 : sal_Int32 mnActiveSheet; /// Displayed (active) sheet.
145 : sal_Int32 mnFirstVisSheet; /// First visible sheet in sheet tabbar.
146 : sal_Int32 mnTabBarWidth; /// Width of sheet tabbar (1/1000 of window width).
147 : sal_Int32 mnVisibility; /// Visibility state of workbook window.
148 : bool mbShowTabBar; /// True = show sheet tabbar.
149 : bool mbShowHorScroll; /// True = show horizontal sheet scrollbars.
150 : bool mbShowVerScroll; /// True = show vertical sheet scrollbars.
151 : bool mbMinimized; /// True = workbook window is minimized.
152 :
153 : explicit WorkbookViewModel();
154 : };
155 :
156 : typedef ::boost::shared_ptr< WorkbookViewModel > WorkbookViewModelRef;
157 :
158 : // ----------------------------------------------------------------------------
159 :
160 22 : class ViewSettings : public WorkbookHelper
161 : {
162 : public:
163 : explicit ViewSettings( const WorkbookHelper& rHelper );
164 :
165 : /** Imports the workbookView element containing workbook view settings. */
166 : void importWorkbookView( const AttributeList& rAttribs );
167 : /** Imports the oleSize element containing the visible size of the workbook. */
168 : void importOleSize( const AttributeList& rAttribs );
169 : /** Imports the WORKBOOKVIEW record containing workbook view settings. */
170 : void importWorkbookView( SequenceInputStream& rStrm );
171 : /** Imports the OLESIZE record containing the visible size of the workbook. */
172 : void importOleSize( SequenceInputStream& rStrm );
173 :
174 : /** Stores converted view settings for a specific worksheet. */
175 : void setSheetViewSettings( sal_Int16 nSheet,
176 : const SheetViewModelRef& rxSheetView,
177 : const ::com::sun::star::uno::Any& rProperties );
178 : /** Stores the used area for a specific worksheet. */
179 : void setSheetUsedArea(
180 : const ::com::sun::star::table::CellRangeAddress& rUsedArea );
181 :
182 : /** Converts all imported document view settings. */
183 : void finalizeImport();
184 :
185 : /** Returns the Calc index of the active sheet. */
186 : sal_Int16 getActiveCalcSheet() const;
187 :
188 : private:
189 : WorkbookViewModel& createWorkbookView();
190 :
191 : private:
192 : typedef RefVector< WorkbookViewModel > WorkbookViewModelVec;
193 : typedef RefMap< sal_Int16, SheetViewModel > SheetViewModelMap;
194 : typedef ::std::map< sal_Int16, ::com::sun::star::uno::Any > SheetPropertiesMap;
195 : typedef ::std::map< sal_Int16, ::com::sun::star::table::CellRangeAddress > SheetUsedAreaMap;
196 :
197 : WorkbookViewModelVec maBookViews; /// Workbook view models.
198 : SheetViewModelMap maSheetViews; /// Active view model for each sheet.
199 : SheetPropertiesMap maSheetProps; /// Converted property sequences for each sheet.
200 : SheetUsedAreaMap maSheetUsedAreas; /// Used area (cell range) of every sheet.
201 : ::com::sun::star::table::CellRangeAddress
202 : maOleSize; /// Visible area if this is an embedded OLE object.
203 : bool mbValidOleSize; /// True = imported OLE size is a valid cell range.
204 : };
205 :
206 : // ============================================================================
207 :
208 : } // namespace xls
209 : } // namespace oox
210 :
211 : #endif
212 :
213 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|