[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 12 11:36:57 UTC 2020


 include/vcl/filter/pdfdocument.hxx     |    2 ++
 vcl/source/filter/ipdf/pdfdocument.cxx |   21 +++++++++------------
 2 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 11b2d63b783a90da16fb9f7291a7ac8134a4d24b
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Nov 5 23:37:30 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Nov 12 12:36:24 2020 +0100

    pdf: use a common call to parse a object
    
    Previously, only Lookup method called parsing correctly, taking
    into account that the object is in its own stream and has its
    own elements vector. Many other methods called parse with the
    wrong - document element vector. This changes the code so that
    a common method is called in all instances with the correct
    elements vector as the input parameter.
    
    Change-Id: I7092f7ce683f07065da15cfa548b06c019efeed4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105491
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 6ab5c9e99dccec23a80eb1980dc46986b8c5abca)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105637
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/vcl/filter/pdfdocument.hxx b/include/vcl/filter/pdfdocument.hxx
index 50679a9fd996..5ab6c2044ac8 100644
--- a/include/vcl/filter/pdfdocument.hxx
+++ b/include/vcl/filter/pdfdocument.hxx
@@ -114,6 +114,8 @@ class VCL_DLLPUBLIC PDFObjectElement final : public PDFElement
     /// nested dictionaries.
     std::vector<PDFReferenceElement*> m_aDictionaryReferences;
 
+    void parseIfNecessary();
+
 public:
     PDFObjectElement(PDFDocument& rDoc, double fObjectValue, double fGenerationValue);
     bool Read(SvStream& rStream) override;
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx
index 690e2daf1263..cf3a0ea430b0 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -2618,7 +2618,7 @@ PDFElement* PDFDictionaryElement::LookupElement(const OString& rDictionaryKey)
     return PDFDictionaryElement::Lookup(m_aItems, rDictionaryKey);
 }
 
-PDFElement* PDFObjectElement::Lookup(const OString& rDictionaryKey)
+void PDFObjectElement::parseIfNecessary()
 {
     if (m_aDictionary.empty())
     {
@@ -2629,7 +2629,11 @@ PDFElement* PDFObjectElement::Lookup(const OString& rDictionaryKey)
             // Normal object: elements are stored as members of the document itself.
             PDFDictionaryElement::Parse(m_rDoc.GetElements(), this, m_aDictionary);
     }
+}
 
+PDFElement* PDFObjectElement::Lookup(const OString& rDictionaryKey)
+{
+    parseIfNecessary();
     return PDFDictionaryElement::Lookup(m_aDictionary, rDictionaryKey);
 }
 
@@ -2655,9 +2659,7 @@ void PDFObjectElement::SetDictionaryOffset(sal_uInt64 nDictionaryOffset)
 
 sal_uInt64 PDFObjectElement::GetDictionaryOffset()
 {
-    if (m_aDictionary.empty())
-        PDFDictionaryElement::Parse(m_rDoc.GetElements(), this, m_aDictionary);
-
+    parseIfNecessary();
     return m_nDictionaryOffset;
 }
 
@@ -2702,9 +2704,7 @@ void PDFObjectElement::SetDictionaryLength(sal_uInt64 nDictionaryLength)
 
 sal_uInt64 PDFObjectElement::GetDictionaryLength()
 {
-    if (m_aDictionary.empty())
-        PDFDictionaryElement::Parse(m_rDoc.GetElements(), this, m_aDictionary);
-
+    parseIfNecessary();
     return m_nDictionaryLength;
 }
 
@@ -2714,8 +2714,7 @@ sal_uInt64 PDFObjectElement::GetArrayLength() const { return m_nArrayLength; }
 
 PDFDictionaryElement* PDFObjectElement::GetDictionary()
 {
-    if (m_aDictionary.empty())
-        PDFDictionaryElement::Parse(m_rDoc.GetElements(), this, m_aDictionary);
+    parseIfNecessary();
     return m_pDictionaryElement;
 }
 
@@ -2743,9 +2742,7 @@ void PDFObjectElement::AddDictionaryReference(PDFReferenceElement* pReference)
 
 const std::map<OString, PDFElement*>& PDFObjectElement::GetDictionaryItems()
 {
-    if (m_aDictionary.empty())
-        PDFDictionaryElement::Parse(m_rDoc.GetElements(), this, m_aDictionary);
-
+    parseIfNecessary();
     return m_aDictionary;
 }
 


More information about the Libreoffice-commits mailing list