office-gobmx/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
Vladimir Glazounov e200eed28c CWS-TOOLING: integrate CWS dba32d
2009-06-30 08:58:13 +0200 fs  r273488 : merging latest changes from CWS dba32c
2009-06-29 11:40:42 +0200 oj  r273459 : #i101652# fix token handling
2009-06-26 09:27:30 +0200 oj  r273394 : #i101994# wrong condition checked
2009-06-22 12:09:04 +0200 fs  r273210 : merging latest changes from CWS dba32c
2009-06-18 11:01:06 +0200 fs  r273108 : merge latest changes from CWS dba32c
2009-06-17 14:19:33 +0200 oj  r273072 : handle images at the correct position
2009-06-17 13:37:19 +0200 oj  r273067 : compile error
2009-06-17 13:35:58 +0200 oj  r273066 : #i102201# handle images
2009-06-17 13:27:21 +0200 oj  r273065 : #i80917# disable checkbox for internal copy
2009-06-17 13:25:38 +0200 oj  r273064 : #i80917# disable checkbox for internal copy
2009-06-15 12:59:16 +0200 fs  r272978 : merging latest changes from CWS dba32c
2009-06-15 10:45:58 +0200 fs  r272967 : CWS-TOOLING: rebase CWS dba32d to trunk@272827 (milestone: DEV300:m50)
2009-06-15 08:41:05 +0200 fs  r272960 : merging changes from CWS dba32c (resulting from rebasing dba32c to m50)
2009-06-03 12:22:32 +0200 fs  r272554 : merging latest changes from CWS dba32c
2009-06-03 11:11:27 +0200 fs  r272549 : #i100818# special treatment for DataAwareness not needed anymore
2009-06-03 11:07:01 +0200 fs  r272548 : #i10000# removed package declaration
2009-06-03 09:21:03 +0200 oj  r272537 : #i93465# save window states
2009-06-03 08:56:25 +0200 oj  r272535 : solve compiler warnings
2009-06-03 08:55:02 +0200 oj  r272534 : #i102295# export shapes i the first cell
2009-06-03 07:35:18 +0200 oj  r272533 : #i101994# check for - and + prefix
2009-06-03 06:51:38 +0200 oj  r272531 : #i101463# use uncomposed table name
2009-06-03 06:33:06 +0200 oj  r272530 : #i102019# word corrected
2009-06-02 14:58:28 +0200 fs  r272507 : #i102443# call initializeParser from LoadFinished
2009-06-02 14:30:10 +0200 oj  r272504 : #i102019# introduce static ints
2009-06-02 13:51:02 +0200 oj  r272501 : #i102439# wrong method used
2009-06-02 13:44:09 +0200 fs  r272500 : #i102440# when tampering with Order/GroupBy, reset the cached columns
2009-06-02 10:53:01 +0200 fs  r272487 : #i102234# preserve the original filter when using a 0=1 filter
2009-06-02 10:21:21 +0200 oj  r272486 : #i100535# handle time values as float
2009-06-02 10:19:07 +0200 fs  r272485 : merging latest changes from CWS dba32c
2009-05-29 16:00:15 +0200 fs  r272467 : merging latest changes from dba32c
2009-05-29 15:31:25 +0200 fs  r272462 : merging latest changes from dba32c
2009-05-29 10:58:03 +0200 oj  r272438 : #101135# export embedded-text
2009-05-29 08:17:57 +0200 oj  r272431 : #i80917# make attribute not optional
2009-05-29 08:17:32 +0200 oj  r272430 : remoe unused token
2009-05-29 07:17:15 +0200 oj  r272429 : #i80917# make attribute not optional
2009-05-28 12:48:14 +0200 oj  r272401 : #i102201# insert images in context menu
2009-05-28 12:47:44 +0200 oj  r272400 : #i80917# add new attribute to handle first line
2009-05-28 12:16:12 +0200 oj  r272397 : #i96134# add / to path when it doesn't exist
2009-05-28 12:11:08 +0200 oj  r272390 : #i80917# add new attribute to handle first line
2009-05-28 11:33:35 +0200 oj  r272388 : #i101652# add new checkbox to handle header line as column names
2009-05-28 11:30:15 +0200 oj  r272387 : #i101652# add localize
2009-05-28 11:15:53 +0200 oj  r272386 : merge from dba32c
2009-05-28 09:08:25 +0200 fs  r272378 : merged a build fix from CWS dba32c
2009-07-06 09:00:26 +00:00

