diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-05-12 23:10:04 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-05-25 00:30:53 +0200 |
commit | 1700fa84cd29c0f2d84d2af17cabb8e04b143ffe (patch) | |
tree | 10f4b08d3f18c9b699d2838964005e55e8258908 | |
parent | 4dca69d89c95f30cd58a668fd2dc54a8149ab6c8 (diff) |
Use size_t consistently for GetFldTypeCount/GetFldType/RemoveFldType
Change-Id: Ie88af20e20f788c0d8b53f99da3decd98dec5078
-rw-r--r-- | sw/inc/editsh.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentFieldsManager.cxx | 69 | ||||
-rw-r--r-- | sw/source/core/edit/edfld.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/config/optload.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldref.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldvar.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/cption.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/fldui/fldmgr.cxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/inc/fldmgr.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdlg2.cxx | 5 |
13 files changed, 77 insertions, 72 deletions
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index c80d81d32642..67bc53ffd119 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -361,11 +361,11 @@ public: void UpdateFields( SwField & ); ///< One single field. - sal_uInt16 GetFieldTypeCount(sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const; - SwFieldType* GetFieldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const; + size_t GetFieldTypeCount(sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const; + SwFieldType* GetFieldType(size_t nField, sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const; SwFieldType* GetFieldType(sal_uInt16 nResId, const OUString& rName) const; - void RemoveFieldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX); + void RemoveFieldType(size_t nField, sal_uInt16 nResId = USHRT_MAX); void RemoveFieldType(sal_uInt16 nResId, const OUString& rName); void FieldToText( SwFieldType* pType ); diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index dc6122b0a181..08f29a616c20 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -162,10 +162,10 @@ const SwFieldTypes* DocumentFieldsManager::GetFieldTypes() const */ SwFieldType* DocumentFieldsManager::InsertFieldType(const SwFieldType &rFieldTyp) { - sal_uInt16 nSize = mpFieldTypes->size(), - nFieldWhich = rFieldTyp.Which(); + const SwFieldTypes::size_type nSize = mpFieldTypes->size(); + const sal_uInt16 nFieldWhich = rFieldTyp.Which(); - sal_uInt16 i = INIT_FLDTYPES; + SwFieldTypes::size_type i = INIT_FLDTYPES; switch( nFieldWhich ) { @@ -236,7 +236,7 @@ SwFieldType* DocumentFieldsManager::InsertFieldType(const SwFieldType &rFieldTyp /// @returns the field type of the Doc SwFieldType *DocumentFieldsManager::GetSysFieldType( const sal_uInt16 eWhich ) const { - for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i ) + for( SwFieldTypes::size_type i = 0; i < INIT_FLDTYPES; ++i ) if( eWhich == (*mpFieldTypes)[i]->Which() ) return (*mpFieldTypes)[i]; return 0; @@ -249,7 +249,8 @@ SwFieldType* DocumentFieldsManager::GetFieldType( bool bDbFieldMatching // used in some UNO calls for RES_DBFLD to use different string matching code #i51815# ) const { - sal_uInt16 nSize = mpFieldTypes->size(), i = 0; + const SwFieldTypes::size_type nSize = mpFieldTypes->size(); + SwFieldTypes::size_type i {0}; const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); switch( nResId ) @@ -296,8 +297,7 @@ void DocumentFieldsManager::RemoveFieldType(size_t nField) /* * Dependent fields present -> ErrRaise */ - size_t nSize = mpFieldTypes->size(); - if(nField < nSize) + if(nField < mpFieldTypes->size()) { SwFieldType* pTmp = (*mpFieldTypes)[nField]; @@ -340,9 +340,9 @@ void DocumentFieldsManager::UpdateFields( SfxPoolItem *pNewHt, bool bCloseDB ) // Call Modify() for every field type, // dependent SwTextField get notified ... - for( sal_uInt16 i=0; i < mpFieldTypes->size(); ++i) + for( auto pFieldType : *mpFieldTypes ) { - switch( (*mpFieldTypes)[i]->Which() ) + switch( pFieldType->Which() ) { // Update table fields second to last // Update references last @@ -358,10 +358,10 @@ void DocumentFieldsManager::UpdateFields( SfxPoolItem *pNewHt, bool bCloseDB ) if( !pNewHt ) { SwMsgPoolItem aUpdateDDE( RES_UPDATEDDETBL ); - (*mpFieldTypes)[i]->ModifyNotification( 0, &aUpdateDDE ); + pFieldType->ModifyNotification( 0, &aUpdateDDE ); } else - (*mpFieldTypes)[i]->ModifyNotification( 0, pNewHt ); + pFieldType->ModifyNotification( 0, pNewHt ); break; } case RES_GETEXPFLD: @@ -372,7 +372,7 @@ void DocumentFieldsManager::UpdateFields( SfxPoolItem *pNewHt, bool bCloseDB ) if( !pNewHt ) break; default: - (*mpFieldTypes)[i]->ModifyNotification ( 0, pNewHt ); + pFieldType->ModifyNotification ( 0, pNewHt ); } } @@ -401,8 +401,8 @@ void DocumentFieldsManager::InsDeletedFieldType( SwFieldType& rFieldTyp ) // - If it's not present, it can be re-inserted. // - If the same type is found, the deleted one has to be renamed. - sal_uInt16 nSize = mpFieldTypes->size(), nFieldWhich = rFieldTyp.Which(); - sal_uInt16 i = INIT_FLDTYPES; + const SwFieldTypes::size_type nSize = mpFieldTypes->size(); + const sal_uInt16 nFieldWhich = rFieldTyp.Which(); OSL_ENSURE( RES_SETEXPFLD == nFieldWhich || RES_USERFLD == nFieldWhich || @@ -412,12 +412,12 @@ void DocumentFieldsManager::InsDeletedFieldType( SwFieldType& rFieldTyp ) const OUString& rFieldNm = rFieldTyp.GetName(); SwFieldType* pFnd; - for( ; i < nSize; ++i ) + for( SwFieldTypes::size_type i = INIT_FLDTYPES; i < nSize; ++i ) if( nFieldWhich == (pFnd = (*mpFieldTypes)[i])->Which() && rSCmp.isEqual( rFieldNm, pFnd->GetName() ) ) { // find new name - sal_uInt16 nNum = 1; + SwFieldTypes::size_type nNum = 1; do { OUString sSrch = rFieldNm + OUString::number( nNum ); for( i = INIT_FLDTYPES; i < nSize; ++i ) @@ -569,9 +569,8 @@ bool DocumentFieldsManager::UpdateField(SwTextField * pDstTextField, SwField & r /// Update reference and table fields void DocumentFieldsManager::UpdateRefFields( SfxPoolItem* pHt ) { - SwFieldType* pFieldType; - for( sal_uInt16 i = 0; i < mpFieldTypes->size(); ++i ) - if( RES_GETREFFLD == ( pFieldType = (*mpFieldTypes)[i] )->Which() ) + for( auto pFieldType : *mpFieldTypes ) + if( RES_GETREFFLD == pFieldType->Which() ) pFieldType->ModifyNotification( 0, pHt ); } @@ -582,15 +581,15 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) SwFieldType* pFieldType(0); - for (sal_uInt16 i = 0; i < mpFieldTypes->size(); ++i) + for (auto pFieldTypeTmp : *mpFieldTypes) { - if( RES_TABLEFLD == ( pFieldType = (*mpFieldTypes)[i] )->Which() ) + if( RES_TABLEFLD == pFieldTypeTmp->Which() ) { SwTableFormulaUpdate* pUpdateField = 0; if( pHt && RES_TABLEFML_UPDATE == pHt->Which() ) pUpdateField = static_cast<SwTableFormulaUpdate*>(pHt); - SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType ); + SwIterator<SwFormatField,SwFieldType> aIter( *pFieldTypeTmp ); for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() ) { if( pFormatField->GetTextField() ) @@ -644,10 +643,9 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) pField->ChgValid( false ); } } - + pFieldType = pFieldTypeTmp; break; } - pFieldType = 0; } // process all table box formulas @@ -850,18 +848,20 @@ void DocumentFieldsManager::UpdateExpFields( SwTextField* pUpdateField, bool bUp return ; } - sal_uInt16 nWhich, n; + sal_uInt16 nWhich; // Hash table for all string replacements is filled on-the-fly. // Try to fabricate an uneven number. - sal_uInt16 nStrFormatCnt = (( mpFieldTypes->size() / 7 ) + 1 ) * 7; + const SwFieldTypes::size_type nHashSize {(( mpFieldTypes->size() / 7 ) + 1 ) * 7}; + const sal_uInt16 nStrFormatCnt = static_cast<sal_uInt16>(nHashSize); + OSL_ENSURE( nStrFormatCnt == nHashSize, "Downcasting to sal_uInt16 lost information!" ); SwHash** pHashStrTable = new SwHash*[ nStrFormatCnt ]; memset( pHashStrTable, 0, sizeof( _HashStr* ) * nStrFormatCnt ); { const SwFieldType* pFieldType; // process separately: - for( n = mpFieldTypes->size(); n; ) + for( auto n = mpFieldTypes->size(); n; ) switch( ( pFieldType = (*mpFieldTypes)[ --n ] )->Which() ) { case RES_USERFLD: @@ -1172,7 +1172,7 @@ void DocumentFieldsManager::UpdateUsrFields() { SwCalc* pCalc = 0; const SwFieldType* pFieldType; - for( sal_uInt16 i = INIT_FLDTYPES; i < mpFieldTypes->size(); ++i ) + for( SwFieldTypes::size_type i = INIT_FLDTYPES; i < mpFieldTypes->size(); ++i ) if( RES_USERFLD == ( pFieldType = (*mpFieldTypes)[i] )->Which() ) { if( !pCalc ) @@ -1189,9 +1189,10 @@ void DocumentFieldsManager::UpdateUsrFields() void DocumentFieldsManager::UpdatePageFields( SfxPoolItem* pMsgHint ) { - SwFieldType* pFieldType; - for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i ) - switch( ( pFieldType = (*mpFieldTypes)[ i ] )->Which() ) + for( SwFieldTypes::size_type i = 0; i < INIT_FLDTYPES; ++i ) + { + SwFieldType* pFieldType = (*mpFieldTypes)[ i ]; + switch( pFieldType->Which() ) { case RES_PAGENUMBERFLD: case RES_CHAPTERFLD: @@ -1203,6 +1204,7 @@ void DocumentFieldsManager::UpdatePageFields( SfxPoolItem* pMsgHint ) pFieldType->ModifyNotification( 0, 0 ); break; } + } SetNewFieldLst(true); } @@ -1550,9 +1552,8 @@ SwTextField * DocumentFieldsManager::GetTextFieldAtPos(const SwPosition & rPos) /// optimization currently only available when no fields exist. bool DocumentFieldsManager::containsUpdatableFields() { - for (sal_uInt16 i = 0; i < mpFieldTypes->size(); ++i) + for (auto pFieldType : *mpFieldTypes) { - SwFieldType* pFieldType = (*mpFieldTypes)[i]; SwIterator<SwFormatField,SwFieldType> aIter(*pFieldType); if (aIter.First()) return true; @@ -1563,7 +1564,7 @@ bool DocumentFieldsManager::containsUpdatableFields() /// Remove all unreferenced field types of a document void DocumentFieldsManager::GCFieldTypes() { - for( sal_uInt16 n = mpFieldTypes->size(); n > INIT_FLDTYPES; ) + for( auto n = mpFieldTypes->size(); n > INIT_FLDTYPES; ) if( !(*mpFieldTypes)[ --n ]->HasWriterListeners() ) RemoveFieldType( n ); } diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index 3bc69b30c123..73cc853b1d60 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -42,7 +42,7 @@ #include <IDocumentContentOperations.hxx> /// count field types with a ResId, if 0 count all -sal_uInt16 SwEditShell::GetFieldTypeCount(sal_uInt16 nResId, bool bUsed ) const +size_t SwEditShell::GetFieldTypeCount(sal_uInt16 nResId, bool bUsed ) const { const SwFieldTypes* pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes(); @@ -51,7 +51,7 @@ sal_uInt16 SwEditShell::GetFieldTypeCount(sal_uInt16 nResId, bool bUsed ) const if(!bUsed) return static_cast<sal_uInt16>(pFieldTypes->size()); - sal_uInt16 nUsed = 0; + size_t nUsed = 0; for ( const auto pFieldType : *pFieldTypes ) { if(IsUsed(*pFieldType)) @@ -61,7 +61,7 @@ sal_uInt16 SwEditShell::GetFieldTypeCount(sal_uInt16 nResId, bool bUsed ) const } // all types with the same ResId - sal_uInt16 nIdx = 0; + size_t nIdx = 0; for(const auto pFieldType : *pFieldTypes) { // same ResId -> increment index @@ -72,7 +72,7 @@ sal_uInt16 SwEditShell::GetFieldTypeCount(sal_uInt16 nResId, bool bUsed ) const } /// get field types with a ResId, if 0 get all -SwFieldType* SwEditShell::GetFieldType(sal_uInt16 nField, sal_uInt16 nResId, bool bUsed ) const +SwFieldType* SwEditShell::GetFieldType(size_t nField, sal_uInt16 nResId, bool bUsed ) const { const SwFieldTypes* pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes(); @@ -81,7 +81,7 @@ SwFieldType* SwEditShell::GetFieldType(sal_uInt16 nField, sal_uInt16 nResId, boo if(!bUsed) return (*pFieldTypes)[nField]; - SwFieldTypes::size_type nUsed = 0; + size_t nUsed = 0; for ( const auto pFieldType : *pFieldTypes ) { if(IsUsed(*pFieldType)) @@ -94,7 +94,7 @@ SwFieldType* SwEditShell::GetFieldType(sal_uInt16 nField, sal_uInt16 nResId, boo return nullptr; } - sal_uInt16 nIdx = 0; + size_t nIdx = 0; for(const auto pFieldType : *pFieldTypes) { // same ResId -> increment index @@ -118,7 +118,7 @@ SwFieldType* SwEditShell::GetFieldType(sal_uInt16 nResId, const OUString& rName) } /// delete field type -void SwEditShell::RemoveFieldType(sal_uInt16 nField, sal_uInt16 nResId) +void SwEditShell::RemoveFieldType(size_t nField, sal_uInt16 nResId) { if( USHRT_MAX == nResId ) { @@ -127,7 +127,7 @@ void SwEditShell::RemoveFieldType(sal_uInt16 nField, sal_uInt16 nResId) } const SwFieldTypes* pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes(); - sal_uInt16 nIdx = 0; + size_t nIdx = 0; const SwFieldTypes::size_type nSize = pFieldTypes->size(); for( SwFieldTypes::size_type i = 0; i < nSize; ++i ) // Gleiche ResId -> Index erhoehen diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index c99b9e222e82..fbc02fb2390b 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -986,7 +986,7 @@ throw (uno::RuntimeException, std::exception) SwFieldType *const pFieldType = GetFieldType(true); if (!pFieldType) throw uno::RuntimeException(); - sal_uInt16 nTypeIdx = USHRT_MAX; + size_t nTypeIdx = SIZE_MAX; const SwFieldTypes* pTypes = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFieldTypes(); for( size_t i = 0; i < pTypes->size(); i++ ) { diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx index 336395c7631f..fecd2a010823 100644 --- a/sw/source/ui/config/optload.cxx +++ b/sw/source/ui/config/optload.cxx @@ -486,7 +486,7 @@ SwCaptionOptPage::SwCaptionOptPage(vcl::Window* pParent, const SfxItemSet& rSet) sal_uInt16 nSelFormat = SVX_NUM_ARABIC; if (pSh) { - for ( sal_uInt16 i = pMgr->GetFieldTypeCount(); i; ) + for ( auto i = pMgr->GetFieldTypeCount(); i; ) { SwFieldType* pFieldType = pMgr->GetFieldType(USHRT_MAX, --i); if (pFieldType->GetName().equals(m_pCategoryBox->GetText())) @@ -706,9 +706,9 @@ IMPL_LINK_NOARG(SwCaptionOptPage, ShowEntryHdl) m_pCategoryBox->InsertEntry(m_sNone); if (pSh) { - const sal_uInt16 nCount = pMgr->GetFieldTypeCount(); + const size_t nCount = pMgr->GetFieldTypeCount(); - for (sal_uInt16 i = 0; i < nCount; i++) + for (size_t i = 0; i < nCount; ++i) { SwFieldType *pType = pMgr->GetFieldType( USHRT_MAX, i ); if( pType->Which() == RES_SETEXPFLD && diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index cef199107340..994ae8f7a72f 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -201,9 +201,11 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) if(!pSh) pSh = ::GetActiveWrtShell(); - const sal_uInt16 nFieldTypeCnt = pSh->GetFieldTypeCount(RES_SETEXPFLD); + const size_t nFieldTypeCnt = pSh->GetFieldTypeCount(RES_SETEXPFLD); - for (sal_uInt16 n = 0; n < nFieldTypeCnt; ++n) + OSL_ENSURE( nFieldTypeCnt < static_cast<size_t>(REFFLDFLAG), "<SwFieldRefPage::Reset> - Item index will overlap flags!" ); + + for (size_t n = 0; n < nFieldTypeCnt; ++n) { SwSetExpFieldType* pType = static_cast<SwSetExpFieldType*>(pSh->GetFieldType(n, RES_SETEXPFLD)); diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index 95c737f0ea7a..5cd8a3eaeafc 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -243,10 +243,10 @@ IMPL_LINK( SwFieldVarPage, SubTypeHdl, ListBox *, pBox ) { sal_uInt16 nTypeId = (sal_uInt16)reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())); sal_Int32 nSelPos = m_pSelectionLB->GetSelectEntryPos(); - sal_uInt16 nSelData = USHRT_MAX; + size_t nSelData = SIZE_MAX; if (nSelPos != LISTBOX_ENTRY_NOTFOUND) - nSelData = (sal_uInt16)reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nSelPos)); + nSelData = static_cast<size_t>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nSelPos))); if (IsFieldEdit() && (!pBox || bInit)) { @@ -574,11 +574,11 @@ IMPL_LINK( SwFieldVarPage, SubTypeHdl, ListBox *, pBox ) nSelPos = m_pSelectionLB->GetSelectEntryPos(); if (nSelPos != LISTBOX_ENTRY_NOTFOUND) - nSelData = (sal_uInt16)reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nSelPos)); + nSelData = static_cast<size_t>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nSelPos))); else - nSelData = USHRT_MAX; + nSelData = SIZE_MAX; - if (nSelData != USHRT_MAX && pBox && !bInit) + if (nSelData != SIZE_MAX && pBox && !bInit) { m_pValueED->ReplaceSelected(m_pSelectionLB->GetSelectEntry()); ModifyHdl(); diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx index bdf1e56ed867..41ba1dcaf749 100644 --- a/sw/source/ui/frmdlg/cption.cxx +++ b/sw/source/ui/frmdlg/cption.cxx @@ -143,8 +143,8 @@ SwCaptionDialog::SwCaptionDialog( vcl::Window *pParent, SwView &rV ) : m_pAutoCaptionButton->SetClickHdl(LINK(this, SwCaptionDialog, CaptionHdl)); m_pCategoryBox->InsertEntry( m_sNone ); - sal_uInt16 nCount = pMgr->GetFieldTypeCount(); - for (sal_uInt16 i = 0; i < nCount; i++) + size_t nCount = pMgr->GetFieldTypeCount(); + for (size_t i = 0; i < nCount; ++i) { SwFieldType *pType = pMgr->GetFieldType( USHRT_MAX, i ); if( pType->Which() == RES_SETEXPFLD && @@ -206,7 +206,7 @@ SwCaptionDialog::SwCaptionDialog( vcl::Window *pParent, SwView &rV ) : // aFormatBox sal_uInt16 nSelFormat = SVX_NUM_ARABIC; nCount = pMgr->GetFieldTypeCount(); - for ( sal_uInt16 i = nCount; i; ) + for ( size_t i = nCount; i; ) { SwFieldType* pFieldType = pMgr->GetFieldType(USHRT_MAX, --i); if( pFieldType->GetName().equals(m_pCategoryBox->GetText()) ) diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index a0c803642668..4dcb18ded161 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -1274,8 +1274,8 @@ void SwTOXSelectTabPage::Reset( const SfxItemSet* ) m_pFromFileCB->Check( !sAutoMarkURL.isEmpty() ); m_pCaptionSequenceLB->Clear(); - const sal_uInt16 nCount = rSh.GetFieldTypeCount(RES_SETEXPFLD); - for (sal_uInt16 i = 0; i < nCount; i++) + const size_t nCount = rSh.GetFieldTypeCount(RES_SETEXPFLD); + for (size_t i = 0; i < nCount; ++i) { SwFieldType *pType = rSh.GetFieldType( i, RES_SETEXPFLD ); if( pType->Which() == RES_SETEXPFLD && diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 884e383f8460..7c00160b99b3 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2109,10 +2109,11 @@ bool SwTransferable::_PasteDDE( TransferableDataHelper& rData, } SwFieldType* pTyp = 0; - sal_uInt16 i = 1,j; + size_t i = 1; + size_t j; OUString aName; bool bAlreadyThere = false, bDoublePaste = false; - sal_uInt16 nSize = rWrtShell.GetFieldTypeCount(); + const size_t nSize = rWrtShell.GetFieldTypeCount(); const ::utl::TransliterationWrapper& rColl = ::GetAppCmpStrIgnore(); do { diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index a205c1515e9a..9cc7533df4e5 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -258,18 +258,18 @@ void SwFieldMgr::RemoveFieldType(sal_uInt16 nResId, const OUString& rName ) pSh->RemoveFieldType(nResId, rName); } -sal_uInt16 SwFieldMgr::GetFieldTypeCount(sal_uInt16 nResId) const +size_t SwFieldMgr::GetFieldTypeCount(sal_uInt16 nResId) const { SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell(); OSL_ENSURE(pSh, "no SwWrtShell found"); return pSh ? pSh->GetFieldTypeCount(nResId) : 0; } -SwFieldType* SwFieldMgr::GetFieldType(sal_uInt16 nResId, sal_uInt16 nId) const +SwFieldType* SwFieldMgr::GetFieldType(sal_uInt16 nResId, size_t nField) const { SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell(); OSL_ENSURE(pSh, "no SwWrtShell found"); - return pSh ? pSh->GetFieldType(nId, nResId) : 0; + return pSh ? pSh->GetFieldType(nField, nResId) : 0; } SwFieldType* SwFieldMgr::GetFieldType(sal_uInt16 nResId, const OUString& rName) const @@ -456,8 +456,8 @@ bool SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) case TYP_USERFLD: { - const sal_uInt16 nCount = pSh->GetFieldTypeCount(); - for(sal_uInt16 i = 0; i < nCount; ++i) + const size_t nCount = pSh->GetFieldTypeCount(); + for(size_t i = 0; i < nCount; ++i) { SwFieldType* pFieldType = pSh->GetFieldType( i ); const sal_uInt16 nWhich = pFieldType->Which(); diff --git a/sw/source/uibase/inc/fldmgr.hxx b/sw/source/uibase/inc/fldmgr.hxx index 39ff1783c7e8..62b38d48f270 100644 --- a/sw/source/uibase/inc/fldmgr.hxx +++ b/sw/source/uibase/inc/fldmgr.hxx @@ -164,8 +164,8 @@ public: bool CanInsertRefMark( const OUString& rStr ); // access to field types via ResId - sal_uInt16 GetFieldTypeCount(sal_uInt16 nResId = USHRT_MAX) const; - SwFieldType* GetFieldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const; + size_t GetFieldTypeCount(sal_uInt16 nResId = USHRT_MAX) const; + SwFieldType* GetFieldType(sal_uInt16 nResId, size_t nField = 0) const; SwFieldType* GetFieldType(sal_uInt16 nResId, const OUString& rName) const; void RemoveFieldType(sal_uInt16 nResId, const OUString& rName); diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx index f9e614001086..32e5f2be043b 100644 --- a/sw/source/uibase/uiview/viewdlg2.cxx +++ b/sw/source/uibase/uiview/viewdlg2.cxx @@ -146,16 +146,17 @@ void SwView::InsertCaption(const InsCaptionOpt *pOpt) sal_uInt16 nID = USHRT_MAX; SwFieldType* pType = 0; - const sal_uInt16 nCount = aMgr.GetFieldTypeCount(); + const size_t nCount = aMgr.GetFieldTypeCount(); if( !rName.isEmpty() ) { - for (sal_uInt16 i = 0; i < nCount; ++i) + for (size_t i = 0; i < nCount; ++i) { pType = aMgr.GetFieldType(USHRT_MAX, i); OUString aTmpName( pType->GetName() ); if (aTmpName == rName && pType->Which() == RES_SETEXPFLD) { nID = i; + OSL_ENSURE(nID==i, "Downcasting to sal_uInt16 lost information!"); break; } } |