1 // Copyright 2016 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 FXBARCODE_CBC_CODEBASE_H_
8 #define FXBARCODE_CBC_CODEBASE_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_string.h"
13 #include "core/fxcrt/fx_system.h"
14 #include "core/fxge/fx_dib.h"
15 #include "fxbarcode/BC_Library.h"
16 
17 class CBC_Reader;
18 class CBC_Writer;
19 class CFX_DIBitmap;
20 class CFX_Matrix;
21 class CFX_RenderDevice;
22 
23 class CBC_CodeBase {
24  public:
25   explicit CBC_CodeBase(std::unique_ptr<CBC_Writer> pWriter);
26   virtual ~CBC_CodeBase();
27 
28   virtual BC_TYPE GetType() = 0;
29   virtual bool Encode(WideStringView contents) = 0;
30   virtual bool RenderDevice(CFX_RenderDevice* device,
31                             const CFX_Matrix* matrix) = 0;
32 
33   bool SetTextLocation(BC_TEXT_LOC location);
34   bool SetWideNarrowRatio(int8_t ratio);
35   bool SetStartChar(char start);
36   bool SetEndChar(char end);
37   bool SetErrorCorrectionLevel(int32_t level);
38   bool SetCharEncoding(int32_t encoding);
39   bool SetModuleHeight(int32_t moduleHeight);
40   bool SetModuleWidth(int32_t moduleWidth);
41   bool SetHeight(int32_t height);
42   bool SetWidth(int32_t width);
43 
44  protected:
45   std::unique_ptr<CBC_Writer> m_pBCWriter;
46 };
47 
48 #endif  // FXBARCODE_CBC_CODEBASE_H_
49