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