Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / sheetdatacontext.hxx
blobb413e3d921b138fcb8505c0eb002b4325b3347a8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <memory>
23 #include "addressconverter.hxx"
24 #include "excelhandlers.hxx"
25 #include "richstring.hxx"
26 #include "sheetdatabuffer.hxx"
27 #include <vcl/svapp.hxx>
29 #define MULTI_THREAD_SHEET_PARSING 1
31 namespace oox::xls {
33 /** This class implements importing the sheetData element.
35 The sheetData element contains all row settings and all cells in a single
36 sheet of a spreadsheet document.
38 class SheetDataContext : public WorksheetContextBase
40 AddressConverter& mrAddressConv; /// The address converter.
41 std::unique_ptr<FormulaParser> mxFormulaParser; /// The formula parser, different one for each SheetDataContext
42 SheetDataBuffer& mrSheetData; /// The sheet data buffer for cell content and formatting.
43 CellModel maCellData; /// Position, contents, formatting of current imported cell.
44 CellFormulaModel maFmlaData; /// Settings for a cell formula.
45 sal_Int16 mnSheet; /// Index of the current sheet.
46 // If we are doing threaded parsing, this SheetDataContext
47 // forms the inner loop for bulk data parsing, and for the
48 // duration of this we can drop the solar mutex.
49 #if MULTI_THREAD_SHEET_PARSING
50 SolarMutexReleaser aReleaser;
51 #endif
53 public:
54 explicit SheetDataContext( WorksheetFragmentBase& rFragment );
55 virtual ~SheetDataContext() override;
57 protected:
58 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
59 virtual void onCharacters( const OUString& rChars ) override;
60 virtual void onEndElement() override;
62 virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
64 private:
65 /** Different types of cell records. */
66 enum CellType { CELLTYPE_VALUE, CELLTYPE_MULTI, CELLTYPE_FORMULA };
68 /** Imports row settings from a row element. */
69 void importRow( const AttributeList& rAttribs );
70 /** Imports cell settings from a c element. */
71 bool importCell( const AttributeList& rAttribs );
72 /** Imports cell settings from an f element. */
73 void importFormula( const AttributeList& rAttribs );
75 /** Imports row settings from a ROW record. */
76 void importRow( SequenceInputStream& rStrm );
78 /** Reads a cell address and the following XF identifier. */
79 bool readCellHeader( SequenceInputStream& rStrm, CellType eCellType );
80 /** Reads a cell formula for the current cell. */
81 ApiTokenSequence readCellFormula( SequenceInputStream& rStrm );
82 /** Reads the formula range used by shared formulas, arrays, and data tables. */
83 bool readFormulaRef( SequenceInputStream& rStrm );
85 /** Imports an empty cell from a CELL_BLANK or MULTCELL_BLANK record. */
86 void importCellBlank( SequenceInputStream& rStrm, CellType eCellType );
87 /** Imports a boolean cell from a CELL_BOOL, MULTCELL_BOOL, or FORMULA_BOOL record. */
88 void importCellBool( SequenceInputStream& rStrm, CellType eCellType );
89 /** Imports a numeric cell from a CELL_DOUBLE, MULTCELL_DOUBLE, or FORMULA_DOUBLE record. */
90 void importCellDouble( SequenceInputStream& rStrm, CellType eCellType );
91 /** Imports an error code cell from a CELL_ERROR, MULTCELL_ERROR, or FORMULA_ERROR record. */
92 void importCellError( SequenceInputStream& rStrm, CellType eCellType );
93 /** Imports an encoded numeric cell from a CELL_RK or MULTCELL_RK record. */
94 void importCellRk( SequenceInputStream& rStrm, CellType eCellType );
95 /** Imports a rich-string cell from a CELL_RSTRING or MULTCELL_RSTRING record. */
96 void importCellRString( SequenceInputStream& rStrm, CellType eCellType );
97 /** Imports a string cell from a CELL_SI or MULTCELL_SI record. */
98 void importCellSi( SequenceInputStream& rStrm, CellType eCellType );
99 /** Imports a string cell from a CELL_STRING, MULTCELL_STRING, or FORMULA_STRING record. */
100 void importCellString( SequenceInputStream& rStrm, CellType eCellType );
102 /** Imports an array formula from an ARRAY record. */
103 void importArray( SequenceInputStream& rStrm );
104 /** Imports table operation from a DATATABLE record. */
105 void importDataTable( SequenceInputStream& rStrm );
106 /** Imports a shared formula from a SHAREDFORMULA record. */
107 void importSharedFmla( SequenceInputStream& rStrm );
109 private:
110 OUString maCellValue; /// Cell value string (OOXML only).
111 RichStringRef mxInlineStr; /// Inline rich string (OOXML only).
112 OUString maFormulaStr;
113 DataTableModel maTableData; /// Settings for table operations.
114 BinAddress maCurrPos; /// Current cell position (BIFF12 only).
115 bool mbHasFormula; /// True = current cell has formula data (OOXML only).
116 bool mbValidRange; /// True = maFmlaData.maFormulaRef is valid (OOXML only).
118 sal_Int32 mnRow; /// row index (0-based)
119 sal_Int32 mnCol; /// column index (0-based)
122 } // namespace oox::xls
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */