[Libreoffice-commits] core.git: 10 commits - sw/source

Matteo Casalin matteo.casalin at yahoo.com
Sat Jun 28 02:32:46 PDT 2014


 sw/source/core/undo/docundo.cxx     |    8 ++--
 sw/source/core/undo/rolbck.cxx      |    3 -
 sw/source/core/undo/unattr.cxx      |    2 -
 sw/source/core/undo/undel.cxx       |    4 +-
 sw/source/core/undo/undobj.cxx      |    5 +-
 sw/source/core/undo/unins.cxx       |    2 -
 sw/source/core/undo/unsort.cxx      |   16 +++-----
 sw/source/core/undo/untbl.cxx       |   67 +++++++++++++++++-------------------
 sw/source/ui/envelp/envfmt.cxx      |    2 -
 sw/source/uibase/inc/numfmtlb.hxx   |    2 -
 sw/source/uibase/inc/uitool.hxx     |    2 -
 sw/source/uibase/inc/wrtsh.hxx      |    2 -
 sw/source/uibase/shells/textsh1.cxx |    2 -
 sw/source/uibase/uiview/viewtab.cxx |    8 +---
 sw/source/uibase/utlui/numfmtlb.cxx |   14 +++----
 sw/source/uibase/utlui/tmplctrl.cxx |    5 +-
 sw/source/uibase/utlui/uiitems.cxx  |    2 -
 sw/source/uibase/utlui/uitool.cxx   |   16 +++-----
 sw/source/uibase/wrtsh/wrtsh2.cxx   |    2 -
 sw/source/uibase/wrtsh/wrtundo.cxx  |    3 -
 20 files changed, 76 insertions(+), 91 deletions(-)

New commits:
commit dc23ed9814e52d3bb052d7c21042ec11d087593c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Jun 28 11:04:32 2014 +0200

    sal_uInt16 to sal_(u)Int32
    
    Change-Id: I20c3715bcfb5212977699d661fd3acf1be28499f

diff --git a/sw/source/uibase/inc/numfmtlb.hxx b/sw/source/uibase/inc/numfmtlb.hxx
index a2abdfd..4af285e 100644
--- a/sw/source/uibase/inc/numfmtlb.hxx
+++ b/sw/source/uibase/inc/numfmtlb.hxx
@@ -28,7 +28,7 @@ class SwView;
 class SW_DLLPUBLIC NumFormatListBox : public ListBox
 {
     short               nCurrFormatType;
-    sal_uInt16              nStdEntry;
+    sal_Int32           nStdEntry;
     bool                bOneArea;
     sal_uLong               nDefFormat;
     SwView*             pVw;
diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx
index b3e3752..58ee538 100644
--- a/sw/source/uibase/utlui/numfmtlb.cxx
+++ b/sw/source/uibase/utlui/numfmtlb.cxx
@@ -206,7 +206,7 @@ void NumFormatListBox::SetFormatType(const short nFormatType)
         }
 
         const SvNumberformat* pFmt;
-        sal_uInt16 nPos, i = 0;
+        sal_Int32 i = 0;
         sal_uLong  nFormat;
         Color* pCol;
         double fVal = GetDefValue( nFormatType );
@@ -241,7 +241,7 @@ void NumFormatListBox::SetFormatType(const short nFormatType)
                 nFormat != nSysShortDateFmt &&
                 nFormat != nSysLongDateFmt)
             {
-                nPos = InsertEntry( sValue );
+                const sal_Int32 nPos = InsertEntry( sValue );
                 SetEntryData( nPos, (void*)nFormat );
 
                 if( nFormat == pFormatter->GetStandardFormat(
@@ -253,7 +253,7 @@ void NumFormatListBox::SetFormatType(const short nFormatType)
 
         if (!pOwnFormatter)
         {
-            nPos = InsertEntry(SW_RESSTR( STR_DEFINE_NUMBERFORMAT ));
+            const sal_Int32 nPos = InsertEntry(SW_RESSTR( STR_DEFINE_NUMBERFORMAT ));
             SetEntryData( nPos, NULL );
         }
 
@@ -290,7 +290,7 @@ void NumFormatListBox::SetDefFormat(const sal_uLong nDefFmt)
 
     sal_uLong nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefFmt, eCurLanguage);
 
-    for (sal_uInt16 i = 0; i < GetEntryCount(); i++)
+    for (sal_Int32 i = 0; i < GetEntryCount(); i++)
     {
         if (nFormat == (sal_uLong)GetEntryData(i))
         {
@@ -315,7 +315,7 @@ void NumFormatListBox::SetDefFormat(const sal_uLong nDefFmt)
         pFormatter->GetOutputString(fValue, nDefFmt, sValue, &pCol);
     }
 
-    sal_uInt16 nPos = 0;
+    sal_Int32 nPos = 0;
     while ((sal_uLong)GetEntryData(nPos) == ULONG_MAX)
         nPos++;
 
@@ -361,7 +361,7 @@ sal_uLong NumFormatListBox::GetFormat() const
 
 IMPL_LINK( NumFormatListBox, SelectHdl, ListBox *, pBox )
 {
-    sal_uInt16 nPos = pBox->GetSelectEntryPos();
+    const sal_Int32 nPos = pBox->GetSelectEntryPos();
     OUString sDefine(SW_RES( STR_DEFINE_NUMBERFORMAT ));
     SwView *pView = GetView();
 
@@ -410,7 +410,7 @@ IMPL_LINK( NumFormatListBox, SelectHdl, ListBox *, pBox )
             {
                 const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)pItem)->GetDelArray();
 
-                for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pItem)->GetDelCount(); i++ )
+                for ( sal_uInt32 i = 0; i < ((SvxNumberInfoItem*)pItem)->GetDelCount(); i++ )
                     pFormatter->DeleteEntry( pDelArr[i] );
             }
 
