[Libreoffice-commits] core.git: 4 commits - sw/inc sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sun May 24 15:31:50 PDT 2015
sw/inc/editsh.hxx | 6 +-
sw/source/core/doc/DocumentFieldsManager.cxx | 69 +++++++++++++------------
sw/source/core/edit/edfld.cxx | 16 +++---
sw/source/core/unocore/unofield.cxx | 2
sw/source/ui/config/optload.cxx | 6 +-
sw/source/ui/fldui/fldref.cxx | 6 +-
sw/source/ui/fldui/fldvar.cxx | 17 +++---
sw/source/ui/frmdlg/cption.cxx | 6 +-
sw/source/ui/index/cnttab.cxx | 4 -
sw/source/uibase/dochdl/swdtflvr.cxx | 72 ++++++++++++---------------
sw/source/uibase/fldui/fldmgr.cxx | 10 +--
sw/source/uibase/inc/fldmgr.hxx | 4 -
sw/source/uibase/uiview/viewdlg2.cxx | 5 +
13 files changed, 111 insertions(+), 112 deletions(-)
New commits:
commit 7dfe9f14d77f216f43ce22efd6addea6f53aad58
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue May 12 23:52:18 2015 +0200
Simplify loop
Change-Id: I9c61e8b1d8552be25c3c78757b280b388cb98694
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 2f64b0a..0c9b091 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -2111,7 +2111,7 @@ bool SwTransferable::_PasteDDE( TransferableDataHelper& rData,
size_t i = 1;
size_t j;
OUString aName;
- bool bAlreadyThere = false, bDoublePaste = false;
+ bool bDoublePaste = false;
const size_t nSize = rWrtShell.GetFieldTypeCount();
const ::utl::TransliterationWrapper& rColl = ::GetAppCmpStrIgnore();
@@ -2136,14 +2136,10 @@ bool SwTransferable::_PasteDDE( TransferableDataHelper& rData,
}
}
if( j == nSize )
- bAlreadyThere = false;
- else
- {
- bAlreadyThere = true;
- i++;
- }
+ break;
+ ++i;
}
- while( bAlreadyThere && !bDoublePaste );
+ while( !bDoublePaste );
if( !bDoublePaste )
{
commit 7deb5886e4559ee5551ab3de43efa3e9be5e21f5
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue May 12 23:37:41 2015 +0200
Fix whitespaces/indentation
Change-Id: I84a9e136b9c463ae794f5ddcbb211707672f170d
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 7c00160..2f64b0a 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -226,7 +226,7 @@ SwTransferable::SwTransferable( SwWrtShell& rSh )
aObjDesc.maDisplayName = URIHelper::removePassword(
rURLObj.GetMainURL( INetURLObject::NO_DECODE ),
INetURLObject::WAS_ENCODED,
- INetURLObject::DECODE_UNAMBIGUOUS );
+ INetURLObject::DECODE_UNAMBIGUOUS );
}
PrepareOLE( aObjDesc );
@@ -486,7 +486,7 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
}
}
- bool bOK = false;
+ bool bOK = false;
if( TRNSFR_OLE == eBufferType )
{
//TODO/MBA: testing - is this the "single OLE object" case?!
@@ -518,8 +518,7 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
{
case SotClipboardFormatId::LINK:
if( refDdeLink.Is() )
- bOK = SetObject( &refDdeLink,
- SWTRANSFER_OBJECTTYPE_DDE, rFlavor );
+ bOK = SetObject( &refDdeLink, SWTRANSFER_OBJECTTYPE_DDE, rFlavor );
break;
case SotClipboardFormatId::OBJECTDESCRIPTOR:
@@ -957,11 +956,11 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
{
AddFormat( SotClipboardFormatId::STRING );
- AddFormat( SotClipboardFormatId::SOLK );
- AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
- AddFormat( SotClipboardFormatId::FILECONTENT );
- AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
- AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
+ AddFormat( SotClipboardFormatId::SOLK );
+ AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
+ AddFormat( SotClipboardFormatId::FILECONTENT );
+ AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
+ AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
nRet = 1;
}
@@ -1041,8 +1040,7 @@ int SwTransferable::CalculateAndCopy()
return 1;
}
-int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary,
- const OUString& rStr )
+int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr )
{
if(!pWrtShell)
return 0;
@@ -1237,7 +1235,8 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
case SotExchangeDest::SWDOC_FREE_AREA_WEB:
bDelSel = true;
break;
- default: break;
+ default:
+ break;
}
if( bDelSel )
@@ -1868,7 +1867,7 @@ bool SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
{
DataFlavor aDataFlavor;
SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
- xObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
+ xObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
}
else if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
{
@@ -1879,7 +1878,7 @@ bool SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
MapMode aMapMode( MAP_100TH_MM );
aGraphic.SetPrefSize( Size( 2500, 2500 ) );
aGraphic.SetPrefMapMode( aMapMode );
- xObjRef.SetGraphic( aGraphic, aMimeType );
+ xObjRef.SetGraphic( aGraphic, aMimeType );
}
//set size. This is a hack because of handing over, size should be
@@ -1887,7 +1886,7 @@ bool SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
Size aSize;
if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
{
- if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
+ if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
aSize = aObjDesc.maSize;
else
{
@@ -3095,11 +3094,11 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
{
AddFormat( SotClipboardFormatId::STRING );
- AddFormat( SotClipboardFormatId::SOLK );
- AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
- AddFormat( SotClipboardFormatId::FILECONTENT );
- AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
- AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
+ AddFormat( SotClipboardFormatId::SOLK );
+ AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
+ AddFormat( SotClipboardFormatId::FILECONTENT );
+ AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
+ AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
}
}
@@ -3123,11 +3122,11 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
if( pWrtShell->GetContentAtPos( aPos, aContentAtPos ) )
{
AddFormat( SotClipboardFormatId::STRING );
- AddFormat( SotClipboardFormatId::SOLK );
- AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
- AddFormat( SotClipboardFormatId::FILECONTENT );
- AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
- AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
+ AddFormat( SotClipboardFormatId::SOLK );
+ AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
+ AddFormat( SotClipboardFormatId::FILECONTENT );
+ AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
+ AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
eBufferType = TRNSFR_INETFLD;
}
}
@@ -3256,7 +3255,7 @@ bool SwTransferable::PrivatePaste( SwWrtShell& rShell )
}
if ( nSelection & nsSelectionType::SEL_DRW) //unselect hovering graphics
{
- rShell.ResetSelect(NULL,false);
+ rShell.ResetSelect(NULL,false);
}
bool bInWrd = false, bEndWrd = false, bSttWrd = false,
@@ -3271,7 +3270,7 @@ bool SwTransferable::PrivatePaste( SwWrtShell& rShell )
bSmart = bInWrd || bEndWrd;
if( bSmart )
{
- bSttWrd = rShell.IsSttWrd();
+ bSttWrd = rShell.IsSttWrd();
if( bSmart && !bSttWrd && (bInWrd || bEndWrd) )
rShell.SwEditShell::Insert(' ');
}
@@ -3557,7 +3556,7 @@ void SwTransferable::CreateSelection( SwWrtShell& rSh,
SwModule *pMod = SW_MOD();
SwTransferable* pNew = new SwTransferable( rSh );
- pNew->pCreatorView = _pCreatorView;
+ pNew->pCreatorView = _pCreatorView;
uno::Reference< XTransferable > xRef( pNew );
pMod->pXSelection = pNew;
commit 1a53de1c087084dc271f6263eb6e6fde183cbd52
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue May 12 23:19:34 2015 +0200
Rework code to avoid an assignemnt just to fail next if()
But keep the test itself, just to play safe
Change-Id: I0b58fa8ea25fbb577a3f9c1f2dbf0ad6d5004e2c
diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index 5cd8a3e..18ab5f2 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -574,14 +574,13 @@ IMPL_LINK( SwFieldVarPage, SubTypeHdl, ListBox *, pBox )
nSelPos = m_pSelectionLB->GetSelectEntryPos();
if (nSelPos != LISTBOX_ENTRY_NOTFOUND)
- nSelData = static_cast<size_t>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nSelPos)));
- else
- nSelData = SIZE_MAX;
-
- if (nSelData != SIZE_MAX && pBox && !bInit)
{
- m_pValueED->ReplaceSelected(m_pSelectionLB->GetSelectEntry());
- ModifyHdl();
+ nSelData = static_cast<size_t>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nSelPos)));
+ if (nSelData != SIZE_MAX && pBox && !bInit)
+ {
+ m_pValueED->ReplaceSelected(m_pSelectionLB->GetSelectEntry());
+ ModifyHdl();
+ }
}
}
break;
commit 1700fa84cd29c0f2d84d2af17cabb8e04b143ffe
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue May 12 23:10:04 2015 +0200
Use size_t consistently for GetFldTypeCount/GetFldType/RemoveFldType
Change-Id: Ie88af20e20f788c0d8b53f99da3decd98dec5078
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index c80d81d..67bc53f 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 dc6122b..08f29a6 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 3bc69b3..73cc853 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 c99b9e2..fbc02fb 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 336395c..fecd2a0 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 cef1991..994ae8f 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 95c737f..5cd8a3e 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 bdf1e56..41ba1dc 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 a0c8036..4dcb18d 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 884e383..7c00160 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 a205c15..9cc7533d 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 39ff178..62b38d4 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 f9e6140..32e5f2b 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;
}
}
More information about the Libreoffice-commits
mailing list