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

Matteo Casalin matteo.casalin at yahoo.com
Sun Mar 30 14:56:04 PDT 2014


 sw/source/core/uibase/inc/mailmrge.hxx |    2 
 sw/source/ui/envelp/labelexp.cxx       |    4 -
 sw/source/ui/envelp/labfmt.cxx         |   81 +++++++++++++++------------------
 sw/source/ui/envelp/labprt.cxx         |    4 -
 sw/source/ui/envelp/mailmrge.cxx       |   40 +++++++---------
 5 files changed, 61 insertions(+), 70 deletions(-)

New commits:
commit 4e9565b24b3a1d393cc7093b363709c233de9d43
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 23:35:07 2014 +0200

    sal_uInt16 to sal_Int32
    
    Change-Id: I7c658f74c70daeece6343e69bd89313d22620a60

diff --git a/sw/source/ui/envelp/labelexp.cxx b/sw/source/ui/envelp/labelexp.cxx
index 669d513..649323c 100644
--- a/sw/source/ui/envelp/labelexp.cxx
+++ b/sw/source/ui/envelp/labelexp.cxx
@@ -52,7 +52,7 @@ void SwVisitingCardPage::InitFrameControl()
     uno::Sequence<OUString> aNames = m_xAutoText->getElementNames();
     const OUString* pGroups = aNames.getConstArray();
 
-    for(sal_uInt16 i = 0; i < aNames.getLength(); i++)
+    for(sal_Int32 i = 0; i < aNames.getLength(); ++i)
     {
         uno::Any aGroup = m_xAutoText->getByName(pGroups[i]);
         uno::Reference< text::XAutoTextGroup >  xGroup;
@@ -66,7 +66,7 @@ void SwVisitingCardPage::InitFrameControl()
                 uno::Any aTitle = xPrSet->getPropertyValue( UNO_NAME_TITLE );
                 OUString uTitle;
                 aTitle >>= uTitle;
-                sal_uInt16 nEntry = m_pAutoTextGroupLB->InsertEntry(uTitle);
+                const sal_Int32 nEntry = m_pAutoTextGroupLB->InsertEntry(uTitle);
                 m_pAutoTextGroupLB->SetEntryData(nEntry, new OUString(pGroups[i]));
             }
         }
commit fa8f89cf46da59c4362537103f4cae39c7e4362d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 23:30:06 2014 +0200

    sal_uInt16 to sal_Int32/size_t
    
    Change-Id: I1c6a0aff1515e8e4fe86f2027f405a9a7c7aa579

diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index 1e06a910..c763b0e 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -157,8 +157,10 @@ void SwLabPreview::Paint(const Rectangle &)
     // Labels
     SetClipRegion(Region(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH))));
     SetFillColor( COL_LIGHTGRAYBLUE );
