From d7e5eae44e18ab89e85a0e6ed633853ede70ec71 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Mon, 12 Feb 2024 00:44:31 +0000 Subject: 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 --- sdext/source/pdfimport/inc/imagecontainer.hxx | 1 + sdext/source/pdfimport/tree/imagecontainer.cxx | 31 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'sdext') 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& 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 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: */ -- cgit ora/co-23.05'>distro/collabora/co-23.05 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2017-04-21gbuild: Remove MSVC 2013 legacy codeDavid Ostrovsky