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

Matteo Casalin matteo.casalin at yahoo.com
Sun Mar 30 07:38:57 PDT 2014


 sw/source/core/uibase/inc/frmpage.hxx  |   24 +-
 sw/source/core/uibase/inc/uitool.hxx   |    2 
 sw/source/core/uibase/utlui/uitool.cxx |   35 +--
 sw/source/ui/fldui/changedb.cxx        |   36 +---
 sw/source/ui/fldui/flddb.cxx           |   57 ++----
 sw/source/ui/fldui/flddinf.cxx         |   24 +-
 sw/source/ui/fldui/flddok.cxx          |   49 ++---
 sw/source/ui/fldui/fldfunc.cxx         |   87 ++++-----
 sw/source/ui/fldui/fldref.cxx          |   89 +++------
 sw/source/ui/fldui/fldref.hxx          |    4 
 sw/source/ui/fldui/fldvar.cxx          |   20 +-
 sw/source/ui/fmtui/tmpdlg.cxx          |    2 
 sw/source/ui/frmdlg/column.cxx         |  159 +++++++----------
 sw/source/ui/frmdlg/cption.cxx         |   28 +--
 sw/source/ui/frmdlg/frmdlg.cxx         |    2 
 sw/source/ui/frmdlg/frmpage.cxx        |  295 +++++++++++++++------------------
 sw/source/ui/index/cntex.cxx           |   18 --
 sw/source/ui/index/cnttab.cxx          |  229 ++++++++-----------------
 18 files changed, 493 insertions(+), 667 deletions(-)

New commits:
commit b5177c6e0415e8e129563087b6e5251d4a715a57
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 15:21:08 2014 +0200

    OUString: avoid temporaries and constify
    
    Change-Id: Id6729de5105bb6cd4119a2ac8cf1fead6f8bb4ff

diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx
index eb9f93e..d0fdd00 100644
--- a/sw/source/ui/fldui/changedb.cxx
+++ b/sw/source/ui/fldui/changedb.cxx
@@ -94,9 +94,7 @@ void SwChangeDBDlg::FillDBPopup()
     Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
 
     const SwDBData& rDBData = pSh->GetDBData();
-    OUString sDBName(rDBData.sDataSource);
-    OUString sTableName(rDBData.sCommand);
-    m_pAvailDBTLB->Select(sDBName, sTableName, aEmptyOUStr);
+    m_pAvailDBTLB->Select(rDBData.sDataSource, rDBData.sCommand, aEmptyOUStr);
 
     std::vector<OUString> aAllDBNames;
 
@@ -118,9 +116,7 @@ void SwChangeDBDlg::FillDBPopup()
 
     for(size_t k = 0; k < nCount; k++)
     {
-        sDBName = aDBNameList[k];
-        sDBName = sDBName.getToken(0, ';');
-        pLast = Insert(sDBName);
+        pLast = Insert(aDBNameList[k].getToken(0, ';'));
         if (!pFirst)
             pFirst = pLast;
     }
