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

Matteo Casalin matteo.casalin at yahoo.com
Sun Apr 6 13:20:31 PDT 2014


 sw/source/ui/dbui/mmlayoutpage.cxx |  116 ++++++++++++++-----------------------
 sw/source/ui/dialog/ascfldlg.cxx   |   27 ++++----
 sw/source/ui/dialog/uiregionsw.cxx |  105 ++++++++++++++++-----------------
 sw/source/ui/envelp/envfmt.cxx     |   30 ++++-----
 sw/source/ui/envelp/envlop1.cxx    |   48 +++++++--------
 sw/source/ui/envelp/envprt.cxx     |    6 -
 sw/source/ui/envelp/envprt.hxx     |    2 
 sw/source/ui/envelp/label1.cxx     |   39 ++++++------
 8 files changed, 171 insertions(+), 202 deletions(-)

New commits:
commit dab78653430200bab325db6348734e570a34fe12
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Apr 5 23:21:44 2014 +0200

    OUString: constify and avoid concatenated appends
    
    Change-Id: I1bef9af92107d4cb4ac869dd0f6cbd2853302330

diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 86192c6..4cbcadf 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -114,7 +114,7 @@ SwMailMergeLayoutPage::SwMailMergeLayoutPage( SwMailMergeWizard* _pParent) :
     uno::Sequence< beans::PropertyValue > aValues(1);
     beans::PropertyValue* pValues = aValues.getArray();
     pValues[0].Name = "FilterName";
-    pValues[0].Value <<= OUString(pSfxFlt->GetFilterName());
+    pValues[0].Value <<= pSfxFlt->GetFilterName();
 
     uno::Reference< frame::XStorable > xStore( pView->GetDocShell()->GetModel(), uno::UNO_QUERY);
     xStore->storeToURL( m_sExampleURL, aValues   );
