"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/rtfgenerator.cpp" between
ansifilter-2.17.tar.bz2 and ansifilter-2.18.tar.bz2

About: Ansifilter parses common ANSI codes to remove them or to convert them to another colored text file format (HTML, TeX, LaTeX, RTF, Pango or BBCode).

rtfgenerator.cpp  (ansifilter-2.17.tar.bz2):rtfgenerator.cpp  (ansifilter-2.18.tar.bz2)
skipping to change at line 35 skipping to change at line 35
#include <sstream> #include <sstream>
#include "charcodes.h" #include "charcodes.h"
#include "version.h" #include "version.h"
#include "rtfgenerator.h" #include "rtfgenerator.h"
#include "stylecolour.h" #include "stylecolour.h"
namespace ansifilter namespace ansifilter
{ {
RtfGenerator::RtfGenerator()
: CodeGenerator(RTF),
pageSize("a4"), // Default: DIN A4
isUtf8(false),
utf16Char(0),
utf8SeqLen(0)
{
newLineTag = "\\line\n";
spacer=" ";
// Page dimensions
psMap["a3"] = PageSize(16837,23811);
psMap["a4"] = PageSize(11905,16837);
psMap["a5"] = PageSize(8390,11905);
psMap["b4"] = PageSize(14173,20012);
psMap["b5"] = PageSize(9977,14173);
psMap["b6"] = PageSize(7086,9977);
psMap["letter"] = PageSize(12240,15840);
psMap["legal"] = PageSize(12240,20163);
}
RtfGenerator::~RtfGenerator()
{}
string RtfGenerator::getAttributes( const StyleColour & col) string RtfGenerator::getAttributes( const StyleColour & col)
{ {
stringstream s; stringstream s;
s << "\\red"<< col.getRed(RTF) s << "\\red"<< col.getRed(RTF)
<< "\\green"<<col.getGreen(RTF) << "\\green"<<col.getGreen(RTF)
<< "\\blue"<<col.getBlue(RTF) << "\\blue"<<col.getBlue(RTF)
<< ";"; << ";";
return s.str(); return s.str();
} }
string RtfGenerator::getOpenTag() string RtfGenerator::getOpenTag()
{ {
ostringstream s; ostringstream s;
if (elementStyle.getFgColourID()>=0) { if (elementStyle.getFgColourID()>=0) {
s << "{\\cf"<<(elementStyle.getFgColourID()+ 1); s << "{\\cf"<<(elementStyle.getFgColourID()+ 1);
} }
if (elementStyle.getBgColourID()>=0) { if (elementStyle.getBgColourID()>=0) {
s << "\\chcbpat"<<(elementStyle.getBgColourID()+1); s << "\\chcbpat"<<(elementStyle.getBgColourID()+1);
} }
s <<"{"; s <<"{";
if (!parseCP437 && elementStyle.isBold()) s << "\\b "; if (!parseCP437 && elementStyle.isBold()) s << "\\b ";
skipping to change at line 71 skipping to change at line 97
string RtfGenerator::getCloseTag() string RtfGenerator::getCloseTag()
{ {
ostringstream s; ostringstream s;
if (!parseCP437 && elementStyle.isBold()) s << "\\b0 "; if (!parseCP437 && elementStyle.isBold()) s << "\\b0 ";
if (elementStyle.isItalic()) s << "\\i0 "; if (elementStyle.isItalic()) s << "\\i0 ";
if (elementStyle.isUnderline()) s << "\\ul0 "; if (elementStyle.isUnderline()) s << "\\ul0 ";
s << "}}"; s << "}}";
return s.str(); return s.str();
} }
RtfGenerator::RtfGenerator() /* '{{\\field{\\*\\fldinst HYPERLINK "'..token..'" }{\\fldrslt\\ul\\ulc0 '..toke
: CodeGenerator(RTF), n..'}}}' */
pageSize("a4"), // Default: DIN A4
isUtf8(false),
utf16Char(0),
utf8SeqLen(0)
{
newLineTag = "\\line\n";
spacer=" ";
// Page dimensions
psMap["a3"] = PageSize(16837,23811);
psMap["a4"] = PageSize(11905,16837);
psMap["a5"] = PageSize(8390,11905);
psMap["b4"] = PageSize(14173,20012); string RtfGenerator::getHyperlink(string uri, string txt){
psMap["b5"] = PageSize(9977,14173); ostringstream os;
psMap["b6"] = PageSize(7086,9977); os <<"{{\\field{\\*\\fldinst HYPERLINK \""<<uri<<"\" }{\\fldrslt\\ul\\ulc0 "
<<txt<<"}}}";
psMap["letter"] = PageSize(12240,15840); return os.str();
psMap["legal"] = PageSize(12240,20163);
} }
RtfGenerator::~RtfGenerator()
{}
string RtfGenerator::getHeader() string RtfGenerator::getHeader()
{ {
return string(); return string();
} }
void RtfGenerator::printBody() void RtfGenerator::printBody()
{ {
isUtf8 = encoding == "utf-8" || encoding == "UTF-8"; // FIXME isUtf8 = encoding == "utf-8" || encoding == "UTF-8"; // FIXME
*out << "{\\rtf1"; *out << "{\\rtf1";
 End of changes. 5 change blocks. 
24 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)