-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtypes.go
More file actions
276 lines (246 loc) · 5.94 KB
/
types.go
File metadata and controls
276 lines (246 loc) · 5.94 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
package rtfdoc
import "image/color"
// http://www.biblioscape.com/rtf15_spec.htm#Heading2
// documentItem composing interface
type documentItem interface {
compose() string
}
// cellItem cellizing interface
type cellItem interface {
inCell()
}
type generalSettings struct {
fontColor *FontTable
colorTable *ColorTable // Основные цветовые схемы. обращение в документе к ним с помощью управляющих слов \cfN, где N - порядковый номер цветовой схемы.
}
// Header - document header struct
type header struct {
version string // RTF Version, default: 1.5
charSet string // available options: ansi, mac, pc, pca
deff string
generalSettings
//FileTBL string
//StyleSheet string
//ListTables string
//RevTBL string
}
// Color type for settings
type colorItem struct {
rgbColor color.RGBA
name string
}
// Document - main document struct
type Document struct {
header
orientation string
margins
pageFormat string
pagesize size
maxWidth int
content []documentItem
}
// ColorTable defines color table
type ColorTable []colorItem
// font defines font struct
type font struct {
family string // nil, roman, swiss, modern, script, decor, tech, bidi
charset int // Specifies the character set of a font in the font table. Values for N are defined by Windows header files, and in the file RTFDEFS.H accompanying this document.
prq int // Specifies the pitch of a font in the font table.
name string
code string
}
// FontTable defines font table
type FontTable []font
// Size struct
type size struct {
width int
height int
}
// Table is a struct for Table.
type Table struct {
width int
align string
docWidth int
maxWidth int
data []*TableRow
margins
paddings
borders
generalSettings
defaultFontSize int
}
// TableCell defines cell properties
type TableCell struct {
cellWidth int
verticalMerged string
tableRowWidth int
maxWidth int
vTextAlign string
content []*Paragraph
borders
margins
paddings
generalSettings
backgroundColor string
}
type borders struct {
borderLeft bool
borderRight bool
borderTop bool
borderBottom bool
borderStyle string
borderWidth int
borderColor string
}
type margins struct {
marginLeft int
marginRight int
marginTop int
marginBottom int
}
type paddings struct {
paddingLeft int
paddingRight int
paddingTop int
paddingBottom int
}
// TableRow definces Table Row struct
type TableRow struct {
cells []*TableCell
tableWidth int
maxWidth int
borders
generalSettings
}
// Main Picture struct
type Picture struct {
format string // EMF, PNG, JPEG
paragraphWidth int
maxWidth int
src []byte
scaleX int
scaleY int
cropL int
cropR int
cropT int
cropB int
height int
width int
}
// ============End of Table structs===========
// Paragraph defines Paragraph instances
type Paragraph struct {
isTable bool
align string
indent string
indentFirstLine int
indentLeftIndent int
indentRightIndent int
content []documentItem
allowedWidth int
maxWidth int
generalSettings
}
// Text defines Text instances
type Text struct {
fontSize int
fontCode int //code for font in font Table
colorCode int
isBold bool
isItalic bool
isUnderlining bool
isScaps bool
isSuper bool
isSub bool
isStrike bool
emphasis string
content string
rotated bool
generalSettings
}
// Common paper orientation formats
const (
OrientationPortrait = "orientation_portrait"
OrientationLandscape = "orientation_landscape"
)
// Commont paper formats
const (
FormatLetter = "format_Letter"
FormatA5 = "format_A5"
FormatA4 = "format_A4"
FormatA3 = "format_A3"
FormatA2 = "format_A2"
)
// Aligning properties
const (
AlignCenter = "c"
AlignLeft = "l"
AlignRight = "r"
AlignJustify = "j"
AlignDistribute = "d"
VAlignTop = "t"
VAlignBottom = "b"
VAlignMiddle = "c"
VAlignJustify = "j"
)
// Common styles of border
const (
BorderSingleThickness = "s"
BorderDoubleThickness = "th"
BorderShadowed = "sh"
BorderDouble = "db"
BorderDotted = "dot"
BorderDashed = "dash"
BorderHairline = "hair"
BorderInset = "inset"
BorderDashSmall = "dashsm"
BorderDotDash = "dashd"
BorderDotDotDash = "dashdd"
BorderOutset = "outset"
BorderTriple = "triple"
BorderThickThinSmall = "tnthsg"
BorderThinThickSmall = "thtnsg"
BorderThickThinMedium = "tnthmg"
BorderThinThickMedium = "thtnmg"
BorderThinThickThinMedium = "tnthtnmg"
BorderThickThinLarge = "tnthlg"
BorderThinThickLarge = "thtnlg"
BorderThinThickThinLarge = "tnthtnlg"
BorderWavy = "wavy"
BorderWavyDouble = "wavydb"
BorderStripped = "dashdotstr"
BorderEmboss = "emboss"
BorderEngrave = "engrave"
)
// Common image formats
const (
ImageFormatJpeg = "jpeg"
ImageFormatPng = "png"
)
// List of common colors
const (
ColorBlack = "color_black"
ColorBlue = "color_blue"
ColorAqua = "color_aqua"
ColorLime = "color_lime"
ColorGreen = "color_green"
ColorMagenta = "color_magenta"
ColorRed = "color_red"
ColorYellow = "color_yellow"
ColorWhite = "color_white"
ColorNavy = "color_navy"
ColorTeal = "color_teal"
ColorPurple = "color_purple"
ColorMaroon = "color_maroon"
ColorOlive = "color_olive"
ColorGray = "color_gray"
ColorSilver = "color_silver"
)
// Common fonts
const (
FontTimesNewRoman = "font_times_new_roman"
FontSymbol = "font_symbol"
FontArial = "font_arial"
FontComicSansMS = "font_comic_sans_ms"
FontCourierNew = "font_courier_new"
)