summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_editpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdf_editpage.cpp')
-rw-r--r--fpdfsdk/fpdf_editpage.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index dbf9124030..3abdcdf0fc 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -133,6 +133,13 @@ CPDF_Dictionary* GetOrCreateMarkParamsDict(FPDF_DOCUMENT document,
return pParams;
}
+bool PageObjectContainsMark(CPDF_PageObject* pPageObj,
+ FPDF_PAGEOBJECTMARK mark) {
+ const CPDF_ContentMarkItem* pMarkItem =
+ CPDFContentMarkItemFromFPDFPageObjectMark(mark);
+ return pMarkItem && pPageObj->m_ContentMark.ContainsItem(pMarkItem);
+}
+
unsigned int GetUnsignedAlpha(float alpha) {
return static_cast<unsigned int>(alpha * 255.f + 0.5f);
}
@@ -484,36 +491,53 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObjMark_SetIntParam(FPDF_DOCUMENT document,
+ FPDF_PAGEOBJECT page_object,
FPDF_PAGEOBJECTMARK mark,
FPDF_BYTESTRING key,
int value) {
+ CPDF_PageObject* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
+ if (!pPageObj || !PageObjectContainsMark(pPageObj, mark))
+ return false;
+
CPDF_Dictionary* pParams = GetOrCreateMarkParamsDict(document, mark);
if (!pParams)
return false;
pParams->SetNewFor<CPDF_Number>(key, value);
+ pPageObj->SetDirty(true);
return true;
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObjMark_SetStringParam(FPDF_DOCUMENT document,
+ FPDF_PAGEOBJECT page_object,
FPDF_PAGEOBJECTMARK mark,
FPDF_BYTESTRING key,
FPDF_BYTESTRING value) {
+ CPDF_PageObject* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
+ if (!pPageObj || !PageObjectContainsMark(pPageObj, mark))
+ return false;
+
CPDF_Dictionary* pParams = GetOrCreateMarkParamsDict(document, mark);
if (!pParams)
return false;
pParams->SetNewFor<CPDF_String>(key, value, false);
+ pPageObj->SetDirty(true);
return true;
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObjMark_SetBlobParam(FPDF_DOCUMENT document,
+ FPDF_PAGEOBJECT page_object,
FPDF_PAGEOBJECTMARK mark,
FPDF_BYTESTRING key,
void* value,
unsigned long value_len) {
+ CPDF_PageObject* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
+ if (!pPageObj || !PageObjectContainsMark(pPageObj, mark))
+ return false;
+
CPDF_Dictionary* pParams = GetOrCreateMarkParamsDict(document, mark);
if (!pParams)
return false;
@@ -523,6 +547,7 @@ FPDFPageObjMark_SetBlobParam(FPDF_DOCUMENT document,
pParams->SetNewFor<CPDF_String>(
key, ByteString(static_cast<const char*>(value), value_len), true);
+ pPageObj->SetDirty(true);
return true;
}