LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - querydescriptor.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 108 0.0 %
Date: 2014-04-11 Functions: 0 34 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             : #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,sal_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,sal_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, ::getCppuType(&m_sElementName));
      83             : 
      84             :     registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
      85           0 :                     &m_sCommand, ::getCppuType(&m_sCommand));
      86             : 
      87             :     registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
      88           0 :                     &m_bEscapeProcessing, ::getBooleanCppuType());
      89             : 
      90             :     registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
      91           0 :                     &m_sUpdateTableName, ::getCppuType(&m_sUpdateTableName));
      92             : 
      93             :     registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
      94           0 :                     &m_sUpdateSchemaName, ::getCppuType(&m_sUpdateSchemaName));
      95             : 
      96             :     registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
      97           0 :                     &m_sUpdateCatalogName, ::getCppuType(&m_sUpdateCatalogName));
      98             : 
      99             :     registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
     100           0 :                     &m_aLayoutInformation, ::getCppuType(&m_aLayoutInformation));
     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           0 : OQueryDescriptor_Base::OQueryDescriptor_Base(::osl::Mutex&  _rMutex,::cppu::OWeakObject& _rMySelf)
     122             :     :m_bColumnsOutOfDate(sal_True)
     123           0 :     ,m_rMutex(_rMutex)
     124             : {
     125           0 :     m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_True,::std::vector< 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           0 :     m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_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           0 : OQueryDescriptor_Base::~OQueryDescriptor_Base()
     143             : {
     144           0 :     m_pColumns->acquire();
     145           0 :     m_pColumns->disposing();
     146           0 :     delete m_pColumns;
     147             : 
     148           0 : }
     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           0 : void OQueryDescriptor_Base::setColumnsOutOfDate( sal_Bool _bOutOfDate )
     164             : {
     165           0 :     m_bColumnsOutOfDate = _bOutOfDate;
     166           0 :     if ( !m_bColumnsOutOfDate )
     167           0 :         m_pColumns->setInitialized();
     168           0 : }
     169             : 
     170           0 : void OQueryDescriptor_Base::implAppendColumn( const OUString& _rName, OColumn* _pColumn )
     171             : {
     172           0 :     m_pColumns->append( _rName, _pColumn );
     173           0 : }
     174             : 
     175           0 : void OQueryDescriptor_Base::clearColumns( )
     176             : {
     177           0 :     m_pColumns->clearColumns();
     178             : 
     179           0 :     setColumnsOutOfDate();
     180           0 : }
     181             : 
     182           0 : Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( ) throw (RuntimeException, std::exception)
     183             : {
     184           0 :     MutexGuard aGuard(m_rMutex);
     185             : 
     186           0 :     if ( isColumnsOutOfDate() )
     187             :     {
     188             :         // clear the current columns
     189           0 :         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           0 :         setColumnsOutOfDate( sal_False );
     196             : 
     197             :         // rebuild them
     198             :         try
     199             :         {
     200           0 :             rebuildColumns();
     201             :         }
     202           0 :         catch ( const Exception& )
     203             :         {
     204           0 :             setColumnsOutOfDate( sal_True );
     205           0 :             throw;
     206             :         }
     207             :     }
     208             : 
     209           0 :     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           0 : void OQueryDescriptor_Base::disposeColumns()
     231             : {
     232           0 :     m_pColumns->disposing();
     233           0 : }
     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.10