summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/cpdfsdk_baannot.cpp123
-rw-r--r--fpdfsdk/cpdfsdk_baannot.h42
2 files changed, 9 insertions, 156 deletions
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index a1578804cf..f9d1f620ac 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -91,29 +91,6 @@ bool CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) {
return !!psub;
}
-void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice,
- const CFX_Matrix* pUser2Device,
- const CPDF_RenderOptions* pOptions) {
- m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions);
-}
-
-void CPDFSDK_BAAnnot::ClearCachedAP() {
- m_pAnnot->ClearCachedAP();
-}
-
-void CPDFSDK_BAAnnot::SetContents(const WideString& sContents) {
- if (sContents.IsEmpty()) {
- m_pAnnot->GetAnnotDict()->RemoveFor("Contents");
- } else {
- m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_String>(
- "Contents", PDF_EncodeText(sContents), false);
- }
-}
-
-WideString CPDFSDK_BAAnnot::GetContents() const {
- return m_pAnnot->GetAnnotDict()->GetUnicodeTextFor("Contents");
-}
-
void CPDFSDK_BAAnnot::SetAnnotName(const WideString& sName) {
if (sName.IsEmpty()) {
m_pAnnot->GetAnnotDict()->RemoveFor("NM");
@@ -127,23 +104,6 @@ WideString CPDFSDK_BAAnnot::GetAnnotName() const {
return m_pAnnot->GetAnnotDict()->GetUnicodeTextFor("NM");
}
-void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st) {
- CPDFSDK_DateTime dt(st);
- ByteString str = dt.ToPDFDateTimeString();
- if (str.IsEmpty())
- m_pAnnot->GetAnnotDict()->RemoveFor("M");
- else
- m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_String>("M", str, false);
-}
-
-FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const {
- FX_SYSTEMTIME systime;
- ByteString str = m_pAnnot->GetAnnotDict()->GetStringFor("M");
- CPDFSDK_DateTime dt(str);
- dt.ToSystemTime(systime);
- return systime;
-}
-
void CPDFSDK_BAAnnot::SetFlags(uint32_t nFlags) {
m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Number>("F",
static_cast<int>(nFlags));
@@ -164,15 +124,6 @@ ByteString CPDFSDK_BAAnnot::GetAppState() const {
return m_pAnnot->GetAnnotDict()->GetStringFor("AS");
}
-void CPDFSDK_BAAnnot::SetStructParent(int key) {
- m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Number>("StructParent", key);
-}
-
-int CPDFSDK_BAAnnot::GetStructParent() const {
- return m_pAnnot->GetAnnotDict()->GetIntegerFor("StructParent");
-}
-
-// border
void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) {
CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border");
if (pBorder) {
@@ -250,56 +201,6 @@ BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const {
return BorderStyle::SOLID;
}
-void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) {
- CPDF_Array* pArray = m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Array>("C");
- pArray->AddNew<CPDF_Number>(static_cast<float>(FXSYS_GetRValue(color)) /
- 255.0f);
- pArray->AddNew<CPDF_Number>(static_cast<float>(FXSYS_GetGValue(color)) /
- 255.0f);
- pArray->AddNew<CPDF_Number>(static_cast<float>(FXSYS_GetBValue(color)) /
- 255.0f);
-}
-
-void CPDFSDK_BAAnnot::RemoveColor() {
- m_pAnnot->GetAnnotDict()->RemoveFor("C");
-}
-
-bool CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const {
- if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayFor("C")) {
- size_t nCount = pEntry->GetCount();
- if (nCount == 1) {
- float g = pEntry->GetNumberAt(0) * 255;
-
- color = FXSYS_RGB((int)g, (int)g, (int)g);
-
- return true;
- } else if (nCount == 3) {
- float r = pEntry->GetNumberAt(0) * 255;
- float g = pEntry->GetNumberAt(1) * 255;
- float b = pEntry->GetNumberAt(2) * 255;
-
- color = FXSYS_RGB((int)r, (int)g, (int)b);
-
- return true;
- } else if (nCount == 4) {
- float c = pEntry->GetNumberAt(0);
- float m = pEntry->GetNumberAt(1);
- float y = pEntry->GetNumberAt(2);
- float k = pEntry->GetNumberAt(3);
-
- float r = 1.0f - std::min(1.0f, c + k);
- float g = 1.0f - std::min(1.0f, m + k);
- float b = 1.0f - std::min(1.0f, y + k);
-
- color = FXSYS_RGB((int)(r * 255), (int)(g * 255), (int)(b * 255));
-
- return true;
- }
- }
-
- return false;
-}
-
bool CPDFSDK_BAAnnot::IsVisible() const {
uint32_t nFlags = GetFlags();
return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) ||
@@ -310,34 +211,10 @@ CPDF_Action CPDFSDK_BAAnnot::GetAction() const {
return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A"));
}
-void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
- CPDF_Dictionary* pDict = action.GetDict();
- if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) {
- CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- if (pDict->IsInline())
- pDict = pDoc->AddIndirectObject(pDict->Clone())->AsDictionary();
- m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Reference>("A", pDoc,
- pDict->GetObjNum());
- }
-}
-
-void CPDFSDK_BAAnnot::RemoveAction() {
- m_pAnnot->GetAnnotDict()->RemoveFor("A");
-}
-
CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA"));
}
-void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) {
- if (aa.GetDict() != m_pAnnot->GetAnnotDict()->GetDictFor("AA"))
- m_pAnnot->GetAnnotDict()->SetFor("AA", pdfium::WrapUnique(aa.GetDict()));
-}
-
-void CPDFSDK_BAAnnot::RemoveAAction() {
- m_pAnnot->GetAnnotDict()->RemoveFor("AA");
-}
-
CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) {
CPDF_AAction AAction = GetAAction();
if (AAction.ActionExist(eAAT))
diff --git a/fpdfsdk/cpdfsdk_baannot.h b/fpdfsdk/cpdfsdk_baannot.h
index ac3c0cb384..f2fdd30b64 100644
--- a/fpdfsdk/cpdfsdk_baannot.h
+++ b/fpdfsdk/cpdfsdk_baannot.h
@@ -32,68 +32,44 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
void SetRect(const CFX_FloatRect& rect) override;
CFX_FloatRect GetRect() const override;
CPDF_Annot* GetPDFAnnot() const override;
+ int GetLayoutOrder() const override;
+
+ virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
+ virtual bool IsAppearanceValid();
+ virtual bool IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
+ virtual void DrawAppearance(CFX_RenderDevice* pDevice,
+ const CFX_Matrix& mtUser2Device,
+ CPDF_Annot::AppearanceMode mode,
+ const CPDF_RenderOptions* pOptions);
CPDF_Dictionary* GetAnnotDict() const;
CPDF_Annot* GetPDFPopupAnnot() const;
CPDF_Dictionary* GetAPDict() const;
- void SetContents(const WideString& sContents);
- WideString GetContents() const;
-
void SetAnnotName(const WideString& sName);
WideString GetAnnotName() const;
- void SetModifiedDate(const FX_SYSTEMTIME& st);
- FX_SYSTEMTIME GetModifiedDate() const;
-
void SetFlags(uint32_t nFlags);
uint32_t GetFlags() const;
void SetAppState(const ByteString& str);
ByteString GetAppState() const;
- void SetStructParent(int key);
- int GetStructParent() const;
-
void SetBorderWidth(int nWidth);
int GetBorderWidth() const;
void SetBorderStyle(BorderStyle nStyle);
BorderStyle GetBorderStyle() const;
- void SetColor(FX_COLORREF color);
- void RemoveColor();
- bool GetColor(FX_COLORREF& color) const;
-
bool IsVisible() const;
CPDF_Action GetAction() const;
- void SetAction(const CPDF_Action& a);
- void RemoveAction();
CPDF_AAction GetAAction() const;
- void SetAAction(const CPDF_AAction& aa);
- void RemoveAAction();
-
- virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
- virtual bool IsAppearanceValid();
- virtual bool IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
- virtual void DrawAppearance(CFX_RenderDevice* pDevice,
- const CFX_Matrix& mtUser2Device,
- CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions);
-
- void DrawBorder(CFX_RenderDevice* pDevice,
- const CFX_Matrix* pUser2Device,
- const CPDF_RenderOptions* pOptions);
-
- void ClearCachedAP();
void SetOpenState(bool bState);
- int GetLayoutOrder() const override;
-
protected:
UnownedPtr<CPDF_Annot> const m_pAnnot;
};