LCOV - code coverage report
Current view: top level - sc/source/filter/inc - worksheethelper.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 5 6 83.3 %
Date: 2014-11-03 Functions: 9 13 69.2 %
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_WORKSHEETHELPER_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_WORKSHEETHELPER_HXX
      22             : 
      23             : #include <oox/helper/containerhelper.hxx>
      24             : #include <oox/helper/progressbar.hxx>
      25             : #include <oox/ole/olehelper.hxx>
      26             : #include "addressconverter.hxx"
      27             : #include "formulabase.hxx"
      28             : 
      29             : namespace com { namespace sun { namespace star {
      30             :     namespace awt { struct Point; }
      31             :     namespace awt { struct Rectangle; }
      32             :     namespace awt { struct Size; }
      33             :     namespace drawing { class XDrawPage; }
      34             :     namespace sheet { class XSheetCellRanges; }
      35             :     namespace sheet { class XSpreadsheet; }
      36             :     namespace table { class XCell; }
      37             :     namespace table { class XCell2; }
      38             :     namespace table { class XCellRange; }
      39             :     namespace table { class XTableColumns; }
      40             :     namespace table { class XTableRows; }
      41             : } } }
      42             : 
      43             : namespace oox {
      44             : namespace xls {
      45             : 
      46             : class AutoFilterBuffer;
      47             : struct BinAddress;
      48             : struct BinRange;
      49             : class CommentsBuffer;
      50             : class CondFormatBuffer;
      51             : class Font;
      52             : class PageSettings;
      53             : class QueryTableBuffer;
      54             : class RichString;
      55             : class SheetDataBuffer;
      56             : class SheetViewSettings;
      57             : class VmlDrawing;
      58             : class WorksheetSettings;
      59             : 
      60             : typedef ::std::map< OUString, void* >  ExtLst;
      61             : 
      62             : typedef ::std::map< BinAddress, sal_Int32 > SharedFormulaMap;
      63             : 
      64             : /** An enumeration for all types of sheets in a workbook. */
      65             : enum WorksheetType
      66             : {
      67             :     SHEETTYPE_WORKSHEET,            /// Worksheet.
      68             :     SHEETTYPE_CHARTSHEET,           /// Chart sheet.
      69             :     SHEETTYPE_MACROSHEET,           /// Macro sheet.
      70             :     SHEETTYPE_DIALOGSHEET,          /// Dialog sheet (BIFF5+).
      71             :     SHEETTYPE_MODULESHEET,          /// VB module sheet (BIFF5 only).
      72             :     SHEETTYPE_EMPTYSHEET            /// Other (unsupported) sheet type.
      73             : };
      74             : 
      75             : /** Stores settings and formatting data about a range of sheet columns. */
      76             : struct ColumnModel
      77             : {
      78             :     ValueRange          maRange;            /// 1-based (!) range of the described columns.
      79             :     double              mfWidth;            /// Column width in number of characters.
      80             :     sal_Int32           mnXfId;             /// Column default formatting.
      81             :     sal_Int32           mnLevel;            /// Column outline level.
      82             :     bool                mbShowPhonetic:1;   /// True = cells in column show phonetic settings.
      83             :     bool                mbHidden:1;         /// True = column is hidden.
      84             :     bool                mbCollapsed:1;      /// True = column outline is collapsed.
      85             : 
      86             :     explicit            ColumnModel();
      87             : 
      88             :     /** Returns true, if this entry can be merged with the passed column range (column settings are equal). */
      89             :     bool                isMergeable( const ColumnModel& rModel ) const;
      90             : };
      91             : 
      92             : /** Stores settings and formatting data about a sheet row. */
      93        4048 : struct RowModel
      94             : {
      95             :     sal_Int32           mnRow;              /// 1-based (!) index of the described row.
      96             :     ValueRangeSet       maColSpans;         /// 0-based (!) column ranges of used cells.
      97             :     double              mfHeight;           /// Row height in points.
      98             :     sal_Int32           mnXfId;             /// Row default formatting (see mbIsFormatted).
      99             :     sal_Int32           mnLevel;            /// Row outline level.
     100             :     bool                mbCustomHeight:1;   /// True = row has custom height.
     101             :     bool                mbCustomFormat:1;   /// True = cells in row have explicit formatting.
     102             :     bool                mbShowPhonetic:1;   /// True = cells in row show phonetic settings.
     103             :     bool                mbHidden:1;         /// True = row is hidden.
     104             :     bool                mbCollapsed:1;      /// True = row outline is collapsed.
     105             :     bool                mbThickTop:1;       /// True = row has extra space above text.
     106             :     bool                mbThickBottom:1;    /// True = row has extra space below text.
     107             : 
     108             :     explicit            RowModel();
     109             : 
     110             :     /** Inserts the passed column span into the row model. */
     111             :     void                insertColSpan( const ValueRange& rColSpan );
     112             :     /** Returns true, if this entry can be merged with the passed row range (row settings are equal). */
     113             :     bool                isMergeable( const RowModel& rModel ) const;
     114             : };
     115             : 
     116             : /** Stores formatting data about a page break. */
     117             : struct PageBreakModel
     118             : {
     119             :     sal_Int32           mnColRow;           /// 0-based (!) index of column/row.
     120             :     sal_Int32           mnMin;              /// Start of limited break.
     121             :     sal_Int32           mnMax;              /// End of limited break.
     122             :     bool                mbManual;           /// True = manual page break.
     123             : 
     124             :     explicit            PageBreakModel();
     125             : };
     126             : 
     127             : /** Stores data about a hyperlink range. */
     128          18 : struct HyperlinkModel : public ::oox::ole::StdHlinkInfo
     129             : {
     130             :     ::com::sun::star::table::CellRangeAddress
     131             :                         maRange;            /// The cell area containing the hyperlink.
     132             :     OUString     maTooltip;          /// Additional tooltip text.
     133             : 
     134             :     explicit            HyperlinkModel();
     135             : };
     136             : 
     137             : /** Stores data about ranges with data validation settings. */
     138           0 : struct ValidationModel
     139             : {
     140             :     ApiCellRangeList    maRanges;
     141             :     ApiTokenSequence    maTokens1;
     142             :     ApiTokenSequence    maTokens2;
     143             :     OUString     msRef;
     144             :     OUString     maInputTitle;
     145             :     OUString     maInputMessage;
     146             :     OUString     maErrorTitle;
     147             :     OUString     maErrorMessage;
     148             :     sal_Int32           mnType;
     149             :     sal_Int32           mnOperator;
     150             :     sal_Int32           mnErrorStyle;
     151             :     bool                mbShowInputMsg:1;
     152             :     bool                mbShowErrorMsg:1;
     153             :     bool                mbNoDropDown:1;
     154             :     bool                mbAllowBlank:1;
     155             : 
     156             :     explicit            ValidationModel();
     157             : 
     158             :     /** Sets the passed BIFF validation type. */
     159             :     void                setBiffType( sal_uInt8 nType );
     160             :     /** Sets the passed BIFF operator. */
     161             :     void                setBiffOperator( sal_uInt8 nOperator );
     162             :     /** Sets the passed BIFF error style. */
     163             :     void                setBiffErrorStyle( sal_uInt8 nErrorStyle );
     164             : };
     165             : 
     166             : class WorksheetGlobals;
     167             : typedef ::boost::shared_ptr< WorksheetGlobals > WorksheetGlobalsRef;
     168             : 
     169         260 : class IWorksheetProgress {
     170             : public:
     171         260 :     virtual ~IWorksheetProgress() {}
     172             :     virtual ISegmentProgressBarRef getRowProgress() = 0;
     173             :     virtual void                   setCustomRowProgress(
     174             :                                         const ISegmentProgressBarRef &rxRowProgress ) = 0;
     175             : };
     176             : 
     177        9718 : class WorksheetHelper : public WorkbookHelper
     178             : {
     179             : public:
     180             :     /*implicit*/        WorksheetHelper( WorksheetGlobals& rSheetGlob );
     181             : 
     182             :     static WorksheetGlobalsRef constructGlobals(
     183             :                             const WorkbookHelper& rHelper,
     184             :                             const ISegmentProgressBarRef& rxProgressBar,
     185             :                             WorksheetType eSheetType,
     186             :                             sal_Int16 nSheet );
     187             : 
     188             :     // horrible accessor for hidden WorksheetGlobals ...
     189             :     static IWorksheetProgress *getWorksheetInterface( const WorksheetGlobalsRef &xRef );
     190             : 
     191             :     /** Returns the type of this sheet. */
     192             :     WorksheetType       getSheetType() const;
     193             :     /** Returns the index of the current sheet. */
     194             :     sal_Int16           getSheetIndex() const;
     195             :     /** Returns the XSpreadsheet interface of the current sheet. */
     196             :     const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >&
     197             :                         getSheet() const;
     198             : 
     199             :     /** Returns the XCell interface for the passed cell address. */
     200             :     ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell >
     201             :                         getCell( const ::com::sun::star::table::CellAddress& rAddress ) const;
     202             :     /** Returns the XCellRange interface for the passed cell range address. */
     203             :     ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
     204             :                         getCellRange( const ::com::sun::star::table::CellRangeAddress& rRange ) const;
     205             : 
     206             :     /** Returns the XDrawPage interface of the draw page of the current sheet. */
     207             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
     208             :                         getDrawPage() const;
     209             : 
     210             :     /** Returns the absolute cell position in 1/100 mm. */
     211             :     ::com::sun::star::awt::Point getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const;
     212             :     /** Returns the cell size in 1/100 mm. */
     213             :     ::com::sun::star::awt::Size getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const;
     214             :     /** Returns the size of the entire drawing page in 1/100 mm. */
     215             :     ::com::sun::star::awt::Size getDrawPageSize() const;
     216             : 
     217             :     /** Returns the buffer for cell contents and cell formatting. */
     218             :     SheetDataBuffer&    getSheetData() const;
     219             :     /** Returns the conditional formatting in this sheet. */
     220             :     CondFormatBuffer&   getCondFormats() const;
     221             :     /** Returns the buffer for all cell comments in this sheet. */
     222             :     CommentsBuffer&     getComments() const;
     223             :     /** Returns the auto filters for the sheet. */
     224             :     AutoFilterBuffer&   getAutoFilters() const;
     225             :     /** Returns the buffer for all web query tables in this sheet. */
     226             :     QueryTableBuffer&   getQueryTables() const;
     227             :     /** Returns the worksheet settings object. */
     228             :     WorksheetSettings&  getWorksheetSettings() const;
     229             :     /** Returns the page/print settings for this sheet. */
     230             :     PageSettings&       getPageSettings() const;
     231             :     /** Returns the view settings for this sheet. */
     232             :     SheetViewSettings&  getSheetViewSettings() const;
     233             :     /** Returns the VML drawing page for this sheet (OOXML/BIFF12 only). */
     234             :     VmlDrawing&         getVmlDrawing() const;
     235             : 
     236             :     ExtLst&             getExtLst() const;
     237             : 
     238             :     /** Sets a column or row page break described in the passed struct. */
     239             :     void                setPageBreak( const PageBreakModel& rModel, bool bRowBreak );
     240             :     /** Inserts the hyperlink URL into the spreadsheet. */
     241             :     void                setHyperlink( const HyperlinkModel& rModel );
     242             :     /** Inserts the data validation settings into the spreadsheet. */
     243             :     void                setValidation( const ValidationModel& rModel );
     244             :     /** Sets the path to the DrawingML fragment of this sheet. */
     245             :     void                setDrawingPath( const OUString& rDrawingPath );
     246             :     /** Sets the path to the legacy VML drawing fragment of this sheet. */
     247             :     void                setVmlDrawingPath( const OUString& rVmlDrawingPath );
     248             : 
     249             :     /** Extends the used area of this sheet by the passed cell position. */
     250             :     void                extendUsedArea( const ::com::sun::star::table::CellAddress& rAddress );
     251             :     /** Extends the used area of this sheet by the passed cell range. */
     252             :     void                extendUsedArea( const ::com::sun::star::table::CellRangeAddress& rRange );
     253             :     /** Extends the shape bounding box by the position and size of the passed rectangle (in 1/100 mm). */
     254             :     void                extendShapeBoundingBox( const ::com::sun::star::awt::Rectangle& rShapeRect );
     255             : 
     256             :     /** Sets base width for all columns (without padding pixels). This value
     257             :         is only used, if width has not been set with setDefaultColumnWidth(). */
     258             :     void                setBaseColumnWidth( sal_Int32 nWidth );
     259             :     /** Sets default width for all columns. This function overrides the base
     260             :         width set with the setBaseColumnWidth() function. */
     261             :     void                setDefaultColumnWidth( double fWidth );
     262             :     /** Sets column settings for a specific range of columns.
     263             :         @descr  Column default formatting is converted directly, other settings
     264             :         are cached and converted in the finalizeWorksheetImport() call. */
     265             :     void                setColumnModel( const ColumnModel& rModel );
     266             : 
     267             :     /** Sets default height and hidden state for all unused rows in the sheet. */
     268             :     void                setDefaultRowSettings(
     269             :                             double fHeight, bool bCustomHeight,
     270             :                             bool bHidden, bool bThickTop, bool bThickBottom );
     271             :     /** Sets row settings for a specific range of rows.
     272             :         @descr  Row default formatting is converted directly, other settings
     273             :         are cached and converted in the finalizeWorksheetImport() call. */
     274             :     void                setRowModel( const RowModel& rModel );
     275             :     /** Specifies that the passed row needs to set its height manually. */
     276             :     void                setManualRowHeight( sal_Int32 nRow );
     277             : 
     278             :     /** Inserts a value cell directly into the Calc sheet. */
     279             :     void putValue( const com::sun::star::table::CellAddress& rAddress, double fValue );
     280             : 
     281             :     /** Inserts a string cell directly into the Calc sheet. */
     282             :     void putString( const com::sun::star::table::CellAddress& rAddress, const OUString& rText );
     283             :     /** Inserts a rich-string cell directly into the Calc sheet. */
     284             :     void putRichString(
     285             :         const com::sun::star::table::CellAddress& rAddress,
     286             :         const RichString& rString, const oox::xls::Font* pFirstPortionFont );
     287             :     /** Inserts a formula cell directly into the Calc sheet. */
     288             :     void putFormulaTokens(
     289             :         const com::sun::star::table::CellAddress& rAddress, const ApiTokenSequence& rTokens );
     290             : 
     291             :     /** Initial conversion before importing the worksheet. */
     292             :     void                initializeWorksheetImport();
     293             :     /** Final conversion after importing the worksheet. */
     294             :     void                finalizeWorksheetImport();
     295             :     /** Final import of drawing objects. Has to be called after all content has been imported */
     296             :     void finalizeDrawingImport();
     297             : 
     298             :     void                setCellFormula( const ::com::sun::star::table::CellAddress& rTokenAddress, const OUString&  );
     299             : 
     300             :     void setCellFormula(
     301             :         const com::sun::star::table::CellAddress& rAddr, sal_Int32 nSharedId,
     302             :         const OUString& rCellValue, sal_Int32 nValueType );
     303             : 
     304             :     void                setCellArrayFormula( const ::com::sun::star::table::CellRangeAddress& rRangeAddress, const ::com::sun::star::table::CellAddress& rTokenAddress, const OUString&  );
     305             : 
     306             :     void createSharedFormulaMapEntry(
     307             :         const com::sun::star::table::CellAddress& rAddress,
     308             :         const com::sun::star::table::CellRangeAddress& rRange,
     309             :         sal_Int32 nSharedId, const OUString& rTokens );
     310             : 
     311             :     void setCellFormulaValue(
     312             :         const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
     313             : 
     314             : private:
     315             :     WorksheetGlobals&   mrSheetGlob;
     316             : };
     317             : 
     318             : } // namespace xls
     319             : } // namespace oox
     320             : 
     321             : #endif
     322             : 
     323             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10