LCOV - code coverage report
Current view: top level - dbaccess/source/ui/inc - querycontroller.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 20 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYCONTROLLER_HXX
      21             : #define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYCONTROLLER_HXX
      22             : 
      23             : #include "JoinController.hxx"
      24             : #include "JoinTableView.hxx"
      25             : #include "querycontainerwindow.hxx"
      26             : #include "queryview.hxx"
      27             : #include "svx/ParseContext.hxx"
      28             : #include "TableFieldDescription.hxx"
      29             : 
      30             : #include <com/sun/star/io/XObjectInputStream.hpp>
      31             : #include <com/sun/star/io/XObjectOutputStream.hpp>
      32             : #include <com/sun/star/sdb/CommandType.hpp>
      33             : #include <com/sun/star/sdb/XSQLQueryComposer.hpp>
      34             : #include <com/sun/star/sdbc/XConnection.hpp>
      35             : #include <com/sun/star/sdbcx/XAlterView.hpp>
      36             : 
      37             : #include <comphelper/proparrhlp.hxx>
      38             : #include <comphelper/propertycontainer.hxx>
      39             : #include <comphelper/uno3.hxx>
      40             : #include <connectivity/sqliterator.hxx>
      41             : #include <connectivity/sqlnode.hxx>
      42             : #include <connectivity/sqlparse.hxx>
      43             : #include <svl/undo.hxx>
      44             : 
      45             : namespace comphelper
      46             : {
      47             :     class NamedValueCollection;
      48             : }
      49             : 
      50             : namespace dbaui
      51             : {
      52             :     class OQueryContainerWindow;
      53             : 
      54             :     typedef ::comphelper::OPropertyContainer                            OQueryController_PBase;
      55             :     typedef ::comphelper::OPropertyArrayUsageHelper< OQueryController > OQueryController_PABase;
      56             :     class OQueryController  :public OJoinController
      57             :                             ,public OQueryController_PBase
      58             :                             ,public OQueryController_PABase
      59             :     {
      60             :         OTableFields                            m_vTableFieldDesc;
      61             :         OTableFields                            m_vUnUsedFieldsDesc; // contains fields which aren't visible and don't have any criteria
      62             : 
      63             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >       m_aFieldInformation;
      64             : 
      65             :         ::svxform::OSystemParseContext*         m_pParseContext;
      66             :         ::connectivity::OSQLParser              m_aSqlParser;
      67             :         ::connectivity::OSQLParseTreeIterator*  m_pSqlIterator;
      68             : 
      69             :         ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer >    m_xComposer;
      70             :         /// if we're editing an existing view, this is non-NULL
      71             :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAlterView >         m_xAlterView;
      72             : 
      73             :         OUString m_sStatement;           // contains the current sql statement
      74             :         OUString m_sUpdateCatalogName;   // catalog for update data
      75             :         OUString m_sUpdateSchemaName;    // schema for update data
      76             :         OUString m_sUpdateTableName;     // table for update data
      77             :         mutable OUString
      78             :                         m_sName;                // name of the query
      79             : 
      80             :         sal_Int64       m_nLimit;           // the limit of the query result (All==-1)
      81             : 
      82             :         sal_Int32       m_nVisibleRows;     // which rows the selection browse should show
      83             :         sal_Int32       m_nSplitPos;        // the position of the splitter
      84             :         sal_Int32       m_nCommandType;     // the type of the object we're designing
      85             :         bool        m_bGraphicalDesign; // are we in the graphical design mode (sal_True) or in the text design (sal_False)?
      86             :         bool        m_bDistinct;        // true when you want "select distinct" otherwise false
      87             :         bool        m_bViewAlias;       // show the alias row in the design view
      88             :         bool        m_bViewTable;       // show the table row in the design view
      89             :         bool        m_bViewFunction;    // show the function row in the design view
      90             :         bool        m_bEscapeProcessing;// is true when we shouldn't parse the statement
      91             : 
      92             : 
      93             :         /** returns the container of queries, views, or command definitions, depending on what object type
      94             :             we design currently.
      95             : 
      96             :             Not allowed to be called if we design an independent SQL command.
      97             :         */
      98             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
      99             :             getObjectContainer() const;
     100             : 
     101           0 :         inline  bool    editingView() const    { return m_nCommandType == ::com::sun::star::sdb::CommandType::TABLE; }
     102           0 :         inline  bool    editingQuery() const   { return m_nCommandType == ::com::sun::star::sdb::CommandType::QUERY; }
     103           0 :         inline  bool    editingCommand() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::COMMAND; }
     104             : 
     105             :         bool askForNewName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xElements,
     106             :                             bool _bSaveAs);
     107             :         // creates the querycomposer
     108             :         void setQueryComposer();
     109             :         void deleteIterator();
     110             :         void executeQuery();
     111             :         bool doSaveAsDoc(bool _bSaveAs);
     112             : 
     113             :         void saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const;
     114             :         void loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings );
     115             :         OUString translateStatement( bool _bFireStatementChange = true );
     116             : 
     117             :         OUString getDefaultName() const;
     118             : 
     119             :         void execute_QueryPropDlg();
     120             : 
     121             :     protected:
     122             :         // all the features which should be handled by this class
     123             :         virtual void            describeSupportedFeatures() SAL_OVERRIDE;
     124             :         // 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.
     125             :         virtual FeatureState    GetState(sal_uInt16 nId) const SAL_OVERRIDE;
     126             :         // execute a feature
     127             :         virtual void            Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs) SAL_OVERRIDE;
     128             : 
     129             :         virtual void            reconnect( bool _bUI ) SAL_OVERRIDE;
     130             :         virtual OUString getPrivateTitle( ) const SAL_OVERRIDE;
     131             : 
     132           0 :         OQueryContainerWindow* getContainer() const { return static_cast< OQueryContainerWindow* >( getView() ); }
     133             : 
     134             :     public:
     135             :         OQueryController(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM);
     136             : 
     137             :         virtual ~OQueryController();
     138           0 :         OTableFields&   getTableFieldDesc()         { return m_vTableFieldDesc; }
     139           0 :         OTableFields&   getUnUsedFields()           { return m_vUnUsedFieldsDesc; }
     140             : 
     141             :         void            clearFields();
     142             : 
     143             :         virtual void impl_onModifyChanged() SAL_OVERRIDE;
     144             : 
     145             :         // should the statement be parsed by our own sql parser
     146           0 :         bool        isEscapeProcessing()    const { return m_bEscapeProcessing; }
     147           0 :         bool        isGraphicalDesign()     const { return m_bGraphicalDesign; }
     148           0 :         bool        isDistinct()            const { return m_bDistinct; }
     149           0 :         sal_Int64       getLimit()              const { return m_nLimit; }
     150             : 
     151           0 :         OUString getStatement()          const { return m_sStatement; }
     152           0 :         sal_Int32       getSplitPos()           const { return m_nSplitPos;}
     153           0 :         sal_Int32       getVisibleRows()        const { return m_nVisibleRows; }
     154             : 
     155           0 :         void            setDistinct(bool _bDistinct)        { m_bDistinct = _bDistinct;}
     156           0 :         void            setLimit(const sal_Int64 _nLimit)       { m_nLimit = _nLimit;}
     157           0 :         void            setSplitPos(sal_Int32 _nSplitPos)       { m_nSplitPos = _nSplitPos;}
     158           0 :         void            setVisibleRows(sal_Int32 _nVisibleRows) { m_nVisibleRows = _nVisibleRows;}
     159             : 
     160             :         sal_Int32       getColWidth(sal_uInt16 _nColPos) const;
     161             : 
     162             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
     163           0 :                         getFieldInformation() const { return m_aFieldInformation; }
     164             : 
     165           0 :         ::connectivity::OSQLParser&             getParser()         { return m_aSqlParser;  }
     166           0 :         ::connectivity::OSQLParseTreeIterator&  getParseIterator()  { return *m_pSqlIterator; }
     167             : 
     168             :         virtual bool Construct(vcl::Window* pParent) SAL_OVERRIDE;
     169             : 
     170             :         DECLARE_XINTERFACE( )
     171             :         DECLARE_XTYPEPROVIDER( )
     172             :         // XPropertySet
     173             :         virtual com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo>  SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     174             :         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
     175             : 
     176             :         // XEventListener
     177             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     178             : 
     179             :         // ::com::sun::star::lang::XComponent
     180             :         virtual void        SAL_CALL disposing() SAL_OVERRIDE;
     181             : 
     182             :         virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     183             :         virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     184             :         // need by registration
     185             :         static OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
     186             :         static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static() throw( ::com::sun::star::uno::RuntimeException );
     187             :         static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     188             :                 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
     189             : 
     190             :         // XController
     191             :         virtual ::com::sun::star::uno::Any SAL_CALL getViewData() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     192             :         virtual void SAL_CALL restoreViewData(const ::com::sun::star::uno::Any& Data) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     193             : 
     194             :     private:
     195             :         virtual void    onLoadedMenu(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager) SAL_OVERRIDE;
     196             :         // OPropertyArrayUsageHelper
     197             :         virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
     198             : 
     199             :         // OPropertySetHelper
     200             :         virtual sal_Bool SAL_CALL convertFastPropertyValue(
     201             :                                     ::com::sun::star::uno::Any& rConvertedValue,
     202             :                                     ::com::sun::star::uno::Any& rOldValue,
     203             :                                     sal_Int32 nHandle,
     204             :                                     const ::com::sun::star::uno::Any& rValue
     205             :                                 ) throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
     206             :         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     207             :                                     sal_Int32 nHandle,
     208             :                                     const ::com::sun::star::uno::Any& rValue
     209             :                                 ) throw (::com::sun::star::uno::Exception, std::exception ) SAL_OVERRIDE;
     210             :         virtual void SAL_CALL getFastPropertyValue(
     211             :                                     ::com::sun::star::uno::Any& rValue,
     212             :                                     sal_Int32 nHandle
     213             :                                 ) const SAL_OVERRIDE;
     214             : 
     215             :         virtual OJoinDesignView*  getJoinView() SAL_OVERRIDE;
     216             :         // ask the user if the design should be saved when it is modified
     217             :         virtual short saveModified() SAL_OVERRIDE;
     218             :         virtual void reset() SAL_OVERRIDE;
     219             :         virtual void impl_initialize() SAL_OVERRIDE;
     220             : 
     221             :         void    impl_reset( const bool i_bIgnoreQuerySettings = false );
     222             :         /// tells the user that we needed to switch to SQL view automatically
     223             :         void    impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails );
     224             : 
     225             :         /** switches to the graphical or SQL view mode, as determined by m_bGraphicalDesign
     226             :         */
     227             :         bool    impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo );
     228             : 
     229             :         /// sets m_sStatement, and notifies our respective property change listeners
     230             :         void    setStatement_fireEvent( const OUString& _rNewStatement, bool _bFireStatementChange = true );
     231             :         /// sets the m_bEscapeProcessing member, and notifies our respective property change listeners
     232             :         void    setEscapeProcessing_fireEvent( const bool _bEscapeProcessing );
     233             : 
     234             :         // OJoinController overridables
     235             :         virtual bool allowViews() const SAL_OVERRIDE;
     236             :         virtual bool allowQueries() const SAL_OVERRIDE;
     237             : 
     238             :     private:
     239             :         DECL_LINK( OnExecuteAddTable, void* );
     240             : 
     241             :     private:
     242             :         using OQueryController_PBase::getFastPropertyValue;
     243             :     };
     244             : }
     245             : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYCONTROLLER_HXX
     246             : 
     247             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11