LCOV - code coverage report
Current view: top level - connectivity/source/commontools - dbtools.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 326 898 36.3 %
Date: 2012-08-25 Functions: 34 59 57.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 446 2183 20.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include "connectivity/CommonTools.hxx"
      22                 :            : #include "diagnose_ex.h"
      23                 :            : #include "TConnection.hxx"
      24                 :            : #include "connectivity/ParameterCont.hxx"
      25                 :            : 
      26                 :            : #include <com/sun/star/awt/XWindow.hpp>
      27                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28                 :            : #include <com/sun/star/container/XChild.hpp>
      29                 :            : #include <com/sun/star/form/FormComponentType.hpp>
      30                 :            : #include <com/sun/star/io/XInputStream.hpp>
      31                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      32                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      33                 :            : #include <com/sun/star/sdb/BooleanComparisonMode.hpp>
      34                 :            : #include <com/sun/star/sdb/CommandType.hpp>
      35                 :            : #include <com/sun/star/sdb/ParametersRequest.hpp>
      36                 :            : #include <com/sun/star/sdb/RowSetVetoException.hpp>
      37                 :            : #include <com/sun/star/sdb/SQLContext.hpp>
      38                 :            : #include <com/sun/star/sdb/XCompletedConnection.hpp>
      39                 :            : #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
      40                 :            : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
      41                 :            : #include <com/sun/star/sdb/XParametersSupplier.hpp>
      42                 :            : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      43                 :            : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
      44                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      45                 :            : #include <com/sun/star/sdbc/XConnection.hpp>
      46                 :            : #include <com/sun/star/sdbc/XDataSource.hpp>
      47                 :            : #include <com/sun/star/sdbc/XDriverManager.hpp>
      48                 :            : #include <com/sun/star/sdbc/XParameters.hpp>
      49                 :            : #include <com/sun/star/sdbc/XRow.hpp>
      50                 :            : #include <com/sun/star/sdbc/XRowSet.hpp>
      51                 :            : #include <com/sun/star/sdbc/XRowUpdate.hpp>
      52                 :            : #include <com/sun/star/sdbcx/KeyType.hpp>
      53                 :            : #include <com/sun/star/sdbcx/Privilege.hpp>
      54                 :            : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      55                 :            : #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
      56                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      57                 :            : #include <com/sun/star/task/XInteractionHandler.hpp>
      58                 :            : #include <com/sun/star/task/XInteractionRequest.hpp>
      59                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      60                 :            : #include <com/sun/star/uno/XNamingService.hpp>
      61                 :            : #include <com/sun/star/util/NumberFormat.hpp>
      62                 :            : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      63                 :            : #include <com/sun/star/util/XNumberFormatTypes.hpp>
      64                 :            : 
      65                 :            : #include <comphelper/extract.hxx>
      66                 :            : #include <comphelper/interaction.hxx>
      67                 :            : #include <comphelper/property.hxx>
      68                 :            : #include <connectivity/conncleanup.hxx>
      69                 :            : #include <connectivity/dbconversion.hxx>
      70                 :            : #include <connectivity/dbexception.hxx>
      71                 :            : #include <connectivity/dbtools.hxx>
      72                 :            : #include <connectivity/statementcomposer.hxx>
      73                 :            : #include <osl/diagnose.h>
      74                 :            : #include <rtl/ustrbuf.hxx>
      75                 :            : #include <tools/diagnose_ex.h>
      76                 :            : 
      77                 :            : #include "resource/common_res.hrc"
      78                 :            : #include "resource/sharedresources.hxx"
      79                 :            : #include "connectivity/OSubComponent.hxx"
      80                 :            : 
      81                 :            : #include <algorithm>
      82                 :            : 
      83                 :            : using namespace ::comphelper;
      84                 :            : using namespace ::com::sun::star::uno;
      85                 :            : using namespace ::com::sun::star::io;
      86                 :            : using namespace ::com::sun::star::awt;
      87                 :            : using namespace ::com::sun::star::ui::dialogs;
      88                 :            : using namespace ::com::sun::star::util;
      89                 :            : using namespace ::com::sun::star::lang;
      90                 :            : using namespace ::com::sun::star::beans;
      91                 :            : using namespace ::com::sun::star::container;
      92                 :            : using namespace ::com::sun::star::sdb;
      93                 :            : using namespace ::com::sun::star::sdbc;
      94                 :            : using namespace ::com::sun::star::sdbcx;
      95                 :            : using namespace ::com::sun::star::form;
      96                 :            : using namespace connectivity;
      97                 :            : 
      98                 :            : //.........................................................................
      99                 :            : namespace dbtools
     100                 :            : {
     101                 :            : //.........................................................................
     102                 :            : 
     103                 :            :     using namespace ::com::sun::star::uno;
     104                 :            :     using namespace ::com::sun::star::beans;
     105                 :            :     using namespace ::com::sun::star::util;
     106                 :            :     using namespace ::com::sun::star::task;
     107                 :            :     using namespace ::com::sun::star::uno;
     108                 :            :     using namespace ::com::sun::star::lang;
     109                 :            :     using namespace ::com::sun::star::sdbc;
     110                 :            :     using namespace ::com::sun::star::task;
     111                 :            : 
     112                 :            : //==============================================================================
     113                 :            : //==============================================================================
     114                 :            : namespace
     115                 :            : {
     116                 :            :     typedef sal_Bool (SAL_CALL XDatabaseMetaData::*FMetaDataSupport)();
     117                 :            : }
     118                 :            : //==============================================================================
     119                 :            : //==============================================================================
     120                 :        880 : sal_Int32 getDefaultNumberFormat(const Reference< XPropertySet >& _xColumn,
     121                 :            :                                  const Reference< XNumberFormatTypes >& _xTypes,
     122                 :            :                                  const Locale& _rLocale)
     123                 :            : {
     124                 :            :     OSL_ENSURE(_xTypes.is() && _xColumn.is(), "dbtools::getDefaultNumberFormat: invalid arg !");
     125 [ +  - ][ -  + ]:        880 :     if (!_xTypes.is() || !_xColumn.is())
                 [ -  + ]
     126                 :          0 :         return NumberFormat::UNDEFINED;
     127                 :            : 
     128                 :        880 :     sal_Int32 nDataType = 0;
     129                 :        880 :     sal_Int32 nScale = 0;
     130                 :            :     try
     131                 :            :     {
     132                 :            :         // determine the datatype of the column
     133 [ +  - ][ +  - ]:        880 :         _xColumn->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type"))) >>= nDataType;
                 [ +  - ]
     134                 :            : 
     135 [ +  + ][ +  - ]:        880 :         if (DataType::NUMERIC == nDataType || DataType::DECIMAL == nDataType)
     136 [ +  - ][ +  - ]:        160 :             _xColumn->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Scale"))) >>= nScale;
         [ +  - ][ #  # ]
     137                 :            :     }
     138         [ #  # ]:          0 :     catch (Exception&)
     139                 :            :     {
     140                 :          0 :         return NumberFormat::UNDEFINED;
     141                 :            :     }
     142                 :            :     return getDefaultNumberFormat(nDataType,
     143                 :            :                     nScale,
     144 [ +  - ][ +  - ]:       1760 :                     ::cppu::any2bool(_xColumn->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsCurrency")))),
         [ +  - ][ +  - ]
     145                 :            :                     _xTypes,
     146         [ +  - ]:        880 :                     _rLocale);
     147                 :            : }
     148                 :            : 
     149                 :            : //------------------------------------------------------------------
     150                 :        880 : sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
     151                 :            :                                  sal_Int32 _nScale,
     152                 :            :                                  sal_Bool _bIsCurrency,
     153                 :            :                                  const Reference< XNumberFormatTypes >& _xTypes,
     154                 :            :                                  const Locale& _rLocale)
     155                 :            : {
     156                 :            :     OSL_ENSURE(_xTypes.is() , "dbtools::getDefaultNumberFormat: invalid arg !");
     157         [ -  + ]:        880 :     if (!_xTypes.is())
     158                 :          0 :         return NumberFormat::UNDEFINED;
     159                 :            : 
     160                 :        880 :     sal_Int32 nFormat = 0;
     161         [ -  + ]:        880 :     sal_Int32 nNumberType   = _bIsCurrency ? NumberFormat::CURRENCY : NumberFormat::NUMBER;
     162   [ +  +  +  +  :        880 :     switch (_nDataType)
                -  -  - ]
     163                 :            :     {
     164                 :            :         case DataType::BIT:
     165                 :            :         case DataType::BOOLEAN:
     166                 :         32 :             nFormat = _xTypes->getStandardFormat(NumberFormat::LOGICAL, _rLocale);
     167                 :         32 :             break;
     168                 :            :         case DataType::TINYINT:
     169                 :            :         case DataType::SMALLINT:
     170                 :            :         case DataType::INTEGER:
     171                 :            :         case DataType::BIGINT:
     172                 :            :         case DataType::FLOAT:
     173                 :            :         case DataType::REAL:
     174                 :            :         case DataType::DOUBLE:
     175                 :            :         case DataType::NUMERIC:
     176                 :            :         case DataType::DECIMAL:
     177                 :            :         {
     178                 :            :             try
     179                 :            :             {
     180 [ +  - ][ +  - ]:        160 :                 nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale);
     181         [ +  - ]:        160 :                 if(_nScale > 0)
     182                 :            :                 {
     183                 :            :                     // generate a new format if necessary
     184         [ +  - ]:        160 :                     Reference< XNumberFormats > xFormats(_xTypes, UNO_QUERY);
     185 [ +  - ][ +  - ]:        160 :                     ::rtl::OUString sNewFormat = xFormats->generateFormat( 0L, _rLocale, sal_False, sal_False, (sal_Int16)_nScale, sal_True);
     186                 :            : 
     187                 :            :                     // and add it to the formatter if necessary
     188 [ +  - ][ +  - ]:        160 :                     nFormat = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
     189         [ +  + ]:        160 :                     if (nFormat == (sal_Int32)-1)
     190 [ +  - ][ +  - ]:        160 :                         nFormat = xFormats->addNew(sNewFormat, _rLocale);
     191                 :            :                 }
     192                 :            :             }
     193         [ #  # ]:          0 :             catch (Exception&)
     194                 :            :             {
     195   [ #  #  #  # ]:          0 :                 nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale);
     196                 :            :             }
     197                 :        160 :         }   break;
     198                 :            :         case DataType::CHAR:
     199                 :            :         case DataType::VARCHAR:
     200                 :            :         case DataType::LONGVARCHAR:
     201                 :            :         case DataType::CLOB:
     202                 :        624 :             nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale);
     203                 :        624 :             break;
     204                 :            :         case DataType::DATE:
     205                 :         64 :             nFormat = _xTypes->getStandardFormat(NumberFormat::DATE, _rLocale);
     206                 :         64 :             break;
     207                 :            :         case DataType::TIME:
     208                 :          0 :             nFormat = _xTypes->getStandardFormat(NumberFormat::TIME, _rLocale);
     209                 :          0 :             break;
     210                 :            :         case DataType::TIMESTAMP:
     211                 :          0 :             nFormat = _xTypes->getStandardFormat(NumberFormat::DATETIME, _rLocale);
     212                 :          0 :             break;
     213                 :            :         case DataType::BINARY:
     214                 :            :         case DataType::VARBINARY:
     215                 :            :         case DataType::LONGVARBINARY:
     216                 :            :         case DataType::SQLNULL:
     217                 :            :         case DataType::OTHER:
     218                 :            :         case DataType::OBJECT:
     219                 :            :         case DataType::DISTINCT:
     220                 :            :         case DataType::STRUCT:
     221                 :            :         case DataType::ARRAY:
     222                 :            :         case DataType::BLOB:
     223                 :            :         case DataType::REF:
     224                 :            :         default:
     225                 :          0 :             nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale);
     226                 :            :             //nFormat = NumberFormat::UNDEFINED;
     227                 :            :     }
     228                 :        880 :     return nFormat;
     229                 :            : }
     230                 :            : 
     231                 :            : //==============================================================================
     232                 :            : //------------------------------------------------------------------------------
     233                 :         92 : Reference< XConnection> findConnection(const Reference< XInterface >& xParent)
     234                 :            : {
     235                 :         92 :     Reference< XConnection> xConnection(xParent, UNO_QUERY);
     236         [ +  - ]:         92 :     if (!xConnection.is())
     237                 :            :     {
     238         [ +  - ]:         92 :         Reference< XChild> xChild(xParent, UNO_QUERY);
     239         [ +  + ]:         92 :         if (xChild.is())
     240 [ +  - ][ +  - ]:         92 :             xConnection = findConnection(xChild->getParent());
         [ +  - ][ +  - ]
     241                 :            :     }
     242                 :         92 :     return xConnection;
     243                 :            : }
     244                 :            : 
     245                 :            : //------------------------------------------------------------------------------
     246                 :         74 : Reference< XDataSource> getDataSource_allowException(
     247                 :            :             const ::rtl::OUString& _rsTitleOrPath,
     248                 :            :             const Reference< XMultiServiceFactory >& _rxFactory )
     249                 :            : {
     250 [ -  + ][ #  # ]:         74 :     ENSURE_OR_RETURN( !_rsTitleOrPath.isEmpty(), "getDataSource_allowException: invalid arg !", NULL );
     251                 :            : 
     252                 :            :     Reference< XNameAccess> xDatabaseContext(
     253         [ +  - ]:         74 :         _rxFactory->createInstance(
     254 [ +  - ][ +  - ]:         74 :             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DatabaseContext" )) ),UNO_QUERY );
                 [ +  - ]
     255                 :            :     OSL_ENSURE( xDatabaseContext.is(), "getDataSource_allowException: could not obtain the database context!" );
     256                 :            : 
     257 [ +  - ][ +  - ]:         74 :     return Reference< XDataSource >( xDatabaseContext->getByName( _rsTitleOrPath ), UNO_QUERY );
                 [ +  - ]
     258                 :            : }
     259                 :            : 
     260                 :            : //------------------------------------------------------------------------------
     261                 :         52 : Reference< XDataSource > getDataSource(
     262                 :            :             const ::rtl::OUString& _rsTitleOrPath,
     263                 :            :             const Reference< XMultiServiceFactory >& _rxFactory )
     264                 :            : {
     265                 :         52 :     Reference< XDataSource > xDS;
     266                 :            :     try
     267                 :            :     {
     268 [ +  - ][ #  # ]:         52 :         xDS = getDataSource_allowException( _rsTitleOrPath, _rxFactory );
                 [ +  - ]
     269                 :            :     }
     270         [ #  # ]:          0 :     catch( const Exception& )
     271                 :            :     {
     272                 :            :         DBG_UNHANDLED_EXCEPTION();
     273                 :            :     }
     274                 :            : 
     275                 :         52 :     return xDS;
     276                 :            : }
     277                 :            : 
     278                 :            : //------------------------------------------------------------------------------
     279                 :         22 : Reference< XConnection > getConnection_allowException(
     280                 :            :             const ::rtl::OUString& _rsTitleOrPath,
     281                 :            :             const ::rtl::OUString& _rsUser,
     282                 :            :             const ::rtl::OUString& _rsPwd,
     283                 :            :             const Reference< XMultiServiceFactory>& _rxFactory)
     284                 :            : {
     285         [ +  - ]:         22 :     Reference< XDataSource> xDataSource( getDataSource_allowException(_rsTitleOrPath, _rxFactory) );
     286                 :         22 :     Reference<XConnection> xConnection;
     287         [ +  - ]:         22 :     if (xDataSource.is())
     288                 :            :     {
     289                 :            :         // do it with interaction handler
     290 [ -  + ][ #  # ]:         22 :         if(_rsUser.isEmpty() || _rsPwd.isEmpty())
                 [ +  - ]
     291                 :            :         {
     292         [ +  - ]:         22 :             Reference<XPropertySet> xProp(xDataSource,UNO_QUERY);
     293                 :         22 :             ::rtl::OUString sPwd, sUser;
     294                 :         22 :             sal_Bool bPwdReq = sal_False;
     295                 :            :             try
     296                 :            :             {
     297 [ +  - ][ +  - ]:         22 :                 xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
         [ +  - ][ +  - ]
     298 [ +  - ][ +  - ]:         22 :                 bPwdReq = ::cppu::any2bool(xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsPasswordRequired"))));
         [ +  - ][ +  - ]
     299 [ +  - ][ +  - ]:         22 :                 xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("User"))) >>= sUser;
         [ #  # ][ +  - ]
     300                 :            :             }
     301         [ #  # ]:          0 :             catch(Exception&)
     302                 :            :             {
     303                 :            :                 OSL_FAIL("dbtools::getConnection: error while retrieving data source properties!");
     304                 :            :             }
     305 [ -  + ][ #  # ]:         22 :             if(bPwdReq && sPwd.isEmpty())
                 [ -  + ]
     306                 :            :             {   // password required, but empty -> connect using an interaction handler
     307         [ #  # ]:          0 :                 Reference<XCompletedConnection> xConnectionCompletion(xProp, UNO_QUERY);
     308         [ #  # ]:          0 :                 if (xConnectionCompletion.is())
     309                 :            :                 {   // instantiate the default SDB interaction handler
     310 [ #  # ][ #  # ]:          0 :                     Reference< XInteractionHandler > xHandler(_rxFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler"))), UNO_QUERY);
         [ #  # ][ #  # ]
     311                 :            :                     OSL_ENSURE(xHandler.is(), "dbtools::getConnection service com.sun.star.task.InteractionHandler not available!");
     312         [ #  # ]:          0 :                     if (xHandler.is())
     313                 :            :                     {
     314 [ #  # ][ #  # ]:          0 :                         xConnection = xConnectionCompletion->connectWithCompletion(xHandler);
                 [ #  # ]
     315                 :          0 :                     }
     316                 :          0 :                 }
     317                 :            :             }
     318                 :            :             else
     319 [ +  - ][ +  - ]:         22 :                 xConnection = xDataSource->getConnection(sUser, sPwd);
                 [ +  - ]
     320                 :            :         }
     321         [ -  + ]:         22 :         if(!xConnection.is()) // try to get one if not already have one, just to make sure
     322 [ #  # ][ #  # ]:          0 :             xConnection = xDataSource->getConnection(_rsUser, _rsPwd);
                 [ #  # ]
     323                 :            :     }
     324                 :         22 :     return xConnection;
     325                 :            : }
     326                 :            : 
     327                 :            : //------------------------------------------------------------------------------
     328                 :          0 : Reference< XConnection> getConnection_withFeedback(const ::rtl::OUString& _rDataSourceName,
     329                 :            :         const ::rtl::OUString& _rUser, const ::rtl::OUString& _rPwd, const Reference< XMultiServiceFactory>& _rxFactory)
     330                 :            :     SAL_THROW ( (SQLException) )
     331                 :            : {
     332                 :          0 :     Reference< XConnection > xReturn;
     333                 :            :     try
     334                 :            :     {
     335 [ #  # ][ #  # ]:          0 :         xReturn = getConnection_allowException(_rDataSourceName, _rUser, _rPwd, _rxFactory);
     336                 :            :     }
     337      [ #  #  # ]:          0 :     catch(SQLException&)
     338                 :            :     {
     339                 :            :         // allowed to pass
     340                 :          0 :         throw;
     341                 :            :     }
     342         [ #  # ]:          0 :     catch(Exception&)
     343                 :            :     {
     344                 :            :         OSL_FAIL("::dbtools::getConnection_withFeedback: unexpected (non-SQL) exception caught!");
     345                 :            :     }
     346                 :          0 :     return xReturn;
     347                 :            : }
     348                 :            : 
     349                 :            : //------------------------------------------------------------------------------
     350                 :          0 : Reference< XConnection> getConnection(
     351                 :            :             const ::rtl::OUString& _rsTitleOrPath,
     352                 :            :             const ::rtl::OUString& _rsUser,
     353                 :            :             const ::rtl::OUString& _rsPwd,
     354                 :            :             const Reference< XMultiServiceFactory>& _rxFactory)
     355                 :            : {
     356                 :          0 :     Reference< XConnection > xReturn;
     357                 :            :     try
     358                 :            :     {
     359 [ #  # ][ #  # ]:          0 :         xReturn = getConnection_allowException(_rsTitleOrPath, _rsUser, _rsPwd, _rxFactory);
                 [ #  # ]
     360                 :            :     }
     361         [ #  # ]:          0 :     catch(Exception&)
     362                 :            :     {
     363                 :            :     }
     364                 :            : 
     365                 :            :     // TODO: if there were not dozens of places which rely on getConnection not throwing an exception ....
     366                 :            :     // I would change this ...
     367                 :            : 
     368                 :          0 :     return xReturn;
     369                 :            : }
     370                 :            : 
     371                 :            : //------------------------------------------------------------------------------
     372                 :        123 : Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) throw (RuntimeException)
     373                 :            : {
     374                 :        123 :     Reference< XConnection> xReturn;
     375         [ +  - ]:        123 :     Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
     376         [ +  - ]:        123 :     if (xRowSetProps.is())
     377 [ +  - ][ +  - ]:        123 :         xRowSetProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection"))) >>= xReturn;
         [ +  - ][ +  - ]
     378                 :        123 :     return xReturn;
     379                 :            : }
     380                 :            : 
     381                 :            : //------------------------------------------------------------------------------
     382                 :            : // helper function which allows to implement both the connectRowset and the ensureRowSetConnection semantics
     383                 :            : // if connectRowset (which is deprecated) is removed, this function and one of its parameters are
     384                 :            : // not needed anymore, the whole implementation can be moved into ensureRowSetConnection then)
     385                 :         56 : SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
     386                 :            :         bool _bSetAsActiveConnection, bool _bAttachAutoDisposer )
     387                 :            :     SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) )
     388                 :            : {
     389                 :         56 :     SharedConnection xConnection;
     390                 :            : 
     391                 :            :     do
     392                 :            :     {
     393         [ +  - ]:         56 :         Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
     394         [ -  + ]:         56 :         if ( !xRowSetProps.is() )
     395                 :            :             break;
     396                 :            : 
     397                 :            :         // 1. already connected?
     398                 :            :         Reference< XConnection > xExistingConn(
     399         [ +  - ]:         56 :             xRowSetProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ) ),
     400 [ +  - ][ +  - ]:         56 :             UNO_QUERY );
                 [ +  - ]
     401                 :            : 
     402   [ +  -  -  + ]:        160 :         if  (   xExistingConn.is()
         [ +  + ][ +  + ]
     403                 :            :             // 2. embedded in a database?
     404         [ +  - ]:         24 :             ||  isEmbeddedInDatabase( _rxRowSet, xExistingConn )
     405                 :            :             // 3. is there a connection in the parent hierarchy?
     406 [ +  - ][ +  - ]:         80 :             ||  ( xExistingConn = findConnection( _rxRowSet ) ).is()
         [ +  + ][ #  # ]
     407                 :            :             )
     408                 :            :         {
     409         [ +  - ]:         32 :             if ( _bSetAsActiveConnection )
     410                 :            :             {
     411 [ +  - ][ +  - ]:         32 :                 xRowSetProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ), makeAny( xExistingConn ) );
         [ +  - ][ +  - ]
     412                 :            :                 // no auto disposer needed, since we did not create the connection
     413                 :            :             }
     414                 :            : 
     415         [ +  - ]:         32 :             xConnection.reset( xExistingConn, SharedConnection::NoTakeOwnership );
     416                 :            :             break;
     417                 :            :         }
     418                 :            : 
     419                 :            :         // build a connection with it's current settings (4. data source name, or 5. URL)
     420                 :            : 
     421         [ +  - ]:         24 :         const ::rtl::OUString sUserProp( RTL_CONSTASCII_USTRINGPARAM( "User" ));
     422                 :         24 :         ::rtl::OUString sDataSourceName;
     423 [ +  - ][ +  - ]:         24 :         xRowSetProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName"))) >>= sDataSourceName;
                 [ +  - ]
     424                 :         24 :         ::rtl::OUString sURL;
     425 [ +  - ][ +  - ]:         24 :         xRowSetProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"))) >>= sURL;
                 [ +  - ]
     426                 :            : 
     427                 :         24 :         Reference< XConnection > xPureConnection;
     428         [ +  + ]:         24 :         if (!sDataSourceName.isEmpty())
     429                 :            :         {   // the row set's data source property is set
     430                 :            :             // -> try to connect, get user and pwd setting for that
     431                 :         22 :             ::rtl::OUString sUser, sPwd;
     432                 :            : 
     433 [ +  - ][ +  - ]:         22 :             if (hasProperty(sUserProp, xRowSetProps))
     434 [ +  - ][ +  - ]:         22 :                 xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
     435 [ +  - ][ +  - ]:         22 :             if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps))
         [ +  - ][ +  - ]
     436 [ +  - ][ +  - ]:         22 :                 xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
         [ +  - ][ +  - ]
     437                 :            : 
     438 [ +  - ][ +  - ]:         22 :             xPureConnection = getConnection_allowException( sDataSourceName, sUser, sPwd, _rxFactory );
     439                 :            :         }
     440         [ -  + ]:          2 :         else if (!sURL.isEmpty())
     441                 :            :         {   // the row set has no data source, but a connection url set
     442                 :            :             // -> try to connection with that url
     443                 :            :             Reference< XDriverManager > xDriverManager(
     444 [ #  # ][ #  # ]:          0 :                 _rxFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.ConnectionPool"))), UNO_QUERY);
         [ #  # ][ #  # ]
     445         [ #  # ]:          0 :             if (xDriverManager.is())
     446                 :            :             {
     447                 :          0 :                 ::rtl::OUString sUser, sPwd;
     448 [ #  # ][ #  # ]:          0 :                 if (hasProperty(sUserProp, xRowSetProps))
     449 [ #  # ][ #  # ]:          0 :                     xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
     450 [ #  # ][ #  # ]:          0 :                 if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps))
         [ #  # ][ #  # ]
     451 [ #  # ][ #  # ]:          0 :                     xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
         [ #  # ][ #  # ]
     452         [ #  # ]:          0 :                 if (!sUser.isEmpty())
     453                 :            :                 {   // use user and pwd together with the url
     454         [ #  # ]:          0 :                     Sequence< PropertyValue> aInfo(2);
     455 [ #  # ][ #  # ]:          0 :                     aInfo.getArray()[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"));
     456 [ #  # ][ #  # ]:          0 :                     aInfo.getArray()[0].Value <<= sUser;
     457 [ #  # ][ #  # ]:          0 :                     aInfo.getArray()[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password"));
     458 [ #  # ][ #  # ]:          0 :                     aInfo.getArray()[1].Value <<= sPwd;
     459 [ #  # ][ #  # ]:          0 :                     xPureConnection = xDriverManager->getConnectionWithInfo( sURL, aInfo );
         [ #  # ][ #  # ]
     460                 :            :                 }
     461                 :            :                 else
     462                 :            :                     // just use the url
     463 [ #  # ][ #  # ]:          0 :                     xPureConnection = xDriverManager->getConnection( sURL );
                 [ #  # ]
     464                 :          0 :             }
     465                 :            :         }
     466                 :            :         xConnection.reset(
     467                 :            :             xPureConnection,
     468                 :            :             _bAttachAutoDisposer ? SharedConnection::NoTakeOwnership : SharedConnection::TakeOwnership
     469                 :            :             /* take ownership if and only if we're *not* going to auto-dispose the connection */
     470 [ +  - ][ +  - ]:         24 :         );
     471                 :            : 
     472                 :            :         // now if we created a connection, forward it to the row set
     473 [ +  + ][ +  - ]:         24 :         if ( xConnection.is() && _bSetAsActiveConnection )
                 [ +  + ]
     474                 :            :         {
     475                 :            :             try
     476                 :            :             {
     477         [ +  - ]:         22 :                 if ( _bAttachAutoDisposer )
     478                 :            :                 {
     479         [ +  - ]:         22 :                     OAutoConnectionDisposer* pAutoDispose = new OAutoConnectionDisposer( _rxRowSet, xConnection );
     480 [ +  - ][ +  - ]:         22 :                     Reference< XPropertyChangeListener > xEnsureDelete(pAutoDispose);
     481                 :            :                 }
     482                 :            :                 else
     483         [ #  # ]:          0 :                     xRowSetProps->setPropertyValue(
     484                 :            :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ),
     485                 :          0 :                         makeAny( xConnection.getTyped() )
     486 [ #  # ][ #  # ]:          0 :                     );
         [ #  # ][ #  # ]
     487                 :            :             }
     488         [ #  # ]:          0 :             catch(Exception&)
     489                 :            :             {
     490                 :            :                 OSL_FAIL("EXception when we set the new active connection!");
     491                 :            :             }
     492 [ +  + ][ +  + ]:         56 :         }
     493                 :            :     }
     494                 :            :     while ( false );
     495                 :            : 
     496                 :         56 :     return xConnection;
     497                 :            : }
     498                 :            : 
     499                 :            : //------------------------------------------------------------------------------
     500                 :         56 : Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
     501                 :            :     sal_Bool _bSetAsActiveConnection )  SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) )
     502                 :            : {
     503         [ +  - ]:         56 :     SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxFactory, _bSetAsActiveConnection, true );
     504         [ +  - ]:         56 :     return xConnection.getTyped();
     505                 :            : }
     506                 :            : 
     507                 :            : //------------------------------------------------------------------------------
     508                 :          0 : SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
     509                 :            :     bool _bUseAutoConnectionDisposer )  SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) )
     510                 :            : {
     511                 :          0 :     return lcl_connectRowSet( _rxRowSet, _rxFactory, true, _bUseAutoConnectionDisposer );
     512                 :            : }
     513                 :            : 
     514                 :            : //------------------------------------------------------------------------------
     515                 :          0 : Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const ::rtl::OUString& _rName)
     516                 :            : {
     517                 :          0 :     Reference< XComponent > xDummy;
     518         [ #  # ]:          0 :     return getFieldsByCommandDescriptor( _rxConn, CommandType::TABLE, _rName, xDummy );
     519                 :            : }
     520                 :            : //------------------------------------------------------------------------------
     521                 :          0 : Reference< XNameAccess> getPrimaryKeyColumns_throw(const Any& i_aTable)
     522                 :            : {
     523         [ #  # ]:          0 :     const Reference< XPropertySet > xTable(i_aTable,UNO_QUERY_THROW);
     524         [ #  # ]:          0 :     return getPrimaryKeyColumns_throw(xTable);
     525                 :            : }
     526                 :            : //------------------------------------------------------------------------------
     527                 :          0 : Reference< XNameAccess> getPrimaryKeyColumns_throw(const Reference< XPropertySet >& i_xTable)
     528                 :            : {
     529                 :          0 :     Reference<XNameAccess> xKeyColumns;
     530         [ #  # ]:          0 :     const Reference<XKeysSupplier> xKeySup(i_xTable,UNO_QUERY);
     531         [ #  # ]:          0 :     if ( xKeySup.is() )
     532                 :            :     {
     533 [ #  # ][ #  # ]:          0 :         const Reference<XIndexAccess> xKeys = xKeySup->getKeys();
     534         [ #  # ]:          0 :         if ( xKeys.is() )
     535                 :            :         {
     536         [ #  # ]:          0 :             ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
     537         [ #  # ]:          0 :             const ::rtl::OUString sPropName = rPropMap.getNameByIndex(PROPERTY_ID_TYPE);
     538                 :          0 :             Reference<XPropertySet> xProp;
     539 [ #  # ][ #  # ]:          0 :             const sal_Int32 nCount = xKeys->getCount();
     540         [ #  # ]:          0 :             for(sal_Int32 i = 0;i< nCount;++i)
     541                 :            :             {
     542 [ #  # ][ #  # ]:          0 :                 xProp.set(xKeys->getByIndex(i),UNO_QUERY_THROW);
                 [ #  # ]
     543         [ #  # ]:          0 :                 if ( xProp.is() )
     544                 :            :                 {
     545                 :          0 :                     sal_Int32 nKeyType = 0;
     546 [ #  # ][ #  # ]:          0 :                     xProp->getPropertyValue(sPropName) >>= nKeyType;
     547         [ #  # ]:          0 :                     if(KeyType::PRIMARY == nKeyType)
     548                 :            :                     {
     549         [ #  # ]:          0 :                         const Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY_THROW);
     550 [ #  # ][ #  # ]:          0 :                         xKeyColumns = xKeyColsSup->getColumns();
                 [ #  # ]
     551                 :          0 :                         break;
     552                 :            :                     }
     553                 :            :                 }
     554                 :          0 :             }
     555                 :          0 :         }
     556                 :            :     }
     557                 :            : 
     558                 :          0 :     return xKeyColumns;
     559                 :            : }
     560                 :            : 
     561                 :            : //------------------------------------------------------------------------------
     562                 :            : namespace
     563                 :            : {
     564                 :            :     enum FieldLookupState
     565                 :            :     {
     566                 :            :         HANDLE_TABLE, HANDLE_QUERY, HANDLE_SQL, RETRIEVE_OBJECT, RETRIEVE_COLUMNS, DONE, FAILED
     567                 :            :     };
     568                 :            : }
     569                 :            : 
     570                 :            : //------------------------------------------------------------------------------
     571                 :          0 : Reference< XNameAccess > getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
     572                 :            :     const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
     573                 :            :     Reference< XComponent >& _rxKeepFieldsAlive, SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
     574                 :            : {
     575                 :            :     OSL_PRECOND( _rxConnection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection!" );
     576                 :            :     OSL_PRECOND( ( CommandType::TABLE == _nCommandType ) || ( CommandType::QUERY == _nCommandType ) || ( CommandType::COMMAND == _nCommandType ),
     577                 :            :         "::dbtools::getFieldsByCommandDescriptor: invalid command type!" );
     578                 :            :     OSL_PRECOND( !_rCommand.isEmpty(), "::dbtools::getFieldsByCommandDescriptor: invalid command (empty)!" );
     579                 :            : 
     580                 :          0 :     Reference< XNameAccess > xFields;
     581                 :            : 
     582                 :            :     // reset the error
     583         [ #  # ]:          0 :     if ( _pErrorInfo )
     584 [ #  # ][ #  # ]:          0 :         *_pErrorInfo = SQLExceptionInfo();
                 [ #  # ]
     585                 :            :     // reset the ownership holder
     586                 :          0 :     _rxKeepFieldsAlive.clear();
     587                 :            : 
     588                 :            :     // go for the fields
     589                 :            :     try
     590                 :            :     {
     591                 :            :         // some kind of state machine to ease the sharing of code
     592                 :          0 :         FieldLookupState eState = FAILED;
     593   [ #  #  #  # ]:          0 :         switch ( _nCommandType )
     594                 :            :         {
     595                 :            :             case CommandType::TABLE:
     596                 :          0 :                 eState = HANDLE_TABLE;
     597                 :          0 :                 break;
     598                 :            :             case CommandType::QUERY:
     599                 :          0 :                 eState = HANDLE_QUERY;
     600                 :          0 :                 break;
     601                 :            :             case CommandType::COMMAND:
     602                 :          0 :                 eState = HANDLE_SQL;
     603                 :          0 :                 break;
     604                 :            :         }
     605                 :            : 
     606                 :            :         // needed in various states:
     607                 :          0 :         Reference< XNameAccess > xObjectCollection;
     608                 :          0 :         Reference< XColumnsSupplier > xSupplyColumns;
     609                 :            : 
     610                 :            :         // go!
     611 [ #  # ][ #  # ]:          0 :         while ( ( DONE != eState ) && ( FAILED != eState ) )
                 [ #  # ]
     612                 :            :         {
     613   [ #  #  #  #  :          0 :             switch ( eState )
                   #  # ]
     614                 :            :             {
     615                 :            :                 case HANDLE_TABLE:
     616                 :            :                 {
     617                 :            :                     // initial state for handling the tables
     618                 :            : 
     619                 :            :                     // get the table objects
     620         [ #  # ]:          0 :                     Reference< XTablesSupplier > xSupplyTables( _rxConnection, UNO_QUERY );
     621         [ #  # ]:          0 :                     if ( xSupplyTables.is() )
     622 [ #  # ][ #  # ]:          0 :                         xObjectCollection = xSupplyTables->getTables();
                 [ #  # ]
     623                 :            :                     // if something went wrong 'til here, then this will be handled in the next state
     624                 :            : 
     625                 :            :                     // next state: get the object
     626                 :          0 :                     eState = RETRIEVE_OBJECT;
     627                 :            :                 }
     628                 :          0 :                 break;
     629                 :            : 
     630                 :            :                 case HANDLE_QUERY:
     631                 :            :                 {
     632                 :            :                     // initial state for handling the tables
     633                 :            : 
     634                 :            :                     // get the table objects
     635         [ #  # ]:          0 :                     Reference< XQueriesSupplier > xSupplyQueries( _rxConnection, UNO_QUERY );
     636         [ #  # ]:          0 :                     if ( xSupplyQueries.is() )
     637 [ #  # ][ #  # ]:          0 :                         xObjectCollection = xSupplyQueries->getQueries();
                 [ #  # ]
     638                 :            :                     // if something went wrong 'til here, then this will be handled in the next state
     639                 :            : 
     640                 :            :                     // next state: get the object
     641                 :          0 :                     eState = RETRIEVE_OBJECT;
     642                 :            :                 }
     643                 :          0 :                 break;
     644                 :            : 
     645                 :            :                 case RETRIEVE_OBJECT:
     646                 :            :                     // here we should have an object (aka query or table) collection, and are going
     647                 :            :                     // to retrieve the desired object
     648                 :            : 
     649                 :            :                     // next state: default to FAILED
     650                 :          0 :                     eState = FAILED;
     651                 :            : 
     652                 :            :                     OSL_ENSURE( xObjectCollection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection (no sdb.Connection, or no Tables-/QueriesSupplier)!");
     653         [ #  # ]:          0 :                     if ( xObjectCollection.is() )
     654                 :            :                     {
     655 [ #  # ][ #  # ]:          0 :                         if ( xObjectCollection.is() && xObjectCollection->hasByName( _rCommand ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     656                 :            :                         {
     657 [ #  # ][ #  # ]:          0 :                             xObjectCollection->getByName( _rCommand ) >>= xSupplyColumns;
                 [ #  # ]
     658                 :            :                                 // (xSupplyColumns being NULL will be handled in the next state)
     659                 :            : 
     660                 :            :                             // next: go for the columns
     661                 :          0 :                             eState = RETRIEVE_COLUMNS;
     662                 :            :                         }
     663                 :            :                     }
     664                 :          0 :                     break;
     665                 :            : 
     666                 :            :                 case RETRIEVE_COLUMNS:
     667                 :            :                     OSL_ENSURE( xSupplyColumns.is(), "::dbtools::getFieldsByCommandDescriptor: could not retrieve the columns supplier!" );
     668                 :            : 
     669                 :            :                     // next state: default to FAILED
     670                 :          0 :                     eState = FAILED;
     671                 :            : 
     672         [ #  # ]:          0 :                     if ( xSupplyColumns.is() )
     673                 :            :                     {
     674 [ #  # ][ #  # ]:          0 :                         xFields = xSupplyColumns->getColumns();
                 [ #  # ]
     675                 :            :                         // that's it
     676                 :          0 :                         eState = DONE;
     677                 :            :                     }
     678                 :          0 :                     break;
     679                 :            : 
     680                 :            :                 case HANDLE_SQL:
     681                 :            :                 {
     682                 :          0 :                     ::rtl::OUString sStatementToExecute( _rCommand );
     683                 :            : 
     684                 :            :                     // well, the main problem here is to handle statements which contain a parameter
     685                 :            :                     // If we would simply execute a parametrized statement, then this will fail because
     686                 :            :                     // we cannot supply any parameter values.
     687                 :            :                     // Thus, we try to analyze the statement, and to append a WHERE 0=1 filter criterion
     688                 :            :                     // This should cause every driver to not really execute the statement, but to return
     689                 :            :                     // an empty result set with the proper structure. We then can use this result set
     690                 :            :                     // to retrieve the columns.
     691                 :            : 
     692                 :            :                     try
     693                 :            :                     {
     694         [ #  # ]:          0 :                         Reference< XMultiServiceFactory > xComposerFac( _rxConnection, UNO_QUERY );
     695                 :            : 
     696         [ #  # ]:          0 :                         if ( xComposerFac.is() )
     697                 :            :                         {
     698 [ #  # ][ #  # ]:          0 :                             Reference< XSingleSelectQueryComposer > xComposer(xComposerFac->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.SingleSelectQueryComposer"))),UNO_QUERY);
         [ #  # ][ #  # ]
     699         [ #  # ]:          0 :                             if ( xComposer.is() )
     700                 :            :                             {
     701 [ #  # ][ #  # ]:          0 :                                 xComposer->setQuery( sStatementToExecute );
     702                 :            : 
     703                 :            :                                 // Now set the filter to a dummy restriction which will result in an empty
     704                 :            :                                 // result set.
     705 [ #  # ][ #  # ]:          0 :                                 xComposer->setFilter( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "0=1" )) );
                 [ #  # ]
     706 [ #  # ][ #  # ]:          0 :                                 sStatementToExecute = xComposer->getQuery( );
     707                 :          0 :                             }
     708         [ #  # ]:          0 :                         }
     709                 :            :                     }
     710         [ #  # ]:          0 :                     catch( const Exception& )
     711                 :            :                     {
     712                 :            :                         // silent this error, this was just a try. If we're here, we did not change sStatementToExecute,
     713                 :            :                         // so it will still be _rCommand, which then will be executed without being touched
     714                 :            :                     }
     715                 :            : 
     716                 :            :                     // now execute
     717 [ #  # ][ #  # ]:          0 :                     Reference< XPreparedStatement > xStatement = _rxConnection->prepareStatement( sStatementToExecute );
     718                 :            :                     // transfer ownership of this temporary object to the caller
     719 [ #  # ][ #  # ]:          0 :                     _rxKeepFieldsAlive = _rxKeepFieldsAlive.query( xStatement );
     720                 :            : 
     721                 :            :                     // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter
     722                 :            :                     // failed - in this case, the MaxRows restriction should at least ensure that there
     723                 :            :                     // is no data returned (which would be potentially expensive)
     724         [ #  # ]:          0 :                     Reference< XPropertySet > xStatementProps( xStatement,UNO_QUERY );
     725                 :            :                     try
     726                 :            :                     {
     727         [ #  # ]:          0 :                         if ( xStatementProps.is() )
     728         [ #  # ]:          0 :                             xStatementProps->setPropertyValue(
     729                 :            :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxRows" ) ),
     730                 :            :                                 makeAny( sal_Int32( 0 ) )
     731 [ #  # ][ #  # ]:          0 :                             );
         [ #  # ][ #  # ]
     732                 :            :                     }
     733         [ #  # ]:          0 :                     catch( const Exception& )
     734                 :            :                     {
     735                 :            :                         OSL_FAIL( "::dbtools::getFieldsByCommandDescriptor: could not set the MaxRows!" );
     736                 :            :                         // oh damn. Not much of a chance to recover, we will no retrieve the complete
     737                 :            :                         // full blown result set
     738                 :            :                     }
     739                 :            : 
     740 [ #  # ][ #  # ]:          0 :                     xSupplyColumns = xSupplyColumns.query( xStatement->executeQuery() );
         [ #  # ][ #  # ]
     741                 :            :                     // this should have given us a result set which does not contain any data, but
     742                 :            :                     // the structural information we need
     743                 :            : 
     744                 :            :                     // so the next state is to get the columns
     745                 :          0 :                     eState = RETRIEVE_COLUMNS;
     746                 :            :                 }
     747                 :          0 :                 break;
     748                 :            : 
     749                 :            :                 default:
     750                 :            :                     OSL_FAIL( "::dbtools::getFieldsByCommandDescriptor: oops! unhandled state here!" );
     751                 :          0 :                     eState = FAILED;
     752                 :            :             }
     753                 :          0 :         }
     754                 :            :     }
     755   [ #  #  #  #  :          0 :     catch( const SQLContext& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
          #  #  #  #  #  
                      # ]
     756   [ #  #  #  #  :          0 :     catch( const SQLWarning& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
          #  #  #  #  #  
                      # ]
     757   [ #  #  #  #  :          0 :     catch( const SQLException& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     758         [ #  # ]:          0 :     catch( const Exception& )
     759                 :            :     {
     760                 :            :         OSL_FAIL( "::dbtools::getFieldsByCommandDescriptor: caught an exception while retrieving the fields!" );
     761                 :            :     }
     762                 :            : 
     763                 :          0 :     return xFields;
     764                 :            : }
     765                 :            : 
     766                 :            : //------------------------------------------------------------------------------
     767                 :          0 : Sequence< ::rtl::OUString > getFieldNamesByCommandDescriptor( const Reference< XConnection >& _rxConnection,
     768                 :            :     const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
     769                 :            :     SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
     770                 :            : {
     771                 :            :     // get the container for the fields
     772                 :          0 :     Reference< XComponent > xKeepFieldsAlive;
     773         [ #  # ]:          0 :     Reference< XNameAccess > xFieldContainer = getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand, xKeepFieldsAlive, _pErrorInfo );
     774                 :            : 
     775                 :            :     // get the names of the fields
     776         [ #  # ]:          0 :     Sequence< ::rtl::OUString > aNames;
     777         [ #  # ]:          0 :     if ( xFieldContainer.is() )
     778 [ #  # ][ #  # ]:          0 :         aNames = xFieldContainer->getElementNames();
         [ #  # ][ #  # ]
     779                 :            : 
     780                 :            :     // clean up any temporary objects which have been created
     781         [ #  # ]:          0 :     disposeComponent( xKeepFieldsAlive );
     782                 :            : 
     783                 :            :     // outta here
     784                 :          0 :     return aNames;
     785                 :            : }
     786                 :            : 
     787                 :            : //------------------------------------------------------------------------------
     788                 :          0 : SQLContext prependContextInfo(const SQLException& _rException, const Reference< XInterface >& _rxContext, const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails)
     789                 :            : {
     790         [ #  # ]:          0 :     return SQLContext( _rContextDescription, _rxContext, ::rtl::OUString(), 0, makeAny( _rException ), _rContextDetails );
     791                 :            : }
     792                 :            : //------------------------------------------------------------------------------
     793                 :          0 : SQLException prependErrorInfo( const SQLException& _rChainedException, const Reference< XInterface >& _rxContext,
     794                 :            :     const ::rtl::OUString& _rAdditionalError, const StandardSQLState _eSQLState, const sal_Int32 _nErrorCode )
     795                 :            : {
     796                 :            :     return SQLException( _rAdditionalError, _rxContext,
     797                 :            :         _eSQLState == SQL_ERROR_UNSPECIFIED ? ::rtl::OUString() : getStandardSQLState( _eSQLState ),
     798 [ #  # ][ #  # ]:          0 :         _nErrorCode, makeAny( _rChainedException ) );
                 [ #  # ]
     799                 :            : }
     800                 :            : 
     801                 :            : //--------------------------------------------------------------------------
     802                 :            : namespace
     803                 :            : {
     804                 :            :     struct NameComponentSupport
     805                 :            :     {
     806                 :            :         const bool  bCatalogs;
     807                 :            :         const bool  bSchemas;
     808                 :            : 
     809                 :            :         NameComponentSupport( )
     810                 :            :             :bCatalogs( true )
     811                 :            :             ,bSchemas( true )
     812                 :            :         {
     813                 :            :         }
     814                 :            : 
     815                 :        892 :         NameComponentSupport( const bool _bCatalogs, const bool _bSchemas )
     816                 :            :             :bCatalogs( _bCatalogs )
     817                 :        892 :             ,bSchemas( _bSchemas )
     818                 :            :         {
     819                 :        892 :         }
     820                 :            :     };
     821                 :            : 
     822                 :        892 :     NameComponentSupport lcl_getNameComponentSupport( const Reference< XDatabaseMetaData >& _rxMetaData, EComposeRule _eComposeRule )
     823                 :            :     {
     824                 :            :         OSL_PRECOND( _rxMetaData.is(), "lcl_getNameComponentSupport: invalid meta data!" );
     825                 :            : 
     826                 :        892 :         FMetaDataSupport pCatalogCall = &XDatabaseMetaData::supportsCatalogsInDataManipulation;
     827                 :        892 :         FMetaDataSupport pSchemaCall = &XDatabaseMetaData::supportsSchemasInDataManipulation;
     828                 :        892 :         bool bIgnoreMetaData = false;
     829                 :            : 
     830   [ -  -  -  -  :        892 :         switch ( _eComposeRule )
                -  +  - ]
     831                 :            :         {
     832                 :            :             case eInTableDefinitions:
     833                 :          0 :                 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInTableDefinitions;
     834                 :          0 :                 pSchemaCall = &XDatabaseMetaData::supportsSchemasInTableDefinitions;
     835                 :          0 :                 break;
     836                 :            :             case eInIndexDefinitions:
     837                 :          0 :                 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInIndexDefinitions;
     838                 :          0 :                 pSchemaCall = &XDatabaseMetaData::supportsSchemasInIndexDefinitions;
     839                 :          0 :                 break;
     840                 :            :             case eInProcedureCalls:
     841                 :          0 :                 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInProcedureCalls;
     842                 :          0 :                 pSchemaCall = &XDatabaseMetaData::supportsSchemasInProcedureCalls;
     843                 :          0 :                 break;
     844                 :            :             case eInPrivilegeDefinitions:
     845                 :          0 :                 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions;
     846                 :          0 :                 pSchemaCall = &XDatabaseMetaData::supportsSchemasInPrivilegeDefinitions;
     847                 :          0 :                 break;
     848                 :            :             case eComplete:
     849                 :          0 :                 bIgnoreMetaData = true;
     850                 :          0 :                 break;
     851                 :            :             case eInDataManipulation:
     852                 :            :                 // already properly set above
     853                 :        892 :                 break;
     854                 :            :         }
     855                 :            :         return NameComponentSupport(
     856 [ +  - ][ -  + ]:        892 :             bIgnoreMetaData ? true : (_rxMetaData.get()->*pCatalogCall)(),
                 [ +  - ]
     857 [ +  - ][ -  + ]:        892 :             bIgnoreMetaData ? true : (_rxMetaData.get()->*pSchemaCall)()
                 [ +  - ]
     858 [ -  + ][ -  + ]:       2676 :         );
     859                 :            :     }
     860                 :            : }
     861                 :            : 
     862                 :            : //--------------------------------------------------------------------------
     863                 :        458 : static ::rtl::OUString impl_doComposeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
     864                 :            :                 const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName,
     865                 :            :                 sal_Bool _bQuote, EComposeRule _eComposeRule )
     866                 :            : {
     867                 :            :     OSL_ENSURE(_rxMetaData.is(), "impl_doComposeTableName : invalid meta data !");
     868         [ -  + ]:        458 :     if ( !_rxMetaData.is() )
     869                 :          0 :         return ::rtl::OUString();
     870                 :            :     OSL_ENSURE(!_rName.isEmpty(), "impl_doComposeTableName : at least the name should be non-empty !");
     871                 :            : 
     872 [ +  - ][ +  - ]:        458 :     const ::rtl::OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
     873         [ +  - ]:        458 :     const NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
     874                 :            : 
     875                 :        458 :     ::rtl::OUStringBuffer aComposedName;
     876                 :            : 
     877                 :        458 :     ::rtl::OUString sCatalogSep;
     878                 :        458 :     sal_Bool bCatlogAtStart = sal_True;
     879 [ #  # ][ -  + ]:        458 :     if ( !_rCatalog.isEmpty() && aNameComps.bCatalogs )
                 [ -  + ]
     880                 :            :     {
     881 [ #  # ][ #  # ]:          0 :         sCatalogSep     = _rxMetaData->getCatalogSeparator();
     882 [ #  # ][ #  # ]:          0 :         bCatlogAtStart  = _rxMetaData->isCatalogAtStart();
     883                 :            : 
     884 [ #  # ][ #  # ]:          0 :         if ( bCatlogAtStart && !sCatalogSep.isEmpty())
                 [ #  # ]
     885                 :            :         {
     886 [ #  # ][ #  # ]:          0 :             aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog );
                 [ #  # ]
     887         [ #  # ]:          0 :             aComposedName.append( sCatalogSep );
     888                 :            :         }
     889                 :            :     }
     890                 :            : 
     891 [ -  + ][ #  # ]:        458 :     if ( !_rSchema.isEmpty() && aNameComps.bSchemas )
                 [ -  + ]
     892                 :            :     {
     893 [ #  # ][ #  # ]:          0 :         aComposedName.append( _bQuote ? quoteName( sQuoteString, _rSchema ) : _rSchema );
                 [ #  # ]
     894         [ #  # ]:          0 :         aComposedName.appendAscii( "." );
     895                 :            :     }
     896                 :            : 
     897 [ +  + ][ +  - ]:        458 :     aComposedName.append( _bQuote ? quoteName( sQuoteString, _rName ) : _rName );
                 [ +  - ]
     898                 :            : 
     899   [ #  #  #  # ]:        458 :     if  (   !_rCatalog.isEmpty()
         [ #  # ][ -  + ]
                 [ -  + ]
     900                 :            :         &&  !bCatlogAtStart
     901                 :          0 :         &&  !sCatalogSep.isEmpty()
     902                 :            :         &&  aNameComps.bCatalogs
     903                 :            :         )
     904                 :            :     {
     905         [ #  # ]:          0 :         aComposedName.append( sCatalogSep );
     906 [ #  # ][ #  # ]:          0 :         aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog );
                 [ #  # ]
     907                 :            :     }
     908                 :            : 
     909         [ +  - ]:        458 :     return aComposedName.makeStringAndClear();
     910                 :            : }
     911                 :            : 
     912                 :            : //------------------------------------------------------------------------------
     913                 :          0 : ::rtl::OUString quoteTableName(const Reference< XDatabaseMetaData>& _rxMeta
     914                 :            :                                , const ::rtl::OUString& _rName
     915                 :            :                                , EComposeRule _eComposeRule)
     916                 :            : {
     917                 :          0 :     ::rtl::OUString sCatalog, sSchema, sTable;
     918         [ #  # ]:          0 :     qualifiedNameComponents(_rxMeta,_rName,sCatalog,sSchema,sTable,_eComposeRule);
     919         [ #  # ]:          0 :     return impl_doComposeTableName( _rxMeta, sCatalog, sSchema, sTable, sal_True, _eComposeRule );
     920                 :            : }
     921                 :            : 
     922                 :            : //------------------------------------------------------------------------------
     923                 :        434 : void qualifiedNameComponents(const Reference< XDatabaseMetaData >& _rxConnMetaData, const ::rtl::OUString& _rQualifiedName, ::rtl::OUString& _rCatalog, ::rtl::OUString& _rSchema, ::rtl::OUString& _rName,EComposeRule _eComposeRule)
     924                 :            : {
     925                 :            :     OSL_ENSURE(_rxConnMetaData.is(), "QualifiedNameComponents : invalid meta data!");
     926                 :            : 
     927         [ +  - ]:        434 :     NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxConnMetaData, _eComposeRule ) );
     928                 :            : 
     929 [ +  - ][ +  - ]:        434 :     ::rtl::OUString sSeparator = _rxConnMetaData->getCatalogSeparator();
     930                 :            : 
     931                 :        434 :     ::rtl::OUString sName(_rQualifiedName);
     932                 :            :     // do we have catalogs ?
     933         [ -  + ]:        434 :     if ( aNameComps.bCatalogs )
     934                 :            :     {
     935 [ #  # ][ #  # ]:          0 :         if (_rxConnMetaData->isCatalogAtStart())
                 [ #  # ]
     936                 :            :         {
     937                 :            :             // search for the catalog name at the beginning
     938                 :          0 :             sal_Int32 nIndex = sName.indexOf(sSeparator);
     939         [ #  # ]:          0 :             if (-1 != nIndex)
     940                 :            :             {
     941                 :          0 :                 _rCatalog = sName.copy(0, nIndex);
     942                 :          0 :                 sName = sName.copy(nIndex + 1);
     943                 :            :             }
     944                 :            :         }
     945                 :            :         else
     946                 :            :         {
     947                 :            :             // Catalogue name at the end
     948                 :          0 :             sal_Int32 nIndex = sName.lastIndexOf(sSeparator);
     949         [ #  # ]:          0 :             if (-1 != nIndex)
     950                 :            :             {
     951                 :          0 :                 _rCatalog = sName.copy(nIndex + 1);
     952                 :          0 :                 sName = sName.copy(0, nIndex);
     953                 :            :             }
     954                 :            :         }
     955                 :            :     }
     956                 :            : 
     957         [ -  + ]:        434 :     if ( aNameComps.bSchemas )
     958                 :            :     {
     959                 :          0 :         sal_Int32 nIndex = sName.indexOf((sal_Unicode)'.');
     960                 :            :         //  OSL_ENSURE(-1 != nIndex, "QualifiedNameComponents : no schema separator!");
     961         [ #  # ]:          0 :         if ( nIndex != -1 )
     962                 :          0 :             _rSchema = sName.copy(0, nIndex);
     963                 :          0 :         sName = sName.copy(nIndex + 1);
     964                 :            :     }
     965                 :            : 
     966                 :        434 :     _rName = sName;
     967                 :        434 : }
     968                 :            : 
     969                 :            : //------------------------------------------------------------------------------
     970                 :        192 : Reference< XNumberFormatsSupplier> getNumberFormats(
     971                 :            :             const Reference< XConnection>& _rxConn,
     972                 :            :             sal_Bool _bAlloweDefault,
     973                 :            :             const Reference< XMultiServiceFactory>& _rxFactory)
     974                 :            : {
     975                 :            :     // ask the parent of the connection (should be an DatabaseAccess)
     976                 :        192 :     Reference< XNumberFormatsSupplier> xReturn;
     977         [ +  - ]:        192 :     Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY);
     978         [ +  - ]:        192 :     ::rtl::OUString sPropFormatsSupplier( RTL_CONSTASCII_USTRINGPARAM( "NumberFormatsSupplier" ));
     979         [ +  + ]:        192 :     if (xConnAsChild.is())
     980                 :            :     {
     981 [ +  - ][ +  - ]:        190 :         Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY);
                 [ +  - ]
     982 [ +  - ][ +  - ]:        190 :         if (xConnParentProps.is() && hasProperty(sPropFormatsSupplier, xConnParentProps))
         [ +  - ][ +  - ]
     983 [ +  - ][ +  - ]:        190 :             xConnParentProps->getPropertyValue(sPropFormatsSupplier) >>= xReturn;
                 [ +  - ]
     984                 :            :     }
     985 [ +  - ][ +  - ]:          2 :     else if(_bAlloweDefault && _rxFactory.is())
                 [ +  - ]
     986                 :            :     {
     987 [ +  - ][ +  - ]:          2 :         xReturn = Reference< XNumberFormatsSupplier>(_rxFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatsSupplier"))),UNO_QUERY);
         [ +  - ][ +  - ]
                 [ +  - ]
     988                 :            :     }
     989                 :        192 :     return xReturn;
     990                 :            : }
     991                 :            : 
     992                 :            : //==============================================================================
     993                 :            : //------------------------------------------------------------------------------
     994                 :          0 : void TransferFormComponentProperties(
     995                 :            :             const Reference< XPropertySet>& xOldProps,
     996                 :            :             const Reference< XPropertySet>& xNewProps,
     997                 :            :             const Locale& _rLocale)
     998                 :            : {
     999                 :            : try
    1000                 :            : {
    1001                 :            :     OSL_ENSURE( xOldProps.is() && xNewProps.is(), "TransferFormComponentProperties: invalid source/dest!" );
    1002 [ #  # ][ #  # ]:          0 :     if ( !xOldProps.is() || !xNewProps.is() )
                 [ #  # ]
    1003                 :            :         return;
    1004                 :            : 
    1005                 :            :     // First we copy all the Props, that are available in source and target and have the same description
    1006 [ #  # ][ #  # ]:          0 :     Reference< XPropertySetInfo> xOldInfo( xOldProps->getPropertySetInfo());
    1007 [ #  # ][ #  # ]:          0 :     Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo());
    1008                 :            : 
    1009 [ #  # ][ #  # ]:          0 :     Sequence< Property> aOldProperties = xOldInfo->getProperties();
    1010 [ #  # ][ #  # ]:          0 :     Sequence< Property> aNewProperties = xNewInfo->getProperties();
    1011                 :          0 :     int nNewLen = aNewProperties.getLength();
    1012                 :            : 
    1013         [ #  # ]:          0 :     Property* pOldProps = aOldProperties.getArray();
    1014         [ #  # ]:          0 :     Property* pNewProps = aNewProperties.getArray();
    1015                 :            : 
    1016         [ #  # ]:          0 :     ::rtl::OUString sPropDefaultControl(RTL_CONSTASCII_USTRINGPARAM("DefaultControl"));
    1017         [ #  # ]:          0 :     ::rtl::OUString sPropLabelControl(RTL_CONSTASCII_USTRINGPARAM("LabelControl"));
    1018         [ #  # ]:          0 :     ::rtl::OUString sPropFormatsSupplier(RTL_CONSTASCII_USTRINGPARAM("FormatsSupplier"));
    1019         [ #  # ]:          0 :     ::rtl::OUString sPropCurrencySymbol(RTL_CONSTASCII_USTRINGPARAM("CurrencySymbol"));
    1020         [ #  # ]:          0 :     ::rtl::OUString sPropDecimals(RTL_CONSTASCII_USTRINGPARAM("Decimals"));
    1021         [ #  # ]:          0 :     ::rtl::OUString sPropEffectiveMin(RTL_CONSTASCII_USTRINGPARAM("EffectiveMin"));
    1022         [ #  # ]:          0 :     ::rtl::OUString sPropEffectiveMax(RTL_CONSTASCII_USTRINGPARAM("EffectiveMax"));
    1023         [ #  # ]:          0 :     ::rtl::OUString sPropEffectiveDefault(RTL_CONSTASCII_USTRINGPARAM("EffectiveDefault"));
    1024         [ #  # ]:          0 :     ::rtl::OUString sPropDefaultText(RTL_CONSTASCII_USTRINGPARAM("DefaultText"));
    1025         [ #  # ]:          0 :     ::rtl::OUString sPropDefaultDate(RTL_CONSTASCII_USTRINGPARAM("DefaultDate"));
    1026         [ #  # ]:          0 :     ::rtl::OUString sPropDefaultTime(RTL_CONSTASCII_USTRINGPARAM("DefaultTime"));
    1027         [ #  # ]:          0 :     ::rtl::OUString sPropValueMin(RTL_CONSTASCII_USTRINGPARAM("ValueMin"));
    1028         [ #  # ]:          0 :     ::rtl::OUString sPropValueMax(RTL_CONSTASCII_USTRINGPARAM("ValueMax"));
    1029         [ #  # ]:          0 :     ::rtl::OUString sPropDecimalAccuracy(RTL_CONSTASCII_USTRINGPARAM("DecimalAccuracy"));
    1030         [ #  # ]:          0 :     ::rtl::OUString sPropClassId(RTL_CONSTASCII_USTRINGPARAM("ClassId"));
    1031         [ #  # ]:          0 :     ::rtl::OUString sFormattedServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.FormattedField" ) );
    1032                 :            : 
    1033         [ #  # ]:          0 :     for (sal_Int16 i=0; i<aOldProperties.getLength(); ++i)
    1034                 :            :     {
    1035   [ #  #  #  # ]:          0 :         if  (   (!pOldProps[i].Name.equals(sPropDefaultControl))
                 [ #  # ]
    1036                 :          0 :             &&  (!pOldProps[i].Name.equals(sPropLabelControl))
    1037                 :            :             )
    1038                 :            :         {
    1039                 :            :             // binary search
    1040                 :            :             Property* pResult = ::std::lower_bound(
    1041         [ #  # ]:          0 :                 pNewProps, pNewProps + nNewLen, pOldProps[i], ::comphelper::PropertyCompareByName());
    1042                 :            : 
    1043         [ #  # ]:          0 :             if (    pResult
           [ #  #  #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1044                 :          0 :                 && ( pResult != pNewProps + nNewLen && pResult->Name == pOldProps[i].Name )
    1045                 :            :                 && ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 )
    1046                 :          0 :                 && ( pResult->Type.equals(pOldProps[i].Type)) )
    1047                 :            :             {   // Attributes match and the property is not read-only
    1048                 :            :                 try
    1049                 :            :                 {
    1050 [ #  # ][ #  # ]:          0 :                     xNewProps->setPropertyValue(pResult->Name, xOldProps->getPropertyValue(pResult->Name));
         [ #  # ][ #  # ]
                 [ #  # ]
    1051                 :            :                 }
    1052         [ #  # ]:          0 :                 catch(IllegalArgumentException& e)
    1053                 :            :                 {
    1054                 :            :                     OSL_UNUSED( e );
    1055                 :            : #ifdef DBG_UTIL
    1056                 :            :                     ::rtl::OUString sMessage(RTL_CONSTASCII_USTRINGPARAM("TransferFormComponentProperties : could not transfer the value for property \""));
    1057                 :            :                     sMessage += pResult->Name;
    1058                 :            :                     sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
    1059                 :            :                     OSL_FAIL(::rtl::OUStringToOString(sMessage, RTL_TEXTENCODING_ASCII_US).getStr());
    1060                 :            : #endif
    1061                 :            :                 }
    1062                 :            :             }
    1063                 :            :         }
    1064                 :            :     }
    1065                 :            : 
    1066                 :            :     // for formatted fields (either old or new) we have some special treatments
    1067         [ #  # ]:          0 :     Reference< XServiceInfo > xSI( xOldProps, UNO_QUERY );
    1068 [ #  # ][ #  # ]:          0 :     sal_Bool bOldIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
         [ #  # ][ #  # ]
    1069 [ #  # ][ #  # ]:          0 :     xSI = Reference< XServiceInfo >( xNewProps, UNO_QUERY );
    1070 [ #  # ][ #  # ]:          0 :     sal_Bool bNewIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
         [ #  # ][ #  # ]
    1071                 :            : 
    1072 [ #  # ][ #  # ]:          0 :     if (!bOldIsFormatted && !bNewIsFormatted)
    1073                 :            :         return; // nothing to do
    1074                 :            : 
    1075 [ #  # ][ #  # ]:          0 :     if (bOldIsFormatted && bNewIsFormatted)
    1076                 :            :         // if both fields are formatted we do no conversions
    1077                 :            :         return;
    1078                 :            : 
    1079         [ #  # ]:          0 :     if (bOldIsFormatted)
    1080                 :            :     {
    1081                 :            :         // get some properties from the selected format and put them in the new Set
    1082 [ #  # ][ #  # ]:          0 :         Any aFormatKey( xOldProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY)) );
         [ #  # ][ #  # ]
    1083         [ #  # ]:          0 :         if (aFormatKey.hasValue())
    1084                 :            :         {
    1085                 :          0 :             Reference< XNumberFormatsSupplier> xSupplier;
    1086 [ #  # ][ #  # ]:          0 :             xOldProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
                 [ #  # ]
    1087         [ #  # ]:          0 :             if (xSupplier.is())
    1088                 :            :             {
    1089 [ #  # ][ #  # ]:          0 :                 Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
    1090 [ #  # ][ #  # ]:          0 :                 Reference< XPropertySet> xFormat(xFormats->getByKey(getINT32(aFormatKey)));
                 [ #  # ]
    1091 [ #  # ][ #  # ]:          0 :                 if (hasProperty(sPropCurrencySymbol, xFormat))
    1092                 :            :                 {
    1093 [ #  # ][ #  # ]:          0 :                     Any aVal( xFormat->getPropertyValue(sPropCurrencySymbol) );
    1094 [ #  # ][ #  # ]:          0 :                     if (aVal.hasValue() && hasProperty(sPropCurrencySymbol, xNewProps))
         [ #  # ][ #  # ]
    1095                 :            :                         // If the source value hasn't been set then don't copy it, so we don´t overwrite the default value
    1096 [ #  # ][ #  # ]:          0 :                         xNewProps->setPropertyValue(sPropCurrencySymbol, aVal);
    1097                 :            :                 }
    1098 [ #  # ][ #  # ]:          0 :                 if (hasProperty(sPropDecimals, xFormat) && hasProperty(sPropDecimals, xNewProps))
         [ #  # ][ #  # ]
                 [ #  # ]
    1099 [ #  # ][ #  # ]:          0 :                     xNewProps->setPropertyValue(sPropDecimals, xFormat->getPropertyValue(sPropDecimals));
         [ #  # ][ #  # ]
    1100                 :          0 :             }
    1101                 :            :         }
    1102                 :            : 
    1103                 :            :         // a potential Min-Max-Conversion
    1104 [ #  # ][ #  # ]:          0 :         Any aEffectiveMin( xOldProps->getPropertyValue(sPropEffectiveMin) );
    1105         [ #  # ]:          0 :         if (aEffectiveMin.hasValue())
    1106                 :            :         {   // Unlike the ValueMin the EffectiveMin can be void
    1107 [ #  # ][ #  # ]:          0 :             if (hasProperty(sPropValueMin, xNewProps))
    1108                 :            :             {
    1109                 :            :                 OSL_ENSURE(aEffectiveMin.getValueType().getTypeClass() == TypeClass_DOUBLE,
    1110                 :            :                     "TransferFormComponentProperties : invalid property type !");
    1111 [ #  # ][ #  # ]:          0 :                 xNewProps->setPropertyValue(sPropValueMin, aEffectiveMin);
    1112                 :            :             }
    1113                 :            :         }
    1114 [ #  # ][ #  # ]:          0 :         Any aEffectiveMax( xOldProps->getPropertyValue(sPropEffectiveMax) );
    1115         [ #  # ]:          0 :         if (aEffectiveMax.hasValue())
    1116                 :            :         {   // analog
    1117 [ #  # ][ #  # ]:          0 :             if (hasProperty(sPropValueMax, xNewProps))
    1118                 :            :             {
    1119                 :            :                 OSL_ENSURE(aEffectiveMax.getValueType().getTypeClass() == TypeClass_DOUBLE,
    1120                 :            :                     "TransferFormComponentProperties : invalid property type !");
    1121 [ #  # ][ #  # ]:          0 :                 xNewProps->setPropertyValue(sPropValueMax, aEffectiveMax);
    1122                 :            :             }
    1123                 :            :         }
    1124                 :            : 
    1125                 :            :         // then we can still convert and copy the default values
    1126 [ #  # ][ #  # ]:          0 :         Any aEffectiveDefault( xOldProps->getPropertyValue(sPropEffectiveDefault) );
    1127         [ #  # ]:          0 :         if (aEffectiveDefault.hasValue())
    1128                 :            :         {
    1129                 :          0 :             sal_Bool bIsString = aEffectiveDefault.getValueType().getTypeClass() == TypeClass_STRING;
    1130                 :            :             OSL_ENSURE(bIsString || aEffectiveDefault.getValueType().getTypeClass() == TypeClass_DOUBLE,
    1131                 :            :                 "TransferFormComponentProperties : invalid property type !");
    1132                 :            :                 // The Effective-Properties should always be void or string or double ....
    1133                 :            : 
    1134 [ #  # ][ #  # ]:          0 :             if (hasProperty(sPropDefaultDate, xNewProps) && !bIsString)
         [ #  # ][ #  # ]
    1135                 :            :             {   // (to convert a ::rtl::OUString into a date will not always succeed, because it might be bound to a text-column,
    1136                 :            :                 // but we can work with a double)
    1137 [ #  # ][ #  # ]:          0 :                 Date aDate = DBTypeConversion::toDate(getDouble(aEffectiveDefault));
                 [ #  # ]
    1138 [ #  # ][ #  # ]:          0 :                 xNewProps->setPropertyValue(sPropDefaultDate, makeAny(aDate));
                 [ #  # ]
    1139                 :            :             }
    1140                 :            : 
    1141 [ #  # ][ #  # ]:          0 :             if (hasProperty(sPropDefaultTime, xNewProps) && !bIsString)
         [ #  # ][ #  # ]
    1142                 :            :             {   // Completely analogous to time
    1143 [ #  # ][ #  # ]:          0 :                 Time aTime = DBTypeConversion::toTime(getDouble(aEffectiveDefault));
    1144 [ #  # ][ #  # ]:          0 :                 xNewProps->setPropertyValue(sPropDefaultTime, makeAny(aTime));
                 [ #  # ]
    1145                 :            :             }
    1146                 :            : 
    1147 [ #  # ][ #  # ]:          0 :             if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), xNewProps) && !bIsString)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1148                 :            :             {   // Here we can simply pass the double
    1149 [ #  # ][ #  # ]:          0 :                 xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), aEffectiveDefault);
         [ #  # ][ #  # ]
    1150                 :            :             }
    1151                 :            : 
    1152 [ #  # ][ #  # ]:          0 :             if (hasProperty(sPropDefaultText, xNewProps) && bIsString)
         [ #  # ][ #  # ]
    1153                 :            :             {   // and here the ::rtl::OUString
    1154 [ #  # ][ #  # ]:          0 :                 xNewProps->setPropertyValue(sPropDefaultText, aEffectiveDefault);
    1155                 :            :             }
    1156                 :            : 
    1157                 :            :             // nyi: The translation between doubles and ::rtl::OUString would offer more alternatives
    1158                 :          0 :         }
    1159                 :            :     }
    1160                 :            : 
    1161                 :            :     // The other direction: the new Control shall be formatted
    1162         [ #  # ]:          0 :     if (bNewIsFormatted)
    1163                 :            :     {
    1164                 :            :         // first the formatting
    1165                 :            :         // we can't set a Supplier, so the new Set must bring one in
    1166                 :          0 :         Reference< XNumberFormatsSupplier> xSupplier;
    1167 [ #  # ][ #  # ]:          0 :         xNewProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
                 [ #  # ]
    1168         [ #  # ]:          0 :         if (xSupplier.is())
    1169                 :            :         {
    1170 [ #  # ][ #  # ]:          0 :             Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
    1171                 :            : 
    1172                 :            :             // Set number of decimals
    1173                 :          0 :             sal_Int16 nDecimals = 2;
    1174 [ #  # ][ #  # ]:          0 :             if (hasProperty(sPropDecimalAccuracy, xOldProps))
    1175 [ #  # ][ #  # ]:          0 :                 xOldProps->getPropertyValue(sPropDecimalAccuracy) >>= nDecimals;
    1176                 :            : 
    1177                 :            :             // base format (depending on the ClassId of the old Set)
    1178                 :          0 :             sal_Int32 nBaseKey = 0;
    1179 [ #  # ][ #  # ]:          0 :             if (hasProperty(sPropClassId, xOldProps))
    1180                 :            :             {
    1181         [ #  # ]:          0 :                 Reference< XNumberFormatTypes> xTypeList(xFormats, UNO_QUERY);
    1182         [ #  # ]:          0 :                 if (xTypeList.is())
    1183                 :            :                 {
    1184                 :          0 :                     sal_Int16 nClassId = 0;
    1185 [ #  # ][ #  # ]:          0 :                     xOldProps->getPropertyValue(sPropClassId) >>= nClassId;
    1186   [ #  #  #  # ]:          0 :                     switch (nClassId)
    1187                 :            :                     {
    1188                 :            :                         case FormComponentType::DATEFIELD :
    1189 [ #  # ][ #  # ]:          0 :                             nBaseKey = xTypeList->getStandardFormat(NumberFormat::DATE, _rLocale);
    1190                 :          0 :                             break;
    1191                 :            : 
    1192                 :            :                         case FormComponentType::TIMEFIELD :
    1193 [ #  # ][ #  # ]:          0 :                             nBaseKey = xTypeList->getStandardFormat(NumberFormat::TIME, _rLocale);
    1194                 :          0 :                             break;
    1195                 :            : 
    1196                 :            :                         case FormComponentType::CURRENCYFIELD :
    1197 [ #  # ][ #  # ]:          0 :                             nBaseKey = xTypeList->getStandardFormat(NumberFormat::CURRENCY, _rLocale);
    1198                 :          0 :                             break;
    1199                 :            :                     }
    1200                 :          0 :                 }
    1201                 :            :             }
    1202                 :            : 
    1203                 :            :             // With this we can generate a new format ...
    1204 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sNewFormat = xFormats->generateFormat(nBaseKey, _rLocale, sal_False, sal_False, nDecimals, 0);
    1205                 :            :             // No thousands separator, negative numbers are not in red, no leading zeros
    1206                 :            : 
    1207                 :            :             // ... and add at FormatsSupplier (if needed)
    1208 [ #  # ][ #  # ]:          0 :             sal_Int32 nKey = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
    1209         [ #  # ]:          0 :             if (nKey == (sal_Int32)-1)
    1210                 :            :             {   // not added yet in my formatter ...
    1211 [ #  # ][ #  # ]:          0 :                 nKey = xFormats->addNew(sNewFormat, _rLocale);
    1212                 :            :             }
    1213                 :            : 
    1214 [ #  # ][ #  # ]:          0 :             xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY), makeAny((sal_Int32)nKey));
         [ #  # ][ #  # ]
                 [ #  # ]
    1215                 :            :         }
    1216                 :            : 
    1217                 :            :         // min-/max-Value
    1218                 :          0 :         Any aNewMin, aNewMax;
    1219 [ #  # ][ #  # ]:          0 :         if (hasProperty(sPropValueMin, xOldProps))
    1220 [ #  # ][ #  # ]:          0 :             aNewMin = xOldProps->getPropertyValue(sPropValueMin);
    1221 [ #  # ][ #  # ]:          0 :         if (hasProperty(sPropValueMax, xOldProps))
    1222 [ #  # ][ #  # ]:          0 :             aNewMax = xOldProps->getPropertyValue(sPropValueMax);
    1223 [ #  # ][ #  # ]:          0 :         xNewProps->setPropertyValue(sPropEffectiveMin, aNewMin);
    1224 [ #  # ][ #  # ]:          0 :         xNewProps->setPropertyValue(sPropEffectiveMax, aNewMax);
    1225                 :            : 
    1226                 :            :         // Default-Value
    1227                 :          0 :         Any aNewDefault;
    1228 [ #  # ][ #  # ]:          0 :         if (hasProperty(sPropDefaultDate, xOldProps))
    1229                 :            :         {
    1230 [ #  # ][ #  # ]:          0 :             Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) );
    1231         [ #  # ]:          0 :             if (aDate.hasValue())
    1232 [ #  # ][ #  # ]:          0 :                 aNewDefault <<= DBTypeConversion::toDouble(*(Date*)aDate.getValue());
                 [ #  # ]
    1233                 :            :         }
    1234                 :            : 
    1235 [ #  # ][ #  # ]:          0 :         if (hasProperty(sPropDefaultTime, xOldProps))
    1236                 :            :         {
    1237 [ #  # ][ #  # ]:          0 :             Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) );
    1238         [ #  # ]:          0 :             if (aTime.hasValue())
    1239 [ #  # ][ #  # ]:          0 :                 aNewDefault <<= DBTypeConversion::toDouble(*(Time*)aTime.getValue());
    1240                 :            :         }
    1241                 :            : 
    1242                 :            :         // double or ::rtl::OUString will be copied directly
    1243 [ #  # ][ #  # ]:          0 :         if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), xOldProps))
         [ #  # ][ #  # ]
    1244 [ #  # ][ #  # ]:          0 :             aNewDefault = xOldProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE));
         [ #  # ][ #  # ]
    1245 [ #  # ][ #  # ]:          0 :         if (hasProperty(sPropDefaultText, xOldProps))
    1246 [ #  # ][ #  # ]:          0 :             aNewDefault = xOldProps->getPropertyValue(sPropDefaultText);
    1247                 :            : 
    1248         [ #  # ]:          0 :         if (aNewDefault.hasValue())
    1249 [ #  # ][ #  # ]:          0 :             xNewProps->setPropertyValue(sPropEffectiveDefault, aNewDefault);
    1250 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1251                 :            : }
    1252                 :          0 : catch(const Exception&)
    1253                 :            : {
    1254                 :            :     OSL_FAIL( "TransferFormComponentProperties: caught an exception!" );
    1255                 :            : }
    1256                 :            : }
    1257                 :            : 
    1258                 :            : //------------------------------------------------------------------------------
    1259                 :          0 : sal_Bool canInsert(const Reference< XPropertySet>& _rxCursorSet)
    1260                 :            : {
    1261 [ #  # ][ #  # ]:          0 :     return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Privileges")))) & Privilege::INSERT) != 0));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1262                 :            : }
    1263                 :            : 
    1264                 :            : //------------------------------------------------------------------------------
    1265                 :          0 : sal_Bool canUpdate(const Reference< XPropertySet>& _rxCursorSet)
    1266                 :            : {
    1267 [ #  # ][ #  # ]:          0 :     return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Privileges")))) & Privilege::UPDATE) != 0));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1268                 :            : }
    1269                 :            : 
    1270                 :            : //------------------------------------------------------------------------------
    1271                 :          0 : sal_Bool canDelete(const Reference< XPropertySet>& _rxCursorSet)
    1272                 :            : {
    1273 [ #  # ][ #  # ]:          0 :     return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Privileges")))) & Privilege::DELETE) != 0));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1274                 :            : }
    1275                 :            : // -----------------------------------------------------------------------------
    1276                 :       1928 : Reference< XDataSource> findDataSource(const Reference< XInterface >& _xParent)
    1277                 :            : {
    1278         [ +  - ]:       1928 :     Reference< XOfficeDatabaseDocument> xDatabaseDocument(_xParent, UNO_QUERY);
    1279                 :       1928 :     Reference< XDataSource> xDataSource;
    1280         [ +  + ]:       1928 :     if ( xDatabaseDocument.is() )
    1281 [ +  - ][ +  - ]:        348 :         xDataSource = xDatabaseDocument->getDataSource();
                 [ +  - ]
    1282         [ +  + ]:       1928 :     if ( !xDataSource.is() )
    1283         [ +  - ]:       1580 :         xDataSource.set(_xParent, UNO_QUERY);
    1284         [ +  + ]:       1928 :     if (!xDataSource.is())
    1285                 :            :     {
    1286         [ +  - ]:        100 :         Reference< XChild> xChild(_xParent, UNO_QUERY);
    1287         [ +  - ]:        100 :         if ( xChild.is() )
    1288 [ +  - ][ +  - ]:        100 :             xDataSource = findDataSource(xChild->getParent());
         [ +  - ][ +  - ]
    1289                 :            :     }
    1290                 :       1928 :     return xDataSource;
    1291                 :            : }
    1292                 :            : 
    1293                 :            : //------------------------------------------------------------------------------
    1294                 :         32 : Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory )
    1295                 :            :     SAL_THROW( ( SQLException ) )
    1296                 :            : {
    1297                 :         32 :     Reference< XSingleSelectQueryComposer > xComposer;
    1298                 :            :     try
    1299                 :            :     {
    1300 [ +  - ][ +  - ]:         32 :         Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxFactory, sal_True );
    1301         [ +  - ]:         32 :         if ( xConn.is() )       // implies _rxRowSet.is()
    1302                 :            :         {
    1303                 :            :             // build the statement the row set is based on (can't use the ActiveCommand property of the set
    1304                 :            :             // as this reflects the status after the last execute, not the currently set properties)
    1305                 :            : 
    1306                 :         32 :             sal_Int32 nCommandType = CommandType::COMMAND;
    1307                 :         32 :             ::rtl::OUString sCommand;
    1308                 :         32 :             sal_Bool bEscapeProcessing = sal_False;
    1309                 :            : 
    1310 [ +  - ][ +  - ]:         32 :             OSL_VERIFY( _rxRowSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CommandType" ))      ) >>= nCommandType      );
                 [ +  - ]
    1311 [ +  - ][ +  - ]:         32 :             OSL_VERIFY( _rxRowSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Command" ))          ) >>= sCommand          );
                 [ +  - ]
    1312 [ +  - ][ +  - ]:         32 :             OSL_VERIFY( _rxRowSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "EscapeProcessing" )) ) >>= bEscapeProcessing );
                 [ +  - ]
    1313                 :            : 
    1314         [ +  - ]:         32 :             StatementComposer aComposer( xConn, sCommand, nCommandType, bEscapeProcessing );
    1315                 :            :             // append sort
    1316 [ +  - ][ +  - ]:         32 :             aComposer.setOrder( getString( _rxRowSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Order" )) ) ) );
         [ +  - ][ +  - ]
                 [ +  - ]
    1317                 :            : 
    1318                 :            :             // append filter
    1319                 :         32 :             sal_Bool bApplyFilter = sal_True;
    1320 [ +  - ][ +  - ]:         32 :             _rxRowSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ApplyFilter" )) ) >>= bApplyFilter;
                 [ +  - ]
    1321         [ +  + ]:         32 :             if ( bApplyFilter )
    1322 [ +  - ][ +  - ]:         22 :                 aComposer.setFilter( getString( _rxRowSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Filter" )) ) ) );
         [ +  - ][ +  - ]
                 [ +  - ]
    1323                 :            : 
    1324         [ +  - ]:         32 :             aComposer.getQuery();
    1325                 :            : 
    1326 [ +  - ][ +  - ]:         32 :             xComposer = aComposer.getComposer();
    1327 [ +  - ][ +  - ]:         32 :             aComposer.setDisposeComposer( false );
    1328                 :         32 :         }
    1329                 :            :     }
    1330      [ #  #  # ]:          0 :     catch( const SQLException& )
    1331                 :            :     {
    1332                 :          0 :         throw;
    1333                 :            :     }
    1334         [ #  # ]:          0 :     catch( const Exception& )
    1335                 :            :     {
    1336                 :            :         DBG_UNHANDLED_EXCEPTION();
    1337                 :            :     }
    1338                 :            : 
    1339                 :         32 :     return xComposer;
    1340                 :            : }
    1341                 :            : 
    1342                 :            : //------------------------------------------------------------------------------
    1343                 :         32 : Reference< XSingleSelectQueryComposer > getCurrentSettingsComposer(
    1344                 :            :                 const Reference< XPropertySet>& _rxRowSetProps,
    1345                 :            :                 const Reference< XMultiServiceFactory>& _rxFactory)
    1346                 :            : {
    1347                 :         32 :     Reference< XSingleSelectQueryComposer > xReturn;
    1348                 :            :     try
    1349                 :            :     {
    1350 [ +  - ][ +  - ]:         32 :         xReturn = getComposedRowSetStatement( _rxRowSetProps, _rxFactory );
    1351                 :            :     }
    1352      [ #  #  # ]:          0 :     catch( const SQLException& )
    1353                 :            :     {
    1354                 :          0 :         throw;
    1355                 :            :     }
    1356         [ #  # ]:          0 :     catch( const Exception& )
    1357                 :            :     {
    1358                 :            :         OSL_FAIL( "::getCurrentSettingsComposer : caught an exception !" );
    1359                 :            :     }
    1360                 :            : 
    1361                 :         32 :     return xReturn;
    1362                 :            : }
    1363                 :            : //--------------------------------------------------------------------------
    1364                 :        408 : ::rtl::OUString composeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
    1365                 :            :                         const ::rtl::OUString& _rCatalog,
    1366                 :            :                         const ::rtl::OUString& _rSchema,
    1367                 :            :                         const ::rtl::OUString& _rName,
    1368                 :            :                         sal_Bool _bQuote,
    1369                 :            :                         EComposeRule _eComposeRule)
    1370                 :            : {
    1371                 :        408 :     return impl_doComposeTableName( _rxMetaData, _rCatalog, _rSchema, _rName, _bQuote, _eComposeRule );
    1372                 :            : }
    1373                 :            : 
    1374                 :            : // -----------------------------------------------------------------------------
    1375                 :         50 : ::rtl::OUString composeTableNameForSelect( const Reference< XConnection >& _rxConnection,
    1376                 :            :     const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName )
    1377                 :            : {
    1378         [ +  - ]:         50 :     sal_Bool bUseCatalogInSelect = isDataSourcePropertyEnabled( _rxConnection, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCatalogInSelect" ) ), sal_True );
    1379         [ +  - ]:         50 :     sal_Bool bUseSchemaInSelect = isDataSourcePropertyEnabled( _rxConnection, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseSchemaInSelect" ) ), sal_True );
    1380                 :            : 
    1381                 :            :     return impl_doComposeTableName(
    1382         [ +  - ]:         50 :         _rxConnection->getMetaData(),
    1383                 :            :         bUseCatalogInSelect ? _rCatalog : ::rtl::OUString(),
    1384                 :            :         bUseSchemaInSelect ? _rSchema : ::rtl::OUString(),
    1385                 :            :         _rName,
    1386                 :            :         true,
    1387                 :            :         eInDataManipulation
    1388 [ +  - ][ +  - ]:        100 :     );
         [ +  - ][ +  - ]
    1389                 :            : }
    1390                 :            : 
    1391                 :            : // -----------------------------------------------------------------------------
    1392                 :            : namespace
    1393                 :            : {
    1394                 :         24 :     static void lcl_getTableNameComponents( const Reference<XPropertySet>& _xTable,
    1395                 :            :         ::rtl::OUString& _out_rCatalog, ::rtl::OUString& _out_rSchema, ::rtl::OUString& _out_rName )
    1396                 :            :     {
    1397         [ +  - ]:         24 :         ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
    1398                 :         24 :         Reference< XPropertySetInfo > xInfo;
    1399         [ +  - ]:         24 :         if (_xTable.is())
    1400 [ +  - ][ +  - ]:         24 :             xInfo = _xTable->getPropertySetInfo();
                 [ +  - ]
    1401 [ +  - ][ +  - ]:         72 :         if (    xInfo.is()
                 [ +  - ]
    1402 [ +  - ][ +  - ]:         48 :             &&  xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) )
         [ +  - ][ +  - ]
                 [ #  # ]
    1403                 :            :         {
    1404 [ +  - ][ +  - ]:         72 :             if (    xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
           [ +  -  #  # ]
    1405 [ +  - ][ +  - ]:         48 :                 &&  xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) )
         [ +  - ][ +  - ]
                 [ #  # ]
    1406                 :            :             {
    1407 [ +  - ][ +  - ]:         24 :                 _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= _out_rCatalog;
                 [ +  - ]
    1408 [ +  - ][ +  - ]:         24 :                 _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME))  >>= _out_rSchema;
                 [ +  - ]
    1409                 :            :             }
    1410 [ +  - ][ +  - ]:         24 :             _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))        >>= _out_rName;
                 [ +  - ]
    1411                 :            :         }
    1412                 :            :         else
    1413                 :         24 :             OSL_FAIL( "::dbtools::lcl_getTableNameComponents: this is no table object!" );
    1414                 :         24 :     }
    1415                 :            : }
    1416                 :            : 
    1417                 :            : // -----------------------------------------------------------------------------
    1418                 :         24 : ::rtl::OUString composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const Reference<XPropertySet>& _xTable )
    1419                 :            : {
    1420                 :         24 :     ::rtl::OUString sCatalog, sSchema, sName;
    1421         [ +  - ]:         24 :     lcl_getTableNameComponents( _xTable, sCatalog, sSchema, sName );
    1422                 :            : 
    1423         [ +  - ]:         24 :     return composeTableNameForSelect( _rxConnection, sCatalog, sSchema, sName );
    1424                 :            : }
    1425                 :            : 
    1426                 :            : // -----------------------------------------------------------------------------
    1427                 :          0 : ::rtl::OUString composeTableName(const Reference<XDatabaseMetaData>& _xMetaData,
    1428                 :            :                                  const Reference<XPropertySet>& _xTable,
    1429                 :            :                                  EComposeRule _eComposeRule,
    1430                 :            :                                  bool _bSuppressCatalog,
    1431                 :            :                                  bool _bSuppressSchema,
    1432                 :            :                                  bool _bQuote )
    1433                 :            : {
    1434                 :          0 :     ::rtl::OUString sCatalog, sSchema, sName;
    1435         [ #  # ]:          0 :     lcl_getTableNameComponents( _xTable, sCatalog, sSchema, sName );
    1436                 :            : 
    1437                 :            :     return impl_doComposeTableName(
    1438                 :            :             _xMetaData,
    1439                 :            :             _bSuppressCatalog ? ::rtl::OUString() : sCatalog,
    1440                 :            :             _bSuppressSchema ? ::rtl::OUString() : sSchema,
    1441                 :            :             sName,
    1442                 :            :             _bQuote,
    1443                 :            :             _eComposeRule
    1444 [ #  # ][ #  # ]:          0 :         );
                 [ #  # ]
    1445                 :            : }
    1446                 :            : // -----------------------------------------------------------------------------
    1447                 :          6 : sal_Int32 getSearchColumnFlag( const Reference< XConnection>& _rxConn,sal_Int32 _nDataType)
    1448                 :            : {
    1449                 :          6 :     sal_Int32 nSearchFlag = 0;
    1450 [ +  - ][ +  - ]:          6 :     Reference<XResultSet> xSet = _rxConn->getMetaData()->getTypeInfo();
         [ +  - ][ +  - ]
    1451         [ +  - ]:          6 :     if(xSet.is())
    1452                 :            :     {
    1453         [ +  - ]:          6 :         Reference<XRow> xRow(xSet,UNO_QUERY);
    1454 [ +  - ][ +  - ]:          6 :         while(xSet->next())
                 [ +  - ]
    1455                 :            :         {
    1456 [ +  - ][ +  - ]:          6 :             if(xRow->getInt(2) == _nDataType)
                 [ +  - ]
    1457                 :            :             {
    1458 [ +  - ][ +  - ]:          6 :                 nSearchFlag = xRow->getInt(9);
    1459                 :          6 :                 break;
    1460                 :            :             }
    1461                 :          6 :         }
    1462                 :            :     }
    1463                 :          6 :     return nSearchFlag;
    1464                 :            : }
    1465                 :            : 
    1466                 :            : // -----------------------------------------------------------------------------
    1467                 :          0 : ::rtl::OUString createUniqueName( const Sequence< ::rtl::OUString >& _rNames, const ::rtl::OUString& _rBaseName, sal_Bool _bStartWithNumber )
    1468                 :            : {
    1469         [ #  # ]:          0 :     ::std::set< ::rtl::OUString > aUsedNames;
    1470                 :            :     ::std::copy(
    1471                 :            :         _rNames.getConstArray(),
    1472                 :          0 :         _rNames.getConstArray() + _rNames.getLength(),
    1473                 :            :         ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aUsedNames, aUsedNames.end() )
    1474         [ #  # ]:          0 :     );
    1475                 :            : 
    1476                 :          0 :     ::rtl::OUString sName( _rBaseName );
    1477                 :          0 :     sal_Int32 nPos = 1;
    1478         [ #  # ]:          0 :     if ( _bStartWithNumber )
    1479                 :          0 :         sName += ::rtl::OUString::valueOf( nPos );
    1480                 :            : 
    1481 [ #  # ][ #  # ]:          0 :     while ( aUsedNames.find( sName ) != aUsedNames.end() )
    1482                 :            :     {
    1483                 :          0 :         sName = _rBaseName;
    1484                 :          0 :         sName += ::rtl::OUString::valueOf( ++nPos );
    1485                 :            :     }
    1486                 :          0 :     return sName;
    1487                 :            : }
    1488                 :            : 
    1489                 :            : // -----------------------------------------------------------------------------
    1490                 :          0 : ::rtl::OUString createUniqueName(const Reference<XNameAccess>& _rxContainer,const ::rtl::OUString& _rBaseName,sal_Bool _bStartWithNumber)
    1491                 :            : {
    1492         [ #  # ]:          0 :     Sequence< ::rtl::OUString > aElementNames;
    1493                 :            : 
    1494                 :            :     OSL_ENSURE( _rxContainer.is(), "createUniqueName: invalid container!" );
    1495         [ #  # ]:          0 :     if ( _rxContainer.is() )
    1496 [ #  # ][ #  # ]:          0 :         aElementNames = _rxContainer->getElementNames();
         [ #  # ][ #  # ]
    1497                 :            : 
    1498 [ #  # ][ #  # ]:          0 :     return createUniqueName( aElementNames, _rBaseName, _bStartWithNumber );
    1499                 :            : }
    1500                 :            : 
    1501                 :            : // -----------------------------------------------------------------------------
    1502                 :          0 : void showError(const SQLExceptionInfo& _rInfo,
    1503                 :            :                const Reference< XWindow>& _xParent,
    1504                 :            :                const Reference< XMultiServiceFactory >& _xFactory)
    1505                 :            : {
    1506         [ #  # ]:          0 :     if (_rInfo.isValid())
    1507                 :            :     {
    1508                 :            :         try
    1509                 :            :         {
    1510         [ #  # ]:          0 :             Sequence< Any > aArgs(2);
    1511 [ #  # ][ #  # ]:          0 :             aArgs[0] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQLException")), 0, _rInfo.get(), PropertyState_DIRECT_VALUE);
                 [ #  # ]
    1512 [ #  # ][ #  # ]:          0 :             aArgs[1] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")), 0, makeAny(_xParent), PropertyState_DIRECT_VALUE);
         [ #  # ][ #  # ]
    1513                 :            : 
    1514 [ #  # ][ #  # ]:          0 :             static ::rtl::OUString s_sDialogServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.ErrorMessageDialog" ));
         [ #  # ][ #  # ]
    1515                 :            :             Reference< XExecutableDialog > xErrorDialog(
    1516 [ #  # ][ #  # ]:          0 :                 _xFactory->createInstanceWithArguments(s_sDialogServiceName, aArgs), UNO_QUERY);
                 [ #  # ]
    1517         [ #  # ]:          0 :             if (xErrorDialog.is())
    1518 [ #  # ][ #  # ]:          0 :                 xErrorDialog->execute();
    1519                 :            :             else
    1520                 :            :             {
    1521                 :            :                 OSL_FAIL("dbtools::showError: no XExecutableDialog found!");
    1522 [ #  # ][ #  # ]:          0 :             }
    1523                 :            :         }
    1524                 :          0 :         catch(Exception&)
    1525                 :            :         {
    1526                 :            :             OSL_FAIL("showError: could not display the error message!");
    1527                 :            :         }
    1528                 :            :     }
    1529                 :          0 : }
    1530                 :            : 
    1531                 :            : // -------------------------------------------------------------------------
    1532                 :          0 : sal_Bool implUpdateObject(const Reference< XRowUpdate >& _rxUpdatedObject,
    1533                 :            :     const sal_Int32 _nColumnIndex, const Any& _rValue) SAL_THROW ( ( SQLException, RuntimeException ) )
    1534                 :            : {
    1535                 :          0 :     sal_Bool bSuccessfullyReRouted = sal_True;
    1536   [ #  #  #  #  :          0 :     switch (_rValue.getValueTypeClass())
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
    1537                 :            :     {
    1538                 :            :         case TypeClass_ANY:
    1539                 :            :         {
    1540                 :          0 :             Any aInnerValue;
    1541                 :          0 :             _rValue >>= aInnerValue;
    1542         [ #  # ]:          0 :             bSuccessfullyReRouted = implUpdateObject(_rxUpdatedObject, _nColumnIndex, aInnerValue);
    1543                 :            :         }
    1544                 :          0 :         break;
    1545                 :            : 
    1546                 :            :         case TypeClass_VOID:
    1547                 :          0 :             _rxUpdatedObject->updateNull(_nColumnIndex);
    1548                 :          0 :             break;
    1549                 :            : 
    1550                 :            :         case TypeClass_STRING:
    1551                 :          0 :             _rxUpdatedObject->updateString(_nColumnIndex, *(rtl::OUString*)_rValue.getValue());
    1552                 :          0 :             break;
    1553                 :            : 
    1554                 :            :         case TypeClass_BOOLEAN:
    1555                 :          0 :             _rxUpdatedObject->updateBoolean(_nColumnIndex, *(sal_Bool *)_rValue.getValue());
    1556                 :          0 :             break;
    1557                 :            : 
    1558                 :            :         case TypeClass_BYTE:
    1559                 :          0 :             _rxUpdatedObject->updateByte(_nColumnIndex, *(sal_Int8 *)_rValue.getValue());
    1560                 :          0 :             break;
    1561                 :            : 
    1562                 :            :         case TypeClass_UNSIGNED_SHORT:
    1563                 :            :         case TypeClass_SHORT:
    1564                 :          0 :             _rxUpdatedObject->updateShort(_nColumnIndex, *(sal_Int16*)_rValue.getValue());
    1565                 :          0 :             break;
    1566                 :            : 
    1567                 :            :         case TypeClass_CHAR:
    1568         [ #  # ]:          0 :             _rxUpdatedObject->updateString(_nColumnIndex,::rtl::OUString((sal_Unicode *)_rValue.getValue(),1));
    1569                 :          0 :             break;
    1570                 :            : 
    1571                 :            :         case TypeClass_UNSIGNED_LONG:
    1572                 :            :         case TypeClass_LONG:
    1573                 :          0 :             _rxUpdatedObject->updateInt(_nColumnIndex, *(sal_Int32*)_rValue.getValue());
    1574                 :          0 :             break;
    1575                 :            : 
    1576                 :            :         case TypeClass_HYPER:
    1577                 :            :         {
    1578                 :          0 :             sal_Int64 nValue = 0;
    1579                 :          0 :             OSL_VERIFY( _rValue >>= nValue );
    1580 [ #  # ][ #  # ]:          0 :             _rxUpdatedObject->updateLong( _nColumnIndex, nValue );
    1581                 :            :         }
    1582                 :          0 :         break;
    1583                 :            : 
    1584                 :            :         case TypeClass_FLOAT:
    1585                 :          0 :             _rxUpdatedObject->updateFloat(_nColumnIndex, *(float*)_rValue.getValue());
    1586                 :          0 :             break;
    1587                 :            : 
    1588                 :            :         case TypeClass_DOUBLE:
    1589                 :          0 :             _rxUpdatedObject->updateDouble(_nColumnIndex, *(double*)_rValue.getValue());
    1590                 :          0 :             break;
    1591                 :            : 
    1592                 :            :         case TypeClass_SEQUENCE:
    1593         [ #  # ]:          0 :             if (_rValue.getValueType() == ::getCppuType((const Sequence< sal_Int8 > *)0))
    1594                 :          0 :                 _rxUpdatedObject->updateBytes(_nColumnIndex, *(Sequence<sal_Int8>*)_rValue.getValue());
    1595                 :            :             else
    1596                 :          0 :                 bSuccessfullyReRouted = sal_False;
    1597                 :          0 :             break;
    1598                 :            :         case TypeClass_STRUCT:
    1599         [ #  # ]:          0 :             if (_rValue.getValueType() == ::getCppuType((const DateTime*)0))
    1600                 :          0 :                 _rxUpdatedObject->updateTimestamp(_nColumnIndex, *(DateTime*)_rValue.getValue());
    1601         [ #  # ]:          0 :             else if (_rValue.getValueType() == ::getCppuType((const Date*)0))
    1602                 :          0 :                 _rxUpdatedObject->updateDate(_nColumnIndex, *(Date*)_rValue.getValue());
    1603         [ #  # ]:          0 :             else if (_rValue.getValueType() == ::getCppuType((const Time*)0))
    1604                 :          0 :                 _rxUpdatedObject->updateTime(_nColumnIndex, *(Time*)_rValue.getValue());
    1605                 :            :             else
    1606                 :          0 :                 bSuccessfullyReRouted = sal_False;
    1607                 :          0 :             break;
    1608                 :            : 
    1609                 :            :         case TypeClass_INTERFACE:
    1610         [ #  # ]:          0 :             if (_rValue.getValueType() == ::getCppuType(static_cast<Reference< XInputStream>*>(NULL)))
    1611                 :            :             {
    1612                 :          0 :                 Reference< XInputStream >  xStream;
    1613         [ #  # ]:          0 :                 _rValue >>= xStream;
    1614 [ #  # ][ #  # ]:          0 :                 _rxUpdatedObject->updateBinaryStream(_nColumnIndex, xStream, xStream->available());
         [ #  # ][ #  # ]
    1615                 :          0 :                 break;
    1616                 :            :             }
    1617                 :            :             // run through
    1618                 :            :         default:
    1619                 :          0 :             bSuccessfullyReRouted = sal_False;
    1620                 :            :     }
    1621                 :            : 
    1622                 :          0 :     return bSuccessfullyReRouted;
    1623                 :            : }
    1624                 :            : // -------------------------------------------------------------------------
    1625                 :          2 : sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
    1626                 :            :                         const sal_Int32 _nColumnIndex, const Any& _rValue) SAL_THROW ( ( SQLException, RuntimeException ) )
    1627                 :            : {
    1628                 :          2 :     sal_Bool bSuccessfullyReRouted = sal_True;
    1629   [ -  -  -  +  :          2 :     switch (_rValue.getValueTypeClass())
          -  -  -  -  -  
          -  -  -  -  -  
                      - ]
    1630                 :            :     {
    1631                 :            :         case TypeClass_HYPER:
    1632                 :            :         {
    1633                 :          0 :             sal_Int64 nValue = 0;
    1634                 :          0 :             OSL_VERIFY( _rValue >>= nValue );
    1635 [ #  # ][ #  # ]:          0 :             _rxParameters->setLong( _nColumnIndex, nValue );
    1636                 :            :         }
    1637                 :          0 :         break;
    1638                 :            : 
    1639                 :            :         case TypeClass_ANY:
    1640                 :            :         {
    1641                 :          0 :             Any aInnerValue;
    1642                 :          0 :             _rValue >>= aInnerValue;
    1643         [ #  # ]:          0 :             bSuccessfullyReRouted = implSetObject(_rxParameters, _nColumnIndex, aInnerValue);
    1644                 :            :         }
    1645                 :          0 :         break;
    1646                 :            : 
    1647                 :            :         case TypeClass_VOID:
    1648                 :          0 :             _rxParameters->setNull(_nColumnIndex,DataType::VARCHAR);
    1649                 :          0 :             break;
    1650                 :            : 
    1651                 :            :         case TypeClass_STRING:
    1652                 :          2 :             _rxParameters->setString(_nColumnIndex, *(rtl::OUString*)_rValue.getValue());
    1653                 :          2 :             break;
    1654                 :            : 
    1655                 :            :         case TypeClass_BOOLEAN:
    1656                 :          0 :             _rxParameters->setBoolean(_nColumnIndex, *(sal_Bool *)_rValue.getValue());
    1657                 :          0 :             break;
    1658                 :            : 
    1659                 :            :         case TypeClass_BYTE:
    1660                 :          0 :             _rxParameters->setByte(_nColumnIndex, *(sal_Int8 *)_rValue.getValue());
    1661                 :          0 :             break;
    1662                 :            : 
    1663                 :            :         case TypeClass_UNSIGNED_SHORT:
    1664                 :            :         case TypeClass_SHORT:
    1665                 :          0 :             _rxParameters->setShort(_nColumnIndex, *(sal_Int16*)_rValue.getValue());
    1666                 :          0 :             break;
    1667                 :            : 
    1668                 :            :         case TypeClass_CHAR:
    1669         [ #  # ]:          0 :             _rxParameters->setString(_nColumnIndex, ::rtl::OUString((sal_Unicode *)_rValue.getValue(),1));
    1670                 :          0 :             break;
    1671                 :            : 
    1672                 :            :         case TypeClass_UNSIGNED_LONG:
    1673                 :            :         case TypeClass_LONG:
    1674                 :          0 :             _rxParameters->setInt(_nColumnIndex, *(sal_Int32*)_rValue.getValue());
    1675                 :          0 :             break;
    1676                 :            : 
    1677                 :            :         case TypeClass_FLOAT:
    1678                 :          0 :             _rxParameters->setFloat(_nColumnIndex, *(float*)_rValue.getValue());
    1679                 :          0 :             break;
    1680                 :            : 
    1681                 :            :         case TypeClass_DOUBLE:
    1682                 :          0 :             _rxParameters->setDouble(_nColumnIndex, *(double*)_rValue.getValue());
    1683                 :          0 :             break;
    1684                 :            : 
    1685                 :            :         case TypeClass_SEQUENCE:
    1686         [ #  # ]:          0 :             if (_rValue.getValueType() == ::getCppuType((const Sequence< sal_Int8 > *)0))
    1687                 :            :             {
    1688                 :          0 :                 _rxParameters->setBytes(_nColumnIndex, *(Sequence<sal_Int8>*)_rValue.getValue());
    1689                 :            :             }
    1690                 :            :             else
    1691                 :          0 :                 bSuccessfullyReRouted = sal_False;
    1692                 :          0 :             break;
    1693                 :            :         case TypeClass_STRUCT:
    1694         [ #  # ]:          0 :             if (_rValue.getValueType() == ::getCppuType((const DateTime*)0))
    1695                 :          0 :                 _rxParameters->setTimestamp(_nColumnIndex, *(DateTime*)_rValue.getValue());
    1696         [ #  # ]:          0 :             else if (_rValue.getValueType() == ::getCppuType((const Date*)0))
    1697                 :          0 :                 _rxParameters->setDate(_nColumnIndex, *(Date*)_rValue.getValue());
    1698         [ #  # ]:          0 :             else if (_rValue.getValueType() == ::getCppuType((const Time*)0))
    1699                 :          0 :                 _rxParameters->setTime(_nColumnIndex, *(Time*)_rValue.getValue());
    1700                 :            :             else
    1701                 :          0 :                 bSuccessfullyReRouted = sal_False;
    1702                 :          0 :             break;
    1703                 :            : 
    1704                 :            :         case TypeClass_INTERFACE:
    1705         [ #  # ]:          0 :             if (_rValue.getValueType() == ::getCppuType(static_cast<Reference< XInputStream>*>(NULL)))
    1706                 :            :             {
    1707                 :          0 :                 Reference< XInputStream >  xStream;
    1708         [ #  # ]:          0 :                 _rValue >>= xStream;
    1709 [ #  # ][ #  # ]:          0 :                 _rxParameters->setBinaryStream(_nColumnIndex, xStream, xStream->available());
         [ #  # ][ #  # ]
    1710                 :          0 :                 break;
    1711                 :            :             }
    1712                 :            :             // run through
    1713                 :            :         default:
    1714                 :          0 :             bSuccessfullyReRouted = sal_False;
    1715                 :            : 
    1716                 :            :     }
    1717                 :            : 
    1718                 :          2 :     return bSuccessfullyReRouted;
    1719                 :            : }
    1720                 :            : 
    1721                 :            : //..................................................................
    1722                 :            : namespace
    1723                 :            : {
    1724         [ -  + ]:          4 :     class OParameterWrapper : public ::cppu::WeakImplHelper1< XIndexAccess >
    1725                 :            :     {
    1726                 :            :         ::std::vector<bool, std::allocator<bool> >       m_aSet;
    1727                 :            :         Reference<XIndexAccess> m_xSource;
    1728                 :            :     public:
    1729         [ +  - ]:          2 :         OParameterWrapper(const ::std::vector<bool, std::allocator<bool> >& _aSet,const Reference<XIndexAccess>& _xSource) : m_aSet(_aSet),m_xSource(_xSource){}
    1730                 :            :     private:
    1731                 :            :         // ::com::sun::star::container::XElementAccess
    1732                 :          0 :         virtual Type SAL_CALL getElementType() throw(RuntimeException)
    1733                 :            :         {
    1734                 :          0 :             return m_xSource->getElementType();
    1735                 :            :         }
    1736                 :          0 :         virtual sal_Bool SAL_CALL hasElements(  ) throw(RuntimeException)
    1737                 :            :         {
    1738         [ #  # ]:          0 :             if ( m_aSet.empty() )
    1739                 :          0 :                 return m_xSource->hasElements();
    1740         [ #  # ]:          0 :             return ::std::count(m_aSet.begin(),m_aSet.end(),false) != 0;
    1741                 :            :         }
    1742                 :            :         // ::com::sun::star::container::XIndexAccess
    1743                 :          0 :         virtual sal_Int32 SAL_CALL getCount(  ) throw(RuntimeException)
    1744                 :            :         {
    1745         [ #  # ]:          0 :             if ( m_aSet.empty() )
    1746                 :          0 :                 return m_xSource->getCount();
    1747         [ #  # ]:          0 :             return ::std::count(m_aSet.begin(),m_aSet.end(),false);
    1748                 :            :         }
    1749                 :          2 :         virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
    1750                 :            :         {
    1751         [ -  + ]:          2 :             if ( m_aSet.empty() )
    1752 [ #  # ][ #  # ]:          0 :                 return m_xSource->getByIndex(Index);
    1753         [ -  + ]:          2 :             if ( m_aSet.size() < (size_t)Index )
    1754         [ #  # ]:          0 :                 throw IndexOutOfBoundsException();
    1755                 :            : 
    1756                 :          2 :             ::std::vector<bool, std::allocator<bool> >::iterator aIter = m_aSet.begin();
    1757                 :          2 :             ::std::vector<bool, std::allocator<bool> >::iterator aEnd = m_aSet.end();
    1758                 :          2 :             sal_Int32 i = 0;
    1759                 :          2 :             sal_Int32 nParamPos = -1;
    1760 [ +  + ][ +  - ]:          4 :             for(; aIter != aEnd && i <= Index; ++aIter)
                 [ +  + ]
    1761                 :            :             {
    1762                 :          2 :                 ++nParamPos;
    1763         [ +  - ]:          2 :                 if ( !*aIter )
    1764                 :            :                 {
    1765                 :          2 :                     ++i;
    1766                 :            :                 }
    1767                 :            :             }
    1768 [ +  - ][ +  - ]:          2 :             return m_xSource->getByIndex(nParamPos);
    1769                 :            :         }
    1770                 :            :     };
    1771                 :            : }
    1772                 :            : 
    1773                 :            : // -----------------------------------------------------------------------------
    1774                 :          8 : void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer,
    1775                 :            :                       const Reference<XParameters>& _xParameters,
    1776                 :            :                       const Reference< XConnection>& _xConnection,
    1777                 :            :                       const Reference< XInteractionHandler >& _rxHandler,
    1778                 :            :                       const ::std::vector<bool, std::allocator<bool> >& _aParametersSet)
    1779                 :            : {
    1780                 :            :     OSL_ENSURE(_xComposer.is(),"dbtools::askForParameters XSQLQueryComposer is null!");
    1781                 :            :     OSL_ENSURE(_xParameters.is(),"dbtools::askForParameters XParameters is null!");
    1782                 :            :     OSL_ENSURE(_xConnection.is(),"dbtools::askForParameters XConnection is null!");
    1783                 :            :     OSL_ENSURE(_rxHandler.is(),"dbtools::askForParameters XInteractionHandler is null!");
    1784                 :            : 
    1785                 :            :     // we have to set this here again because getCurrentSettingsComposer can force a setpropertyvalue
    1786         [ +  - ]:          8 :     Reference<XParametersSupplier>  xParameters = Reference<XParametersSupplier> (_xComposer, UNO_QUERY);
    1787                 :            : 
    1788 [ +  - ][ +  - ]:          8 :     Reference<XIndexAccess>  xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
                 [ +  - ]
    1789 [ +  - ][ +  - ]:          8 :     sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
                 [ +  - ]
    1790         [ +  - ]:          8 :     ::std::vector<bool, std::allocator<bool> > aNewParameterSet( _aParametersSet );
    1791 [ +  + ][ +  - ]:          8 :     if ( nParamCount && ::std::count(aNewParameterSet.begin(),aNewParameterSet.end(),true) != nParamCount )
         [ +  - ][ +  + ]
           [ +  +  #  # ]
    1792                 :            :     {
    1793 [ +  - ][ +  - ]:          2 :         static const ::rtl::OUString PROPERTY_NAME(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME));
         [ +  - ][ +  - ]
                 [ #  # ]
    1794         [ +  - ]:          2 :         aNewParameterSet.resize(nParamCount ,false);
    1795                 :            :         typedef ::std::map< ::rtl::OUString, ::std::vector<sal_Int32> > TParameterPositions;
    1796         [ +  - ]:          2 :         TParameterPositions aParameterNames;
    1797         [ +  + ]:          4 :         for(sal_Int32 i = 0; i < nParamCount; ++i)
    1798                 :            :         {
    1799 [ +  - ][ +  - ]:          2 :             Reference<XPropertySet> xParam(xParamsAsIndicies->getByIndex(i),UNO_QUERY);
                 [ +  - ]
    1800                 :          2 :             ::rtl::OUString sName;
    1801 [ +  - ][ +  - ]:          2 :             xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
    1802                 :            : 
    1803         [ +  - ]:          2 :             TParameterPositions::iterator aFind = aParameterNames.find(sName);
    1804         [ -  + ]:          2 :             if ( aFind != aParameterNames.end() )
    1805         [ #  # ]:          0 :                 aNewParameterSet[i] = true;
    1806 [ +  - ][ +  - ]:          2 :             aParameterNames[sName].push_back(i+1);
    1807                 :          2 :         }
    1808                 :            :         // build an interaction request
    1809                 :            :         // two continuations (Ok and Cancel)
    1810         [ +  - ]:          2 :         OInteractionAbort* pAbort = new OInteractionAbort;
    1811         [ +  - ]:          2 :         OParameterContinuation* pParams = new OParameterContinuation;
    1812                 :            :         // the request
    1813         [ +  - ]:          2 :         ParametersRequest aRequest;
    1814 [ +  - ][ +  - ]:          2 :         Reference<XIndexAccess> xWrappedParameters = new OParameterWrapper(aNewParameterSet,xParamsAsIndicies);
                 [ +  - ]
    1815         [ +  - ]:          2 :         aRequest.Parameters = xWrappedParameters;
    1816         [ +  - ]:          2 :         aRequest.Connection = _xConnection;
    1817 [ +  - ][ +  - ]:          2 :         OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest));
    1818 [ +  - ][ +  - ]:          2 :         Reference< XInteractionRequest > xRequest(pRequest);
    1819                 :            :         // some knittings
    1820 [ +  - ][ +  - ]:          2 :         pRequest->addContinuation(pAbort);
                 [ +  - ]
    1821 [ +  - ][ +  - ]:          2 :         pRequest->addContinuation(pParams);
                 [ +  - ]
    1822                 :            : 
    1823                 :            :         // execute the request
    1824 [ +  - ][ +  - ]:          2 :         _rxHandler->handle(xRequest);
    1825                 :            : 
    1826         [ -  + ]:          2 :         if (!pParams->wasSelected())
    1827                 :            :         {
    1828                 :            :             // canceled by the user (i.e. (s)he canceled the dialog)
    1829         [ #  # ]:          0 :             RowSetVetoException e;
    1830                 :          0 :             e.ErrorCode = ParameterInteractionCancelled;
    1831         [ #  # ]:          0 :             throw e;
    1832                 :            :         }
    1833                 :            : 
    1834                 :            :         // now transfer the values from the continuation object to the parameter columns
    1835         [ +  - ]:          2 :         Sequence< PropertyValue > aFinalValues = pParams->getValues();
    1836                 :          2 :         const PropertyValue* pFinalValues = aFinalValues.getConstArray();
    1837         [ +  + ]:          4 :         for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
    1838                 :            :         {
    1839 [ +  - ][ +  - ]:          2 :             Reference< XPropertySet > xParamColumn(xWrappedParameters->getByIndex(i),UNO_QUERY);
                 [ +  - ]
    1840         [ +  - ]:          2 :             if (xParamColumn.is())
    1841                 :            :             {
    1842                 :          2 :                 ::rtl::OUString sName;
    1843 [ +  - ][ +  - ]:          2 :                 xParamColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
    1844                 :            :                 OSL_ENSURE(sName.equals(pFinalValues->Name), "::dbaui::askForParameters: inconsistent parameter names!");
    1845                 :            : 
    1846                 :            :                 // determine the field type and ...
    1847                 :          2 :                 sal_Int32 nParamType = 0;
    1848 [ +  - ][ +  - ]:          2 :                 xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nParamType;
         [ +  - ][ +  - ]
    1849                 :            :                 // ... the scale of the parameter column
    1850                 :          2 :                 sal_Int32 nScale = 0;
    1851 [ +  - ][ +  - ]:          2 :                 if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), xParamColumn))
         [ +  - ][ +  - ]
    1852 [ +  - ][ +  - ]:          2 :                     xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale;
         [ +  - ][ +  - ]
    1853                 :            :                     // (the index of the parameters is one-based)
    1854         [ +  - ]:          2 :                 TParameterPositions::iterator aFind = aParameterNames.find(pFinalValues->Name);
    1855                 :          2 :                 ::std::vector<sal_Int32>::iterator aIterPos = aFind->second.begin();
    1856                 :          2 :                 ::std::vector<sal_Int32>::iterator aEndPos = aFind->second.end();
    1857 [ +  - ][ +  - ]:          4 :                 for(;aIterPos != aEndPos;++aIterPos)
                 [ +  + ]
    1858                 :            :                 {
    1859 [ +  - ][ +  - ]:          2 :                     if ( _aParametersSet.empty() || !_aParametersSet[(*aIterPos)-1] )
         [ +  - ][ +  - ]
                 [ +  - ]
    1860                 :            :                     {
    1861 [ +  - ][ +  - ]:          2 :                         _xParameters->setObjectWithInfo(*aIterPos, pFinalValues->Value, nParamType, nScale);
                 [ +  - ]
    1862                 :            :                     }
    1863                 :          2 :                 }
    1864                 :            :             }
    1865 [ +  - ][ +  - ]:          4 :         }
    1866                 :          8 :     }
    1867                 :          8 : }
    1868                 :            : // -----------------------------------------------------------------------------
    1869                 :         12 : void setObjectWithInfo(const Reference<XParameters>& _xParams,
    1870                 :            :                        sal_Int32 parameterIndex,
    1871                 :            :                        const Any& x,
    1872                 :            :                        sal_Int32 sqlType,
    1873                 :            :                        sal_Int32 scale)  throw(SQLException, RuntimeException)
    1874                 :            : {
    1875                 :         12 :     ORowSetValue aVal;
    1876         [ +  - ]:         12 :     aVal.fill(x);
    1877 [ +  - ][ +  - ]:         12 :     setObjectWithInfo(_xParams,parameterIndex,aVal,sqlType,scale);
    1878                 :         12 : }
    1879                 :            : // -----------------------------------------------------------------------------
    1880                 :         12 : void setObjectWithInfo(const Reference<XParameters>& _xParams,
    1881                 :            :                        sal_Int32 parameterIndex,
    1882                 :            :                        const ::connectivity::ORowSetValue& _rValue,
    1883                 :            :                        sal_Int32 sqlType,
    1884                 :            :                        sal_Int32 scale)  throw(SQLException, RuntimeException)
    1885                 :            : {
    1886         [ -  + ]:         12 :     if ( _rValue.isNull() )
    1887                 :          0 :         _xParams->setNull(parameterIndex,sqlType);
    1888                 :            :     else
    1889                 :            :     {
    1890   [ -  +  -  -  :         12 :         switch(sqlType)
          -  -  -  -  -  
          -  -  -  -  -  
                      - ]
    1891                 :            :         {
    1892                 :            :             case DataType::DECIMAL:
    1893                 :            :             case DataType::NUMERIC:
    1894         [ #  # ]:          0 :                 _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,scale);
    1895                 :          0 :                 break;
    1896                 :            :             case DataType::CHAR:
    1897                 :            :             case DataType::VARCHAR:
    1898                 :            :             case DataType::LONGVARCHAR:
    1899         [ +  - ]:         12 :                 _xParams->setString(parameterIndex,_rValue);
    1900                 :         12 :                 break;
    1901                 :            :             case DataType::CLOB:
    1902                 :            :                 {
    1903         [ #  # ]:          0 :                     Any x(_rValue.makeAny());
    1904                 :          0 :                     ::rtl::OUString sValue;
    1905         [ #  # ]:          0 :                     if ( x >>= sValue )
    1906 [ #  # ][ #  # ]:          0 :                         _xParams->setString(parameterIndex,sValue);
    1907                 :            :                     else
    1908                 :            :                     {
    1909                 :          0 :                         Reference< XClob > xClob;
    1910 [ #  # ][ #  # ]:          0 :                         if(x >>= xClob)
    1911 [ #  # ][ #  # ]:          0 :                             _xParams->setClob(parameterIndex,xClob);
    1912                 :            :                         else
    1913                 :            :                         {
    1914                 :          0 :                             Reference< ::com::sun::star::io::XInputStream > xStream;
    1915 [ #  # ][ #  # ]:          0 :                             if(x >>= xStream)
    1916 [ #  # ][ #  # ]:          0 :                                 _xParams->setCharacterStream(parameterIndex,xStream,xStream->available());
         [ #  # ][ #  # ]
    1917                 :          0 :                         }
    1918                 :          0 :                     }
    1919                 :            :                 }
    1920                 :          0 :                 break;
    1921                 :            :             case DataType::BIGINT:
    1922         [ #  # ]:          0 :                 if ( _rValue.isSigned() )
    1923                 :          0 :                     _xParams->setLong(parameterIndex,_rValue);
    1924                 :            :                 else
    1925         [ #  # ]:          0 :                     _xParams->setString(parameterIndex,_rValue);
    1926                 :          0 :                 break;
    1927                 :            : 
    1928                 :            :             case DataType::FLOAT:
    1929                 :          0 :                 _xParams->setFloat(parameterIndex,_rValue);
    1930                 :          0 :                 break;
    1931                 :            :             case DataType::REAL:
    1932                 :            :             case DataType::DOUBLE:
    1933                 :          0 :                 _xParams->setDouble(parameterIndex,_rValue);
    1934                 :          0 :                 break;
    1935                 :            :             case DataType::DATE:
    1936         [ #  # ]:          0 :                 _xParams->setDate(parameterIndex,_rValue);
    1937                 :          0 :                 break;
    1938                 :            :             case DataType::TIME:
    1939         [ #  # ]:          0 :                 _xParams->setTime(parameterIndex,_rValue);
    1940                 :          0 :                 break;
    1941                 :            :             case DataType::TIMESTAMP:
    1942         [ #  # ]:          0 :                 _xParams->setTimestamp(parameterIndex,_rValue);
    1943                 :          0 :                 break;
    1944                 :            :             case DataType::BINARY:
    1945                 :            :             case DataType::VARBINARY:
    1946                 :            :             case DataType::LONGVARBINARY:
    1947                 :            :             case DataType::BLOB:
    1948                 :            :                 {
    1949         [ #  # ]:          0 :                     Any x(_rValue.makeAny());
    1950         [ #  # ]:          0 :                     Sequence< sal_Int8> aBytes;
    1951 [ #  # ][ #  # ]:          0 :                     if(x >>= aBytes)
    1952 [ #  # ][ #  # ]:          0 :                         _xParams->setBytes(parameterIndex,aBytes);
    1953                 :            :                     else
    1954                 :            :                     {
    1955                 :          0 :                         Reference< XBlob > xBlob;
    1956 [ #  # ][ #  # ]:          0 :                         if(x >>= xBlob)
    1957 [ #  # ][ #  # ]:          0 :                             _xParams->setBlob(parameterIndex,xBlob);
    1958                 :            :                         else
    1959                 :            :                         {
    1960                 :          0 :                             Reference< XClob > xClob;
    1961 [ #  # ][ #  # ]:          0 :                             if(x >>= xClob)
    1962 [ #  # ][ #  # ]:          0 :                                 _xParams->setClob(parameterIndex,xClob);
    1963                 :            :                             else
    1964                 :            :                             {
    1965                 :          0 :                                 Reference< ::com::sun::star::io::XInputStream > xBinStream;
    1966 [ #  # ][ #  # ]:          0 :                                 if(x >>= xBinStream)
    1967 [ #  # ][ #  # ]:          0 :                                     _xParams->setBinaryStream(parameterIndex,xBinStream,xBinStream->available());
         [ #  # ][ #  # ]
    1968                 :          0 :                             }
    1969                 :          0 :                         }
    1970         [ #  # ]:          0 :                     }
    1971                 :            :                 }
    1972                 :          0 :                 break;
    1973                 :            :             case DataType::BIT:
    1974                 :            :             case DataType::BOOLEAN:
    1975                 :          0 :                 _xParams->setBoolean(parameterIndex,_rValue);
    1976                 :          0 :                 break;
    1977                 :            :             case DataType::TINYINT:
    1978         [ #  # ]:          0 :                 if ( _rValue.isSigned() )
    1979                 :          0 :                     _xParams->setByte(parameterIndex,_rValue);
    1980                 :            :                 else
    1981                 :          0 :                     _xParams->setShort(parameterIndex,_rValue);
    1982                 :          0 :                 break;
    1983                 :            :             case DataType::SMALLINT:
    1984         [ #  # ]:          0 :                 if ( _rValue.isSigned() )
    1985                 :          0 :                     _xParams->setShort(parameterIndex,_rValue);
    1986                 :            :                 else
    1987                 :          0 :                     _xParams->setInt(parameterIndex,_rValue);
    1988                 :          0 :                 break;
    1989                 :            :             case DataType::INTEGER:
    1990         [ #  # ]:          0 :                 if ( _rValue.isSigned() )
    1991                 :          0 :                     _xParams->setInt(parameterIndex,_rValue);
    1992                 :            :                 else
    1993                 :          0 :                     _xParams->setLong(parameterIndex,_rValue);
    1994                 :          0 :                 break;
    1995                 :            :             default:
    1996                 :            :                 {
    1997         [ #  # ]:          0 :                     ::connectivity::SharedResources aResources;
    1998                 :            :                     const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
    1999                 :            :                             STR_UNKNOWN_PARA_TYPE,
    2000                 :            :                             "$position$", ::rtl::OUString::valueOf(parameterIndex)
    2001         [ #  # ]:          0 :                          ) );
    2002 [ #  # ][ #  # ]:          0 :                     ::dbtools::throwGenericSQLException(sError,NULL);
                 [ #  # ]
    2003                 :            :                 }
    2004                 :            :         }
    2005                 :            :     }
    2006                 :         12 : }
    2007                 :            : 
    2008                 :            : // --------------------------------------------------------------------
    2009                 :          0 : void getBoleanComparisonPredicate( const ::rtl::OUString& _rExpression, const sal_Bool _bValue, const sal_Int32 _nBooleanComparisonMode,
    2010                 :            :     ::rtl::OUStringBuffer& _out_rSQLPredicate )
    2011                 :            : {
    2012   [ #  #  #  # ]:          0 :     switch ( _nBooleanComparisonMode )
    2013                 :            :     {
    2014                 :            :     case BooleanComparisonMode::IS_LITERAL:
    2015                 :          0 :         _out_rSQLPredicate.append( _rExpression );
    2016         [ #  # ]:          0 :         if ( _bValue )
    2017                 :          0 :             _out_rSQLPredicate.appendAscii( " IS TRUE" );
    2018                 :            :         else
    2019                 :          0 :             _out_rSQLPredicate.appendAscii( " IS FALSE" );
    2020                 :          0 :         break;
    2021                 :            : 
    2022                 :            :     case BooleanComparisonMode::EQUAL_LITERAL:
    2023                 :          0 :         _out_rSQLPredicate.append( _rExpression );
    2024         [ #  # ]:          0 :         _out_rSQLPredicate.appendAscii( _bValue ? " = TRUE" : " = FALSE" );
    2025                 :          0 :         break;
    2026                 :            : 
    2027                 :            :     case BooleanComparisonMode::ACCESS_COMPAT:
    2028         [ #  # ]:          0 :         if ( _bValue )
    2029                 :            :         {
    2030                 :          0 :             _out_rSQLPredicate.appendAscii( " NOT ( ( " );
    2031                 :          0 :             _out_rSQLPredicate.append( _rExpression );
    2032                 :          0 :             _out_rSQLPredicate.appendAscii( " = 0 ) OR ( " );
    2033                 :          0 :             _out_rSQLPredicate.append( _rExpression );
    2034                 :          0 :             _out_rSQLPredicate.appendAscii( " IS NULL ) )" );
    2035                 :            :         }
    2036                 :            :         else
    2037                 :            :         {
    2038                 :          0 :             _out_rSQLPredicate.append( _rExpression );
    2039                 :          0 :             _out_rSQLPredicate.appendAscii( " = 0" );
    2040                 :            :         }
    2041                 :          0 :         break;
    2042                 :            : 
    2043                 :            :     case BooleanComparisonMode::EQUAL_INTEGER:
    2044                 :            :         // fall through
    2045                 :            :     default:
    2046                 :          0 :         _out_rSQLPredicate.append( _rExpression );
    2047         [ #  # ]:          0 :         _out_rSQLPredicate.appendAscii( _bValue ? " = 1" : " = 0" );
    2048                 :          0 :         break;
    2049                 :            :     }
    2050                 :          0 : }
    2051                 :            : 
    2052                 :            : //.........................................................................
    2053                 :            : }   // namespace dbtools
    2054                 :            : //.........................................................................
    2055                 :            : 
    2056                 :            : //.........................................................................
    2057                 :            : namespace connectivity
    2058                 :            : {
    2059                 :            : //.........................................................................
    2060                 :            : 
    2061                 :       9282 : void release(oslInterlockedCount& _refCount,
    2062                 :            :              ::cppu::OBroadcastHelper& rBHelper,
    2063                 :            :              Reference< XInterface >& _xInterface,
    2064                 :            :              ::com::sun::star::lang::XComponent* _pObject)
    2065                 :            : {
    2066         [ +  + ]:       9282 :     if (osl_decrementInterlockedCount( &_refCount ) == 0)
    2067                 :            :     {
    2068                 :        244 :         osl_incrementInterlockedCount( &_refCount );
    2069                 :            : 
    2070 [ +  - ][ +  + ]:        244 :         if (!rBHelper.bDisposed && !rBHelper.bInDispose)
    2071                 :            :         {
    2072                 :            :             // remember the parent
    2073                 :        166 :             Reference< XInterface > xParent;
    2074                 :            :             {
    2075         [ +  - ]:        166 :                 ::osl::MutexGuard aGuard( rBHelper.rMutex );
    2076         [ +  - ]:        166 :                 xParent = _xInterface;
    2077 [ +  - ][ +  - ]:        166 :                 _xInterface = NULL;
    2078                 :            :             }
    2079                 :            : 
    2080                 :            :             // First dispose
    2081         [ +  - ]:        166 :             _pObject->dispose();
    2082                 :            : 
    2083                 :            :             // only the alive ref holds the object
    2084                 :            :             OSL_ASSERT( _refCount == 1 );
    2085                 :            : 
    2086                 :            :             // release the parent in the ~
    2087         [ +  - ]:        166 :             if (xParent.is())
    2088                 :            :             {
    2089         [ +  - ]:        166 :                 ::osl::MutexGuard aGuard( rBHelper.rMutex );
    2090 [ +  - ][ +  - ]:        166 :                 _xInterface = xParent;
    2091                 :        166 :             }
    2092                 :            : 
    2093                 :            : //                  // destroy the object if xHoldAlive decrement the refcount to 0
    2094                 :            : //                  m_pDerivedImplementation->WEAK::release();
    2095                 :            :         }
    2096                 :            :     }
    2097                 :            :     else
    2098                 :       9038 :         osl_incrementInterlockedCount( &_refCount );
    2099                 :       9282 : }
    2100                 :            : 
    2101                 :      52446 : void checkDisposed(sal_Bool _bThrow) throw ( DisposedException )
    2102                 :            : {
    2103         [ +  + ]:      52446 :     if (_bThrow)
    2104         [ +  - ]:         16 :         throw DisposedException();
    2105                 :            : 
    2106                 :      52430 : }
    2107                 :            : // -------------------------------------------------------------------------
    2108                 :       5232 :     OSQLColumns::Vector::const_iterator find(   OSQLColumns::Vector::const_iterator __first,
    2109                 :            :                                         OSQLColumns::Vector::const_iterator __last,
    2110                 :            :                                         const ::rtl::OUString& _rVal,
    2111                 :            :                                         const ::comphelper::UStringMixEqual& _rCase)
    2112                 :            :     {
    2113 [ +  - ][ +  - ]:       5232 :         ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
    2114         [ +  - ]:       5232 :         return find(__first,__last,sName,_rVal,_rCase);
    2115                 :            :     }
    2116                 :            :     // -------------------------------------------------------------------------
    2117                 :          0 :     OSQLColumns::Vector::const_iterator findRealName(   OSQLColumns::Vector::const_iterator __first,
    2118                 :            :                                         OSQLColumns::Vector::const_iterator __last,
    2119                 :            :                                         const ::rtl::OUString& _rVal,
    2120                 :            :                                         const ::comphelper::UStringMixEqual& _rCase)
    2121                 :            :     {
    2122 [ #  # ][ #  # ]:          0 :         ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
    2123         [ #  # ]:          0 :         return find(__first,__last,sRealName,_rVal,_rCase);
    2124                 :            :     }
    2125                 :            :     // -------------------------------------------------------------------------
    2126                 :       5232 :     OSQLColumns::Vector::const_iterator find(   OSQLColumns::Vector::const_iterator __first,
    2127                 :            :                                         OSQLColumns::Vector::const_iterator __last,
    2128                 :            :                                         const ::rtl::OUString& _rProp,
    2129                 :            :                                         const ::rtl::OUString& _rVal,
    2130                 :            :                                         const ::comphelper::UStringMixEqual& _rCase)
    2131                 :            :     {
    2132 [ +  - ][ +  + ]:      63918 :         while (__first != __last && !_rCase(getString((*__first)->getPropertyValue(_rProp)),_rVal))
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
         [ +  + ][ +  + ]
           [ +  +  #  #  
                   #  # ]
    2133                 :      58686 :             ++__first;
    2134                 :       5232 :         return __first;
    2135                 :            :     }
    2136                 :            : 
    2137                 :            : // -----------------------------------------------------------------------------
    2138                 :            : } //namespace connectivity
    2139                 :            : // -----------------------------------------------------------------------------
    2140                 :            : 
    2141                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10