forked from pangwa/rtfcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RtfCpp.h
81 lines (71 loc) · 4.62 KB
/
RtfCpp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
/*
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "rtfdefs.h"
#include <string>
class RtfWriter
{
public:
RtfWriter(const std::wstring& filename);
~RtfWriter();
bool open(char* fonts, char* colors);
bool write_header(); // Writes RTF document header
void init(); // Sets global RTF library params
void set_fonttable(char* fonts); // Sets new RTF document font table
void set_colortable(char* colors); // Sets new RTF document color table
RTF_DOCUMENT_FORMAT* get_documentformat(); // Gets RTF document formatting properties
void set_documentformat(RTF_DOCUMENT_FORMAT* df); // Sets RTF document formatting properties
bool write_documentformat(); // Writes RTF document formatting properties
RTF_SECTION_FORMAT* get_sectionformat(); // Gets RTF section formatting properties
void set_sectionformat(RTF_SECTION_FORMAT* sf); // Sets RTF section formatting properties
bool write_sectionformat(); // Writes RTF section formatting properties
int start_section(); // Starts new RTF section
RTF_PARAGRAPH_FORMAT* get_paragraphformat(); // Gets RTF paragraph formatting properties
void set_paragraphformat(RTF_PARAGRAPH_FORMAT* pf); // Sets RTF paragraph formatting properties
bool write_paragraphformat(); // Writes RTF paragraph formatting properties
int start_paragraph(const char* text, bool newPar); // Starts new RTF paragraph
int load_image(char* image, int width, int height); // Loads image from file
char* bin_hex_convert(unsigned char* binary, int size); // Converts binary data to hex
void set_defaultformat(); // Sets default RTF document formatting
int start_tablerow(); // Starts new RTF table row
int end_tablerow(); // Ends RTF table row
int start_tablecell(int rightMargin); // Starts new RTF table cell
int end_tablecell(); // Ends RTF table cell
RTF_TABLEROW_FORMAT* get_tablerowformat(); // Gets RTF table row formatting properties
void set_tablerowformat(RTF_TABLEROW_FORMAT* rf); // Sets RTF table row formatting properties
RTF_TABLECELL_FORMAT* get_tablecellformat(); // Gets RTF table cell formatting properties
void set_tablecellformat(RTF_TABLECELL_FORMAT* cf); // Sets RTF table cell formatting properties
char* get_bordername(int border_type); // Gets border name
char* get_shadingname(int shading_type, bool cell); // Gets shading name
//
// helper method to convert unicode string to ansi string
static std::string encodeWString(const std::wstring& str);
private:
std::wstring _filename;
RTF_DOCUMENT_FORMAT _rtfDocFormat; // RTF document formatting params
RTF_SECTION_FORMAT _rtfSecFormat; // RTF section formatting params
RTF_PARAGRAPH_FORMAT _rtfParFormat; // RTF paragraph formatting params
RTF_TABLEROW_FORMAT _rtfRowFormat; // RTF table row formatting params
RTF_TABLECELL_FORMAT _rtfCellFormat; // RTF table cell formatting params
std::string _rtfFontTable;
std::string _rtfColorTable;
// RTF library global params
FILE* _rtfFile;
//IPicture* _rtfPicture;
};