[Libreoffice-commits] core.git: Branch 'feature/fixes22' - sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu May 26 08:27:12 UTC 2016
sw/inc/ndgrf.hxx | 2 ++
sw/source/core/graphic/ndgrf.cxx | 19 +++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
New commits:
commit a578aab11e13ed9963f1f04ac7ed0138dbff2829
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu May 26 10:02:59 2016 +0200
sw: speed up saving of swapped out non-SVG images
Add a new SwGrfNode::mbHasReplacementGraphic to remember if the graphic
is an SVG, and don't attempt to query for a replacement image in case it
is not. The result is nullptr anyway, but it's expensive to count it.
Change-Id: I7afd9313e071686614eb6c9a06c537252ca44ce1
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 7b960c9..5f0041e 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -38,6 +38,8 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTextNode
GraphicObject maGrfObj;
GraphicObject *mpReplacementGraphic;
+ /// If false, don't try to read a replacement graphic even if mpReplacementGraphic is nullptr.
+ bool mbHasReplacementGraphic;
tools::SvRef<sfx2::SvBaseLink> refLink; ///< If graphics only as link then pointer is set.
Size nGrfSize;
bool bInSwapIn :1;
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index d50ac70..d62291d 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -69,6 +69,7 @@ SwGrfNode::SwGrfNode(
SwNoTextNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
maGrfObj(),
mpReplacementGraphic(nullptr),
+ mbHasReplacementGraphic(true),
// #i73788#
mbLinkedInputStreamReady( false ),
mbIsStreamReadOnly( false )
@@ -79,6 +80,10 @@ SwGrfNode::SwGrfNode(
bGraphicArrived = true;
ReRead(rGrfName, rFltName, pGraphic, nullptr, false);
+
+ const SvgDataPtr& rSvgDataPtr = GetGrf().getSvgData();
+ if (!rSvgDataPtr.get())
+ mbHasReplacementGraphic = false;
}
SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
@@ -87,6 +92,7 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
SwNoTextNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
maGrfObj(rGrfObj),
mpReplacementGraphic(nullptr),
+ mbHasReplacementGraphic(true),
// #i73788#
mbLinkedInputStreamReady( false ),
mbIsStreamReadOnly( false )
@@ -95,6 +101,10 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
bInSwapIn = bChgTwipSize =
bFrameInPaint = bScaleImageMap = false;
bGraphicArrived = true;
+
+ const SvgDataPtr& rSvgDataPtr = GetGrf().getSvgData();
+ if (!rSvgDataPtr.get())
+ mbHasReplacementGraphic = false;
}
/** Create new SW/G reader.
@@ -110,6 +120,7 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
SwNoTextNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
maGrfObj(),
mpReplacementGraphic(nullptr),
+ mbHasReplacementGraphic(true),
// #i73788#
mbLinkedInputStreamReady( false ),
mbIsStreamReadOnly( false )
@@ -329,12 +340,12 @@ void SwGrfNode::onGraphicChanged()
// when it is set.
SwFlyFrameFormat* pFlyFormat = dynamic_cast< SwFlyFrameFormat* >(GetFlyFormat());
+ const SvgDataPtr& rSvgDataPtr = GetGrf().getSvgData();
if(pFlyFormat)
{
OUString aName;
OUString aTitle;
OUString aDesc;
- const SvgDataPtr& rSvgDataPtr = GetGrf().getSvgData();
if(rSvgDataPtr.get())
{
@@ -372,6 +383,8 @@ void SwGrfNode::onGraphicChanged()
SetDescription(aDesc);
}
}
+ if (!rSvgDataPtr.get())
+ mbHasReplacementGraphic = false;
}
void SwGrfNode::SetGraphic(const Graphic& rGraphic, const OUString& rLink)
@@ -394,7 +407,9 @@ const GraphicObject& SwGrfNode::GetGrfObj(bool bWait) const
const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
{
- if(!mpReplacementGraphic)
+ // Don't attempt potentially expensive GetGrfObj() that may trigger a
+ // SwapIn() in case we know that getSvgData() will be nullptr anyway.
+ if(!mpReplacementGraphic && mbHasReplacementGraphic)
{
const SvgDataPtr& rSvgDataPtr = GetGrfObj().GetGraphic().getSvgData();
More information about the Libreoffice-commits
mailing list