diff options
-rw-r--r-- | include/vcl/gfxlink.hxx | 5 | ||||
-rw-r--r-- | include/vcl/vectorgraphicdata.hxx | 4 | ||||
-rw-r--r-- | vcl/source/filter/graphicfilter.cxx | 13 | ||||
-rw-r--r-- | vcl/source/filter/ipdf/pdfread.cxx | 33 | ||||
-rw-r--r-- | vcl/source/filter/wmf/wmf.cxx | 14 | ||||
-rw-r--r-- | vcl/source/gdi/TypeSerializer.cxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 14 | ||||
-rw-r--r-- | vcl/source/gdi/vectorgraphicdata.cxx | 21 |
8 files changed, 47 insertions, 65 deletions
diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx index 85bb85cb53f2..1acb51d05c0a 100644 --- a/include/vcl/gfxlink.hxx +++ b/include/vcl/gfxlink.hxx @@ -86,6 +86,11 @@ public: sal_uInt32 GetDataSize() const { return maDataContainer.getSize(); } const sal_uInt8* GetData() const; + const BinaryDataContainer& getDataContainer() + { + return maDataContainer; + } + const Size& GetPrefSize() const { return maPrefSize;} void SetPrefSize( const Size& rPrefSize ); bool IsPrefSizeValid() const { return mbPrefSizeValid;} diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx index 21d86fa12b3d..2d51bb61c228 100644 --- a/include/vcl/vectorgraphicdata.hxx +++ b/include/vcl/vectorgraphicdata.hxx @@ -86,10 +86,6 @@ private: VectorGraphicData& operator=(const VectorGraphicData&) = delete; public: - VectorGraphicData( - const VectorGraphicDataArray& rVectorGraphicDataArray, - VectorGraphicDataType eVectorDataType, - sal_Int32 nPageIndex = -1); VectorGraphicData(const OUString& rPath, VectorGraphicDataType eVectorDataType); VectorGraphicData( const BinaryDataContainer& rDataContainer, diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 5b4ad1737165..7f7af5239cad 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1624,7 +1624,8 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, if(!aMemStream.GetError() ) { - auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, VectorGraphicDataType::Svg); + BinaryDataContainer aDataContainer(reinterpret_cast<const sal_uInt8*>(aNewData.getConstArray()), aNewData.getLength()); + auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aDataContainer, VectorGraphicDataType::Svg); rGraphic = Graphic(aVectorGraphicDataPtr); bOkay = true; } @@ -1637,7 +1638,8 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, if(!rIStream.GetError()) { - auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, VectorGraphicDataType::Svg); + BinaryDataContainer aDataContainer(reinterpret_cast<const sal_uInt8*>(aNewData.getConstArray()), aNewData.getLength()); + auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aDataContainer, VectorGraphicDataType::Svg); rGraphic = Graphic(aVectorGraphicDataPtr); bOkay = true; } @@ -1711,10 +1713,11 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, { const bool bIsWmf(aFilterName.equalsIgnoreAsciiCase(IMP_WMF)); const VectorGraphicDataType aDataType(bIsWmf ? VectorGraphicDataType::Wmf : VectorGraphicDataType::Emf); + + BinaryDataContainer aDataContainer(reinterpret_cast<const sal_uInt8*>(aNewData.getConstArray()), aNewData.getLength()); + auto aVectorGraphicDataPtr = - std::make_shared<VectorGraphicData>( - aNewData, - aDataType); + std::make_shared<VectorGraphicData>(aDataContainer, aDataType); if (pExtHeader) { diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index bfa27f68358b..7a7d1c75aa38 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -107,23 +107,23 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream) } #endif // HAVE_FEATURE_PDFIUM -VectorGraphicDataArray createVectorGraphicDataArray(SvStream& rStream) +BinaryDataContainer createBinaryDataContainer(SvStream& rStream) { // Save the original PDF stream for later use. SvMemoryStream aMemoryStream; if (!getCompatibleStream(rStream, aMemoryStream)) - return VectorGraphicDataArray(); + return BinaryDataContainer(); const sal_uInt32 nStreamLength = aMemoryStream.TellEnd(); - VectorGraphicDataArray aPdfData(nStreamLength); + auto aPdfData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength); aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN); - aMemoryStream.ReadBytes(aPdfData.begin(), nStreamLength); + aMemoryStream.ReadBytes(aPdfData->data(), aPdfData->size()); if (aMemoryStream.GetError()) - return VectorGraphicDataArray(); + return BinaryDataContainer(); - return aPdfData; + return BinaryDataContainer(std::move(aPdfData)); } } // end anonymous namespace @@ -233,15 +233,15 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& r bool importPdfVectorGraphicData(SvStream& rStream, std::shared_ptr<VectorGraphicData>& rVectorGraphicData) { - VectorGraphicDataArray aPdfDataArray = createVectorGraphicDataArray(rStream); - if (!aPdfDataArray.hasElements()) + BinaryDataContainer aDataContainer = createBinaryDataContainer(rStream); + if (aDataContainer.isEmpty()) { SAL_WARN("vcl.filter", "ImportPDF: empty PDF data array"); return false; } rVectorGraphicData - = std::make_shared<VectorGraphicData>(aPdfDataArray, VectorGraphicDataType::Pdf); + = std::make_shared<VectorGraphicData>(aDataContainer, VectorGraphicDataType::Pdf); return true; } @@ -442,17 +442,12 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG ::utl::UcbStreamHelper::CreateStream(rURL, StreamMode::READ | StreamMode::SHARE_DENYNONE)); // Save the original PDF stream for later use. - BinaryDataContainer aBinaryDataContainer; - { - VectorGraphicDataArray aPdfDataArray = createVectorGraphicDataArray(*xStream); - if (!aPdfDataArray.hasElements()) - return 0; - const sal_uInt8* pData = reinterpret_cast<const sal_uInt8*>(aPdfDataArray.getConstArray()); - aBinaryDataContainer = BinaryDataContainer(pData, aPdfDataArray.getLength()); - } + BinaryDataContainer aDataContainer = createBinaryDataContainer(*xStream); + if (aDataContainer.isEmpty()) + return 0; // Prepare the link with the PDF stream. - auto pGfxLink = std::make_shared<GfxLink>(aBinaryDataContainer, GfxLinkType::NativePdf); + auto pGfxLink = std::make_shared<GfxLink>(aDataContainer, GfxLinkType::NativePdf); auto pPdfium = vcl::pdf::PDFiumLibrary::get(); @@ -480,7 +475,7 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG tools::Long nPageHeight = convertTwipToMm100(aPageSize.getY() * pointToTwipconversionRatio); auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>( - aBinaryDataContainer, VectorGraphicDataType::Pdf, nPageIndex); + aDataContainer, VectorGraphicDataType::Pdf, nPageIndex); // Create the Graphic with the VectorGraphicDataPtr and link the original PDF stream. // We swap out this Graphic as soon as possible, and a later swap in diff --git a/vcl/source/filter/wmf/wmf.cxx b/vcl/source/filter/wmf/wmf.cxx index 70ff37f7473f..ccff80c20339 100644 --- a/vcl/source/filter/wmf/wmf.cxx +++ b/vcl/source/filter/wmf/wmf.cxx @@ -42,8 +42,9 @@ bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF ) // Read binary data to mem array const sal_uInt32 nStreamLength(nStreamEnd - nStreamStart); - VectorGraphicDataArray aNewData(nStreamLength); - rStream.ReadBytes(aNewData.begin(), nStreamLength); + auto rData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength); + rStream.ReadBytes(rData->data(), rData->size()); + BinaryDataContainer aDataContainer(std::move(rData)); rStream.Seek(nStreamStart); if (rStream.good()) @@ -52,9 +53,7 @@ bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF ) // too much for type, this will be checked there. Also no path // needed, it is a temporary object auto aVectorGraphicDataPtr = - std::make_shared<VectorGraphicData>( - aNewData, - VectorGraphicDataType::Emf); + std::make_shared<VectorGraphicData>(aDataContainer, VectorGraphicDataType::Emf); // create a Graphic and grep Metafile from it const Graphic aGraphic(aVectorGraphicDataPtr); @@ -93,10 +92,9 @@ bool ConvertGraphicToWMF(const Graphic& rGraphic, SvStream& rTargetStream, { // This may be an EMF+ file, converting that to WMF is better done by re-parsing EMF+ as EMF // and converting that to WMF. - uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8*>(aLink.GetData()), - aLink.GetDataSize()); + auto & rDataContainer = aLink.getDataContainer(); auto aVectorGraphicData - = std::make_shared<VectorGraphicData>(aData, VectorGraphicDataType::Emf); + = std::make_shared<VectorGraphicData>(rDataContainer, VectorGraphicDataType::Emf); aVectorGraphicData->setEnableEMFPlus(false); Graphic aGraphic(aVectorGraphicData); bool bRet = ConvertGDIMetaFileToWMF(aGraphic.GetGDIMetaFile(), rTargetStream, pConfigItem, diff --git a/vcl/source/gdi/TypeSerializer.cxx b/vcl/source/gdi/TypeSerializer.cxx index 70bc9420153a..5a360f15675a 100644 --- a/vcl/source/gdi/TypeSerializer.cxx +++ b/vcl/source/gdi/TypeSerializer.cxx @@ -278,9 +278,9 @@ void TypeSerializer::readGraphic(Graphic& rGraphic) if (nLength) { - VectorGraphicDataArray aData(nLength); - - mrStream.ReadBytes(aData.getArray(), nLength); + auto rData = std::make_unique<std::vector<sal_uInt8>>(nLength); + mrStream.ReadBytes(rData->data(), rData->size()); + BinaryDataContainer aDataContainer(std::move(rData)); if (!mrStream.GetError()) { @@ -300,7 +300,7 @@ void TypeSerializer::readGraphic(Graphic& rGraphic) } auto aVectorGraphicDataPtr - = std::make_shared<VectorGraphicData>(aData, aDataType); + = std::make_shared<VectorGraphicData>(aDataContainer, aDataType); rGraphic = Graphic(aVectorGraphicDataPtr); } } diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 9ce49671b5ef..07f0df76acb0 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1561,14 +1561,14 @@ bool ImpGraphic::swapInGraphic(SvStream& rStream) if (constSvgMagic == nMagic || constWmfMagic == nMagic || constEmfMagic == nMagic || constPdfMagic == nMagic) { - sal_uInt32 nVectorGraphicDataArrayLength(0); - rStream.ReadUInt32(nVectorGraphicDataArrayLength); + sal_uInt32 nVectorGraphicDataSize(0); + rStream.ReadUInt32(nVectorGraphicDataSize); - if (nVectorGraphicDataArrayLength) + if (nVectorGraphicDataSize) { - VectorGraphicDataArray aNewData(nVectorGraphicDataArrayLength); - - rStream.ReadBytes(aNewData.getArray(), nVectorGraphicDataArrayLength); + auto rData = std::make_unique<std::vector<sal_uInt8>>(nVectorGraphicDataSize); + rStream.ReadBytes(rData->data(), nVectorGraphicDataSize); + BinaryDataContainer aDataContainer(std::move(rData)); if (rStream.GetError()) return false; @@ -1593,7 +1593,7 @@ bool ImpGraphic::swapInGraphic(SvStream& rStream) return false; } - auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, aDataType); + auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aDataContainer, aDataType); if (!rStream.GetError()) { diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx index 4bd56a01a887..5e027e0bcd34 100644 --- a/vcl/source/gdi/vectorgraphicdata.cxx +++ b/vcl/source/gdi/vectorgraphicdata.cxx @@ -250,9 +250,9 @@ void VectorGraphicData::ensureSequenceAndRange() {"PageIndex", uno::makeAny<sal_Int32>(mnPageIndex)}, }); // TODO: change xPdfDecomposer to use BinaryDataContainer directly - VectorGraphicDataArray aVectorGraphicDataArray(maDataContainer.getSize()); - std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aVectorGraphicDataArray.begin()); - auto xPrimitive2D = xPdfDecomposer->getDecomposition(aVectorGraphicDataArray, aDecompositionParameters); + css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize()); + std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin()); + auto xPrimitive2D = xPdfDecomposer->getDecomposition(aDataSequence, aDecompositionParameters); maSequence = comphelper::sequenceToContainer<std::deque<uno::Reference<graphic::XPrimitive2D>>>(xPrimitive2D); break; @@ -300,21 +300,6 @@ std::pair<VectorGraphicData::State, size_t> VectorGraphicData::getSizeBytes() co } VectorGraphicData::VectorGraphicData( - const VectorGraphicDataArray& rVectorGraphicDataArray, - VectorGraphicDataType eVectorDataType, - sal_Int32 nPageIndex) -: maDataContainer(reinterpret_cast<const sal_uInt8*>(rVectorGraphicDataArray.begin()), rVectorGraphicDataArray.getLength()), - mbSequenceCreated(false), - maRange(), - maSequence(), - maReplacement(), - mNestedBitmapSize(0), - meVectorGraphicDataType(eVectorDataType), - mnPageIndex(nPageIndex) -{ -} - -VectorGraphicData::VectorGraphicData( const BinaryDataContainer& rDataContainer, VectorGraphicDataType eVectorDataType, sal_Int32 nPageIndex) |