summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/graphic/GraphicObject.cxx351
1 files changed, 32 insertions, 319 deletions
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)