Kaydet (Commit) 78a4b424 authored tarafından Matteo Casalin's avatar Matteo Casalin

SwapIn/SwapOut can return bool + sal_Bool to bool

Change-Id: Ia5477d6bb83af38435b9ac44359fe2f46b00807c
üst cb375b90
...@@ -403,9 +403,9 @@ public: ...@@ -403,9 +403,9 @@ public:
Link GetAnimationNotifyHdl() const { return maGraphic.GetAnimationNotifyHdl(); } Link GetAnimationNotifyHdl() const { return maGraphic.GetAnimationNotifyHdl(); }
sal_Bool SwapOut(); bool SwapOut();
sal_Bool SwapOut( SvStream* pOStm ); bool SwapOut( SvStream* pOStm );
sal_Bool SwapIn(); bool SwapIn();
sal_Bool IsInSwapIn() const { return mbIsInSwapIn; } sal_Bool IsInSwapIn() const { return mbIsInSwapIn; }
sal_Bool IsInSwapOut() const { return mbIsInSwapOut; } sal_Bool IsInSwapOut() const { return mbIsInSwapOut; }
......
...@@ -1055,9 +1055,9 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const / ...@@ -1055,9 +1055,9 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const /
return aGraphic; return aGraphic;
} }
sal_Bool GraphicObject::SwapOut() bool GraphicObject::SwapOut()
{ {
sal_Bool bRet = ( !mbAutoSwapped ? maGraphic.SwapOut() : sal_False ); const bool bRet = !mbAutoSwapped && maGraphic.SwapOut();
if( bRet && mpMgr ) if( bRet && mpMgr )
mpMgr->ImplGraphicObjectWasSwappedOut( *this ); mpMgr->ImplGraphicObjectWasSwappedOut( *this );
...@@ -1065,9 +1065,9 @@ sal_Bool GraphicObject::SwapOut() ...@@ -1065,9 +1065,9 @@ sal_Bool GraphicObject::SwapOut()
return bRet; return bRet;
} }
sal_Bool GraphicObject::SwapOut( SvStream* pOStm ) bool GraphicObject::SwapOut( SvStream* pOStm )
{ {
sal_Bool bRet = ( !mbAutoSwapped ? maGraphic.SwapOut( pOStm ) : sal_False ); const bool bRet = !mbAutoSwapped && maGraphic.SwapOut( pOStm );
if( bRet && mpMgr ) if( bRet && mpMgr )
mpMgr->ImplGraphicObjectWasSwappedOut( *this ); mpMgr->ImplGraphicObjectWasSwappedOut( *this );
...@@ -1075,17 +1075,17 @@ sal_Bool GraphicObject::SwapOut( SvStream* pOStm ) ...@@ -1075,17 +1075,17 @@ sal_Bool GraphicObject::SwapOut( SvStream* pOStm )
return bRet; return bRet;
} }
sal_Bool GraphicObject::SwapIn() bool GraphicObject::SwapIn()
{ {
sal_Bool bRet; bool bRet = false;
if( mbAutoSwapped ) if( mbAutoSwapped )
{ {
ImplAutoSwapIn(); ImplAutoSwapIn();
bRet = sal_True; bRet = true;
} }
else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) ) else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
bRet = sal_True; bRet = true;
else else
{ {
bRet = maGraphic.SwapIn(); bRet = maGraphic.SwapIn();
......
...@@ -171,9 +171,9 @@ public: ...@@ -171,9 +171,9 @@ public:
const GraphicObject* pGrfObj = 0, const GraphicObject* pGrfObj = 0,
bool bModify = true ); bool bModify = true );
/// Loading of graphic immediately before displaying. /// Loading of graphic immediately before displaying.
short SwapIn( bool bWaitForData = false ); bool SwapIn( bool bWaitForData = false );
/// Remove graphic in order to free memory. /// Remove graphic in order to free memory.
short SwapOut(); bool SwapOut();
/// Access to storage stream-name. /// Access to storage stream-name.
void SetStreamName( const OUString& r ) { maGrfObj.SetUserData( r ); } void SetStreamName( const OUString& r ) { maGrfObj.SetUserData( r ); }
/// Is this node selected by any shell? /// Is this node selected by any shell?
......
...@@ -31,7 +31,7 @@ class SwBaseLink : public ::sfx2::SvBaseLink ...@@ -31,7 +31,7 @@ class SwBaseLink : public ::sfx2::SvBaseLink
friend long GrfNodeChanged( void* pLink, void* pCaller ); friend long GrfNodeChanged( void* pLink, void* pCaller );
SwCntntNode* pCntntNode; SwCntntNode* pCntntNode;
sal_Bool bSwapIn : 1; bool bSwapIn : 1;
sal_Bool bNoDataFlag : 1; sal_Bool bNoDataFlag : 1;
sal_Bool bIgnoreDataChanged : 1; sal_Bool bIgnoreDataChanged : 1;
ReReadThread* m_pReReadThread; ReReadThread* m_pReReadThread;
...@@ -42,7 +42,7 @@ protected: ...@@ -42,7 +42,7 @@ protected:
SwBaseLink( const OUString& rNm, sal_uInt16 nObjectType, ::sfx2::SvLinkSource* pObj, SwBaseLink( const OUString& rNm, sal_uInt16 nObjectType, ::sfx2::SvLinkSource* pObj,
SwCntntNode* pNode = 0 ) SwCntntNode* pNode = 0 )
: ::sfx2::SvBaseLink( rNm, nObjectType, pObj ), pCntntNode( pNode ), : ::sfx2::SvBaseLink( rNm, nObjectType, pObj ), pCntntNode( pNode ),
bSwapIn( sal_False ), bNoDataFlag( sal_False ), bIgnoreDataChanged( sal_False ), bSwapIn( false ), bNoDataFlag( sal_False ), bIgnoreDataChanged( sal_False ),
m_pReReadThread(0) m_pReReadThread(0)
{} {}
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
SwBaseLink( sal_uInt16 nMode, sal_uInt16 nFormat, SwCntntNode* pNode = 0 ) SwBaseLink( sal_uInt16 nMode, sal_uInt16 nFormat, SwCntntNode* pNode = 0 )
: ::sfx2::SvBaseLink( nMode, nFormat ), pCntntNode( pNode ), : ::sfx2::SvBaseLink( nMode, nFormat ), pCntntNode( pNode ),
bSwapIn( sal_False ), bNoDataFlag( sal_False ), bIgnoreDataChanged( sal_False ), bSwapIn( false ), bNoDataFlag( sal_False ), bIgnoreDataChanged( sal_False ),
m_pReReadThread(0) m_pReReadThread(0)
{} {}
virtual ~SwBaseLink(); virtual ~SwBaseLink();
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
SwCntntNode *GetCntntNode() { return pCntntNode; } SwCntntNode *GetCntntNode() { return pCntntNode; }
// For graphics only. // For graphics only.
sal_Bool SwapIn( sal_Bool bWaitForData = sal_False, sal_Bool bNativFormat = sal_False ); bool SwapIn( bool bWaitForData = false, bool bNativFormat = false );
sal_Bool Connect() { return 0 != SvBaseLink::GetRealObject(); } sal_Bool Connect() { return 0 != SvBaseLink::GetRealObject(); }
......
...@@ -855,7 +855,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons ...@@ -855,7 +855,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
if( bContinue ) if( bContinue )
{ {
const sal_Bool bSwapped = rGrfObj.IsSwappedOut(); const sal_Bool bSwapped = rGrfObj.IsSwappedOut();
const bool bSwappedIn = 0 != pGrfNd->SwapIn( bPrn ); const bool bSwappedIn = pGrfNd->SwapIn( bPrn );
if( bSwappedIn && rGrfObj.GetGraphic().IsSupportedGraphic()) if( bSwappedIn && rGrfObj.GetGraphic().IsSupportedGraphic())
{ {
const bool bAnimate = rGrfObj.IsAnimated() && const bool bAnimate = rGrfObj.IsAnimated() &&
......
...@@ -369,11 +369,9 @@ sal_Bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfN ...@@ -369,11 +369,9 @@ sal_Bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfN
return bRet; return bRet;
} }
sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat ) bool SwBaseLink::SwapIn( bool bWaitForData, bool bNativFormat )
{ {
bSwapIn = sal_True; bSwapIn = true;
sal_Bool bRes;
if( !GetObj() && ( bNativFormat || ( !IsSynchron() && bWaitForData ) )) if( !GetObj() && ( bNativFormat || ( !IsSynchron() && bWaitForData ) ))
{ {
...@@ -392,6 +390,8 @@ sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat ) ...@@ -392,6 +390,8 @@ sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat )
} }
#endif #endif
bool bRes = false;
if( GetObj() ) if( GetObj() )
{ {
OUString aMimeType( SotExchange::GetFormatMimeType( GetContentType() )); OUString aMimeType( SotExchange::GetFormatMimeType( GetContentType() ));
...@@ -401,14 +401,17 @@ sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat ) ...@@ -401,14 +401,17 @@ sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat )
if( bWaitForData && !GetObj() ) if( bWaitForData && !GetObj() )
{ {
OSL_ENSURE( !this, "The SvxFileObject was deleted in a GetData!" ); OSL_ENSURE( !this, "The SvxFileObject was deleted in a GetData!" );
bRes = sal_False;
} }
else if( 0 != ( bRes = aValue.hasValue() ) ) else
{ {
// The Flag needs to be reset on a SwapIn, because bRes = aValue.hasValue();
// we want to reapply the data. if ( bRes )
bIgnoreDataChanged = sal_False; {
DataChanged( aMimeType, aValue ); // The Flag needs to be reset on a SwapIn, because
// we want to reapply the data.
bIgnoreDataChanged = sal_False;
DataChanged( aMimeType, aValue );
}
} }
} }
else if( !IsSynchron() && bWaitForData ) else if( !IsSynchron() && bWaitForData )
...@@ -420,7 +423,7 @@ sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat ) ...@@ -420,7 +423,7 @@ sal_Bool SwBaseLink::SwapIn( sal_Bool bWaitForData, sal_Bool bNativFormat )
else else
bRes = Update(); bRes = Update();
bSwapIn = sal_False; bSwapIn = false;
return bRes; return bRes;
} }
......
...@@ -517,16 +517,15 @@ StreamAndStorageNames lcl_GetStreamStorageNames( const OUString sUserData ) ...@@ -517,16 +517,15 @@ StreamAndStorageNames lcl_GetStreamStorageNames( const OUString sUserData )
} }
/** /**
* @return -1 if ReRead successful, * @return true if ReRead or reading successful,
* 1 if reading successful, * false if not loaded
* 0 if not loaded
*/ */
short SwGrfNode::SwapIn( bool bWaitForData ) bool SwGrfNode::SwapIn( bool bWaitForData )
{ {
if( bInSwapIn ) // not recursively! if( bInSwapIn ) // not recursively!
return short(!maGrfObj.IsSwappedOut()); return !maGrfObj.IsSwappedOut();
short nRet = 0; bool bRet = false;
bInSwapIn = true; bInSwapIn = true;
SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink; SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
...@@ -537,7 +536,9 @@ short SwGrfNode::SwapIn( bool bWaitForData ) ...@@ -537,7 +536,9 @@ short SwGrfNode::SwapIn( bool bWaitForData )
{ {
// link was not loaded yet // link was not loaded yet
if( pLink->SwapIn( bWaitForData ) ) if( pLink->SwapIn( bWaitForData ) )
nRet = -1; {
bRet = true;
}
else if( GRAPHIC_DEFAULT == maGrfObj.GetType() ) else if( GRAPHIC_DEFAULT == maGrfObj.GetType() )
{ {
// no default bitmap anymore, thus re-paint // no default bitmap anymore, thus re-paint
...@@ -550,18 +551,21 @@ short SwGrfNode::SwapIn( bool bWaitForData ) ...@@ -550,18 +551,21 @@ short SwGrfNode::SwapIn( bool bWaitForData )
ModifyNotification( &aMsgHint, &aMsgHint ); ModifyNotification( &aMsgHint, &aMsgHint );
} }
} }
else if( maGrfObj.IsSwappedOut() ) { else if( maGrfObj.IsSwappedOut() )
{
// link to download // link to download
nRet = pLink->SwapIn( bWaitForData ) ? 1 : 0; bRet = pLink->SwapIn( bWaitForData );
} }
else else
nRet = 1; bRet = true;
} }
else if( maGrfObj.IsSwappedOut() ) else if( maGrfObj.IsSwappedOut() )
{ {
// graphic is in storage or in a temp file // graphic is in storage or in a temp file
if( !HasStreamName() ) if( !HasStreamName() )
nRet = (short)maGrfObj.SwapIn(); {
bRet = maGrfObj.SwapIn();
}
else else
{ {
try try
...@@ -571,8 +575,7 @@ short SwGrfNode::SwapIn( bool bWaitForData ) ...@@ -571,8 +575,7 @@ short SwGrfNode::SwapIn( bool bWaitForData )
SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream ); SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
if ( pStrm ) if ( pStrm )
{ {
if ( ImportGraphic( *pStrm ) ) bRet = ImportGraphic( *pStrm );
nRet = 1;
delete pStrm; delete pStrm;
} }
} }
...@@ -583,26 +586,26 @@ short SwGrfNode::SwapIn( bool bWaitForData ) ...@@ -583,26 +586,26 @@ short SwGrfNode::SwapIn( bool bWaitForData )
} }
} }
if( 1 == nRet ) if( bRet )
{ {
SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN ); SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN );
ModifyNotification( &aMsg, &aMsg ); ModifyNotification( &aMsg, &aMsg );
} }
} }
else else
nRet = 1; bRet = true;
OSL_ENSURE( nRet, "Cannot swap in graphic" ); OSL_ENSURE( bRet, "Cannot swap in graphic" );
if( nRet ) if( bRet )
{ {
if( !nGrfSize.Width() && !nGrfSize.Height() ) if( !nGrfSize.Width() && !nGrfSize.Height() )
SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) ); SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) );
} }
bInSwapIn = false; bInSwapIn = false;
return nRet; return bRet;
} }
short SwGrfNode::SwapOut() bool SwGrfNode::SwapOut()
{ {
if( maGrfObj.GetType() != GRAPHIC_DEFAULT && if( maGrfObj.GetType() != GRAPHIC_DEFAULT &&
maGrfObj.GetType() != GRAPHIC_NONE && maGrfObj.GetType() != GRAPHIC_NONE &&
...@@ -615,12 +618,12 @@ short SwGrfNode::SwapOut() ...@@ -615,12 +618,12 @@ short SwGrfNode::SwapOut()
// if there is no stream name in the storage yet // if there is no stream name in the storage yet
if( !HasStreamName() ) if( !HasStreamName() )
if( !maGrfObj.SwapOut() ) if( !maGrfObj.SwapOut() )
return 0; return false;
} }
// written graphics and links are removed here // written graphics and links are removed here
return (short) maGrfObj.SwapOut( NULL ); return maGrfObj.SwapOut( NULL );
} }
return 1; return true;
} }
bool SwGrfNode::GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const bool SwGrfNode::GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment