[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 129 commits - accessibility/inc avmedia/Library_avmediavlc.mk avmedia/Module_avmedia.mk avmedia/source basctl/source basegfx/source basegfx/test basic/source canvas/inc canvas/source chart2/qa chart2/source comphelper/source compilerplugins/clang config_host.mk.in configmgr/source configure.ac connectivity/source cppcanvas/qa cppcanvas/source cui/source cui/uiconfig dbaccess/qa dbaccess/source dbaccess/uiconfig desktop/source distro-configs/Jenkins drawinglayer/CppunitTest_drawinglayer_border.mk drawinglayer/inc drawinglayer/Library_drawinglayercore.mk drawinglayer/Library_drawinglayer.mk drawinglayer/Module_drawinglayer.mk drawinglayer/source editeng/source emfio/CppunitTest_emfio_emf.mk emfio/Library_emfio.mk emfio/qa emfio/source extensions/source filter/Library_pdffilter.mk filter/Library_svgfilter.mk filter/qa filter/source forms/source framework/inc framework/qa framework/source helpcontent2 i18npool/inc i18npool/source ico n-themes/elementary icon-themes/elementary_svg include/basegfx include/comphelper include/drawinglayer include/editeng include/filter include/o3tl include/rtl include/sax include/sfx2 include/sot include/svl include/svx include/tools include/vcl include/xmloff l10ntools/source lotuswordpro/qa lotuswordpro/source o3tl/qa offapi/com offapi/UnoApi_offapi.mk officecfg/registry oox/qa oox/source postprocess/Rdb_services.mk reportdesign/source Repository.mk sal/qa sax/source sc/CppunitTest_sc_parallelism.mk sc/CppunitTest_sc_ucalc.mk sc/Library_sc.mk sc/qa scripting/source sc/source sd/CppunitTest_sd_uimpress.mk sdext/source sd/Library_sd.mk sd/qa sd/source sfx2/Library_sfx.mk sfx2/qa sfx2/source sfx2/uiconfig slideshow/source solenv/clang-format solenv/CompilerTest_compilerplugins_clang.mk solenv/gbuild sot/source starmath/source stoc/source svgio/CppunitTest_svgio.mk svgio/Library_svgio.mk svgio/source svl/source svtools/source svx/CppunitTest_svx_unit.mk svx/Library_svxcore.mk svx/Libr ary_svx.mk svx/qa svx/sdi svx/source sw/CppunitTest_sw_uwriter.mk sw/inc sw/Library_sw.mk sw/Library_swui.mk sw/qa sw/source sw/uiconfig testtools/source toolkit/source tools/source ucb/source unotools/qa unotools/source vbahelper/source vcl/backendtest vcl/CppunitTest_vcl_graphic_test.mk vcl/headless vcl/inc vcl/IwyuFilter_vcl.yaml vcl/jsdialog vcl/Library_vcl.mk vcl/qa vcl/qt5 vcl/quartz vcl/skia vcl/source vcl/unx vcl/vcl.common.component vcl/win vcl/workben wizards/source writerfilter/qa writerfilter/source writerperfect/qa writerperfect/source xmloff/qa xmloff/source xmlscript/source xmlsecurity/qa
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Dec 29 04:15:56 UTC 2020
Rebased ref, commits from common ancestor:
commit 24e0e9469dab9cb4eb774f0fd3794706d3a128cb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 29 10:42:17 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 29 10:48:33 2020 +0900
vcl: remove or rename too long methods names in VectorGraphicData
Change-Id: I8a64d27927b608afdc7996e0b0bbc59a58fde90f
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index ae00508380e1..c2240ed612e5 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -517,7 +517,7 @@ namespace emfio
return;
}
- if (pVectorGraphicData->getVectorGraphicDataType() != VectorGraphicDataType::Pdf)
+ if (pVectorGraphicData->getType() != VectorGraphicDataType::Pdf)
{
return;
}
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index a15dc12f53e6..2d930f897359 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -256,7 +256,7 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto
auto const & rVectorGraphicData(aGraphic.getVectorGraphicData());
bool bContainsNoGeometry(false);
- if(bool(rVectorGraphicData) && VectorGraphicDataType::Svg == rVectorGraphicData->getVectorGraphicDataType())
+ if(bool(rVectorGraphicData) && VectorGraphicDataType::Svg == rVectorGraphicData->getType())
{
const drawinglayer::primitive2d::Primitive2DContainer aContainer(rVectorGraphicData->getPrimitive2DSequence());
diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx
index 02511dd7909c..18800bac04d9 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -64,12 +64,12 @@ private:
std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence;
BitmapEx maReplacement;
size_t mNestedBitmapSize;
- VectorGraphicDataType meVectorGraphicDataType;
+ VectorGraphicDataType meType;
// extra:
std::unique_ptr<WmfExternal> mpExternalHeader;
- // If the vector format has more pages this denotes which page to render
+ /// If the vector format has more pages this denotes which page to render
sal_Int32 mnPageIndex;
/// Useful for PDF, which is vector-based, but still rendered to a bitmap.
@@ -104,23 +104,21 @@ public:
return maDataContainer;
}
- sal_uInt32 getVectorGraphicDataArrayLength() const
- {
- return maDataContainer.getSize();
- }
-
enum class State { UNPARSED, PARSED };
std::pair<State, size_t> getSizeBytes() const;
- const VectorGraphicDataType& getVectorGraphicDataType() const { return meVectorGraphicDataType; }
+ const VectorGraphicDataType& getType() const { return meType; }
/// data read and evtl. on demand creation
const basegfx::B2DRange& getRange() const;
- const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& getPrimitive2DSequence() const;
+ const std::deque<css::uno::Reference<css::graphic::XPrimitive2D>>& getPrimitive2DSequence() const;
const BitmapEx& getReplacement() const;
BitmapChecksum GetChecksum() const;
- sal_Int32 getPageIndex() const { return std::max(sal_Int32(0), mnPageIndex); }
+ sal_Int32 getPageIndex() const
+ {
+ return std::max(sal_Int32(0), mnPageIndex);
+ }
void setPageIndex(sal_Int32 nPageIndex)
{
diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index 85fb33d8243c..243699c99743 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -107,8 +107,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testImportSimpleText)
Graphic aGraphic = pGraphicObject->GetGraphic();
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
// Mark the object
SdrView* pView = pViewShell->GetView();
@@ -197,8 +196,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
Graphic aGraphic = pGraphicObject->GetGraphic();
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
// Write the PDF
aContainer = pVectorGraphicData->getBinaryDataContainer();
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 6397f8c25acc..9b898119a47c 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -303,8 +303,7 @@ void LOKitSearchTest::testSearchInPDFNonExisting()
Graphic aGraphic = pGraphicObject->GetGraphic();
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
lcl_search("NonExisting");
@@ -332,8 +331,7 @@ void LOKitSearchTest::testSearchInPDF()
Graphic aGraphic = pGraphicObject->GetGraphic();
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
// Search
lcl_search("ABC");
@@ -381,8 +379,7 @@ void LOKitSearchTest::testSearchInPDFOnePDFObject()
Graphic aGraphic = pGraphicObject->GetGraphic();
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
// Search down
lcl_search("ABC", false, false);
@@ -419,8 +416,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
Graphic aGraphic = pGraphicObject->GetGraphic();
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
}
// Search for "him"
@@ -511,8 +507,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
Graphic aGraphic = pGraphicObject->GetGraphic();
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
}
// Expected for backwards search is:
@@ -633,8 +628,7 @@ void LOKitSearchTest::testSearchIn2MixedObjects()
auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
}
// Let's try to search now
@@ -716,8 +710,7 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
CPPUNIT_ASSERT(pGraphicObject);
auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
}
// Check Object 3
@@ -743,8 +736,7 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
CPPUNIT_ASSERT(pGraphicObject);
auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Svg,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Svg, pVectorGraphicData->getType());
}
// Check Object 6
@@ -756,8 +748,7 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
CPPUNIT_ASSERT(pGraphicObject);
auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
}
// Search "ABC" which is in all objects (2 times in Object 3)
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 59e740b4bda1..1e58117cdb81 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1154,7 +1154,7 @@ bool isValidVectorGraphicObject(const sd::outliner::IteratorPosition& rPosition)
if (pGraphicObject)
{
auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
- if (pVectorGraphicData && VectorGraphicDataType::Pdf == pVectorGraphicData->getVectorGraphicDataType())
+ if (pVectorGraphicData && VectorGraphicDataType::Pdf == pVectorGraphicData->getType())
{
return true;
}
diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx
index fb483c5bfe54..a43f17cee56b 100644
--- a/svx/source/core/graphichelper.cxx
+++ b/svx/source/core/graphichelper.cxx
@@ -69,9 +69,9 @@ void GraphicHelper::GetPreferredExtension( OUString& rExtension, const Graphic&
OUString aExtension = "png";
auto const & rVectorGraphicDataPtr(rGraphic.getVectorGraphicData());
- if (rVectorGraphicDataPtr && rVectorGraphicDataPtr->getVectorGraphicDataArrayLength())
+ if (rVectorGraphicDataPtr && !rVectorGraphicDataPtr->getBinaryDataContainer().isEmpty())
{
- switch (rVectorGraphicDataPtr->getVectorGraphicDataType())
+ switch (rVectorGraphicDataPtr->getType())
{
case VectorGraphicDataType::Wmf:
aExtension = "wmf";
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index f688c32df82b..9dd795bb632b 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -2103,7 +2103,7 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
Graphic aGraphic = pGraf->GetGraphic();
auto const & pVectorGraphicData = aGraphic.getVectorGraphicData();
- if (pVectorGraphicData && pVectorGraphicData->getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+ if (pVectorGraphicData && pVectorGraphicData->getType() == VectorGraphicDataType::Pdf)
{
#if HAVE_FEATURE_PDFIUM
aLogicRect = pGraf->GetLogicRect();
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index c0904bf1e1ce..8e0461272fd9 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -142,7 +142,7 @@ void SdrGrafObj::onGraphicChanged()
// Skip for PDF as it is only a bitmap primitive in a sequence and
// doesn't contain metadata. However getting the primitive sequence
// will also trigger a premature rendering of the PDF.
- if (rVectorGraphicDataPtr->getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+ if (rVectorGraphicDataPtr->getType() == VectorGraphicDataType::Pdf)
return;
const drawinglayer::primitive2d::Primitive2DContainer aSequence(rVectorGraphicDataPtr->getPrimitive2DSequence());
@@ -560,7 +560,7 @@ OUString SdrGrafObj::TakeObjNameSingul() const
if (rVectorGraphicDataPtr)
{
- switch (rVectorGraphicDataPtr->getVectorGraphicDataType())
+ switch (rVectorGraphicDataPtr->getType())
{
case VectorGraphicDataType::Svg:
{
@@ -635,7 +635,7 @@ OUString SdrGrafObj::TakeObjNamePlural() const
if (rVectorGraphicDataPtr)
{
- switch (rVectorGraphicDataPtr->getVectorGraphicDataType())
+ switch (rVectorGraphicDataPtr->getType())
{
case VectorGraphicDataType::Svg:
{
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 6dba9e722a7d..9f53d9c22d41 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -129,12 +129,12 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName,
// #i121128# use shortcut to write Vector Graphic Data data in original form (if possible)
auto const & rVectorGraphicDataPtr(rGraphic.getVectorGraphicData());
- if (rVectorGraphicDataPtr && rVectorGraphicDataPtr->getVectorGraphicDataArrayLength())
+ if (rVectorGraphicDataPtr && rVectorGraphicDataPtr->getBinaryDataContainer().getSize())
{
- const bool bIsSvg(rFilterName.equalsIgnoreAsciiCase("svg") && VectorGraphicDataType::Svg == rVectorGraphicDataPtr->getVectorGraphicDataType());
- const bool bIsWmf(rFilterName.equalsIgnoreAsciiCase("wmf") && VectorGraphicDataType::Wmf == rVectorGraphicDataPtr->getVectorGraphicDataType());
- const bool bIsEmf(rFilterName.equalsIgnoreAsciiCase("emf") && VectorGraphicDataType::Emf == rVectorGraphicDataPtr->getVectorGraphicDataType());
- const bool bIsPdf(rFilterName.equalsIgnoreAsciiCase("pdf") && VectorGraphicDataType::Pdf == rVectorGraphicDataPtr->getVectorGraphicDataType());
+ const bool bIsSvg(rFilterName.equalsIgnoreAsciiCase("svg") && VectorGraphicDataType::Svg == rVectorGraphicDataPtr->getType());
+ const bool bIsWmf(rFilterName.equalsIgnoreAsciiCase("wmf") && VectorGraphicDataType::Wmf == rVectorGraphicDataPtr->getType());
+ const bool bIsEmf(rFilterName.equalsIgnoreAsciiCase("emf") && VectorGraphicDataType::Emf == rVectorGraphicDataPtr->getType());
+ const bool bIsPdf(rFilterName.equalsIgnoreAsciiCase("pdf") && VectorGraphicDataType::Pdf == rVectorGraphicDataPtr->getType());
if (bIsSvg || bIsWmf || bIsEmf || bIsPdf)
{
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index e4829860a515..4a998039a4bc 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -377,8 +377,7 @@ void GraphicTest::testEmfToWmfConversion()
sal_uInt16 nFormat = aGraphicFilter.GetImportFormatNumberForShortName(u"WMF");
CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE,
aGraphicFilter.ImportGraphic(aGraphic, OUString(), aStream, nFormat));
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Wmf,
- aGraphic.getVectorGraphicData()->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Wmf, aGraphic.getVectorGraphicData()->getType());
// Save as WMF.
sal_uInt16 nFilterType = aGraphicFilter.GetExportFormatNumberForShortName(u"WMF");
@@ -661,7 +660,7 @@ void GraphicTest::testSwappingVectorGraphic_SVG_WithGfxLink()
CPPUNIT_ASSERT_EQUAL(true, bool(pVectorData));
CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
- CPPUNIT_ASSERT_EQUAL(sal_uInt32(223), pVectorData->getVectorGraphicDataArrayLength());
+ CPPUNIT_ASSERT_EQUAL(size_t(223), pVectorData->getBinaryDataContainer().getSize());
CPPUNIT_ASSERT_EQUAL(true, aGraphic.IsGfxLink());
CPPUNIT_ASSERT_EQUAL(sal_uInt32(223), aGraphic.GetGfxLink().GetDataSize());
@@ -711,8 +710,8 @@ void GraphicTest::testSwappingVectorGraphic_SVG_WithoutGfxLink()
GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
Graphic aInputGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
- CPPUNIT_ASSERT_EQUAL(sal_uInt32(223),
- aInputGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
+ CPPUNIT_ASSERT_EQUAL(size_t(223),
+ aInputGraphic.getVectorGraphicData()->getBinaryDataContainer().getSize());
// Create graphic
Graphic aGraphic(aInputGraphic.getVectorGraphicData());
@@ -721,8 +720,8 @@ void GraphicTest::testSwappingVectorGraphic_SVG_WithoutGfxLink()
CPPUNIT_ASSERT_EQUAL(true, bool(aGraphic.getVectorGraphicData()));
CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
- CPPUNIT_ASSERT_EQUAL(sal_uInt32(223),
- aGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
+ CPPUNIT_ASSERT_EQUAL(size_t(223),
+ aGraphic.getVectorGraphicData()->getBinaryDataContainer().getSize());
CPPUNIT_ASSERT_EQUAL(false, aGraphic.IsGfxLink());
@@ -775,8 +774,8 @@ void GraphicTest::testSwappingVectorGraphic_SVG_WithoutGfxLink()
CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
CPPUNIT_ASSERT_EQUAL(true, bool(aGraphic.getVectorGraphicData()));
- sal_uInt32 nVectorByteSize = aGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength();
- CPPUNIT_ASSERT_EQUAL(sal_uInt32(223), nVectorByteSize);
+ size_t nVectorByteSize = aGraphic.getVectorGraphicData()->getBinaryDataContainer().getSize();
+ CPPUNIT_ASSERT_EQUAL(size_t(223), nVectorByteSize);
CPPUNIT_ASSERT_EQUAL(false, aGraphic.IsGfxLink());
@@ -863,8 +862,8 @@ void GraphicTest::testSwappingGraphicProperties_SVG_WithoutGfxLink()
GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
Graphic aInputGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
- CPPUNIT_ASSERT_EQUAL(sal_uInt32(223),
- aInputGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
+ CPPUNIT_ASSERT_EQUAL(size_t(223),
+ aInputGraphic.getVectorGraphicData()->getBinaryDataContainer().getSize());
// Create graphic
Graphic aGraphic(aInputGraphic.getVectorGraphicData());
@@ -934,10 +933,9 @@ void GraphicTest::testSwappingVectorGraphic_PDF_WithGfxLink()
// Set the page index
aGraphic.getVectorGraphicData()->setPageIndex(1);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- aGraphic.getVectorGraphicData()->getVectorGraphicDataType());
- CPPUNIT_ASSERT_EQUAL(sal_uInt32(17693),
- aGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, aGraphic.getVectorGraphicData()->getType());
+ CPPUNIT_ASSERT_EQUAL(size_t(17693),
+ aGraphic.getVectorGraphicData()->getBinaryDataContainer().getSize());
CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getVectorGraphicData()->getPageIndex());
@@ -975,10 +973,9 @@ void GraphicTest::testSwappingVectorGraphic_PDF_WithoutGfxLink()
// Set the page index
aGraphic.getVectorGraphicData()->setPageIndex(1);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- aGraphic.getVectorGraphicData()->getVectorGraphicDataType());
- CPPUNIT_ASSERT_EQUAL(sal_uInt32(17693),
- aGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, aGraphic.getVectorGraphicData()->getType());
+ CPPUNIT_ASSERT_EQUAL(size_t(17693),
+ aGraphic.getVectorGraphicData()->getBinaryDataContainer().getSize());
CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getVectorGraphicData()->getPageIndex());
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 597737864a87..be03a3e005b8 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -62,8 +62,7 @@ void PDFiumLibraryTest::testDocument()
auto pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
@@ -89,8 +88,7 @@ void PDFiumLibraryTest::testPages()
auto pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
@@ -114,8 +112,7 @@ void PDFiumLibraryTest::testPageObjects()
auto pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
@@ -163,8 +160,7 @@ void PDFiumLibraryTest::testAnnotationsMadeInEvince()
auto pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
@@ -219,8 +215,7 @@ void PDFiumLibraryTest::testAnnotationsMadeInAcrobat()
auto pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
@@ -296,8 +291,7 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
auto pVectorGraphicData = aGraphic.getVectorGraphicData();
CPPUNIT_ASSERT(pVectorGraphicData);
- CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
- pVectorGraphicData->getVectorGraphicDataType());
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 35b060409d42..0aeb54fb5b85 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1984,9 +1984,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
// VectorGraphicDataType::Wmf means WMF or EMF, allow direct write in the WMF case
// only.
if (rVectorGraphicDataPtr
- && rVectorGraphicDataPtr->getVectorGraphicDataArrayLength()
- && VectorGraphicDataType::Wmf
- == rVectorGraphicDataPtr->getVectorGraphicDataType()
+ && rVectorGraphicDataPtr->getType() == VectorGraphicDataType::Wmf
+ && !rVectorGraphicDataPtr->getBinaryDataContainer().isEmpty()
&& !bIsEMF)
{
auto & aDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer();
@@ -2020,8 +2019,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
auto const & rVectorGraphicDataPtr(rGraphic.getVectorGraphicData());
if (rVectorGraphicDataPtr
- && rVectorGraphicDataPtr->getVectorGraphicDataArrayLength()
- && VectorGraphicDataType::Emf == rVectorGraphicDataPtr->getVectorGraphicDataType())
+ && rVectorGraphicDataPtr->getType() == VectorGraphicDataType::Emf
+ && !rVectorGraphicDataPtr->getBinaryDataContainer().isEmpty())
{
auto & aDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer();
rOStm.WriteBytes(aDataContainer.getData(), aDataContainer.getSize());
@@ -2115,8 +2114,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
auto const & rVectorGraphicDataPtr(rGraphic.getVectorGraphicData());
if (rVectorGraphicDataPtr
- && rVectorGraphicDataPtr->getVectorGraphicDataArrayLength()
- && VectorGraphicDataType::Svg == rVectorGraphicDataPtr->getVectorGraphicDataType())
+ && rVectorGraphicDataPtr->getType() == VectorGraphicDataType::Svg
+ && !rVectorGraphicDataPtr->getBinaryDataContainer().isEmpty())
{
auto & aDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer();
rOStm.WriteBytes(aDataContainer.getData(), aDataContainer.getSize());
diff --git a/vcl/source/gdi/TypeSerializer.cxx b/vcl/source/gdi/TypeSerializer.cxx
index c1525786fc56..dd71fa2343c7 100644
--- a/vcl/source/gdi/TypeSerializer.cxx
+++ b/vcl/source/gdi/TypeSerializer.cxx
@@ -362,7 +362,7 @@ void TypeSerializer::writeGraphic(const Graphic& rGraphic)
// this is used e.g. in swapping out graphic data and in transporting it over UNO API
// as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
// no problem to extend it; only used at runtime
- switch (pVectorGraphicData->getVectorGraphicDataType())
+ switch (pVectorGraphicData->getType())
{
case VectorGraphicDataType::Wmf:
{
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 83ae4c849b24..f6e9e74ad80e 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -672,8 +672,8 @@ const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
ensureAvailable();
if (!maMetaFile.GetActionSize()
&& maVectorGraphicData
- && (VectorGraphicDataType::Emf == maVectorGraphicData->getVectorGraphicDataType()
- || VectorGraphicDataType::Wmf == maVectorGraphicData->getVectorGraphicDataType()))
+ && (VectorGraphicDataType::Emf == maVectorGraphicData->getType()
+ || VectorGraphicDataType::Wmf == maVectorGraphicData->getType()))
{
// If we have a Emf/Wmf VectorGraphic object, we
// need a way to get the Metafile data out of the primitive
@@ -1173,7 +1173,7 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
// this is used e.g. in swapping out graphic data and in transporting it over UNO API
// as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
// no problem to extend it; only used at runtime
- switch (maVectorGraphicData->getVectorGraphicDataType())
+ switch (maVectorGraphicData->getType())
{
case VectorGraphicDataType::Wmf:
{
@@ -1197,7 +1197,7 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
}
}
- rStream.WriteUInt32(maVectorGraphicData->getVectorGraphicDataArrayLength());
+ rStream.WriteUInt32(maVectorGraphicData->getBinaryDataContainer().getSize());
rStream.WriteBytes(
maVectorGraphicData->getBinaryDataContainer().getData(),
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 1547f4a8ea99..95a01cce70fd 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9000,7 +9000,7 @@ void PDFWriterImpl::createEmbeddedFile(const Graphic& rGraphic, ReferenceXObject
// no pdf data.
rEmit.m_nBitmapObject = nBitmapObject;
- if (!rGraphic.getVectorGraphicData() || rGraphic.getVectorGraphicData()->getVectorGraphicDataType() != VectorGraphicDataType::Pdf)
+ if (!rGraphic.getVectorGraphicData() || rGraphic.getVectorGraphicData()->getType() != VectorGraphicDataType::Pdf)
return;
BinaryDataContainer const & rDataContainer = rGraphic.getVectorGraphicData()->getBinaryDataContainer();
@@ -9073,7 +9073,7 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const
{
m_aJPGs.emplace( m_aJPGs.begin() );
JPGEmit& rEmit = m_aJPGs.front();
- if (!rGraphic.getVectorGraphicData() || rGraphic.getVectorGraphicData()->getVectorGraphicDataType() != VectorGraphicDataType::Pdf || m_aContext.UseReferenceXObject)
+ if (!rGraphic.getVectorGraphicData() || rGraphic.getVectorGraphicData()->getType() != VectorGraphicDataType::Pdf || m_aContext.UseReferenceXObject)
rEmit.m_nObject = createObject();
rEmit.m_aID = aID;
rEmit.m_pStream = std::move( pStream );
@@ -9177,7 +9177,7 @@ const BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx& i_rBitmap, co
m_aBitmaps.push_front( BitmapEmit() );
m_aBitmaps.front().m_aID = aID;
m_aBitmaps.front().m_aBitmap = aBitmap;
- if (!rGraphic.getVectorGraphicData() || rGraphic.getVectorGraphicData()->getVectorGraphicDataType() != VectorGraphicDataType::Pdf || m_aContext.UseReferenceXObject)
+ if (!rGraphic.getVectorGraphicData() || rGraphic.getVectorGraphicData()->getType() != VectorGraphicDataType::Pdf || m_aContext.UseReferenceXObject)
m_aBitmaps.front().m_nObject = createObject();
createEmbeddedFile(rGraphic, m_aBitmaps.front().m_aReferenceXObject, m_aBitmaps.front().m_nObject);
it = m_aBitmaps.begin();
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index 7f11dc454753..24be63da30dc 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -113,9 +113,9 @@ static size_t estimateSize(
bool VectorGraphicData::operator==(const VectorGraphicData& rCandidate) const
{
- if (getVectorGraphicDataType() == rCandidate.getVectorGraphicDataType())
+ if (getType() == rCandidate.getType())
{
- if (getVectorGraphicDataArrayLength() == rCandidate.getVectorGraphicDataArrayLength())
+ if (maDataContainer.getSize() == rCandidate.maDataContainer.getSize())
{
if (0 == memcmp(
maDataContainer.getData(),
@@ -142,7 +142,7 @@ void VectorGraphicData::setWmfExternalHeader(const WmfExternal& aExtHeader)
void VectorGraphicData::ensurePdfReplacement()
{
- assert(getVectorGraphicDataType() == VectorGraphicDataType::Pdf);
+ assert(getType() == VectorGraphicDataType::Pdf);
if (!maReplacement.IsEmpty())
return; // nothing to do
@@ -166,7 +166,7 @@ void VectorGraphicData::ensureReplacement()
// shortcut for PDF - PDFium can generate the replacement bitmap for us
// directly
- if (getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+ if (getType() == VectorGraphicDataType::Pdf)
{
ensurePdfReplacement();
return;
@@ -193,7 +193,7 @@ void VectorGraphicData::ensureSequenceAndRange()
// create Vector Graphic Data interpreter
uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
- switch (getVectorGraphicDataType())
+ switch (getType())
{
case VectorGraphicDataType::Svg:
{
@@ -311,7 +311,7 @@ VectorGraphicData::VectorGraphicData(
maSequence(),
maReplacement(),
mNestedBitmapSize(0),
- meVectorGraphicDataType(eVectorDataType),
+ meType(eVectorDataType),
mnPageIndex(nPageIndex)
{
}
diff --git a/vcl/source/graphic/GraphicID.cxx b/vcl/source/graphic/GraphicID.cxx
index cfd2d751d246..f2a9afa60dbe 100644
--- a/vcl/source/graphic/GraphicID.cxx
+++ b/vcl/source/graphic/GraphicID.cxx
@@ -36,7 +36,7 @@ GraphicID::GraphicID(ImpGraphic const& rGraphic)
{
const basegfx::B2DRange& rRange = rVectorGraphicDataPtr->getRange();
- mnID1 |= rVectorGraphicDataPtr->getVectorGraphicDataArrayLength();
+ mnID1 |= rVectorGraphicDataPtr->getBinaryDataContainer().getSize();
mnID2 = basegfx::fround(rRange.getWidth());
mnID3 = basegfx::fround(rRange.getHeight());
mnID4 = vcl_get_checksum(0, rVectorGraphicDataPtr->getBinaryDataContainer().getData(),
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx
index 3c1003d29654..c5e04060bc1b 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -237,7 +237,7 @@ bool VectorGraphicSearch::search(OUString const& rSearchString,
{
auto pData = maGraphic.getVectorGraphicData();
- if (pData && pData->getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+ if (pData && pData->getType() == VectorGraphicDataType::Pdf)
{
if (searchPDF(pData))
{
commit 44e22e0732c70a1abff403bf2b9fcea0d71a7c5e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Dec 28 18:45:13 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 29 10:48:33 2020 +0900
vcl: remove VectorGraphicDataArray, use BinaryDataContainer instead
This change removes the contructor taking VectorGraphicDataArray
for constructing VectorGraphicData, and instead of this, use the
BinaryDataContainer instead. This further removes duplication and
copying of the binary source data for various vector graphics
formats (most importantly PDF and SVG).
Change-Id: I1b9abf1662e1f30965c9068d04cb0afb82b3edaf
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 8d55a9487d26..02511dd7909c 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 BinaryDataContainer& rDataContainer,
VectorGraphicDataType eVectorDataType,
diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx
index c62fcd47a1e5..52906069e483 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -164,15 +164,13 @@ bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWid
if ( !FileExists(aObj) )
return false;
- std::vector<sal_uInt8> aBinaryData;
+ auto aBinaryData = std::make_unique<std::vector<sal_uInt8>>();
OUString aPath = aObj.PathToFileName();
- if (!loadDataFromFile(aPath, aBinaryData))
+ if (!loadDataFromFile(aPath, *aBinaryData))
return false;
- VectorGraphicDataArray aVectorGraphicDataArray;
- std::copy(aBinaryData.cbegin(), aBinaryData.cend(), aVectorGraphicDataArray.begin());
-
- VectorGraphicData aVectorGraphicData(aVectorGraphicDataArray, VectorGraphicDataType::Svg);
+ BinaryDataContainer aDataContainer(aBinaryData);
+ VectorGraphicData aVectorGraphicData(aDataContainer, VectorGraphicDataType::Svg);
// transform into [0,0,width,width*aspect] std dimensions
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 65f3b8bb450f..35b060409d42 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1620,7 +1620,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;
}
@@ -1633,7 +1634,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;
}
@@ -1707,10 +1709,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..69376a621d79 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(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..2394c66d217d 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(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 b1cdf4790c01..c1525786fc56 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(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 aeb471852ec8..83ae4c849b24 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1546,14 +1546,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(rData);
if (rStream.GetError())
return false;
@@ -1578,7 +1578,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 609040f44129..7f11dc454753 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -252,9 +252,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;
@@ -301,21 +301,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,
commit ec92c4b2995d67e0c78236d0e739f6735d77d9a0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Dec 28 18:34:39 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 29 10:48:32 2020 +0900
vcl: a way to create data for BinaryDataContainer without copying
Construstor for BinaryDataContainer taking unique_ptr<sal_uInt8>
represents a way how to create and fill the data for the container
and make sure that the container is the only one that is managing
the data after construction.
Generally we don't want to give the access to the internal
shared_ptr to the outside, so with the unique_ptr we make sure
that there is no outside references present (which would be the
case if the we would take shared_ptr as the constructor) and the
unique_ptr is cleared (moved) after construction.
Change-Id: I123114c8bee92e342740d94a784b2c16e2564528
diff --git a/include/vcl/BinaryDataContainer.hxx b/include/vcl/BinaryDataContainer.hxx
index 94ace9767a07..d8a20a94aa3f 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -28,6 +28,7 @@ private:
public:
explicit BinaryDataContainer();
explicit BinaryDataContainer(const sal_uInt8* pData, size_t nSize);
+ explicit BinaryDataContainer(std::unique_ptr<std::vector<sal_uInt8>>& rData);
BinaryDataContainer(const BinaryDataContainer& rBinaryDataContainer)
: mpData(rBinaryDataContainer.mpData)
diff --git a/vcl/qa/cppunit/BinaryDataContainerTest.cxx b/vcl/qa/cppunit/BinaryDataContainerTest.cxx
index 597e7d4bc3aa..3f965e8bd3fd 100644
--- a/vcl/qa/cppunit/BinaryDataContainerTest.cxx
+++ b/vcl/qa/cppunit/BinaryDataContainerTest.cxx
@@ -19,14 +19,14 @@ namespace
{
class BinaryDataContainerTest : public CppUnit::TestFixture
{
- void test();
+ void testConstruct();
CPPUNIT_TEST_SUITE(BinaryDataContainerTest);
- CPPUNIT_TEST(test);
+ CPPUNIT_TEST(testConstruct);
CPPUNIT_TEST_SUITE_END();
};
-void BinaryDataContainerTest::test()
+void BinaryDataContainerTest::testConstruct()
{
{
BinaryDataContainer aContainer;
@@ -54,6 +54,21 @@ void BinaryDataContainerTest::test()
CPPUNIT_ASSERT_EQUAL(true, bool(aCopyOfContainer.isEmpty()));
CPPUNIT_ASSERT_EQUAL(size_t(0), aCopyOfContainer.getSize());
}
+ {
+ // construct a unique_ptr data array
+ std::vector<sal_uInt8> aTestByteArray = { 1, 2, 3, 4 };
+ auto aConstructionByteArray = std::make_unique<std::vector<sal_uInt8>>(aTestByteArray);
+
+ // remember for later to compare
+ const sal_uInt8* pInternal = aConstructionByteArray->data();
+
+ BinaryDataContainer aContainer(aConstructionByteArray);
+
+ // make sure the unique_ptr was moved into BinaryDataContainer
+ CPPUNIT_ASSERT_EQUAL(false, bool(aConstructionByteArray));
+ // make sure we didn't copy data into BinaryDataContainer (pointers match)
+ CPPUNIT_ASSERT_EQUAL(pInternal, aContainer.getData());
+ }
}
} // namespace
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx b/vcl/source/graphic/BinaryDataContainer.cxx
index 7576852215b1..4490fb78339b 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -19,6 +19,11 @@ BinaryDataContainer::BinaryDataContainer(const sal_uInt8* pData, size_t nSize)
std::copy(pData, pData + nSize, mpData->data());
}
+BinaryDataContainer::BinaryDataContainer(std::unique_ptr<std::vector<sal_uInt8>>& rData)
+ : mpData(std::move(rData))
+{
+}
+
size_t BinaryDataContainer::calculateHash() const
{
size_t nSeed = 0;
commit b9a453239b10eae808bd848afe87d3549b76eb3f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Dec 28 10:03:18 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 29 10:48:32 2020 +0900
vcl: use BinaryDataContianer in VectorGraphicData
This change is needed so we can use the same data in GfxLink and
in VectorGraphicData. Currently the data needed to be duplicated,
which is less than ideal.
Change-Id: I79419921d09681fa8f0b1ac4bf8ea84199d4aae6
diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx
index e231435312e8..8d55a9487d26 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -23,6 +23,7 @@
#include <basegfx/range/b2drange.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/BinaryDataContainer.hxx>
#include <rtl/ustring.hxx>
#include <deque>
#include <memory>
@@ -55,7 +56,7 @@ class VCL_DLLPUBLIC VectorGraphicData
{
private:
// the file and length
- VectorGraphicDataArray maVectorGraphicDataArray;
+ BinaryDataContainer maDataContainer;
// on demand created content
bool mbSequenceCreated;
@@ -89,6 +90,10 @@ public:
const VectorGraphicDataArray& rVectorGraphicDataArray,
VectorGraphicDataType eVectorDataType,
sal_Int32 nPageIndex = -1);
+ VectorGraphicData(
+ const BinaryDataContainer& rDataContainer,
+ VectorGraphicDataType eVectorDataType,
+ sal_Int32 nPageIndex = -1);
~VectorGraphicData();
/// compare op
@@ -98,8 +103,16 @@ public:
void setWmfExternalHeader(const WmfExternal& aExtHeader);
/// data read
- const VectorGraphicDataArray& getVectorGraphicDataArray() const { return maVectorGraphicDataArray; }
- sal_uInt32 getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray.getLength(); }
+ const BinaryDataContainer& getBinaryDataContainer() const
+ {
+ return maDataContainer;
+ }
+
+ sal_uInt32 getVectorGraphicDataArrayLength() const
+ {
+ return maDataContainer.getSize();
+ }
+
enum class State { UNPARSED, PARSED };
std::pair<State, size_t> getSizeBytes() const;
diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index f5e24fd19ede..85fb33d8243c 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -175,8 +175,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell();
CPPUNIT_ASSERT(pViewShell);
- const void* pData = nullptr;
- int nLength = 0;
+ BinaryDataContainer aContainer;
{
// Get the first page - there should be only one.
@@ -202,13 +201,15 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
pVectorGraphicData->getVectorGraphicDataType());
// Write the PDF
- pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ aContainer = pVectorGraphicData->getBinaryDataContainer();
}
{ // check graphic PDF has annotations
- auto pPDFDocument = pPdfiumLibrary->openDocument(pData, nLength);
+ CPPUNIT_ASSERT_EQUAL(false, aContainer.isEmpty());
+
+ auto pPDFDocument
+ = pPdfiumLibrary->openDocument(aContainer.getData(), aContainer.getSize());
auto pPDFPage = pPDFDocument->openPage(0);
CPPUNIT_ASSERT_EQUAL(2, pPDFPage->getAnnotationCount());
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index bf8681502682..259c14233efa 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1380,8 +1380,8 @@ void SdImportTest::testPDFImportShared()
{
Graphic const & rGraphic = aGraphics[i];
CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all PDF streams to be identical.",
- rFirstGraphic.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray(),
- rGraphic.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray());
+ rFirstGraphic.getVectorGraphicData()->getBinaryDataContainer().getData(),
+ rGraphic.getVectorGraphicData()->getBinaryDataContainer().getData());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all GfxLinks to be identical.",
rFirstGraphic.GetSharedGfxLink().get(),
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index e1ae905cef33..4cd84120fafe 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -125,8 +125,8 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools:
// Load the buffer using pdfium.
auto const& rVectorGraphicData = rGraphic.getVectorGraphicData();
- auto* pData = rVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- sal_Int32 nSize = rVectorGraphicData->getVectorGraphicDataArrayLength();
+ auto* pData = rVectorGraphicData->getBinaryDataContainer().getData();
+ sal_Int32 nSize = rVectorGraphicData->getBinaryDataContainer().getSize();
mpPdfDocument = mpPDFium->openDocument(pData, nSize);
if (!mpPdfDocument)
return;
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 1d0c23e92780..6dba9e722a7d 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -149,7 +149,8 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName,
if (pOStm)
{
- pOStm->WriteBytes(rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), rVectorGraphicDataPtr->getVectorGraphicDataArrayLength());
+ auto & rDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer();
+ pOStm->WriteBytes(rDataContainer.getData(), rDataContainer.getSize());
aMedium.Commit();
if (!aMedium.GetError())
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx b/vcl/inc/pdf/ExternalPDFStreams.hxx
index ab3d057bd83c..f47aa56578d8 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -18,6 +18,7 @@
#include <memory>
#include <vcl/filter/pdfdocument.hxx>
+#include <vcl/BinaryDataContainer.hxx>
namespace vcl
{
@@ -27,7 +28,7 @@ namespace vcl
// reused to avoid unnecessary parsing.
struct VCL_DLLPUBLIC ExternalPDFStream
{
- std::vector<sal_uInt8> maData;
+ BinaryDataContainer maDataContainer;
std::shared_ptr<filter::PDFDocument> mpPDFDocument;
std::map<sal_Int32, sal_Int32> maCopiedResources;
@@ -38,7 +39,7 @@ struct VCL_DLLPUBLIC ExternalPDFStream
if (!mpPDFDocument)
{
SvMemoryStream aPDFStream;
- aPDFStream.WriteBytes(maData.data(), maData.size());
+ aPDFStream.WriteBytes(maDataContainer.getData(), maDataContainer.getSize());
aPDFStream.Seek(0);
mpPDFDocument = std::make_shared<filter::PDFDocument>();
if (!mpPDFDocument->Read(aPDFStream))
@@ -61,7 +62,7 @@ private:
public:
ExternalPDFStreams() {}
- sal_Int32 store(const sal_uInt8* pData, sal_uInt32 nLength);
+ sal_Int32 store(BinaryDataContainer const& rDataContainer);
ExternalPDFStream& get(sal_uInt32 nIndex);
};
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 577f73ed1130..597737864a87 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -65,12 +65,11 @@ void PDFiumLibraryTest::testDocument()
CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
pVectorGraphicData->getVectorGraphicDataType());
- const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
CPPUNIT_ASSERT(pPdfium);
- auto pDocument = pPdfium->openDocument(pData, nLength);
+ auto pDocument = pPdfium->openDocument(rDataContainer.getData(), rDataContainer.getSize());
CPPUNIT_ASSERT(pDocument);
CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
@@ -93,11 +92,10 @@ void PDFiumLibraryTest::testPages()
CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
pVectorGraphicData->getVectorGraphicDataType());
- const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
- auto pDocument = pPdfium->openDocument(pData, nLength);
+ auto pDocument = pPdfium->openDocument(rDataContainer.getData(), rDataContainer.getSize());
CPPUNIT_ASSERT(pDocument);
CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
@@ -119,11 +117,10 @@ void PDFiumLibraryTest::testPageObjects()
CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
pVectorGraphicData->getVectorGraphicDataType());
- const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
- auto pDocument = pPdfium->openDocument(pData, nLength);
+ auto pDocument = pPdfium->openDocument(rDataContainer.getData(), rDataContainer.getSize());
CPPUNIT_ASSERT(pDocument);
CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
@@ -169,11 +166,10 @@ void PDFiumLibraryTest::testAnnotationsMadeInEvince()
CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
pVectorGraphicData->getVectorGraphicDataType());
- const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
- auto pDocument = pPdfium->openDocument(pData, nLength);
+ auto pDocument = pPdfium->openDocument(rDataContainer.getData(), rDataContainer.getSize());
CPPUNIT_ASSERT(pDocument);
CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
@@ -226,11 +222,10 @@ void PDFiumLibraryTest::testAnnotationsMadeInAcrobat()
CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
pVectorGraphicData->getVectorGraphicDataType());
- const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
- auto pDocument = pPdfium->openDocument(pData, nLength);
+ auto pDocument = pPdfium->openDocument(rDataContainer.getData(), rDataContainer.getSize());
CPPUNIT_ASSERT(pDocument);
CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
@@ -304,11 +299,10 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
pVectorGraphicData->getVectorGraphicDataType());
- const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
- int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ auto& rDataContainer = pVectorGraphicData->getBinaryDataContainer();
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
- auto pDocument = pPdfium->openDocument(pData, nLength);
+ auto pDocument = pPdfium->openDocument(rDataContainer.getData(), rDataContainer.getSize());
CPPUNIT_ASSERT(pDocument);
CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 02747b4e869b..65f3b8bb450f 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1986,7 +1986,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
== rVectorGraphicDataPtr->getVectorGraphicDataType()
&& !bIsEMF)
{
- rOStm.WriteBytes(rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), rVectorGraphicDataPtr->getVectorGraphicDataArrayLength());
+ auto & aDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer();
+ rOStm.WriteBytes(aDataContainer.getData(), aDataContainer.getSize());
if (rOStm.GetError())
{
@@ -2019,7 +2020,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
&& rVectorGraphicDataPtr->getVectorGraphicDataArrayLength()
&& VectorGraphicDataType::Emf == rVectorGraphicDataPtr->getVectorGraphicDataType())
{
- rOStm.WriteBytes(rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), rVectorGraphicDataPtr->getVectorGraphicDataArrayLength());
+ auto & aDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer();
+ rOStm.WriteBytes(aDataContainer.getData(), aDataContainer.getSize());
if (rOStm.GetError())
{
@@ -2113,7 +2115,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
&& rVectorGraphicDataPtr->getVectorGraphicDataArrayLength()
&& VectorGraphicDataType::Svg == rVectorGraphicDataPtr->getVectorGraphicDataType())
{
- rOStm.WriteBytes(rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), rVectorGraphicDataPtr->getVectorGraphicDataArrayLength());
+ auto & aDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer();
+ rOStm.WriteBytes(aDataContainer.getData(), aDataContainer.getSize());
if( rOStm.GetError() )
{
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 9c8493fcf58c..bfa27f68358b 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -442,18 +442,17 @@ 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.
- VectorGraphicDataArray aPdfDataArray = createVectorGraphicDataArray(*xStream);
- if (!aPdfDataArray.hasElements())
- return 0;
+ 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());
+ }
// Prepare the link with the PDF stream.
- const size_t nGraphicContentSize = aPdfDataArray.getLength();
- std::unique_ptr<sal_uInt8[]> pGraphicContent(new sal_uInt8[nGraphicContentSize]);
-
- std::copy(aPdfDataArray.begin(), aPdfDataArray.end(), pGraphicContent.get());
-
- auto pGfxLink = std::make_shared<GfxLink>(std::move(pGraphicContent), nGraphicContentSize,
- GfxLinkType::NativePdf);
+ auto pGfxLink = std::make_shared<GfxLink>(aBinaryDataContainer, GfxLinkType::NativePdf);
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
@@ -481,7 +480,7 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG
tools::Long nPageHeight = convertTwipToMm100(aPageSize.getY() * pointToTwipconversionRatio);
auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(
- aPdfDataArray, VectorGraphicDataType::Pdf, nPageIndex);
+ aBinaryDataContainer, 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/gdi/TypeSerializer.cxx b/vcl/source/gdi/TypeSerializer.cxx
index 114a8de73719..b1cdf4790c01 100644
--- a/vcl/source/gdi/TypeSerializer.cxx
+++ b/vcl/source/gdi/TypeSerializer.cxx
@@ -386,10 +386,10 @@ void TypeSerializer::writeGraphic(const Graphic& rGraphic)
}
}
- sal_uInt32 nSize = pVectorGraphicData->getVectorGraphicDataArrayLength();
+ sal_uInt32 nSize = pVectorGraphicData->getBinaryDataContainer().getSize();
mrStream.WriteUInt32(nSize);
- mrStream.WriteBytes(
- pVectorGraphicData->getVectorGraphicDataArray().getConstArray(), nSize);
+ mrStream.WriteBytes(pVectorGraphicData->getBinaryDataContainer().getData(),
+ nSize);
// For backwards compatibility, used to serialize path
mrStream.WriteUniOrByteString(OUString(), mrStream.GetStreamCharSet());
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 8dc81eb4987f..aeb471852ec8 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1200,8 +1200,8 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
rStream.WriteUInt32(maVectorGraphicData->getVectorGraphicDataArrayLength());
rStream.WriteBytes(
- maVectorGraphicData->getVectorGraphicDataArray().getConstArray(),
- maVectorGraphicData->getVectorGraphicDataArrayLength());
+ maVectorGraphicData->getBinaryDataContainer().getData(),
+ maVectorGraphicData->getBinaryDataContainer().getSize());
}
else if (ImplIsAnimated())
{
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 3ba778e09d49..1547f4a8ea99 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4484,12 +4484,12 @@ bool PDFWriterImpl::emitEmbeddedFiles()
aLine.append(rEmbeddedFile.m_nObject);
aLine.append(" 0 obj\n");
aLine.append("<< /Type /EmbeddedFile /Length ");
- aLine.append(static_cast<sal_Int64>(rEmbeddedFile.m_pData->size()));
+ aLine.append(static_cast<sal_Int64>(rEmbeddedFile.m_aDataContainer.getSize()));
aLine.append(" >>\nstream\n");
CHECK_RETURN(writeBuffer(aLine.getStr(), aLine.getLength()));
aLine.setLength(0);
- CHECK_RETURN(writeBuffer(rEmbeddedFile.m_pData->data(), rEmbeddedFile.m_pData->size()));
+ CHECK_RETURN(writeBuffer(rEmbeddedFile.m_aDataContainer.getData(), rEmbeddedFile.m_aDataContainer.getSize()));
aLine.append("\nendstream\nendobj\n\n");
CHECK_RETURN(writeBuffer(aLine.getStr(), aLine.getLength()));
@@ -9003,22 +9003,19 @@ void PDFWriterImpl::createEmbeddedFile(const Graphic& rGraphic, ReferenceXObject
if (!rGraphic.getVectorGraphicData() || rGraphic.getVectorGraphicData()->getVectorGraphicDataType() != VectorGraphicDataType::Pdf)
return;
- sal_uInt32 nLength = rGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength();
- auto const & rArray = rGraphic.getVectorGraphicData()->getVectorGraphicDataArray();
+ BinaryDataContainer const & rDataContainer = rGraphic.getVectorGraphicData()->getBinaryDataContainer();
if (m_aContext.UseReferenceXObject)
{
- auto pPDFData = std::make_shared<std::vector<sal_Int8>>(rArray.getConstArray(), rArray.getConstArray() + nLength);
-
// Store the original PDF data as an embedded file.
m_aEmbeddedFiles.emplace_back();
m_aEmbeddedFiles.back().m_nObject = createObject();
- m_aEmbeddedFiles.back().m_pData = pPDFData;
+ m_aEmbeddedFiles.back().m_aDataContainer = rDataContainer;
rEmit.m_nEmbeddedObject = m_aEmbeddedFiles.back().m_nObject;
}
else
{
- sal_Int32 aIndex = m_aExternalPDFStreams.store(reinterpret_cast<const sal_uInt8*>(rArray.getConstArray()), nLength);
+ sal_Int32 aIndex = m_aExternalPDFStreams.store(rDataContainer);
rEmit.m_nExternalPDFPageIndex = rGraphic.getVectorGraphicData()->getPageIndex();
rEmit.m_nExternalPDFDataIndex = aIndex;
}
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 25a2774f7ab7..cfbe450e859a 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -50,6 +50,7 @@
#include <o3tl/lru_map.hxx>
#include <comphelper/hash.hxx>
#include <tools/stream.hxx>
+#include <vcl/BinaryDataContainer.hxx>
#include <vcl/filter/pdfobjectcontainer.hxx>
#include <pdf/ExternalPDFStreams.hxx>
@@ -402,7 +403,7 @@ struct PDFEmbeddedFile
/// ID of the file.
sal_Int32 m_nObject;
/// Contents of the file.
- std::shared_ptr<std::vector<sal_Int8>> m_pData;
+ BinaryDataContainer m_aDataContainer;
PDFEmbeddedFile()
: m_nObject(0)
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index 61618b7adfe8..609040f44129 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -39,6 +39,7 @@
#include <vcl/outdev.hxx>
#include <vcl/wmfexternal.hxx>
#include <vcl/pdfread.hxx>
+#include <unotools/streamwrap.hxx>
using namespace ::com::sun::star;
@@ -117,9 +118,9 @@ bool VectorGraphicData::operator==(const VectorGraphicData& rCandidate) const
if (getVectorGraphicDataArrayLength() == rCandidate.getVectorGraphicDataArrayLength())
{
if (0 == memcmp(
- getVectorGraphicDataArray().getConstArray(),
- rCandidate.getVectorGraphicDataArray().getConstArray(),
- getVectorGraphicDataArrayLength()))
+ maDataContainer.getData(),
+ rCandidate.maDataContainer.getData(),
+ maDataContainer.getSize()))
{
return true;
}
@@ -151,8 +152,8 @@ void VectorGraphicData::ensurePdfReplacement()
sal_Int32 nUsePageIndex = 0;
if (mnPageIndex >= 0)
nUsePageIndex = mnPageIndex;
- vcl::RenderPDFBitmaps(maVectorGraphicDataArray.getConstArray(),
- maVectorGraphicDataArray.getLength(), aBitmaps, nUsePageIndex, 1,
+ vcl::RenderPDFBitmaps(maDataContainer.getData(),
+ maDataContainer.getSize(), aBitmaps, nUsePageIndex, 1,
&maSizeHint);
if (!aBitmaps.empty())
maReplacement = aBitmaps[0];
@@ -181,7 +182,9 @@ void VectorGraphicData::ensureReplacement()
void VectorGraphicData::ensureSequenceAndRange()
{
- if (mbSequenceCreated || !maVectorGraphicDataArray.hasElements())
+ printf ("VectorGraphicData::ensureSequenceAndRange\n");
+
+ if (mbSequenceCreated || maDataContainer.isEmpty())
return;
// import SVG to maSequence, also set maRange
@@ -194,11 +197,15 @@ void VectorGraphicData::ensureSequenceAndRange()
{
case VectorGraphicDataType::Svg:
{
+ css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize());
+ std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin());
+ const uno::Reference<io::XInputStream> xInputStream(new comphelper::SequenceInputStream(aDataSequence));
+
+
const uno::Reference< graphic::XSvgParser > xSvgParser = graphic::SvgTools::create(xContext);
- const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maVectorGraphicDataArray));
- if (myInputStream.is())
- maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xSvgParser->getDecomposition(myInputStream, OUString()));
+ if (xInputStream.is())
+ maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xSvgParser->getDecomposition(xInputStream, OUString()));
break;
}
@@ -206,7 +213,11 @@ void VectorGraphicData::ensureSequenceAndRange()
case VectorGraphicDataType::Wmf:
{
const uno::Reference< graphic::XEmfParser > xEmfParser = graphic::EmfTools::create(xContext);
- const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maVectorGraphicDataArray));
+
+ css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize());
+ std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin());
+ const uno::Reference<io::XInputStream> xInputStream(new comphelper::SequenceInputStream(aDataSequence));
+
uno::Sequence< ::beans::PropertyValue > aSequence;
if (mpExternalHeader)
@@ -214,7 +225,7 @@ void VectorGraphicData::ensureSequenceAndRange()
aSequence = mpExternalHeader->getSequence();
}
- if (myInputStream.is())
+ if (xInputStream.is())
{
// Pass the size hint of the graphic to the EMF parser.
geometry::RealPoint2D aSizeHint;
@@ -224,15 +235,12 @@ void VectorGraphicData::ensureSequenceAndRange()
if (!mbEnableEMFPlus)
{
- auto aVector
- = comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(
- aSequence);
- aVector.push_back(
- comphelper::makePropertyValue("EMFPlusEnable", uno::makeAny(false)));
+ auto aVector = comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aSequence);
+ aVector.push_back(comphelper::makePropertyValue("EMFPlusEnable", uno::makeAny(false)));
aSequence = comphelper::containerToSequence(aVector);
}
- maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xEmfParser->getDecomposition(myInputStream, OUString(), aSequence));
+ maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xEmfParser->getDecomposition(xInputStream, OUString(), aSequence));
}
break;
@@ -243,7 +251,10 @@ void VectorGraphicData::ensureSequenceAndRange()
uno::Sequence<beans::PropertyValue> aDecompositionParameters = comphelper::InitPropertySequence({
{"PageIndex", uno::makeAny<sal_Int32>(mnPageIndex)},
});
- auto xPrimitive2D = xPdfDecomposer->getDecomposition(maVectorGraphicDataArray, aDecompositionParameters);
+ // 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);
maSequence = comphelper::sequenceToContainer<std::deque<uno::Reference<graphic::XPrimitive2D>>>(xPrimitive2D);
break;
@@ -280,13 +291,13 @@ void VectorGraphicData::ensureSequenceAndRange()
std::pair<VectorGraphicData::State, size_t> VectorGraphicData::getSizeBytes() const
{
- if (!maSequence.empty() && maVectorGraphicDataArray.hasElements())
+ if (!maSequence.empty() && !maDataContainer.isEmpty())
{
- return std::make_pair(State::PARSED, maVectorGraphicDataArray.getLength() + mNestedBitmapSize);
+ return std::make_pair(State::PARSED, maDataContainer.getSize() + mNestedBitmapSize);
}
else
{
- return std::make_pair(State::UNPARSED, maVectorGraphicDataArray.getLength());
+ return std::make_pair(State::UNPARSED, maDataContainer.getSize());
}
}
@@ -294,7 +305,22 @@ VectorGraphicData::VectorGraphicData(
const VectorGraphicDataArray& rVectorGraphicDataArray,
VectorGraphicDataType eVectorDataType,
sal_Int32 nPageIndex)
-: maVectorGraphicDataArray(rVectorGraphicDataArray),
+: 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)
+: maDataContainer(rDataContainer),
mbSequenceCreated(false),
maRange(),
maSequence(),
@@ -332,7 +358,7 @@ const BitmapEx& VectorGraphicData::getReplacement() const
BitmapChecksum VectorGraphicData::GetChecksum() const
{
- return vcl_get_checksum(0, maVectorGraphicDataArray.getConstArray(), maVectorGraphicDataArray.getLength());
+ return vcl_get_checksum(0, maDataContainer.getData(), maDataContainer.getSize());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/GraphicID.cxx b/vcl/source/graphic/GraphicID.cxx
index 1cad217241fa..cfd2d751d246 100644
--- a/vcl/source/graphic/GraphicID.cxx
+++ b/vcl/source/graphic/GraphicID.cxx
@@ -39,9 +39,8 @@ GraphicID::GraphicID(ImpGraphic const& rGraphic)
mnID1 |= rVectorGraphicDataPtr->getVectorGraphicDataArrayLength();
mnID2 = basegfx::fround(rRange.getWidth());
mnID3 = basegfx::fround(rRange.getHeight());
- mnID4 = vcl_get_checksum(
- 0, rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(),
- rVectorGraphicDataPtr->getVectorGraphicDataArrayLength());
+ mnID4 = vcl_get_checksum(0, rVectorGraphicDataPtr->getBinaryDataContainer().getData(),
+ rVectorGraphicDataPtr->getBinaryDataContainer().getSize());
}
else if (rGraphic.ImplIsAnimated())
{
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx
index dfa747bc1a6a..3c1003d29654 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -252,8 +252,8 @@ bool VectorGraphicSearch::search(OUString const& rSearchString,
bool VectorGraphicSearch::searchPDF(std::shared_ptr<VectorGraphicData> const& rData)
{
mpImplementation->mpPdfDocument
- = FPDF_LoadMemDocument(rData->getVectorGraphicDataArray().getConstArray(),
- rData->getVectorGraphicDataArrayLength(), /*password=*/nullptr);
+ = FPDF_LoadMemDocument(rData->getBinaryDataContainer().getData(),
+ rData->getBinaryDataContainer().getSize(), /*password=*/nullptr);
if (!mpImplementation->mpPdfDocument)
{
diff --git a/vcl/source/pdf/ExternalPDFStreams.cxx b/vcl/source/pdf/ExternalPDFStreams.cxx
index 08f31ed22829..e3716e1e0aed 100644
--- a/vcl/source/pdf/ExternalPDFStreams.cxx
+++ b/vcl/source/pdf/ExternalPDFStreams.cxx
@@ -13,19 +13,18 @@
namespace vcl
{
-sal_Int32 ExternalPDFStreams::store(const sal_uInt8* pData, sal_uInt32 nLength)
+sal_Int32 ExternalPDFStreams::store(BinaryDataContainer const& rDataContainer)
{
sal_Int32 nIndex = -1;
- std::vector<sal_uInt8> aHash
- = comphelper::Hash::calculateHash(pData, nLength, comphelper::HashType::SHA1);
+ std::vector<sal_uInt8> aHash = comphelper::Hash::calculateHash(
+ rDataContainer.getData(), rDataContainer.getSize(), comphelper::HashType::SHA1);
auto it = maStreamIndexMap.find(aHash);
if (it == maStreamIndexMap.end())
{
auto& rExternalStream = maStreamList.emplace_back();
- rExternalStream.maData.resize(nLength);
- std::copy(pData, pData + nLength, rExternalStream.maData.begin());
+ rExternalStream.maDataContainer = rDataContainer;
nIndex = maStreamList.size() - 1;
maStreamIndexMap.emplace(aHash, nIndex);
}
commit 82080920848d63168c714f1b3745f601ac1fbb8d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Dec 27 19:07:57 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 29 10:48:31 2020 +0900
vcl: implement BinaryDataContainer copy, move + test
Also remove constructor that takes size only - BinaryDataContainer
should always be constructed with data, that is copied into the
container and should be immutable.
Change-Id: Ic61b393b7729b948843bd20e6676c9290c68936f
diff --git a/include/vcl/BinaryDataContainer.hxx b/include/vcl/BinaryDataContainer.hxx
index 5eb5f4486b9e..94ace9767a07 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -27,13 +27,29 @@ private:
public:
explicit BinaryDataContainer();
- explicit BinaryDataContainer(size_t nSize);
explicit BinaryDataContainer(const sal_uInt8* pData, size_t nSize);
- explicit BinaryDataContainer(const BinaryDataContainer& rBinaryDataContainer) = default;
- explicit BinaryDataContainer(BinaryDataContainer&& rBinaryDataContainer) = default;
- BinaryDataContainer& operator=(const BinaryDataContainer& rBinaryDataContainer) = default;
- BinaryDataContainer& operator=(BinaryDataContainer&& rBinaryDataContainer) = default;
+ BinaryDataContainer(const BinaryDataContainer& rBinaryDataContainer)
+ : mpData(rBinaryDataContainer.mpData)
+ {
+ }
+
+ BinaryDataContainer(BinaryDataContainer&& rBinaryDataContainer)
+ : mpData(std::move(rBinaryDataContainer.mpData))
+ {
+ }
+
+ BinaryDataContainer& operator=(const BinaryDataContainer& rBinaryDataContainer)
+ {
+ mpData = rBinaryDataContainer.mpData;
+ return *this;
+ }
+
+ BinaryDataContainer& operator=(BinaryDataContainer&& rBinaryDataContainer)
+ {
+ mpData = std::move(rBinaryDataContainer.mpData);
+ return *this;
+ }
size_t getSize() const { return mpData ? mpData->size() : 0; }
bool isEmpty() const { return mpData && mpData->empty(); }
diff --git a/vcl/CppunitTest_vcl_graphic_test.mk b/vcl/CppunitTest_vcl_graphic_test.mk
index 2f2c61735ef8..9221fd474fdd 100644
--- a/vcl/CppunitTest_vcl_graphic_test.mk
+++ b/vcl/CppunitTest_vcl_graphic_test.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_graphic_test, \
vcl/qa/cppunit/GraphicFormatDetectorTest \
vcl/qa/cppunit/GraphicNativeMetadataTest \
vcl/qa/cppunit/VectorGraphicSearchTest \
+ vcl/qa/cppunit/BinaryDataContainerTest \
))
$(eval $(call gb_CppunitTest_use_externals,vcl_graphic_test, \
diff --git a/vcl/qa/cppunit/BinaryDataContainerTest.cxx b/vcl/qa/cppunit/BinaryDataContainerTest.cxx
new file mode 100644
index 000000000000..597e7d4bc3aa
--- /dev/null
+++ b/vcl/qa/cppunit/BinaryDataContainerTest.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <vcl/BinaryDataContainer.hxx>
+
+using namespace css;
+
+namespace
+{
+class BinaryDataContainerTest : public CppUnit::TestFixture
+{
+ void test();
+
+ CPPUNIT_TEST_SUITE(BinaryDataContainerTest);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void BinaryDataContainerTest::test()
+{
+ {
+ BinaryDataContainer aContainer;
+ CPPUNIT_ASSERT_EQUAL(true, bool(aContainer.isEmpty()));
+ CPPUNIT_ASSERT_EQUAL(size_t(0), aContainer.getSize());
+ }
+ {
+ std::vector<sal_uInt8> aTestByteArray = { 1, 2, 3, 4 };
+ BinaryDataContainer aContainer(aTestByteArray.data(), aTestByteArray.size());
+ CPPUNIT_ASSERT_EQUAL(false, bool(aContainer.isEmpty()));
+ CPPUNIT_ASSERT_EQUAL(size_t(4), aContainer.getSize());
+
+ // Test Copy
+ BinaryDataContainer aCopyOfContainer = aContainer;
+ CPPUNIT_ASSERT_EQUAL(false, bool(aCopyOfContainer.isEmpty()));
+ CPPUNIT_ASSERT_EQUAL(size_t(4), aCopyOfContainer.getSize());
+ CPPUNIT_ASSERT_EQUAL(aCopyOfContainer.getData(), aContainer.getData());
+
+ // Test Move
+ BinaryDataContainer aMovedInContainer = std::move(aCopyOfContainer);
+ CPPUNIT_ASSERT_EQUAL(false, bool(aMovedInContainer.isEmpty()));
+ CPPUNIT_ASSERT_EQUAL(size_t(4), aMovedInContainer.getSize());
+ CPPUNIT_ASSERT_EQUAL(aMovedInContainer.getData(), aContainer.getData());
+
+ CPPUNIT_ASSERT_EQUAL(true, bool(aCopyOfContainer.isEmpty()));
+ CPPUNIT_ASSERT_EQUAL(size_t(0), aCopyOfContainer.getSize());
+ }
+}
+
+} // namespace
+
+CPPUNIT_TEST_SUITE_REGISTRATION(BinaryDataContainerTest);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx b/vcl/source/graphic/BinaryDataContainer.cxx
index 4c556195fe6a..7576852215b1 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -13,11 +13,6 @@
BinaryDataContainer::BinaryDataContainer() = default;
-BinaryDataContainer::BinaryDataContainer(size_t nSize)
- : mpData(std::make_shared<std::vector<sal_uInt8>>(nSize))
-{
-}
-
BinaryDataContainer::BinaryDataContainer(const sal_uInt8* pData, size_t nSize)
: mpData(std::make_shared<std::vector<sal_uInt8>>(nSize))
{
commit f7e03d34232251c9d8d4938098288344a12dd53c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Dec 26 12:41:08 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 29 10:48:31 2020 +0900
vcl: remove "path" attribute from VectorGraphicData
This isn't used for anything important for the vector graphic
and is mostly empty string anyways.
Change-Id: I1c5b52b5b407bd320cb5053141f1699971607399
diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx
index cb3963947d2d..e231435312e8 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -57,9 +57,6 @@ private:
// the file and length
VectorGraphicDataArray maVectorGraphicDataArray;
- // The absolute Path if available
- OUString maPath;
-
// on demand created content
bool mbSequenceCreated;
basegfx::B2DRange maRange;
@@ -90,7 +87,6 @@ private:
public:
VectorGraphicData(
const VectorGraphicDataArray& rVectorGraphicDataArray,
- const OUString& rPath,
VectorGraphicDataType eVectorDataType,
sal_Int32 nPageIndex = -1);
~VectorGraphicData();
@@ -106,7 +102,7 @@ public:
sal_uInt32 getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray.getLength(); }
enum class State { UNPARSED, PARSED };
std::pair<State, size_t> getSizeBytes() const;
- const OUString& getPath() const { return maPath; }
+
const VectorGraphicDataType& getVectorGraphicDataType() const { return meVectorGraphicDataType; }
/// data read and evtl. on demand creation
diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx
index 37011ff1cc2f..c62fcd47a1e5 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -166,13 +166,13 @@ bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWid
std::vector<sal_uInt8> aBinaryData;
OUString aPath = aObj.PathToFileName();
- if (!loadDataFromFile(aObj.PathToFileName(), aBinaryData))
+ if (!loadDataFromFile(aPath, aBinaryData))
return false;
VectorGraphicDataArray aVectorGraphicDataArray;
std::copy(aBinaryData.cbegin(), aBinaryData.cend(), aVectorGraphicDataArray.begin());
- VectorGraphicData aVectorGraphicData(aVectorGraphicDataArray, aPath, VectorGraphicDataType::Svg);
+ VectorGraphicData aVectorGraphicData(aVectorGraphicDataArray, VectorGraphicDataType::Svg);
// transform into [0,0,width,width*aspect] std dimensions
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 538995ff5dd2..e4829860a515 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -325,6 +325,10 @@ void GraphicTest::testUnloadedGraphicSizeUnit()
Size aMtfSize100(42, 42);
SvFileStream aStream(aURL, StreamMode::READ);
Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream, 0, &aMtfSize100);
+
+ CPPUNIT_ASSERT_EQUAL(Size(42, 42), aGraphic.GetPrefSize());
+
+ // Force it to swap in
aGraphic.makeAvailable();
// Without the accompanying fix in place, this test would have failed with:
@@ -753,10 +757,10 @@ void GraphicTest::testSwappingVectorGraphic_SVG_WithoutGfxLink()
CPPUNIT_ASSERT_EQUAL(true, bool(xStream));
// Check size of the stream
- CPPUNIT_ASSERT_EQUAL(sal_uInt64(249), xStream->remainingSize());
+ CPPUNIT_ASSERT_EQUAL(sal_uInt64(247), xStream->remainingSize());
std::vector<unsigned char> aHash = calculateHash(xStream);
- CPPUNIT_ASSERT_EQUAL(std::string("322da9ea0683f03ce35cf8a71e59b686b9be28e8"),
+ CPPUNIT_ASSERT_EQUAL(std::string("666820973fd95e6cd9e7bc5f1c53732acbc99326"),
toHexString(aHash));
}
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 2a708336d233..02747b4e869b 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1620,7 +1620,7 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
if(!aMemStream.GetError() )
{
- auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, rPath, VectorGraphicDataType::Svg);
+ auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, VectorGraphicDataType::Svg);
rGraphic = Graphic(aVectorGraphicDataPtr);
bOkay = true;
}
@@ -1633,7 +1633,7 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
if(!rIStream.GetError())
{
- auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, rPath, VectorGraphicDataType::Svg);
+ auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, VectorGraphicDataType::Svg);
rGraphic = Graphic(aVectorGraphicDataPtr);
bOkay = true;
}
@@ -1710,7 +1710,6 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
auto aVectorGraphicDataPtr =
std::make_shared<VectorGraphicData>(
aNewData,
- rPath,
aDataType);
if (pExtHeader)
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index ecc22331520a..9c8493fcf58c 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -240,8 +240,8 @@ bool importPdfVectorGraphicData(SvStream& rStream,
return false;
}
- rVectorGraphicData = std::make_shared<VectorGraphicData>(aPdfDataArray, OUString(),
- VectorGraphicDataType::Pdf);
+ rVectorGraphicData
+ = std::make_shared<VectorGraphicData>(aPdfDataArray, VectorGraphicDataType::Pdf);
return true;
}
@@ -481,7 +481,7 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG
tools::Long nPageHeight = convertTwipToMm100(aPageSize.getY() * pointToTwipconversionRatio);
auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(
- aPdfDataArray, OUString(), VectorGraphicDataType::Pdf, nPageIndex);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list