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

Generated by: LCOV version 1.10