2010-10-27 12:33:13 +01: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 .
|
|
|
|
*/
|
2007-11-21 15:05:27 +00:00
|
|
|
|
2013-11-05 02:18:53 +01:00
|
|
|
#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYCONTROLLER_HXX
|
|
|
|
#define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYCONTROLLER_HXX
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2001-02-28 09:11:33 +00:00
|
|
|
#include "JoinController.hxx"
|
2007-11-21 15:05:27 +00:00
|
|
|
#include "JoinTableView.hxx"
|
|
|
|
#include "querycontainerwindow.hxx"
|
2001-01-09 15:11:54 +00:00
|
|
|
#include "queryview.hxx"
|
2007-11-21 15:05:27 +00:00
|
|
|
#include "svx/ParseContext.hxx"
|
|
|
|
#include "TableFieldDescription.hxx"
|
|
|
|
|
|
|
|
#include <com/sun/star/io/XObjectInputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XObjectOutputStream.hpp>
|
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XAlterView.hpp>
|
|
|
|
|
2007-01-15 13:35:26 +00:00
|
|
|
#include <comphelper/proparrhlp.hxx>
|
2007-11-21 15:05:27 +00:00
|
|
|
#include <comphelper/propertycontainer.hxx>
|
2007-07-06 07:31:39 +00:00
|
|
|
#include <comphelper/uno3.hxx>
|
2007-11-21 15:05:27 +00:00
|
|
|
#include <connectivity/sqliterator.hxx>
|
2001-02-05 08:12:46 +00:00
|
|
|
#include <connectivity/sqlnode.hxx>
|
2007-11-21 15:05:27 +00:00
|
|
|
#include <connectivity/sqlparse.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/undo.hxx>
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2010-02-15 14:34:48 +01:00
|
|
|
namespace comphelper
|
|
|
|
{
|
|
|
|
class NamedValueCollection;
|
|
|
|
}
|
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
class OQueryContainerWindow;
|
2001-10-05 05:49:21 +00:00
|
|
|
|
2007-01-15 13:35:26 +00:00
|
|
|
typedef ::comphelper::OPropertyContainer OQueryController_PBase;
|
|
|
|
typedef ::comphelper::OPropertyArrayUsageHelper< OQueryController > OQueryController_PABase;
|
|
|
|
class OQueryController :public OJoinController
|
|
|
|
,public OQueryController_PBase
|
|
|
|
,public OQueryController_PABase
|
2001-01-09 15:11:54 +00:00
|
|
|
{
|
2001-10-05 05:49:21 +00:00
|
|
|
OTableFields m_vTableFieldDesc;
|
|
|
|
OTableFields m_vUnUsedFieldsDesc; // contains fields which aren't visible and don't have any criteria
|
2001-02-05 08:12:46 +00:00
|
|
|
|
2008-12-09 07:25:38 +00:00
|
|
|
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aFieldInformation;
|
|
|
|
|
2006-07-10 14:33:14 +00:00
|
|
|
::svxform::OSystemParseContext* m_pParseContext;
|
|
|
|
::connectivity::OSQLParser m_aSqlParser;
|
|
|
|
::connectivity::OSQLParseTreeIterator* m_pSqlIterator;
|
2001-02-05 08:12:46 +00:00
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > m_xComposer;
|
2007-11-21 15:05:27 +00:00
|
|
|
/// if we're editing an existing view, this is non-NULL
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAlterView > m_xAlterView;
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_sStatement; // contains the current sql statement
|
|
|
|
OUString m_sUpdateCatalogName; // catalog for update data
|
|
|
|
OUString m_sUpdateSchemaName; // schema for update data
|
|
|
|
OUString m_sUpdateTableName; // table for update data
|
|
|
|
mutable OUString
|
2008-04-04 13:02:30 +00:00
|
|
|
m_sName; // name of the query
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2013-02-04 15:21:33 +01:00
|
|
|
sal_Int64 m_nLimit; // the limit of the query result (All==-1)
|
|
|
|
|
2001-02-05 08:12:46 +00:00
|
|
|
sal_Int32 m_nVisibleRows; // which rows the selection browse should show
|
|
|
|
sal_Int32 m_nSplitPos; // the position of the splitter
|
2007-11-21 15:05:27 +00:00
|
|
|
sal_Int32 m_nCommandType; // the type of the object we're designing
|
2011-01-14 15:00:11 +01:00
|
|
|
sal_Bool m_bGraphicalDesign; // are we in the graphical design mode (sal_True) or in the text design (sal_False)?
|
2001-01-09 15:11:54 +00:00
|
|
|
sal_Bool m_bDistinct; // true when you want "select distinct" otherwise false
|
|
|
|
sal_Bool m_bViewAlias; // show the alias row in the design view
|
|
|
|
sal_Bool m_bViewTable; // show the table row in the design view
|
|
|
|
sal_Bool m_bViewFunction; // show the function row in the design view
|
2007-11-21 15:05:27 +00:00
|
|
|
sal_Bool m_bEscapeProcessing;// is true when we shouldn't parse the statement
|
|
|
|
|
|
|
|
|
|
|
|
/** returns the container of queries, views, or command definitions, depending on what object type
|
|
|
|
we design currently.
|
|
|
|
|
|
|
|
Not allowed to be called if we design an independent SQL command.
|
|
|
|
*/
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
|
|
|
|
getObjectContainer() const;
|
|
|
|
|
|
|
|
inline bool editingView() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::TABLE; }
|
|
|
|
inline bool editingQuery() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::QUERY; }
|
|
|
|
inline bool editingCommand() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::COMMAND; }
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2001-10-01 10:57:41 +00:00
|
|
|
sal_Bool askForNewName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xElements,
|
2001-04-24 13:34:10 +00:00
|
|
|
sal_Bool _bSaveAs);
|
2001-01-09 15:11:54 +00:00
|
|
|
// creates the querycomposer
|
|
|
|
void setQueryComposer();
|
2001-04-06 12:47:18 +00:00
|
|
|
void deleteIterator();
|
2001-04-02 09:18:50 +00:00
|
|
|
void executeQuery();
|
2007-11-21 15:05:27 +00:00
|
|
|
bool doSaveAsDoc(sal_Bool _bSaveAs);
|
2004-08-02 15:01:44 +00:00
|
|
|
|
2010-02-16 15:21:07 +01:00
|
|
|
void saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const;
|
|
|
|
void loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings );
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString translateStatement( bool _bFireStatementChange = true );
|
2004-08-02 15:01:44 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString getDefaultName() const;
|
2001-01-26 13:12:52 +00:00
|
|
|
|
2013-02-28 20:07:03 +01:00
|
|
|
void execute_QueryPropDlg();
|
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
protected:
|
|
|
|
// all the features which should be handled by this class
|
2004-11-16 13:32:12 +00:00
|
|
|
virtual void describeSupportedFeatures();
|
2001-01-09 15:11:54 +00:00
|
|
|
// state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
|
2002-01-24 16:43:35 +00:00
|
|
|
virtual FeatureState GetState(sal_uInt16 nId) const;
|
2001-01-09 15:11:54 +00:00
|
|
|
// execute a feature
|
2004-09-09 08:45:58 +00:00
|
|
|
virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2001-10-05 05:49:21 +00:00
|
|
|
virtual void reconnect( sal_Bool _bUI );
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual OUString getPrivateTitle( ) const;
|
2001-08-23 13:23:57 +00:00
|
|
|
|
2010-02-09 17:26:40 +01:00
|
|
|
OQueryContainerWindow* getContainer() const { return static_cast< OQueryContainerWindow* >( getView() ); }
|
2001-08-23 13:23:57 +00:00
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
public:
|
2013-01-07 17:46:55 +02:00
|
|
|
OQueryController(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM);
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2007-07-06 07:31:39 +00:00
|
|
|
virtual ~OQueryController();
|
2001-10-05 05:49:21 +00:00
|
|
|
OTableFields& getTableFieldDesc() { return m_vTableFieldDesc; }
|
|
|
|
OTableFields& getUnUsedFields() { return m_vUnUsedFieldsDesc; }
|
|
|
|
|
|
|
|
void clearFields();
|
2001-02-05 08:12:46 +00:00
|
|
|
|
2010-02-10 14:05:19 +01:00
|
|
|
virtual void impl_onModifyChanged();
|
2001-02-05 08:12:46 +00:00
|
|
|
|
|
|
|
// should the statement be parsed by our own sql parser
|
2007-11-21 15:05:27 +00:00
|
|
|
sal_Bool isEsacpeProcessing() const { return m_bEscapeProcessing; }
|
|
|
|
sal_Bool isGraphicalDesign() const { return m_bGraphicalDesign; }
|
2001-02-05 08:12:46 +00:00
|
|
|
sal_Bool isDistinct() const { return m_bDistinct; }
|
2013-02-04 15:21:33 +01:00
|
|
|
sal_Int64 getLimit() const { return m_nLimit; }
|
2001-02-05 08:12:46 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString getStatement() const { return m_sStatement; }
|
2001-02-05 08:12:46 +00:00
|
|
|
sal_Int32 getSplitPos() const { return m_nSplitPos;}
|
|
|
|
sal_Int32 getVisibleRows() const { return m_nVisibleRows; }
|
|
|
|
|
|
|
|
void setDistinct(sal_Bool _bDistinct) { m_bDistinct = _bDistinct;}
|
2013-02-04 15:21:33 +01:00
|
|
|
void setLimit(const sal_Int64 _nLimit) { m_nLimit = _nLimit;}
|
2001-02-05 08:12:46 +00:00
|
|
|
void setSplitPos(sal_Int32 _nSplitPos) { m_nSplitPos = _nSplitPos;}
|
|
|
|
void setVisibleRows(sal_Int32 _nVisibleRows) { m_nVisibleRows = _nVisibleRows;}
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2008-12-09 07:25:38 +00:00
|
|
|
sal_Int32 getColWidth(sal_uInt16 _nColPos) const;
|
|
|
|
|
2010-02-16 15:21:07 +01:00
|
|
|
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
|
|
|
|
getFieldInformation() const { return m_aFieldInformation; }
|
|
|
|
|
2006-07-10 14:33:14 +00:00
|
|
|
::connectivity::OSQLParser& getParser() { return m_aSqlParser; }
|
2001-02-05 08:12:46 +00:00
|
|
|
::connectivity::OSQLParseTreeIterator& getParseIterator() { return *m_pSqlIterator; }
|
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
virtual sal_Bool Construct(Window* pParent);
|
|
|
|
|
2007-07-06 07:31:39 +00:00
|
|
|
DECLARE_XINTERFACE( )
|
|
|
|
DECLARE_XTYPEPROVIDER( )
|
|
|
|
// XPropertySet
|
2014-02-25 21:31:58 +01:00
|
|
|
virtual com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException, std::exception);
|
2007-07-06 07:31:39 +00:00
|
|
|
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
|
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
// XEventListener
|
2014-02-25 21:31:58 +01:00
|
|
|
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception);
|
2001-01-09 15:11:54 +00:00
|
|
|
|
|
|
|
// ::com::sun::star::lang::XComponent
|
2001-03-01 14:17:55 +00:00
|
|
|
virtual void SAL_CALL disposing();
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception);
|
|
|
|
virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception);
|
2001-01-09 15:11:54 +00:00
|
|
|
// need by registration
|
2013-04-07 12:06:47 +02:00
|
|
|
static OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
|
|
|
|
static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
|
2001-01-09 15:11:54 +00:00
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
|
|
|
|
SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
|
2001-03-01 12:29:19 +00:00
|
|
|
|
2010-02-10 14:05:19 +01:00
|
|
|
// XController
|
2014-02-25 21:31:58 +01:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL getViewData(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
|
|
|
|
virtual void SAL_CALL restoreViewData(const ::com::sun::star::uno::Any& Data) throw( ::com::sun::star::uno::RuntimeException, std::exception );
|
2010-02-10 14:05:19 +01:00
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
private:
|
2005-03-01 18:17:11 +00:00
|
|
|
virtual void onLoadedMenu(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager);
|
2007-07-06 07:31:39 +00:00
|
|
|
// OPropertyArrayUsageHelper
|
|
|
|
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
|
2004-10-22 11:06:52 +00:00
|
|
|
|
2010-02-15 14:34:48 +01:00
|
|
|
// OPropertySetHelper
|
|
|
|
virtual sal_Bool SAL_CALL convertFastPropertyValue(
|
|
|
|
::com::sun::star::uno::Any& rConvertedValue,
|
|
|
|
::com::sun::star::uno::Any& rOldValue,
|
|
|
|
sal_Int32 nHandle,
|
|
|
|
const ::com::sun::star::uno::Any& rValue
|
|
|
|
) throw (::com::sun::star::lang::IllegalArgumentException);
|
|
|
|
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
|
|
|
|
sal_Int32 nHandle,
|
|
|
|
const ::com::sun::star::uno::Any& rValue
|
2014-02-25 21:31:58 +01:00
|
|
|
) throw (::com::sun::star::uno::Exception, std::exception );
|
2010-02-15 14:34:48 +01:00
|
|
|
virtual void SAL_CALL getFastPropertyValue(
|
|
|
|
::com::sun::star::uno::Any& rValue,
|
|
|
|
sal_Int32 nHandle
|
|
|
|
) const;
|
|
|
|
|
2001-09-27 05:19:05 +00:00
|
|
|
virtual OJoinDesignView* getJoinView();
|
2001-10-23 11:30:27 +00:00
|
|
|
// ask the user if the design should be saved when it is modified
|
|
|
|
virtual short saveModified();
|
|
|
|
virtual void reset();
|
2006-07-10 14:33:14 +00:00
|
|
|
virtual void impl_initialize();
|
2004-08-02 15:01:44 +00:00
|
|
|
|
2010-02-16 15:21:07 +01:00
|
|
|
void impl_reset( const bool i_bIgnoreQuerySettings = false );
|
2008-12-01 12:31:27 +00:00
|
|
|
/// tells the user that we needed to switch to SQL view automatically
|
|
|
|
void impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails );
|
|
|
|
|
|
|
|
/** switches to the graphical or SQL view mode, as determined by m_bGraphicalDesign
|
|
|
|
*/
|
|
|
|
bool impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo );
|
2004-03-19 11:12:13 +00:00
|
|
|
|
|
|
|
/// sets m_sStatement, and notifies our respective property change listeners
|
2013-04-07 12:06:47 +02:00
|
|
|
void setStatement_fireEvent( const OUString& _rNewStatement, bool _bFireStatementChange = true );
|
2007-11-21 15:05:27 +00:00
|
|
|
/// sets the m_bEscapeProcessing member, and notifies our respective property change listeners
|
|
|
|
void setEscapeProcessing_fireEvent( const sal_Bool _bEscapeProcessing );
|
2004-03-19 11:12:13 +00:00
|
|
|
|
2006-07-10 14:33:14 +00:00
|
|
|
// OJoinController overridables
|
|
|
|
virtual bool allowViews() const;
|
|
|
|
virtual bool allowQueries() const;
|
2008-12-01 12:31:27 +00:00
|
|
|
|
2004-03-19 11:12:13 +00:00
|
|
|
private:
|
|
|
|
DECL_LINK( OnExecuteAddTable, void* );
|
2010-02-19 10:23:50 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
using OQueryController_PBase::getFastPropertyValue;
|
2001-01-09 15:11:54 +00:00
|
|
|
};
|
|
|
|
}
|
2013-11-05 02:18:53 +01:00
|
|
|
#endif // INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYCONTROLLER_HXX
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2010-10-27 12:33:13 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|