summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp9
-rw-r--r--fpdfsdk/fsdk_annothandler.cpp14
-rw-r--r--xfa/fde/xml/cfx_saxreader.h4
-rw-r--r--xfa/fxfa/app/xfa_checksum.cpp86
-rw-r--r--xfa/fxfa/include/xfa_checksum.h18
-rw-r--r--xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp11
6 files changed, 70 insertions, 72 deletions
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index 9d8fb42059..c8aca0d5b0 100644
--- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -677,8 +677,8 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
continue;
if (!pPDFObj->IsReference())
continue;
- CPDF_Object* pDirectObj = pPDFObj->GetDirect();
- if (!pDirectObj->IsStream())
+ CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect());
+ if (!pStream)
continue;
if (pPrePDFObj->GetString() == "form") {
m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, &fileWrite,
@@ -698,13 +698,10 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
content.GetLength());
}
-
- CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj;
- CPDF_StreamAcc* pAcc = new CPDF_StreamAcc;
+ std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc);
pAcc->LoadAllData(pStream);
fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(),
pAcc->GetSize());
- delete pAcc;
}
}
}
diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp
index ded04c9371..c3bc1953f1 100644
--- a/fpdfsdk/fsdk_annothandler.cpp
+++ b/fpdfsdk/fsdk_annothandler.cpp
@@ -97,7 +97,7 @@ void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
pAnnotHandler->OnRelease(pAnnot);
pAnnotHandler->ReleaseAnnot(pAnnot);
} else {
- delete (CPDFSDK_Annot*)pAnnot;
+ delete pAnnot;
}
}
@@ -402,7 +402,7 @@ FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
if (pAnnot->GetSubType() == BFFT_SIGNATURE)
return FALSE;
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
if (!pWidget->IsVisible())
return FALSE;
@@ -451,12 +451,10 @@ void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
if (m_pFormFiller)
m_pFormFiller->OnDelete(pAnnot);
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ std::unique_ptr<CPDFSDK_Widget> pWidget(static_cast<CPDFSDK_Widget*>(pAnnot));
CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
- CPDF_FormControl* pCtrol = pWidget->GetFormControl();
- pInterForm->RemoveMap(pCtrol);
-
- delete pWidget;
+ CPDF_FormControl* pControl = pWidget->GetFormControl();
+ pInterForm->RemoveMap(pControl);
}
void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
@@ -651,7 +649,7 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
if (pAnnot->GetSubType() == BFFT_SIGNATURE)
return;
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
if (!pWidget->IsAppearanceValid())
pWidget->ResetAppearance(nullptr, FALSE);
diff --git a/xfa/fde/xml/cfx_saxreader.h b/xfa/fde/xml/cfx_saxreader.h
index 18aa039ccc..e602c3d9e2 100644
--- a/xfa/fde/xml/cfx_saxreader.h
+++ b/xfa/fde/xml/cfx_saxreader.h
@@ -9,6 +9,8 @@
#include "core/fxcrt/include/fx_basic.h"
+class CXFA_SAXContext;
+
class CFX_SAXItem {
public:
enum class Type {
@@ -29,7 +31,7 @@ class CFX_SAXItem {
m_pPrev(nullptr),
m_pNext(nullptr) {}
- void* m_pNode;
+ CXFA_SAXContext* m_pNode;
Type m_eNode;
uint32_t m_dwID;
FX_BOOL m_bSkip;
diff --git a/xfa/fxfa/app/xfa_checksum.cpp b/xfa/fxfa/app/xfa_checksum.cpp
index b279dc9596..9313ad7ea2 100644
--- a/xfa/fxfa/app/xfa_checksum.cpp
+++ b/xfa/fxfa/app/xfa_checksum.cpp
@@ -96,9 +96,10 @@ CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext)
ASSERT(m_pContext);
}
CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {}
-void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName,
- CFX_SAXItem::Type eType,
- uint32_t dwStartPos) {
+CXFA_SAXContext* CXFA_SAXReaderHandler::OnTagEnter(
+ const CFX_ByteStringC& bsTagName,
+ CFX_SAXItem::Type eType,
+ uint32_t dwStartPos) {
UpdateChecksum(TRUE);
if (eType != CFX_SAXItem::Type::Tag &&
eType != CFX_SAXItem::Type::Instruction) {
@@ -114,78 +115,79 @@ void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName,
m_SAXContext.m_bsTagName = bsTagName;
return &m_SAXContext;
}
-void CXFA_SAXReaderHandler::OnTagAttribute(void* pTag,
+
+void CXFA_SAXReaderHandler::OnTagAttribute(CXFA_SAXContext* pTag,
const CFX_ByteStringC& bsAttri,
const CFX_ByteStringC& bsValue) {
- if (pTag == NULL) {
+ if (!pTag)
return;
- }
- CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf;
- textBuf << " " << bsAttri << "=\"" << bsValue << "\"";
+
+ pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\"";
}
-void CXFA_SAXReaderHandler::OnTagBreak(void* pTag) {
- if (pTag == NULL) {
+
+void CXFA_SAXReaderHandler::OnTagBreak(CXFA_SAXContext* pTag) {
+ if (!pTag)
return;
- }
- CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf;
- textBuf << ">";
+
+ pTag->m_TextBuf << ">";
UpdateChecksum(FALSE);
}
-void CXFA_SAXReaderHandler::OnTagData(void* pTag,
+
+void CXFA_SAXReaderHandler::OnTagData(CXFA_SAXContext* pTag,
CFX_SAXItem::Type eType,
const CFX_ByteStringC& bsData,
uint32_t dwStartPos) {
- if (pTag == NULL) {
+ if (!pTag)
return;
- }
- CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf;
- if (eType == CFX_SAXItem::Type::CharData) {
+
+ CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
+ if (eType == CFX_SAXItem::Type::CharData)
textBuf << "<![CDATA[";
- }
+
textBuf << bsData;
- if (eType == CFX_SAXItem::Type::CharData) {
+ if (eType == CFX_SAXItem::Type::CharData)
textBuf << "]]>";
- }
}
-void CXFA_SAXReaderHandler::OnTagClose(void* pTag, uint32_t dwEndPos) {
- if (pTag == NULL) {
+
+void CXFA_SAXReaderHandler::OnTagClose(CXFA_SAXContext* pTag,
+ uint32_t dwEndPos) {
+ if (!pTag)
return;
- }
- CXFA_SAXContext* pSAXContext = (CXFA_SAXContext*)pTag;
- CFX_ByteTextBuf& textBuf = pSAXContext->m_TextBuf;
- if (pSAXContext->m_eNode == CFX_SAXItem::Type::Instruction) {
+
+ CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
+ if (pTag->m_eNode == CFX_SAXItem::Type::Instruction)
textBuf << "?>";
- } else if (pSAXContext->m_eNode == CFX_SAXItem::Type::Tag) {
- textBuf << "></" << pSAXContext->m_bsTagName.AsStringC() << ">";
- }
+ else if (pTag->m_eNode == CFX_SAXItem::Type::Tag)
+ textBuf << "></" << pTag->m_bsTagName.AsStringC() << ">";
+
UpdateChecksum(FALSE);
}
-void CXFA_SAXReaderHandler::OnTagEnd(void* pTag,
+
+void CXFA_SAXReaderHandler::OnTagEnd(CXFA_SAXContext* pTag,
const CFX_ByteStringC& bsTagName,
uint32_t dwEndPos) {
- if (pTag == NULL) {
+ if (!pTag)
return;
- }
- CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf;
- textBuf << "</" << bsTagName << ">";
+
+ pTag->m_TextBuf << "</" << bsTagName << ">";
UpdateChecksum(FALSE);
}
-void CXFA_SAXReaderHandler::OnTargetData(void* pTag,
+
+void CXFA_SAXReaderHandler::OnTargetData(CXFA_SAXContext* pTag,
CFX_SAXItem::Type eType,
const CFX_ByteStringC& bsData,
uint32_t dwStartPos) {
- if (pTag == NULL && eType != CFX_SAXItem::Type::Comment) {
+ if (!pTag && eType != CFX_SAXItem::Type::Comment)
return;
- }
+
if (eType == CFX_SAXItem::Type::Comment) {
- CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf;
- textBuf << "<!--" << bsData << "-->";
+ m_SAXContext.m_TextBuf << "<!--" << bsData << "-->";
UpdateChecksum(FALSE);
} else {
- CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf;
- textBuf << " " << bsData;
+ pTag->m_TextBuf << " " << bsData;
}
}
+
void CXFA_SAXReaderHandler::UpdateChecksum(FX_BOOL bCheckSpace) {
int32_t iLength = m_SAXContext.m_TextBuf.GetLength();
if (iLength < 1) {
diff --git a/xfa/fxfa/include/xfa_checksum.h b/xfa/fxfa/include/xfa_checksum.h
index a5e5592cec..e959a8053a 100644
--- a/xfa/fxfa/include/xfa_checksum.h
+++ b/xfa/fxfa/include/xfa_checksum.h
@@ -27,23 +27,23 @@ class CXFA_SAXReaderHandler {
CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext);
~CXFA_SAXReaderHandler();
- void* OnTagEnter(const CFX_ByteStringC& bsTagName,
- CFX_SAXItem::Type eType,
- uint32_t dwStartPos);
- void OnTagAttribute(void* pTag,
+ CXFA_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName,
+ CFX_SAXItem::Type eType,
+ uint32_t dwStartPos);
+ void OnTagAttribute(CXFA_SAXContext* pTag,
const CFX_ByteStringC& bsAttri,
const CFX_ByteStringC& bsValue);
- void OnTagBreak(void* pTag);
- void OnTagData(void* pTag,
+ void OnTagBreak(CXFA_SAXContext* pTag);
+ void OnTagData(CXFA_SAXContext* pTag,
CFX_SAXItem::Type eType,
const CFX_ByteStringC& bsData,
uint32_t dwStartPos);
- void OnTagClose(void* pTag, uint32_t dwEndPos);
- void OnTagEnd(void* pTag,
+ void OnTagClose(CXFA_SAXContext* pTag, uint32_t dwEndPos);
+ void OnTagEnd(CXFA_SAXContext* pTag,
const CFX_ByteStringC& bsTagName,
uint32_t dwEndPos);
- void OnTargetData(void* pTag,
+ void OnTargetData(CXFA_SAXContext* pTag,
CFX_SAXItem::Type eType,
const CFX_ByteStringC& bsData,
uint32_t dwStartPos);
diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
index bac3c18514..67416f2166 100644
--- a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
@@ -242,7 +242,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray(
if (!bOnPageArea) {
CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
CXFA_TraverseStrategy_ContentLayoutItem>
- iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild);
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem->m_pFirstChild));
for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
pItemChild; pItemChild = iterator.MoveToNext()) {
if (!pItemChild->IsContentLayoutItem()) {
@@ -266,7 +266,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray(
if (bOnPageArea) {
CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
CXFA_TraverseStrategy_ContentLayoutItem>
- iterator((CXFA_ContentLayoutItem*)pItem);
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem));
for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
pItemChild; pItemChild = iterator.MoveToNext()) {
if (!pItemChild->IsContentLayoutItem()) {
@@ -306,7 +306,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray(
if (!bOnPageArea) {
CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
CXFA_TraverseStrategy_ContentLayoutItem>
- iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild);
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem->m_pFirstChild));
for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
pItemChild; pItemChild = iterator.MoveToNext()) {
if (!pItemChild->IsContentLayoutItem())
@@ -323,7 +323,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray(
if (bOnPageArea) {
CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
CXFA_TraverseStrategy_ContentLayoutItem>
- iterator((CXFA_ContentLayoutItem*)pItem);
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem));
for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
pItemChild; pItemChild = iterator.MoveToNext()) {
if (!pItemChild->IsContentLayoutItem())
@@ -375,8 +375,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent(
CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument);
pArrayNodeList->SetArrayNodeList(retArray);
pArguments->GetReturnValue()->SetObject(
- (CXFA_Object*)pArrayNodeList,
- m_pDocument->GetScriptContext()->GetJseNormalClass());
+ pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass());
}
void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount(
CFXJSE_Arguments* pArguments) {