Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WPXTable.h
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* libwpd
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) 2002 William Lachance (wrlach@gmail.com)
11
 * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
12
 *
13
 * For minor contributions see the git repository.
14
 *
15
 * Alternatively, the contents of this file may be used under the terms
16
 * of the GNU Lesser General Public License Version 2.1 or later
17
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18
 * applicable instead of those above.
19
 *
20
 * For further information visit http://libwpd.sourceforge.net
21
 */
22
23
/* "This product is not manufactured, approved, or supported by
24
 * Corel Corporation or Corel Corporation Limited."
25
 */
26
27
// WPXTable: an intermediate representation of a table, designed to be created
28
// "ahead of time". unlike wordperfect's table definition messages, this representation
29
// is _consistent_: we can always count on the messages being sent using this representation
30
// (once it is created and finalized) to be reliable (assuming no bugs in this code!) :-)
31
//
32
// example situation where this might be useful: WordPerfect allows two cells,
33
// side by side, one with border, one without-- creating a false ambiguity (none
34
// actually exists: if one cell does not have a border, the other doesn't either)
35
36
#ifndef _WPXTABLE_H
37
#define _WPXTABLE_H
38
39
#include <vector>
40
41
struct WPXTableCell
42
{
43
  WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
44
  unsigned char m_colSpan;
45
  unsigned char m_rowSpan;
46
  unsigned char m_borderBits;
47
};
48
49
class WPXTable
50
{
51
public:
52
56.7k
  WPXTable() : m_tableRows() {}
53
  ~WPXTable();
54
  void insertRow();
55
  void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
56
  const WPXTableCell  *getCell(std::size_t i, std::size_t j)
57
111k
  {
58
111k
    return &(m_tableRows[i])[j];
59
111k
  }
60
  void makeBordersConsistent();
61
62
  unsigned getRowCount() const
63
111k
  {
64
111k
    return m_tableRows.size();
65
111k
  }
66
  unsigned getColumnCount(unsigned row) const
67
111k
  {
68
111k
    return m_tableRows[row].size();
69
111k
  }
70
  bool isEmpty() const
71
6.50k
  {
72
6.50k
    return m_tableRows.empty();
73
6.50k
  }
74
75
private:
76
  static void _makeCellBordersConsistent(WPXTableCell &cell, std::vector<WPXTableCell *> &adjacentCells,
77
                                         int adjacencyBitCell, int adjacencyBitBoundCells);
78
  std::vector<WPXTableCell *>  _getCellsBottomAdjacent(int i, int j);
79
  std::vector<WPXTableCell *>  _getCellsRightAdjacent(int i, int j);
80
81
private:
82
  std::vector< std::vector<WPXTableCell> > m_tableRows;
83
};
84
85
#endif /* _WPXTABLE_H */
86
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */