• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
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 #ifndef XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_
8 #define XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_
9 
10 #include <memory>
11 
12 #include "core/fxge/cfx_renderdevice.h"
13 #include "xfa/fxbarcode/BC_Library.h"
14 #include "xfa/fxbarcode/BC_Writer.h"
15 
16 class CBC_CommonBitMatrix;
17 class CFX_Font;
18 class CFX_RenderDevice;
19 
20 class CBC_OneDimWriter : public CBC_Writer {
21  public:
22   CBC_OneDimWriter();
23   ~CBC_OneDimWriter() override;
24 
25   virtual uint8_t* Encode(const CFX_ByteString& contents,
26                           BCFORMAT format,
27                           int32_t& outWidth,
28                           int32_t& outHeight,
29                           int32_t& e);
30   virtual uint8_t* Encode(const CFX_ByteString& contents,
31                           BCFORMAT format,
32                           int32_t& outWidth,
33                           int32_t& outHeight,
34                           int32_t hints,
35                           int32_t& e);
36   virtual uint8_t* Encode(const CFX_ByteString& contents,
37                           int32_t& outLength,
38                           int32_t& e);
39 
40   virtual void RenderResult(const CFX_WideStringC& contents,
41                             uint8_t* code,
42                             int32_t codeLength,
43                             bool isDevice,
44                             int32_t& e);
45   virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
46                                   const CFX_WideStringC& contents,
47                                   int32_t& e);
48   virtual void RenderDeviceResult(CFX_RenderDevice* device,
49                                   const CFX_Matrix* matrix,
50                                   const CFX_WideStringC& contents,
51                                   int32_t& e);
52   virtual bool CheckContentValidity(const CFX_WideStringC& contents);
53   virtual CFX_WideString FilterContents(const CFX_WideStringC& contents);
54   virtual CFX_WideString RenderTextContents(const CFX_WideStringC& contents);
55   virtual void SetPrintChecksum(bool checksum);
56   virtual void SetDataLength(int32_t length);
57   virtual void SetCalcChecksum(bool state);
58   virtual void SetFontSize(FX_FLOAT size);
59   virtual void SetFontStyle(int32_t style);
60   virtual void SetFontColor(FX_ARGB color);
61   bool SetFont(CFX_Font* cFont);
62 
63  protected:
64   virtual void CalcTextInfo(const CFX_ByteString& text,
65                             FXTEXT_CHARPOS* charPos,
66                             CFX_Font* cFont,
67                             FX_FLOAT geWidth,
68                             int32_t fontSize,
69                             FX_FLOAT& charsLen);
70   virtual void ShowChars(const CFX_WideStringC& contents,
71                          CFX_DIBitmap* pOutBitmap,
72                          CFX_RenderDevice* device,
73                          const CFX_Matrix* matrix,
74                          int32_t barWidth,
75                          int32_t multiple,
76                          int32_t& e);
77   virtual void ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
78                                const CFX_ByteString str,
79                                FX_FLOAT geWidth,
80                                FXTEXT_CHARPOS* pCharPos,
81                                FX_FLOAT locX,
82                                FX_FLOAT locY,
83                                int32_t barWidth);
84   virtual void ShowDeviceChars(CFX_RenderDevice* device,
85                                const CFX_Matrix* matrix,
86                                const CFX_ByteString str,
87                                FX_FLOAT geWidth,
88                                FXTEXT_CHARPOS* pCharPos,
89                                FX_FLOAT locX,
90                                FX_FLOAT locY,
91                                int32_t barWidth);
92   virtual int32_t AppendPattern(uint8_t* target,
93                                 int32_t pos,
94                                 const int32_t* pattern,
95                                 int32_t patternLength,
96                                 int32_t startColor,
97                                 int32_t& e);
98 
99   FX_WCHAR Upper(FX_WCHAR ch);
100 
101   bool m_bPrintChecksum;
102   int32_t m_iDataLenth;
103   bool m_bCalcChecksum;
104   CFX_Font* m_pFont;
105   FX_FLOAT m_fFontSize;
106   int32_t m_iFontStyle;
107   uint32_t m_fontColor;
108   BC_TEXT_LOC m_locTextLoc;
109   int32_t m_iContentLen;
110   bool m_bLeftPadding;
111   bool m_bRightPadding;
112   std::unique_ptr<CBC_CommonBitMatrix> m_output;
113   int32_t m_barWidth;
114   int32_t m_multiple;
115   FX_FLOAT m_outputHScale;
116 };
117 
118 #endif  // XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_
119