@@ -302,14 +302,10 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame(
         SwFldMgr aFldMgr(&rShell);
         //create a database string source.command.commandtype.column
         const SwDBData& rData = rConfigItem.GetCurrentDBData();
-        OUString sDBName(rData.sDataSource);
-        sDBName += OUString(DB_DELIM);
-        sDBName += rData.sCommand;
-        sDBName += OUString(DB_DELIM);
-        OUString sDatabaseConditionPrefix(sDBName);
-        sDatabaseConditionPrefix = sDatabaseConditionPrefix.replace(DB_DELIM, '.');
-        sDBName += OUString::number(rData.nCommandType);
-        sDBName += OUString(DB_DELIM);
+        OUString sDBName(rData.sDataSource + OUString(DB_DELIM)
+            + rData.sCommand + OUString(DB_DELIM));
+        const OUString sDatabaseConditionPrefix(sDBName.replace(DB_DELIM, '.'));
+        sDBName += OUString::number(rData.nCommandType) + OUString(DB_DELIM);
 
         // if only the country is in an address line the
         // paragraph has to be hidden depending on the
@@ -321,12 +317,13 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame(
         bool bSpecialReplacementForCountry = (!bIncludeCountry || !rExcludeCountry.isEmpty());
 
         const ResStringArray& rHeaders = rConfigItem.GetDefaultAddressHeaders();
-        OUString sCountryColumn = rHeaders.GetString(MM_PART_COUNTRY);
         Sequence< OUString> aAssignment =
                         rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
         const OUString* pAssignment = aAssignment.getConstArray();
-        if(aAssignment.getLength() > MM_PART_COUNTRY && !aAssignment[MM_PART_COUNTRY].isEmpty())
-            sCountryColumn = aAssignment[MM_PART_COUNTRY];
+        const OUString sCountryColumn(
+            (aAssignment.getLength() > MM_PART_COUNTRY && !aAssignment[MM_PART_COUNTRY].isEmpty())
+            ? aAssignment[MM_PART_COUNTRY]
+            : rHeaders.GetString(MM_PART_COUNTRY));
 
         OUString sHideParagraphsExpression;
         SwAddressIterator aIter(aBlocks[0]);
@@ -348,8 +345,7 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame(
                         break;
                     }
                 }
-                OUString sDB(sDBName);
-                sDB += sConvertedColumn;
+                const OUString sDB(sDBName + sConvertedColumn);
 
                 if(!sHideParagraphsExpression.isEmpty())
                    sHideParagraphsExpression += " AND ";
@@ -358,19 +354,18 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame(
                 if( bSpecialReplacementForCountry && sCountryColumn == sConvertedColumn )
                 {
                     // now insert a hidden paragraph field
-                    OUString sExpression;
                     if( !rExcludeCountry.isEmpty() )
                     {
-                        sExpression = "[" + sDatabaseConditionPrefix + sCountryColumn + "]";
-
-                        OUString sCondition = sExpression + " != \"" + rExcludeCountry + "\"";
-
-                        SwInsertFld_Data aData(TYP_CONDTXTFLD, 0, sCondition, sExpression, 0, &rShell );
+                        const OUString sExpression("[" + sDatabaseConditionPrefix + sCountryColumn + "]");
+                        SwInsertFld_Data aData(TYP_CONDTXTFLD, 0,
+                                               sExpression + " != \"" + rExcludeCountry + "\"",
+                                               sExpression,
+                                               0, &rShell );
                         aFldMgr.InsertFld( aData );
                     }
                     else
                     {
-                        SwInsertFld_Data aData(TYP_HIDDENPARAFLD, 0, sExpression, aEmptyOUStr, 0, &rShell );
+                        SwInsertFld_Data aData(TYP_HIDDENPARAFLD, 0, "", "", 0, &rShell );
                         aFldMgr.InsertFld( aData );
                     }
                 }
@@ -462,7 +457,6 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
     }
     //now insert the greeting text - if we have any?
     const sal_Bool bIndividual = rConfigItem.IsIndividualGreeting(sal_False);
-    OUString sGreeting;
     if(bIndividual)
     {
         //lock expression fields - prevents hiding of the paragraph to insert into
@@ -477,8 +471,8 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
                 sal_Int32 nCurrent = rConfigItem.GetCurrentGreeting((SwMailMergeConfigItem::Gender)eGender);
                 if( nCurrent >= 0 && nCurrent < aEntries.getLength())
                 {
-                    sGreeting = aEntries[nCurrent];
-                    rShell.Insert(sGreeting);
+                    // Greeting
+                    rShell.Insert(aEntries[nCurrent]);
                     break;
                 }
             }
@@ -490,33 +484,19 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
             //are to be inserted
 
             //name of the gender column
-            OUString sGenderColumn = rConfigItem.GetAssignedColumn(MM_PART_GENDER);
-            OUString sNameColumn = rConfigItem.GetAssignedColumn(MM_PART_LASTNAME);
+            const OUString sGenderColumn = rConfigItem.GetAssignedColumn(MM_PART_GENDER);
+            const OUString sNameColumn = rConfigItem.GetAssignedColumn(MM_PART_LASTNAME);
 
             const OUString& rFemaleGenderValue = rConfigItem.GetFemaleGenderValue();
             sal_Bool bHideEmptyParagraphs = rConfigItem.IsHideEmptyParagraphs();
             const SwDBData& rData = rConfigItem.GetCurrentDBData();
-            OUString sConditionBase(rData.sDataSource);
-            sConditionBase += ".";
-            sConditionBase += rData.sCommand;
-            sConditionBase += ".";
-            //split the name column from here
-            OUString sNameColumnBase(sConditionBase);
-
-            sConditionBase += sGenderColumn;
-            sConditionBase += "]";
-            sConditionBase = "[" + sConditionBase;
-
-            sNameColumnBase += sNameColumn;
-            sNameColumnBase += "]";
-            sNameColumnBase = "[" + sNameColumnBase;
-
-            OUString sDBName(rData.sDataSource);
-            sDBName += OUString(DB_DELIM);
-            sDBName += rData.sCommand;
-            sDBName += OUString(DB_DELIM);
-            sDBName += OUString::number(rData.nCommandType);
-            sDBName += OUString(DB_DELIM);
+            const OUString sCommonBase(rData.sDataSource + "." + rData.sCommand + ".");
+            const OUString sConditionBase("[" + sCommonBase + sGenderColumn + "]");
+            const OUString sNameColumnBase("[" + sCommonBase + sNameColumn + "]");
+
+            const OUString sDBName(rData.sDataSource + OUString(DB_DELIM)
+                + rData.sCommand + OUString(DB_DELIM)
+                + OUString::number(rData.nCommandType) + OUString(DB_DELIM));
 
 //          Female:  [database.sGenderColumn] != "rFemaleGenderValue" && [database.NameColumn]
 //          Male:    [database.sGenderColumn] == "rFemaleGenderValue" && [database.rGenderColumn]
@@ -531,25 +511,19 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
                 sal_Int32 nCurrent = rConfigItem.GetCurrentGreeting((SwMailMergeConfigItem::Gender)eGender);
                 if( nCurrent >= 0 && nCurrent < aEntries.getLength())
                 {
-                    sGreeting = aEntries[nCurrent];
-                    OUString sCondition(sConditionBase);
+                    const OUString sGreeting = aEntries[nCurrent];
+                    OUString sCondition;
                     OUString sHideParagraphsExpression;
                     switch(eGender)
                     {
                         case  SwMailMergeConfigItem::FEMALE:
-                            sCondition += " != \"";
-                            sCondition += rFemaleGenderValue;
-                            sCondition += "\" OR NOT ";
-                            sCondition += sNameColumnBase;
-
-                            sHideParagraphsExpression += "!";
-                            sHideParagraphsExpression += sNameColumnBase;
+                            sCondition = sConditionBase + " != \"" + rFemaleGenderValue
+                                + "\" OR NOT " + sNameColumnBase;
+                            sHideParagraphsExpression = "!" + sNameColumnBase;
                         break;
                         case  SwMailMergeConfigItem::MALE:
-                            sCondition += " == \"";
-                            sCondition += rFemaleGenderValue;
-                            sCondition += "\" OR NOT ";
-                            sCondition += sNameColumnBase;
+                            sCondition = sConditionBase + " == \"" + rFemaleGenderValue
+                                + "\" OR NOT " + sNameColumnBase;
                         break;
                         case  SwMailMergeConfigItem::NEUTRAL:
                             sCondition = sNameColumnBase;
@@ -578,7 +552,6 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
                         SwMergeAddressItem aItem = aIter.Next();
                         if(aItem.bIsColumn)
                         {
-                            OUString sDB(sDBName);
                             OUString sConvertedColumn = aItem.sText;
                             for(sal_uInt32 nColumn = 0;
                                     nColumn < rHeaders.Count() &&
@@ -592,8 +565,9 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
                                     break;
                                 }
                             }
-                            sDB += sConvertedColumn;
-                            SwInsertFld_Data aData(TYP_DBFLD, 0, sDB, aEmptyOUStr, 0, &rShell );
+                            SwInsertFld_Data aData(TYP_DBFLD, 0,
+                                sDBName + sConvertedColumn,
+                                aEmptyOUStr, 0, &rShell );
                             aFldMgr.InsertFld( aData );
                         }
                         else
@@ -613,9 +587,9 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
     {
         Sequence< OUString> aEntries = rConfigItem.GetGreetings(SwMailMergeConfigItem::NEUTRAL);
         sal_Int32 nCurrent = rConfigItem.GetCurrentGreeting(SwMailMergeConfigItem::NEUTRAL);
-        if( nCurrent >= 0 && nCurrent < aEntries.getLength())
-            sGreeting = aEntries[nCurrent];
-        rShell.Insert(sGreeting);
+        // Greeting
+        rShell.Insert(( nCurrent >= 0 && nCurrent < aEntries.getLength() )
+            ? aEntries[nCurrent] : OUString());
     }
     // now insert a new paragraph here if necessary
     if(bSplitNode)
commit 7493a4ad64ebeb0569e5efa3c8d9719f22cd1275
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Apr 4 07:12:22 2014 +0200

    sal_uInt16 to sal_uInt32
    
    Change-Id: I4cd153b38a02d7b1d58877134857dd9825b6ace5

diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 416ef7b..86192c6 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -336,8 +336,9 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame(
             if(aItem.bIsColumn)
             {
                 OUString sConvertedColumn = aItem.sText;
-                for(sal_uInt16 nColumn = 0;
-                        nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+                for(sal_uInt32 nColumn = 0;
+                        nColumn < rHeaders.Count() &&
+                        nColumn < static_cast<sal_uInt32>(aAssignment.getLength());
                                                                                     ++nColumn)
                 {
                     if (rHeaders.GetString(nColumn).equals(aItem.sText) &&
@@ -579,8 +580,9 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
                         {
                             OUString sDB(sDBName);
                             OUString sConvertedColumn = aItem.sText;
-                            for(sal_uInt16 nColumn = 0;
-                                    nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+                            for(sal_uInt32 nColumn = 0;
+                                    nColumn < rHeaders.Count() &&
+                                    nColumn < static_cast<sal_uInt32>(aAssignment.getLength());
                                                                                                 ++nColumn)
                             {
                                 if (rHeaders.GetString(nColumn).equals(aItem.sText) &&
commit 487099327b957fc55ae643967eec9a353a1f954f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 23:58:59 2014 +0200

    Avoid concatenated OUString appends
    
    Change-Id: Ib1daffc252bf389c04cad8ae84f14c9b99c852b9

diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index b93c7e4..a1d1295 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -276,11 +276,7 @@ void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions )
             if( -1 != nEnd )
                 GetExtraData() = GetExtraData().replaceAt( nStt, nEnd - nStt + 1, "" );
         }
-        OUString sTmp(GetExtraData());
-        sTmp += sFindNm;
-        sTmp += sData;
-        sTmp += OUString(cDialogExtraDataClose);
-        GetExtraData() = sTmp;
+        GetExtraData() += sFindNm + sData + OUString(cDialogExtraDataClose);
     }
 }
 
commit 96fb465431dab1362f10b8c7d0981db26b343f01
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 23:42:25 2014 +0200

    Reduce scope
    
    Change-Id: Ib49437559d08f41a111dc6348939a1b82564f1a5

diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index 5dc9cd4..b93c7e4 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -43,11 +43,16 @@
 
 using namespace ::com::sun::star;
 
+namespace
+{
+
 const sal_Unicode cDialogExtraDataClose = '}';
 const char sDialogImpExtraData[] = "EncImpDlg:{";
 const char sDialogExpExtraData[] = "EncExpDlg:{";
 const sal_Int32 nDialogExtraDataLen = 11;      // 12345678901
 
+}
+
 SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
                                     SvStream* pStream )
     : SfxModalDialog(pParent, "AsciiFilterDialog", "modules/swriter/ui/asciifilterdialog.ui")
commit 2644ccd1f4b2178f6d3db642e31479f92072c9ef
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 23:40:01 2014 +0200

    Use proper types and constify
    
    Change-Id: Iff4783bbe386fdc0aff2a2b722d3390277e5fdea

diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index 1b09a0b..5dc9cd4 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -46,7 +46,7 @@ using namespace ::com::sun::star;
 const sal_Unicode cDialogExtraDataClose = '}';
 const char sDialogImpExtraData[] = "EncImpDlg:{";
 const char sDialogExpExtraData[] = "EncExpDlg:{";
-const sal_uInt16 nDialogExtraDataLen = 11;      // 12345678901
+const sal_Int32 nDialogExtraDataLen = 11;      // 12345678901
 
 SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
                                     SvStream* pStream )
@@ -88,8 +88,8 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
     if( pStream )
     {
         char aBuffer[ 4098 ];
-        sal_uLong nOldPos = pStream->Tell();
-        sal_uLong nBytesRead = pStream->Read( aBuffer, 4096 );
+        const sal_uLong nOldPos = pStream->Tell();
+        const sal_uLong nBytesRead = pStream->Read( aBuffer, 4096 );
         pStream->Seek( nOldPos );
 
         if( nBytesRead <= 4096 )
@@ -99,7 +99,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
         }
 
         bool bCR = false, bLF = false, bNullChar = false;
-        for( sal_uInt16 nCnt = 0; nCnt < nBytesRead; ++nCnt )
+        for( sal_uLong nCnt = 0; nCnt < nBytesRead; ++nCnt )
             switch( aBuffer[ nCnt ] )
             {
                 case 0x0:   bNullChar = true; break;
@@ -130,7 +130,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
             }
         }
 
-        sal_uInt16 nAppScriptType = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() );
+        const sal_uInt16 nAppScriptType = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() );
         SwDoc* pDoc = rDocSh.GetDoc();
 
         // initialize language
@@ -139,7 +139,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
             {
                 if(pDoc)
                 {
-                    sal_uInt16 nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType);
+                    const sal_uInt16 nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType);
                     aOpt.SetLanguage( ((SvxLanguageItem&)pDoc->
                                 GetDefault( nWhich )).GetLanguage());
                 }
@@ -242,11 +242,11 @@ void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions )
 {
     sal_uLong nCCode = m_pCharSetLB->GetSelectTextEncoding();
     OUString sFont;
-    sal_uLong nLng = 0;
+    LanguageType nLng = 0;
     if( m_pFontLB->IsVisible() )
     {
         sFont = m_pFontLB->GetSelectEntry();
-        nLng = (sal_uLong)m_pLanguageLB->GetSelectLanguage();
+        nLng = m_pLanguageLB->GetSelectLanguage();
     }
 
     rOptions.SetFontName( sFont );
commit 52154a7f161c309768437fa7103a551f2bbc31ef
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 18:14:55 2014 +0200

    Use index to get consecutive OUString tokens
    
    Change-Id: I7dc854444d6176f99fd9b79445e643a2bb464020

diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index 37a9aa9..44c56d1 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -259,9 +259,10 @@ void SectRepr::SetFilter( const OUString& rFilter )
 void SectRepr::SetSubRegion(const OUString& rSubRegion)
 {
     OUString sNewFile;
-    OUString sOldFileName( m_SectionData.GetLinkFileName() );
-    const OUString sFilter( sOldFileName.getToken( 1, sfx2::cTokenSeparator ) );
-    sOldFileName = sOldFileName.getToken( 0, sfx2::cTokenSeparator );
+    sal_Int32 n;
+    const OUString sLinkFileName(m_SectionData.GetLinkFileName());
+    const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
+    const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
 
     if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
         sNewFile = sOldFileName + OUString(sfx2::cTokenSeparator) +
@@ -1517,9 +1518,10 @@ short   SwInsertSectionTabDialog::Ok()
                     m_pSectionData->IsEditInReadonlyFlag()));
 
         const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
