2013-04-06 16:42:54 +00:00
|
|
|
/*
|
|
|
|
* HTMLTextPage.cc
|
|
|
|
*
|
|
|
|
* Generate and optimized HTML for one Page
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "HTMLTextPage.h"
|
|
|
|
|
|
|
|
namespace pdf2htmlEX {
|
|
|
|
|
|
|
|
using std::ostream;
|
2013-04-07 09:01:37 +00:00
|
|
|
using std::unique_ptr;
|
2013-04-06 16:42:54 +00:00
|
|
|
|
2013-04-07 08:10:52 +00:00
|
|
|
HTMLTextPage::HTMLTextPage(const Param & param, AllStateManager & all_manager)
|
2013-04-06 16:42:54 +00:00
|
|
|
: param(param)
|
|
|
|
, all_manager(all_manager)
|
2013-04-07 15:50:23 +00:00
|
|
|
, cur_line(nullptr)
|
2013-04-06 16:42:54 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
void HTMLTextPage::dump_text(ostream & out)
|
|
|
|
{
|
2013-04-07 09:14:51 +00:00
|
|
|
for(auto iter = text_lines.begin(); iter != text_lines.end(); ++iter)
|
|
|
|
(*iter)->prepare();
|
|
|
|
if(param.optimize_text)
|
|
|
|
optimize();
|
2013-04-06 16:42:54 +00:00
|
|
|
for(auto iter = text_lines.begin(); iter != text_lines.end(); ++iter)
|
|
|
|
(*iter)->dump_text(out);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HTMLTextPage::dump_css(ostream & out)
|
|
|
|
{
|
|
|
|
//TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void HTMLTextPage::clear(void)
|
|
|
|
{
|
|
|
|
text_lines.clear();
|
2013-04-07 15:50:23 +00:00
|
|
|
cur_line = nullptr;
|
2013-04-06 16:42:54 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 15:50:23 +00:00
|
|
|
void HTMLTextPage::open_new_line(const HTMLLineState & line_state)
|
2013-04-06 16:42:54 +00:00
|
|
|
{
|
2013-04-07 15:50:23 +00:00
|
|
|
if((!text_lines.empty()) && (text_lines.back()->text_empty()))
|
2013-04-06 16:42:54 +00:00
|
|
|
{
|
2013-04-07 15:50:23 +00:00
|
|
|
text_lines.pop_back();
|
2013-04-06 16:42:54 +00:00
|
|
|
}
|
2013-04-07 15:50:23 +00:00
|
|
|
text_lines.emplace_back(new HTMLTextLine(line_state, param, all_manager));
|
|
|
|
cur_line = text_lines.back().get();
|
2013-04-06 16:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HTMLTextPage::optimize(void)
|
|
|
|
{
|
|
|
|
//TODO
|
2013-04-07 09:11:49 +00:00
|
|
|
//group lines with same x-axis
|
|
|
|
//collect common states
|
2013-04-06 16:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace pdf2htmlEX
|