-    for (sal_uInt16 nRow = 0; nRow < std::min((sal_uInt16) 2, (sal_uInt16) aItem.nRows); nRow++)
-        for (sal_uInt16 nCol = 0; nCol < std::min((sal_uInt16) 2, (sal_uInt16) aItem.nCols); nCol++)
+    const sal_Int32 nRows = std::min<sal_Int32>(2, aItem.nRows);
+    const sal_Int32 nCols = std::min<sal_Int32>(2, aItem.nCols);
+    for (sal_Int32 nRow = 0; nRow < nRows; ++nRow)
+        for (sal_Int32 nCol = 0; nCol < nCols; ++nCol)
             DrawRect(Rectangle(
               Point(lX0 + ROUND(f * (aItem.lLeft  + nCol * aItem.lHDist)),
                     lY0 + ROUND(f * (aItem.lUpper + nRow * aItem.lVDist))),
@@ -495,8 +497,8 @@ void SwLabFmtPage::FillItem(SwLabItem& rItem)
         rItem.lHeight = rRec.lHeight = static_cast< long >(GETFLDVAL(*m_pHeightField));
         rItem.lLeft   = rRec.lLeft   = static_cast< long >(GETFLDVAL(*m_pLeftField  ));
         rItem.lUpper  = rRec.lUpper  = static_cast< long >(GETFLDVAL(*m_pUpperField ));
-        rItem.nCols   = rRec.nCols   = (sal_uInt16) m_pColsField->GetValue();
-        rItem.nRows   = rRec.nRows   = (sal_uInt16) m_pRowsField->GetValue();
+        rItem.nCols   = rRec.nCols   = static_cast< sal_Int32 >(m_pColsField->GetValue());
+        rItem.nRows   = rRec.nRows   = static_cast< sal_Int32 >(m_pRowsField->GetValue());
         rItem.lPWidth  = rRec.lPWidth  = static_cast< long >(GETFLDVAL(*m_pPWidthField ));
         rItem.lPHeight = rRec.lPHeight = static_cast< long >(GETFLDVAL(*m_pPHeightField));
     }
@@ -552,8 +554,8 @@ IMPL_LINK_NOARG(SwLabFmtPage, SaveHdl)
     aRec.lHeight = static_cast< long >(GETFLDVAL(*m_pHeightField));
     aRec.lLeft   = static_cast< long >(GETFLDVAL(*m_pLeftField  ));
     aRec.lUpper  = static_cast< long >(GETFLDVAL(*m_pUpperField ));
-    aRec.nCols   = (sal_uInt16) m_pColsField->GetValue();
-    aRec.nRows   = (sal_uInt16) m_pRowsField->GetValue();
+    aRec.nCols   = static_cast< sal_Int32 >(m_pColsField->GetValue());
+    aRec.nRows   = static_cast< sal_Int32 >(m_pRowsField->GetValue());
     aRec.lPWidth  = static_cast< long >(GETFLDVAL(*m_pPWidthField ));
     aRec.lPHeight = static_cast< long >(GETFLDVAL(*m_pPHeightField));
     aRec.bCont = aItem.bCont;
@@ -594,7 +596,7 @@ SwSaveLabelDlg::SwSaveLabelDlg(SwLabFmtPage* pParent, SwLabRec& rRec)
 
     SwLabelConfig& rCfg = pLabPage->GetParentSwLabDlg()->GetLabelsConfig();
     const std::vector<OUString>& rMan = rCfg.GetManufacturers();
-    for (sal_uInt16 i = 0; i < rMan.size(); i++)
+    for (size_t i = 0; i < rMan.size(); ++i)
     {
         m_pMakeCB->InsertEntry(rMan[i]);
     }
@@ -621,9 +623,8 @@ IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl)
             replaceAll("%1", sMake).replaceAll("%2", sType));
         aQuery.set_secondary_text(aQuery.get_secondary_text().
             replaceAll("%1", sMake).replaceAll("%2", sType));
-        sal_uInt16 eRet = aQuery.Execute();
 
-        if (RET_YES != eRet)
+        if (RET_YES != aQuery.Execute())
             return 0;
     }
     rLabRec.aType = sType;
commit 0d4f072d018d4b3764b91507bed778ff007f0153
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 23:19:13 2014 +0200

    Constify
    
    Change-Id: I8d215b0cea56cda55d8e991da1649fca765d149b

diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index 6b18458..1e06a910 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -92,14 +92,14 @@ void SwLabPreview::Paint(const Rectangle &)
 {
     const Size aSz(GetOutputSizePixel());
 
-    long lOutWPix   = aSz.Width ();
-    long lOutHPix   = aSz.Height();
+    const long lOutWPix   = aSz.Width ();
+    const long lOutHPix   = aSz.Height();
 
     // Scale factor
-    float fxpix = (float)(lOutWPix - (2 * (lLeftWidth + 15))) / (float)lOutWPix;
+    const float fxpix = (float)(lOutWPix - (2 * (lLeftWidth + 15))) / (float)lOutWPix;
 
-    long lOutWPix23 = (long)((float)lOutWPix * fxpix);
-    long lOutHPix23 = (long)((float)lOutHPix * fxpix);
+    const long lOutWPix23 = (long)((float)lOutWPix * fxpix);
+    const long lOutHPix23 = (long)((float)lOutHPix * fxpix);
 
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     const Color& rWinColor = rStyleSettings.GetWindowColor();
@@ -119,34 +119,28 @@ void SwLabPreview::Paint(const Rectangle &)
     SetFont(aPaintFont);
 
     // size of region to be displayed
-    long lDispW = aItem.lLeft  + aItem.lHDist;
-    long lDispH = aItem.lUpper + aItem.lVDist;
-    if (aItem.nCols == 1)
-        lDispW += aItem.lLeft ;
-    else
-        lDispW += ROUND(aItem.lHDist / 10.0);
-    if (aItem.nRows == 1)
-        lDispH += aItem.lUpper;
-    else
-        lDispH += ROUND(aItem.lVDist / 10.0);
+    const long lDispW = aItem.lLeft + aItem.lHDist
+        + ((aItem.nCols == 1) ? aItem.lLeft : ROUND(aItem.lHDist/10.0));
+    const long lDispH = aItem.lUpper + aItem.lVDist
+        + ((aItem.nRows == 1) ? aItem.lUpper : ROUND(aItem.lVDist/10.0));
 
     // Scale factor
-    float fx = (float) lOutWPix23 / std::max(1L, lDispW),
-          fy = (float) lOutHPix23 / std::max(1L, lDispH),
-          f  = fx < fy ? fx : fy;
+    const float fx = (float) lOutWPix23 / std::max(1L, lDispW);
+    const float fy = (float) lOutHPix23 / std::max(1L, lDispH);
+    const float f  = fx < fy ? fx : fy;
 
     // zero point
-    long lOutlineW = ROUND(f * lDispW);
-    long lOutlineH = ROUND(f * lDispH);
-
-    long lX0 = (lOutWPix - lOutlineW) / 2;
-    long lY0 = (lOutHPix - lOutlineH) / 2;
-    long lX1 = lX0 + ROUND(f *  aItem.lLeft );
-    long lY1 = lY0 + ROUND(f *  aItem.lUpper);
-    long lX2 = lX0 + ROUND(f * (aItem.lLeft  + aItem.lWidth ));
-    long lY2 = lY0 + ROUND(f * (aItem.lUpper + aItem.lHeight));
-    long lX3 = lX0 + ROUND(f * (aItem.lLeft  + aItem.lHDist ));
-    long lY3 = lY0 + ROUND(f * (aItem.lUpper + aItem.lVDist ));
+    const long lOutlineW = ROUND(f * lDispW);
+    const long lOutlineH = ROUND(f * lDispH);
+
+    const long lX0 = (lOutWPix - lOutlineW) / 2;
+    const long lY0 = (lOutHPix - lOutlineH) / 2;
+    const long lX1 = lX0 + ROUND(f *  aItem.lLeft );
+    const long lY1 = lY0 + ROUND(f *  aItem.lUpper);
+    const long lX2 = lX0 + ROUND(f * (aItem.lLeft  + aItem.lWidth ));
+    const long lY2 = lY0 + ROUND(f * (aItem.lUpper + aItem.lHeight));
+    const long lX3 = lX0 + ROUND(f * (aItem.lLeft  + aItem.lHDist ));
+    const long lY3 = lY0 + ROUND(f * (aItem.lUpper + aItem.lVDist ));
 
     // draw outline (area)
     DrawRect(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH)));
commit 53387dabd30c61ba9eb215f1432106f3ab3d98d4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 23:17:38 2014 +0200

    Apply ROUND to floats and let it return longs
    
    Change-Id: I88476c1ca2eff0898d31ab48d7d5a36301297bb9

diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index 97abd79..6b18458 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -39,7 +39,7 @@ using namespace utl;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::beans;
 
-#define ROUND(x) ((sal_uInt16) ((x) + .5))
+#define ROUND(x) static_cast<long>((x) + .5)
 
 SwLabPreview::SwLabPreview(Window* pParent)
     : Window(pParent, 0)
