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

Generated by: LCOV version 1.11