282 lines
16 KiB
C++

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SingleSelectQueryComposer.hxx,v $
* $Revision: 1.9 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX
#define DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX
#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_
#include <com/sun/star/sdb/XParametersSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
#include <com/sun/star/script/XTypeConverter.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE5_HXX_
#include <cppuhelper/implbase5.hxx>
#endif
#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
#include <connectivity/sqliterator.hxx>
#endif
#ifndef _CONNECTIVITY_SQLPARSE_HXX
#include <connectivity/sqlparse.hxx>
#endif
#ifndef _DBASHARED_APITOOLS_HXX_
#include "apitools.hxx"
#endif
#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
#include <comphelper/broadcasthelper.hxx>
#endif
#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif
#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
#include <comphelper/proparrhlp.hxx>
#endif
#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
#include <comphelper/propertycontainer.hxx>
#endif
#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
#include <comphelper/componentcontext.hxx>
#endif
#include <memory>
namespace com { namespace sun { namespace star { namespace util {
class XNumberFormatsSupplier;
class XNumberFormatter;
}}}}
namespace dbaccess
{
typedef ::cppu::ImplHelper5< ::com::sun::star::sdb::XSingleSelectQueryComposer,
::com::sun::star::sdb::XParametersSupplier,
::com::sun::star::sdbcx::XColumnsSupplier,
::com::sun::star::sdbcx::XTablesSupplier,
::com::sun::star::lang::XServiceInfo > OSingleSelectQueryComposer_BASE;
class OPrivateColumns;
class OPrivateTables;
class OSingleSelectQueryComposer : public ::comphelper::OMutexAndBroadcastHelper
,public OSubComponent
,public ::comphelper::OPropertyContainer
,public ::comphelper::OPropertyArrayUsageHelper < OSingleSelectQueryComposer >
,public OSingleSelectQueryComposer_BASE
{
enum SQLPart
{
Where = 0, // the 0 is important, as it will be used as index into arrays
Group,
Having,
Order,
SQLPartCount
};
inline void incSQLPart( SQLPart& e ) { e = (SQLPart)(1 + (size_t)e); }
enum EColumnType
{
SelectColumns = 0,
GroupByColumns = 1,
OrderColumns = 2,
ParameterColumns = 3
};
typedef ::std::const_mem_fun_t< const ::connectivity::OSQLParseNode*, ::connectivity::OSQLParseTreeIterator >
TGetParseNode;
::connectivity::OSQLParser m_aSqlParser;
::connectivity::OSQLParseTreeIterator m_aSqlIterator; // the iterator for the complete statement
::connectivity::OSQLParseTreeIterator m_aAdditiveIterator; // the iterator for the "additive statement" (means without the clauses of the elementary statement)
::std::vector<OPrivateColumns*> m_aColumnsCollection; // used for columns and parameters of old queries
::std::vector<OPrivateTables*> m_aTablesCollection;
::std::vector< ::rtl::OUString > m_aElementaryParts; // the filter/groupby/having/order of the elementary statement
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionTables;
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns;
::comphelper::ComponentContext m_aContext;
::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
::std::vector<OPrivateColumns*> m_aCurrentColumns;
OPrivateTables* m_pTables; // currently used tables
::rtl::OUString m_aPureSelectSQL; // the pure select statement, without filter/order/groupby/having
::rtl::OUString m_sDecimalSep;
::com::sun::star::lang::Locale m_aLocale;
sal_Int32 m_nBoolCompareMode; // how to compare bool values
// <properties>
::rtl::OUString m_sOrignal;
// </properties>
sal_Bool setORCriteria(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator,
::std::vector< ::std::vector < ::com::sun::star::beans::PropertyValue > >& rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const;
sal_Bool setANDCriteria(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator,
::std::vector < ::com::sun::star::beans::PropertyValue > & rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const;
sal_Bool setComparsionPredicate(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator,
::std::vector < ::com::sun::star::beans::PropertyValue > & rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const;
::rtl::OUString getColumnName(::connectivity::OSQLParseNode* pColumnRef,::connectivity::OSQLParseTreeIterator& _rIterator) const;
::rtl::OUString getTableAlias(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) const;
sal_Int32 getPredicateType(::connectivity::OSQLParseNode * _pPredicate) const;
// clears all Columns,Parameters and tables and insert it to their vectors
void clearCurrentCollections();
// clears the columns collection given by EColumnType
void clearColumns( const EColumnType _eType );
/** retrieves a particular part of a statement
@param _rIterator
the iterator to use.
*/
::rtl::OUString getStatementPart( TGetParseNode& _aGetFunctor, ::connectivity::OSQLParseTreeIterator& _rIterator );
void setQuery_Impl( const ::rtl::OUString& command );
void setConditionByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column
, sal_Bool andCriteria
,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor);
/** getStructuredCondition returns the structured condition for the where or having clause
@param _aGetFunctor
A member function to get the correct parse node.
@return
The structured filter
*/
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >
getStructuredCondition( TGetParseNode& _aGetFunctor );
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >
setCurrentColumns( EColumnType _eType, const ::vos::ORef< ::connectivity::OSQLColumns >& _rCols );
//helper methods for mem_fun_t
inline bool implSetFilter(::rtl::OUString _sFilter) { setFilter(_sFilter); return true;}
inline bool implSetHavingClause(::rtl::OUString _sFilter) { setHavingClause(_sFilter); return true;}
/** returns the part of the seelect statement
@param _ePart
Which part should be returned.
@param _bWithKeyword
If <TRUE/> the keyword will be added too. Otherwise not.
@param _rIterator
The iterator to use.
@return
The part of the select statement.
*/
::rtl::OUString getSQLPart( SQLPart _ePart, ::connectivity::OSQLParseTreeIterator& _rIterator, sal_Bool _bWithKeyword );
/** retrieves the keyword for the given SQLPart
*/
::rtl::OUString getKeyword( SQLPart _ePart ) const;
/** sets a single "additive" clause, means a filter/groupby/having/order clause
*/
void setSingleAdditiveClause( SQLPart _ePart, const ::rtl::OUString& _rClause );
/** composes a statement from m_aPureSelectSQL and the 4 usual clauses
*/
::rtl::OUString composeStatementFromParts( const ::std::vector< ::rtl::OUString >& _rParts );
/** return the name of the column.
*/
::rtl::OUString impl_getColumnName_throw(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column);
protected:
virtual ~OSingleSelectQueryComposer();
public:
OSingleSelectQueryComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xTableSupplier,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
const ::comphelper::ComponentContext& _rContext);
void SAL_CALL disposing(void);
// ::com::sun::star::lang::XTypeProvider
DECLARE_TYPEPROVIDER( );
// com::sun::star::lang::XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
// ::com::sun::star::uno::XInterface
DECLARE_XINTERFACE( )
// XServiceInfo
DECLARE_SERVICE_INFO();
DECLARE_PROPERTYCONTAINER_DEFAULTS();
// ::com::sun::star::sdb::XSingleSelectQueryComposer
virtual ::rtl::OUString SAL_CALL getElementaryQuery() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setElementaryQuery( const ::rtl::OUString& _rElementary ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setFilter( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setStructuredFilter( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendGroupByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setGroup( const ::rtl::OUString& group ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setHavingClause( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setStructuredHavingClause( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendHavingClauseByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendOrderByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool ascending ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setOrder( const ::rtl::OUString& order ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
// XSingleSelectQueryAnalyzer
virtual ::rtl::OUString SAL_CALL getQuery( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setQuery( const ::rtl::OUString& command ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getFilter( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getGroup( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getGroupColumns( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getHavingClause( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredHavingClause( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getOrder( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getOrderColumns( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getQueryWithSubstitution( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
// XColumnsSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException);
// XTablesSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
// XParametersSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getParameters( ) throw(::com::sun::star::uno::RuntimeException);
};
}
#endif // DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX