summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
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: */