summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/querydesign/QueryDesignView.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/querydesign/QueryDesignView.cxx')
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx111
1 files changed, 47 insertions, 64 deletions
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index e2f338b30737..7de007624f3d 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -23,8 +23,9 @@
#include <querycontroller.hxx>
#include <sqlbison.hxx>
#include <vcl/split.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <o3tl/safeint.hxx>
+#include <o3tl/string_view.hxx>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
@@ -52,12 +53,10 @@
#include <string_view>
using namespace ::dbaui;
-using namespace ::utl;
using namespace ::connectivity;
using namespace ::dbtools;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
@@ -96,7 +95,7 @@ namespace
bool bHaving,
bool _bAddOrOnOneLine);
- OUString quoteTableAlias(bool _bQuote, const OUString& _sAliasName, const OUString& _sQuote)
+ OUString quoteTableAlias(bool _bQuote, const OUString& _sAliasName, std::u16string_view _sQuote)
{
OUString sRet;
if ( _bQuote && !_sAliasName.isEmpty() )
@@ -160,12 +159,8 @@ namespace
OUString aSourceFieldName(_aDragLeft->GetField());
OUString aDestFieldName(_aDragRight->GetField());
// the connection could point on the other side
- if(pConn->GetSourceWin() == _aDragRight->GetTabWindow())
- {
- OUString aTmp(aSourceFieldName);
- aSourceFieldName = aDestFieldName;
- aDestFieldName = aTmp;
- }
+ if (pConn->GetSourceWin() == _aDragRight->GetTabWindow())
+ std::swap(aSourceFieldName, aDestFieldName);
pConn->GetData()->AppendConnLine( aSourceFieldName,aDestFieldName);
pConn->UpdateLineList();
// Modified-Flag
@@ -290,11 +285,12 @@ namespace
{
if(!aCondition.isEmpty())
aCondition.append(C_AND);
- aCondition.append(quoteTableAlias(true,pData->GetAliasName(JTCS_FROM),aQuote));
- aCondition.append(::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_FROM) ));
- aCondition.append(" = ");
- aCondition.append(quoteTableAlias(true,pData->GetAliasName(JTCS_TO),aQuote));
- aCondition.append(::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_TO) ));
+ aCondition.append(
+ quoteTableAlias(true,pData->GetAliasName(JTCS_FROM),aQuote)
+ + ::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_FROM) )
+ + " = "
+ + quoteTableAlias(true,pData->GetAliasName(JTCS_TO),aQuote)
+ + ::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_TO) ));
}
}
catch(SQLException&)
@@ -326,7 +322,7 @@ namespace
if(_rJoin.endsWith(")"))
{
bBrace = true;
- _rJoin = _rJoin.replaceAt(_rJoin.getLength()-1,1,OUString(' '));
+ _rJoin = _rJoin.replaceAt(_rJoin.getLength()-1,1, u" ");
}
_rJoin += C_AND + BuildJoinCriteria(_xConnection,&pData->GetConnLineDataList(),pData);
if(bBrace)
@@ -658,11 +654,7 @@ namespace
if ( field->isAggregateFunction() )
{
OSL_ENSURE(!field->GetFunction().isEmpty(),"Function name must not be empty! ;-(");
- OUStringBuffer aTmpStr2( field->GetFunction());
- aTmpStr2.append("(");
- aTmpStr2.append(aTmpStr.makeStringAndClear());
- aTmpStr2.append(")");
- aTmpStr = aTmpStr2;
+ aTmpStr = field->GetFunction() + "(" + aTmpStr + ")";
}
if (!rFieldAlias.isEmpty() &&
@@ -670,10 +662,10 @@ namespace
field->isNumericOrAggregateFunction() ||
field->isOtherFunction()))
{
- aTmpStr.append(" AS ");
- aTmpStr.append(::dbtools::quoteName(aQuote, rFieldAlias));
+ aTmpStr.append(" AS " + ::dbtools::quoteName(aQuote, rFieldAlias));
}
- aFieldListStr.append(aTmpStr.makeStringAndClear());
+ aFieldListStr.append(aTmpStr);
+ aTmpStr.setLength(0);
aFieldListStr.append(", ");
}
}
@@ -922,14 +914,11 @@ namespace
{
aWorkStr += quoteTableAlias(bMulti,field->GetAlias(),aQuote) + ::dbtools::quoteName(aQuote, aColumnName);
}
- aWorkStr += " " + OUString( ";ASC;DESC" ).getToken( static_cast<sal_uInt16>(eOrder), ';' ) + ",";
+ aWorkStr += OUString::Concat(" ") + o3tl::getToken( u";ASC;DESC", static_cast<sal_uInt16>(eOrder), ';' ) + ",";
}
}
- {
- OUString sTemp(comphelper::string::stripEnd(aWorkStr, ','));
- aWorkStr = sTemp;
- }
+ aWorkStr = comphelper::string::stripEnd(aWorkStr, ',');
if ( !aWorkStr.isEmpty() )
{
@@ -1085,7 +1074,7 @@ namespace
}
if(!aTableListStr.isEmpty())
- aTableListStr = aTableListStr.replaceAt(aTableListStr.getLength()-1,1, OUString() );
+ aTableListStr = aTableListStr.replaceAt(aTableListStr.getLength()-1,1, u"" );
return aTableListStr;
}
OUString GenerateGroupBy(const OQueryDesignView* _pView,OTableFields& _rFieldList, bool bMulti )
@@ -1143,9 +1132,8 @@ namespace
}
if ( !aGroupByStr.isEmpty() )
{
- aGroupByStr = aGroupByStr.replaceAt(aGroupByStr.getLength()-1,1, OUString(' ') );
- OUString aGroupByStr2 = " GROUP BY " + aGroupByStr;
- aGroupByStr = aGroupByStr2;
+ aGroupByStr = aGroupByStr.replaceAt(aGroupByStr.getLength()-1,1, u" " );
+ aGroupByStr = " GROUP BY " + aGroupByStr;
}
}
catch(SQLException&)
@@ -1822,27 +1810,26 @@ namespace
else
return false;
- if ( eJoinType == CROSS_JOIN || bNatural )
- {
+ if ( eJoinType != CROSS_JOIN && !bNatural )
+ return true;
- OQueryTableWindow* pLeftWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pNode->getChild(0)) );
- OQueryTableWindow* pRightWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTableRef) );
- OSL_ENSURE(pLeftWindow && pRightWindow,"Table Windows could not be found!");
- if ( !pLeftWindow || !pRightWindow )
- return false;
+ OQueryTableWindow* pLeftWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pNode->getChild(0)) );
+ OQueryTableWindow* pRightWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTableRef) );
+ OSL_ENSURE(pLeftWindow && pRightWindow,"Table Windows could not be found!");
+ if ( !pLeftWindow || !pRightWindow )
+ return false;
- OTableFieldDescRef aDragLeft = new OTableFieldDesc();
- aDragLeft->SetTabWindow(pLeftWindow);
- aDragLeft->SetTable(pLeftWindow->GetTableName());
- aDragLeft->SetAlias(pLeftWindow->GetAliasName());
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ aDragLeft->SetTabWindow(pLeftWindow);
+ aDragLeft->SetTable(pLeftWindow->GetTableName());
+ aDragLeft->SetAlias(pLeftWindow->GetAliasName());
- OTableFieldDescRef aDragRight = new OTableFieldDesc();
- aDragRight->SetTabWindow(pRightWindow);
- aDragRight->SetTable(pRightWindow->GetTableName());
- aDragRight->SetAlias(pRightWindow->GetAliasName());
+ OTableFieldDescRef aDragRight = new OTableFieldDesc();
+ aDragRight->SetTabWindow(pRightWindow);
+ aDragRight->SetTable(pRightWindow->GetTableName());
+ aDragRight->SetAlias(pRightWindow->GetAliasName());
- insertConnection(_pView,eJoinType,aDragLeft,aDragRight,bNatural);
- }
+ insertConnection(_pView,eJoinType,aDragLeft,aDragRight,bNatural);
return true;
}
@@ -2175,7 +2162,7 @@ namespace
if ( SQL_ISRULE(pColumnRef,general_set_fct) )
{
aInfo->SetFunctionType(nFunctionType|FKT_AGGREGATE);
- aInfo->SetFunction(comphelper::string::stripEnd(aColumns.getToken(0,'('), ' '));
+ aInfo->SetFunction(OUString(comphelper::string::stripEnd(o3tl::getToken(aColumns,0,'('), ' ')));
}
else
aInfo->SetFunctionType(nFunctionType|FKT_OTHER);
@@ -2364,7 +2351,7 @@ namespace
OUString getParseErrorMessage( SqlParseError _eErrorCode )
{
- const char* pResId;
+ TranslateId pResId;
switch (_eErrorCode)
{
case eIllegalJoin:
@@ -2683,7 +2670,7 @@ void OQueryDesignView::fillValidFields(std::u16string_view sAliasName, weld::Com
bool OQueryDesignView::PreNotify(NotifyEvent& rNEvt)
{
- if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS)
+ if (rNEvt.GetType() == NotifyEventType::GETFOCUS)
{
if ( m_pSelectionBox && m_pSelectionBox->HasChildPathFocus() )
m_eChildFocus = SELECTION;
@@ -2765,22 +2752,19 @@ OUString OQueryDesignView::getStatement()
OUString aTmp = "( " + aJoinCrit + " )";
if(!aCriteriaListStr.isEmpty())
{
- aTmp += C_AND + aCriteriaListStr.makeStringAndClear();
+ aTmp += C_AND;
}
- aCriteriaListStr = aTmp;
+ aCriteriaListStr.insert(0, aTmp);
}
// ----------------- construct statement ----------------------
OUStringBuffer aSqlCmd("SELECT ");
if(rController.isDistinct())
aSqlCmd.append(" DISTINCT ");
- aSqlCmd.append(aFieldListStr);
- aSqlCmd.append(" FROM ");
- aSqlCmd.append(aTableListStr);
+ aSqlCmd.append(aFieldListStr + " FROM " + aTableListStr);
if (!aCriteriaListStr.isEmpty())
{
- aSqlCmd.append(" WHERE ");
- aSqlCmd.append(aCriteriaListStr.makeStringAndClear());
+ aSqlCmd.append(" WHERE " + aCriteriaListStr);
}
Reference<XDatabaseMetaData> xMeta;
if ( xConnection.is() )
@@ -2793,8 +2777,7 @@ OUString OQueryDesignView::getStatement()
// ----------------- construct GroupBy and attach ------------
if(!aHavingStr.isEmpty())
{
- aSqlCmd.append(" HAVING ");
- aSqlCmd.append(aHavingStr.makeStringAndClear());
+ aSqlCmd.append(" HAVING " + aHavingStr);
}
// ----------------- construct sorting and attach ------------
OUString sOrder;
@@ -2813,7 +2796,7 @@ OUString OQueryDesignView::getStatement()
const sal_Int64 nLimit = rController.getLimit();
if( nLimit != -1 )
{
- aSqlCmd.append( " LIMIT " ).append( OUString::number(nLimit) );
+ aSqlCmd.append( " LIMIT " + OUString::number(nLimit) );
}
}
@@ -2944,7 +2927,7 @@ std::unique_ptr<OSQLParseNode> OQueryDesignView::getPredicateTreeFromEntry(const
}
Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
- parse::OParseColumn* pColumn = new parse::OParseColumn( pEntry->GetField(),
+ rtl::Reference<parse::OParseColumn> pColumn = new parse::OParseColumn( pEntry->GetField(),
OUString(),
OUString(),
OUString(),