commit 53e3cfdcd35cb4bc934975d233b0e8d24c8af9b1
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Jun 28 10:48:29 2014 +0200

    Micro optimizations: pre-increment and constify
    
    Change-Id: Icefef960e1ecc0f6529e8f1b5f903c676b62e154

diff --git a/sw/source/uibase/utlui/tmplctrl.cxx b/sw/source/uibase/utlui/tmplctrl.cxx
index 0f774e3..d86eadb 100644
--- a/sw/source/uibase/utlui/tmplctrl.cxx
+++ b/sw/source/uibase/utlui/tmplctrl.cxx
@@ -110,13 +110,12 @@ void SwTemplateControl::Command( const CommandEvent& rCEvt )
                     SfxStyleSheetBase* pStyle = pPool->First();
                     while( pStyle )
                     {
-                        nCount++;
-                        aPop.InsertItem( nCount, pStyle->GetName() );
+                        aPop.InsertItem( ++nCount, pStyle->GetName() );
                         pStyle = pPool->Next();
                     }
 
                     aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel());
-                    sal_uInt16 nCurrId = aPop.GetCurId();
+                    const sal_uInt16 nCurrId = aPop.GetCurId();
                     if( nCurrId != USHRT_MAX)
                     {
                         // looks a bit awkward, but another way is not possible
commit 540eba75564e2c04d6a13677ac87d10907bd422d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Jun 28 10:37:21 2014 +0200

    sal_uInt16 to SwTwips and delay downcasts
    
    Change-Id: I4a8a05905a779bb8c7fad830c049d1e403d79711

diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index 072f619..bdc1992 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -282,7 +282,7 @@ IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
         const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
             pSh->GetView().GetCurShell()->GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
 
-        const sal_uInt16 nDefDist = ::GetTabDist( rDefTabs );
+        const sal_uInt16 nDefDist = static_cast<sal_uInt16>(::GetTabDist( rDefTabs ));
         SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
         aTmpSet.Put( aDefDistItem );
 
diff --git a/sw/source/uibase/inc/uitool.hxx b/sw/source/uibase/inc/uitool.hxx
index 1bfc6c8..8e2d596 100644
--- a/sw/source/uibase/inc/uitool.hxx
+++ b/sw/source/uibase/inc/uitool.hxx
@@ -74,7 +74,7 @@ SW_DLLPUBLIC void   MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs);
 //void  EraseDefTabs(SvxTabStopItem& rTabs);
 
 // determine space between 1st and 2nd element
-SW_DLLPUBLIC sal_uInt16     GetTabDist(const SvxTabStopItem& rTabs);
+SW_DLLPUBLIC SwTwips GetTabDist(const SvxTabStopItem& rTabs);
 
 // determine whether a Sfx-PageDesc combination exists in the set
 // and set this in the set and delete the transport items
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 90fcfb0..a01bd9f 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -915,7 +915,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
             const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
                             GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
 
-            sal_uInt16 nDefDist = ::GetTabDist( rDefTabs );
+            const sal_uInt16 nDefDist = static_cast<sal_uInt16>(::GetTabDist( rDefTabs ));
             SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
             aCoreSet.Put( aDefDistItem );
 
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index c47ed97..6a1b0f67 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -640,8 +640,7 @@ void SwView::ExecTabWin( SfxRequest& rReq )
             }
 
             // Populate with default tabs.
