libwpd: WPXTable.h Source File documentation

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

# WPXTable.h

Go to the documentation of this file.

    00001 /* libwpd
    00002  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
    00003  * Copyright (C) 2002 Marc Maurer (j.m.maurer@student.utwente.nl)
    00004  *
    00005  * This library is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU Library General Public
    00007  * License as published by the Free Software Foundation; either
    00008  * version 2 of the License, or (at your option) any later version.
    00009  *
    00010  * This library is distributed in the hope that it will be useful,
    00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  * Library General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU Library General Public
    00016  * License along with this library; if not, write to the Free Software
    00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
    00018  *
    00019  * For further information visit http://libwpd.sourceforge.net
    00020  */
    00021
    00022 /* "This product is not manufactured, approved, or supported by
    00023  * Corel Corporation or Corel Corporation Limited."
    00024  */
    00025
    00026 // WPXTable: an intermediate representation of a table, designed to be created
    00027 // "ahead of time". unlike wordperfect's table definition messages, this representation
    00028 // is _consistent_: we can always count on the messages being sent using this representation
    00029 // (once it is created and finalized) to be reliable (assuming no bugs in this code!) :-)
    00030 //
    00031 // example situation where this might be useful: WordPerfect allows two cells,
    00032 // side by side, one with border, one without-- creating a false ambiguity (none
    00033 // actually exists: if one cell does not have a border, the other doesn't either)
    00034
    00035 #ifndef _WPXTABLE_H
    00036 #define _WPXTABLE_H
    00037 #include <vector>
    00038 #include "libwpd_types.h"
    00039
    00040 typedef struct _WPXTableCell WPXTableCell;
    00041
    00042 struct _WPXTableCell
    00043 {
    00044         _WPXTableCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits);
    00045         uint8_t m_colSpan;
    00046         uint8_t m_rowSpan;
    00047         uint8_t m_borderBits;
    00048 };
    00049
    00050 class WPXTable
    00051 {
    00052 public:
    00053         WPXTable() {}
    00054         ~WPXTable();
    00055         void insertRow();
    00056         void insertCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits);
    00057         const WPXTableCell * getCell(int i, int j) { return (*m_tableRows[i])[j]; }
    00058         void makeBordersConsistent();
    00059         void _makeCellBordersConsistent(WPXTableCell *cell, std::vector<WPXTableCell *> *adjacentCells,
    00060                                       int adjacencyBitCell, int adjacencyBitBoundCells);
    00061         std::vector<WPXTableCell *> * _getCellsBottomAdjacent(int i, int j);
    00062         std::vector<WPXTableCell *> * _getCellsRightAdjacent(int i, int j);
    00063
    00064         const std::vector< std::vector<WPXTableCell *> * > * getTableRows() const { return &m_tableRows; } // ugly, but whatever
    00065
    00066 private:
    00067         std::vector< std::vector<WPXTableCell *> * > m_tableRows;
    00068 };
    00069
    00070 class WPXTableList
    00071 {
    00072 public:
    00073         WPXTableList();
    00074         WPXTableList(const WPXTableList &);
    00075         WPXTableList & operator=(const WPXTableList & tableList);
    00076         virtual ~WPXTableList();
    00077
    00078         WPXTable * operator[](size_t i) { return (*m_tableList)[i]; }
    00079         void add(WPXTable *table) { m_tableList->push_back(table); }
    00080
    00081 private:
    00082         void release();
    00083         void acquire(int *refCount, std::vector<WPXTable *> *tableList);
    00084         int * getRef() const { return m_refCount; }
    00085         std::vector<WPXTable *> * get() const { return m_tableList; }
    00086
    00087         std::vector<WPXTable *> *m_tableList;
    00088         int *m_refCount;
    00089 };
    00090 #endif /* _WPXTABLE_H */