summaryrefslogtreecommitdiff
path: root/vcl/source/filter/ipdf/pdfdocument.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-03-27 09:17:30 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-27 09:48:02 +0000
commit044e8d795276cc495c1f796a14ad36e6a5f9cdb9 (patch)
tree0d8ae233397681b8a2f366d7671abbf238e96677 /vcl/source/filter/ipdf/pdfdocument.cxx
parentbe94475414c878d1e3228da577b496985a4a6a8c (diff)
tdf#106693 vcl PDF export, norefxobj: copy array objects
So far only the dictionary and the stream of the object was copied, see if it has an array, and take care of that as well. Also check if the array contains a reference and act accordingly. Change-Id: I7f3bb12ec0bbc6f6e1db4f43625c7768b862c895 Reviewed-on: https://gerrit.libreoffice.org/35744 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/source/filter/ipdf/pdfdocument.cxx')
-rw-r--r--vcl/source/filter/ipdf/pdfdocument.cxx46
1 files changed, 42 insertions, 4 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx
index 8744729fdd83..926ebb0500fd 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -944,7 +944,10 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s
// The array is attached directly, inform the object.
pArray = pArr;
if (pObject)
+ {
pObject->SetArray(pArray);
+ pObject->SetArrayOffset(rStream.Tell());
+ }
}
rStream.SeekRel(-1);
if (!rElements.back()->Read(rStream))
@@ -959,6 +962,13 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s
rElements.push_back(std::unique_ptr<PDFElement>(new PDFEndArrayElement()));
pArray = nullptr;
rStream.SeekRel(-1);
+ if (nDictionaryDepth == 0)
+ {
+ if (pObject)
+ {
+ pObject->SetArrayLength(rStream.Tell() - pObject->GetArrayOffset());
+ }
+ }
if (!rElements.back()->Read(rStream))
{
SAL_WARN("vcl.filter", "PDFDocument::Tokenize: PDFEndArrayElement::Read() failed");
@@ -1049,7 +1059,7 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s
}
else
{
- rElements.push_back(std::unique_ptr<PDFElement>(new PDFReferenceElement(*this, pObjectNumber->GetValue(), pGenerationNumber->GetValue())));
+ rElements.push_back(std::unique_ptr<PDFElement>(new PDFReferenceElement(*this, *pObjectNumber, *pGenerationNumber)));
if (pArray)
// Reference is part of a direct (non-dictionary) array, inform the array.
pArray->PushBack(rElements.back().get());
@@ -2068,6 +2078,8 @@ PDFObjectElement::PDFObjectElement(PDFDocument& rDoc, double fObjectValue, doubl
m_nDictionaryOffset(0),
m_nDictionaryLength(0),
m_pDictionaryElement(nullptr),
+ m_nArrayOffset(0),
+ m_nArrayLength(0),
m_pArrayElement(nullptr),
m_pStreamElement(nullptr)
{
@@ -2368,6 +2380,16 @@ sal_uInt64 PDFObjectElement::GetDictionaryOffset()
return m_nDictionaryOffset;
}
+void PDFObjectElement::SetArrayOffset(sal_uInt64 nArrayOffset)
+{
+ m_nArrayOffset = nArrayOffset;
+}
+
+sal_uInt64 PDFObjectElement::GetArrayOffset()
+{
+ return m_nArrayOffset;
+}
+
void PDFDictionaryElement::SetKeyOffset(const OString& rKey, sal_uInt64 nOffset)
{
m_aDictionaryKeyOffset[rKey] = nOffset;
@@ -2414,6 +2436,16 @@ sal_uInt64 PDFObjectElement::GetDictionaryLength()
return m_nDictionaryLength;
}
+void PDFObjectElement::SetArrayLength(sal_uInt64 nArrayLength)
+{
+ m_nArrayLength = nArrayLength;
+}
+
+sal_uInt64 PDFObjectElement::GetArrayLength()
+{
+ return m_nArrayLength;
+}
+
PDFDictionaryElement* PDFObjectElement::GetDictionary() const
{
return m_pDictionaryElement;
@@ -2599,11 +2631,17 @@ PDFDocument& PDFObjectElement::GetDocument()
return m_rDoc;
}
-PDFReferenceElement::PDFReferenceElement(PDFDocument& rDoc, int fObjectValue, int fGenerationValue)
+PDFReferenceElement::PDFReferenceElement(PDFDocument& rDoc, PDFNumberElement& rObject, PDFNumberElement& rGeneration)
: m_rDoc(rDoc),
- m_fObjectValue(fObjectValue),
- m_fGenerationValue(fGenerationValue)
+ m_fObjectValue(rObject.GetValue()),
+ m_fGenerationValue(rGeneration.GetValue()),
+ m_rObject(rObject)
+{
+}
+
+PDFNumberElement& PDFReferenceElement::GetObjectElement() const
{
+ return m_rObject;
}
bool PDFReferenceElement::Read(SvStream& rStream)