summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_baannot.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-19 15:24:49 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-19 19:56:19 +0000
commitcb2ea42cc56eb6aaab3e498abf13e63742e64181 (patch)
treeb6e576eb901382cd302109e831d693f81913644a /fpdfsdk/cpdfsdk_baannot.cpp
parent67ccef73bf664b7cdb4c6eed7acbaa4163c22a80 (diff)
downloadpdfium-cb2ea42cc56eb6aaab3e498abf13e63742e64181.tar.xz
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>
Diffstat (limited to 'fpdfsdk/cpdfsdk_baannot.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_baannot.cpp51
1 files changed, 7 insertions, 44 deletions
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index 1f4f279b5e..a426749fff 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -38,6 +38,13 @@ CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const {
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 @@ bool CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const {
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) ||