From 9f87bacc0316ed46ca1df575b180441e7802de9d Mon Sep 17 00:00:00 2001 From: Joshua Richardson Date: Wed, 22 Jun 2011 20:04:52 -0700 Subject: [PATCH 3/3] Changed to HTML5/XHTML5. Now rotation should work across all HTML5 compliant browsers. --- utils/HtmlFonts.cc | 17 +++------- utils/HtmlFonts.h | 2 +- utils/HtmlOutputDev.cc | 87 +++++++++++++++++++++++++++--------------------- utils/HtmlOutputDev.h | 9 ++++- 4 files changed, 62 insertions(+), 53 deletions(-) mode change 100644 => 100755 utils/HtmlFonts.cc mode change 100644 => 100755 utils/HtmlFonts.h mode change 100644 => 100755 utils/HtmlOutputDev.cc mode change 100644 => 100755 utils/HtmlOutputDev.h diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc old mode 100644 new mode 100755 index e4af947..de9130d --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -22,6 +22,7 @@ // Copyright (C) 2008 Tomas Are Haavet // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar Potdar (onkar@cdacmumbai.in) // Copyright (C) 2011 Joshua Richardson +// Copyright (C) 2011 Stephen Reichling // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -239,11 +240,11 @@ GooString* HtmlFont::HtmlFilter(Unicode* u, int uLen) { for (int i = 0; i < uLen; ++i) { switch (u[i]) { - case '"': tmp->append("""); break; + case '"': tmp->append("""); break; case '&': tmp->append("&"); break; case '<': tmp->append("<"); break; case '>': tmp->append(">"); break; - case ' ': tmp->append( !xml && ( i+1 >= uLen || !tmp->getLength() || tmp->getChar( tmp->getLength()-1 ) == ' ' ) ? " " : " " ); + case ' ': tmp->append( !xml && ( i+1 >= uLen || !tmp->getLength() || tmp->getChar( tmp->getLength()-1 ) == ' ' ) ? " " : " " ); break; default: { @@ -297,25 +298,17 @@ int HtmlFontAccu::AddFont(const HtmlFont& font){ } // get CSS font name for font #i -GooString* HtmlFontAccu::getCSStyle(int i, GooString* content, int j){ +GooString* HtmlFontAccu::getCSStyle(GooString* content){ GooString *tmp; - GooString *iStr=GooString::fromInt(i); - GooString *jStr=GooString::fromInt(j); if (!xml) { - tmp = new GooString("append(jStr); - tmp->append(iStr); - tmp->append("\">"); + tmp = new GooString(""); tmp->append(content); tmp->append(""); } else { tmp = new GooString(""); tmp->append(content); } - - delete jStr; - delete iStr; return tmp; } diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h old mode 100644 new mode 100755 index 607979c..032dbe8 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -110,7 +110,7 @@ public: HtmlFont *Get(int i){ return &(*accu)[i]; } - GooString* getCSStyle (int i,GooString* content, int j = 0); + GooString* getCSStyle (GooString* content); GooString* CSStyle(int i, int j = 0); int size() const {return accu->size();} diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc old mode 100644 new mode 100755 index 3c87a5c..4e7d59c --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -29,6 +29,7 @@ // Copyright (C) 2010 Hib Eris // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar Potdar (onkar@cdacmumbai.in) // Copyright (C) 2011 Joshua Richardson +// Copyright (C) 2011 Stephen Reichling // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -630,13 +631,13 @@ void HtmlPage::coalesce() { str1->size * sizeof(double)); if (addSpace) { str1->text[str1->len] = 0x20; - str1->htext->append(xml?" ":" "); + str1->htext->append(xml?" ":" "); str1->xRight[str1->len] = str2->xMin; ++str1->len; } if (addLineBreak) { str1->text[str1->len] = '\n'; - str1->htext->append("
"); + str1->htext->append("
"); str1->xRight[str1->len] = str2->xMin; ++str1->len; str1->yMin = str2->yMin; @@ -751,7 +752,7 @@ void HtmlPage::dumpAsXML(FILE* f,int page){ fprintf(f,"yMin),xoutRound(tmp->xMin)); fprintf(f,"width=\"%d\" height=\"%d\" ",xoutRound(tmp->xMax-tmp->xMin),xoutRound(tmp->yMax-tmp->yMin)); fprintf(f,"font=\"%d\">", tmp->fontpos); - str1=fonts->getCSStyle(tmp->fontpos, str); + str1=fonts->getCSStyle(str); fputs(str1->getCString(),f); delete str; delete str1; @@ -761,16 +762,11 @@ void HtmlPage::dumpAsXML(FILE* f,int page){ fputs("\n",f); } - -void HtmlPage::dumpComplex(FILE *file, int page){ - FILE* pageFile; +int HtmlPage::dumpComplexHeaders(FILE * const file, FILE *& pageFile, int page) { GooString* tmp; char* htmlEncoding; - if( firstPage == -1 ) firstPage = page; - - if( !noframes ) - { + if( !noframes ) { GooString* pgNum=GooString::fromInt(page); tmp = new GooString(DocName); if (!singleHtml){ @@ -784,36 +780,45 @@ void HtmlPage::dumpComplex(FILE *file, int page){ if (!pageFile) { error(-1, "Couldn't open html file '%s'", tmp->getCString()); delete tmp; - return; + return 1; } if (!singleHtml) - fprintf(pageFile,"%s\n\n\nPage %d\n\n", DOCTYPE, page); + fprintf(pageFile,"%s\n\n\nPage %d\n\n", + DOCTYPE, page); else - fprintf(pageFile,"%s\n\n\n%s\n\n", DOCTYPE, tmp->getCString()); + fprintf(pageFile,"%s\n\n\n%s\n\n", DOCTYPE, tmp->getCString()); delete tmp; htmlEncoding = HtmlOutputDev::mapEncodingToHtml (globalParams->getTextEncodingName()); if (!singleHtml) - fprintf(pageFile, "\n", htmlEncoding); + fprintf(pageFile, "\n", htmlEncoding); else - fprintf(pageFile, "\n
\n", htmlEncoding); - } - else - { + fprintf(pageFile, "\n
\n", + htmlEncoding); + } else { pageFile = file; fprintf(pageFile,"\n", page); fprintf(pageFile,"\n", page); } - fprintf(pageFile,"
\n", - pageWidth, pageHeight); + return 0; +} + +void HtmlPage::dumpComplex(FILE *file, int page){ + FILE* pageFile; + GooString* tmp; + + if( firstPage == -1 ) firstPage = page; + + if (dumpComplexHeaders(file, pageFile, page)) { error(-1, "Couldn't write headers."); return; } tmp=basename(DocName); fputs("