1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef OOX_XLS_VIEWSETTINGS_HXX 25 #define OOX_XLS_VIEWSETTINGS_HXX 26 27 #include <com/sun/star/table/CellAddress.hpp> 28 #include <com/sun/star/table/CellRangeAddress.hpp> 29 #include "oox/xls/addressconverter.hxx" 30 #include "oox/xls/stylesbuffer.hxx" 31 #include "oox/xls/worksheethelper.hxx" 32 33 namespace oox { 34 namespace xls { 35 36 // ============================================================================ 37 38 /** Contains all settings for a selection in a single pane of a sheet. */ 39 struct PaneSelectionModel 40 { 41 ::com::sun::star::table::CellAddress maActiveCell; /// Position of active cell (cursor). 42 ApiCellRangeList maSelection; /// Selected cell ranges. 43 sal_Int32 mnActiveCellId; /// Index of active cell in selection list. 44 45 explicit PaneSelectionModel(); 46 }; 47 48 // ---------------------------------------------------------------------------- 49 50 /** Contains all view settings for a single sheet. */ 51 struct SheetViewModel 52 { 53 typedef RefMap< sal_Int32, PaneSelectionModel > PaneSelectionModelMap; 54 55 PaneSelectionModelMap maPaneSelMap; /// Selections of all panes. 56 Color maGridColor; /// Grid color. 57 ::com::sun::star::table::CellAddress maFirstPos; /// First visible cell. 58 ::com::sun::star::table::CellAddress maSecondPos; /// First visible cell in additional panes. 59 sal_Int32 mnWorkbookViewId; /// Index into list of workbookView elements. 60 sal_Int32 mnViewType; /// View type (normal, page break, layout). 61 sal_Int32 mnActivePaneId; /// Active pane (with cell cursor). 62 sal_Int32 mnPaneState; /// Pane state (frozen, split). 63 double mfSplitX; /// Split X position (twips), or number of frozen columns. 64 double mfSplitY; /// Split Y position (twips), or number of frozen rows. 65 sal_Int32 mnCurrentZoom; /// Zoom factor for current view. 66 sal_Int32 mnNormalZoom; /// Zoom factor for normal view. 67 sal_Int32 mnSheetLayoutZoom; /// Zoom factor for pagebreak preview. 68 sal_Int32 mnPageLayoutZoom; /// Zoom factor for page layout view. 69 bool mbSelected; /// True = sheet is selected. 70 bool mbRightToLeft; /// True = sheet in right-to-left mode. 71 bool mbDefGridColor; /// True = default grid color. 72 bool mbShowFormulas; /// True = show formulas instead of results. 73 bool mbShowGrid; /// True = show cell grid. 74 bool mbShowHeadings; /// True = show column/row headings. 75 bool mbShowZeros; /// True = show zero value zells. 76 bool mbShowOutline; /// True = show outlines. 77 bool mbZoomToFit; /// True = zoom chart sheet to fit window. 78 79 explicit SheetViewModel(); 80 81 /** Returns true, if page break preview is active. */ 82 bool isPageBreakPreview() const; 83 /** Returns the zoom in normal view (returns default, if current value is 0). */ 84 sal_Int32 getNormalZoom() const; 85 /** Returns the zoom in pagebreak preview (returns default, if current value is 0). */ 86 sal_Int32 getPageBreakZoom() const; 87 /** Returns the grid color as RGB value. */ 88 sal_Int32 getGridColor( const ::oox::core::FilterBase& rFilter ) const; 89 90 /** Returns the selection data, if available, otherwise 0. */ 91 const PaneSelectionModel* getPaneSelection( sal_Int32 nPaneId ) const; 92 /** Returns the selection data of the active pane. */ 93 const PaneSelectionModel* getActiveSelection() const; 94 /** Returns read/write access to the selection data of the specified pane. */ 95 PaneSelectionModel& createPaneSelection( sal_Int32 nPaneId ); 96 }; 97 98 typedef ::boost::shared_ptr< SheetViewModel > SheetViewModelRef; 99 100 // ---------------------------------------------------------------------------- 101 102 class SheetViewSettings : public WorksheetHelper 103 { 104 public: 105 explicit SheetViewSettings( const WorksheetHelper& rHelper ); 106 107 /** Imports the sheetView element containing sheet view settings. */ 108 void importSheetView( const AttributeList& rAttribs ); 109 /** Imports the pane element containing sheet pane settings. */ 110 void importPane( const AttributeList& rAttribs ); 111 /** Imports the selection element containing selection settings for a pane. */ 112 void importSelection( const AttributeList& rAttribs ); 113 /** Imports the sheetView element containing view settings of a chart sheet. */ 114 void importChartSheetView( const AttributeList& rAttribs ); 115 116 /** Imports the SHEETVIEW record containing sheet view settings. */ 117 void importSheetView( SequenceInputStream& rStrm ); 118 /** Imports the PANE record containing sheet pane settings. */ 119 void importPane( SequenceInputStream& rStrm ); 120 /** Imports the SELECTION record containing selection settings for a pane. */ 121 void importSelection( SequenceInputStream& rStrm ); 122 /** Imports the CHARTSHEETVIEW record containing view settings of a chart sheet. */ 123 void importChartSheetView( SequenceInputStream& rStrm ); 124 125 /** Imports the WINDOW2 record containing sheet view settings. */ 126 void importWindow2( BiffInputStream& rStrm ); 127 /** Imports the PANE record containing sheet pane settings. */ 128 void importPane( BiffInputStream& rStrm ); 129 /** Imports the SCL record containing sheet zoom settings. */ 130 void importScl( BiffInputStream& rStrm ); 131 /** Imports the SELECTION record containing selection settings for a pane. */ 132 void importSelection( BiffInputStream& rStrm ); 133 134 /** Converts all imported sheet view settings. */ 135 void finalizeImport(); 136 137 /** Returns true, if the sheet layout is set to right-to-left. */ 138 bool isSheetRightToLeft() const; 139 140 private: 141 SheetViewModelRef createSheetView(); 142 143 private: 144 typedef RefVector< SheetViewModel > SheetViewModelVec; 145 SheetViewModelVec maSheetViews; 146 }; 147 148 // ============================================================================ 149 150 /** Contains all view settings for the entire document. */ 151 struct WorkbookViewModel 152 { 153 sal_Int32 mnWinX; /// X position of the workbook window (twips). 154 sal_Int32 mnWinY; /// Y position of the workbook window (twips). 155 sal_Int32 mnWinWidth; /// Width of the workbook window (twips). 156 sal_Int32 mnWinHeight; /// Height of the workbook window (twips). 157 sal_Int32 mnActiveSheet; /// Displayed (active) sheet. 158 sal_Int32 mnFirstVisSheet; /// First visible sheet in sheet tabbar. 159 sal_Int32 mnTabBarWidth; /// Width of sheet tabbar (1/1000 of window width). 160 sal_Int32 mnVisibility; /// Visibility state of workbook window. 161 bool mbShowTabBar; /// True = show sheet tabbar. 162 bool mbShowHorScroll; /// True = show horizontal sheet scrollbars. 163 bool mbShowVerScroll; /// True = show vertical sheet scrollbars. 164 bool mbMinimized; /// True = workbook window is minimized. 165 166 explicit WorkbookViewModel(); 167 }; 168 169 typedef ::boost::shared_ptr< WorkbookViewModel > WorkbookViewModelRef; 170 171 // ---------------------------------------------------------------------------- 172 173 class ViewSettings : public WorkbookHelper 174 { 175 public: 176 explicit ViewSettings( const WorkbookHelper& rHelper ); 177 178 /** Imports the workbookView element containing workbook view settings. */ 179 void importWorkbookView( const AttributeList& rAttribs ); 180 /** Imports the oleSize element containing the visible size of the workbook. */ 181 void importOleSize( const AttributeList& rAttribs ); 182 /** Imports the WORKBOOKVIEW record containing workbook view settings. */ 183 void importWorkbookView( SequenceInputStream& rStrm ); 184 /** Imports the OLESIZE record containing the visible size of the workbook. */ 185 void importOleSize( SequenceInputStream& rStrm ); 186 /** Imports the WINDOW1 record containing workbook view settings. */ 187 void importWindow1( BiffInputStream& rStrm ); 188 /** Imports the OLESIZE record containing the visible size of the workbook. */ 189 void importOleSize( BiffInputStream& rStrm ); 190 191 /** Stores converted view settings for a specific worksheet. */ 192 void setSheetViewSettings( sal_Int16 nSheet, 193 const SheetViewModelRef& rxSheetView, 194 const ::com::sun::star::uno::Any& rProperties ); 195 /** Stores the used area for a specific worksheet. */ 196 void setSheetUsedArea( 197 const ::com::sun::star::table::CellRangeAddress& rUsedArea ); 198 199 /** Converts all imported document view settings. */ 200 void finalizeImport(); 201 202 /** Returns the Calc index of the active sheet. */ 203 sal_Int16 getActiveCalcSheet() const; 204 205 private: 206 WorkbookViewModel& createWorkbookView(); 207 208 private: 209 typedef RefVector< WorkbookViewModel > WorkbookViewModelVec; 210 typedef RefMap< sal_Int16, SheetViewModel > SheetViewModelMap; 211 typedef ::std::map< sal_Int16, ::com::sun::star::uno::Any > SheetPropertiesMap; 212 typedef ::std::map< sal_Int16, ::com::sun::star::table::CellRangeAddress > SheetUsedAreaMap; 213 214 WorkbookViewModelVec maBookViews; /// Workbook view models. 215 SheetViewModelMap maSheetViews; /// Active view model for each sheet. 216 SheetPropertiesMap maSheetProps; /// Converted property sequences for each sheet. 217 SheetUsedAreaMap maSheetUsedAreas; /// Used area (cell range) of every sheet. 218 ::com::sun::star::table::CellRangeAddress 219 maOleSize; /// Visible area if this is an embedded OLE object. 220 bool mbValidOleSize; /// True = imported OLE size is a valid cell range. 221 }; 222 223 // ============================================================================ 224 225 } // namespace xls 226 } // namespace oox 227 228 #endif 229