summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-28 11:28:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-28 17:22:52 +0200
commitd407304544cdb2edc3cbdb4e56d49f3ceda79c38 (patch)
tree765668628540687b669d67b14d824adb893c1308 /dbaccess
parentfa87224130a4ab6c4b79f993cc990adc4be0465b (diff)
loplugin:stringloop cui,dbaccess
Change-Id: I32b63d2435d36b869823ea022ebd7f8347a46ea0 Reviewed-on: https://gerrit.libreoffice.org/58211 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/api/KeySet.cxx10
-rw-r--r--dbaccess/source/ui/dlg/directsql.cxx6
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.cxx23
-rw-r--r--dbaccess/source/ui/dlg/queryorder.cxx12
-rw-r--r--dbaccess/source/ui/dlg/tablespage.cxx19
-rw-r--r--dbaccess/source/ui/inc/queryfilter.hxx2
-rw-r--r--dbaccess/source/ui/misc/DExport.cxx18
-rw-r--r--dbaccess/source/ui/misc/HtmlReader.cxx8
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx14
9 files changed, 52 insertions, 60 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 78c10485df14..84cd83a3a43e 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -714,10 +714,8 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const OUString& i_sSQ
if ( i_sTableName.isEmpty() && !bAutoValuesFetched && m_bInserted )
{
// first check if all key column values were set
- const OUString sMax(" MAX(");
- const OUString sMaxEnd("),");
const OUString sQuote = getIdentifierQuoteString();
- OUString sMaxStmt;
+ OUStringBuffer sMaxStmt;
auto aEnd = m_pKeyColumnNames->end();
for (auto const& autoColumn : m_aAutoColumns)
{
@@ -725,14 +723,14 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const OUString& i_sSQ
SelectColumnsMetaData::const_iterator aFind = m_pKeyColumnNames->find(autoColumn);
if ( aFind != aEnd )
{
- sMaxStmt += sMax + ::dbtools::quoteName( sQuote,aFind->second.sRealName) + sMaxEnd;
+ sMaxStmt.append(" MAX(").append(::dbtools::quoteName( sQuote,aFind->second.sRealName)).append("),");
}
}
if(!sMaxStmt.isEmpty())
{
- sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1," ");
- OUString sStmt = "SELECT " + sMaxStmt + "FROM ";
+ sMaxStmt[sMaxStmt.getLength()-1] = ' ';
+ OUString sStmt = "SELECT " + sMaxStmt.makeStringAndClear() + "FROM ";
OUString sCatalog,sSchema,sTable;
::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx
index 6cab0eaa90d1..16216f60315f 100644
--- a/dbaccess/source/ui/dlg/directsql.cxx
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -259,7 +259,7 @@ namespace dbaui
while (xRS->next())
{
// initialise the output line for each row
- OUString out("");
+ OUStringBuffer out;
// work along the columns until that are none left
try
{
@@ -267,7 +267,7 @@ namespace dbaui
for (;;)
{
// be dumb, treat everything as a string
- out += xRow->getString(i) + ",";
+ out.append(xRow->getString(i)).append(",");
i++;
}
}
@@ -276,7 +276,7 @@ namespace dbaui
{
}
// report the output
- addOutputText(out);
+ addOutputText(out.makeStringAndClear());
}
}
diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx
index 72d1bdf51ac0..66f9c8c1d4fd 100644
--- a/dbaccess/source/ui/dlg/queryfilter.cxx
+++ b/dbaccess/source/ui/dlg/queryfilter.cxx
@@ -98,11 +98,10 @@ DlgFilterCrit::DlgFilterCrit(vcl::Window * pParent,
m_pLB_WHERECOMP2->set_width_request(aSize.Width());
m_pLB_WHERECOMP3->set_width_request(aSize.Width());
const sal_Int32 nEntryCount = m_pLB_WHERECOMP1->GetEntryCount();
+ m_aSTR_COMPARE_OPERATORS.resize(nEntryCount);
for (sal_Int32 i = 0; i < nEntryCount; ++i)
{
- if (i > 0)
- m_aSTR_COMPARE_OPERATORS += ";";
- m_aSTR_COMPARE_OPERATORS += m_pLB_WHERECOMP1->GetEntry(i);
+ m_aSTR_COMPARE_OPERATORS[i] = m_pLB_WHERECOMP1->GetEntry(i);
}
m_pLB_WHERECOMP1->Clear();
@@ -218,8 +217,8 @@ void DlgFilterCrit::dispose()
sal_Int32 DlgFilterCrit::GetOSQLPredicateType( const OUString& _rSelectedPredicate ) const
{
sal_Int32 nPredicateIndex = -1;
- for ( sal_Int32 i=0; i < comphelper::string::getTokenCount(m_aSTR_COMPARE_OPERATORS, ';'); ++i)
- if ( m_aSTR_COMPARE_OPERATORS.getToken(i, ';') == _rSelectedPredicate )
+ for ( size_t i=0; i < m_aSTR_COMPARE_OPERATORS.size(); ++i)
+ if ( m_aSTR_COMPARE_OPERATORS[i] == _rSelectedPredicate )
{
nPredicateIndex = i;
break;
@@ -675,21 +674,21 @@ IMPL_LINK( DlgFilterCrit, ListSelectHdl, ListBox&, rListBox, void )
if(eColumnSearch == ColumnSearch::FULL)
{
- for(sal_Int32 i=0;i < comphelper::string::getTokenCount(m_aSTR_COMPARE_OPERATORS, ';');i++)
- pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS.getToken(i, ';'));
+ for(size_t i=0;i < m_aSTR_COMPARE_OPERATORS.size(); i++)
+ pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
}
else if(eColumnSearch == ColumnSearch::CHAR)
{
for(sal_Int32 i=6; i<10; i++)
- pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS.getToken(i, ';'));
+ pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
}
else if(eColumnSearch == ColumnSearch::BASIC)
{
- sal_Int32 i;
+ size_t i;
for( i = 0; i < 6; i++ )
- pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS.getToken(i, ';'));
- for(i=8; i < comphelper::string::getTokenCount(m_aSTR_COMPARE_OPERATORS, ';'); ++i)
- pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS.getToken(i, ';'));
+ pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
+ for(i=8; i < m_aSTR_COMPARE_OPERATORS.size(); ++i)
+ pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
}
else
{
diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx
index cb8af47b7f9b..a5d02374760a 100644
--- a/dbaccess/source/ui/dlg/queryorder.cxx
+++ b/dbaccess/source/ui/dlg/queryorder.cxx
@@ -219,23 +219,23 @@ OUString DlgOrderCrit::GetOrderList( ) const
Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
- OUString sOrder;
+ OUStringBuffer sOrder;
for( sal_uInt16 i=0 ; i<DOG_ROWS; i++ )
{
if(m_aColumnList[i]->GetSelectedEntryPos() != 0)
{
if(!sOrder.isEmpty())
- sOrder += ",";
+ sOrder.append(",");
OUString sName = m_aColumnList[i]->GetSelectedEntry();
- sOrder += ::dbtools::quoteName(sQuote,sName);
+ sOrder.append(::dbtools::quoteName(sQuote,sName));
if(m_aValueList[i]->GetSelectedEntryPos())
- sOrder += " DESC ";
+ sOrder.append(" DESC ");
else
- sOrder += " ASC ";
+ sOrder.append(" ASC ");
}
}
- return sOrder;
+ return sOrder.makeStringAndClear();
}
void DlgOrderCrit::BuildOrderPart()
diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx
index 431db3828481..ac348069c0e5 100644
--- a/dbaccess/source/ui/dlg/tablespage.cxx
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -437,7 +437,6 @@ namespace dbaui
Sequence< OUString > aTableFilter;
static const char sWildcard[] = "%";
- OUString sComposedName;
const SvTreeListEntry* pAllObjectsEntry = m_pTablesList->getAllObjectsEntry();
if (!pAllObjectsEntry)
return aTableFilter;
@@ -451,6 +450,7 @@ namespace dbaui
if (m_pTablesList->GetCheckButtonState(pEntry) == SvButtonState::Checked && !m_pTablesList->GetModel()->HasChildren(pEntry))
{ // checked and a leaf, which means it's no catalog, no schema, but a real table
+ OUStringBuffer sComposedName;
OUString sCatalog;
if(m_pTablesList->GetModel()->HasParent(pEntry))
{
@@ -473,9 +473,9 @@ namespace dbaui
bCatalogWildcard = OTableTreeListBox::isWildcardChecked(pCatalog);
if (m_bCatalogAtStart)
{
- sComposedName += m_pTablesList->GetEntryText( pCatalog ) + m_sCatalogSeparator;
+ sComposedName.append(m_pTablesList->GetEntryText( pCatalog )).append(m_sCatalogSeparator);
if (bCatalogWildcard)
- sComposedName += sWildcard;
+ sComposedName.append(sWildcard);
}
else
{
@@ -488,26 +488,23 @@ namespace dbaui
}
}
bSchemaWildcard = OTableTreeListBox::isWildcardChecked(pSchema);
- sComposedName += m_pTablesList->GetEntryText( pSchema ) + ".";
+ sComposedName.append(m_pTablesList->GetEntryText( pSchema )).append(".");
}
if (bSchemaWildcard)
- sComposedName += sWildcard;
+ sComposedName.append(sWildcard);
}
if (!bSchemaWildcard && !bCatalogWildcard)
- sComposedName += m_pTablesList->GetEntryText( pEntry );
+ sComposedName.append(m_pTablesList->GetEntryText( pEntry ));
if (!m_bCatalogAtStart && !bCatalogWildcard)
- sComposedName += sCatalog;
+ sComposedName.append(sCatalog);
// need some space
sal_Int32 nOldLen = aTableFilter.getLength();
aTableFilter.realloc(nOldLen + 1);
// add the new name
- aTableFilter[nOldLen] = sComposedName;
-
- // reset the composed name
- sComposedName.clear();
+ aTableFilter[nOldLen] = sComposedName.makeStringAndClear();
}
if (bCatalogWildcard)
diff --git a/dbaccess/source/ui/inc/queryfilter.hxx b/dbaccess/source/ui/inc/queryfilter.hxx
index 377fb8dd51b9..1c4d46b7cc97 100644
--- a/dbaccess/source/ui/inc/queryfilter.hxx
+++ b/dbaccess/source/ui/inc/queryfilter.hxx
@@ -81,7 +81,7 @@ namespace dbaui
VclPtr<ListBox> m_pLB_WHERECOMP3;
VclPtr<Edit> m_pET_WHEREVALUE3;
- OUString m_aSTR_COMPARE_OPERATORS;
+ std::vector<OUString> m_aSTR_COMPARE_OPERATORS;
css::uno::Reference< css::sdb::XSingleSelectQueryComposer> m_xQueryComposer;
css::uno::Reference< css::container::XNameAccess> m_xColumns;
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
index ddd3a07bc042..8cb191f8da8f 100644
--- a/dbaccess/source/ui/misc/DExport.cxx
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -804,12 +804,12 @@ Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const R
{
OUString sComposedTableName = ::dbtools::composeTableName( _xMetaData, _xDestTable, ::dbtools::EComposeRule::InDataManipulation, true );
- OUString aSql = "INSERT INTO "
+ OUStringBuffer aSql = "INSERT INTO "
+ sComposedTableName
+ " ( ";
// set values and column names
- OUString aValues(" VALUES ( ");
+ OUStringBuffer aValues(" VALUES ( ");
OUString aQuote;
if ( _xMetaData.is() )
@@ -843,18 +843,18 @@ Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const R
{
if ( !elem.isEmpty() )
{
- aSql += elem;
- aSql += ",";
- aValues += "?,";
+ aSql.append(elem);
+ aSql.append(",");
+ aValues.append("?,");
}
}
- aSql = aSql.replaceAt(aSql.getLength()-1, 1, ")");
- aValues = aValues.replaceAt(aValues.getLength()-1, 1, ")");
+ aSql[aSql.getLength()-1] = ')';
+ aValues[aValues.getLength()-1] = ')';
- aSql += aValues;
+ aSql.append(aValues);
// now create,fill and execute the prepared statement
- return _xMetaData->getConnection()->prepareStatement(aSql);
+ return _xMetaData->getConnection()->prepareStatement(aSql.makeStringAndClear());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx
index c810a9175cf7..ad79d3b751ba 100644
--- a/dbaccess/source/ui/misc/HtmlReader.cxx
+++ b/dbaccess/source/ui/misc/HtmlReader.cxx
@@ -339,7 +339,7 @@ void OHTMLReader::TableFontOn(FontDescriptor& _rFont, Color &_rTextColor)
case HtmlOptionId::FACE :
{
const OUString& rFace = rOption.GetString();
- OUString aFontName;
+ OUStringBuffer aFontName;
sal_Int32 nPos = 0;
while( nPos != -1 )
{
@@ -347,11 +347,11 @@ void OHTMLReader::TableFontOn(FontDescriptor& _rFont, Color &_rTextColor)
OUString aFName = rFace.getToken( 0, ',', nPos );
aFName = comphelper::string::strip(aFName, ' ');
if( !aFontName.isEmpty() )
- aFontName += ";";
- aFontName += aFName;
+ aFontName.append(";");
+ aFontName.append(aFName);
}
if ( !aFontName.isEmpty() )
- _rFont.Name = aFontName;
+ _rFont.Name = aFontName.makeStringAndClear();
}
break;
case HtmlOptionId::SIZE :
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index ca58612c2c81..35b9df1de937 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -158,7 +158,7 @@ void ObjectCopySource::copyFilterAndSortingTo( const Reference< XConnection >& _
const OUString sTargetName = ::dbtools::composeTableNameForSelect(_xConnection,_rxObject);
const OUString sTargetNameTemp = sTargetName + ".";
- OUString sStatement = "SELECT * FROM " + sTargetName + " WHERE 0=1";
+ OUStringBuffer sStatement = "SELECT * FROM " + sTargetName + " WHERE 0=1";
for (const std::pair<OUString,OUString> & aPropertie : aProperties)
{
@@ -168,17 +168,17 @@ void ObjectCopySource::copyFilterAndSortingTo( const Reference< XConnection >& _
m_xObject->getPropertyValue( aPropertie.first ) >>= sFilter;
if ( !sFilter.isEmpty() )
{
- sStatement += aPropertie.second;
+ sStatement.append(aPropertie.second);
OUString sReplace = sFilter;
sReplace = sReplace.replaceFirst(sSourceName,sTargetNameTemp);
sFilter = sReplace;
_rxObject->setPropertyValue( aPropertie.first, makeAny(sFilter) );
- sStatement += sFilter;
+ sStatement.append(sFilter);
}
}
}
- _xConnection->createStatement()->executeQuery(sStatement);
+ _xConnection->createStatement()->executeQuery(sStatement.makeStringAndClear());
if ( m_xObjectPSI->hasPropertyByName( PROPERTY_APPLYFILTER ) )
_rxObject->setPropertyValue( PROPERTY_APPLYFILTER, m_xObject->getPropertyValue( PROPERTY_APPLYFILTER ) );
@@ -1384,8 +1384,7 @@ OUString OCopyTableWizard::convertColumnName(const TColumnFindFunctor& _rCmpFu
while(_rCmpFunctor(sName))
{
- sName = sAlias;
- sName += OUString::number(++nPos);
+ sName = sAlias + OUString::number(++nPos);
}
sAlias = sName;
// we have to check again, it could happen that the name is already to long
@@ -1521,8 +1520,7 @@ OUString OCopyTableWizard::createUniqueName(const OUString& _sName)
sal_Int32 nPos = 0;
while(m_vSourceColumns.find(sName) != m_vSourceColumns.end())
{
- sName = _sName;
- sName += OUString::number(++nPos);
+ sName = _sName + OUString::number(++nPos);
}
}
}