LCOV - code coverage report
Current view: top level - connectivity/source/commontools - dbtools2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 63 481 13.1 %
Date: 2012-08-25 Functions: 8 23 34.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 62 1301 4.8 %

           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                 :            : #include "connectivity/dbtools.hxx"
      21                 :            : #include "connectivity/dbconversion.hxx"
      22                 :            : #include "connectivity/dbcharset.hxx"
      23                 :            : #include "connectivity/SQLStatementHelper.hxx"
      24                 :            : #include <unotools/confignode.hxx>
      25                 :            : #include "resource/sharedresources.hxx"
      26                 :            : #include "resource/common_res.hrc"
      27                 :            : #include <com/sun/star/sdbc/XConnection.hpp>
      28                 :            : #include <com/sun/star/sdbc/ColumnValue.hpp>
      29                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      30                 :            : #include <com/sun/star/sdbc/XRow.hpp>
      31                 :            : #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
      32                 :            : #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
      33                 :            : #include <com/sun/star/sdbc/XDriverAccess.hpp>
      34                 :            : #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
      35                 :            : #include <com/sun/star/sdbcx/Privilege.hpp>
      36                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      37                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      38                 :            : #include <com/sun/star/sdbc/KeyRule.hpp>
      39                 :            : #include <com/sun/star/sdbcx/KeyType.hpp>
      40                 :            : #include "TConnection.hxx"
      41                 :            : #include "connectivity/sdbcx/VColumn.hxx"
      42                 :            : #include <com/sun/star/frame/XModel.hpp>
      43                 :            : #include <com/sun/star/container/XChild.hpp>
      44                 :            : 
      45                 :            : #include <tools/diagnose_ex.h>
      46                 :            : #include <unotools/sharedunocomponent.hxx>
      47                 :            : 
      48                 :            : //.........................................................................
      49                 :            : namespace dbtools
      50                 :            : {
      51                 :            : //.........................................................................
      52                 :            :     using namespace ::com::sun::star::uno;
      53                 :            :     using namespace ::com::sun::star::beans;
      54                 :            :     using namespace ::com::sun::star::sdbc;
      55                 :            :     using namespace ::com::sun::star::sdbcx;
      56                 :            :     using namespace ::com::sun::star::lang;
      57                 :            :     using namespace ::com::sun::star::container;
      58                 :            :     using namespace ::com::sun::star::frame;
      59                 :            :     using namespace connectivity;
      60                 :            :     using namespace comphelper;
      61                 :            : 
      62                 :          0 : ::rtl::OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const ::rtl::OUString& _sCreatePattern)
      63                 :            : {
      64                 :            : 
      65 [ #  # ][ #  # ]:          0 :     Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
      66                 :            : 
      67         [ #  # ]:          0 :     ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
      68                 :            : 
      69                 :          0 :     ::rtl::OUString sTypeName;
      70                 :          0 :     sal_Int32       nDataType   = 0;
      71                 :          0 :     sal_Int32       nPrecision  = 0;
      72                 :          0 :     sal_Int32       nScale      = 0;
      73                 :            : 
      74 [ #  # ][ #  # ]:          0 :     const ::rtl::OUString sQuoteString = xMetaData->getIdentifierQuoteString();
      75 [ #  # ][ #  # ]:          0 :     ::rtl::OUStringBuffer aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      76                 :            : 
      77         [ #  # ]:          0 :     aSql.appendAscii(" ");
      78                 :            : 
      79                 :          0 :     nDataType = nPrecision = nScale = 0;
      80                 :          0 :     sal_Bool bIsAutoIncrement = sal_False;
      81 [ #  # ][ #  # ]:          0 :     xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPENAME))           >>= sTypeName;
                 [ #  # ]
      82 [ #  # ][ #  # ]:          0 :     xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE))               >>= nDataType;
                 [ #  # ]
      83 [ #  # ][ #  # ]:          0 :     xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_PRECISION))          >>= nPrecision;
                 [ #  # ]
      84 [ #  # ][ #  # ]:          0 :     xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCALE))              >>= nScale;
                 [ #  # ]
      85 [ #  # ][ #  # ]:          0 :     xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))    >>= bIsAutoIncrement;
                 [ #  # ]
      86                 :            : 
      87                 :            :     // check if the user enter a specific string to create autoincrement values
      88                 :          0 :     ::rtl::OUString sAutoIncrementValue;
      89 [ #  # ][ #  # ]:          0 :     Reference<XPropertySetInfo> xPropInfo = xColProp->getPropertySetInfo();
      90 [ #  # ][ #  # ]:          0 :     if ( xPropInfo.is() && xPropInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION)) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
      91 [ #  # ][ #  # ]:          0 :         xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION)) >>= sAutoIncrementValue;
                 [ #  # ]
      92                 :            :     // look if we have to use precisions
      93                 :          0 :     sal_Bool bUseLiteral = sal_False;
      94                 :          0 :     ::rtl::OUString sPreFix,sPostFix,sCreateParams;
      95                 :            :     {
      96 [ #  # ][ #  # ]:          0 :         Reference<XResultSet> xRes = xMetaData->getTypeInfo();
      97         [ #  # ]:          0 :         if(xRes.is())
      98                 :            :         {
      99         [ #  # ]:          0 :             Reference<XRow> xRow(xRes,UNO_QUERY);
     100 [ #  # ][ #  # ]:          0 :             while(xRes->next())
                 [ #  # ]
     101                 :            :             {
     102 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString sTypeName2Cmp = xRow->getString(1);
     103 [ #  # ][ #  # ]:          0 :                 sal_Int32 nType = xRow->getShort(2);
     104 [ #  # ][ #  # ]:          0 :                 sPreFix = xRow->getString (4);
     105 [ #  # ][ #  # ]:          0 :                 sPostFix = xRow->getString (5);
     106 [ #  # ][ #  # ]:          0 :                 sCreateParams = xRow->getString(6);
     107                 :            :                 // first identical type will be used if typename is empty
     108 [ #  # ][ #  # ]:          0 :                 if ( sTypeName.isEmpty() && nType == nDataType )
                 [ #  # ]
     109                 :          0 :                     sTypeName = sTypeName2Cmp;
     110                 :            : 
     111 [ #  # ][ #  # ]:          0 :                 if( sTypeName.equalsIgnoreAsciiCase(sTypeName2Cmp) && nType == nDataType && !sCreateParams.isEmpty() && !xRow->wasNull())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     112                 :            :                 {
     113                 :          0 :                     bUseLiteral = sal_True;
     114                 :            :                     break;
     115                 :            :                 }
     116         [ #  # ]:          0 :             }
     117                 :          0 :         }
     118                 :            :     }
     119                 :            : 
     120                 :          0 :     sal_Int32 nIndex = 0;
     121 [ #  # ][ #  # ]:          0 :     if ( !sAutoIncrementValue.isEmpty() && (nIndex = sTypeName.indexOf(sAutoIncrementValue)) != -1 )
                 [ #  # ]
     122                 :            :     {
     123                 :          0 :         sTypeName = sTypeName.replaceAt(nIndex,sTypeName.getLength() - nIndex,::rtl::OUString());
     124                 :            :     }
     125                 :            : 
     126 [ #  # ][ #  # ]:          0 :     if ( (nPrecision > 0 || nScale > 0) && bUseLiteral )
                 [ #  # ]
     127                 :            :     {
     128                 :          0 :         sal_Int32 nParenPos = sTypeName.indexOf('(');
     129         [ #  # ]:          0 :         if ( nParenPos == -1 )
     130                 :            :         {
     131         [ #  # ]:          0 :             aSql.append(sTypeName);
     132         [ #  # ]:          0 :             aSql.appendAscii("(");
     133                 :            :         }
     134                 :            :         else
     135                 :            :         {
     136         [ #  # ]:          0 :             aSql.append(sTypeName.copy(0,++nParenPos));
     137                 :            :         }
     138                 :            : 
     139 [ #  # ][ #  # ]:          0 :         if ( nPrecision > 0 && nDataType != DataType::TIMESTAMP )
     140                 :            :         {
     141         [ #  # ]:          0 :             aSql.append(nPrecision);
     142 [ #  # ][ #  # ]:          0 :             if ( (nScale > 0) || (!_sCreatePattern.isEmpty() && sCreateParams.indexOf(_sCreatePattern) != -1) )
         [ #  # ][ #  # ]
     143         [ #  # ]:          0 :                 aSql.appendAscii(",");
     144                 :            :         }
     145 [ #  # ][ #  # ]:          0 :         if ( (nScale > 0) || ( !_sCreatePattern.isEmpty() && sCreateParams.indexOf(_sCreatePattern) != -1 ) || nDataType == DataType::TIMESTAMP )
         [ #  # ][ #  # ]
                 [ #  # ]
     146         [ #  # ]:          0 :             aSql.append(nScale);
     147                 :            : 
     148         [ #  # ]:          0 :         if ( nParenPos == -1 )
     149         [ #  # ]:          0 :             aSql.appendAscii(")");
     150                 :            :         else
     151                 :            :         {
     152                 :          0 :             nParenPos = sTypeName.indexOf(')',nParenPos);
     153         [ #  # ]:          0 :             aSql.append(sTypeName.copy(nParenPos));
     154                 :          0 :         }
     155                 :            :     }
     156                 :            :     else
     157         [ #  # ]:          0 :         aSql.append(sTypeName); // simply add the type name
     158                 :            : 
     159 [ #  # ][ #  # ]:          0 :     ::rtl::OUString aDefault = ::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)));
         [ #  # ][ #  # ]
     160         [ #  # ]:          0 :     if ( !aDefault.isEmpty() )
     161                 :            :     {
     162 [ #  # ][ #  # ]:          0 :         aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DEFAULT ")));
     163         [ #  # ]:          0 :         aSql.append(sPreFix);
     164         [ #  # ]:          0 :         aSql.append(aDefault);
     165         [ #  # ]:          0 :         aSql.append(sPostFix);
     166                 :            :     } // if ( aDefault.getLength() )
     167                 :            : 
     168 [ #  # ][ #  # ]:          0 :     if(::comphelper::getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS)
         [ #  # ][ #  # ]
                 [ #  # ]
     169 [ #  # ][ #  # ]:          0 :         aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT NULL")));
     170                 :            : 
     171 [ #  # ][ #  # ]:          0 :     if ( bIsAutoIncrement && !sAutoIncrementValue.isEmpty())
                 [ #  # ]
     172                 :            :     {
     173         [ #  # ]:          0 :         aSql.appendAscii(" ");
     174         [ #  # ]:          0 :         aSql.append(sAutoIncrementValue);
     175                 :            :     }
     176                 :            : 
     177         [ #  # ]:          0 :     if ( _pHelper )
     178         [ #  # ]:          0 :         _pHelper->addComment(xColProp,aSql);
     179                 :            : 
     180         [ #  # ]:          0 :     return aSql.makeStringAndClear();
     181                 :            : }
     182                 :            : // -----------------------------------------------------------------------------
     183                 :            : 
     184                 :          0 : ::rtl::OUString createStandardCreateStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const ::rtl::OUString& _sCreatePattern)
     185                 :            : {
     186 [ #  # ][ #  # ]:          0 :     ::rtl::OUStringBuffer aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATE TABLE ")));
     187                 :          0 :     ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
     188                 :            : 
     189 [ #  # ][ #  # ]:          0 :     Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
     190         [ #  # ]:          0 :     ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
     191                 :            : 
     192 [ #  # ][ #  # ]:          0 :     descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))  >>= sCatalog;
                 [ #  # ]
     193 [ #  # ][ #  # ]:          0 :     descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME))   >>= sSchema;
                 [ #  # ]
     194 [ #  # ][ #  # ]:          0 :     descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))         >>= sTable;
                 [ #  # ]
     195                 :            : 
     196         [ #  # ]:          0 :     sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInTableDefinitions );
     197         [ #  # ]:          0 :     if ( sComposedName.isEmpty() )
     198         [ #  # ]:          0 :         ::dbtools::throwFunctionSequenceException(_xConnection);
     199                 :            : 
     200         [ #  # ]:          0 :     aSql.append(sComposedName);
     201 [ #  # ][ #  # ]:          0 :     aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (")));
     202                 :            : 
     203                 :            :     // columns
     204         [ #  # ]:          0 :     Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
     205 [ #  # ][ #  # ]:          0 :     Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
                 [ #  # ]
     206                 :            :     // check if there are columns
     207 [ #  # ][ #  # ]:          0 :     if(!xColumns.is() || !xColumns->getCount())
         [ #  # ][ #  # ]
                 [ #  # ]
     208         [ #  # ]:          0 :         ::dbtools::throwFunctionSequenceException(_xConnection);
     209                 :            : 
     210                 :          0 :     Reference< XPropertySet > xColProp;
     211                 :            : 
     212 [ #  # ][ #  # ]:          0 :     sal_Int32 nCount = xColumns->getCount();
     213         [ #  # ]:          0 :     for(sal_Int32 i=0;i<nCount;++i)
     214                 :            :     {
     215 [ #  # ][ #  # ]:          0 :         if ( (xColumns->getByIndex(i) >>= xColProp) && xColProp.is() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     216                 :            :         {
     217 [ #  # ][ #  # ]:          0 :             aSql.append(createStandardColumnPart(xColProp,_xConnection,_pHelper,_sCreatePattern));
     218         [ #  # ]:          0 :             aSql.appendAscii(",");
     219                 :            :         }
     220                 :            :     }
     221         [ #  # ]:          0 :     return aSql.makeStringAndClear();
     222                 :            : }
     223                 :            : namespace
     224                 :            : {
     225                 :          0 :     ::rtl::OUString generateColumnNames(const Reference<XIndexAccess>& _xColumns,const Reference<XDatabaseMetaData>& _xMetaData)
     226                 :            :     {
     227         [ #  # ]:          0 :         ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
     228 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sComma(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")));
         [ #  # ][ #  # ]
     229                 :            : 
     230 [ #  # ][ #  # ]:          0 :         const ::rtl::OUString sQuote(_xMetaData->getIdentifierQuoteString());
     231         [ #  # ]:          0 :         ::rtl::OUString sSql( RTL_CONSTASCII_USTRINGPARAM( " (" ));
     232                 :          0 :         Reference< XPropertySet > xColProp;
     233                 :            : 
     234 [ #  # ][ #  # ]:          0 :         sal_Int32 nColCount  = _xColumns->getCount();
     235         [ #  # ]:          0 :         for(sal_Int32 i=0;i<nColCount;++i)
     236                 :            :         {
     237 [ #  # ][ #  # ]:          0 :             if ( (_xColumns->getByIndex(i) >>= xColProp) && xColProp.is() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     238         [ #  # ]:          0 :                 sSql += ::dbtools::quoteName(sQuote,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))
     239 [ #  # ][ #  # ]:          0 :                         + sComma;
         [ #  # ][ #  # ]
     240                 :            :         }
     241                 :            : 
     242         [ #  # ]:          0 :         if ( nColCount )
     243         [ #  # ]:          0 :             sSql = sSql.replaceAt(sSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
     244                 :          0 :         return sSql;
     245                 :            :     }
     246                 :            : }
     247                 :            : // -----------------------------------------------------------------------------
     248                 :          0 : ::rtl::OUString createStandardKeyStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection)
     249                 :            : {
     250 [ #  # ][ #  # ]:          0 :     Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
     251         [ #  # ]:          0 :     ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
     252                 :            : 
     253                 :          0 :     ::rtl::OUStringBuffer aSql;
     254                 :            :     // keys
     255         [ #  # ]:          0 :     Reference<XKeysSupplier> xKeySup(descriptor,UNO_QUERY);
     256 [ #  # ][ #  # ]:          0 :     Reference<XIndexAccess> xKeys = xKeySup->getKeys();
     257         [ #  # ]:          0 :     if ( xKeys.is() )
     258                 :            :     {
     259                 :          0 :         Reference< XPropertySet > xColProp;
     260                 :          0 :         Reference<XIndexAccess> xColumns;
     261                 :          0 :         Reference<XColumnsSupplier> xColumnSup;
     262                 :          0 :         ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
     263                 :          0 :         sal_Bool bPKey = sal_False;
     264 [ #  # ][ #  # ]:          0 :         for(sal_Int32 i=0;i<xKeys->getCount();++i)
                 [ #  # ]
     265                 :            :         {
     266 [ #  # ][ #  # ]:          0 :             if ( (xKeys->getByIndex(i) >>= xColProp) && xColProp.is() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     267                 :            :             {
     268                 :            : 
     269 [ #  # ][ #  # ]:          0 :                 sal_Int32 nKeyType      = ::comphelper::getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)));
         [ #  # ][ #  # ]
     270                 :            : 
     271         [ #  # ]:          0 :                 if ( nKeyType == KeyType::PRIMARY )
     272                 :            :                 {
     273         [ #  # ]:          0 :                     if(bPKey)
     274         [ #  # ]:          0 :                         ::dbtools::throwFunctionSequenceException(_xConnection);
     275                 :            : 
     276                 :          0 :                     bPKey = sal_True;
     277 [ #  # ][ #  # ]:          0 :                     xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
     278 [ #  # ][ #  # ]:          0 :                     xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
         [ #  # ][ #  # ]
     279 [ #  # ][ #  # ]:          0 :                     if(!xColumns.is() || !xColumns->getCount())
         [ #  # ][ #  # ]
                 [ #  # ]
     280         [ #  # ]:          0 :                         ::dbtools::throwFunctionSequenceException(_xConnection);
     281                 :            : 
     282 [ #  # ][ #  # ]:          0 :                     const ::rtl::OUString sQuote     = xMetaData->getIdentifierQuoteString();
     283 [ #  # ][ #  # ]:          0 :                     aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PRIMARY KEY ")));
     284 [ #  # ][ #  # ]:          0 :                     aSql.append(generateColumnNames(xColumns,xMetaData));
     285                 :            :                 }
     286         [ #  # ]:          0 :                 else if(nKeyType == KeyType::UNIQUE)
     287                 :            :                 {
     288 [ #  # ][ #  # ]:          0 :                     xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
     289 [ #  # ][ #  # ]:          0 :                     xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
         [ #  # ][ #  # ]
     290 [ #  # ][ #  # ]:          0 :                     if(!xColumns.is() || !xColumns->getCount())
         [ #  # ][ #  # ]
                 [ #  # ]
     291         [ #  # ]:          0 :                         ::dbtools::throwFunctionSequenceException(_xConnection);
     292                 :            : 
     293 [ #  # ][ #  # ]:          0 :                     const ::rtl::OUString sQuote     = xMetaData->getIdentifierQuoteString();
     294 [ #  # ][ #  # ]:          0 :                     aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" UNIQUE ")));
     295 [ #  # ][ #  # ]:          0 :                     aSql.append(generateColumnNames(xColumns,xMetaData));
     296                 :            :                 }
     297         [ #  # ]:          0 :                 else if(nKeyType == KeyType::FOREIGN)
     298                 :            :                 {
     299 [ #  # ][ #  # ]:          0 :                     sal_Int32 nDeleteRule   = getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)));
         [ #  # ][ #  # ]
     300                 :            : 
     301 [ #  # ][ #  # ]:          0 :                     xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
     302 [ #  # ][ #  # ]:          0 :                     xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
         [ #  # ][ #  # ]
     303 [ #  # ][ #  # ]:          0 :                     if(!xColumns.is() || !xColumns->getCount())
         [ #  # ][ #  # ]
                 [ #  # ]
     304         [ #  # ]:          0 :                         ::dbtools::throwFunctionSequenceException(_xConnection);
     305                 :            : 
     306 [ #  # ][ #  # ]:          0 :                     aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FOREIGN KEY ")));
     307 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString sRefTable = getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)));
         [ #  # ][ #  # ]
     308                 :            :                     ::dbtools::qualifiedNameComponents(xMetaData,
     309                 :            :                                                         sRefTable,
     310                 :            :                                                         sCatalog,
     311                 :            :                                                         sSchema,
     312                 :            :                                                         sTable,
     313         [ #  # ]:          0 :                                                         ::dbtools::eInDataManipulation);
     314         [ #  # ]:          0 :                     sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInTableDefinitions );
     315                 :            : 
     316                 :            : 
     317         [ #  # ]:          0 :                     if ( sComposedName.isEmpty() )
     318         [ #  # ]:          0 :                         ::dbtools::throwFunctionSequenceException(_xConnection);
     319                 :            : 
     320 [ #  # ][ #  # ]:          0 :                     aSql.append(generateColumnNames(xColumns,xMetaData));
     321                 :            : 
     322   [ #  #  #  #  :          0 :                     switch(nDeleteRule)
                      # ]
     323                 :            :                     {
     324                 :            :                         case KeyRule::CASCADE:
     325 [ #  # ][ #  # ]:          0 :                             aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON DELETE CASCADE ")));
     326                 :          0 :                             break;
     327                 :            :                         case KeyRule::RESTRICT:
     328 [ #  # ][ #  # ]:          0 :                             aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON DELETE RESTRICT ")));
     329                 :          0 :                             break;
     330                 :            :                         case KeyRule::SET_NULL:
     331 [ #  # ][ #  # ]:          0 :                             aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON DELETE SET NULL ")));
     332                 :          0 :                             break;
     333                 :            :                         case KeyRule::SET_DEFAULT:
     334 [ #  # ][ #  # ]:          0 :                             aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON DELETE SET DEFAULT ")));
     335                 :          0 :                             break;
     336                 :            :                         default:
     337                 :            :                             ;
     338                 :          0 :                     }
     339                 :            :                 }
     340                 :            :             }
     341                 :          0 :         }
     342                 :            :     }
     343                 :            : 
     344         [ #  # ]:          0 :     if ( aSql.getLength() )
     345                 :            :     {
     346         [ #  # ]:          0 :         if ( aSql[aSql.getLength() - 1] == ',' )
     347                 :          0 :             aSql[aSql.getLength() - 1] = ')';
     348                 :            :         else
     349         [ #  # ]:          0 :             aSql.appendAscii(")");
     350                 :            :     }
     351                 :            : 
     352         [ #  # ]:          0 :     return aSql.makeStringAndClear();
     353                 :            : 
     354                 :            : }
     355                 :            : // -----------------------------------------------------------------------------
     356                 :          0 : ::rtl::OUString createSqlCreateTableStatement(  const Reference< XPropertySet >& descriptor,
     357                 :            :                                                 const Reference< XConnection>& _xConnection,
     358                 :            :                                                 ISQLStatementHelper* _pHelper,
     359                 :            :                                                 const ::rtl::OUString& _sCreatePattern)
     360                 :            : {
     361         [ #  # ]:          0 :     ::rtl::OUString aSql = ::dbtools::createStandardCreateStatement(descriptor,_xConnection,_pHelper,_sCreatePattern);
     362         [ #  # ]:          0 :     const ::rtl::OUString sKeyStmt = ::dbtools::createStandardKeyStatement(descriptor,_xConnection);
     363         [ #  # ]:          0 :     if ( !sKeyStmt.isEmpty() )
     364                 :          0 :         aSql += sKeyStmt;
     365                 :            :     else
     366                 :            :     {
     367         [ #  # ]:          0 :         if ( aSql.lastIndexOf(',') == (aSql.getLength()-1) )
     368         [ #  # ]:          0 :             aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
     369                 :            :         else
     370         [ #  # ]:          0 :             aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
     371                 :            :     }
     372                 :          0 :     return aSql;
     373                 :            : }
     374                 :            : namespace
     375                 :            : {
     376                 :          0 :     Reference<XPropertySet> lcl_createSDBCXColumn(const Reference<XNameAccess>& _xPrimaryKeyColumns,
     377                 :            :                                           const Reference<XConnection>& _xConnection,
     378                 :            :                                           const Any& _aCatalog,
     379                 :            :                                           const ::rtl::OUString& _aSchema,
     380                 :            :                                           const ::rtl::OUString& _aTable,
     381                 :            :                                           const ::rtl::OUString& _rQueryName,
     382                 :            :                                           const ::rtl::OUString& _rName,
     383                 :            :                                           sal_Bool _bCase,
     384                 :            :                                           sal_Bool _bQueryForInfo,
     385                 :            :                                           sal_Bool _bIsAutoIncrement,
     386                 :            :                                           sal_Bool _bIsCurrency,
     387                 :            :                                           sal_Int32 _nDataType)
     388                 :            :     {
     389                 :          0 :         Reference<XPropertySet> xProp;
     390 [ #  # ][ #  # ]:          0 :         Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
     391 [ #  # ][ #  # ]:          0 :         Reference< XResultSet > xResult = xMetaData->getColumns(_aCatalog, _aSchema, _aTable, _rQueryName);
     392                 :            : 
     393         [ #  # ]:          0 :         if ( xResult.is() )
     394                 :            :         {
     395                 :          0 :             UStringMixEqual aMixCompare(_bCase);
     396         [ #  # ]:          0 :             Reference< XRow > xRow(xResult,UNO_QUERY);
     397 [ #  # ][ #  # ]:          0 :             while( xResult->next() )
                 [ #  # ]
     398                 :            :             {
     399 [ #  # ][ #  # ]:          0 :                 if ( aMixCompare(xRow->getString(4),_rName) )
                 [ #  # ]
     400                 :            :                 {
     401 [ #  # ][ #  # ]:          0 :                     sal_Int32       nField5 = xRow->getInt(5);
     402 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString aField6 = xRow->getString(6);
     403 [ #  # ][ #  # ]:          0 :                     sal_Int32       nField7 = xRow->getInt(7)
     404 [ #  # ][ #  # ]:          0 :                                 ,   nField9 = xRow->getInt(9)
     405 [ #  # ][ #  # ]:          0 :                                 ,   nField11= xRow->getInt(11);
     406 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString sField12 = xRow->getString(12),
     407 [ #  # ][ #  # ]:          0 :                                     sField13 = xRow->getString(13);
     408         [ #  # ]:          0 :                     ::comphelper::disposeComponent(xRow);
     409                 :            : 
     410                 :          0 :                     sal_Bool bAutoIncrement = _bIsAutoIncrement
     411                 :          0 :                             ,bIsCurrency    = _bIsCurrency;
     412         [ #  # ]:          0 :                     if ( _bQueryForInfo )
     413                 :            :                     {
     414 [ #  # ][ #  # ]:          0 :                         const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString();
     415         [ #  # ]:          0 :                         ::rtl::OUString sQuotedName  = ::dbtools::quoteName(sQuote,_rName);
     416                 :          0 :                         ::rtl::OUString sComposedName;
     417 [ #  # ][ #  # ]:          0 :                         sComposedName = composeTableNameForSelect(_xConnection, getString( _aCatalog ), _aSchema, _aTable );
     418                 :            : 
     419         [ #  # ]:          0 :                         ColumnInformationMap aInfo(_bCase);
     420         [ #  # ]:          0 :                         collectColumnInformation(_xConnection,sComposedName,sQuotedName,aInfo);
     421                 :          0 :                         ColumnInformationMap::iterator aIter = aInfo.begin();
     422         [ #  # ]:          0 :                         if ( aIter != aInfo.end() )
     423                 :            :                         {
     424                 :          0 :                             bAutoIncrement  = aIter->second.first.first;
     425                 :          0 :                             bIsCurrency     = aIter->second.first.second;
     426         [ #  # ]:          0 :                             if ( DataType::OTHER == nField5 )
     427                 :          0 :                                 nField5     = aIter->second.second;
     428                 :          0 :                         }
     429                 :            :                     }
     430         [ #  # ]:          0 :                     else if ( DataType::OTHER == nField5 )
     431                 :          0 :                         nField5 = _nDataType;
     432                 :            : 
     433         [ #  # ]:          0 :                     if ( nField11 != ColumnValue::NO_NULLS )
     434                 :            :                     {
     435                 :            :                         try
     436                 :            :                         {
     437         [ #  # ]:          0 :                             if ( _xPrimaryKeyColumns.is() )
     438                 :            :                             {
     439 [ #  # ][ #  # ]:          0 :                                 if ( _xPrimaryKeyColumns->hasByName(_rName) )
                 [ #  # ]
     440                 :          0 :                                     nField11 = ColumnValue::NO_NULLS;
     441                 :            : 
     442                 :            :                             }
     443                 :            :                             else
     444                 :            :                             {
     445 [ #  # ][ #  # ]:          0 :                                 Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable );
     446         [ #  # ]:          0 :                                 Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW );
     447 [ #  # ][ #  # ]:          0 :                                 while( xPKeys->next() ) // there can be only one primary key
                 [ #  # ]
     448                 :            :                                 {
     449 [ #  # ][ #  # ]:          0 :                                     ::rtl::OUString sKeyColumn = xPKeyRow->getString(4);
     450         [ #  # ]:          0 :                                     if ( aMixCompare(_rName,sKeyColumn) )
     451                 :            :                                     {
     452                 :          0 :                                         nField11 = ColumnValue::NO_NULLS;
     453                 :            :                                         break;
     454                 :            :                                     }
     455 [ #  # ][ #  # ]:          0 :                                 }
     456                 :            :                             }
     457                 :            :                         }
     458         [ #  # ]:          0 :                         catch(SQLException&)
     459                 :            :                         {
     460                 :            :                             OSL_FAIL( "lcl_createSDBCXColumn: caught an exception!" );
     461                 :            :                         }
     462                 :            :                     }
     463                 :            : 
     464                 :            :                     connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName,
     465                 :            :                                                 aField6,
     466                 :            :                                                 sField13,
     467                 :            :                                                 sField12,
     468                 :            :                                                 nField11,
     469                 :            :                                                 nField7,
     470                 :            :                                                 nField9,
     471                 :            :                                                 nField5,
     472                 :            :                                                 bAutoIncrement,
     473                 :            :                                                 sal_False,
     474                 :            :                                                 bIsCurrency,
     475         [ #  # ]:          0 :                                                 _bCase);
     476                 :            : 
     477 [ #  # ][ #  # ]:          0 :                     xProp = pRet;
     478                 :          0 :                     break;
     479                 :            :                 }
     480                 :          0 :             }
     481                 :            :         }
     482                 :            : 
     483                 :          0 :         return xProp;
     484                 :            :     }
     485                 :            :     //------------------------------------------------------------------
     486                 :       1036 :     Reference< XModel> lcl_getXModel(const Reference< XInterface>& _xIface)
     487                 :            :     {
     488                 :       1036 :         Reference< XInterface > xParent = _xIface;
     489         [ +  - ]:       1036 :         Reference< XModel > xModel(xParent,UNO_QUERY);;
     490 [ +  + ][ +  + ]:       2360 :         while( xParent.is() && !xModel.is() )
                 [ +  + ]
     491                 :            :         {
     492         [ +  - ]:       1324 :             Reference<XChild> xChild(xParent,UNO_QUERY);
     493 [ +  - ][ +  - ]:       1324 :             xParent.set(xChild.is() ? xChild->getParent() : Reference< XInterface >(),UNO_QUERY);
         [ +  - ][ +  - ]
     494         [ +  - ]:       1324 :             xModel.set(xParent,UNO_QUERY);
     495                 :       1324 :         }
     496                 :       1036 :         return xModel;
     497                 :            :     }
     498                 :            : }
     499                 :            : // -----------------------------------------------------------------------------
     500                 :          0 : Reference<XPropertySet> createSDBCXColumn(const Reference<XPropertySet>& _xTable,
     501                 :            :                                           const Reference<XConnection>& _xConnection,
     502                 :            :                                           const ::rtl::OUString& _rName,
     503                 :            :                                           sal_Bool _bCase,
     504                 :            :                                           sal_Bool _bQueryForInfo,
     505                 :            :                                           sal_Bool _bIsAutoIncrement,
     506                 :            :                                           sal_Bool _bIsCurrency,
     507                 :            :                                           sal_Int32 _nDataType)
     508                 :            : {
     509                 :          0 :     Reference<XPropertySet> xProp;
     510                 :            :     OSL_ENSURE(_xTable.is(),"Table is NULL!");
     511         [ #  # ]:          0 :     if ( !_xTable.is() )
     512                 :            :         return xProp;
     513                 :            : 
     514         [ #  # ]:          0 :     ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
     515 [ #  # ][ #  # ]:          0 :     Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
     516                 :          0 :     Any aCatalog;
     517 [ #  # ][ #  # ]:          0 :     aCatalog = _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME));
                 [ #  # ]
     518                 :            : 
     519                 :          0 :     ::rtl::OUString aSchema, aTable;
     520 [ #  # ][ #  # ]:          0 :     _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME))  >>= aSchema;
                 [ #  # ]
     521 [ #  # ][ #  # ]:          0 :     _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))        >>= aTable;
                 [ #  # ]
     522                 :            : 
     523         [ #  # ]:          0 :     Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(_xTable);
     524                 :            : 
     525 [ #  # ][ #  # ]:          0 :     xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, _rName,_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
     526         [ #  # ]:          0 :     if ( !xProp.is() )
     527                 :            :     {
     528 [ #  # ][ #  # ]:          0 :         xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
                 [ #  # ]
     529         [ #  # ]:          0 :         if ( !xProp.is() )
     530                 :            :             xProp = new connectivity::sdbcx::OColumn(_rName,
     531                 :            :                                                 ::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
     532                 :            :                                                 ColumnValue::NULLABLE_UNKNOWN,
     533                 :            :                                                 0,
     534                 :            :                                                 0,
     535                 :            :                                                 DataType::VARCHAR,
     536                 :            :                                                 _bIsAutoIncrement,
     537                 :            :                                                 sal_False,
     538                 :            :                                                 _bIsCurrency,
     539 [ #  # ][ #  # ]:          0 :                                                 _bCase);
                 [ #  # ]
     540                 :            : 
     541                 :            :     }
     542                 :            : 
     543                 :          0 :     return xProp;
     544                 :            : }
     545                 :            : 
     546                 :            : // -----------------------------------------------------------------------------
     547                 :          0 : bool getBooleanDataSourceSetting( const Reference< XConnection >& _rxConnection, const sal_Char* _pAsciiSettingName )
     548                 :            : {
     549                 :          0 :     bool bValue( false );
     550                 :            :     try
     551                 :            :     {
     552 [ #  # ][ #  # ]:          0 :         Reference< XPropertySet> xDataSourceProperties( findDataSource( _rxConnection ), UNO_QUERY );
     553                 :            :         OSL_ENSURE( xDataSourceProperties.is(), "::dbtools::getBooleanDataSourceSetting: somebody is using this with a non-SDB-level connection!" );
     554         [ #  # ]:          0 :         if ( xDataSourceProperties.is() )
     555                 :            :         {
     556                 :            :             Reference< XPropertySet > xSettings(
     557         [ #  # ]:          0 :                 xDataSourceProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings") ) ),
     558                 :            :                 UNO_QUERY_THROW
     559 [ #  # ][ #  # ]:          0 :             );
                 [ #  # ]
     560 [ #  # ][ #  # ]:          0 :             OSL_VERIFY( xSettings->getPropertyValue( ::rtl::OUString::createFromAscii( _pAsciiSettingName ) ) >>= bValue );
     561         [ #  # ]:          0 :         }
     562                 :            :     }
     563         [ #  # ]:          0 :     catch( const Exception& )
     564                 :            :     {
     565                 :            :         DBG_UNHANDLED_EXCEPTION();
     566                 :            :     }
     567                 :          0 :     return bValue;
     568                 :            : }
     569                 :            : // -------------------------------------------------------------------------
     570                 :       1728 : bool getDataSourceSetting( const Reference< XInterface >& _xChild, const ::rtl::OUString& _sAsciiSettingsName,
     571                 :            :     Any& /* [out] */ _rSettingsValue )
     572                 :            : {
     573                 :       1728 :     bool bIsPresent = false;
     574                 :            :     try
     575                 :            :     {
     576 [ +  - ][ +  - ]:       1728 :         const Reference< XPropertySet> xDataSourceProperties( findDataSource( _xChild ), UNO_QUERY );
     577         [ -  + ]:       1728 :         if ( !xDataSourceProperties.is() )
     578                 :          0 :             return false;
     579                 :            : 
     580                 :            :         const Reference< XPropertySet > xSettings(
     581         [ +  - ]:       1728 :                 xDataSourceProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings") ) ),
     582                 :            :                 UNO_QUERY_THROW
     583 [ +  - ][ +  - ]:       1728 :             );
                 [ +  - ]
     584                 :            : 
     585 [ +  - ][ +  - ]:       1728 :         _rSettingsValue = xSettings->getPropertyValue( _sAsciiSettingsName );
     586 [ +  - ][ #  # ]:       1728 :         bIsPresent = true;
     587                 :            :     }
     588                 :          0 :     catch( const Exception& )
     589                 :            :     {
     590                 :          0 :         bIsPresent = false;
     591                 :            :     }
     592                 :       1728 :     return bIsPresent;
     593                 :            : }
     594                 :            : // -------------------------------------------------------------------------
     595                 :       1652 : bool getDataSourceSetting( const Reference< XInterface >& _rxDataSource, const sal_Char* _pAsciiSettingsName,
     596                 :            :     Any& /* [out] */ _rSettingsValue )
     597                 :            : {
     598                 :       1652 :     ::rtl::OUString sAsciiSettingsName = ::rtl::OUString::createFromAscii(_pAsciiSettingsName);
     599         [ +  - ]:       1652 :     return getDataSourceSetting( _rxDataSource, sAsciiSettingsName,_rSettingsValue );
     600                 :            : }
     601                 :            : // -----------------------------------------------------------------------------
     602                 :        100 : sal_Bool isDataSourcePropertyEnabled(const Reference<XInterface>& _xProp,const ::rtl::OUString& _sProperty,sal_Bool _bDefault)
     603                 :            : {
     604                 :        100 :     sal_Bool bEnabled = _bDefault;
     605                 :            :     try
     606                 :            :     {
     607 [ +  - ][ +  - ]:        100 :         Reference< XPropertySet> xProp(findDataSource(_xProp),UNO_QUERY);
     608         [ +  - ]:        100 :         if ( xProp.is() )
     609                 :            :         {
     610         [ +  - ]:        100 :             Sequence< PropertyValue > aInfo;
     611 [ +  - ][ +  - ]:        100 :             xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Info"))) >>= aInfo;
         [ +  - ][ +  - ]
     612                 :            :             const PropertyValue* pValue =::std::find_if(aInfo.getConstArray(),
     613                 :        100 :                                                 aInfo.getConstArray() + aInfo.getLength(),
     614   [ +  -  +  - ]:        200 :                                                 ::std::bind2nd(TPropertyValueEqualFunctor(),_sProperty));
     615 [ -  + ][ -  + ]:        100 :             if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
                 [ +  - ]
     616         [ +  - ]:        100 :                 pValue->Value >>= bEnabled;
     617         [ #  # ]:        100 :         }
     618                 :            :     }
     619         [ #  # ]:          0 :     catch(SQLException&)
     620                 :            :     {
     621                 :            :         DBG_UNHANDLED_EXCEPTION();
     622                 :            :     }
     623                 :        100 :     return bEnabled;
     624                 :            : }
     625                 :            : // -----------------------------------------------------------------------------
     626                 :         56 : Reference< XTablesSupplier> getDataDefinitionByURLAndConnection(
     627                 :            :             const ::rtl::OUString& _rsUrl,
     628                 :            :             const Reference< XConnection>& _xConnection,
     629                 :            :             const Reference< XMultiServiceFactory>& _rxFactory)
     630                 :            : {
     631                 :         56 :     Reference< XTablesSupplier> xTablesSup;
     632                 :            :     try
     633                 :            :     {
     634                 :            :         Reference< XDriverAccess> xManager(
     635         [ +  - ]:         56 :             _rxFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager")) ),
     636 [ +  - ][ +  - ]:         56 :             UNO_QUERY_THROW );
                 [ +  - ]
     637 [ +  - ][ +  - ]:         56 :         Reference< XDataDefinitionSupplier > xSupp( xManager->getDriverByURL( _rsUrl ), UNO_QUERY );
                 [ +  - ]
     638                 :            : 
     639         [ +  - ]:         56 :         if ( xSupp.is() )
     640                 :            :         {
     641 [ +  - ][ +  - ]:         56 :             xTablesSup = xSupp->getDataDefinitionByConnection( _xConnection );
                 [ +  - ]
     642                 :            :             OSL_ENSURE(xTablesSup.is(),"No table supplier!");
     643         [ #  # ]:         56 :         }
     644                 :            :     }
     645         [ #  # ]:          0 :     catch( const Exception& )
     646                 :            :     {
     647                 :            :         DBG_UNHANDLED_EXCEPTION();
     648                 :            :     }
     649                 :         56 :     return xTablesSup;
     650                 :            : }
     651                 :            : 
     652                 :            : // -----------------------------------------------------------------------------
     653                 :          0 : sal_Int32 getTablePrivileges(const Reference< XDatabaseMetaData>& _xMetaData,
     654                 :            :                              const ::rtl::OUString& _sCatalog,
     655                 :            :                              const ::rtl::OUString& _sSchema,
     656                 :            :                              const ::rtl::OUString& _sTable)
     657                 :            : {
     658                 :            :     OSL_ENSURE(_xMetaData.is(),"Invalid metadata!");
     659                 :          0 :     sal_Int32 nPrivileges = 0;
     660                 :            :     try
     661                 :            :     {
     662                 :          0 :         Any aVal;
     663         [ #  # ]:          0 :         if(!_sCatalog.isEmpty())
     664         [ #  # ]:          0 :             aVal <<= _sCatalog;
     665 [ #  # ][ #  # ]:          0 :         Reference< XResultSet > xPrivileges = _xMetaData->getTablePrivileges(aVal, _sSchema, _sTable);
     666         [ #  # ]:          0 :         Reference< XRow > xCurrentRow(xPrivileges, UNO_QUERY);
     667                 :            : 
     668 [ #  # ][ #  # ]:          0 :         const ::rtl::OUString sUserWorkingFor = _xMetaData->getUserName();
     669 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sSELECT( RTL_CONSTASCII_USTRINGPARAM( "SELECT" ));
         [ #  # ][ #  # ]
     670 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sINSERT( RTL_CONSTASCII_USTRINGPARAM( "INSERT" ));
         [ #  # ][ #  # ]
     671 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sUPDATE( RTL_CONSTASCII_USTRINGPARAM( "UPDATE" ));
         [ #  # ][ #  # ]
     672 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sDELETE( RTL_CONSTASCII_USTRINGPARAM( "DELETE" ));
         [ #  # ][ #  # ]
     673 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sREAD( RTL_CONSTASCII_USTRINGPARAM( "READ" ));
         [ #  # ][ #  # ]
     674 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sCREATE( RTL_CONSTASCII_USTRINGPARAM( "CREATE" ));
         [ #  # ][ #  # ]
     675 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sALTER( RTL_CONSTASCII_USTRINGPARAM( "ALTER" ));
         [ #  # ][ #  # ]
     676 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sREFERENCE( RTL_CONSTASCII_USTRINGPARAM( "REFERENCE" ));
         [ #  # ][ #  # ]
     677 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString sDROP( RTL_CONSTASCII_USTRINGPARAM( "DROP" ));
         [ #  # ][ #  # ]
     678                 :            : 
     679         [ #  # ]:          0 :         if ( xCurrentRow.is() )
     680                 :            :         {
     681                 :            :             // after creation the set is positioned before the first record, per definition
     682                 :            : #ifdef DBG_UTIL
     683                 :            :             Reference< XResultSetMetaDataSupplier > xSup(xPrivileges,UNO_QUERY);
     684                 :            :             if ( xSup.is() )
     685                 :            :             {
     686                 :            :                 Reference< XResultSetMetaData > xRsMetaData = xSup->getMetaData();
     687                 :            :                 if ( xRsMetaData.is() )
     688                 :            :                 {
     689                 :            :                     sal_Int32 nCount = xRsMetaData->getColumnCount();
     690                 :            :                     for (sal_Int32 i=1; i<=nCount; ++i)
     691                 :            :                     {
     692                 :            :                         ::rtl::OUString sColumnName = xRsMetaData->getColumnName(i);
     693                 :            :                     }
     694                 :            :                 }
     695                 :            :             }
     696                 :            : #endif
     697                 :            : 
     698                 :          0 :             ::rtl::OUString sPrivilege, sGrantee;
     699 [ #  # ][ #  # ]:          0 :             while ( xPrivileges->next() )
                 [ #  # ]
     700                 :            :             {
     701                 :            : #ifdef DBG_UTIL
     702                 :            :                 ::rtl::OUString sCat, sSchema, sName, sGrantor, sGrantable;
     703                 :            :                 sCat        = xCurrentRow->getString(1);
     704                 :            :                 sSchema     = xCurrentRow->getString(2);
     705                 :            :                 sName       = xCurrentRow->getString(3);
     706                 :            :                 sGrantor    = xCurrentRow->getString(4);
     707                 :            : #endif
     708 [ #  # ][ #  # ]:          0 :                 sGrantee    = xCurrentRow->getString(5);
     709 [ #  # ][ #  # ]:          0 :                 sPrivilege  = xCurrentRow->getString(6);
     710                 :            : #ifdef DBG_UTIL
     711                 :            :                 sGrantable  = xCurrentRow->getString(7);
     712                 :            : #endif
     713                 :            : 
     714         [ #  # ]:          0 :                 if (!sUserWorkingFor.equalsIgnoreAsciiCase(sGrantee))
     715                 :          0 :                     continue;
     716                 :            : 
     717         [ #  # ]:          0 :                 if (sPrivilege.equalsIgnoreAsciiCase(sSELECT))
     718                 :          0 :                     nPrivileges |= Privilege::SELECT;
     719         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sINSERT))
     720                 :          0 :                     nPrivileges |= Privilege::INSERT;
     721         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sUPDATE))
     722                 :          0 :                     nPrivileges |= Privilege::UPDATE;
     723         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sDELETE))
     724                 :          0 :                     nPrivileges |= Privilege::DELETE;
     725         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sREAD))
     726                 :          0 :                     nPrivileges |= Privilege::READ;
     727         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sCREATE))
     728                 :          0 :                     nPrivileges |= Privilege::CREATE;
     729         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sALTER))
     730                 :          0 :                     nPrivileges |= Privilege::ALTER;
     731         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sREFERENCE))
     732                 :          0 :                     nPrivileges |= Privilege::REFERENCE;
     733         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sDROP))
     734                 :          0 :                     nPrivileges |= Privilege::DROP;
     735                 :          0 :             }
     736                 :            :         }
     737         [ #  # ]:          0 :         disposeComponent(xPrivileges);
     738                 :            : 
     739                 :            :         // Some drivers put a table privilege as soon as any column has the privilege,
     740                 :            :         // some drivers only if all columns have the privilege.
     741                 :            :         // To unifiy the situation, collect column privileges here, too.
     742 [ #  # ][ #  # ]:          0 :         Reference< XResultSet > xColumnPrivileges = _xMetaData->getColumnPrivileges(aVal, _sSchema, _sTable, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
                 [ #  # ]
     743         [ #  # ]:          0 :         Reference< XRow > xColumnCurrentRow(xColumnPrivileges, UNO_QUERY);
     744         [ #  # ]:          0 :         if ( xColumnCurrentRow.is() )
     745                 :            :         {
     746                 :            :             // after creation the set is positioned before the first record, per definition
     747                 :          0 :             ::rtl::OUString sPrivilege, sGrantee;
     748 [ #  # ][ #  # ]:          0 :             while ( xColumnPrivileges->next() )
                 [ #  # ]
     749                 :            :             {
     750                 :            : #ifdef DBG_UTIL
     751                 :            :                 ::rtl::OUString sCat, sSchema, sTableName, sColumnName, sGrantor, sGrantable;
     752                 :            :                 sCat        = xColumnCurrentRow->getString(1);
     753                 :            :                 sSchema     = xColumnCurrentRow->getString(2);
     754                 :            :                 sTableName  = xColumnCurrentRow->getString(3);
     755                 :            :                 sColumnName = xColumnCurrentRow->getString(4);
     756                 :            :                 sGrantor    = xColumnCurrentRow->getString(5);
     757                 :            : #endif
     758 [ #  # ][ #  # ]:          0 :                 sGrantee    = xColumnCurrentRow->getString(6);
     759 [ #  # ][ #  # ]:          0 :                 sPrivilege  = xColumnCurrentRow->getString(7);
     760                 :            : #ifdef DBG_UTIL
     761                 :            :                 sGrantable  = xColumnCurrentRow->getString(8);
     762                 :            : #endif
     763                 :            : 
     764         [ #  # ]:          0 :                 if (!sUserWorkingFor.equalsIgnoreAsciiCase(sGrantee))
     765                 :          0 :                     continue;
     766                 :            : 
     767         [ #  # ]:          0 :                 if (sPrivilege.equalsIgnoreAsciiCase(sSELECT))
     768                 :          0 :                     nPrivileges |= Privilege::SELECT;
     769         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sINSERT))
     770                 :          0 :                     nPrivileges |= Privilege::INSERT;
     771         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sUPDATE))
     772                 :          0 :                     nPrivileges |= Privilege::UPDATE;
     773         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sDELETE))
     774                 :          0 :                     nPrivileges |= Privilege::DELETE;
     775         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sREAD))
     776                 :          0 :                     nPrivileges |= Privilege::READ;
     777         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sCREATE))
     778                 :          0 :                     nPrivileges |= Privilege::CREATE;
     779         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sALTER))
     780                 :          0 :                     nPrivileges |= Privilege::ALTER;
     781         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sREFERENCE))
     782                 :          0 :                     nPrivileges |= Privilege::REFERENCE;
     783         [ #  # ]:          0 :                 else if (sPrivilege.equalsIgnoreAsciiCase(sDROP))
     784                 :          0 :                     nPrivileges |= Privilege::DROP;
     785                 :          0 :             }
     786                 :            :         }
     787         [ #  # ]:          0 :         disposeComponent(xColumnPrivileges);
     788                 :            :     }
     789         [ #  # ]:          0 :     catch(const SQLException& e)
     790                 :            :     {
     791   [ #  #  #  #  :          0 :         static ::rtl::OUString sNotSupportedState( RTL_CONSTASCII_USTRINGPARAM( "IM001" ));
             #  #  #  # ]
     792                 :            :         // some drivers don't support any privileges so we assume that we are allowed to do all we want :-)
     793         [ #  # ]:          0 :         if(e.SQLState == sNotSupportedState)
     794                 :            :             nPrivileges |=  Privilege::DROP         |
     795                 :            :                             Privilege::REFERENCE    |
     796                 :            :                             Privilege::ALTER        |
     797                 :            :                             Privilege::CREATE       |
     798                 :            :                             Privilege::READ         |
     799                 :            :                             Privilege::DELETE       |
     800                 :            :                             Privilege::UPDATE       |
     801                 :            :                             Privilege::INSERT       |
     802                 :          0 :                             Privilege::SELECT;
     803                 :            :         else
     804                 :            :             OSL_FAIL("Could not collect the privileges !");
     805                 :            :     }
     806                 :          0 :     return nPrivileges;
     807                 :            : }
     808                 :            : // -----------------------------------------------------------------------------
     809                 :            : // we need some more information about the column
     810                 :          0 : void collectColumnInformation(const Reference< XConnection>& _xConnection,
     811                 :            :                               const ::rtl::OUString& _sComposedName,
     812                 :            :                               const ::rtl::OUString& _rName,
     813                 :            :                               ColumnInformationMap& _rInfo)
     814                 :            : {
     815 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString STR_WHERE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE "));
         [ #  # ][ #  # ]
     816                 :            : 
     817         [ #  # ]:          0 :     ::rtl::OUString sSelect = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT "));
     818                 :          0 :     sSelect += _rName;
     819         [ #  # ]:          0 :     sSelect += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM "));
     820                 :          0 :     sSelect += _sComposedName;
     821                 :          0 :     sSelect += STR_WHERE;
     822         [ #  # ]:          0 :     sSelect += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0 = 1"));
     823                 :            : 
     824                 :            :     try
     825                 :            :     {
     826 [ #  # ][ #  # ]:          0 :         ::utl::SharedUNOComponent< XStatement > xStmt( _xConnection->createStatement() );
                 [ #  # ]
     827         [ #  # ]:          0 :         Reference< XPropertySet > xStatementProps( xStmt, UNO_QUERY_THROW );
     828 [ #  # ][ #  # ]:          0 :         xStatementProps->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_ESCAPEPROCESSING ), makeAny( (sal_Bool)sal_False ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     829 [ #  # ][ #  # ]:          0 :         Reference< XResultSet > xResult( xStmt->executeQuery( sSelect ), UNO_QUERY_THROW );
                 [ #  # ]
     830         [ #  # ]:          0 :         Reference< XResultSetMetaDataSupplier > xSuppMeta( xResult, UNO_QUERY_THROW );
     831 [ #  # ][ #  # ]:          0 :         Reference< XResultSetMetaData > xMeta( xSuppMeta->getMetaData(), UNO_QUERY_THROW );
                 [ #  # ]
     832                 :            : 
     833 [ #  # ][ #  # ]:          0 :         sal_Int32 nCount = xMeta->getColumnCount();
     834                 :            :         OSL_ENSURE( nCount != 0, "::dbtools::collectColumnInformation: result set has empty (column-less) meta data!" );
     835         [ #  # ]:          0 :         for (sal_Int32 i=1; i <= nCount ; ++i)
     836                 :            :         {
     837         [ #  # ]:          0 :             _rInfo.insert(ColumnInformationMap::value_type(xMeta->getColumnName(i),
     838 [ #  # ][ #  # ]:          0 :                 ColumnInformation(TBoolPair(xMeta->isAutoIncrement(i),xMeta->isCurrency(i)),xMeta->getColumnType(i))));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     839 [ #  # ][ #  # ]:          0 :         }
     840                 :            :     }
     841         [ #  # ]:          0 :     catch( const Exception& )
     842                 :            :     {
     843                 :            :         DBG_UNHANDLED_EXCEPTION();
     844                 :          0 :     }
     845                 :          0 : }
     846                 :            : 
     847                 :            : // -----------------------------------------------------------------------------
     848                 :       1036 : bool isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent, Reference< XConnection >& _rxActualConnection )
     849                 :            : {
     850                 :       1036 :     bool bIsEmbedded = false;
     851                 :            :     try
     852                 :            :     {
     853         [ +  - ]:       1036 :         Reference< XModel > xModel = lcl_getXModel( _rxComponent );
     854                 :            : 
     855         [ +  + ]:       1036 :         if ( xModel.is() )
     856                 :            :         {
     857 [ +  - ][ +  + ]:       1019 :             Sequence< PropertyValue > aArgs = xModel->getArgs();
     858                 :        507 :             const PropertyValue* pIter = aArgs.getConstArray();
     859                 :        507 :             const PropertyValue* pEnd  = pIter + aArgs.getLength();
     860         [ +  + ]:       5572 :             for(;pIter != pEnd;++pIter)
     861                 :            :             {
     862         [ -  + ]:       5065 :                 if ( pIter->Name == "ComponentData" )
     863                 :            :                 {
     864         [ #  # ]:          0 :                     Sequence<PropertyValue> aDocumentContext;
     865         [ #  # ]:          0 :                     pIter->Value >>= aDocumentContext;
     866                 :          0 :                     const PropertyValue* pContextIter = aDocumentContext.getConstArray();
     867                 :          0 :                     const PropertyValue* pContextEnd  = pContextIter + aDocumentContext.getLength();
     868         [ #  # ]:          0 :                     for(;pContextIter != pContextEnd;++pContextIter)
     869                 :            :                     {
     870 [ #  # ][ #  # ]:          0 :                         if (  pContextIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ActiveConnection" ) )
                 [ #  # ]
     871         [ #  # ]:          0 :                         && ( pContextIter->Value >>= _rxActualConnection )
     872                 :            :                         )
     873                 :            :                         {
     874                 :          0 :                             bIsEmbedded = true;
     875                 :          0 :                             break;
     876                 :            :                         }
     877                 :            :                     }
     878         [ #  # ]:          0 :                     break;
     879                 :            :                 }
     880         [ +  - ]:       1019 :             }
     881         [ -  + ]:       1036 :         }
     882                 :            :     }
     883                 :        512 :     catch(Exception&)
     884                 :            :     {
     885                 :            :         // not intereseted in
     886                 :            :     }
     887                 :       1036 :     return bIsEmbedded;
     888                 :            : }
     889                 :            : // -----------------------------------------------------------------------------
     890                 :            : namespace
     891                 :            : {
     892                 :          0 :     ::rtl::OUString lcl_getEncodingName( rtl_TextEncoding _eEncoding )
     893                 :            :     {
     894                 :          0 :         ::rtl::OUString sEncodingName;
     895                 :            : 
     896         [ #  # ]:          0 :         OCharsetMap aCharsets;
     897         [ #  # ]:          0 :         OCharsetMap::CharsetIterator aEncodingPos = aCharsets.find( _eEncoding );
     898                 :            :         OSL_ENSURE( aEncodingPos != aCharsets.end(), "lcl_getEncodingName: *which* encoding?" );
     899 [ #  # ][ #  # ]:          0 :         if ( aEncodingPos != aCharsets.end() )
         [ #  # ][ #  # ]
     900 [ #  # ][ #  # ]:          0 :             sEncodingName = (*aEncodingPos).getIanaName();
     901                 :            : 
     902 [ #  # ][ #  # ]:          0 :         return sEncodingName;
     903                 :            :     }
     904                 :            : }
     905                 :            : 
     906                 :            : // -----------------------------------------------------------------------------
     907                 :         10 : sal_Int32 DBTypeConversion::convertUnicodeString( const ::rtl::OUString& _rSource, ::rtl::OString& _rDest, rtl_TextEncoding _eEncoding ) SAL_THROW((com::sun::star::sdbc::SQLException))
     908                 :            : {
     909         [ -  + ]:         10 :     if ( !rtl_convertUStringToString( &_rDest.pData, _rSource.getStr(), _rSource.getLength(),
     910                 :            :             _eEncoding,
     911                 :            :             RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
     912                 :            :             RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |
     913                 :            :             RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |
     914                 :         10 :             RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE )
     915                 :            :         )
     916                 :            :     {
     917         [ #  # ]:          0 :         SharedResources aResources;
     918                 :            :         ::rtl::OUString sMessage = aResources.getResourceStringWithSubstitution( STR_CANNOT_CONVERT_STRING,
     919                 :            :             "$string$", _rSource,
     920                 :            :             "$charset$",  lcl_getEncodingName( _eEncoding )
     921 [ #  # ][ #  # ]:          0 :         );
     922                 :            : 
     923                 :            :         throw SQLException(
     924                 :            :             sMessage,
     925                 :            :             NULL,
     926                 :            :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "22018" ) ),
     927                 :            :             22018,
     928                 :            :             Any()
     929 [ #  # ][ #  # ]:          0 :         );
                 [ #  # ]
     930                 :            :     }
     931                 :            : 
     932                 :         10 :     return _rDest.getLength();
     933                 :            : }
     934                 :            : 
     935                 :            : // -----------------------------------------------------------------------------
     936                 :          8 : sal_Int32 DBTypeConversion::convertUnicodeStringToLength( const ::rtl::OUString& _rSource, ::rtl::OString&  _rDest,
     937                 :            :    sal_Int32 _nMaxLen, rtl_TextEncoding _eEncoding ) SAL_THROW((SQLException))
     938                 :            : {
     939                 :          8 :     sal_Int32 nLen = convertUnicodeString( _rSource, _rDest, _eEncoding );
     940         [ -  + ]:          8 :     if ( nLen > _nMaxLen )
     941                 :            :     {
     942         [ #  # ]:          0 :         SharedResources aResources;
     943                 :            :         ::rtl::OUString sMessage = aResources.getResourceStringWithSubstitution( STR_STRING_LENGTH_EXCEEDED,
     944                 :            :             "$string$", _rSource,
     945                 :            :             "$maxlen$", ::rtl::OUString::valueOf( _nMaxLen ),
     946                 :            :             "$charset$", lcl_getEncodingName( _eEncoding )
     947 [ #  # ][ #  # ]:          0 :         );
     948                 :            : 
     949                 :            :         throw SQLException(
     950                 :            :             sMessage,
     951                 :            :             NULL,
     952                 :            :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "22001" ) ),
     953                 :            :             22001,
     954                 :            :             Any()
     955 [ #  # ][ #  # ]:          0 :         );
                 [ #  # ]
     956                 :            :     }
     957                 :            : 
     958                 :          8 :    return nLen;
     959                 :            : }
     960                 :          0 : ::rtl::OUString lcl_getReportEngines()
     961                 :            : {
     962 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/ReportEngines"));
         [ #  # ][ #  # ]
     963                 :          0 :     return s_sNodeName;
     964                 :            : }
     965                 :            : // -----------------------------------------------------------------------------
     966                 :          0 : ::rtl::OUString lcl_getDefaultReportEngine()
     967                 :            : {
     968 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("DefaultReportEngine"));
         [ #  # ][ #  # ]
     969                 :          0 :     return s_sNodeName;
     970                 :            : }
     971                 :            : // -----------------------------------------------------------------------------
     972                 :          0 : ::rtl::OUString lcl_getReportEngineNames()
     973                 :            : {
     974 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("ReportEngineNames"));
         [ #  # ][ #  # ]
     975                 :          0 :     return s_sNodeName;
     976                 :            : }
     977                 :            : // -----------------------------------------------------------------------------
     978                 :          0 : ::rtl::OUString getDefaultReportEngineServiceName(const Reference< XMultiServiceFactory >& _rxORB)
     979                 :            : {
     980                 :            :     ::utl::OConfigurationTreeRoot aReportEngines = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
     981 [ #  # ][ #  # ]:          0 :         _rxORB, lcl_getReportEngines(), -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
     982                 :            : 
     983         [ #  # ]:          0 :     if ( aReportEngines.isValid() )
     984                 :            :     {
     985                 :          0 :         ::rtl::OUString sDefaultReportEngineName;
     986         [ #  # ]:          0 :         aReportEngines.getNodeValue(lcl_getDefaultReportEngine()) >>= sDefaultReportEngineName;
     987         [ #  # ]:          0 :         if ( !sDefaultReportEngineName.isEmpty() )
     988                 :            :         {
     989         [ #  # ]:          0 :             ::utl::OConfigurationNode aReportEngineNames = aReportEngines.openNode(lcl_getReportEngineNames());
     990         [ #  # ]:          0 :             if ( aReportEngineNames.isValid() )
     991                 :            :             {
     992                 :          0 :                 ::utl::OConfigurationNode aReportEngine = aReportEngineNames.openNode(sDefaultReportEngineName);
     993         [ #  # ]:          0 :                 if ( aReportEngine.isValid() )
     994                 :            :                 {
     995                 :          0 :                     ::rtl::OUString sRet;
     996 [ #  # ][ #  # ]:          0 :                     const static ::rtl::OUString s_sService(RTL_CONSTASCII_USTRINGPARAM("ServiceName"));
         [ #  # ][ #  # ]
     997                 :          0 :                     aReportEngine.getNodeValue(s_sService) >>= sRet;
     998                 :          0 :                     return sRet;
     999 [ #  # ][ #  # ]:          0 :                 }
    1000 [ #  # ][ #  # ]:          0 :             }
    1001                 :            :         }
    1002                 :            :         else
    1003 [ #  # ][ #  # ]:          0 :             return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
    1004                 :            :     }
    1005                 :            :     else
    1006         [ #  # ]:          0 :         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
    1007         [ #  # ]:          0 :     return ::rtl::OUString();
    1008                 :            : }
    1009                 :            : // -----------------------------------------------------------------------------
    1010                 :            : //.........................................................................
    1011                 :            : }   // namespace dbtools
    1012                 :            : //.........................................................................
    1013                 :            : 
    1014                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10