Resolve xfa/fxa/parser to xfa/fgas/crt circular includes.
Introduce a LocaleMgrIface interface defined by the lower layer
for the higher layer to implement.
Change-Id: I3460ea6e8e21230439ceb21b44bd7c779b2133d8
Reviewed-on: https://pdfium-review.googlesource.com/c/49550
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fgas/BUILD.gn b/xfa/fgas/BUILD.gn
index 8099775..e2f84c6 100644
--- a/xfa/fgas/BUILD.gn
+++ b/xfa/fgas/BUILD.gn
@@ -15,6 +15,7 @@
"crt/cfgas_formatstring.cpp",
"crt/cfgas_formatstring.h",
"crt/locale_iface.h",
+ "crt/locale_mgr_iface.h",
"font/cfgas_defaultfontmanager.cpp",
"font/cfgas_defaultfontmanager.h",
"font/cfgas_fontmgr.cpp",
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index cc02425..d07f14f 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -12,7 +12,6 @@
#include "core/fxcrt/fx_extension.h"
#include "xfa/fgas/crt/cfgas_decimal.h"
-#include "xfa/fxfa/parser/cxfa_localemgr.h"
#define FX_LOCALECATEGORY_DateHash 0xbde9abde
#define FX_LOCALECATEGORY_TimeHash 0x2d71b00f
@@ -839,7 +838,7 @@
return true;
}
-CFGAS_FormatString::CFGAS_FormatString(CXFA_LocaleMgr* pLocaleMgr)
+CFGAS_FormatString::CFGAS_FormatString(LocaleMgrIface* pLocaleMgr)
: m_pLocaleMgr(pLocaleMgr) {}
CFGAS_FormatString::~CFGAS_FormatString() {}
diff --git a/xfa/fgas/crt/cfgas_formatstring.h b/xfa/fgas/crt/cfgas_formatstring.h
index 5dab9ed..fab32e1 100644
--- a/xfa/fgas/crt/cfgas_formatstring.h
+++ b/xfa/fgas/crt/cfgas_formatstring.h
@@ -11,8 +11,7 @@
#include "core/fxcrt/unowned_ptr.h"
#include "xfa/fgas/crt/locale_iface.h"
-
-class CXFA_LocaleMgr;
+#include "xfa/fgas/crt/locale_mgr_iface.h"
bool FX_DateFromCanonical(const WideString& wsDate, CFX_DateTime* datetime);
bool FX_TimeFromCanonical(WideStringView wsTime,
@@ -21,7 +20,7 @@
class CFGAS_FormatString {
public:
- explicit CFGAS_FormatString(CXFA_LocaleMgr* pLocaleMgr);
+ explicit CFGAS_FormatString(LocaleMgrIface* pLocaleMgr);
~CFGAS_FormatString();
void SplitFormatString(const WideString& wsFormatString,
@@ -71,7 +70,7 @@
WideString* wsDatePattern,
WideString* wsTimePattern) const;
- UnownedPtr<CXFA_LocaleMgr> const m_pLocaleMgr;
+ UnownedPtr<LocaleMgrIface> const m_pLocaleMgr;
};
#endif // XFA_FGAS_CRT_CFGAS_FORMATSTRING_H_
diff --git a/xfa/fgas/crt/locale_mgr_iface.h b/xfa/fgas/crt/locale_mgr_iface.h
new file mode 100644
index 0000000..42f5ada
--- /dev/null
+++ b/xfa/fgas/crt/locale_mgr_iface.h
@@ -0,0 +1,22 @@
+// Copyright 2019 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 XFA_FGAS_CRT_LOCALE_MGR_IFACE_H_
+#define XFA_FGAS_CRT_LOCALE_MGR_IFACE_H_
+
+#include "core/fxcrt/fx_string.h"
+
+class LocaleIface;
+
+class LocaleMgrIface {
+ public:
+ virtual ~LocaleMgrIface() = default;
+
+ virtual LocaleIface* GetDefLocale() = 0;
+ virtual LocaleIface* GetLocaleByName(const WideString& wsLCID) = 0;
+};
+
+#endif // XFA_FGAS_CRT_LOCALE_MGR_IFACE_H_
diff --git a/xfa/fxfa/parser/BUILD.gn b/xfa/fxfa/parser/BUILD.gn
index addcb1e..4bd913e 100644
--- a/xfa/fxfa/parser/BUILD.gn
+++ b/xfa/fxfa/parser/BUILD.gn
@@ -708,10 +708,7 @@
"../../fgas",
"../../fxgraphics",
]
- allow_circular_includes_from = [
- "../../fgas",
- "../../../fxjs",
- ]
+ allow_circular_includes_from = [ "../../../fxjs" ]
configs += [
"../../../:pdfium_core_config",
"../../:xfa_warnings",
diff --git a/xfa/fxfa/parser/cxfa_localemgr.h b/xfa/fxfa/parser/cxfa_localemgr.h
index a59fdcd..9370988 100644
--- a/xfa/fxfa/parser/cxfa_localemgr.h
+++ b/xfa/fxfa/parser/cxfa_localemgr.h
@@ -12,17 +12,18 @@
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxcrt/widestring.h"
+#include "xfa/fgas/crt/locale_mgr_iface.h"
class CXFA_Node;
class LocaleIface;
-class CXFA_LocaleMgr {
+class CXFA_LocaleMgr : public LocaleMgrIface {
public:
CXFA_LocaleMgr(CXFA_Node* pLocaleSet, WideString wsDeflcid);
- ~CXFA_LocaleMgr();
+ ~CXFA_LocaleMgr() override;
- LocaleIface* GetDefLocale();
- LocaleIface* GetLocaleByName(const WideString& wsLocaleName);
+ LocaleIface* GetDefLocale() override;
+ LocaleIface* GetLocaleByName(const WideString& wsLocaleName) override;
void SetDefLocale(LocaleIface* pLocale);
WideString GetConfigLocaleName(CXFA_Node* pConfig);