Coverage Report

Created: 2026-06-13 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwps/src/lib/WPS8Table.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) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11
 * Copyright (C) 2006, 2007 Andrew Ziem
12
 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13
 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14
 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15
 *
16
 * For minor contributions see the git repository.
17
 *
18
 * Alternatively, the contents of this file may be used under the terms
19
 * of the GNU Lesser General Public License Version 2.1 or later
20
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21
 * applicable instead of those above.
22
 *
23
 * For further information visit http://libwps.sourceforge.net
24
 */
25
26
#ifndef WPS8_TABLE
27
#  define WPS8_TABLE
28
29
#include "libwps_internal.h"
30
31
#include "WPSDebug.h"
32
33
class WPS8Parser;
34
35
namespace WPS8TableInternal
36
{
37
struct Cell;
38
struct State;
39
}
40
41
////////////////////////////////////////////////////////////
42
//
43
// class to parse the object
44
//
45
////////////////////////////////////////////////////////////
46
47
/** \brief the main class to read/store table in a Pc MS Works document v5-8
48
 *
49
 * This class must be associated with a WPS8Parser. It contains code to read
50
 * the MCLD entries which seems to correspond to a table entry (potentially a table
51
 * entry with only one cells).
52
 *
53
 * \note Actually, the relations between the MCLD entries and the FRAM entries (which
54
 * seems to store all the object positions) are not fully understood ; so the result
55
 * of this parsing is not used to create the document.
56
 */
57
class WPS8Table
58
{
59
  friend struct WPS8TableInternal::Cell;
60
  friend class WPS8Parser;
61
public:
62
  //! constructor
63
  explicit WPS8Table(WPS8Parser &parser);
64
65
  //! destructor
66
  ~WPS8Table();
67
68
  //! sets the listener
69
  void setListener(WPSContentListenerPtr &listen)
70
8.94k
  {
71
8.94k
    m_listener = listen;
72
8.94k
  }
73
74
  //! computes the final position of all table: does nothing as table anchors seem always a char
75
  void computePositions() const;
76
77
  //! returns the number page where we find a picture. In practice, 0/1
78
  int numPages() const;
79
80
  /** sends the data which have not been send to the listener. */
81
  void flushExtra();
82
83
protected:
84
  //! finds all structures which correspond to a table
85
  bool readStructures(RVNGInputStreamPtr const &input);
86
87
  /** tries to send a table corresponding to strsid with actual size siz
88
   *
89
   * \param siz the size of the table in the document
90
   * \param tableId the table identificator
91
   * \param strsid indicates the text entry (and its corresponding TCD )
92
   * \param inTextBox indicates if we have already created a textbox to insert the table
93
   * which contains the cells' text.
94
   */
95
  bool sendTable(Vec2f const &siz, int tableId, int strsid, bool inTextBox=false);
96
97
  // interface with main parser
98
  void sendTextInCell(int strsId, int cellId);
99
100
protected: // low level
101
102
  //! reads a MCLD zone: a zone which stores the tables structures
103
  bool readMCLD(RVNGInputStreamPtr input, WPSEntry const &entry);
104
105
  //! returns the file version
106
  int version() const;
107
108
  //! returns the debug file
109
  libwps::DebugFile &ascii()
110
4.65M
  {
111
4.65M
    return m_asciiFile;
112
4.65M
  }
113
private:
114
  WPS8Table(WPS8Table const &orig) = delete;
115
  WPS8Table &operator=(WPS8Table const &orig) = delete;
116
117
protected:
118
  //! the listener
119
  WPSContentListenerPtr m_listener;
120
121
  //! the main parser
122
  WPS8Parser &m_mainParser;
123
124
  //! the state
125
  mutable std::shared_ptr<WPS8TableInternal::State> m_state;
126
127
  //! the ascii file
128
  libwps::DebugFile &m_asciiFile;
129
};
130
131
#endif
132
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: