mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
buildable with gcc 4.4.6
This commit is contained in:
parent
3de65a5156
commit
16de2e5f5e
@ -52,6 +52,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wunused-function")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused-function")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
static const void * nullptr = NULL;
|
||||
#ifndef nullptr
|
||||
#define nullptr (NULL)
|
||||
#endif
|
||||
|
||||
static const double EPS = 1e-6;
|
||||
extern const double id_matrix[6];
|
||||
|
@ -22,8 +22,8 @@ FontPreprocessor::FontPreprocessor(void)
|
||||
|
||||
FontPreprocessor::~FontPreprocessor(void)
|
||||
{
|
||||
for(auto & p : code_maps)
|
||||
delete [] p.second;
|
||||
for(auto iter = code_maps.begin(); iter != code_maps.end(); ++iter)
|
||||
delete [] iter->second;
|
||||
}
|
||||
|
||||
void FontPreprocessor::drawChar(GfxState *state, double x, double y,
|
||||
@ -39,7 +39,7 @@ void FontPreprocessor::drawChar(GfxState *state, double x, double y,
|
||||
if(fn_id != cur_font_id)
|
||||
{
|
||||
cur_font_id = fn_id;
|
||||
auto p = code_maps.insert(std::make_pair(cur_font_id, nullptr));
|
||||
auto p = code_maps.insert(std::make_pair(cur_font_id, (char*)nullptr));
|
||||
if(p.second)
|
||||
{
|
||||
// this is a new font
|
||||
|
@ -194,11 +194,11 @@ class HTMLRenderer : public OutputDev
|
||||
// states
|
||||
////////////////////////////////////////////////////
|
||||
bool line_opened;
|
||||
enum class NewLineState
|
||||
enum NewLineState
|
||||
{
|
||||
NONE, // stay with the same style
|
||||
SPAN, // open a new <span> if possible, otherwise a new <div>
|
||||
DIV // has to open a new <div>
|
||||
NLS_NONE, // stay with the same style
|
||||
NLS_SPAN, // open a new <span> if possible, otherwise a new <div>
|
||||
NLS_DIV // has to open a new <div>
|
||||
} new_line_state;
|
||||
|
||||
// The order is according to the appearance in check_state_change
|
||||
|
@ -33,7 +33,7 @@ void HTMLRenderer::LineBuffer::append_offset(double width)
|
||||
if((!offsets.empty()) && (offsets.back().start_idx == text.size()))
|
||||
offsets.back().width += width;
|
||||
else
|
||||
offsets.push_back({text.size(), width});
|
||||
offsets.push_back(Offset({text.size(), width}));
|
||||
}
|
||||
|
||||
void HTMLRenderer::LineBuffer::append_state(void)
|
||||
@ -61,17 +61,20 @@ void HTMLRenderer::LineBuffer::flush(void)
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto & s : states)
|
||||
s.hash();
|
||||
for(auto iter = states.begin(); iter != states.end(); ++iter)
|
||||
iter->hash();
|
||||
|
||||
states.resize(states.size() + 1);
|
||||
states.back().start_idx = text.size();
|
||||
|
||||
offsets.push_back({text.size(), 0});
|
||||
offsets.push_back(Offset({text.size(), 0}));
|
||||
|
||||
double max_ascent = 0;
|
||||
for(const State & s : states)
|
||||
for(auto iter = states.begin(); iter != states.end(); ++iter)
|
||||
{
|
||||
const auto & s = *iter;
|
||||
max_ascent = max(max_ascent, s.ascent * s.draw_font_size);
|
||||
}
|
||||
|
||||
// TODO: class for height ?
|
||||
ostream & out = renderer->html_fout;
|
||||
|
@ -83,8 +83,10 @@ void HTMLRenderer::export_transform_matrix (long long tm_id, const double * tm)
|
||||
// we have already shifted the origin
|
||||
|
||||
// TODO: recognize common matices
|
||||
for(const string & prefix : {"", "-ms-", "-moz-", "-webkit-", "-o-"})
|
||||
auto prefixes = {"", "-ms-", "-moz-", "-webkit-", "-o-"};
|
||||
for(auto iter = prefixes.begin(); iter != prefixes.end(); ++iter)
|
||||
{
|
||||
const auto & prefix = *iter;
|
||||
// PDF use a different coordinate system from Web
|
||||
allcss_fout << prefix << "transform:matrix("
|
||||
<< tm[0] << ','
|
||||
|
@ -252,10 +252,11 @@ void HTMLRenderer::clean_tmp_files()
|
||||
if(!param->clean_tmp)
|
||||
return;
|
||||
|
||||
for(const auto & fn : tmp_files)
|
||||
for(auto iter = tmp_files.begin(); iter != tmp_files.end(); ++iter)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto fn = *iter;
|
||||
remove(tmp_dir / fn);
|
||||
if(param->debug)
|
||||
cerr << "Remove temporary file: " << fn << endl;
|
||||
|
@ -75,7 +75,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
// DEPENDENCY WARNING
|
||||
// don't adjust the order of state checking
|
||||
|
||||
new_line_state = NewLineState::NONE;
|
||||
new_line_state = NLS_NONE;
|
||||
|
||||
bool need_recheck_position = false;
|
||||
bool need_rescale_font = false;
|
||||
@ -95,7 +95,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
|
||||
if(!(new_font_info->id == cur_font_info->id))
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::SPAN);
|
||||
new_line_state = max(new_line_state, NLS_SPAN);
|
||||
cur_font_info = new_font_info;
|
||||
}
|
||||
|
||||
@ -165,13 +165,13 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
|
||||
if(!(_equal(new_draw_font_size, draw_font_size)))
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::SPAN);
|
||||
new_line_state = max(new_line_state, NLS_SPAN);
|
||||
draw_font_size = new_draw_font_size;
|
||||
cur_fs_id = install_font_size(draw_font_size);
|
||||
}
|
||||
if(!(_tm_equal(new_draw_ctm, draw_ctm, 4)))
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::DIV);
|
||||
new_line_state = max(new_line_state, NLS_DIV);
|
||||
memcpy(draw_ctm, new_draw_ctm, sizeof(draw_ctm));
|
||||
cur_tm_id = install_transform_matrix(draw_ctm);
|
||||
}
|
||||
@ -233,7 +233,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
|
||||
if(!merged)
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::DIV);
|
||||
new_line_state = max(new_line_state, NLS_DIV);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
double new_letter_space = state->getCharSpace();
|
||||
if(!_equal(cur_letter_space, new_letter_space))
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::SPAN);
|
||||
new_line_state = max(new_line_state, NLS_SPAN);
|
||||
cur_letter_space = new_letter_space;
|
||||
cur_ls_id = install_letter_space(cur_letter_space * draw_scale);
|
||||
}
|
||||
@ -257,7 +257,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
double new_word_space = state->getWordSpace();
|
||||
if(!_equal(cur_word_space, new_word_space))
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::SPAN);
|
||||
new_line_state = max(new_line_state, NLS_SPAN);
|
||||
cur_word_space = new_word_space;
|
||||
cur_ws_id = install_word_space(cur_word_space * draw_scale);
|
||||
}
|
||||
@ -270,7 +270,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
state->getFillRGB(&new_color);
|
||||
if(!((new_color.r == cur_color.r) && (new_color.g == cur_color.g) && (new_color.b == cur_color.b)))
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::SPAN);
|
||||
new_line_state = max(new_line_state, NLS_SPAN);
|
||||
cur_color = new_color;
|
||||
cur_color_id = install_color(&new_color);
|
||||
}
|
||||
@ -283,7 +283,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||
double new_rise = state->getRise();
|
||||
if(!_equal(cur_rise, new_rise))
|
||||
{
|
||||
new_line_state = max(new_line_state, NewLineState::SPAN);
|
||||
new_line_state = max(new_line_state, NLS_SPAN);
|
||||
cur_rise = new_rise;
|
||||
cur_rise_id = install_rise(new_rise * draw_scale);
|
||||
}
|
||||
@ -313,10 +313,10 @@ void HTMLRenderer::prepare_line(GfxState * state)
|
||||
{
|
||||
if(!line_opened)
|
||||
{
|
||||
new_line_state = NewLineState::DIV;
|
||||
new_line_state = NLS_DIV;
|
||||
}
|
||||
|
||||
if(new_line_state == NewLineState::DIV)
|
||||
if(new_line_state == NLS_DIV)
|
||||
{
|
||||
close_line();
|
||||
|
||||
@ -342,7 +342,7 @@ void HTMLRenderer::prepare_line(GfxState * state)
|
||||
}
|
||||
}
|
||||
|
||||
if(new_line_state != NewLineState::NONE)
|
||||
if(new_line_state != NLS_NONE)
|
||||
{
|
||||
line_buf.append_state();
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ path HTMLRenderer::dump_embedded_font (GfxFont * font, long long fn_id)
|
||||
void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo & info, bool get_metric_only)
|
||||
{
|
||||
string suffix = filepath.extension().string();
|
||||
for(auto & c : suffix)
|
||||
c = tolower(c);
|
||||
for(auto iter = suffix.begin(); iter != suffix.end(); ++iter)
|
||||
*iter = tolower(*iter);
|
||||
|
||||
ff_load_font(filepath.c_str());
|
||||
|
||||
|
@ -125,8 +125,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
//prepare the directories
|
||||
for(const auto & p : {param.dest_dir, param.tmp_dir})
|
||||
auto user_dirs = {param.dest_dir, param.tmp_dir};
|
||||
for(auto iter = user_dirs.begin(); iter != user_dirs.end(); ++iter)
|
||||
{
|
||||
const auto & p = *iter;
|
||||
if(equivalent(PDF2HTMLEX_DATA_PATH, p))
|
||||
{
|
||||
cerr << "The specified directory \"" << p << "\" is the library path for pdf2htmlEX. Please use another one." << endl;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <vector>
|
||||
|
||||
#include <GfxState.h>
|
||||
#include <GfxFont.h>
|
||||
@ -215,6 +216,8 @@ public:
|
||||
double _[6];
|
||||
};
|
||||
|
||||
// may move inside base64stream when we have to create a util.c
|
||||
static const char * base64_encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
class base64stream
|
||||
{
|
||||
public:
|
||||
@ -256,7 +259,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static const char * base64_encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
istream * in;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user