diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-01-25 23:07:39 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-02-01 07:49:08 +0100 |
commit | c81f3aec1ae17c6a1c6a5702cf5e42fbbad4e4b1 (patch) | |
tree | 993333fa0885f217fea55b616d994f8a08ad07ec /vcl | |
parent | 52e6dea5220c563405e37e1533f45d8d3aaa0c04 (diff) |
vcl: swap-in load all vector formats without intermediate Graphic
Previously only PDF were loaded without the intermediate Graphic
objects. With this change all vector graphic formats are loaded
directly to a new VectorGraphicData instance, without the need
to create a intermediate Graphic object.
Change-Id: Idfa7c0ae433c4bf9500110dff82b6d1ec3f3caa4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109931
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/graphic/VectorGraphicLoader.hxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 32 | ||||
-rw-r--r-- | vcl/source/graphic/VectorGraphicLoader.cxx | 6 |
3 files changed, 35 insertions, 7 deletions
diff --git a/vcl/inc/graphic/VectorGraphicLoader.hxx b/vcl/inc/graphic/VectorGraphicLoader.hxx index b6f38120885c..943f7b8dc6d5 100644 --- a/vcl/inc/graphic/VectorGraphicLoader.hxx +++ b/vcl/inc/graphic/VectorGraphicLoader.hxx @@ -17,8 +17,8 @@ namespace vcl { -std::shared_ptr<VectorGraphicData> -loadPdfFromDataContainer(BinaryDataContainer const& rDataContainer); +std::shared_ptr<VectorGraphicData> loadVectorGraphic(BinaryDataContainer const& rDataContainer, + VectorGraphicDataType eType); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 9e57ff26ce98..6d10f7268e38 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1424,6 +1424,33 @@ void ImpGraphic::restoreFromSwapInfo() } } +namespace +{ + +std::optional<VectorGraphicDataType> lclConvertToVectorGraphicType(GfxLink const & rLink) +{ + switch(rLink.GetType()) + { + case GfxLinkType::NativePdf: + return VectorGraphicDataType::Pdf; + + case GfxLinkType::NativeWmf: + if (rLink.IsEMF()) + return VectorGraphicDataType::Emf; + else + return VectorGraphicDataType::Wmf; + + case GfxLinkType::NativeSvg: + return VectorGraphicDataType::Svg; + + default: + break; + } + return std::optional<VectorGraphicDataType>(); +} + +} // end namespace + bool ImpGraphic::swapIn() { if (!isSwappedOut()) @@ -1444,9 +1471,10 @@ bool ImpGraphic::swapIn() } else if (mpGfxLink && mpGfxLink->IsNative()) { - if (mpGfxLink->GetType() == GfxLinkType::NativePdf) + std::optional<VectorGraphicDataType> oType = lclConvertToVectorGraphicType(*mpGfxLink); + if (oType) { - maVectorGraphicData = vcl::loadPdfFromDataContainer(mpGfxLink->getDataContainer()); + maVectorGraphicData = vcl::loadVectorGraphic(mpGfxLink->getDataContainer(), *oType); // Set to 0, to force recalculation mnSizeBytes = 0; diff --git a/vcl/source/graphic/VectorGraphicLoader.cxx b/vcl/source/graphic/VectorGraphicLoader.cxx index 988c3db803be..997681092305 100644 --- a/vcl/source/graphic/VectorGraphicLoader.cxx +++ b/vcl/source/graphic/VectorGraphicLoader.cxx @@ -13,13 +13,13 @@ namespace vcl { -std::shared_ptr<VectorGraphicData> -loadPdfFromDataContainer(BinaryDataContainer const& rDataContainer) +std::shared_ptr<VectorGraphicData> loadVectorGraphic(BinaryDataContainer const& rDataContainer, + VectorGraphicDataType eType) { if (rDataContainer.isEmpty()) return std::shared_ptr<VectorGraphicData>(); - return std::make_shared<VectorGraphicData>(rDataContainer, VectorGraphicDataType::Pdf); + return std::make_shared<VectorGraphicData>(rDataContainer, eType); } } |