From 740bcd892d22136873b2b123b94e51bf6e77b8f9 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 1 Sep 2017 12:40:05 -0700 Subject: Split fx_ucd.h into fx_unicode.h and fx_ucddata.h. File naming now matches. Fix one usage not going through the accessor function. Change-Id: I5cc4986238764964f2a71807a94bd2facf517263 Reviewed-on: https://pdfium-review.googlesource.com/12930 Commit-Queue: dsinclair Reviewed-by: dsinclair --- BUILD.gn | 3 ++- core/fpdftext/cpdf_textpage.cpp | 2 +- core/fxcrt/cfx_char.h | 2 +- core/fxcrt/fx_arabic.cpp | 2 +- core/fxcrt/fx_bidi.cpp | 2 +- core/fxcrt/fx_ucd.h | 54 --------------------------------------- core/fxcrt/fx_ucddata.cpp | 3 ++- core/fxcrt/fx_ucddata.h | 18 +++++++++++++ core/fxcrt/fx_unicode.cpp | 4 ++- core/fxcrt/fx_unicode.h | 48 ++++++++++++++++++++++++++++++++++ xfa/fgas/layout/cfx_linebreak.cpp | 2 +- xfa/fgas/layout/cfx_rtfbreak.h | 2 +- xfa/fgas/layout/cfx_txtbreak.cpp | 2 +- 13 files changed, 80 insertions(+), 64 deletions(-) delete mode 100644 core/fxcrt/fx_ucd.h create mode 100644 core/fxcrt/fx_ucddata.h create mode 100644 core/fxcrt/fx_unicode.h diff --git a/BUILD.gn b/BUILD.gn index c7b86ea411..ddb0d5e8e2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -850,9 +850,10 @@ static_library("fxcrt") { "core/fxcrt/fx_string.h", "core/fxcrt/fx_system.cpp", "core/fxcrt/fx_system.h", - "core/fxcrt/fx_ucd.h", "core/fxcrt/fx_ucddata.cpp", + "core/fxcrt/fx_ucddata.h", "core/fxcrt/fx_unicode.cpp", + "core/fxcrt/fx_unicode.h", "core/fxcrt/ifx_fileaccess.h", "core/fxcrt/ifx_pauseindicator.h", "core/fxcrt/xml/cxml_attritem.cpp", diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index ffc3729af4..3006ebce2b 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -21,7 +21,7 @@ #include "core/fpdftext/unicodenormalizationdata.h" #include "core/fxcrt/fx_bidi.h" #include "core/fxcrt/fx_extension.h" -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/fx_unicode.h" #include "third_party/base/stl_util.h" namespace { diff --git a/core/fxcrt/cfx_char.h b/core/fxcrt/cfx_char.h index 009e87b388..74f0a4f9cd 100644 --- a/core/fxcrt/cfx_char.h +++ b/core/fxcrt/cfx_char.h @@ -9,7 +9,7 @@ #include -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/fx_unicode.h" enum class CFX_BreakType { None = 0, Piece, Line, Paragraph, Page }; diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp index d9804ba4a9..0d6f0395a6 100644 --- a/core/fxcrt/fx_arabic.cpp +++ b/core/fxcrt/fx_arabic.cpp @@ -10,7 +10,7 @@ #include #include "core/fxcrt/fx_memory.h" -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/fx_unicode.h" #include "third_party/base/stl_util.h" namespace { diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp index 5b5b1982cc..b7c7cacad8 100644 --- a/core/fxcrt/fx_bidi.cpp +++ b/core/fxcrt/fx_bidi.cpp @@ -8,7 +8,7 @@ #include -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/fx_unicode.h" #include "third_party/base/ptr_util.h" #ifdef PDF_ENABLE_XFA diff --git a/core/fxcrt/fx_ucd.h b/core/fxcrt/fx_ucd.h deleted file mode 100644 index bca830fc0f..0000000000 --- a/core/fxcrt/fx_ucd.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXCRT_FX_UCD_H_ -#define CORE_FXCRT_FX_UCD_H_ - -#include "core/fxcrt/cfx_retain_ptr.h" - -extern const uint32_t kTextLayoutCodeProperties[]; -extern const size_t kTextLayoutCodePropertiesSize; - -extern const uint16_t kFXTextLayoutBidiMirror[]; -extern const size_t kFXTextLayoutBidiMirrorSize; - -uint32_t FX_GetUnicodeProperties(wchar_t wch); -wchar_t FX_GetMirrorChar(wchar_t wch); - -#ifdef PDF_ENABLE_XFA - -// As defined in http://www.unicode.org/reports/tr14 -constexpr uint8_t kBreakPropertySpace = 35; -constexpr uint8_t kBreakPropertyTB = 37; // Don't know what this is ... - -constexpr uint32_t FX_CHARTYPEBITS = 11; -constexpr uint32_t FX_CHARTYPEBITSMASK = 0xF << FX_CHARTYPEBITS; - -enum FX_CHARTYPE { - FX_CHARTYPE_Unknown = 0, - FX_CHARTYPE_Tab = (1 << FX_CHARTYPEBITS), - FX_CHARTYPE_Space = (2 << FX_CHARTYPEBITS), - FX_CHARTYPE_Control = (3 << FX_CHARTYPEBITS), - FX_CHARTYPE_Combination = (4 << FX_CHARTYPEBITS), - FX_CHARTYPE_Numeric = (5 << FX_CHARTYPEBITS), - FX_CHARTYPE_Normal = (6 << FX_CHARTYPEBITS), - FX_CHARTYPE_ArabicAlef = (7 << FX_CHARTYPEBITS), - FX_CHARTYPE_ArabicSpecial = (8 << FX_CHARTYPEBITS), - FX_CHARTYPE_ArabicDistortion = (9 << FX_CHARTYPEBITS), - FX_CHARTYPE_ArabicNormal = (10 << FX_CHARTYPEBITS), - FX_CHARTYPE_ArabicForm = (11 << FX_CHARTYPEBITS), - FX_CHARTYPE_Arabic = (12 << FX_CHARTYPEBITS), -}; - -inline FX_CHARTYPE GetCharTypeFromProp(uint32_t prop) { - return static_cast(prop & FX_CHARTYPEBITSMASK); -} - -wchar_t FX_GetMirrorChar(wchar_t wch, uint32_t dwProps); - -#endif // PDF_ENABLE_XFA - -#endif // CORE_FXCRT_FX_UCD_H_ diff --git a/core/fxcrt/fx_ucddata.cpp b/core/fxcrt/fx_ucddata.cpp index 1f28bfbd37..527eacfdbd 100644 --- a/core/fxcrt/fx_ucddata.cpp +++ b/core/fxcrt/fx_ucddata.cpp @@ -4,8 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fxcrt/fx_ucddata.h" + #include "core/fxcrt/fx_memory.h" -#include "core/fxcrt/fx_ucd.h" const uint32_t kTextLayoutCodeProperties[] = { 0xfffe9a93, 0xfffe9a93, 0xfffe9a93, 0xfffe9a93, 0xfffe9a93, 0xfffe9a93, diff --git a/core/fxcrt/fx_ucddata.h b/core/fxcrt/fx_ucddata.h new file mode 100644 index 0000000000..78a6b970cc --- /dev/null +++ b/core/fxcrt/fx_ucddata.h @@ -0,0 +1,18 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXCRT_FX_UCDDATA_H_ +#define CORE_FXCRT_FX_UCDDATA_H_ + +#include "core/fxcrt/fx_system.h" + +extern const uint32_t kTextLayoutCodeProperties[]; +extern const size_t kTextLayoutCodePropertiesSize; + +extern const uint16_t kFXTextLayoutBidiMirror[]; +extern const size_t kFXTextLayoutBidiMirrorSize; + +#endif // CORE_FXCRT_FX_UCDDATA_H_ diff --git a/core/fxcrt/fx_unicode.cpp b/core/fxcrt/fx_unicode.cpp index f23200491a..aafdba15ee 100644 --- a/core/fxcrt/fx_unicode.cpp +++ b/core/fxcrt/fx_unicode.cpp @@ -4,7 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/fx_unicode.h" + +#include "core/fxcrt/fx_ucddata.h" namespace { diff --git a/core/fxcrt/fx_unicode.h b/core/fxcrt/fx_unicode.h new file mode 100644 index 0000000000..a4a237ae6d --- /dev/null +++ b/core/fxcrt/fx_unicode.h @@ -0,0 +1,48 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXCRT_FX_UNICODE_H_ +#define CORE_FXCRT_FX_UNICODE_H_ + +#include "core/fxcrt/cfx_retain_ptr.h" + +uint32_t FX_GetUnicodeProperties(wchar_t wch); +wchar_t FX_GetMirrorChar(wchar_t wch); + +#ifdef PDF_ENABLE_XFA + +// As defined in http://www.unicode.org/reports/tr14 +constexpr uint8_t kBreakPropertySpace = 35; +constexpr uint8_t kBreakPropertyTB = 37; // Don't know what this is ... + +constexpr uint32_t FX_CHARTYPEBITS = 11; +constexpr uint32_t FX_CHARTYPEBITSMASK = 0xF << FX_CHARTYPEBITS; + +enum FX_CHARTYPE { + FX_CHARTYPE_Unknown = 0, + FX_CHARTYPE_Tab = (1 << FX_CHARTYPEBITS), + FX_CHARTYPE_Space = (2 << FX_CHARTYPEBITS), + FX_CHARTYPE_Control = (3 << FX_CHARTYPEBITS), + FX_CHARTYPE_Combination = (4 << FX_CHARTYPEBITS), + FX_CHARTYPE_Numeric = (5 << FX_CHARTYPEBITS), + FX_CHARTYPE_Normal = (6 << FX_CHARTYPEBITS), + FX_CHARTYPE_ArabicAlef = (7 << FX_CHARTYPEBITS), + FX_CHARTYPE_ArabicSpecial = (8 << FX_CHARTYPEBITS), + FX_CHARTYPE_ArabicDistortion = (9 << FX_CHARTYPEBITS), + FX_CHARTYPE_ArabicNormal = (10 << FX_CHARTYPEBITS), + FX_CHARTYPE_ArabicForm = (11 << FX_CHARTYPEBITS), + FX_CHARTYPE_Arabic = (12 << FX_CHARTYPEBITS), +}; + +inline FX_CHARTYPE GetCharTypeFromProp(uint32_t prop) { + return static_cast(prop & FX_CHARTYPEBITSMASK); +} + +wchar_t FX_GetMirrorChar(wchar_t wch, uint32_t dwProps); + +#endif // PDF_ENABLE_XFA + +#endif // CORE_FXCRT_FX_UNICODE_H_ diff --git a/xfa/fgas/layout/cfx_linebreak.cpp b/xfa/fgas/layout/cfx_linebreak.cpp index 9531bc55b0..14352481bd 100644 --- a/xfa/fgas/layout/cfx_linebreak.cpp +++ b/xfa/fgas/layout/cfx_linebreak.cpp @@ -6,7 +6,7 @@ #include "xfa/fgas/layout/cfx_linebreak.h" -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/fx_unicode.h" const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32] = { {FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, diff --git a/xfa/fgas/layout/cfx_rtfbreak.h b/xfa/fgas/layout/cfx_rtfbreak.h index 5151f4f6db..699815ab98 100644 --- a/xfa/fgas/layout/cfx_rtfbreak.h +++ b/xfa/fgas/layout/cfx_rtfbreak.h @@ -12,7 +12,7 @@ #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/fx_unicode.h" #include "core/fxge/cfx_renderdevice.h" #include "xfa/fgas/layout/cfx_break.h" #include "xfa/fxfa/cxfa_textuserdata.h" diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp index 2ea64d2bd5..c30b4a1704 100644 --- a/xfa/fgas/layout/cfx_txtbreak.cpp +++ b/xfa/fgas/layout/cfx_txtbreak.cpp @@ -202,7 +202,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar) { } CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) { - uint32_t dwProps = kTextLayoutCodeProperties[static_cast(wch)]; + uint32_t dwProps = FX_GetUnicodeProperties(wch); FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); m_pCurLine->m_LineChars.emplace_back(wch, dwProps, m_iHorizontalScale, m_iVerticalScale); -- cgit v1.2.3