LCOV - code coverage report
Current view: top level - sc/source/filter/inc - viewsettings.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 4 100.0 %
Date: 2015-06-13 12:38:46 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          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 INCLUDED_SC_SOURCE_FILTER_INC_VIEWSETTINGS_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_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             : /** Contains all settings for a selection in a single pane of a sheet. */
      33         195 : struct PaneSelectionModel
      34             : {
      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.
      38             : 
      39             :     explicit            PaneSelectionModel();
      40             : };
      41             : 
      42             : /** Contains all view settings for a single sheet. */
      43         269 : struct SheetViewModel
      44             : {
      45             :     typedef RefMap< sal_Int32, PaneSelectionModel > PaneSelectionModelMap;
      46             : 
      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.
      70             : 
      71             :     explicit            SheetViewModel();
      72             : 
      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;
      81             : 
      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 );
      88             : };
      89             : 
      90             : typedef std::shared_ptr< SheetViewModel > SheetViewModelRef;
      91             : 
      92         269 : class SheetViewSettings : public WorksheetHelper
      93             : {
      94             : public:
      95             :     explicit            SheetViewSettings( const WorksheetHelper& rHelper );
      96             : 
      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 );
     105             : 
     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 );
     114             : 
     115             :     /** Converts all imported sheet view settings. */
     116             :     void                finalizeImport();
     117             : 
     118             :     /** Returns true, if the sheet layout is set to right-to-left. */
     119             :     bool                isSheetRightToLeft() const;
     120             : 
     121             : private:
     122             :     SheetViewModelRef   createSheetView();
     123             : 
     124             : private:
     125             :     typedef RefVector< SheetViewModel > SheetViewModelVec;
     126             :     SheetViewModelVec   maSheetViews;
     127             : };
     128             : 
     129             : /** Contains all view settings for the entire document. */
     130             : struct WorkbookViewModel
     131             : {
     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.
     144             : 
     145             :     explicit            WorkbookViewModel();
     146             : };
     147             : 
     148             : typedef std::shared_ptr< WorkbookViewModel > WorkbookViewModelRef;
     149             : 
     150         290 : class ViewSettings : public WorkbookHelper
     151             : {
     152             : public:
     153             :     explicit            ViewSettings( const WorkbookHelper& rHelper );
     154             : 
     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 );
     163             : 
     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 );
     171             : 
     172             :     /** Converts all imported document view settings. */
     173             :     void                finalizeImport();
     174             : 
     175             :     /** Returns the Calc index of the active sheet. */
     176             :     sal_Int16           getActiveCalcSheet() const;
     177             : 
     178             : private:
     179             :     WorkbookViewModel&  createWorkbookView();
     180             : 
     181             : private:
     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;
     186             : 
     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.
     194             : };
     195             : 
     196             : } // namespace xls
     197             : } // namespace oox
     198             : 
     199             : #endif
     200             : 
     201             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11