summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-11-02 16:34:56 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2023-11-03 13:41:08 +0100
commit822a0c4fcd4607d5247b828c69728a510684a442 (patch)
treeb86dbb2877566d4b83a7b3a3b4d9cf11f4791c31
parent3d15de525534197960e9a9c64eba3ad2153aa113 (diff)
tdf#157028 vcl: PDF export: inline OBJR dictionaries
There seems to be no reason why SE child OBJR dictionaries are separate objects, they could just be inline. Change-Id: I9e4fcdf56d9b7454325f9d3ef7ba55bdc090f948 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158838 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
-rw-r--r--vcl/inc/pdf/pdfwriter_impl.hxx14
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx90
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport2.cxx72
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx53
4 files changed, 108 insertions, 121 deletions
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 23ba7c7baed5..ae8754e6cc1a 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -29,6 +29,7 @@
#include <string_view>
#include <vector>
#include <stack>
+#include <variant>
#include <pdf/ResourceDict.hxx>
#include <pdf/BitmapID.hxx>
@@ -566,15 +567,10 @@ struct PDFStructureAttribute
{}
};
-struct PDFStructureElementKid // for Kids entries
-{
- sal_Int32 const nObject; // an object number if nMCID is -1,
- // else the page object relevant to MCID
- sal_Int32 const nMCID; // an MCID if >= 0
-
- explicit PDFStructureElementKid( sal_Int32 nObj ) : nObject( nObj ), nMCID( -1 ) {}
- PDFStructureElementKid( sal_Int32 MCID, sal_Int32 nPage ) : nObject( nPage ), nMCID( MCID ) {}
-};
+struct ObjReference { sal_Int32 const nObject; };
+struct ObjReferenceObj { sal_Int32 const nObject; };
+struct MCIDReference { sal_Int32 const nPageObj; sal_Int32 const nMCID; };
+typedef ::std::variant<ObjReference, ObjReferenceObj, MCIDReference> PDFStructureElementKid;
struct PDFStructureElement
{
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 9db3cf63f187..ef317e600ca5 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2064,19 +2064,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2129,19 +2129,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2193,19 +2193,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2257,19 +2257,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2321,19 +2321,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2448,19 +2448,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2513,19 +2513,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2600,19 +2600,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2665,19 +2665,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index bfdd1ae8ea31..f7f2557f0594 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -2346,7 +2346,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testSpans)
auto nRef(0);
for (size_t i = 0; i < vKids102101.size(); ++i)
{
- auto pKid = dynamic_cast<vcl::filter::PDFReferenceElement*>(vKids102101[i]);
+ auto pKid = dynamic_cast<vcl::filter::PDFDictionaryElement*>(vKids102101[i]);
if (pKid)
{
++nRef; // annotation
@@ -2815,19 +2815,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2886,19 +2886,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2959,19 +2959,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -3039,19 +3039,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
auto pAnnotRef
- = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
auto pAnnot = pAnnotRef->LookupObject();
auto pAType = dynamic_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"));
CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -3534,18 +3534,18 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testMediaShapeAnnot)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
- auto pAnnotRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ auto pAnnotRef
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
CPPUNIT_ASSERT_EQUAL(pAnnot, pAnnotRef->LookupObject());
}
}
@@ -3651,18 +3651,18 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFlyFrameHyperlinkAnnot)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
- auto pAnnotRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ auto pAnnotRef
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
CPPUNIT_ASSERT_EQUAL(pAnnot, pAnnotRef->LookupObject());
}
}
@@ -3795,18 +3795,18 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFormControlAnnot)
for (size_t i = 0; i < pKids->GetElements().size(); ++i)
{
auto pNum = dynamic_cast<vcl::filter::PDFNumberElement*>(pKids->GetElement(i));
- auto pRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKids->GetElement(i));
+ auto pObjR = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pKids->GetElement(i));
if (pNum)
{
++nMCID;
}
- if (pRef)
+ if (pObjR)
{
++nRef;
- auto pObjR = pRef->LookupObject();
- auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->Lookup("Type"));
+ auto pOType = dynamic_cast<vcl::filter::PDFNameElement*>(pObjR->LookupElement("Type"));
CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
- auto pAnnotRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->Lookup("Obj"));
+ auto pAnnotRef
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObjR->LookupElement("Obj"));
CPPUNIT_ASSERT_EQUAL(pAnnot, pAnnotRef->LookupObject());
}
}
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 15eafe302953..e8b9cf7a777c 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1988,21 +1988,7 @@ void PDFWriterImpl::AppendAnnotKid(PDFStructureElement& i_rEle, T & rAnnot)
m_aStructParentTree.push_back( aStructParentEntry );
rAnnot.m_nStructParent = m_aStructParentTree.size()-1;
sal_Int32 const nAnnotObj(rAnnot.m_nObject);
-
- sal_Int32 const nRefObject = createObject();
- if (updateObject(nRefObject))
- {
- OString aRef =
- OString::number( nRefObject ) +
- " 0 obj\n"
- "<</Type/OBJR/Obj " +
- OString::number(nAnnotObj) +
- " 0 R>>\n"
- "endobj\n\n";
- writeBuffer( aRef );
- }
-
- i_rEle.m_aKids.emplace_back( nRefObject );
+ i_rEle.m_aKids.emplace_back(ObjReferenceObj{nAnnotObj});
}
OString PDFWriterImpl::emitStructureAttributes( PDFStructureElement& i_rEle )
@@ -2257,29 +2243,34 @@ sal_Int32 PDFWriterImpl::emitStructure( PDFStructureElement& rEle )
{
unsigned int i = 0;
aLine.append( "/K[" );
- for (auto const& kid : rEle.m_aKids)
+ for (auto const& rKid : rEle.m_aKids)
{
- if( kid.nMCID == -1 )
+ if (std::holds_alternative<ObjReference>(rKid))
{
- aLine.append(
- OString::number(kid.nObject)
- + " 0 R" );
+ ObjReference const& rObj(std::get<ObjReference>(rKid));
+ appendObjectReference(rObj.nObject, aLine);
aLine.append( ( (i & 15) == 15 ) ? "\n" : " " );
}
+ else if (std::holds_alternative<ObjReferenceObj>(rKid))
+ {
+ ObjReferenceObj const& rObj(std::get<ObjReferenceObj>(rKid));
+ aLine.append("<</Type/OBJR/Obj ");
+ appendObjectReference(rObj.nObject, aLine);
+ aLine.append(">>\n");
+ }
else
{
- if( kid.nObject == rEle.m_nFirstPageObject )
+ assert(std::holds_alternative<MCIDReference>(rKid));
+ MCIDReference const& rMCID(std::get<MCIDReference>(rKid));
+ if (rMCID.nPageObj == rEle.m_nFirstPageObject)
{
- aLine.append( OString::number(kid.nMCID) + " " );
+ aLine.append(OString::number(rMCID.nMCID) + " ");
}
else
{
- aLine.append(
- "<</Type/MCR/Pg "
- + OString::number(kid.nObject)
- + " 0 R /MCID "
- + OString::number(kid.nMCID)
- + ">>\n" );
+ aLine.append("<</Type/MCR/Pg ");
+ appendObjectReference(rMCID.nPageObj, aLine);
+ aLine.append(" /MCID " + OString::number(rMCID.nMCID) + ">>\n");
}
}
++i;
@@ -10724,7 +10715,7 @@ void PDFWriterImpl::beginStructureElementMCSeq()
SAL_INFO("vcl.pdfwriter", "beginning marked content id " << nMCID << " on page object "
<< m_aPages[ m_nCurrentPage ].m_nPageObject << ", structure first page = "
<< rEle.m_nFirstPageObject);
- rEle.m_aKids.emplace_back( nMCID, m_aPages[m_nCurrentPage].m_nPageObject );
+ rEle.m_aKids.emplace_back(MCIDReference{m_aPages[m_nCurrentPage].m_nPageObject, nMCID});
// update the page's mcid parent list
m_aPages[ m_nCurrentPage ].m_aMCIDParents.push_back( rEle.m_nObject );
// mark element MC sequence as open
@@ -10872,7 +10863,7 @@ void PDFWriterImpl::initStructureElement(sal_Int32 const id,
{
rEle.m_nObject = createObject();
// update parent's kids list
- m_aStructure[ rEle.m_nParentElement ].m_aKids.emplace_back(rEle.m_nObject);
+ m_aStructure[ rEle.m_nParentElement ].m_aKids.emplace_back(ObjReference{rEle.m_nObject});
// ISO 14289-1:2014, Clause: 7.9
if (*rEle.m_oType == PDFWriter::Note)
{
@@ -11081,7 +11072,7 @@ void PDFWriterImpl::addInternalStructureContainer( PDFStructureElement& rEle )
rEleNew.m_nFirstPageObject = m_aStructure[ rEle.m_aChildren.front() ].m_nFirstPageObject;
rEleNew.m_nObject = createObject();//assign a PDF object number
//add the object to the kid list of the parent
- aNewKids.emplace_back( rEleNew.m_nObject );
+ aNewKids.emplace_back(ObjReference{rEleNew.m_nObject});
aNewChildren.push_back( nNewId );
std::vector< sal_Int32 >::iterator aChildEndIt( rEle.m_aChildren.begin() );