1 |
foucault |
27 |
//---------------------------------------------------------------------------
|
2 |
|
|
|
3 |
|
|
#include <sstream>
|
4 |
|
|
#include <fstream>
|
5 |
|
|
#include <map>
|
6 |
|
|
#include <vector>
|
7 |
|
|
#include <set>
|
8 |
|
|
#include <process.h>
|
9 |
|
|
|
10 |
|
|
#pragma hdrstop
|
11 |
|
|
|
12 |
|
|
#include <stdlib.h>
|
13 |
|
|
#include "CAD4FE_Common_platform.h"
|
14 |
|
|
|
15 |
|
|
#include "CAD4FE_HtmlText.h"
|
16 |
|
|
//---------------------------------------------------------------------------
|
17 |
|
|
#pragma package(smart_init)
|
18 |
|
|
|
19 |
|
|
using namespace CAD4FE;
|
20 |
|
|
|
21 |
|
|
HtmlText_Table::HtmlText_Table (std::vector <std::string> & __head)
|
22 |
|
|
{
|
23 |
|
|
_head = __head;
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
HtmlText_Table::HtmlText_Table (std::vector <std::string> & __head, std::vector < std::vector <std::string> > & __rows)
|
27 |
|
|
{
|
28 |
|
|
_head = __head;
|
29 |
|
|
_rows = __rows;
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
void HtmlText_Table::AddRow (std::vector <std::string> & __row)
|
33 |
|
|
{
|
34 |
|
|
_rows.push_back(__row);
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
std::string HtmlText_Table::GetHtml()
|
38 |
|
|
{
|
39 |
|
|
std::ostringstream out;
|
40 |
|
|
out << "<table border=\"2\" cellpadding=5 frame=\"vhsides\" rules=\"cols\">\n";
|
41 |
|
|
out << "<tr>";
|
42 |
|
|
for (unsigned i=0; i<_head.size(); i++)
|
43 |
|
|
out << "<th>" << _head[i] << "</th>";
|
44 |
|
|
out << "</tr>\n";
|
45 |
|
|
for (unsigned j=0; j<_rows.size(); j++)
|
46 |
|
|
{
|
47 |
|
|
std::vector <std::string> & row = _rows[j];
|
48 |
|
|
out << "<tr>";
|
49 |
|
|
for (unsigned i=0; i<row.size(); i++)
|
50 |
|
|
out << "<td>" << row[i] << "</td>";
|
51 |
|
|
out << "</tr>\n";
|
52 |
|
|
}
|
53 |
|
|
out << "</table>\n";
|
54 |
|
|
return out.str();
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
HtmlText_Page::HtmlText_Page()
|
58 |
|
|
{
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
void HtmlText_Page::Add(std::string __html)
|
62 |
|
|
{
|
63 |
|
|
_html += __html;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
void HtmlText_Page::operator << (const std::ostringstream & __os)
|
67 |
|
|
{
|
68 |
|
|
_html += __os.str();
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
void HtmlText_Page::Close()
|
72 |
|
|
{
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
std::string HtmlText_Page::GetHtml()
|
76 |
|
|
{
|
77 |
|
|
return _html;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
void HtmlText_Page::Show(std::string __filename)
|
82 |
|
|
{
|
83 |
|
|
WriteFile(__filename);
|
84 |
|
|
//ēchar htmlViewer[] = "c:\\Program Files\\Mozilla Firefox\\firefox.exe";
|
85 |
|
|
char htmlViewer[] = "c:\\Program Files\\Internet Explorer\\iexplore.exe";
|
86 |
|
|
spawnl (P_NOWAIT, htmlViewer, htmlViewer, __filename.c_str(), 0);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
void HtmlText_Page::WriteFile(std::string __filename)
|
90 |
|
|
{
|
91 |
|
|
std::ofstream file;
|
92 |
|
|
file.open(__filename.c_str());
|
93 |
|
|
file << _html;
|
94 |
|
|
file.close();
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
void HtmlText_Page::Clear()
|
99 |
|
|
{
|
100 |
|
|
_html.clear();
|
101 |
|
|
}
|
102 |
|
|
|