2010-10-12 15:59:03 +02:00
|
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*
|
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
|
*
|
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
|
*/
|
2006-09-17 06:22:14 +00:00
|
|
|
|
|
2001-02-05 08:35:57 +00:00
|
|
|
|
#include "QueryDesignView.hxx"
|
|
|
|
|
#include "QueryTableView.hxx"
|
|
|
|
|
#include "QTableWindow.hxx"
|
|
|
|
|
#include <vcl/toolbox.hxx>
|
|
|
|
|
#include "querycontroller.hxx"
|
|
|
|
|
#include <vcl/split.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
|
#include <svl/undo.hxx>
|
2008-05-05 15:05:19 +00:00
|
|
|
|
#include <tools/diagnose_ex.h>
|
2011-02-03 00:33:36 +01:00
|
|
|
|
#include <osl/diagnose.h>
|
2001-02-05 08:35:57 +00:00
|
|
|
|
#include "adtabdlg.hxx"
|
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
#include <vcl/combobox.hxx>
|
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
|
#include "browserids.hxx"
|
|
|
|
|
#include "SelectionBrowseBox.hxx"
|
2002-08-19 07:01:32 +00:00
|
|
|
|
#include "dbu_qry.hrc"
|
2001-02-05 08:35:57 +00:00
|
|
|
|
#include <unotools/configmgr.hxx>
|
2012-01-02 10:55:27 +00:00
|
|
|
|
#include <comphelper/extract.hxx>
|
|
|
|
|
#include <comphelper/string.hxx>
|
2001-02-05 08:35:57 +00:00
|
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
|
#include <connectivity/dbtools.hxx>
|
2006-07-10 14:41:12 +00:00
|
|
|
|
#include <connectivity/dbexception.hxx>
|
2001-02-05 08:35:57 +00:00
|
|
|
|
#include <com/sun/star/i18n/XLocaleData.hpp>
|
|
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
2001-09-27 05:19:05 +00:00
|
|
|
|
#include <com/sun/star/sdbc/ColumnValue.hpp>
|
|
|
|
|
#include <connectivity/PColumn.hxx>
|
2001-02-05 08:35:57 +00:00
|
|
|
|
#include "QTableConnection.hxx"
|
|
|
|
|
#include "ConnectionLine.hxx"
|
|
|
|
|
#include "ConnectionLineData.hxx"
|
|
|
|
|
#include "QTableConnectionData.hxx"
|
|
|
|
|
#include "dbustrings.hrc"
|
2001-02-23 14:04:37 +00:00
|
|
|
|
#include "UITools.hxx"
|
2001-08-23 13:39:09 +00:00
|
|
|
|
#include "querycontainerwindow.hxx"
|
2002-04-09 14:30:33 +00:00
|
|
|
|
#include "sqlmessage.hxx"
|
2009-10-16 00:05:16 +02:00
|
|
|
|
#include <unotools/syslocale.hxx>
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
|
|
|
|
using namespace ::dbaui;
|
|
|
|
|
using namespace ::utl;
|
|
|
|
|
using namespace ::connectivity;
|
2006-07-10 14:41:12 +00:00
|
|
|
|
using namespace ::dbtools;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// here we define our functions used in the anonymous namespace to get our header file smaller
|
|
|
|
|
// please look at the book LargeScale C++ to know why
|
|
|
|
|
namespace
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2010-11-13 21:19:14 +00:00
|
|
|
|
static const ::rtl::OUString C_AND(RTL_CONSTASCII_USTRINGPARAM(" AND "));
|
|
|
|
|
static const ::rtl::OUString C_OR(RTL_CONSTASCII_USTRINGPARAM(" OR "));
|
2001-09-27 05:19:05 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// forward declarations
|
|
|
|
|
sal_Bool InsertJoin( const OQueryDesignView* _pView,
|
|
|
|
|
const ::connectivity::OSQLParseNode *pNode);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError InstallFields(OQueryDesignView* _pView,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pNode,
|
|
|
|
|
OJoinTableView::OTableWindowMap* pTabList );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetGroupCriteria( OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pSelectRoot );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetHavingCriteria(OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pSelectRoot,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_uInt16& rLevel );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetOrderCriteria( OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pParseRoot );
|
2002-04-09 14:30:33 +00:00
|
|
|
|
|
2004-03-15 11:43:43 +00:00
|
|
|
|
SqlParseError AddFunctionCondition(OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
const sal_uInt16 nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving,
|
|
|
|
|
bool _bAddOrOnOneLine);
|
2004-03-15 11:43:43 +00:00
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
::rtl::OUString quoteTableAlias(sal_Bool _bQuote, const ::rtl::OUString& _sAliasName, const ::rtl::OUString& _sQuote)
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sRet;
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( _bQuote && !_sAliasName.isEmpty() )
|
2002-08-30 10:13:38 +00:00
|
|
|
|
{
|
|
|
|
|
sRet = ::dbtools::quoteName(_sQuote,_sAliasName);
|
|
|
|
|
const static ::rtl::OUString sTableSeparater('.');
|
|
|
|
|
sRet += sTableSeparater;
|
|
|
|
|
}
|
|
|
|
|
return sRet;
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2007-11-01 14:31:21 +00:00
|
|
|
|
::rtl::OUString getTableRange(const OQueryDesignView* _pView,const ::connectivity::OSQLParseNode* _pTableRef)
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
|
2007-11-01 14:31:21 +00:00
|
|
|
|
::rtl::OUString sTableRange;
|
|
|
|
|
if ( _pTableRef )
|
|
|
|
|
{
|
2008-06-16 11:33:33 +00:00
|
|
|
|
sTableRange = ::connectivity::OSQLParseNode::getTableRange(_pTableRef);
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( sTableRange.isEmpty() )
|
2008-06-16 11:33:33 +00:00
|
|
|
|
_pTableRef->parseNodeToStr(sTableRange,xConnection,NULL,sal_False,sal_False);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
|
|
|
|
return sTableRange;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
void insertConnection(const OQueryDesignView* _pView,const EJoinType& _eJoinType,OTableFieldDescRef _aDragLeft,OTableFieldDescRef _aDragRight,bool _bNatural = false)
|
|
|
|
|
{
|
|
|
|
|
OQueryTableView* pTableView = static_cast<OQueryTableView*>(_pView->getTableView());
|
|
|
|
|
OQueryTableConnection* pConn = static_cast<OQueryTableConnection*>( pTableView->GetTabConn(static_cast<OTableWindow*>(_aDragLeft->GetTabWindow()),static_cast<OTableWindow*>(_aDragRight->GetTabWindow()),true));
|
|
|
|
|
|
|
|
|
|
if ( !pConn )
|
|
|
|
|
{
|
|
|
|
|
OQueryTableConnectionData* pInfoData = new OQueryTableConnectionData();
|
|
|
|
|
TTableConnectionData::value_type aInfoData(pInfoData);
|
|
|
|
|
pInfoData->InitFromDrag(_aDragLeft, _aDragRight);
|
|
|
|
|
pInfoData->SetJoinType(_eJoinType);
|
|
|
|
|
|
|
|
|
|
if ( _bNatural )
|
|
|
|
|
{
|
|
|
|
|
aInfoData->ResetConnLines();
|
|
|
|
|
pInfoData->setNatural(_bNatural);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Reference<XNameAccess> xReferencedTableColumns(aInfoData->getReferencedTable()->getColumns());
|
|
|
|
|
Sequence< ::rtl::OUString> aSeq = aInfoData->getReferencingTable()->getColumns()->getElementNames();
|
|
|
|
|
const ::rtl::OUString* pIter = aSeq.getConstArray();
|
|
|
|
|
const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
|
|
|
|
|
for(;pIter != pEnd;++pIter)
|
|
|
|
|
{
|
|
|
|
|
if ( xReferencedTableColumns->hasByName(*pIter) )
|
|
|
|
|
aInfoData->AppendConnLine(*pIter,*pIter);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-05-05 15:05:19 +00:00
|
|
|
|
catch( const Exception& )
|
2007-11-01 14:31:21 +00:00
|
|
|
|
{
|
2008-05-05 15:05:19 +00:00
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OQueryTableConnection aInfo(pTableView, aInfoData);
|
|
|
|
|
// da ein OQueryTableConnection-Objekt nie den Besitz der uebergebenen Daten uebernimmt, sondern sich nur den Zeiger merkt,
|
|
|
|
|
// ist dieser Zeiger auf eine lokale Variable hier unkritisch, denn aInfoData und aInfo haben die selbe Lebensdauer
|
|
|
|
|
pTableView->NotifyTabConnection( aInfo );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aSourceFieldName(_aDragLeft->GetField());
|
|
|
|
|
::rtl::OUString aDestFieldName(_aDragRight->GetField());
|
|
|
|
|
// the connection could point on the other side
|
|
|
|
|
if(pConn->GetSourceWin() == _aDragRight->GetTabWindow())
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aTmp(aSourceFieldName);
|
|
|
|
|
aSourceFieldName = aDestFieldName;
|
|
|
|
|
aDestFieldName = aTmp;
|
|
|
|
|
}
|
|
|
|
|
pConn->GetData()->AppendConnLine( aSourceFieldName,aDestFieldName);
|
|
|
|
|
pConn->UpdateLineList();
|
|
|
|
|
// Modified-Flag
|
|
|
|
|
// SetModified();
|
|
|
|
|
// und neu zeichnen
|
|
|
|
|
pConn->RecalcLines();
|
|
|
|
|
// fuer das unten folgende Invalidate muss ich dieser neuen Connection erst mal die Moeglichkeit geben,
|
|
|
|
|
// ihr BoundingRect zu ermitteln
|
|
|
|
|
pConn->InvalidateConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::rtl::OUString ParseCondition( OQueryController& rController
|
2004-03-15 11:43:43 +00:00
|
|
|
|
,const ::connectivity::OSQLParseNode* pCondition
|
|
|
|
|
,const ::rtl::OUString _sDecimal
|
|
|
|
|
,const ::com::sun::star::lang::Locale& _rLocale
|
|
|
|
|
,sal_uInt32 _nStartIndex)
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aCondition;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2004-03-15 11:43:43 +00:00
|
|
|
|
if ( xConnection.is() )
|
|
|
|
|
{
|
|
|
|
|
sal_uInt32 nCount = pCondition->count();
|
|
|
|
|
for(sal_uInt32 i = _nStartIndex ; i < nCount ; ++i)
|
|
|
|
|
pCondition->getChild(i)->parseNodeToPredicateStr(aCondition,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.getNumberFormatter(),
|
2004-03-15 11:43:43 +00:00
|
|
|
|
_rLocale,
|
|
|
|
|
static_cast<sal_Char>(_sDecimal.toChar()),
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2004-03-15 11:43:43 +00:00
|
|
|
|
}
|
|
|
|
|
return aCondition;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError FillOuterJoins(OQueryDesignView* _pView,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pTableRefList)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
|
|
|
|
sal_uInt32 nCount = pTableRefList->count();
|
2003-04-28 15:00:22 +00:00
|
|
|
|
sal_Bool bError = sal_False;
|
|
|
|
|
for (sal_uInt32 i=0; !bError && i < nCount; ++i)
|
2001-02-05 15:17:40 +00:00
|
|
|
|
{
|
2003-04-28 15:00:22 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode* pParseNode = pTableRefList->getChild(i);
|
|
|
|
|
const ::connectivity::OSQLParseNode* pJoinNode = NULL;
|
2002-02-19 13:04:20 +00:00
|
|
|
|
|
2008-07-25 06:52:25 +00:00
|
|
|
|
if ( SQL_ISRULE( pParseNode, qualified_join ) || SQL_ISRULE( pParseNode, joined_table ) || SQL_ISRULE( pParseNode, cross_union ) )
|
2003-04-28 15:00:22 +00:00
|
|
|
|
pJoinNode = pParseNode;
|
2008-06-16 11:33:33 +00:00
|
|
|
|
else if( SQL_ISRULE(pParseNode,table_ref)
|
|
|
|
|
&& pParseNode->count() == 4 ) // '{' SQL_TOKEN_OJ joined_table '}'
|
2003-04-28 15:00:22 +00:00
|
|
|
|
pJoinNode = pParseNode->getChild(2);
|
2002-02-19 13:04:20 +00:00
|
|
|
|
|
2003-04-28 15:00:22 +00:00
|
|
|
|
if ( pJoinNode )
|
2002-05-06 08:45:36 +00:00
|
|
|
|
{
|
2003-04-28 15:00:22 +00:00
|
|
|
|
if ( !InsertJoin(_pView,pJoinNode) )
|
|
|
|
|
bError = sal_True;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
}
|
2001-02-05 15:17:40 +00:00
|
|
|
|
}
|
2010-12-04 12:33:49 +09:00
|
|
|
|
// check if error occurred
|
2003-04-28 15:00:22 +00:00
|
|
|
|
if ( bError )
|
|
|
|
|
eErrorCode = eIllegalJoin;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
/** FillDragInfo fills the field description out of the table
|
|
|
|
|
*/
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError FillDragInfo( const OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode* pColumnRef,
|
|
|
|
|
OTableFieldDescRef& _rDragInfo)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
sal_Bool bErg = sal_False;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString aTableRange,aColumnName;
|
|
|
|
|
sal_uInt16 nCntAccount;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::connectivity::OSQLParseTreeIterator& rParseIter = static_cast<OQueryController&>(_pView->getController()).getParseIterator();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
rParseIter.getColumnRange( pColumnRef, aColumnName, aTableRange );
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( !aTableRange.isEmpty() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* pSTW = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( aTableRange );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
bErg = (pSTW && pSTW->ExistsField( aColumnName, _rDragInfo ) );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( !bErg )
|
2008-12-10 13:41:25 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
bErg = static_cast<OQueryTableView*>(_pView->getTableView())->FindTableFromField(aColumnName, _rDragInfo, nCntAccount);
|
2008-12-10 13:41:25 +00:00
|
|
|
|
if ( !bErg )
|
|
|
|
|
bErg = _pView->HasFieldByAliasName(aColumnName, _rDragInfo);
|
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( !bErg )
|
|
|
|
|
{
|
|
|
|
|
eErrorCode = eColumnNotFound;
|
|
|
|
|
String sError(ModuleRes(STR_QRY_COLUMN_NOT_FOUND));
|
|
|
|
|
sError.SearchAndReplaceAscii("$name$",aColumnName);
|
2008-12-01 12:31:27 +00:00
|
|
|
|
_pView->getController().appendError( sError );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
2003-12-01 09:38:33 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference<XDatabaseMetaData> xMeta = _pView->getController().getConnection()->getMetaData();
|
2006-08-15 09:56:06 +00:00
|
|
|
|
if ( xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() )
|
2008-12-01 12:31:27 +00:00
|
|
|
|
_pView->getController().appendError( String( ModuleRes( STR_QRY_CHECK_CASESENSITIVE ) ) );
|
2003-12-01 09:38:33 +00:00
|
|
|
|
}
|
|
|
|
|
catch(Exception&)
|
|
|
|
|
{
|
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return eErrorCode;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString BuildJoinCriteria( const Reference< XConnection>& _xConnection,
|
2012-12-02 18:32:38 +01:00
|
|
|
|
const OConnectionLineDataVec* pLineDataList,
|
|
|
|
|
const OQueryTableConnectionData* pData)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::rtl::OUStringBuffer aCondition;
|
|
|
|
|
if ( _xConnection.is() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2012-12-02 18:32:38 +01:00
|
|
|
|
OConnectionLineDataVec::const_iterator aIter = pLineDataList->begin();
|
|
|
|
|
OConnectionLineDataVec::const_iterator aEnd = pLineDataList->end();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData();
|
|
|
|
|
const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
|
|
|
|
|
const ::rtl::OUString sEqual(RTL_CONSTASCII_USTRINGPARAM(" = "));
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(;aIter != aEnd;++aIter)
|
|
|
|
|
{
|
|
|
|
|
OConnectionLineDataRef pLineData = *aIter;
|
|
|
|
|
if(aCondition.getLength())
|
|
|
|
|
aCondition.append(C_AND);
|
|
|
|
|
aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_FROM),aQuote));
|
|
|
|
|
aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_FROM) ));
|
|
|
|
|
aCondition.append(sEqual);
|
|
|
|
|
aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_TO),aQuote));
|
|
|
|
|
aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_TO) ));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(SQLException&)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-03-12 13:57:34 +01:00
|
|
|
|
OSL_FAIL("Failure while building Join criteria!");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
|
return aCondition.makeStringAndClear();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
/** JoinCycle looks for a join cycle and append it to the string
|
2002-05-06 08:45:36 +00:00
|
|
|
|
@param _xConnection the connection
|
2002-02-06 07:08:30 +00:00
|
|
|
|
@param _pEntryConn the table connection which holds the data
|
|
|
|
|
@param _pEntryTabTo the corresponding table window
|
|
|
|
|
@param _rJoin the String which will contain the resulting string
|
|
|
|
|
*/
|
2002-05-06 08:45:36 +00:00
|
|
|
|
void JoinCycle( const Reference< XConnection>& _xConnection,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OQueryTableConnection* _pEntryConn,
|
|
|
|
|
const OQueryTableWindow* _pEntryTabTo,
|
|
|
|
|
::rtl::OUString& _rJoin )
|
|
|
|
|
{
|
|
|
|
|
OSL_ENSURE(_pEntryConn,"TableConnection can not be null!");
|
|
|
|
|
|
2007-11-01 14:31:21 +00:00
|
|
|
|
OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pEntryConn->GetData().get());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if ( pData->GetJoinType() != INNER_JOIN && _pEntryTabTo->ExistsAVisitedConn() )
|
|
|
|
|
{
|
|
|
|
|
sal_Bool bBrace = sal_False;
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if(!_rJoin.isEmpty() && _rJoin.lastIndexOf(')') == (_rJoin.getLength()-1))
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
bBrace = sal_True;
|
|
|
|
|
_rJoin = _rJoin.replaceAt(_rJoin.getLength()-1,1,::rtl::OUString(' '));
|
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
(_rJoin += C_AND) += BuildJoinCriteria(_xConnection,pData->GetConnLineDataList(),pData);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(bBrace)
|
|
|
|
|
_rJoin += ::rtl::OUString(')');
|
|
|
|
|
_pEntryConn->SetVisited(sal_True);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString BuildTable( const Reference< XConnection>& _xConnection,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
const OQueryTableWindow* pEntryTab,
|
|
|
|
|
bool _bForce = false
|
2003-09-04 07:33:37 +00:00
|
|
|
|
)
|
2001-04-18 10:44:59 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString aDBName(pEntryTab->GetComposedName());
|
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if( _xConnection.is() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData();
|
2002-06-27 07:21:18 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
::rtl::OUString sCatalog, sSchema, sTable;
|
|
|
|
|
::dbtools::qualifiedNameComponents( xMetaData, aDBName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
|
|
|
|
|
::rtl::OUString aTableListStr = ::dbtools::composeTableNameForSelect( _xConnection, sCatalog, sSchema, sTable );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( _bForce || isAppendTableAliasEnabled( _xConnection ) || pEntryTab->GetAliasName() != aDBName )
|
2003-09-04 07:33:37 +00:00
|
|
|
|
{
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aTableListStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
|
2006-12-13 15:53:22 +00:00
|
|
|
|
if ( generateAsBeforeTableAlias( _xConnection ) )
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aTableListStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AS "));
|
2006-12-13 15:53:22 +00:00
|
|
|
|
aTableListStr += ::dbtools::quoteName( aQuote, pEntryTab->GetAliasName() );
|
2003-09-04 07:33:37 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aDBName = aTableListStr;
|
|
|
|
|
}
|
2008-05-05 15:05:19 +00:00
|
|
|
|
catch(const SQLException&)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2008-05-05 15:05:19 +00:00
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return aDBName;
|
2001-04-18 10:44:59 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const ::rtl::OUString& rLh,
|
|
|
|
|
const ::rtl::OUString& rRh,
|
2012-12-02 18:32:38 +01:00
|
|
|
|
const OQueryTableConnectionData* pData)
|
2001-05-02 11:44:27 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
String aErg(rLh);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( pData->isNatural() && pData->GetJoinType() != CROSS_JOIN )
|
|
|
|
|
aErg.AppendAscii(" NATURAL ");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
switch(pData->GetJoinType())
|
|
|
|
|
{
|
|
|
|
|
case LEFT_JOIN:
|
|
|
|
|
aErg.AppendAscii(" LEFT OUTER ");
|
|
|
|
|
break;
|
|
|
|
|
case RIGHT_JOIN:
|
|
|
|
|
aErg.AppendAscii(" RIGHT OUTER ");
|
|
|
|
|
break;
|
2007-11-01 14:31:21 +00:00
|
|
|
|
case CROSS_JOIN:
|
|
|
|
|
OSL_ENSURE(!pData->isNatural(),"OQueryDesignView::BuildJoin: This should not happen!");
|
|
|
|
|
aErg.AppendAscii(" CROSS ");
|
|
|
|
|
break;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
case INNER_JOIN:
|
2007-11-01 14:31:21 +00:00
|
|
|
|
OSL_ENSURE(pData->isNatural(),"OQueryDesignView::BuildJoin: This should not happen!");
|
|
|
|
|
aErg.AppendAscii(" INNER ");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
aErg.AppendAscii(" FULL OUTER ");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
aErg.AppendAscii("JOIN ");
|
|
|
|
|
aErg += String(rRh);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( CROSS_JOIN != pData->GetJoinType() && !pData->isNatural() )
|
|
|
|
|
{
|
|
|
|
|
aErg.AppendAscii(" ON ");
|
|
|
|
|
aErg += String(BuildJoinCriteria(_xConnection,pData->GetConnLineDataList(),pData));
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
return aErg;
|
2001-05-02 11:44:27 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
|
2012-12-02 18:32:38 +01:00
|
|
|
|
const OQueryTableWindow* pLh,
|
|
|
|
|
const OQueryTableWindow* pRh,
|
|
|
|
|
const OQueryTableConnectionData* pData
|
2003-09-04 07:33:37 +00:00
|
|
|
|
)
|
2001-05-02 11:44:27 +00:00
|
|
|
|
{
|
2007-11-01 14:31:21 +00:00
|
|
|
|
bool bForce = pData->GetJoinType() == CROSS_JOIN || pData->isNatural();
|
|
|
|
|
return BuildJoin(_xConnection,BuildTable(_xConnection,pLh,bForce),BuildTable(_xConnection,pRh,bForce),pData);
|
2001-05-02 11:44:27 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const ::rtl::OUString &rLh,
|
2012-12-02 18:32:38 +01:00
|
|
|
|
const OQueryTableWindow* pRh,
|
|
|
|
|
const OQueryTableConnectionData* pData
|
2003-09-04 07:33:37 +00:00
|
|
|
|
)
|
2001-05-02 11:44:27 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return BuildJoin(_xConnection,rLh,BuildTable(_xConnection,pRh),pData);
|
2001-05-02 11:44:27 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
|
2012-12-02 18:32:38 +01:00
|
|
|
|
const OQueryTableWindow* pLh,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const ::rtl::OUString &rRh,
|
2012-12-02 18:32:38 +01:00
|
|
|
|
const OQueryTableConnectionData* pData
|
2003-09-04 07:33:37 +00:00
|
|
|
|
)
|
2001-05-02 11:44:27 +00:00
|
|
|
|
{
|
2012-12-02 18:32:38 +01:00
|
|
|
|
// strict ANSI SQL:
|
|
|
|
|
// - does not support any bracketing of JOINS
|
|
|
|
|
// - supports nested joins only in the LEFT HAND SIDE
|
|
|
|
|
// In this case, we are trying to build a join with a nested join
|
|
|
|
|
// in the right hand side.
|
|
|
|
|
// So switch the direction of the join and both hand sides.
|
|
|
|
|
OQueryTableConnectionData data(*pData);
|
|
|
|
|
switch (data.GetJoinType())
|
|
|
|
|
{
|
2012-12-02 18:55:44 +01:00
|
|
|
|
case LEFT_JOIN:
|
|
|
|
|
data.SetJoinType(RIGHT_JOIN);
|
|
|
|
|
break;
|
|
|
|
|
case RIGHT_JOIN:
|
|
|
|
|
data.SetJoinType(LEFT_JOIN);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// the other join types are symmetric, so nothing to change
|
|
|
|
|
break;
|
2012-12-02 18:32:38 +01:00
|
|
|
|
}
|
|
|
|
|
return BuildJoin(_xConnection, rRh, BuildTable(_xConnection,pLh), &data);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
void GetNextJoin( const Reference< XConnection>& _xConnection,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OQueryTableConnection* pEntryConn,
|
|
|
|
|
OQueryTableWindow* pEntryTabTo,
|
|
|
|
|
::rtl::OUString &aJoin)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2007-11-01 14:31:21 +00:00
|
|
|
|
OQueryTableConnectionData* pEntryConnData = static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get());
|
|
|
|
|
if ( pEntryConnData->GetJoinType() == INNER_JOIN && !pEntryConnData->isNatural() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if(aJoin.isEmpty())
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin());
|
2002-05-06 08:45:36 +00:00
|
|
|
|
aJoin = BuildJoin(_xConnection,pEntryTabFrom,pEntryTabTo,pEntryConnData);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else if(pEntryTabTo == pEntryConn->GetDestWin())
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-11-19 17:43:08 +00:00
|
|
|
|
aJoin = BuildJoin(_xConnection,aJoin,pEntryTabTo,pEntryConnData);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
else if(pEntryTabTo == pEntryConn->GetSourceWin())
|
|
|
|
|
{
|
2008-11-19 17:43:08 +00:00
|
|
|
|
aJoin = BuildJoin(_xConnection,pEntryTabTo,aJoin,pEntryConnData);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
pEntryConn->SetVisited(sal_True);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// first search for the "to" window
|
2002-02-19 13:04:20 +00:00
|
|
|
|
const ::std::vector<OTableConnection*>* pConnections = pEntryConn->GetParent()->getTableConnections();
|
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter = pConnections->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aEnd = pConnections->end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter);
|
|
|
|
|
if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabTo || pNext->GetDestWin() == pEntryTabTo))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabTo ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin());
|
|
|
|
|
// exists there a connection to a OQueryTableWindow that holds a connection that has been already visited
|
2002-05-06 08:45:36 +00:00
|
|
|
|
JoinCycle(_xConnection,pNext,pEntryTab,aJoin);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(!pNext->IsVisited())
|
2002-05-06 08:45:36 +00:00
|
|
|
|
GetNextJoin(_xConnection,pNext,pEntryTab,aJoin);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// when nothing found found look for the "from" window
|
2009-07-03 12:24:35 +00:00
|
|
|
|
if(aIter == aEnd)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin());
|
2002-02-19 13:04:20 +00:00
|
|
|
|
aIter = pConnections->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter);
|
|
|
|
|
if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabFrom || pNext->GetDestWin() == pEntryTabFrom))
|
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabFrom ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin());
|
|
|
|
|
// exists there a connection to a OQueryTableWindow that holds a connection that has been already visited
|
2002-05-06 08:45:36 +00:00
|
|
|
|
JoinCycle(_xConnection,pNext,pEntryTab,aJoin);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(!pNext->IsVisited())
|
2002-05-06 08:45:36 +00:00
|
|
|
|
GetNextJoin(_xConnection,pNext,pEntryTab,aJoin);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError InsertJoinConnection( const OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode *pNode,
|
2010-01-11 13:22:04 +01:00
|
|
|
|
const EJoinType& _eJoinType,
|
|
|
|
|
const ::connectivity::OSQLParseNode *pLeftTable,
|
|
|
|
|
const ::connectivity::OSQLParseNode *pRightTable)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (pNode->count() == 3 && // Ausdruck is geklammert
|
|
|
|
|
SQL_ISPUNCTUATION(pNode->getChild(0),"(") &&
|
|
|
|
|
SQL_ISPUNCTUATION(pNode->getChild(2),")"))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2010-01-11 13:22:04 +01:00
|
|
|
|
eErrorCode = InsertJoinConnection(_pView,pNode->getChild(1), _eJoinType,pLeftTable,pRightTable);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2002-02-19 13:04:20 +00:00
|
|
|
|
else if (SQL_ISRULEOR2(pNode,search_condition,boolean_term) && // AND/OR-Verknuepfung:
|
2002-02-06 07:08:30 +00:00
|
|
|
|
pNode->count() == 3)
|
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
// nur AND Verkn<6B>pfung zulassen
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (!SQL_ISTOKEN(pNode->getChild(1),AND))
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = eIllegalJoinCondition;
|
2010-01-11 13:22:04 +01:00
|
|
|
|
else if ( eOk == (eErrorCode = InsertJoinConnection(_pView,pNode->getChild(0), _eJoinType,pLeftTable,pRightTable)) )
|
|
|
|
|
eErrorCode = InsertJoinConnection(_pView,pNode->getChild(2), _eJoinType,pLeftTable,pRightTable);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
else if (SQL_ISRULE(pNode,comparison_predicate))
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
// only the comparison of columns is allowed
|
2011-02-03 00:33:36 +01:00
|
|
|
|
OSL_ENSURE(pNode->count() == 3,"OQueryDesignView::InsertJoinConnection: Fehler im Parse Tree");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (!(SQL_ISRULE(pNode->getChild(0),column_ref) &&
|
|
|
|
|
SQL_ISRULE(pNode->getChild(2),column_ref) &&
|
|
|
|
|
pNode->getChild(1)->getNodeType() == SQL_NODE_EQUAL))
|
2002-05-06 08:45:36 +00:00
|
|
|
|
{
|
|
|
|
|
String sError(ModuleRes(STR_QRY_JOIN_COLUMN_COMPARE));
|
2008-12-01 12:31:27 +00:00
|
|
|
|
_pView->getController().appendError( sError );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eIllegalJoin;
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
|
|
|
|
OTableFieldDescRef aDragRight = new OTableFieldDesc();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( eOk != ( eErrorCode = FillDragInfo(_pView,pNode->getChild(0),aDragLeft)) ||
|
|
|
|
|
eOk != ( eErrorCode = FillDragInfo(_pView,pNode->getChild(2),aDragRight)))
|
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2010-01-11 13:22:04 +01:00
|
|
|
|
if ( pLeftTable )
|
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* pLeftWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pLeftTable->getByRule(OSQLParseNode::table_ref) ));
|
|
|
|
|
if ( pLeftWindow == aDragLeft->GetTabWindow() )
|
|
|
|
|
insertConnection(_pView,_eJoinType,aDragLeft,aDragRight);
|
|
|
|
|
else
|
|
|
|
|
insertConnection(_pView,_eJoinType,aDragRight,aDragLeft);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
insertConnection(_pView,_eJoinType,aDragLeft,aDragRight);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
else
|
|
|
|
|
eErrorCode = eIllegalJoin;
|
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
sal_Bool GetInnerJoinCriteria( const OQueryDesignView* _pView,
|
|
|
|
|
const ::connectivity::OSQLParseNode *pCondition)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2010-01-11 13:22:04 +01:00
|
|
|
|
return InsertJoinConnection(_pView,pCondition, INNER_JOIN,NULL,NULL) != eOk;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
::rtl::OUString GenerateSelectList( const OQueryDesignView* _pView,
|
|
|
|
|
OTableFields& _rFieldList,
|
|
|
|
|
sal_Bool bAlias)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
|
Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
|
|
|
|
|
if ( !xConnection.is() )
|
|
|
|
|
return ::rtl::OUString();
|
|
|
|
|
|
|
|
|
|
::rtl::OUStringBuffer aTmpStr,aFieldListStr;
|
2001-10-11 07:38:14 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
sal_Bool bAsterix = sal_False;
|
|
|
|
|
int nVis = 0;
|
|
|
|
|
OTableFields::iterator aIter = _rFieldList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OTableFields::iterator aEnd = _rFieldList.end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFieldDescRef pEntryField = *aIter;
|
2002-08-19 07:01:32 +00:00
|
|
|
|
if ( pEntryField->IsVisible() )
|
2001-10-11 07:38:14 +00:00
|
|
|
|
{
|
2002-08-19 07:01:32 +00:00
|
|
|
|
if ( pEntryField->GetField().toChar() == '*' )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
bAsterix = sal_True;
|
|
|
|
|
++nVis;
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(nVis == 1)
|
|
|
|
|
bAsterix = sal_False;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
try
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
|
const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
|
2001-10-11 07:38:14 +00:00
|
|
|
|
|
2004-03-15 11:43:43 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap* pTabList = _pView->getTableView()->GetTabWinMap();
|
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
const static ::rtl::OUString sFieldSeparator(RTL_CONSTASCII_USTRINGPARAM(", "));
|
2009-07-03 12:24:35 +00:00
|
|
|
|
const static ::rtl::OUString s_sAs(RTL_CONSTASCII_USTRINGPARAM(" AS "));
|
2002-08-30 10:13:38 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aIter = _rFieldList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFieldDescRef pEntryField = *aIter;
|
|
|
|
|
::rtl::OUString rFieldName = pEntryField->GetField();
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( !rFieldName.isEmpty() && pEntryField->IsVisible() )
|
2001-10-11 07:38:14 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aTmpStr = ::rtl::OUString();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
const ::rtl::OUString rAlias = pEntryField->GetAlias();
|
|
|
|
|
const ::rtl::OUString rFieldAlias = pEntryField->GetFieldAlias();
|
2002-08-30 10:13:38 +00:00
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aTmpStr.append(quoteTableAlias((bAlias || bAsterix),rAlias,aQuote));
|
2002-08-30 10:13:38 +00:00
|
|
|
|
|
|
|
|
|
// if we have a none numeric field, the table alias could be in the name
|
|
|
|
|
// otherwise we are not allowed to do this (e.g. 0.1 * PRICE )
|
2010-01-14 12:14:15 +01:00
|
|
|
|
if ( !pEntryField->isOtherFunction() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2004-03-15 11:43:43 +00:00
|
|
|
|
// we have to look if we have alias.* here but before we have to check if the column doesn't already exist
|
2002-08-30 10:13:38 +00:00
|
|
|
|
String sTemp = rFieldName;
|
2004-03-15 11:43:43 +00:00
|
|
|
|
OTableFieldDescRef aInfo = new OTableFieldDesc();
|
2006-06-20 02:26:39 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap::iterator tableIter = pTabList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap::iterator tableEnd = pTabList->end();
|
2004-03-15 11:43:43 +00:00
|
|
|
|
sal_Bool bFound = sal_False;
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(;!bFound && tableIter != tableEnd ;++tableIter)
|
2004-03-15 11:43:43 +00:00
|
|
|
|
{
|
2006-06-20 02:26:39 +00:00
|
|
|
|
OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(tableIter->second);
|
2004-03-15 11:43:43 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
bFound = pTabWin->ExistsField( rFieldName, aInfo );
|
|
|
|
|
if ( bFound )
|
2004-03-15 11:43:43 +00:00
|
|
|
|
rFieldName = aInfo->GetField();
|
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( ( rFieldName.toChar() != '*' ) && ( rFieldName.indexOf( aQuote ) == -1 ) )
|
2002-08-30 10:13:38 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
OSL_ENSURE(!pEntryField->GetTable().isEmpty(),"No table field name!");
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aTmpStr.append(::dbtools::quoteName(aQuote, rFieldName));
|
2002-08-30 10:13:38 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aTmpStr.append(rFieldName);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aTmpStr.append(rFieldName);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if ( pEntryField->isAggreateFunction() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
OSL_ENSURE(!pEntryField->GetFunction().isEmpty(),"Functionname darf hier nicht leer sein! ;-(");
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::rtl::OUStringBuffer aTmpStr2( pEntryField->GetFunction());
|
|
|
|
|
aTmpStr2.appendAscii("(");
|
|
|
|
|
aTmpStr2.append(aTmpStr.makeStringAndClear());
|
|
|
|
|
aTmpStr2.appendAscii(")");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aTmpStr = aTmpStr2;
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if (!rFieldAlias.isEmpty() &&
|
2002-02-06 07:08:30 +00:00
|
|
|
|
(rFieldName.toChar() != '*' ||
|
2002-08-30 10:13:38 +00:00
|
|
|
|
pEntryField->isNumericOrAggreateFunction() ||
|
|
|
|
|
pEntryField->isOtherFunction()))
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aTmpStr.append(s_sAs);
|
|
|
|
|
aTmpStr.append(::dbtools::quoteName(aQuote, rFieldAlias));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aFieldListStr.append(aTmpStr.makeStringAndClear());
|
|
|
|
|
aFieldListStr.append(sFieldSeparator);
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(aFieldListStr.getLength())
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aFieldListStr.setLength(aFieldListStr.getLength()-2);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
catch(SQLException&)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2011-03-12 13:57:34 +01:00
|
|
|
|
OSL_FAIL("Failure while building select list!");
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
|
return aFieldListStr.makeStringAndClear();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
sal_Bool GenerateCriterias( OQueryDesignView* _pView,
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::rtl::OUStringBuffer& rRetStr,
|
|
|
|
|
::rtl::OUStringBuffer& rHavingStr,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFields& _rFieldList,
|
|
|
|
|
sal_Bool bMulti )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// * darf keine Filter enthalten : habe ich die entsprechende Warnung schon angezeigt ?
|
|
|
|
|
sal_Bool bCritsOnAsterikWarning = sal_False; // ** TMFS **
|
|
|
|
|
|
|
|
|
|
::rtl::OUString aFieldName,aCriteria,aWhereStr,aHavingStr,aWork/*,aOrderStr*/;
|
|
|
|
|
// Zeilenweise werden die Ausdr"ucke mit AND verknuepft
|
|
|
|
|
sal_uInt16 nMaxCriteria = 0;
|
|
|
|
|
OTableFields::iterator aIter = _rFieldList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OTableFields::iterator aEnd = _rFieldList.end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
nMaxCriteria = ::std::max<sal_uInt16>(nMaxCriteria,(sal_uInt16)(*aIter)->GetCriteria().size());
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(!xConnection.is())
|
2011-01-14 15:00:11 +01:00
|
|
|
|
return sal_False;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
|
const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
|
2008-06-25 11:52:59 +00:00
|
|
|
|
const IParseContext& rContext = static_cast<OQueryController&>(_pView->getController()).getParser().getContext();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
for (sal_uInt16 i=0 ; i < nMaxCriteria ; i++)
|
|
|
|
|
{
|
|
|
|
|
aHavingStr = aWhereStr = ::rtl::OUString();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(aIter = _rFieldList.begin();aIter != aEnd;++aIter)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OTableFieldDescRef pEntryField = *aIter;
|
|
|
|
|
aFieldName = pEntryField->GetField();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if (aFieldName.isEmpty())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
continue;
|
|
|
|
|
aCriteria = pEntryField->GetCriteria( i );
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( !aCriteria.isEmpty() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-08-30 10:13:38 +00:00
|
|
|
|
// * is not allowed to contain any filter, only when used in combination an aggregate function
|
|
|
|
|
if ( aFieldName.toChar() == '*' && pEntryField->isNoneFunction() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
// only show the messagebox the first time
|
|
|
|
|
if (!bCritsOnAsterikWarning)
|
|
|
|
|
ErrorBox(_pView, ModuleRes( ERR_QRY_CRITERIA_ON_ASTERISK)).Execute();
|
|
|
|
|
bCritsOnAsterikWarning = sal_True;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
aWork = ::rtl::OUString();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aWork += quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
|
|
|
|
|
|
|
|
|
|
if ( (pEntryField->GetFunctionType() & (FKT_OTHER|FKT_NUMERIC)) || (aFieldName.toChar() == '*') )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aWork += aFieldName;
|
|
|
|
|
else
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aWork += ::dbtools::quoteName(aQuote, aFieldName);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if ( pEntryField->isAggreateFunction() || pEntryField->IsGroupBy() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if (aHavingStr.isEmpty()) // noch keine Kriterien
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aHavingStr += ::rtl::OUString('('); // Klammern
|
|
|
|
|
else
|
|
|
|
|
aHavingStr += C_AND;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if ( pEntryField->isAggreateFunction() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
OSL_ENSURE(!pEntryField->GetFunction().isEmpty(),"No function name for aggregate given!");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aHavingStr += pEntryField->GetFunction();
|
|
|
|
|
aHavingStr += ::rtl::OUString('('); // Klammern
|
|
|
|
|
aHavingStr += aWork;
|
|
|
|
|
aHavingStr += ::rtl::OUString(')'); // Klammern
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
aHavingStr += aWork;
|
|
|
|
|
|
|
|
|
|
::rtl::OUString aTmp = aCriteria;
|
|
|
|
|
::rtl::OUString aErrorMsg;
|
|
|
|
|
Reference<XPropertySet> xColumn;
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::std::auto_ptr< ::connectivity::OSQLParseNode> pParseNode(_pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn));
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if (pParseNode.get())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if (bMulti && !(pEntryField->isOtherFunction() || (aFieldName.toChar() == '*')))
|
2002-06-27 07:21:18 +00:00
|
|
|
|
pParseNode->replaceNodeValue(pEntryField->GetAlias(),aFieldName);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString sHavingStr = aHavingStr;
|
2004-03-15 11:43:43 +00:00
|
|
|
|
|
|
|
|
|
sal_uInt32 nCount = pParseNode->count();
|
2006-06-20 02:26:39 +00:00
|
|
|
|
for( sal_uInt32 node = 1 ; node < nCount ; ++node)
|
|
|
|
|
pParseNode->getChild(node)->parseNodeToStr( sHavingStr,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2002-02-19 13:04:20 +00:00
|
|
|
|
&rContext,
|
|
|
|
|
sal_False,
|
2002-08-30 10:13:38 +00:00
|
|
|
|
!pEntryField->isOtherFunction());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aHavingStr = sHavingStr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
aHavingStr += aCriteria;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( aWhereStr.isEmpty() ) // noch keine Kriterien
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aWhereStr += ::rtl::OUString('('); // Klammern
|
|
|
|
|
else
|
|
|
|
|
aWhereStr += C_AND;
|
|
|
|
|
|
|
|
|
|
aWhereStr += ::rtl::OUString(' ');
|
|
|
|
|
// aCriteria could have some german numbers so I have to be sure here
|
|
|
|
|
::rtl::OUString aTmp = aCriteria;
|
|
|
|
|
::rtl::OUString aErrorMsg;
|
|
|
|
|
Reference<XPropertySet> xColumn;
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::std::auto_ptr< ::connectivity::OSQLParseNode> pParseNode( _pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn));
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if (pParseNode.get())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if (bMulti && !(pEntryField->isOtherFunction() || (aFieldName.toChar() == '*')))
|
2002-06-27 07:21:18 +00:00
|
|
|
|
pParseNode->replaceNodeValue(pEntryField->GetAlias(),aFieldName);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString aWhere = aWhereStr;
|
|
|
|
|
pParseNode->parseNodeToStr( aWhere,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
&rContext,
|
|
|
|
|
sal_False,
|
2002-08-30 10:13:38 +00:00
|
|
|
|
!pEntryField->isOtherFunction() );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aWhereStr = aWhere;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aWhereStr += aWork;
|
2004-03-02 11:46:44 +00:00
|
|
|
|
aWhereStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("="));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aWhereStr += aCriteria;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-12-19 18:10:37 -02:00
|
|
|
|
// nur einmal f<>r jedes Feld
|
2002-08-30 10:13:38 +00:00
|
|
|
|
else if ( !i && pEntryField->isCondition() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if (aWhereStr.isEmpty()) // noch keine Kriterien
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aWhereStr += ::rtl::OUString('('); // Klammern
|
|
|
|
|
else
|
|
|
|
|
aWhereStr += C_AND;
|
|
|
|
|
aWhereStr += pEntryField->GetField();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if (!aWhereStr.isEmpty())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
aWhereStr += ::rtl::OUString(')'); // Klammern zu fuer 'AND' Zweig
|
|
|
|
|
if (rRetStr.getLength()) // schon Feldbedingungen ?
|
2009-07-03 12:24:35 +00:00
|
|
|
|
rRetStr.append(C_OR);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else // Klammern auf fuer 'OR' Zweig
|
2009-07-03 12:24:35 +00:00
|
|
|
|
rRetStr.append(sal_Unicode('('));
|
|
|
|
|
rRetStr.append(aWhereStr);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if (!aHavingStr.isEmpty())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
aHavingStr += ::rtl::OUString(')'); // Klammern zu fuer 'AND' Zweig
|
|
|
|
|
if (rHavingStr.getLength()) // schon Feldbedingungen ?
|
2009-07-03 12:24:35 +00:00
|
|
|
|
rHavingStr.append(C_OR);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else // Klammern auf fuer 'OR' Zweig
|
2009-07-03 12:24:35 +00:00
|
|
|
|
rHavingStr.append(sal_Unicode('('));
|
|
|
|
|
rHavingStr.append(aHavingStr);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (rRetStr.getLength())
|
2009-07-03 12:24:35 +00:00
|
|
|
|
rRetStr.append(sal_Unicode(')')); // Klammern zu fuer 'OR' Zweig
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (rHavingStr.getLength())
|
2009-07-03 12:24:35 +00:00
|
|
|
|
rHavingStr.append(sal_Unicode(')')); // Klammern zu fuer 'OR' Zweig
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
catch(SQLException&)
|
|
|
|
|
{
|
2011-03-12 13:57:34 +01:00
|
|
|
|
OSL_FAIL("Failure while building where clause!");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
return sal_True;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GenerateOrder( OQueryDesignView* _pView,
|
|
|
|
|
OTableFields& _rFieldList,
|
|
|
|
|
sal_Bool bMulti,
|
|
|
|
|
::rtl::OUString& _rsRet)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
const OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( !xConnection.is() )
|
|
|
|
|
return eNoConnection;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
|
|
|
|
|
|
|
|
|
::rtl::OUString aColumnName;
|
2002-08-30 10:13:38 +00:00
|
|
|
|
::rtl::OUString aWorkStr;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
try
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
const bool bColumnAliasInOrderBy = rController.getSdbMetaData().supportsColumnAliasInOrderBy();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
|
|
|
|
|
// * darf keine Filter enthalten : habe ich die entsprechende Warnung schon angezeigt ?
|
|
|
|
|
sal_Bool bCritsOnAsterikWarning = sal_False; // ** TMFS **
|
|
|
|
|
OTableFields::iterator aIter = _rFieldList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OTableFields::iterator aEnd = _rFieldList.end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFieldDescRef pEntryField = *aIter;
|
|
|
|
|
EOrderDir eOrder = pEntryField->GetOrderDir();
|
2001-12-10 10:04:08 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// nur wenn eine Sortierung und ein Tabellenname vorhanden ist-> erzeugen
|
|
|
|
|
// sonst werden die Expressions vom Order By im GenerateCriteria mit erzeugt
|
2005-03-10 15:52:55 +00:00
|
|
|
|
if ( eOrder != ORDER_NONE )
|
2001-12-10 10:04:08 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aColumnName = pEntryField->GetField();
|
|
|
|
|
if(aColumnName.toChar() == '*')
|
|
|
|
|
{
|
|
|
|
|
// die entsprechende MessageBox nur beim ersten mal anzeigen
|
|
|
|
|
if (!bCritsOnAsterikWarning)
|
|
|
|
|
ErrorBox(_pView, ModuleRes( ERR_QRY_ORDERBY_ON_ASTERISK)).Execute();
|
|
|
|
|
bCritsOnAsterikWarning = sal_True;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2002-08-30 10:13:38 +00:00
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( bColumnAliasInOrderBy && !pEntryField->GetFieldAlias().isEmpty() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aWorkStr += ::dbtools::quoteName(aQuote, pEntryField->GetFieldAlias());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2002-08-30 10:13:38 +00:00
|
|
|
|
else if ( pEntryField->isNumericOrAggreateFunction() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
OSL_ENSURE(!pEntryField->GetFunction().isEmpty(),"Functionname darf hier nicht leer sein! ;-(");
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aWorkStr += pEntryField->GetFunction();
|
|
|
|
|
aWorkStr += ::rtl::OUString('(');
|
|
|
|
|
aWorkStr += quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
|
|
|
|
|
// only quote column name when we don't have a numeric
|
|
|
|
|
if ( pEntryField->isNumeric() )
|
|
|
|
|
aWorkStr += aColumnName;
|
|
|
|
|
else
|
|
|
|
|
aWorkStr += ::dbtools::quoteName(aQuote, aColumnName);
|
|
|
|
|
|
|
|
|
|
aWorkStr += ::rtl::OUString(')');
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2006-10-18 12:32:24 +00:00
|
|
|
|
else if ( pEntryField->isOtherFunction() )
|
|
|
|
|
{
|
|
|
|
|
aWorkStr += aColumnName;
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aWorkStr += quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
|
|
|
|
|
aWorkStr += ::dbtools::quoteName(aQuote, aColumnName);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2012-07-02 16:02:38 +01:00
|
|
|
|
aWorkStr += rtl::OUString(' ');
|
|
|
|
|
aWorkStr += rtl::OUString( ";ASC;DESC" ).getToken( (sal_uInt16)eOrder, ';' );
|
|
|
|
|
aWorkStr += rtl::OUString(',');
|
2001-12-10 10:04:08 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
{
|
2012-06-11 13:15:18 +01:00
|
|
|
|
String sTemp(comphelper::string::stripEnd(aWorkStr, ','));
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aWorkStr = sTemp;
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( !aWorkStr.isEmpty() )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
const sal_Int32 nMaxOrder = xMetaData->getMaxColumnsInOrderBy();
|
2002-08-30 10:13:38 +00:00
|
|
|
|
String sToken(aWorkStr);
|
2012-01-02 10:55:27 +00:00
|
|
|
|
if ( nMaxOrder && nMaxOrder < comphelper::string::getTokenCount(sToken, ',') )
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = eStatementTooLong;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2010-11-13 21:19:14 +00:00
|
|
|
|
_rsRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ORDER BY "));
|
2002-05-06 08:45:36 +00:00
|
|
|
|
_rsRet += aWorkStr;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
catch(SQLException&)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2011-03-12 13:57:34 +01:00
|
|
|
|
OSL_FAIL("Failure while building group by!");
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
void GenerateInnerJoinCriterias(const Reference< XConnection>& _xConnection,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString& _rJoinCrit,
|
|
|
|
|
const ::std::vector<OTableConnection*>* _pConnList)
|
2001-10-26 06:57:11 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter = _pConnList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aEnd = _pConnList->end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
const OQueryTableConnection* pEntryConn = static_cast<const OQueryTableConnection*>(*aIter);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
OQueryTableConnectionData* pEntryConnData = static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get());
|
|
|
|
|
if ( pEntryConnData->GetJoinType() == INNER_JOIN && !pEntryConnData->isNatural() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if(!_rJoinCrit.isEmpty())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
_rJoinCrit += C_AND;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
_rJoinCrit += BuildJoinCriteria(_xConnection,pEntryConnData->GetConnLineDataList(),pEntryConnData);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-10-26 06:57:11 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
void searchAndAppendName(const Reference< XConnection>& _xConnection,
|
2002-02-19 13:04:20 +00:00
|
|
|
|
const OQueryTableWindow* _pTableWindow,
|
2008-01-29 16:13:13 +00:00
|
|
|
|
::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess>& _rTableNames,
|
2003-09-04 07:33:37 +00:00
|
|
|
|
::rtl::OUString& _rsTableListStr
|
|
|
|
|
)
|
2002-02-19 13:04:20 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString sTabName(BuildTable(_xConnection,_pTableWindow));
|
2002-02-19 13:04:20 +00:00
|
|
|
|
|
|
|
|
|
if(_rTableNames.find(sTabName) == _rTableNames.end())
|
|
|
|
|
{
|
|
|
|
|
_rTableNames[sTabName] = sal_True;
|
|
|
|
|
_rsTableListStr += sTabName;
|
|
|
|
|
_rsTableListStr += ::rtl::OUString(',');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString GenerateFromClause( const Reference< XConnection>& _xConnection,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const OQueryTableView::OTableWindowMap* pTabList,
|
2003-09-04 07:33:37 +00:00
|
|
|
|
const ::std::vector<OTableConnection*>* pConnList
|
|
|
|
|
)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString aTableListStr;
|
|
|
|
|
// wird gebraucht um sicher zustelllen das eine Tabelle nicht doppelt vorkommt
|
2008-01-29 16:13:13 +00:00
|
|
|
|
::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess> aTableNames;
|
2001-10-11 07:38:14 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// generate outer join clause in from
|
|
|
|
|
if(!pConnList->empty())
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-19 13:04:20 +00:00
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter = pConnList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aEnd = pConnList->end();
|
2010-01-11 13:22:04 +01:00
|
|
|
|
::std::map<OTableWindow*,sal_Int32> aConnectionCount;
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2010-01-11 13:22:04 +01:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
static_cast<OQueryTableConnection*>(*aIter)->SetVisited(sal_False);
|
2012-12-02 16:06:58 +01:00
|
|
|
|
++aConnectionCount[(*aIter)->GetSourceWin()];
|
|
|
|
|
++aConnectionCount[(*aIter)->GetDestWin()];
|
2010-01-11 13:22:04 +01:00
|
|
|
|
}
|
|
|
|
|
::std::multimap<sal_Int32 , OTableWindow*> aMulti;
|
|
|
|
|
::std::map<OTableWindow*,sal_Int32>::iterator aCountIter = aConnectionCount.begin();
|
|
|
|
|
::std::map<OTableWindow*,sal_Int32>::iterator aCountEnd = aConnectionCount.end();
|
|
|
|
|
for(;aCountIter != aCountEnd;++aCountIter)
|
|
|
|
|
{
|
|
|
|
|
aMulti.insert(::std::multimap<sal_Int32 , OTableWindow*>::value_type(aCountIter->second,aCountIter->first));
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2012-05-17 14:00:15 +01:00
|
|
|
|
const sal_Bool bUseEscape = ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_OUTERJOINESCAPE.ascii );
|
2010-01-11 13:22:04 +01:00
|
|
|
|
::std::multimap<sal_Int32 , OTableWindow*>::reverse_iterator aRIter = aMulti.rbegin();
|
|
|
|
|
::std::multimap<sal_Int32 , OTableWindow*>::reverse_iterator aREnd = aMulti.rend();
|
|
|
|
|
for(;aRIter != aREnd;++aRIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2010-01-11 13:22:04 +01:00
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aConIter = aRIter->second->getTableView()->getTableConnections(aRIter->second);
|
|
|
|
|
for(;aConIter != aEnd;++aConIter)
|
2001-10-11 07:38:14 +00:00
|
|
|
|
{
|
2010-01-11 13:22:04 +01:00
|
|
|
|
OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aConIter);
|
|
|
|
|
if(!pEntryConn->IsVisited() && pEntryConn->GetSourceWin() == aRIter->second )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2010-01-11 13:22:04 +01:00
|
|
|
|
::rtl::OUString aJoin;
|
|
|
|
|
GetNextJoin(_xConnection,pEntryConn,static_cast<OQueryTableWindow*>(pEntryConn->GetDestWin()),aJoin);
|
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if(!aJoin.isEmpty())
|
2007-11-01 14:31:21 +00:00
|
|
|
|
{
|
2010-01-11 13:22:04 +01:00
|
|
|
|
// insert tables into table list to avoid double entries
|
|
|
|
|
OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin());
|
|
|
|
|
OQueryTableWindow* pEntryTabTo = static_cast<OQueryTableWindow*>(pEntryConn->GetDestWin());
|
|
|
|
|
|
|
|
|
|
::rtl::OUString sTabName(BuildTable(_xConnection,pEntryTabFrom));
|
|
|
|
|
if(aTableNames.find(sTabName) == aTableNames.end())
|
|
|
|
|
aTableNames[sTabName] = sal_True;
|
|
|
|
|
sTabName = BuildTable(_xConnection,pEntryTabTo);
|
|
|
|
|
if(aTableNames.find(sTabName) == aTableNames.end())
|
|
|
|
|
aTableNames[sTabName] = sal_True;
|
|
|
|
|
|
|
|
|
|
::rtl::OUString aStr;
|
|
|
|
|
switch(static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get())->GetJoinType())
|
|
|
|
|
{
|
|
|
|
|
case LEFT_JOIN:
|
|
|
|
|
case RIGHT_JOIN:
|
|
|
|
|
case FULL_JOIN:
|
|
|
|
|
{
|
|
|
|
|
// create outer join
|
|
|
|
|
if ( bUseEscape )
|
|
|
|
|
aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("{ OJ "));
|
|
|
|
|
aStr += aJoin;
|
|
|
|
|
if ( bUseEscape )
|
|
|
|
|
aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" }"));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2007-11-01 14:31:21 +00:00
|
|
|
|
aStr += aJoin;
|
2010-01-11 13:22:04 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
|
|
|
|
|
aTableListStr += aStr;
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// and now all inner joins
|
2012-12-02 18:31:17 +01:00
|
|
|
|
// these are implemented as
|
|
|
|
|
// "FROM tbl1, tbl2 WHERE tbl1.col1=tlb2.col2"
|
|
|
|
|
// rather than
|
|
|
|
|
// "FROM tbl1 INNER JOIN tbl2 ON tbl1.col1=tlb2.col2"
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aIter = pConnList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aIter);
|
|
|
|
|
if(!pEntryConn->IsVisited())
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
searchAndAppendName(_xConnection,
|
2002-02-19 13:04:20 +00:00
|
|
|
|
static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin()),
|
|
|
|
|
aTableNames,
|
|
|
|
|
aTableListStr);
|
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
searchAndAppendName(_xConnection,
|
2002-02-19 13:04:20 +00:00
|
|
|
|
static_cast<OQueryTableWindow*>(pEntryConn->GetDestWin()),
|
|
|
|
|
aTableNames,
|
|
|
|
|
aTableListStr);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// all tables that haven't a connection to anyone
|
|
|
|
|
OQueryTableView::OTableWindowMap::const_iterator aTabIter = pTabList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OQueryTableView::OTableWindowMap::const_iterator aTabEnd = pTabList->end();
|
|
|
|
|
for(;aTabIter != aTabEnd;++aTabIter)
|
2001-10-11 07:38:14 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const OQueryTableWindow* pEntryTab = static_cast<const OQueryTableWindow*>(aTabIter->second);
|
|
|
|
|
if(!pEntryTab->ExistsAConn())
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
aTableListStr += BuildTable(_xConnection,pEntryTab);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aTableListStr += ::rtl::OUString(',');
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if(!aTableListStr.isEmpty())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aTableListStr = aTableListStr.replaceAt(aTableListStr.getLength()-1,1, ::rtl::OUString() );
|
|
|
|
|
return aTableListStr;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
::rtl::OUString GenerateGroupBy(const OQueryDesignView* _pView,OTableFields& _rFieldList, sal_Bool bMulti )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
|
|
|
|
const Reference< XConnection> xConnection = rController.getConnection();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(!xConnection.is())
|
|
|
|
|
return ::rtl::OUString();
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::std::map< rtl::OUString,bool> aGroupByNames;
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString aGroupByStr;
|
|
|
|
|
try
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFields::iterator aIter = _rFieldList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OTableFields::iterator aEnd = _rFieldList.end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2001-10-11 07:38:14 +00:00
|
|
|
|
OTableFieldDescRef pEntryField = *aIter;
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if ( pEntryField->IsGroupBy() )
|
2001-10-11 07:38:14 +00:00
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
|
OSL_ENSURE(!pEntryField->GetField().isEmpty(),"Kein FieldName vorhanden!;-(");
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::rtl::OUString sGroupByPart = quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
|
2001-10-11 07:38:14 +00:00
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
// only quote the field name when it isn't calculated
|
|
|
|
|
if ( pEntryField->isNoneFunction() )
|
2008-06-25 11:52:59 +00:00
|
|
|
|
{
|
|
|
|
|
sGroupByPart += ::dbtools::quoteName(aQuote, pEntryField->GetField());
|
|
|
|
|
}
|
2002-08-30 10:13:38 +00:00
|
|
|
|
else
|
2007-11-01 14:31:21 +00:00
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aTmp = pEntryField->GetField();
|
|
|
|
|
::rtl::OUString aErrorMsg;
|
|
|
|
|
Reference<XPropertySet> xColumn;
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::std::auto_ptr< ::connectivity::OSQLParseNode> pParseNode(_pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn));
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if (pParseNode.get())
|
2007-11-01 14:31:21 +00:00
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sGroupBy;
|
2010-01-14 12:14:15 +01:00
|
|
|
|
pParseNode->getChild(0)->parseNodeToStr( sGroupBy,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext(),
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_False,
|
|
|
|
|
!pEntryField->isOtherFunction());
|
2008-06-25 11:52:59 +00:00
|
|
|
|
sGroupByPart += sGroupBy;
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2008-06-25 11:52:59 +00:00
|
|
|
|
sGroupByPart += pEntryField->GetField();
|
|
|
|
|
}
|
|
|
|
|
if ( aGroupByNames.find(sGroupByPart) == aGroupByNames.end() )
|
|
|
|
|
{
|
|
|
|
|
aGroupByNames.insert(::std::map< rtl::OUString,bool>::value_type(sGroupByPart,true));
|
|
|
|
|
aGroupByStr += sGroupByPart;
|
|
|
|
|
aGroupByStr += ::rtl::OUString(',');
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( !aGroupByStr.isEmpty() )
|
2001-10-11 07:38:14 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aGroupByStr = aGroupByStr.replaceAt(aGroupByStr.getLength()-1,1, ::rtl::OUString(' ') );
|
2010-11-13 21:19:14 +00:00
|
|
|
|
::rtl::OUString aGroupByStr2(RTL_CONSTASCII_USTRINGPARAM(" GROUP BY "));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aGroupByStr2 += aGroupByStr;
|
|
|
|
|
aGroupByStr = aGroupByStr2;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
catch(SQLException&)
|
|
|
|
|
{
|
2011-03-12 13:57:34 +01:00
|
|
|
|
OSL_FAIL("Failure while building group by!");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
return aGroupByStr;
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetORCriteria(OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
2002-05-06 08:45:36 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_uInt16& nLevel ,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving = sal_False,
|
|
|
|
|
bool bAddOrOnOneLine = false);
|
2002-05-06 08:45:36 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
SqlParseError GetSelectionCriteria( OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pNode,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_uInt16& rLevel )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
if (!SQL_ISRULE(pNode, select_statement))
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eNoSelectStatement;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// nyi: mehr Pruefung auf korrekte Struktur!
|
|
|
|
|
pNode = pNode ? pNode->getChild(3)->getChild(1) : NULL;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
// no where clause found
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (!pNode || pNode->isLeaf())
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eOk;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
// Naechster freier Satz ...
|
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::connectivity::OSQLParseNode * pCondition = pNode->getChild(1);
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( pCondition ) // no where clause
|
2002-02-19 13:04:20 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
// now we have to chech the other conditions
|
|
|
|
|
// first make the logical easier
|
2002-02-19 13:04:20 +00:00
|
|
|
|
::connectivity::OSQLParseNode::negateSearchCondition(pCondition);
|
|
|
|
|
::connectivity::OSQLParseNode *pNodeTmp = pNode->getChild(1);
|
2002-10-07 12:09:48 +00:00
|
|
|
|
|
2002-02-19 13:04:20 +00:00
|
|
|
|
::connectivity::OSQLParseNode::disjunctiveNormalForm(pNodeTmp);
|
|
|
|
|
pNodeTmp = pNode->getChild(1);
|
|
|
|
|
::connectivity::OSQLParseNode::absorptions(pNodeTmp);
|
|
|
|
|
pNodeTmp = pNode->getChild(1);
|
2008-12-01 12:31:27 +00:00
|
|
|
|
// compress sort the criteria @see http://www.openoffice.org/issues/show_bug.cgi?id=24079
|
|
|
|
|
OSQLParseNode::compress(pNodeTmp);
|
|
|
|
|
pNodeTmp = pNode->getChild(1);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-19 13:04:20 +00:00
|
|
|
|
// first extract the inner joins conditions
|
|
|
|
|
GetInnerJoinCriteria(_pView,pNodeTmp);
|
2009-11-11 14:07:55 +01:00
|
|
|
|
// now simplify again, join are checked in ComparisonPredicate
|
|
|
|
|
::connectivity::OSQLParseNode::absorptions(pNodeTmp);
|
2009-11-02 07:24:27 +00:00
|
|
|
|
pNodeTmp = pNode->getChild(1);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-19 13:04:20 +00:00
|
|
|
|
// it could happen that pCondition is not more valid
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pNodeTmp, rLevel);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetANDCriteria( OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2009-11-11 14:07:55 +01:00
|
|
|
|
sal_uInt16& nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving,
|
|
|
|
|
bool bAddOrOnOneLine);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2004-03-15 11:43:43 +00:00
|
|
|
|
SqlParseError ComparisonPredicate(OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
const sal_uInt16 nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving,
|
|
|
|
|
bool bAddOrOnOneLine);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetORCriteria(OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_uInt16& nLevel ,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving,
|
|
|
|
|
bool bAddOrOnOneLine)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
// Runde Klammern um den Ausdruck
|
|
|
|
|
if (pCondition->count() == 3 &&
|
|
|
|
|
SQL_ISPUNCTUATION(pCondition->getChild(0),"(") &&
|
|
|
|
|
SQL_ISPUNCTUATION(pCondition->getChild(2),")"))
|
|
|
|
|
{
|
2007-11-01 14:31:21 +00:00
|
|
|
|
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(1),nLevel,bHaving,bAddOrOnOneLine);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
// oder Verknuepfung
|
|
|
|
|
// a searchcondition can only look like this: search_condition SQL_TOKEN_OR boolean_term
|
|
|
|
|
else if (SQL_ISRULE(pCondition,search_condition))
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
for (int i = 0; i < 3 && eErrorCode == eOk ; i+=2)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-01-30 07:54:21 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode* pChild = pCondition->getChild(i);
|
|
|
|
|
if ( SQL_ISRULE(pChild,search_condition) )
|
|
|
|
|
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pChild,nLevel,bHaving,bAddOrOnOneLine);
|
2001-10-11 07:38:14 +00:00
|
|
|
|
else
|
2009-11-11 14:07:55 +01:00
|
|
|
|
{
|
|
|
|
|
eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, nLevel,bHaving, i == 0 ? false : bAddOrOnOneLine);
|
|
|
|
|
if ( !bAddOrOnOneLine)
|
|
|
|
|
nLevel++;
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else
|
2007-11-01 14:31:21 +00:00
|
|
|
|
eErrorCode = GetANDCriteria( _pView,_pSelectionBrw,pCondition, nLevel, bHaving,bAddOrOnOneLine );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
|
|
|
|
return eErrorCode;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2008-01-30 07:54:21 +00:00
|
|
|
|
bool CheckOrCriteria(const ::connectivity::OSQLParseNode* _pCondition,::connectivity::OSQLParseNode* _pFirstColumnRef)
|
|
|
|
|
{
|
|
|
|
|
bool bRet = true;
|
|
|
|
|
::connectivity::OSQLParseNode* pFirstColumnRef = _pFirstColumnRef;
|
|
|
|
|
for (int i = 0; i < 3 && bRet; i+=2)
|
|
|
|
|
{
|
|
|
|
|
const ::connectivity::OSQLParseNode* pChild = _pCondition->getChild(i);
|
|
|
|
|
if ( SQL_ISRULE(pChild,search_condition) )
|
|
|
|
|
bRet = CheckOrCriteria(pChild,pFirstColumnRef);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// this is a simple way to test columns are the same, may be we have to adjust this algo a little bit in future. :-)
|
|
|
|
|
::connectivity::OSQLParseNode* pSecondColumnRef = pChild->getByRule(::connectivity::OSQLParseNode::column_ref);
|
|
|
|
|
if ( pFirstColumnRef && pSecondColumnRef )
|
|
|
|
|
bRet = *pFirstColumnRef == *pSecondColumnRef;
|
|
|
|
|
else if ( !pFirstColumnRef )
|
|
|
|
|
pFirstColumnRef = pSecondColumnRef;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetANDCriteria( OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2009-11-11 14:07:55 +01:00
|
|
|
|
sal_uInt16& nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving,
|
|
|
|
|
bool bAddOrOnOneLine)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
const ::com::sun::star::lang::Locale aLocale = _pView->getLocale();
|
|
|
|
|
const ::rtl::OUString sDecimal = _pView->getDecimalSeparator();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// ich werde ein paar Mal einen gecasteten Pointer auf meinen ::com::sun::star::sdbcx::Container brauchen
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// Runde Klammern
|
|
|
|
|
if (SQL_ISRULE(pCondition,boolean_primary))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-01-30 07:54:21 +00:00
|
|
|
|
// check if we have to put the or criteria on one line.
|
2009-11-11 14:07:55 +01:00
|
|
|
|
const ::connectivity::OSQLParseNode* pSearchCondition = pCondition->getChild(1);
|
|
|
|
|
bool bMustAddOrOnOneLine = CheckOrCriteria(pSearchCondition,NULL);
|
|
|
|
|
if ( SQL_ISRULE( pSearchCondition, search_condition) ) // we have a or
|
|
|
|
|
{
|
|
|
|
|
_pSelectionBrw->DuplicateConditionLevel( nLevel);
|
|
|
|
|
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(0), nLevel,bHaving,bMustAddOrOnOneLine );
|
|
|
|
|
++nLevel;
|
|
|
|
|
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(2), nLevel,bHaving,bMustAddOrOnOneLine );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition, nLevel,bHaving,bMustAddOrOnOneLine );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
// Das erste Element ist (wieder) eine AND-Verknuepfung
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
|
else if ( SQL_ISRULE(pCondition,boolean_term) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
|
OSL_ENSURE(pCondition->count() == 3,"Illegal definifiton of boolean_term");
|
2007-11-01 14:31:21 +00:00
|
|
|
|
eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pCondition->getChild(0), nLevel,bHaving,bAddOrOnOneLine );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( eErrorCode == eOk )
|
2007-11-01 14:31:21 +00:00
|
|
|
|
eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pCondition->getChild(2), nLevel,bHaving,bAddOrOnOneLine );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
else if (SQL_ISRULE( pCondition, comparison_predicate))
|
|
|
|
|
{
|
2007-11-01 14:31:21 +00:00
|
|
|
|
eErrorCode = ComparisonPredicate(_pView,_pSelectionBrw,pCondition,nLevel,bHaving,bAddOrOnOneLine);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
else if( SQL_ISRULE(pCondition,like_predicate) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2007-11-01 14:31:21 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode* pValueExp = pCondition->getChild(0);
|
|
|
|
|
if (SQL_ISRULE(pValueExp, column_ref ) )
|
2001-10-11 07:38:14 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString aColumnName;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString aCondition;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2002-04-09 14:30:33 +00:00
|
|
|
|
if ( xConnection.is() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
// the international doesn't matter I have a string
|
|
|
|
|
pCondition->parseNodeToPredicateStr(aCondition,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.getNumberFormatter(),
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aLocale,
|
|
|
|
|
static_cast<sal_Char>(sDecimal.toChar()),
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2007-11-01 14:31:21 +00:00
|
|
|
|
pValueExp->parseNodeToPredicateStr( aColumnName,
|
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.getNumberFormatter(),
|
2007-11-01 14:31:21 +00:00
|
|
|
|
aLocale,
|
|
|
|
|
static_cast<sal_Char>(sDecimal.toChar()),
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
// don't display the column name
|
|
|
|
|
aCondition = aCondition.copy(aColumnName.getLength());
|
|
|
|
|
aCondition = aCondition.trim();
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( eOk == ( eErrorCode = FillDragInfo(_pView,pValueExp,aDragLeft) ))
|
2008-06-06 13:13:08 +00:00
|
|
|
|
{
|
|
|
|
|
if ( bHaving )
|
|
|
|
|
aDragLeft->SetGroupBy(sal_True);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
_pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
|
2008-06-06 13:13:08 +00:00
|
|
|
|
}
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
2011-10-30 13:34:01 +01:00
|
|
|
|
else if(SQL_ISRULEOR3(pValueExp, general_set_fct, set_fct_spec, position_exp) ||
|
|
|
|
|
SQL_ISRULEOR3(pValueExp, extract_exp, fold, char_substring_fct) ||
|
|
|
|
|
SQL_ISRULEOR2(pValueExp, length_exp, char_value_fct))
|
2007-11-01 14:31:21 +00:00
|
|
|
|
{
|
|
|
|
|
AddFunctionCondition( _pView,
|
|
|
|
|
_pSelectionBrw,
|
|
|
|
|
pCondition,
|
|
|
|
|
nLevel,
|
|
|
|
|
bHaving,
|
|
|
|
|
bAddOrOnOneLine);
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = eNoColumnInLike;
|
|
|
|
|
String sError(ModuleRes(STR_QRY_LIKE_LEFT_NO_COLUMN));
|
2008-12-01 12:31:27 +00:00
|
|
|
|
_pView->getController().appendError( sError );
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-19 13:04:20 +00:00
|
|
|
|
else if( SQL_ISRULEOR2(pCondition,test_for_null,in_predicate)
|
|
|
|
|
|| SQL_ISRULEOR2(pCondition,all_or_any_predicate,between_predicate))
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2004-03-15 11:43:43 +00:00
|
|
|
|
if ( SQL_ISRULEOR2(pCondition->getChild(0), set_fct_spec , general_set_fct ) )
|
|
|
|
|
{
|
|
|
|
|
AddFunctionCondition( _pView,
|
|
|
|
|
_pSelectionBrw,
|
|
|
|
|
pCondition,
|
|
|
|
|
nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
bHaving,
|
|
|
|
|
bAddOrOnOneLine);
|
2004-03-15 11:43:43 +00:00
|
|
|
|
}
|
|
|
|
|
else if ( SQL_ISRULE(pCondition->getChild(0), column_ref ) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
// parse condition
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::rtl::OUString sCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,1);
|
2004-03-15 11:43:43 +00:00
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
|
|
|
|
if ( eOk == ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(0),aDragLeft)) )
|
2008-06-06 13:13:08 +00:00
|
|
|
|
{
|
|
|
|
|
if ( bHaving )
|
|
|
|
|
aDragLeft->SetGroupBy(sal_True);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
_pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine);
|
2008-06-06 13:13:08 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2009-11-11 14:07:55 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Funktions-Bedingung parsen
|
|
|
|
|
::rtl::OUString sCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,1);
|
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
|
|
|
|
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
// the international doesn't matter I have a string
|
|
|
|
|
::rtl::OUString sName;
|
|
|
|
|
pCondition->getChild(0)->parseNodeToPredicateStr(sName,
|
|
|
|
|
xConnection,
|
|
|
|
|
rController.getNumberFormatter(),
|
|
|
|
|
aLocale,
|
|
|
|
|
static_cast<sal_Char>(sDecimal.toChar()),
|
|
|
|
|
&rController.getParser().getContext());
|
|
|
|
|
|
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
|
|
|
|
aDragLeft->SetField(sName);
|
|
|
|
|
aDragLeft->SetFunctionType(FKT_OTHER);
|
|
|
|
|
|
|
|
|
|
if ( bHaving )
|
|
|
|
|
aDragLeft->SetGroupBy(sal_True);
|
|
|
|
|
_pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine);
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-19 13:04:20 +00:00
|
|
|
|
else if( SQL_ISRULEOR2(pCondition,existence_test,unique_test) )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// Funktions-Bedingung parsen
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::rtl::OUString aCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,0);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2004-03-15 11:43:43 +00:00
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aDragLeft->SetField(aCondition);
|
|
|
|
|
aDragLeft->SetFunctionType(FKT_CONDITION);
|
|
|
|
|
|
2010-10-15 12:22:54 -05:00
|
|
|
|
eErrorCode = _pSelectionBrw->InsertField(aDragLeft,BROWSER_INVALIDID,sal_False,sal_True).is() ? eOk : eTooManyColumns;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
else //! TODO not supported yet
|
|
|
|
|
eErrorCode = eStatementTooComplex;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// Fehler einfach weiterreichen.
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2004-03-15 11:43:43 +00:00
|
|
|
|
SqlParseError AddFunctionCondition(OQueryDesignView* _pView,
|
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
const sal_uInt16 nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving,
|
|
|
|
|
bool bAddOrOnOneLine)
|
2004-03-15 11:43:43 +00:00
|
|
|
|
{
|
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
2004-03-15 11:43:43 +00:00
|
|
|
|
|
|
|
|
|
OSQLParseNode* pFunction = pCondition->getChild(0);
|
|
|
|
|
|
2011-10-30 13:34:01 +01:00
|
|
|
|
OSL_ENSURE(SQL_ISRULEOR3(pFunction, general_set_fct, set_fct_spec, position_exp) ||
|
|
|
|
|
SQL_ISRULEOR3(pFunction, extract_exp, fold, char_substring_fct) ||
|
|
|
|
|
SQL_ISRULEOR2(pFunction,length_exp,char_value_fct),
|
|
|
|
|
"Illegal call!");
|
2007-11-01 14:31:21 +00:00
|
|
|
|
::rtl::OUString aCondition;
|
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
|
|
|
|
|
2004-03-15 11:43:43 +00:00
|
|
|
|
::rtl::OUString aColumnName;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2004-03-15 11:43:43 +00:00
|
|
|
|
if(xConnection.is())
|
|
|
|
|
{
|
|
|
|
|
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
pCondition->parseNodeToPredicateStr(aCondition,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.getNumberFormatter(),
|
2004-03-15 11:43:43 +00:00
|
|
|
|
_pView->getLocale(),
|
|
|
|
|
static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2004-03-15 11:43:43 +00:00
|
|
|
|
|
2007-11-01 14:31:21 +00:00
|
|
|
|
pFunction->parseNodeToStr( aColumnName,
|
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext(),
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_True,
|
|
|
|
|
sal_True); // quote is to true because we need quoted elements inside the function
|
2004-03-15 11:43:43 +00:00
|
|
|
|
// don't display the column name
|
|
|
|
|
aCondition = aCondition.copy(aColumnName.getLength());
|
|
|
|
|
aCondition = aCondition.trim();
|
|
|
|
|
if ( aCondition.indexOf('=',0) == 0 ) // ignore the equal sign
|
|
|
|
|
aCondition = aCondition.copy(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( SQL_ISRULE(pFunction, general_set_fct ) )
|
|
|
|
|
{
|
|
|
|
|
sal_Int32 nFunctionType = FKT_AGGREGATE;
|
|
|
|
|
OSQLParseNode* pParamNode = pFunction->getChild(pFunction->count()-2);
|
|
|
|
|
if ( pParamNode && pParamNode->getTokenValue().toChar() == '*' )
|
|
|
|
|
{
|
|
|
|
|
OJoinTableView::OTableWindowMap* pTabList = _pView->getTableView()->GetTabWinMap();
|
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aTabEnd = pTabList->end();
|
|
|
|
|
for(;aIter != aTabEnd;++aIter)
|
2004-03-15 11:43:43 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second);
|
2010-11-13 21:19:14 +00:00
|
|
|
|
if (pTabWin->ExistsField( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), aDragLeft ))
|
2004-03-15 11:43:43 +00:00
|
|
|
|
{
|
|
|
|
|
aDragLeft->SetAlias(String());
|
|
|
|
|
aDragLeft->SetTable(String());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( eOk != ( eErrorCode = FillDragInfo(_pView,pParamNode,aDragLeft))
|
|
|
|
|
&& SQL_ISRULE(pParamNode,num_value_exp) )
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sParameterValue;
|
|
|
|
|
pParamNode->parseNodeToStr( sParameterValue,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2004-03-15 11:43:43 +00:00
|
|
|
|
nFunctionType |= FKT_NUMERIC;
|
|
|
|
|
aDragLeft->SetField(sParameterValue);
|
|
|
|
|
eErrorCode = eOk;
|
|
|
|
|
}
|
|
|
|
|
aDragLeft->SetFunctionType(nFunctionType);
|
|
|
|
|
if ( bHaving )
|
|
|
|
|
aDragLeft->SetGroupBy(sal_True);
|
|
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
|
aDragLeft->SetFunction(aColumnName.getToken(0,'(',nIndex));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// bei unbekannten Funktionen wird der gesamte Text in das Field gechrieben
|
|
|
|
|
aDragLeft->SetField(aColumnName);
|
|
|
|
|
if(bHaving)
|
|
|
|
|
aDragLeft->SetGroupBy(sal_True);
|
|
|
|
|
aDragLeft->SetFunctionType(FKT_OTHER|FKT_NUMERIC);
|
|
|
|
|
}
|
2007-11-01 14:31:21 +00:00
|
|
|
|
_pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
|
2004-03-15 11:43:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return eErrorCode;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
SqlParseError ComparisonPredicate(OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode * pCondition,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
const sal_uInt16 nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_Bool bHaving
|
|
|
|
|
,bool bAddOrOnOneLine)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2011-02-03 00:33:36 +01:00
|
|
|
|
OSL_ENSURE(SQL_ISRULE( pCondition, comparison_predicate),"ComparisonPredicate: pCondition ist kein ComparisonPredicate");
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( SQL_ISRULE(pCondition->getChild(0), column_ref )
|
|
|
|
|
|| SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aCondition;
|
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
|
|
|
|
if ( SQL_ISRULE(pCondition->getChild(0), column_ref ) && SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref ) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OTableFieldDescRef aDragRight = new OTableFieldDesc();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if (eOk != ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(0),aDragLeft)) ||
|
|
|
|
|
eOk != ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(2),aDragRight)))
|
|
|
|
|
return eErrorCode;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2007-11-01 14:31:21 +00:00
|
|
|
|
OQueryTableConnection* pConn = static_cast<OQueryTableConnection*>(
|
|
|
|
|
_pView->getTableView()->GetTabConn(static_cast<OQueryTableWindow*>(aDragLeft->GetTabWindow()),
|
|
|
|
|
static_cast<OQueryTableWindow*>(aDragRight->GetTabWindow()),
|
|
|
|
|
true));
|
|
|
|
|
if ( pConn )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
OConnectionLineDataVec* pLineDataList = pConn->GetData()->GetConnLineDataList();
|
|
|
|
|
OConnectionLineDataVec::iterator aIter = pLineDataList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OConnectionLineDataVec::iterator aEnd = pLineDataList->end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
if((*aIter)->GetSourceFieldName() == aDragLeft->GetField() ||
|
|
|
|
|
(*aIter)->GetDestFieldName() == aDragLeft->GetField() )
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
|
if(aIter != aEnd)
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eOk;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2004-02-04 12:55:13 +00:00
|
|
|
|
sal_uInt32 nPos = 0;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(SQL_ISRULE(pCondition->getChild(0), column_ref ))
|
|
|
|
|
{
|
|
|
|
|
nPos = 0;
|
|
|
|
|
sal_uInt32 i=1;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// don't display the equal
|
|
|
|
|
if (pCondition->getChild(i)->getNodeType() == SQL_NODE_EQUAL)
|
|
|
|
|
i++;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// Bedingung parsen
|
2008-06-25 11:52:59 +00:00
|
|
|
|
aCondition = ParseCondition(rController
|
2004-03-15 11:43:43 +00:00
|
|
|
|
,pCondition
|
|
|
|
|
,_pView->getDecimalSeparator()
|
|
|
|
|
,_pView->getLocale()
|
|
|
|
|
,i);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
else if( SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref ) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
nPos = pCondition->count()-1;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2004-03-02 11:46:44 +00:00
|
|
|
|
sal_Int32 i = static_cast<sal_Int32>(pCondition->count() - 2);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
switch (pCondition->getChild(i)->getNodeType())
|
|
|
|
|
{
|
|
|
|
|
case SQL_NODE_EQUAL:
|
|
|
|
|
// don't display the equal
|
|
|
|
|
i--;
|
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_LESS:
|
|
|
|
|
// take the opposite as we change the order
|
|
|
|
|
i--;
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">"));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_LESSEQ:
|
|
|
|
|
// take the opposite as we change the order
|
|
|
|
|
i--;
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">="));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_GREAT:
|
|
|
|
|
// take the opposite as we change the order
|
|
|
|
|
i--;
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<"));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_GREATEQ:
|
|
|
|
|
// take the opposite as we change the order
|
|
|
|
|
i--;
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<="));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
break;
|
2006-06-20 02:26:39 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// go backward
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(xConnection.is())
|
|
|
|
|
{
|
|
|
|
|
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
for (; i >= 0; i--)
|
|
|
|
|
pCondition->getChild(i)->parseNodeToPredicateStr(aCondition,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.getNumberFormatter(),
|
2002-02-06 07:08:30 +00:00
|
|
|
|
_pView->getLocale(),
|
|
|
|
|
static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2004-02-04 12:55:13 +00:00
|
|
|
|
// else ???
|
|
|
|
|
|
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if( eOk == ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(nPos),aDragLeft)))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(bHaving)
|
|
|
|
|
aDragLeft->SetGroupBy(sal_True);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
_pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-19 13:04:20 +00:00
|
|
|
|
else if( SQL_ISRULEOR2(pCondition->getChild(0), set_fct_spec , general_set_fct ) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2004-03-15 11:43:43 +00:00
|
|
|
|
AddFunctionCondition( _pView,
|
|
|
|
|
_pSelectionBrw,
|
|
|
|
|
pCondition,
|
|
|
|
|
nLevel,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
bHaving,
|
|
|
|
|
bAddOrOnOneLine);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else // kann sich nur um einen Expr. Ausdruck handeln
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::rtl::OUString aName,aCondition;
|
|
|
|
|
|
|
|
|
|
::connectivity::OSQLParseNode *pLhs = pCondition->getChild(0);
|
|
|
|
|
::connectivity::OSQLParseNode *pRhs = pCondition->getChild(2);
|
|
|
|
|
// Feldnamen
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2001-06-28 13:22:47 +00:00
|
|
|
|
if(xConnection.is())
|
|
|
|
|
{
|
2004-03-15 11:43:43 +00:00
|
|
|
|
pLhs->parseNodeToStr(aName,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext(),
|
2006-12-13 15:53:22 +00:00
|
|
|
|
sal_True);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// Kriterium
|
|
|
|
|
aCondition = pCondition->getChild(1)->getTokenValue();
|
2004-03-15 11:43:43 +00:00
|
|
|
|
pRhs->parseNodeToPredicateStr(aCondition,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.getNumberFormatter(),
|
2004-03-15 11:43:43 +00:00
|
|
|
|
_pView->getLocale(),
|
|
|
|
|
static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2001-06-28 13:22:47 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aDragLeft->SetField(aName);
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aDragLeft->SetFunctionType(FKT_OTHER|FKT_NUMERIC);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// und anh"angen
|
2007-11-01 14:31:21 +00:00
|
|
|
|
_pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* lcl_findColumnInTables( const ::rtl::OUString& _rColumName, const OJoinTableView::OTableWindowMap& _rTabList, OTableFieldDescRef& _rInfo )
|
|
|
|
|
{
|
|
|
|
|
OJoinTableView::OTableWindowMap::const_iterator aIter = _rTabList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap::const_iterator aEnd = _rTabList.end();
|
|
|
|
|
for ( ; aIter != aEnd; ++aIter )
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* pTabWin = static_cast< OQueryTableWindow* >( aIter->second );
|
|
|
|
|
if ( pTabWin && pTabWin->ExistsField( _rColumName, _rInfo ) )
|
|
|
|
|
return pTabWin;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
void InsertColumnRef(const OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode * pColumnRef,
|
|
|
|
|
::rtl::OUString& aColumnName,
|
|
|
|
|
const ::rtl::OUString& aColumnAlias,
|
|
|
|
|
::rtl::OUString& aTableRange,
|
|
|
|
|
OTableFieldDescRef& _raInfo,
|
|
|
|
|
OJoinTableView::OTableWindowMap* pTabList)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// Tabellennamen zusammen setzen
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::connectivity::OSQLParseTreeIterator& rParseIter = static_cast<OQueryController&>(_pView->getController()).getParseIterator();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
rParseIter.getColumnRange( pColumnRef, aColumnName, aTableRange );
|
|
|
|
|
|
2002-02-19 13:04:20 +00:00
|
|
|
|
sal_Bool bFound(sal_False);
|
2011-12-19 18:10:37 -02:00
|
|
|
|
OSL_ENSURE(!aColumnName.isEmpty(),"Columnname darf nicht leer sein");
|
|
|
|
|
if (aTableRange.isEmpty())
|
2001-06-28 13:22:47 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// SELECT column, ...
|
2006-07-10 14:41:12 +00:00
|
|
|
|
bFound = NULL != lcl_findColumnInTables( aColumnName, *pTabList, _raInfo );
|
|
|
|
|
if ( bFound && ( aColumnName.toChar() != '*' ) )
|
|
|
|
|
_raInfo->SetFieldAlias(aColumnAlias);
|
2001-06-28 13:22:47 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// SELECT range.column, ...
|
|
|
|
|
OQueryTableWindow* pTabWin = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable(aTableRange);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (pTabWin && pTabWin->ExistsField(aColumnName, _raInfo))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(aColumnName.toChar() != '*')
|
|
|
|
|
_raInfo->SetFieldAlias(aColumnAlias);
|
2002-02-19 13:04:20 +00:00
|
|
|
|
bFound = sal_True;
|
2002-09-20 09:25:38 +00:00
|
|
|
|
}
|
2002-02-19 13:04:20 +00:00
|
|
|
|
}
|
|
|
|
|
if (!bFound)
|
|
|
|
|
{
|
|
|
|
|
_raInfo->SetTable(::rtl::OUString());
|
|
|
|
|
_raInfo->SetAlias(::rtl::OUString());
|
|
|
|
|
_raInfo->SetField(aColumnName);
|
|
|
|
|
_raInfo->SetFieldAlias(aColumnAlias); // nyi : hier ein fortlaufendes Expr_1, Expr_2 ...
|
|
|
|
|
_raInfo->SetFunctionType(FKT_OTHER);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2002-02-19 13:04:20 +00:00
|
|
|
|
sal_Bool checkJoinConditions( const OQueryDesignView* _pView,
|
|
|
|
|
const ::connectivity::OSQLParseNode* _pNode )
|
|
|
|
|
{
|
|
|
|
|
const ::connectivity::OSQLParseNode* pJoinNode = NULL;
|
|
|
|
|
sal_Bool bRet = sal_True;
|
|
|
|
|
if (SQL_ISRULE(_pNode,qualified_join))
|
|
|
|
|
pJoinNode = _pNode;
|
2008-11-19 17:43:08 +00:00
|
|
|
|
else if (SQL_ISRULE(_pNode,table_ref)
|
|
|
|
|
&& _pNode->count() == 3
|
|
|
|
|
&& SQL_ISPUNCTUATION(_pNode->getChild(0),"(")
|
|
|
|
|
&& SQL_ISPUNCTUATION(_pNode->getChild(2),")") ) // '(' joined_table ')'
|
|
|
|
|
pJoinNode = _pNode->getChild(1);
|
2008-06-16 11:33:33 +00:00
|
|
|
|
else if (! ( SQL_ISRULE(_pNode, table_ref) && _pNode->count() == 2) ) // table_node table_primary_as_range_column
|
2002-02-19 13:04:20 +00:00
|
|
|
|
bRet = sal_False;
|
|
|
|
|
|
|
|
|
|
if (pJoinNode && !InsertJoin(_pView,pJoinNode))
|
|
|
|
|
bRet = sal_False;
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
sal_Bool InsertJoin(const OQueryDesignView* _pView,
|
|
|
|
|
const ::connectivity::OSQLParseNode *pNode)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-02-03 00:33:36 +01:00
|
|
|
|
OSL_ENSURE( SQL_ISRULE( pNode, qualified_join ) || SQL_ISRULE( pNode, joined_table ) || SQL_ISRULE( pNode, cross_union ),
|
2002-02-06 07:08:30 +00:00
|
|
|
|
"OQueryDesignView::InsertJoin: Fehler im Parse Tree");
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2008-07-25 06:52:25 +00:00
|
|
|
|
if (SQL_ISRULE(pNode,joined_table))
|
|
|
|
|
return InsertJoin(_pView,pNode->getChild(1));
|
|
|
|
|
|
2002-02-19 13:04:20 +00:00
|
|
|
|
// first check the left and right side
|
2008-06-16 11:33:33 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode* pRightTableRef = pNode->getChild(3); // table_ref
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( SQL_ISRULE(pNode, qualified_join) && SQL_ISTOKEN(pNode->getChild(1),NATURAL) )
|
|
|
|
|
pRightTableRef = pNode->getChild(4); // table_ref
|
|
|
|
|
|
|
|
|
|
if ( !checkJoinConditions(_pView,pNode->getChild(0)) || !checkJoinConditions(_pView,pRightTableRef))
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return sal_False;
|
2001-09-27 05:19:05 +00:00
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
// named column join wird sp<73>ter vieleicht noch implementiert
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// SQL_ISRULE(pNode->getChild(4),named_columns_join)
|
2007-11-01 14:31:21 +00:00
|
|
|
|
EJoinType eJoinType = INNER_JOIN;
|
|
|
|
|
bool bNatural = false;
|
|
|
|
|
if ( SQL_ISRULE(pNode, qualified_join) )
|
2001-06-28 13:22:47 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::connectivity::OSQLParseNode* pJoinType = pNode->getChild(1); // join_type
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( SQL_ISTOKEN(pJoinType,NATURAL) )
|
|
|
|
|
{
|
|
|
|
|
bNatural = true;
|
|
|
|
|
pJoinType = pNode->getChild(2);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-15 12:38:17 +01:00
|
|
|
|
if (SQL_ISRULE(pJoinType,join_type) && (!pJoinType->count() || SQL_ISTOKEN(pJoinType->getChild(0),INNER)))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
eJoinType = INNER_JOIN;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2001-09-27 05:19:05 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (SQL_ISRULE(pJoinType,join_type)) // eine Ebene tiefer
|
|
|
|
|
pJoinType = pJoinType->getChild(0);
|
2001-10-11 07:38:14 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (SQL_ISTOKEN(pJoinType->getChild(0),LEFT))
|
|
|
|
|
eJoinType = LEFT_JOIN;
|
|
|
|
|
else if(SQL_ISTOKEN(pJoinType->getChild(0),RIGHT))
|
|
|
|
|
eJoinType = RIGHT_JOIN;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
else
|
2002-02-06 07:08:30 +00:00
|
|
|
|
eJoinType = FULL_JOIN;
|
|
|
|
|
}
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( SQL_ISRULE(pNode->getChild(4),join_condition) )
|
|
|
|
|
{
|
2010-01-11 13:22:04 +01:00
|
|
|
|
if ( InsertJoinConnection(_pView,pNode->getChild(4)->getChild(1), eJoinType,pNode->getChild(0),pRightTableRef) != eOk )
|
2007-11-01 14:31:21 +00:00
|
|
|
|
return sal_False;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ( SQL_ISRULE(pNode, cross_union) )
|
|
|
|
|
{
|
|
|
|
|
eJoinType = CROSS_JOIN;
|
|
|
|
|
pRightTableRef = pNode->getChild(pNode->count() - 1);
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
else
|
|
|
|
|
return sal_False;
|
|
|
|
|
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( eJoinType == CROSS_JOIN || bNatural )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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 sal_False;
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
insertConnection(_pView,eJoinType,aDragLeft,aDragRight,bNatural);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-02-05 08:35:57 +00:00
|
|
|
|
return sal_True;
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-30 10:13:38 +00:00
|
|
|
|
void insertUnUsedFields(OQueryDesignView* _pView,OSelectionBrowseBox* _pSelectionBrw)
|
|
|
|
|
{
|
|
|
|
|
// now we have to insert the fields which aren't in the statement
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
|
|
|
|
OTableFields& rUnUsedFields = rController.getUnUsedFields();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OTableFields::iterator aEnd = rUnUsedFields.end();
|
|
|
|
|
for(OTableFields::iterator aIter = rUnUsedFields.begin();aIter != aEnd;++aIter)
|
2010-10-15 12:22:54 -05:00
|
|
|
|
if(_pSelectionBrw->InsertField(*aIter,BROWSER_INVALIDID,sal_False,sal_False).is())
|
2002-08-30 10:13:38 +00:00
|
|
|
|
(*aIter) = NULL;
|
|
|
|
|
OTableFields().swap( rUnUsedFields );
|
|
|
|
|
}
|
2010-02-16 15:21:07 +01:00
|
|
|
|
|
2002-08-30 10:13:38 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError InitFromParseNodeImpl(OQueryDesignView* _pView,OSelectionBrowseBox* _pSelectionBrw)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
_pSelectionBrw->PreFill();
|
2008-06-25 11:52:59 +00:00
|
|
|
|
_pSelectionBrw->SetReadOnly(rController.isReadOnly());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
_pSelectionBrw->Fill();
|
2001-02-05 15:17:40 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::connectivity::OSQLParseTreeIterator& aIterator = rController.getParseIterator();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
const ::connectivity::OSQLParseNode* pParseTree = aIterator.getParseTree();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
do
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( !pParseTree )
|
|
|
|
|
{
|
|
|
|
|
// now we have to insert the fields which aren't in the statement
|
|
|
|
|
insertUnUsedFields(_pView,_pSelectionBrw);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if ( !rController.isEsacpeProcessing() ) // not allowed in this mode
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = eNativeMode;
|
2006-07-10 14:41:12 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !( SQL_ISRULE( pParseTree, select_statement ) ) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
eErrorCode = eNoSelectStatement;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2011-01-04 13:12:33 +01:00
|
|
|
|
const OSQLParseNode* pTableExp = pParseTree->getChild(3);
|
|
|
|
|
if ( pTableExp->getChild(6)->count() > 0 || pTableExp->getChild(7)->count() > 0 || pTableExp->getChild(8)->count() > 0)
|
|
|
|
|
{
|
|
|
|
|
eErrorCode = eStatementTooComplex;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( !xConnection.is() )
|
|
|
|
|
{
|
2011-02-25 17:47:41 +01:00
|
|
|
|
OSL_FAIL( "InitFromParseNodeImpl: no connection? no connection!" );
|
2006-07-10 14:41:12 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const OSQLTables& aMap = aIterator.getTables();
|
|
|
|
|
::comphelper::UStringMixLess aTmp(aMap.key_comp());
|
|
|
|
|
::comphelper::UStringMixEqual aKeyComp( aTmp.isCaseSensitive() );
|
|
|
|
|
|
|
|
|
|
Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
sal_Int32 nMax = xMetaData->getMaxTablesInSelect();
|
|
|
|
|
if ( nMax && nMax < (sal_Int32)aMap.size() )
|
2001-06-28 13:22:47 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
eErrorCode = eTooManyTables;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::rtl::OUString sComposedName;
|
|
|
|
|
::rtl::OUString sAlias;
|
|
|
|
|
|
|
|
|
|
OQueryTableView* pTableView = static_cast<OQueryTableView*>(_pView->getTableView());
|
2007-11-01 14:31:21 +00:00
|
|
|
|
pTableView->clearLayoutInformation();
|
2006-07-10 14:41:12 +00:00
|
|
|
|
OSQLTables::const_iterator aIter = aMap.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OSQLTables::const_iterator aEnd = aMap.end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
OSQLTable xTable = aIter->second;
|
|
|
|
|
Reference< XPropertySet > xTableProps( xTable, UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
|
|
sAlias = aIter->first;
|
|
|
|
|
|
|
|
|
|
// check whether this is a query
|
|
|
|
|
Reference< XPropertySetInfo > xPSI = xTableProps->getPropertySetInfo();
|
|
|
|
|
bool bIsQuery = xPSI.is() && xPSI->hasPropertyByName( PROPERTY_COMMAND );
|
|
|
|
|
|
|
|
|
|
if ( bIsQuery )
|
|
|
|
|
OSL_VERIFY( xTableProps->getPropertyValue( PROPERTY_NAME ) >>= sComposedName );
|
|
|
|
|
else
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sComposedName = ::dbtools::composeTableName( xMetaData, xTableProps, ::dbtools::eInDataManipulation, false, false, false );
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
// if the alias is the complete (composed) table, then shorten it
|
|
|
|
|
if ( aKeyComp( sComposedName, aIter->first ) )
|
2001-06-28 13:22:47 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
::rtl::OUString sCatalog, sSchema, sTable;
|
|
|
|
|
::dbtools::qualifiedNameComponents( xMetaData, sComposedName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
|
|
|
|
|
sAlias = sTable;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
// find the existent window for this alias
|
|
|
|
|
OQueryTableWindow* pExistentWin = pTableView->FindTable( sAlias );
|
|
|
|
|
if ( !pExistentWin )
|
|
|
|
|
{
|
|
|
|
|
pTableView->AddTabWin( sComposedName, sAlias, sal_False ); // don't create data here
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// there already exists a window for this alias ....
|
|
|
|
|
if ( !aKeyComp( pExistentWin->GetData()->GetComposedName(), sComposedName ) )
|
|
|
|
|
// ... but for another complete table name -> new window
|
|
|
|
|
pTableView->AddTabWin(sComposedName, sAlias);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
// now delete the data for which we haven't any tablewindow
|
2006-10-18 12:32:24 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap aTableMap(*pTableView->GetTabWinMap());
|
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIterTableMap = aTableMap.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIterTableEnd = aTableMap.end();
|
|
|
|
|
for(;aIterTableMap != aIterTableEnd;++aIterTableMap)
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
if(aMap.find(aIterTableMap->second->GetComposedName()) == aMap.end() &&
|
|
|
|
|
aMap.find(aIterTableMap->first) == aMap.end())
|
|
|
|
|
pTableView->RemoveTabWin(aIterTableMap->second);
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2011-01-04 13:12:33 +01:00
|
|
|
|
if ( eOk == (eErrorCode = FillOuterJoins(_pView,pTableExp->getChild(0)->getChild(1))) )
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
// check if we have a distinct statement
|
|
|
|
|
if(SQL_ISTOKEN(pParseTree->getChild(1),DISTINCT))
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.setDistinct(sal_True);
|
|
|
|
|
rController.InvalidateFeature(SID_QUERY_DISTINCT_VALUES);
|
2006-07-10 14:41:12 +00:00
|
|
|
|
}
|
2012-12-28 23:38:57 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rController.setDistinct(sal_False);
|
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( (eErrorCode = InstallFields(_pView,pParseTree, pTableView->GetTabWinMap())) == eOk )
|
|
|
|
|
{
|
|
|
|
|
// GetSelectionCriteria must be called before GetHavingCriteria
|
|
|
|
|
sal_uInt16 nLevel=0;
|
2001-02-05 15:17:40 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( eOk == (eErrorCode = GetSelectionCriteria(_pView,_pSelectionBrw,pParseTree,nLevel)) )
|
|
|
|
|
{
|
|
|
|
|
if ( eOk == (eErrorCode = GetGroupCriteria(_pView,_pSelectionBrw,pParseTree)) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( eOk == (eErrorCode = GetHavingCriteria(_pView,_pSelectionBrw,pParseTree,nLevel)) )
|
2002-05-06 08:45:36 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( eOk == (eErrorCode = GetOrderCriteria(_pView,_pSelectionBrw,pParseTree)) )
|
|
|
|
|
insertUnUsedFields(_pView,_pSelectionBrw);
|
2002-05-06 08:45:36 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2001-10-11 07:38:14 +00:00
|
|
|
|
}
|
2001-06-28 13:22:47 +00:00
|
|
|
|
}
|
2001-02-05 15:17:40 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
catch(SQLException&)
|
|
|
|
|
{
|
2011-02-25 17:47:41 +01:00
|
|
|
|
OSL_FAIL("getMaxTablesInSelect!");
|
2006-07-10 14:41:12 +00:00
|
|
|
|
}
|
2002-08-30 10:13:38 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
while ( false );
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// Durch das Neuerzeugen wurden wieder Undo-Actions in den Manager gestellt
|
2010-11-25 14:28:03 +01:00
|
|
|
|
rController.ClearUndoManager();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
_pSelectionBrw->Invalidate();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
/** fillSelectSubList
|
|
|
|
|
@return
|
|
|
|
|
<TRUE/> when columns could be inserted otherwise <FALSE/>
|
|
|
|
|
*/
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
SqlParseError fillSelectSubList( OQueryDesignView* _pView,
|
2002-02-19 13:04:20 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap* _pTabList)
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2002-02-19 13:04:20 +00:00
|
|
|
|
sal_Bool bFirstField = sal_True;
|
|
|
|
|
::rtl::OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*"));
|
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIter = _pTabList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aEnd = _pTabList->end();
|
|
|
|
|
for(;aIter != aEnd && eOk == eErrorCode ;++aIter)
|
2002-02-19 13:04:20 +00:00
|
|
|
|
{
|
|
|
|
|
OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second);
|
2008-10-01 12:28:29 +00:00
|
|
|
|
OTableFieldDescRef aInfo = new OTableFieldDesc();
|
2002-02-19 13:04:20 +00:00
|
|
|
|
if (pTabWin->ExistsField( sAsterix, aInfo ))
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
|
2002-02-19 13:04:20 +00:00
|
|
|
|
bFirstField = sal_False;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2002-02-19 13:04:20 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError InstallFields(OQueryDesignView* _pView,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pNode,
|
|
|
|
|
OJoinTableView::OTableWindowMap* pTabList )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if( pNode==0 || !SQL_ISRULE(pNode,select_statement))
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eNoSelectStatement;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2009-11-26 12:56:23 +01:00
|
|
|
|
::connectivity::OSQLParseNode* pParseTree = pNode->getChild(2); // selection
|
2011-12-19 18:10:37 -02:00
|
|
|
|
sal_Bool bFirstField = sal_True; // bei der Initialisierung mu<6D> auf alle Faelle das erste Feld neu aktiviert werden
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
|
|
|
|
|
|
|
|
|
if ( pParseTree->isRule() && SQL_ISPUNCTUATION(pParseTree->getChild(0),"*") )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// SELECT * ...
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = fillSelectSubList(_pView,pTabList);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
else if (SQL_ISRULE(pParseTree,scalar_exp_commalist) )
|
|
|
|
|
{
|
|
|
|
|
// SELECT column, ...
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
::rtl::OUString aColumnName,aTableRange;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
for (sal_uInt32 i = 0; i < pParseTree->count() && eOk == eErrorCode ; ++i)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::connectivity::OSQLParseNode * pColumnRef = pParseTree->getChild(i);
|
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
do {
|
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( SQL_ISRULE(pColumnRef,select_sublist) )
|
2004-03-15 11:43:43 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = fillSelectSubList(_pView,pTabList);
|
2006-07-10 14:41:12 +00:00
|
|
|
|
break;
|
2004-03-15 11:43:43 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
|
|
|
|
|
if ( SQL_ISRULE(pColumnRef,derived_column) )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::rtl::OUString aColumnAlias(rController.getParseIterator().getColumnAlias(pColumnRef)); // kann leer sein
|
2006-07-10 14:41:12 +00:00
|
|
|
|
pColumnRef = pColumnRef->getChild(0);
|
|
|
|
|
OTableFieldDescRef aInfo = new OTableFieldDesc();
|
|
|
|
|
|
|
|
|
|
if ( pColumnRef->count() == 3 &&
|
|
|
|
|
SQL_ISPUNCTUATION(pColumnRef->getChild(0),"(") &&
|
|
|
|
|
SQL_ISPUNCTUATION(pColumnRef->getChild(2),")")
|
|
|
|
|
)
|
|
|
|
|
pColumnRef = pColumnRef->getChild(1);
|
|
|
|
|
|
|
|
|
|
if (SQL_ISRULE(pColumnRef,column_ref))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
InsertColumnRef(_pView,pColumnRef,aColumnName,aColumnAlias,aTableRange,aInfo,pTabList);
|
|
|
|
|
eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
|
|
|
|
|
bFirstField = sal_False;
|
|
|
|
|
}
|
2011-10-30 13:34:01 +01:00
|
|
|
|
else if(SQL_ISRULEOR3(pColumnRef, general_set_fct, set_fct_spec, position_exp) ||
|
|
|
|
|
SQL_ISRULEOR3(pColumnRef, extract_exp, fold, char_substring_fct) ||
|
|
|
|
|
SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct))
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aColumns;
|
2010-02-10 10:50:53 +01:00
|
|
|
|
pColumnRef->parseNodeToPredicateStr(aColumns,
|
|
|
|
|
xConnection,
|
|
|
|
|
rController.getNumberFormatter(),
|
|
|
|
|
_pView->getLocale(),
|
|
|
|
|
static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
|
|
|
|
|
&rController.getParser().getContext());
|
2006-07-10 14:41:12 +00:00
|
|
|
|
|
|
|
|
|
sal_Int32 nFunctionType = FKT_NONE;
|
|
|
|
|
::connectivity::OSQLParseNode* pParamRef = NULL;
|
|
|
|
|
sal_Int32 nColumnRefPos = pColumnRef->count() - 2;
|
|
|
|
|
if ( nColumnRefPos >= 0 && static_cast<sal_uInt32>(nColumnRefPos) < pColumnRef->count() )
|
|
|
|
|
pParamRef = pColumnRef->getChild(nColumnRefPos);
|
|
|
|
|
|
|
|
|
|
if ( SQL_ISRULE(pColumnRef,general_set_fct)
|
|
|
|
|
&& SQL_ISRULE(pParamRef,column_ref) )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
// Parameter auf Columnref pr"ufen
|
|
|
|
|
InsertColumnRef(_pView,pParamRef,aColumnName,aColumnAlias,aTableRange,aInfo,pTabList);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
else if ( SQL_ISRULE(pColumnRef,general_set_fct) )
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( pParamRef && pParamRef->getTokenValue().toChar() == '*' )
|
2001-06-28 13:22:47 +00:00
|
|
|
|
{
|
2011-10-30 13:17:52 +01:00
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin();
|
|
|
|
|
const OJoinTableView::OTableWindowMap::const_iterator aEnd = pTabList->end();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second);
|
2010-11-13 21:19:14 +00:00
|
|
|
|
if (pTabWin->ExistsField( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), aInfo ))
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2006-07-10 14:41:12 +00:00
|
|
|
|
aInfo->SetAlias(String());
|
|
|
|
|
aInfo->SetTable(String());
|
|
|
|
|
break;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-08-30 10:13:38 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sFieldName = aColumns;
|
2006-07-10 14:41:12 +00:00
|
|
|
|
if ( pParamRef )
|
|
|
|
|
{ // we got an aggregate function but without column name inside
|
|
|
|
|
// so we set the whole argument of the function as field name
|
|
|
|
|
nFunctionType |= FKT_NUMERIC;
|
|
|
|
|
sFieldName = ::rtl::OUString();
|
|
|
|
|
pParamRef->parseNodeToStr( sFieldName,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext(),
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_True,
|
|
|
|
|
sal_True); // quote is to true because we need quoted elements inside the function
|
2002-08-30 10:13:38 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
aInfo->SetDataType(DataType::DOUBLE);
|
2002-08-30 10:13:38 +00:00
|
|
|
|
aInfo->SetFieldType(TAB_NORMAL_FIELD);
|
|
|
|
|
aInfo->SetField(sFieldName);
|
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
aInfo->SetTabWindow(NULL);
|
|
|
|
|
aInfo->SetFieldAlias(aColumnAlias);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
else
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2009-11-26 12:56:23 +01:00
|
|
|
|
_pView->fillFunctionInfo(pColumnRef,aColumns,aInfo);
|
2001-10-05 05:49:21 +00:00
|
|
|
|
aInfo->SetFieldAlias(aColumnAlias);
|
2006-07-10 14:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( SQL_ISRULE(pColumnRef,general_set_fct) )
|
|
|
|
|
{
|
|
|
|
|
aInfo->SetFunctionType(nFunctionType|FKT_AGGREGATE);
|
|
|
|
|
String aCol(aColumns);
|
2012-06-11 13:15:18 +01:00
|
|
|
|
aInfo->SetFunction(comphelper::string::stripEnd(aCol.GetToken(0,'('), ' '));
|
2006-07-10 14:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
aInfo->SetFunctionType(nFunctionType|FKT_OTHER);
|
|
|
|
|
|
|
|
|
|
eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
|
|
|
|
|
bFirstField = sal_False;
|
|
|
|
|
}
|
2010-11-25 01:16:20 +00:00
|
|
|
|
else
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aColumns;
|
|
|
|
|
pColumnRef->parseNodeToStr( aColumns,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext(),
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_True,
|
|
|
|
|
sal_True); // quote is to true because we need quoted elements inside the function
|
|
|
|
|
|
|
|
|
|
aInfo->SetTabWindow( NULL );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
// since we support queries in queries, the thingie might belong to an existing "table"
|
2006-08-04 12:57:37 +00:00
|
|
|
|
OQueryTableWindow* pExistingTable = lcl_findColumnInTables( aColumns, *pTabList, aInfo );
|
|
|
|
|
if ( pExistingTable )
|
2006-07-10 14:41:12 +00:00
|
|
|
|
{
|
2006-08-04 12:57:37 +00:00
|
|
|
|
aInfo->SetTabWindow( pExistingTable );
|
|
|
|
|
aInfo->SetTable( pExistingTable->GetTableName() );
|
|
|
|
|
aInfo->SetAlias( pExistingTable->GetAliasName() );
|
2001-06-28 13:22:47 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
|
|
|
|
|
aInfo->SetDataType(DataType::DOUBLE);
|
|
|
|
|
aInfo->SetFieldType(TAB_NORMAL_FIELD);
|
|
|
|
|
aInfo->SetField(aColumns);
|
|
|
|
|
aInfo->SetFieldAlias(aColumnAlias);
|
|
|
|
|
aInfo->SetFunctionType(FKT_NUMERIC | FKT_OTHER);
|
|
|
|
|
|
|
|
|
|
eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
|
|
|
|
|
bFirstField = sal_False;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
|
|
|
|
|
break;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2006-07-10 14:41:12 +00:00
|
|
|
|
|
2011-02-25 17:47:41 +01:00
|
|
|
|
OSL_FAIL( "InstallFields: don't know how to interpret this parse node!" );
|
2006-07-10 14:41:12 +00:00
|
|
|
|
|
|
|
|
|
} while ( false );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = eStatementTooComplex;
|
2001-06-28 13:22:47 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetOrderCriteria( OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pParseRoot )
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2012-03-15 18:54:17 +01:00
|
|
|
|
if (!pParseRoot->getChild(3)->getChild(ORDER_BY_CHILD_POS)->isLeaf())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2012-03-15 18:54:17 +01:00
|
|
|
|
::connectivity::OSQLParseNode* pNode = pParseRoot->getChild(3)->getChild(ORDER_BY_CHILD_POS)->getChild(2);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::connectivity::OSQLParseNode* pParamRef = NULL;
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
EOrderDir eOrderDir;
|
|
|
|
|
for( sal_uInt32 i=0 ; i<pNode->count() ; i++ )
|
|
|
|
|
{
|
2012-03-20 11:03:08 +01:00
|
|
|
|
OTableFieldDescRef aDragLeft = new OTableFieldDesc();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
eOrderDir = ORDER_ASC;
|
|
|
|
|
::connectivity::OSQLParseNode* pChild = pNode->getChild( i );
|
|
|
|
|
|
|
|
|
|
if (SQL_ISTOKEN( pChild->getChild(1), DESC ) )
|
|
|
|
|
eOrderDir = ORDER_DESC;
|
|
|
|
|
|
2006-10-18 12:32:24 +00:00
|
|
|
|
::connectivity::OSQLParseNode* pArgument = pChild->getChild(0);
|
|
|
|
|
|
|
|
|
|
if(SQL_ISRULE(pArgument,column_ref))
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2006-10-18 12:32:24 +00:00
|
|
|
|
if( eOk == FillDragInfo(_pView,pArgument,aDragLeft))
|
2005-03-10 15:52:55 +00:00
|
|
|
|
_pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
else // it could be a alias name for a field
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString aTableRange,aColumnName;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::connectivity::OSQLParseTreeIterator& rParseIter = rController.getParseIterator();
|
2006-10-18 12:32:24 +00:00
|
|
|
|
rParseIter.getColumnRange( pArgument, aColumnName, aTableRange );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OTableFields& aList = rController.getTableFieldDesc();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFields::iterator aIter = aList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OTableFields::iterator aEnd = aList.end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-06-28 13:22:47 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFieldDescRef pEntry = *aIter;
|
2010-10-15 12:22:54 -05:00
|
|
|
|
if(pEntry.is() && pEntry->GetFieldAlias() == aColumnName)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
pEntry->SetOrderDir( eOrderDir );
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2006-10-18 12:32:24 +00:00
|
|
|
|
else if(SQL_ISRULE(pArgument, general_set_fct ) &&
|
|
|
|
|
SQL_ISRULE(pParamRef = pArgument->getChild(pArgument->count()-2),column_ref) &&
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eOk == FillDragInfo(_pView,pParamRef,aDragLeft))
|
2005-03-10 15:52:55 +00:00
|
|
|
|
_pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i );
|
2006-10-18 12:32:24 +00:00
|
|
|
|
else if( SQL_ISRULE(pArgument, set_fct_spec ) )
|
|
|
|
|
{
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2006-10-18 12:32:24 +00:00
|
|
|
|
if(xConnection.is())
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sCondition;
|
|
|
|
|
pArgument->parseNodeToPredicateStr(sCondition,
|
2006-12-13 15:53:22 +00:00
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
rController.getNumberFormatter(),
|
2006-10-18 12:32:24 +00:00
|
|
|
|
_pView->getLocale(),
|
|
|
|
|
static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext());
|
2009-11-26 12:56:23 +01:00
|
|
|
|
_pView->fillFunctionInfo(pArgument,sCondition,aDragLeft);
|
2006-10-18 12:32:24 +00:00
|
|
|
|
aDragLeft->SetFunctionType(FKT_OTHER);
|
|
|
|
|
aDragLeft->SetOrderDir(eOrderDir);
|
|
|
|
|
aDragLeft->SetVisible(sal_False);
|
|
|
|
|
_pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
eErrorCode = eColumnNotFound;
|
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
else
|
|
|
|
|
eErrorCode = eColumnNotFound;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetHavingCriteria( OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pSelectRoot,
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_uInt16& rLevel )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (!pSelectRoot->getChild(3)->getChild(3)->isLeaf())
|
2002-05-06 08:45:36 +00:00
|
|
|
|
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSelectRoot->getChild(3)->getChild(3)->getChild(1),rLevel, sal_True);
|
|
|
|
|
return eErrorCode;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError GetGroupCriteria( OQueryDesignView* _pView,
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OSelectionBrowseBox* _pSelectionBrw,
|
|
|
|
|
const ::connectivity::OSQLParseNode* pSelectRoot )
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError eErrorCode = eOk;
|
2009-11-26 12:56:23 +01:00
|
|
|
|
if (!pSelectRoot->getChild(3)->getChild(2)->isLeaf()) // opt_group_by_clause
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
::connectivity::OSQLParseNode* pGroupBy = pSelectRoot->getChild(3)->getChild(2)->getChild(2);
|
2011-01-17 14:06:45 +01:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
for( sal_uInt32 i=0 ; i < pGroupBy->count() && eOk == eErrorCode; ++i )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2011-01-17 14:06:45 +01:00
|
|
|
|
OTableFieldDescRef aDragInfo = new OTableFieldDesc();
|
2007-11-01 14:31:21 +00:00
|
|
|
|
::connectivity::OSQLParseNode* pParamRef = NULL;
|
|
|
|
|
::connectivity::OSQLParseNode* pArgument = pGroupBy->getChild( i );
|
|
|
|
|
if(SQL_ISRULE(pArgument,column_ref))
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if ( eOk == (eErrorCode = FillDragInfo(_pView,pArgument,aDragInfo)) )
|
2001-06-28 13:22:47 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aDragInfo->SetGroupBy(sal_True);
|
2005-03-10 15:52:55 +00:00
|
|
|
|
_pSelectionBrw->AddGroupBy(aDragInfo,i);
|
2001-06-28 13:22:47 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2007-11-01 14:31:21 +00:00
|
|
|
|
else if(SQL_ISRULE(pArgument, general_set_fct ) &&
|
|
|
|
|
SQL_ISRULE(pParamRef = pArgument->getChild(pArgument->count()-2),column_ref) &&
|
|
|
|
|
eOk == FillDragInfo(_pView,pParamRef,aDragInfo))
|
|
|
|
|
{
|
|
|
|
|
aDragInfo->SetGroupBy(sal_True);
|
|
|
|
|
_pSelectionBrw->AddGroupBy( aDragInfo, i );
|
|
|
|
|
}
|
|
|
|
|
else if( SQL_ISRULE(pArgument, set_fct_spec ) )
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2007-11-01 14:31:21 +00:00
|
|
|
|
if(xConnection.is())
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sGroupByExpression;
|
|
|
|
|
pArgument->parseNodeToStr( sGroupByExpression,
|
|
|
|
|
xConnection,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
&rController.getParser().getContext(),
|
2007-11-01 14:31:21 +00:00
|
|
|
|
sal_True,
|
|
|
|
|
sal_True); // quote is to true because we need quoted elements inside the function
|
2009-11-26 12:56:23 +01:00
|
|
|
|
_pView->fillFunctionInfo(pArgument,sGroupByExpression,aDragInfo);
|
2007-11-01 14:31:21 +00:00
|
|
|
|
aDragInfo->SetFunctionType(FKT_OTHER);
|
|
|
|
|
aDragInfo->SetGroupBy(sal_True);
|
|
|
|
|
aDragInfo->SetVisible(sal_False);
|
|
|
|
|
_pSelectionBrw->AddGroupBy( aDragInfo, i );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
eErrorCode = eColumnNotFound;
|
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return eErrorCode;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2008-12-01 12:31:27 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2008-12-01 12:31:27 +00:00
|
|
|
|
String getParseErrorMessage( SqlParseError _eErrorCode )
|
2002-05-06 08:45:36 +00:00
|
|
|
|
{
|
2011-01-14 15:00:11 +01:00
|
|
|
|
sal_uInt16 nResId;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
switch(_eErrorCode)
|
|
|
|
|
{
|
|
|
|
|
case eIllegalJoin:
|
|
|
|
|
nResId = STR_QRY_ILLEGAL_JOIN;
|
|
|
|
|
break;
|
|
|
|
|
case eStatementTooLong:
|
|
|
|
|
nResId = STR_QRY_TOO_LONG_STATEMENT;
|
|
|
|
|
break;
|
|
|
|
|
case eNoConnection:
|
|
|
|
|
nResId = STR_QRY_SYNTAX;
|
|
|
|
|
break;
|
|
|
|
|
case eNoSelectStatement:
|
|
|
|
|
nResId = STR_QRY_NOSELECT;
|
|
|
|
|
break;
|
|
|
|
|
case eColumnInLikeNotFound:
|
|
|
|
|
nResId = STR_QRY_SYNTAX;
|
|
|
|
|
break;
|
|
|
|
|
case eNoColumnInLike:
|
|
|
|
|
nResId = STR_QRY_SYNTAX;
|
|
|
|
|
break;
|
|
|
|
|
case eColumnNotFound:
|
|
|
|
|
nResId = STR_QRY_SYNTAX;
|
|
|
|
|
break;
|
|
|
|
|
case eNativeMode:
|
|
|
|
|
nResId = STR_QRY_NATIVE;
|
|
|
|
|
break;
|
|
|
|
|
case eTooManyTables:
|
|
|
|
|
nResId = STR_QRY_TOO_MANY_TABLES;
|
|
|
|
|
break;
|
|
|
|
|
case eTooManyConditions:
|
|
|
|
|
nResId = STR_QRY_TOOMANYCOND;
|
|
|
|
|
break;
|
|
|
|
|
case eTooManyColumns:
|
|
|
|
|
nResId = STR_QRY_TOO_MANY_COLUMNS;
|
|
|
|
|
break;
|
|
|
|
|
case eStatementTooComplex:
|
|
|
|
|
nResId = STR_QRY_TOOCOMPLEX;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
nResId = STR_QRY_SYNTAX;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-12-01 12:31:27 +00:00
|
|
|
|
;
|
|
|
|
|
return String( ModuleRes( nResId ) );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
|
|
|
|
// end of anonymouse namespace
|
2005-09-23 11:43:07 +00:00
|
|
|
|
DBG_NAME(OQueryDesignView)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
OQueryDesignView::OQueryDesignView( OQueryContainerWindow* _pParent,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& _rController,
|
2012-12-14 12:58:00 +02:00
|
|
|
|
const Reference< XComponentContext >& _rxContext)
|
|
|
|
|
:OQueryView( _pParent, _rController, _rxContext )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
,m_aSplitter( this )
|
|
|
|
|
,m_eChildFocus(NONE)
|
2002-05-24 12:03:58 +00:00
|
|
|
|
,m_bInSplitHandler( sal_False )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2005-09-23 11:43:07 +00:00
|
|
|
|
DBG_CTOR(OQueryDesignView,NULL);
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2002-04-09 14:49:26 +00:00
|
|
|
|
SvtSysLocale aSysLocale;
|
2012-11-23 23:06:10 +01:00
|
|
|
|
m_aLocale = aSysLocale.GetLanguageTag().getLocale();
|
2002-04-09 14:49:26 +00:00
|
|
|
|
m_sDecimalSep = aSysLocale.GetLocaleData().getNumDecimalSep();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
catch(Exception&)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_pSelectionBox = new OSelectionBrowseBox(this);
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
setNoneVisbleRow(static_cast<OQueryController&>(getController()).getVisibleRows());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
m_pSelectionBox->Show();
|
|
|
|
|
// Splitter einrichten
|
|
|
|
|
m_aSplitter.SetSplitHdl(LINK(this, OQueryDesignView,SplitHdl));
|
|
|
|
|
m_aSplitter.Show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
OQueryDesignView::~OQueryDesignView()
|
|
|
|
|
{
|
2005-03-10 15:52:55 +00:00
|
|
|
|
if ( m_pTableView )
|
|
|
|
|
::dbaui::notifySystemWindow(this,m_pTableView,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2002-05-07 06:19:29 +00:00
|
|
|
|
::std::auto_ptr<Window> aTemp(m_pSelectionBox);
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
2002-05-07 06:19:29 +00:00
|
|
|
|
m_pSelectionBox = NULL;
|
2005-09-23 11:43:07 +00:00
|
|
|
|
|
|
|
|
|
DBG_DTOR(OQueryDesignView,NULL);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2006-06-20 02:26:39 +00:00
|
|
|
|
IMPL_LINK( OQueryDesignView, SplitHdl, void*, /*p*/ )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if (!getController().isReadOnly())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-05-24 12:03:58 +00:00
|
|
|
|
m_bInSplitHandler = sal_True;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
m_aSplitter.SetPosPixel( Point( m_aSplitter.GetPosPixel().X(),m_aSplitter.GetSplitPosPixel() ) );
|
2008-06-25 11:52:59 +00:00
|
|
|
|
static_cast<OQueryController&>(getController()).setSplitPos(m_aSplitter.GetSplitPosPixel());
|
2010-02-10 14:05:19 +01:00
|
|
|
|
static_cast<OQueryController&>(getController()).setModified( sal_True );
|
2002-02-06 07:08:30 +00:00
|
|
|
|
Resize();
|
2002-05-24 12:03:58 +00:00
|
|
|
|
m_bInSplitHandler = sal_True;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
return 0L;
|
|
|
|
|
}
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::Construct()
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
m_pTableView = new OQueryTableView(m_pScrollWindow,this);
|
|
|
|
|
::dbaui::notifySystemWindow(this,m_pTableView,::comphelper::mem_fun(&TaskPaneList::AddWindow));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OQueryView::Construct();
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::initialize()
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if(static_cast<OQueryController&>(getController()).getSplitPos() != -1)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
m_aSplitter.SetPosPixel( Point( m_aSplitter.GetPosPixel().X(),static_cast<OQueryController&>(getController()).getSplitPos() ) );
|
|
|
|
|
m_aSplitter.SetSplitPosPixel(static_cast<OQueryController&>(getController()).getSplitPos());
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
m_pSelectionBox->initialize();
|
|
|
|
|
reset();
|
|
|
|
|
}
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::resizeDocumentView(Rectangle& _rPlayground)
|
|
|
|
|
{
|
|
|
|
|
Point aPlaygroundPos( _rPlayground.TopLeft() );
|
|
|
|
|
Size aPlaygroundSize( _rPlayground.GetSize() );
|
|
|
|
|
|
|
|
|
|
// calc the split pos, and forward it to the controller
|
2008-06-25 11:52:59 +00:00
|
|
|
|
sal_Int32 nSplitPos = static_cast<OQueryController&>(getController()).getSplitPos();
|
2002-05-24 12:03:58 +00:00
|
|
|
|
if ( 0 != aPlaygroundSize.Height() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2002-05-24 12:03:58 +00:00
|
|
|
|
if ( ( -1 == nSplitPos )
|
|
|
|
|
|| ( nSplitPos >= aPlaygroundSize.Height() )
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
// let the selection browse box determine an optimal size
|
|
|
|
|
Size aSelectionBoxSize = m_pSelectionBox->CalcOptimalSize( aPlaygroundSize );
|
|
|
|
|
nSplitPos = aPlaygroundSize.Height() - aSelectionBoxSize.Height() - m_aSplitter.GetSizePixel().Height();
|
|
|
|
|
// still an invalid size?
|
|
|
|
|
if ( nSplitPos == -1 || nSplitPos >= aPlaygroundSize.Height() )
|
|
|
|
|
nSplitPos = sal_Int32(aPlaygroundSize.Height()*0.6);
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
static_cast<OQueryController&>(getController()).setSplitPos(nSplitPos);
|
2002-05-24 12:03:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !m_bInSplitHandler )
|
|
|
|
|
{ // the resize is triggered by something else than the split handler
|
|
|
|
|
// our main focus is to try to preserve the size of the selectionbrowse box
|
|
|
|
|
Size aSelBoxSize = m_pSelectionBox->GetSizePixel();
|
|
|
|
|
if ( aSelBoxSize.Height() )
|
|
|
|
|
{
|
|
|
|
|
// keep the size of the sel box constant
|
|
|
|
|
nSplitPos = aPlaygroundSize.Height() - m_aSplitter.GetSizePixel().Height() - aSelBoxSize.Height();
|
|
|
|
|
|
|
|
|
|
// and if the box is smaller than the optimal size, try to do something about it
|
|
|
|
|
Size aSelBoxOptSize = m_pSelectionBox->CalcOptimalSize( aPlaygroundSize );
|
|
|
|
|
if ( aSelBoxOptSize.Height() > aSelBoxSize.Height() )
|
|
|
|
|
{
|
|
|
|
|
nSplitPos = aPlaygroundSize.Height() - m_aSplitter.GetSizePixel().Height() - aSelBoxOptSize.Height();
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
static_cast< OQueryController& >(getController()).setSplitPos( nSplitPos );
|
2002-05-24 12:03:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// normalize the split pos
|
|
|
|
|
Point aSplitPos = Point( _rPlayground.Left(), nSplitPos );
|
|
|
|
|
Size aSplitSize = Size( _rPlayground.GetSize().Width(), m_aSplitter.GetSizePixel().Height() );
|
|
|
|
|
|
|
|
|
|
if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() ))
|
|
|
|
|
aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height();
|
|
|
|
|
|
|
|
|
|
if( aSplitPos.Y() <= aPlaygroundPos.Y() )
|
|
|
|
|
aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.2);
|
|
|
|
|
|
|
|
|
|
// position the table
|
|
|
|
|
Size aTableViewSize(aPlaygroundSize.Width(), aSplitPos.Y() - aPlaygroundPos.Y());
|
|
|
|
|
m_pScrollWindow->SetPosSizePixel(aPlaygroundPos, aTableViewSize);
|
|
|
|
|
|
|
|
|
|
// position the selection browse box
|
|
|
|
|
Point aPos( aPlaygroundPos.X(), aSplitPos.Y() + aSplitSize.Height() );
|
|
|
|
|
m_pSelectionBox->SetPosSizePixel( aPos, Size( aPlaygroundSize.Width(), aPlaygroundSize.Height() - aSplitSize.Height() - aTableViewSize.Height() ));
|
|
|
|
|
|
|
|
|
|
// set the size of the splitter
|
|
|
|
|
m_aSplitter.SetPosSizePixel( aSplitPos, aSplitSize );
|
|
|
|
|
m_aSplitter.SetDragRectPixel( _rPlayground );
|
|
|
|
|
|
|
|
|
|
// just for completeness: there is no space left, we occupied it all ...
|
|
|
|
|
_rPlayground.SetPos( _rPlayground.BottomRight() );
|
|
|
|
|
_rPlayground.SetSize( Size( 0, 0 ) );
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::setReadOnly(sal_Bool _bReadOnly)
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->SetReadOnly(_bReadOnly);
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::clear()
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->ClearAll(); // clear the whole selection
|
|
|
|
|
m_pTableView->ClearAll();
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 02:26:39 +00:00
|
|
|
|
void OQueryDesignView::setStatement(const ::rtl::OUString& /*_rsStatement*/)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::copy()
|
|
|
|
|
{
|
|
|
|
|
if( m_eChildFocus == SELECTION)
|
|
|
|
|
m_pSelectionBox->copy();
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
sal_Bool OQueryDesignView::isCutAllowed()
|
|
|
|
|
{
|
|
|
|
|
sal_Bool bAllowed = sal_False;
|
2006-06-20 02:26:39 +00:00
|
|
|
|
if ( SELECTION == m_eChildFocus )
|
|
|
|
|
bAllowed = m_pSelectionBox->isCutAllowed();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return bAllowed;
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
sal_Bool OQueryDesignView::isPasteAllowed()
|
|
|
|
|
{
|
|
|
|
|
sal_Bool bAllowed = sal_False;
|
2006-06-20 02:26:39 +00:00
|
|
|
|
if ( SELECTION == m_eChildFocus )
|
|
|
|
|
bAllowed = m_pSelectionBox->isPasteAllowed();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return bAllowed;
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
sal_Bool OQueryDesignView::isCopyAllowed()
|
|
|
|
|
{
|
|
|
|
|
sal_Bool bAllowed = sal_False;
|
2006-06-20 02:26:39 +00:00
|
|
|
|
if ( SELECTION == m_eChildFocus )
|
|
|
|
|
bAllowed = m_pSelectionBox->isCopyAllowed();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return bAllowed;
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::stopTimer()
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->stopTimer();
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::startTimer()
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->startTimer();
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::cut()
|
|
|
|
|
{
|
|
|
|
|
if( m_eChildFocus == SELECTION)
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->cut();
|
2008-06-25 11:52:59 +00:00
|
|
|
|
static_cast<OQueryController&>(getController()).setModified(sal_True);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::paste()
|
|
|
|
|
{
|
|
|
|
|
if( m_eChildFocus == SELECTION)
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->paste();
|
2008-06-25 11:52:59 +00:00
|
|
|
|
static_cast<OQueryController&>(getController()).setModified(sal_True);
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::TableDeleted(const ::rtl::OUString& rAliasName)
|
|
|
|
|
{
|
|
|
|
|
// Nachricht, dass Tabelle aus dem Fenster gel"oscht wurde
|
|
|
|
|
DeleteFields(rAliasName);
|
2008-06-25 11:52:59 +00:00
|
|
|
|
static_cast<OQueryController&>(getController()).InvalidateFeature(ID_BROWSER_ADDTABLE); // view nochmal bescheid sagen
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::DeleteFields( const ::rtl::OUString& rAliasName )
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->DeleteFields( rAliasName );
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-12-10 13:41:25 +00:00
|
|
|
|
bool OQueryDesignView::HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const
|
|
|
|
|
{
|
|
|
|
|
return m_pSelectionBox->HasFieldByAliasName( rFieldName, rInfo);
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
SqlParseError OQueryDesignView::InsertField( const OTableFieldDescRef& rInfo, sal_Bool bVis, sal_Bool bActivate)
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
|
return m_pSelectionBox->InsertField( rInfo, BROWSER_INVALIDID,bVis, bActivate ).is() ? eOk : eTooManyColumns;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-12-09 07:25:38 +00:00
|
|
|
|
sal_Int32 OQueryDesignView::getColWidth(sal_uInt16 _nColPos) const
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2008-12-09 07:25:38 +00:00
|
|
|
|
static sal_Int32 s_nDefaultWidth = GetTextWidth(String(RTL_CONSTASCII_USTRINGPARAM("0"))) * 15;
|
|
|
|
|
sal_Int32 nWidth = static_cast<OQueryController&>(getController()).getColWidth(_nColPos);
|
|
|
|
|
if ( !nWidth )
|
|
|
|
|
nWidth = s_nDefaultWidth;
|
|
|
|
|
return nWidth;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-02-06 07:08:30 +00:00
|
|
|
|
void OQueryDesignView::fillValidFields(const ::rtl::OUString& sAliasName, ComboBox* pFieldList)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2011-02-03 00:33:36 +01:00
|
|
|
|
OSL_ENSURE(pFieldList != NULL, "OQueryDesignView::FillValidFields : What the hell do you think I can do with a NULL-ptr ? This will crash !");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
pFieldList->Clear();
|
|
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
|
sal_Bool bAllTables = sAliasName.isEmpty();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
OJoinTableView::OTableWindowMap* pTabWins = m_pTableView->GetTabWinMap();
|
|
|
|
|
::rtl::OUString strCurrentPrefix;
|
|
|
|
|
::std::vector< ::rtl::OUString> aFields;
|
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIter = pTabWins->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aEnd = pTabWins->end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OQueryTableWindow* pCurrentWin = static_cast<OQueryTableWindow*>(aIter->second);
|
|
|
|
|
if (bAllTables || (pCurrentWin->GetAliasName() == sAliasName))
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
strCurrentPrefix = pCurrentWin->GetAliasName();
|
|
|
|
|
strCurrentPrefix += ::rtl::OUString('.');
|
|
|
|
|
|
|
|
|
|
pCurrentWin->EnumValidFields(aFields);
|
|
|
|
|
|
|
|
|
|
::std::vector< ::rtl::OUString>::iterator aStrIter = aFields.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::std::vector< ::rtl::OUString>::iterator aStrEnd = aFields.end();
|
|
|
|
|
for(;aStrIter != aStrEnd;++aStrIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (bAllTables || aStrIter->toChar() == '*')
|
|
|
|
|
pFieldList->InsertEntry(::rtl::OUString(strCurrentPrefix) += *aStrIter);
|
|
|
|
|
else
|
|
|
|
|
pFieldList->InsertEntry(*aStrIter);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
|
|
|
|
if (!bAllTables)
|
|
|
|
|
// das heisst, dass ich in diesen Block kam, weil der Tabellenname genau der gesuchte war, also bin ich fertig
|
|
|
|
|
// (dadurch verhindere ich auch das doppelte Einfuegen von Feldern, wenn eine Tabelle mehrmals als TabWin vorkommt)
|
|
|
|
|
break;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
long OQueryDesignView::PreNotify(NotifyEvent& rNEvt)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
switch (rNEvt.GetType())
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
case EVENT_GETFOCUS:
|
2003-04-15 15:03:54 +00:00
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2002-08-30 10:13:38 +00:00
|
|
|
|
{
|
|
|
|
|
Window* pFocus = Application::GetFocusWindow();
|
2006-06-20 02:26:39 +00:00
|
|
|
|
(void)pFocus;
|
2002-08-30 10:13:38 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if ( m_pSelectionBox && m_pSelectionBox->HasChildPathFocus() )
|
2002-05-06 08:45:36 +00:00
|
|
|
|
m_eChildFocus = SELECTION;
|
|
|
|
|
else
|
|
|
|
|
m_eChildFocus = TABLEVIEW;
|
2002-02-11 12:02:08 +00:00
|
|
|
|
break;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2002-05-06 08:45:36 +00:00
|
|
|
|
return OQueryView::PreNotify(rNEvt);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// check if the statement is correct when not returning false
|
|
|
|
|
sal_Bool OQueryDesignView::checkStatement()
|
|
|
|
|
{
|
2003-03-19 16:57:12 +00:00
|
|
|
|
sal_Bool bRet = sal_True;
|
|
|
|
|
if ( m_pSelectionBox )
|
2010-12-04 12:33:49 +09:00
|
|
|
|
bRet = m_pSelectionBox->Save(); // an error occurred so we return no
|
2003-03-19 16:57:12 +00:00
|
|
|
|
return bRet;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
|
::rtl::OUString OQueryDesignView::getStatement()
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(getController());
|
|
|
|
|
m_rController.clearError();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// used for fields which aren't any longer in the statement
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OTableFields& rUnUsedFields = rController.getUnUsedFields();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFields().swap( rUnUsedFields );
|
|
|
|
|
|
|
|
|
|
// create the select columns
|
|
|
|
|
sal_uInt32 nFieldcount = 0;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OTableFields& rFieldList = rController.getTableFieldDesc();
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFields::iterator aIter = rFieldList.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
|
OTableFields::iterator aEnd = rFieldList.end();
|
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OTableFieldDescRef pEntryField = *aIter;
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if (!pEntryField->GetField().isEmpty() && pEntryField->IsVisible() )
|
2002-08-30 10:13:38 +00:00
|
|
|
|
++nFieldcount;
|
2011-12-19 18:10:37 -02:00
|
|
|
|
else if (!pEntryField->GetField().isEmpty() &&
|
2002-02-06 07:08:30 +00:00
|
|
|
|
!pEntryField->HasCriteria() &&
|
2002-08-30 10:13:38 +00:00
|
|
|
|
pEntryField->isNoneFunction() &&
|
2002-02-06 07:08:30 +00:00
|
|
|
|
pEntryField->GetOrderDir() == ORDER_NONE &&
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
|
!pEntryField->IsGroupBy() &&
|
2011-12-19 18:10:37 -02:00
|
|
|
|
pEntryField->GetFunction().isEmpty() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
rUnUsedFields.push_back(pEntryField);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if ( !nFieldcount ) // keine Felder sichtbar also zur"uck
|
|
|
|
|
{
|
|
|
|
|
rUnUsedFields = rFieldList;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return ::rtl::OUString();
|
2002-08-30 10:13:38 +00:00
|
|
|
|
}
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
OQueryTableView::OTableWindowMap* pTabList = m_pTableView->GetTabWinMap();
|
|
|
|
|
sal_uInt32 nTabcount = pTabList->size();
|
|
|
|
|
|
|
|
|
|
::rtl::OUString aFieldListStr(GenerateSelectList(this,rFieldList,nTabcount>1));
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if( aFieldListStr.isEmpty() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return ::rtl::OUString();
|
|
|
|
|
// Ausnahmebehandlung, wenn keine Felder angegeben worden sind
|
|
|
|
|
// Dann darf die Tabpage nicht gewechselt werden
|
|
|
|
|
// Im TabBarSelectHdl wird der SQL-::rtl::OUString auf STATEMENT_NOFIELDS abgefragt
|
|
|
|
|
// und eine Errormeldung erzeugt
|
|
|
|
|
// ----------------- Tabellenliste aufbauen ----------------------
|
|
|
|
|
|
2002-02-19 13:04:20 +00:00
|
|
|
|
const ::std::vector<OTableConnection*>* pConnList = m_pTableView->getTableConnections();
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = rController.getConnection();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString aTableListStr(GenerateFromClause(xConnection,pTabList,pConnList));
|
2011-12-19 18:10:37 -02:00
|
|
|
|
OSL_ENSURE(!aTableListStr.isEmpty(), "OQueryDesignView::getStatement() : unerwartet : habe Felder, aber keine Tabellen !");
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// wenn es Felder gibt, koennen die nur durch Einfuegen aus einer schon existenten Tabelle entstanden sein; wenn andererseits
|
|
|
|
|
// eine Tabelle geloescht wird, verschwinden auch die zugehoerigen Felder -> ergo KANN es das nicht geben, dass Felder
|
|
|
|
|
// existieren, aber keine Tabellen (und aFieldListStr hat schon eine Laenge, das stelle ich oben sicher)
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::rtl::OUStringBuffer aHavingStr,aCriteriaListStr;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// ----------------- Kriterien aufbauen ----------------------
|
|
|
|
|
if (!GenerateCriterias(this,aCriteriaListStr,aHavingStr,rFieldList, nTabcount > 1))
|
|
|
|
|
return ::rtl::OUString();
|
|
|
|
|
|
|
|
|
|
::rtl::OUString aJoinCrit;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
GenerateInnerJoinCriterias(xConnection,aJoinCrit,pConnList);
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if(!aJoinCrit.isEmpty())
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2010-11-13 21:19:14 +00:00
|
|
|
|
::rtl::OUString aTmp(RTL_CONSTASCII_USTRINGPARAM("( "));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aTmp += aJoinCrit;
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aTmp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" )"));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if(aCriteriaListStr.getLength())
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aTmp += C_AND;
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aTmp += aCriteriaListStr.makeStringAndClear();
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
aCriteriaListStr = aTmp;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// ----------------- Statement aufbauen ----------------------
|
2010-11-13 21:19:14 +00:00
|
|
|
|
::rtl::OUStringBuffer aSqlCmd(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")));
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if(static_cast<OQueryController&>(getController()).isDistinct())
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DISTINCT ")));
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aSqlCmd.append(aFieldListStr);
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM ")));
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aSqlCmd.append(aTableListStr);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2002-02-06 07:08:30 +00:00
|
|
|
|
if (aCriteriaListStr.getLength())
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")));
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aSqlCmd.append(aCriteriaListStr.makeStringAndClear());
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// ----------------- GroupBy aufbauen und Anh"angen ------------
|
|
|
|
|
Reference<XDatabaseMetaData> xMeta;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( xConnection.is() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
xMeta = xConnection->getMetaData();
|
|
|
|
|
sal_Bool bUseAlias = nTabcount > 1;
|
2002-05-06 08:45:36 +00:00
|
|
|
|
if ( xMeta.is() )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
bUseAlias = bUseAlias || !xMeta->supportsGroupByUnrelated();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aSqlCmd.append(GenerateGroupBy(this,rFieldList,bUseAlias));
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// ----------------- having Anh"angen ------------
|
|
|
|
|
if(aHavingStr.getLength())
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2010-11-13 21:19:14 +00:00
|
|
|
|
aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" HAVING ")));
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aSqlCmd.append(aHavingStr.makeStringAndClear());
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// ----------------- Sortierung aufbauen und Anh"angen ------------
|
2002-05-06 08:45:36 +00:00
|
|
|
|
::rtl::OUString sOrder;
|
|
|
|
|
SqlParseError eErrorCode = eOk;
|
|
|
|
|
if ( (eErrorCode = GenerateOrder(this,rFieldList,nTabcount > 1,sOrder)) == eOk)
|
2009-07-03 12:24:35 +00:00
|
|
|
|
aSqlCmd.append(sOrder);
|
2002-05-06 08:45:36 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
|
if ( !m_rController.hasError() )
|
|
|
|
|
m_rController.appendError( getParseErrorMessage( eErrorCode ) );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
|
m_rController.displayError();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::rtl::OUString sSQL = aSqlCmd.makeStringAndClear();
|
2008-01-30 07:54:21 +00:00
|
|
|
|
if ( xConnection.is() )
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::connectivity::OSQLParser& rParser( rController.getParser() );
|
2008-01-30 07:54:21 +00:00
|
|
|
|
::rtl::OUString sErrorMessage;
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2009-07-03 12:24:35 +00:00
|
|
|
|
::std::auto_ptr<OSQLParseNode> pParseNode( rParser.parseTree( sErrorMessage, sSQL, sal_True ) );
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
2008-01-30 07:54:21 +00:00
|
|
|
|
if ( pParseNode.get() )
|
|
|
|
|
{
|
|
|
|
|
OSQLParseNode* pNode = pParseNode->getChild(3)->getChild(1);
|
|
|
|
|
if ( pNode->count() > 1 )
|
|
|
|
|
{
|
|
|
|
|
::connectivity::OSQLParseNode * pCondition = pNode->getChild(1);
|
|
|
|
|
if ( pCondition ) // no where clause
|
|
|
|
|
{
|
|
|
|
|
OSQLParseNode::compress(pCondition);
|
|
|
|
|
::rtl::OUString sTemp;
|
|
|
|
|
pParseNode->parseNodeToStr(sTemp,xConnection);
|
2009-07-03 12:24:35 +00:00
|
|
|
|
sSQL = sTemp;
|
2008-01-30 07:54:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
|
return sSQL;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable)
|
|
|
|
|
{
|
|
|
|
|
sal_uInt16 nRow;
|
|
|
|
|
switch (_nSlotId)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2004-09-09 08:48:21 +00:00
|
|
|
|
case SID_QUERY_VIEW_FUNCTIONS:
|
2002-02-06 07:08:30 +00:00
|
|
|
|
nRow = BROW_FUNCTION_ROW;
|
|
|
|
|
break;
|
2004-09-09 08:48:21 +00:00
|
|
|
|
case SID_QUERY_VIEW_TABLES:
|
2002-02-06 07:08:30 +00:00
|
|
|
|
nRow = BROW_TABLE_ROW;
|
|
|
|
|
break;
|
2004-09-09 08:48:21 +00:00
|
|
|
|
case SID_QUERY_VIEW_ALIASES:
|
2002-02-06 07:08:30 +00:00
|
|
|
|
nRow = BROW_COLUMNALIAS_ROW;
|
|
|
|
|
break;
|
2004-02-04 12:55:13 +00:00
|
|
|
|
default:
|
|
|
|
|
// ????????????
|
|
|
|
|
nRow = 0;
|
|
|
|
|
break;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
m_pSelectionBox->SetRowVisible(nRow,_bEnable);
|
|
|
|
|
m_pSelectionBox->Invalidate();
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
sal_Bool OQueryDesignView::isSlotEnabled(sal_Int32 _nSlotId)
|
|
|
|
|
{
|
|
|
|
|
sal_uInt16 nRow;
|
|
|
|
|
switch (_nSlotId)
|
2001-02-05 08:35:57 +00:00
|
|
|
|
{
|
2004-09-09 08:48:21 +00:00
|
|
|
|
case SID_QUERY_VIEW_FUNCTIONS:
|
2002-02-06 07:08:30 +00:00
|
|
|
|
nRow = BROW_FUNCTION_ROW;
|
|
|
|
|
break;
|
2004-09-09 08:48:21 +00:00
|
|
|
|
case SID_QUERY_VIEW_TABLES:
|
2002-02-06 07:08:30 +00:00
|
|
|
|
nRow = BROW_TABLE_ROW;
|
|
|
|
|
break;
|
2004-09-09 08:48:21 +00:00
|
|
|
|
case SID_QUERY_VIEW_ALIASES:
|
2002-02-06 07:08:30 +00:00
|
|
|
|
nRow = BROW_COLUMNALIAS_ROW;
|
|
|
|
|
break;
|
2004-02-04 12:55:13 +00:00
|
|
|
|
default:
|
|
|
|
|
// ?????????
|
|
|
|
|
nRow = 0;
|
|
|
|
|
break;
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
return m_pSelectionBox->IsRowVisible(nRow);
|
2001-02-05 08:35:57 +00:00
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-02-05 15:17:40 +00:00
|
|
|
|
void OQueryDesignView::SaveUIConfig()
|
|
|
|
|
{
|
2008-06-25 11:52:59 +00:00
|
|
|
|
OQueryController& rCtrl = static_cast<OQueryController&>(getController());
|
|
|
|
|
rCtrl.SaveTabWinsPosSize( m_pTableView->GetTabWinMap(), m_pScrollWindow->GetHScrollBar()->GetThumbPos(), m_pScrollWindow->GetVScrollBar()->GetThumbPos() );
|
|
|
|
|
rCtrl.setVisibleRows( m_pSelectionBox->GetNoneVisibleRows() );
|
|
|
|
|
if ( m_aSplitter.GetSplitPosPixel() != 0 )
|
|
|
|
|
rCtrl.setSplitPos( m_aSplitter.GetSplitPosPixel() );
|
2001-02-05 15:17:40 +00:00
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-10-05 05:49:21 +00:00
|
|
|
|
OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pEntry,
|
2001-09-27 05:19:05 +00:00
|
|
|
|
const String& _sCriteria,
|
|
|
|
|
::rtl::OUString& _rsErrorMessage,
|
2007-11-01 14:31:21 +00:00
|
|
|
|
Reference<XPropertySet>& _rxColumn) const
|
2001-09-27 05:19:05 +00:00
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
|
OSL_ENSURE(pEntry.is(),"Entry is null!");
|
|
|
|
|
if(!pEntry.is())
|
2001-09-27 05:19:05 +00:00
|
|
|
|
return NULL;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
Reference< XConnection> xConnection = static_cast<OQueryController&>(getController()).getConnection();
|
2001-09-27 05:19:05 +00:00
|
|
|
|
if(!xConnection.is())
|
|
|
|
|
return NULL;
|
2001-02-05 15:17:40 +00:00
|
|
|
|
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::connectivity::OSQLParser& rParser( static_cast<OQueryController&>(getController()).getParser() );
|
2001-09-27 05:19:05 +00:00
|
|
|
|
OQueryTableWindow* pWin = static_cast<OQueryTableWindow*>(pEntry->GetTabWindow());
|
2001-02-05 08:35:57 +00:00
|
|
|
|
|
2001-09-27 05:19:05 +00:00
|
|
|
|
String sTest(_sCriteria);
|
|
|
|
|
// special handling for functions
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if ( pEntry->GetFunctionType() & (FKT_OTHER | FKT_AGGREGATE | FKT_NUMERIC) )
|
2001-09-27 05:19:05 +00:00
|
|
|
|
{
|
|
|
|
|
// we have a function here so we have to distinguish the type of return value
|
|
|
|
|
String sFunction;
|
2002-08-30 10:13:38 +00:00
|
|
|
|
if ( pEntry->isNumericOrAggreateFunction() )
|
2001-09-27 05:19:05 +00:00
|
|
|
|
sFunction = pEntry->GetFunction();
|
2007-11-01 14:31:21 +00:00
|
|
|
|
|
2007-09-26 13:52:43 +00:00
|
|
|
|
if ( !sFunction.Len() )
|
2001-09-27 05:19:05 +00:00
|
|
|
|
sFunction = pEntry->GetField();
|
|
|
|
|
|
2012-01-02 10:55:27 +00:00
|
|
|
|
if (comphelper::string::getTokenCount(sFunction, '(') > 1)
|
2001-09-27 05:19:05 +00:00
|
|
|
|
sFunction = sFunction.GetToken(0,'('); // this should be the name of the function
|
2002-08-30 10:13:38 +00:00
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
sal_Int32 nType = ::connectivity::OSQLParser::getFunctionReturnType(sFunction,&rParser.getContext());
|
2004-03-15 11:43:43 +00:00
|
|
|
|
if ( nType == DataType::OTHER || (!sFunction.Len() && pEntry->isNumericOrAggreateFunction()) )
|
|
|
|
|
{
|
|
|
|
|
// first try the international version
|
|
|
|
|
::rtl::OUString sSql;
|
|
|
|
|
sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * "));
|
|
|
|
|
sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x WHERE "));
|
|
|
|
|
sSql += pEntry->GetField();
|
|
|
|
|
sSql += _sCriteria;
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2008-06-25 11:52:59 +00:00
|
|
|
|
::std::auto_ptr<OSQLParseNode> pParseNode( rParser.parseTree( _rsErrorMessage, sSql, sal_True ) );
|
2011-09-22 15:00:08 +01:00
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
2002-08-30 10:13:38 +00:00
|
|
|
|
nType = DataType::DOUBLE;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
if ( pParseNode.get() )
|
2004-03-15 11:43:43 +00:00
|
|
|
|
{
|
|
|
|
|
OSQLParseNode* pColumnRef = pParseNode->getByRule(OSQLParseNode::column_ref);
|
|
|
|
|
if ( pColumnRef )
|
|
|
|
|
{
|
|
|
|
|
OTableFieldDescRef aField = new OTableFieldDesc();
|
|
|
|
|
if ( eOk == FillDragInfo(this,pColumnRef,aField) )
|
|
|
|
|
{
|
|
|
|
|
nType = aField->GetDataType();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-09-27 05:19:05 +00:00
|
|
|
|
|
2003-12-01 09:38:33 +00:00
|
|
|
|
Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
|
2001-09-27 05:19:05 +00:00
|
|
|
|
parse::OParseColumn* pColumn = new parse::OParseColumn( pEntry->GetField(),
|
2010-01-13 08:44:34 +01:00
|
|
|
|
::rtl::OUString(),
|
2001-09-27 05:19:05 +00:00
|
|
|
|
::rtl::OUString(),
|
|
|
|
|
::rtl::OUString(),
|
|
|
|
|
ColumnValue::NULLABLE_UNKNOWN,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
nType,
|
|
|
|
|
sal_False,
|
|
|
|
|
sal_False,
|
2012-11-01 14:19:14 +01:00
|
|
|
|
xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
|
|
|
|
|
::rtl::OUString(),
|
|
|
|
|
::rtl::OUString(),
|
|
|
|
|
::rtl::OUString());
|
2001-09-27 05:19:05 +00:00
|
|
|
|
_rxColumn = pColumn;
|
|
|
|
|
pColumn->setFunction(sal_True);
|
|
|
|
|
pColumn->setRealName(pEntry->GetField());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (pWin)
|
|
|
|
|
{
|
|
|
|
|
Reference<XNameAccess> xColumns = pWin->GetOriginalColumns();
|
|
|
|
|
if (xColumns.is() && xColumns->hasByName(pEntry->GetField()))
|
|
|
|
|
xColumns->getByName(pEntry->GetField()) >>= _rxColumn;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-10 14:41:12 +00:00
|
|
|
|
OSQLParseNode* pParseNode = rParser.predicateTree( _rsErrorMessage,
|
2001-09-27 05:19:05 +00:00
|
|
|
|
sTest,
|
2008-06-25 11:52:59 +00:00
|
|
|
|
static_cast<OQueryController&>(getController()).getNumberFormatter(),
|
2001-09-27 05:19:05 +00:00
|
|
|
|
_rxColumn);
|
|
|
|
|
return pParseNode;
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-10-22 08:57:52 +00:00
|
|
|
|
void OQueryDesignView::GetFocus()
|
|
|
|
|
{
|
2002-05-06 08:45:36 +00:00
|
|
|
|
OQueryView::GetFocus();
|
|
|
|
|
if ( m_pSelectionBox && !m_pSelectionBox->HasChildPathFocus() )
|
2001-10-22 08:57:52 +00:00
|
|
|
|
{
|
2012-02-11 12:37:03 +08:00
|
|
|
|
// first we have to deactivate the current cell to refill when necessary
|
2002-05-22 10:31:21 +00:00
|
|
|
|
m_pSelectionBox->DeactivateCell();
|
2001-10-22 08:57:52 +00:00
|
|
|
|
m_pSelectionBox->ActivateCell(m_pSelectionBox->GetCurRow(), m_pSelectionBox->GetCurColumnId());
|
2002-05-06 08:45:36 +00:00
|
|
|
|
m_pSelectionBox->GrabFocus();
|
2001-10-22 08:57:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-10-23 11:30:27 +00:00
|
|
|
|
void OQueryDesignView::reset()
|
|
|
|
|
{
|
|
|
|
|
m_pTableView->ClearAll();
|
|
|
|
|
m_pTableView->ReSync();
|
|
|
|
|
}
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::setNoneVisbleRow(sal_Int32 _nRows)
|
|
|
|
|
{
|
|
|
|
|
m_pSelectionBox->SetNoneVisbleRow(_nRows);
|
|
|
|
|
}
|
2010-02-16 15:21:07 +01:00
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void OQueryDesignView::initByFieldDescriptions( const Sequence< PropertyValue >& i_rFieldDescriptions )
|
|
|
|
|
{
|
|
|
|
|
OQueryController& rController = static_cast< OQueryController& >( getController() );
|
|
|
|
|
|
|
|
|
|
m_pSelectionBox->PreFill();
|
|
|
|
|
m_pSelectionBox->SetReadOnly( rController.isReadOnly() );
|
|
|
|
|
m_pSelectionBox->Fill();
|
|
|
|
|
|
|
|
|
|
for ( const PropertyValue* field = i_rFieldDescriptions.getConstArray();
|
|
|
|
|
field != i_rFieldDescriptions.getConstArray() + i_rFieldDescriptions.getLength();
|
|
|
|
|
++field
|
|
|
|
|
)
|
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
|
::rtl::Reference< OTableFieldDesc > pField( new OTableFieldDesc() );
|
2010-02-16 15:21:07 +01:00
|
|
|
|
pField->Load( *field, true );
|
|
|
|
|
InsertField( pField, sal_True, sal_False );
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-25 14:28:03 +01:00
|
|
|
|
rController.ClearUndoManager();
|
2010-02-16 15:21:07 +01:00
|
|
|
|
m_pSelectionBox->Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-23 11:30:27 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-12-01 12:31:27 +00:00
|
|
|
|
bool OQueryDesignView::initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo )
|
2002-02-06 07:08:30 +00:00
|
|
|
|
{
|
2007-11-01 14:31:21 +00:00
|
|
|
|
SqlParseError eErrorCode = eNativeMode;
|
2008-06-25 11:52:59 +00:00
|
|
|
|
m_rController.clearError();
|
2008-12-01 12:31:27 +00:00
|
|
|
|
|
2007-11-01 14:31:21 +00:00
|
|
|
|
try
|
2002-05-06 08:45:36 +00:00
|
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
|
eErrorCode = InitFromParseNodeImpl( this, m_pSelectionBox );
|
|
|
|
|
|
|
|
|
|
if ( eErrorCode != eOk )
|
2007-11-01 14:31:21 +00:00
|
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
|
if ( !m_rController.hasError() )
|
|
|
|
|
m_rController.appendError( getParseErrorMessage( eErrorCode ) );
|
2002-05-06 08:45:36 +00:00
|
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
|
if ( _pErrorInfo )
|
|
|
|
|
{
|
|
|
|
|
*_pErrorInfo = m_rController.getError();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_rController.displayError();
|
|
|
|
|
}
|
2007-11-01 14:31:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-01 12:31:27 +00:00
|
|
|
|
catch ( const Exception& )
|
2007-11-01 14:31:21 +00:00
|
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2002-05-06 08:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
return eErrorCode == eOk;
|
2002-02-06 07:08:30 +00:00
|
|
|
|
}
|
2011-10-30 12:35:22 +01:00
|
|
|
|
|
|
|
|
|
// Utility function for fillFunctionInfo
|
|
|
|
|
namespace {
|
|
|
|
|
sal_Int32 char_datatype(const::connectivity::OSQLParseNode* pDataType, const unsigned int offset) {
|
|
|
|
|
int cnt = pDataType->count() - offset;
|
|
|
|
|
if ( cnt < 0 )
|
|
|
|
|
{
|
|
|
|
|
OSL_FAIL("internal error in decoding character datatype specification");
|
|
|
|
|
return DataType::VARCHAR;
|
|
|
|
|
}
|
|
|
|
|
else if ( cnt == 0 )
|
|
|
|
|
{
|
|
|
|
|
if ( offset == 0 )
|
|
|
|
|
{
|
|
|
|
|
// The datatype is the node itself
|
|
|
|
|
if ( SQL_ISTOKENOR2 (pDataType, CHARACTER, CHAR) )
|
|
|
|
|
return DataType::CHAR;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, VARCHAR) )
|
|
|
|
|
return DataType::VARCHAR;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, CLOB) )
|
|
|
|
|
return DataType::CLOB;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OSL_FAIL("unknown/unexpected token in decoding character datatype specification");
|
|
|
|
|
return DataType::VARCHAR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// No child left to read!
|
|
|
|
|
OSL_FAIL("incomplete datatype in decoding character datatype specification");
|
|
|
|
|
return DataType::VARCHAR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( SQL_ISTOKEN(pDataType->getChild(offset), NATIONAL) )
|
|
|
|
|
return char_datatype(pDataType, offset+1);
|
|
|
|
|
else if ( SQL_ISTOKENOR3(pDataType->getChild(offset), CHARACTER, CHAR, NCHAR) )
|
|
|
|
|
{
|
|
|
|
|
if ( cnt > 2 && SQL_ISTOKEN(pDataType->getChild(offset+1), LARGE) && SQL_ISTOKEN(pDataType->getChild(offset+2), OBJECT) )
|
|
|
|
|
return DataType::CLOB;
|
|
|
|
|
else if ( cnt > 1 && SQL_ISTOKEN(pDataType->getChild(offset+1), VARYING) )
|
|
|
|
|
return DataType::VARCHAR;
|
|
|
|
|
else
|
|
|
|
|
return DataType::CHAR;
|
|
|
|
|
}
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType->getChild(offset), VARCHAR) )
|
|
|
|
|
return DataType::VARCHAR;
|
|
|
|
|
else if ( SQL_ISTOKENOR2 (pDataType->getChild(offset), CLOB, NCLOB) )
|
|
|
|
|
return DataType::CLOB;
|
|
|
|
|
|
|
|
|
|
OSL_FAIL("unrecognised character datatype");
|
|
|
|
|
return DataType::VARCHAR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 12:56:23 +01:00
|
|
|
|
//------------------------------------------------------------------------------
|
2011-10-30 12:35:22 +01:00
|
|
|
|
// Try to guess the type of an expression in simple cases.
|
|
|
|
|
// Originally meant to be called only on a function call (hence the misnomer),
|
|
|
|
|
// but now tries to do the best it can also in other cases.
|
|
|
|
|
// Don't completely rely on fillFunctionInfo,
|
|
|
|
|
// it won't look at the function's arguments to find the return type
|
|
|
|
|
// (in particular, in the case of general_set_fct,
|
|
|
|
|
// the return type is the type of the argument;
|
|
|
|
|
// if that is (as is typical) a column reference,
|
|
|
|
|
// it is the type of the column).
|
|
|
|
|
// TODO: There is similar "guess the expression's type" code in several places:
|
|
|
|
|
// SelectionBrowseBox.cxx: OSelectionBrowseBox::saveField
|
|
|
|
|
// QueryDesignView.cxx: InstallFields, GetOrderCriteria, GetGroupCriteria
|
|
|
|
|
// If possible, they should be factorised into this function
|
|
|
|
|
// (which should then be renamed...)
|
|
|
|
|
|
2009-11-26 12:56:23 +01:00
|
|
|
|
void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* pNode
|
|
|
|
|
,const ::rtl::OUString& sFunctionTerm
|
|
|
|
|
,OTableFieldDescRef& aInfo)
|
|
|
|
|
{
|
2011-10-30 12:35:22 +01:00
|
|
|
|
// get the type of the expression, as far as easily possible
|
2009-11-26 12:56:23 +01:00
|
|
|
|
OQueryController& rController = static_cast<OQueryController&>(getController());
|
|
|
|
|
sal_Int32 nDataType = DataType::DOUBLE;
|
2011-10-30 12:35:22 +01:00
|
|
|
|
switch(pNode->getNodeType())
|
|
|
|
|
{
|
|
|
|
|
case SQL_NODE_CONCAT:
|
|
|
|
|
case SQL_NODE_STRING:
|
|
|
|
|
nDataType = DataType::VARCHAR;
|
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_INTNUM:
|
|
|
|
|
nDataType = DataType::INTEGER;
|
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_APPROXNUM:
|
|
|
|
|
nDataType = DataType::DOUBLE;
|
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_DATE:
|
|
|
|
|
case SQL_NODE_ACCESS_DATE:
|
|
|
|
|
nDataType = DataType::TIMESTAMP;
|
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_COMPARISON:
|
|
|
|
|
case SQL_NODE_EQUAL:
|
|
|
|
|
case SQL_NODE_LESS:
|
|
|
|
|
case SQL_NODE_GREAT:
|
|
|
|
|
case SQL_NODE_LESSEQ:
|
|
|
|
|
case SQL_NODE_GREATEQ:
|
|
|
|
|
case SQL_NODE_NOTEQUAL:
|
|
|
|
|
nDataType = DataType::BOOLEAN;
|
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_NAME:
|
|
|
|
|
case SQL_NODE_LISTRULE:
|
|
|
|
|
case SQL_NODE_COMMALISTRULE:
|
|
|
|
|
case SQL_NODE_KEYWORD:
|
|
|
|
|
case SQL_NODE_AMMSC: //??
|
|
|
|
|
case SQL_NODE_PUNCTUATION:
|
|
|
|
|
OSL_FAIL("Unexpected SQL Node Type");
|
|
|
|
|
break;
|
|
|
|
|
case SQL_NODE_RULE:
|
|
|
|
|
switch(pNode->getKnownRuleID())
|
|
|
|
|
{
|
|
|
|
|
case OSQLParseNode::select_statement:
|
|
|
|
|
case OSQLParseNode::table_exp:
|
|
|
|
|
case OSQLParseNode::table_ref_commalist:
|
|
|
|
|
case OSQLParseNode::table_ref:
|
|
|
|
|
case OSQLParseNode::catalog_name:
|
|
|
|
|
case OSQLParseNode::schema_name:
|
|
|
|
|
case OSQLParseNode::table_name:
|
|
|
|
|
case OSQLParseNode::opt_column_commalist:
|
|
|
|
|
case OSQLParseNode::column_commalist:
|
|
|
|
|
case OSQLParseNode::column_ref_commalist:
|
|
|
|
|
case OSQLParseNode::column_ref:
|
|
|
|
|
case OSQLParseNode::opt_order_by_clause:
|
|
|
|
|
case OSQLParseNode::ordering_spec_commalist:
|
|
|
|
|
case OSQLParseNode::ordering_spec:
|
|
|
|
|
case OSQLParseNode::opt_asc_desc:
|
|
|
|
|
case OSQLParseNode::where_clause:
|
|
|
|
|
case OSQLParseNode::opt_where_clause:
|
|
|
|
|
case OSQLParseNode::opt_escape:
|
|
|
|
|
case OSQLParseNode::scalar_exp_commalist:
|
|
|
|
|
case OSQLParseNode::scalar_exp: // Seems to never be generated?
|
|
|
|
|
case OSQLParseNode::parameter_ref:
|
|
|
|
|
case OSQLParseNode::parameter:
|
|
|
|
|
case OSQLParseNode::range_variable:
|
|
|
|
|
case OSQLParseNode::delete_statement_positioned:
|
|
|
|
|
case OSQLParseNode::delete_statement_searched:
|
|
|
|
|
case OSQLParseNode::update_statement_positioned:
|
|
|
|
|
case OSQLParseNode::update_statement_searched:
|
|
|
|
|
case OSQLParseNode::assignment_commalist:
|
|
|
|
|
case OSQLParseNode::assignment:
|
|
|
|
|
case OSQLParseNode::insert_statement:
|
|
|
|
|
case OSQLParseNode::insert_atom_commalist:
|
|
|
|
|
case OSQLParseNode::insert_atom:
|
|
|
|
|
case OSQLParseNode::from_clause:
|
|
|
|
|
case OSQLParseNode::qualified_join:
|
|
|
|
|
case OSQLParseNode::cross_union:
|
|
|
|
|
case OSQLParseNode::select_sublist:
|
|
|
|
|
case OSQLParseNode::join_type:
|
|
|
|
|
case OSQLParseNode::named_columns_join:
|
|
|
|
|
case OSQLParseNode::joined_table:
|
|
|
|
|
case OSQLParseNode::sql_not:
|
|
|
|
|
case OSQLParseNode::manipulative_statement:
|
|
|
|
|
case OSQLParseNode::value_exp_commalist:
|
|
|
|
|
case OSQLParseNode::union_statement:
|
|
|
|
|
case OSQLParseNode::outer_join_type:
|
|
|
|
|
case OSQLParseNode::selection:
|
|
|
|
|
case OSQLParseNode::base_table_def:
|
|
|
|
|
case OSQLParseNode::base_table_element_commalist:
|
|
|
|
|
case OSQLParseNode::data_type:
|
|
|
|
|
case OSQLParseNode::column_def:
|
|
|
|
|
case OSQLParseNode::table_node:
|
|
|
|
|
case OSQLParseNode::as: // Seems to never be generated?
|
|
|
|
|
case OSQLParseNode::op_column_commalist:
|
|
|
|
|
case OSQLParseNode::table_primary_as_range_column:
|
|
|
|
|
case OSQLParseNode::character_string_type:
|
|
|
|
|
OSL_FAIL("Unexpected SQL RuleID");
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::column:
|
|
|
|
|
case OSQLParseNode::column_val:
|
|
|
|
|
OSL_FAIL("Cannot guess column type");
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::values_or_query_spec:
|
|
|
|
|
OSL_FAIL("Cannot guess VALUES type");
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::derived_column:
|
|
|
|
|
OSL_FAIL("Cannot guess computed column type");
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::subquery:
|
|
|
|
|
OSL_FAIL("Cannot guess subquery return type");
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::search_condition:
|
|
|
|
|
case OSQLParseNode::comparison_predicate:
|
|
|
|
|
case OSQLParseNode::between_predicate:
|
|
|
|
|
case OSQLParseNode::like_predicate:
|
|
|
|
|
case OSQLParseNode::test_for_null:
|
|
|
|
|
case OSQLParseNode::predicate_check: // Seems to never be generated?
|
|
|
|
|
case OSQLParseNode::boolean_term:
|
|
|
|
|
case OSQLParseNode::boolean_primary:
|
|
|
|
|
case OSQLParseNode::in_predicate:
|
|
|
|
|
case OSQLParseNode::existence_test:
|
|
|
|
|
case OSQLParseNode::unique_test:
|
|
|
|
|
case OSQLParseNode::all_or_any_predicate:
|
|
|
|
|
case OSQLParseNode::join_condition:
|
|
|
|
|
case OSQLParseNode::boolean_factor:
|
|
|
|
|
case OSQLParseNode::boolean_test:
|
|
|
|
|
case OSQLParseNode::comparison_predicate_part_2:
|
|
|
|
|
case OSQLParseNode::parenthesized_boolean_value_expression:
|
|
|
|
|
case OSQLParseNode::other_like_predicate_part_2:
|
|
|
|
|
case OSQLParseNode::between_predicate_part_2:
|
|
|
|
|
nDataType = DataType::BOOLEAN;
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::num_value_exp:
|
|
|
|
|
case OSQLParseNode::extract_exp:
|
|
|
|
|
case OSQLParseNode::term:
|
|
|
|
|
case OSQLParseNode::factor:
|
|
|
|
|
// Might by an integer or a float; take the most generic
|
|
|
|
|
nDataType = DataType::DOUBLE;
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::value_exp_primary:
|
|
|
|
|
case OSQLParseNode::value_exp:
|
|
|
|
|
case OSQLParseNode::odbc_call_spec:
|
|
|
|
|
// Really, we don't know. Let the default.
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::position_exp:
|
|
|
|
|
case OSQLParseNode::length_exp:
|
|
|
|
|
nDataType = DataType::INTEGER;
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::char_value_exp:
|
|
|
|
|
case OSQLParseNode::char_value_fct:
|
|
|
|
|
case OSQLParseNode::fold:
|
|
|
|
|
case OSQLParseNode::char_substring_fct:
|
|
|
|
|
case OSQLParseNode::char_factor:
|
|
|
|
|
case OSQLParseNode::concatenation:
|
|
|
|
|
nDataType = DataType::VARCHAR;
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::datetime_primary:
|
|
|
|
|
nDataType = DataType::TIMESTAMP;
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::bit_value_fct:
|
|
|
|
|
nDataType = DataType::BINARY;
|
|
|
|
|
break;
|
|
|
|
|
case OSQLParseNode::general_set_fct: // May depend on argument; ignore that for now
|
|
|
|
|
case OSQLParseNode::set_fct_spec:
|
|
|
|
|
{
|
|
|
|
|
if (pNode->count() == 0)
|
|
|
|
|
{
|
|
|
|
|
// This is not a function call, no sense to continue with a function return type lookup
|
|
|
|
|
OSL_FAIL("Got leaf SQL node where non-leaf expected");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
const OSQLParseNode* pFunctionName = pNode->getChild(0);
|
|
|
|
|
if ( SQL_ISPUNCTUATION(pFunctionName,"{") )
|
|
|
|
|
{
|
|
|
|
|
if ( pNode->count() == 3 )
|
|
|
|
|
return fillFunctionInfo( pNode->getChild(1), sFunctionTerm, aInfo );
|
|
|
|
|
else
|
|
|
|
|
OSL_FAIL("ODBC escape not in recognised form");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( SQL_ISRULEOR2(pNode,length_exp,char_value_fct) )
|
|
|
|
|
pFunctionName = pFunctionName->getChild(0);
|
2009-11-26 12:56:23 +01:00
|
|
|
|
|
2011-10-30 12:35:22 +01:00
|
|
|
|
::rtl::OUString sFunctionName = pFunctionName->getTokenValue();
|
2011-12-19 18:10:37 -02:00
|
|
|
|
if ( sFunctionName.isEmpty() )
|
2011-10-30 12:35:22 +01:00
|
|
|
|
sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8);
|
2009-11-26 12:56:23 +01:00
|
|
|
|
|
2011-10-30 12:35:22 +01:00
|
|
|
|
nDataType = OSQLParser::getFunctionReturnType(
|
|
|
|
|
sFunctionName
|
|
|
|
|
,&rController.getParser().getContext());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case OSQLParseNode::odbc_fct_spec:
|
|
|
|
|
{
|
|
|
|
|
if (pNode->count() != 2)
|
|
|
|
|
{
|
|
|
|
|
OSL_FAIL("interior of ODBC escape not in recognised shape");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const OSQLParseNode* const pEscapeType = pNode->getChild(0);
|
|
|
|
|
if (SQL_ISTOKEN(pEscapeType, TS))
|
|
|
|
|
nDataType = DataType::TIMESTAMP;
|
|
|
|
|
else if (SQL_ISTOKEN(pEscapeType, D))
|
|
|
|
|
nDataType = DataType::DATE;
|
|
|
|
|
else if (SQL_ISTOKEN(pEscapeType, T))
|
|
|
|
|
nDataType = DataType::TIME;
|
|
|
|
|
else if (SQL_ISTOKEN(pEscapeType, FN))
|
|
|
|
|
return fillFunctionInfo( pNode->getChild(1), sFunctionTerm, aInfo );
|
|
|
|
|
else
|
|
|
|
|
OSL_FAIL("Unknown ODBC escape");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case OSQLParseNode::cast_spec:
|
|
|
|
|
{
|
|
|
|
|
if ( pNode->count() != 6 || !SQL_ISTOKEN(pNode->getChild(3), AS) )
|
|
|
|
|
{
|
|
|
|
|
OSL_FAIL("CAST not in recognised shape");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
const OSQLParseNode *pCastTarget = pNode->getChild(4);
|
|
|
|
|
if ( SQL_ISTOKENOR2(pCastTarget, INTEGER, INT) )
|
|
|
|
|
nDataType = DataType::INTEGER;
|
|
|
|
|
else if ( SQL_ISTOKEN(pCastTarget, SMALLINT) )
|
|
|
|
|
nDataType = DataType::SMALLINT;
|
|
|
|
|
else if ( SQL_ISTOKEN(pCastTarget, BIGINT) )
|
|
|
|
|
nDataType = DataType::BIGINT;
|
|
|
|
|
else if ( SQL_ISTOKEN(pCastTarget, FLOAT) )
|
|
|
|
|
nDataType = DataType::FLOAT;
|
|
|
|
|
else if ( SQL_ISTOKEN(pCastTarget, REAL) )
|
|
|
|
|
nDataType = DataType::REAL;
|
|
|
|
|
else if ( SQL_ISTOKEN(pCastTarget, DOUBLE) )
|
|
|
|
|
nDataType = DataType::DOUBLE;
|
|
|
|
|
else if ( SQL_ISTOKEN(pCastTarget, BOOLEAN) )
|
|
|
|
|
nDataType = DataType::BOOLEAN;
|
|
|
|
|
else if ( SQL_ISTOKEN(pCastTarget, DATE) )
|
|
|
|
|
nDataType = DataType::DATE;
|
|
|
|
|
else if ( pCastTarget->count() > 0 )
|
|
|
|
|
{
|
|
|
|
|
const OSQLParseNode *pDataType = pCastTarget->getChild(0);
|
|
|
|
|
while (pDataType->count() > 0)
|
|
|
|
|
{
|
|
|
|
|
pCastTarget = pDataType;
|
|
|
|
|
pDataType = pDataType->getChild(0);
|
|
|
|
|
}
|
|
|
|
|
if ( SQL_ISTOKEN (pDataType, TIME) )
|
|
|
|
|
nDataType = DataType::TIME;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, TIMESTAMP) )
|
|
|
|
|
nDataType = DataType::TIMESTAMP;
|
|
|
|
|
else if ( SQL_ISTOKENOR3 (pDataType, CHARACTER, CHAR, NCHAR) )
|
|
|
|
|
nDataType = char_datatype(pCastTarget, 0);
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, VARCHAR) )
|
|
|
|
|
nDataType = DataType::VARCHAR;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, CLOB) )
|
|
|
|
|
nDataType = DataType::CLOB;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, NATIONAL) )
|
|
|
|
|
nDataType = char_datatype(pCastTarget, 1);
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, BINARY) )
|
|
|
|
|
{
|
|
|
|
|
if ( pCastTarget->count() > 2 && SQL_ISTOKEN(pCastTarget->getChild(1), LARGE) && SQL_ISTOKEN(pCastTarget->getChild(2), OBJECT) )
|
|
|
|
|
nDataType = DataType::BLOB;
|
|
|
|
|
else if ( pCastTarget->count() > 1 && SQL_ISTOKEN(pCastTarget->getChild(1), VARYING) )
|
|
|
|
|
nDataType = DataType::VARBINARY;
|
|
|
|
|
else
|
|
|
|
|
nDataType = DataType::BINARY;
|
|
|
|
|
}
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, VARBINARY) )
|
|
|
|
|
nDataType = DataType::VARBINARY;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, BLOB) )
|
|
|
|
|
nDataType = DataType::BLOB;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, NUMERIC) )
|
|
|
|
|
nDataType = DataType::NUMERIC;
|
|
|
|
|
else if ( SQL_ISTOKENOR2 (pDataType, DECIMAL, DEC) )
|
|
|
|
|
nDataType = DataType::DECIMAL;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, FLOAT) )
|
|
|
|
|
nDataType = DataType::FLOAT;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, DOUBLE) )
|
|
|
|
|
nDataType = DataType::DOUBLE;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, TIME) )
|
|
|
|
|
nDataType = DataType::TIME;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, TIMESTAMP) )
|
|
|
|
|
nDataType = DataType::TIMESTAMP;
|
|
|
|
|
else if ( SQL_ISTOKEN (pDataType, INTERVAL) )
|
|
|
|
|
// Not in DataType published constant (because not in JDBC...)
|
|
|
|
|
nDataType = DataType::VARCHAR;
|
|
|
|
|
else
|
|
|
|
|
OSL_FAIL("Failed to decode CAST target");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
OSL_FAIL("Could not decipher CAST target");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
OSL_FAIL("Unknown SQL RuleID");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
OSL_FAIL("Unknown SQL Node Type");
|
|
|
|
|
break;
|
2009-11-26 12:56:23 +01:00
|
|
|
|
}
|
2011-10-30 12:35:22 +01:00
|
|
|
|
|
2009-11-26 12:56:23 +01:00
|
|
|
|
aInfo->SetDataType(nDataType);
|
|
|
|
|
aInfo->SetFieldType(TAB_NORMAL_FIELD);
|
2011-10-30 13:05:17 +01:00
|
|
|
|
aInfo->SetField(sFunctionTerm);
|
2009-11-26 12:56:23 +01:00
|
|
|
|
aInfo->SetTabWindow(NULL);
|
|
|
|
|
}
|
2002-02-06 07:08:30 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
2010-10-12 15:59:03 +02:00
|
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|