@@ -119,16 +119,16 @@ void SwLabPreview::Paint(const Rectangle &)
     SetFont(aPaintFont);
 
     // size of region to be displayed
-    long lDispW = ROUND(aItem.lLeft  + aItem.lHDist);
-    long lDispH = ROUND(aItem.lUpper + aItem.lVDist);
+    long lDispW = aItem.lLeft  + aItem.lHDist;
+    long lDispH = aItem.lUpper + aItem.lVDist;
     if (aItem.nCols == 1)
-        lDispW += ROUND(aItem.lLeft );
+        lDispW += aItem.lLeft ;
     else
-        lDispW += ROUND(aItem.lHDist / 10);
+        lDispW += ROUND(aItem.lHDist / 10.0);
     if (aItem.nRows == 1)
-        lDispH += ROUND(aItem.lUpper);
+        lDispH += aItem.lUpper;
     else
-        lDispH += ROUND(aItem.lVDist / 10);
+        lDispH += ROUND(aItem.lVDist / 10.0);
 
     // Scale factor
     float fx = (float) lOutWPix23 / std::max(1L, lDispW),
@@ -141,12 +141,12 @@ void SwLabPreview::Paint(const Rectangle &)
 
     long lX0 = (lOutWPix - lOutlineW) / 2;
     long lY0 = (lOutHPix - lOutlineH) / 2;
-    long lX1 = ROUND(lX0 + f *  aItem.lLeft );
-    long lY1 = ROUND(lY0 + f *  aItem.lUpper);
-    long lX2 = ROUND(lX0 + f * (aItem.lLeft  + aItem.lWidth ));
-    long lY2 = ROUND(lY0 + f * (aItem.lUpper + aItem.lHeight));
-    long lX3 = ROUND(lX0 + f * (aItem.lLeft  + aItem.lHDist ));
-    long lY3 = ROUND(lY0 + f * (aItem.lUpper + aItem.lVDist ));
+    long lX1 = lX0 + ROUND(f *  aItem.lLeft );
+    long lY1 = lY0 + ROUND(f *  aItem.lUpper);
+    long lX2 = lX0 + ROUND(f * (aItem.lLeft  + aItem.lWidth ));
+    long lY2 = lY0 + ROUND(f * (aItem.lUpper + aItem.lHeight));
+    long lX3 = lX0 + ROUND(f * (aItem.lLeft  + aItem.lHDist ));
+    long lY3 = lY0 + ROUND(f * (aItem.lUpper + aItem.lVDist ));
 
     // draw outline (area)
     DrawRect(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH)));
@@ -166,8 +166,8 @@ void SwLabPreview::Paint(const Rectangle &)
     for (sal_uInt16 nRow = 0; nRow < std::min((sal_uInt16) 2, (sal_uInt16) aItem.nRows); nRow++)
         for (sal_uInt16 nCol = 0; nCol < std::min((sal_uInt16) 2, (sal_uInt16) aItem.nCols); nCol++)
             DrawRect(Rectangle(
-              Point(ROUND(lX0 + f * (aItem.lLeft  + nCol * aItem.lHDist)),
-                    ROUND(lY0 + f * (aItem.lUpper + nRow * aItem.lVDist))),
+              Point(lX0 + ROUND(f * (aItem.lLeft  + nCol * aItem.lHDist)),
+                    lY0 + ROUND(f * (aItem.lUpper + nRow * aItem.lVDist))),
               Size (ROUND(f * aItem.lWidth ),
                     ROUND(f * aItem.lHeight))));
     SetClipRegion();
@@ -185,7 +185,7 @@ void SwLabPreview::Paint(const Rectangle &)
     if (aItem.lUpper)
     {
         DrawArrow(Point(lX0 - 5, lY0), Point(lX0 - 5, lY1), false);
-        DrawText(Point(lX0 - 10 - lUpperWidth, ROUND(lY0 + f * aItem.lUpper / 2 - lXHeight / 2)), aUpperStr);
+        DrawText(Point(lX0 - 10 - lUpperWidth, lY0 + ROUND(f*aItem.lUpper/2.0 - lXHeight/2.0)), aUpperStr);
     }
 
     // annotation: width and height
