diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2015-05-03 23:25:52 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2015-05-03 23:31:53 +0200 |
commit | 98436c4b53639d86f261ac630c46d32e3c7b8e28 (patch) | |
tree | be3be3fb1cdd44ad92c8a171ef72e00a96815be2 | |
parent | bc9d02b0ca6244b46c9e2c59b7cc3618eb0f0148 (diff) |
tdf#89783: Adjust to new GetPos retval (size_t vs. sal_uInt16)
Some of the usages of GetPos were just misusing it to find out
whether a vector contains given element -- use Contains() in those
cases
This patch is partially based on work of Christoph Lutz
Conflicts:
sw/source/filter/ww8/wrtw8esh.cxx
sw/source/filter/ww8/wrtw8num.cxx
Change-Id: I40bedba905e7577ba23f69acee178e0ea7cc1521
-rw-r--r-- | sw/inc/IDocumentFieldsAccess.hxx | 2 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentFieldsManager.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/fields/dbfld.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/inc/DocumentFieldsManager.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/tox/tox.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/undo/rolbck.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/undo/unattr.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/undo/undobj1.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/undo/unfmco.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/undo/untbl.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/undo/untblk.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/basflt/shellio.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8num.cxx | 2 |
16 files changed, 45 insertions, 49 deletions
diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx index f0859a3afd51..36c012924185 100644 --- a/sw/inc/IDocumentFieldsAccess.hxx +++ b/sw/inc/IDocumentFieldsAccess.hxx @@ -54,7 +54,7 @@ namespace com { namespace sun { namespace star { namespace uno { class Any; } } virtual SwFieldType* GetFldType(sal_uInt16 nResId, const OUString& rName, bool bDbFieldMatching) const = 0; - virtual void RemoveFldType(sal_uInt16 nFld) = 0; + virtual void RemoveFldType(size_t nFld) = 0; virtual void UpdateFlds( SfxPoolItem* pNewHt, bool bCloseDB) = 0; diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index c935ede87074..2dab95b69ce9 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -826,7 +826,7 @@ public: SwCharFmt *MakeCharFmt(const OUString &rFmtName, SwCharFmt *pDerivedFrom, bool bBroadcast = false, bool bAuto = true ); - void DelCharFmt(sal_uInt16 nFmt, bool bBroadcast = false); + void DelCharFmt(size_t nFmt, bool bBroadcast = false); void DelCharFmt(SwCharFmt* pFmt, bool bBroadcast = false); SwCharFmt* FindCharFmtByName( const OUString& rName ) const { return static_cast<SwCharFmt*>(FindFmtByName( (SwFmtsBase&)*mpCharFmtTbl, rName )); } @@ -844,7 +844,7 @@ public: SwConditionTxtFmtColl* MakeCondTxtFmtColl( const OUString &rFmtName, SwTxtFmtColl *pDerivedFrom, bool bBroadcast = false); - void DelTxtFmtColl(sal_uInt16 nFmt, bool bBroadcast = false); + void DelTxtFmtColl(size_t nFmt, bool bBroadcast = false); void DelTxtFmtColl( SwTxtFmtColl* pColl, bool bBroadcast = false ); /** Add 4th optional parameter <bResetListAttrs>. 'side effect' of <SetTxtFmtColl> with <bReset = true> is that the hard diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index e1746a22b216..847a96b1d0b5 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -290,13 +290,13 @@ SwFieldType* DocumentFieldsManager::GetFldType( } /// Remove field type -void DocumentFieldsManager::RemoveFldType(sal_uInt16 nFld) +void DocumentFieldsManager::RemoveFldType(size_t nFld) { OSL_ENSURE( INIT_FLDTYPES <= nFld, "don't remove InitFlds" ); /* * Dependent fields present -> ErrRaise */ - sal_uInt16 nSize = mpFldTypes->size(); + size_t nSize = mpFldTypes->size(); if(nFld < nSize) { SwFieldType* pTmp = (*mpFldTypes)[nFld]; diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 08bb0562127e..1dbcb1358144 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -667,7 +667,7 @@ const SfxPoolItem& SwDoc::GetDefault( sal_uInt16 nFmtHint ) const } /// Delete the formats -void SwDoc::DelCharFmt(sal_uInt16 nFmt, bool bBroadcast) +void SwDoc::DelCharFmt(size_t nFmt, bool bBroadcast) { SwCharFmt * pDel = (*mpCharFmtTbl)[nFmt]; @@ -691,8 +691,8 @@ void SwDoc::DelCharFmt(sal_uInt16 nFmt, bool bBroadcast) void SwDoc::DelCharFmt( SwCharFmt *pFmt, bool bBroadcast ) { - sal_uInt16 nFmt = mpCharFmtTbl->GetPos( pFmt ); - OSL_ENSURE( USHRT_MAX != nFmt, "Fmt not found," ); + size_t nFmt = mpCharFmtTbl->GetPos( pFmt ); + OSL_ENSURE( SIZE_MAX != nFmt, "Fmt not found," ); DelCharFmt( nFmt, bBroadcast ); } @@ -952,7 +952,7 @@ SwGrfFmtColl* SwDoc::MakeGrfFmtColl( const OUString &rFmtName, return pFmtColl; } -void SwDoc::DelTxtFmtColl(sal_uInt16 nFmtColl, bool bBroadcast) +void SwDoc::DelTxtFmtColl(size_t nFmtColl, bool bBroadcast) { OSL_ENSURE( nFmtColl, "Remove fuer Coll 0." ); @@ -991,8 +991,8 @@ void SwDoc::DelTxtFmtColl(sal_uInt16 nFmtColl, bool bBroadcast) void SwDoc::DelTxtFmtColl( SwTxtFmtColl *pColl, bool bBroadcast ) { - sal_uInt16 nFmt = mpTxtFmtCollTbl->GetPos( pColl ); - OSL_ENSURE( USHRT_MAX != nFmt, "Collection not found," ); + size_t nFmt = mpTxtFmtCollTbl->GetPos( pColl ); + OSL_ENSURE( SIZE_MAX != nFmt, "Collection not found," ); DelTxtFmtColl( nFmt, bBroadcast ); } diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index 631efa78f1c3..a971af328459 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -89,9 +89,9 @@ void SwDBFieldType::ReleaseRef() if (--nRefCnt <= 0) { - sal_uInt16 nPos = GetDoc()->getIDocumentFieldsAccess().GetFldTypes()->GetPos(this); + size_t nPos = GetDoc()->getIDocumentFieldsAccess().GetFldTypes()->GetPos(this); - if (nPos != USHRT_MAX) + if (nPos != SIZE_MAX) { GetDoc()->getIDocumentFieldsAccess().RemoveFldType(nPos); delete this; diff --git a/sw/source/core/inc/DocumentFieldsManager.hxx b/sw/source/core/inc/DocumentFieldsManager.hxx index c29a4d9eb833..010481d7e16a 100644 --- a/sw/source/core/inc/DocumentFieldsManager.hxx +++ b/sw/source/core/inc/DocumentFieldsManager.hxx @@ -40,7 +40,7 @@ public: virtual SwFieldType *InsertFldType(const SwFieldType &) SAL_OVERRIDE; virtual SwFieldType *GetSysFldType( const sal_uInt16 eWhich ) const SAL_OVERRIDE; virtual SwFieldType* GetFldType(sal_uInt16 nResId, const OUString& rName, bool bDbFieldMatching) const SAL_OVERRIDE; - virtual void RemoveFldType(sal_uInt16 nFld) SAL_OVERRIDE; + virtual void RemoveFldType(size_t nFld) SAL_OVERRIDE; virtual void UpdateFlds( SfxPoolItem* pNewHt, bool bCloseDB) SAL_OVERRIDE; virtual void InsDeletedFldType(SwFieldType &) SAL_OVERRIDE; virtual bool PutValueToField(const SwPosition & rPos, const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich) SAL_OVERRIDE; diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index dd9bc1177e76..14417ca08b4c 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -461,7 +461,7 @@ SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource ) { maMSTOCExpression = rSource.maMSTOCExpression; SwTOXType* pType = const_cast<SwTOXType*>(rSource.GetTOXType()); - if( pDoc && USHRT_MAX == pDoc->GetTOXTypes().GetPos( pType )) + if( pDoc && !pDoc->GetTOXTypes().Contains( pType )) { // type not in pDoc, so create it now const SwTOXTypes& rTypes = pDoc->GetTOXTypes(); diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 1c1a7fceebad..60e5111d6093 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -522,14 +522,12 @@ void SwHistoryChangeFmtColl::SetInDoc( SwDoc* pDoc, bool ) { if ( ND_TEXTNODE == m_nNodeType ) { - if ( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( - static_cast<SwTxtFmtColl * const>(m_pColl) )) + if (pDoc->GetTxtFmtColls()->Contains( static_cast<SwTxtFmtColl * const>(m_pColl) )) { pCntntNd->ChgFmtColl( m_pColl ); } } - else if ( USHRT_MAX != pDoc->GetGrfFmtColls()->GetPos( - static_cast<SwGrfFmtColl * const>(m_pColl) )) + else if (pDoc->GetGrfFmtColls()->Contains( static_cast<SwGrfFmtColl * const>(m_pColl) )) { pCntntNd->ChgFmtColl( m_pColl ); } @@ -873,8 +871,7 @@ void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool ) { ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); - const sal_uInt16 nPos = pDoc->GetSpzFrmFmts()->GetPos( &m_rFmt ); - if ( USHRT_MAX != nPos ) // Format does still exist + if ( pDoc->GetSpzFrmFmts()->Contains( &m_rFmt ) ) // Format does still exist { SwFmtAnchor aTmp( m_rFmt.GetAnchor() ); @@ -912,12 +909,12 @@ SwHistoryChangeFlyChain::SwHistoryChangeFlyChain( SwFlyFrmFmt& rFmt, void SwHistoryChangeFlyChain::SetInDoc( SwDoc* pDoc, bool ) { - if ( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pFlyFmt ) ) + if (pDoc->GetSpzFrmFmts()->Contains( m_pFlyFmt ) ) { SwFmtChain aChain; if ( m_pPrevFmt && - USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pPrevFmt ) ) + pDoc->GetSpzFrmFmts()->Contains( m_pPrevFmt ) ) { aChain.SetPrev( m_pPrevFmt ); SwFmtChain aTmp( m_pPrevFmt->GetChain() ); @@ -926,7 +923,7 @@ void SwHistoryChangeFlyChain::SetInDoc( SwDoc* pDoc, bool ) } if ( m_pNextFmt && - USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pNextFmt ) ) + pDoc->GetSpzFrmFmts()->Contains( m_pNextFmt ) ) { aChain.SetNext( m_pNextFmt ); SwFmtChain aTmp( m_pNextFmt->GetChain() ); diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 458d1a81ca29..eac70f8dd101 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -233,20 +233,20 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) { // search for the Format in the Document; if it does not exist any more, // the attribute is not restored! - sal_uInt16 nPos = USHRT_MAX; + bool bFound = false; switch ( m_nFmtWhich ) { case RES_TXTFMTCOLL: - nPos = pDoc->GetTxtFmtColls()->GetPos( m_pFmt ); + bFound = pDoc->GetTxtFmtColls()->Contains( m_pFmt ); break; case RES_GRFFMTCOLL: - nPos = pDoc->GetGrfFmtColls()->GetPos( + bFound = pDoc->GetGrfFmtColls()->Contains( static_cast<const SwGrfFmtColl*>(m_pFmt) ); break; case RES_CHRFMT: - nPos = pDoc->GetCharFmts()->GetPos( m_pFmt ); + bFound = pDoc->GetCharFmts()->Contains( m_pFmt ); break; case RES_FRMFMT: @@ -257,14 +257,14 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) { m_pFmt = static_cast<SwTableNode*>(pNd)->GetTable().GetFrmFmt(); - nPos = 0; + bFound = true; break; } else if ( pNd->IsSectionNode() ) { m_pFmt = static_cast<SwSectionNode*>(pNd)->GetSection().GetFmt(); - nPos = 0; + bFound = true; break; } else if ( pNd->IsStartNode() && (SwTableBoxStartNode == @@ -278,7 +278,7 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) if ( pBox ) { m_pFmt = pBox->GetFrmFmt(); - nPos = 0; + bFound = true; break; } } @@ -287,15 +287,15 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) // no break! case RES_DRAWFRMFMT: case RES_FLYFRMFMT: - nPos = pDoc->GetSpzFrmFmts()->GetPos( m_pFmt ); - if ( USHRT_MAX == nPos ) + bFound = pDoc->GetSpzFrmFmts()->Contains( m_pFmt ); + if ( !bFound ) { - nPos = pDoc->GetFrmFmts()->GetPos( m_pFmt ); + bFound = pDoc->GetFrmFmts()->Contains( m_pFmt ); } break; } - if ( USHRT_MAX == nPos ) + if ( !bFound ) { // Format does not exist; reset m_pFmt = 0; diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 0ef2e5f6d451..9977593e02a7 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -537,7 +537,7 @@ void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( pOldFmt ) ) + if( rDoc.GetFrmFmts()->Contains( pOldFmt ) ) { if( bAnchorChgd ) pFrmFmt->DelFrms(); @@ -610,7 +610,7 @@ void SwUndoSetFlyFmt::RedoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( pNewFmt ) ) + if( rDoc.GetFrmFmts()->Contains( pNewFmt ) ) { if( bAnchorChgd ) diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx index dd73605fa8fe..458b400860f9 100644 --- a/sw/source/core/undo/unfmco.cxx +++ b/sw/source/core/undo/unfmco.cxx @@ -72,10 +72,9 @@ void SwUndoFmtColl::DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM) { // Only one TextFrmColl can be applied to a section, thus request only in // this array. - sal_uInt16 const nPos = rDoc.GetTxtFmtColls()->GetPos( - static_cast<SwTxtFmtColl*>(pFmtColl) ); + // does the format still exist? - if( USHRT_MAX != nPos ) + if( rDoc.GetTxtFmtColls()->Contains(static_cast<SwTxtFmtColl*>(pFmtColl)) ) { rDoc.SetTxtFmtColl(rPaM, static_cast<SwTxtFmtColl*>(pFmtColl), mbReset, mbResetListAttrs); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 48d39db51162..fe957e5ba0fc 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -889,8 +889,8 @@ _SaveTable::~_SaveTable() sal_uInt16 _SaveTable::AddFmt( SwFrmFmt* pFmt, bool bIsLine ) { - sal_uInt16 nRet = aFrmFmts.GetPos( pFmt ); - if( USHRT_MAX == nRet ) + size_t nRet = aFrmFmts.GetPos( pFmt ); + if( SIZE_MAX == nRet ) { // Create copy of ItemSet std::shared_ptr<SfxItemSet> pSet( new SfxItemSet( *pFmt->GetAttrSet().GetPool(), @@ -917,7 +917,7 @@ sal_uInt16 _SaveTable::AddFmt( SwFrmFmt* pFmt, bool bIsLine ) aSets.push_back( pSet ); aFrmFmts.insert( aFrmFmts.begin() + nRet, pFmt ); } - return nRet; + return static_cast<sal_uInt16>(nRet); } void _SaveTable::RestoreAttr( SwTable& rTbl, bool bMdfyBox ) diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 7490daec5780..126e2eb390ba 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -229,7 +229,7 @@ void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & rContext) pTxtNode->ResetAllAttr(); - if( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( pTxtFmtColl )) + if( pDoc->GetTxtFmtColls()->Contains( pTxtFmtColl )) pTxtFmtColl = static_cast<SwTxtFmtColl*>(pTxtNode->ChgFmtColl( pTxtFmtColl )) ; pHistory->SetTmpEnd( nSetPos ); @@ -268,7 +268,7 @@ void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext) pPam->Exchange(); } - if( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( pTxtFmtColl )) + if( pDoc->GetTxtFmtColls()->Contains( pTxtFmtColl )) { SwTxtNode* pTxtNd = pPam->GetMark()->nNode.GetNode().GetTxtNode(); if( pTxtNd ) @@ -276,7 +276,7 @@ void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext) } pTxtFmtColl = pSavTxtFmtColl; - if( pLastNdColl && USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( pLastNdColl ) && + if( pLastNdColl && pDoc->GetTxtFmtColls()->Contains( pLastNdColl ) && pPam->GetPoint()->nNode != pPam->GetMark()->nNode ) { SwTxtNode* pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode(); diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index fcec80704d1b..a1c9376513e5 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -224,7 +224,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) { SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ n ]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if( USHRT_MAX == aFlyFrmArr.GetPos( pFrmFmt) ) + if( !aFlyFrmArr.Contains( pFrmFmt) ) { SwPosition const*const pFrameAnchor( rAnchor.GetCntntAnchor()); diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 77b8271124f3..682eb68b0c97 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1007,7 +1007,7 @@ sal_uInt32 WW8Export::GetSdrOrdNum( const SwFrmFmt& rFmt ) const { // no Layout for this format, then recalc the ordnum SwFrmFmt* pFmt = const_cast<SwFrmFmt*>(&rFmt); - nOrdNum = m_pDoc->GetSpzFrmFmts()->GetPos( pFmt ); + nOrdNum = static_cast<sal_uInt32>(m_pDoc->GetSpzFrmFmts()->GetPos( pFmt )); const SwDrawModel* pModel = m_pDoc->getIDocumentDrawModelAccess().GetDrawModel(); if( pModel ) diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx index 5a59b0b87510..c9185fde1e74 100644 --- a/sw/source/filter/ww8/wrtw8num.cxx +++ b/sw/source/filter/ww8/wrtw8num.cxx @@ -100,7 +100,7 @@ sal_uInt16 MSWordExportBase::GetId( const SwNumRule& rNumRule ) } } SwNumRule* p = const_cast<SwNumRule*>(&rNumRule); - sal_uInt16 nRet = m_pUsedNumTbl->GetPos(p); + sal_uInt16 nRet = static_cast<sal_uInt16>(m_pUsedNumTbl->GetPos(p)); // Is this list now duplicated into a new list which we should use // #i77812# - perform 'deep' search in duplication map |