WPXTable.h
Go to the documentation of this file.
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 #include <vector>
39 #include <stdio.h>
40 
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:
53  ~WPXTable();
54  void insertRow();
55  void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
56  const WPXTableCell *getCell(size_t i, size_t j)
57  {
58  return (m_tableRows[i])[j];
59  }
60  void makeBordersConsistent();
61  void _makeCellBordersConsistent(WPXTableCell *cell, std::vector<WPXTableCell *> &adjacentCells,
62  int adjacencyBitCell, int adjacencyBitBoundCells);
63  std::vector<WPXTableCell *> _getCellsBottomAdjacent(int i, int j);
64  std::vector<WPXTableCell *> _getCellsRightAdjacent(int i, int j);
65 
66  const std::vector< std::vector<WPXTableCell *> > &getRows() const
67  {
68  return m_tableRows;
69  }
70  bool isEmpty() const
71  {
72  return m_tableRows.empty();
73  }
74 
75 private:
76  std::vector< std::vector<WPXTableCell *> > m_tableRows;
77 };
78 
80 {
81 public:
82  WPXTableList();
83  WPXTableList(const WPXTableList &);
84  WPXTableList &operator=(const WPXTableList &tableList);
85  virtual ~WPXTableList();
86 
87  WPXTable *operator[](unsigned long i)
88  {
89  return (*m_tableList)[i];
90  }
91  void add(WPXTable *table)
92  {
93  m_tableList->push_back(table);
94  }
95  size_t size() const
96  {
97  return m_tableList->size();
98  }
99 
100 private:
101  void release();
102  void acquire(int *refCount, std::vector<WPXTable *> *tableList);
103  int *getRef() const
104  {
105  return m_refCount;
106  }
107  std::vector<WPXTable *> *get() const
108  {
109  return m_tableList;
110  }
111 
112  std::vector<WPXTable *> *m_tableList;
114 };
115 #endif /* _WPXTABLE_H */
116 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
void acquire(int *refCount, std::vector< WPXTable *> *tableList)
Definition: WPXTable.cpp:181
unsigned char m_rowSpan
Definition: WPXTable.h:45
const WPXTableCell * getCell(size_t i, size_t j)
Definition: WPXTable.h:56
Definition: WPXTable.h:49
WPXTableList()
Definition: WPXTable.cpp:155
int * getRef() const
Definition: WPXTable.h:103
const std::vector< std::vector< WPXTableCell * > > & getRows() const
Definition: WPXTable.h:66
WPXTableList & operator=(const WPXTableList &tableList)
Definition: WPXTable.cpp:170
void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:54
Definition: WPXTable.h:79
std::vector< std::vector< WPXTableCell * > > m_tableRows
Definition: WPXTable.h:76
Definition: WPXTable.h:41
std::vector< WPXTable * > * m_tableList
Definition: WPXTable.h:112
std::vector< WPXTableCell * > _getCellsRightAdjacent(int i, int j)
Definition: WPXTable.cpp:131
unsigned char m_colSpan
Definition: WPXTable.h:44
void release()
Definition: WPXTable.cpp:189
void insertRow()
Definition: WPXTable.cpp:49
int * m_refCount
Definition: WPXTable.h:113
void makeBordersConsistent()
Definition: WPXTable.cpp:64
WPXTable()
Definition: WPXTable.h:52
bool isEmpty() const
Definition: WPXTable.h:70
virtual ~WPXTableList()
Definition: WPXTable.cpp:205
WPXTable * operator[](unsigned long i)
Definition: WPXTable.h:87
void _makeCellBordersConsistent(WPXTableCell *cell, std::vector< WPXTableCell *> &adjacentCells, int adjacencyBitCell, int adjacencyBitBoundCells)
Definition: WPXTable.cpp:87
~WPXTable()
Definition: WPXTable.cpp:38
void add(WPXTable *table)
Definition: WPXTable.h:91
std::vector< WPXTableCell * > _getCellsBottomAdjacent(int i, int j)
Definition: WPXTable.cpp:111
WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:31
size_t size() const
Definition: WPXTable.h:95
unsigned char m_borderBits
Definition: WPXTable.h:46

Generated for libwpd by doxygen 1.8.14