summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-04-14 15:13:05 +0900
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-18 13:34:31 -0400
commitd46098a213eda6fdb8237e1cd3d862bea4f187a0 (patch)
tree5decdb8b2b77162b3d484119ee829dcce0456cfc /svx
parentbc559eecccf08b3cb7fd328f49ea81aba32a6d71 (diff)
Function to load graphic swapped out (loaded on demand)
When a document is loaded it takes a lot of time and memory to load the graphic that are in the documet, so avoid that and just store the compressed graphic into a temporary file (handeled by GfxLink) and load when we really need to show the graphic. GraphicObject cached some attributes from Graphic, but this attributes now aren't available immediately so this attributes are removed form GraphicObject and now delegate to the Graphic itself. GetSizeBytes attribute however was removed as it is only used in some tests. GfxLink initial values were moved to the constructor and are not set in the header file anymore (as it is the recommended way to do it). The SdImportTest::testDocumentLayout failed as it looks like the dump sometimes didn't include the width and height of the null bitmap (which is set to 32x32) of the FillBitmap in some situations, but then in other situations it did include this attributes. With this change the width and height are always included for the FillBitmap which looks like it is more correct. Reviewed-on: https://gerrit.libreoffice.org/53016 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 7b355669c6ddeab2e6cec692d6afdff41c61d0fb) Change-Id: Ia1218f93b1735402b7828404f65660e2d4acf32f
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdograf.cxx8
-rw-r--r--svx/source/xml/xmlgrhlp.cxx15
2 files changed, 14 insertions, 9 deletions
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 2aced9a3227f..0415cfbe3eb2 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -288,7 +288,7 @@ sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact()
void SdrGrafObj::onGraphicChanged()
{
- if (!pGraphic || pGraphic->IsSwappedOut()) // don't force swap-in for this
+ if (!pGraphic || !pGraphic->GetGraphic().isAvailable())
return;
const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData();
@@ -552,12 +552,12 @@ bool SdrGrafObj::IsSwappedOut() const
return mbIsPreview || pGraphic->IsSwappedOut();
}
-const MapMode& SdrGrafObj::GetGrafPrefMapMode() const
+MapMode SdrGrafObj::GetGrafPrefMapMode() const
{
return pGraphic->GetPrefMapMode();
}
-const Size& SdrGrafObj::GetGrafPrefSize() const
+Size SdrGrafObj::GetGrafPrefSize() const
{
return pGraphic->GetPrefSize();
}
@@ -1338,7 +1338,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
if( pO->IsInSwapOut() )
{
- if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && pGraphic->GetSizeBytes() > 20480 )
+ if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && pGraphic->GetGraphic().GetSizeBytes() > 20480 )
{
// test if this object is visualized from someone
// ## test only if there are VOCs other than the preview renderer
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 1add678a67b1..53b4f60dbecb 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -499,15 +499,20 @@ OUString SvXMLGraphicHelper::ImplGetGraphicMimeType( const OUString& rFileName )
Graphic SvXMLGraphicHelper::ImplReadGraphic( const OUString& rPictureStorageName,
const OUString& rPictureStreamName )
{
- Graphic aGraphic;
+ Graphic aReturnGraphic;
SvxGraphicHelperStream_Impl aStream( ImplGetGraphicStream( rPictureStorageName, rPictureStreamName ) );
- if( aStream.xStream.is() )
+ if (aStream.xStream.is())
{
- std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream( aStream.xStream ));
- GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, "", *pStream );
+ GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+ std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream));
+ Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(*pStream);
+ if (aGraphic)
+ aReturnGraphic = aGraphic;
+ else
+ rGraphicFilter.ImportGraphic(aReturnGraphic, "", *pStream);
}
- return aGraphic;
+ return aReturnGraphic;
}
bool SvXMLGraphicHelper::ImplWriteGraphic( const OUString& rPictureStorageName,