[Libreoffice-commits] core.git: 2 commits - sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sat Jan 24 00:52:04 PST 2015
sw/source/core/doc/DocumentLinksAdministrationManager.cxx | 2
sw/source/core/doc/DocumentOutlineNodesManager.cxx | 10 +-
sw/source/core/doc/DocumentSettingManager.cxx | 2
sw/source/core/doc/doc.cxx | 49 ++++++--------
4 files changed, 31 insertions(+), 32 deletions(-)
New commits:
commit af76cc04722386f2635e0fe2ce196974f356deaf
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jan 24 09:39:44 2015 +0100
Use more proper integer types
Change-Id: I43116c77b05d6c695c6f38c373f9d48e67ab8f20
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 034c122..1a470e0 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -525,7 +525,7 @@ sal_uInt16 _PostItFld::GetPageNo(
//Probably only once. For the page number we don't select a random one,
//but the PostIt's first occurrence in the selected area.
rVirtPgNo = 0;
- sal_uInt16 nPos = GetCntnt();
+ const sal_Int32 nPos = GetCntnt();
SwIterator<SwTxtFrm,SwTxtNode> aIter( GetTxtFld()->GetTxtNode() );
for( SwTxtFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
{
@@ -738,7 +738,8 @@ void SwDoc::UpdatePagesForPrintingWithPostItData(
sal_Int16 nPostItMode = (sal_Int16) rOptions.getIntValue( "PrintAnnotationMode", 0 );
OSL_ENSURE(nPostItMode == POSTITS_NONE || rData.HasPostItData(),
"print post-its without post-it data?" );
- const sal_uInt16 nPostItCount = rData.HasPostItData() ? rData.m_pPostItFields->size() : 0;
+ const _SetGetExpFlds::size_type nPostItCount =
+ rData.HasPostItData() ? rData.m_pPostItFields->size() : 0;
if (nPostItMode != POSTITS_NONE && nPostItCount > 0)
{
SET_CURR_SHELL( rData.m_pPostItShell.get() );
@@ -765,7 +766,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData(
// already get them in the correct order
sal_uInt16 nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
bool bIsFirstPostIt = true;
- for (sal_uInt16 i = 0; i < nPostItCount; ++i)
+ for (_SetGetExpFlds::size_type i = 0; i < nPostItCount; ++i)
{
_PostItFld& rPostIt = static_cast<_PostItFld&>(*(*rData.m_pPostItFields)[ i ]);
nLastPageNum = nPhyPageNum;
@@ -895,8 +896,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
return;
const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
- sal_Int32 i = 0;
- for ( i = 1; pStPage && i < nDocPageCount; ++i )
+ for ( sal_Int32 i = 1; pStPage && i < nDocPageCount; ++i )
pStPage = static_cast<const SwPageFrm*>(pStPage->GetNext());
if ( !pStPage ) // Then it was that
return;
@@ -936,7 +936,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
// now fill the vector for calculating the page pairs with the start frames
// from the above obtained vector
std::vector< const SwPageFrm * > aVec;
- for ( i = 0; i < sal_Int32(aPagesToPrint.size()); ++i)
+ for ( std::vector< sal_Int32 >::size_type i = 0; i < aPagesToPrint.size(); ++i)
{
const sal_Int32 nPage = aPagesToPrint[i];
const SwPageFrm *pFrm = validStartFrms[ nPage ];
@@ -956,9 +956,9 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
}
// make sure that all pages are in correct order
- sal_uInt16 nSPg = 0;
- sal_uInt32 nEPg = aVec.size();
- sal_uInt16 nStep = 1;
+ std::vector< const SwPageFrm * >::size_type nSPg = 0;
+ std::vector< const SwPageFrm * >::size_type nEPg = aVec.size();
+ sal_Int32 nStep = 1;
if ( 0 == (nEPg & 1 )) // there are no uneven ones!
--nEPg;
@@ -973,7 +973,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
// the number of 'virtual' pages to be printed
sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
- for ( sal_uInt16 nPrintCount = 0; nSPg < nEPg &&
+ for ( sal_Int32 nPrintCount = 0; nSPg < nEPg &&
nPrintCount < nCntPage; ++nPrintCount )
{
pStPage = aVec[ nSPg ];
@@ -1196,20 +1196,19 @@ void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bIm
const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
if( pExtDoc && !rOutNds.empty() )
{
- sal_uInt16 i;
::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.size(), GetDocShell() );
SwNodeIndex aEndOfDoc( pExtDoc->GetNodes().GetEndOfContent(), -1 );
- for( i = 0; i < rOutNds.size(); ++i )
+ for( SwOutlineNodes::size_type i = 0; i < rOutNds.size(); ++i )
{
- ::SetProgressState( i, GetDocShell() );
+ ::SetProgressState( static_cast<long>(i), GetDocShell() );
const sal_uLong nIndex = rOutNds[ i ]->GetIndex();
const int nLvl = GetNodes()[ nIndex ]->GetTxtNode()->GetAttrOutlineLevel()-1;
if( nLvl > nLevel )
continue;
- sal_uInt16 nEndOfs = 1;
+ long nEndOfs = 1;
sal_uInt8 nWish = nPara;
- sal_uLong nNextOutNd = i + 1 < (sal_uInt16)rOutNds.size() ?
+ sal_uLong nNextOutNd = i + 1 < rOutNds.size() ?
rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
bool bKeep = false;
while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
@@ -1226,7 +1225,7 @@ void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bIm
GetNodes()._Copy( aRange, aEndOfDoc );
}
const SwTxtFmtColls *pColl = pExtDoc->GetTxtFmtColls();
- for( i = 0; i < pColl->size(); ++i )
+ for( SwTxtFmtColls::size_type i = 0; i < pColl->size(); ++i )
(*pColl)[ i ]->ResetFmtAttr( RES_PAGEDESC, RES_BREAK );
SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() );
++aEndOfDoc;
@@ -1351,9 +1350,8 @@ bool SwDoc::RemoveInvisibleContent()
// Delete/empty all hidden areas
SwSectionFmts aSectFmts;
SwSectionFmts& rSectFmts = GetSections();
- sal_uInt16 n;
- for( n = rSectFmts.size(); n; )
+ for( SwSectionFmts::size_type n = rSectFmts.size(); n; )
{
SwSectionFmt* pSectFmt = rSectFmts[ --n ];
// don't add sections in Undo/Redo
@@ -1380,11 +1378,13 @@ bool SwDoc::RemoveInvisibleContent()
SwSectionData aSectionData( *pSect );
aSectionData.SetCondition( OUString() );
aSectionData.SetHidden( false );
- UpdateSection( n, aSectionData );
+ UpdateSection( static_cast<sal_uInt16>(n), aSectionData );
}
}
- if( 0 != ( n = aSectFmts.size() ))
+ SwSectionFmts::size_type n = aSectFmts.size();
+
+ if( 0 != n )
{
while( n )
{
@@ -1460,9 +1460,8 @@ bool SwDoc::HasInvisibleContent() const
if( ! bRet )
{
const SwSectionFmts& rSectFmts = GetSections();
- sal_uInt16 n;
- for( n = rSectFmts.size(); !bRet && (n > 0); )
+ for( SwSectionFmts::size_type n = rSectFmts.size(); !bRet && (n > 0); )
{
SwSectionFmt* pSectFmt = rSectFmts[ --n ];
// don't add sections in Undo/Redo
@@ -1496,9 +1495,9 @@ bool SwDoc::ConvertFieldsToText()
GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE, NULL );
const SwFldTypes* pMyFldTypes = getIDocumentFieldsAccess().GetFldTypes();
- sal_uInt16 nCount = pMyFldTypes->size();
+ const SwFldTypes::size_type nCount = pMyFldTypes->size();
//go backward, field types are removed
- for(sal_uInt16 nType = nCount; nType > 0; --nType)
+ for(SwFldTypes::size_type nType = nCount; nType > 0; --nType)
{
const SwFieldType *pCurType = (*pMyFldTypes)[nType - 1];
@@ -1702,7 +1701,7 @@ SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, bool bTblCrsr )
void SwDoc::ChkCondColls()
{
- for (sal_uInt16 n = 0; n < mpTxtFmtCollTbl->size(); n++)
+ for (SwTxtFmtColls::size_type n = 0; n < mpTxtFmtCollTbl->size(); ++n)
{
SwTxtFmtColl *pColl = (*mpTxtFmtCollTbl)[n];
if (RES_CONDTXTFMTCOLL == pColl->Which())
commit c626a7813973a3cdb7bd4dbca6fcafa3ca3918e4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Jan 8 15:50:44 2015 +0100
sal_uInt16 to size_type/sal_Int32, and avoid unneeded downcasts
Change-Id: I66ac08c52d472d96979da84f5be462dca3105e0b
diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index 5a54951..febda03 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -63,7 +63,7 @@ namespace
::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks, sfx2::LinkManager& rLnkMgr )
{
- for( sal_uInt16 n = 0; n < rLinks.size(); ++n )
+ for( ::sfx2::SvBaseLinks::size_type n = 0; n < rLinks.size(); ++n )
{
::sfx2::SvBaseLink* pLnk = &(*rLinks[ n ]);
if( pLnk &&
diff --git a/sw/source/core/doc/DocumentOutlineNodesManager.cxx b/sw/source/core/doc/DocumentOutlineNodesManager.cxx
index f6f5a61..5e00616 100644
--- a/sw/source/core/doc/DocumentOutlineNodesManager.cxx
+++ b/sw/source/core/doc/DocumentOutlineNodesManager.cxx
@@ -34,7 +34,7 @@ sal_Int32 DocumentOutlineNodesManager::getOutlineNodesCount() const
int DocumentOutlineNodesManager::getOutlineLevel( const sal_Int32 nIdx ) const
{
- return m_rDoc.GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->
+ return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->
GetTxtNode()->GetAttrOutlineLevel()-1;
}
@@ -43,14 +43,14 @@ OUString DocumentOutlineNodesManager::getOutlineText( const sal_Int32 nIdx,
const bool bWithSpacesForLevel,
const bool bWithFtn ) const
{
- return m_rDoc.GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->
+ return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->
GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
bWithNumber, bWithSpacesForLevel, bWithFtn );
}
SwTxtNode* DocumentOutlineNodesManager::getOutlineNode( const sal_Int32 nIdx ) const
{
- return m_rDoc.GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->GetTxtNode();
+ return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTxtNode();
}
void DocumentOutlineNodesManager::getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const
@@ -58,8 +58,8 @@ void DocumentOutlineNodesManager::getOutlineNodes( IDocumentOutlineNodes::tSorte
orOutlineNodeList.clear();
orOutlineNodeList.reserve( getOutlineNodesCount() );
- const sal_uInt16 nOutlCount( static_cast<sal_uInt16>(getOutlineNodesCount()) );
- for ( sal_uInt16 i = 0; i < nOutlCount; ++i )
+ const sal_Int32 nOutlCount = getOutlineNodesCount();
+ for ( sal_Int32 i = 0; i < nOutlCount; ++i )
{
orOutlineNodeList.push_back(
m_rDoc.GetNodes().GetOutLineNds()[i]->GetTxtNode() );
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 95dca59..65be501 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -209,7 +209,7 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
mbOldNumbering = value;
const SwNumRuleTbl& rNmTbl = m_rDoc.GetNumRuleTbl();
- for( sal_uInt16 n = 0; n < rNmTbl.size(); ++n )
+ for( SwNumRuleTbl::size_type n = 0; n < rNmTbl.size(); ++n )
rNmTbl[n]->SetInvalidRule(true);
m_rDoc.UpdateNumRule();
More information about the Libreoffice-commits
mailing list