summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-20 15:55:07 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-20 15:55:07 -0400
commit1fb42f8e8ecb0696c41c5d80e2d6a4ca521fd24d (patch)
treee081e4c569e717987097c4abb74a9076d1d5666b
parent7be2fd11d068bdea630caad2607e6166b12b9288 (diff)
vcl: remove swapping logic from GraphicObject to support lazy-loading private/Ashod/cd-5.3-3.2_import_unloaded
Change-Id: I286a9b6ee75f07744232771263c26579ad9653e7
-rw-r--r--include/vcl/GraphicObject.hxx50
-rw-r--r--svx/source/sdr/contact/viewcontactofgraphic.cxx4
-rw-r--r--svx/source/svdraw/svdograf.cxx179
-rw-r--r--sw/source/core/doc/notxtfrm.cxx30
-rw-r--r--sw/source/core/docnode/swbaslnk.cxx2
-rw-r--r--sw/source/core/edit/editsh.cxx3
-rw-r--r--sw/source/core/graphic/ndgrf.cxx159
-rw-r--r--vcl/source/graphic/GraphicObject.cxx351
8 files changed, 57 insertions, 721 deletions
diff --git a/include/vcl/GraphicObject.hxx b/include/vcl/GraphicObject.hxx
index 822f37abb72b..00df8ee00042 100644
--- a/include/vcl/GraphicObject.hxx
+++ b/include/vcl/GraphicObject.hxx
@@ -173,30 +173,8 @@ class VCL_DLLPUBLIC GraphicObject
private:
Graphic maGraphic;
GraphicAttr maAttr;
- Size maPrefSize;
- MapMode maPrefMapMode;
- sal_uLong mnSizeBytes;
- GraphicType meType;
- OUString maLink;
- Link<const GraphicObject*, SvStream*> maSwapStreamHdl;
OUString maUserData;
- std::unique_ptr<Timer> mxSwapOutTimer;
std::unique_ptr<GrfSimpleCacheObj> mxSimpleCache;
- sal_uInt32 mnAnimationLoopCount;
-
- // a unique increasing ID to be able to say which data change is older
- sal_uLong mnDataChangeTimeStamp;
-
- bool mbAutoSwapped : 1;
- bool mbTransparent : 1;
- bool mbAnimated : 1;
- bool mbEPS : 1;
- bool mbIsInSwapIn : 1;
- bool mbIsInSwapOut : 1;
-
- void VCL_DLLPRIVATE ImplAssignGraphicData();
- static void VCL_DLLPRIVATE ImplEnsureGraphicManager();
- void VCL_DLLPRIVATE ImplAutoSwapIn();
bool VCL_DLLPRIVATE ImplGetCropParams(
OutputDevice* pOut,
@@ -299,12 +277,6 @@ private:
bool bEnlarge
) const;
- DECL_LINK( ImplAutoSwapOutHdl, Timer*, void );
-protected:
-
- SvStream* GetSwapStream() const;
- void SetSwapState();
-
public:
GraphicObject();
GraphicObject( const Graphic& rGraphic );
@@ -316,12 +288,6 @@ public:
bool operator==( const GraphicObject& rCacheObj ) const;
bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); }
- bool HasSwapStreamHdl() const { return maSwapStreamHdl.IsSet(); }
- void SetSwapStreamHdl(const Link<const GraphicObject*, SvStream*>& rHdl);
-
- void FireSwapInRequest();
- void FireSwapOutRequest();
-
const Graphic& GetGraphic() const;
void SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj = nullptr);
void SetGraphic( const Graphic& rGraphic, const OUString& rLink );
@@ -361,11 +327,6 @@ public:
void SetAttr( const GraphicAttr& rAttr );
const GraphicAttr& GetAttr() const { return maAttr; }
- bool HasLink() const { return !maLink.isEmpty(); }
- void SetLink();
- void SetLink( const OUString& rLink );
- const OUString& GetLink() const { return maLink; }
-
bool HasUserData() const { return !maUserData.isEmpty(); }
void SetUserData();
void SetUserData( const OUString& rUserData );
@@ -373,14 +334,6 @@ public:
OString GetUniqueID() const;
- bool SwapOut();
- bool SwapOut( SvStream* pOStm );
- bool SwapIn();
-
- bool IsInSwapIn() const { return mbIsInSwapIn; }
- bool IsInSwapOut() const { return mbIsInSwapOut; }
- bool IsSwappedOut() const { return( mbAutoSwapped || maGraphic.IsSwapOut() ); }
-
GraphicType GetType() const;
Size GetPrefSize() const;
MapMode GetPrefMapMode() const;
@@ -462,9 +415,6 @@ public:
double fTopCrop,
double fRightCrop,
double fBottomCrop) const;
-
- // read access
- sal_uLong GetDataChangeTimeStamp() const { return mnDataChangeTimeStamp; }
};
namespace vcl
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
index 89b763deb3ef..9e49fae47d7f 100644
--- a/svx/source/sdr/contact/viewcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -418,10 +418,6 @@ namespace sdr
// draft when swapped out
const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject();
- static bool bAllowReplacements(true);
-
- if(rGraphicObject.IsSwappedOut() && bAllowReplacements)
- return true;
// draft when no graphic
if(GraphicType::NONE == rGraphicObject.GetType() || GraphicType::Default == rGraphicObject.GetType())
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 0415cfbe3eb2..9563815e199f 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -339,7 +339,6 @@ SdrGrafObj::SdrGrafObj()
{
pGraphic = new GraphicObject;
mpReplacementGraphic = nullptr;
- pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
// #i118485# Shear allowed and possible now
@@ -363,7 +362,6 @@ SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect)
{
pGraphic = new GraphicObject( rGrf );
mpReplacementGraphic = nullptr;
- pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
// #i118485# Shear allowed and possible now
@@ -387,7 +385,6 @@ SdrGrafObj::SdrGrafObj( const Graphic& rGrf )
{
pGraphic = new GraphicObject( rGrf );
mpReplacementGraphic = nullptr;
- pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
// #i118485# Shear allowed and possible now
@@ -416,7 +413,6 @@ void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj )
*pGraphic = rGrfObj;
delete mpReplacementGraphic;
mpReplacementGraphic = nullptr;
- pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
pGraphic->SetUserData();
mbIsPreview = false;
SetChanged();
@@ -426,10 +422,8 @@ void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj )
const GraphicObject& SdrGrafObj::GetGraphicObject(bool bForceSwapIn) const
{
- if(bForceSwapIn)
- {
+ if (bForceSwapIn)
ForceSwapIn();
- }
return *pGraphic;
}
@@ -450,11 +444,6 @@ const GraphicObject* SdrGrafObj::GetReplacementGraphicObject() const
// Replacement graphic for bitmap + PDF is just the bitmap.
const_cast<SdrGrafObj*>(this)->mpReplacementGraphic = new GraphicObject(pGraphic->GetGraphic().GetBitmapEx());
}
- if (mpReplacementGraphic)
- {
- mpReplacementGraphic->SetSwapStreamHdl(
- LINK(const_cast<SdrGrafObj*>(this), SdrGrafObj, ReplacementSwapHdl));
- }
}
return mpReplacementGraphic;
@@ -549,7 +538,7 @@ bool SdrGrafObj::IsEPS() const
bool SdrGrafObj::IsSwappedOut() const
{
- return mbIsPreview || pGraphic->IsSwappedOut();
+ return false;
}
MapMode SdrGrafObj::GetGrafPrefMapMode() const
@@ -607,29 +596,10 @@ Size SdrGrafObj::getOriginalSize() const
void SdrGrafObj::ForceSwapIn() const
{
- if( mbIsPreview && pGraphic->HasUserData() )
+ if (pGraphicLink && (pGraphic->GetType() == GraphicType::NONE ||
+ pGraphic->GetType() == GraphicType::Default) )
{
- // removing preview graphic
- const OUString aUserData( pGraphic->GetUserData() );
-
- Graphic aEmpty;
- pGraphic->SetGraphic( aEmpty );
- pGraphic->SetUserData( aUserData );
-
- const_cast< SdrGrafObj* >( this )->mbIsPreview = false;
- }
- if ( pGraphicLink && pGraphic->IsSwappedOut() )
- ImpUpdateGraphicLink( false );
- else
- pGraphic->FireSwapInRequest();
-
- if( pGraphic->IsSwappedOut() ||
- ( pGraphic->GetType() == GraphicType::NONE ) ||
- ( pGraphic->GetType() == GraphicType::Default ) )
- {
- Graphic aDefaultGraphic;
- aDefaultGraphic.SetDefaultType();
- pGraphic->SetGraphic( aDefaultGraphic );
+ pGraphicLink->Update();
}
}
@@ -669,7 +639,6 @@ void SdrGrafObj::SetGraphicLink(const OUString& rFileName, const OUString& rRefe
aFilterName = rFilterName;
ImpLinkAnmeldung();
pGraphic->SetUserData();
- pGraphic->SetSwapState();
}
void SdrGrafObj::ReleaseGraphicLink()
@@ -1309,144 +1278,6 @@ void SdrGrafObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly )
}
}
-IMPL_LINK(SdrGrafObj, ReplacementSwapHdl, const GraphicObject*, pO, SvStream*)
-{
- // replacement image is always swapped
- if (pO->IsInSwapOut())
- {
- SdrSwapGraphicsMode const nSwapMode(pModel->GetSwapGraphicsMode());
- if (nSwapMode & SdrSwapGraphicsMode::TEMP)
- {
- return GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- }
- else if (pO->IsInSwapIn())
- {
- return GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- else
- {
- assert(!"why is swap handler being called?");
- }
-
- return GRFMGR_AUTOSWAPSTREAM_NONE;
-}
-
-IMPL_LINK( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
-{
- SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
-
- if( pO->IsInSwapOut() )
- {
- 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
- if(!GetViewContact().HasViewObjectContacts())
- {
- const SdrSwapGraphicsMode nSwapMode = pModel->GetSwapGraphicsMode();
-
- if( ( pGraphicLink ) &&
- ( nSwapMode & SdrSwapGraphicsMode::PURGE ) )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
- }
- else if( nSwapMode & SdrSwapGraphicsMode::TEMP )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
- pGraphic->SetUserData();
- }
-
- // #i102380#
- sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&GetViewContact());
-
- if(pVC)
- {
- pVC->flushGraphicObjects();
- }
- }
- }
- }
- else if( pO->IsInSwapIn() )
- {
- // can be loaded from the original document stream later
- if( pModel != nullptr )
- {
- if( pGraphic->HasUserData() )
- {
- ::comphelper::LifecycleProxy proxy;
- OUString aUserData = pGraphic->GetUserData();
- uno::Reference<io::XInputStream> const xStream(
- pModel->GetDocumentStream(aUserData, proxy));
-
- std::unique_ptr<SvStream> const pStream( (xStream.is())
- ? ::utl::UcbStreamHelper::CreateStream(xStream)
- : nullptr );
-
- if( pStream != nullptr )
- {
- Graphic aGraphic;
-
- std::unique_ptr<css::uno::Sequence< css::beans::PropertyValue > > pFilterData;
-
- if(mbInsidePaint && !GetViewContact().HasViewObjectContacts())
- {
- pFilterData.reset(new css::uno::Sequence< css::beans::PropertyValue >( 3 ));
-
- const css::awt::Size aPreviewSizeHint( 64, 64 );
- const bool bAllowPartialStreamRead = true;
- // create <GfxLink> instance also for previews in order to avoid that its corresponding
- // data is cleared in the graphic cache entry in case that the preview data equals the complete graphic data
- const bool bCreateNativeLink = true;
- (*pFilterData)[ 0 ].Name = "PreviewSizeHint";
- (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
- (*pFilterData)[ 1 ].Name = "AllowPartialStreamRead";
- (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
- (*pFilterData)[ 2 ].Name = "CreateNativeLink";
- (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
-
- mbIsPreview = true;
- }
-
- if(!GraphicFilter::GetGraphicFilter().ImportGraphic(
- aGraphic, aUserData, *pStream,
- GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pFilterData.get()))
- {
- const OUString aNewUserData( pGraphic->GetUserData() );
- pGraphic->SetGraphic( aGraphic );
- if( mbIsPreview )
- {
- pGraphic->SetUserData(aNewUserData);
- }
- else
- {
- pGraphic->SetUserData();
- }
-
- // Graphic successfully swapped in.
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
- }
- pFilterData.reset();
-
- pStream->ResetError();
- }
- }
- else if( !ImpUpdateGraphicLink( false ) )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- else
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
- }
- }
- else
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
-
- return pRet;
-}
-
void SdrGrafObj::SetGrafAnimationAllowed(bool bNew)
{
if(mbGrafAnimationAllowed != bNew)
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 556727e5d504..00c01953ab35 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -770,26 +770,26 @@ void paintGraphicUsingPrimitivesHelper(vcl::RenderContext & rOutputDevice,
// - it's indeed a jpeg graphic (could be checked by the url ending, but is more reliable to check later)
// In all other cases (normal repaint, print, etc...) use the available Graphic with the
// already loaded pixel graphic as before this change.
- if (rOutputDevice.GetExtOutDevData() && rGrfObj.HasLink() && !rGrfObj.GetGraphic().IsGfxLink())
+ if (rOutputDevice.GetExtOutDevData() /*&& rGrfObj.HasLink()*/ && !rGrfObj.GetGraphic().IsGfxLink())
{
const vcl::PDFExtOutDevData* pPDFExt = dynamic_cast< const vcl::PDFExtOutDevData* >(rOutputDevice.GetExtOutDevData());
if (pPDFExt && pPDFExt->GetIsLosslessCompression())
{
- Graphic aTempGraphic;
- INetURLObject aURL(rGrfObj.GetLink());
-
- if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aTempGraphic, aURL))
- {
- if(aTempGraphic.IsGfxLink() && GfxLinkType::NativeJpg == aTempGraphic.GetGfxLink().GetType())
- {
- aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
- aTargetTransform,
- aTempGraphic,
- rGraphicAttr);
- bDone = true;
- }
- }
+ // Graphic aTempGraphic;
+ // INetURLObject aURL(rGrfObj.GetLink());
+
+ // if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aTempGraphic, aURL))
+ // {
+ // if(aTempGraphic.IsGfxLink() && GfxLinkType::NativeJpg == aTempGraphic.GetGfxLink().GetType())
+ // {
+ // aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
+ // aTargetTransform,
+ // aTempGraphic,
+ // rGraphicAttr);
+ // bDone = true;
+ // }
+ // }
}
}
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index 80f4ca21d25c..a7d626eb0176 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -163,7 +163,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
bGraphicPieceArrived = false;
}
- pSwGrfNode->SetGraphic(aGrf, rGrfObj.GetLink());
+ pSwGrfNode->SetGraphic(aGrf, "");
bUpdate = true;
// In order for the Node to have the right transparency status
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 0ece2156ee4f..c76a51820034 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -248,8 +248,7 @@ bool SwEditShell::IsLinkedGrfSwapOut() const
SwGrfNode *pGrfNode = GetGrfNode_();
return pGrfNode &&
( pGrfNode->IsLinkedFile() &&
- ( GraphicType::Default == pGrfNode->GetGrfObj().GetType() ||
- pGrfNode->GetGrfObj().IsSwappedOut()));
+ ( GraphicType::Default == pGrfNode->GetGrfObj().GetType()));
}
const GraphicObject* SwEditShell::GetGraphicObj() const
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 82f0678a1843..0c0e90ee3159 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -71,7 +71,6 @@ SwGrfNode::SwGrfNode(
mbLinkedInputStreamReady( false ),
mbIsStreamReadOnly( false )
{
- maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) );
bInSwapIn = bChgTwipSize =
bFrameInPaint = bScaleImageMap = false;
@@ -89,7 +88,6 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
mbLinkedInputStreamReady( false ),
mbIsStreamReadOnly( false )
{
- maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) );
bInSwapIn = bChgTwipSize =
bFrameInPaint = bScaleImageMap = false;
bGraphicArrived = true;
@@ -112,8 +110,6 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
mbLinkedInputStreamReady( false ),
mbIsStreamReadOnly( false )
{
- maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) );
-
Graphic aGrf; aGrf.SetDefaultType();
maGrfObj.SetGraphic( aGrf, rGrfName );
@@ -188,13 +184,6 @@ bool SwGrfNode::ReRead(
onGraphicChanged();
bReadGrf = true;
}
- else if( pGrfObj )
- {
- maGrfObj = *pGrfObj;
- maGrfObj.SetLink( rGrfName );
- onGraphicChanged();
- bReadGrf = true;
- }
else
{
// reset data of the old graphic so that the correct placeholder is
@@ -249,15 +238,6 @@ bool SwGrfNode::ReRead(
// create connection without update, as we have the graphic
static_cast<SwBaseLink*>( refLink.get() )->Connect();
}
- else if( pGrfObj )
- {
- maGrfObj = *pGrfObj;
- maGrfObj.SetLink( rGrfName );
- onGraphicChanged();
- bReadGrf = true;
- // create connection without update, as we have the graphic
- static_cast<SwBaseLink*>( refLink.get() )->Connect();
- }
else
{
Graphic aGrf;
@@ -406,11 +386,6 @@ const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
// This returns the bitmap, without the pdf data.
const_cast<SwGrfNode*>(this)->mpReplacementGraphic = new GraphicObject(GetGrfObj().GetGraphic().GetBitmapEx());
}
- if (mpReplacementGraphic)
- {
- mpReplacementGraphic->SetSwapStreamHdl(
- LINK(const_cast<SwGrfNode*>(this), SwGrfNode, SwapReplacement));
- }
}
return mpReplacementGraphic;
@@ -524,7 +499,7 @@ StreamAndStorageNames lcl_GetStreamStorageNames( const OUString& sUserData )
bool SwGrfNode::SwapIn( bool bWaitForData )
{
if( bInSwapIn ) // not recursively!
- return !maGrfObj.IsSwappedOut();
+ return true;
bool bRet = false;
bInSwapIn = true;
@@ -552,56 +527,15 @@ bool SwGrfNode::SwapIn( bool bWaitForData )
ModifyNotification( &aMsgHint, &aMsgHint );
}
}
- else if( maGrfObj.IsSwappedOut() )
- {
- // link to download
- bRet = pLink->SwapIn( bWaitForData );
- }
else
- bRet = true;
- }
- else if( maGrfObj.IsSwappedOut() )
- {
- // graphic is in storage or in a temp file
- if( !HasEmbeddedStreamName() )
{
- bRet = maGrfObj.SwapIn();
- }
- else
- {
- try
- {
- const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
- uno::Reference < embed::XStorage > refPics = GetDocSubstorageOrRoot( aNames.sStorage );
- SvStream* pStrm = GetStreamForEmbedGrf( refPics, aNames.sStream );
- if ( pStrm )
- {
- bRet = ImportGraphic( *pStrm );
- delete pStrm;
- if( bRet )
- {
- maGrfObj.SetUserData();
- }
- }
- }
- catch (const uno::Exception&)
- {
- // #i48434#
- OSL_FAIL( "<SwGrfNode::SwapIn(..)> - unhandled exception!" );
- }
- }
-
- if( bRet )
- {
- SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN );
- ModifyNotification( &aMsg, &aMsg );
+ bRet = true;
}
}
else
bRet = true;
- OSL_ENSURE( bRet, "Cannot swap in graphic" );
- if( bRet )
+ if (bRet)
{
if( !nGrfSize.Width() && !nGrfSize.Height() )
SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), nullptr ) );
@@ -612,21 +546,6 @@ bool SwGrfNode::SwapIn( bool bWaitForData )
bool SwGrfNode::SwapOut()
{
- if( maGrfObj.GetType() != GraphicType::Default &&
- maGrfObj.GetType() != GraphicType::NONE &&
- !maGrfObj.IsSwappedOut() && !bInSwapIn )
- {
- if( refLink.Is() )
- {
- // written graphics and links are removed here
- return maGrfObj.SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK );
- }
- else
- {
- return maGrfObj.SwapOut();
- }
-
- }
return true;
}
@@ -732,14 +651,12 @@ void SwGrfNode::InsertLink( const OUString& rGrfName, const OUString& rFltName )
(!bSync && !rFltName.isEmpty() ? &rFltName : nullptr) );
}
}
- maGrfObj.SetLink( rGrfName );
}
void SwGrfNode::ReleaseLink()
{
if( refLink.Is() )
{
- const OUString aFileName(maGrfObj.GetLink());
const Graphic aLocalGraphic(maGrfObj.GetGraphic());
const bool bHasOriginalData(aLocalGraphic.IsGfxLink());
@@ -752,7 +669,6 @@ void SwGrfNode::ReleaseLink()
getIDocumentLinksAdministration().GetLinkManager().Remove( refLink.get() );
refLink.Clear();
- maGrfObj.SetLink();
// #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
@@ -769,21 +685,6 @@ void SwGrfNode::ReleaseLink()
// This happens e.g. when inserting a linked graphic and breaking the link
maGrfObj.SetGraphic(aLocalGraphic);
}
- else if(!aFileName.isEmpty())
- {
- // #i15508# we have no original data, but a file name. This happens e.g.
- // when inserting a linked graphic and save, reload document. Try to access
- // that data from the original file; if this works, use it. Else use the
- // data we have (but without knowing the original format)
- GraphicFilter& rFlt = GraphicFilter::GetGraphicFilter();
- Graphic aNew;
- int nRes = GraphicFilter::LoadGraphic( aFileName, OUString(), aNew, &rFlt);
-
- if(GRFILTER_OK == nRes)
- {
- maGrfObj.SetGraphic(aNew);
- }
- }
}
}
@@ -961,60 +862,6 @@ SwContentNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
return pGrfNd;
}
-IMPL_STATIC_LINK(SwGrfNode, SwapReplacement, const GraphicObject*, pGrfObj, SvStream*)
-{
- // replacement image is always swapped
- if (pGrfObj->IsInSwapOut())
- {
- return GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- else if (pGrfObj->IsInSwapIn())
- {
- return GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- else
- {
- assert(!"why is swap handler being called?");
- }
-
- return GRFMGR_AUTOSWAPSTREAM_NONE;
-}
-
-IMPL_LINK( SwGrfNode, SwapGraphic, const GraphicObject*, pGrfObj, SvStream* )
-{
- SvStream* pRet;
-
- // Keep graphic while in swap in. That's at least important
- // when breaking links, because in this situation a reschedule call and
- // a DataChanged call lead to a paint of the graphic.
- if( pGrfObj->IsInSwapOut() && (IsSelected() || bInSwapIn) )
- pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
- else if( refLink.Is() )
- {
- if( pGrfObj->IsInSwapIn() )
- {
- // then make it by your self
- if( !bInSwapIn )
- {
- const bool bIsModifyLocked = IsModifyLocked();
- LockModify();
- SwapIn();
- if( !bIsModifyLocked )
- UnlockModify();
- }
- pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
- }
- else
- pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
- }
- else
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
-
- return pRet;
-}
-
/// returns the Graphic-Attr-Structure filled with our graphic attributes
GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA,
const SwFrame* pFrame ) const
diff --git a/vcl/source/graphic/GraphicObject.cxx b/vcl/source/graphic/GraphicObject.cxx
index 8e2df2a7f440..624a4f8d6e53 100644
--- a/vcl/source/graphic/GraphicObject.cxx
+++ b/vcl/source/graphic/GraphicObject.cxx
@@ -303,129 +303,29 @@ struct GrfSimpleCacheObj
};
GraphicObject::GraphicObject()
- : mbAutoSwapped(false)
- , mbIsInSwapIn(false)
- , mbIsInSwapOut(false)
{
- ImplEnsureGraphicManager();
- ImplAssignGraphicData();
}
GraphicObject::GraphicObject(const Graphic& rGraphic)
: maGraphic(rGraphic)
- , mbAutoSwapped(false)
- , mbIsInSwapIn(false)
- , mbIsInSwapOut(false)
{
- ImplEnsureGraphicManager();
- ImplAssignGraphicData();
}
GraphicObject::GraphicObject(const GraphicObject& rGraphicObj)
: maGraphic(rGraphicObj.GetGraphic())
, maAttr(rGraphicObj.maAttr)
- , maLink(rGraphicObj.maLink)
, maUserData(rGraphicObj.maUserData)
- , mbAutoSwapped(false)
- , mbIsInSwapIn(false)
- , mbIsInSwapOut(false)
{
- ImplAssignGraphicData();
- if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
- SetSwapState();
}
GraphicObject::GraphicObject(const OString& rUniqueID)
- : mbAutoSwapped(false)
- , mbIsInSwapIn(false)
- , mbIsInSwapOut(false)
{
- ImplEnsureGraphicManager();
-
- // assign default properties
- ImplAssignGraphicData();
-
- // update properties
- ImplAssignGraphicData();
}
GraphicObject::~GraphicObject()
{
}
-void GraphicObject::ImplAssignGraphicData()
-{
- maPrefSize = maGraphic.GetPrefSize();
- maPrefMapMode = maGraphic.GetPrefMapMode();
- mnSizeBytes = maGraphic.GetSizeBytes();
- meType = maGraphic.GetType();
- mbTransparent = maGraphic.IsTransparent();
- // mbAlpha = maGraphic.IsAlpha();
- mbAnimated = maGraphic.IsAnimated();
- mbEPS = maGraphic.IsEPS();
- mnAnimationLoopCount = ( mbAnimated ? maGraphic.GetAnimationLoopCount() : 0 );
-}
-
-void GraphicObject::ImplEnsureGraphicManager()
-{
-}
-
-void GraphicObject::ImplAutoSwapIn()
-{
- if( !IsSwappedOut() )
- return;
-
- {
- mbIsInSwapIn = true;
-
- if( maGraphic.SwapIn() )
- mbAutoSwapped = false;
- else
- {
- SvStream* pStream = GetSwapStream();
-
- if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream )
- {
- if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream )
- {
- if( HasLink() )
- {
- OUString aURLStr;
-
- if( osl::FileBase::getFileURLFromSystemPath( GetLink(), aURLStr ) == osl::FileBase::E_None )
- {
- std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURLStr, StreamMode::READ ));
-
- if( pIStm )
- {
- ReadGraphic( *pIStm, maGraphic );
- mbAutoSwapped = ( maGraphic.GetType() != GraphicType::NONE );
- }
- }
- }
- }
- else if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream )
- mbAutoSwapped = !maGraphic.SwapIn();
- else if( GRFMGR_AUTOSWAPSTREAM_LOADED == pStream )
- mbAutoSwapped = maGraphic.IsSwapOut();
- else
- {
- mbAutoSwapped = !maGraphic.SwapIn( pStream );
- delete pStream;
- }
- }
- else
- {
- DBG_ASSERT( ( GraphicType::NONE == meType ) || ( GraphicType::Default == meType ),
- "GraphicObject::ImplAutoSwapIn: could not get stream to swap in graphic! (=>KA)" );
- }
- }
-
- mbIsInSwapIn = false;
- }
- ImplAssignGraphicData();
-}
-
GraphicType GraphicObject::GetType() const
{
return maGraphic.GetType();
@@ -529,16 +429,11 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
{
if( &rGraphicObj != this )
{
- maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
mxSimpleCache.reset();
maGraphic = rGraphicObj.GetGraphic();
maAttr = rGraphicObj.maAttr;
- maLink = rGraphicObj.maLink;
maUserData = rGraphicObj.maUserData;
- mbAutoSwapped = false;
- if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
- SetSwapState();
}
return *this;
@@ -547,26 +442,14 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
bool GraphicObject::operator==( const GraphicObject& rGraphicObj ) const
{
return( ( rGraphicObj.maGraphic == maGraphic ) &&
- ( rGraphicObj.maAttr == maAttr ) &&
- ( rGraphicObj.GetLink() == GetLink() ) );
+ ( rGraphicObj.maAttr == maAttr ) );
}
OString GraphicObject::GetUniqueID() const
{
- if ( !IsInSwapIn() && IsEPS() )
- const_cast<GraphicObject*>(this)->FireSwapInRequest();
-
return GetGraphic().getUniqueID();
}
-SvStream* GraphicObject::GetSwapStream() const
-{
- if( HasSwapStreamHdl() )
- return maSwapStreamHdl.Call( this );
- else
- return GRFMGR_AUTOSWAPSTREAM_NONE;
-}
-
void GraphicObject::SetAttr( const GraphicAttr& rAttr )
{
maAttr = rAttr;
@@ -575,16 +458,6 @@ void GraphicObject::SetAttr( const GraphicAttr& rAttr )
mxSimpleCache.reset();
}
-void GraphicObject::SetLink()
-{
- maLink.clear();
-}
-
-void GraphicObject::SetLink( const OUString& rLink )
-{
- maLink = rLink;
-}
-
void GraphicObject::SetUserData()
{
maUserData.clear();
@@ -593,8 +466,6 @@ void GraphicObject::SetUserData()
void GraphicObject::SetUserData( const OUString& rUserData )
{
maUserData = rUserData;
- if( !rUserData.isEmpty() )
- SetSwapState();
}
static sal_uInt32 GetCacheTimeInMs()
@@ -609,38 +480,6 @@ static sal_uInt32 GetCacheTimeInMs()
return nSeconds * 1000;
}
-void GraphicObject::SetSwapStreamHdl(const Link<const GraphicObject*, SvStream*>& rHdl)
-{
- maSwapStreamHdl = rHdl;
-
- sal_uInt32 const nSwapOutTimeout(GetCacheTimeInMs());
- if (nSwapOutTimeout)
- {
- if (!mxSwapOutTimer)
- {
- mxSwapOutTimer.reset(new Timer("svtools::GraphicObject mpSwapOutTimer"));
- mxSwapOutTimer->SetTimeoutHdl( LINK( this, GraphicObject, ImplAutoSwapOutHdl ) );
- }
-
- mxSwapOutTimer->SetTimeout( nSwapOutTimeout );
- mxSwapOutTimer->Start();
- }
- else
- {
- mxSwapOutTimer.reset();
- }
-}
-
-void GraphicObject::FireSwapInRequest()
-{
- ImplAutoSwapIn();
-}
-
-void GraphicObject::FireSwapOutRequest()
-{
- ImplAutoSwapOutHdl( nullptr );
-}
-
bool GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
const GraphicAttr* pAttr, GraphicManagerDrawFlags nFlags )
{
@@ -737,49 +576,46 @@ bool GraphicObject::StartAnimation( OutputDevice* pOut, const Point& rPt, const
GetGraphic();
- if( !IsSwappedOut() )
+ const GraphicAttr aAttr( GetAttr() );
+
+ if (IsAnimated())
{
- const GraphicAttr aAttr( GetAttr() );
+ Point aPt( rPt );
+ Size aSz( rSz );
+ bool bCropped = aAttr.IsCropped();
- if( mbAnimated )
+ if( bCropped )
{
- Point aPt( rPt );
- Size aSz( rSz );
- bool bCropped = aAttr.IsCropped();
-
- if( bCropped )
- {
- tools::PolyPolygon aClipPolyPoly;
- bool bRectClip;
- const bool bCrop = ImplGetCropParams( pOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip );
+ tools::PolyPolygon aClipPolyPoly;
+ bool bRectClip;
+ const bool bCrop = ImplGetCropParams( pOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip );
- pOut->Push( PushFlags::CLIPREGION );
+ pOut->Push( PushFlags::CLIPREGION );
- if( bCrop )
- {
- if( bRectClip )
- pOut->IntersectClipRegion( aClipPolyPoly.GetBoundRect() );
- else
- pOut->IntersectClipRegion(vcl::Region(aClipPolyPoly));
- }
- }
-
- if (!mxSimpleCache || (mxSimpleCache->maAttr != aAttr) || pFirstFrameOutDev)
+ if( bCrop )
{
- mxSimpleCache.reset(new GrfSimpleCacheObj(GetTransformedGraphic(&aAttr), aAttr));
- mxSimpleCache->maGraphic.SetAnimationNotifyHdl(GetGraphic().GetAnimationNotifyHdl());
+ if( bRectClip )
+ pOut->IntersectClipRegion( aClipPolyPoly.GetBoundRect() );
+ else
+ pOut->IntersectClipRegion(vcl::Region(aClipPolyPoly));
}
+ }
+
+ if (!mxSimpleCache || (mxSimpleCache->maAttr != aAttr) || pFirstFrameOutDev)
+ {
+ mxSimpleCache.reset(new GrfSimpleCacheObj(GetTransformedGraphic(&aAttr), aAttr));
+ mxSimpleCache->maGraphic.SetAnimationNotifyHdl(GetGraphic().GetAnimationNotifyHdl());
+ }
- mxSimpleCache->maGraphic.StartAnimation(pOut, aPt, aSz, nExtraData, pFirstFrameOutDev);
+ mxSimpleCache->maGraphic.StartAnimation(pOut, aPt, aSz, nExtraData, pFirstFrameOutDev);
- if( bCropped )
- pOut->Pop();
+ if( bCropped )
+ pOut->Pop();
- bRet = true;
- }
- else
- bRet = Draw( pOut, rPt, rSz, &aAttr );
+ bRet = true;
}
+ else
+ bRet = Draw( pOut, rPt, rSz, &aAttr );
return bRet;
}
@@ -792,43 +628,17 @@ void GraphicObject::StopAnimation( OutputDevice* pOut, long nExtraData )
const Graphic& GraphicObject::GetGraphic() const
{
- GraphicObject *pThis = const_cast<GraphicObject*>(this);
- (void)pThis->SwapIn();
-
- //fdo#50697 If we've been asked to provide the graphic, then reset
- //the cache timeout to start from now and not remain at the
- //time of creation
- // restart SwapOut timer; this is like touching in a cache to reset to the full timeout value
- if (pThis->mxSwapOutTimer && pThis->mxSwapOutTimer->IsActive())
- {
- pThis->mxSwapOutTimer->Stop();
- pThis->mxSwapOutTimer->Start();
- }
-
return maGraphic;
}
void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* /*pCopyObj*/ )
{
- if (mxSwapOutTimer)
- mxSwapOutTimer->Stop();
-
maGraphic = rGraphic;
- mbAutoSwapped = false;
- maLink.clear();
- mxSimpleCache.reset();
-
- if (mxSwapOutTimer)
- mxSwapOutTimer->Start();
}
void GraphicObject::SetGraphic( const Graphic& rGraphic, const OUString& rLink )
{
- // in case we are called from a situation where rLink and maLink are the same thing,
- // we need a copy because SetGraphic clears maLink
- OUString sLinkCopy = rLink;
SetGraphic( rGraphic );
- maLink = sLinkCopy;
}
Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMode& rDestMap, const GraphicAttr& rAttr ) const
@@ -1065,7 +875,7 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const
Graphic aGraphic;
GraphicAttr aAttr( pAttr ? *pAttr : GetAttr() );
- if( maGraphic.IsSupportedGraphic() && !maGraphic.IsSwapOut() )
+ if (maGraphic.IsSupportedGraphic())
{
if( aAttr.IsSpecialDrawMode() || aAttr.IsAdjusted() || aAttr.IsMirrored() || aAttr.IsRotated() || aAttr.IsTransparent() )
{
@@ -1075,7 +885,7 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const
{
Animation aAnimation( maGraphic.GetAnimation() );
lclImplAdjust( aAnimation, aAttr, GraphicAdjustmentFlags::ALL );
- aAnimation.SetLoopCount( mnAnimationLoopCount );
+ aAnimation.SetLoopCount(maGraphic.GetAnimationLoopCount());
aGraphic = aAnimation;
}
else
@@ -1108,103 +918,6 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const
return aGraphic;
}
-bool GraphicObject::SwapOut()
-{
- const bool bRet = !mbAutoSwapped && maGraphic.SwapOut();
-
- return bRet;
-}
-
-bool GraphicObject::SwapOut( SvStream* pOStm )
-{
- bool bRet = false;
- try
- {
- bRet = !mbAutoSwapped;
- // swap out as a link
- if( pOStm == GRFMGR_AUTOSWAPSTREAM_LINK )
- {
- maGraphic.SwapOutAsLink();
- }
- else
- {
- bRet = bRet && maGraphic.SwapOut( pOStm );
- }
- }
- catch(...)
- {
- SAL_WARN( "svtools", "GraphicObject::SwapIn exception");
- }
- return bRet;
-}
-
-bool GraphicObject::SwapIn()
-{
- bool bRet = false;
- try
- {
- if( mbAutoSwapped )
- {
- ImplAutoSwapIn();
- bRet = true;
- }
- else
- {
- bRet = maGraphic.SwapIn();
- }
-
- if( bRet )
- {
- ImplAssignGraphicData();
- }
- }
- catch (...)
- {
- SAL_WARN( "svtools", "GraphicObject::SwapIn exception");
- }
-
- return bRet;
-}
-
-void GraphicObject::SetSwapState()
-{
- if( !IsSwappedOut() )
- {
- mbAutoSwapped = true;
- }
-}
-
-IMPL_LINK_NOARG(GraphicObject, ImplAutoSwapOutHdl, Timer *, void)
-{
- if( !IsSwappedOut() )
- {
- mbIsInSwapOut = true;
-
- SvStream* pStream = GetSwapStream();
-
- if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream )
- {
- if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream )
- mbAutoSwapped = SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK );
- else
- {
- if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream )
- mbAutoSwapped = SwapOut();
- else
- {
- mbAutoSwapped = SwapOut( pStream );
- delete pStream;
- }
- }
- }
-
- mbIsInSwapOut = false;
- }
-
- if (mxSwapOutTimer)
- mxSwapOutTimer->Start();
-}
-
#define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
bool GraphicObject::isGraphicObjectUniqueIdURL(OUString const & rURL)