12#include <rtl/strbuf.hxx>
25 : m_rContainer(rContainer)
31 std::map<sal_Int32, sal_Int32>& rCopiedResources)
49 for (
auto const& pElement : pInputArray->GetElements())
59 for (
auto const& pPair : pInputDictionary->GetItems())
62 rLine.append(pPair.first);
77 std::map<sal_Int32, sal_Int32>& rCopiedResources)
80 if (it != rCopiedResources.end())
90 <<
" -> " << nObject);
93 aLine.append(nObject);
94 aLine.append(
" 0 obj\n");
108 aLine.append(rPair.first);
113 aLine.append(
" >>\n");
119 aLine.append(
"stream\n");
126 const std::vector<filter::PDFElement*>& rElements = pArray->GetElements();
129 for (
auto const& pElement : rElements)
143 pNumber->writeString(aLine);
158 aLine.append(
static_cast<const char*
>(rStream.
GetData()), rStream.
GetSize());
164 aLine.append(
"\nendstream\n");
170 aLine.append(
"endobj\n\n");
178 const OString& rKind,
179 std::map<sal_Int32, sal_Int32>& rCopiedResources)
183 std::map<OString, sal_Int32> aRet;
186 std::map<OString, filter::PDFElement*> aItems;
195 aItems = pDictionary->GetItems();
206 pKindObject = pReferenced;
217 aItems = pDictionary->GetItems();
222 aItems =
pObject->GetDictionaryItems();
230 bool bHasDictValue =
false;
232 for (
const auto& rItem : aItems)
240 bHasDictValue =
true;
253 aRet[rItem.first] = nObject;
256 if (bHasDictValue && pKindObject)
259 return "/" + rKind +
" " + OString::number(nObject) +
" 0 R";
263 OStringBuffer sRet(
"/" + rKind +
"<<");
264 for (
const auto& rPair : aRet)
266 sRet.append(
"/" + rPair.first +
" " + OString::number(rPair.second) +
" 0 R");
270 return sRet.makeStringAndClear();
276 std::map<sal_Int32, sal_Int32> aCopiedResources;
281 std::map<sal_Int32, sal_Int32>& rCopiedResources)
283 rLine.append(
" /Resources <<");
284 static const std::initializer_list<OString> aKeys
285 = {
"ColorSpace",
"ExtGState",
"Font",
"XObject",
"Shading",
"Pattern" };
286 for (
const auto& rKey : aKeys)
296 for (
auto pContent : rContentStreams)
301 SAL_WARN(
"vcl.pdfwriter",
"PDFObjectCopier::copyPageStreams: contents has no stream");
309 if (!pFilter && pFilterArray)
312 if (!aElements.empty())
318 if (pFilter->GetValue() !=
"FlateDecode")
327 aZCodec.
Decompress(rPageStream, aMemoryStream);
330 SAL_WARN(
"vcl.pdfwriter",
"PDFObjectCopier::copyPageStreams: decompression failed");
344 return rStream.
Tell();
std::size_t WriteBytes(const void *pData, std::size_t nSize)
sal_uInt64 Seek(sal_uInt64 nPos)
tools::Long Decompress(SvStream &rIStm, SvStream &rOStm)
tools::Long EndCompression()
void BeginCompression(int nCompressLevel=ZCODEC_DEFAULT_COMPRESSION, bool gzLib=false)
Allows creating, updating and writing PDF objects in a container.
virtual void checkAndEnableStreamEncryption(sal_Int32 nObject)=0
virtual bool updateObject(sal_Int32 n)=0
virtual sal_Int32 createObject()=0
virtual void disableStreamEncryption()=0
virtual bool writeBuffer(const void *pBuffer, sal_uInt64 nBytes)=0
OString copyExternalResources(filter::PDFObjectElement &rPage, const OString &rKind, std::map< sal_Int32, sal_Int32 > &rCopiedResources)
Copies resources of a given kind from an external page to the output, returning what has to be includ...
PDFObjectCopier(PDFObjectContainer &rContainer)
void copyRecursively(OStringBuffer &rLine, filter::PDFElement &rInputElement, SvMemoryStream &rDocBuffer, std::map< sal_Int32, sal_Int32 > &rCopiedResources)
static sal_Int32 copyPageStreams(std::vector< filter::PDFObjectElement * > &rContentStreams, SvMemoryStream &rStream, bool &rCompressed)
Copies page one or more page streams from rContentStreams into rStream.
void copyPageResources(filter::PDFObjectElement *pPage, OStringBuffer &rLine)
Copies resources of pPage into rLine.
PDFObjectContainer & m_rContainer
sal_Int32 copyExternalResource(SvMemoryStream &rDocBuffer, filter::PDFObjectElement &rObject, std::map< sal_Int32, sal_Int32 > &rCopiedResources)
Copies a single resource from an external document, returns the new object ID in our document.
static bool compressStream(SvMemoryStream *)
const std::vector< PDFElement * > & GetElements() const
Dictionary object: a set key-value pairs.
SvMemoryStream & GetEditBuffer()
Access to the input document, even after the input stream is gone.
A byte range in a PDF file.
virtual void writeString(OStringBuffer &rBuffer)=0
Name object: a key string.
Numbering object: an integer or a real.
Indirect object: something with a unique ID.
const std::map< OString, PDFElement * > & GetDictionaryItems()
Get access to the parsed key-value items from the object dictionary.
double GetObjectValue() const
PDFElement * Lookup(const OString &rDictionaryKey)
PDFStreamElement * GetStream() const
Access to the stream of the object, if it has any.
PDFArrayElement * GetArray()
PDFNumberElement * GetNumberElement() const
PDFObjectElement * LookupObject(const OString &rDictionaryKey)
PDFDocument & GetDocument()
PDFDictionaryElement * GetDictionary()
Reference object: something with a unique ID.
Stream object: a byte array with a known length.
SvMemoryStream & GetMemory()
EmbeddedObjectRef * pObject
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)