summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-24 13:00:46 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-06-24 11:51:01 +0000
commit7d76bb251e0c88ff17282a33b801a5d17a434af5 (patch)
tree927e5ff1968764b40b070dca8e6aae8b3e9d25ce /vcl/source
parent47443d720d5f2bee0993222fd6383a59056d8591 (diff)
vcl: add graphic export-as-pdf filter
In case the metafile was imported from a PDF originally, then this allows storing the PDF stream next to the graphic. This means that e.g. in Writer choosing 'Save' from the context menu of the graphic can write the original PDF stream, not the replacement metafile. Change-Id: I4ab45d5af17fe46d7538df6d79d6b57ed163572a Reviewed-on: https://gerrit.libreoffice.org/26628 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/source')
-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
5 files changed, 30 insertions, 1 deletions
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()