diff options
author | Ihar Filipau <thephilips@gmail.com> | 2012-03-16 00:07:45 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2012-03-16 00:07:45 +0100 |
commit | 4a9238441a5317c3304296e4e6430cccefe8322c (patch) | |
tree | 25bc77b6879c52f4c5ad3fe92d28e9c62a588081 /utils | |
parent | 6d68d0d3acc8c8e0d9d310b2e1ba2b07d6bfe942 (diff) |
Flip images if they need to
Bug 32340
Diffstat (limited to 'utils')
-rw-r--r-- | utils/HtmlOutputDev.cc | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index 82464df2..3d8836be 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -777,6 +777,42 @@ void HtmlPage::dumpAsXML(FILE* f,int page){ fputs("</page>\n",f); } +static void printCSS(FILE *f) +{ + // Image flip/flop CSS + // Source: + // http://stackoverflow.com/questions/1309055/cross-browser-way-to-flip-html-image-via-javascript-css + // tested in Chrome, Fx (Linux) and IE9 (W7) + static const char css[] = + "<STYLE type=\"text/css\">" "\n" + "<!--" "\n" + ".xflip {" "\n" + " -moz-transform: scaleX(-1);" "\n" + " -webkit-transform: scaleX(-1);" "\n" + " -o-transform: scaleX(-1);" "\n" + " transform: scaleX(-1);" "\n" + " filter: fliph;" "\n" + "}" "\n" + ".yflip {" "\n" + " -moz-transform: scaleY(-1);" "\n" + " -webkit-transform: scaleY(-1);" "\n" + " -o-transform: scaleY(-1);" "\n" + " transform: scaleY(-1);" "\n" + " filter: flipv;" "\n" + "}" "\n" + ".xyflip {" "\n" + " -moz-transform: scaleX(-1) scaleY(-1);" "\n" + " -webkit-transform: scaleX(-1) scaleY(-1);" "\n" + " -o-transform: scaleX(-1) scaleY(-1);" "\n" + " transform: scaleX(-1) scaleY(-1);" "\n" + " filter: fliph + flipv;" "\n" + "}" "\n" + "-->" "\n" + "</STYLE>" "\n"; + + fwrite( css, sizeof(css)-1, 1, f ); +} + int HtmlPage::dumpComplexHeaders(FILE * const file, FILE *& pageFile, int page) { GooString* tmp; @@ -905,7 +941,14 @@ void HtmlPage::dump(FILE *f, int pageNum) int listlen=imgList->getLength(); for (int i = 0; i < listlen; i++) { HtmlImage *img = (HtmlImage*)imgList->del(0); - fprintf(f,"<IMG src=\"%s\"/><br/>\n",img->fName->getCString()); + + // see printCSS() for class names + const char *styles[4] = { "", " class=\"xflip\"", " class=\"yflip\"", " class=\"xyflip\"" }; + int style_index=0; + if (img->xMin > img->xMax) style_index += 1; // xFlip + if (img->yMin > img->yMax) style_index += 2; // yFlip + + fprintf(f,"<IMG%s src=\"%s\"/><br/>\n",styles[style_index],img->fName->getCString()); delete img; } @@ -1124,7 +1167,9 @@ HtmlOutputDev::HtmlOutputDev(Catalog *catalogA, char *fileName, char *title, } delete right; fputs(DOCTYPE, page); - fputs("<HTML>\n<HEAD>\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n",page); + fputs("<HTML>\n<HEAD>\n<TITLE></TITLE>\n",page); + printCSS(page); + fputs("</HEAD>\n<BODY>\n",page); } } @@ -1156,6 +1201,7 @@ HtmlOutputDev::HtmlOutputDev(Catalog *catalogA, char *fileName, char *title, fprintf(page, "<META http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->getCString()); dumpMetaVars(page); + printCSS(page); fprintf(page,"</HEAD>\n"); fprintf(page,"<BODY bgcolor=\"#A0A0A0\" vlink=\"blue\" link=\"blue\">\n"); } |