Create CPWL_AppStream.
This CL creates a CPWL_AppStream and consolidates app stream generation
code from CPDFSDK_Widget, CPDFSDK_BAAnnot and CPWL_Utils. The remaining
app stream code from CPWL_Utils will be cleaned up in a future CL.
Change-Id: I20cfdec09a351bd509241d2c667a182fba84b0c1
Reviewed-on: https://pdfium-review.googlesource.com/8310
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index 1f4f279..a426749 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -38,6 +38,13 @@
return m_pAnnot->GetAnnotDict();
}
+CPDF_Dictionary* CPDFSDK_BAAnnot::GetAPDict() const {
+ CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP");
+ if (!pAPDict)
+ pAPDict = m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Dictionary>("AP");
+ return pAPDict;
+}
+
void CPDFSDK_BAAnnot::SetRect(const CFX_FloatRect& rect) {
ASSERT(rect.right - rect.left >= GetMinWidth());
ASSERT(rect.top - rect.bottom >= GetMinHeight());
@@ -293,50 +300,6 @@
return false;
}
-void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
- const CFX_FloatRect& rcBBox,
- const CFX_Matrix& matrix,
- const CFX_ByteString& sContents,
- const CFX_ByteString& sAPState) {
- CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP");
- if (!pAPDict)
- pAPDict = m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Dictionary>("AP");
-
- CPDF_Stream* pStream = nullptr;
- CPDF_Dictionary* pParentDict = nullptr;
- if (sAPState.IsEmpty()) {
- pParentDict = pAPDict;
- pStream = pAPDict->GetStreamFor(sAPType);
- } else {
- CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictFor(sAPType);
- if (!pAPTypeDict)
- pAPTypeDict = pAPDict->SetNewFor<CPDF_Dictionary>(sAPType);
-
- pParentDict = pAPTypeDict;
- pStream = pAPTypeDict->GetStreamFor(sAPState);
- }
-
- if (!pStream) {
- CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- pStream = pDoc->NewIndirect<CPDF_Stream>();
- pParentDict->SetNewFor<CPDF_Reference>(sAPType, pDoc, pStream->GetObjNum());
- }
-
- CPDF_Dictionary* pStreamDict = pStream->GetDict();
- if (!pStreamDict) {
- auto pNewDict = pdfium::MakeUnique<CPDF_Dictionary>(
- m_pAnnot->GetDocument()->GetByteStringPool());
- pStreamDict = pNewDict.get();
- pStreamDict->SetNewFor<CPDF_Name>("Type", "XObject");
- pStreamDict->SetNewFor<CPDF_Name>("Subtype", "Form");
- pStreamDict->SetNewFor<CPDF_Number>("FormType", 1);
- pStream->InitStream(nullptr, 0, std::move(pNewDict));
- }
- pStreamDict->SetMatrixFor("Matrix", matrix);
- pStreamDict->SetRectFor("BBox", rcBBox);
- pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength());
-}
-
bool CPDFSDK_BAAnnot::IsVisible() const {
uint32_t nFlags = GetFlags();
return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) ||