-            sal_uInt16 nDef = ::GetTabDist( rDefTabs );
-            ::MakeDefTabs( nDef, aTabStops );
+            ::MakeDefTabs( ::GetTabDist( rDefTabs ), aTabStops );
 
             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
             if( pColl && pColl->IsAutoUpdateFmt() )
@@ -720,8 +719,7 @@ void SwView::ExecTabWin( SfxRequest& rReq )
 
                     const SvxTabStopItem& rDefTabs =
                         (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
-                    sal_uInt16 nDef = ::GetTabDist(rDefTabs);
-                    ::MakeDefTabs( nDef, aTabStops );
+                    ::MakeDefTabs( ::GetTabDist(rDefTabs), aTabStops );
 
                     if( pColl && pColl->IsAutoUpdateFmt())
                     {
@@ -1209,7 +1207,7 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                                             rSh.GetDefault(RES_PARATR_TABSTOP);
 
                 OSL_ENSURE(m_pHRuler, "why is there no ruler?");
-                long nDefTabDist = ::GetTabDist(rDefTabs);
+                const long nDefTabDist = ::GetTabDist(rDefTabs);
                 m_pHRuler->SetDefTabDist( nDefTabDist );
                 m_pVRuler->SetDefTabDist( nDefTabDist );
                 ::lcl_EraseDefTabs(aTabStops);
diff --git a/sw/source/uibase/utlui/uiitems.cxx b/sw/source/uibase/utlui/uiitems.cxx
index 1a7e347..0490a93 100644
--- a/sw/source/uibase/utlui/uiitems.cxx
+++ b/sw/source/uibase/utlui/uiitems.cxx
@@ -76,7 +76,7 @@ SfxItemPresentation  SwPageFtnInfoItem::GetPresentation
         case SFX_ITEM_PRESENTATION_NAMELESS:
         case SFX_ITEM_PRESENTATION_COMPLETE:
         {
-            sal_uInt16 nHght = (sal_uInt16) GetPageFtnInfo().GetHeight();
+            const SwTwips nHght = GetPageFtnInfo().GetHeight();
             if ( nHght )
             {
                 rText = SW_RESSTR( STR_MAX_FTN_HEIGHT ) + " " +
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index 678ef99..1327f48 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -557,14 +557,9 @@ void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs)
 
 // Distance between two tabs
 
-sal_uInt16 GetTabDist(const SvxTabStopItem& rTabs)
+SwTwips GetTabDist(const SvxTabStopItem& rTabs)
 {
-    sal_uInt16 nDefDist;
-    if( rTabs.Count() )
-        nDefDist = (sal_uInt16)( rTabs[0].GetTabPos() );
-    else
-        nDefDist = 1134;     // 2cm
-    return nDefDist;
+    return rTabs.Count() ? rTabs[0].GetTabPos() : 1134; // 1134 = 2 cm
 }
 
 // Inquire if in the set is a Sfx-PageDesc combination present and return it.
commit ddd86d9ee9562ef781133abd0e6f5281d480a657
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Jun 28 10:01:51 2014 +0200

    sal_uInt16: constify and avoid unneed cast
    
    Change-Id: I78fe90f24805c5bca3548cf4c005d2c44574aa5c

diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index b3e6259..678ef99 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -259,7 +259,7 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
     {
         const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE);
 
-        sal_uInt16 nUse = (sal_uInt16)rPageItem.GetPageUsage();
+        const sal_uInt16 nUse = rPageItem.GetPageUsage();
         if(nUse)
             rPageDesc.SetUseOn( lcl_convertUseFromSvx((UseOnPage) nUse) );
         rPageDesc.SetLandscape(rPageItem.IsLandscape());
@@ -380,7 +380,8 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
             SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl );
             if( !pColl )
             {
-                sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+                const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
+                    rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
                 if( USHRT_MAX != nId )
                     pColl = rDoc.GetTxtCollFromPool( nId );
                 else
@@ -781,7 +782,7 @@ void SetApplyCharUnit(bool bApplyChar, bool bWeb)
 bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId )
 {
     bool bRet = false;
-    sal_uInt16 nItemCount = rMenu.GetItemCount();
+    const sal_uInt16 nItemCount = rMenu.GetItemCount();
     OUString sCommand;
     for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem)
     {
commit 4ad08a7008dbf8e2161249c95ce51c56e31ccee6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Jun 27 23:18:37 2014 +0200

    sal_uInt16 to short
    
    Change-Id: I6d39bc1a1132972eece99f1ea05cb25962805351

diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 36d2321..3b1896c 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -227,7 +227,7 @@ bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, bool bNextButton, OString* p
     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     if(pWindowState && !pWindowState->isEmpty())
         pDlg->SetWindowState(*pWindowState);
-    sal_uInt16 nRet = pDlg->Execute();
+    const short nRet = pDlg->Execute();
     if(pWindowState)
         *pWindowState = pDlg->GetWindowState();
     pDlg.reset();
commit 6f9f28f8e122fac74ffbc93814f30ca43cca92a0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Jun 27 22:48:17 2014 +0200

    Return value (sal_uInt16/size_t) is never used
    
    Change-Id: I6342a407878e24e671615b0c12a9badcfc774f37

diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 2d835ec..2ba573a 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -361,7 +361,7 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
     void    Do( DoType eDoType, sal_uInt16 nCnt = 1 );
     OUString  GetDoString( DoType eDoType ) const;
     OUString  GetRepeatString() const;
-    sal_uInt16  GetDoStrings( DoType eDoType, SfxStringListItem& rStrLstItem ) const;
+    void    GetDoStrings( DoType eDoType, SfxStringListItem& rStrLstItem ) const;
 
     // search and replace
     sal_uLong SearchPattern(const com::sun::star::util::SearchOptions& rSearchOpt,
diff --git a/sw/source/uibase/wrtsh/wrtundo.cxx b/sw/source/uibase/wrtsh/wrtundo.cxx
index e8851d1..9b70e25 100644
--- a/sw/source/uibase/wrtsh/wrtundo.cxx
+++ b/sw/source/uibase/wrtsh/wrtundo.cxx
@@ -114,7 +114,7 @@ OUString SwWrtShell::GetDoString( DoType eDoType ) const
     return  SvtResId( nResStr ).toString() + aUndoStr;
 }
 
-sal_uInt16 SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const
+void SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const
 {
     SwUndoComments_t comments;
     switch( eDoType )
@@ -135,7 +135,6 @@ sal_uInt16 SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs )
         buf += comments[i] + "\n";
     }
     rStrs.SetString(buf);
-    return static_cast<sal_uInt16>(comments.size());
 }
 
 OUString SwWrtShell::GetRepeatString() const
commit bd479676f275dd96df497a5098951ab45165335d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Jun 27 21:52:53 2014 +0200

    sal_uInt16 to size_t
    
    Change-Id: I8b045cf44b3e62616c8c3e0a896524af13310dd3

diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 845dfb7..f097c21 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -308,8 +308,8 @@ SwUndoComments_t UndoManager::GetUndoComments() const
             "GetUndoComments() called while in list action?");
 
     SwUndoComments_t ret;