@@ -213,7 +213,7 @@ void SwLabPreview::Paint(const Rectangle &)
     if (aItem.nRows > 1)
     {
         DrawArrow(Point(lX0 - 5, lY1), Point(lX0 - 5, lY3), false);
-        DrawText(Point(lX0 - 10 - lVDistWidth, ROUND(lY1 + f * aItem.lVDist / 2 - lXHeight / 2)), aVDistStr);
+        DrawText(Point(lX0 - 10 - lVDistWidth, lY1 + ROUND(f*aItem.lVDist/2.0 - lXHeight/2.0)), aVDistStr);
     }
 
     // annotation: columns
commit 8d0f6946e48a6882da689c8d862ad1ff50a54a7a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 21:53:35 2014 +0200

    Convert to proper integer type
    
    Change-Id: I1a310dfbc65233098f583840780ff9b020e1c856

diff --git a/sw/source/ui/envelp/labprt.cxx b/sw/source/ui/envelp/labprt.cxx
index 0912469..454660d 100644
--- a/sw/source/ui/envelp/labprt.cxx
+++ b/sw/source/ui/envelp/labprt.cxx
@@ -114,8 +114,8 @@ int SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
 void SwLabPrtPage::FillItem(SwLabItem& rItem)
 {
     rItem.bPage = m_pPageButton->IsChecked();
-    rItem.nCol  = (sal_uInt16) m_pColField->GetValue();
-    rItem.nRow  = (sal_uInt16) m_pRowField->GetValue();
+    rItem.nCol = static_cast<sal_Int32>(m_pColField->GetValue());
+    rItem.nRow = static_cast<sal_Int32>(m_pRowField->GetValue());
     rItem.bSynchron = m_pSynchronCB->IsChecked() && m_pSynchronCB->IsEnabled();
 }
 
commit 0472978510569d52d41ac1daa87d7251d6041812
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 21:42:00 2014 +0200

    No need to store these OUStrings in class object
    
    Change-Id: I96ff3ff8eda5ffb96432c519a9584d7d1d82b332

diff --git a/sw/source/core/uibase/inc/mailmrge.hxx b/sw/source/core/uibase/inc/mailmrge.hxx
index e93b16c..b312e05 100644
--- a/sw/source/core/uibase/inc/mailmrge.hxx
+++ b/sw/source/core/uibase/inc/mailmrge.hxx
@@ -105,8 +105,6 @@ class SwMailMergeDlg : public SvxStandardDialog
 
     SwWrtShell&     rSh;
     SwModuleOptions* pModOpt;
-    OUString        rDBName;
-    OUString        rTableName;
 
     sal_uInt16          nMergeType;
     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >       m_aSelection;
diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index e3e4abf..8f9be8a 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -192,8 +192,6 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
     pImpl           (new SwMailMergeDlg_Impl),
 
     rSh             (rShell),