-        aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator )));
-        aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 1, sfx2::cTokenSeparator )));
-        aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 2, sfx2::cTokenSeparator )));
+        sal_Int32 n = 0;
+        aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
+        aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
+        aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
         aRequest.Done();
     }
     return nRet;
commit 699f5229c7475b42a6e8e7a7563b5a5d78991e5a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 18:05:03 2014 +0200

    OUString: constify, remove temporaries and unneeded casts
    
    Change-Id: Icd2a14798dddad5810e63f4c8f77aee5cdf99ceb

diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index c91058a..37a9aa9 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -82,7 +82,7 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
                     (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
                     && TOX_HEADER_SECTION != eTmpType )
             {
-                    OUString sString(pFmt->GetSection()->GetSectionName());
+                    const OUString sString(pFmt->GetSection()->GetSectionName());
                     if(pAvailNames)
                         pAvailNames->InsertEntry(sString);
                     rSubRegions.InsertEntry(sString);
@@ -102,7 +102,7 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
                     (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
                     && TOX_HEADER_SECTION != eTmpType )
                 {
-                    OUString sString(pFmt->GetSection()->GetSectionName());
+                    const OUString sString(pFmt->GetSection()->GetSectionName());
                     if(pAvailNames)
                         pAvailNames->InsertEntry(sString);
                     rSubRegions.InsertEntry(sString);
@@ -211,8 +211,8 @@ void SectRepr::SetFile( const OUString& rFile )
     OUString sNewFile( INetURLObject::decode( rFile, '%',
                                            INetURLObject::DECODE_UNAMBIGUOUS,
                                         RTL_TEXTENCODING_UTF8 ));
-    OUString sOldFileName( m_SectionData.GetLinkFileName() );
-    OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
+    const OUString sOldFileName( m_SectionData.GetLinkFileName() );
+    const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
 
     if( !rFile.isEmpty() || !sSub.isEmpty() )
     {
@@ -220,8 +220,7 @@ void SectRepr::SetFile( const OUString& rFile )
         if( !rFile.isEmpty() ) // Filter only with FileName
             sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator );
 
-        sNewFile += OUString(sfx2::cTokenSeparator);
-        sNewFile += sSub;
+        sNewFile += OUString(sfx2::cTokenSeparator) + sSub;
     }
 
     m_SectionData.SetLinkFileName( sNewFile );
@@ -239,9 +238,9 @@ void SectRepr::SetFile( const OUString& rFile )
 void SectRepr::SetFilter( const OUString& rFilter )
 {
     OUString sNewFile;
-    OUString sOldFileName( m_SectionData.GetLinkFileName() );
-    OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator ) );
-    OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
+    const OUString sOldFileName( m_SectionData.GetLinkFileName() );
+    const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator ) );
+    const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
 
     if( !sFile.isEmpty() )
         sNewFile = sFile + OUString(sfx2::cTokenSeparator) +
