summaryrefslogtreecommitdiff
path: root/sw/source/core/graphic/ndgrf.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-30 10:35:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-31 20:06:51 +0200
commite21042b43ff3fe93440c543b91a052b5a00d3515 (patch)
tree75b6f4d37bc6bfa6f52ee31f0554742486b170b4 /sw/source/core/graphic/ndgrf.cxx
parentfb8371400e4b2d32b3981b42c910e04f35ab166b (diff)
loplugin:flatten in sw/core/frmedt
Change-Id: I64f743d6f696584ff4c3c9185ae1e8fa42451677 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99884 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/graphic/ndgrf.cxx')
-rw-r--r--sw/source/core/graphic/ndgrf.cxx208
1 files changed, 104 insertions, 104 deletions
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index bb39141cc49a..2495deaf5636 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -308,48 +308,48 @@ void SwGrfNode::onGraphicChanged()
// when it is set.
SwFlyFrameFormat* pFlyFormat = dynamic_cast< SwFlyFrameFormat* >(GetFlyFormat());
- if(pFlyFormat)
+ if(!pFlyFormat)
+ return;
+
+ OUString aName;
+ OUString aTitle;
+ OUString aDesc;
+ auto const & rVectorGraphicDataPtr = GetGrf().getVectorGraphicData();
+
+ if (rVectorGraphicDataPtr)
{
- OUString aName;
- OUString aTitle;
- OUString aDesc;
- auto const & rVectorGraphicDataPtr = GetGrf().getVectorGraphicData();
+ const drawinglayer::primitive2d::Primitive2DContainer aSequence(rVectorGraphicDataPtr->getPrimitive2DSequence());
- if (rVectorGraphicDataPtr)
+ if(!aSequence.empty())
{
- const drawinglayer::primitive2d::Primitive2DContainer aSequence(rVectorGraphicDataPtr->getPrimitive2DSequence());
+ drawinglayer::geometry::ViewInformation2D aViewInformation2D;
+ drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor(aViewInformation2D);
- if(!aSequence.empty())
- {
- drawinglayer::geometry::ViewInformation2D aViewInformation2D;
- drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor(aViewInformation2D);
-
- aProcessor.process(aSequence);
+ aProcessor.process(aSequence);
- const drawinglayer::primitive2d::ObjectInfoPrimitive2D* pResult = aProcessor.getResult();
+ const drawinglayer::primitive2d::ObjectInfoPrimitive2D* pResult = aProcessor.getResult();
- if(pResult)
- {
- aName = pResult->getName();
- aTitle = pResult->getTitle();
- aDesc = pResult->getDesc();
- }
+ if(pResult)
+ {
+ aName = pResult->getName();
+ aTitle = pResult->getTitle();
+ aDesc = pResult->getDesc();
}
}
+ }
- if(!aTitle.isEmpty())
- {
- SetTitle(aTitle);
- }
- else if (!aName.isEmpty())
- {
- SetTitle(aName);
- }
+ if(!aTitle.isEmpty())
+ {
+ SetTitle(aTitle);
+ }
+ else if (!aName.isEmpty())
+ {
+ SetTitle(aName);
+ }
- if(!aDesc.isEmpty())
- {
- SetDescription(aDesc);
- }
+ if(!aDesc.isEmpty())
+ {
+ SetDescription(aDesc);
}
}
@@ -558,63 +558,63 @@ void SwGrfNode::InsertLink( const OUString& rGrfName, const OUString& rFltName )
mxLink = new SwBaseLink( SfxLinkUpdateMode::ONCALL, SotClipboardFormatId::GDIMETAFILE, this );
IDocumentLinksAdministration& rIDLA = getIDocumentLinksAdministration();
- if( GetNodes().IsDocNodes() )
+ if( !GetNodes().IsDocNodes() )
+ return;
+
+ mxLink->SetVisible( rIDLA.IsVisibleLinks() );
+ if( rFltName == "DDE" )
{
- mxLink->SetVisible( rIDLA.IsVisibleLinks() );
- if( rFltName == "DDE" )
- {
- sal_Int32 nTmp = 0;
- const OUString sApp{ rGrfName.getToken( 0, sfx2::cTokenSeparator, nTmp ) };
- const OUString sTopic{ rGrfName.getToken( 0, sfx2::cTokenSeparator, nTmp ) };
- const OUString sItem{ rGrfName.copy( nTmp ) };
- rIDLA.GetLinkManager().InsertDDELink( mxLink.get(), sApp, sTopic, sItem );
- }
- else
- {
- const bool bSync = rFltName == "SYNCHRON";
- mxLink->SetSynchron( bSync );
- mxLink->SetContentType( SotClipboardFormatId::SVXB );
+ sal_Int32 nTmp = 0;
+ const OUString sApp{ rGrfName.getToken( 0, sfx2::cTokenSeparator, nTmp ) };
+ const OUString sTopic{ rGrfName.getToken( 0, sfx2::cTokenSeparator, nTmp ) };
+ const OUString sItem{ rGrfName.copy( nTmp ) };
+ rIDLA.GetLinkManager().InsertDDELink( mxLink.get(), sApp, sTopic, sItem );
+ }
+ else
+ {
+ const bool bSync = rFltName == "SYNCHRON";
+ mxLink->SetSynchron( bSync );
+ mxLink->SetContentType( SotClipboardFormatId::SVXB );
- rIDLA.GetLinkManager().InsertFileLink( *mxLink,
- sfx2::SvBaseLinkObjectType::ClientGraphic, rGrfName,
- (!bSync && !rFltName.isEmpty() ? &rFltName : nullptr) );
- }
+ rIDLA.GetLinkManager().InsertFileLink( *mxLink,
+ sfx2::SvBaseLinkObjectType::ClientGraphic, rGrfName,
+ (!bSync && !rFltName.isEmpty() ? &rFltName : nullptr) );
}
}
void SwGrfNode::ReleaseLink()
{
- if( mxLink.is() )
- {
- Graphic aLocalGraphic(maGrfObj.GetGraphic());
- const bool bHasOriginalData(aLocalGraphic.IsGfxLink());
+ if( !mxLink.is() )
+ return;
- {
- mbInSwapIn = true;
- SwBaseLink* pLink = static_cast<SwBaseLink*>( mxLink.get() );
- pLink->SwapIn( true, true );
- mbInSwapIn = false;
- }
+ Graphic aLocalGraphic(maGrfObj.GetGraphic());
+ const bool bHasOriginalData(aLocalGraphic.IsGfxLink());
- getIDocumentLinksAdministration().GetLinkManager().Remove( mxLink.get() );
- mxLink.clear();
- aLocalGraphic.setOriginURL("");
-
- // #i15508# added extra processing after getting rid of the link. Use whatever is
- // known from the formerly linked graphic to get to a state as close to a directly
- // unlinked inserted graphic as possible. Goal is to have a valid GfxLink at the
- // ImplGraphic (see there) that holds temporary data to the original data and type
- // information about the original data. Only when this is given will
- // SvXMLGraphicHelper::ImplInsertGraphicURL which is used at export use that type
- // and use the original graphic at export for the ODF, without evtl. recoding
- // of the bitmap graphic data to something without loss (e.g. PNG) but bigger
- if(bHasOriginalData)
- {
- // #i15508# if we have the original data at the Graphic, let it survive
- // by using that Graphic again, this time at a GraphicObject without link.
- // This happens e.g. when inserting a linked graphic and breaking the link
- maGrfObj.SetGraphic(aLocalGraphic);
- }
+ {
+ mbInSwapIn = true;
+ SwBaseLink* pLink = static_cast<SwBaseLink*>( mxLink.get() );
+ pLink->SwapIn( true, true );
+ mbInSwapIn = false;
+ }
+
+ getIDocumentLinksAdministration().GetLinkManager().Remove( mxLink.get() );
+ mxLink.clear();
+ aLocalGraphic.setOriginURL("");
+
+ // #i15508# added extra processing after getting rid of the link. Use whatever is
+ // known from the formerly linked graphic to get to a state as close to a directly
+ // unlinked inserted graphic as possible. Goal is to have a valid GfxLink at the
+ // ImplGraphic (see there) that holds temporary data to the original data and type
+ // information about the original data. Only when this is given will
+ // SvXMLGraphicHelper::ImplInsertGraphicURL which is used at export use that type
+ // and use the original graphic at export for the ODF, without evtl. recoding
+ // of the bitmap graphic data to something without loss (e.g. PNG) but bigger
+ if(bHasOriginalData)
+ {
+ // #i15508# if we have the original data at the Graphic, let it survive
+ // by using that Graphic again, this time at a GraphicObject without link.
+ // This happens e.g. when inserting a linked graphic and breaking the link
+ maGrfObj.SetGraphic(aLocalGraphic);
}
}
@@ -801,20 +801,20 @@ void SwGrfNode::TriggerAsyncRetrieveInputStream()
return;
}
- if (mpThreadConsumer == nullptr)
- {
- mpThreadConsumer.reset(new SwAsyncRetrieveInputStreamThreadConsumer(*this), o3tl::default_delete<SwAsyncRetrieveInputStreamThreadConsumer>());
+ if (mpThreadConsumer != nullptr)
+ return;
- OUString sGrfNm;
- sfx2::LinkManager::GetDisplayNames( mxLink.get(), nullptr, &sGrfNm );
- OUString sReferer;
- SfxObjectShell * sh = GetDoc()->GetPersist();
- if (sh != nullptr && sh->HasName())
- {
- sReferer = sh->GetMedium()->GetName();
- }
- mpThreadConsumer->CreateThread( sGrfNm, sReferer );
+ mpThreadConsumer.reset(new SwAsyncRetrieveInputStreamThreadConsumer(*this), o3tl::default_delete<SwAsyncRetrieveInputStreamThreadConsumer>());
+
+ OUString sGrfNm;
+ sfx2::LinkManager::GetDisplayNames( mxLink.get(), nullptr, &sGrfNm );
+ OUString sReferer;
+ SfxObjectShell * sh = GetDoc()->GetPersist();
+ if (sh != nullptr && sh->HasName())
+ {
+ sReferer = sh->GetMedium()->GetName();
}
+ mpThreadConsumer->CreateThread( sGrfNm, sReferer );
}
@@ -838,19 +838,19 @@ void SwGrfNode::ApplyInputStream(
void SwGrfNode::UpdateLinkWithInputStream()
{
// do not work on link, if a <SwapIn> has been triggered.
- if ( !mbInSwapIn && IsLinkedFile() )
- {
- GetLink()->setStreamToLoadFrom( mxInputStream, mbIsStreamReadOnly );
- GetLink()->Update();
- SwMsgPoolItem aMsgHint( RES_GRAPHIC_ARRIVED );
- ModifyNotification( &aMsgHint, &aMsgHint );
+ if ( !(!mbInSwapIn && IsLinkedFile()) )
+ return;
- // #i88291#
- mxInputStream.clear();
- GetLink()->clearStreamToLoadFrom();
- mbLinkedInputStreamReady = false;
- mpThreadConsumer.reset();
- }
+ GetLink()->setStreamToLoadFrom( mxInputStream, mbIsStreamReadOnly );
+ GetLink()->Update();
+ SwMsgPoolItem aMsgHint( RES_GRAPHIC_ARRIVED );
+ ModifyNotification( &aMsgHint, &aMsgHint );
+
+ // #i88291#
+ mxInputStream.clear();
+ GetLink()->clearStreamToLoadFrom();
+ mbLinkedInputStreamReady = false;
+ mpThreadConsumer.reset();
}
// #i90395#