summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2014-03-15 22:20:17 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2014-03-16 09:51:13 +0100
commit78a4b4247b90a75e7a5a8b42aef8d39187cc0182 (patch)
tree8b6d726ff55647c4a0828bfdb751f913c1ef07d3 /sw
parentcb375b90031aa91274a82fea37f0aa341246e86c (diff)
SwapIn/SwapOut can return bool + sal_Bool to bool
Change-Id: Ia5477d6bb83af38435b9ac44359fe2f46b00807c
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ndgrf.hxx4
-rw-r--r--sw/inc/swbaslnk.hxx8
-rw-r--r--sw/source/core/doc/notxtfrm.cxx2
-rw-r--r--sw/source/core/docnode/swbaslnk.cxx25
-rw-r--r--sw/source/core/graphic/ndgrf.cxx47
5 files changed, 46 insertions, 40 deletions
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 63a7e017919f..850b23079770 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -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?
diff --git a/sw/inc/swbaslnk.hxx b/sw/inc/swbaslnk.hxx
index 70608375bd73..f145b5b05e3e 100644
--- a/sw/inc/swbaslnk.hxx
+++ b/sw/inc/swbaslnk.hxx
@@ -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(); }
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index fd5842792c74..df0c4e7cf0dd 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -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() &&
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index 2dd2075bc0ca..9825b7f859d8 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -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;
}
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 59e6d3c434fe..aca1675ec68d 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -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