@@ -261,7 +260,7 @@ void SectRepr::SetSubRegion(const OUString& rSubRegion)
 {
     OUString sNewFile;
     OUString sOldFileName( m_SectionData.GetLinkFileName() );
-    OUString sFilter( sOldFileName.getToken( 1, sfx2::cTokenSeparator ) );
+    const OUString sFilter( sOldFileName.getToken( 1, sfx2::cTokenSeparator ) );
     sOldFileName = sOldFileName.getToken( 0, sfx2::cTokenSeparator );
 
     if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
@@ -282,29 +281,29 @@ void SectRepr::SetSubRegion(const OUString& rSubRegion)
 
 OUString SectRepr::GetFile() const
 {
-    OUString sLinkFile( m_SectionData.GetLinkFileName() );
-    if( !sLinkFile.isEmpty() )
+    const OUString sLinkFile( m_SectionData.GetLinkFileName() );
+
+    if( sLinkFile.isEmpty() )
     {
-        if (DDE_LINK_SECTION == m_SectionData.GetType())
-        {
-            sal_Int32 n = 0;
-            sLinkFile = sLinkFile.replaceFirst( OUString(sfx2::cTokenSeparator), " ", &n );
-            sLinkFile = sLinkFile.replaceFirst( OUString(sfx2::cTokenSeparator), " ", &n );
-        }
-        else
-            sLinkFile = INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
-                                        '%',
-                                        INetURLObject::DECODE_UNAMBIGUOUS,
-                                        RTL_TEXTENCODING_UTF8 );
+        return sLinkFile;
     }
-    return sLinkFile;
+    if (DDE_LINK_SECTION == m_SectionData.GetType())
+    {
+        sal_Int32 n = 0;
+        return sLinkFile.replaceFirst( OUString(sfx2::cTokenSeparator), " ", &n )
+                        .replaceFirst( OUString(sfx2::cTokenSeparator), " ", &n );
+    }
+    return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
+                                  '%',
+                                  INetURLObject::DECODE_UNAMBIGUOUS,
+                                  RTL_TEXTENCODING_UTF8 );
 }
 
 OUString SectRepr::GetSubRegion() const
 {
-    OUString sLinkFile( m_SectionData.GetLinkFileName() );
+    const OUString sLinkFile( m_SectionData.GetLinkFileName() );
     if( !sLinkFile.isEmpty() )
-        sLinkFile = sLinkFile.getToken( 2, sfx2::cTokenSeparator );
+        return sLinkFile.getToken( 2, sfx2::cTokenSeparator );
     return sLinkFile;
 }
 
@@ -413,7 +412,7 @@ sal_Bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
             bRet = sal_False;
             if (aPasswdDlg.Execute())
             {
-                OUString sNewPasswd( aPasswdDlg.GetPassword() );
+                const OUString sNewPasswd( aPasswdDlg.GetPassword() );
                 ::com::sun::star::uno::Sequence <sal_Int8 > aNewPasswd;
                 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
                 if (SvPasswordHelper::CompareHashPassword(
@@ -611,8 +610,7 @@ IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox )
             }
             else
             {
-                OUString sTemp(rData.GetCondition());
-                if(sCondition != sTemp)
+                if(sCondition != rData.GetCondition())
                     bConditionValid = false;
                 bHiddenValid      = (bHidden == rData.IsHidden());
                 bProtectValid     = (bProtect == rData.IsProtectFlag());
@@ -684,8 +682,8 @@ IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox )
         m_pCurName->SetText(pBox->GetEntryText(pEntry));
         m_pCurName->Enable();
         m_pDismiss->Enable();
-        OUString aFile = pRepr->GetFile();
-        OUString sSub = pRepr->GetSubRegion();
+        const OUString aFile = pRepr->GetFile();
+        const OUString sSub = pRepr->GetSubRegion();
         m_bSubRegionsFilled = false;
         m_pSubRegionED->Clear();
         if( !aFile.isEmpty() || !sSub.isEmpty() )
@@ -1039,7 +1037,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, FileSearchHdl)
     Application::SetDefDialogParent( this );
     delete m_pDocInserter;
     m_pDocInserter =
-        new ::sfx2::DocumentInserter( OUString("swriter") );
+        new ::sfx2::DocumentInserter( "swriter" );
     m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
     return 0;
 }
@@ -1269,7 +1267,7 @@ IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox )
                 aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
                 if(RET_OK == aPasswdDlg.Execute())
                 {
-                    OUString sNewPasswd( aPasswdDlg.GetPassword() );
+                    const OUString sNewPasswd( aPasswdDlg.GetPassword() );
                     if( aPasswdDlg.GetConfirm() == sNewPasswd )
                     {
                         SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
@@ -1312,7 +1310,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, NameEditHdl)
     OSL_ENSURE(pEntry,"no entry found");
     if (pEntry)
     {
-        OUString aName = m_pCurName->GetText();
+        const OUString aName = m_pCurName->GetText();
         m_pTree->SetEntryText(pEntry,aName);
         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
         pRepr->GetSectionData().SetSectionName(aName);
@@ -1518,7 +1516,7 @@ short   SwInsertSectionTabDialog::Ok()
         aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_EDIT_IN_READONLY,
                     m_pSectionData->IsEditInReadonlyFlag()));
 
-        OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
+        const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
         aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator )));
         aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 1, sfx2::cTokenSeparator )));
         aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 2, sfx2::cTokenSeparator )));
@@ -1625,8 +1623,8 @@ bool SwInsertSectionTabPage::FillItemSet( SfxItemSet& )
     {
         aSection.SetPassword(m_aNewPasswd);
     }
