"Fossies" - the Fresh Open Source Software Archive

Member "ansifilter-2.18/src/rtfgenerator.h" (30 Jan 2021, 3225 Bytes) of package /linux/privat/ansifilter-2.18.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rtfgenerator.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.17_vs_2.18.

    1 /***************************************************************************
    2                           rtfcode.h  -  description
    3                              -------------------
    4 
    5     copyright            : (C) 2007 by Andre Simon
    6     email                : a.simon@mailbox.org
    7  ***************************************************************************/
    8 
    9 /*
   10 This file is part of ANSIFilter.
   11 
   12 ANSIFilter is free software: you can redistribute it and/or modify
   13 it under the terms of the GNU General Public License as published by
   14 the Free Software Foundation, either version 3 of the License, or
   15 (at your option) any later version.
   16 
   17 ANSIFilter is distributed in the hope that it will be useful,
   18 but WITHOUT ANY WARRANTY; without even the implied warranty of
   19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   20 GNU General Public License for more details.
   21 
   22 You should have received a copy of the GNU General Public License
   23 along with ANSIFilter.  If not, see <http://www.gnu.org/licenses/>.
   24 */
   25 
   26 #ifndef RTFGENERATOR_H
   27 #define RTFGENERATOR_H
   28 
   29 #include <string>
   30 #include <map>
   31 #include "codegenerator.h"
   32 
   33 
   34 namespace ansifilter
   35 {
   36 
   37 /**
   38    \brief This class generates RTF.
   39 
   40    It contains information about the resulting document structure (document
   41    header and footer), the colour system, white space handling and text
   42    formatting attributes.
   43 
   44 * @author Andre Simon
   45 */
   46 
   47 
   48 struct PageSize {
   49     /// RTF page width
   50     int width;
   51     /// RTF page height
   52     int height;
   53     PageSize()
   54     {
   55     }
   56     /** Constructor to define page dimensions
   57         @param w width
   58         @param h height*/
   59     PageSize(int w, int h)
   60     {
   61         width=w;
   62         height = h;
   63     }
   64 };
   65 
   66 /** mapping of page size names and dimensions */
   67 typedef  map<string, struct PageSize> PagesizeMap;
   68 
   69 class RtfGenerator : public ansifilter::CodeGenerator
   70 {
   71 public:
   72 
   73     RtfGenerator();
   74     ~RtfGenerator();
   75 
   76     /** \param page size*/
   77     void setPageSize(const string & ps);
   78 
   79 private:
   80 
   81     /** prints document header
   82      */
   83     string getHeader();
   84 
   85     /** Prints document footer*/
   86     string getFooter();
   87 
   88     /** Prints document body*/
   89     void printBody();
   90 
   91     /** Map of several pagesizes */
   92     PagesizeMap psMap;
   93 
   94     /** name of page size which is mapped to page dimensions*/
   95     string pageSize;
   96 
   97 
   98     /** flag to enable Unicode conversion */
   99     bool isUtf8;
  100 
  101     /** utf-8 to utf-16 conversion variables */
  102     unsigned long utf16Char;
  103     size_t utf8SeqLen;
  104 
  105 
  106     /** \return escaped character*/
  107     virtual string maskCharacter(unsigned char );
  108 
  109     /** \return escaped character*/
  110     virtual string maskCP437Character(unsigned char );
  111 
  112     virtual string getHyperlink(string uri, string txt);
  113 
  114     /**\return text formatting attributes in RTF format */
  115     string  getAttributes( const StyleColour & col);
  116 
  117     /** @param styleNumber number of current style
  118         @param elem associated element style
  119         @return RTF formatting seqence (colour index + bold + italic)*/
  120     string getOpenTag();
  121 
  122     /** @param elem associated element style
  123         @return RTF formatting sequnce to close element formatting */
  124     string getCloseTag();
  125 
  126 
  127     void insertLineNumber ();
  128     string unicodeFromHTML(const string &);
  129 
  130 };
  131 
  132 }
  133 #endif