summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/inc/impgraph.hxx5
-rw-r--r--vcl/source/gdi/impgraph.cxx47
2 files changed, 39 insertions, 13 deletions
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 90e658c67308..159b70a691e0 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -75,6 +75,8 @@ private:
GDIMetaFile maMetaFile;
BitmapEx maEx;
+ /// If maEx is empty, this preferred size will be set on it when it gets initialized.
+ Size maExPrefSize;
ImpSwapInfo maSwapInfo;
std::unique_ptr<Animation> mpAnimation;
std::shared_ptr<GraphicReader> mpContext;
@@ -232,6 +234,9 @@ private:
void setPdfData(const std::shared_ptr<std::vector<sal_Int8>>& rPdfData);
+ /// Gets the bitmap replacement for a vector graphic.
+ BitmapEx getVectorGraphicReplacement() const;
+
bool ensureAvailable () const;
bool loadPrepared();
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 280ad3c2f1cd..e523f9acb23e 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -668,6 +668,18 @@ bool ImpGraphic::makeAvailable()
return ensureAvailable();
}
+BitmapEx ImpGraphic::getVectorGraphicReplacement() const
+{
+ BitmapEx aRet = maVectorGraphicData->getReplacement();
+
+ if (maExPrefSize.getWidth() && maExPrefSize.getHeight())
+ {
+ aRet.SetPrefSize(maExPrefSize);
+ }
+
+ return aRet;
+}
+
Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) const
{
Bitmap aRetBmp;
@@ -679,7 +691,7 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters)
if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = getVectorGraphicReplacement();
}
const BitmapEx& rRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
@@ -789,7 +801,7 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(const GraphicConversionParameters& rParamet
if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = getVectorGraphicReplacement();
}
aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
@@ -876,7 +888,7 @@ const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
if(maVectorGraphicData.get() && !maEx)
{
// use maEx as local buffer for rendered svg
- pThat->maEx = maVectorGraphicData->getReplacement();
+ pThat->maEx = getVectorGraphicReplacement();
}
// #123983# directly create a metafile with the same PrefSize and PrefMapMode
@@ -931,10 +943,17 @@ Size ImpGraphic::ImplGetPrefSize() const
{
if(maVectorGraphicData.get() && maEx.IsEmpty())
{
- // svg not yet buffered in maEx, return size derived from range
- const basegfx::B2DRange& rRange = maVectorGraphicData->getRange();
+ if (!maExPrefSize.getWidth() || !maExPrefSize.getHeight())
+ {
+ // svg not yet buffered in maEx, return size derived from range
+ const basegfx::B2DRange& rRange = maVectorGraphicData->getRange();
- aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight()));
+ aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight()));
+ }
+ else
+ {
+ aSize = maExPrefSize;
+ }
}
else
{
@@ -976,8 +995,7 @@ void ImpGraphic::ImplSetPrefSize( const Size& rPrefSize )
// to allow setting the PrefSize at the BitmapEx to hold it
if(maVectorGraphicData.get() && maEx.IsEmpty())
{
- // use maEx as local buffer for rendered svg
- maEx = maVectorGraphicData->getReplacement();
+ maExPrefSize = rPrefSize;
}
// #108077# Push through pref size to animation object,
@@ -987,7 +1005,10 @@ void ImpGraphic::ImplSetPrefSize( const Size& rPrefSize )
const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefSize( rPrefSize );
}
- maEx.SetPrefSize( rPrefSize );
+ if (!maExPrefSize.getWidth() || !maExPrefSize.getHeight())
+ {
+ maEx.SetPrefSize( rPrefSize );
+ }
}
break;
@@ -1060,7 +1081,7 @@ void ImpGraphic::ImplSetPrefMapMode( const MapMode& rPrefMapMode )
if(maVectorGraphicData.get())
{
// ignore for Vector Graphic Data. If this is really used (except the grfcache)
- // it can be extended by using maEx as buffer for maVectorGraphicData->getReplacement()
+ // it can be extended by using maEx as buffer for getVectorGraphicReplacement()
}
else
{
@@ -1132,7 +1153,7 @@ void ImpGraphic::ImplDraw( OutputDevice* pOutDev, const Point& rDestPt ) const
if(maVectorGraphicData.get() && !maEx)
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = getVectorGraphicReplacement();
}
if ( mpAnimation )
@@ -1169,7 +1190,7 @@ void ImpGraphic::ImplDraw( OutputDevice* pOutDev,
if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = getVectorGraphicReplacement();
}
if( mpAnimation )
@@ -1317,7 +1338,7 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- maEx = maVectorGraphicData->getReplacement();
+ maEx = getVectorGraphicReplacement();
}
maEx.SetSizePixel(aSize);