summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/impgraph.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-01-25 23:07:39 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-01 07:49:08 +0100
commitc81f3aec1ae17c6a1c6a5702cf5e42fbbad4e4b1 (patch)
tree993333fa0885f217fea55b616d994f8a08ad07ec /vcl/source/gdi/impgraph.cxx
parent52e6dea5220c563405e37e1533f45d8d3aaa0c04 (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/source/gdi/impgraph.cxx')
-rw-r--r--vcl/source/gdi/impgraph.cxx32
1 files changed, 30 insertions, 2 deletions
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;