diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-11-07 16:18:00 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-11-13 11:07:41 +0100 |
commit | 3262db463ce81722c6c4f10ec4bdecaa5e36011c (patch) | |
tree | b48f50ec3010aa5a5884d10684ee198e0c4fc536 /vcl | |
parent | 11b2d63b783a90da16fb9f7291a7ac8134a4d24b (diff) |
pdf: add writeString for pdf elements for writing element content
This adds a writeString virtual method to PDFElement and
subclasses and implemnts them for each element. This is used to
write the PDF object hierarchy back to a string buffer.
Change-Id: I484c9cebd8ab9149029b925a47e68b6a4fdf9be1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105492
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit fbf14b4e48c7677d5acf9a0ab91a3dc8d4ffc6fd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105778
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/ipdf/pdfdocument.cxx | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index cf3a0ea430b0..f83d1614364e 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -49,6 +49,7 @@ class PDFCommentElement : public PDFElement public: explicit PDFCommentElement(PDFDocument& rDoc); bool Read(SvStream& rStream) override; + void writeString(OStringBuffer& /*rBuffer*/) override {} }; class PDFReferenceElement; @@ -63,6 +64,8 @@ public: PDFEndDictionaryElement(); bool Read(SvStream& rStream) override; sal_uInt64 GetLocation() const; + + void writeString(OStringBuffer& /*rBuffer*/) override {} }; /// End of a stream: 'endstream' keyword. @@ -70,6 +73,8 @@ class PDFEndStreamElement : public PDFElement { public: bool Read(SvStream& rStream) override; + + void writeString(OStringBuffer& /*rBuffer*/) override {} }; /// End of an object: 'endobj' keyword. @@ -77,6 +82,8 @@ class PDFEndObjectElement : public PDFElement { public: bool Read(SvStream& rStream) override; + + void writeString(OStringBuffer& /*rBuffer*/) override {} }; /// End of an array: ']'. @@ -89,14 +96,27 @@ public: PDFEndArrayElement(); bool Read(SvStream& rStream) override; sal_uInt64 GetOffset() const; + + void writeString(OStringBuffer& /*rBuffer*/) override {} }; /// Boolean object: a 'true' or a 'false'. class PDFBooleanElement : public PDFElement { + bool m_aValue; + public: - explicit PDFBooleanElement(bool bValue); + explicit PDFBooleanElement(bool bValue) + : m_aValue(bValue) + { + } + bool Read(SvStream& rStream) override; + + void writeString(OStringBuffer& rBuffer) override + { + rBuffer.append(m_aValue ? "true" : "false"); + } }; /// Null object: the 'null' singleton. @@ -104,6 +124,8 @@ class PDFNullElement : public PDFElement { public: bool Read(SvStream& rStream) override; + + void writeString(OStringBuffer& rBuffer) override { rBuffer.append("null"); } }; /// The trailer singleton is at the end of the doc. @@ -119,6 +141,8 @@ public: bool Read(SvStream& rStream) override; PDFElement* Lookup(const OString& rDictionaryKey); sal_uInt64 GetLocation() const; + + void writeString(OStringBuffer& /*rBuffer*/) override {} }; XRefEntry::XRefEntry() = default; @@ -2212,8 +2236,6 @@ sal_uInt64 PDFNumberElement::GetLocation() const { return m_nOffset; } sal_uInt64 PDFNumberElement::GetLength() const { return m_nLength; } -PDFBooleanElement::PDFBooleanElement(bool /*bValue*/) {} - bool PDFBooleanElement::Read(SvStream& /*rStream*/) { return true; } bool PDFNullElement::Read(SvStream& /*rStream*/) { return true; } |