LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - TableDeco.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 141 277 50.9 %
Date: 2014-04-11 Functions: 19 36 52.8 %
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 "TableDeco.hxx"
      23             : #include <definitioncolumn.hxx>
      24             : #include "dbastrings.hrc"
      25             : #include "core_resource.hxx"
      26             : #include "core_resource.hrc"
      27             : #include <tools/debug.hxx>
      28             : #include <osl/diagnose.h>
      29             : 
      30             : #include <cppuhelper/typeprovider.hxx>
      31             : #include <comphelper/enumhelper.hxx>
      32             : #include <comphelper/container.hxx>
      33             : #include <comphelper/sequence.hxx>
      34             : #include <comphelper/property.hxx>
      35             : #include <comphelper/types.hxx>
      36             : #include <com/sun/star/util/XRefreshListener.hpp>
      37             : #include <com/sun/star/sdbc/XConnection.hpp>
      38             : #include <com/sun/star/sdbc/XRow.hpp>
      39             : #include <com/sun/star/sdbcx/Privilege.hpp>
      40             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      41             : #include <connectivity/dbtools.hxx>
      42             : #include <connectivity/dbexception.hxx>
      43             : #include <comphelper/extract.hxx>
      44             : #include "ContainerMediator.hxx"
      45             : 
      46             : using namespace dbaccess;
      47             : using namespace ::com::sun::star::uno;
      48             : using namespace ::com::sun::star::util;
      49             : using namespace ::com::sun::star::lang;
      50             : using namespace ::com::sun::star::beans;
      51             : using namespace ::com::sun::star::sdbc;
      52             : using namespace ::com::sun::star::sdbcx;
      53             : using namespace ::com::sun::star::container;
      54             : using namespace ::osl;
      55             : using namespace ::comphelper;
      56             : using namespace ::dbtools;
      57             : using namespace ::cppu;
      58             : 
      59             : // ODBTableDecorator
      60             : 
      61          16 : ODBTableDecorator::ODBTableDecorator( const Reference< XConnection >& _rxConnection, const Reference< XColumnsSupplier >& _rxNewTable,
      62             :         const Reference< XNumberFormatsSupplier >& _rxNumberFormats, const Reference< XNameAccess >& _xColumnDefinitions ) throw(SQLException)
      63             :     :OTableDescriptor_BASE(m_aMutex)
      64             :     ,ODataSettings(OTableDescriptor_BASE::rBHelper)
      65             :     ,m_xTable(_rxNewTable)
      66             :     ,m_xColumnDefinitions(_xColumnDefinitions)
      67             :     ,m_xConnection( _rxConnection )
      68          32 :     ,m_xMetaData( _rxConnection.is() ? _rxConnection->getMetaData() : Reference< XDatabaseMetaData >() )
      69             :     ,m_xNumberFormats( _rxNumberFormats )
      70             :     ,m_nPrivileges(-1)
      71          48 :     ,m_pColumns(NULL)
      72             : {
      73             :     SAL_INFO("dbaccess", "ODBTableDecorator::ODBTableDecorator" );
      74          16 :     ODataSettings::registerPropertiesFor(this);
      75          16 : }
      76             : 
      77          48 : ODBTableDecorator::~ODBTableDecorator()
      78             : {
      79          16 :     if ( m_pColumns )
      80          16 :         delete m_pColumns;
      81          32 : }
      82             : 
      83           0 : Sequence< sal_Int8 > ODBTableDecorator::getImplementationId() throw (RuntimeException, std::exception)
      84             : {
      85           0 :     return css::uno::Sequence<sal_Int8>();
      86             : }
      87             : 
      88             : // OComponentHelper
      89          16 : void SAL_CALL ODBTableDecorator::disposing()
      90             : {
      91             :     SAL_INFO("dbaccess", "ODBTableDecorator::disposing" );
      92          16 :     OPropertySetHelper::disposing();
      93          16 :     OTableDescriptor_BASE::disposing();
      94             : 
      95          16 :     MutexGuard aGuard(m_aMutex);
      96          16 :     m_xTable        = NULL;
      97          16 :     m_xMetaData     = NULL;
      98          16 :     m_xColumnDefinitions = NULL;
      99          16 :     m_xNumberFormats = NULL;
     100          16 :     if ( m_pColumns )
     101          16 :         m_pColumns->disposing();
     102          16 :     m_xColumnMediator = NULL;
     103          16 : }
     104             : 
     105         803 : sal_Bool SAL_CALL ODBTableDecorator::convertFastPropertyValue(
     106             :                             Any & rConvertedValue,
     107             :                             Any & rOldValue,
     108             :                             sal_Int32 nHandle,
     109             :                             const Any& rValue )
     110             :                                 throw (::com::sun::star::lang::IllegalArgumentException)
     111             : {
     112         803 :     sal_Bool bRet = sal_True;
     113         803 :     switch(nHandle)
     114             :     {
     115             :         case PROPERTY_ID_PRIVILEGES:
     116             :         case PROPERTY_ID_FILTER:
     117             :         case PROPERTY_ID_ORDER:
     118             :         case PROPERTY_ID_APPLYFILTER:
     119             :         case PROPERTY_ID_FONT:
     120             :         case PROPERTY_ID_ROW_HEIGHT:
     121             :         case PROPERTY_ID_TEXTCOLOR:
     122             :         case PROPERTY_ID_TEXTLINECOLOR:
     123             :         case PROPERTY_ID_TEXTEMPHASIS:
     124             :         case PROPERTY_ID_TEXTRELIEF:
     125             :         case PROPERTY_ID_FONTCHARWIDTH:
     126             :         case PROPERTY_ID_FONTCHARSET:
     127             :         case PROPERTY_ID_FONTFAMILY:
     128             :         case PROPERTY_ID_FONTHEIGHT:
     129             :         case PROPERTY_ID_FONTKERNING:
     130             :         case PROPERTY_ID_FONTNAME:
     131             :         case PROPERTY_ID_FONTORIENTATION:
     132             :         case PROPERTY_ID_FONTPITCH:
     133             :         case PROPERTY_ID_FONTSLANT:
     134             :         case PROPERTY_ID_FONTSTRIKEOUT:
     135             :         case PROPERTY_ID_FONTSTYLENAME:
     136             :         case PROPERTY_ID_FONTUNDERLINE:
     137             :         case PROPERTY_ID_FONTWEIGHT:
     138             :         case PROPERTY_ID_FONTWIDTH:
     139             :         case PROPERTY_ID_FONTWORDLINEMODE:
     140             :         case PROPERTY_ID_FONTTYPE:
     141         803 :             bRet = ODataSettings::convertFastPropertyValue(rConvertedValue, rOldValue,nHandle,rValue);
     142         803 :             break;
     143             : 
     144             :         default:
     145             :             {
     146           0 :                 Any aValue;
     147           0 :                 getFastPropertyValue(aValue,nHandle);
     148           0 :                 bRet = ::comphelper::tryPropertyValue(rConvertedValue,rOldValue,rValue,aValue,::getCppuType(static_cast< OUString*>(0)));
     149             :             }
     150           0 :             break; // we assume that it works
     151             :     }
     152         803 :     return bRet;
     153             : }
     154             : 
     155           7 : void ODBTableDecorator::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception, std::exception)
     156             : {
     157             :     SAL_INFO("dbaccess", "ODBTableDecorator::setFastPropertyValue_NoBroadcast" );
     158           7 :     switch(_nHandle)
     159             :     {
     160             :         case PROPERTY_ID_PRIVILEGES:
     161             :             SAL_WARN("dbaccess", "Property is readonly!");
     162             :             /* Fall through */
     163             :         case PROPERTY_ID_FILTER:
     164             :         case PROPERTY_ID_ORDER:
     165             :         case PROPERTY_ID_APPLYFILTER:
     166             :         case PROPERTY_ID_FONT:
     167             :         case PROPERTY_ID_ROW_HEIGHT:
     168             :         case PROPERTY_ID_TEXTCOLOR:
     169             :         case PROPERTY_ID_TEXTLINECOLOR:
     170             :         case PROPERTY_ID_TEXTEMPHASIS:
     171             :         case PROPERTY_ID_TEXTRELIEF:
     172             :         case PROPERTY_ID_FONTCHARWIDTH:
     173             :         case PROPERTY_ID_FONTCHARSET:
     174             :         case PROPERTY_ID_FONTFAMILY:
     175             :         case PROPERTY_ID_FONTHEIGHT:
     176             :         case PROPERTY_ID_FONTKERNING:
     177             :         case PROPERTY_ID_FONTNAME:
     178             :         case PROPERTY_ID_FONTORIENTATION:
     179             :         case PROPERTY_ID_FONTPITCH:
     180             :         case PROPERTY_ID_FONTSLANT:
     181             :         case PROPERTY_ID_FONTSTRIKEOUT:
     182             :         case PROPERTY_ID_FONTSTYLENAME:
     183             :         case PROPERTY_ID_FONTUNDERLINE:
     184             :         case PROPERTY_ID_FONTWEIGHT:
     185             :         case PROPERTY_ID_FONTWIDTH:
     186             :         case PROPERTY_ID_FONTWORDLINEMODE:
     187             :         case PROPERTY_ID_FONTTYPE:
     188             : 
     189           7 :             ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
     190           7 :             break;
     191             :         case PROPERTY_ID_CATALOGNAME:
     192             :             {
     193           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     194           0 :                 xProp->setPropertyValue(PROPERTY_CATALOGNAME,_rValue);
     195             :             }
     196           0 :             break;
     197             :         case PROPERTY_ID_SCHEMANAME:
     198             :             {
     199           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     200           0 :                 xProp->setPropertyValue(PROPERTY_SCHEMANAME,_rValue);
     201             :             }
     202           0 :             break;
     203             :         case PROPERTY_ID_NAME:
     204             :             {
     205           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     206           0 :                 xProp->setPropertyValue(PROPERTY_NAME,_rValue);
     207             :             }
     208           0 :             break;
     209             :         case PROPERTY_ID_DESCRIPTION:
     210             :             {
     211           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     212           0 :                 xProp->setPropertyValue(PROPERTY_DESCRIPTION,_rValue);
     213             :             }
     214           0 :             break;
     215             :         case PROPERTY_ID_TYPE:
     216             :             {
     217           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     218           0 :                 xProp->setPropertyValue(PROPERTY_TYPE,_rValue);
     219             :             }
     220           0 :             break;
     221             :     }
     222           7 : }
     223             : 
     224          45 : void ODBTableDecorator::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
     225             : {
     226             : 
     227          45 :     switch(_nHandle)
     228             :     {
     229             :         case PROPERTY_ID_PRIVILEGES:
     230             :             {
     231           0 :                 if ( -1 == m_nPrivileges )
     232           0 :                     fillPrivileges();
     233           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     234           0 :                 Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
     235           0 :                 if ( xInfo->hasPropertyByName(PROPERTY_PRIVILEGES) )
     236             :                 {
     237           0 :                     _rValue <<= m_nPrivileges;
     238           0 :                     break;
     239           0 :                 }
     240             :             }
     241             :             // run through
     242             : 
     243             :         case PROPERTY_ID_FILTER:
     244             :         case PROPERTY_ID_ORDER:
     245             :         case PROPERTY_ID_APPLYFILTER:
     246             :         case PROPERTY_ID_FONT:
     247             :         case PROPERTY_ID_ROW_HEIGHT:
     248             :         case PROPERTY_ID_TEXTCOLOR:
     249             :         case PROPERTY_ID_TEXTLINECOLOR:
     250             :         case PROPERTY_ID_TEXTEMPHASIS:
     251             :         case PROPERTY_ID_TEXTRELIEF:
     252             :         case PROPERTY_ID_FONTCHARWIDTH:
     253             :         case PROPERTY_ID_FONTCHARSET:
     254             :         case PROPERTY_ID_FONTFAMILY:
     255             :         case PROPERTY_ID_FONTHEIGHT:
     256             :         case PROPERTY_ID_FONTKERNING:
     257             :         case PROPERTY_ID_FONTNAME:
     258             :         case PROPERTY_ID_FONTORIENTATION:
     259             :         case PROPERTY_ID_FONTPITCH:
     260             :         case PROPERTY_ID_FONTSLANT:
     261             :         case PROPERTY_ID_FONTSTRIKEOUT:
     262             :         case PROPERTY_ID_FONTSTYLENAME:
     263             :         case PROPERTY_ID_FONTUNDERLINE:
     264             :         case PROPERTY_ID_FONTWEIGHT:
     265             :         case PROPERTY_ID_FONTWIDTH:
     266             :         case PROPERTY_ID_FONTWORDLINEMODE:
     267             :         case PROPERTY_ID_FONTTYPE:
     268           9 :             ODataSettings::getFastPropertyValue(_rValue, _nHandle);
     269           9 :             break;
     270             :         case PROPERTY_ID_CATALOGNAME:
     271             :             {
     272          12 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     273          12 :                 _rValue = xProp->getPropertyValue(PROPERTY_CATALOGNAME);
     274             :             }
     275          12 :             break;
     276             :         case PROPERTY_ID_SCHEMANAME:
     277             :             {
     278          12 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     279          12 :                 _rValue = xProp->getPropertyValue(PROPERTY_SCHEMANAME);
     280             :             }
     281          12 :             break;
     282             :         case PROPERTY_ID_NAME:
     283             :             {
     284          12 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     285          12 :                 _rValue = xProp->getPropertyValue(PROPERTY_NAME);
     286             :             }
     287          12 :             break;
     288             :         case PROPERTY_ID_DESCRIPTION:
     289             :             {
     290           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     291           0 :                 _rValue = xProp->getPropertyValue(PROPERTY_DESCRIPTION);
     292             :             }
     293           0 :             break;
     294             :         case PROPERTY_ID_TYPE:
     295             :             {
     296           0 :                 Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     297           0 :                 _rValue = xProp->getPropertyValue(PROPERTY_TYPE);
     298             :             }
     299           0 :             break;
     300             :         default:
     301             :             SAL_WARN("dbaccess", "Invalid Handle for table");
     302             :     }
     303          45 : }
     304             : 
     305          16 : void ODBTableDecorator::construct()
     306             : {
     307             :     SAL_INFO("dbaccess", "ODBTableDecorator::construct" );
     308          16 :     sal_Bool bNotFound = sal_True;
     309          16 :     Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     310          16 :     if ( xProp.is() )
     311             :     {
     312          16 :         Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
     313          16 :         bNotFound = !xInfo->hasPropertyByName(PROPERTY_PRIVILEGES);
     314             :     }
     315          16 :     if ( bNotFound )
     316             :         registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND  | PropertyAttribute::READONLY,
     317          15 :                         &m_nPrivileges, ::getCppuType(static_cast<sal_Int32*>(NULL)));
     318          16 : }
     319             : 
     320          16 : ::cppu::IPropertyArrayHelper* ODBTableDecorator::createArrayHelper(sal_Int32 /*_nId*/) const
     321             : {
     322          16 :     Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     323          32 :     Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
     324             : 
     325          32 :     Sequence< Property > aTableProps = xInfo->getProperties();
     326          16 :     Property* pIter = aTableProps.getArray();
     327          16 :     Property* pEnd = pIter + aTableProps.getLength();
     328          97 :     for (;pIter != pEnd ; ++pIter)
     329             :     {
     330          81 :         if (pIter->Name == PROPERTY_CATALOGNAME)
     331          16 :             pIter->Handle = PROPERTY_ID_CATALOGNAME;
     332          65 :         else if (pIter->Name == PROPERTY_SCHEMANAME)
     333          16 :             pIter->Handle = PROPERTY_ID_SCHEMANAME;
     334          49 :         else if (pIter->Name == PROPERTY_NAME)
     335          16 :             pIter->Handle = PROPERTY_ID_NAME;
     336          33 :         else if (pIter->Name == PROPERTY_DESCRIPTION)
     337          16 :             pIter->Handle = PROPERTY_ID_DESCRIPTION;
     338          17 :         else if (pIter->Name == PROPERTY_TYPE)
     339          16 :             pIter->Handle = PROPERTY_ID_TYPE;
     340           1 :         else if (pIter->Name == PROPERTY_PRIVILEGES)
     341           1 :             pIter->Handle = PROPERTY_ID_PRIVILEGES;
     342             :     }
     343             : 
     344          16 :     describeProperties(aTableProps);
     345             : 
     346          32 :     return new ::cppu::OPropertyArrayHelper(aTableProps);
     347             : }
     348             : 
     349        2164 : ::cppu::IPropertyArrayHelper & SAL_CALL ODBTableDecorator::getInfoHelper()
     350             : {
     351        2164 :     Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     352             : 
     353        4328 :     Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
     354        2164 :     bool bIsDescriptor = (xInfo->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY) == 0;
     355             : 
     356        4328 :     return *ODBTableDecorator_PROP::getArrayHelper( bIsDescriptor ? 0 : 1 );
     357             : 
     358             :     // TODO: this is a HACK, and prone to errors
     359             :     // The OIdPropertyArrayUsageHelper is intended for classes where there exists a known, limited
     360             :     // number of different property set infos (distinguished by the ID), all implemented by this very
     361             :     // same class.
     362             :     // However, in this case here we have an unknown, potentially unlimited number of different
     363             :     // property set infos: Depending on the table for which we act as decorator, different property
     364             :     // sets might exist.
     365             : }
     366             : 
     367             : // XServiceInfo
     368           2 : IMPLEMENT_SERVICE_INFO1(ODBTableDecorator, "com.sun.star.sdb.dbaccess.ODBTableDecorator", SERVICE_SDBCX_TABLE)
     369             : 
     370         430 : Any SAL_CALL ODBTableDecorator::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     371             : {
     372         430 :     Any aRet;
     373         430 :     if(m_xTable.is())
     374             :     {
     375         430 :         aRet = m_xTable->queryInterface(rType);
     376         430 :         if(aRet.hasValue())
     377             :         {   // now we know that our table supports this type so we return ourself
     378         430 :             aRet = OTableDescriptor_BASE::queryInterface(rType);
     379         430 :             if(!aRet.hasValue())
     380          38 :                 aRet = ODataSettings::queryInterface(rType);
     381             :         }
     382             :     }
     383             : 
     384         430 :     return aRet;
     385             : }
     386             : 
     387           0 : Sequence< Type > SAL_CALL ODBTableDecorator::getTypes(  ) throw(RuntimeException, std::exception)
     388             : {
     389           0 :     Reference<XTypeProvider> xTypes(m_xTable,UNO_QUERY);
     390             :     OSL_ENSURE(xTypes.is(),"Table must be a TypePropvider!");
     391           0 :     return xTypes->getTypes();
     392             : }
     393             : 
     394             : // XRename,
     395           0 : void SAL_CALL ODBTableDecorator::rename( const OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException, std::exception)
     396             : {
     397             :     SAL_INFO("dbaccess", "ODBTableDecorator::rename" );
     398           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     399           0 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     400           0 :     Reference<XRename> xRename(m_xTable,UNO_QUERY);
     401           0 :     if(xRename.is())
     402             :     {
     403           0 :         xRename->rename(_rNewName);
     404             :     }
     405             :     else // not supported
     406           0 :         throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
     407           0 : }
     408             : 
     409             : // XAlterTable,
     410           0 : void SAL_CALL ODBTableDecorator::alterColumnByName( const OUString& _rName, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, NoSuchElementException, RuntimeException, std::exception)
     411             : {
     412             :     SAL_INFO("dbaccess", "ODBTableDecorator::alterColumnByName" );
     413           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     414           0 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     415           0 :     Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
     416           0 :     if(xAlter.is())
     417             :     {
     418           0 :         xAlter->alterColumnByName(_rName,_rxDescriptor);
     419             :     }
     420             :     else
     421           0 :         throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_NAME),*this,SQLSTATE_GENERAL,1000,Any() );
     422           0 :     if(m_pColumns)
     423           0 :         m_pColumns->refresh();
     424           0 : }
     425             : 
     426           0 : void SAL_CALL ODBTableDecorator::alterColumnByIndex( sal_Int32 _nIndex, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, IndexOutOfBoundsException, RuntimeException, std::exception)
     427             : {
     428             :     SAL_INFO("dbaccess", "ODBTableDecorator::alterColumnByIndex" );
     429           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     430           0 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     431           0 :     Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
     432           0 :     if(xAlter.is())
     433             :     {
     434           0 :         xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
     435           0 :         if(m_pColumns)
     436           0 :             m_pColumns->refresh();
     437             :     }
     438             :     else // not supported
     439           0 :         throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_INDEX),*this,SQLSTATE_GENERAL,1000,Any() );
     440           0 : }
     441             : 
     442           0 : Reference< XNameAccess> ODBTableDecorator::getIndexes() throw (RuntimeException, std::exception)
     443             : {
     444             :     SAL_INFO("dbaccess", "ODBTableDecorator::getIndexes" );
     445           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     446           0 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     447           0 :     return Reference< XIndexesSupplier>(m_xTable,UNO_QUERY)->getIndexes();
     448             : }
     449             : 
     450           0 : Reference< XIndexAccess> ODBTableDecorator::getKeys() throw (RuntimeException, std::exception)
     451             : {
     452             :     SAL_INFO("dbaccess", "ODBTableDecorator::getKeys" );
     453           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     454           0 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     455           0 :     return Reference< XKeysSupplier>(m_xTable,UNO_QUERY)->getKeys();
     456             : }
     457             : 
     458         465 : Reference< XNameAccess> ODBTableDecorator::getColumns() throw (RuntimeException, std::exception)
     459             : {
     460             :     SAL_INFO("dbaccess", "ODBTableDecorator::getColumns" );
     461         465 :     ::osl::MutexGuard aGuard(m_aMutex);
     462         465 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     463             : 
     464         465 :     if(!m_pColumns)
     465          16 :         refreshColumns();
     466             : 
     467         465 :     return m_pColumns;
     468             : }
     469             : 
     470           0 : OUString SAL_CALL ODBTableDecorator::getName() throw(RuntimeException, std::exception)
     471             : {
     472             :     SAL_INFO("dbaccess", "ODBTableDecorator::getName" );
     473           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     474           0 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     475           0 :     Reference<XNamed> xName(m_xTable,UNO_QUERY);
     476             :     OSL_ENSURE(xName.is(),"Table should support the XNamed interface");
     477           0 :     return xName->getName();
     478             : }
     479             : 
     480           0 : sal_Int64 SAL_CALL ODBTableDecorator::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException, std::exception)
     481             : {
     482             :     SAL_INFO("dbaccess", "ODBTableDecorator::getSomething" );
     483           0 :     if (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
     484           0 :         return reinterpret_cast<sal_Int64>(this);
     485             : 
     486           0 :     sal_Int64 nRet = 0;
     487           0 :     Reference<XUnoTunnel> xTunnel(m_xTable,UNO_QUERY);
     488           0 :     if(xTunnel.is())
     489           0 :         nRet = xTunnel->getSomething(rId);
     490           0 :     return nRet;
     491             : }
     492             : 
     493           0 : Sequence< sal_Int8 > ODBTableDecorator::getUnoTunnelImplementationId()
     494             : {
     495             :     SAL_INFO("dbaccess", "ODBTableDecorator::getUnoTunnelImplementationId" );
     496             :     static ::cppu::OImplementationId * pId = 0;
     497           0 :     if (! pId)
     498             :     {
     499           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     500           0 :         if (! pId)
     501             :         {
     502           0 :             static ::cppu::OImplementationId aId;
     503           0 :             pId = &aId;
     504           0 :         }
     505             :     }
     506           0 :     return pId->getImplementationId();
     507             : }
     508             : 
     509           0 : void ODBTableDecorator::fillPrivileges() const
     510             : {
     511             :     SAL_INFO("dbaccess", "ODBTableDecorator::fillPrivileges" );
     512             :     // somebody is asking for the privileges and we do not know them, yet
     513           0 :     m_nPrivileges = 0;
     514             :     try
     515             :     {
     516           0 :         Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
     517           0 :         if ( xProp.is() )
     518             :         {
     519           0 :             if ( xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES) )
     520             :             {
     521           0 :                 xProp->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
     522             :             }
     523           0 :             if ( m_nPrivileges == 0 ) // second chance
     524             :             {
     525           0 :                 OUString sCatalog,sSchema,sName;
     526           0 :                 xProp->getPropertyValue(PROPERTY_CATALOGNAME)   >>= sCatalog;
     527           0 :                 xProp->getPropertyValue(PROPERTY_SCHEMANAME)    >>= sSchema;
     528           0 :                 xProp->getPropertyValue(PROPERTY_NAME)          >>= sName;
     529           0 :                 m_nPrivileges = ::dbtools::getTablePrivileges(getMetaData(),sCatalog,sSchema, sName);
     530             :             }
     531           0 :         }
     532             :     }
     533           0 :     catch(const SQLException& e)
     534             :     {
     535             :         (void)e;
     536             :         SAL_WARN("dbaccess", "ODBTableDecorator::ODBTableDecorator : could not collect the privileges !");
     537             :     }
     538           0 : }
     539             : 
     540           0 : Reference< XPropertySet > SAL_CALL ODBTableDecorator::createDataDescriptor(  ) throw (RuntimeException, std::exception)
     541             : {
     542             :     SAL_INFO("dbaccess", "ODBTableDecorator::createDataDescriptor" );
     543           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     544           0 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     545             : 
     546           0 :     Reference< XDataDescriptorFactory > xFactory( m_xTable, UNO_QUERY );
     547             :     OSL_ENSURE( xFactory.is(), "ODBTableDecorator::createDataDescriptor: invalid table!" );
     548           0 :     Reference< XColumnsSupplier > xColsSupp;
     549           0 :     if ( xFactory.is() )
     550           0 :         xColsSupp = xColsSupp.query( xFactory->createDataDescriptor() );
     551             : 
     552             :     return new ODBTableDecorator(
     553             :         m_xConnection,
     554             :         xColsSupp,
     555             :         m_xNumberFormats,
     556             :         NULL
     557           0 :     );
     558             : }
     559             : 
     560          61 : Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODBTableDecorator::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
     561             : {
     562             :     SAL_INFO("dbaccess", "ODBTableDecorator::getPropertySetInfo" );
     563          61 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     564             : }
     565             : 
     566          16 : void ODBTableDecorator::refreshColumns()
     567             : {
     568             :     SAL_INFO("dbaccess", "ODBTableDecorator::refreshColumns" );
     569          16 :     ::osl::MutexGuard aGuard(m_aMutex);
     570          16 :     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     571             : 
     572          32 :     ::std::vector< OUString> aVector;
     573             : 
     574          32 :     Reference<XNameAccess> xNames;
     575          16 :     if(m_xTable.is())
     576             :     {
     577          16 :         xNames = m_xTable->getColumns();
     578          16 :         if(xNames.is())
     579             :         {
     580          16 :             Sequence< OUString> aNames = xNames->getElementNames();
     581          16 :             const OUString* pIter    = aNames.getConstArray();
     582          16 :             const OUString* pEnd     = pIter + aNames.getLength();
     583         327 :             for(;pIter != pEnd;++pIter)
     584         327 :                 aVector.push_back(*pIter);
     585             :         }
     586             :     }
     587          16 :     if(!m_pColumns)
     588             :     {
     589          16 :         OColumns* pCol = new OColumns(*this,m_aMutex,xNames,m_xMetaData.is() && m_xMetaData->supportsMixedCaseQuotedIdentifiers(),aVector,
     590             :                                     this,this,
     591          16 :                                     m_xMetaData.is() && m_xMetaData->supportsAlterTableWithAddColumn(),
     592          32 :                                     m_xMetaData.is() && m_xMetaData->supportsAlterTableWithDropColumn());
     593             : 
     594          16 :         pCol->setParent(*this);
     595          16 :         OContainerMediator* pMediator = new OContainerMediator( pCol, m_xColumnDefinitions, m_xConnection );
     596          16 :         m_xColumnMediator = pMediator;
     597          16 :         pCol->setMediator( pMediator );
     598          16 :         m_pColumns  = pCol;
     599             :     }
     600             :     else
     601          16 :         m_pColumns->reFill(aVector);
     602          16 : }
     603             : 
     604         221 : OColumn* ODBTableDecorator::createColumn(const OUString& _rName) const
     605             : {
     606             :     SAL_INFO("dbaccess", "ODBTableDecorator::createColumn" );
     607         221 :     OColumn* pReturn = NULL;
     608             : 
     609         221 :     Reference<XNameAccess> xNames;
     610         221 :     if ( m_xTable.is() )
     611             :     {
     612         221 :         xNames = m_xTable->getColumns();
     613             : 
     614         221 :         if ( xNames.is() && xNames->hasByName(_rName) )
     615             :         {
     616         221 :             Reference<XPropertySet> xProp(xNames->getByName(_rName),UNO_QUERY);
     617             : 
     618         442 :             Reference<XPropertySet> xColumnDefintion;
     619         221 :             if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName))
     620         128 :                 xColumnDefintion.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY);
     621             : 
     622         442 :             pReturn = new OTableColumnWrapper( xProp, xColumnDefintion, false );
     623             :         }
     624             :     }
     625         221 :     return pReturn;
     626             : }
     627             : 
     628           0 : void ODBTableDecorator::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
     629             : {
     630             :     SAL_INFO("dbaccess", "ODBTableDecorator::columnAppended" );
     631             :     // not interested in
     632           0 : }
     633             : 
     634           0 : void ODBTableDecorator::columnDropped(const OUString& _sName)
     635             : {
     636             :     SAL_INFO("dbaccess", "ODBTableDecorator::columnDropped" );
     637           0 :     Reference<XDrop> xDrop(m_xColumnDefinitions,UNO_QUERY);
     638           0 :     if ( xDrop.is() && m_xColumnDefinitions->hasByName(_sName) )
     639           0 :         xDrop->dropByName(_sName);
     640           0 : }
     641             : 
     642           0 : Reference< XPropertySet > ODBTableDecorator::createColumnDescriptor()
     643             : {
     644             :     SAL_INFO("dbaccess", "ODBTableDecorator::createColumnDescriptor" );
     645           0 :     Reference<XDataDescriptorFactory> xNames;
     646           0 :     if(m_xTable.is())
     647           0 :         xNames.set(m_xTable->getColumns(),UNO_QUERY);
     648           0 :     Reference< XPropertySet > xRet;
     649           0 :     if ( xNames.is() )
     650           0 :         xRet = new OTableColumnDescriptorWrapper( xNames->createDataDescriptor(), false, true );
     651           0 :     return xRet;
     652             : }
     653             : 
     654        3184 : void SAL_CALL ODBTableDecorator::acquire() throw()
     655             : {
     656        3184 :     OTableDescriptor_BASE::acquire();
     657        3184 : }
     658             : 
     659        3184 : void SAL_CALL ODBTableDecorator::release() throw()
     660             : {
     661        3184 :     OTableDescriptor_BASE::release();
     662        3184 : }
     663             : 
     664           0 : void SAL_CALL ODBTableDecorator::setName( const OUString& /*aName*/ ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     665             : {
     666             :     SAL_INFO("dbaccess", "ODBTableDecorator::setName" );
     667           0 :     throwFunctionNotSupportedException( "XNamed::setName", *this );
     668           0 : }
     669             : 
     670             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10