1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-06-28 23:09:01 +00:00

clean code

This commit is contained in:
Lu Wang 2012-08-21 20:37:25 +02:00
parent c9aec8d3b6
commit db3a54159e
2 changed files with 10 additions and 103 deletions

View File

@ -151,27 +151,27 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state)
cur_rise = 0;
cur_fn_id = cur_fs_id = 0;
cur_font_size = 0;
draw_scale = 1.0;
cur_fn_id = install_font(nullptr);
cur_font_size = draw_font_size = 0;
cur_fs_id = install_font_size(cur_font_size);
cur_tm_id = 0;
memcpy(cur_ctm, id_matrix, sizeof(cur_ctm));
memcpy(draw_ctm, id_matrix, sizeof(draw_ctm));
cur_tm_id = install_transform_matrix(draw_ctm);
cur_ls_id = cur_ws_id = 0;
cur_letter_space = cur_word_space = 0;
cur_ls_id = install_letter_space(cur_letter_space);
cur_ws_id = install_word_space(cur_word_space);
cur_color_id = 0;
cur_color.r = cur_color.g = cur_color.b = 0;
cur_color_id = install_color(&cur_color);
cur_tx = cur_ty = 0;
memcpy(draw_ctm, id_matrix, sizeof(draw_ctm));
draw_font_size = 0;
draw_scale = 1.0;
draw_tx = draw_ty = 0;
reset_state_change();
all_changed = true;
}

View File

@ -23,8 +23,6 @@
#include <PDFDoc.h>
#include <PDFDocFactory.h>
#include <GlobalParams.h>
#include <Error.h>
#include <DateInfo.h>
#include "HTMLRenderer.h"
#include "Param.h"
@ -41,9 +39,6 @@ PDFDoc *doc = nullptr;
GooString *fileName = nullptr;
GooString *ownerPW, *userPW;
GooString *docTitle = nullptr;
GooString *author = nullptr, *keywords = nullptr, *subject = nullptr, *date = nullptr;
HTMLRenderer *htmlOut = nullptr;
int finished = -1;
@ -51,56 +46,6 @@ int finished = -1;
po::options_description opt_visible("Options"), opt_hidden, opt_all;
po::positional_options_description opt_positional;
//====================helper functions=========================================
/*
static GooString* getInfoString(Dict *infoDict, char *key) {
Object obj;
GooString *s1 = nullptr;
if (infoDict->lookup(key, &obj)->isString()) {
s1 = new GooString(obj.getString());
}
obj.free();
return s1;
}
static GooString* getInfoDate(Dict *infoDict, char *key) {
Object obj;
char *s;
int year, mon, day, hour, min, sec, tz_hour, tz_minute;
char tz;
struct tm tmStruct;
GooString *result = nullptr;
char buf[256];
if (infoDict->lookup(key, &obj)->isString()) {
s = obj.getString()->getCString();
// TODO do something with the timezone info
if ( parseDateString( s, &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute ) ) {
tmStruct.tm_year = year - 1900;
tmStruct.tm_mon = mon - 1;
tmStruct.tm_mday = day;
tmStruct.tm_hour = hour;
tmStruct.tm_min = min;
tmStruct.tm_sec = sec;
tmStruct.tm_wday = -1;
tmStruct.tm_yday = -1;
tmStruct.tm_isdst = -1;
mktime(&tmStruct); // compute the tm_wday and tm_yday fields
if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S+00:00", &tmStruct)) {
result = new GooString(buf);
} else {
result = new GooString(s);
}
} else {
result = new GooString(s);
}
}
obj.free();
return result;
}
*/
void show_usage(void)
{
cerr << "pdftohtmlEX version " << PDF2HTMLEX_VERSION << endl;
@ -158,8 +103,6 @@ po::variables_map parse_options (int argc, char **argv)
}
}
//====================entry point==============================================
int main(int argc, char **argv)
{
auto opt_map = parse_options(argc, argv);
@ -216,22 +159,6 @@ int main(int argc, char **argv)
param.first_page = min(max(param.first_page, 1), doc->getNumPages());
param.last_page = min(max(param.last_page, param.first_page), doc->getNumPages());
/*
// get meta info
doc->getDocInfo(&info);
if (info.isDict()) {
docTitle = getInfoString(info.getDict(), "Title");
author = getInfoString(info.getDict(), "Author");
keywords = getInfoString(info.getDict(), "Keywords");
subject = getInfoString(info.getDict(), "Subject");
date = getInfoDate(info.getDict(), "ModDate");
if( !date )
date = getInfoDate(info.getDict(), "CreationDate");
}
info.free();
if( !docTitle ) docTitle = fileName->copy();
*/
if(param.output_filename == "")
{
const string s = path(param.input_filename).filename().string();
@ -247,27 +174,7 @@ int main(int argc, char **argv)
htmlOut = new HTMLRenderer(&param);
htmlOut->process(doc);
{
/*
escapeHTMLString(docTitle);
if(author) escapeHTMLString(author);
if(date) escapeHTMLString(date);
printf("{\"doc_id\": \"\", \"title\":\"%s\", \"author\":\"%s\",\"mod_date\":\"%s\",\n",
docTitle->getCString(),
author? author->getCString():"",
date? date->getCString():"");
printf("\"pages\":[\n");
*/
}
delete htmlOut;
delete docTitle;
if( author ) delete author;
if( keywords ) delete keywords;
if( subject ) delete subject;
if( date ) delete date;
finished = 0;