summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dave@treblig.org>2024-02-12 00:44:31 +0000
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-29 08:26:04 +0100
commitd7e5eae44e18ab89e85a0e6ed633853ede70ec71 (patch)
treee7df94c49705fb0651318f27d8f602640962b767 /sdext
parentff160e93d32c62e09b28393979b3535e01057cdc (diff)
tdf#113050 sdext.pdfimport: Add ImageContainer::asBase64EncodedString'
For fill-images we need the image as a string. Change-Id: I4a8429563b0e19ad977b4e933a0ffee378dab244 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163569 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/inc/imagecontainer.hxx1
-rw-r--r--sdext/source/pdfimport/tree/imagecontainer.cxx31
2 files changed, 32 insertions, 0 deletions
diff --git a/sdext/source/pdfimport/inc/imagecontainer.hxx b/sdext/source/pdfimport/inc/imagecontainer.hxx
index d21ed7504f63..03672e8ca8b2 100644
--- a/sdext/source/pdfimport/inc/imagecontainer.hxx
+++ b/sdext/source/pdfimport/inc/imagecontainer.hxx
@@ -42,6 +42,7 @@ namespace pdfi
ImageId addImage( const css::uno::Sequence<
css::beans::PropertyValue>& xBitmap );
void writeBase64EncodedStream( ImageId nImageId, EmitContext& rContext );
+ OUString asBase64EncodedString( ImageId nId ) const;
};
}
diff --git a/sdext/source/pdfimport/tree/imagecontainer.cxx b/sdext/source/pdfimport/tree/imagecontainer.cxx
index a7154164d771..b9f7ef52e061 100644
--- a/sdext/source/pdfimport/tree/imagecontainer.cxx
+++ b/sdext/source/pdfimport/tree/imagecontainer.cxx
@@ -141,6 +141,37 @@ void ImageContainer::writeBase64EncodedStream( ImageId nId, EmitContext& rContex
rContext.rEmitter.write( encodeBase64( aData.getConstArray(), aData.getLength() ));
}
+OUString ImageContainer::asBase64EncodedString( ImageId nId ) const
+{
+ OSL_ASSERT( nId >= 0 && o3tl::make_unsigned(nId) < m_aImages.size() );
+
+ const uno::Sequence<beans::PropertyValue>& rEntry( m_aImages[nId] );
+
+ // find "InputSequence" property
+ const beans::PropertyValue* pAry(rEntry.getConstArray());
+ const sal_Int32 nLen(rEntry.getLength());
+ const beans::PropertyValue* pValue(
+ std::find_if(pAry, pAry+nLen,
+ [] (beans::PropertyValue const& v) -> bool {
+ return v.Name == "InputSequence";
+ }));
+
+ if (pValue == pAry + nLen )
+ {
+ SAL_WARN("sdext.pdfimport", "InputSequence not found");
+ return "";
+ }
+
+ uno::Sequence<sal_Int8> aData;
+ if( !(pValue->Value >>= aData) )
+ {
+ SAL_WARN("sdext.pdfimport", "Wrong data type");
+ return "";
+ }
+
+ return encodeBase64( aData.getConstArray(), aData.getLength() );
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */