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 FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_
8 #define FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_string.h"
13 #include "core/fxcrt/fx_system.h"
14 #include "fxbarcode/oned/BC_OneDimWriter.h"
15 
16 class CBC_OnedEAN13Writer;
17 class CFX_DIBitmap;
18 class CFX_Matrix;
19 class CFX_RenderDevice;
20 
21 class CBC_OnedUPCAWriter : public CBC_OneDimWriter {
22  public:
23   CBC_OnedUPCAWriter();
24   ~CBC_OnedUPCAWriter() override;
25 
26   // CBC_OneDimWriter
27   uint8_t* EncodeWithHint(const ByteString& contents,
28                           BCFORMAT format,
29                           int32_t& outWidth,
30                           int32_t& outHeight,
31                           int32_t hints) override;
32   uint8_t* EncodeImpl(const ByteString& contents, int32_t& outLength) override;
33   bool CheckContentValidity(const WideStringView& contents) override;
34   WideString FilterContents(const WideStringView& contents) override;
35 
36   void Init();
37   int32_t CalcChecksum(const ByteString& contents);
38 
39  protected:
40   bool ShowChars(const WideStringView& contents,
41                  CFX_RenderDevice* device,
42                  const CFX_Matrix* matrix,
43                  int32_t barWidth,
44                  int32_t multiple) override;
45 
46  private:
47   std::unique_ptr<CBC_OnedEAN13Writer> m_subWriter;
48 };
49 
50 #endif  // FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_
51