-    sal_uInt16 const nUndoCount(SdrUndoManager::GetUndoActionCount(TopLevel));
-    for (sal_uInt16 n = 0; n < nUndoCount; ++n)
+    const size_t nUndoCount(SdrUndoManager::GetUndoActionCount(TopLevel));
+    for (size_t n = 0; n < nUndoCount; ++n)
     {
         OUString const comment(
                 SdrUndoManager::GetUndoActionComment(n, TopLevel));
@@ -352,8 +352,8 @@ SwUndoComments_t UndoManager::GetRedoComments() const
             "GetRedoComments() called while in list action?");
 
     SwUndoComments_t ret;
-    sal_uInt16 const nRedoCount(SdrUndoManager::GetRedoActionCount(TopLevel));
-    for (sal_uInt16 n = 0; n < nRedoCount; ++n)
+    const size_t nRedoCount(SdrUndoManager::GetRedoActionCount(TopLevel));
+    for (size_t n = 0; n < nRedoCount; ++n)
     {
         OUString const comment(
                 SdrUndoManager::GetRedoActionComment(n, TopLevel));
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index c5cfc34..44079f8 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -1127,8 +1127,7 @@ bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
         return false;
 
     SwHistoryHint * pHHt;
-    sal_uInt16 i;
-    for ( i = Count(); i > nStart ; )
+    for ( sal_uInt16 i = Count(); i > nStart ; )
     {
         pHHt = m_SwpHstry[ --i ];
         pHHt->SetInDoc( pDoc, false );
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index ed0ac1c..3df0fc9 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -924,7 +924,7 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc )
                     if ( COMPLETE_STRING != nCntnt )
                     {
                         const std::vector<sal_uInt16>& rArr = pHistoryHint->GetArr();
-                        for ( sal_uInt16 i = rArr.size(); i; )
+                        for ( size_t i = rArr.size(); i; )
                         {
                             if ( RES_TXTATR_FTN == rArr[ --i ] )
                             {
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index 7e1074c..cb31802 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -54,7 +54,7 @@ static void lcl_MakeAutoFrms( const SwFrmFmts& rSpzArr, sal_uLong nMovedIndex )
     {
         SwFlyFrmFmt* pFmt;
         const SwFmtAnchor* pAnchor;
-        for( sal_uInt16 n = 0; n < rSpzArr.size(); ++n )
+        for( size_t n = 0; n < rSpzArr.size(); ++n )
         {
             pFmt = (SwFlyFrmFmt*)rSpzArr[n];
             pAnchor = &pFmt->GetAnchor();
@@ -720,7 +720,7 @@ static void lcl_ReAnchorAtCntntFlyFrames( const SwFrmFmts& rSpzArr, SwPosition &
         SwFlyFrmFmt* pFmt;
         const SwFmtAnchor* pAnchor;
         const SwPosition* pAPos;
-        for( sal_uInt16 n = 0; n < rSpzArr.size(); ++n )
+        for( size_t n = 0; n < rSpzArr.size(); ++n )
         {
             pFmt = (SwFlyFrmFmt*)rSpzArr[n];
             pAnchor = &pFmt->GetAnchor();
commit 5247da4e4a821ca9c1336ffc9169b970cd547baf
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Jun 27 08:58:29 2014 +0200

    sal_uInt16 to sal_Int32 and remove/fix comments
    
    Change-Id: Icf49a339fb23d6217dd0bc41c9012233717ad808

diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index bb54674..7124511 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -64,7 +64,7 @@ public:
 #endif
 };
 
-// This class saves the Pam as sal_uInt16s and can recompose those into a PaM
+// This class saves the Pam as integers and can recompose those into a PaM
 SwUndRng::SwUndRng()
     : nSttNode( 0 ), nEndNode( 0 ), nSttCntnt( 0 ), nEndCntnt( 0 )
 {
@@ -343,7 +343,6 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx,
 
     const SwPosition* pStt = rPaM.Start(), *pEnd = rPaM.End();
 
-    // keep as sal_uInt16; the indices shift!
     sal_uLong nTmpMvNode = aPos.nNode.GetIndex();
 
     if( pCpyNd || pEndNdIdx )
@@ -696,7 +695,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark,
         if( pMarkAccess->getAllMarksCount() )
         {
 
-            for( sal_uInt16 n = 0; n < pMarkAccess->getAllMarksCount(); ++n )
+            for( sal_Int32 n = 0; n < pMarkAccess->getAllMarksCount(); ++n )
             {
                 // #i81002#
                 bool bSavePos = false;
commit 37953bfacc1cb47b80bc458f607c4da838ecce7d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Jun 27 08:34:25 2014 +0200

    sal_uInt16 to size_t
    
    Change-Id: Ib4a3f8401e2ddd4cb76c76c968151799c86b5845

diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index e18a02e..298a1e4 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -170,7 +170,7 @@ bool SwUndoInsert::CanGrouping( const SwPosition& rPos )
                 SwRedlineData aRData( nsRedlineType_t::REDLINE_INSERT, rDoc.GetRedlineAuthor() );
                 const SwIndexReg* pIReg = rPos.nContent.GetIdxReg();
                 SwIndex* pIdx;
-                for( sal_uInt16 i = 0; i < rTbl.size(); ++i )
+                for( size_t i = 0; i < rTbl.size(); ++i )
                 {
                     SwRangeRedline* pRedl = rTbl[ i ];
                     if( pIReg == (pIdx = &pRedl->End()->nContent)->GetIdxReg() &&
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index 5316daa..fec1483 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -94,7 +94,7 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
         const SwTable& rTbl = pTblNd->GetTable();
 
         SwMovedBoxes aMovedList;
-        for( sal_uInt16 i=0; i < aSortList.size(); i++)
+        for( size_t i=0; i < aSortList.size(); i++)
         {
             const SwTableBox* pSource = rTbl.GetTblBox(
                     *aSortList[i].SORT_TXT_TBL.TBL.pSource );
@@ -124,10 +124,9 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
         // create index for (sorted) positions
         // The IndexList must be created based on (asc.) sorted SourcePosition.
         SwUndoSortList aIdxList;
-        sal_uInt16 i;
 
-        for( i = 0; i < aSortList.size(); ++i)
-            for( sal_uInt16 ii=0; ii < aSortList.size(); ++ii )
+        for( size_t i = 0; i < aSortList.size(); ++i)
+            for( size_t ii=0; ii < aSortList.size(); ++ii )
                 if( aSortList[ii].SORT_TXT_TBL.TXT.nSource == nSttNode + i )
                 {
                     SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
@@ -136,7 +135,7 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
                     break;
                 }
 
-        for(i=0; i < aSortList.size(); ++i)
+        for(size_t i=0; i < aSortList.size(); ++i)
         {
             SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i );
             SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
@@ -170,7 +169,7 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
         const SwTable& rTbl = pTblNd->GetTable();
 
         SwMovedBoxes aMovedList;
-        for(sal_uInt16 i=0; i < aSortList.size(); ++i)
+        for(size_t i=0; i < aSortList.size(); ++i)
         {
             const SwTableBox* pSource = rTbl.GetTblBox(
                     *aSortList[i].SORT_TXT_TBL.TBL.pSource );
@@ -203,16 +202,15 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
         RemoveIdxFromRange(rPam, true);
 
         SwUndoSortList aIdxList;
-        sal_uInt16 i;
 
-        for( i = 0; i < aSortList.size(); ++i)
+        for( size_t i = 0; i < aSortList.size(); ++i)
         {   // current position is starting point
             SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
                     aSortList[i].SORT_TXT_TBL.TXT.nSource);
             aIdxList.insert( aIdxList.begin() + i, pIdx );
         }
 
-        for(i=0; i < aSortList.size(); ++i)
+        for( size_t i = 0; i < aSortList.size(); ++i)
         {
             SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i);
             SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
commit bd16f1cebc2cf4980ef1b7eb383807b785d6c318
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Jun 26 23:39:35 2014 +0200

    sal_uInt16 to size_t
    
    Change-Id: I5fe887cdb800a5f5cc6f6277b52a5f02c1b9bb84

diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 54ce92d..47154c9 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -414,7 +414,7 @@ SwUndoTblToTxt::SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh )
     sal_uLong nTblStt = pTblNd->GetIndex(), nTblEnd = pTblNd->EndOfSectionIndex();
 
     const SwFrmFmts& rFrmFmtTbl = *pTblNd->GetDoc()->GetSpzFrmFmts();
-    for( sal_uInt16 n = 0; n < rFrmFmtTbl.size(); ++n )
+    for( size_t n = 0; n < rFrmFmtTbl.size(); ++n )
     {
         SwFrmFmt* pFmt = rFrmFmtTbl[ n ];
         SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
@@ -541,7 +541,7 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
     pTblNd->GetTable().GetTabLines().insert( pTblNd->GetTable().GetTabLines().begin(), pLine );
 
     const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
-    for( sal_uInt16 n = rSavedData.size(); n; )
+    for( size_t n = rSavedData.size(); n; )
     {
         const SwTblToTxtSave* pSave = &rSavedData[ --n ];
         // if the start node was merged with last from prev. cell,
@@ -730,7 +730,7 @@ void SwUndoTxtToTbl::UndoImpl(::sw::UndoRedoContext & rContext)
     {
         pTNd->DelFrms();
         SwTable& rTbl = pTNd->GetTable();
-        for( sal_uInt16 n = pDelBoxes->size(); n; )
+        for( size_t n = pDelBoxes->size(); n; )
         {
             SwTableBox* pBox = rTbl.GetTblBox( (*pDelBoxes)[ --n ] );
             if( pBox )
@@ -920,8 +920,6 @@ sal_uInt16 _SaveTable::AddFmt( SwFrmFmt* pFmt, bool bIsLine )
 
 void _SaveTable::RestoreAttr( SwTable& rTbl, bool bMdfyBox )
 {
-    sal_uInt16 n;
-
     bModifyBox = bMdfyBox;
 
     // first, get back attributes of TableFrmFormat
@@ -947,15 +945,15 @@ void _SaveTable::RestoreAttr( SwTable& rTbl, bool bMdfyBox )
 
     // fill FrmFmts with defaults (0)
     pFmt = 0;
-    for( n = aSets.size(); n; --n )
+    for( size_t n = aSets.size(); n; --n )
         aFrmFmts.push_back( pFmt );
 
-    sal_uInt16 nLnCnt = nLineCount;
-    if( USHRT_MAX == nLnCnt )
-        nLnCnt = rTbl.GetTabLines().size();
+    const size_t nLnCnt = ( USHRT_MAX == nLineCount )
+        ? rTbl.GetTabLines().size()
+        : nLineCount;
 
     _SaveLine* pLn = pLine;
-    for( n = 0; n < nLnCnt; ++n, pLn = pLn->pNext )
+    for( size_t n = 0; n < nLnCnt; ++n, pLn = pLn->pNext )
     {
         if( !pLn )
         {
@@ -978,8 +976,6 @@ void _SaveTable::SaveCntntAttrs( SwDoc* pDoc )
 void _SaveTable::CreateNew( SwTable& rTbl, bool bCreateFrms,
                             bool bRestoreChart )
 {
-    sal_uInt16 n;
-
     _FndBox aTmpBox( 0, 0 );
     aTmpBox.DelFrms( rTbl );
 
@@ -1000,20 +996,21 @@ void _SaveTable::CreateNew( SwTable& rTbl, bool bCreateFrms,
 
     // fill FrmFmts with defaults (0)
     pFmt = 0;
-    for( n = aSets.size(); n; --n )
+    for( size_t n = aSets.size(); n; --n )
         aFrmFmts.push_back( pFmt );
 
     pLine->CreateNew( rTbl, aParent, *this );
     aFrmFmts.clear();
 
     // add new lines, delete old ones
-    sal_uInt16 nOldLines = nLineCount;
-    if( USHRT_MAX == nLineCount )
-        nOldLines = rTbl.GetTabLines().size();
+    const size_t nOldLines = ( USHRT_MAX == nLineCount )
+        ? rTbl.GetTabLines().size()
+        : nLineCount;
 
     SwDoc *pDoc = rTbl.GetFrmFmt()->GetDoc();
     SwChartDataProvider *pPCD = pDoc->GetChartDataProvider();
-    for( n = 0; n < aParent.GetTabLines().size(); ++n )
+    size_t n = 0;
+    for( ; n < aParent.GetTabLines().size(); ++n )
     {
         SwTableLine* pLn = aParent.GetTabLines()[ n ];
         pLn->SetUpper( 0 );
@@ -1023,8 +1020,8 @@ void _SaveTable::CreateNew( SwTable& rTbl, bool bCreateFrms,
 
             // TL_CHART2: notify chart about boxes to be removed
             const SwTableBoxes &rBoxes = pOld->GetTabBoxes();
-            sal_uInt16 nBoxes = rBoxes.size();
-            for (sal_uInt16 k = 0;  k < nBoxes;  ++k)
+            const size_t nBoxes = rBoxes.size();
+            for (size_t k = 0; k < nBoxes;  ++k)
             {
                 SwTableBox *pBox = rBoxes[k];
                 if (pPCD)
@@ -1041,11 +1038,11 @@ void _SaveTable::CreateNew( SwTable& rTbl, bool bCreateFrms,
     if( n < nOldLines )
     {
         // remove remaining lines...
-        for (sal_uInt16 k1 = 0; k1 < nOldLines - n;  ++k1)
+        for (size_t k1 = 0; k1 < nOldLines - n; ++k1)
         {
             const SwTableBoxes &rBoxes = rTbl.GetTabLines()[n + k1]->GetTabBoxes();
-            sal_uInt16 nBoxes = rBoxes.size();
-            for (sal_uInt16 k2 = 0;  k2 < nBoxes;  ++k2)
+            const size_t nBoxes = rBoxes.size();
+            for (size_t k2 = 0; k2 < nBoxes; ++k2)
             {
                 SwTableBox *pBox = rBoxes[k2];
                 // TL_CHART2: notify chart about boxes to be removed
@@ -1133,7 +1130,7 @@ _SaveLine::_SaveLine( _SaveLine* pPrev, const SwTableLine& rLine, _SaveTable& rS
 
     pBox = new _SaveBox( 0, *rLine.GetTabBoxes()[ 0 ], rSTbl );
     _SaveBox* pBx = pBox;
-    for( sal_uInt16 n = 1; n < rLine.GetTabBoxes().size(); ++n )
+    for( size_t n = 1; n < rLine.GetTabBoxes().size(); ++n )
         pBx = new _SaveBox( pBx, *rLine.GetTabBoxes()[ n ], rSTbl );
 }
 
@@ -1148,7 +1145,7 @@ void _SaveLine::RestoreAttr( SwTableLine& rLine, _SaveTable& rSTbl )
     rSTbl.NewFrmFmt( &rLine, 0, nItemSet, rLine.GetFrmFmt() );
 
     _SaveBox* pBx = pBox;
-    for( sal_uInt16 n = 0; n < rLine.GetTabBoxes().size(); ++n, pBx = pBx->pNext )
+    for( size_t n = 0; n < rLine.GetTabBoxes().size(); ++n, pBx = pBx->pNext )
     {
         if( !pBx )
         {
@@ -1214,7 +1211,7 @@ _SaveBox::_SaveBox( _SaveBox* pPrev, const SwTableBox& rBox, _SaveTable& rSTbl )
         Ptrs.pLine = new _SaveLine( 0, *rBox.GetTabLines()[ 0 ], rSTbl );
 
         _SaveLine* pLn = Ptrs.pLine;
-        for( sal_uInt16 n = 1; n < rBox.GetTabLines().size(); ++n )
+        for( size_t n = 1; n < rBox.GetTabLines().size(); ++n )
             pLn = new _SaveLine( pLn, *rBox.GetTabLines()[ n ], rSTbl );
     }
 }
@@ -1241,7 +1238,7 @@ void _SaveBox::RestoreAttr( SwTableBox& rBox, _SaveTable& rSTbl )
         else
         {
             _SaveLine* pLn = Ptrs.pLine;
-            for( sal_uInt16 n = 0; n < rBox.GetTabLines().size(); ++n, pLn = pLn->pNext )
+            for( size_t n = 0; n < rBox.GetTabLines().size(); ++n, pLn = pLn->pNext )
             {
                 if( !pLn )
                 {
@@ -1697,7 +1694,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
         SwTableBoxes& rLnBoxes = pCpyBox->GetUpper()->GetTabBoxes();
 
         // restore sections
-        for( sal_uInt16 n = pDelSects->size(); n; )
+        for( size_t n = pDelSects->size(); n; )
         {
             SwUndoSaveSection* pSave = &(*pDelSects)[ --n ];
             pSave->RestoreSection( &rDoc, &aIdx, SwTableBoxStartNode );
@@ -1790,7 +1787,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
     }
 
     // Remove boxes from table structure
-    for( sal_uInt16 n = 0; n < aDelBoxes.size(); ++n )
+    for( size_t n = 0; n < aDelBoxes.size(); ++n )
     {
         SwTableBox* pCurrBox = aDelBoxes[n];
         SwTableBoxes* pTBoxes = &pCurrBox->GetUpper()->GetTabBoxes();
@@ -1963,7 +1960,6 @@ CHECKTABLE(pTblNd->GetTable())
 
     SwSelBoxes aSelBoxes;
     SwTxtFmtColl* pColl = rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
-    sal_uInt16 n;
 
     std::set<sal_uLong>::iterator it;
     for (it = m_Boxes.begin(); it != m_Boxes.end(); ++it)
@@ -1983,7 +1979,7 @@ CHECKTABLE(pTblNd->GetTable())
     SwChartDataProvider *pPCD = rDoc.GetChartDataProvider();
     // 2. deleted the inserted boxes
     // delete nodes (from last to first)
-    for( n = aNewSttNds.size(); n; )
+    for( size_t n = aNewSttNds.size(); n; )
     {
         // remove box from table structure
         sal_uLong nIdx = aNewSttNds[ --n ];
@@ -1999,7 +1995,7 @@ CHECKTABLE(pTblNd->GetTable())
                     *pBox->GetSttNd()->EndOfSectionNode() ), pColl );
 
             // this was the separator -> restore moved ones
-            for( sal_uInt16 i = pMoves->size(); i; )
+            for( size_t i = pMoves->size(); i; )
             {
                 SwTxtNode* pTxtNd = 0;
                 sal_Int32 nDelPos = 0;
@@ -2429,7 +2425,7 @@ void SwUndoTblCpyTbl::UndoImpl(::sw::UndoRedoContext & rContext)
     _DEBUG_REDLINE( &rDoc )
 
     SwTableNode* pTblNd = 0;
-    for( sal_uInt16 n = pArr->size(); n; )
+    for( size_t n = pArr->size(); n; )
     {
         _UndoTblCpyTbl_Entry* pEntry = &(*pArr)[ --n ];
         sal_uLong nSttPos = pEntry->nBoxIdx + pEntry->nOffset;
@@ -2580,7 +2576,7 @@ void SwUndoTblCpyTbl::RedoImpl(::sw::UndoRedoContext & rContext)
     }
 
     SwTableNode* pTblNd = 0;
-    for( sal_uInt16 n = 0; n < pArr->size(); ++n )
+    for( size_t n = 0; n < pArr->size(); ++n )
     {
         _UndoTblCpyTbl_Entry* pEntry = &(*pArr)[ n ];
         sal_uLong nSttPos = pEntry->nBoxIdx + pEntry->nOffset;
@@ -3104,13 +3100,14 @@ void SwUndoMergeTbl::SaveFormula( SwHistory& rHistory )
 
 void InsertSort( std::vector<sal_uInt16>& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos )
 {
-    sal_uInt16 nO   = rArr.size(), nM, nU = 0;
+    size_t nO = rArr.size();
+    size_t nU = 0;
     if( nO > 0 )
     {
         nO--;
         while( nU <= nO )
         {
-            nM = nU + ( nO - nU ) / 2;
+            const size_t nM = nU + ( nO - nU ) / 2;
             if ( rArr[nM] == nIdx )
             {
                 OSL_FAIL( "Index already exists. This should never happen." );


More information about the Libreoffice-commits mailing list