Coverage Report

Created: 2026-07-20 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwps/src/lib/Quattro9Spreadsheet.h
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* libwps
3
 * Version: MPL 2.0 / LGPLv2.1+
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
 * Major Contributor(s):
10
 * Copyright (C) 2006, 2007 Andrew Ziem
11
 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
12
 * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
13
 *
14
 * For minor contributions see the git repository.
15
 *
16
 * Alternatively, the contents of this file may be used under the terms
17
 * of the GNU Lesser General Public License Version 2.1 or later
18
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19
 * applicable instead of those above.
20
 */
21
22
#ifndef QUATTRO9_SPREADSHEET_H
23
#define QUATTRO9_SPREADSHEET_H
24
25
#include <ostream>
26
#include <map>
27
#include <vector>
28
29
#include <librevenge-stream/librevenge-stream.h>
30
31
#include "libwps_internal.h"
32
33
#include "WPSDebug.h"
34
#include "WKSContentListener.h"
35
36
#include "QuattroFormula.h"
37
38
namespace Quattro9SpreadsheetInternal
39
{
40
struct CellData;
41
class SpreadSheet;
42
struct State;
43
}
44
45
namespace Quattro9ParserInternal
46
{
47
struct TextEntry;
48
}
49
50
class Quattro9Parser;
51
52
/**
53
 * This class parses Quattro9 Pro spreadsheet file
54
 *
55
 */
56
class Quattro9Spreadsheet
57
{
58
public:
59
  friend class Quattro9Parser;
60
61
  //! constructor
62
  explicit Quattro9Spreadsheet(Quattro9Parser &parser);
63
  //! destructor
64
  ~Quattro9Spreadsheet();
65
  //! sets the listener
66
  void setListener(WKSContentListenerPtr &listen)
67
7.45k
  {
68
7.45k
    m_listener = listen;
69
7.45k
  }
70
  //! clean internal state
71
  void cleanState();
72
  //! update the state (need to be called before sending data)
73
  void updateState();
74
75
protected:
76
  //! return the file version
77
  int version() const;
78
  //! return the file sub version
79
  int subversion() const;
80
  //! returns the function to read a cell's reference
81
  QuattroFormulaManager::CellReferenceFunction getReadCellReferenceFunction();
82
83
  //! returns the number of spreadsheet
84
  int getNumSpreadsheets() const;
85
  //! returns the name of the id's spreadsheet
86
  librevenge::RVNGString getSheetName(int id) const;
87
  //! send the sheetId'th spreadsheet
88
  void sendSpreadsheet(int sheetId);
89
  //! returns the beginning position of a cell
90
  Vec2f getPosition(int sheetId, Vec2i const &cell) const;
91
  //! add a dll's correspondance between an id and a name
92
  void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1);
93
  //! add a user format's correspondance between an id and a name
94
  void addUserFormat(int id, librevenge::RVNGString const &name);
95
  //! set the document strings list
96
  void addDocumentStrings(std::shared_ptr<WPSStream> const &stream,
97
                          std::vector<Quattro9ParserInternal::TextEntry> const &entries);
98
99
  //
100
  // low level
101
  //
102
103
  //! send the cell data
104
  void sendCellContent(Quattro9SpreadsheetInternal::CellData const *cell, Vec2i pos, int sheetId, int numRepeated);
105
106
  //! reads a cell attribute: zone a
107
  bool readCellStyles(std::shared_ptr<WPSStream> const &stream);
108
  //! reads the document formulas: zone 408
109
  bool readDocumentFormulas(std::shared_ptr<WPSStream> const &stream);
110
  //! read the begin sheet zone: zone 601
111
  bool readBeginSheet(std::shared_ptr<WPSStream> const &stream, int &sheetId);
112
  //! read the end sheet zone: zone 602
113
  bool readEndSheet(std::shared_ptr<WPSStream> const &stream);
114
  //! read the page break zone: zone 617
115
  static bool readPageBreak(std::shared_ptr<WPSStream> const &stream);
116
  //! read the merged cell: zone 61d
117
  bool readMergedCells(std::shared_ptr<WPSStream> const &stream);
118
  //! read a col/row default dimension: zone 631, 632
119
  bool readColRowDefault(std::shared_ptr<WPSStream> const &stream);
120
  //! read a col/row dimension: zone 633, 634
121
  bool readColRowDimension(std::shared_ptr<WPSStream> const &stream);
122
  //! read a col/row dimensions: zone 635, 636
123
  bool readColRowDimensions(std::shared_ptr<WPSStream> const &stream);
124
  //! read the begin column zone: zone a01
125
  bool readBeginColumn(std::shared_ptr<WPSStream> const &stream);
126
  //! read the end column zone: zone a02
127
  bool readEndColumn(std::shared_ptr<WPSStream> const &stream);
128
  //! reads a cell list zone: zone c01
129
  bool readCellList(std::shared_ptr<WPSStream> const &stream);
130
  //! reads a cell result zone: zone c02
131
  bool readCellResult(std::shared_ptr<WPSStream> const &stream);
132
133
  /* reads a cell */
134
  static bool readCell(std::shared_ptr<WPSStream> const &stream, Vec2i actPos, WKSContentListener::FormulaInstruction &instr, int sheetId, librevenge::RVNGString const &fName);
135
  //! try to read a cell reference
136
  bool readCellReference(std::shared_ptr<WPSStream> const &stream, long endPos,
137
                         QuattroFormulaInternal::CellReference &ref,
138
                         Vec2i const &pos=Vec2i(0,0), int sheetId=0) const;
139
  //////////////////////// spreadsheet //////////////////////////////
140
141
private:
142
  Quattro9Spreadsheet(Quattro9Spreadsheet const &orig) = delete;
143
  Quattro9Spreadsheet &operator=(Quattro9Spreadsheet const &orig) = delete;
144
  std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
145
  //! the main parser
146
  Quattro9Parser &m_mainParser;
147
  //! the internal state
148
  std::shared_ptr<Quattro9SpreadsheetInternal::State> m_state;
149
};
150
151
#endif /* WPS4_H */
152
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */