File indexing completed on 2025-02-02 04:57:57

0001 /*  This is RTF to HTML converter, implemented as a text filter, generally.
0002     Copyright (C) 2003 Valentin Lavrinenko, vlavrinenko@users.sourceforge.net
0003 
0004     available at http://rtf2html.sf.net
0005 
0006     Original available under the terms of the GNU LGPL2, and according
0007     to those terms, relicensed under the GNU GPL2 for inclusion in Tellico */
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or         *
0012  *   modify it under the terms of the GNU General Public License as        *
0013  *   published by the Free Software Foundation; either version 2 of        *
0014  *   the License or (at your option) version 3 or any later version        *
0015  *   accepted by the membership of KDE e.V. (or its successor approved     *
0016  *   by the membership of KDE e.V.), which shall act as a proxy            *
0017  *   defined in Section 14 of version 3 of the license.                    *
0018  *                                                                         *
0019  *   This program is distributed in the hope that it will be useful,       *
0020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0022  *   GNU General Public License for more details.                          *
0023  *                                                                         *
0024  *   You should have received a copy of the GNU General Public License     *
0025  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0026  *                                                                         *
0027  ***************************************************************************/
0028 
0029 #ifndef __RTF_H__
0030 #define __RTF_H__
0031 
0032 #include "common.h"
0033 #include <vector>
0034 #include <cmath>
0035 #include <list>
0036 #include <cstdlib>
0037 
0038 namespace rtf {
0039 
0040 struct table_cell
0041 {
0042    int Rowspan;
0043    std::string Text;
0044    table_cell() : Rowspan(0) {}
0045 };
0046 
0047 struct table_cell_def
0048 {
0049    enum valign {valign_top, valign_bottom, valign_center};
0050    bool BorderTop, BorderBottom, BorderLeft, BorderRight;
0051    bool *ActiveBorder;
0052    int Right, Left;
0053    bool Merged, FirstMerged;
0054    valign VAlign;
0055    table_cell_def()
0056    {
0057       BorderTop=BorderBottom=BorderLeft=BorderRight=Merged=FirstMerged=false;
0058       ActiveBorder=NULL;
0059       Right=Left=0;
0060       VAlign=valign_top;
0061    }
0062    bool right_equals(int x) { return x==Right; }
0063    bool left_equals(int x) { return x==Left; }
0064 };
0065 
0066 template <class T>
0067 class killing_ptr_vector : public std::vector<T*>
0068 {
0069  public:
0070    ~killing_ptr_vector()
0071    {
0072       for (typename killing_ptr_vector<T>::iterator i=this->begin(); i!=this->end(); ++i)
0073          delete *i;
0074    }
0075 };
0076 
0077 typedef killing_ptr_vector<table_cell> table_cells;
0078 typedef killing_ptr_vector<table_cell_def> table_cell_defs;
0079 
0080 typedef std::list<table_cell_defs> table_cell_defs_list;
0081 
0082 struct table_row
0083 {
0084    table_cells Cells;
0085    table_cell_defs_list::iterator CellDefs;
0086    int Height;
0087    int Left;
0088    table_row() : Height(-1000),  Left(-1000) {}
0089 };
0090 
0091 class table : public killing_ptr_vector<table_row>
0092 {
0093  private:
0094    typedef killing_ptr_vector<table_row> base_class;
0095  public:
0096    table() : base_class() {}
0097    std::string make();
0098 };
0099 
0100 }
0101 
0102 #endif