-    rDBName         (rSourceName),
-    rTableName      (rTblName),
     nMergeType      (DBMGR_MERGE_MAILING),
     m_aDialogSize( GetSizePixel() )
 {
@@ -288,9 +286,9 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
                 Sequence<PropertyValue> aProperties(3);
                 PropertyValue* pProperties = aProperties.getArray();
                 pProperties[0].Name = "DataSourceName";
-                pProperties[0].Value <<= rDBName;
+                pProperties[0].Value <<= rSourceName;
                 pProperties[1].Name = "Command";
-                pProperties[1].Value <<= rTableName;
+                pProperties[1].Value <<= rTblName;
                 pProperties[2].Name = "CommandType";
                 pProperties[2].Value <<= nCommandType;
                 xD->dispatch(aURL, aProperties);
@@ -356,9 +354,9 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
 
     SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
     if(_xConnection.is())
-        pNewDBMgr->GetColumnNames(&aAddressFldLB, _xConnection, rTableName);
+        pNewDBMgr->GetColumnNames(&aAddressFldLB, _xConnection, rTblName);
     else
-        pNewDBMgr->GetColumnNames(&aAddressFldLB, rDBName, rTableName);
+        pNewDBMgr->GetColumnNames(&aAddressFldLB, rSourceName, rTblName);
     for(sal_Int32 nEntry = 0; nEntry < aAddressFldLB.GetEntryCount(); ++nEntry)
         aColumnLB.InsertEntry(aAddressFldLB.GetEntry(nEntry));
 
commit 1fc1d74ce397e8f92757aa88093286a56d78ac5f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 19:03:23 2014 +0200

    Use sal_Int32 as index for a Sequence
    
    Change-Id: Ib692af0f1ab9b2cbe67e6113257f9186d0c1f102

diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index e0b2c89..e3e4abf 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -421,7 +421,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
             aProps >>= aFilterProperties;
             OUString sUIName2;
             const beans::PropertyValue* pFilterProperties = aFilterProperties.getConstArray();
-            for(int nProp = 0; nProp < aFilterProperties.getLength(); nProp++)
+            for(sal_Int32 nProp = 0; nProp < aFilterProperties.getLength(); ++nProp)
             {
                 if(pFilterProperties[nProp].Name == "UIName")
                 {
commit 641009c4744b586b228393110cf0101de2c64c4b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 18:59:30 2014 +0200

    Avoid unneeded OUString conversions and concatenated appends
    
    Change-Id: Ied9fded44e1deee17be4c02f10261a459f88e530

diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index 0b42dbb..e0b2c89 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -288,9 +288,9 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
                 Sequence<PropertyValue> aProperties(3);
                 PropertyValue* pProperties = aProperties.getArray();
                 pProperties[0].Name = "DataSourceName";
-                pProperties[0].Value <<= OUString(rSourceName);
+                pProperties[0].Value <<= rDBName;
                 pProperties[1].Name = "Command";
-                pProperties[1].Value <<= OUString(rTableName);
+                pProperties[1].Value <<= rTableName;
                 pProperties[2].Name = "CommandType";
                 pProperties[2].Value <<= nCommandType;
                 xD->dispatch(aURL, aProperties);
@@ -362,7 +362,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
     for(sal_Int32 nEntry = 0; nEntry < aAddressFldLB.GetEntryCount(); ++nEntry)
         aColumnLB.InsertEntry(aAddressFldLB.GetEntry(nEntry));
 
-    aAddressFldLB.SelectEntry(OUString("EMAIL"));
+    aAddressFldLB.SelectEntry("EMAIL");
 
     OUString sPath(pModOpt->GetMailingPath());
     if(sPath.isEmpty())
@@ -378,7 +378,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
 
     if (!bColumn )
     {
-        aColumnLB.SelectEntry(OUString("NAME"));
+        aColumnLB.SelectEntry("NAME");
     }
     else
         aColumnLB.SelectEntry(pModOpt->GetNameFromColumn());
@@ -403,18 +403,18 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
         uno::Reference< container::XNameContainer> xFilterFactory(
                 xMSF->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY_THROW);
         uno::Reference< container::XContainerQuery > xQuery(xFilterFactory, UNO_QUERY_THROW);
-        OUString sCommand("matchByDocumentService=com.sun.star.text.TextDocument:iflags=");
-        sCommand += OUString::number(SFX_FILTER_EXPORT);
-        sCommand += ":eflags=";
-        sCommand += OUString::number(SFX_FILTER_NOTINFILEDLG);
-        sCommand += ":default_first";
+        const OUString sCommand("matchByDocumentService=com.sun.star.text.TextDocument:iflags="
+            + OUString::number(SFX_FILTER_EXPORT)
+            + ":eflags="
+            + OUString::number(SFX_FILTER_NOTINFILEDLG)
+            + ":default_first");
         uno::Reference< container::XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
         const OUString sName("Name");
         sal_Int32 nODT = -1;
         while(xList->hasMoreElements())
         {
             comphelper::SequenceAsHashMap aFilter(xList->nextElement());
-            OUString sFilter = aFilter.getUnpackedValueOrDefault(sName, OUString());
+            const OUString sFilter = aFilter.getUnpackedValueOrDefault(sName, OUString());
 
             uno::Any aProps = xFilterFactory->getByName(sFilter);
             uno::Sequence< beans::PropertyValue > aFilterProperties;
@@ -423,7 +423,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
             const beans::PropertyValue* pFilterProperties = aFilterProperties.getConstArray();
             for(int nProp = 0; nProp < aFilterProperties.getLength(); nProp++)
             {
-                if(pFilterProperties[nProp].Name.equalsAscii("UIName"))
+                if(pFilterProperties[nProp].Name == "UIName")
                 {
                     pFilterProperties[nProp].Value >>= sUIName2;
                     break;
@@ -666,7 +666,7 @@ bool SwMailMergeDlg::ExecQryShell()
                 aAbs, aPathED.GetText(), URIHelper::GetMaybeFileHdl()));
         pModOpt->SetMailingPath(sPath);
 
-        const OUString sDelim = OUString(INET_PATH_TOKEN);
+        const OUString sDelim(INET_PATH_TOKEN);
         if (!sPath.endsWith(sDelim))
             sPath += sDelim;
 
commit 1cf621d25240ff3465d4baacaf7e3aa557c819a6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Mar 30 18:29:51 2014 +0200

    sal_uInt16 to sal_Int32 and USHRT_MAX to -1
    
    The original code seems to use USHRT_MAX to perform no selection in
    the default case, but USHRT_MAX can be a valid position for ListBox.
    Use a negative value instead, so to have the desired behaviour.
    
    Change-Id: I050940f6779fb6592c788000e95d1095e571667d

diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index 1f89e60..0b42dbb 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -359,7 +359,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
         pNewDBMgr->GetColumnNames(&aAddressFldLB, _xConnection, rTableName);
     else
         pNewDBMgr->GetColumnNames(&aAddressFldLB, rDBName, rTableName);
-    for(sal_uInt16 nEntry = 0; nEntry < aAddressFldLB.GetEntryCount(); nEntry++)
+    for(sal_Int32 nEntry = 0; nEntry < aAddressFldLB.GetEntryCount(); ++nEntry)
         aColumnLB.InsertEntry(aAddressFldLB.GetEntry(nEntry));
 
     aAddressFldLB.SelectEntry(OUString("EMAIL"));
@@ -410,7 +410,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
         sCommand += ":default_first";
         uno::Reference< container::XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
         const OUString sName("Name");
-        sal_uInt16 nODT = USHRT_MAX;
+        sal_Int32 nODT = -1;
         while(xList->hasMoreElements())
         {
             comphelper::SequenceAsHashMap aFilter(xList->nextElement());
@@ -431,7 +431,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
             }
             if( !sUIName2.isEmpty() )
             {
-                sal_uInt16 nFilter = aFilterLB.InsertEntry( sUIName2 );
+                const sal_Int32 nFilter = aFilterLB.InsertEntry( sUIName2 );
                 if( sFilter.equalsAscii("writer8") )
                     nODT = nFilter;
                 aFilterLB.SetEntryData( nFilter, new OUString( sFilter ) );
@@ -454,7 +454,7 @@ SwMailMergeDlg::~SwMailMergeDlg()
     else
         delete pBeamerWin;
 
-    for( sal_uInt16 nFilter = 0; nFilter < aFilterLB.GetEntryCount(); ++nFilter )
+    for( sal_Int32 nFilter = 0; nFilter < aFilterLB.GetEntryCount(); ++nFilter )
     {
         OUString* pData = reinterpret_cast< OUString* >( aFilterLB.GetEntryData(nFilter) );
         delete pData;


More information about the Libreoffice-commits mailing list