Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cfx_barcode.cpp
Go to the documentation of this file.
1
// Copyright 2014 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"fxbarcode/cfx_barcode.h"
8
9
#
include
<
memory
>
10
11
#
include
"core/fxcrt/notreached.h"
12
#
include
"core/fxcrt/ptr_util.h"
13
#
include
"fxbarcode/cbc_codabar.h"
14
#
include
"fxbarcode/cbc_code128.h"
15
#
include
"fxbarcode/cbc_code39.h"
16
#
include
"fxbarcode/cbc_codebase.h"
17
#
include
"fxbarcode/cbc_datamatrix.h"
18
#
include
"fxbarcode/cbc_ean13.h"
19
#
include
"fxbarcode/cbc_ean8.h"
20
#
include
"fxbarcode/cbc_pdf417i.h"
21
#
include
"fxbarcode/cbc_qrcode.h"
22
#
include
"fxbarcode/cbc_upca.h"
23
24
namespace
{
25
26
std::unique_ptr<CBC_CodeBase> CreateBarCodeEngineObject(
BC_TYPE
type) {
27
switch
(type) {
28
case
BC_TYPE
::
kCode39
:
29
return
std
::make_unique<CBC_Code39>();
30
case
BC_TYPE
::
kCodabar
:
31
return
std
::make_unique<CBC_Codabar>();
32
case
BC_TYPE
::
kCode128
:
33
return
std
::make_unique<CBC_Code128>(
BC_TYPE
::
kCode128B
);
34
case
BC_TYPE
::
kCode128B
:
35
return
std
::make_unique<CBC_Code128>(
BC_TYPE
::
kCode128B
);
36
case
BC_TYPE
::
kCode128C
:
37
return
std
::make_unique<CBC_Code128>(
BC_TYPE
::
kCode128C
);
38
case
BC_TYPE
::
kEAN8
:
39
return
std
::make_unique<CBC_EAN8>();
40
case
BC_TYPE
::
kUPCA
:
41
return
std
::make_unique<CBC_UPCA>();
42
case
BC_TYPE
::
kEAN13
:
43
return
std
::make_unique<CBC_EAN13>();
44
case
BC_TYPE
::
kQRCode
:
45
return
std
::make_unique<CBC_QRCode>();
46
case
BC_TYPE
::
kPDF417
:
47
return
std
::make_unique<CBC_PDF417I>();
48
case
BC_TYPE
::
kDataMatrix
:
49
return
std
::make_unique<CBC_DataMatrix>();
50
case
BC_TYPE
::
kUnknown
:
51
return
nullptr
;
52
}
53
NOTREACHED_NORETURN
();
54
}
55
56
}
// namespace
57
58
CFX_Barcode
::CFX_Barcode() =
default
;
59
60
CFX_Barcode
::~
CFX_Barcode
() =
default
;
61
62
std::unique_ptr<CFX_Barcode>
CFX_Barcode
::Create(
BC_TYPE
type) {
63
auto
barcode =
pdfium
::WrapUnique(
new
CFX_Barcode
());
// Private ctor.
64
barcode->m_pBCEngine = CreateBarCodeEngineObject(type);
65
return
barcode;
66
}
67
68
BC_TYPE
CFX_Barcode
::
GetType
() {
69
return
m_pBCEngine ? m_pBCEngine->GetType() : BC_TYPE::kUnknown;
70
}
71
72
bool
CFX_Barcode
::
SetModuleHeight
(int32_t moduleHeight) {
73
return
m_pBCEngine && m_pBCEngine->SetModuleHeight(moduleHeight);
74
}
75
76
bool
CFX_Barcode
::
SetModuleWidth
(int32_t moduleWidth) {
77
return
m_pBCEngine && m_pBCEngine->SetModuleWidth(moduleWidth);
78
}
79
80
void
CFX_Barcode
::
SetHeight
(int32_t height) {
81
if
(m_pBCEngine)
82
m_pBCEngine->SetHeight(height);
83
}
84
85
void
CFX_Barcode
::
SetWidth
(int32_t width) {
86
if
(m_pBCEngine)
87
m_pBCEngine->SetWidth(width);
88
}
89
90
bool
CFX_Barcode
::
SetPrintChecksum
(
bool
checksum) {
91
if
(!m_pBCEngine)
92
return
false
;
93
94
switch
(
GetType
(
)
) {
95
case
BC_TYPE::kCode39:
96
case
BC_TYPE::kCodabar:
97
case
BC_TYPE::kCode128:
98
case
BC_TYPE::kCode128B:
99
case
BC_TYPE::kCode128C:
100
case
BC_TYPE::kEAN8:
101
case
BC_TYPE::kEAN13:
102
case
BC_TYPE::kUPCA:
103
static_cast
<CBC_OneCode*>(m_pBCEngine.get())->SetPrintChecksum(checksum);
104
return
true
;
105
default
:
106
return
false
;
107
}
108
}
109
110
bool
CFX_Barcode
::
SetDataLength
(int32_t length) {
111
if
(!m_pBCEngine)
112
return
false
;
113
114
switch
(
GetType
(
)
) {
115
case
BC_TYPE::kCode39:
116
case
BC_TYPE::kCodabar:
117
case
BC_TYPE::kCode128:
118
case
BC_TYPE::kCode128B:
119
case
BC_TYPE::kCode128C:
120
case
BC_TYPE::kEAN8:
121
case
BC_TYPE::kEAN13:
122
case
BC_TYPE::kUPCA:
123
static_cast
<CBC_OneCode*>(m_pBCEngine.get())->SetDataLength(length);
124
return
true
;
125
default
:
126
return
false
;
127
}
128
}
129
130
bool
CFX_Barcode
::
SetCalChecksum
(
bool
state) {
131
if
(!m_pBCEngine)
132
return
false
;
133
134
switch
(
GetType
(
)
) {
135
case
BC_TYPE::kCode39:
136
case
BC_TYPE::kCodabar:
137
case
BC_TYPE::kCode128:
138
case
BC_TYPE::kCode128B:
139
case
BC_TYPE::kCode128C:
140
case
BC_TYPE::kEAN8:
141
case
BC_TYPE::kEAN13:
142
case
BC_TYPE::kUPCA:
143
static_cast
<CBC_OneCode*>(m_pBCEngine.get())->SetCalChecksum(state);
144
return
true
;
145
default
:
146
return
false
;
147
}
148
}
149
150
bool
CFX_Barcode
::
SetFont
(
CFX_Font
* pFont) {
151
if
(!m_pBCEngine)
152
return
false
;
153
154
switch
(
GetType
(
)
) {
155
case
BC_TYPE::kCode39:
156
case
BC_TYPE::kCodabar:
157
case
BC_TYPE::kCode128:
158
case
BC_TYPE::kCode128B:
159
case
BC_TYPE::kCode128C:
160
case
BC_TYPE::kEAN8:
161
case
BC_TYPE::kEAN13:
162
case
BC_TYPE::kUPCA:
163
return
static_cast
<CBC_OneCode*>(m_pBCEngine.get())->SetFont(pFont);
164
default
:
165
return
false
;
166
}
167
}
168
169
bool
CFX_Barcode
::
SetFontSize
(
float
size) {
170
if
(!m_pBCEngine)
171
return
false
;
172
173
switch
(
GetType
(
)
) {
174
case
BC_TYPE::kCode39:
175
case
BC_TYPE::kCodabar:
176
case
BC_TYPE::kCode128:
177
case
BC_TYPE::kCode128B:
178
case
BC_TYPE::kCode128C:
179
case
BC_TYPE::kEAN8:
180
case
BC_TYPE::kEAN13:
181
case
BC_TYPE::kUPCA:
182
static_cast
<CBC_OneCode*>(m_pBCEngine.get())->SetFontSize(size);
183
return
true
;
184
default
:
185
return
false
;
186
}
187
}
188
189
bool
CFX_Barcode
::
SetFontColor
(
FX_ARGB
color) {
190
if
(!m_pBCEngine)
191
return
false
;
192
193
switch
(
GetType
(
)
) {
194
case
BC_TYPE::kCode39:
195
case
BC_TYPE::kCodabar:
196
case
BC_TYPE::kCode128:
197
case
BC_TYPE::kCode128B:
198
case
BC_TYPE::kCode128C:
199
case
BC_TYPE::kEAN8:
200
case
BC_TYPE::kEAN13:
201
case
BC_TYPE::kUPCA:
202
static_cast
<CBC_OneCode*>(m_pBCEngine.get())->SetFontColor(color);
203
return
true
;
204
default
:
205
return
false
;
206
}
207
}
208
209
void
CFX_Barcode
::
SetTextLocation
(
BC_TEXT_LOC
location) {
210
if
(m_pBCEngine)
211
m_pBCEngine->SetTextLocation(location);
212
}
213
214
bool
CFX_Barcode
::
SetWideNarrowRatio
(int8_t ratio) {
215
return
m_pBCEngine && m_pBCEngine->SetWideNarrowRatio(ratio);
216
}
217
218
bool
CFX_Barcode
::
SetStartChar
(
char
start) {
219
return
m_pBCEngine && m_pBCEngine->SetStartChar(start);
220
}
221
222
bool
CFX_Barcode
::
SetEndChar
(
char
end) {
223
return
m_pBCEngine && m_pBCEngine->SetEndChar(end);
224
}
225
226
bool
CFX_Barcode
::
SetErrorCorrectionLevel
(int32_t level) {
227
return
m_pBCEngine && m_pBCEngine->SetErrorCorrectionLevel(level);
228
}
229
230
bool
CFX_Barcode
::
Encode
(
WideStringView
contents) {
231
return
m_pBCEngine && m_pBCEngine->Encode(contents);
232
}
233
234
bool
CFX_Barcode
::
RenderDevice
(
CFX_RenderDevice
* device,
235
const
CFX_Matrix
& matrix) {
236
return
m_pBCEngine && m_pBCEngine->RenderDevice(device, matrix);
237
}
BC_TEXT_LOC
BC_TEXT_LOC
Definition
BC_Library.h:12
BC_TYPE
BC_TYPE
Definition
BC_Library.h:20
BC_TYPE::kQRCode
@ kQRCode
Definition
BC_Library.h:30
BC_TYPE::kEAN8
@ kEAN8
Definition
BC_Library.h:27
BC_TYPE::kEAN13
@ kEAN13
Definition
BC_Library.h:29
BC_TYPE::kUnknown
@ kUnknown
Definition
BC_Library.h:21
BC_TYPE::kUPCA
@ kUPCA
Definition
BC_Library.h:28
BC_TYPE::kCode128C
@ kCode128C
Definition
BC_Library.h:26
BC_TYPE::kCodabar
@ kCodabar
Definition
BC_Library.h:23
BC_TYPE::kPDF417
@ kPDF417
Definition
BC_Library.h:31
BC_TYPE::kDataMatrix
@ kDataMatrix
Definition
BC_Library.h:32
BC_TYPE::kCode128B
@ kCode128B
Definition
BC_Library.h:25
BC_TYPE::kCode39
@ kCode39
Definition
BC_Library.h:22
BC_TYPE::kCode128
@ kCode128
Definition
BC_Library.h:24
CFX_Barcode
Definition
cfx_barcode.h:23
CFX_Barcode::SetEndChar
bool SetEndChar(char end)
Definition
cfx_barcode.cpp:222
CFX_Barcode::SetModuleWidth
bool SetModuleWidth(int32_t moduleWidth)
Definition
cfx_barcode.cpp:76
CFX_Barcode::SetStartChar
bool SetStartChar(char start)
Definition
cfx_barcode.cpp:218
CFX_Barcode::SetPrintChecksum
bool SetPrintChecksum(bool checksum)
Definition
cfx_barcode.cpp:90
CFX_Barcode::SetTextLocation
void SetTextLocation(BC_TEXT_LOC location)
Definition
cfx_barcode.cpp:209
CFX_Barcode::SetHeight
void SetHeight(int32_t height)
Definition
cfx_barcode.cpp:80
CFX_Barcode::SetErrorCorrectionLevel
bool SetErrorCorrectionLevel(int32_t level)
Definition
cfx_barcode.cpp:226
CFX_Barcode::SetModuleHeight
bool SetModuleHeight(int32_t moduleHeight)
Definition
cfx_barcode.cpp:72
CFX_Barcode::SetCalChecksum
bool SetCalChecksum(bool state)
Definition
cfx_barcode.cpp:130
CFX_Barcode::SetDataLength
bool SetDataLength(int32_t length)
Definition
cfx_barcode.cpp:110
CFX_Barcode::SetFont
bool SetFont(CFX_Font *pFont)
Definition
cfx_barcode.cpp:150
CFX_Barcode::~CFX_Barcode
~CFX_Barcode()
CFX_Barcode::Encode
bool Encode(WideStringView contents)
Definition
cfx_barcode.cpp:230
CFX_Barcode::GetType
BC_TYPE GetType()
Definition
cfx_barcode.cpp:68
CFX_Barcode::SetFontSize
bool SetFontSize(float size)
Definition
cfx_barcode.cpp:169
CFX_Barcode::SetWidth
void SetWidth(int32_t width)
Definition
cfx_barcode.cpp:85
CFX_Barcode::SetFontColor
bool SetFontColor(FX_ARGB color)
Definition
cfx_barcode.cpp:189
CFX_Barcode::RenderDevice
bool RenderDevice(CFX_RenderDevice *device, const CFX_Matrix &matrix)
Definition
cfx_barcode.cpp:234
CFX_Barcode::SetWideNarrowRatio
bool SetWideNarrowRatio(int8_t ratio)
Definition
cfx_barcode.cpp:214
CFX_Font
Definition
cfx_font.h:38
CFX_Matrix
Definition
fx_coordinates.h:440
CFX_RenderDevice
Definition
cfx_renderdevice.h:39
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
FX_ARGB
uint32_t FX_ARGB
Definition
fx_dib.h:36
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
NOTREACHED_NORETURN
#define NOTREACHED_NORETURN()
Definition
notreached.h:22
WideStringView
fxcrt::WideStringView WideStringView
Definition
string_view_template.h:326
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxbarcode
cfx_barcode.cpp
Generated on
for Qt by
1.18.0