summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-03 19:12:34 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-03 19:12:34 +0000
commit95b0293a29b235c746db0f01c8462ca89d7a814e (patch)
treeed5e19f83b4e5d0e90bac2c0764175a8ed7a5b8f /xfa
parentd96fa3b42797332ab53c05b8e6b6357676838e55 (diff)
downloadpdfium-95b0293a29b235c746db0f01c8462ca89d7a814e.tar.xz
Use more UnowendPtr<> in cfgas_formatstring.h and cfx_break.h
Move initializers to .h file (proves none missing). Change-Id: Iff8fe76e46634aa32a32ecd592476594a9d1bafa Reviewed-on: https://pdfium-review.googlesource.com/36950 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fgas/crt/cfgas_formatstring.h3
-rw-r--r--xfa/fgas/crt/cfgas_formatstring_unittest.cpp1
-rw-r--r--xfa/fgas/layout/cfx_break.cpp22
-rw-r--r--xfa/fgas/layout/cfx_break.h41
-rw-r--r--xfa/fgas/layout/cfx_rtfbreak.cpp2
-rw-r--r--xfa/fgas/layout/cfx_txtbreak.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_localevalue.cpp30
-rw-r--r--xfa/fxfa/parser/cxfa_localevalue.h15
8 files changed, 47 insertions, 69 deletions
diff --git a/xfa/fgas/crt/cfgas_formatstring.h b/xfa/fgas/crt/cfgas_formatstring.h
index 2cc5d569cd..3cbe6ff65a 100644
--- a/xfa/fgas/crt/cfgas_formatstring.h
+++ b/xfa/fgas/crt/cfgas_formatstring.h
@@ -10,6 +10,7 @@
#include <vector>
#include "core/fxcrt/locale_iface.h"
+#include "core/fxcrt/unowned_ptr.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
bool FX_DateFromCanonical(const WideString& wsDate, CFX_DateTime* datetime);
@@ -67,7 +68,7 @@ class CFGAS_FormatString {
WideString* wsDatePattern,
WideString* wsTimePattern);
- CXFA_LocaleMgr* m_pLocaleMgr;
+ UnownedPtr<CXFA_LocaleMgr> m_pLocaleMgr;
};
#endif // XFA_FGAS_CRT_CFGAS_FORMATSTRING_H_
diff --git a/xfa/fgas/crt/cfgas_formatstring_unittest.cpp b/xfa/fgas/crt/cfgas_formatstring_unittest.cpp
index 51c001090c..afbd00f068 100644
--- a/xfa/fgas/crt/cfgas_formatstring_unittest.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring_unittest.cpp
@@ -44,6 +44,7 @@ class CFGAS_FormatStringTest : public testing::Test {
// Note, this re-creates the fmt on each call. If you need to multiple
// times store it locally.
CFGAS_FormatString* fmt(const WideString& locale) {
+ fmt_.reset(); // Can't outlive |mgr_|.
mgr_ = pdfium::MakeUnique<CXFA_LocaleMgr>(nullptr, locale);
fmt_ = pdfium::MakeUnique<CFGAS_FormatString>(mgr_.get());
return fmt_.get();
diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp
index 889c043ec2..43ef9a3833 100644
--- a/xfa/fgas/layout/cfx_break.cpp
+++ b/xfa/fgas/layout/cfx_break.cpp
@@ -19,29 +19,11 @@ const int kMinimumTabWidth = 160000;
} // namespace
CFX_Break::CFX_Break(uint32_t dwLayoutStyles)
- : m_eCharType(FX_CHARTYPE_Unknown),
- m_bSingleLine(false),
- m_bCombText(false),
- m_dwIdentity(0),
- m_dwLayoutStyles(dwLayoutStyles),
- m_iLineStart(0),
- m_iLineWidth(2000000),
- m_wParagraphBreakChar(L'\n'),
- m_iFontSize(240),
- m_iTabWidth(720000),
- m_iHorizontalScale(100),
- m_iVerticalScale(100),
- m_iTolerance(0),
- m_iCharSpace(0),
- m_iDefChar(0),
- m_wDefChar(0xFEFF),
- m_pFont(nullptr),
- m_pCurLine(nullptr),
- m_iReadyLineIndex(-1) {
+ : m_dwLayoutStyles(dwLayoutStyles) {
m_pCurLine = &m_Line[0];
}
-CFX_Break::~CFX_Break() {}
+CFX_Break::~CFX_Break() = default;
void CFX_Break::Reset() {
m_eCharType = FX_CHARTYPE_Unknown;
diff --git a/xfa/fgas/layout/cfx_break.h b/xfa/fgas/layout/cfx_break.h
index cc985b7c59..88cef53df1 100644
--- a/xfa/fgas/layout/cfx_break.h
+++ b/xfa/fgas/layout/cfx_break.h
@@ -10,6 +10,7 @@
#include <stdint.h>
#include "core/fxcrt/retain_ptr.h"
+#include "core/fxcrt/unowned_ptr.h"
#include "xfa/fgas/layout/cfx_breakline.h"
class CFGAS_GEFont;
@@ -57,7 +58,9 @@ class CFX_Break {
void ClearBreakPieces();
CFX_Char* GetLastChar(int32_t index, bool bOmitChar, bool bRichText) const;
- const CFX_BreakLine* GetCurrentLineForTesting() const { return m_pCurLine; }
+ const CFX_BreakLine* GetCurrentLineForTesting() const {
+ return m_pCurLine.Get();
+ }
protected:
explicit CFX_Break(uint32_t dwLayoutStyles);
@@ -66,25 +69,25 @@ class CFX_Break {
bool HasLine() const { return m_iReadyLineIndex >= 0; }
FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const;
- FX_CHARTYPE m_eCharType;
- bool m_bSingleLine;
- bool m_bCombText;
- uint32_t m_dwIdentity;
- uint32_t m_dwLayoutStyles;
- int32_t m_iLineStart;
- int32_t m_iLineWidth;
- wchar_t m_wParagraphBreakChar;
- int32_t m_iFontSize;
- int32_t m_iTabWidth;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
- int32_t m_iTolerance;
- int32_t m_iCharSpace;
- int32_t m_iDefChar;
- wchar_t m_wDefChar;
+ FX_CHARTYPE m_eCharType = FX_CHARTYPE_Unknown;
+ bool m_bSingleLine = false;
+ bool m_bCombText = false;
+ uint32_t m_dwIdentity = 0;
+ uint32_t m_dwLayoutStyles = 0;
+ int32_t m_iLineStart = 0;
+ int32_t m_iLineWidth = 2000000;
+ wchar_t m_wParagraphBreakChar = L'\n';
+ int32_t m_iFontSize = 240;
+ int32_t m_iTabWidth = 720000;
+ int32_t m_iHorizontalScale = 100;
+ int32_t m_iVerticalScale = 100;
+ int32_t m_iTolerance = 0;
+ int32_t m_iCharSpace = 0;
+ int32_t m_iDefChar = 0;
+ wchar_t m_wDefChar = 0xFEFF;
RetainPtr<CFGAS_GEFont> m_pFont;
- CFX_BreakLine* m_pCurLine;
- int8_t m_iReadyLineIndex;
+ UnownedPtr<CFX_BreakLine> m_pCurLine;
+ int8_t m_iReadyLineIndex = -1;
CFX_BreakLine m_Line[2];
private:
diff --git a/xfa/fgas/layout/cfx_rtfbreak.cpp b/xfa/fgas/layout/cfx_rtfbreak.cpp
index de8703fb2d..4dfe8989d1 100644
--- a/xfa/fgas/layout/cfx_rtfbreak.cpp
+++ b/xfa/fgas/layout/cfx_rtfbreak.cpp
@@ -355,7 +355,7 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
case FX_CHARTYPE_Space:
break;
default:
- SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars);
+ SplitTextLine(m_pCurLine.Get(), pNextLine, !m_bPagination && bAllChars);
bDone = true;
break;
}
diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp
index 7633c4c91e..490426a221 100644
--- a/xfa/fgas/layout/cfx_txtbreak.cpp
+++ b/xfa/fgas/layout/cfx_txtbreak.cpp
@@ -293,7 +293,7 @@ bool CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
case FX_CHARTYPE_Space:
break;
default:
- SplitTextLine(m_pCurLine, pNextLine, bAllChars);
+ SplitTextLine(m_pCurLine.Get(), pNextLine, bAllChars);
bDone = true;
break;
}
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 3a55045905..15082ae5e3 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -64,14 +64,7 @@ bool ValueSplitDateTime(const WideString& wsDateTime,
} // namespace
-CXFA_LocaleValue::CXFA_LocaleValue()
- : m_pLocaleMgr(nullptr), m_dwType(XFA_VT_NULL), m_bValid(true) {}
-
-CXFA_LocaleValue::CXFA_LocaleValue(const CXFA_LocaleValue& value)
- : m_pLocaleMgr(value.m_pLocaleMgr),
- m_wsValue(value.m_wsValue),
- m_dwType(value.m_dwType),
- m_bValid(value.m_bValid) {}
+CXFA_LocaleValue::CXFA_LocaleValue() = default;
CXFA_LocaleValue::CXFA_LocaleValue(uint32_t dwType, CXFA_LocaleMgr* pLocaleMgr)
: m_pLocaleMgr(pLocaleMgr),
@@ -95,15 +88,12 @@ CXFA_LocaleValue::CXFA_LocaleValue(uint32_t dwType,
m_dwType(dwType),
m_bValid(ParsePatternValue(wsValue, wsFormat, pLocale)) {}
-CXFA_LocaleValue& CXFA_LocaleValue::operator=(const CXFA_LocaleValue& value) {
- m_wsValue = value.m_wsValue;
- m_dwType = value.m_dwType;
- m_bValid = value.m_bValid;
- m_pLocaleMgr = value.m_pLocaleMgr;
- return *this;
-}
+CXFA_LocaleValue::CXFA_LocaleValue(const CXFA_LocaleValue& that) = default;
+
+CXFA_LocaleValue& CXFA_LocaleValue::operator=(const CXFA_LocaleValue& that) =
+ default;
-CXFA_LocaleValue::~CXFA_LocaleValue() {}
+CXFA_LocaleValue::~CXFA_LocaleValue() = default;
bool CXFA_LocaleValue::ValidateValue(const WideString& wsValue,
const WideString& wsPattern,
@@ -114,7 +104,7 @@ bool CXFA_LocaleValue::ValidateValue(const WideString& wsValue,
if (pLocale)
m_pLocaleMgr->SetDefLocale(pLocale);
- auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr);
+ auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
std::vector<WideString> wsPatterns;
pFormat->SplitFormatString(wsPattern, &wsPatterns);
@@ -310,7 +300,7 @@ bool CXFA_LocaleValue::FormatPatterns(WideString& wsResult,
const WideString& wsFormat,
LocaleIface* pLocale,
XFA_VALUEPICTURE eValueType) const {
- auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr);
+ auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
std::vector<WideString> wsPatterns;
pFormat->SplitFormatString(wsFormat, &wsPatterns);
wsResult.clear();
@@ -332,7 +322,7 @@ bool CXFA_LocaleValue::FormatSinglePattern(WideString& wsResult,
wsResult.clear();
bool bRet = false;
- auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr);
+ auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
FX_LOCALECATEGORY eCategory =
ValueCategory(pFormat->GetCategory(wsFormat), m_dwType);
switch (eCategory) {
@@ -597,7 +587,7 @@ bool CXFA_LocaleValue::ParsePatternValue(const WideString& wsValue,
if (pLocale)
m_pLocaleMgr->SetDefLocale(pLocale);
- auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr);
+ auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get());
std::vector<WideString> wsPatterns;
pFormat->SplitFormatString(wsPattern, &wsPatterns);
bool bRet = false;
diff --git a/xfa/fxfa/parser/cxfa_localevalue.h b/xfa/fxfa/parser/cxfa_localevalue.h
index cedea10b10..c6f9c1ee98 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.h
+++ b/xfa/fxfa/parser/cxfa_localevalue.h
@@ -9,6 +9,7 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/unowned_ptr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
class LocaleIface;
@@ -28,7 +29,6 @@ class CXFA_LocaleMgr;
class CXFA_LocaleValue {
public:
CXFA_LocaleValue();
- CXFA_LocaleValue(const CXFA_LocaleValue& value);
CXFA_LocaleValue(uint32_t dwType, CXFA_LocaleMgr* pLocaleMgr);
CXFA_LocaleValue(uint32_t dwType,
const WideString& wsValue,
@@ -38,8 +38,10 @@ class CXFA_LocaleValue {
const WideString& wsFormat,
LocaleIface* pLocale,
CXFA_LocaleMgr* pLocaleMgr);
+ CXFA_LocaleValue(const CXFA_LocaleValue& that);
~CXFA_LocaleValue();
- CXFA_LocaleValue& operator=(const CXFA_LocaleValue& value);
+
+ CXFA_LocaleValue& operator=(const CXFA_LocaleValue& that);
bool ValidateValue(const WideString& wsValue,
const WideString& wsPattern,
@@ -56,6 +58,7 @@ class CXFA_LocaleValue {
const WideString& wsFormat,
LocaleIface* pLocale);
+ bool IsValid() const { return m_bValid; }
WideString GetValue() const { return m_wsValue; }
uint32_t GetType() const { return m_dwType; }
double GetDoubleNum() const;
@@ -63,8 +66,6 @@ class CXFA_LocaleValue {
CFX_DateTime GetDate() const;
CFX_DateTime GetTime() const;
- bool IsValid() const { return m_bValid; }
-
private:
bool FormatSinglePattern(WideString& wsResult,
const WideString& wsFormat,
@@ -81,10 +82,10 @@ class CXFA_LocaleValue {
const WideString& wsPattern,
LocaleIface* pLocale);
- CXFA_LocaleMgr* m_pLocaleMgr;
+ UnownedPtr<CXFA_LocaleMgr> m_pLocaleMgr;
WideString m_wsValue;
- uint32_t m_dwType;
- bool m_bValid;
+ uint32_t m_dwType = XFA_VT_NULL;
+ bool m_bValid = true;
};
#endif // XFA_FXFA_PARSER_CXFA_LOCALEVALUE_H_