summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-06-11 08:09:14 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-06-11 11:31:57 +0200
commitacb803b730f2c6bd82e39beab58949ec14f85eb0 (patch)
tree51ef2b3635a0a7fdb2a41727a403e5a08649b2e6 /vcl
parent425db2cc9881e00a28cf6184451ffc1eca841299 (diff)
tdf#125591 DOC import: lazy-load metafiles with explicit size
Regression from commit 69b62cfcbd364d7f62142149c2f690104b217ca1 (tdf#125281 DOC import: fix size of lazy-loaded metafiles, 2019-05-27), the problem is that setting the preferred size of a Graphic swaps it in. Avoid this by extending ImportUnloadedGraphic(): if a size hint is provided, then that will be used instead of info from the graphic descriptor (which is usually only meaningful for bitmaps). This way we maintain the correct size and we're back to lazy-loading metafiles from binary MSO files as well. Change-Id: Ide12d12166110e98ea47b5347dd24fb203b22da3 Reviewed-on: https://gerrit.libreoffice.org/73798 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impgraph.hxx2
-rw-r--r--vcl/source/filter/graphicfilter.cxx5
-rw-r--r--vcl/source/gdi/impgraph.cxx42
3 files changed, 29 insertions, 20 deletions
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index b97f736c770d..ce6ad8616e92 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -114,7 +114,7 @@ public:
ImpGraphic( const GDIMetaFile& rMtf );
~ImpGraphic();
- void ImplSetPrepared(bool bAnimated);
+ void ImplSetPrepared(bool bAnimated, Size* pSizeHint);
private:
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 61c38ec51067..87aeaefa0ec7 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1178,7 +1178,8 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra
}
}
-Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 sizeLimit)
+Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 sizeLimit,
+ Size* pSizeHint)
{
Graphic aGraphic;
sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW;
@@ -1403,7 +1404,7 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size
bAnimated = IsGIFAnimated(aMemoryStream);
}
aGraphic.SetGfxLink(std::make_shared<GfxLink>(std::move(pGraphicContent), nGraphicContentSize, eLinkType));
- aGraphic.ImplGetImpGraphic()->ImplSetPrepared(bAnimated);
+ aGraphic.ImplGetImpGraphic()->ImplSetPrepared(bAnimated, pSizeHint);
}
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 3cd67b08ce33..5a621025423f 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -522,7 +522,7 @@ ImpSwapFile::~ImpSwapFile()
}
}
-void ImpGraphic::ImplSetPrepared(bool bAnimated)
+void ImpGraphic::ImplSetPrepared(bool bAnimated, Size* pSizeHint)
{
mbPrepared = true;
mbSwapOut = true;
@@ -530,25 +530,33 @@ void ImpGraphic::ImplSetPrepared(bool bAnimated)
SvMemoryStream aMemoryStream(const_cast<sal_uInt8*>(mpGfxLink->GetData()), mpGfxLink->GetDataSize(), StreamMode::READ | StreamMode::WRITE);
- GraphicDescriptor aDescriptor(aMemoryStream, nullptr);
- if (aDescriptor.Detect(true))
+ if (pSizeHint)
{
- // If we have logic size, work with that, as later pixel -> logic
- // conversion will work with the output device DPI, not the graphic
- // DPI.
- Size aLogSize = aDescriptor.GetSize_100TH_MM();
- if (aLogSize.getWidth() && aLogSize.getHeight())
- {
- maSwapInfo.maPrefSize = aLogSize;
- maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM);
- }
- else
+ maSwapInfo.maPrefSize = *pSizeHint;
+ maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM);
+ }
+ else
+ {
+ GraphicDescriptor aDescriptor(aMemoryStream, nullptr);
+ if (aDescriptor.Detect(true))
{
- maSwapInfo.maPrefSize = aDescriptor.GetSizePixel();
- maSwapInfo.maPrefMapMode = MapMode(MapUnit::MapPixel);
- }
+ // If we have logic size, work with that, as later pixel -> logic
+ // conversion will work with the output device DPI, not the graphic
+ // DPI.
+ Size aLogSize = aDescriptor.GetSize_100TH_MM();
+ if (aLogSize.getWidth() && aLogSize.getHeight())
+ {
+ maSwapInfo.maPrefSize = aLogSize;
+ maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM);
+ }
+ else
+ {
+ maSwapInfo.maPrefSize = aDescriptor.GetSizePixel();
+ maSwapInfo.maPrefMapMode = MapMode(MapUnit::MapPixel);
+ }
- maSwapInfo.maSizePixel = aDescriptor.GetSizePixel();
+ maSwapInfo.maSizePixel = aDescriptor.GetSizePixel();
+ }
}
maSwapInfo.mnAnimationLoopCount = 0;
maSwapInfo.mbIsEPS = false;