summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_baseannot.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-05 15:50:32 -0700
committerLei Zhang <thestig@chromium.org>2015-06-05 15:50:32 -0700
commit64adf195e2c1da338567220d3bd1b45861f79ee2 (patch)
tree4122e569026653c4dfc47d583d73024f3ee71502 /fpdfsdk/src/fsdk_baseannot.cpp
parentca7db372a6379580c0e81a7f3b123eb91eae95b8 (diff)
downloadpdfium-64adf195e2c1da338567220d3bd1b45861f79ee2.tar.xz
Merge to XFA: Cleanup: Make CPDF_Annot::m_pAnnotDict private.
Remove dead code in CPDF_Annot as well. R=tsepez@chromium.org TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1157773012 (cherry picked from commit b7eb193dcec1594952cbc1dca356a40f66724159) Review URL: https://codereview.chromium.org/1157323005
Diffstat (limited to 'fpdfsdk/src/fsdk_baseannot.cpp')
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp179
1 files changed, 50 insertions, 129 deletions
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index e80d3b8e73..9a340a1a3a 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -555,17 +555,15 @@ CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const
{
ASSERT(m_pAnnot != NULL);
- return m_pAnnot->m_pAnnotDict;
+ return m_pAnnot->GetAnnotDict();
}
void CPDFSDK_BAAnnot::SetRect(const CPDF_Rect& rect)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
ASSERT(rect.right - rect.left >= GetMinWidth());
ASSERT(rect.top - rect.bottom >= GetMinHeight());
- m_pAnnot->m_pAnnotDict->SetAtRect("Rect", rect);
+ m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect);
}
CPDF_Rect CPDFSDK_BAAnnot::GetRect() const
@@ -606,18 +604,12 @@ void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matri
FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid()
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- return m_pAnnot->m_pAnnotDict->GetDict("AP") != NULL;
+ return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL;
}
FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Dictionary* pAP = m_pAnnot->m_pAnnotDict->GetDict("AP");
+ CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
if (pAP == NULL) return FALSE;
// Choose the right sub-ap
@@ -651,63 +643,45 @@ void CPDFSDK_BAAnnot::ClearCachedAP()
void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
if (sContents.IsEmpty())
- m_pAnnot->m_pAnnotDict->RemoveAt("Contents");
+ m_pAnnot->GetAnnotDict()->RemoveAt("Contents");
else
- m_pAnnot->m_pAnnotDict->SetAtString("Contents", PDF_EncodeText(sContents));
+ m_pAnnot->GetAnnotDict()->SetAtString("Contents", PDF_EncodeText(sContents));
}
CFX_WideString CPDFSDK_BAAnnot::GetContents() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- return m_pAnnot->m_pAnnotDict->GetUnicodeText("Contents");
+ return m_pAnnot->GetAnnotDict()->GetUnicodeText("Contents");
}
void CPDFSDK_BAAnnot::SetAnnotName(const CFX_WideString& sName)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
if (sName.IsEmpty())
- m_pAnnot->m_pAnnotDict->RemoveAt("NM");
+ m_pAnnot->GetAnnotDict()->RemoveAt("NM");
else
- m_pAnnot->m_pAnnotDict->SetAtString("NM", PDF_EncodeText(sName));
+ m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName));
}
CFX_WideString CPDFSDK_BAAnnot::GetAnnotName() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- return m_pAnnot->m_pAnnotDict->GetUnicodeText("NM");
+ return m_pAnnot->GetAnnotDict()->GetUnicodeText("NM");
}
void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
CPDFSDK_DateTime dt(st);
CFX_ByteString str = dt.ToPDFDateTimeString();
if (str.IsEmpty())
- m_pAnnot->m_pAnnotDict->RemoveAt("M");
+ m_pAnnot->GetAnnotDict()->RemoveAt("M");
else
- m_pAnnot->m_pAnnotDict->SetAtString("M", str);
+ m_pAnnot->GetAnnotDict()->SetAtString("M", str);
}
FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
FX_SYSTEMTIME systime;
- CFX_ByteString str = m_pAnnot->m_pAnnotDict->GetString("M");
+ CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetString("M");
CPDFSDK_DateTime dt(str);
dt.ToSystemTime(systime);
@@ -717,62 +691,41 @@ FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const
void CPDFSDK_BAAnnot::SetFlags(int nFlags)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- m_pAnnot->m_pAnnotDict->SetAtInteger("F", nFlags);
+ m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags);
}
int CPDFSDK_BAAnnot::GetFlags() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- return m_pAnnot->m_pAnnotDict->GetInteger("F");
+ return m_pAnnot->GetAnnotDict()->GetInteger("F");
}
void CPDFSDK_BAAnnot::SetAppState(const CFX_ByteString& str)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
if (str.IsEmpty())
- m_pAnnot->m_pAnnotDict->RemoveAt("AS");
+ m_pAnnot->GetAnnotDict()->RemoveAt("AS");
else
- m_pAnnot->m_pAnnotDict->SetAtString("AS", str);
+ m_pAnnot->GetAnnotDict()->SetAtString("AS", str);
}
CFX_ByteString CPDFSDK_BAAnnot::GetAppState() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- return m_pAnnot->m_pAnnotDict->GetString("AS");
+ return m_pAnnot->GetAnnotDict()->GetString("AS");
}
void CPDFSDK_BAAnnot::SetStructParent(int key)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- m_pAnnot->m_pAnnotDict->SetAtInteger("StructParent", key);
+ m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key);
}
int CPDFSDK_BAAnnot::GetStructParent() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- return m_pAnnot->m_pAnnotDict->GetInteger("StructParent");
+ return m_pAnnot->GetAnnotDict()->GetInteger("StructParent");
}
//border
void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Array* pBorder = m_pAnnot->m_pAnnotDict->GetArray("Border");
+ CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
if (pBorder)
{
@@ -780,12 +733,12 @@ void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth)
}
else
{
- CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS");
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (!pBSDict)
{
pBSDict = FX_NEW CPDF_Dictionary;
- m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict);
+ m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
}
pBSDict->SetAtInteger("W", nWidth);
@@ -794,10 +747,7 @@ void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth)
int CPDFSDK_BAAnnot::GetBorderWidth() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Array* pBorder = m_pAnnot->m_pAnnotDict->GetArray("Border");
+ CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
if (pBorder)
{
@@ -805,7 +755,7 @@ int CPDFSDK_BAAnnot::GetBorderWidth() const
}
else
{
- CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS");
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (pBSDict)
{
@@ -817,14 +767,11 @@ int CPDFSDK_BAAnnot::GetBorderWidth() const
void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS");
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (!pBSDict)
{
- pBSDict = FX_NEW CPDF_Dictionary;
- m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict);
+ pBSDict = new CPDF_Dictionary;
+ m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
}
switch (nStyle)
@@ -849,10 +796,7 @@ void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle)
int CPDFSDK_BAAnnot::GetBorderStyle() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS");
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (pBSDict)
{
CFX_ByteString sBorderStyle = pBSDict->GetString("S", "S");
@@ -863,7 +807,7 @@ int CPDFSDK_BAAnnot::GetBorderStyle() const
if (sBorderStyle == "U") return BBS_UNDERLINE;
}
- CPDF_Array* pBorder = m_pAnnot->m_pAnnotDict->GetArray("Border");
+ CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
if (pBorder)
{
if (pBorder->GetCount() >= 4)
@@ -879,14 +823,11 @@ int CPDFSDK_BAAnnot::GetBorderStyle() const
void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS");
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (!pBSDict)
{
- pBSDict = FX_NEW CPDF_Dictionary;
- m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict);
+ pBSDict = new CPDF_Dictionary;
+ m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
}
CPDF_Array* pArray = FX_NEW CPDF_Array;
@@ -900,19 +841,16 @@ void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array)
void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
CPDF_Array* pDash = NULL;
- CPDF_Array* pBorder = m_pAnnot->m_pAnnotDict->GetArray("Border");
+ CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
if (pBorder)
{
pDash = pBorder->GetArray(3);
}
else
{
- CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS");
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (pBSDict)
{
pDash = pBSDict->GetArray("D");
@@ -930,30 +868,21 @@ void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const
void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Array* pArray = FX_NEW CPDF_Array;
+ CPDF_Array* pArray = new CPDF_Array;
pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f);
pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f);
pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f);
- m_pAnnot->m_pAnnotDict->SetAt("C", pArray);
+ m_pAnnot->GetAnnotDict()->SetAt("C", pArray);
}
void CPDFSDK_BAAnnot::RemoveColor()
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- m_pAnnot->m_pAnnotDict->RemoveAt("C") ;
+ m_pAnnot->GetAnnotDict()->RemoveAt("C");
}
FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- if (CPDF_Array* pEntry = m_pAnnot->m_pAnnotDict->GetArray("C"))
+ if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArray("C"))
{
int nCount = pEntry->GetCount();
if (nCount == 1)
@@ -999,15 +928,12 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_
const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
const CFX_ByteString& sAPState)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP");
+ CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
if (!pAPDict)
{
- pAPDict = FX_NEW CPDF_Dictionary;
- m_pAnnot->m_pAnnotDict->SetAt("AP", pAPDict);
+ pAPDict = new CPDF_Dictionary;
+ m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
}
CPDF_Stream* pStream = NULL;
@@ -1089,49 +1015,44 @@ FX_BOOL CPDFSDK_BAAnnot::IsVisible() const
CPDF_Action CPDFSDK_BAAnnot::GetAction() const
{
- return CPDF_Action(m_pAnnot->m_pAnnotDict->GetDict("A"));
+ return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A"));
}
void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action)
{
ASSERT(action);
- if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->m_pAnnotDict->GetDict("A")))
+ if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A")))
{
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
CPDF_Dictionary* pDict = action.GetDict();
if (pDict && pDict->GetObjNum() == 0) {
pDoc->AddIndirectObject(pDict);
}
- m_pAnnot->m_pAnnotDict->SetAtReference("A", pDoc, pDict->GetObjNum());
+ m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetObjNum());
}
}
void CPDFSDK_BAAnnot::RemoveAction()
{
- m_pAnnot->m_pAnnotDict->RemoveAt("A");
+ m_pAnnot->GetAnnotDict()->RemoveAt("A");
}
CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const
{
- return m_pAnnot->m_pAnnotDict->GetDict("AA");
+ return m_pAnnot->GetAnnotDict()->GetDict("AA");
}
void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
ASSERT(aa != NULL);
- if ((CPDF_AAction&)aa != m_pAnnot->m_pAnnotDict->GetDict("AA"))
- m_pAnnot->m_pAnnotDict->SetAt("AA", (CPDF_AAction&)aa);
+ if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA"))
+ m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
}
void CPDFSDK_BAAnnot::RemoveAAction()
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- m_pAnnot->m_pAnnotDict->RemoveAt("AA");
+ m_pAnnot->GetAnnotDict()->RemoveAt("AA");
}
CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT)