summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/Configuration_filter.mk1
-rw-r--r--filter/source/config/fragments/internalgraphicfilters/pdf_Export.xcu17
-rw-r--r--include/vcl/gfxlink.hxx5
-rw-r--r--include/vcl/graph.hxx3
-rw-r--r--include/vcl/graphicfilter.hxx1
-rw-r--r--svx/source/core/graphichelper.cxx3
-rw-r--r--svx/source/xoutdev/_xoutbmp.cxx20
-rw-r--r--vcl/inc/impgraph.hxx1
-rw-r--r--vcl/source/filter/FilterConfigCache.cxx2
-rw-r--r--vcl/source/filter/graphicfilter.cxx2
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx7
-rw-r--r--vcl/source/gdi/graph.cxx11
-rw-r--r--vcl/source/gdi/impgraph.cxx9
13 files changed, 79 insertions, 3 deletions
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index ef895de4f1de..44c442021eb8 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -839,6 +839,7 @@ $(eval $(call filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_inter
pcd_Import_Base16 \
pct_Import \
pcx_Import \
+ pdf_Export \
pdf_Import \
pgm_Import \
png_Export \
diff --git a/filter/source/config/fragments/internalgraphicfilters/pdf_Export.xcu b/filter/source/config/fragments/internalgraphicfilters/pdf_Export.xcu
new file mode 100644
index 000000000000..d82c771da22f
--- /dev/null
+++ b/filter/source/config/fragments/internalgraphicfilters/pdf_Export.xcu
@@ -0,0 +1,17 @@
+<!--
+ * 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/.
+-->
+ <node oor:name="pdf_Export" oor:op="replace" >
+ <prop oor:name="Type"><value>pdf_Portable_Document_Format</value></prop>
+ <prop oor:name="FormatName"><value>SVEPDF</value></prop>
+ <prop oor:name="RealFilterName"/>
+ <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">PDF - Portable Document Format</value>
+ </prop>
+ <prop oor:name="Flags"><value>EXPORT</value></prop>
+ </node>
diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx
index 0fc6e0c26293..0fcca069bfbb 100644
--- a/include/vcl/gfxlink.hxx
+++ b/include/vcl/gfxlink.hxx
@@ -42,11 +42,12 @@ enum class GfxLinkType
NativePct = 8, // Don't forget to update the following defines
NativeSvg = 9, // Don't forget to update the following defines
NativeMov = 10, // Don't forget to update the following defines
- NativeBmp = 11 // Don't forget to update the following defines
+ NativeBmp = 11,
+ NativePdf = 12 // Don't forget to update the following defines
};
#define GFX_LINK_FIRST_NATIVE_ID GfxLinkType::NativeGif
-#define GFX_LINK_LAST_NATIVE_ID GfxLinkType::NativeBmp
+#define GFX_LINK_LAST_NATIVE_ID GfxLinkType::NativePdf
class Graphic;
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index cffafa7660de..697565dbd1e6 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -220,6 +220,9 @@ public:
const SvgDataPtr& getSvgData() const;
+ void setPdfData(const css::uno::Sequence<sal_Int8>& rPdfData);
+ const css::uno::Sequence<sal_Int8>& getPdfData() const;
+
static css::uno::Sequence<sal_Int8> getUnoTunnelId();
};
diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index 0a2f8d5cf628..ff8353c30146 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -82,6 +82,7 @@ namespace o3tl
#define EXP_EMF "SVEMF"
#define EXP_JPEG "SVEJPEG"
#define EXP_SVG "SVESVG"
+#define EXP_PDF "SVEPDF"
#define EXP_PNG "SVEPNG"
#define BMP_SHORTNAME "BMP"
diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx
index f163af063b04..5be57e8a8c2a 100644
--- a/svx/source/core/graphichelper.cxx
+++ b/svx/source/core/graphichelper.cxx
@@ -87,6 +87,9 @@ void GraphicHelper::GetPreferredExtension( OUString& rExtension, const Graphic&
case GfxLinkType::NativeSvg:
aExtension = "svg";
break;
+ case GfxLinkType::NativePdf:
+ aExtension = "pdf";
+ break;
default:
break;
}
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 7dea7331395d..592434b40154 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -39,6 +39,8 @@
#define FORMAT_JPG "jpg"
#define FORMAT_PNG "png"
+using namespace com::sun::star;
+
GraphicFilter* XOutBitmap::pGrfFilter = nullptr;
Animation XOutBitmap::MirrorAnimation( const Animation& rAnimation, bool bHMirr, bool bVMirr )
@@ -172,6 +174,24 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam
}
}
+ // Write PDF data in original form if possible.
+ if (rGraphic.getPdfData().hasElements() && rFilterName.equalsIgnoreAsciiCase("pdf"))
+ {
+ if (!(nFlags & XOutFlags::DontAddExtension))
+ aURL.setExtension(rFilterName);
+
+ rFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+ SfxMedium aMedium(aURL.GetMainURL(INetURLObject::NO_DECODE), StreamMode::WRITE|StreamMode::SHARE_DENYNONE|StreamMode::TRUNC);
+ if (SvStream* pOutStream = aMedium.GetOutStream())
+ {
+ uno::Sequence<sal_Int8> aPdfData = rGraphic.getPdfData();
+ pOutStream->WriteBytes(aPdfData.getConstArray(), aPdfData.getLength());
+ aMedium.Commit();
+ if (!aMedium.GetError())
+ nErr = GRFILTER_OK;
+ }
+ }
+
if( GRFILTER_OK != nErr )
{
if( ( nFlags & XOutFlags::UseNativeIfPossible ) &&
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 5f26354904d9..a41d684e0273 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -51,6 +51,7 @@ private:
bool mbSwapUnderway;
bool mbDummyContext;
SvgDataPtr maSvgData;
+ css::uno::Sequence<sal_Int8> maPdfData;
private:
diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx
index d8d8862447c1..262bd66d7582 100644
--- a/vcl/source/filter/FilterConfigCache.cxx
+++ b/vcl/source/filter/FilterConfigCache.cxx
@@ -43,7 +43,7 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameLi
const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] =
{
IMP_SVMETAFILE, IMP_WMF, IMP_EMF, IMP_SVSGF, IMP_SVSGV, IMP_SVG, IMP_PDF,
- EXP_SVMETAFILE, EXP_WMF, EXP_EMF, EXP_SVG, nullptr
+ EXP_SVMETAFILE, EXP_WMF, EXP_EMF, EXP_SVG, EXP_PDF, nullptr
};
const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] =
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 38e72dc5e837..b65a8a02ea78 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1698,6 +1698,8 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
{
if (!ImportPDF(rIStream, rGraphic))
nStatus = GRFILTER_FILTERERROR;
+ else
+ eLinkType = GfxLinkType::NativePdf;
}
else
nStatus = GRFILTER_FILTERERROR;
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index cc63415eba6d..6bd1f6f524a8 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -101,6 +101,13 @@ VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
rGraphic = aMtf;
+ // Save the original PDF stream for later use.
+ rStream.Seek(STREAM_SEEK_TO_END);
+ uno::Sequence<sal_Int8> aPdfData(rStream.Tell());
+ rStream.Seek(STREAM_SEEK_TO_BEGIN);
+ rStream.ReadBytes(aPdfData.getArray(), aPdfData.getLength());
+ rGraphic.setPdfData(aPdfData);
+
return true;
}
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index c5a7901e25ca..7a61594e1b42 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -593,6 +593,17 @@ const SvgDataPtr& Graphic::getSvgData() const
return mpImpGraphic->getSvgData();
}
+void Graphic::setPdfData(const uno::Sequence<sal_Int8>& rPdfData)
+{
+ ImplTestRefCount();
+ mpImpGraphic->maPdfData = rPdfData;
+}
+
+const uno::Sequence<sal_Int8>& Graphic::getPdfData() const
+{
+ return mpImpGraphic->maPdfData;
+}
+
namespace {
struct Id: public rtl::Static<cppu::OImplementationId, Id> {};
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 8c66d1a0e548..933a0a60ffe9 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -51,6 +51,8 @@
#define GRAPHIC_FORMAT_50 static_cast<sal_uInt32>(COMPAT_FORMAT( 'G', 'R', 'F', '5' ))
#define NATIVE_FORMAT_50 static_cast<sal_uInt32>(COMPAT_FORMAT( 'N', 'A', 'T', '5' ))
+using namespace com::sun::star;
+
struct ImpSwapFile
{
INetURLObject aSwapURL;
@@ -132,6 +134,7 @@ ImpGraphic::ImpGraphic( const ImpGraphic& rImpGraphic ) :
mpAnimation = nullptr;
maSvgData = rImpGraphic.maSvgData;
+ maPdfData = rImpGraphic.maPdfData;
}
ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
@@ -256,6 +259,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
mpGfxLink = nullptr;
maSvgData = rImpGraphic.maSvgData;
+ maPdfData = rImpGraphic.maPdfData;
}
return *this;
@@ -304,6 +308,10 @@ bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const
}
}
}
+ else if (maPdfData.hasElements())
+ {
+ bRet = maPdfData == rImpGraphic.maPdfData;
+ }
else if( mpAnimation )
{
if( rImpGraphic.mpAnimation && ( *rImpGraphic.mpAnimation == *mpAnimation ) )
@@ -349,6 +357,7 @@ void ImpGraphic::ImplClearGraphics( bool bCreateSwapInfo )
}
maSvgData.reset();
+ maPdfData = uno::Sequence<sal_Int8>();
}
void ImpGraphic::ImplClear()