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