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_SHEETDATACONTEXT_HXX
30 : : #define OOX_XLS_SHEETDATACONTEXT_HXX
31 : :
32 : : #include "excelhandlers.hxx"
33 : : #include "richstring.hxx"
34 : : #include "sheetdatabuffer.hxx"
35 : :
36 : : namespace oox {
37 : : namespace xls {
38 : :
39 : : // ============================================================================
40 : :
41 : : /** Used as base for sheet data context classes. Provides fast access to often
42 : : used converter objects and sheet index, to improve performance.
43 : : */
44 : : struct SheetDataContextBase
45 : : {
46 : : AddressConverter& mrAddressConv; /// The address converter.
47 : : FormulaParser& mrFormulaParser; /// The formula parser.
48 : : SheetDataBuffer& mrSheetData; /// The sheet data buffer for cell content and formatting.
49 : : CellModel maCellData; /// Position, contents, formatting of current imported cell.
50 : : CellFormulaModel maFmlaData; /// Settings for a cell formula.
51 : : sal_Int16 mnSheet; /// Index of the current sheet.
52 : :
53 : : explicit SheetDataContextBase( const WorksheetHelper& rHelper );
54 : : virtual ~SheetDataContextBase();
55 : : };
56 : :
57 : : // ============================================================================
58 : :
59 : : /** This class implements importing the sheetData element.
60 : :
61 : : The sheetData element contains all row settings and all cells in a single
62 : : sheet of a spreadsheet document.
63 : : */
64 [ + - ][ - + ]: 120 : class SheetDataContext : public WorksheetContextBase, private SheetDataContextBase
65 : : {
66 : : public:
67 : : explicit SheetDataContext( WorksheetFragmentBase& rFragment );
68 : :
69 : : protected:
70 : : virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
71 : : virtual void onCharacters( const ::rtl::OUString& rChars );
72 : : virtual void onEndElement();
73 : :
74 : : virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
75 : :
76 : : private:
77 : : /** Different types of cell records. */
78 : : enum CellType { CELLTYPE_VALUE, CELLTYPE_MULTI, CELLTYPE_FORMULA };
79 : :
80 : : /** Imports row settings from a row element. */
81 : : void importRow( const AttributeList& rAttribs );
82 : : /** Imports cell settings from a c element. */
83 : : bool importCell( const AttributeList& rAttribs );
84 : : /** Imports cell settings from an f element. */
85 : : void importFormula( const AttributeList& rAttribs );
86 : :
87 : : /** Imports row settings from a ROW record. */
88 : : void importRow( SequenceInputStream& rStrm );
89 : :
90 : : /** Reads a cell address and the following XF identifier. */
91 : : bool readCellHeader( SequenceInputStream& rStrm, CellType eCellType );
92 : : /** Reads a cell formula for the current cell. */
93 : : ApiTokenSequence readCellFormula( SequenceInputStream& rStrm );
94 : : /** Reads the formula range used by shared formulas, arrays, and data tables. */
95 : : bool readFormulaRef( SequenceInputStream& rStrm );
96 : :
97 : : /** Imports an empty cell from a CELL_BLANK or MULTCELL_BLANK record. */
98 : : void importCellBlank( SequenceInputStream& rStrm, CellType eCellType );
99 : : /** Imports a boolean cell from a CELL_BOOL, MULTCELL_BOOL, or FORMULA_BOOL record. */
100 : : void importCellBool( SequenceInputStream& rStrm, CellType eCellType );
101 : : /** Imports a numeric cell from a CELL_DOUBLE, MULTCELL_DOUBLE, or FORMULA_DOUBLE record. */
102 : : void importCellDouble( SequenceInputStream& rStrm, CellType eCellType );
103 : : /** Imports an error code cell from a CELL_ERROR, MULTCELL_ERROR, or FORMULA_ERROR record. */
104 : : void importCellError( SequenceInputStream& rStrm, CellType eCellType );
105 : : /** Imports an encoded numeric cell from a CELL_RK or MULTCELL_RK record. */
106 : : void importCellRk( SequenceInputStream& rStrm, CellType eCellType );
107 : : /** Imports a rich-string cell from a CELL_RSTRING or MULTCELL_RSTRING record. */
108 : : void importCellRString( SequenceInputStream& rStrm, CellType eCellType );
109 : : /** Imports a string cell from a CELL_SI or MULTCELL_SI record. */
110 : : void importCellSi( SequenceInputStream& rStrm, CellType eCellType );
111 : : /** Imports a string cell from a CELL_STRING, MULTCELL_STRING, or FORMULA_STRING record. */
112 : : void importCellString( SequenceInputStream& rStrm, CellType eCellType );
113 : :
114 : : /** Imports an array formula from an ARRAY record. */
115 : : void importArray( SequenceInputStream& rStrm );
116 : : /** Imports table operation from a DATATABLE record. */
117 : : void importDataTable( SequenceInputStream& rStrm );
118 : : /** Imports a shared formula from a SHAREDFORMULA record. */
119 : : void importSharedFmla( SequenceInputStream& rStrm );
120 : :
121 : : private:
122 : : ::rtl::OUString maCellValue; /// Cell value string (OOXML only).
123 : : RichStringRef mxInlineStr; /// Inline rich string (OOXML only).
124 : : ::rtl::OUString maFormulaStr;
125 : : DataTableModel maTableData; /// Settings for table operations.
126 : : BinAddress maCurrPos; /// Current cell position (BIFF12 only).
127 : : bool mbHasFormula; /// True = current cell has formula data (OOXML only).
128 : : bool mbValidRange; /// True = maFmlaData.maFormulaRef is valid (OOXML only).
129 : : };
130 : :
131 : : // ============================================================================
132 : :
133 : :
134 : : } // namespace xls
135 : : } // namespace oox
136 : :
137 : : #endif
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|