[Libreoffice-commits] core.git: 25 commits - sw/inc sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sun Apr 12 13:40:12 PDT 2015
sw/inc/editsh.hxx | 6 -
sw/source/core/docnode/ndsect.cxx | 29 ++++---
sw/source/core/docnode/ndtbl.cxx | 80 ++++++++++---------
sw/source/core/docnode/ndtbl1.cxx | 97 ++++++++++++------------
sw/source/core/docnode/node2lay.cxx | 8 -
sw/source/core/docnode/nodes.cxx | 10 +-
sw/source/core/docnode/section.cxx | 8 -
sw/source/core/docnode/swbaslnk.cxx | 2
sw/source/core/draw/dcontact.cxx | 3
sw/source/core/draw/dflyobj.cxx | 6 -
sw/source/core/edit/autofmt.cxx | 29 +++----
sw/source/core/edit/edattr.cxx | 25 +++---
sw/source/core/edit/edfld.cxx | 74 +++++++-----------
sw/source/core/edit/edfldexp.cxx | 11 --
sw/source/core/edit/edglbldc.cxx | 10 --
sw/source/core/edit/edglss.cxx | 26 ++----
sw/source/core/edit/editsh.cxx | 13 +--
sw/source/core/text/EnhancedPDFExportHelper.cxx | 6 -
sw/source/ui/chrdlg/drpcps.cxx | 10 +-
sw/source/uibase/utlui/content.cxx | 62 ++++++---------
20 files changed, 248 insertions(+), 267 deletions(-)
New commits:
commit a4c222af6283da2e9252cffa468091f0f85cfcc6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 12 22:16:25 2015 +0200
sal_uInt16 to sal_Int32
Change-Id: I163c88ff2d6e8ac2ac14b7ff585bf09f6262270e
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index b2e8ee2..c1ea880 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -790,7 +790,7 @@ public:
bool bKeepSelection = false );
void GetINetAttrs( SwGetINetAttrs& rArr );
- OUString GetDropTxt( const sal_uInt16 nChars ) const;
+ OUString GetDropTxt( const sal_Int32 nChars ) const;
void ReplaceDropTxt( const OUString &rStr, SwPaM* pPaM = NULL );
/** May an outline be moved or copied?
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 65c480a..148ea26 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -438,7 +438,7 @@ sal_uInt16 SwEditShell::GetRefMarks( std::vector<OUString>* pStrings ) const
return GetDoc()->GetRefMarks( pStrings );
}
-OUString SwEditShell::GetDropTxt( const sal_uInt16 nChars ) const
+OUString SwEditShell::GetDropTxt( const sal_Int32 nChars ) const
{
/*
* pb: made changes for #i74939#
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index e10da98..0343fed 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -181,10 +181,10 @@ void SwDropCapsPict::InitPrinter( void )
}
// Create Default-String from character-count (A, AB, ABC, ...)
-OUString GetDefaultString(sal_uInt16 nChars)
+OUString GetDefaultString(sal_Int32 nChars)
{
OUString aStr;
- for (sal_uInt16 i = 0; i < nChars; i++)
+ for (sal_Int32 i = 0; i < nChars; i++)
aStr += OUString((char) (i + 65));
return aStr;
}
@@ -620,7 +620,7 @@ void SwDropCapsPage::Reset(const SfxItemSet *rSet)
// Enable controls
m_pDropCapsBox->Check(aFmtDrop.GetLines() > 1);
- const sal_uInt16 nVal = sal_uInt16(m_pDropCapsField->GetValue());
+ const sal_Int32 nVal = static_cast<sal_Int32>(m_pDropCapsField->GetValue());
if (bFormat)
m_pTextEdit->SetText(GetDefaultString(nVal));
else
@@ -688,8 +688,8 @@ IMPL_LINK( SwDropCapsPage, ModifyHdl, Edit *, pEdit )
// set text if applicable
if (pEdit == m_pDropCapsField)
{
- const sal_uInt16 nVal = !m_pWholeWordCB->IsChecked()
- ? (sal_uInt16)m_pDropCapsField->GetValue()
+ const sal_Int32 nVal = !m_pWholeWordCB->IsChecked()
+ ? static_cast<sal_Int32>(m_pDropCapsField->GetValue())
: 0;
bool bSetText = false;
commit bafc6196c5364c2692e9a4f538a580e3dedec073
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Apr 7 23:05:25 2015 +0200
Use size() on array filled by SwEditShell::GetINetAttrs to get number of items
Change-Id: I10d05c6b635c220f2ec833e4207afbd46651aec8
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 58f04ba..b2e8ee2 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -788,7 +788,7 @@ public:
bool InsertURL( const SwFmtINetFmt& rFmt, const OUString& rStr,
bool bKeepSelection = false );
- sal_uInt16 GetINetAttrs( SwGetINetAttrs& rArr );
+ void GetINetAttrs( SwGetINetAttrs& rArr );
OUString GetDropTxt( const sal_uInt16 nChars ) const;
void ReplaceDropTxt( const OUString &rStr, SwPaM* pPaM = NULL );
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 1f32889..65c480a 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -660,7 +660,7 @@ bool SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const OUString& rStr, boo
return true;
}
-sal_uInt16 SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr )
+void SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr )
{
rArr.clear();
@@ -689,7 +689,6 @@ sal_uInt16 SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr )
}
}
}
- return rArr.size();
}
/// If the cursor is in a INetAttribute then it will be deleted completely (incl. hint text, the
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 7a08004..e63aa81 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1623,10 +1623,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
// HYPERLINKS
SwGetINetAttrs aArr;
- const sal_uInt16 nHyperLinkCount = mrSh.GetINetAttrs( aArr );
- for( sal_uInt16 n = 0; n < nHyperLinkCount; ++n )
+ mrSh.GetINetAttrs( aArr );
+ for( auto &rAttr : aArr )
{
- SwGetINetAttr* p = &aArr[ n ];
+ SwGetINetAttr* p = &rAttr;
OSL_ENSURE( 0 != p, "Enhanced pdf export - SwGetINetAttr is missing" );
const SwTxtNode* pTNd = p->rINetAttr.GetpTxtNode();
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 5554062..bec9651 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -153,8 +153,9 @@ namespace
const SwContentType *pCntType)
{
SwGetINetAttrs aArr;
- const sal_uInt16 nCount = pWrtShell->GetINetAttrs( aArr );
- for( sal_uInt16 n = 0; n < nCount; ++n )
+ pWrtShell->GetINetAttrs( aArr );
+ const SwGetINetAttrs::size_type nCount {aArr.size()};
+ for( SwGetINetAttrs::size_type n = 0; n < nCount; ++n )
{
SwGetINetAttr* p = &aArr[ n ];
SwURLFieldContent* pCnt = new SwURLFieldContent(
commit 6fcb52aa3d8b8f3686ba1dfae03f9d3cc281b5d3
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Apr 7 22:48:45 2015 +0200
Group common code
Change-Id: I9ad05054d40b283042b9775333f8e103668ae7a6
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 35e099d..5554062 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -146,6 +146,30 @@ namespace
{
return IDocumentMarkAccess::GetType(*rpMark) == IDocumentMarkAccess::MarkType::BOOKMARK;
}
+
+ sal_uInt16 lcl_InsertURLFieldContent(
+ SwContentArr *pMember,
+ SwWrtShell* pWrtShell,
+ const SwContentType *pCntType)
+ {
+ SwGetINetAttrs aArr;
+ const sal_uInt16 nCount = pWrtShell->GetINetAttrs( aArr );
+ for( sal_uInt16 n = 0; n < nCount; ++n )
+ {
+ SwGetINetAttr* p = &aArr[ n ];
+ SwURLFieldContent* pCnt = new SwURLFieldContent(
+ pCntType,
+ p->sText,
+ INetURLObject::decode(
+ p->rINetAttr.GetINetFmt().GetValue(),
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 ),
+ &p->rINetAttr,
+ n );
+ pMember->insert( pCnt );
+ }
+ return nCount;
+ }
}
// Content, contains names and reference at the content type.
@@ -354,22 +378,8 @@ void SwContentType::Init(bool* pbInvalidateWindow)
else if(!pMember->empty())
pMember->DeleteAndDestroyAll();
- SwGetINetAttrs aArr;
- nMemberCount = pWrtShell->GetINetAttrs( aArr );
- for( sal_uInt16 n = 0; n < nMemberCount; ++n )
- {
- SwGetINetAttr* p = &aArr[ n ];
- SwURLFieldContent* pCnt = new SwURLFieldContent(
- this,
- p->sText,
- INetURLObject::decode(
- p->rINetAttr.GetINetFmt().GetValue(),
- INetURLObject::DECODE_UNAMBIGUOUS,
- RTL_TEXTENCODING_UTF8 ),
- &p->rINetAttr,
- n );
- pMember->insert( pCnt );
- }
+ nMemberCount = lcl_InsertURLFieldContent(pMember, pWrtShell, this);
+
bEdit = true;
nOldMemberCount = nMemberCount;
bDelete = false;
@@ -657,24 +667,7 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
}
break;
case CONTENT_TYPE_URLFIELD:
- {
- SwGetINetAttrs aArr;
- nMemberCount = pWrtShell->GetINetAttrs( aArr );
- for( sal_uInt16 n = 0; n < nMemberCount; ++n )
- {
- SwGetINetAttr* p = &aArr[ n ];
- SwURLFieldContent* pCnt = new SwURLFieldContent(
- this,
- p->sText,
- INetURLObject::decode(
- p->rINetAttr.GetINetFmt().GetValue(),
- INetURLObject::DECODE_UNAMBIGUOUS,
- RTL_TEXTENCODING_UTF8 ),
- &p->rINetAttr,
- n );
- pMember->insert( pCnt );
- }
- }
+ nMemberCount = lcl_InsertURLFieldContent(pMember, pWrtShell, this);
break;
case CONTENT_TYPE_INDEX:
{
commit 6106d7a2372fbd3030638901874d4cc260c0c521
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 21:01:26 2015 +0200
USHRT_MAX ==> COMPLETE_STRING
Change-Id: Ie8ba1fee144177d48a91143da8bdf6f2ab05e295
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 2835488..1f32889 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -863,8 +863,8 @@ sal_uInt16 SwEditShell::GetLineCount( bool bActPos )
{
if( 0 != ( pCntFrm = pCNd->getLayoutFrm( GetLayout() ) ) && pCntFrm->IsTxtFrm() )
{
- sal_Int32 nActPos = bActPos && aStart == rPtIdx ?
- pPam->GetPoint()->nContent.GetIndex() : USHRT_MAX;
+ const sal_Int32 nActPos = bActPos && aStart == rPtIdx ?
+ pPam->GetPoint()->nContent.GetIndex() : COMPLETE_STRING;
nRet = nRet + static_cast<SwTxtFrm*>(pCntFrm)->GetLineCount( nActPos );
}
}
commit e456f1e86f0f1f02ce7307243f61825a14dc4760
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 20:41:28 2015 +0200
Use more proper integer types
Change-Id: I62235badde4d7b108f7545e07c1afe96df6a3114
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index f442c9a..2835488 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -666,7 +666,7 @@ sal_uInt16 SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr )
const SwTxtNode* pTxtNd;
const SwCharFmts* pFmts = GetDoc()->GetCharFmts();
- for( sal_uInt16 n = pFmts->size(); 1 < n; )
+ for( auto n = pFmts->size(); 1 < n; )
{
SwIterator<SwTxtINetFmt,SwCharFmt> aIter(*(*pFmts)[--n]);
for( SwTxtINetFmt* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
@@ -733,7 +733,7 @@ void SwEditShell::SetNumberingRestart()
Push();
// iterate over all text contents - body, frames, header, footer, footnote text
SwPaM* pCrsr = GetCrsr();
- for(sal_uInt16 i = 0; i < 2; i++)
+ for(int i = 0; i < 2; i++)
{
if(!i)
MakeFindRange(DOCPOS_START, DOCPOS_END, pCrsr); // body content
commit 975e35565ea7ac2fc2597a8c3940b76cffc2854b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 19:53:19 2015 +0200
Use auto instead of sal_uInt16
Change-Id: Iaaf71bd7e1137ef0536c46c7fa4e78d2a6e6e162
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 14bc8be..8139e10 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -191,7 +191,7 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
{
const OUString rTblName = pTblNd->GetTable().GetFrmFmt()->GetName();
const SwFrmFmts& rTblFmts = *pInsDoc->GetTblFrmFmts();
- for( sal_uInt16 n = rTblFmts.size(); n; )
+ for( auto n = rTblFmts.size(); n; )
if( rTblFmts[ --n ]->GetName() == rTblName )
{
bCpyTblNm = false;
commit 85b6a8a43c8c5841235da0f315ca2c7d1cac28ec
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 19:52:53 2015 +0200
Simplify by early bail-out
Change-Id: Ia98b0712de66315b42fac4bb2978cfa206932523
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 63bcf4e..14bc8be 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -57,25 +57,19 @@ sal_uInt16 SwEditShell::MakeGlossary( SwTextBlocks& rBlks, const OUString& rName
}
rBlks.SetBaseURL( sBase );
- sal_uInt16 nRet;
-
if( pOnlyTxt )
- nRet = rBlks.PutText( rShortName, rName, *pOnlyTxt );
- else
+ return rBlks.PutText( rShortName, rName, *pOnlyTxt );
+
+ rBlks.ClearDoc();
+ if( rBlks.BeginPutDoc( rShortName, rName ) )
{
- rBlks.ClearDoc();
- if( rBlks.BeginPutDoc( rShortName, rName ) )
- {
- rBlks.GetDoc()->getIDocumentRedlineAccess().SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES );
- _CopySelToDoc( pGDoc );
- rBlks.GetDoc()->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)0 );
- nRet = rBlks.PutDoc();
- }
- else
- nRet = (sal_uInt16) -1;
+ rBlks.GetDoc()->getIDocumentRedlineAccess().SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES );
+ _CopySelToDoc( pGDoc );
+ rBlks.GetDoc()->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)0 );
+ return rBlks.PutDoc();
}
- return nRet;
+ return USHRT_MAX;
}
sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock,
commit d9639f222626e02aa84a62c7ce1dc02fbd567e8a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 19:35:49 2015 +0200
return value of SwEditShell::GetGlobalDocContent is always discarded
Change-Id: Ib1d6ff89f378aa1e1e311cce5aaf186d843b0bef
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 3831545..58f04ba 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -869,7 +869,7 @@ public:
bool IsGlobalDoc() const;
void SetGlblDocSaveLinks( bool bFlag = true );
bool IsGlblDocSaveLinks() const;
- sal_uInt16 GetGlobalDocContent( SwGlblDocContents& rArr ) const;
+ void GetGlobalDocContent( SwGlblDocContents& rArr ) const;
bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
SwSectionData & rNew );
bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx
index 1aa514f..5666b73 100644
--- a/sw/source/core/edit/edglbldc.cxx
+++ b/sw/source/core/edit/edglbldc.cxx
@@ -51,12 +51,12 @@ bool SwEditShell::IsGlblDocSaveLinks() const
return getIDocumentSettingAccess()->get(DocumentSettingId::GLOBAL_DOCUMENT_SAVE_LINKS);
}
-sal_uInt16 SwEditShell::GetGlobalDocContent( SwGlblDocContents& rArr ) const
+void SwEditShell::GetGlobalDocContent( SwGlblDocContents& rArr ) const
{
rArr.DeleteAndDestroyAll();
if( !getIDocumentSettingAccess()->get(DocumentSettingId::GLOBAL_DOCUMENT) )
- return 0;
+ return;
// then all linked areas on the topmost level
SwDoc* pMyDoc = GetDoc();
@@ -131,7 +131,6 @@ sal_uInt16 SwEditShell::GetGlobalDocContent( SwGlblDocContents& rArr ) const
pMyDoc->GetNodes().GetEndOfExtras().GetIndex() + 2 );
rArr.insert( pNew );
}
- return rArr.size();
}
bool SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos,
commit 2002c37ae1ee2a4ef238cf4286cc7b21a799a939
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 19:14:30 2015 +0200
Use more proper integer types and reduce scope
Change-Id: Ib5483f857c4bddd7d0ece6b54e4d57a0347ee13a
diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx
index 1eced03..1aa514f 100644
--- a/sw/source/core/edit/edglbldc.cxx
+++ b/sw/source/core/edit/edglbldc.cxx
@@ -61,9 +61,8 @@ sal_uInt16 SwEditShell::GetGlobalDocContent( SwGlblDocContents& rArr ) const
// then all linked areas on the topmost level
SwDoc* pMyDoc = GetDoc();
const SwSectionFmts& rSectFmts = pMyDoc->GetSections();
- sal_uInt16 n;
- for( n = rSectFmts.size(); n; )
+ for( auto n = rSectFmts.size(); n; )
{
const SwSection* pSect = rSectFmts[ --n ]->GetGlobalDocSection();
if( pSect )
@@ -90,7 +89,7 @@ sal_uInt16 SwEditShell::GetGlobalDocContent( SwGlblDocContents& rArr ) const
// and finally add the dummies (other text)
SwNode* pNd;
sal_uLong nSttIdx = pMyDoc->GetNodes().GetEndOfExtras().GetIndex() + 2;
- for( n = 0; n < rArr.size(); ++n )
+ for( SwGlblDocContents::size_type n = 0; n < rArr.size(); ++n )
{
const SwGlblDocContent& rNew = *rArr[ n ];
// Search from StartPos until rNew.DocPos for a content node.
commit b8ca608a2a41ae72e09fd9095fe4ec8a04410cd2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 14:56:27 2015 +0200
Use more proper integer types and range-for loops
Change-Id: Ie32cef06ecb742e8545e4081d7f99181f5289397
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index acd35ae..1d97403 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -45,17 +45,16 @@
sal_uInt16 SwEditShell::GetFldTypeCount(sal_uInt16 nResId, bool bUsed ) const
{
const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
- const sal_uInt16 nSize = pFldTypes->size();
if(nResId == USHRT_MAX)
{
if(!bUsed)
- return nSize;
+ return static_cast<sal_uInt16>(pFldTypes->size());
sal_uInt16 nUsed = 0;
- for ( sal_uInt16 i = 0; i < nSize; i++ )
+ for ( const auto pFldType : *pFldTypes )
{
- if(IsUsed(*(*pFldTypes)[i]))
+ if(IsUsed(*pFldType))
nUsed++;
}
return nUsed;
@@ -63,10 +62,10 @@ sal_uInt16 SwEditShell::GetFldTypeCount(sal_uInt16 nResId, bool bUsed ) const
// all types with the same ResId
sal_uInt16 nIdx = 0;
- for(sal_uInt16 i = 0; i < nSize; ++i)
- { // same ResId -> increment index
- SwFieldType& rFldType = *((*pFldTypes)[i]);
- if(rFldType.Which() == nResId)
+ for(const auto pFldType : *pFldTypes)
+ {
+ // same ResId -> increment index
+ if(pFldType->Which() == nResId)
nIdx++;
}
return nIdx;
@@ -76,30 +75,29 @@ sal_uInt16 SwEditShell::GetFldTypeCount(sal_uInt16 nResId, bool bUsed ) const
SwFieldType* SwEditShell::GetFldType(sal_uInt16 nFld, sal_uInt16 nResId, bool bUsed ) const
{
const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
- const sal_uInt16 nSize = pFldTypes->size();
- if(nResId == USHRT_MAX && nFld < nSize)
+ if(nResId == USHRT_MAX && nFld < pFldTypes->size())
{
if(!bUsed)
return (*pFldTypes)[nFld];
- sal_uInt16 i, nUsed = 0;
- for ( i = 0; i < nSize; i++ )
+ SwFldTypes::size_type nUsed = 0;
+ for ( const auto pFldType : *pFldTypes )
{
- if(IsUsed(*(*pFldTypes)[i]))
+ if(IsUsed(*pFldType))
{
if(nUsed == nFld)
- break;
+ return pFldType;
nUsed++;
}
}
- return i < nSize ? (*pFldTypes)[i] : 0;
+ return nullptr;
}
sal_uInt16 nIdx = 0;
- for(sal_uInt16 i = 0; i < nSize; ++i)
- { // same ResId -> increment index
- SwFieldType* pFldType = (*pFldTypes)[i];
+ for(const auto pFldType : *pFldTypes)
+ {
+ // same ResId -> increment index
if(pFldType->Which() == nResId)
{
if (!bUsed || IsUsed(*pFldType))
@@ -129,12 +127,11 @@ void SwEditShell::RemoveFldType(sal_uInt16 nFld, sal_uInt16 nResId)
}
const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
- const sal_uInt16 nSize = pFldTypes->size();
sal_uInt16 nIdx = 0;
- for( sal_uInt16 i = 0; i < nSize; ++i )
+ const SwFldTypes::size_type nSize = pFldTypes->size();
+ for( SwFldTypes::size_type i; i < nSize; ++i )
// Gleiche ResId -> Index erhoehen
- if( (*pFldTypes)[i]->Which() == nResId &&
- nIdx++ == nFld )
+ if( (*pFldTypes)[i]->Which() == nResId && nIdx++ == nFld )
{
GetDoc()->getIDocumentFieldsAccess().RemoveFldType( i );
return;
@@ -145,12 +142,12 @@ void SwEditShell::RemoveFldType(sal_uInt16 nFld, sal_uInt16 nResId)
void SwEditShell::RemoveFldType(sal_uInt16 nResId, const OUString& rStr)
{
const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
- const sal_uInt16 nSize = pFldTypes->size();
+ const SwFldTypes::size_type nSize = pFldTypes->size();
const CharClass& rCC = GetAppCharClass();
OUString aTmp( rCC.lowercase( rStr ));
- for(sal_uInt16 i = 0; i < nSize; ++i)
+ for(SwFldTypes::size_type i = 0; i < nSize; ++i)
{
// same ResId -> increment index
SwFieldType* pFldType = (*pFldTypes)[i];
@@ -434,21 +431,18 @@ void SwEditShell::ChangeAuthorityData(const SwAuthEntry* pNewData)
bool SwEditShell::IsAnyDatabaseFieldInDoc()const
{
const SwFldTypes * pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
- const sal_uInt16 nSize = pFldTypes->size();
- for(sal_uInt16 i = 0; i < nSize; ++i)
+ for(const auto pFldType : *pFldTypes)
{
- SwFieldType& rFldType = *((*pFldTypes)[i]);
- sal_uInt16 nWhich = rFldType.Which();
- if(IsUsed(rFldType))
+ if(IsUsed(*pFldType))
{
- switch(nWhich)
+ switch(pFldType->Which())
{
case RES_DBFLD:
case RES_DBNEXTSETFLD:
case RES_DBNUMSETFLD:
case RES_DBSETNUMBERFLD:
{
- SwIterator<SwFmtFld,SwFieldType> aIter( rFldType );
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
SwFmtFld* pFld = aIter.First();
while(pFld)
{
diff --git a/sw/source/core/edit/edfldexp.cxx b/sw/source/core/edit/edfldexp.cxx
index ca14b58..52de1de 100644
--- a/sw/source/core/edit/edfldexp.cxx
+++ b/sw/source/core/edit/edfldexp.cxx
@@ -38,20 +38,17 @@ using namespace com::sun::star;
bool SwEditShell::IsFieldDataSourceAvailable(OUString& rUsedDataSource) const
{
const SwFldTypes * pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
- const sal_uInt16 nSize = pFldTypes->size();
uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
uno::Reference<sdb::XDatabaseContext> xDBContext = sdb::DatabaseContext::create(xContext);
- for(sal_uInt16 i = 0; i < nSize; ++i)
+ for(const auto pFldType : *pFldTypes)
{
- SwFieldType& rFldType = *((*pFldTypes)[i]);
- sal_uInt16 nWhich = rFldType.Which();
- if(IsUsed(rFldType))
+ if(IsUsed(*pFldType))
{
- switch(nWhich)
+ switch(pFldType->Which())
{
case RES_DBFLD:
{
- SwIterator<SwFmtFld,SwFieldType> aIter( rFldType );
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
SwFmtFld* pFmtFld = aIter.First();
while(pFmtFld)
{
commit 721024be23424099d39f9896496ba0ce96460f4d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 14:30:02 2015 +0200
Avoid else branches after return statements
Change-Id: Ia64d2b6c94c8ead92a2f44a3c554acae5a54917f
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index f9b0e7f..acd35ae 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -51,16 +51,14 @@ sal_uInt16 SwEditShell::GetFldTypeCount(sal_uInt16 nResId, bool bUsed ) const
{
if(!bUsed)
return nSize;
- else
+
+ sal_uInt16 nUsed = 0;
+ for ( sal_uInt16 i = 0; i < nSize; i++ )
{
- sal_uInt16 nUsed = 0;
- for ( sal_uInt16 i = 0; i < nSize; i++ )
- {
- if(IsUsed(*(*pFldTypes)[i]))
- nUsed++;
- }
- return nUsed;
+ if(IsUsed(*(*pFldTypes)[i]))
+ nUsed++;
}
+ return nUsed;
}
// all types with the same ResId
@@ -84,20 +82,18 @@ SwFieldType* SwEditShell::GetFldType(sal_uInt16 nFld, sal_uInt16 nResId, bool bU
{
if(!bUsed)
return (*pFldTypes)[nFld];
- else
+
+ sal_uInt16 i, nUsed = 0;
+ for ( i = 0; i < nSize; i++ )
{
- sal_uInt16 i, nUsed = 0;
- for ( i = 0; i < nSize; i++ )
+ if(IsUsed(*(*pFldTypes)[i]))
{
- if(IsUsed(*(*pFldTypes)[i]))
- {
- if(nUsed == nFld)
- break;
- nUsed++;
- }
+ if(nUsed == nFld)
+ break;
+ nUsed++;
}
- return i < nSize ? (*pFldTypes)[i] : 0;
}
+ return i < nSize ? (*pFldTypes)[i] : 0;
}
sal_uInt16 nIdx = 0;
commit 6753a14a496b93a9dae0d807c7c9d42fb57e708d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 14:08:51 2015 +0200
getMaxLookup() can return by value and also be local inline
Change-Id: Ic8975e931992f9010dcb86761d0716c0dffb84ba
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index ef35edc..bfbcc06 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -54,10 +54,9 @@
// if selection is bigger as max nodes or more than max selections
// => no attributes
-const sal_uInt16& getMaxLookup()
+static inline sal_uInt16 getMaxLookup()
{
- static const sal_uInt16 nMaxLookup = 1000;
- return nMaxLookup;
+ return 1000;
}
bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet,
commit 4b16c2e87303680482b60a16dc2cbfad3b4560e7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 13:34:57 2015 +0200
Fix indentation and simplify
Change-Id: I7557fa22ffe14dd62cf6c0a3ab99323118d97b29
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index ed8a079..ef35edc 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -543,15 +543,17 @@ void SwEditShell::MoveLeftMargin( bool bRight, bool bModulus )
static inline sal_uInt16 lcl_SetScriptFlags( sal_uInt16 nType )
{
- sal_uInt16 nRet;
- switch( nType )
+ switch( nType )
{
- case ::com::sun::star::i18n::ScriptType::LATIN: nRet = SCRIPTTYPE_LATIN; break;
- case ::com::sun::star::i18n::ScriptType::ASIAN: nRet = SCRIPTTYPE_ASIAN; break;
- case ::com::sun::star::i18n::ScriptType::COMPLEX: nRet = SCRIPTTYPE_COMPLEX; break;
- default: nRet = 0;
+ case ::com::sun::star::i18n::ScriptType::LATIN:
+ return SCRIPTTYPE_LATIN;
+ case ::com::sun::star::i18n::ScriptType::ASIAN:
+ return SCRIPTTYPE_ASIAN;
+ case ::com::sun::star::i18n::ScriptType::COMPLEX:
+ return SCRIPTTYPE_COMPLEX;
+ default:
+ return 0;
}
- return nRet;
}
static bool lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, sal_Int32 nPos,
commit 6fbdc7cb86db2495a70acaf91e7c74575bf7bf6b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 13:31:22 2015 +0200
Use range-for loop
Change-Id: I971bdbe38b78a9d0cba2ddbf189171fb9a21013f
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 248fa1f..ed8a079 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -421,9 +421,9 @@ bool SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn )
bool SwEditShell::HasFtns( bool bEndNotes ) const
{
const SwFtnIdxs &rIdxs = mpDoc->GetFtnIdxs();
- for ( sal_uInt16 i = 0; i < rIdxs.size(); ++i )
+ for ( auto pIdx : rIdxs )
{
- const SwFmtFtn &rFtn = rIdxs[i]->GetFtn();
+ const SwFmtFtn &rFtn = pIdx->GetFtn();
if ( bEndNotes == rFtn.IsEndNote() )
return true;
}
commit c860df99d26061588f428f75e3881f755a72811b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 13:24:13 2015 +0200
Evaluate expression just once
Change-Id: I7557234d31dcf73c784c98cb046e40c9b11fe486
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 45a6f89..6a1de5b 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -2319,19 +2319,16 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags,
m_bEmptyLine = false;
const OUString sEndClrStr( DelTrailingBlanks(sClrStr) );
- const sal_Int32 nLen = sEndClrStr.getLength();
+ const sal_Unicode cLast = sEndClrStr[sEndClrStr.getLength() - 1];
// not, then check if headline
- if( ':' == sEndClrStr[ nLen - 1 ] )
+ if( ':' == cLast )
{
- {
- BuildHeadLine( 2 );
- m_eStat = READ_NEXT_PARA;
- break;
- }
+ BuildHeadLine( 2 );
+ m_eStat = READ_NEXT_PARA;
+ break;
}
- else if( 256 <= sEndClrStr[ nLen-1 ] ||
- !strchr( ",.;", sEndClrStr[ nLen-1 ]) )
+ else if( 256 <= cLast || !strchr( ",.;", cLast ) )
{
if( bNxtEmpty || bNxtAlpha
|| ( pNxtNd && IsEnumericChar( *pNxtNd ))
commit 243d89dd04c696a5d7b9e42199964d966a9258e6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 13:19:48 2015 +0200
Simplify DelLeadingBlanks interface
Change-Id: I79d29272e8665404d08674c9853d87bba7b68694
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 72063b3..45a6f89 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -169,7 +169,7 @@ class SwAutoFormat
sal_Int32 GetBigIndent( sal_Int32& rAktSpacePos ) const;
OUString DelLeadingBlanks(const OUString& rStr) const;
- OUString& DelTrailingBlanks( OUString& rStr ) const;
+ OUString DelTrailingBlanks( const OUString& rStr ) const;
sal_Int32 GetLeadingBlanks( const OUString& rStr ) const;
sal_Int32 GetTrailingBlanks( const OUString& rStr ) const;
@@ -671,7 +671,7 @@ OUString SwAutoFormat::DelLeadingBlanks( const OUString& rStr ) const
return rStr;
}
-OUString& SwAutoFormat::DelTrailingBlanks( OUString& rStr ) const
+OUString SwAutoFormat::DelTrailingBlanks( const OUString& rStr ) const
{
sal_Int32 nL = rStr.getLength(), n = nL;
if( !nL )
@@ -680,7 +680,7 @@ OUString& SwAutoFormat::DelTrailingBlanks( OUString& rStr ) const
while( --n && IsSpace( rStr[ n ] ) )
;
if( n+1 != nL ) // no Spaces
- rStr = rStr.copy( 0, n+1 );
+ return rStr.copy( 0, n+1 );
return rStr;
}
@@ -2303,7 +2303,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags,
if( !bReplaceStyles )
break;
- OUString sClrStr( DelLeadingBlanks(m_pCurTxtNd->GetTxt()) );
+ const OUString sClrStr( DelLeadingBlanks(m_pCurTxtNd->GetTxt()) );
if( sClrStr.isEmpty() )
{
@@ -2318,8 +2318,8 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags,
break;
m_bEmptyLine = false;
- OUString sEndClrStr( sClrStr );
- sal_Int32 nLen = DelTrailingBlanks( sEndClrStr ).getLength();
+ const OUString sEndClrStr( DelTrailingBlanks(sClrStr) );
+ const sal_Int32 nLen = sEndClrStr.getLength();
// not, then check if headline
if( ':' == sEndClrStr[ nLen - 1 ] )
commit 9e888629564ef9c32b2b8ee07dee5afba44b5a24
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 12:32:45 2015 +0200
Use range-for loops
Change-Id: I00a7af83acd1b67e913c444aaffbe74986b589a3
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 28ddb84..dcf788a 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1800,9 +1800,8 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch )
{
const SwNodeIndex& rIdx = pAnch->GetCntntAnchor()->nNode;
SwFrmFmts& rFmts = *(pDrawFrmFmt->GetDoc()->GetSpzFrmFmts());
- for( sal_uInt16 i = 0; i < rFmts.size(); ++i )
+ for( auto pFlyFmt : rFmts )
{
- SwFrmFmt* pFlyFmt = rFmts[i];
if( pFlyFmt->GetCntnt().GetCntntIdx() &&
rIdx == *(pFlyFmt->GetCntnt().GetCntntIdx()) )
{
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 4d1557e..7713e3a 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -759,11 +759,9 @@ void SwVirtFlyDrawObj::NbcResize(const Point& rRef,
const SwFmtCol& rCol = rAttrs.GetAttrSet().GetCol();
if ( rCol.GetColumns().size() > 1 )
{
- for ( sal_uInt16 i = 0; i < rCol.GetColumns().size(); ++i )
+ for ( const auto &rC : rCol.GetColumns() )
{
- nMin += rCol.GetColumns()[i].GetLeft() +
- rCol.GetColumns()[i].GetRight() +
- MINFLY;
+ nMin += rC.GetLeft() + rC.GetRight() + MINFLY;
}
nMin -= MINFLY;
}
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 8f1cf99..72063b3 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -343,9 +343,9 @@ bool SwAutoFormat::HasObjects( const SwNode& rNd )
// like borders, DrawObjects, ...
bool bRet = false;
const SwFrmFmts& rFmts = *m_pDoc->GetSpzFrmFmts();
- for( sal_uInt16 n = 0; n < rFmts.size(); ++n )
+ for( auto pFrmFmt : rFmts )
{
- const SwFmtAnchor& rAnchor = rFmts[ n ]->GetAnchor();
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
if ((FLY_AT_PAGE != rAnchor.GetAnchorId()) &&
rAnchor.GetCntntAnchor() &&
&rAnchor.GetCntntAnchor()->nNode.GetNode() == &rNd )
commit 7436db1ebb2a3d66c3d85b825246bdbad62727de
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 12:18:57 2015 +0200
Use auto for backward loop index
Change-Id: I6d8c0c86cb2693bef6ef28ec85f9ac12cc4401f5
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 00e52c0..98cf47e 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -601,7 +601,7 @@ void SwSection::MakeChildLinksVisible( const SwSectionNode& rSectNd )
{
const SwNode* pNd;
const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->getIDocumentLinksAdministration().GetLinkManager().GetLinks();
- for( sal_uInt16 n = rLnks.size(); n; )
+ for( auto n = rLnks.size(); n; )
{
::sfx2::SvBaseLink* pBLnk = &(*rLnks[ --n ]);
if( pBLnk && !pBLnk->IsVisible() &&
@@ -1116,7 +1116,7 @@ static void lcl_BreakSectionLinksInSect( const SwSectionNode& rSectNd )
}
const ::sfx2::SvBaseLink* pOwnLink( &(rSectNd.GetSection().GetBaseLink() ) );
const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->getIDocumentLinksAdministration().GetLinkManager().GetLinks();
- for ( sal_uInt16 n = rLnks.size(); n > 0; )
+ for ( auto n = rLnks.size(); n > 0; )
{
SwIntrnlSectRefLink* pSectLnk = dynamic_cast<SwIntrnlSectRefLink*>(&(*rLnks[ --n ]));
if ( pSectLnk && pSectLnk != pOwnLink &&
@@ -1148,7 +1148,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
aValue <<= sName; // Arbitrary name
const ::sfx2::SvBaseLinks& rLnks = pDoc->getIDocumentLinksAdministration().GetLinkManager().GetLinks();
- for( sal_uInt16 n = rLnks.size(); n; )
+ for( auto n = rLnks.size(); n; )
{
SwBaseLink* pBLink;
@@ -1459,7 +1459,7 @@ void SwIntrnlSectRefLink::Closed()
// Advise says goodbye: mark the Section as not protected
// and change the Flag
const SwSectionFmts& rFmts = pDoc->GetSections();
- for( sal_uInt16 n = rFmts.size(); n; )
+ for( auto n = rFmts.size(); n; )
if( rFmts[ --n ] == &rSectFmt )
{
SwViewShell* pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index 3b3ae1b..edd25b6 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -226,7 +226,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
bInNotifyLinks = true;
const ::sfx2::SvBaseLinks& rLnks = pDoc->getIDocumentLinksAdministration().GetLinkManager().GetLinks();
- for( sal_uInt16 n = rLnks.size(); n; )
+ for( auto n = rLnks.size(); n; )
{
::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]);
if( pLnk && OBJECT_CLIENT_GRF == pLnk->GetObjType() &&
commit 93ef3530d56afb7347fdf652a1c52db08a306890
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 12:16:15 2015 +0200
Use more proper integer types
Change-Id: I8224c3de495fde84a708e1bdd4a71ff27461057e
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index d0ba456..3ae5e3b 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -137,7 +137,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
{
// Move order: from front to back, so that new entries are added at
// first position, thus, deletion position stays the same
- sal_uInt16 nDiff = rDelPos.GetIndex() < rInsPos.GetIndex() ? 0 : 1;
+ const sal_uLong nDiff = rDelPos.GetIndex() < rInsPos.GetIndex() ? 0 : 1;
for( sal_uLong n = rDelPos.GetIndex(); nSz; n += nDiff, --nSz )
{
@@ -443,11 +443,11 @@ bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
return false;
}
- sal_uInt16 nLevel = 0; // level counter
sal_uLong nInsPos = 0; // counter for tmp array
// array as a stack, storing all StartOfSelections
SwSttNdPtrs aSttNdStack;
+ SwSttNdPtrs::size_type nLevel = 0; // level counter
// set start index
SwNodeIndex aIdx( aIndex );
@@ -458,7 +458,7 @@ bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
SwNodeRange aOrigInsPos( aIdx, -1, aIdx ); // original insertion position
// call DelFrms/MakeFrms for the upmost SectionNode
- sal_uInt16 nSectNdCnt = 0;
+ int nSectNdCnt = 0;
bool bSaveNewFrms = bNewFrms;
// continue until everything has been moved
@@ -1072,7 +1072,7 @@ void SwNodes::SectionUpDown( const SwNodeIndex & aStart, const SwNodeIndex & aEn
*/
void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes)
{
- sal_uInt16 nLevel = 0; // level counter
+ int nLevel = 0; // level counter
SwNode * pAktNode;
sal_uLong nCnt = Count() - rIndex.GetIndex() - 1;
@@ -1729,7 +1729,7 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange,
SwNodeIndex aInsPos( rIndex );
SwNodeIndex aOrigInsPos( rIndex, -1 ); // original insertion position
- sal_uInt16 nLevel = 0; // level counter
+ int nLevel = 0; // level counter
for( sal_uLong nNodeCnt = aRg.aEnd.GetIndex() - aRg.aStart.GetIndex();
nNodeCnt > 0; --nNodeCnt )
commit c1b1df71858cdf3b2818d6408e60cdef9bafa652
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 12:01:05 2015 +0200
Use vector<T>::size_type
Change-Id: I467cd6677b467f095eba9e33d84e88e262548c77
diff --git a/sw/source/core/docnode/node2lay.cxx b/sw/source/core/docnode/node2lay.cxx
index 849b5df..e935187 100644
--- a/sw/source/core/docnode/node2lay.cxx
+++ b/sw/source/core/docnode/node2lay.cxx
@@ -348,7 +348,7 @@ void SwNode2LayImpl::RestoreUpperFrms( SwNodes& rNds, sal_uLong nStt, sal_uLong
SwFrm* pNxt;
SwLayoutFrm* pUp;
if( (pNd = rNds[nStt])->IsCntntNode() )
- for( sal_uInt16 n = 0; n < pUpperFrms->size(); )
+ for( std::vector<SwFrm*>::size_type n = 0; n < pUpperFrms->size(); )
{
pNxt = (*pUpperFrms)[n++];
if( bFirst && pNxt && pNxt->IsSctFrm() )
@@ -363,7 +363,7 @@ void SwNode2LayImpl::RestoreUpperFrms( SwNodes& rNds, sal_uLong nStt, sal_uLong
(*pUpperFrms)[n-2] = pNew;
}
else if( pNd->IsTableNode() )
- for( sal_uInt16 x = 0; x < pUpperFrms->size(); )
+ for( std::vector<SwFrm*>::size_type x = 0; x < pUpperFrms->size(); )
{
pNxt = (*pUpperFrms)[x++];
if( bFirst && pNxt && pNxt->IsSctFrm() )
@@ -382,7 +382,7 @@ void SwNode2LayImpl::RestoreUpperFrms( SwNodes& rNds, sal_uLong nStt, sal_uLong
else if( pNd->IsSectionNode() )
{
nStt = pNd->EndOfSectionIndex();
- for( sal_uInt16 x = 0; x < pUpperFrms->size(); )
+ for( std::vector<SwFrm*>::size_type x = 0; x < pUpperFrms->size(); )
{
pNxt = (*pUpperFrms)[x++];
if( bFirst && pNxt && pNxt->IsSctFrm() )
@@ -396,7 +396,7 @@ void SwNode2LayImpl::RestoreUpperFrms( SwNodes& rNds, sal_uLong nStt, sal_uLong
}
bFirst = false;
}
- for( sal_uInt16 x = 0; x < pUpperFrms->size(); ++x )
+ for( std::vector<SwFrm*>::size_type x = 0; x < pUpperFrms->size(); ++x )
{
SwFrm* pTmp = (*pUpperFrms)[++x];
if( pTmp->IsFtnFrm() )
commit 9ac2d69fea187d71f987bc0e786461699a46dd04
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 6 11:47:37 2015 +0200
Indent properly
Change-Id: Id4ddf08f8c79139a561fda90af402ad3698c5b16
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index e2e984a..da85f7d 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3046,12 +3046,12 @@ void sw_BoxSetSplitBoxFmts( SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara )
}
else
{
-sal_uInt16 aTableSplitBoxSetRange[] = {
- RES_LR_SPACE, RES_UL_SPACE,
- RES_BACKGROUND, RES_SHADOW,
- RES_PROTECT, RES_PROTECT,
- RES_VERT_ORIENT, RES_VERT_ORIENT,
- 0 };
+ sal_uInt16 aTableSplitBoxSetRange[] = {
+ RES_LR_SPACE, RES_UL_SPACE,
+ RES_BACKGROUND, RES_SHADOW,
+ RES_PROTECT, RES_PROTECT,
+ RES_VERT_ORIENT, RES_VERT_ORIENT,
+ 0 };
SfxItemSet aTmpSet( pFmt->GetDoc()->GetAttrPool(),
aTableSplitBoxSetRange );
commit dadd14b21ab3f11bb2607666ff538cde40c6f575
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 5 21:46:08 2015 +0200
Use more proper types and range-for loops
Change-Id: Ic4e455f5cfe80fabf8d2ab6b6679863ac6f90f8e
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 351dd01..e2e984a 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3868,13 +3868,12 @@ OUString SwDoc::GetUniqueTblName() const
ResId aId( STR_TABLE_DEFNAME, *pSwResMgr );
const OUString aName( aId );
- size_t nNum, nTmp, nFlagSize = ( mpTblFrmFmtTbl->size() / 8 ) + 2;
- size_t n;
+ const size_t nFlagSize = ( mpTblFrmFmtTbl->size() / 8 ) + 2;
sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ];
memset( pSetFlags, 0, nFlagSize );
- for( n = 0; n < mpTblFrmFmtTbl->size(); ++n )
+ for( size_t n = 0; n < mpTblFrmFmtTbl->size(); ++n )
{
const SwFrmFmt* pFmt = (*mpTblFrmFmtTbl)[ n ];
if( !pFmt->IsDefault() && IsUsed( *pFmt ) &&
@@ -3882,23 +3881,29 @@ OUString SwDoc::GetUniqueTblName() const
{
// Get number and set the Flag
const sal_Int32 nNmLen = aName.getLength();
- nNum = static_cast<sal_uInt16>(pFmt->GetName().copy( nNmLen ).toInt32());
+ size_t nNum = pFmt->GetName().copy( nNmLen ).toInt32();
if( nNum-- && nNum < mpTblFrmFmtTbl->size() )
pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
}
}
// All numbers are flagged properly, thus calculate the right number
- nNum = mpTblFrmFmtTbl->size();
- for( n = 0; n < nFlagSize; ++n )
- if( 0xff != ( nTmp = pSetFlags[ n ] ))
+ size_t nNum = mpTblFrmFmtTbl->size();
+ for( size_t n = 0; n < nFlagSize; ++n )
+ {
+ auto nTmp = pSetFlags[ n ];
+ if( nTmp != 0xFF )
{
// Calculate the number
nNum = n * 8;
while( nTmp & 1 )
- ++nNum, nTmp >>= 1;
+ {
+ ++nNum;
+ nTmp >>= 1;
+ }
break;
}
+ }
delete [] pSetFlags;
return aName + OUString::number( ++nNum );
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 2b122d0..a2f2ca8 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -80,9 +80,8 @@ SwTblFmtCmp::SwTblFmtCmp( SwFrmFmt *pO, SwFrmFmt *pN, sal_Int16 nT )
SwFrmFmt *SwTblFmtCmp::FindNewFmt( std::vector<SwTblFmtCmp*> &rArr, SwFrmFmt *pOld, sal_Int16 nType )
{
- for ( sal_uInt16 i = 0; i < rArr.size(); ++i )
+ for ( auto pCmp : rArr )
{
- SwTblFmtCmp *pCmp = rArr[i];
if ( pCmp->pOld == pOld && pCmp->nType == nType )
return pCmp->pNew;
}
@@ -91,8 +90,8 @@ SwFrmFmt *SwTblFmtCmp::FindNewFmt( std::vector<SwTblFmtCmp*> &rArr, SwFrmFmt *pO
void SwTblFmtCmp::Delete( std::vector<SwTblFmtCmp*> &rArr )
{
- for ( sal_uInt16 i = 0; i < rArr.size(); ++i )
- delete rArr[i];
+ for ( auto pCmp : rArr )
+ delete pCmp;
}
static void lcl_GetStartEndCell( const SwCursor& rCrsr,
@@ -189,9 +188,8 @@ bool _FindBox( _FndBox & rBox, LinesAndTable* pPara )
: pPara->rTable.GetTabLines();
if (rBox.GetLines().size() == rLines.size())
{
- for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
- ::InsertLine( pPara->rLines,
- (SwTableLine*)rLines[i] );
+ for ( auto pLine : rLines )
+ ::InsertLine( pPara->rLines, pLine );
}
else
pPara->bInsertLines = false;
@@ -238,10 +236,10 @@ static void lcl_CollectLines( std::vector<SwTableLine*> &rArr, const SwCursor& r
// (Not for row split)
if ( bRemoveLines )
{
- for ( sal_uInt16 i = 0; i < rArr.size(); ++i )
+ for ( std::vector<SwTableLine*>::size_type i = 0; i < rArr.size(); ++i )
{
SwTableLine *pUpLine = rArr[i];
- for ( sal_uInt16 k = 0; k < rArr.size(); ++k )
+ for ( std::vector<SwTableLine*>::size_type k = 0; k < rArr.size(); ++k )
{
if ( k != i && ::lcl_IsAnLower( pUpLine, rArr[k] ) )
{
@@ -275,8 +273,8 @@ static void lcl_ProcessRowSize( std::vector<SwTblFmtCmp*> &rFmtCmp, SwTableLine
{
lcl_ProcessRowAttr( rFmtCmp, pLine, rNew );
SwTableBoxes &rBoxes = pLine->GetTabBoxes();
- for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
- ::lcl_ProcessBoxSize( rFmtCmp, rBoxes[i], rNew );
+ for ( auto pBox : rBoxes )
+ ::lcl_ProcessBoxSize( rFmtCmp, pBox, rNew );
}
static void lcl_ProcessBoxSize( std::vector<SwTblFmtCmp*> &rFmtCmp, SwTableBox *pBox, const SwFmtFrmSize &rNew )
@@ -286,8 +284,8 @@ static void lcl_ProcessBoxSize( std::vector<SwTblFmtCmp*> &rFmtCmp, SwTableBox *
{
SwFmtFrmSize aSz( rNew );
aSz.SetHeight( rNew.GetHeight() ? rNew.GetHeight() / rLines.size() : 0 );
- for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
- ::lcl_ProcessRowSize( rFmtCmp, rLines[i], aSz );
+ for ( auto pLine : rLines )
+ ::lcl_ProcessRowSize( rFmtCmp, pLine, aSz );
}
}
@@ -309,8 +307,8 @@ void SwDoc::SetRowSplit( const SwCursor& rCursor, const SwFmtRowSplit &rNew )
std::vector<SwTblFmtCmp*> aFmtCmp;
aFmtCmp.reserve( std::max( 255, (int)aRowArr.size() ) );
- for( sal_uInt16 i = 0; i < aRowArr.size(); ++i )
- ::lcl_ProcessRowAttr( aFmtCmp, aRowArr[i], rNew );
+ for( auto pLn : aRowArr )
+ ::lcl_ProcessRowAttr( aFmtCmp, pLn, rNew );
SwTblFmtCmp::Delete( aFmtCmp );
getIDocumentState().SetModified();
@@ -332,10 +330,16 @@ void SwDoc::GetRowSplit( const SwCursor& rCursor, SwFmtRowSplit *& rpSz ) const
{
rpSz = &(SwFmtRowSplit&)aRowArr[0]->GetFrmFmt()->GetRowSplit();
- for ( sal_uInt16 i = 1; i < aRowArr.size() && rpSz; ++i )
+ if (rpSz)
{
- if ( (*rpSz).GetValue() != aRowArr[i]->GetFrmFmt()->GetRowSplit().GetValue() )
- rpSz = 0;
+ for ( auto pLn : aRowArr )
+ {
+ if ( (*rpSz).GetValue() != pLn->GetFrmFmt()->GetRowSplit().GetValue() )
+ {
+ rpSz = 0;
+ break;
+ }
+ }
}
if ( rpSz )
rpSz = new SwFmtRowSplit( *rpSz );
@@ -375,8 +379,8 @@ void SwDoc::SetRowHeight( const SwCursor& rCursor, const SwFmtFrmSize &rNew )
std::vector<SwTblFmtCmp*> aFmtCmp;
aFmtCmp.reserve( std::max( 255, (int)aRowArr.size() ) );
- for ( sal_uInt16 i = 0; i < aRowArr.size(); ++i )
- ::lcl_ProcessRowSize( aFmtCmp, aRowArr[i], rNew );
+ for ( auto pLn : aRowArr )
+ ::lcl_ProcessRowSize( aFmtCmp, pLn, rNew );
SwTblFmtCmp::Delete( aFmtCmp );
getIDocumentState().SetModified();
@@ -398,10 +402,16 @@ void SwDoc::GetRowHeight( const SwCursor& rCursor, SwFmtFrmSize *& rpSz ) const
{
rpSz = &(SwFmtFrmSize&)aRowArr[0]->GetFrmFmt()->GetFrmSize();
- for ( sal_uInt16 i = 1; i < aRowArr.size() && rpSz; ++i )
+ if (rpSz)
{
- if ( *rpSz != aRowArr[i]->GetFrmFmt()->GetFrmSize() )
- rpSz = 0;
+ for ( auto pLn : aRowArr )
+ {
+ if ( *rpSz != pLn->GetFrmFmt()->GetFrmSize() )
+ {
+ rpSz = 0;
+ break;
+ }
+ }
}
if ( rpSz )
rpSz = new SwFmtFrmSize( *rpSz );
@@ -423,11 +433,10 @@ bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly )
if( !bTstOnly )
{
long nHeight = 0;
- sal_uInt16 i;
- for ( i = 0; i < aRowArr.size(); ++i )
+ for ( auto pLn : aRowArr )
{
- SwIterator<SwFrm,SwFmt> aIter( *aRowArr[i]->GetFrmFmt() );
+ SwIterator<SwFrm,SwFmt> aIter( *pLn->GetFrmFmt() );
SwFrm* pFrm = aIter.First();
while ( pFrm )
{
@@ -445,8 +454,8 @@ bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly )
std::vector<SwTblFmtCmp*> aFmtCmp;
aFmtCmp.reserve( std::max( 255, (int)aRowArr.size() ) );
- for( i = 0; i < aRowArr.size(); ++i )
- ::lcl_ProcessRowSize( aFmtCmp, (SwTableLine*)aRowArr[i], aNew );
+ for( auto pLn : aRowArr )
+ ::lcl_ProcessRowSize( aFmtCmp, pLn, aNew );
SwTblFmtCmp::Delete( aFmtCmp );
getIDocumentState().SetModified();
@@ -475,8 +484,8 @@ void SwDoc::SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew
std::vector<SwTblFmtCmp*> aFmtCmp;
aFmtCmp.reserve( std::max( 255, (int)aRowArr.size() ) );
- for( sal_uInt16 i = 0; i < aRowArr.size(); ++i )
- ::lcl_ProcessRowAttr( aFmtCmp, aRowArr[i], rNew );
+ for( auto pLn : aRowArr )
+ ::lcl_ProcessRowAttr( aFmtCmp, pLn, rNew );
SwTblFmtCmp::Delete( aFmtCmp );
getIDocumentState().SetModified();
@@ -498,7 +507,7 @@ bool SwDoc::GetRowBackground( const SwCursor& rCursor, SvxBrushItem &rToFill ) c
rToFill = aRowArr[0]->GetFrmFmt()->makeBackgroundBrushItem();
bRet = true;
- for ( sal_uInt16 i = 1; i < aRowArr.size(); ++i )
+ for ( std::vector<SwTableLine*>::size_type i = 1; i < aRowArr.size(); ++i )
if ( rToFill != aRowArr[i]->GetFrmFmt()->makeBackgroundBrushItem() )
{
bRet = false;
@@ -607,7 +616,7 @@ void SwDoc::SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet )
}
bool bFirst = true;
- for ( sal_uInt16 i = 0; i < aUnions.size(); ++i )
+ for ( SwSelUnions::size_type i = 0; i < aUnions.size(); ++i )
{
SwSelUnion *pUnion = &aUnions[i];
SwTabFrm *pTab = pUnion->GetTable();
@@ -626,9 +635,8 @@ void SwDoc::SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet )
// also not be Outer Borders.
// Outer Borders are set on the left, right, at the top and at the bottom.
// Inner Borders are only set at the top and on the left.
- for ( sal_uInt16 j = 0; j < aCellArr.size(); ++j )
+ for ( auto pCell : aCellArr )
{
- SwCellFrm *pCell = aCellArr[j];
const bool bVert = pTab->IsVertical();
const bool bRTL = pTab->IsRightToLeft();
bool bTopOver, bLeftOver, bRightOver, bBottomOver;
@@ -844,18 +852,16 @@ void SwDoc::SetTabLineStyle( const SwCursor& rCursor,
GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd));
}
- for( sal_uInt16 i = 0; i < aUnions.size(); ++i )
+ for( auto &rU : aUnions )
{
- SwSelUnion *pUnion = &aUnions[i];
+ SwSelUnion *pUnion = &rU;
SwTabFrm *pTab = pUnion->GetTable();
std::vector<SwCellFrm*> aCellArr;
aCellArr.reserve( 255 );
::lcl_CollectCells( aCellArr, pUnion->GetUnion(), pTab );
- for ( sal_uInt16 j = 0; j < aCellArr.size(); ++j )
+ for ( auto pCell : aCellArr )
{
- SwCellFrm *pCell = aCellArr[j];
-
// Do not set anything by default in HeadlineRepeats
if ( pTab->IsFollow() && pTab->IsInHeadline( *pCell ) )
continue;
@@ -928,7 +934,7 @@ void SwDoc::GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet ) const
aSetBoxInfo.ResetFlags();
- for ( sal_uInt16 i = 0; i < aUnions.size(); ++i )
+ for ( SwSelUnions::size_type i; i < aUnions.size(); ++i )
{
SwSelUnion *pUnion = &aUnions[i];
const SwTabFrm *pTab = pUnion->GetTable();
@@ -940,9 +946,8 @@ void SwDoc::GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet ) const
aCellArr.reserve(255);
::lcl_CollectCells( aCellArr, rUnion, const_cast<SwTabFrm*>(pTab) );
- for ( sal_uInt16 j = 0; j < aCellArr.size(); ++j )
+ for ( auto pCell : aCellArr )
{
- SwCellFrm *pCell = aCellArr[j];
const bool bVert = pTab->IsVertical();
const bool bRTL = bRTLTab = pTab->IsRightToLeft();
bool bTopOver, bLeftOver, bRightOver, bBottomOver;
@@ -1093,7 +1098,7 @@ void SwDoc::GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet ) const
rBox.GetDistance( k ) )
{
aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISTANCE, false );
- aSetBox.SetDistance( (sal_uInt16) 0 );
+ aSetBox.SetDistance( 0 );
break;
}
}
@@ -1356,9 +1361,9 @@ static void lcl_CalcColValues( std::vector<sal_uInt16> &rToFill, const SwTabCols
::MakeSelUnions( aUnions, pStart, pEnd,
bWishValues ? nsSwTblSearchType::TBLSEARCH_NONE : nsSwTblSearchType::TBLSEARCH_COL );
- for ( sal_uInt16 i2 = 0; i2 < aUnions.size(); ++i2 )
+ for ( auto &rU : aUnions )
{
- SwSelUnion *pSelUnion = &aUnions[i2];
+ SwSelUnion *pSelUnion = &rU;
const SwTabFrm *pTab = pSelUnion->GetTable();
const SwRect &rUnion = pSelUnion->GetUnion();
@@ -1506,7 +1511,7 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, bool bBalance )
// only afterwards.
// The first column's desired width would be discarded as it would cause
// the Table's width to exceed the maximum width.
- for ( sal_uInt16 k = 0; k < 2; ++k )
+ for ( int k = 0; k < 2; ++k )
{
for ( size_t i = 0; i <= aTabCols.Count(); ++i )
{
commit 3d6d8305dac631108e17e1f1e401e00f570cdfd0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 5 21:07:10 2015 +0200
Use more proper types and range-for loops
Change-Id: I9a14cd871e85cedac3dba1bca98799fc9796bf74
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 8401666..351dd01 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -765,12 +765,12 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
SwTableBoxFmt *pBoxF = 0;
SwTableLines& rLines = rNdTbl.GetTabLines();
- sal_uInt16 nRows = rLines.size();
- for( sal_uInt16 n = 0; n < nRows; ++n )
+ const SwTableLines::size_type nRows = rLines.size();
+ for( SwTableLines::size_type n = 0; n < nRows; ++n )
{
SwTableBoxes& rBoxes = rLines[ n ]->GetTabBoxes();
- sal_uInt16 nCols = rBoxes.size();
- for( sal_uInt16 i = 0; i < nCols; ++i )
+ const SwTableBoxes::size_type nCols = rBoxes.size();
+ for( SwTableBoxes::size_type i = 0; i < nCols; ++i )
{
SwTableBox* pBox = rBoxes[ i ];
bool bChgSz = false;
@@ -1641,9 +1641,9 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
// #i28006# Fly frames have to be restored even if the table was
// #alone in the section
const SwFrmFmts& rFlyArr = *GetDoc()->GetSpzFrmFmts();
- for( sal_uInt16 n = 0; n < rFlyArr.size(); ++n )
+ for( auto pFly : rFlyArr )
{
- SwFrmFmt *const pFmt = (SwFrmFmt*)rFlyArr[n];
+ SwFrmFmt *const pFmt = (SwFrmFmt*)pFly;
const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
if (pAPos &&
@@ -2920,10 +2920,10 @@ void SwCollectTblLineBoxes::AddBox( const SwTableBox& rBox )
const SwTableBox* SwCollectTblLineBoxes::GetBoxOfPos( const SwTableBox& rBox )
{
const SwTableBox* pRet = 0;
- sal_uInt16 n;
if( !aPosArr.empty() )
{
+ std::vector<sal_uInt16>::size_type n;
for( n = 0; n < aPosArr.size(); ++n )
if( aPosArr[ n ] == nWidth )
break;
@@ -2947,7 +2947,7 @@ bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth )
{
if( !aPosArr.empty() )
{
- size_t n;
+ std::vector<sal_uInt16>::size_type n;
for( n = 0; n < aPosArr.size(); ++n )
{
if( aPosArr[ n ] == nOffset )
@@ -2998,7 +2998,7 @@ bool sw_Line_CollectBox( const SwTableLine*& rpLine, void* pPara )
void sw_Box_CollectBox( const SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara )
{
- sal_uInt16 nLen = pBox->GetTabLines().size();
+ auto nLen = pBox->GetTabLines().size();
if( nLen )
{
// Continue with the actual Line
@@ -3016,7 +3016,7 @@ void sw_Box_CollectBox( const SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara
void sw_BoxSetSplitBoxFmts( SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara )
{
- sal_uInt16 nLen = pBox->GetTabLines().size();
+ auto nLen = pBox->GetTabLines().size();
if( nLen )
{
// Continue with the actual Line
@@ -3251,12 +3251,12 @@ static bool lcl_ChgTblSize( SwTable& rTbl )
aTblMaxSz.SetWidth( 0 );
SwTableLines& rLns = rTbl.GetTabLines();
- for( sal_uInt16 nLns = 0; nLns < rLns.size(); ++nLns )
+ for( auto pLn : rLns )
{
SwTwips nMaxLnWidth = 0;
- SwTableBoxes& rBoxes = rLns[ nLns ]->GetTabBoxes();
- for( sal_uInt16 nBox = 0; nBox < rBoxes.size(); ++nBox )
- nMaxLnWidth += rBoxes[nBox]->GetFrmFmt()->GetFrmSize().GetWidth();
+ SwTableBoxes& rBoxes = pLn->GetTabBoxes();
+ for( auto pBox : rBoxes )
+ nMaxLnWidth += pBox->GetFrmFmt()->GetFrmSize().GetWidth();
if( nMaxLnWidth > aTblMaxSz.GetWidth() )
aTblMaxSz.SetWidth( nMaxLnWidth );
@@ -3396,13 +3396,13 @@ SwTableNode* SwNodes::SplitTable( const SwNodeIndex& rPos, bool bAfter,
SwChartDataProvider *pPCD = rTbl.GetFrmFmt()->getIDocumentChartDataProviderAccess()->GetChartDataProvider();
if( pPCD )
{
- for (sal_uInt16 k = nLinePos; k < rTbl.GetTabLines().size(); ++k)
+ for (SwTableLines::size_type k = nLinePos; k < rTbl.GetTabLines().size(); ++k)
{
- sal_uInt16 nLineIdx = (rTbl.GetTabLines().size() - 1) - k + nLinePos;
- sal_uInt16 nBoxCnt = rTbl.GetTabLines()[ nLineIdx ]->GetTabBoxes().size();
- for (sal_uInt16 j = 0; j < nBoxCnt; ++j)
+ const SwTableLines::size_type nLineIdx = (rTbl.GetTabLines().size() - 1) - k + nLinePos;
+ const SwTableBoxes::size_type nBoxCnt = rTbl.GetTabLines()[ nLineIdx ]->GetTabBoxes().size();
+ for (SwTableBoxes::size_type j = 0; j < nBoxCnt; ++j)
{
- sal_uInt16 nIdx = nBoxCnt - 1 - j;
+ const SwTableBoxes::size_type nIdx = nBoxCnt - 1 - j;
pPCD->DeleteBox( &rTbl, *rTbl.GetTabLines()[ nLineIdx ]->GetTabBoxes()[nIdx] );
}
}
@@ -3560,7 +3560,7 @@ bool SwNodes::MergeTable( const SwNodeIndex& rPos, bool bWithPrev,
}
// Move the Lines and Boxes
- sal_uInt16 nOldSize = rTbl.GetTabLines().size();
+ SwTableLines::size_type nOldSize = rTbl.GetTabLines().size();
rTbl.GetTabLines().insert( rTbl.GetTabLines().begin() + nOldSize,
rDelTbl.GetTabLines().begin(), rDelTbl.GetTabLines().end() );
rDelTbl.GetTabLines().clear();
@@ -3739,11 +3739,10 @@ bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& rNe
_SetAFmtTabPara aPara( rNew );
_FndLines& rFLns = pFndBox->GetLines();
- _FndLine* pLine;
- for( sal_uInt16 n = 0; n < rFLns.size(); ++n )
+ for( _FndLines::size_type n = 0; n < rFLns.size(); ++n )
{
- pLine = &rFLns[n];
+ _FndLine* pLine = &rFLns[n];
// Set Upper to 0 (thus simulate BaseLine)
_FndBox* pSaveBox = pLine->GetUpper();
@@ -4484,7 +4483,7 @@ bool SwDoc::UnProtectTbls( const SwPaM& rPam )
SwFrmFmts& rFmts = *GetTblFrmFmts();
SwTable* pTbl;
const SwTableNode* pTblNd;
- for( sal_uInt16 n = rFmts.size(); n ; )
+ for( auto n = rFmts.size(); n ; )
if( 0 != (pTbl = SwTable::FindTable( rFmts[ --n ] )) &&
0 != (pTblNd = pTbl->GetTableNode() ) &&
pTblNd->GetNodes().IsDocNodes() )
commit c810c2d7840ebd71fc5be5aada61ca0823c69229
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 5 19:51:38 2015 +0200
Use more proper types and range-for loops
Change-Id: Ie4eef716a65c126583945bb9742ca58b59c76a74
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 2b2db1a..746679f 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -1393,23 +1393,21 @@ OUString SwDoc::GetUniqueSectionName( const OUString* pChkStr ) const
const OUString aName( ResId( STR_REGION_DEFNAME, *pSwResMgr ) );
- sal_uInt16 nNum = 0;
- sal_uInt16 nFlagSize = ( mpSectionFmtTbl->size() / 8 ) +2;
+ SwSectionFmts::size_type nNum = 0;
+ const SwSectionFmts::size_type nFlagSize = ( mpSectionFmtTbl->size() / 8 ) + 2;
sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ];
memset( pSetFlags, 0, nFlagSize );
- sal_uInt16 n;
-
- for( n = 0; n < mpSectionFmtTbl->size(); ++n )
+ for( auto pFmt : *mpSectionFmtTbl )
{
- const SwSectionNode *const pSectNd = (*mpSectionFmtTbl)[ n ]->GetSectionNode( false );
+ const SwSectionNode *const pSectNd = pFmt->GetSectionNode( false );
if( pSectNd != nullptr )
{
const OUString rNm = pSectNd->GetSection().GetSectionName();
if (rNm.startsWith( aName ))
{
// Calculate the Number and reset the Flag
- nNum = static_cast<sal_uInt16>(rNm.copy( aName.getLength() ).toInt32());
+ nNum = rNm.copy( aName.getLength() ).toInt32();
if( nNum-- && nNum < mpSectionFmtTbl->size() )
pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
}
@@ -1422,7 +1420,7 @@ OUString SwDoc::GetUniqueSectionName( const OUString* pChkStr ) const
{
// Flagged all Numbers accordingly, so get the right Number
nNum = mpSectionFmtTbl->size();
- for( n = 0; n < nFlagSize; ++n )
+ for( SwSectionFmts::size_type n = 0; n < nFlagSize; ++n )
{
auto nTmp = pSetFlags[ n ];
if( nTmp != 0xFF )
commit 4de0d33deff40ce7bd2755a7d17caca72d2fd25f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 5 19:37:11 2015 +0200
Reduce scope and make code more readable
Change-Id: Ic3525571be577c555e45d40b3a6a7de0c7665678
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 7eee0d6..2b2db1a 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -1394,15 +1394,16 @@ OUString SwDoc::GetUniqueSectionName( const OUString* pChkStr ) const
const OUString aName( ResId( STR_REGION_DEFNAME, *pSwResMgr ) );
sal_uInt16 nNum = 0;
- sal_uInt16 nTmp, nFlagSize = ( mpSectionFmtTbl->size() / 8 ) +2;
+ sal_uInt16 nFlagSize = ( mpSectionFmtTbl->size() / 8 ) +2;
sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ];
memset( pSetFlags, 0, nFlagSize );
- const SwSectionNode* pSectNd;
sal_uInt16 n;
for( n = 0; n < mpSectionFmtTbl->size(); ++n )
- if( 0 != ( pSectNd = (*mpSectionFmtTbl)[ n ]->GetSectionNode( false ) ))
+ {
+ const SwSectionNode *const pSectNd = (*mpSectionFmtTbl)[ n ]->GetSectionNode( false );
+ if( pSectNd != nullptr )
{
const OUString rNm = pSectNd->GetSection().GetSectionName();
if (rNm.startsWith( aName ))
@@ -1415,21 +1416,27 @@ OUString SwDoc::GetUniqueSectionName( const OUString* pChkStr ) const
if( pChkStr && *pChkStr==rNm )
pChkStr = 0;
}
+ }
if( !pChkStr )
{
// Flagged all Numbers accordingly, so get the right Number
nNum = mpSectionFmtTbl->size();
for( n = 0; n < nFlagSize; ++n )
- if( 0xff != ( nTmp = pSetFlags[ n ] ))
+ {
+ auto nTmp = pSetFlags[ n ];
+ if( nTmp != 0xFF )
{
// Calculate the Number
nNum = n * 8;
while( nTmp & 1 )
- ++nNum, nTmp >>= 1;
+ {
+ ++nNum;
+ nTmp >>= 1;
+ }
break;
}
-
+ }
}
delete [] pSetFlags;
if( pChkStr )
More information about the Libreoffice-commits
mailing list