From 2eeb42b74b1d29b3cf7fb7344530137debb680dd Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 14 Dec 2017 20:14:54 +0000 Subject: Fold CXFA_TextData into CXFA_Text This CL folds the CXFA_TextData back into CXFA_Text. CXFA_TextData is a thin wrapper around the CXFA_Text object. Change-Id: I4edc37f2ac66fc9b662942d3351fce6b697f27c7 Reviewed-on: https://pdfium-review.googlesource.com/21172 Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima --- xfa/fxfa/cxfa_widgetacc.cpp | 6 +++--- xfa/fxfa/parser/cxfa_calculatedata.cpp | 9 ++++----- xfa/fxfa/parser/cxfa_text.cpp | 4 ++++ xfa/fxfa/parser/cxfa_text.h | 3 +++ xfa/fxfa/parser/cxfa_textdata.cpp | 15 --------------- xfa/fxfa/parser/cxfa_textdata.h | 22 ---------------------- xfa/fxfa/parser/cxfa_value.cpp | 4 ++-- xfa/fxfa/parser/cxfa_value.h | 4 ++-- 8 files changed, 18 insertions(+), 49 deletions(-) delete mode 100644 xfa/fxfa/parser/cxfa_textdata.cpp delete mode 100644 xfa/fxfa/parser/cxfa_textdata.h (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 65c4649fed..f8ea037bf3 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -502,9 +502,9 @@ WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) { if (captionData.HasValidNode()) { CXFA_Value* capValue = captionData.GetValue(); if (capValue) { - CXFA_TextData captionTextData = capValue->GetTextData(); - if (captionTextData.HasValidNode()) - wsCaptionName = captionTextData.GetContent(); + CXFA_Text* captionText = capValue->GetText(); + if (captionText) + wsCaptionName = captionText->GetContent(); } } } diff --git a/xfa/fxfa/parser/cxfa_calculatedata.cpp b/xfa/fxfa/parser/cxfa_calculatedata.cpp index b0feb59fd4..32dc8ef5b7 100644 --- a/xfa/fxfa/parser/cxfa_calculatedata.cpp +++ b/xfa/fxfa/parser/cxfa_calculatedata.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_calculatedata.h" #include "xfa/fxfa/parser/cxfa_node.h" -#include "xfa/fxfa/parser/cxfa_textdata.h" +#include "xfa/fxfa/parser/cxfa_text.h" CXFA_CalculateData::CXFA_CalculateData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} @@ -27,8 +27,7 @@ WideString CXFA_CalculateData::GetMessageText() const { if (!pNode) return L""; - CXFA_TextData textData(pNode->GetChild(0, XFA_Element::Text, false)); - if (!textData.HasValidNode()) - return L""; - return textData.GetContent(); + CXFA_Text* text = + static_cast(pNode->GetChild(0, XFA_Element::Text, false)); + return text ? text->GetContent() : L""; } diff --git a/xfa/fxfa/parser/cxfa_text.cpp b/xfa/fxfa/parser/cxfa_text.cpp index e890aca7ec..e000493446 100644 --- a/xfa/fxfa/parser/cxfa_text.cpp +++ b/xfa/fxfa/parser/cxfa_text.cpp @@ -37,3 +37,7 @@ CXFA_Text::CXFA_Text(CXFA_Document* doc, XFA_PacketType packet) pdfium::MakeUnique(this)) {} CXFA_Text::~CXFA_Text() {} + +WideString CXFA_Text::GetContent() { + return JSObject()->GetContent(false); +} diff --git a/xfa/fxfa/parser/cxfa_text.h b/xfa/fxfa/parser/cxfa_text.h index 6883904b55..a75aef2b01 100644 --- a/xfa/fxfa/parser/cxfa_text.h +++ b/xfa/fxfa/parser/cxfa_text.h @@ -7,12 +7,15 @@ #ifndef XFA_FXFA_PARSER_CXFA_TEXT_H_ #define XFA_FXFA_PARSER_CXFA_TEXT_H_ +#include "core/fxcrt/fx_string.h" #include "xfa/fxfa/parser/cxfa_node.h" class CXFA_Text : public CXFA_Node { public: CXFA_Text(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Text() override; + + WideString GetContent(); }; #endif // XFA_FXFA_PARSER_CXFA_TEXT_H_ diff --git a/xfa/fxfa/parser/cxfa_textdata.cpp b/xfa/fxfa/parser/cxfa_textdata.cpp deleted file mode 100644 index 2ce6c0368e..0000000000 --- a/xfa/fxfa/parser/cxfa_textdata.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 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 - -#include "xfa/fxfa/parser/cxfa_textdata.h" - -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_TextData::CXFA_TextData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} - -WideString CXFA_TextData::GetContent() const { - return m_pNode->JSObject()->GetContent(false); -} diff --git a/xfa/fxfa/parser/cxfa_textdata.h b/xfa/fxfa/parser/cxfa_textdata.h deleted file mode 100644 index 4a28a88d59..0000000000 --- a/xfa/fxfa/parser/cxfa_textdata.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 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_FXFA_PARSER_CXFA_TEXTDATA_H_ -#define XFA_FXFA_PARSER_CXFA_TEXTDATA_H_ - -#include "core/fxcrt/fx_string.h" -#include "xfa/fxfa/parser/cxfa_datadata.h" - -class CXFA_Node; - -class CXFA_TextData : public CXFA_DataData { - public: - explicit CXFA_TextData(CXFA_Node* pNode); - - WideString GetContent() const; -}; - -#endif // XFA_FXFA_PARSER_CXFA_TEXTDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp index aae11da211..d4911c56db 100644 --- a/xfa/fxfa/parser/cxfa_value.cpp +++ b/xfa/fxfa/parser/cxfa_value.cpp @@ -75,8 +75,8 @@ CXFA_RectangleData CXFA_Value::GetRectangleData() const { return CXFA_RectangleData(GetNodeItem(XFA_NODEITEM_FirstChild)); } -CXFA_TextData CXFA_Value::GetTextData() const { - return CXFA_TextData(GetNodeItem(XFA_NODEITEM_FirstChild)); +CXFA_Text* CXFA_Value::GetText() const { + return static_cast(GetNodeItem(XFA_NODEITEM_FirstChild)); } CXFA_ExDataData CXFA_Value::GetExData() const { diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h index 0a964ff353..f510446d11 100644 --- a/xfa/fxfa/parser/cxfa_value.h +++ b/xfa/fxfa/parser/cxfa_value.h @@ -15,7 +15,7 @@ #include "xfa/fxfa/parser/cxfa_linedata.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_rectangledata.h" -#include "xfa/fxfa/parser/cxfa_textdata.h" +#include "xfa/fxfa/parser/cxfa_text.h" class CXFA_Value : public CXFA_Node { public: @@ -27,7 +27,7 @@ class CXFA_Value : public CXFA_Node { CXFA_ArcData GetArcData() const; CXFA_LineData GetLineData() const; CXFA_RectangleData GetRectangleData() const; - CXFA_TextData GetTextData() const; + CXFA_Text* GetText() const; CXFA_ExDataData GetExData() const; CXFA_ImageData GetImageData() const; }; -- cgit v1.2.3