LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/inc - querycontroller.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 18 0.0 %
Date: 2012-12-27 Functions: 0 18 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 DBAUI_QUERYCONTROLLER_HXX
      21             : #define DBAUI_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             :     class OQueryController;
      55             :     typedef ::comphelper::OPropertyContainer                            OQueryController_PBase;
      56             :     typedef ::comphelper::OPropertyArrayUsageHelper< OQueryController > OQueryController_PABase;
      57             :     class OQueryController  :public OJoinController
      58             :                             ,public OQueryController_PBase
      59             :                             ,public OQueryController_PABase
      60             :     {
      61             :         OTableFields                            m_vTableFieldDesc;
      62             :         OTableFields                            m_vUnUsedFieldsDesc; // contains fields which aren't visible and don't have any criteria
      63             : 
      64             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >       m_aFieldInformation;
      65             : 
      66             :         ::svxform::OSystemParseContext*         m_pParseContext;
      67             :         ::connectivity::OSQLParser              m_aSqlParser;
      68             :         ::connectivity::OSQLParseTreeIterator*  m_pSqlIterator;
      69             : 
      70             :         ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer >    m_xComposer;
      71             :         /// if we're editing an existing view, this is non-NULL
      72             :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAlterView >         m_xAlterView;
      73             : 
      74             :         ::rtl::OUString m_sStatement;           // contains the current sql statement
      75             :         ::rtl::OUString m_sUpdateCatalogName;   // catalog for update data
      76             :         ::rtl::OUString m_sUpdateSchemaName;    // schema for update data
      77             :         ::rtl::OUString m_sUpdateTableName;     // table for update data
      78             :         mutable ::rtl::OUString
      79             :                         m_sName;                // name of the query
      80             : 
      81             :         sal_Int32       m_nVisibleRows;     // which rows the selection browse should show
      82             :         sal_Int32       m_nSplitPos;        // the position of the splitter
      83             :         sal_Int32       m_nCommandType;     // the type of the object we're designing
      84             :         sal_Bool        m_bGraphicalDesign; // are we in the graphical design mode (sal_True) or in the text design (sal_False)?
      85             :         sal_Bool        m_bDistinct;        // true when you want "select distinct" otherwise false
      86             :         sal_Bool        m_bViewAlias;       // show the alias row in the design view
      87             :         sal_Bool        m_bViewTable;       // show the table row in the design view
      88             :         sal_Bool        m_bViewFunction;    // show the function row in the design view
      89             :         sal_Bool        m_bEscapeProcessing;// is true when we shouldn't parse the statement
      90             : 
      91             : 
      92             :         /** returns the container of queries, views, or command definitions, depending on what object type
      93             :             we design currently.
      94             : 
      95             :             Not allowed to be called if we design an independent SQL command.
      96             :         */
      97             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
      98             :             getObjectContainer() const;
      99             : 
     100           0 :         inline  bool    editingView() const    { return m_nCommandType == ::com::sun::star::sdb::CommandType::TABLE; }
     101           0 :         inline  bool    editingQuery() const   { return m_nCommandType == ::com::sun::star::sdb::CommandType::QUERY; }
     102           0 :         inline  bool    editingCommand() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::COMMAND; }
     103             : 
     104             :         sal_Bool askForNewName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xElements,
     105             :                             sal_Bool _bSaveAs);
     106             :         // creates the querycomposer
     107             :         void setQueryComposer();
     108             :         void deleteIterator();
     109             :         void executeQuery();
     110             :         bool doSaveAsDoc(sal_Bool _bSaveAs);
     111             : 
     112             :         void saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const;
     113             :         void loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings );
     114             :         ::rtl::OUString translateStatement( bool _bFireStatementChange = true );
     115             : 
     116             :         ::rtl::OUString getDefaultName() const;
     117             : 
     118             :     protected:
     119             :         // all the features which should be handled by this class
     120             :         virtual void            describeSupportedFeatures();
     121             :         // 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.
     122             :         virtual FeatureState    GetState(sal_uInt16 nId) const;
     123             :         // execute a feature
     124             :         virtual void            Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
     125             : 
     126             :         virtual void            reconnect( sal_Bool _bUI );
     127             :         virtual ::rtl::OUString getPrivateTitle( ) const;
     128             : 
     129           0 :         OQueryContainerWindow* getContainer() const { return static_cast< OQueryContainerWindow* >( getView() ); }
     130             : 
     131             :     public:
     132             :         OQueryController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
     133             : 
     134             :         virtual ~OQueryController();
     135           0 :         OTableFields&   getTableFieldDesc()         { return m_vTableFieldDesc; }
     136           0 :         OTableFields&   getUnUsedFields()           { return m_vUnUsedFieldsDesc; }
     137             : 
     138             :         void            clearFields();
     139             : 
     140             :         virtual void impl_onModifyChanged();
     141             : 
     142             :         // should the statement be parsed by our own sql parser
     143           0 :         sal_Bool        isEsacpeProcessing()    const { return m_bEscapeProcessing; }
     144           0 :         sal_Bool        isGraphicalDesign()     const { return m_bGraphicalDesign; }
     145           0 :         sal_Bool        isDistinct()            const { return m_bDistinct; }
     146             : 
     147           0 :         ::rtl::OUString getStatement()          const { return m_sStatement; }
     148           0 :         sal_Int32       getSplitPos()           const { return m_nSplitPos;}
     149           0 :         sal_Int32       getVisibleRows()        const { return m_nVisibleRows; }
     150             : 
     151           0 :         void            setDistinct(sal_Bool _bDistinct)        { m_bDistinct = _bDistinct;}
     152           0 :         void            setSplitPos(sal_Int32 _nSplitPos)       { m_nSplitPos = _nSplitPos;}
     153           0 :         void            setVisibleRows(sal_Int32 _nVisibleRows) { m_nVisibleRows = _nVisibleRows;}
     154             : 
     155             :         sal_Int32       getColWidth(sal_uInt16 _nColPos) const;
     156             : 
     157             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
     158           0 :                         getFieldInformation() const { return m_aFieldInformation; }
     159             : 
     160           0 :         ::connectivity::OSQLParser&             getParser()         { return m_aSqlParser;  }
     161           0 :         ::connectivity::OSQLParseTreeIterator&  getParseIterator()  { return *m_pSqlIterator; }
     162             : 
     163             :         virtual sal_Bool Construct(Window* pParent);
     164             : 
     165             :         DECLARE_XINTERFACE( )
     166             :         DECLARE_XTYPEPROVIDER( )
     167             :         // XPropertySet
     168             :         virtual com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo>  SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException);
     169             :         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
     170             : 
     171             :         // XEventListener
     172             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
     173             : 
     174             :         // ::com::sun::star::lang::XComponent
     175             :         virtual void        SAL_CALL disposing();
     176             : 
     177             :         virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
     178             :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
     179             :         // need by registration
     180             :         static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
     181             :         static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
     182             :         static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     183             :                 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
     184             : 
     185             :         // XController
     186             :         virtual ::com::sun::star::uno::Any SAL_CALL getViewData(void) throw( ::com::sun::star::uno::RuntimeException );
     187             :         virtual void SAL_CALL restoreViewData(const ::com::sun::star::uno::Any& Data) throw( ::com::sun::star::uno::RuntimeException );
     188             : 
     189             :     private:
     190             :         virtual void    onLoadedMenu(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager);
     191             :         // OPropertyArrayUsageHelper
     192             :         virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
     193             : 
     194             :         // OPropertySetHelper
     195             :         virtual sal_Bool SAL_CALL convertFastPropertyValue(
     196             :                                     ::com::sun::star::uno::Any& rConvertedValue,
     197             :                                     ::com::sun::star::uno::Any& rOldValue,
     198             :                                     sal_Int32 nHandle,
     199             :                                     const ::com::sun::star::uno::Any& rValue
     200             :                                 ) throw (::com::sun::star::lang::IllegalArgumentException);
     201             :         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     202             :                                     sal_Int32 nHandle,
     203             :                                     const ::com::sun::star::uno::Any& rValue
     204             :                                 ) throw (::com::sun::star::uno::Exception );
     205             :         virtual void SAL_CALL getFastPropertyValue(
     206             :                                     ::com::sun::star::uno::Any& rValue,
     207             :                                     sal_Int32 nHandle
     208             :                                 ) const;
     209             : 
     210             :         virtual OJoinDesignView*  getJoinView();
     211             :         // ask the user if the design should be saved when it is modified
     212             :         virtual short saveModified();
     213             :         virtual void reset();
     214             :         virtual void impl_initialize();
     215             : 
     216             :         void    impl_reset( const bool i_bIgnoreQuerySettings = false );
     217             :         /// tells the user that we needed to switch to SQL view automatically
     218             :         void    impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails );
     219             : 
     220             :         /** switches to the graphical or SQL view mode, as determined by m_bGraphicalDesign
     221             :         */
     222             :         bool    impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo );
     223             : 
     224             :         /// sets m_sStatement, and notifies our respective property change listeners
     225             :         void    setStatement_fireEvent( const ::rtl::OUString& _rNewStatement, bool _bFireStatementChange = true );
     226             :         /// sets the m_bEscapeProcessing member, and notifies our respective property change listeners
     227             :         void    setEscapeProcessing_fireEvent( const sal_Bool _bEscapeProcessing );
     228             : 
     229             :         // OJoinController overridables
     230             :         virtual bool allowViews() const;
     231             :         virtual bool allowQueries() const;
     232             : 
     233             :     private:
     234             :         DECL_LINK( OnExecuteAddTable, void* );
     235             : 
     236             :     private:
     237             :         using OQueryController_PBase::getFastPropertyValue;
     238             :     };
     239             : }
     240             : #endif // DBAUI_QUERYCONTROLLER_HXX
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10