ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/CAD4FE/src/CAD4FE_HtmlText.cpp
Revision: 176
Committed: Tue May 19 20:56:11 2009 UTC (15 years, 11 months ago) by foucault
Original Path: magic/lib/CAD4FE/CAD4FE/src/CAD4FE_HtmlText.cpp
File size: 2415 byte(s)
Log Message:
Mise à jour :
* CAD4FE
* outil : HypergraphLib qui est maintenant compilable sous Linux (essais mois aout 2008)
* outil : ot_mathematique.cpp suppression d'une méthode de classe inutile nécessaire pour compiler avec CodeGear Builder 2006 OT_VECTEUR_3D::OT_VECTEUR_3D(OT_VECTEUR_3D& mdd)

File Contents

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