summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-10-24 15:58:14 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2023-10-24 18:46:50 +0200
commit049f458143cbd02ab915271418625cda1299f4b1 (patch)
tree7c59077a28ff22eb68bd61e7d587b2552332d8fc /vcl/source
parent4edff633dd36ea47d17a993e0afb30fcfc4f9a61 (diff)
tdf#157028 vcl: PDF export: inline attribute dictionaries
There seems to be no reason why SE attribute dictionaries are separate objects, they could just be inline, which saves a little space (1%) and more importantly the PDF file is easier to read with less clutter. Change-Id: Iaaea2432313c0b710edabecae32545205f4f495e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158392 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx35
1 files changed, 14 insertions, 21 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 5699b2dc6ddc..677212e15d1a 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2052,22 +2052,20 @@ OString PDFWriterImpl::emitStructureAttributes( PDFStructureElement& i_rEle )
aLayout.append( "]\n" );
}
- std::vector< sal_Int32 > aAttribObjects;
+ OStringBuffer aRet(256);
+ bool isArray(false);
+ if (1 < (aLayout.isEmpty() ? 0 : 1) + (aList.isEmpty() ? 0 : 1)
+ + (aPrintField.isEmpty() ? 0 : 1) + (aTable.isEmpty() ? 0 : 1))
+ {
+ isArray = true;
+ aRet.append(" [");
+ }
auto const WriteAttrs = [&](char const*const pName, OStringBuffer & rBuf)
{
- aAttribObjects.push_back( createObject() );
- if (updateObject( aAttribObjects.back() ))
- {
- OStringBuffer aObj( 64 );
- aObj.append( aAttribObjects.back() );
- aObj.append( " 0 obj\n"
- "<</O");
- aObj.append(pName);
- aObj.append("\n");
- rBuf.append(">>\nendobj\n\n");
- writeBuffer(aObj);
- writeBuffer(rBuf);
- }
+ aRet.append(" <</O");
+ aRet.append(pName);
+ aRet.append(rBuf);
+ aRet.append(">>");
};
if( !aLayout.isEmpty() )
{
@@ -2086,15 +2084,10 @@ OString PDFWriterImpl::emitStructureAttributes( PDFStructureElement& i_rEle )
WriteAttrs("/Table", aTable);
}
- OStringBuffer aRet( 64 );
- if( aAttribObjects.size() > 1 )
- aRet.append( " [" );
- for (auto const& attrib : aAttribObjects)
+ if (isArray)
{
- aRet.append( " " + OString::number(attrib) + " 0 R" );
- }
- if( aAttribObjects.size() > 1 )
aRet.append( " ]" );
+ }
return aRet.makeStringAndClear();
}