[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1d99e76 008/156: Make pdf_writer_wx::output_h
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1d99e76 008/156: Make pdf_writer_wx::output_html() type safe by taking html::text |
Date: |
Tue, 30 Jan 2018 17:21:50 -0500 (EST) |
branch: master
commit 1d99e761fe208c0382515c99eb98e41616b6488a
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Make pdf_writer_wx::output_html() type safe by taking html::text
Accept html::text which is guaranteed to be correctly escaped, by
construction, rather than arbitrary strings.
---
group_quote_pdf_gen_wx.cpp | 6 +++---
pdf_writer_wx.cpp | 6 ++++--
pdf_writer_wx.hpp | 4 +++-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index 66ba8f1..42b659c 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -945,7 +945,7 @@ void group_quote_pdf_generator_wx::output_document_header
(pdf_writer.get_horz_margin()
,*pos_y
,pdf_writer.get_page_width() / 2
- ,title_html.as_html()
+ ,title_html
);
// Build the summary table with all the mandatory fields, starting by
@@ -1020,7 +1020,7 @@ void group_quote_pdf_generator_wx::output_document_header
(pdf_writer.get_horz_margin() + pdf_writer.get_page_width() / 2
,*pos_y
,pdf_writer.get_page_width() / 2
- ,summary_html.as_html()
+ ,summary_html
);
// wxHTML tables don't support "frame" attribute, so draw the border around
@@ -1201,7 +1201,7 @@ void group_quote_pdf_generator_wx::output_footer
(pdf_writer.get_horz_margin()
,*pos_y
,pdf_writer.get_page_width()
- ,footer_html.as_html()
+ ,footer_html
,output_mode
);
}
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index 72d8105..1190a4d 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -24,6 +24,7 @@
#include "pdf_writer_wx.hpp"
#include "alert.hpp"
+#include "html.hpp"
#include <wx/html/htmlcell.h>
@@ -140,12 +141,13 @@ int pdf_writer_wx::output_html
(int x
,int y
,int width
- ,wxString const& html
+ ,html::text const& html
,enum_output_mode output_mode
)
{
+ auto const html_str = wxString::FromUTF8(html.as_html());
std::unique_ptr<wxHtmlContainerCell> const cell
- (static_cast<wxHtmlContainerCell*>(html_parser_.Parse(html))
+ (static_cast<wxHtmlContainerCell*>(html_parser_.Parse(html_str))
);
LMI_ASSERT(cell);
diff --git a/pdf_writer_wx.hpp b/pdf_writer_wx.hpp
index fff8a53..21fccb0 100644
--- a/pdf_writer_wx.hpp
+++ b/pdf_writer_wx.hpp
@@ -32,6 +32,8 @@
#include <memory> // std::unique_ptr
+namespace html { class text; }
+
enum enum_output_mode
{e_output_normal
,e_output_measure_only
@@ -55,7 +57,7 @@ class pdf_writer_wx
(int x
,int y
,int width
- ,wxString const& html
+ ,html::text const& html
,enum_output_mode output_mode = e_output_normal
);
- [lmi-commits] [lmi] master updated (70fb246 -> 408ba18), Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master cfdf224 016/156: Use raw multiline string instead of concatenating several strings, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1d99e76 008/156: Make pdf_writer_wx::output_html() type safe by taking html::text,
Greg Chicares <=
- [lmi-commits] [lmi] master e43a485 005/156: Further improve wxPdfDocument API encapsulation and reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7d278ef 011/156: Add footer to the cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d5d8185 057/156: Add tabular_details page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master bb64784 013/156: Add a helper allowing to interpolate variables in strings, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b72ced6 014/156: Replace ad hoc illustration properties with HTML interpolator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e7d763d 066/156: Add company logo display to the PDF illustration header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f575c94 003/156: Refactor more group_quote_pdf_gen_wx code to allow its reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5e2fc70 007/156: Make HTML generation utilities more type-safe, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7ed2bbf 027/156: Simplify footer generation code by moving font tag outside, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d7244c1 043/156: Change the colour used for lines and borders, Greg Chicares, 2018/01/30