From 2d0cefae7a899e5ed62730468f4fb0f25d6297e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Vajngerl?= Date: Thu, 31 Dec 2020 21:10:27 +0900 Subject: [PATCH] [API CHANGE] change XPdfDecomposer to use XBinaryDataContainer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using BinaryDataContainer doesn't require to copy the data as it is compatible with what is used in Graphic, VectorGraphicData and GfxLink. Change-Id: I01589158ae6bf6ac407bde60f07952e3968e3970 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109597 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl --- filter/source/pdf/pdfdecomposer.cxx | 14 ++++++++++---- offapi/com/sun/star/graphic/XPdfDecomposer.idl | 7 ++++--- vcl/source/gdi/vectorgraphicdata.cxx | 11 +++++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/filter/source/pdf/pdfdecomposer.cxx b/filter/source/pdf/pdfdecomposer.cxx index ce1321a3ceb5..f4572f93742a 100644 --- a/filter/source/pdf/pdfdecomposer.cxx +++ b/filter/source/pdf/pdfdecomposer.cxx @@ -17,11 +17,14 @@ #include #include #include +#include +#include #include #include #include #include +#include using namespace css; @@ -38,7 +41,7 @@ public: // XPdfDecomposer uno::Sequence> SAL_CALL - getDecomposition(const uno::Sequence& xPdfData, + getDecomposition(const uno::Reference& xDataContainer, const uno::Sequence& xDecompositionParameters) override; // XServiceInfo @@ -49,8 +52,9 @@ public: XPdfDecomposer::XPdfDecomposer(uno::Reference const&) {} -uno::Sequence> SAL_CALL XPdfDecomposer::getDecomposition( - const uno::Sequence& xPdfData, const uno::Sequence& xParameters) +uno::Sequence> SAL_CALL +XPdfDecomposer::getDecomposition(const uno::Reference& xDataContainer, + const uno::Sequence& xParameters) { sal_Int32 nPageIndex = -1; @@ -66,8 +70,10 @@ uno::Sequence> SAL_CALL XPdfDecomposer::ge if (nPageIndex < 0) nPageIndex = 0; + BinaryDataContainer aDataContainer = vcl::convertUnoBinaryDataContainer(xDataContainer); + std::vector aBitmaps; - int rv = vcl::RenderPDFBitmaps(xPdfData.getConstArray(), xPdfData.getLength(), aBitmaps, + int rv = vcl::RenderPDFBitmaps(aDataContainer.getData(), aDataContainer.getSize(), aBitmaps, nPageIndex, 1); if (rv == 0) return {}; // happens if we do not have PDFium diff --git a/offapi/com/sun/star/graphic/XPdfDecomposer.idl b/offapi/com/sun/star/graphic/XPdfDecomposer.idl index 25bf8870c1ee..9976475d74cd 100644 --- a/offapi/com/sun/star/graphic/XPdfDecomposer.idl +++ b/offapi/com/sun/star/graphic/XPdfDecomposer.idl @@ -11,6 +11,7 @@ #define __com_sun_star_graphic_XPdfDecomposer_idl__ #include +#include module com { module sun { module star { module graphic { @@ -26,15 +27,15 @@ interface XPdfDecomposer : ::com::sun::star::uno::XInterface { /** Retrieve decomposed list - in this case a bitmap with the rendered PDF. - @param xPdfData - The PDF data. + @param xDataContainer + The PDF data in a data container @param xDecompositionParameters Parameters for decomposition. Parameters include: sal_Int32 PageIndex - which page to use */ - sequence getDecomposition([in] sequence xPdfData, + sequence getDecomposition([in] com::sun::star::util::XBinaryDataContainer xDataContainer, [in] sequence xDecompositionParameters); }; diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx index 2afe12e97fbd..5a977191fef4 100644 --- a/vcl/source/gdi/vectorgraphicdata.cxx +++ b/vcl/source/gdi/vectorgraphicdata.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -249,10 +251,11 @@ void VectorGraphicData::ensureSequenceAndRange() uno::Sequence aDecompositionParameters = comphelper::InitPropertySequence({ {"PageIndex", uno::makeAny(mnPageIndex)}, }); - // TODO: change xPdfDecomposer to use BinaryDataContainer directly - css::uno::Sequence aDataSequence(maDataContainer.getSize()); - std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin()); - auto xPrimitive2D = xPdfDecomposer->getDecomposition(aDataSequence, aDecompositionParameters); + + auto* pUnoBinaryDataContainer = new UnoBinaryDataContainer(getBinaryDataContainer()); + uno::Reference xDataContainer = pUnoBinaryDataContainer; + + auto xPrimitive2D = xPdfDecomposer->getDecomposition(xDataContainer, aDecompositionParameters); maSequence = comphelper::sequenceToContainer>>(xPrimitive2D); break;