[Libreoffice-commits] core.git: 21 commits - sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Thu Apr 17 22:45:06 PDT 2014
sw/source/ui/config/optpage.cxx | 88 ++++++--------
sw/source/ui/dbui/addresslistdialog.cxx | 69 ++++-------
sw/source/ui/dbui/createaddresslistdialog.cxx | 79 +++++--------
sw/source/ui/dbui/dbinsdlg.cxx | 153 ++++++++++++--------------
sw/source/ui/dbui/mmaddressblockpage.cxx | 137 ++++++++++-------------
sw/source/ui/dbui/mmgreetingspage.cxx | 34 ++---
sw/source/ui/dbui/mmlayoutpage.cxx | 2
7 files changed, 255 insertions(+), 307 deletions(-)
New commits:
commit 17196e613b61e4f5ae3b714006dd2f449c75188d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Apr 15 07:35:33 2014 +0200
OUString: constify and remove a temporary
Change-Id: Iac24bd0de87dd97e752760ee54f40433bda1db41
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 2c2f02c..7e3ada0 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -121,7 +121,7 @@ SwContentOptPage::SwContentOptPage( Window* pParent,
SvxStringArray aMetricArr( SW_RES( STR_ARR_METRIC ) );
for ( size_t i = 0; i < aMetricArr.Count(); ++i )
{
- OUString sMetric = aMetricArr.GetStringByPos( i );
+ const OUString sMetric = aMetricArr.GetStringByPos( i );
FieldUnit eFUnit = (FieldUnit)aMetricArr.GetValue( i );
switch ( eFUnit )
@@ -404,7 +404,7 @@ bool SwAddPrinterTabPage::FillItemSet( SfxItemSet& rCoreSet )
if (m_pInMarginsRB->IsChecked()) aAddPrinterAttr.nPrintPostIts =
POSTITS_INMARGINS;
- OUString sFax = m_pFaxLB->GetSelectEntry();
+ const OUString sFax = m_pFaxLB->GetSelectEntry();
aAddPrinterAttr.sFaxName = sNone == sFax ? aEmptyOUStr : sFax;
rCoreSet.Put(aAddPrinterAttr);
}
@@ -624,11 +624,11 @@ bool SwStdFontTabPage::FillItemSet( SfxItemSet& )
sal_Bool bNotDocOnly = !pDocOnlyCB->IsChecked();
SW_MOD()->GetModuleConfig()->SetDefaultFontInCurrDocOnly(!bNotDocOnly);
- OUString sStandard = pStandardBox->GetText();
- OUString sTitle = pTitleBox->GetText();
- OUString sList = pListBox->GetText();
- OUString sLabel = pLabelBox->GetText();
- OUString sIdx = pIdxBox->GetText();
+ const OUString sStandard = pStandardBox->GetText();
+ const OUString sTitle = pTitleBox->GetText();
+ const OUString sList = pListBox->GetText();
+ const OUString sLabel = pLabelBox->GetText();
+ const OUString sIdx = pIdxBox->GetText();
bool bStandardHeightChanged = pStandardHeightLB->GetSavedValue() != pStandardHeightLB->GetText();
bool bTitleHeightChanged = pTitleHeightLB->GetSavedValue() != pTitleHeightLB->GetText();
@@ -759,13 +759,12 @@ void SwStdFontTabPage::Reset( const SfxItemSet& rSet)
if( SFX_ITEM_SET == rSet.GetItemState(nLangSlot, false, &pLang))
eLanguage = ((const SvxLanguageItem*)pLang)->GetValue();
- OUString sTmp = pLabelFT->GetText();
OUString sToReplace = sScriptWestern;
if(FONT_GROUP_CJK == nFontGroup )
sToReplace = sScriptAsian;
else if(FONT_GROUP_CTL == nFontGroup )
sToReplace = sScriptComplex;
- pLabelFT->SetText(sTmp.replaceFirst("%1", sToReplace));
+ pLabelFT->SetText(pLabelFT->GetText().replaceFirst("%1", sToReplace));
const SfxPoolItem* pItem;
@@ -981,7 +980,7 @@ IMPL_LINK( SwStdFontTabPage, ModifyHdl, ComboBox*, pBox )
{
if(pBox == pStandardBox)
{
- OUString sEntry = pBox->GetText();
+ const OUString sEntry = pBox->GetText();
if(bSetListDefault && bListDefault)
pListBox->SetText(sEntry);
if(bSetLabelDefault && bLabelDefault)
@@ -1034,7 +1033,7 @@ IMPL_LINK( SwStdFontTabPage, ModifyHeightHdl, FontSizeBox*, pBox )
IMPL_LINK( SwStdFontTabPage, LoseFocusHdl, ComboBox*, pBox )
{
FontSizeBox* pHeightLB = 0;
- OUString sEntry = pBox->GetText();
+ const OUString sEntry = pBox->GetText();
if(pBox == pStandardBox)
{
pHeightLB = pStandardHeightLB;
@@ -1701,7 +1700,7 @@ SwRedlineOptionsTabPage::SwRedlineOptionsTabPage( Window* pParent,
for (sal_Int32 i = 0; i < pInsertLB->GetEntryCount(); ++i)
{
- OUString sEntry(pInsertLB->GetEntry(i));
+ const OUString sEntry(pInsertLB->GetEntry(i));
pDeletedLB->InsertEntry(sEntry);
pChangedLB->InsertEntry(sEntry);
};
@@ -1901,7 +1900,7 @@ void SwRedlineOptionsTabPage::Reset( const SfxItemSet& )
{
XColorEntry* pEntry = pColorLst->GetColor( i );
Color aColor = pEntry->GetColor();
- OUString sName = pEntry->GetName();
+ const OUString sName = pEntry->GetName();
pInsertColorLB->InsertEntry( aColor, sName );
pDeletedColorLB->InsertEntry( aColor, sName );
commit eb011eea8b1c1553fe73d4ceb557446a5b54e685
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Apr 15 07:28:17 2014 +0200
Use SAL_N_ELEMENTS() for array size
Change-Id: Ifcdeb47b5481ca6c16cd5eb6eb35858e7b2261c5
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 9991f30..2c2f02c 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -49,6 +49,7 @@
#include <editeng/fontitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/svxenum.hxx>
+#include <sal/macros.h>
#include <sfx2/dialoghelper.hxx>
#include <sfx2/request.hxx>
#include <sfx2/printer.hxx>
@@ -1960,12 +1961,9 @@ void SwRedlineOptionsTabPage::Reset( const SfxItemSet& )
pDeletedLB->SelectEntryPos(0);
pChangedLB->SelectEntryPos(0);
- lcl_FillRedlineAttrListBox(*pInsertLB, rInsertAttr, aInsertAttrMap,
- sizeof(aInsertAttrMap) / sizeof(sal_uInt16));
- lcl_FillRedlineAttrListBox(*pDeletedLB, rDeletedAttr, aDeletedAttrMap,
- sizeof(aDeletedAttrMap) / sizeof(sal_uInt16));
- lcl_FillRedlineAttrListBox(*pChangedLB, rChangedAttr, aChangedAttrMap,
- sizeof(aChangedAttrMap) / sizeof(sal_uInt16));
+ lcl_FillRedlineAttrListBox(*pInsertLB, rInsertAttr, aInsertAttrMap, SAL_N_ELEMENTS(aInsertAttrMap));
+ lcl_FillRedlineAttrListBox(*pDeletedLB, rDeletedAttr, aDeletedAttrMap, SAL_N_ELEMENTS(aDeletedAttrMap));
+ lcl_FillRedlineAttrListBox(*pChangedLB, rChangedAttr, aChangedAttrMap, SAL_N_ELEMENTS(aChangedAttrMap));
sal_Int32 nPos = 0;
switch (pOpt->GetMarkAlignMode())
commit 6618a52c1bed51236d85355cb35b20828ad750a6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Apr 15 07:22:37 2014 +0200
Use more proper integer types and constify
Change-Id: Ia1da4606c9c159741d5bb5f0e85750737ad7486d
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 602896b..9991f30 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -243,8 +243,8 @@ bool SwContentOptPage::FillItemSet(SfxItemSet& rSet)
if ( nMPos != m_pMetricLB->GetSavedValue() )
{
// Double-Cast for VA3.0
- sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pMetricLB->GetEntryData( nMPos );
- rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nFieldUnit ) );
+ const sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pMetricLB->GetEntryData( nMPos );
+ rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, nFieldUnit ) );
bRet = sal_True;
}
@@ -252,16 +252,16 @@ bool SwContentOptPage::FillItemSet(SfxItemSet& rSet)
if ( nMPos != m_pHMetric->GetSavedValue() || nMPos != nGlobalMetricPos )
{
// Double-Cast for VA3.0
- sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pHMetric->GetEntryData( nMPos );
- rSet.Put( SfxUInt16Item( FN_HSCROLL_METRIC, (sal_uInt16)nFieldUnit ) );
+ const sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pHMetric->GetEntryData( nMPos );
+ rSet.Put( SfxUInt16Item( FN_HSCROLL_METRIC, nFieldUnit ) );
bRet = sal_True;
}
nMPos = m_pVMetric->GetSelectEntryPos();
if ( nMPos != m_pVMetric->GetSavedValue() || nMPos != nGlobalMetricPos )
{
// Double-Cast for VA3.0
- sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pVMetric->GetEntryData( nMPos );
- rSet.Put( SfxUInt16Item( FN_VSCROLL_METRIC, (sal_uInt16)nFieldUnit ) );
+ const sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pVMetric->GetEntryData( nMPos );
+ rSet.Put( SfxUInt16Item( FN_VSCROLL_METRIC, nFieldUnit ) );
bRet = sal_True;
}
return bRet;
@@ -672,10 +672,10 @@ bool SwStdFontTabPage::FillItemSet( SfxItemSet& )
pWrtShell->StartAllAction();
SfxPrinter* pPrinter = pWrtShell->getIDocumentDeviceAccess()->getPrinter( false );
bool bMod = false;
- sal_uInt16 nFontWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
+ const sal_uInt16 nFontWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONT :
FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONT : RES_CHRATR_CTL_FONT);
- sal_uInt16 nFontHeightWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
+ const sal_uInt16 nFontHeightWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONTSIZE :
FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONTSIZE : RES_CHRATR_CTL_FONTSIZE);
if(sStandard != sShellStd)
@@ -752,7 +752,7 @@ bool SwStdFontTabPage::FillItemSet( SfxItemSet& )
void SwStdFontTabPage::Reset( const SfxItemSet& rSet)
{
const SfxPoolItem* pLang;
- sal_uInt16 nLangSlot = nFontGroup == FONT_GROUP_DEFAULT ? SID_ATTR_LANGUAGE :
+ const sal_uInt16 nLangSlot = nFontGroup == FONT_GROUP_DEFAULT ? SID_ATTR_LANGUAGE :
FONT_GROUP_CJK == nFontGroup ? SID_ATTR_CHAR_CJK_LANGUAGE : SID_ATTR_CHAR_CTL_LANGUAGE;
if( SFX_ITEM_SET == rSet.GetItemState(nLangSlot, false, &pLang))
@@ -862,7 +862,7 @@ void SwStdFontTabPage::Reset( const SfxItemSet& rSet)
FONT_GROUP_CJK == nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
sShellStd = sStdBackup = rFont.GetFamilyName();
- sal_uInt16 nFontHeightWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
+ const sal_uInt16 nFontHeightWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONTSIZE :
FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONTSIZE : RES_CHRATR_CTL_FONTSIZE );
const SvxFontHeightItem& rFontHeightStandard = (const SvxFontHeightItem& )pColl->GetFmtAttr(nFontHeightWhich);
@@ -876,7 +876,7 @@ void SwStdFontTabPage::Reset( const SfxItemSet& rSet)
const SvxFontHeightItem& rFontHeightTitle = (const SvxFontHeightItem&)pColl->GetFmtAttr( nFontHeightWhich, sal_True );
nTitleHeight = (sal_Int32)rFontHeightTitle.GetHeight();
- sal_uInt16 nFontWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
+ const sal_uInt16 nFontWhich = sal::static_int_cast< sal_uInt16, RES_CHRATR >(
nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONT :
FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONT : RES_CHRATR_CTL_FONT);
pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_NUMBUL_BASE);
@@ -1227,7 +1227,7 @@ void SwTableOptionsTabPage::Reset( const SfxItemSet& rSet)
}
SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode);
- sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode;
+ const sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode;
pHeaderCB->Check(0 != (nInsTblFlags & tabopts::HEADLINE));
pRepeatHeaderCB->Check((!bHTMLMode) && (aInsOpts.mnRowsToRepeat > 0));
@@ -1537,18 +1537,18 @@ void SwMarkPreview::Paint(const Rectangle &/*rRect*/)
// Page
aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3));
- sal_uLong nOutWPix = aPage.GetWidth();
- sal_uLong nOutHPix = aPage.GetHeight();
+ const long nOutWPix = aPage.GetWidth();
+ const long nOutHPix = aPage.GetHeight();
// PrintArea
- sal_uLong nLBorder = 8;
- sal_uLong nRBorder = 8;
- sal_uLong nTBorder = 4;
- sal_uLong nBBorder = 4;
+ const long nLBorder = 8;
+ const long nRBorder = 8;
+ const long nTBorder = 4;
+ const long nBBorder = 4;
aLeftPagePrtArea = Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
- sal_uInt16 nWidth = (sal_uInt16)aLeftPagePrtArea.GetWidth();
- sal_uInt16 nKorr = (nWidth & 1) != 0 ? 0 : 1;
+ const long nWidth = aLeftPagePrtArea.GetWidth();
+ const long nKorr = (nWidth & 1) != 0 ? 0 : 1;
aLeftPagePrtArea.SetSize(Size(nWidth / 2 - (nLBorder + nRBorder) / 2 + nKorr, aLeftPagePrtArea.GetHeight()));
aRightPagePrtArea = aLeftPagePrtArea;
@@ -1616,14 +1616,11 @@ void SwMarkPreview::PaintPage(const Rectangle &rRect)
aTextLine.Right() -= nRTxtBorder;
aTextLine.Move(0, nTTxtBorder);
- sal_Int32 nStep;
- sal_uInt16 nLines;
-
- nStep = aTextLine.GetHeight() + 2;
- nLines = (sal_uInt16)(rRect.GetHeight() / (aTextLine.GetHeight() + 2)) - 1;
+ const long nStep = aTextLine.GetHeight() + 2;
+ const long nLines = rRect.GetHeight() / (aTextLine.GetHeight() + 2) - 1;
// simulate text
- for (sal_uInt16 i = 0; i < nLines; ++i)
+ for (long i = 0; i < nLines; ++i)
{
if (i == (nLines - 1))
aTextLine.SetSize(Size(aTextLine.GetWidth() / 2, aTextLine.GetHeight()));
@@ -1652,9 +1649,9 @@ namespace
{
void lcl_FillRedlineAttrListBox(
ListBox& rLB, const AuthorCharAttr& rAttrToSelect,
- const sal_uInt16* pAttrMap, const sal_uInt16 nAttrMapSize)
+ const sal_uInt16* pAttrMap, const size_t nAttrMapSize)
{
- for (sal_uInt16 i = 0; i != nAttrMapSize; ++i)
+ for (size_t i = 0; i != nAttrMapSize; ++i)
{
CharAttr& rAttr(aRedlineAttr[pAttrMap[i]]);
rLB.SetEntryData(i, &rAttr);
commit 1decd1ef25cf7c2fde6e28b72462dc19ead89601
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 14 23:30:52 2014 +0200
OUString: constify, remove temporaries and concatenated appends
Change-Id: I7333d32a437a75a3fe9728591217258a2fa6c5e3
diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx
index e835f4f..65e0a1b 100644
--- a/sw/source/ui/dbui/addresslistdialog.cxx
+++ b/sw/source/ui/dbui/addresslistdialog.cxx
@@ -76,8 +76,6 @@ using namespace ::rtl;
#define ITEMID_NAME 1
#define ITEMID_TABLE 2
-static const char* cUTF8 = "UTF-8";
-
struct AddressUserData_Impl
{
uno::Reference<XDataSource> xSource;
@@ -96,7 +94,6 @@ struct AddressUserData_Impl
static OUString lcl_getFlatURL( uno::Reference<beans::XPropertySet>& xSourceProperties )
{
- OUString sURL;
if(xSourceProperties.is())
{
OUString sDBURL;
@@ -124,20 +121,16 @@ static OUString lcl_getFlatURL( uno::Reference<beans::XPropertySet>& xSourceProp
else if(aInfo[nInfo].Name == "CharSet")
aInfo[nInfo].Value >>= sCharSet;
}
- if(sCharSet.equalsAscii( cUTF8 ))
+ if (sCharSet=="UTF-8")
{
- sURL = sDBURL.copy(10);
//#i97577# at this point the 'URL' can also be a file name!
- sURL = URIHelper::SmartRel2Abs( INetURLObject(), sURL );
- sURL += "/";
- sURL += aFilters[0];
- sURL += ".";
- sURL += sExtension;
+ return URIHelper::SmartRel2Abs( INetURLObject(), sDBURL.copy(10) )
+ + "/" + aFilters[0] + "." + sExtension;
}
}
}
}
- return sURL;
+ return OUString();
}
class SwAddrSourceLB : public SvSimpleTable
@@ -192,9 +185,9 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
m_sTable = get<FixedText>("table")->GetText();
m_sConnecting = get<FixedText>("connecting")->GetText();
- OUString sTemp(m_pDescriptionFI->GetText());
- sTemp = sTemp.replaceFirst("%1", m_pLoadListPB->GetText());
- sTemp = sTemp.replaceFirst("%2", m_pCreateListPB->GetText());
+ const OUString sTemp(m_pDescriptionFI->GetText()
+ .replaceFirst("%1", m_pLoadListPB->GetText())
+ .replaceFirst("%2", m_pCreateListPB->GetText()));
m_pDescriptionFI->SetText(sTemp);
m_pFilterPB->SetClickHdl( LINK( this, SwAddressListDialog, FilterHdl_Impl ));
m_pLoadListPB->SetClickHdl( LINK( this, SwAddressListDialog, LoadHdl_Impl ));
@@ -226,7 +219,7 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
m_pListLB->SelectAll( false );
SwDBConfig aDb;
- OUString sBibliography = aDb.GetBibliographySource().sDataSource;
+ const OUString sBibliography = aDb.GetBibliographySource().sDataSource;
uno::Sequence< OUString> aNames = m_xDBContext->getElementNames();
const OUString* pNames = aNames.getConstArray();
for(sal_Int32 nName = 0; nName < aNames.getLength(); ++nName)
@@ -288,7 +281,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl)
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
if(pSelect)
{
- OUString sCommand = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
+ const OUString sCommand = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
if (sCommand.isEmpty())
return 0;
@@ -305,9 +298,8 @@ IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl)
xMgr->createInstance("com.sun.star.sdb.RowSet"), UNO_QUERY);
uno::Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
xRowProperties->setPropertyValue("DataSourceName",
- makeAny(OUString(m_pListLB->GetEntryText(pSelect, ITEMID_NAME - 1))));
- xRowProperties->setPropertyValue("Command", makeAny(
- OUString(sCommand)));
+ makeAny(m_pListLB->GetEntryText(pSelect, ITEMID_NAME - 1)));
+ xRowProperties->setPropertyValue("Command", makeAny(sCommand));
xRowProperties->setPropertyValue("CommandType", makeAny(pUserData->nCommandType));
xRowProperties->setPropertyValue("ActiveConnection", makeAny(pUserData->xConnection.getTyped()));
xRowSet->execute();
@@ -339,7 +331,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl)
IMPL_LINK_NOARG(SwAddressListDialog, LoadHdl_Impl)
{
- OUString sNewSource = SwNewDBMgr::LoadAndRegisterDataSource();
+ const OUString sNewSource = SwNewDBMgr::LoadAndRegisterDataSource();
if(!sNewSource.isEmpty())
{
SvTreeListEntry* pNewSource = m_pListLB->InsertEntry(sNewSource);
@@ -360,29 +352,27 @@ IMPL_LINK(SwAddressListDialog, CreateHdl_Impl, PushButton*, pButton)
if(RET_OK == pDlg->Execute())
{
//register the URL a new datasource
- OUString sURL = pDlg->GetURL();
+ const OUString sURL = pDlg->GetURL();
try
{
uno::Reference<XSingleServiceFactory> xFact( m_xDBContext, UNO_QUERY);
uno::Reference<XInterface> xNewInstance = xFact->createInstance();
INetURLObject aURL( sURL );
- OUString sNewName = aURL.getBase();
+ const OUString sNewName = aURL.getBase();
//find a unique name if sNewName already exists
OUString sFind(sNewName);
sal_Int32 nIndex = 0;
while(m_xDBContext->hasByName(sFind))
{
- sFind = sNewName;
- sFind += OUString::number(++nIndex);
+ sFind = sNewName + OUString::number(++nIndex);
}
uno::Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
- OUString sDBURL("sdbc:flat:");
//only the 'path' has to be added
INetURLObject aTempURL(aURL);
aTempURL.removeSegment();
aTempURL.removeFinalSlash();
- sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ const OUString sDBURL("sdbc:flat:" + aTempURL.GetMainURL(INetURLObject::NO_DECODE));
Any aAny(&sDBURL, ::getCppuType(&sDBURL));
xDataProperties->setPropertyValue("URL", aAny);
//set the filter to the file name without extension
@@ -398,9 +388,9 @@ IMPL_LINK(SwAddressListDialog, CreateHdl_Impl, PushButton*, pButton)
pInfo[1].Name = "StringDelimiter";
pInfo[1].Value <<= OUString('"');
pInfo[2].Name = "Extension";
- pInfo[2].Value <<= OUString(aURL.getExtension());//"csv";
+ pInfo[2].Value <<= aURL.getExtension();//"csv";
pInfo[3].Name = "CharSet";
- pInfo[3].Value <<= OUString::createFromAscii(cUTF8);
+ pInfo[3].Value <<= OUString("UTF-8");
aAny <<= aInfo;
xDataProperties->setPropertyValue("Info", aAny);
@@ -419,10 +409,7 @@ IMPL_LINK(SwAddressListDialog, CreateHdl_Impl, PushButton*, pButton)
uno::Reference<XNamingService> xNaming(m_xDBContext, UNO_QUERY);
xNaming->registerObject( sFind, xNewInstance );
//now insert the new source into the ListBox
- OUString sEntry(sFind);
- sEntry += "\t";
- sEntry += aFilters[0];
- m_pCreatedDataSource = m_pListLB->InsertEntry(sEntry);
+ m_pCreatedDataSource = m_pListLB->InsertEntry(sFind + "\t" + aFilters[0]);
AddressUserData_Impl* pUserData = new AddressUserData_Impl();
pUserData->sURL = sURL;
m_pCreatedDataSource->SetUserData(pUserData);
@@ -486,7 +473,7 @@ IMPL_STATIC_LINK(SwAddressListDialog, StaticListBoxSelectHdl_Impl, SvTreeListEnt
AddressUserData_Impl* pUserData = 0;
if(pSelect)
{
- OUString sTable = pThis->m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
+ const OUString sTable(pThis->m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1));
if(sTable.isEmpty())
{
pThis->m_pListLB->SetEntryText(pThis->m_sConnecting, pSelect, ITEMID_TABLE - 1);
@@ -521,8 +508,7 @@ IMPL_STATIC_LINK(SwAddressListDialog, StaticListBoxSelectHdl_Impl, SvTreeListEnt
pThis->m_aDBData.nCommandType = pUserData->nCommandType;
pThis->m_pOK->Enable(true);
}
- sTable = pThis->m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
- if(sTable == pThis->m_sConnecting)
+ if(pThis->m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1) == pThis->m_sConnecting)
pThis->m_pListLB->SetEntryText(OUString(), pSelect, ITEMID_TABLE - 1);
}
pThis->m_pEditPB->Enable(pUserData && !pUserData->sURL.isEmpty() &&
@@ -577,7 +563,7 @@ void SwAddressListDialog::DetectTablesAndQueries(
{
//now call the table select dialog - if more than one table exists
boost::scoped_ptr<SwSelectDBTableDialog> pDlg(new SwSelectDBTableDialog(this, pUserData->xConnection));
- OUString sTable = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
+ const OUString sTable = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
if(!sTable.isEmpty())
pDlg->SetSelectedTable(sTable, pUserData->nCommandType == CommandType::TABLE);
if(RET_OK == pDlg->Execute())
@@ -618,7 +604,7 @@ void SwAddressListDialog::DetectTablesAndQueries(
else
m_pListLB->SetEntryText(OUString(), pSelect, ITEMID_TABLE - 1);
}
- OUString sCommand = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
+ const OUString sCommand = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
m_pOK->Enable(pSelect && !sCommand.isEmpty());
m_pFilterPB->Enable( pUserData->xConnection.is() && !sCommand.isEmpty() );
m_pTablePB->Enable( pUserData->nTableAndQueryCount > 1 );
@@ -639,7 +625,7 @@ IMPL_LINK(SwAddressListDialog, TableSelectHdl_Impl, PushButton*, pButton)
AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
//only call the table select dialog if tables have not been searched for or there
//are more than 1
- OUString sTable = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
+ const OUString sTable = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
if( pUserData->nTableAndQueryCount > 1 || pUserData->nTableAndQueryCount == -1)
{
DetectTablesAndQueries(pSelect, (pButton != 0) || sTable.isEmpty());
@@ -695,14 +681,13 @@ uno::Reference< XColumnsSupplier> SwAddressListDialog::GetColumnsSupplier()
OUString SwAddressListDialog::GetFilter()
{
- OUString sRet;
SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
if(pSelect)
{
AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
- sRet = pUserData->sFilter;
+ return pUserData->sFilter;
}
- return sRet;
+ return OUString();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a6f8de662e0e03e3ac2160823dc02b84fa6ba091
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 14 23:22:53 2014 +0200
sal_uInt16 to int
Change-Id: I8a27d7fc2cbdb3093e7955b80642675dc9b8ab55
diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx
index 88ad0cf..e835f4f 100644
--- a/sw/source/ui/dbui/addresslistdialog.cxx
+++ b/sw/source/ui/dbui/addresslistdialog.cxx
@@ -492,7 +492,7 @@ IMPL_STATIC_LINK(SwAddressListDialog, StaticListBoxSelectHdl_Impl, SvTreeListEnt
pThis->m_pListLB->SetEntryText(pThis->m_sConnecting, pSelect, ITEMID_TABLE - 1);
// allow painting of the new entry
pThis->m_pListLB->Window::Invalidate(INVALIDATE_UPDATE);
- for (sal_uInt16 i = 0; i < 10; i++)
+ for (int i = 0; i < 10; ++i)
Application::Reschedule();
}
commit c6ba1deab0f04c05e8554caaf563c4349a4005af
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 14 22:42:07 2014 +0200
Group common code for csv generation and simplify OUString handling
Though writing data incrementally without building the whole line would
be more efficient.
Change-Id: I396378c6f306f4ff0d10037f87c33005b7e4b640
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index 2f42b8a..aebd382 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -541,6 +541,30 @@ IMPL_LINK(SwCreateAddressListDialog, CustomizeHdl_Impl, PushButton*, pButton)
return 0;
}
+namespace
+{
+
+void lcl_WriteValues(const ::std::vector<OUString> *pFields, SvStream* pStream)
+{
+ OUString sLine;
+ const ::std::vector< OUString >::const_iterator aBegin = pFields->begin();
+ const ::std::vector< OUString >::const_iterator aEnd = pFields->end();
+ for(::std::vector< OUString >::const_iterator aIter = aBegin; aIter != aEnd; ++aIter)
+ {
+ if (aIter==aBegin)
+ {
+ sLine += "\"" + *aIter + "\"";
+ }
+ else
+ {
+ sLine += "\t\"" + *aIter + "\"";
+ }
+ }
+ pStream->WriteByteStringLine( sLine, RTL_TEXTENCODING_UTF8 );
+}
+
+}
+
IMPL_LINK_NOARG(SwCreateAddressListDialog, OkHdl_Impl)
{
if(m_sURL.isEmpty())
@@ -569,39 +593,12 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, OkHdl_Impl)
pStream->SetLineDelimiter( LINEEND_LF );
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
- OUString sQuote('"');
- OUString sTempMiddle(sQuote);
- sTempMiddle += OUString(sal_Unicode(9));
- OUString sMiddle(sTempMiddle);
- sMiddle += sQuote;
-
- //create a string for the header line
- OUString sLine(sQuote);
- ::std::vector< OUString >::iterator aHeaderIter;
- for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin();
- aHeaderIter != m_pCSVData->aDBColumnHeaders.end();
- ++aHeaderIter)
- {
- sLine += *aHeaderIter;
- sLine += sMiddle;
- }
- //remove tab and quote
- sLine = sLine.copy( 0, sLine.getLength() - 2 );
- pStream->WriteByteStringLine( sLine, RTL_TEXTENCODING_UTF8 );
+ lcl_WriteValues(&(m_pCSVData->aDBColumnHeaders), pStream);
::std::vector< ::std::vector< OUString > >::iterator aDataIter;
for( aDataIter = m_pCSVData->aDBData.begin(); aDataIter != m_pCSVData->aDBData.end(); ++aDataIter)
{
- sLine = sQuote;
- ::std::vector< OUString >::iterator aColumnIter;
- for(aColumnIter = aDataIter->begin(); aColumnIter != aDataIter->end(); ++aColumnIter)
- {
- sLine += *aColumnIter;
- sLine += sMiddle;
- }
- //remove tab and quote
- sLine = sLine.copy( 0, sLine.getLength() - 2 );
- pStream->WriteByteStringLine( sLine, RTL_TEXTENCODING_UTF8 );
+ lcl_WriteValues(&(*aDataIter), pStream);
}
aMedium.Commit();
EndDialog(RET_OK);
commit 280c5fc0ab10b8d64c48de3c7febb2ea3e69cea6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 14 20:05:47 2014 +0200
OUString: constify and avoid temporaries
Change-Id: Iffff24e9d49f378b2ca6bb470d678ec0724f0594
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index 50ccd2b..2f42b8a 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -402,7 +402,7 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
sal_Int32 nIndex = 0;
for( sal_Int32 nToken = 0; nToken < nHeaders; ++nToken)
{
- OUString sHeader = sLine.getToken( 0, '\t', nIndex );
+ const OUString sHeader = sLine.getToken( 0, '\t', nIndex );
OSL_ENSURE(sHeader.getLength() > 2 &&
sHeader.startsWith("\"") && sHeader.endsWith("\""),
"Wrong format of header");
@@ -420,7 +420,7 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
sal_Int32 nIndex = 0;
for( sal_Int32 nToken = 0; nToken < nDataCount; ++nToken)
{
- OUString sData = sLine.getToken( 0, '\t', nIndex );
+ const OUString sData = sLine.getToken( 0, '\t', nIndex );
OSL_ENSURE( sData.startsWith("\"") && sData.endsWith("\""),
"Wrong format of line");
if(sData.getLength() >= 2)
@@ -548,19 +548,17 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, OkHdl_Impl)
sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_SIMPLE, 0 );
uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
- OUString sPath( SvtPathOptions().SubstituteVariable(
- OUString("$(userurl)/database") ));
+ const OUString sPath( SvtPathOptions().SubstituteVariable("$(userurl)/database") );
aDlgHelper.SetDisplayDirectory( sPath );
uno::Reference< XFilterManager > xFltMgr(xFP, uno::UNO_QUERY);
- OUString sCSV("*.csv");
- xFltMgr->appendFilter( m_sAddressListFilterName, sCSV );
+ xFltMgr->appendFilter( m_sAddressListFilterName, "*.csv" );
xFltMgr->setCurrentFilter( m_sAddressListFilterName ) ;
if( ERRCODE_NONE == aDlgHelper.Execute() )
{
m_sURL = xFP->getFiles().getConstArray()[0];
INetURLObject aResult( m_sURL );
- aResult.setExtension(OUString("csv"));
+ aResult.setExtension("csv");
m_sURL = aResult.GetMainURL(INetURLObject::NO_DECODE);
}
}
@@ -658,7 +656,7 @@ void SwCreateAddressListDialog::UpdateButtons()
void SwCreateAddressListDialog::Find(const OUString& rSearch, sal_Int32 nColumn)
{
- OUString sSearch = OUString(rSearch).toAsciiLowerCase();
+ const OUString sSearch = rSearch.toAsciiLowerCase();
sal_uInt32 nCurrent = m_pAddressControl->GetCurrentDataSet();
//search forward
bool bFound = false;
commit 8f06f94827bd5ec347008df22b5bbb4c835032f3
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 14 00:10:19 2014 +0200
Remove unused OUStrings
Change-Id: I7c98a0113418ac82f0b91b373073c8a11b6f9740
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index 1d2df4a..50ccd2b 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -392,10 +392,6 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
pStream->SetLineDelimiter( LINEEND_LF );
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
- OUString sQuote('"');
- OUString sTempMiddle(sQuote);
- sTempMiddle += OUString(sal_Unicode(9));
-
OUString sLine;
bool bRead = pStream->ReadByteStringLine( sLine, RTL_TEXTENCODING_UTF8 );
commit 51b633998e322def386a28a87e9313781bc8b1e4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 14 00:07:19 2014 +0200
sal_uInt16 to sal_uInt32 + constify
Change-Id: I7b5035d6189d6b3a33f767a926b443760adb5be0
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index 70fac42..1d2df4a 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -331,7 +331,7 @@ bool SwAddressControl_Impl::PreNotify( NotifyEvent& rNEvt )
if(rNEvt.GetType() == EVENT_COMMAND)
{
const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
- sal_uInt16 nCmd = pCEvt->GetCommand();
+ const sal_uInt16 nCmd = pCEvt->GetCommand();
if( COMMAND_WHEEL == nCmd )
{
Command(*pCEvt);
@@ -440,8 +440,8 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
{
//database has to be created
const ResStringArray& rAddressHeader = rConfig.GetDefaultAddressHeaders();
- sal_uInt32 nCount = rAddressHeader.Count();
- for(sal_uInt16 nHeader = 0; nHeader < nCount; ++nHeader)
+ const sal_uInt32 nCount = rAddressHeader.Count();
+ for(sal_uInt32 nHeader = 0; nHeader < nCount; ++nHeader)
m_pCSVData->aDBColumnHeaders.push_back( rAddressHeader.GetString(nHeader));
::std::vector<OUString> aNewData;
OUString sTemp;
commit d77e8348f372bd069aa8adccabb65a3722539323
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 14 00:04:40 2014 +0200
Simplify generation of unique name
Change-Id: Ifed55197ed6836dfb16d958c7dd34afad6c4aca7
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index ee12e1f..dae0b0f 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1492,26 +1492,20 @@ static Sequence<OUString> lcl_CreateSubNames(const OUString& rSubNodeName)
static OUString lcl_CreateUniqueName(const Sequence<OUString>& aNames)
{
- sal_Int32 nIdx = aNames.getLength();
+ const sal_Int32 nNames = aNames.getLength();
+ sal_Int32 nIdx = nNames;
const OUString* pNames = aNames.getConstArray();
- OUString sTest("_");
- OUString sRet;
while(true)
{
- sRet = sTest; sRet += OUString::number(nIdx++);
- bool bFound = false;
- for(sal_Int32 i = 0; i < aNames.getLength(); i++)
+ const OUString sRet = "_" + OUString::number(nIdx++);
+ sal_Int32 i = 0;
+ while ( i < nNames && pNames[i] != sRet )
{
- if(pNames[i] == sRet)
- {
- bFound = true;
- break;
- }
+ ++i;
}
- if(!bFound)
- break;
+ if ( i >= nNames )
+ return sRet; // No match found, return unique name
}
- return sRet;
}
void SwInsertDBColAutoPilot::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
commit 4e69f4d4ec6e52189d2bcc31a01c31d626e6c394
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 13 23:50:27 2014 +0200
OUString: reduce temporaries/concatenated appends + minor optimizations
Change-Id: I30ea3ee112ef65555bfa5d7f2b8e908bb394ca58
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index b579e8f..ee12e1f 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -162,7 +162,12 @@ struct _DB_Column
struct _DB_ColumnConfigData: private boost::noncopyable
{
SwInsDBColumns aDBColumns;
- OUString sSource, sTable, sEdit, sTblList, sTmplNm, sTAutoFmtNm;
+ OUString sSource;
+ OUString sTable;
+ OUString sEdit;
+ OUString sTblList;
+ OUString sTmplNm;
+ OUString sTAutoFmtNm;
sal_Bool bIsTable : 1,
bIsField : 1,
bIsHeadlineOn : 1,
@@ -421,8 +426,7 @@ IMPL_LINK( SwInsertDBColAutoPilot, PageHdl, Button*, pButton )
{
bool bShowTbl = pButton == m_pRbAsTable;
- OUString sTxt(pButton->GetText());
- m_pHeadFrame->set_label(MnemonicGenerator::EraseAllMnemonicChars(sTxt));
+ m_pHeadFrame->set_label(MnemonicGenerator::EraseAllMnemonicChars(pButton->GetText()));
m_pLbTxtDbColumn->Show( !bShowTbl );
m_pIbDbcolToEdit->Show( !bShowTbl );
@@ -527,7 +531,7 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
nInsPos = LISTBOX_ENTRY_NOTFOUND;
while( ++it != aDBColumns.end() &&
LISTBOX_ENTRY_NOTFOUND == (nInsPos = m_pLbTblDbColumn->
- GetEntryPos( OUString( (*it)->sColumn ))) )
+ GetEntryPos( (*it)->sColumn )) )
;
}
@@ -590,8 +594,7 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
}
}
- aStr = aStr.replaceAt( nPos, 0, aFld );
- m_pEdDbText->SetText( aStr );
+ m_pEdDbText->SetText( aStr.replaceAt( nPos, 0, aFld ) );
nPos += aFld.getLength();
m_pEdDbText->SetSelection( Selection( nPos ));
}
@@ -803,7 +806,7 @@ IMPL_LINK( SwInsertDBColAutoPilot, SelectHdl, ListBox*, pBox )
if( bEnableFmt )
{
- sTxt = sTxt + " (" + aSrch.sColumn + ")";
+ sTxt += " (" + aSrch.sColumn + ")";
}
sal_Bool bIsDBFmt = (*it)->bIsDBFmt;
@@ -1128,7 +1131,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
}
else
{
- OUString sVal = xColumn->getString();
+ const OUString sVal = xColumn->getString();
if(!xColumn->wasNull())
{
rSh.SwEditShell::Insert2( sVal );
@@ -1185,7 +1188,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
SwTxtFmtColl* pColl = 0;
{
- OUString sTmplNm( m_pLbDbParaColl->GetSelectEntry() );
+ const OUString sTmplNm( m_pLbDbParaColl->GetSelectEntry() );
if( sNoTmpl != sTmplNm )
{
pColl = rSh.FindTxtFmtCollByName( sTmplNm );
@@ -1229,7 +1232,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
aDBFormatData.aLocale = LanguageTag( rSh.GetCurLang() ).getLocale();
SwDBNextSetField aNxtDBFld( (SwDBNextSetFieldType*)rSh.
GetFldType( 0, RES_DBNEXTSETFLD ),
- OUString("1"), aEmptyOUStr, aDBData );
+ "1", "", aDBData );
bool bSetCrsr = true;
const size_t nCols = aColArr.size();
@@ -1522,16 +1525,14 @@ void SwInsertDBColAutoPilot::Commit()
{
Sequence<OUString> aSourceNames(2);
OUString* pSourceNames = aSourceNames.getArray();
- pSourceNames[0] = pNames[nNode];
- pSourceNames[0] += "/DataSource";
- pSourceNames[1] = pNames[nNode];
- pSourceNames[1] += "/Command";
+ pSourceNames[0] = pNames[nNode] + "/DataSource";
+ pSourceNames[1] = pNames[nNode] + "/Command";
Sequence<Any> aSourceProperties = GetProperties(aSourceNames);
const Any* pSourceProps = aSourceProperties.getArray();
OUString sSource, sCommand;
pSourceProps[0] >>= sSource;
pSourceProps[1] >>= sCommand;
- if(sSource.equals(aDBData.sDataSource) && sCommand.equals(aDBData.sCommand))
+ if(sSource==aDBData.sDataSource && sCommand==aDBData.sCommand)
{
Sequence<OUString> aElements(1);
aElements.getArray()[0] = pNames[nNode];
@@ -1545,22 +1546,20 @@ void SwInsertDBColAutoPilot::Commit()
Sequence<PropertyValue> aValues(aNodeNames.getLength());
PropertyValue* pValues = aValues.getArray();
const OUString* pNodeNames = aNodeNames.getConstArray();
- OUString sSlash("/");
for(sal_Int32 i = 0; i < aNodeNames.getLength(); i++)
{
- pValues[i].Name = sSlash;
- pValues[i].Name += pNodeNames[i];
+ pValues[i].Name = "/" + pNodeNames[i];
}
- pValues[0].Value <<= OUString(aDBData.sDataSource);
- pValues[1].Value <<= OUString(aDBData.sCommand);
+ pValues[0].Value <<= aDBData.sDataSource;
+ pValues[1].Value <<= aDBData.sCommand;
pValues[2].Value <<= aDBData.nCommandType;
- pValues[3].Value <<= OUString(m_pEdDbText->GetText());
+ pValues[3].Value <<= m_pEdDbText->GetText();
OUString sTmp;
const sal_Int32 nCnt = m_pLbTableCol->GetEntryCount();
for( sal_Int32 n = 0; n < nCnt; ++n )
- (sTmp += m_pLbTableCol->GetEntry(n)) += "\x0a";
+ sTmp += m_pLbTableCol->GetEntry(n) + "\x0a";
if (!sTmp.isEmpty())
pValues[4].Value <<= sTmp;
@@ -1569,7 +1568,7 @@ void SwInsertDBColAutoPilot::Commit()
pValues[5].Value <<= sTmp;
if( pTAutoFmt )
- pValues[6].Value <<= OUString(pTAutoFmt->GetName());
+ pValues[6].Value <<= pTAutoFmt->GetName();
const Type& rBoolType = ::getBooleanCppuType();
sal_Bool bTmp = m_pRbAsTable->IsChecked();
@@ -1587,21 +1586,17 @@ void SwInsertDBColAutoPilot::Commit()
SetSetProperties(OUString(), aValues);
sNewNode += "/ColumnSet";
- OUString sDelim("/__");
LanguageType ePrevLang = (LanguageType)-1;
- OUString sPrevLang;
SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
for(size_t nCol = 0; nCol < aDBColumns.size(); nCol++)
{
- OUString sColumnNode = sNewNode;
- SwInsDBColumn* pColumn = aDBColumns[nCol];
- OUString sColumnInsertNode(sColumnNode);
- sColumnInsertNode += sDelim;
- if( nCol < 100 )
- sColumnInsertNode += "0";
+ SwInsDBColumn* pColumn = aDBColumns[nCol];
+ OUString sColumnInsertNode(sNewNode + "/__");
if( nCol < 10 )
+ sColumnInsertNode += "00";
+ else if( nCol < 100 )
sColumnInsertNode += "0";
sColumnInsertNode += OUString::number( nCol );
@@ -1626,7 +1621,7 @@ void SwInsertDBColAutoPilot::Commit()
LanguageType eLang;
if( pNF )
{
- pSubValues[4].Value <<= OUString(pNF->GetFormatstring());
+ pSubValues[4].Value <<= pNF->GetFormatstring();
eLang = pNF->GetLanguage();
}
else
@@ -1635,6 +1630,7 @@ void SwInsertDBColAutoPilot::Commit()
eLang = GetAppLanguage();
}
+ OUString sPrevLang;
if( eLang != ePrevLang )
{
sPrevLang = LanguageTag::convertToBcp47( eLang );
@@ -1642,7 +1638,7 @@ void SwInsertDBColAutoPilot::Commit()
}
pSubValues[5].Value <<= sPrevLang;
- SetSetProperties(sColumnNode, aSubValues);
+ SetSetProperties(sNewNode, aSubValues);
}
}
@@ -1682,15 +1678,13 @@ void SwInsertDBColAutoPilot::Load()
if(pDataSourceProps[10].hasValue())
pNewData->bIsEmptyHeadln = *(sal_Bool*)pDataSourceProps[10].getValue();
- OUString sSubNodeName(pNames[nNode]);
- sSubNodeName += "/ColumnSet/";
+ const OUString sSubNodeName(pNames[nNode] + "/ColumnSet/");
Sequence <OUString> aSubNames = GetNodeNames(sSubNodeName);
const OUString* pSubNames = aSubNames.getConstArray();
for(sal_Int32 nSub = 0; nSub < aSubNames.getLength(); nSub++)
{
- OUString sSubSubNodeName(sSubNodeName);
- sSubSubNodeName += pSubNames[nSub];
- Sequence <OUString> aSubNodeNames = lcl_CreateSubNames(sSubSubNodeName);
+ Sequence <OUString> aSubNodeNames =
+ lcl_CreateSubNames(sSubNodeName + pSubNames[nSub]);
Sequence< Any> aSubProps = GetProperties(aSubNodeNames);
const Any* pSubProps = aSubProps.getConstArray();
@@ -1740,7 +1734,7 @@ void SwInsertDBColAutoPilot::Load()
{
sal_Int32 n = 0;
do {
- OUString sEntry( sTmp.getToken( 0, '\x0a', n ) );
+ const OUString sEntry( sTmp.getToken( 0, '\x0a', n ) );
//preselect column - if they still exist!
if(m_pLbTblDbColumn->GetEntryPos(sEntry) != LISTBOX_ENTRY_NOTFOUND)
{
commit 5da934fb90fa9232540c3afb10905f52f93f079b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 13 23:20:20 2014 +0200
This seems to be an infinite loop (never triggered?)
Change-Id: If619adcb5aa7951be159a387eaebf8553feb22e5
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 003d1b1..b579e8f 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1747,7 +1747,7 @@ void SwInsertDBColAutoPilot::Load()
m_pLbTableCol->InsertEntry( sEntry );
m_pLbTblDbColumn->RemoveEntry( sEntry );
}
- } while( n < sTmp.getLength() );
+ } while( n>=0 );
if( !m_pLbTblDbColumn->GetEntryCount() )
{
commit 821bde3ffc9ffd1458ea8794ddba6c04283bd531
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 13 23:10:48 2014 +0200
Use more proper integer types + minor optimizations
Change-Id: I10df0245363715911d0eea2869a32a5ab849d3c4
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 9b20eaf..003d1b1 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -258,8 +258,8 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView,
Reference <XNameAccess> xCols = xColSupp->getColumns();
Sequence<OUString> aColNames = xCols->getElementNames();
const OUString* pColNames = aColNames.getConstArray();
- long nCount = aColNames.getLength();
- for (long n = 0; n < nCount; n++)
+ sal_Int32 nCount = aColNames.getLength();
+ for (sal_Int32 n = 0; n < nCount; ++n)
{
SwInsDBColumn* pNew = new SwInsDBColumn( pColNames[n], (sal_uInt16)n );
Any aCol = xCols->getByName(pColNames[n]);
@@ -391,11 +391,11 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView,
m_pLbTblDbColumn->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
m_pLbTableCol->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
- for( sal_uInt16 n = 0; n < aDBColumns.size(); ++n )
+ for( size_t n = 0; n < aDBColumns.size(); ++n )
{
const OUString& rS = aDBColumns[ n ]->sColumn;
- m_pLbTblDbColumn->InsertEntry( rS, n );
- m_pLbTxtDbColumn->InsertEntry( rS, n );
+ m_pLbTblDbColumn->InsertEntry( rS, static_cast<sal_Int32>(n) );
+ m_pLbTxtDbColumn->InsertEntry( rS, static_cast<sal_Int32>(n) );
}
m_pLbTxtDbColumn->SelectEntryPos( 0 );
m_pLbTblDbColumn->SelectEntryPos( 0 );
@@ -554,8 +554,9 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
m_pLbTblDbColumn->Clear();
m_pLbTableCol->Clear();
- for( sal_uInt16 n = 0; n < aDBColumns.size(); ++n )
- m_pLbTblDbColumn->InsertEntry( aDBColumns[ n ]->sColumn, n );
+ for( size_t n = 0; n < aDBColumns.size(); ++n )
+ m_pLbTblDbColumn->InsertEntry( aDBColumns[ n ]->sColumn,
+ static_cast<sal_Int32>(n) );
m_pLbTblDbColumn->SelectEntryPos( 0 );
}
else if( pButton == m_pIbDbcolToEdit )
@@ -566,8 +567,8 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
if( !aFld.isEmpty() )
{
OUString aStr( m_pEdDbText->GetText() );
- sal_uInt16 nPos = (sal_uInt16)m_pEdDbText->GetSelection().Min();
- sal_uInt16 nSel = sal_uInt16(m_pEdDbText->GetSelection().Max()) - nPos;
+ sal_Int32 nPos = static_cast<sal_Int32>(m_pEdDbText->GetSelection().Min());
+ const sal_Int32 nSel = static_cast<sal_Int32>(m_pEdDbText->GetSelection().Max()) - nPos;
if( nSel )
// first delete the existing selection
aStr = aStr.replaceAt( nPos, nSel, "" );
@@ -591,7 +592,7 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
aStr = aStr.replaceAt( nPos, 0, aFld );
m_pEdDbText->SetText( aStr );
- nPos = nPos + aFld.getLength();
+ nPos += aFld.getLength();
m_pEdDbText->SetSelection( Selection( nPos ));
}
}
@@ -713,16 +714,18 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblFmtHdl, PushButton*, pButton )
{
// Number of columns has changed: then the TabCols have to be adjusted
long nWidth = pRep->GetWidth();
- sal_Int32 nCols = m_pLbTableCol->GetEntryCount() - 1;
+ const sal_Int32 nCols = m_pLbTableCol->GetEntryCount() - 1;
SwTabCols aTabCols( nCols );
aTabCols.SetRight( nWidth );
aTabCols.SetRightMax( nWidth );
if( nCols )
- for( sal_uInt16 n = 0, nStep = (sal_uInt16)(nWidth / (nCols+1)), nW = nStep;
- n < nCols; ++n, nW = nW + nStep )
+ {
+ const sal_Int32 nStep = nWidth / (nCols+1);
+ for( sal_Int32 n = 0; n < nCols; ++n )
{
- aTabCols.Insert( nW, sal_False, n );
+ aTabCols.Insert( nStep*(n+1), sal_False, n );
}
+ }
delete pRep;
pRep = new SwTableRep( aTabCols );
pRep->SetAlign( text::HoriOrientation::NONE );
@@ -974,12 +977,12 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
rSh.DoUndo( sal_False );
sal_Int32 nCols = m_pLbTableCol->GetEntryCount();
- sal_uInt16 nRows = 0;
+ sal_Int32 nRows = 0;
if( m_pCbTableHeadon->IsChecked() )
nRows++;
if( pSelection )
- nRows = nRows + (sal_uInt16)rSelection.getLength();
+ nRows += rSelection.getLength();
else
++nRows;
@@ -1188,7 +1191,8 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
pColl = rSh.FindTxtFmtCollByName( sTmplNm );
if( !pColl )
{
- sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmplNm, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+ const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
+ sTmplNm, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
if( USHRT_MAX != nId )
pColl = rSh.GetTxtCollFromPool( nId );
else
@@ -1228,7 +1232,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
OUString("1"), aEmptyOUStr, aDBData );
bool bSetCrsr = true;
- sal_uInt16 n = 0, nCols = aColArr.size();
+ const size_t nCols = aColArr.size();
::sw::mark::IMark* pMark = NULL;
for( sal_Int32 i = 0 ; ; ++i )
{
@@ -1252,7 +1256,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
if(bBreak)
break;
- for( n = 0; n < nCols; ++n )
+ for( size_t n = 0; n < nCols; ++n )
{
_DB_Column* pDBCol = &aColArr[ n ];
OUString sIns;
@@ -1554,7 +1558,8 @@ void SwInsertDBColAutoPilot::Commit()
pValues[3].Value <<= OUString(m_pEdDbText->GetText());
OUString sTmp;
- for( sal_uInt16 n = 0, nCnt = m_pLbTableCol->GetEntryCount(); n < nCnt; ++n )
+ const sal_Int32 nCnt = m_pLbTableCol->GetEntryCount();
+ for( sal_Int32 n = 0; n < nCnt; ++n )
(sTmp += m_pLbTableCol->GetEntry(n)) += "\x0a";
if (!sTmp.isEmpty())
@@ -1588,7 +1593,7 @@ void SwInsertDBColAutoPilot::Commit()
OUString sPrevLang;
SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
- for(sal_uInt16 nCol = 0; nCol < aDBColumns.size(); nCol++)
+ for(size_t nCol = 0; nCol < aDBColumns.size(); nCol++)
{
OUString sColumnNode = sNewNode;
SwInsDBColumn* pColumn = aDBColumns[nCol];
@@ -1693,7 +1698,7 @@ void SwInsertDBColAutoPilot::Load()
pSubProps[0] >>= sColumn;
//check for existance of the loaded column name
bool bFound = false;
- for(sal_uInt16 nRealColumn = 0; nRealColumn < aDBColumns.size(); nRealColumn++)
+ for(size_t nRealColumn = 0; nRealColumn < aDBColumns.size(); ++nRealColumn)
{
if(aDBColumns[nRealColumn]->sColumn == sColumn)
{
@@ -1730,10 +1735,10 @@ void SwInsertDBColAutoPilot::Load()
pNewData->aDBColumns.insert(pInsDBColumn);
}
- sal_Int32 n = 0;
OUString sTmp( pNewData->sTblList );
if( !sTmp.isEmpty() )
{
+ sal_Int32 n = 0;
do {
OUString sEntry( sTmp.getToken( 0, '\x0a', n ) );
//preselect column - if they still exist!
@@ -1767,7 +1772,7 @@ void SwInsertDBColAutoPilot::Load()
// then load the AutoFmt file and look for Autoformat first
SwTableAutoFmtTbl aAutoFmtTbl;
aAutoFmtTbl.Load();
- for( sal_uInt16 nAutoFmt = aAutoFmtTbl.size(); nAutoFmt; )
+ for( size_t nAutoFmt = aAutoFmtTbl.size(); nAutoFmt; )
if( sTmp == aAutoFmtTbl[ --nAutoFmt ].GetName() )
{
pTAutoFmt = new SwTableAutoFmt( aAutoFmtTbl[ nAutoFmt ] );
@@ -1786,10 +1791,10 @@ void SwInsertDBColAutoPilot::Load()
// now copy the user defined Numberformat strings to the
// Shell. Then only these are available as ID
- for( n = 0; n < (sal_Int32) aDBColumns.size() ; ++n )
+ for( size_t n = 0; n < aDBColumns.size() ; ++n )
{
SwInsDBColumn& rSet = *aDBColumns[ n ];
- for( sal_uInt16 m = 0; m < pNewData->aDBColumns.size() ; ++m )
+ for( size_t m = 0; m < pNewData->aDBColumns.size() ; ++m )
{
SwInsDBColumn& rGet = *pNewData->aDBColumns[ m ];
if(rGet.sColumn == rSet.sColumn)
commit 973de4ef151c58f5831e79e72181653768a9297a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 13 21:40:58 2014 +0200
Avoid temporary bool
Change-Id: I82b5f986b0a66aceb258960fd89bd5bf2754291a
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 47b2987..cb036a0 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -663,8 +663,7 @@ bool SwCustomizeAddressBlockDialog::HasItem_Impl(sal_Int32 nUserData)
}
}
//search for this entry in the content
- bool bRet = m_pDragED->GetText().indexOf("<" + sEntry + ">") != -1;
- return bRet;
+ return m_pDragED->GetText().indexOf("<" + sEntry + ">") >= 0;
}
IMPL_LINK(SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl, AddressMultiLineEdit*, pEdit)
commit b074e463e0f971e00fd70f0f526a3cc8034014b0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 13 21:37:06 2014 +0200
OUString: reduce temporaries and constify
Change-Id: I6524ce5924c12223702440426eb98665ba8df2a5
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 0f984f9..47b2987 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -112,7 +112,7 @@ void SwMailMergeAddressBlockPage::ActivatePage()
if (bIsLetter)
{
m_pHideEmptyParagraphsCB->Check( rConfigItem.IsHideEmptyParagraphs() );
- m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", OUString::number(1)));
+ m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", "1"));
m_pSettingsWIN->Clear();
const uno::Sequence< OUString> aBlocks =
@@ -232,8 +232,8 @@ IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl)
const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
const uno::Sequence< OUString> aBlocks =
m_pWizard->GetConfigItem().GetAddressBlocks();
- OUString sPreview = SwAddressPreview::FillData(aBlocks[nSel], m_pWizard->GetConfigItem());
- m_pPreviewWIN->SetAddress(sPreview);
+ m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(aBlocks[nSel],
+ m_pWizard->GetConfigItem()));
m_pWizard->GetConfigItem().SetCurrentAddressBlockIndex( nSel );
GetWizard()->UpdateRoadmap();
GetWizard()->enableButtons(WZB_NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
@@ -279,8 +279,7 @@ IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, ImageButton*, pButton
const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
const uno::Sequence< OUString> aBlocks =
m_pWizard->GetConfigItem().GetAddressBlocks();
- OUString sPreview = SwAddressPreview::FillData(aBlocks[nSel], rConfig);
- m_pPreviewWIN->SetAddress(sPreview);
+ m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(aBlocks[nSel], rConfig));
}
}
m_pPrevSetIB->Enable(bEnable);
@@ -383,10 +382,9 @@ void SwSelectAddressBlockDialog::SetSettings(
OUString SwSelectAddressBlockDialog::GetCountry() const
{
- OUString sRet;
if(m_pDependentRB->IsChecked())
- sRet = m_pCountryED->GetText();
- return sRet;
+ return m_pCountryED->GetText();
+ return OUString();
}
IMPL_LINK(SwSelectAddressBlockDialog, DeleteHdl_Impl, PushButton*, pButton)
@@ -424,15 +422,14 @@ IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, PushButton*, pButton
}
if(RET_OK == pDlg->Execute())
{
+ const OUString sNew = pDlg->GetAddress();
if(bCustomize)
{
- OUString sNew = pDlg->GetAddress();
m_pPreview->ReplaceSelectedAddress(sNew);
m_aAddressBlocks[m_pPreview->GetSelectedAddress()] = sNew;
}
else
{
- OUString sNew = pDlg->GetAddress();
m_pPreview->AddAddress(sNew);
m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() + 1);
const sal_Int32 nSelect = m_aAddressBlocks.getLength() - 1;
@@ -531,11 +528,11 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog(
{
m_pFieldFT->Show();
m_pFieldCB->Show();
- SvTreeListEntry* pEntry = m_pAddressElementsLB->InsertEntry(OUString(SW_RES(ST_SALUTATION )));
+ SvTreeListEntry* pEntry = m_pAddressElementsLB->InsertEntry(SW_RESSTR(ST_SALUTATION));
pEntry->SetUserData((void*)(sal_Int32)USER_DATA_SALUTATION );
- pEntry = m_pAddressElementsLB->InsertEntry(OUString(SW_RES(ST_PUNCTUATION)));
+ pEntry = m_pAddressElementsLB->InsertEntry(SW_RESSTR(ST_PUNCTUATION));
pEntry->SetUserData((void*)(sal_Int32)USER_DATA_PUNCTUATION );
- pEntry = m_pAddressElementsLB->InsertEntry(OUString(SW_RES(ST_TEXT )));
+ pEntry = m_pAddressElementsLB->InsertEntry(SW_RESSTR(ST_TEXT));
pEntry->SetUserData((void*)(sal_Int32)USER_DATA_TEXT );
ResStringArray aSalutArr(SW_RES(RA_SALUTATION));
for(sal_uInt32 i = 0; i < aSalutArr.Count(); ++i)
@@ -543,25 +540,24 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog(
ResStringArray aPunctArr(SW_RES(RA_PUNCTUATION));
for(sal_uInt32 i = 0; i < aPunctArr.Count(); ++i)
m_aPunctuations.push_back(aPunctArr.GetString(i));
- m_pDragED->SetText(OUString(" "));
- SetText( OUString( SW_RES( eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE)));
- m_pAddressElementsFT->SetText(OUString(SW_RES(ST_SALUTATIONELEMENTS)));
- m_pInsertFieldIB->SetQuickHelpText(OUString(SW_RES(ST_INSERTSALUTATIONFIELD)));
- m_pRemoveFieldIB->SetQuickHelpText(OUString(SW_RES(ST_REMOVESALUTATIONFIELD)));
- m_pDragFT->SetText(OUString(SW_RES(ST_DRAGSALUTATION)));
+ m_pDragED->SetText(" ");
+ SetText(SW_RESSTR(eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE));
+ m_pAddressElementsFT->SetText(SW_RESSTR(ST_SALUTATIONELEMENTS));
+ m_pInsertFieldIB->SetQuickHelpText(SW_RESSTR(ST_INSERTSALUTATIONFIELD));
+ m_pRemoveFieldIB->SetQuickHelpText(SW_RESSTR(ST_REMOVESALUTATIONFIELD));
+ m_pDragFT->SetText(SW_RESSTR(ST_DRAGSALUTATION));
}
else
{
if(eType == ADDRESSBLOCK_EDIT)
- SetText(OUString(SW_RES(ST_TITLE_EDIT)));
- m_pDragED->SetText(OUString("\n\n\n\n\n"));
+ SetText(SW_RESSTR(ST_TITLE_EDIT));
+ m_pDragED->SetText("\n\n\n\n\n");
}
const ResStringArray& rHeaders = m_rConfigItem.GetDefaultAddressHeaders();
for(sal_uInt32 i = 0; i < rHeaders.Count(); ++i)
{
- const OUString rHeader = rHeaders.GetString( i );
- SvTreeListEntry* pEntry = m_pAddressElementsLB->InsertEntry(rHeader);
+ SvTreeListEntry* pEntry = m_pAddressElementsLB->InsertEntry(rHeaders.GetString( i ));
pEntry->SetUserData((void*)(sal_IntPtr)i);
}
m_pOK->SetClickHdl(LINK(this, SwCustomizeAddressBlockDialog, OKHdl_Impl));
@@ -601,10 +597,7 @@ IMPL_LINK(SwCustomizeAddressBlockDialog, ListBoxSelectHdl_Impl, DDListBox*, pBox
IMPL_LINK_NOARG(SwCustomizeAddressBlockDialog, EditModifyHdl_Impl)
{
- OUString sAddress = SwAddressPreview::FillData(
- GetAddress(),
- m_rConfigItem);
- m_pPreviewWIN->SetAddress(sAddress);
+ m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(GetAddress(), m_rConfigItem));
UpdateImageButtons_Impl();
return 0;
}
@@ -616,8 +609,7 @@ IMPL_LINK(SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl, ImageButton*, pBut
SvTreeListEntry* pEntry = m_pAddressElementsLB->GetCurEntry();
if(pEntry)
{
- OUString sEntry = "<" + m_pAddressElementsLB->GetEntryText(pEntry) + ">";
- m_pDragED->InsertNewEntry(sEntry);
+ m_pDragED->InsertNewEntry("<" + m_pAddressElementsLB->GetEntryText(pEntry) + ">");
}
}
else if (m_pRemoveFieldIB == pButton)
@@ -642,12 +634,12 @@ IMPL_LINK(SwCustomizeAddressBlockDialog, ImageButtonHdl_Impl, ImageButton*, pBut
sal_Int32 SwCustomizeAddressBlockDialog::GetSelectedItem_Impl()
{
sal_Int32 nRet = USER_DATA_NONE;
- OUString sSelected = m_pDragED->GetCurrentItem();
+ const OUString sSelected = m_pDragED->GetCurrentItem();
if(!sSelected.isEmpty())
for(sal_uLong i = 0; i < m_pAddressElementsLB->GetEntryCount(); ++i)
{
SvTreeListEntry* pEntry = m_pAddressElementsLB->GetEntry(i);
- OUString sEntry = m_pAddressElementsLB->GetEntryText(pEntry);
+ const OUString sEntry = m_pAddressElementsLB->GetEntryText(pEntry);
if( sEntry == sSelected.copy( 1, sSelected.getLength() - 2 ) )
{
nRet = (sal_Int32)(sal_IntPtr)pEntry->GetUserData();
@@ -670,11 +662,8 @@ bool SwCustomizeAddressBlockDialog::HasItem_Impl(sal_Int32 nUserData)
break;
}
}
- //put it into '<>'
- sEntry = "<" + sEntry + ">";
//search for this entry in the content
- OUString sText = m_pDragED->GetText();
- bool bRet = sText.indexOf(sEntry) != -1;
+ bool bRet = m_pDragED->GetText().indexOf("<" + sEntry + ">") != -1;
return bRet;
}
@@ -735,7 +724,7 @@ IMPL_LINK_NOARG(SwCustomizeAddressBlockDialog, FieldChangeHdl_Impl)
{
//changing the field content changes the related members, too
sal_Int32 nSelected = GetSelectedItem_Impl();
- OUString sContent = m_pFieldCB->GetText();
+ const OUString sContent = m_pFieldCB->GetText();
switch(nSelected) {
case USER_DATA_SALUTATION:
m_sCurrentSalutation = sContent;
@@ -782,13 +771,19 @@ OUString SwCustomizeAddressBlockDialog::GetAddress()
for(sal_uLong i = 0; i < m_pAddressElementsLB->GetEntryCount(); ++i)
{
SvTreeListEntry* pEntry = m_pAddressElementsLB->GetEntry(i);
- OUString sEntry = "<" + m_pAddressElementsLB->GetEntryText(pEntry) + ">";
+ const OUString sEntry = "<" + m_pAddressElementsLB->GetEntryText(pEntry) + ">";
sal_Int32 nUserData = (sal_Int32)(sal_IntPtr)pEntry->GetUserData();
switch(nUserData)
{
- case USER_DATA_SALUTATION : sAddress = sAddress.replaceFirst(sEntry, m_sCurrentSalutation); break;
- case USER_DATA_PUNCTUATION: sAddress = sAddress.replaceFirst(sEntry, m_sCurrentPunctuation); break;
- case USER_DATA_TEXT : sAddress = sAddress.replaceFirst(sEntry, m_sCurrentText); break;
+ case USER_DATA_SALUTATION:
+ sAddress = sAddress.replaceFirst(sEntry, m_sCurrentSalutation);
+ break;
+ case USER_DATA_PUNCTUATION:
+ sAddress = sAddress.replaceFirst(sEntry, m_sCurrentPunctuation);
+ break;
+ case USER_DATA_TEXT:
+ sAddress = sAddress.replaceFirst(sEntry, m_sCurrentText);
+ break;
}
}
}
@@ -1226,8 +1221,7 @@ void DDListBox::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
//special entries can only be once in the address / greeting
if(nUserData >= 0 || !m_pParentDialog->HasItem_Impl(nUserData))
{
- OUString sEntry = "<" + GetEntryText(pEntry) + ">";
- pContainer->CopyString( sEntry );
+ pContainer->CopyString( "<" + GetEntryText(pEntry) + ">" );
pContainer->StartDrag( this, DND_ACTION_COPY, GetDragFinishedHdl() );
}
}
@@ -1309,11 +1303,11 @@ void AddressMultiLineEdit::SetText( const OUString& rStr )
for(sal_uLong nPara = 0; nPara < nParaCount; ++nPara)
{
sal_Int32 nIndex = 0;
- OUString sPara = pTextEngine->GetText( nPara );
+ const OUString sPara = pTextEngine->GetText( nPara );
if(!sPara.isEmpty() && !sPara.endsWith(" "))
{
TextPaM aPaM(nPara, sPara.getLength());
- pTextEngine->ReplaceText(TextSelection( aPaM ), OUString(' '));
+ pTextEngine->ReplaceText(TextSelection( aPaM ), " ");
}
while(true)
{
@@ -1335,7 +1329,7 @@ void AddressMultiLineEdit::SetText( const OUString& rStr )
if(nLastLen)
{
TextPaM aPaM(nParaCount ? nParaCount - 1 : 0, nLastLen);
- pTextEngine->ReplaceText( TextSelection( aPaM ), OUString("\n \n "));
+ pTextEngine->ReplaceText(TextSelection( aPaM ), "\n \n ");
}
}
}
@@ -1412,7 +1406,7 @@ void AddressMultiLineEdit::MoveCurrentItem(sal_uInt16 nMove)
sal_uLong nPara = rSelection.GetStart().GetPara();
sal_uInt16 nIndex = pBeginAttrib->GetStart();
TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
- OUString sCurrentItem = pTextEngine->GetText(aEntrySel);
+ const OUString sCurrentItem = pTextEngine->GetText(aEntrySel);
pTextEngine->RemoveAttrib( nPara, *pBeginAttrib );
pTextEngine->ReplaceText(aEntrySel, OUString());
switch(nMove)
@@ -1422,7 +1416,7 @@ void AddressMultiLineEdit::MoveCurrentItem(sal_uInt16 nMove)
{
//go left to find a predecessor or simple text
--nIndex;
- OUString sPara = pTextEngine->GetText( nPara );
+ const OUString sPara = pTextEngine->GetText( nPara );
sal_Int32 nSearchIndex = sPara.lastIndexOf( '>', nIndex+1 );
if( nSearchIndex != -1 && nSearchIndex == nIndex )
{
@@ -1457,7 +1451,7 @@ void AddressMultiLineEdit::MoveCurrentItem(sal_uInt16 nMove)
{
TextPaM aTemp(nPara - 1, pTextEngine->GetTextLen( nPara - 1 ));
- pTextEngine->ReplaceText( aTemp, OUString('\n'));
+ pTextEngine->ReplaceText(aTemp, "\n");
}
InsertNewEntryAtPosition( sCurrentItem, nPara, nIndex );
@@ -1505,7 +1499,6 @@ bool AddressMultiLineEdit::HasCurrentItem()
OUString AddressMultiLineEdit::GetCurrentItem()
{
- OUString sRet;
ExtTextEngine* pTextEngine = GetTextEngine();
ExtTextView* pTextView = GetTextView();
const TextSelection& rSelection = pTextView->GetSelection();
@@ -1516,9 +1509,9 @@ OUString AddressMultiLineEdit::GetCurrentItem()
{
sal_uLong nPara = rSelection.GetStart().GetPara();
TextSelection aEntrySel(TextPaM( nPara, pBeginAttrib->GetStart()), TextPaM(nPara, pBeginAttrib->GetEnd()));
- sRet = pTextEngine->GetText( aEntrySel );
+ return pTextEngine->GetText( aEntrySel );
}
- return sRet;
+ return OUString();
}
void AddressMultiLineEdit::SelectCurrentItem()
@@ -1545,7 +1538,7 @@ OUString AddressMultiLineEdit::GetAddress()
sal_uLong nParaCount = pTextEngine->GetParagraphCount();
for(sal_uLong nPara = nParaCount; nPara; --nPara)
{
- OUString sPara = comphelper::string::stripEnd(pTextEngine->GetText(nPara - 1), ' ');
+ const OUString sPara = comphelper::string::stripEnd(pTextEngine->GetText(nPara - 1), ' ');
//don't add empty trailing paragraphs
if(!sRet.isEmpty() || !sPara.isEmpty())
{
commit 988c2991ea491dfcbe7e670ae092b93391c992bf
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 13 20:49:06 2014 +0200
sal_uInt16 to sal_Int32/sal_uInt32 + constify
Change-Id: Id7ac0150841475d7fdc6c5b6a3e35cc01143aa23
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 61e014b..0f984f9 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -192,7 +192,7 @@ IMPL_LINK(SwMailMergeAddressBlockPage, SettingsHdl_Impl, PushButton*, pButton)
IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, PushButton*, pButton)
{
SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
- sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
+ const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
const uno::Sequence< OUString> aBlocks = rConfigItem.GetAddressBlocks();
boost::scoped_ptr<SwAssignFieldsDialog> pDlg(
new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), aBlocks[nSel], true));
@@ -229,7 +229,7 @@ IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockHdl_Impl, CheckBox*, pBox)
IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl)
{
- sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
+ const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
const uno::Sequence< OUString> aBlocks =
m_pWizard->GetConfigItem().GetAddressBlocks();
OUString sPreview = SwAddressPreview::FillData(aBlocks[nSel], m_pWizard->GetConfigItem());
@@ -276,7 +276,7 @@ IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, ImageButton*, pButton
if(m_pSettingsWIN->IsVisible())
{
//Fill data into preview
- sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
+ const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
const uno::Sequence< OUString> aBlocks =
m_pWizard->GetConfigItem().GetAddressBlocks();
OUString sPreview = SwAddressPreview::FillData(aBlocks[nSel], rConfig);
@@ -347,15 +347,15 @@ void SwSelectAddressBlockDialog::SetAddressBlocks(const uno::Sequence< OUString>
const uno::Sequence< OUString >& SwSelectAddressBlockDialog::GetAddressBlocks()
{
//put the selected block to the first position
- sal_uInt16 nSelect = m_pPreview->GetSelectedAddress();
+ const sal_Int32 nSelect = static_cast<sal_Int32>(m_pPreview->GetSelectedAddress());
if(nSelect)
{
uno::Sequence< OUString >aTemp = m_aAddressBlocks;
OUString* pTemp = aTemp.getArray();
pTemp[0] = m_aAddressBlocks[nSelect];
- sal_uInt32 nIndex = 0;
- const sal_uInt32 nNumBlocks = m_aAddressBlocks.getLength();
- for(sal_uInt32 nAddress = 1; nAddress < nNumBlocks; ++nAddress)
+ sal_Int32 nIndex = 0;
+ const sal_Int32 nNumBlocks = m_aAddressBlocks.getLength();
+ for(sal_Int32 nAddress = 1; nAddress < nNumBlocks; ++nAddress)
{
if(nIndex == nSelect)
++nIndex;
@@ -393,7 +393,7 @@ IMPL_LINK(SwSelectAddressBlockDialog, DeleteHdl_Impl, PushButton*, pButton)
{
if(m_aAddressBlocks.getLength())
{
- sal_uInt16 nSelected = m_pPreview->GetSelectedAddress();
+ const sal_Int32 nSelected = static_cast<sal_Int32>(m_pPreview->GetSelectedAddress());
OUString* pAddressBlocks = m_aAddressBlocks.getArray();
sal_Int32 nSource = 0;
for(sal_Int32 nTarget = 0; nTarget < m_aAddressBlocks.getLength() - 1; nTarget++)
@@ -435,9 +435,9 @@ IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, PushButton*, pButton
OUString sNew = pDlg->GetAddress();
m_pPreview->AddAddress(sNew);
m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() + 1);
- sal_uInt16 nSelect = (sal_uInt16)m_aAddressBlocks.getLength() - 1;
+ const sal_Int32 nSelect = m_aAddressBlocks.getLength() - 1;
m_aAddressBlocks[nSelect] = sNew;
- m_pPreview->SelectAddress(nSelect);
+ m_pPreview->SelectAddress(static_cast<sal_uInt16>(nSelect));
}
m_pDeletePB->Enable( m_aAddressBlocks.getLength() > 1);
}
@@ -481,11 +481,11 @@ void SwRestrictedComboBox::Modify()
{
Selection aSel = GetSelection();
OUString sTemp = GetText();
- for(sal_uInt16 i = 0; i < sForbiddenChars.getLength(); i++)
+ for(sal_Int32 i = 0; i < sForbiddenChars.getLength(); ++i)
{
sTemp = comphelper::string::remove(sTemp, sForbiddenChars[i]);
}
- sal_Int32 nDiff = GetText().getLength() - sTemp.getLength();
+ const sal_Int32 nDiff = GetText().getLength() - sTemp.getLength();
if(nDiff)
{
aSel.setMin(aSel.getMin() - nDiff);
@@ -538,11 +538,10 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog(
pEntry = m_pAddressElementsLB->InsertEntry(OUString(SW_RES(ST_TEXT )));
pEntry->SetUserData((void*)(sal_Int32)USER_DATA_TEXT );
ResStringArray aSalutArr(SW_RES(RA_SALUTATION));
- sal_uInt16 i;
- for(i = 0; i < aSalutArr.Count(); ++i)
+ for(sal_uInt32 i = 0; i < aSalutArr.Count(); ++i)
m_aSalutations.push_back(aSalutArr.GetString(i));
ResStringArray aPunctArr(SW_RES(RA_PUNCTUATION));
- for(i = 0; i < aPunctArr.Count(); ++i)
+ for(sal_uInt32 i = 0; i < aPunctArr.Count(); ++i)
m_aPunctuations.push_back(aPunctArr.GetString(i));
m_pDragED->SetText(OUString(" "));
SetText( OUString( SW_RES( eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE)));
@@ -559,7 +558,7 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog(
}
const ResStringArray& rHeaders = m_rConfigItem.GetDefaultAddressHeaders();
- for(sal_uInt16 i = 0; i < rHeaders.Count(); ++i)
+ for(sal_uInt32 i = 0; i < rHeaders.Count(); ++i)
{
const OUString rHeader = rHeaders.GetString( i );
SvTreeListEntry* pEntry = m_pAddressElementsLB->InsertEntry(rHeader);
@@ -894,7 +893,7 @@ SwAssignFieldsControl::SwAssignFieldsControl(
};
//fill the controls
- for(sal_uInt16 i = 0; i < rHeaders.Count(); ++i)
+ for(sal_uInt32 i = 0; i < rHeaders.Count(); ++i)
{
const OUString rHeader = rHeaders.GetString( i );
FixedInfo* pNewText = new FixedInfo(&m_aWindow, ResId( FT_FIELDS, *rResId.GetResMgr()));
@@ -907,7 +906,7 @@ SwAssignFieldsControl::SwAssignFieldsControl(
FixedInfo* pNewPreview = new FixedInfo(&m_aWindow, ResId( FT_PREVIEW, *rResId.GetResMgr() ));
//select the ListBox
//if there is an assignment
- if(aAssignments.getLength() > i && !aAssignments[i].isEmpty())
+ if(static_cast<sal_uInt32>(aAssignments.getLength()) > i && !aAssignments[i].isEmpty())
pNewLB->SelectEntry(aAssignments[i]);
else //otherwise the current column name may match one of the db columns
pNewLB->SelectEntry(rHeader);
@@ -998,7 +997,7 @@ bool SwAssignFieldsControl::PreNotify( NotifyEvent& rNEvt )
if(rNEvt.GetType() == EVENT_COMMAND)
{
const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
- sal_uInt16 nCmd = pCEvt->GetCommand();
+ const sal_uInt16 nCmd = pCEvt->GetCommand();
if( COMMAND_WHEEL == nCmd )
{
Command(*pCEvt);
@@ -1357,7 +1356,7 @@ void AddressMultiLineEdit::InsertNewEntry( const OUString& rStr )
// select the new entry
pAttrib = pTextEngine->FindCharAttrib(TextPaM(nPara, nIndex),TEXTATTR_PROTECTED);
- sal_uInt16 nEnd = pAttrib ? pAttrib->GetEnd() : nIndex;
+ const sal_uInt16 nEnd = pAttrib ? pAttrib->GetEnd() : nIndex;
TextSelection aEntrySel(TextPaM(nPara, nIndex), TextPaM(nPara, nEnd));
pTextView->SetSelection(aEntrySel);
Invalidate();
commit 5a72fba4a62f08182fd349b6db026e3f949d58ce
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Apr 12 00:25:19 2014 +0200
Pass constant ASCII string directly
Change-Id: I011afefa52f77d914754e6ef99aa41fff28e8d2c
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 4cbcadf..6a1488a 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -98,7 +98,7 @@ SwMailMergeLayoutPage::SwMailMergeLayoutPage( SwMailMergeWizard* _pParent) :
get(m_pZoomLB, "zoom");
const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
- OUString( FILTER_XML ),
+ FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
//save the current document into a temporary file
{
commit c86f83a8b0af2255cdccbe0b819590628dbb110f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 7 22:37:10 2014 +0200
OUString: constify, remove unneeded casts and concatenated appends"
Change-Id: I5f712c4c8bda937a0ae1f542dda1bc2b6879604e
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
index f09aa7a..cda35b7 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -133,9 +133,7 @@ void SwGreetingsHandler::UpdatePreview()
IMPL_LINK(SwMailMergeGreetingsPage, AssignHdl_Impl, PushButton*, pButton)
{
- OUString sPreview = m_pFemaleLB->GetSelectEntry();
- sPreview += "\n";
- sPreview += m_pMaleLB->GetSelectEntry();
+ const OUString sPreview(m_pFemaleLB->GetSelectEntry() + "\n" + m_pMaleLB->GetSelectEntry());
boost::scoped_ptr<SwAssignFieldsDialog> pDlg(
new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), sPreview, false));
if(RET_OK == pDlg->Execute())
@@ -160,8 +158,8 @@ void SwMailMergeGreetingsPage::UpdatePreview()
bool bNoValue = !m_pFemaleColumnLB->IsEnabled();
if( !bNoValue )
{
- OUString sFemaleValue = m_pFemaleFieldCB->GetText();
- OUString sFemaleColumn = m_pFemaleColumnLB->GetSelectEntry();
+ const OUString sFemaleValue = m_pFemaleFieldCB->GetText();
+ const OUString sFemaleColumn = m_pFemaleColumnLB->GetSelectEntry();
Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pWizard->GetConfigItem().GetResultSet(), UNO_QUERY);
Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
if(!sFemaleValue.isEmpty() && !sFemaleColumn.isEmpty() &&
@@ -176,19 +174,18 @@ void SwMailMergeGreetingsPage::UpdatePreview()
{
try
{
- OUString sFemaleColumnValue = xColumn->getString();
- bFemale = sFemaleColumnValue == sFemaleValue;
+ bFemale = xColumn->getString() == sFemaleValue;
if( !bNoValue )
{
//no last name value marks the greeting also als neutral
SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
- OUString sLastNameColumn = rConfig.GetAssignedColumn(MM_PART_LASTNAME);
+ const OUString sLastNameColumn =
+ rConfig.GetAssignedColumn(MM_PART_LASTNAME);
if ( xColAccess->hasByName(sLastNameColumn) )
{
aCol = xColAccess->getByName(sLastNameColumn);
aCol >>= xColumn;
- OUString sLastNameColumnValue = xColumn->getString();
- bNoValue = sLastNameColumnValue.isEmpty();
+ bNoValue = xColumn->getString().isEmpty();
}
}
}
@@ -200,8 +197,8 @@ void SwMailMergeGreetingsPage::UpdatePreview()
}
}
- OUString sPreview = bFemale ? OUString(m_pFemaleLB->GetSelectEntry()) :
- bNoValue ? m_pNeutralCB->GetText() : OUString(m_pMaleLB->GetSelectEntry());
+ OUString sPreview = bFemale ? m_pFemaleLB->GetSelectEntry() :
+ bNoValue ? m_pNeutralCB->GetText() : m_pMaleLB->GetSelectEntry();
sPreview = SwAddressPreview::FillData(sPreview, m_pWizard->GetConfigItem());
m_pPreviewWIN->SetAddress(sPreview);
@@ -313,8 +310,7 @@ void SwMailMergeGreetingsPage::ActivatePage()
m_pFemaleColumnLB->InsertEntry(aColumns[nName]);
}
- OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
- m_pFemaleColumnLB->SelectEntry(sGenderColumn);
+ m_pFemaleColumnLB->SelectEntry(rConfig.GetAssignedColumn(MM_PART_GENDER));
m_pFemaleColumnLB->SaveValue();
m_pFemaleFieldCB->SetText(rConfig.GetFemaleGenderValue());
@@ -483,8 +479,7 @@ SwMailBodyDialog::SwMailBodyDialog(Window* pParent, SwMailMergeWizard* _pWizard)
m_aFemaleColumnLB.InsertEntry(aColumns[nName]);
}
- OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
- m_aFemaleColumnLB.SelectEntry(sGenderColumn);
+ m_aFemaleColumnLB.SelectEntry(rConfig.GetAssignedColumn(MM_PART_GENDER));
m_aFemaleColumnLB.SaveValue();
m_aFemaleFieldCB.SetText(rConfig.GetFemaleGenderValue());
commit 6c35d8a391df247c58168a5c742c238ecd5a597a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 7 22:35:14 2014 +0200
OUString::number(1) == "1"
Change-Id: Ieaf4b12224b11914a88eb963e915a375747a1e23
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
index 221954b..f09aa7a 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -291,7 +291,7 @@ SwMailMergeGreetingsPage::SwMailMergeGreetingsPage(SwMailMergeWizard* _pParent)
lcl_FillGreetingsBox(*m_pMaleLB, rConfig, SwMailMergeConfigItem::MALE);
lcl_FillGreetingsBox(*m_pNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
- m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", OUString::number(1)));
+ m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", "1"));
}
SwMailMergeGreetingsPage::~SwMailMergeGreetingsPage()
commit b63a8a60ae9c5c3bab76c99035f80c1ea2159dd2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 7 22:27:45 2014 +0200
Remove code commented-out since 2009
Change-Id: I99000430cde8e9f23c8f11341472548329555c85
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
index c40aae9..221954b 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -178,7 +178,6 @@ void SwMailMergeGreetingsPage::UpdatePreview()
{
OUString sFemaleColumnValue = xColumn->getString();
bFemale = sFemaleColumnValue == sFemaleValue;
- //bNoValue = !sFemaleColumnValue.getLength();
if( !bNoValue )
{
//no last name value marks the greeting also als neutral
commit 5a98cdbfeb6bc524ccb41f43426590362c376e42
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 7 22:22:38 2014 +0200
Remove unneeded casts
Change-Id: I2d69e8933883440bcb48439c6055c40dc140a429
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
index 4499e74..c40aae9 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -43,7 +43,7 @@ static void lcl_FillGreetingsBox(ListBox& rBox,
const Sequence< OUString> rEntries = rConfig.GetGreetings(eType);
for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
rBox.InsertEntry(rEntries[nEntry]);
- rBox.SelectEntryPos((sal_uInt16)rConfig.GetCurrentGreeting(eType));
+ rBox.SelectEntryPos(rConfig.GetCurrentGreeting(eType));
}
static void lcl_FillGreetingsBox(ComboBox& rBox,
@@ -53,7 +53,7 @@ static void lcl_FillGreetingsBox(ComboBox& rBox,
const Sequence< OUString> rEntries = rConfig.GetGreetings(eType);
for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
rBox.InsertEntry(rEntries[nEntry]);
- rBox.SelectEntryPos((sal_uInt16)rConfig.GetCurrentGreeting(eType));
+ rBox.SelectEntryPos(rConfig.GetCurrentGreeting(eType));
}
static void lcl_StoreGreetingsBox(ListBox& rBox,
More information about the Libreoffice-commits
mailing list