-    OUString sFileName = m_pFileNameED->GetText();
-    OUString sSubRegion = m_pSubRegionED->GetText();
+    const OUString sFileName = m_pFileNameED->GetText();
+    const OUString sSubRegion = m_pSubRegionED->GetText();
     sal_Bool bDDe = m_pDDECB->IsChecked();
     if(m_pFileCB->IsChecked() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
     {
@@ -1713,7 +1711,7 @@ IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton )
             aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
             if(RET_OK == aPasswdDlg.Execute())
             {
-                OUString sNewPasswd( aPasswdDlg.GetPassword() );
+                const OUString sNewPasswd( aPasswdDlg.GetPassword() );
                 if( aPasswdDlg.GetConfirm() == sNewPasswd )
                 {
                     SvPasswordHelper::GetHashPassword( m_aNewPasswd, sNewPasswd );
@@ -1734,7 +1732,7 @@ IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton )
 
 IMPL_LINK_NOARG_INLINE_START(SwInsertSectionTabPage, NameEditHdl)
 {
-    OUString aName = m_pCurName->GetText();
+    const OUString aName = m_pCurName->GetText();
     GetTabDialog()->GetOKButton().Enable(!aName.isEmpty() && m_pCurName->GetEntryPos( aName ) == USHRT_MAX);
     return 0;
 }
@@ -1775,8 +1773,7 @@ IMPL_LINK_NOARG(SwInsertSectionTabPage, FileSearchHdl)
     m_pOldDefDlgParent = Application::GetDefDialogParent();
     Application::SetDefDialogParent( this );
     delete m_pDocInserter;
-    m_pDocInserter = new ::sfx2::DocumentInserter(
-            OUString("swriter") );
+    m_pDocInserter = new ::sfx2::DocumentInserter( "swriter" );
     m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
     return 0;
 }
commit 352bb1fe2cd64464e8b1abcc7103f7a5e7a5898b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 17:40:06 2014 +0200

    Constify some variables
    
    Change-Id: Ibc513d125ce792170d9310359539ed4336b6dab6

diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index cafe6f1..c91058a 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -73,7 +73,7 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
     const SwSectionFmt* pFmt;
     if( !pNewFmt )
     {
-        sal_uInt16 nCount = rSh.GetSectionFmtCount();
+        const sal_uInt16 nCount = rSh.GetSectionFmtCount();
         for(sal_uInt16 i=0;i<nCount;i++)
         {
             SectionType eTmpType;
@@ -93,7 +93,7 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
     else
     {
         SwSections aTmpArr;
-        sal_uInt16 nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS);
+        const sal_uInt16 nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS);
         if( nCnt )
         {
             SectionType eTmpType;
@@ -452,7 +452,7 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
 
     if (!pFmt)
     {
-        sal_uInt16 nCount=rSh.GetSectionFmtCount();
+        const sal_uInt16 nCount=rSh.GetSectionFmtCount();
         for ( sal_uInt16 n=0; n < nCount; n++ )
         {
             SectionType eTmpType;
@@ -478,7 +478,7 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
     {
         SwSections aTmpArr;
         SvTreeListEntry* pNEntry;
-        sal_uInt16 nCnt = pFmt->GetChildSections(aTmpArr,SORTSECT_POS);
+        const sal_uInt16 nCnt = pFmt->GetChildSections(aTmpArr,SORTSECT_POS);
         if( nCnt )
         {
             for( sal_uInt16 n = 0; n < nCnt; ++n )
@@ -515,7 +515,7 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
 
 sal_uInt16 SwEditRegionDlg::FindArrPos(const SwSectionFmt* pFmt )
 {
-    sal_uInt16 nCount=rSh.GetSectionFmtCount();
+    const sal_uInt16 nCount=rSh.GetSectionFmtCount();
     for (sal_uInt16 i=0;i<nCount;i++)
         if (pFmt==&rSh.GetSectionFmt(i))
             return i;
@@ -808,7 +808,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl)
     for (SectReprArr::reverse_iterator aI = aSectReprArr.rbegin(), aEnd = aSectReprArr.rend(); aI != aEnd; ++aI)
     {
         SwSectionFmt* pFmt = aOrigArray[ aI->GetArrPos() ];
-        sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
+        const sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
         if( USHRT_MAX != nNewPos )
             rSh.DelSectionFmt( nNewPos );
     }
@@ -1979,7 +1979,7 @@ void SwSectionFtnEndTabPage::ResetState( sal_Bool bFtn,
         pOffsetFld = pEndOffsetFld;
     }
 
-    sal_uInt16 eState = rAttr.GetValue();
+    const sal_uInt16 eState = rAttr.GetValue();
     switch( eState )
     {
     case FTNEND_ATTXTEND_OWNNUMANDFMT:
commit 4fb4e733f31aebf9875135507a8fa9942ec733c8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 17:29:08 2014 +0200

    Constify OUString
    
    Change-Id: I610fbdc860e04ae486b428432e8fb4dd62464557

diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index e7bd317..82f9480 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -180,7 +180,7 @@ SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet)
     {
         if (i != PAPER_USER)
         {
-            OUString aPaperName = SvxPaperInfo::GetName((Paper) i);
+            const OUString aPaperName = SvxPaperInfo::GetName((Paper) i);
 
             if (aPaperName.isEmpty())
                 continue;
commit 33a9039df8819b69b2ed9b08d408ac281a61359a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 17:28:08 2014 +0200

    Simplify loop
    
    Change-Id: Ie6ccc6b7b77fe4d169e39eb1235042dc3c864e92

diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index a74fe47..e7bd317 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -185,15 +185,11 @@ SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet)
             if (aPaperName.isEmpty())
                 continue;
 
-            sal_Int32 nPos   = 0;
-            bool bFound = false;
-            while (nPos < m_pSizeFormatBox->GetEntryCount() && !bFound)
+            sal_Int32 nPos = 0;
+            while (nPos < m_pSizeFormatBox->GetEntryCount() &&
+                   m_pSizeFormatBox->GetEntry(nPos) < aPaperName)
             {
-                OUString aEntryName = m_pSizeFormatBox->GetEntry(nPos);
-                if (aEntryName < aPaperName)
-                    nPos++;
-                else
-                    bFound = true;
+                ++nPos;
             }
             m_pSizeFormatBox->InsertEntry(aPaperName, nPos);
             aIDs.insert( aIDs.begin() + nPos, i);
commit 5709b98cc23c18074e4d99abafc487e3f37a2eea
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 17:22:48 2014 +0200

    It does not make sense to iterate on a list with a constant index
    
    Change-Id: If0d12158c23df10d003d9f7ad5bb2bd003b75aa3

diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index 3c65be1..a74fe47 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -189,7 +189,7 @@ SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet)
             bool bFound = false;
             while (nPos < m_pSizeFormatBox->GetEntryCount() && !bFound)
             {
-                OUString aEntryName = m_pSizeFormatBox->GetEntry(i);
+                OUString aEntryName = m_pSizeFormatBox->GetEntry(nPos);
                 if (aEntryName < aPaperName)
                     nPos++;
                 else
commit cb2ccc4321eba9f42ffb1ecb8a781d068ecf5ab4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Apr 3 17:02:44 2014 +0200

    sal_uInt16 to sal_Int32/size_t + some constification
    
    Change-Id: I4026e9d0b6e9e6e593298c0564bb5d2c6b028f6c

diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index e983575..3c65be1 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -185,7 +185,7 @@ SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet)
             if (aPaperName.isEmpty())
                 continue;
 
-            sal_uInt16 nPos   = 0;
+            sal_Int32 nPos   = 0;
             bool bFound = false;
             while (nPos < m_pSizeFormatBox->GetEntryCount() && !bFound)
             {
@@ -196,7 +196,7 @@ SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet)
                     bFound = true;
             }
             m_pSizeFormatBox->InsertEntry(aPaperName, nPos);
-            aIDs.insert( aIDs.begin() + nPos, (sal_uInt16) i);
+            aIDs.insert( aIDs.begin() + nPos, i);
         }
     }
     m_pSizeFormatBox->InsertEntry(SvxPaperInfo::GetName(PAPER_USER));
@@ -216,9 +216,9 @@ IMPL_LINK_INLINE_START( SwEnvFmtPage, ModifyHdl, Edit *, pEdit )
     {
         Paper ePaper = SvxPaperInfo::GetSvxPaper(
             Size(lHeight, lWidth), MAP_TWIP, true);
-        for (sal_uInt16 i = 0; i < (sal_uInt16)aIDs.size(); i++)
+        for (size_t i = 0; i < aIDs.size(); ++i)
             if (aIDs[i] == (sal_uInt16)ePaper)
-                m_pSizeFormatBox->SelectEntryPos(i);
+                m_pSizeFormatBox->SelectEntryPos(static_cast<sal_Int32>(i));
 
         // remember user size
         if (aIDs[m_pSizeFormatBox->GetSelectEntryPos()] == (sal_uInt16)PAPER_USER)
@@ -285,7 +285,7 @@ IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
         const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
             pSh->GetView().GetCurShell()->GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
 
-        sal_uInt16 nDefDist = ::GetTabDist( rDefTabs );
+        const sal_uInt16 nDefDist = ::GetTabDist( rDefTabs );
         SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
         aTmpSet.Put( aDefDistItem );
 
@@ -380,7 +380,7 @@ IMPL_LINK_NOARG(SwEnvFmtPage, FormatHdl)
     long lAddrFromLeft;
     long lAddrFromTop;
 
-    sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectEntryPos()];
+    const sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectEntryPos()];
     if (nPaper != (sal_uInt16)PAPER_USER)
     {
         Size aSz = SvxPaperInfo::GetPaperSize((Paper)nPaper);
@@ -476,7 +476,7 @@ void SwEnvFmtPage::FillItem(SwEnvItem& rItem)
     rItem.lSendFromLeft = static_cast< sal_Int32 >(GetFldVal(*m_pSendLeftField));
     rItem.lSendFromTop  = static_cast< sal_Int32 >(GetFldVal(*m_pSendTopField ));
 
-    sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectEntryPos()];
+    const sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectEntryPos()];
     if (nPaper == (sal_uInt16)PAPER_USER)
     {
         long lWVal = static_cast< long >(GetFldVal(*m_pSizeWidthField ));
@@ -507,9 +507,9 @@ void SwEnvFmtPage::Reset(const SfxItemSet& rSet)
     Paper ePaper = SvxPaperInfo::GetSvxPaper(
         Size( std::min(rItem.lWidth, rItem.lHeight),
         std::max(rItem.lWidth, rItem.lHeight)), MAP_TWIP, true);
-    for (sal_uInt16 i = 0; i < (sal_uInt16) aIDs.size(); i++)
+    for (size_t i = 0; i < aIDs.size(); ++i)
         if (aIDs[i] == (sal_uInt16)ePaper)
-            m_pSizeFormatBox->SelectEntryPos(i);
+            m_pSizeFormatBox->SelectEntryPos(static_cast<sal_Int32>(i));
 
     // Metric fields
     SetFldVal(*m_pAddrLeftField, rItem.lAddrFromLeft);
commit 59c13c04cc28e0690667c9240cb7508fbc773949
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Tue Apr 1 09:03:00 2014 +0200

    long to sal_Int32 as index for Sequence
    
    Change-Id: I111fe8aaf9b2ce3b6276c51195911520961602e4

diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index e5c03f2..a316ec1 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -290,7 +290,7 @@ void SwEnvPage::InitDatabaseBox()
         Sequence<OUString> aDataNames = SwNewDBMgr::GetExistingDatabaseNames();
         const OUString* pDataNames = aDataNames.getConstArray();
 
-        for (long i = 0; i < aDataNames.getLength(); i++)
+        for (sal_Int32 i = 0; i < aDataNames.getLength(); i++)
             m_pDatabaseLB->InsertEntry(pDataNames[i]);
 
         OUString sDBName = sActDBName.getToken( 0, DB_DELIM );
commit c41b573daa5bb117c853c8b194ec8a700f47d8ba
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Tue Apr 1 09:01:36 2014 +0200

    Avoid concatenated appends
    
    Change-Id: I6234eb875ce3042d25e33ca33c1973770a422977

diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index 26c3c20..e5c03f2 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -227,9 +227,7 @@ SwEnvPage::SwEnvPage(Window* pParent, const SfxItemSet& rSet)
     m_pPreview->SetBorderStyle( WINDOW_BORDER_MONO );
 
     SwDBData aData = pSh->GetDBData();
-    sActDBName = aData.sDataSource;
-    sActDBName += OUString(DB_DELIM);
-    sActDBName += aData.sCommand;
+    sActDBName = aData.sDataSource + OUString(DB_DELIM) + aData.sCommand;
     InitDatabaseBox();
 }
 
commit 15f6acbab9ba4c4b44ffff4165333fb822bd0cb7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Tue Apr 1 08:51:40 2014 +0200

    Do not cast to intermediate sal_uInt16 + constify
    
    Change-Id: Ie7145eddf79069fc52e14f0276596228fd12333e

diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index ddf453d..26c3c20 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -80,12 +80,12 @@ void SwEnvPreview::Paint(const Rectangle &)
     const SwEnvItem& rItem =
         ((SwEnvDlg*) GetParentDialog())->aEnvItem;
 
-    sal_uInt16 nPageW = (sal_uInt16) std::max(rItem.lWidth, rItem.lHeight),
-           nPageH = (sal_uInt16) std::min(rItem.lWidth, rItem.lHeight);
+    const long nPageW = std::max(rItem.lWidth, rItem.lHeight);
+    const long nPageH = std::min(rItem.lWidth, rItem.lHeight);
 
-    float fx = (float)GetOutputSizePixel().Width () / (float)nPageW,
-          fy = (float)GetOutputSizePixel().Height() / (float)nPageH,
-          f  = 0.8f * ( fx < fy ? fx : fy );
+    const float f = 0.8 * std::min(
+        static_cast<float>(GetOutputSizePixel().Width())/static_cast<float>(nPageW),
+        static_cast<float>(GetOutputSizePixel().Height())/static_cast<float>(nPageH));
 
     Color aBack = rSettings.GetWindowColor( );
     Color aFront = SwViewOption::GetFontColor();
@@ -97,38 +97,38 @@ void SwEnvPreview::Paint(const Rectangle &)
     SetLineColor( aFront );
 
     // Envelope
-    long   nW = (sal_uInt16) (f * nPageW),
-           nH = (sal_uInt16) (f * nPageH),
-           nX = (GetOutputSizePixel().Width () - nW) / 2,
-           nY = (GetOutputSizePixel().Height() - nH) / 2;
+    const long nW = static_cast<long>(f * nPageW);
+    const long nH = static_cast<long>(f * nPageH);
+    const long nX = (GetOutputSizePixel().Width () - nW) / 2;
+    const long nY = (GetOutputSizePixel().Height() - nH) / 2;
     SetFillColor( aBack );
     DrawRect(Rectangle(Point(nX, nY), Size(nW, nH)));
 
     // Sender
     if (rItem.bSend)
     {
-        long   nSendX = nX + (sal_uInt16) (f * rItem.lSendFromLeft),
-               nSendY = nY + (sal_uInt16) (f * rItem.lSendFromTop ),
-               nSendW = (sal_uInt16) (f * (rItem.lAddrFromLeft - rItem.lSendFromLeft)),
-               nSendH = (sal_uInt16) (f * (rItem.lAddrFromTop  - rItem.lSendFromTop  - 566));
+        const long nSendX = nX + static_cast<long>(f * rItem.lSendFromLeft);
+        const long nSendY = nY + static_cast<long>(f * rItem.lSendFromTop );
+        const long nSendW = static_cast<long>(f * (rItem.lAddrFromLeft - rItem.lSendFromLeft));
+        const long nSendH = static_cast<long>(f * (rItem.lAddrFromTop  - rItem.lSendFromTop  - 566));
         SetFillColor( aMedium );
 
         DrawRect(Rectangle(Point(nSendX, nSendY), Size(nSendW, nSendH)));
     }
 
     // Addressee
-    long   nAddrX = nX + (sal_uInt16) (f * rItem.lAddrFromLeft),
-           nAddrY = nY + (sal_uInt16) (f * rItem.lAddrFromTop ),
-           nAddrW = (sal_uInt16) (f * (nPageW - rItem.lAddrFromLeft - 566)),
-           nAddrH = (sal_uInt16) (f * (nPageH - rItem.lAddrFromTop  - 566));
+    const long nAddrX = nX + static_cast<long>(f * rItem.lAddrFromLeft);
+    const long nAddrY = nY + static_cast<long>(f * rItem.lAddrFromTop );
+    const long nAddrW = static_cast<long>(f * (nPageW - rItem.lAddrFromLeft - 566));
+    const long nAddrH = static_cast<long>(f * (nPageH - rItem.lAddrFromTop  - 566));
     SetFillColor( aMedium );
     DrawRect(Rectangle(Point(nAddrX, nAddrY), Size(nAddrW, nAddrH)));
 
     // Stamp
-    long   nStmpW = (sal_uInt16) (f * 1417 /* 2,5 cm */),
-           nStmpH = (sal_uInt16) (f * 1701 /* 3,0 cm */),
-           nStmpX = nX + nW - (sal_uInt16) (f * 566) - nStmpW,
-           nStmpY = nY + (sal_uInt16) (f * 566);
+    const long nStmpW = static_cast<long>(f * 1417 /* 2,5 cm */);
+    const long nStmpH = static_cast<long>(f * 1701 /* 3,0 cm */);
+    const long nStmpX = nX + nW - static_cast<long>(f * 566) - nStmpW;
+    const long nStmpY = nY + static_cast<long>(f * 566);
 
     SetFillColor( aBack );
     DrawRect(Rectangle(Point(nStmpX, nStmpY), Size(nStmpW, nStmpH)));
commit b73b824b8361d5cf38363eab6730e90809f6529e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Mar 31 23:40:32 2014 +0200

    sal_uInt16 to int
    
    Change-Id: Ic5c2c85eb264f15cd6c73ed4fa15279a14f308d1

diff --git a/sw/source/ui/envelp/envprt.cxx b/sw/source/ui/envelp/envprt.cxx
index 9ec2eb8..714f2bc 100644
--- a/sw/source/ui/envelp/envprt.cxx
+++ b/sw/source/ui/envelp/envprt.cxx
@@ -112,7 +112,7 @@ IMPL_LINK_NOARG(SwEnvPrtPage, AlignHdl)
 {
     if (m_pAlignBox->GetCurItemId())
     {
-        for (sal_uInt16 i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
+        for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
             m_pAlignBox->CheckItem(m_aIds[i], false);
         m_pAlignBox->CheckItem(m_pAlignBox->GetCurItemId(), true);
     }
@@ -145,8 +145,8 @@ int SwEnvPrtPage::DeactivatePage(SfxItemSet* _pSet)
 
 void SwEnvPrtPage::FillItem(SwEnvItem& rItem)
 {
-    sal_uInt16 nOrient = 0;
-    for (sal_uInt16 i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
+    int nOrient = 0;
+    for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
     {
         if (m_pAlignBox->IsItemChecked(m_aIds[i]))
         {
commit 8f77b01856b2e086cd8965af158e114b2ce70bf2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Mar 31 23:34:57 2014 +0200

    Avoid magic number for array size
    
    Change-Id: I79267391286855859d2a7d6ccff1500dc096a023

diff --git a/sw/source/ui/envelp/envprt.hxx b/sw/source/ui/envelp/envprt.hxx
index b1941e8..8b0f3ea 100644
--- a/sw/source/ui/envelp/envprt.hxx
+++ b/sw/source/ui/envelp/envprt.hxx
@@ -44,7 +44,7 @@ class SwEnvPrtPage : public SfxTabPage
     FixedText*   m_pPrinterInfo;
     PushButton*  m_pPrtSetup;
 
-    sal_uInt16 m_aIds[6];
+    sal_uInt16 m_aIds[ENV_VER_RGHT-ENV_HOR_LEFT+1];
 
     Printer* pPrt;
 
commit a0e0d5f9cb280178cdcf8eed40e5775b3e9cf1ab
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Mar 31 21:54:04 2014 +0200

    OUString: remove temporaries and unneeded conversions
    
    Change-Id: I99d876bb37b3ac781a0686fe27c6a9c52aaf26b5

diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index ccbda4d..a1499d8 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -71,7 +71,7 @@ void SwLabDlg::_ReplaceGroup( const OUString &rMake )
 {
     // Remove old entries
     pRecs->erase(pRecs->begin() + 1, pRecs->end());
-    aLabelsCfg.FillLabels(OUString(rMake), *pRecs);
+    aLabelsCfg.FillLabels(rMake, *pRecs);
     aLstGroup = rMake;
 }
 
@@ -134,8 +134,7 @@ SwLabDlg::SwLabDlg(Window* pParent, const SfxItemSet& rSet,
     // Read user label from writer.cfg
     SwLabItem aItem((const SwLabItem&)rSet.Get( FN_LABEL ));
     SwLabRec* pRec = new SwLabRec;
-    const OUString aTmp( SW_RES( STR_CUSTOM ) );
-    pRec->aMake   = pRec->aType = aTmp;
+    pRec->aMake = pRec->aType = SW_RESSTR( STR_CUSTOM );
     pRec->SetFromItem( aItem );
 
     bool bDouble = false;
@@ -201,7 +200,7 @@ SwLabRec* SwLabDlg::GetRecord(const OUString &rRecName, sal_Bool bCont)
 {
     SwLabRec* pRec = NULL;
     bool bFound = false;
-    OUString sCustom(SW_RES(STR_CUSTOM));
+    const OUString sCustom(SW_RES(STR_CUSTOM));
 
     const size_t nCount = Recs().size();
     for (size_t i = 0; i < nCount; ++i)
@@ -326,8 +325,8 @@ IMPL_LINK( SwLabPage, DatabaseHdl, ListBox *, pListBox )
 
 IMPL_LINK_NOARG(SwLabPage, FieldHdl)
 {
-    OUString aStr("<" + OUString(m_pDatabaseLB->GetSelectEntry()) + "." +
-                  OUString(m_pTableLB->GetSelectEntry()) + "." +
+    OUString aStr("<" + m_pDatabaseLB->GetSelectEntry() + "." +
+                  m_pTableLB->GetSelectEntry() + "." +
                   (m_pTableLB->GetEntryData(m_pTableLB->GetSelectEntryPos()) == 0 ? OUString("0") : OUString("1")) + "." +
                   m_pDBFieldLB->GetSelectEntry() + ">");
     m_pWritingEdit->ReplaceSelected(aStr);
commit 060d2e0e997c603a341e29eeac7f4fa3032f056a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Mar 31 09:06:06 2014 +0200

    Remove redundant loop condition, to break is enough
    
    Change-Id: Ia02e8483437fd7bd4db6fd9d74d11f6eb10952bc

diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index fdc2237..ccbda4d 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -666,7 +666,7 @@ void SwVisitingCardPage::Reset(const SfxItemSet& rSet)
 
     bool bFound = false;
     sal_Int32 i;
-    for(i = 0; i < m_pAutoTextGroupLB->GetEntryCount() && !bFound; i++)
+    for(i = 0; i < m_pAutoTextGroupLB->GetEntryCount(); i++)
         if( aLabItem.sGlossaryGroup == *(const OUString*)m_pAutoTextGroupLB->GetEntryData( i ))
         {
             bFound = true;
@@ -677,7 +677,7 @@ void SwVisitingCardPage::Reset(const SfxItemSet& rSet)
     {
         // initially search for a group starting with "crd" which is the name of the
         // business card AutoTexts
-        for(i = 0; i < m_pAutoTextGroupLB->GetEntryCount() && !bFound; i++)
+        for(i = 0; i < m_pAutoTextGroupLB->GetEntryCount(); i++)
             if (((const OUString*)m_pAutoTextGroupLB->GetEntryData(i))->startsWith("crd"))
             {
                 bFound = true;
commit de13902e517e9705a6156387433138eacd3ab75d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Mar 31 09:01:16 2014 +0200

    sal_uInt16 to size_t/sal_Int32
    
    Change-Id: I59f0100b96208ced0a372dee2aa405bdb3cbccd9

diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index e366477..fdc2237 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -140,7 +140,7 @@ SwLabDlg::SwLabDlg(Window* pParent, const SfxItemSet& rSet,
 
     bool bDouble = false;
 
-    for (sal_uInt16 nRecPos = 0; nRecPos < pRecs->size(); nRecPos++)
+    for (size_t nRecPos = 0; nRecPos < pRecs->size(); ++nRecPos)
     {
         if (pRec->aMake == (*pRecs)[nRecPos]->aMake &&
             pRec->aType == (*pRecs)[nRecPos]->aType)
@@ -155,9 +155,9 @@ SwLabDlg::SwLabDlg(Window* pParent, const SfxItemSet& rSet,
     else
         delete pRec;
 
-    sal_uInt16 nLstGroup = 0;
+    size_t nLstGroup = 0;
     const std::vector<OUString>& rMan = aLabelsCfg.GetManufacturers();
-    for(sal_uInt16 nMan = 0; nMan < rMan.size(); nMan++)
+    for(size_t nMan = 0; nMan < rMan.size(); ++nMan)
     {
         aMakes.push_back(rMan[nMan]);
         if ( rMan[nMan] == aItem.aLstMake )
@@ -203,8 +203,8 @@ SwLabRec* SwLabDlg::GetRecord(const OUString &rRecName, sal_Bool bCont)
     bool bFound = false;
     OUString sCustom(SW_RES(STR_CUSTOM));
 
-    const sal_uInt16 nCount = Recs().size();
-    for (sal_uInt16 i = 0; i < nCount; i++)
+    const size_t nCount = Recs().size();
+    for (size_t i = 0; i < nCount; ++i)
     {
         pRec = Recs()[i];
         if (pRec->aType != sCustom &&
@@ -274,7 +274,7 @@ SwLabPage::SwLabPage(Window* pParent, const SfxItemSet& rSet)
 
     size_t nLstGroup = 0;
 
-    const sal_uInt16 nCount = (sal_uInt16)GetParentSwLabDlg()->Makes().size();
+    const size_t nCount = GetParentSwLabDlg()->Makes().size();
     for(size_t i = 0; i < nCount; ++i)
     {
         OUString& rStr = GetParentSwLabDlg()->Makes()[i];
@@ -357,12 +357,12 @@ IMPL_LINK_NOARG(SwLabPage, MakeHdl)
     aItem.aLstMake = aMake;
 
     const sal_Bool   bCont    = m_pContButton->IsChecked();
-    const sal_uInt16 nCount   = GetParentSwLabDlg()->Recs().size();
-          sal_uInt16 nLstType = 0;
+    const size_t nCount   = GetParentSwLabDlg()->Recs().size();
+    size_t nLstType = 0;
 
     const OUString sCustom(SW_RES(STR_CUSTOM));
     //insert the entries into the sorted list box
-    for ( sal_uInt16 i = 0; i < nCount; ++i )
+    for ( size_t i = 0; i < nCount; ++i )
     {
         const OUString aType ( GetParentSwLabDlg()->Recs()[i]->aType );
         bool bInsert = false;
@@ -386,7 +386,7 @@ IMPL_LINK_NOARG(SwLabPage, MakeHdl)
                 nLstType = GetParentSwLabDlg()->TypeIds().size();
         }
     }
-    for(sal_uInt16 nEntry = 0; nEntry < m_pHiddenSortTypeBox->GetEntryCount(); nEntry++)
+    for(sal_Int32 nEntry = 0; nEntry < m_pHiddenSortTypeBox->GetEntryCount(); ++nEntry)
     {
         m_pTypeBox->InsertEntry(m_pHiddenSortTypeBox->GetEntry(nEntry));
     }
@@ -588,7 +588,7 @@ SwVisitingCardPage::SwVisitingCardPage(Window* pParent, const SfxItemSet& rSet)
 
 SwVisitingCardPage::~SwVisitingCardPage()
 {
-    for(sal_uInt16 i = 0; i < m_pAutoTextGroupLB->GetEntryCount(); i++)
+    for(sal_Int32 i = 0; i < m_pAutoTextGroupLB->GetEntryCount(); ++i)
         delete (OUString*)m_pAutoTextGroupLB->GetEntryData( i );
     m_xAutoText = 0;
 
@@ -665,7 +665,7 @@ void SwVisitingCardPage::Reset(const SfxItemSet& rSet)
     aLabItem = (const SwLabItem&) rSet.Get(FN_LABEL);
 
     bool bFound = false;
-    sal_uInt16 i;
+    sal_Int32 i;
     for(i = 0; i < m_pAutoTextGroupLB->GetEntryCount() && !bFound; i++)
         if( aLabItem.sGlossaryGroup == *(const OUString*)m_pAutoTextGroupLB->GetEntryData( i ))
         {


More information about the Libreoffice-commits mailing list