@@ -135,8 +131,8 @@ void SwChangeDBDlg::FillDBPopup()
 
 SvTreeListEntry* SwChangeDBDlg::Insert(const OUString& rDBName)
 {
-    OUString sDBName(rDBName.getToken(0, DB_DELIM));
-    OUString sTableName(rDBName.getToken(1, DB_DELIM));
+    const OUString sDBName(rDBName.getToken(0, DB_DELIM));
+    const OUString sTableName(rDBName.getToken(1, DB_DELIM));
     sal_IntPtr nCommandType = rDBName.getToken(2, DB_DELIM).toInt32();
     SvTreeListEntry* pParent;
     SvTreeListEntry* pChild;
@@ -252,20 +248,20 @@ IMPL_LINK_NOARG(SwChangeDBDlg, TreeSelectHdl)
  --------------------------------------------------------------------*/
 void SwChangeDBDlg::ShowDBName(const SwDBData& rDBData)
 {
-    OUString sTmp(rDBData.sDataSource);
-    sTmp += ".";
-    sTmp += rDBData.sCommand;
-
-    OUString sName(sTmp.replaceAll("~", "~~"));
-    if (sName == ".") //empty
-        sName = SW_RESSTR(SW_STR_NONE);
-
-    m_pDocDBNameFT->SetText(sName);
+    if (rDBData.sDataSource.isEmpty() && rDBData.sCommand.isEmpty())
+    {
+        m_pDocDBNameFT->SetText(SW_RESSTR(SW_STR_NONE));
+    }
+    else
+    {
+        const OUString sName(rDBData.sDataSource + "." + rDBData.sCommand);
+        m_pDocDBNameFT->SetText(sName.replaceAll("~", "~~"));
+    }
 }
 
 IMPL_LINK_NOARG(SwChangeDBDlg, AddDBHdl)
 {
-    OUString sNewDB = SwNewDBMgr::LoadAndRegisterDataSource();
+    const OUString sNewDB = SwNewDBMgr::LoadAndRegisterDataSource();
     if (!sNewDB.isEmpty())
         m_pAvailDBTLB->AddDataSource(sNewDB);
     return 0;
commit edd0f4792f099da64239fdc2918dce1f5d5653b4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 15:04:33 2014 +0200

    sal_uInt16 to sal_uLong
    
    Change-Id: I0b854237f52320d8ec98d9278a5552a375aad463

diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx
index f304d90..eb9f93e 100644
--- a/sw/source/ui/fldui/changedb.cxx
+++ b/sw/source/ui/fldui/changedb.cxx
@@ -141,8 +141,8 @@ SvTreeListEntry* SwChangeDBDlg::Insert(const OUString& rDBName)
     SvTreeListEntry* pParent;
     SvTreeListEntry* pChild;
 
-    sal_uInt16 nParent = 0;
-    sal_uInt16 nChild = 0;
+    sal_uLong nParent = 0;
+    sal_uLong nChild = 0;
 
     Image aTableImg = aImageList.GetImage(IMG_DBTABLE);
     Image aDBImg = aImageList.GetImage(IMG_DB);
commit 98d2b568f43410da83c176c97bd3f539d2079ab6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 14:58:04 2014 +0200

    OUString: constify and avoid some temporaries
    
    Change-Id: Ic5a86644dc0215da5c48c795abb51ee664298d57

diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index 0a3c569..f62a2db 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -150,8 +150,7 @@ void SwFldDBPage::Reset(const SfxItemSet&)
         OUString sUserData = GetUserData();
         if (sUserData.getToken(0, ';').equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
         {
-            OUString sVal = sUserData.getToken(1, ';');
-            const sal_uInt16 nVal = (sal_uInt16)sVal.toInt32();
+            const sal_uInt16 nVal = (sal_uInt16)sUserData.getToken(1, ';').toInt32();
             if(nVal != USHRT_MAX)
             {
                 for (sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); ++i)
@@ -369,7 +368,7 @@ IMPL_LINK( SwFldDBPage, TypeHdl, ListBox *, pBox )
         {
             m_pValueED->SetText(aEmptyOUStr);
             if (bCond)
-                m_pConditionED->SetText(OUString("TRUE"));
+                m_pConditionED->SetText("TRUE");
             else
                 m_pConditionED->SetText(aEmptyOUStr);
         }
@@ -480,13 +479,10 @@ IMPL_LINK_NOARG(SwFldDBPage, ModifyHdl)
 
 void    SwFldDBPage::FillUserData()
 {
-    OUString sData(USER_DATA_VERSION);
-    sData += ";";
     const sal_Int32 nEntryPos = m_pTypeLB->GetSelectEntryPos();
     const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
         ? USHRT_MAX : (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData( nEntryPos );
-    sData += OUString::number( nTypeSel );
-    SetUserData(sData);
+    SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
 }
 
 void SwFldDBPage::ActivateMailMergeAddress()
commit 1fb58ff7909269993f4e1459af6b96ef16f44c5f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 14:39:08 2014 +0200

    Constify, reduce scope, use proper types and avoid some casts
    
    Change-Id: Ia329afd86f4435122d487bd1146c1b9b52e11144

diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index 2f77536..0a3c569 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -82,30 +82,28 @@ void SwFldDBPage::Reset(const SfxItemSet&)
     Init(); // Allgemeine initialisierung
 
     m_pTypeLB->SetUpdateMode(false);
-    sal_Int32 nOldPos = m_pTypeLB->GetSelectEntryPos();
+    const sal_Int32 nOldPos = m_pTypeLB->GetSelectEntryPos();
     m_sOldDBName = m_pDatabaseTLB->GetDBName(m_sOldTableName, m_sOldColumnName);
 
     m_pTypeLB->Clear();
 
-    sal_Int32 nPos;
-    sal_uInt16 nTypeId, i;
-
     if (!IsFldEdit())
     {
         // initialise TypeListBox
         const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
 
-        for(i = rRg.nStart; i < rRg.nEnd; ++i)
+        for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i)
         {
-            nTypeId = GetFldMgr().GetTypeId(i);
-            nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(i));
+            const sal_uInt16 nTypeId = GetFldMgr().GetTypeId(i);
+            const sal_Int32 nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(i));
             m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
         }
     }
     else
     {
-        nTypeId = GetCurField()->GetTypeId();
-        nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
+        const sal_uInt16 nTypeId = GetCurField()->GetTypeId();
+        const sal_Int32 nPos = m_pTypeLB->InsertEntry(
+            GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
         m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     }
 
@@ -115,11 +113,11 @@ void SwFldDBPage::Reset(const SfxItemSet&)
 
     m_pFormatLB->Clear();
 
-    sal_uInt16 nSize = GetFldMgr().GetFormatCount(TYP_DBSETNUMBERFLD, false, IsFldDlgHtmlMode());
-    for( i = 0; i < nSize; ++i )
+    const sal_uInt16 nSize = GetFldMgr().GetFormatCount(TYP_DBSETNUMBERFLD, false, IsFldDlgHtmlMode());
+    for( sal_uInt16 i = 0; i < nSize; ++i )
     {
-        sal_Int32 nEntryPos = m_pFormatLB->InsertEntry(GetFldMgr().GetFormatStr(TYP_DBSETNUMBERFLD, i));
-        sal_uInt16 nFmtId = GetFldMgr().GetFormatId( TYP_DBSETNUMBERFLD, i );
+        const sal_Int32 nEntryPos = m_pFormatLB->InsertEntry(GetFldMgr().GetFormatStr(TYP_DBSETNUMBERFLD, i));
+        const sal_uInt16 nFmtId = GetFldMgr().GetFormatId( TYP_DBSETNUMBERFLD, i );
         m_pFormatLB->SetEntryData( nEntryPos, reinterpret_cast<void*>(nFmtId) );
         if( SVX_NUM_ARABIC == nFmtId )
             m_pFormatLB->SelectEntryPos( nEntryPos );
@@ -153,10 +151,10 @@ void SwFldDBPage::Reset(const SfxItemSet&)
         if (sUserData.getToken(0, ';').equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
         {
             OUString sVal = sUserData.getToken(1, ';');
-            sal_uInt16 nVal = (sal_uInt16)sVal.toInt32();
+            const sal_uInt16 nVal = (sal_uInt16)sVal.toInt32();
             if(nVal != USHRT_MAX)
             {
-                for(i = 0; i < m_pTypeLB->GetEntryCount(); i++)
+                for (sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); ++i)
                     if(nVal == (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(i))
                     {
                         m_pTypeLB->SelectEntryPos(i);
@@ -199,7 +197,7 @@ bool SwFldDBPage::FillItemSet(SfxItemSet& )
 
     if(!aData.sDataSource.isEmpty())       // without database no new field command
     {
-        sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+        const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
         sal_uLong nFormat = 0;
         sal_uInt16 nSubType = 0;
 
@@ -225,7 +223,7 @@ bool SwFldDBPage::FillItemSet(SfxItemSet& )
             break;
 
         case TYP_DBSETNUMBERFLD:
-            nFormat = (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(
+            nFormat = (sal_uLong)m_pFormatLB->GetEntryData(
                                 m_pFormatLB->GetSelectEntryPos() );
             break;
         }
@@ -280,7 +278,7 @@ IMPL_LINK( SwFldDBPage, TypeHdl, ListBox *, pBox )
         if(!pSh)
             pSh = ::GetActiveWrtShell();
         sal_Bool bCond = sal_False, bSetNo = sal_False, bFormat = sal_False, bDBFormat = sal_False;
-        sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+        const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
         m_pDatabaseTLB->ShowColumns(nTypeId == TYP_DBFLD);
 
@@ -346,7 +344,7 @@ IMPL_LINK( SwFldDBPage, TypeHdl, ListBox *, pBox )
                 if( IsFldEdit() )
                 {
                     for( sal_Int32 nI = m_pFormatLB->GetEntryCount(); nI; )
-                        if( GetCurField()->GetFormat() == (sal_uInt16)(sal_uLong)
+                        if( GetCurField()->GetFormat() == (sal_uLong)
                             m_pFormatLB->GetEntryData( --nI ))
                         {
                             m_pFormatLB->SelectEntryPos( nI );
@@ -393,7 +391,7 @@ IMPL_LINK( SwFldDBPage, NumSelectHdl, NumFormatListBox *, pLB )
 void SwFldDBPage::CheckInsert()
 {
     bool bInsert = true;
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     SvTreeListEntry* pEntry = m_pDatabaseTLB->GetCurEntry();
 
@@ -425,7 +423,7 @@ IMPL_LINK( SwFldDBPage, TreeSelectHdl, SvTreeListBox *, pBox )
     SvTreeListEntry* pEntry = pColEntry = pBox->GetCurEntry();
     if (pEntry)
     {
-        sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+        const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
         pEntry = m_pDatabaseTLB->GetParent(pEntry);
 
@@ -484,12 +482,9 @@ void    SwFldDBPage::FillUserData()
 {
     OUString sData(USER_DATA_VERSION);
     sData += ";";
-    sal_Int32 nTypeSel = m_pTypeLB->GetSelectEntryPos();
-
-    if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
-        nTypeSel = USHRT_MAX;
-    else
-        nTypeSel = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData( nTypeSel );
+    const sal_Int32 nEntryPos = m_pTypeLB->GetSelectEntryPos();
+    const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
+        ? USHRT_MAX : (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData( nEntryPos );
     sData += OUString::number( nTypeSel );
     SetUserData(sData);
 }
commit e31de5159b43a15fab9fb3319d3fd427db4a81ae
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 14:18:43 2014 +0200

    OUString: constify, avoid concatenated appends, use != or ==
    
    Change-Id: I7e3d2b1afe2c16e9d110b3d83d854de113bc5849

diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index 06917d5..f2d297b 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -123,11 +123,10 @@ void SwFldDokInfPage::Reset(const SfxItemSet& )
     }
 
     sal_Int32 nSelEntryData = LISTBOX_ENTRY_NOTFOUND;
-    OUString sUserData = GetUserData();
+    const OUString sUserData = GetUserData();
     if (sUserData.getToken(0, ';').equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
     {
-        OUString sVal = sUserData.getToken(1, ';');
-        nSelEntryData = sVal.toInt32();
+        nSelEntryData = sUserData.getToken(1, ';').toInt32();
     }
 
     std::vector<OUString> aLst;
@@ -150,9 +149,9 @@ void SwFldDokInfPage::Reset(const SfxItemSet& )
 
                         for (sal_Int32 n=0; n < rProperties.getLength(); n++)
                         {
-                            OUString sEntry = rProperties[n].Name;
+                            const OUString sEntry = rProperties[n].Name;
                             pEntry = m_pTypeTLB->InsertEntry(sEntry, pInfo);
-                            if(m_sOldCustomFieldName.equals( sEntry ))
+                            if (m_sOldCustomFieldName == sEntry)
                             {
                                 pSelEntry = pEntry;
                                 m_pTypeTLB->Expand( pInfo );
@@ -245,7 +244,7 @@ IMPL_LINK_NOARG(SwFldDokInfPage, SubTypeHdl)
                 if( nSubType == DI_CUSTOM )
                 {
                     //find out which type the custom field has - for a start set to DATE format
-                    OUString sName = m_pTypeTLB->GetEntryText(pSelEntry);
+                    const OUString sName = m_pTypeTLB->GetEntryText(pSelEntry);
                     try
                     {
                         uno::Any aVal = xCustomPropertySet->getPropertyValue( sName );
@@ -440,7 +439,7 @@ bool SwFldDokInfPage::FillItemSet(SfxItemSet& )
 
     if (!IsFldEdit() || nOldSel != m_pSelectionLB->GetSelectEntryPos() ||
         nOldFormat != nFormat || m_pFixedCB->GetState() != m_pFixedCB->GetSavedValue()
-        || (DI_CUSTOM == nSubType && !aName.equals( m_sOldCustomFieldName )))
+        || (DI_CUSTOM == nSubType && aName != m_sOldCustomFieldName ))
     {
         InsertFld(TYP_DOCINFOFLD, nSubType, aName, aEmptyOUStr, nFormat,
                 ' ', m_pFormatLB->IsAutomaticLanguage());
@@ -462,12 +461,9 @@ sal_uInt16 SwFldDokInfPage::GetGroup()
 
 void    SwFldDokInfPage::FillUserData()
 {
-    OUString sData(USER_DATA_VERSION);
-    sData += ";";
     SvTreeListEntry* pEntry = m_pTypeTLB->FirstSelected();
     sal_uInt16 nTypeSel = pEntry ? sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(pEntry->GetUserData())) : USHRT_MAX;
-    sData += OUString::number( nTypeSel );
-    SetUserData(sData);
+    SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 27f07b6caf0eeb4f5c84f0914092e8b08a2155ec
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 14:10:51 2014 +0200

    Remove unneeded variables
    
    Change-Id: I58efa026e1a14ca1f0cf9c9cc3bc5aa3eeb350a2

diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index 18e2393..06917d5 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -99,7 +99,6 @@ void SwFldDokInfPage::Reset(const SfxItemSet& )
     pSelEntry = 0;
 
     // display SubTypes in TypeLB
-    sal_uInt16 nTypeId = TYP_DOCINFOFLD;
     SvTreeListEntry* pEntry = 0;
 
     SvTreeListEntry* pInfo = 0;
@@ -132,7 +131,7 @@ void SwFldDokInfPage::Reset(const SfxItemSet& )
     }
 
     std::vector<OUString> aLst;
-    GetFldMgr().GetSubTypes(nTypeId, aLst);
+    GetFldMgr().GetSubTypes(TYP_DOCINFOFLD, aLst);
     for(size_t i = 0; i < aLst.size(); ++i)
     {
         if (!IsFldEdit() || nSubType == i)
@@ -419,7 +418,6 @@ bool SwFldDokInfPage::FillItemSet(SfxItemSet& )
     if (!pSelEntry || (sal_uInt16)(sal_uLong)pSelEntry->GetUserData() == USHRT_MAX)
         return false;
 
-    sal_uInt16 nTypeId = TYP_DOCINFOFLD;
     sal_uInt16 nSubType = (sal_uInt16)(sal_uLong)pSelEntry->GetUserData();
 
     sal_uLong nFormat = 0;
@@ -444,7 +442,7 @@ bool SwFldDokInfPage::FillItemSet(SfxItemSet& )
         nOldFormat != nFormat || m_pFixedCB->GetState() != m_pFixedCB->GetSavedValue()
         || (DI_CUSTOM == nSubType && !aName.equals( m_sOldCustomFieldName )))
     {
-        InsertFld(nTypeId, nSubType, aName, aEmptyOUStr, nFormat,
+        InsertFld(TYP_DOCINFOFLD, nSubType, aName, aEmptyOUStr, nFormat,
                 ' ', m_pFormatLB->IsAutomaticLanguage());
     }
 
commit cad8953432504451d50ae5d16048edfb06a164f9
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 14:00:12 2014 +0200

    Constify some OUStrings and avoid some appends
    
    Change-Id: Id90d02bab3c3a3b3e2e59097fdf741e2de2b331c

diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx
index c085d5e..95bc444 100644
--- a/sw/source/ui/fldui/flddok.cxx
+++ b/sw/source/ui/fldui/flddok.cxx
@@ -153,10 +153,10 @@ void SwFldDokPage::Reset(const SfxItemSet& )
 
     if( !IsRefresh() )
     {
-        OUString sUserData = GetUserData();
+        const OUString sUserData = GetUserData();
         if (sUserData.getToken(0, ';').equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
         {
-            OUString sVal = sUserData.getToken(1, ';');
+            const OUString sVal = sUserData.getToken(1, ';');
             const sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
             if(nVal != USHRT_MAX)
             {
@@ -257,7 +257,7 @@ IMPL_LINK_NOARG(SwFldDokPage, TypeHdl)
 
                         case TYP_AUTHORFLD:
                         {
-                            OUString sFmt(GetFldMgr().GetFormatStr(nTypeId, i));
+                            const OUString sFmt(GetFldMgr().GetFormatStr(nTypeId, i));
                             nPos = m_pSelectionLB->InsertEntry(sFmt);
                             m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
                             m_pSelectionLB->SelectEntry(GetFldMgr().GetFormatStr(nTypeId, GetCurField()->GetFormat()));
@@ -524,8 +524,8 @@ IMPL_LINK_NOARG(SwFldDokPage, FormatHdl)
         // Prev/Next - PageNumFields special treatment:
         sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(
                                         m_pFormatLB->GetSelectEntryPos() );
-        OUString sOldTxt( m_pValueFT->GetText() );
-        OUString sNewTxt( SW_RES( SVX_NUM_CHAR_SPECIAL == nTmp  ? STR_VALUE
+        const OUString sOldTxt( m_pValueFT->GetText() );
+        const OUString sNewTxt( SW_RES( SVX_NUM_CHAR_SPECIAL == nTmp  ? STR_VALUE
                                                          : STR_OFFSET ));
 
         if( sOldTxt != sNewTxt )
@@ -643,15 +643,11 @@ sal_uInt16 SwFldDokPage::GetGroup()
 
 void    SwFldDokPage::FillUserData()
 {
-    OUString sData(USER_DATA_VERSION);
-    sData += ";";
-    sal_Int32 nTypeSel = m_pTypeLB->GetSelectEntryPos();
-    if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
-        nTypeSel = USHRT_MAX;
-    else
-        nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nTypeSel )));
-    sData += OUString::number( nTypeSel );
-    SetUserData(sData);
+    const sal_Int32 nEntryPos = m_pTypeLB->GetSelectEntryPos();
+    const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
+        ? USHRT_MAX : sal::static_int_cast< sal_uInt16 >
+            (reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nEntryPos )));
+    SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f3f866b5c0ea196b8df7528607244a13ac04849a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 13:46:02 2014 +0200

    Use more consistent integer types, constify and reduce scope
    
    Change-Id: I6ea41796bd42ba47e0070aa172323c7c866c0e16

diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx
index 7753fcc..c085d5e 100644
--- a/sw/source/ui/fldui/flddok.cxx
+++ b/sw/source/ui/fldui/flddok.cxx
@@ -92,15 +92,14 @@ void SwFldDokPage::Reset(const SfxItemSet& )
     m_pTypeLB->Clear();
 
     sal_Int32 nPos;
-    sal_uInt16 nTypeId;
 
     if (!IsFldEdit())
     {
         bool bPage = false;
         // fill Type-Listbox
-        for(short i = rRg.nStart; i < rRg.nEnd; ++i)
+        for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i)
         {
-            nTypeId = GetFldMgr().GetTypeId(i);
+            const sal_uInt16 nTypeId = GetFldMgr().GetTypeId(i);
 
             switch (nTypeId)
             {
@@ -125,7 +124,7 @@ void SwFldDokPage::Reset(const SfxItemSet& )
     else
     {
         const SwField* pCurField = GetCurField();
-        nTypeId = pCurField->GetTypeId();
+        sal_uInt16 nTypeId = pCurField->GetTypeId();
         if (nTypeId == TYP_FIXDATEFLD)
             nTypeId = TYP_DATEFLD;
         if (nTypeId == TYP_FIXTIMEFLD)
@@ -158,7 +157,7 @@ void SwFldDokPage::Reset(const SfxItemSet& )
         if (sUserData.getToken(0, ';').equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
         {
             OUString sVal = sUserData.getToken(1, ';');
-            sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
+            const sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
             if(nVal != USHRT_MAX)
             {
                 for(sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); i++)
@@ -340,7 +339,7 @@ IMPL_LINK_NOARG(SwFldDokPage, TypeHdl)
             case TYP_NEXTPAGEFLD:
                 if (IsFldEdit())
                 {
-                    sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(
+                    const sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(
                                             m_pFormatLB->GetSelectEntryPos() );
 
                     if(SVX_NUM_CHAR_SPECIAL != nTmp)
@@ -434,7 +433,7 @@ IMPL_LINK_NOARG(SwFldDokPage, TypeHdl)
 
 void SwFldDokPage::AddSubType(sal_uInt16 nTypeId)
 {
-    sal_Int32 nPos = m_pSelectionLB->InsertEntry(SwFieldType::GetTypeStr(nTypeId));
+    const sal_Int32 nPos = m_pSelectionLB->InsertEntry(SwFieldType::GetTypeStr(nTypeId));
     m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
 }
 
@@ -444,10 +443,10 @@ IMPL_LINK_NOARG(SwFldDokPage, SubTypeHdl)
     if(nPos == LISTBOX_ENTRY_NOTFOUND)
         nPos = 0;
 
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nPos);
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nPos);
     FillFormatLB(nTypeId);
 
-    sal_uInt16 nTextRes = 0;
+    sal_uInt32 nTextRes = 0;
     switch (nTypeId)
     {
     case TYP_CHAPTERFLD:
@@ -480,12 +479,12 @@ sal_Int32 SwFldDokPage::FillFormatLB(sal_uInt16 nTypeId)
     if (nTypeId == TYP_AUTHORFLD)
         return m_pFormatLB->GetEntryCount();
 
-    sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
+    const sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
 
     for( sal_uInt16 i = 0; i < nSize; ++i )
     {
-        sal_Int32 nPos = m_pFormatLB->InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
-        sal_uInt16 nFmtId = GetFldMgr().GetFormatId( nTypeId, i );
+        const sal_Int32 nPos = m_pFormatLB->InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
+        const sal_uInt16 nFmtId = GetFldMgr().GetFormatId( nTypeId, i );
         m_pFormatLB->SetEntryData( nPos, reinterpret_cast<void*>( nFmtId ));
         if (IsFldEdit() && nFmtId == (GetCurField()->GetFormat() & ~AF_FIXED))
             m_pFormatLB->SelectEntryPos( nPos );
@@ -559,7 +558,7 @@ bool SwFldDokPage::FillItemSet(SfxItemSet& )
     {
         sal_Int32 nPos = m_pFormatLB->GetSelectEntryPos();
         if(nPos != LISTBOX_ENTRY_NOTFOUND)
-            nFormat = (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(nPos);
+            nFormat = (sal_uLong)m_pFormatLB->GetEntryData(nPos);
     }
 
     if (m_pSelectionLB->IsEnabled())
commit 2fd9ce37b23372c1d1fd42d14231497e910a1320
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 12:39:28 2014 +0200

    OUStringBuffer to OUString and optimize related code
    
    Change-Id: I491fd1d1a8430457e681af2df723ef140cedc579

diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx
index 4ba5159..3cb7b72 100644
--- a/sw/source/ui/fldui/fldfunc.cxx
+++ b/sw/source/ui/fldui/fldfunc.cxx
@@ -583,22 +583,20 @@ OUString SwFldFuncPage::TurnMacroString(const OUString &rMacro)
     if (!rMacro.isEmpty())
     {
         // reverse content of aName
-        OUString sTmp;
-        OUStringBuffer sBuf;
+        OUString sMacro;
         sal_Int32 nPos = 0;
 
         for (int i = 0; i < 4 && nPos != -1; i++)
         {
-            if (i == 3)
-                sTmp = rMacro.copy(nPos);
-            else
-                sTmp = rMacro.getToken(0, '.', nPos);
+            OUString sTmp = (i == 3)
+                ? rMacro.copy(nPos)
+                : rMacro.getToken(0, '.', nPos);
 
-            if( !sBuf.isEmpty() )
-                sTmp += ".";
-            sBuf.insert(0, sTmp);
+            sMacro = !sMacro.isEmpty()
+                ? sTmp + "." + sMacro
+                : sTmp;
         }
-        return sBuf.makeStringAndClear();
+        return sMacro;
     }
 
     return rMacro;
commit b0760c7fa850a4ec7dd93d3bed0a541ee4172f8c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 12:22:39 2014 +0200

    Remove temporary OUStrings
    
    Change-Id: I59df3c125084c7c5f12d91a0c2e0eb7f6da882c8

diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx
index b998e72..4ba5159 100644
--- a/sw/source/ui/fldui/fldfunc.cxx
+++ b/sw/source/ui/fldui/fldfunc.cxx
@@ -124,8 +124,7 @@ void SwFldFuncPage::Reset(const SfxItemSet& )
 
         if (nTypeId == TYP_MACROFLD)
         {
-            OUString sName(GetCurField()->GetPar1());
-            GetFldMgr().SetMacroPath(sName);
+            GetFldMgr().SetMacroPath(GetCurField()->GetPar1());
         }
     }
 
@@ -270,9 +269,9 @@ IMPL_LINK_NOARG(SwFldFuncPage, TypeHdl)
         if(bDropDown)
             ListEnableHdl(0);
 
-        if( m_pNameFT->GetText() != OUString(m_sOldNameFT) )
+        if (m_pNameFT->GetText() != m_sOldNameFT)
             m_pNameFT->SetText(m_sOldNameFT);
-        if (m_pValueFT->GetText() != OUString(m_sOldValueFT))
+        if (m_pValueFT->GetText() != m_sOldValueFT)
             m_pValueFT->SetText(m_sOldValueFT);
 
         switch (nTypeId)
@@ -399,7 +398,7 @@ IMPL_LINK( SwFldFuncPage, ListModifyHdl, Control*, pControl)
     if(pControl == m_pListAddPB ||
             (pControl == m_pListItemED && m_pListAddPB->IsEnabled()))
     {
-        OUString sEntry(m_pListItemED->GetText());
+        const OUString sEntry(m_pListItemED->GetText());
         m_pListItemsLB->InsertEntry(sEntry);
         m_pListItemsLB->SelectEntry(sEntry);
     }
@@ -415,7 +414,7 @@ IMPL_LINK( SwFldFuncPage, ListModifyHdl, Control*, pControl)
         {
             if(nSelPos)
             {
-                OUString sEntry = m_pListItemsLB->GetSelectEntry();
+                const OUString sEntry = m_pListItemsLB->GetSelectEntry();
                 m_pListItemsLB->RemoveEntry(nSelPos);
                 nSelPos--;
                 m_pListItemsLB->InsertEntry(sEntry, nSelPos);
@@ -426,7 +425,7 @@ IMPL_LINK( SwFldFuncPage, ListModifyHdl, Control*, pControl)
         {
             if(nSelPos < m_pListItemsLB->GetEntryCount() - 1)
             {
-                OUString sEntry = m_pListItemsLB->GetSelectEntry();
+                const OUString sEntry = m_pListItemsLB->GetSelectEntry();
                 m_pListItemsLB->RemoveEntry(nSelPos);
                 nSelPos++;
                 m_pListItemsLB->InsertEntry(sEntry, nSelPos);
@@ -467,7 +466,7 @@ void SwFldFuncPage::UpdateSubType()
 
     std::vector<OUString> aLst;
     GetFldMgr().GetSubTypes(nTypeId, aLst);
-    size_t nCount = aLst.size();
+    const size_t nCount = aLst.size();
 
     for(size_t i = 0; i < nCount; ++i)
     {
@@ -507,9 +506,7 @@ IMPL_LINK( SwFldFuncPage, MacroHdl, Button *, pBtn )
     Window* pDefModalDlgParent = Application::GetDefDialogParent();
     Application::SetDefDialogParent( pBtn );
 
-    OUString sMacro(TurnMacroString(m_pNameED->GetText()));
-    sMacro = sMacro.replaceAll(".", ";");
-
+    const OUString sMacro(TurnMacroString(m_pNameED->GetText()).replaceAll(".", ";"));
     if (GetFldMgr().ChooseMacro(sMacro))
         UpdateSubType();
 
@@ -620,21 +617,17 @@ sal_uInt16 SwFldFuncPage::GetGroup()
 
 void    SwFldFuncPage::FillUserData()
 {
-    OUString sData(USER_DATA_VERSION);
-    sData += ";";
     const sal_Int32 nEntryPos = m_pTypeLB->GetSelectEntryPos();
     const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
         ? USHRT_MAX
         : sal::static_int_cast< sal_uInt16 >
             (reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nEntryPos )));
-    sData += OUString::number( nTypeSel );
-    SetUserData(sData);
+    SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
 }
 
 IMPL_LINK_NOARG(SwFldFuncPage, ModifyHdl)
 {
-    OUString aName(m_pNameED->GetText());
-    const sal_Int32 nLen = aName.getLength();
+    const sal_Int32 nLen = m_pNameED->GetText().getLength();
 
     sal_Bool bEnable = sal_True;
     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
commit 5449ab5a411716392c634b71c4d956797bb5386d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 12:13:10 2014 +0200

    Use more consistent integer types + constify
    
    Change-Id: If760f0fefa499b2bf03a2aa22f634dbdfff90504

diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx
index 8ab5f5e..b998e72 100644
--- a/sw/source/ui/fldui/fldfunc.cxx
+++ b/sw/source/ui/fldui/fldfunc.cxx
@@ -102,7 +102,6 @@ void SwFldFuncPage::Reset(const SfxItemSet& )
     m_pTypeLB->Clear();
 
     sal_Int32 nPos;
-    sal_uInt16 nTypeId;
 
     if (!IsFldEdit())
     {
@@ -110,16 +109,16 @@ void SwFldFuncPage::Reset(const SfxItemSet& )
         const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
 
         // fill Typ-Listbox
-        for(short i = rRg.nStart; i < rRg.nEnd; ++i)
+        for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i)
         {
-            nTypeId = GetFldMgr().GetTypeId(i);
+            const sal_uInt16 nTypeId = GetFldMgr().GetTypeId(i);
             nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(i));
             m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
         }
     }
     else
     {
-        nTypeId = GetCurField()->GetTypeId();
+        const sal_uInt16 nTypeId = GetCurField()->GetTypeId();
         nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
         m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
 
@@ -155,7 +154,7 @@ void SwFldFuncPage::Reset(const SfxItemSet& )
         if(sUserData.getToken(0, ';').equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
         {
             OUString sVal = sUserData.getToken(1, ';');
-            sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
+            const sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
             if(nVal != USHRT_MAX)
             {
                 for(sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); i++)
@@ -197,7 +196,7 @@ IMPL_LINK_NOARG(SwFldFuncPage, TypeHdl)
 
     if (nOld != GetTypeSel())
     {
-        sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+        const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
         // fill Selection-Listbox
         UpdateSubType();
@@ -205,7 +204,7 @@ IMPL_LINK_NOARG(SwFldFuncPage, TypeHdl)
         // fill Format-Listbox
         m_pFormatLB->Clear();
 
-        sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
+        const sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
 
         for (sal_uInt16 i = 0; i < nSize; i++)
         {
@@ -216,7 +215,7 @@ IMPL_LINK_NOARG(SwFldFuncPage, TypeHdl)
         if (nSize)
         {
             if (IsFldEdit() && nTypeId == TYP_JUMPEDITFLD)
-                m_pFormatLB->SelectEntry(SW_RESSTR(FMT_MARK_BEGIN + (sal_uInt16)GetCurField()->GetFormat()));
+                m_pFormatLB->SelectEntry(SW_RESSTR(FMT_MARK_BEGIN + GetCurField()->GetFormat()));
 
             if (!m_pFormatLB->GetSelectEntryCount())
                 m_pFormatLB->SelectEntryPos(0);
@@ -378,7 +377,7 @@ IMPL_LINK_NOARG(SwFldFuncPage, TypeHdl)
 
 IMPL_LINK_NOARG(SwFldFuncPage, SelectHdl)
 {
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     if( TYP_MACROFLD == nTypeId )
         m_pNameED->SetText( m_pSelectionLB->GetSelectEntry() );
@@ -460,7 +459,7 @@ IMPL_LINK_NOARG(SwFldFuncPage, ListEnableHdl)
  --------------------------------------------------------------------*/
 void SwFldFuncPage::UpdateSubType()
 {
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     // fill Selction-Listbox
     m_pSelectionLB->SetUpdateMode(false);
@@ -521,16 +520,13 @@ IMPL_LINK( SwFldFuncPage, MacroHdl, Button *, pBtn )
 
 bool SwFldFuncPage::FillItemSet(SfxItemSet& )
 {
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     sal_uInt16 nSubType = 0;
 
-    sal_uLong nFormat = m_pFormatLB->GetSelectEntryPos();
-
-    if(nFormat == LISTBOX_ENTRY_NOTFOUND)
-        nFormat = 0;
-    else
-        nFormat = (sal_uLong)m_pFormatLB->GetEntryData(nFormat);
+    const sal_Int32 nEntryPos = m_pFormatLB->GetSelectEntryPos();
+    const sal_uLong nFormat = (nEntryPos == LISTBOX_ENTRY_NOTFOUND)
+        ? 0 : (sal_uLong)m_pFormatLB->GetEntryData(nEntryPos);
 
     OUString aVal(m_pValueED->GetText());
     OUString aName(m_pNameED->GetText());
@@ -594,7 +590,7 @@ OUString SwFldFuncPage::TurnMacroString(const OUString &rMacro)
         OUStringBuffer sBuf;
         sal_Int32 nPos = 0;
 
-        for (sal_uInt16 i = 0; i < 4 && nPos != -1; i++)
+        for (int i = 0; i < 4 && nPos != -1; i++)
         {
             if (i == 3)
                 sTmp = rMacro.copy(nPos);
@@ -626,11 +622,11 @@ void    SwFldFuncPage::FillUserData()
 {
     OUString sData(USER_DATA_VERSION);
     sData += ";";
-    sal_Int32 nTypeSel = m_pTypeLB->GetSelectEntryPos();
-    if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
-        nTypeSel = USHRT_MAX;
-    else
-        nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nTypeSel )));
+    const sal_Int32 nEntryPos = m_pTypeLB->GetSelectEntryPos();
+    const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
+        ? USHRT_MAX
+        : sal::static_int_cast< sal_uInt16 >
+            (reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nEntryPos )));
     sData += OUString::number( nTypeSel );
     SetUserData(sData);
 }
@@ -638,7 +634,7 @@ void    SwFldFuncPage::FillUserData()
 IMPL_LINK_NOARG(SwFldFuncPage, ModifyHdl)
 {
     OUString aName(m_pNameED->GetText());
-    const sal_uInt16 nLen = aName.getLength();
+    const sal_Int32 nLen = aName.getLength();
 
     sal_Bool bEnable = sal_True;
     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
commit 1e5826163af8473b52a00124b04b7b7dc8c3d52d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 11:47:33 2014 +0200

    Some more conversion to consinstent integer types
    
    Change-Id: Idca4a41c8c23e7761d8b10a7269f1e50fa74e379

diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index e33e842..9e5a1f8 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -957,11 +957,11 @@ sal_uInt16 SwFldRefPage::GetGroup()
 
 void    SwFldRefPage::FillUserData()
 {
-    sal_Int32 nTypeSel = m_pTypeLB->GetSelectEntryPos();
-    if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
-        nTypeSel = USHRT_MAX;
-    else
-        nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nTypeSel )));
+    const sal_Int32 nEntryPos = m_pTypeLB->GetSelectEntryPos();
+    const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
+        ? USHRT_MAX
+        : sal::static_int_cast< sal_uInt16 >
+            (reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nEntryPos )));
     SetUserData( USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
 }
 
commit 1f1aa85a1884d9ecbe897b36e651ded7222690fe
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 11:44:07 2014 +0200

    Avoid some OUString concatenations
    
    Change-Id: I73c5af00bee383de6e0c39932e91495632eb9dfb

diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 1642eac..e33e842 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -957,15 +957,12 @@ sal_uInt16 SwFldRefPage::GetGroup()
 
 void    SwFldRefPage::FillUserData()
 {
-    OUString sData(USER_DATA_VERSION);
-    sData += ";";
     sal_Int32 nTypeSel = m_pTypeLB->GetSelectEntryPos();
     if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
         nTypeSel = USHRT_MAX;
     else
         nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nTypeSel )));
-    sData += OUString::number( nTypeSel );
-    SetUserData(sData);
+    SetUserData( USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 057c882c82fd5ed473b86950b5afc1f41f69c242
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 10:38:29 2014 +0200

    OUString: use isEmpty instead of getLength()==0
    
    Change-Id: Iaabfc2fb1f3fdf40681959232dbd7b02b333b877

diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 4c227e0..1642eac 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -746,13 +746,13 @@ sal_Int32 SwFldRefPage::FillFormatLB(sal_uInt16 nTypeId)
 IMPL_LINK_NOARG(SwFldRefPage, ModifyHdl)
 {
     OUString aName(m_pNameED->GetText());
-    const sal_uInt16 nLen = aName.getLength();
+    const bool bEmptyName = aName.isEmpty();
 
     sal_Bool bEnable = sal_True;
     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     if ((nTypeId == TYP_SETREFFLD && !GetFldMgr().CanInsertRefMark(aName)) ||
-        (nLen == 0 && (nTypeId == TYP_GETREFFLD || nTypeId == TYP_SETREFFLD ||
+        (bEmptyName && (nTypeId == TYP_GETREFFLD || nTypeId == TYP_SETREFFLD ||
                        nTypeId == REFFLDFLAG_BOOKMARK)))
         bEnable = sal_False;
 
commit c060aa34303212de017879c6b27d7f54129586c7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 10:34:45 2014 +0200

    Use more consistent integer types + constify
    
    Change-Id: I1c35af35661d26b1331bce6193c233aa3c1171a0

diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 01bff16..4c227e0 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -124,16 +124,16 @@ void SwFldRefPage::SaveSelectedTxtNode()
 
             if ( nTypeId == REFFLDFLAG_HEADING )
             {
-                mnSavedSelectedPos = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData()));
-                if ( static_cast<size_t>(mnSavedSelectedPos) < maOutlineNodes.size() )
+                mnSavedSelectedPos = static_cast<size_t>(reinterpret_cast<sal_uLong>(pEntry->GetUserData()));
+                if ( mnSavedSelectedPos < maOutlineNodes.size() )
                 {
                     mpSavedSelectedTxtNode = maOutlineNodes[mnSavedSelectedPos];
                 }
             }
             else if ( nTypeId == REFFLDFLAG_NUMITEM )
             {
-                mnSavedSelectedPos = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData()));
-                if ( static_cast<size_t>(mnSavedSelectedPos) < maNumItems.size() )
+                mnSavedSelectedPos = static_cast<size_t>(reinterpret_cast<sal_uLong>(pEntry->GetUserData()));
+                if ( mnSavedSelectedPos < maNumItems.size() )
                 {
                     mpSavedSelectedTxtNode = maNumItems[mnSavedSelectedPos]->GetTxtNode();
                 }
@@ -187,7 +187,7 @@ void SwFldRefPage::Reset(const SfxItemSet& )
     if(!pSh)
         pSh = ::GetActiveWrtShell();
 
-    sal_uInt16 nFldTypeCnt = pSh->GetFldTypeCount(RES_SETEXPFLD);
+    const sal_uInt16 nFldTypeCnt = pSh->GetFldTypeCount(RES_SETEXPFLD);
 
     for (sal_uInt16 n = 0; n < nFldTypeCnt; ++n)
     {
@@ -233,7 +233,7 @@ void SwFldRefPage::Reset(const SfxItemSet& )
                                 equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
         {
             OUString sVal = sUserData.getToken(1, ';');
-            sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
+            const sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
             if(nVal != USHRT_MAX)
             {
                 for(sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); i++)
@@ -372,7 +372,7 @@ IMPL_LINK_NOARG(SwFldRefPage, TypeHdl)
             default:
                 if( REFFLDFLAG & nTypeId )
                 {
-                    sal_uInt16 nOldId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(nOld);
+                    const sal_uInt16 nOldId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(nOld);
                     if( nOldId & REFFLDFLAG || nOldId == TYP_GETREFFLD )
                         // then the old one stays
                         nFldDlgFmtSel = m_pFormatLB->GetSelectEntryPos();
@@ -496,7 +496,7 @@ void SwFldRefPage::UpdateSubType()
         {
             m_pSelectionLB->SetStyle(m_pSelectionLB->GetStyle() & ~WB_SORT);
             SwSeqFldList aArr;
-            sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr );
+            const sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr );
 
             for( sal_uInt16 n = 0; n < nCnt; ++n )
             {
@@ -509,7 +509,7 @@ void SwFldRefPage::UpdateSubType()
         {
             m_pSelectionLB->SetStyle(m_pSelectionLB->GetStyle() & ~WB_SORT);
             SwSeqFldList aArr;
-            sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr, true );
+            const sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr, true );
 
             for( sal_uInt16 n = 0; n < nCnt; ++n )
             {
@@ -527,8 +527,7 @@ void SwFldRefPage::UpdateSubType()
             pIDoc->getOutlineNodes( maOutlineNodes );
             bool bCertainTxtNodeSelected( false );
             SvTreeListEntry* pEntry = 0;
-            sal_uInt16 nOutlIdx = 0;
-            for ( nOutlIdx = 0; nOutlIdx < maOutlineNodes.size(); ++nOutlIdx )
+            for ( size_t nOutlIdx = 0; nOutlIdx < maOutlineNodes.size(); ++nOutlIdx )
             {
                 pEntry = m_pSelectionToolTipLB->InsertEntry(
                                 pIDoc->getOutlineText( nOutlIdx, true, true, false ) );
@@ -541,8 +540,7 @@ void SwFldRefPage::UpdateSubType()
                     sOldSel = "";
                     bCertainTxtNodeSelected = true;
                 }
-                else if ( !bCertainTxtNodeSelected &&
-                          mnSavedSelectedPos == nOutlIdx )
+                else if ( !bCertainTxtNodeSelected && mnSavedSelectedPos == nOutlIdx )
                 {
                     m_pSelectionToolTipLB->Select( pEntry );
                     sOldSel = "";
@@ -557,8 +555,7 @@ void SwFldRefPage::UpdateSubType()
             pIDoc->getNumItems( maNumItems );
             bool bCertainTxtNodeSelected( false );
             SvTreeListEntry* pEntry = 0;
-            sal_uInt16 nNumItemIdx = 0;
-            for ( nNumItemIdx = 0; nNumItemIdx < maNumItems.size(); ++nNumItemIdx )
+            for ( size_t nNumItemIdx = 0; nNumItemIdx < maNumItems.size(); ++nNumItemIdx )
             {
                 pEntry = m_pSelectionToolTipLB->InsertEntry(
                             pIDoc->getListItemText( *maNumItems[nNumItemIdx], true, true ) );
@@ -571,8 +568,7 @@ void SwFldRefPage::UpdateSubType()
                     sOldSel = "";
                     bCertainTxtNodeSelected = true;
                 }
-                else if ( !bCertainTxtNodeSelected &&
-                          mnSavedSelectedPos == nNumItemIdx )
+                else if ( !bCertainTxtNodeSelected && mnSavedSelectedPos == nNumItemIdx )
                 {
                     m_pSelectionToolTipLB->Select( pEntry );
                     sOldSel = "";
@@ -593,7 +589,7 @@ void SwFldRefPage::UpdateSubType()
                 if(IsFldEdit())
                     sOldSel = "";
 
-                sal_uInt16 nCnt = pType->GetSeqFldList( aArr );
+                const sal_uInt16 nCnt = pType->GetSeqFldList( aArr );
                 for( sal_uInt16 n = 0; n < nCnt; ++n )
                 {
                     m_pSelectionLB->InsertEntry( aArr[ n ]->sDlgEntry );
@@ -730,7 +726,7 @@ sal_Int32 SwFldRefPage::FillFormatLB(sal_uInt16 nTypeId)
         if (!IsFldEdit())
             m_pFormatLB->SelectEntry(sOldSel);
         else
-            m_pFormatLB->SelectEntry(SW_RESSTR(FMT_REF_BEGIN + (sal_uInt16)GetCurField()->GetFormat()));
+            m_pFormatLB->SelectEntry(SW_RESSTR(FMT_REF_BEGIN + GetCurField()->GetFormat()));
 
         if (!m_pFormatLB->GetSelectEntryCount())
         {
@@ -773,14 +769,9 @@ bool SwFldRefPage::FillItemSet(SfxItemSet& )
     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     sal_uInt16 nSubType = 0;
-    sal_uLong nFormat;
-
-    nFormat = m_pFormatLB->GetSelectEntryPos();
-
-    if(nFormat == LISTBOX_ENTRY_NOTFOUND)
-        nFormat = 0;
-    else
-        nFormat = (sal_uLong)m_pFormatLB->GetEntryData((sal_uInt16)nFormat);
+    const sal_Int32 nEntryPos = m_pFormatLB->GetSelectEntryPos();
+    const sal_uLong nFormat = (nEntryPos == LISTBOX_ENTRY_NOTFOUND)
+        ? 0 : (sal_uLong)m_pFormatLB->GetEntryData(nEntryPos);
 
     OUString aVal(m_pValueED->GetText());
     OUString aName(m_pNameED->GetText());
@@ -869,7 +860,8 @@ bool SwFldRefPage::FillItemSet(SfxItemSet& )
                     "<SwFldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
             if ( pEntry )
             {
-                const sal_uInt16 nOutlIdx( static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())) );
+                const size_t nOutlIdx( static_cast<size_t>
+                    (reinterpret_cast<sal_uLong>(pEntry->GetUserData())) );
                 pSh->getIDocumentOutlineNodesAccess()->getOutlineNodes( maOutlineNodes );
                 if ( nOutlIdx < maOutlineNodes.size() )
                 {
@@ -889,7 +881,8 @@ bool SwFldRefPage::FillItemSet(SfxItemSet& )
                     "<SwFldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
             if ( pEntry )
             {
-                const sal_uInt16 nNumItemIdx( static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())) );
+                const size_t nNumItemIdx( static_cast<size_t>
+                    (reinterpret_cast<sal_uLong>(pEntry->GetUserData())) );
                 pSh->getIDocumentListItemsAccess()->getNumItems( maNumItems );
                 if ( nNumItemIdx < maNumItems.size() )
                 {
diff --git a/sw/source/ui/fldui/fldref.hxx b/sw/source/ui/fldui/fldref.hxx
index 7d78d40..ceb0c2d 100644
--- a/sw/source/ui/fldui/fldref.hxx
+++ b/sw/source/ui/fldui/fldref.hxx
@@ -59,7 +59,7 @@ class SwFldRefPage : public SwFldPage
     // in order to restore selection after update of selection listbox
     const SwTxtNode* mpSavedSelectedTxtNode;
     // fallback, if previously selected text node doesn't exist anymore
-    sal_Int32  mnSavedSelectedPos;
+    size_t mnSavedSelectedPos;
 
     DECL_LINK(TypeHdl, void *);
     DECL_LINK(SubTypeHdl, void * = 0);
commit 42705f6b5e7bcf7b6d46a73cd931d17999d4890b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 09:53:37 2014 +0200

    Do not use accessors for private variables
    
    Change-Id: Ia3fc7078a0e0ba2f84b7e0fd94011d6851ccff73

diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index b7a38ff..01bff16 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -142,16 +142,6 @@ void SwFldRefPage::SaveSelectedTxtNode()
     }
 }
 
-const SwTxtNode* SwFldRefPage::GetSavedSelectedTxtNode() const
-{
-    return mpSavedSelectedTxtNode;
-}
-
-sal_Int32 SwFldRefPage::GetSavedSelectedPos() const
-{
-    return mnSavedSelectedPos;
-}
-
 void SwFldRefPage::Reset(const SfxItemSet& )
 {
     if (!IsFldEdit())
@@ -545,14 +535,14 @@ void SwFldRefPage::UpdateSubType()
                 pEntry->SetUserData( reinterpret_cast<void*>(nOutlIdx) );
                 if ( ( IsFldEdit() &&
                        pRefFld->GetReferencedTxtNode() == maOutlineNodes[nOutlIdx] ) ||
-                     GetSavedSelectedTxtNode() == maOutlineNodes[nOutlIdx] )
+                     mpSavedSelectedTxtNode == maOutlineNodes[nOutlIdx] )
                 {
                     m_pSelectionToolTipLB->Select( pEntry );
                     sOldSel = "";
                     bCertainTxtNodeSelected = true;
                 }
                 else if ( !bCertainTxtNodeSelected &&
-                          GetSavedSelectedPos() == nOutlIdx )
+                          mnSavedSelectedPos == nOutlIdx )
                 {
                     m_pSelectionToolTipLB->Select( pEntry );
                     sOldSel = "";
@@ -575,14 +565,14 @@ void SwFldRefPage::UpdateSubType()
                 pEntry->SetUserData( reinterpret_cast<void*>(nNumItemIdx) );
                 if ( ( IsFldEdit() &&
                        pRefFld->GetReferencedTxtNode() == maNumItems[nNumItemIdx]->GetTxtNode() ) ||
-                     GetSavedSelectedTxtNode() == maNumItems[nNumItemIdx]->GetTxtNode() )
+                     mpSavedSelectedTxtNode == maNumItems[nNumItemIdx]->GetTxtNode() )
                 {
                     m_pSelectionToolTipLB->Select( pEntry );
                     sOldSel = "";
                     bCertainTxtNodeSelected = true;
                 }
                 else if ( !bCertainTxtNodeSelected &&
-                          GetSavedSelectedPos() == nNumItemIdx )
+                          mnSavedSelectedPos == nNumItemIdx )
                 {
                     m_pSelectionToolTipLB->Select( pEntry );
                     sOldSel = "";
diff --git a/sw/source/ui/fldui/fldref.hxx b/sw/source/ui/fldui/fldref.hxx
index 7f7e8f9..7d78d40 100644
--- a/sw/source/ui/fldui/fldref.hxx
+++ b/sw/source/ui/fldui/fldref.hxx
@@ -70,8 +70,6 @@ class SwFldRefPage : public SwFldPage
 
     // #i83479#
     void SaveSelectedTxtNode();
-    const SwTxtNode* GetSavedSelectedTxtNode() const;
-    sal_Int32  GetSavedSelectedPos() const;
 
 protected:
     virtual sal_uInt16      GetGroup() SAL_OVERRIDE;
commit 7d87349bde54febf25ce6b3a19e13ab545913250
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 09:36:21 2014 +0200

    This file level variable can be static
    
    Change-Id: I77d59760e80978d22d8f3cfeaed1c133003de2af

diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 8820f86..b7a38ff 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -43,7 +43,7 @@
 #define REFFLDFLAG_HEADING  0x7100
 #define REFFLDFLAG_NUMITEM  0x7200
 
-sal_uInt16  nFldDlgFmtSel       = 0;
+static sal_uInt16 nFldDlgFmtSel = 0;
 
 #define USER_DATA_VERSION_1 "1"
 #define USER_DATA_VERSION USER_DATA_VERSION_1
@@ -353,7 +353,8 @@ IMPL_LINK_NOARG(SwFldRefPage, TypeHdl)
         // fill selection-ListBox
         UpdateSubType();
 
-        sal_Bool bName = sal_False;     nFldDlgFmtSel = 0;
+        sal_Bool bName = sal_False;
+        nFldDlgFmtSel = 0;
 
         if ( ( !IsFldEdit() || m_pSelectionLB->GetEntryCount() ) &&
              nOld != LISTBOX_ENTRY_NOTFOUND )
commit b6bddf965a27cb66674c5c6e74a66b96970e80d0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 22:42:18 2014 +0100

    Constify some variables
    
    Change-Id: I5ca2d66409222e9e9444f6b3d83c583f74494165

diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index 460ef90..406d1d1 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -398,8 +398,8 @@ IMPL_LINK( SwFldVarPage, SubTypeHdl, ListBox *, pBox )
                 m_pNameED->SetText( sName );
 
                 // User- or SetField ?
-                sal_uInt16 nInpType = 0;
-                nInpType = static_cast< sal_uInt16 >(GetFldMgr().GetFldType(RES_USERFLD, sName) ? 0 : TYP_SETINPFLD);
+                const sal_uInt16 nInpType = static_cast< sal_uInt16 >
+                    (GetFldMgr().GetFldType(RES_USERFLD, sName) ? 0 : TYP_SETINPFLD);
 
                 if (nInpType)   // SETEXPFLD
                 {
@@ -571,7 +571,7 @@ IMPL_LINK( SwFldVarPage, SubTypeHdl, ListBox *, pBox )
 void SwFldVarPage::UpdateSubType()
 {
     OUString sOldSel;
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     SetSelectionSel(m_pSelectionLB->GetSelectEntryPos());
     if(GetSelectionSel() != LISTBOX_ENTRY_NOTFOUND)
@@ -769,12 +769,12 @@ sal_Int32 SwFldVarPage::FillFormatLB(sal_uInt16 nTypeId)
             m_pNumFormatLB->SelectEntry(sOldSel);
     }
 
-    sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
+    const sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
 
     for (sal_uInt16 i = 0; i < nSize; i++)
     {
         sal_Int32 nPos = m_pFormatLB->InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
-        sal_uInt16 nFldId = GetFldMgr().GetFormatId( nTypeId, i );
+        const sal_uInt16 nFldId = GetFldMgr().GetFormatId( nTypeId, i );
         m_pFormatLB->SetEntryData( nPos, reinterpret_cast<void*>(nFldId) );
         if (IsFldEdit() && nFldId == GetCurField()->GetFormat())
             m_pFormatLB->SelectEntryPos( nPos );
@@ -806,7 +806,7 @@ IMPL_LINK_NOARG(SwFldVarPage, ModifyHdl)
 {
     OUString sValue(m_pValueED->GetText());
     sal_Bool bHasValue = !sValue.isEmpty();
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
     bool bInsert = false, bApply = false, bDelete = false;
 
     OUString sName( m_pNameED->GetText() );
@@ -929,9 +929,9 @@ IMPL_LINK_NOARG(SwFldVarPage, ModifyHdl)
 
 IMPL_LINK( SwFldVarPage, TBClickHdl, ToolBox *, pBox )
 {
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
-    sal_uInt16 nCurId = pBox->GetCurItemId();
+    const sal_uInt16 nCurId = pBox->GetCurItemId();
 
     if (nCurId == m_nDeleteId)
     {
@@ -1095,12 +1095,12 @@ IMPL_LINK_NOARG(SwFldVarPage, SeparatorHdl)
 
 bool SwFldVarPage::FillItemSet(SfxItemSet& )
 {
-    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
+    const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
 
     OUString aVal(m_pValueED->GetText());
     OUString aName(m_pNameED->GetText());
 
-    sal_Int32 nSubPos = m_pSelectionLB->GetSelectEntryPos();
+    const sal_Int32 nSubPos = m_pSelectionLB->GetSelectEntryPos();
     sal_uInt16 nSubType = (nSubPos == LISTBOX_ENTRY_NOTFOUND) ? 0 :
         (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nSubPos);
 
commit f4910a27d333fac865bb498896b624fb3bbd12d5
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 22:26:55 2014 +0100

    sal_uInt16 to sal_Int32
    
    Change-Id: I278f325925717bcb8bc45afacd6dbf442f0eefbe

diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index 956840d..10a3e55 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -530,7 +530,7 @@ void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
         ::FillCharStyleListBox(rCharFmtLB,  pDocShell);
 
         std::vector<OUString> aList;
-        for(sal_uInt16 j = 0; j < rCharFmtLB.GetEntryCount(); j++)
+        for(sal_Int32 j = 0; j < rCharFmtLB.GetEntryCount(); j++)
              aList.push_back( rCharFmtLB.GetEntry(j) );
 
         aSet.Put( SfxStringListItem( SID_CHAR_FMT_LIST_BOX,&aList ) ) ;
commit 3351ebde48a31173c2fea9f7270224017e1f4412
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 22:22:42 2014 +0100

    OUString: remove temporaries and repeated expressions
    
    Change-Id: I1d86be40c4bde4e8fb51c430c6416165655c055c

diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index de4ed2c..dcefde3 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -193,9 +193,8 @@ SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh)
     const sal_Int32 nPagePos = m_pApplyToLB->GetEntryPos( (void*) LISTBOX_PAGE );
     if (pPageSet && pPageDesc)
     {
-        OUString sPageStr = m_pApplyToLB->GetEntry(nPagePos);
+        const OUString sPageStr = m_pApplyToLB->GetEntry(nPagePos) + pPageDesc->GetName();
         m_pApplyToLB->RemoveEntry(nPagePos);
-        sPageStr += pPageDesc->GetName();
         m_pApplyToLB->InsertEntry( sPageStr, nPagePos );
         m_pApplyToLB->SetEntryData( nPagePos, (void*) LISTBOX_PAGE);
     }
@@ -915,41 +914,28 @@ void SwColumnPage::UpdateCols()
 
 void SwColumnPage::SetLabels( sal_uInt16 nVis )
 {
-    OUString sLbl( '~' );
-
-    OUString sLbl2( OUString::number( nVis + 1 ));
-    OUString tmp1(sLbl2);
-    sLbl2 = sLbl2.replaceAt(sLbl2.getLength() - 1, 0, sLbl);
-    m_pLbl1->SetText(sLbl2);
-
-    sLbl2 = OUString::number( nVis + 2 );
-    OUString tmp2(sLbl2);
-    sLbl2 = sLbl2.replaceAt(sLbl2.getLength() - 1, 0, sLbl);
-    m_pLbl2->SetText(sLbl2);
-
-    sLbl2 = OUString::number( nVis + 3 );
-    OUString tmp3(sLbl2);
-    sLbl2 = sLbl2.replaceAt(sLbl2.getLength() - 1, 0, sLbl);
-    m_pLbl3->SetText(sLbl2);
-    OUString sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ;
-    aEd1.SetAccessibleName(sColumnWidth.replaceFirst("%1", tmp1));
-
-    sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ;
-    aEd2.SetAccessibleName(sColumnWidth.replaceFirst("%1", tmp2));
-
-    sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ;
-    aEd3.SetAccessibleName(sColumnWidth.replaceFirst("%1", tmp3));
-
-    OUString sDist = SW_RESSTR( STR_ACCESS_PAGESETUP_SPACING ) ;
-    OUString sDist1 = sDist;
-    sDist1 = sDist1.replaceFirst("%1", tmp1);
-    sDist1 = sDist1.replaceFirst("%2", tmp2);
-    aDistEd1.SetAccessibleName(sDist1);
-
-    OUString sDist2 = sDist;
-    sDist2 = sDist2.replaceFirst("%1", tmp2);
-    sDist2 = sDist2.replaceFirst("%2", tmp3);
-    aDistEd2.SetAccessibleName(sDist2);
+    const OUString sLbl( '~' );
+
+    const OUString sLbl1(OUString::number( nVis + 1 ));
+    m_pLbl1->SetText(sLbl1 + sLbl);
+
+    const OUString sLbl2(OUString::number( nVis + 2 ));
+    m_pLbl2->SetText(sLbl2 + sLbl);
+
+    const OUString sLbl3(OUString::number( nVis + 3 ));
+    m_pLbl3->SetText(sLbl3 + sLbl);
+
+    const OUString sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ;
+    aEd1.SetAccessibleName(sColumnWidth.replaceFirst("%1", sLbl1));
+    aEd2.SetAccessibleName(sColumnWidth.replaceFirst("%1", sLbl2));
+    aEd3.SetAccessibleName(sColumnWidth.replaceFirst("%1", sLbl3));
+
+    const OUString sDist = SW_RESSTR( STR_ACCESS_PAGESETUP_SPACING ) ;
+    aDistEd1.SetAccessibleName(
+        sDist.replaceFirst("%1", sLbl1).replaceFirst("%2", sLbl2));
+
+    aDistEd2.SetAccessibleName(
+        sDist.replaceFirst("%1", sLbl2).replaceFirst("%2", sLbl3));
 }
 
 /*------------------------------------------------------------------------
commit b50155ae687f640ffdd68beae06442a4d0b0083c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 22:06:03 2014 +0100

    Do not evaluate the same expression 10 times
    
    Change-Id: I3feb440e0013ba75b738e4110315c7034ef29639

diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index f708407..de4ed2c 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -1016,12 +1016,12 @@ IMPL_LINK( SwColumnPage, GapModify, MetricField*, pMetricFld )
     }
     else
     {
-        const sal_uInt16 nOffset = (pFld == &aDistEd2) ? 1 : 0;
-        long nDiff = nActValue - nColDist[nFirstVis + nOffset];
+        const sal_uInt16 nVis = nFirstVis + (pFld == &aDistEd2) ? 1 : 0;
+        long nDiff = nActValue - nColDist[nVis];
         if(nDiff)
         {
-            long nLeft = nColWidth[nFirstVis + nOffset];
-            long nRight = nColWidth[nFirstVis + nOffset + 1];
+            long nLeft = nColWidth[nVis];
+            long nRight = nColWidth[nVis + 1];
             if(nLeft + nRight + 2 * MINLAY < nDiff)
                 nDiff = nLeft + nRight - 2 * MINLAY;
             if(nDiff < nRight - MINLAY)
@@ -1044,13 +1044,13 @@ IMPL_LINK( SwColumnPage, GapModify, MetricField*, pMetricFld )
                 }
                 nDiff = nTemp;
             }
-            nColWidth[nFirstVis + nOffset] = nLeft;
-            nColWidth[nFirstVis + nOffset + 1] = nRight;
-            nColDist[nFirstVis + nOffset] += nDiff;
+            nColWidth[nVis] = nLeft;
+            nColWidth[nVis + 1] = nRight;
+            nColDist[nVis] += nDiff;
 
-            pColMgr->SetColWidth( nFirstVis + nOffset, sal_uInt16(nLeft) );
-            pColMgr->SetColWidth( nFirstVis + nOffset + 1, sal_uInt16(nRight) );
-            pColMgr->SetGutterWidth( sal_uInt16(nColDist[nFirstVis + nOffset]), nFirstVis + nOffset );
+            pColMgr->SetColWidth( nVis, sal_uInt16(nLeft) );
+            pColMgr->SetColWidth( nVis + 1, sal_uInt16(nRight) );
+            pColMgr->SetGutterWidth( sal_uInt16(nColDist[nVis]), nVis );
         }
 
     }
commit 84ee76302fd1d6800d289ba45d96f5e861744416
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 21:58:17 2014 +0100

    Check early bail-out before performing unrelated operations
    
    Change-Id: I335a90070221153810e94938cfcfbfe10688071b

diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index 561d8c9..f708407 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -993,11 +993,11 @@ IMPL_LINK( SwColumnPage, ColModify, NumericField *, pNF )
 ------------------------------------------------------------------------*/
 IMPL_LINK( SwColumnPage, GapModify, MetricField*, pMetricFld )
 {
+    if (nCols < 2)
+        return 0;
     PercentField *pFld = m_aPercentFieldsMap[pMetricFld];
     assert(pFld);
     long nActValue = static_cast< long >(pFld->DenormalizePercent(pFld->GetValue(FUNIT_TWIP)));
-    if(nCols < 2)
-        return 0;
     if(m_pAutoWidthBox->IsChecked())
     {
         const long nMaxGap = static_cast< long >
commit 1f04f53cc794553d68c86c40be285a6c71fb2cc4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 21:52:04 2014 +0100

    Removed OSL_ENSURE since condition cannot happen
    
    Change-Id: Ifa71ac9a56ea7ffb5491bdfabc4ec5473e85a02d

diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index b210e07..561d8c9 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -1000,7 +1000,6 @@ IMPL_LINK( SwColumnPage, GapModify, MetricField*, pMetricFld )
         return 0;
     if(m_pAutoWidthBox->IsChecked())
     {
-        OSL_ENSURE(nCols, "Abstand kann nicht ohne Spalten eingestellt werden");
         const long nMaxGap = static_cast< long >
             ((pColMgr->GetActualSize() - nCols * MINLAY)/(nCols - 1));
         if(nActValue > nMaxGap)
commit f711d01041afc292ffa6aa3d880129b5629ceb4f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 21:50:26 2014 +0100

    sal_uInt16: to sal_Int32/long, constify, reworked some casts
    
    Change-Id: I81e13e42619d73346c63689bf4392f924348b4ae

diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index 43fb6a7..b210e07 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -112,7 +112,7 @@ SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh)
                                                 0 };
 
     const SwSection* pCurrSection = rWrtShell.GetCurrSection();
-    sal_uInt16 nFullSectCnt = rWrtShell.GetFullSelectedSectionCount();
+    const sal_uInt16 nFullSectCnt = rWrtShell.GetFullSelectedSectionCount();
     if( pCurrSection && ( !rWrtShell.HasSelection() || 0 != nFullSectCnt ))
     {
         nSelectionWidth = rSh.GetSectionWidth(*pCurrSection->GetFmt());
@@ -190,7 +190,7 @@ SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh)
     if (!rWrtShell.GetFlyFrmFmt())
         m_pApplyToLB->RemoveEntry(m_pApplyToLB->GetEntryPos( (void*) LISTBOX_FRAME ));
 
-    sal_uInt16 nPagePos = m_pApplyToLB->GetEntryPos( (void*) LISTBOX_PAGE );
+    const sal_Int32 nPagePos = m_pApplyToLB->GetEntryPos( (void*) LISTBOX_PAGE );
     if (pPageSet && pPageDesc)
     {
         OUString sPageStr = m_pApplyToLB->GetEntry(nPagePos);
@@ -329,7 +329,7 @@ IMPL_LINK_NOARG(SwColumnDlg, OkHdl)
     {
         const SwSection* pCurrSection = rWrtShell.GetCurrSection();
         const SwSectionFmt* pFmt = pCurrSection->GetFmt();
-        sal_uInt16 nNewPos = rWrtShell.GetSectionFmtPos( *pFmt );
+        const sal_uInt16 nNewPos = rWrtShell.GetSectionFmtPos( *pFmt );
         SwSectionData aData(*pCurrSection);
         rWrtShell.UpdateSection( nNewPos, aData, pSectionSet );
     }
@@ -388,8 +388,7 @@ void SwColumnPage::ResetColWidth()
 {
     if( nCols )
     {
-        sal_uInt16 nWidth = GetMaxWidth( pColMgr, nCols );
-        nWidth = nWidth / nCols;
+        const sal_uInt16 nWidth = GetMaxWidth( pColMgr, nCols ) / nCols;
 
         for(sal_uInt16 i = 0; i < nCols; ++i)
             nColWidth[i] = (long) nWidth;
@@ -574,7 +573,8 @@ void SwColumnPage::connectPercentField(PercentField &rWrap, const OString &rName
 
 void SwColumnPage::Reset(const SfxItemSet &rSet)
 {
-    sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
+    const sal_uInt16 nHtmlMode =
+        ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
     if(nHtmlMode & HTMLMODE_ON)
     {
         bHtmlMode = sal_True;
@@ -590,7 +590,7 @@ void SwColumnPage::Reset(const SfxItemSet &rSet)
     delete pColMgr;
     pColMgr = new SwColMgr(rSet);
     nCols   = pColMgr->GetCount() ;
-    m_pCLNrEdt->SetMax(std::max((sal_uInt16)m_pCLNrEdt->GetMax(), (sal_uInt16)nCols));
+    m_pCLNrEdt->SetMax(std::max((sal_uInt16)m_pCLNrEdt->GetMax(), nCols));
     m_pCLNrEdt->SetLast(std::max(nCols,(sal_uInt16)m_pCLNrEdt->GetMax()));
 
     if(bFrm)
@@ -618,7 +618,7 @@ void SwColumnPage::Reset(const SfxItemSet &rSet)
     {
         const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
         sal_uIntPtr nVal  = rItem.GetValue();
-        sal_uInt16 nPos = m_pTextDirectionLB->GetEntryPos( (void*) nVal );
+        const sal_Int32 nPos = m_pTextDirectionLB->GetEntryPos( (void*) nVal );
         m_pTextDirectionLB->SelectEntryPos( nPos );
         m_pTextDirectionLB->SaveValue();
     }
@@ -655,13 +655,14 @@ bool SwColumnPage::FillItemSet(SfxItemSet &rSet)
     {
         rSet.Put(SwFmtNoBalancedColumns(!m_pBalanceColsCB->IsChecked() ));
     }
-    sal_uInt16 nPos;
-    if( m_pTextDirectionLB->IsVisible() &&
-        ( nPos = m_pTextDirectionLB->GetSelectEntryPos() ) !=
-                                            m_pTextDirectionLB->GetSavedValue() )
+    if( m_pTextDirectionLB->IsVisible())
     {
-        sal_uInt32 nDirection = (sal_uInt32)(sal_IntPtr)m_pTextDirectionLB->GetEntryData( nPos );
-        rSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR));
+        const sal_Int32 nPos = m_pTextDirectionLB->GetSelectEntryPos();
+        if ( nPos != m_pTextDirectionLB->GetSavedValue() )
+        {
+            sal_uInt32 nDirection = (sal_uInt32)(sal_IntPtr)m_pTextDirectionLB->GetEntryData( nPos );
+            rSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR));
+        }
     }
     return true;
 }
@@ -677,9 +678,8 @@ IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ )
             // Determine whether the most narrow column is too narrow
             // for the adjusted column gap
         long nMin = nColWidth[0];
-        sal_uInt16 i;
 
-        for( i = 1; i < nCols; ++i)
+        for( sal_uInt16 i = 1; i < nCols; ++i )
             nMin = std::min(nMin, nColWidth[i]);
 
         sal_Bool bAutoWidth = m_pAutoWidthBox->IsChecked();
@@ -689,10 +689,10 @@ IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ )
                 // when the user didn't allocate the whole width,
                 // add the missing amount to the last column.
             long nSum = 0;
-            for(i = 0; i < nCols; ++i)
+            for(sal_uInt16 i = 0; i < nCols; ++i)
                 nSum += nColWidth[i];
             nGutterWidth = 0;
-            for(i = 0; i < nCols - 1; ++i)
+            for(sal_uInt16 i = 0; i < nCols - 1; ++i)
                 nGutterWidth += nColDist[i];
             nSum += nGutterWidth;
 
@@ -701,11 +701,11 @@ IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ )
             if( nSum < nMaxW  )
                 nColWidth[nCols - 1] += nMaxW - nSum;
 
-            pColMgr->SetColWidth( 0, static_cast< sal_uInt16 >(nColWidth[0] + (sal_uInt16)nColDist[0]/2) );
-            for( i = 1; i < nCols-1; ++i )
+            pColMgr->SetColWidth( 0, static_cast< sal_uInt16 >(nColWidth[0] + nColDist[0]/2) );
+            for( sal_uInt16 i = 1; i < nCols-1; ++i )
             {
                 long nActDist = (nColDist[i] + nColDist[i - 1]) / 2;
-                pColMgr->SetColWidth( i, (sal_uInt16)nColWidth[i] + (sal_uInt16)nActDist );
+                pColMgr->SetColWidth( i, static_cast< sal_uInt16 >(nColWidth[i] + nActDist ));
             }
             pColMgr->SetColWidth( nCols-1, static_cast< sal_uInt16 >(nColWidth[nCols-1] + nColDist[nCols -2]/2) );
 
@@ -786,8 +786,7 @@ void SwColumnPage::Init()
 
     sal_Int32 nColumnWidthSum = 0;
     // set the widths
-    sal_uInt16 i;
-    for(i = 0; i < nCols; ++i)
+    for(sal_uInt16 i = 0; i < nCols; ++i)
     {
         nColWidth[i] = pColMgr->GetColWidth(i);
         nColumnWidthSum += nColWidth[i];
@@ -801,7 +800,7 @@ void SwColumnPage::Init()
         if(bAutoWidth)
         {
             nColumnWidthSum /= nCols;
-            for(i = 0; i < nCols; ++i)
+            for(sal_uInt16 i = 0; i < nCols; ++i)
                 nColWidth[i] = nColumnWidthSum;
         }
         SwColLineAdj eAdj = pColMgr->GetAdjust();
@@ -822,7 +821,7 @@ void SwColumnPage::Init()
             m_pLineHeightEdit->SetValue( pColMgr->GetLineHeightPercent() );
 
         }
-        m_pLinePosDLB->SelectEntryPos( static_cast< sal_uInt16 >(eAdj - 1) );
+        m_pLinePosDLB->SelectEntryPos( static_cast< sal_Int32 >(eAdj - 1) );
     }
     else
     {
@@ -1001,9 +1000,9 @@ IMPL_LINK( SwColumnPage, GapModify, MetricField*, pMetricFld )
         return 0;
     if(m_pAutoWidthBox->IsChecked())
     {
-        sal_uInt16 nMaxGap = pColMgr->GetActualSize() - nCols * MINLAY;
         OSL_ENSURE(nCols, "Abstand kann nicht ohne Spalten eingestellt werden");
-        nMaxGap /= nCols - 1;
+        const long nMaxGap = static_cast< long >
+            ((pColMgr->GetActualSize() - nCols * MINLAY)/(nCols - 1));
         if(nActValue > nMaxGap)
         {
             nActValue = nMaxGap;
@@ -1017,13 +1016,8 @@ IMPL_LINK( SwColumnPage, GapModify, MetricField*, pMetricFld )
         UpdateCols();
     }
     else
-
     {
-        sal_uInt16 nOffset = 0;
-        if(pFld == &aDistEd2)
-        {
-            nOffset = 1;
-        }
+        const sal_uInt16 nOffset = (pFld == &aDistEd2) ? 1 : 0;
         long nDiff = nActValue - nColDist[nFirstVis + nOffset];
         if(nDiff)
         {
@@ -1140,8 +1134,8 @@ void SwColumnPage::Timeout()
         else if(pModifiedField == &aEd3)
             nChanged += 2;
 
-        long nNewWidth = (sal_uInt16)
-            pModifiedField->DenormalizePercent(pModifiedField->GetValue(FUNIT_TWIP));
+        long nNewWidth = static_cast< long >
+            (pModifiedField->DenormalizePercent(pModifiedField->GetValue(FUNIT_TWIP)));
         long nDiff = nNewWidth - nColWidth[nChanged];
 
         // when it's the last column
@@ -1217,7 +1211,7 @@ void SwColumnPage::ActivatePage(const SfxItemSet& rSet)
             const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get(
                                                                 RES_LR_SPACE );
             const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
-            sal_uInt16 nActWidth = static_cast< sal_uInt16 >(rSize.GetSize().Width()
+            const sal_uInt16 nActWidth = static_cast< sal_uInt16 >(rSize.GetSize().Width()
                             - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetDistance());
 
             if( pColMgr->GetActualSize() != nActWidth)
@@ -1295,7 +1289,7 @@ sal_uInt16* SwColumnPage::GetRanges()
 
 IMPL_LINK( SwColumnPage, SetDefaultsHdl, ValueSet *, pVS )
 {
-    sal_uInt16 nItem = pVS->GetSelectItemId();
+    const sal_uInt16 nItem = pVS->GetSelectItemId();
     if( nItem < 4 )
     {
         m_pCLNrEdt->SetValue( nItem );
@@ -1311,15 +1305,15 @@ IMPL_LINK( SwColumnPage, SetDefaultsHdl, ValueSet *, pVS )
         aDistEd1.SetPrcntValue(0);
         ColModify(0);
         // now set the width ratio to 2 : 1 or 1 : 2 respectively
-        sal_uInt16 nSmall = pColMgr->GetActualSize()  / 3;
+        const long nSmall = static_cast< long >(pColMgr->GetActualSize() / 3);
         if(nItem == 4)
         {
-            aEd2.SetPrcntValue(aEd2.NormalizePercent(long(nSmall)), FUNIT_TWIP);
+            aEd2.SetPrcntValue(aEd2.NormalizePercent(nSmall), FUNIT_TWIP);
             pModifiedField = &aEd2;
         }
         else
         {
-            aEd1.SetPrcntValue(aEd1.NormalizePercent(long(nSmall)), FUNIT_TWIP);
+            aEd1.SetPrcntValue(aEd1.NormalizePercent(nSmall), FUNIT_TWIP);
             pModifiedField = &aEd1;
         }
         bLockUpdate = false;
@@ -1349,7 +1343,7 @@ void ColumnValueSet::UserDraw( const UserDrawEvent& rUDEvt )
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
 
     Rectangle aRect = rUDEvt.GetRect();
-    sal_uInt16  nItemId = rUDEvt.GetItemId();
+    const sal_uInt16 nItemId = rUDEvt.GetItemId();
     long nRectWidth = aRect.GetWidth();
     long nRectHeight = aRect.GetHeight();
 
commit e5734c659f81fa38f3b050fd9fc939d74f3c7da9
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 20:31:28 2014 +0100

    Remove consecutive appends + minor optimizations
    
    Change-Id: I001d958763c5d9104ff9dd24a4d81828e00034c0

diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 7f23c1b..c9774e2 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -350,7 +350,7 @@ void SwCaptionDialog::DrawSample()
             //#i61007# order of captions
             if( !bOrderNumberingFirst )
             {
-                aStr += sFldTypeName;
+                aStr = sFldTypeName;
                 if ( !aStr.isEmpty() )
                     aStr += " ";
             }
@@ -368,7 +368,7 @@ void SwCaptionDialog::DrawSample()
                 OUString sNumber( rSh.GetOutlineNumRule()->
                                 MakeNumString(aNumVector, sal_False ));
                 if( !sNumber.isEmpty() )
-                    (aStr += sNumber) += pFldType->GetDelimiter();
+                    aStr += sNumber + pFldType->GetDelimiter();
             }
 
             switch( nNumFmt )
@@ -384,8 +384,7 @@ void SwCaptionDialog::DrawSample()
             //#i61007# order of captions
             if( bOrderNumberingFirst )
             {
-                aStr += m_pNumberingSeparatorED->GetText();
-                aStr += sFldTypeName;
+                aStr += m_pNumberingSeparatorED->GetText() + sFldTypeName;
             }
 
         }
@@ -418,7 +417,7 @@ SwSequenceOptionDialog::SwSequenceOptionDialog( Window *pParent, SwView &rV,
 
     SwWrtShell &rSh = rView.GetWrtShell();
 
-    OUString sNone(SW_RESSTR(SW_STR_NONE));
+    const OUString sNone(SW_RESSTR(SW_STR_NONE));
 
     m_pLbLevel->InsertEntry(sNone);
     for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
@@ -479,10 +478,9 @@ void SwSequenceOptionDialog::Apply()
 
 OUString  SwSequenceOptionDialog::GetCharacterStyle() const
 {
-    OUString sRet;
     if(m_pLbCharStyle->GetSelectEntryPos())
-        sRet = m_pLbCharStyle->GetSelectEntry();
-    return sRet;
+        return m_pLbCharStyle->GetSelectEntry();
+    return OUString();
 }
 
 void    SwSequenceOptionDialog::SetCharacterStyle(const OUString& rStyle)
commit c9646ebe43b28e1acf32cf97c7eb3de113bf4774
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 19:41:55 2014 +0100

    Constify and reduce scope
    
    Change-Id: I42074930dd59875bea4f1b3c0d73400020ea7485

diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 6e4f8ec..7f23c1b 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -131,8 +131,8 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
     m_pAutoCaptionButton->SetClickHdl(LINK(this, SwCaptionDialog, CaptionHdl));
 
     m_pCategoryBox->InsertEntry( m_sNone );
-    sal_uInt16 i, nCount = pMgr->GetFldTypeCount();
-    for (i = 0; i < nCount; i++)
+    sal_uInt16 nCount = pMgr->GetFldTypeCount();
+    for (sal_uInt16 i = 0; i < nCount; i++)
     {
         SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i );
         if( pType->Which() == RES_SETEXPFLD &&
@@ -195,7 +195,7 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
     sal_uInt16 nSelFmt = SVX_NUM_ARABIC;
     nCount = pMgr->GetFldTypeCount();
     SwFieldType* pFldType;
-    for ( i = nCount; i; )
+    for ( sal_uInt16 i = nCount; i; )
     {
         pFldType = pMgr->GetFldType(USHRT_MAX, --i);
         if( pFldType->GetName().equals(m_pCategoryBox->GetText()) )
@@ -206,10 +206,10 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
     }
 
     nCount = pMgr->GetFormatCount(TYP_SEQFLD, false);
-    for ( i = 0; i < nCount; ++i )
+    for ( sal_uInt16 i = 0; i < nCount; ++i )
     {
         m_pFormatBox->InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) );
-        sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i);
+        const sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i);
         m_pFormatBox->SetEntryData( i, reinterpret_cast<void*>( nFmtId ) );
         if( nFmtId == nSelFmt )
             m_pFormatBox->SelectEntryPos( i );
@@ -342,7 +342,7 @@ void SwCaptionDialog::DrawSample()
     bool bNone = sFldTypeName == m_sNone;
     if( !bNone )
     {
-        sal_uInt16 nNumFmt = (sal_uInt16)(sal_uIntPtr)m_pFormatBox->GetEntryData(
+        const sal_uInt16 nNumFmt = (sal_uInt16)(sal_uIntPtr)m_pFormatBox->GetEntryData(
                                         m_pFormatBox->GetSelectEntryPos() );
         if( SVX_NUM_NUMBER_NONE != nNumFmt )
         {
@@ -499,7 +499,7 @@ bool CategoryBox::PreNotify( NotifyEvent& rNEvt )
     {
         const KeyEvent* pEvent = rNEvt.GetKeyEvent();
         const KeyCode&  rKeyCode = pEvent->GetKeyCode();
-        sal_uInt16 nTmpCode = rKeyCode.GetFullCode() & ~KEY_ALLMODTYPE;
+        const sal_uInt16 nTmpCode = rKeyCode.GetFullCode() & ~KEY_ALLMODTYPE;
 
         if(nTmpCode != KEY_BACKSPACE && nTmpCode != KEY_RETURN
                 && nTmpCode != KEY_TAB && nTmpCode != KEY_ESCAPE)
commit 9b1fd4678d657282136ccf64b0f13e7371cb4302
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 19:30:18 2014 +0100

    Remove unneeded (and probably wrong) cast to sal_Bool
    
    Change-Id: I8fa169749922d1ea015c9009f5a54099bdf40f93

diff --git a/sw/source/ui/frmdlg/frmdlg.cxx b/sw/source/ui/frmdlg/frmdlg.cxx
index e7d8d24..add00da 100644
--- a/sw/source/ui/frmdlg/frmdlg.cxx
+++ b/sw/source/ui/frmdlg/frmdlg.cxx
@@ -78,7 +78,7 @@ SwFrmDlg::SwFrmDlg( SfxViewFrame*       pViewFrame,
     , m_nBorderId(0)
 {
     sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
-    m_bHTMLMode = static_cast< sal_Bool >(nHtmlMode & HTMLMODE_ON);
+    m_bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
 
     // example font for both example TabPages
 
commit fce156679073a2a05925d59ecb0b916fe177d3d0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 19:24:56 2014 +0100

    OUString: constify and remove unneeded casts
    
    Change-Id: I89825bbb4b0255c5525bc4680194ab0ce37f7f7b

diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 7794d1a..ffadcf8 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -1375,8 +1375,8 @@ sal_Int32 SwFrmPage::FillPosLB(const FrmMap* _pMap,
                             const sal_Int16 _nRel,
                             ListBox& _rLB )
 {
-    OUString sSelEntry, sOldEntry;
-    sOldEntry = _rLB.GetSelectEntry();
+    OUString sSelEntry;
+    const OUString sOldEntry = _rLB.GetSelectEntry();
 
     _rLB.Clear();
 
@@ -1443,7 +1443,7 @@ sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
     {
         if (_pMap == aVAsCharHtmlMap || _pMap == aVAsCharMap)
         {
-            OUString sOldEntry(_rLB.GetSelectEntry());
+            const OUString sOldEntry(_rLB.GetSelectEntry());
             const size_t nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
             SvxSwFramePosString::StringId eStrId = _pMap[_nLBSelPos].eStrId;
 
@@ -1464,7 +1464,7 @@ sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
                                                                 bIsVerticalFrame,
                                                                 bIsVerticalL2R,
                                                                 bIsInRightToLeft);
-                            OUString sEntry = aFramePosString.GetString(sStrId1);
+                            const OUString sEntry = aFramePosString.GetString(sStrId1);
                             sal_Int32 nPos = _rLB.InsertEntry(sEntry);
                             _rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]);
                             if (_pMap[nMapPos].nAlign == _nAlign)
@@ -1529,7 +1529,7 @@ sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
                                                                 bIsVerticalFrame,
                                                                 bIsVerticalL2R,
                                                                 bIsInRightToLeft);
-                            OUString sEntry = aFramePosString.GetString(eStrId1);
+                            const OUString sEntry = aFramePosString.GetString(eStrId1);
                             sal_Int32 nPos = _rLB.InsertEntry(sEntry);
                             _rLB.SetEntryData(nPos, &aRelationMap[nRelPos]);
                             if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == _nRel)
@@ -1661,8 +1661,8 @@ sal_Int32 SwFrmPage::GetMapPos( const FrmMap *pMap, ListBox &rAlignLB )
     {
         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
         {
-            size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
-            OUString sSelEntry(rAlignLB.GetSelectEntry());
+            const size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
+            const OUString sSelEntry(rAlignLB.GetSelectEntry());
 
             for (size_t i = 0; i < nMapCount; i++)
             {
@@ -2791,10 +2791,10 @@ bool SwFrmURLPage::FillItemSet(SfxItemSet &rSet)
         pFmtURL = new SwFmtURL();
 
     {
-        OUString sText = pURLED->GetText();
+        const OUString sText = pURLED->GetText();
 
         if( pFmtURL->GetURL() != sText ||
-            OUString(pFmtURL->GetName()) != pNameED->GetText() ||
+            pFmtURL->GetName() != pNameED->GetText() ||
             pServerCB->IsChecked() != pFmtURL->IsServerMap() )
         {
             pFmtURL->SetURL( sText, pServerCB->IsChecked() );
@@ -2809,7 +2809,7 @@ bool SwFrmURLPage::FillItemSet(SfxItemSet &rSet)
         bModified = sal_True;
     }
 
-    if(OUString(pFmtURL->GetTargetFrameName()) != pFrameCB->GetText())
+    if(pFmtURL->GetTargetFrameName() != pFrameCB->GetText())
     {
         pFmtURL->SetTargetFrameName(pFrameCB->GetText());
         bModified = sal_True;
@@ -2831,7 +2831,7 @@ IMPL_LINK_NOARG(SwFrmURLPage, InsertFileHdl)
 
     try
     {
-        OUString sTemp(pURLED->GetText());
+        const OUString sTemp(pURLED->GetText());
         if(!sTemp.isEmpty())
             xFP->setDisplayDirectory(sTemp);
     }
@@ -3194,7 +3194,7 @@ IMPL_LINK(SwFrmAddPage, ChainModifyHdl, ListBox*, pBox)
                         aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
         lcl_InsertVectors(rChangeLB,
                 aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
-        OUString sToSelect = bNextBox ? sCurrentPrevChain : sCurrentNextChain;
+        const OUString sToSelect = bNextBox ? sCurrentPrevChain : sCurrentNextChain;
         if(rChangeLB.GetEntryPos(sToSelect) != LISTBOX_ENTRY_NOTFOUND)
             rChangeLB.SelectEntry(sToSelect);
         else
commit c697b0741a014e67cde1f4e2ce79c2ad8f6a1276
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 19:04:04 2014 +0100

    sal_uInt16 to size_t/sal_Int32
    
    Change-Id: I49a479d1fca258d5d3e713454d84a2fcb6fd74c1

diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 70cf51c..7794d1a 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -440,7 +440,7 @@ static void lcl_InsertVectors(ListBox& rBox,
     const ::std::vector< OUString >& rNext, const ::std::vector< OUString >& rRemain)
 {
     ::std::vector< OUString >::const_iterator aIt;
-    sal_uInt16 nEntry = 0;
+    sal_Int32 nEntry = 0;
     for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt)
         nEntry = rBox.InsertEntry(*aIt);
     for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt)
@@ -522,8 +522,7 @@ static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(SvxSwFramePo
             {SwFPos::REL_FRM_TOP,    SwFPos::REL_FRM_LEFT },
             {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
         };
-        sal_uInt16 nIndex;
-        for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
+        for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
         {
             if(aHoriIds[nIndex].eHori == eStringId)
             {
@@ -531,8 +530,7 @@ static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(SvxSwFramePo
                 return eStringId;
             }
         }
-        nIndex = 0;
-        for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
+        for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
         {
             // --> OD 2009-08-31 #mongolianlayout#
             if ( !bVerticalL2R )
@@ -562,8 +560,8 @@ static sal_uLong lcl_GetLBRelationsForRelations( const sal_Int16 _nRel )
 {
     sal_uLong nLBRelations = 0L;
 
-    sal_uInt16 nRelMapSize = SAL_N_ELEMENTS(aRelationMap);
-    for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
+    const size_t nRelMapSize = SAL_N_ELEMENTS(aRelationMap);
+    for ( size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
     {
         if ( aRelationMap[nRelMapPos].nRelation == _nRel )
         {
@@ -1065,7 +1063,7 @@ bool SwFrmPage::FillItemSet(SfxItemSet &rSet)
         SwFmtHoriOrient aHoriOrient( (const SwFmtHoriOrient&)
                                                 rOldSet.Get(RES_HORI_ORIENT) );
 
-        sal_uInt16 nMapPos = static_cast<sal_uInt16>(GetMapPos(pHMap, *m_pHorizontalDLB));
+        const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
         const sal_Int16 eHOri = GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB);
         const sal_Int16 eRel = GetRelation(pHMap, *m_pHoriRelationLB);
 
@@ -1101,7 +1099,7 @@ bool SwFrmPage::FillItemSet(SfxItemSet &rSet)
         SwFmtVertOrient aVertOrient( (const SwFmtVertOrient&)
                                                 rOldSet.Get(RES_VERT_ORIENT) );
 
-        sal_uInt16 nMapPos = static_cast<sal_uInt16>(GetMapPos(pVMap, *m_pVerticalDLB));
+        const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
         const sal_Int16 eVOri = GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB);
         const sal_Int16 eRel = GetRelation(pVMap, *m_pVertRelationLB);
 
@@ -1446,7 +1444,7 @@ sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
         if (_pMap == aVAsCharHtmlMap || _pMap == aVAsCharMap)
         {
             OUString sOldEntry(_rLB.GetSelectEntry());
-            sal_uInt16 nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
+            const size_t nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
             SvxSwFramePosString::StringId eStrId = _pMap[_nLBSelPos].eStrId;
 
             for (size_t nMapPos = 0; nMapPos < nMapCount; nMapPos++)
@@ -1454,7 +1452,7 @@ sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
                 if (_pMap[nMapPos].eStrId == eStrId)
                 {
                     nLBRelations = _pMap[nMapPos].nLBRelations;
-                    for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
+                    for (size_t nRelPos = 0; nRelPos < nRelCount; ++nRelPos)
                     {
                         if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation)
                         {
@@ -1498,8 +1496,6 @@ sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
         }
         else
         {
-            sal_uInt16 nRelCount = SAL_N_ELEMENTS(aRelationMap);
-
             // special handling for map <aVCharMap>,
             // because its ambigous in its <eStrId>/<eMirrorStrId>.
             if ( _pMap == aVCharMap )
@@ -1515,11 +1511,13 @@ sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
                 nLBRelations = _pMap[_nLBSelPos].nLBRelations;
             }
 
+            const size_t nRelCount = SAL_N_ELEMENTS(aRelationMap);
+
             for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
             {
                 if (nLBRelations & nBit)
                 {
-                    for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
+                    for (size_t nRelPos = 0; nRelPos < nRelCount; ++nRelPos)
                     {
                         if (aRelationMap[nRelPos].nLBRelation == nBit)
                         {
@@ -1796,7 +1794,7 @@ IMPL_LINK_NOARG(SwFrmPage, RangeModifyHdl)
     SwFlyFrmAttrMgr aMgr( bNew, pSh, (const SwAttrSet&)GetItemSet() );
     SvxSwFrameValidation        aVal;
 
-    aVal.nAnchorType = static_cast< sal_uInt16 >(GetAnchor());
+    aVal.nAnchorType = static_cast< sal_Int16 >(GetAnchor());
     aVal.bAutoHeight = m_pAutoHeightCB->IsChecked();
     aVal.bAutoWidth = m_pAutoWidthCB->IsChecked();
     aVal.bMirror = m_pMirrorPagesCB->IsChecked();
@@ -1805,7 +1803,7 @@ IMPL_LINK_NOARG(SwFrmPage, RangeModifyHdl)
     if ( pHMap )
     {
         // alignment horizonal
-        sal_uInt16 nMapPos = static_cast<sal_uInt16>(GetMapPos(pHMap, *m_pHorizontalDLB));
+        const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
         aVal.nHoriOrient = GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB);
         aVal.nHRelOrient = GetRelation(pHMap, *m_pHoriRelationLB);
     }
@@ -1815,7 +1813,7 @@ IMPL_LINK_NOARG(SwFrmPage, RangeModifyHdl)
     if ( pVMap )
     {
         // alignment vertical
-        sal_uInt16 nMapPos = static_cast<sal_uInt16>(GetMapPos(pVMap, *m_pVerticalDLB));
+        const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
         aVal.nVertOrient = GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB);
         aVal.nVRelOrient = GetRelation(pVMap, *m_pVertRelationLB);
     }
@@ -1851,7 +1849,7 @@ IMPL_LINK_NOARG(SwFrmPage, RangeModifyHdl)
         const SwFmtCol& rCol = (const SwFmtCol&)GetTabDialog()->GetExampleSet()->Get(RES_COL);
         if ( rCol.GetColumns().size() > 1 )
         {
-            for ( sal_uInt16 i = 0; i < rCol.GetColumns().size(); ++i )
+            for ( size_t i = 0; i < rCol.GetColumns().size(); ++i )
             {
                 aVal.nMinWidth += rCol.GetColumns()[i].GetLeft() +
                                   rCol.GetColumns()[i].GetRight() +
@@ -1942,7 +1940,7 @@ IMPL_LINK( SwFrmPage, PosHdl, ListBox *, pLB )
     FixedText *pRelFT = bHori ? m_pHoriRelationFT : m_pVertRelationFT;
     FrmMap *pMap = bHori ? pHMap : pVMap;
 
-    sal_uInt16 nMapPos = static_cast<sal_uInt16>(GetMapPos(pMap, *pLB));
+    const sal_Int32 nMapPos = GetMapPos(pMap, *pLB);
     const sal_Int16 nAlign = GetAlignment(pMap, nMapPos, *pLB, *pRelLB);
 
     if (bHori)
@@ -2123,7 +2121,7 @@ void SwFrmPage::UpdateExample()
     sal_Int32 nPos = m_pHorizontalDLB->GetSelectEntryPos();
     if ( pHMap && nPos != LISTBOX_ENTRY_NOTFOUND )
     {
-        sal_uInt16 nMapPos = static_cast<sal_uInt16>(GetMapPos(pHMap, *m_pHorizontalDLB));
+        const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
         m_pExampleWN->SetHAlign(GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB));
         m_pExampleWN->SetHoriRel(GetRelation(pHMap, *m_pHoriRelationLB));
     }
@@ -2131,7 +2129,7 @@ void SwFrmPage::UpdateExample()
     nPos = m_pVerticalDLB->GetSelectEntryPos();
     if ( pVMap && nPos != LISTBOX_ENTRY_NOTFOUND )
     {
-        sal_uInt16 nMapPos = static_cast<sal_uInt16>(GetMapPos(pVMap, *m_pVerticalDLB));
+        const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
         m_pExampleWN->SetVAlign(GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB));
         m_pExampleWN->SetVertRel(GetRelation(pVMap, *m_pVertRelationLB));
     }
@@ -2141,7 +2139,7 @@ void SwFrmPage::UpdateExample()
     long nYPos = static_cast< long >(m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP)));
     m_pExampleWN->SetRelPos(Point(nXPos, nYPos));
 
-    m_pExampleWN->SetAnchor( static_cast< sal_uInt16 >(GetAnchor()) );
+    m_pExampleWN->SetAnchor( static_cast< sal_Int16 >(GetAnchor()) );
     m_pExampleWN->Invalidate();
 }
 
@@ -2409,7 +2407,7 @@ SfxTabPage* SwGrfExtPage::Create( Window *pParent, const SfxItemSet &rSet )
 void SwGrfExtPage::Reset(const SfxItemSet &rSet)
 {
     const SfxPoolItem* pItem;
-    sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
+    const sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
     bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
 
     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_GRF_CONNECT, true, &pItem)
@@ -2452,9 +2450,8 @@ void SwGrfExtPage::ActivatePage(const SfxItemSet& rSet)
             ;
         }
 
-        sal_uInt16 nPos = ((const SwMirrorGrf* )pItem)->IsGrfToggle() ? 1 : 0;
-        nPos += (eMirror == RES_MIRROR_GRAPH_VERT || eMirror == RES_MIRROR_GRAPH_BOTH)
-                 ? 2 : 0;
+        const int nPos = (((const SwMirrorGrf* )pItem)->IsGrfToggle() ? 1 : 0)
+            + ((eMirror == RES_MIRROR_GRAPH_VERT || eMirror == RES_MIRROR_GRAPH_BOTH) ? 2 : 0);
 
         bEnableMirrorRB = nPos != 0;
 
@@ -3062,7 +3059,7 @@ void SwFrmAddPage::Reset(const SfxItemSet &rSet )
     if ( rSet.GetItemState(RES_TEXT_VERT_ADJUST) > SFX_ITEM_AVAILABLE )
     {
         SdrTextVertAdjust nAdjust = ((const SdrTextVertAdjustItem&)rSet.Get(RES_TEXT_VERT_ADJUST)).GetValue();
-        sal_uInt16 nPos = 0;
+        sal_Int32 nPos = 0;
         switch(nAdjust)
         {
             case SDRTEXTVERTADJUST_TOP:      nPos = 0;   break;
commit 6a502f3494dcf9f72bc92f6f4ffb5e5f7ca4ebb6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Mar 29 18:06:17 2014 +0100

    sal_uInt16/short to sal_Int16 + minor optimizations
    
    Change-Id: Ia75c12ecdcd33d2013e8c138dfcbb07b8be6a551

diff --git a/sw/source/core/uibase/inc/frmpage.hxx b/sw/source/core/uibase/inc/frmpage.hxx
index 1b1b1e1..e2f0356 100644
--- a/sw/source/core/uibase/inc/frmpage.hxx
+++ b/sw/source/core/uibase/inc/frmpage.hxx
@@ -118,10 +118,10 @@ class SwFrmPage: public SfxTabPage
     const SwPosition* mpToCharCntntPos;
 
     // old alignment
-    short        nOldH;
-    short    nOldHRel;
-    short        nOldV;
-    short    nOldVRel;
+    sal_Int16 nOldH;
+    sal_Int16 nOldHRel;
+    sal_Int16 nOldV;
+    sal_Int16 nOldVRel;
 
     FrmMap* pVMap;
     FrmMap* pHMap;
@@ -137,8 +137,8 @@ class SwFrmPage: public SfxTabPage
     DECL_LINK(AnchorTypeHdl, void *);
     DECL_LINK( PosHdl, ListBox * );
     DECL_LINK( RelHdl, ListBox * );
-    void            InitPos(RndStdIds eId, sal_uInt16 nH, sal_uInt16 nHRel,
-                            sal_uInt16 nV,  sal_uInt16 nVRel,
+    void            InitPos(RndStdIds eId, sal_Int16 nH, sal_Int16 nHRel,
+                            sal_Int16 nV, sal_Int16 nVRel,
                             long   nX,  long   nY);
 
     DECL_LINK(RealSizeHdl, void *);
@@ -156,20 +156,20 @@ class SwFrmPage: public SfxTabPage
     // OD 12.11.2003 #i22341# - adjustment to handle maps, that are ambigous
     //                          in the alignment.
     sal_Int32       FillPosLB( const FrmMap* _pMap,
-                               const sal_uInt16 _nAlign,
-                               const sal_uInt16 _nRel,
+                               const sal_Int16 _nAlign,
+                               const sal_Int16 _nRel,
                                ListBox& _rLB );
     // OD 14.11.2003 #i22341# - adjustment to handle maps, that are ambigous
     //                          in their string entries.
     sal_uLong       FillRelLB( const FrmMap* _pMap,
                                const sal_uInt16 _nLBSelPos,
-                               const sal_uInt16 _nAlign,
-                               sal_uInt16 _nRel,
+                               const sal_Int16 _nAlign,
+                               const sal_Int16 _nRel,
                                ListBox& _rLB,
                                FixedText& _rFT );
     sal_Int32       GetMapPos( const FrmMap *pMap, ListBox &rAlignLB );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list