poppler/Annot.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
New commits: commit e0c5c126dd25025bf3cfb39b92b0c71478ab307c Author: Albert Astals Cid <aa...@kde.org> Date: Mon Nov 22 17:10:02 2021 +0100 Rename registerResourceForWidget to make it more generic diff --git a/poppler/Annot.cc b/poppler/Annot.cc index 20586d00..1397c730 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -4949,16 +4949,14 @@ bool AnnotAppearanceBuilder::drawSignatureFieldText(const FormFieldSignature *fi return true; } -// Helper function for AnnotAppearanceBuilder::drawSignatureFieldText(). Registers a resource. -// Argument resourceType should be "XObject" or "Font". -static void registerResourceForWidget(const char *resourceType, Dict *resourcesDict, const char *resourceId, const Ref resourceRef, XRef *xref) +static void setChildDictEntryValue(Dict *parentDict, const char *childDictName, const char *childDictEntryName, const Ref childDictEntryValue, XRef *xref) { - Object childDictionaryObj = resourcesDict->lookup(resourceType); + Object childDictionaryObj = parentDict->lookup(childDictName); if (!childDictionaryObj.isDict()) { childDictionaryObj = Object(new Dict(xref)); - resourcesDict->set(resourceType, childDictionaryObj.copy()); + parentDict->set(childDictName, childDictionaryObj.copy()); } - childDictionaryObj.dictSet(resourceId, Object(resourceRef)); + childDictionaryObj.dictSet(childDictEntryName, Object(childDictEntryValue)); } void AnnotAppearanceBuilder::drawSignatureFieldText(const GooString &text, const DefaultAppearance &da, const AnnotBorder *border, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict, double leftMargin, bool centerVertically, @@ -4982,7 +4980,7 @@ void AnnotAppearanceBuilder::drawSignatureFieldText(const GooString &text, const // Print a background image. if (imageResourceRef != Ref::INVALID()) { static const char *imageResourceId = "SigImg"; - registerResourceForWidget("XObject", resourcesDict, imageResourceId, imageResourceRef, xref); + setChildDictEntryValue(resourcesDict, "XObject", imageResourceId, imageResourceRef, xref); Matrix matrix = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }; matrix.scale(width, height); commit ca9716dd9c475649a5ea4e412c3b15a6e95bdfc5 Author: Albert Astals Cid <aa...@kde.org> Date: Mon Nov 22 17:08:34 2021 +0100 registerResourceForWidget use set instead of add In case resourcesDict has a resourceType of non Dict type we want to overwrite it diff --git a/poppler/Annot.cc b/poppler/Annot.cc index f3f6a8e0..20586d00 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -4956,7 +4956,7 @@ static void registerResourceForWidget(const char *resourceType, Dict *resourcesD Object childDictionaryObj = resourcesDict->lookup(resourceType); if (!childDictionaryObj.isDict()) { childDictionaryObj = Object(new Dict(xref)); - resourcesDict->add(resourceType, childDictionaryObj.copy()); + resourcesDict->set(resourceType, childDictionaryObj.copy()); } childDictionaryObj.dictSet(resourceId, Object(resourceRef)); }