summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-09 15:03:33 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-09 22:24:52 +0000
commit8a6fdadccd2eedf332ae3a72f0149c1b40cb5bd9 (patch)
tree307288716efc81c5b3d5d0e05c380cdd10add95a /fpdfsdk
parent392cfd62f6fd6fc505b644b67938ea30131eb837 (diff)
downloadpdfium-8a6fdadccd2eedf332ae3a72f0149c1b40cb5bd9.tar.xz
Create common CXML_Object base class for CXML_Content and CXML_Element.
They should each know what they are rather than having an external ChildRecord struct to track the type. Change-Id: Ic647ba45569764073e944d30af1a96dccdc29eb3 Reviewed-on: https://pdfium-review.googlesource.com/5210 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_ext.cpp19
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.cpp34
2 files changed, 25 insertions, 28 deletions
diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp
index 8773d680ea..f598835e3c 100644
--- a/fpdfsdk/fpdf_ext.cpp
+++ b/fpdfsdk/fpdf_ext.cpp
@@ -16,6 +16,7 @@
#include "core/fpdfdoc/cpdf_metadata.h"
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_memory.h"
+#include "core/fxcrt/xml/cxml_content.h"
#include "core/fxcrt/xml/cxml_element.h"
#include "fpdfsdk/fsdk_define.h"
#include "third_party/base/ptr_util.h"
@@ -86,12 +87,13 @@ bool CheckSharedForm(const CXML_Element* pElement, CFX_ByteString cbName) {
if (space == "xmlns" && name == "adhocwf" &&
value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") {
CXML_Element* pVersion =
- pElement->GetElement("adhocwf", cbName.AsStringC());
+ pElement->GetElement("adhocwf", cbName.AsStringC(), 0);
if (!pVersion)
continue;
- CFX_WideString wsContent = pVersion->GetContent(0);
- int nType = wsContent.GetInteger();
- switch (nType) {
+ CXML_Content* pContent = ToContent(pVersion->GetChild(0));
+ if (!pContent)
+ continue;
+ switch (pContent->m_Content.GetInteger()) {
case 1:
FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACROBAT);
break;
@@ -107,12 +109,9 @@ bool CheckSharedForm(const CXML_Element* pElement, CFX_ByteString cbName) {
uint32_t nCount = pElement->CountChildren();
for (i = 0; i < (int)nCount; i++) {
- CXML_Element::ChildType childType = pElement->GetChildType(i);
- if (childType == CXML_Element::Element) {
- CXML_Element* pChild = pElement->GetElement(i);
- if (CheckSharedForm(pChild, cbName))
- return true;
- }
+ CXML_Element* pChild = ToElement(pElement->GetChild(i));
+ if (pChild && CheckSharedForm(pChild, cbName))
+ return true;
}
return false;
}
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp
index b1285a8428..90572746da 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfdoc/cpvt_word.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/xml/cxml_content.h"
#include "core/fxcrt/xml/cxml_element.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_pathdata.h"
@@ -55,30 +56,27 @@ void CPWL_Edit::SetText(const CFX_WideString& csText) {
m_pEdit->SetText(swText);
return;
}
-
- int32_t nCount = pXML->CountChildren();
- bool bFirst = true;
-
swText.clear();
+ bool bFirst = true;
+ int32_t nCount = pXML->CountChildren();
for (int32_t i = 0; i < nCount; i++) {
- CXML_Element* pSubElement = pXML->GetElement(i);
- if (!pSubElement)
+ CXML_Element* pSubElement = ToElement(pXML->GetChild(i));
+ if (!pSubElement || !pSubElement->GetTagName().EqualNoCase("p"))
continue;
- CFX_ByteString tag = pSubElement->GetTagName();
- if (tag.EqualNoCase("p")) {
- int nChild = pSubElement->CountChildren();
- CFX_WideString swSection;
- for (int32_t j = 0; j < nChild; j++)
- swSection += pSubElement->GetContent(j);
-
- if (bFirst)
- bFirst = false;
- else
- swText += FWL_VKEY_Return;
- swText += swSection;
+ CFX_WideString swSection;
+ int nSubChild = pSubElement->CountChildren();
+ for (int32_t j = 0; j < nSubChild; j++) {
+ CXML_Content* pSubContent = ToContent(pSubElement->GetChild(j));
+ if (pSubContent)
+ swSection += pSubContent->m_Content;
}
+ if (bFirst)
+ bFirst = false;
+ else
+ swText += FWL_VKEY_Return;
+ swText += swSection;
}
m_pEdit->SetText(swText);