summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-11 17:23:48 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-11 17:23:48 -0800
commit211d4edbe2f71ca62c76f36ce25090342c58e43c (patch)
tree645a4823ce6df9021333552b55288cd13344a4f9 /xfa/fxfa/parser
parent8f3eb6051c0465923d6694bd0f0b6dc5bb51cbe3 (diff)
downloadpdfium-211d4edbe2f71ca62c76f36ce25090342c58e43c.tar.xz
Add fpdfppo_embeddertest.cpp.
The lack of coverage of the fpdfppo APIs was noticed while trying to diagnose another issue. Adding basic calls to these APIs then kicked out an assert in XFA, where duplicate global CFXA_TimeZoneProviders were not expected. These are cheap to create except for the global C RTL tzset() call, so keep track of that and make these on demand. Review-Url: https://codereview.chromium.org/2488403004
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/xfa_locale.cpp10
-rw-r--r--xfa/fxfa/parser/xfa_locale.h4
-rw-r--r--xfa/fxfa/parser/xfa_localemgr.cpp44
-rw-r--r--xfa/fxfa/parser/xfa_localemgr.h7
4 files changed, 22 insertions, 43 deletions
diff --git a/xfa/fxfa/parser/xfa_locale.cpp b/xfa/fxfa/parser/xfa_locale.cpp
index 8c106209aa..5b18bcf64b 100644
--- a/xfa/fxfa/parser/xfa_locale.cpp
+++ b/xfa/fxfa/parser/xfa_locale.cpp
@@ -103,8 +103,9 @@ void CXFA_XMLLocale::GetMeridiemName(CFX_WideString& wsMeridiemName,
wsMeridiemName = GetCalendarSymbol("meridiem", bAM ? 0 : 1, false);
}
-void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE& tz) const {
- CXFA_TimeZoneProvider::Get()->GetTimeZone(tz);
+void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE* tz) const {
+ CXFA_TimeZoneProvider provider;
+ provider.GetTimeZone(tz);
}
void CXFA_XMLLocale::GetEraName(CFX_WideString& wsEraName, bool bAD) const {
@@ -288,8 +289,9 @@ void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName,
GetCalendarSymbol(XFA_Element::MeridiemNames, bAM ? 0 : 1, false);
}
-void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const {
- CXFA_TimeZoneProvider::Get()->GetTimeZone(tz);
+void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE* tz) const {
+ CXFA_TimeZoneProvider provider;
+ provider.GetTimeZone(tz);
}
void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, bool bAD) const {
diff --git a/xfa/fxfa/parser/xfa_locale.h b/xfa/fxfa/parser/xfa_locale.h
index b9a3259ead..6d03843419 100644
--- a/xfa/fxfa/parser/xfa_locale.h
+++ b/xfa/fxfa/parser/xfa_locale.h
@@ -31,7 +31,7 @@ class CXFA_XMLLocale : public IFX_Locale {
bool bAbbr = true) const override;
void GetMeridiemName(CFX_WideString& wsMeridiemName,
bool bAM = true) const override;
- void GetTimeZone(FX_TIMEZONE& tz) const override;
+ void GetTimeZone(FX_TIMEZONE* tz) const override;
void GetEraName(CFX_WideString& wsEraName, bool bAD = true) const override;
void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
@@ -73,7 +73,7 @@ class CXFA_NodeLocale : public IFX_Locale {
bool bAbbr = true) const override;
void GetMeridiemName(CFX_WideString& wsMeridiemName,
bool bAM = true) const override;
- void GetTimeZone(FX_TIMEZONE& tz) const override;
+ void GetTimeZone(FX_TIMEZONE* tz) const override;
void GetEraName(CFX_WideString& wsEraName, bool bAD = true) const override;
void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp
index 74565a7ea0..cfa5801e3c 100644
--- a/xfa/fxfa/parser/xfa_localemgr.cpp
+++ b/xfa/fxfa/parser/xfa_localemgr.cpp
@@ -6,6 +6,8 @@
#include "xfa/fxfa/parser/xfa_localemgr.h"
+#include <time.h>
+
#include <memory>
#include <utility>
@@ -1245,37 +1247,21 @@ CFX_WideStringC CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) {
return m_wsConfigLocale.AsStringC();
}
-static CXFA_TimeZoneProvider* g_pProvider = nullptr;
-
-// Static.
-CXFA_TimeZoneProvider* CXFA_TimeZoneProvider::Create() {
- ASSERT(!g_pProvider);
- g_pProvider = new CXFA_TimeZoneProvider();
- return g_pProvider;
-}
-
-// Static.
-CXFA_TimeZoneProvider* CXFA_TimeZoneProvider::Get() {
- if (!g_pProvider) {
- g_pProvider = new CXFA_TimeZoneProvider();
- }
- return g_pProvider;
-}
-
-// Static.
-void CXFA_TimeZoneProvider::Destroy() {
- delete g_pProvider;
- g_pProvider = nullptr;
-}
+static bool g_bProviderTimeZoneSet = false;
-#include <time.h>
CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- _tzset();
+ if (!g_bProviderTimeZoneSet) {
+ g_bProviderTimeZoneSet = true;
+ _tzset();
+ }
m_tz.tzHour = (int8_t)(_timezone / 3600 * -1);
m_tz.tzMinute = (int8_t)((FXSYS_abs(_timezone) % 3600) / 60);
#else
- tzset();
+ if (!g_bProviderTimeZoneSet) {
+ g_bProviderTimeZoneSet = true;
+ tzset();
+ }
m_tz.tzHour = (int8_t)(timezone / 3600 * -1);
m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60);
#endif
@@ -1283,10 +1269,6 @@ CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() {
CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {}
-void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) {
- m_tz = tz;
-}
-
-void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) {
- tz = m_tz;
+void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE* tz) const {
+ *tz = m_tz;
}
diff --git a/xfa/fxfa/parser/xfa_localemgr.h b/xfa/fxfa/parser/xfa_localemgr.h
index 51c6a3b5fb..eb405dcfc7 100644
--- a/xfa/fxfa/parser/xfa_localemgr.h
+++ b/xfa/fxfa/parser/xfa_localemgr.h
@@ -62,12 +62,7 @@ class CXFA_TimeZoneProvider {
CXFA_TimeZoneProvider();
~CXFA_TimeZoneProvider();
- static CXFA_TimeZoneProvider* Create();
- static CXFA_TimeZoneProvider* Get();
- static void Destroy();
-
- void SetTimeZone(FX_TIMEZONE& tz);
- void GetTimeZone(FX_TIMEZONE& tz);
+ void GetTimeZone(FX_TIMEZONE* tz) const;
private:
FX_TIMEZONE m_tz;