Coverage Report

Created: 2026-04-29 07:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwps/src/lib/QuattroDosSpreadsheet.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 QUATTRO_DOS_SPREADSHEET_H
23
#define QUATTRO_DOS_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
namespace QuattroDosSpreadsheetInternal
37
{
38
class Cell;
39
class SpreadSheet;
40
struct State;
41
}
42
43
class QuattroDosParser;
44
45
/**
46
 * This class parses Quattro Pro DOS spreadsheet file
47
 *
48
 */
49
class QuattroDosSpreadsheet
50
{
51
public:
52
  friend class QuattroDosParser;
53
54
  //! constructor
55
  explicit QuattroDosSpreadsheet(QuattroDosParser &parser);
56
  //! destructor
57
  ~QuattroDosSpreadsheet();
58
  //! sets the listener
59
  void setListener(WKSContentListenerPtr &listen)
60
5.47k
  {
61
5.47k
    m_listener = listen;
62
5.47k
  }
63
64
protected:
65
  //! return true if the pos is in the file, update the file size if need
66
  bool checkFilePosition(long pos);
67
  //! return the file version
68
  int version() const;
69
70
  //! returns the number of spreadsheet
71
  int getNumSpreadsheets() const;
72
  //! returns the name of the id's spreadsheet
73
  librevenge::RVNGString getSheetName(int id) const;
74
  //! send the sId'th spreadsheet
75
  void sendSpreadsheet(int sId, std::map<Vec2i,Vec2i> const &chartCellMap);
76
77
  //! send the cell data
78
  void sendCellContent(QuattroDosSpreadsheetInternal::Cell const &cell, int sheetId,
79
                       int cellChartSheetId=-1, Vec2f const &chartSize=Vec2f());
80
81
  //////////////////////// open/close //////////////////////////////
82
83
  //! reads a sheet header zone 0:dc (Quattro Pro wq2)
84
  bool readSpreadsheetOpen();
85
  //! reads a sheet header zone 0:dd (Quattro Pro wq2)
86
  bool readSpreadsheetClose();
87
88
  //
89
  // low level
90
  //
91
  //////////////////////// spread sheet //////////////////////////////
92
93
  //! reads a cell content data
94
  bool readCell();
95
  //! reads the result of a text formula
96
  bool readCellFormulaResult();
97
  //! reads sheet size
98
  bool readSheetSize();
99
  //! reads a sheet name (zone 0xde), unused...
100
  bool readSpreadsheetName();
101
  //! reads the column size ( in ??? )
102
  bool readColumnSize();
103
  //! reads the column size ( in points )
104
  bool readRowSize();
105
  //! reads the list of hidden columns zone ( unused )
106
  bool readHiddenColumns();
107
108
  //! reads a Quattro Pro property (zone 0x9d)
109
  bool readCellProperty();
110
  //! reads a Quattro Pro cell styles (zone 0xd8)
111
  bool readCellStyle();
112
  //! reads a Quattro Pro style ( zone 0xc9)
113
  bool readUserStyle();
114
115
  /* reads a cell */
116
  bool readCell(Vec2i actPos, WKSContentListener::FormulaInstruction &instr, bool hasSheetId=false, int sheetId=0);
117
  /* reads a formula */
118
  bool readFormula(long endPos, Vec2i const &pos, int sheetId,
119
                   std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
120
121
private:
122
  QuattroDosSpreadsheet(QuattroDosSpreadsheet const &orig) = delete;
123
  QuattroDosSpreadsheet &operator=(QuattroDosSpreadsheet const &orig) = delete;
124
  //! returns the debug file
125
  libwps::DebugFile &ascii()
126
940k
  {
127
940k
    return m_asciiFile;
128
940k
  }
129
  /** the input */
130
  RVNGInputStreamPtr m_input;
131
  std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
132
  //! the main parser
133
  QuattroDosParser &m_mainParser;
134
  //! the internal state
135
  std::shared_ptr<QuattroDosSpreadsheetInternal::State> m_state;
136
  //! the ascii file
137
  libwps::DebugFile &m_asciiFile;
138
};
139
140
#endif /* WPS4_H */
141
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */