[Libreoffice-commits] core.git: vcl/inc vcl/Library_vcl.mk vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sun Dec 29 20:40:34 UTC 2019
vcl/Library_vcl.mk | 1
vcl/inc/pdf/ResourceDict.hxx | 42 ++++++++++++++++++++++++++
vcl/source/gdi/pdfwriter_impl.cxx | 39 ------------------------
vcl/source/gdi/pdfwriter_impl.hxx | 12 -------
vcl/source/pdf/ResourceDict.cxx | 60 ++++++++++++++++++++++++++++++++++++++
5 files changed, 104 insertions(+), 50 deletions(-)
New commits:
commit 7c648f0d455e64e87861683454a3cc2c132a010a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Dec 29 19:40:01 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Dec 29 21:40:00 2019 +0100
pdf: move struct ResourceDict to it's own file
Change-Id: I60ee0e17c7945e053b9ada69d7abda57714dd388
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85958
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 0bc271576da7..d557ce3f0bc4 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -316,6 +316,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/scrptrun \
vcl/source/gdi/CommonSalLayout \
vcl/source/gdi/TypeSerializer \
+ vcl/source/pdf/ResourceDict \
vcl/source/graphic/GraphicLoader \
vcl/source/graphic/GraphicObject \
vcl/source/graphic/GraphicObject2 \
diff --git a/vcl/inc/pdf/ResourceDict.hxx b/vcl/inc/pdf/ResourceDict.hxx
new file mode 100644
index 000000000000..8334e1f52c39
--- /dev/null
+++ b/vcl/inc/pdf/ResourceDict.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_PDF_RESOURCEDICT_HXX
+#define INCLUDED_VCL_INC_PDF_RESOURCEDICT_HXX
+
+#include <vcl/dllapi.h>
+#include <rtl/strbuf.hxx>
+#include <map>
+
+namespace vcl::pdf
+{
+enum ResourceKind
+{
+ ResXObject,
+ ResExtGState,
+ ResShading,
+ ResPattern
+};
+
+struct ResourceDict
+{
+ // note: handle fonts globally for performance
+ std::map<OString, sal_Int32> m_aXObjects;
+ std::map<OString, sal_Int32> m_aExtGStates;
+ std::map<OString, sal_Int32> m_aShadings;
+ std::map<OString, sal_Int32> m_aPatterns;
+
+ void append(OStringBuffer& rBuffer, sal_Int32 nFontDictObject);
+};
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 553c109dcafb..3d500ce15e99 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -683,45 +683,6 @@ void Matrix3::append( PDFWriterImpl::PDFPage const & rPage, OStringBuffer& rBuff
rPage.appendPoint( Point( static_cast<long>(f[4]), static_cast<long>(f[5]) ), rBuffer );
}
-static void appendResourceMap( OStringBuffer& rBuf, const char* pPrefix, std::map<OString, sal_Int32> const & rList )
-{
- if( rList.empty() )
- return;
- rBuf.append( '/' );
- rBuf.append( pPrefix );
- rBuf.append( "<<" );
- int ni = 0;
- for (auto const& item : rList)
- {
- if( !item.first.isEmpty() && item.second > 0 )
- {
- rBuf.append( '/' );
- rBuf.append( item.first );
- rBuf.append( ' ' );
- rBuf.append( item.second );
- rBuf.append( " 0 R" );
- if( ((++ni) & 7) == 0 )
- rBuf.append( '\n' );
- }
- }
- rBuf.append( ">>\n" );
-}
-
-void PDFWriterImpl::ResourceDict::append( OStringBuffer& rBuf, sal_Int32 nFontDictObject )
-{
- rBuf.append( "<</Font " );
- rBuf.append( nFontDictObject );
- rBuf.append( " 0 R\n" );
- appendResourceMap( rBuf, "XObject", m_aXObjects );
- appendResourceMap( rBuf, "ExtGState", m_aExtGStates );
- appendResourceMap( rBuf, "Shading", m_aShadings );
- appendResourceMap( rBuf, "Pattern", m_aPatterns );
- rBuf.append( "/ProcSet[/PDF/Text" );
- if( !m_aXObjects.empty() )
- rBuf.append( "/ImageC/ImageI/ImageB" );
- rBuf.append( "]\n>>\n" );
-};
-
PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation )
:
m_pWriter( pWriter ),
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 4ce2112715a9..0420567ef5ba 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -25,6 +25,7 @@
#include <memory>
#include <vector>
+#include <pdf/ResourceDict.hxx>
#include <pdf/BitmapID.hxx>
#include <com/sun/star/lang/Locale.hpp>
@@ -103,17 +104,6 @@ class PDFWriterImpl : public VirtualDevice
friend class PDFStreamIf;
public:
- enum ResourceKind { ResXObject, ResExtGState, ResShading, ResPattern };
- struct ResourceDict
- {
- // note: handle fonts globally for performance
- std::map<OString, sal_Int32> m_aXObjects;
- std::map<OString, sal_Int32> m_aExtGStates;
- std::map<OString, sal_Int32> m_aShadings;
- std::map<OString, sal_Int32> m_aPatterns;
-
- void append( OStringBuffer&, sal_Int32 nFontDictObject );
- };
struct PDFPage
{
diff --git a/vcl/source/pdf/ResourceDict.cxx b/vcl/source/pdf/ResourceDict.cxx
new file mode 100644
index 000000000000..3490da30b899
--- /dev/null
+++ b/vcl/source/pdf/ResourceDict.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <pdf/ResourceDict.hxx>
+
+namespace vcl::pdf
+{
+namespace
+{
+void appendResourceMap(OStringBuffer& rBuf, const char* pPrefix,
+ std::map<OString, sal_Int32> const& rList)
+{
+ if (rList.empty())
+ return;
+ rBuf.append('/');
+ rBuf.append(pPrefix);
+ rBuf.append("<<");
+ int ni = 0;
+ for (auto const& item : rList)
+ {
+ if (!item.first.isEmpty() && item.second > 0)
+ {
+ rBuf.append('/');
+ rBuf.append(item.first);
+ rBuf.append(' ');
+ rBuf.append(item.second);
+ rBuf.append(" 0 R");
+ if (((++ni) & 7) == 0)
+ rBuf.append('\n');
+ }
+ }
+ rBuf.append(">>\n");
+}
+}
+
+void ResourceDict::append(OStringBuffer& rBuf, sal_Int32 nFontDictObject)
+{
+ rBuf.append("<</Font ");
+ rBuf.append(nFontDictObject);
+ rBuf.append(" 0 R\n");
+ appendResourceMap(rBuf, "XObject", m_aXObjects);
+ appendResourceMap(rBuf, "ExtGState", m_aExtGStates);
+ appendResourceMap(rBuf, "Shading", m_aShadings);
+ appendResourceMap(rBuf, "Pattern", m_aPatterns);
+ rBuf.append("/ProcSet[/PDF/Text");
+ if (!m_aXObjects.empty())
+ rBuf.append("/ImageC/ImageI/ImageB");
+ rBuf.append("]\n>>\n");
+}
+
+} // end vcl::pdf
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list