LCOV - code coverage report
Current view: top level - sc/source/filter/inc - viewsettings.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 4 100.0 %
Date: 2012-08-25 Functions: 5 6 83.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

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

Generated by: LCOV version 1.10