LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - querydescriptor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 106 0.0 %
Date: 2012-08-25 Functions: 0 35 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 166 0.0 %

           Branch data     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                 :            : 
      21                 :            : #include "querydescriptor.hxx"
      22                 :            : #include "apitools.hxx"
      23                 :            : #include "dbastrings.hrc"
      24                 :            : #include <comphelper/property.hxx>
      25                 :            : #include <comphelper/sequence.hxx>
      26                 :            : #include <cppuhelper/typeprovider.hxx>
      27                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28                 :            : #include "definitioncolumn.hxx"
      29                 :            : #include <tools/debug.hxx>
      30                 :            : 
      31                 :            : using namespace ::com::sun::star::uno;
      32                 :            : using namespace ::com::sun::star::awt;
      33                 :            : using namespace ::com::sun::star::lang;
      34                 :            : using namespace ::com::sun::star::beans;
      35                 :            : using namespace ::com::sun::star::container;
      36                 :            : using namespace ::com::sun::star::util;
      37                 :            : using namespace ::comphelper;
      38                 :            : using namespace ::osl;
      39                 :            : using namespace ::cppu;
      40                 :            : 
      41                 :            : namespace dbaccess
      42                 :            : {
      43                 :            : 
      44                 :            : //==========================================================================
      45                 :            : //= OQueryDescriptor
      46                 :            : //==========================================================================
      47                 :            : DBG_NAME(OQueryDescriptor)
      48                 :            : 
      49                 :          0 : OQueryDescriptor::OQueryDescriptor()
      50                 :            :     :OQueryDescriptor_Base(m_aMutex,*this)
      51 [ #  # ][ #  # ]:          0 :     ,ODataSettings(m_aBHelper,sal_True)
                 [ #  # ]
      52                 :            : {
      53                 :            :     DBG_CTOR(OQueryDescriptor,NULL);
      54         [ #  # ]:          0 :     registerProperties();
      55         [ #  # ]:          0 :     ODataSettings::registerPropertiesFor(this);
      56                 :          0 : }
      57                 :            : 
      58                 :          0 : OQueryDescriptor::OQueryDescriptor(const OQueryDescriptor_Base& _rSource)
      59                 :            :     :OQueryDescriptor_Base(_rSource,*this)
      60 [ #  # ][ #  # ]:          0 :     ,ODataSettings(m_aBHelper,sal_True)
                 [ #  # ]
      61                 :            : {
      62                 :            :     DBG_CTOR(OQueryDescriptor,NULL);
      63         [ #  # ]:          0 :     registerProperties();
      64         [ #  # ]:          0 :     ODataSettings::registerPropertiesFor(this);
      65                 :          0 : }
      66                 :            : 
      67 [ #  # ][ #  # ]:          0 : OQueryDescriptor::~OQueryDescriptor()
         [ #  # ][ #  # ]
      68                 :            : {
      69                 :            :     DBG_DTOR(OQueryDescriptor,NULL);
      70         [ #  # ]:          0 : }
      71                 :            : 
      72 [ #  # ][ #  # ]:          0 : IMPLEMENT_TYPEPROVIDER2(OQueryDescriptor,OQueryDescriptor_Base,ODataSettings);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      73 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XINTERFACE3( OQueryDescriptor,OWeakObject,OQueryDescriptor_Base,ODataSettings)
         [ #  # ][ #  # ]
      74                 :            : 
      75                 :          0 : void OQueryDescriptor::registerProperties()
      76                 :            : {
      77                 :            :     // the properties which OCommandBase supplies (it has no own registration, as it's not derived from
      78                 :            :     // a OPropertyStateContainer)
      79                 :            :     registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
      80         [ #  # ]:          0 :                     &m_sElementName, ::getCppuType(&m_sElementName));
      81                 :            : 
      82                 :            :     registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
      83         [ #  # ]:          0 :                     &m_sCommand, ::getCppuType(&m_sCommand));
      84                 :            : 
      85                 :            :     registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
      86         [ #  # ]:          0 :                     &m_bEscapeProcessing, ::getBooleanCppuType());
      87                 :            : 
      88                 :            :     registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
      89         [ #  # ]:          0 :                     &m_sUpdateTableName, ::getCppuType(&m_sUpdateTableName));
      90                 :            : 
      91                 :            :     registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
      92         [ #  # ]:          0 :                     &m_sUpdateSchemaName, ::getCppuType(&m_sUpdateSchemaName));
      93                 :            : 
      94                 :            :     registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
      95         [ #  # ]:          0 :                     &m_sUpdateCatalogName, ::getCppuType(&m_sUpdateCatalogName));
      96                 :            : 
      97                 :            :     registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
      98         [ #  # ]:          0 :                     &m_aLayoutInformation, ::getCppuType(&m_aLayoutInformation));
      99                 :          0 : }
     100                 :            : 
     101                 :          0 : Reference< XPropertySetInfo > SAL_CALL OQueryDescriptor::getPropertySetInfo(  ) throw(RuntimeException)
     102                 :            : {
     103                 :          0 :     return createPropertySetInfo( getInfoHelper() ) ;
     104                 :            : }
     105                 :            : 
     106                 :          0 : ::cppu::IPropertyArrayHelper& OQueryDescriptor::getInfoHelper()
     107                 :            : {
     108                 :          0 :     return *getArrayHelper();
     109                 :            : }
     110                 :            : 
     111                 :          0 : ::cppu::IPropertyArrayHelper* OQueryDescriptor::createArrayHelper( ) const
     112                 :            : {
     113         [ #  # ]:          0 :     Sequence< Property > aProps;
     114         [ #  # ]:          0 :     describeProperties(aProps);
     115 [ #  # ][ #  # ]:          0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     116                 :            : }
     117                 :            : 
     118                 :            : DBG_NAME(OQueryDescriptor_Base);
     119                 :            : 
     120                 :          0 : OQueryDescriptor_Base::OQueryDescriptor_Base(::osl::Mutex&  _rMutex,::cppu::OWeakObject& _rMySelf)
     121                 :            :     :m_bColumnsOutOfDate(sal_True)
     122         [ #  # ]:          0 :     ,m_rMutex(_rMutex)
     123                 :            : {
     124                 :            :     DBG_CTOR(OQueryDescriptor_Base,NULL);
     125 [ #  # ][ #  # ]:          0 :     m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_True,::std::vector< ::rtl::OUString>(), this,this);
                 [ #  # ]
     126                 :          0 : }
     127                 :            : 
     128                 :          0 : OQueryDescriptor_Base::OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf)
     129                 :            :     :m_bColumnsOutOfDate(sal_True)
     130         [ #  # ]:          0 :     ,m_rMutex(_rSource.m_rMutex)
     131                 :            : {
     132                 :            :     DBG_CTOR(OQueryDescriptor_Base,NULL);
     133 [ #  # ][ #  # ]:          0 :     m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_True,::std::vector< ::rtl::OUString>(), this,this);
                 [ #  # ]
     134                 :            : 
     135                 :          0 :     m_sCommand = _rSource.m_sCommand;
     136                 :          0 :     m_bEscapeProcessing = _rSource.m_bEscapeProcessing;
     137                 :          0 :     m_sUpdateTableName = _rSource.m_sUpdateTableName;
     138                 :          0 :     m_sUpdateSchemaName = _rSource.m_sUpdateSchemaName;
     139                 :          0 :     m_sUpdateCatalogName = _rSource.m_sUpdateCatalogName;
     140         [ #  # ]:          0 :     m_aLayoutInformation = _rSource.m_aLayoutInformation;
     141                 :          0 : }
     142                 :            : 
     143         [ #  # ]:          0 : OQueryDescriptor_Base::~OQueryDescriptor_Base()
     144                 :            : {
     145                 :          0 :     m_pColumns->acquire();
     146         [ #  # ]:          0 :     m_pColumns->disposing();
     147 [ #  # ][ #  # ]:          0 :     delete m_pColumns;
     148                 :            : 
     149                 :            :     DBG_DTOR(OQueryDescriptor_Base,NULL);
     150         [ #  # ]:          0 : }
     151                 :            : 
     152                 :          0 : sal_Int64 SAL_CALL OQueryDescriptor_Base::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
     153                 :            : {
     154         [ #  # ]:          0 :     if (_rIdentifier.getLength() != 16)
     155                 :          0 :         return 0;
     156                 :            : 
     157 [ #  # ][ #  # ]:          0 :     if (0 == rtl_compareMemory(getImplementationId().getConstArray(),  _rIdentifier.getConstArray(), 16 ) )
     158                 :          0 :         return reinterpret_cast<sal_Int64>(this);
     159                 :            : 
     160                 :          0 :     return 0;
     161                 :            : }
     162                 :            : 
     163 [ #  # ][ #  # ]:          0 : IMPLEMENT_IMPLEMENTATION_ID(OQueryDescriptor_Base)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     164                 :            : 
     165                 :          0 : void OQueryDescriptor_Base::setColumnsOutOfDate( sal_Bool _bOutOfDate )
     166                 :            : {
     167                 :          0 :     m_bColumnsOutOfDate = _bOutOfDate;
     168         [ #  # ]:          0 :     if ( !m_bColumnsOutOfDate )
     169                 :          0 :         m_pColumns->setInitialized();
     170                 :          0 : }
     171                 :            : 
     172                 :          0 : void OQueryDescriptor_Base::implAppendColumn( const ::rtl::OUString& _rName, OColumn* _pColumn )
     173                 :            : {
     174                 :          0 :     m_pColumns->append( _rName, _pColumn );
     175                 :          0 : }
     176                 :            : 
     177                 :          0 : void OQueryDescriptor_Base::clearColumns( )
     178                 :            : {
     179                 :          0 :     m_pColumns->clearColumns();
     180                 :            : 
     181                 :          0 :     setColumnsOutOfDate();
     182                 :          0 : }
     183                 :            : 
     184                 :          0 : Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( ) throw (RuntimeException)
     185                 :            : {
     186         [ #  # ]:          0 :     MutexGuard aGuard(m_rMutex);
     187                 :            : 
     188         [ #  # ]:          0 :     if ( isColumnsOutOfDate() )
     189                 :            :     {
     190                 :            :         // clear the current columns
     191         [ #  # ]:          0 :         clearColumns();
     192                 :            : 
     193                 :            :         // do this before rebuildColumns. This prevents recursion, e.g. in the case where we
     194                 :            :         // have queries with cyclic references:
     195                 :            :         // foo := SELECT * FROM bar
     196                 :            :         // bar := SELECT * FROM foo
     197                 :          0 :         setColumnsOutOfDate( sal_False );
     198                 :            : 
     199                 :            :         // rebuild them
     200                 :            :         try
     201                 :            :         {
     202         [ #  # ]:          0 :             rebuildColumns();
     203                 :            :         }
     204         [ #  # ]:          0 :         catch ( const Exception& )
     205                 :            :         {
     206                 :          0 :             setColumnsOutOfDate( sal_True );
     207                 :          0 :             throw;
     208                 :            :         }
     209                 :            :     }
     210                 :            : 
     211 [ #  # ][ #  # ]:          0 :     return m_pColumns;
                 [ #  # ]
     212                 :            : }
     213                 :            : 
     214                 :          0 : ::rtl::OUString SAL_CALL OQueryDescriptor_Base::getImplementationName(  ) throw(RuntimeException)
     215                 :            : {
     216                 :          0 :     return ::rtl::OUString("com.sun.star.sdb.OQueryDescriptor");
     217                 :            : }
     218                 :            : 
     219                 :          0 : sal_Bool SAL_CALL OQueryDescriptor_Base::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
     220                 :            : {
     221 [ #  # ][ #  # ]:          0 :     return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
     222                 :            : }
     223                 :            : 
     224                 :          0 : Sequence< ::rtl::OUString > SAL_CALL OQueryDescriptor_Base::getSupportedServiceNames(  ) throw(RuntimeException)
     225                 :            : {
     226                 :          0 :     Sequence< ::rtl::OUString > aSupported(2);
     227 [ #  # ][ #  # ]:          0 :     aSupported.getArray()[0] = SERVICE_SDB_DATASETTINGS;
     228 [ #  # ][ #  # ]:          0 :     aSupported.getArray()[1] = SERVICE_SDB_QUERYDESCRIPTOR;
     229                 :          0 :     return aSupported;
     230                 :            : }
     231                 :            : 
     232                 :          0 : void OQueryDescriptor_Base::disposeColumns()
     233                 :            : {
     234                 :          0 :     m_pColumns->disposing();
     235                 :          0 : }
     236                 :            : 
     237                 :          0 : void OQueryDescriptor_Base::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
     238                 :            : {
     239                 :            :     // not interested in
     240                 :          0 : }
     241                 :            : 
     242                 :          0 : void OQueryDescriptor_Base::columnDropped(const ::rtl::OUString& /*_sName*/)
     243                 :            : {
     244                 :            :     // not interested in
     245                 :          0 : }
     246                 :            : 
     247                 :          0 : Reference< XPropertySet > OQueryDescriptor_Base::createColumnDescriptor()
     248                 :            : {
     249                 :            :     OSL_FAIL( "OQueryDescriptor_Base::createColumnDescriptor: called why?" );
     250                 :          0 :     return NULL;
     251                 :            : }
     252                 :            : 
     253                 :          0 : void OQueryDescriptor_Base::rebuildColumns( )
     254                 :            : {
     255                 :          0 : }
     256                 :            : 
     257                 :            : // IRefreshableColumns
     258                 :          0 : void OQueryDescriptor_Base::refreshColumns()
     259                 :            : {
     260         [ #  # ]:          0 :     MutexGuard aGuard( m_rMutex );
     261                 :            : 
     262         [ #  # ]:          0 :     clearColumns();
     263 [ #  # ][ #  # ]:          0 :     rebuildColumns();
     264                 :          0 : }
     265                 :            : 
     266                 :          0 : OColumn* OQueryDescriptor_Base::createColumn( const ::rtl::OUString& /*_rName*/ ) const
     267                 :            : {
     268                 :            :     // creating a column/descriptor for a query/descriptor does not make sense at all
     269                 :          0 :     return NULL;
     270                 :            : }
     271                 :            : 
     272                 :            : }
     273                 :            : 
     274                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10