Kaydet (Commit) eb841c06 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:returnconstant in linguistic,lotuswordpro

Change-Id: If5c7d936020e5470b09c2fe54d41fb006c296a34
Reviewed-on: https://gerrit.libreoffice.org/58877
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst ff4d6a7e
......@@ -208,14 +208,14 @@ public:
processDictionaryListEvent(
const linguistic2::DictionaryListEvent& rDicListEvent ) override;
inline bool AddLngSvcMgrListener(
inline void AddLngSvcMgrListener(
const uno::Reference< lang::XEventListener >& rxListener );
inline bool RemoveLngSvcMgrListener(
inline void RemoveLngSvcMgrListener(
const uno::Reference< lang::XEventListener >& rxListener );
void DisposeAndClear( const lang::EventObject &rEvtObj );
bool AddLngSvcEvtBroadcaster(
void AddLngSvcEvtBroadcaster(
const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster );
bool RemoveLngSvcEvtBroadcaster(
void RemoveLngSvcEvtBroadcaster(
const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster );
void AddLngSvcEvt( sal_Int16 nLngSvcEvt );
......@@ -349,19 +349,17 @@ void LngSvcMgrListenerHelper::LaunchEvent( sal_Int16 nLngSvcEvtFlags )
}
inline bool LngSvcMgrListenerHelper::AddLngSvcMgrListener(
inline void LngSvcMgrListenerHelper::AddLngSvcMgrListener(
const uno::Reference< lang::XEventListener >& rxListener )
{
aLngSvcMgrListeners.addInterface( rxListener );
return true;
}
inline bool LngSvcMgrListenerHelper::RemoveLngSvcMgrListener(
inline void LngSvcMgrListenerHelper::RemoveLngSvcMgrListener(
const uno::Reference< lang::XEventListener >& rxListener )
{
aLngSvcMgrListeners.removeInterface( rxListener );
return true;
}
......@@ -389,7 +387,7 @@ void LngSvcMgrListenerHelper::DisposeAndClear( const lang::EventObject &rEvtObj
}
bool LngSvcMgrListenerHelper::AddLngSvcEvtBroadcaster(
void LngSvcMgrListenerHelper::AddLngSvcEvtBroadcaster(
const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster )
{
if (rxBroadcaster.is())
......@@ -398,11 +396,10 @@ bool LngSvcMgrListenerHelper::AddLngSvcEvtBroadcaster(
rxBroadcaster->addLinguServiceEventListener(
static_cast<linguistic2::XLinguServiceEventListener *>(this) );
}
return false;
}
bool LngSvcMgrListenerHelper::RemoveLngSvcEvtBroadcaster(
void LngSvcMgrListenerHelper::RemoveLngSvcEvtBroadcaster(
const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster )
{
if (rxBroadcaster.is())
......@@ -411,7 +408,6 @@ bool LngSvcMgrListenerHelper::RemoveLngSvcEvtBroadcaster(
rxBroadcaster->removeLinguServiceEventListener(
static_cast<linguistic2::XLinguServiceEventListener *>(this) );
}
return false;
}
......@@ -1436,14 +1432,13 @@ sal_Bool SAL_CALL
{
osl::MutexGuard aGuard( GetLinguMutex() );
bool bRes = false;
if (!bDisposing && xListener.is())
{
if (!mxListenerHelper.is())
GetListenerHelper_Impl();
bRes = mxListenerHelper->AddLngSvcMgrListener( xListener );
}
return bRes;
if (bDisposing || !xListener.is())
return false;
if (!mxListenerHelper.is())
GetListenerHelper_Impl();
mxListenerHelper->AddLngSvcMgrListener( xListener );
return true;
}
......@@ -1453,15 +1448,14 @@ sal_Bool SAL_CALL
{
osl::MutexGuard aGuard( GetLinguMutex() );
bool bRes = false;
if (!bDisposing && xListener.is())
{
DBG_ASSERT( mxListenerHelper.is(), "listener removed without being added" );
if (!mxListenerHelper.is())
GetListenerHelper_Impl();
bRes = mxListenerHelper->RemoveLngSvcMgrListener( xListener );
}
return bRes;
if (bDisposing || !xListener.is())
return false;
DBG_ASSERT( mxListenerHelper.is(), "listener removed without being added" );
if (!mxListenerHelper.is())
GetListenerHelper_Impl();
mxListenerHelper->RemoveLngSvcMgrListener( xListener );
return true;
}
......@@ -1918,14 +1912,12 @@ void SAL_CALL
bool LngSvcMgr::AddLngSvcEvtBroadcaster(
const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster )
{
bool bRes = false;
if (rxBroadcaster.is())
{
if (!mxListenerHelper.is())
GetListenerHelper_Impl();
bRes = mxListenerHelper->AddLngSvcEvtBroadcaster( rxBroadcaster );
}
return bRes;
if (!rxBroadcaster.is())
return false;
if (!mxListenerHelper.is())
GetListenerHelper_Impl();
mxListenerHelper->AddLngSvcEvtBroadcaster( rxBroadcaster );
return true;
}
......
......@@ -168,13 +168,11 @@ LtcBenContainer::LtcBenContainer(LwpSvStream * pStream)
* @param buffer pointer
* @param buffer size
* @param number of bytes read
* @return BenError
*/
BenError LtcBenContainer::Read(void * pBuffer, size_t MaxSize,
void LtcBenContainer::Read(void * pBuffer, size_t MaxSize,
size_t* pAmtRead)
{
*pAmtRead = cpStream->Read(pBuffer, MaxSize);
return BenErr_OK;
}
/**
* Read buffer from bento file with specified size
......@@ -194,24 +192,19 @@ BenError LtcBenContainer::ReadKnownSize(void * pBuffer, size_t Amt)
/**
* Seek to position from the beginning of the bento file
* @param position in container file from beginning
* @return BenError
*/
BenError LtcBenContainer::SeekToPosition(BenContainerPos Pos)
void LtcBenContainer::SeekToPosition(BenContainerPos Pos)
{
cpStream->Seek(Pos);
return BenErr_OK;
}
/**
* Seek to position compare to end of bento file
* @param position in container file from end
* @return BenError
*/
BenError LtcBenContainer::SeekFromEnd(long Offset)
void LtcBenContainer::SeekFromEnd(long Offset)
{
cpStream->Seek(STREAM_SEEK_TO_END);
cpStream->SeekRel(Offset);
return BenErr_OK;
}
/**
* Find the next value stream with property name
......
......@@ -209,11 +209,11 @@ public: // Internal methods
~LtcBenContainer();
sal_uLong remainingSize() const;
BenError Read(void * pBuffer, size_t MaxSize,
void Read(void * pBuffer, size_t MaxSize,
size_t* pAmtRead);
BenError ReadKnownSize(void * pBuffer, size_t Amt);
BenError SeekToPosition(BenContainerPos Pos);
BenError SeekFromEnd(long Offset);
void SeekToPosition(BenContainerPos Pos);
void SeekFromEnd(long Offset);
void SetNextAvailObjectID(BenObjectID ID) { cNextAvailObjectID = ID; }
CUtList& GetObjects() { return cObjects; }
......
......@@ -78,7 +78,6 @@ void
CBenValue::ReadValueData(void * pReadBuffer, size_t Offset,
size_t Amt, size_t* pAmtRead)
{
BenError Err;
size_t SegOffset = 0;
*pAmtRead = 0;
CBenValueSegment * pCurrSeg = nullptr;
......@@ -114,13 +113,9 @@ CBenValue::ReadValueData(void * pReadBuffer, size_t Offset,
}
else
{
if ((Err = pContainer->SeekToPosition(pCurrSeg->GetPosition() +
OffsetIntoSeg)) != BenErr_OK)
return;
if ((Err = pContainer->Read(pBuffer, AmtThisSeg,
&AmtReadThisSeg)) != BenErr_OK)
return;
pContainer->SeekToPosition(pCurrSeg->GetPosition() +
OffsetIntoSeg);
pContainer->Read(pBuffer, AmtThisSeg, &AmtReadThisSeg);
}
*pAmtRead += AmtReadThisSeg;
......
......@@ -81,8 +81,7 @@ CBenTOCReader::ReadLabelAndTOC()
if (cTOCSize > nLength - TOCOffset)
return BenErr_ReadPastEndOfTOC;
if ((Err = cpContainer->SeekToPosition(TOCOffset)) != BenErr_OK)
return Err;
cpContainer->SeekToPosition(TOCOffset);
cpTOC.reset( new BenByte[cTOCSize] );
if ((Err = cpContainer->ReadKnownSize(cpTOC.get(), cTOCSize)) != BenErr_OK)
......@@ -100,8 +99,7 @@ CBenTOCReader::ReadLabel(unsigned long * pTOCOffset, unsigned long * pTOCSize)
// If seek fails, then probably because stream is smaller than
// BEN_LABEL_SIZE and thus can't be Bento container
BenError Err;
if ((Err = cpContainer->SeekFromEnd(-BEN_LABEL_SIZE)) != BenErr_OK)
return BenErr_NotBentoContainer;
cpContainer->SeekFromEnd(-BEN_LABEL_SIZE);
BenByte Label[BEN_LABEL_SIZE];
if ((Err = cpContainer->ReadKnownSize(Label, BEN_LABEL_SIZE)) != BenErr_OK)
......@@ -172,9 +170,7 @@ CBenTOCReader::SearchForLabel(BenByte * pLabel)
UsedBufferSize = CurrOffset;
else UsedBufferSize = LABEL_READ_BUFFER_SIZE;
if ((Err = cpContainer->SeekToPosition(CurrOffset - UsedBufferSize))
!= BenErr_OK)
return Err;
cpContainer->SeekToPosition(CurrOffset - UsedBufferSize);
if ((Err = cpContainer->ReadKnownSize(Buffer, UsedBufferSize)) !=
BenErr_OK)
......@@ -186,9 +182,8 @@ CBenTOCReader::SearchForLabel(BenByte * pLabel)
if (memcmp(Buffer + (CurrOffset - BEN_MAGIC_BYTES_SIZE -
BufferStartOffset), gsBenMagicBytes, BEN_MAGIC_BYTES_SIZE) == 0)
{
if ((Err = cpContainer->SeekToPosition(CurrOffset -
BEN_MAGIC_BYTES_SIZE)) != BenErr_OK)
return Err;
cpContainer->SeekToPosition(CurrOffset -
BEN_MAGIC_BYTES_SIZE);
return cpContainer->ReadKnownSize(pLabel, BEN_LABEL_SIZE);
}
......@@ -265,8 +260,7 @@ CBenTOCReader::ReadTOC()
return Err;
LookAhead = GetCode();
if ((Err = cpContainer->SeekToPosition(Pos)) != BenErr_OK)
return Err;
cpContainer->SeekToPosition(Pos);
const auto nRemainingSize = cpContainer->remainingSize();
if (Length > nRemainingSize)
......
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