LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/fldui - xfldui.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 47 0.0 %
Date: 2012-12-27 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <osl/diagnose.h>
      21             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      22             : #include <com/sun/star/container/XNameAccess.hpp>
      23             : #include <com/sun/star/sdbc/XDataSource.hpp>
      24             : #include <com/sun/star/sdbc/DataType.hpp>
      25             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      26             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      27             : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <comphelper/processfactory.hxx>
      30             : #include <fldmgr.hxx>
      31             : #include <dbmgr.hxx>
      32             : #include <wrtsh.hxx>        // active window
      33             : #include <view.hxx>
      34             : #include <swmodule.hxx>
      35             : 
      36             : 
      37             : using namespace ::com::sun::star::uno;
      38             : using namespace ::com::sun::star::container;
      39             : using namespace ::com::sun::star::lang;
      40             : using namespace ::com::sun::star::sdb;
      41             : using namespace ::com::sun::star::sdbc;
      42             : using namespace ::com::sun::star::sdbcx;
      43             : using namespace ::com::sun::star::beans;
      44             : 
      45             : 
      46             : // ---------------------------------------------------------------------------
      47             : // This file contains all routines of the fldui directory, which must compile
      48             : // with exceptions. So we can reduce the code of the other files, which don't
      49             : // need any exception handling.
      50             : // ---------------------------------------------------------------------------
      51             : 
      52             : /*--------------------------------------------------------------------
      53             :      Description: Is the database field numeric?
      54             :      remark: in case of error sal_True is returned
      55             :  --------------------------------------------------------------------*/
      56             : 
      57           0 : sal_Bool SwFldMgr::IsDBNumeric( const String& rDBName, const String& rTblQryName,
      58             :                             sal_Bool bIsTable, const String& rFldName)
      59             : {
      60           0 :     sal_Bool bNumeric = sal_True;
      61             : 
      62           0 :     SwNewDBMgr* pDBMgr = pWrtShell ? pWrtShell->GetNewDBMgr() :
      63           0 :                             ::GetActiveView()->GetWrtShell().GetNewDBMgr();
      64             : 
      65           0 :     ::rtl::OUString sSource(rDBName);
      66             :     Reference< XConnection> xConnection =
      67           0 :                     pDBMgr->RegisterConnection(sSource);
      68             : 
      69           0 :     if( !xConnection.is() )
      70           0 :         return bNumeric;
      71             : 
      72           0 :     Reference<XColumnsSupplier> xColsSupplier;
      73           0 :     if(bIsTable)
      74             :     {
      75           0 :         Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
      76           0 :         if(xTSupplier.is())
      77             :         {
      78           0 :             Reference<XNameAccess> xTbls = xTSupplier->getTables();
      79             :             OSL_ENSURE(xTbls->hasByName(rTblQryName), "table not available anymore?");
      80             :             try
      81             :             {
      82           0 :                 Any aTable = xTbls->getByName(rTblQryName);
      83           0 :                 Reference<XPropertySet> xPropSet;
      84           0 :                 aTable >>= xPropSet;
      85           0 :                 xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
      86             :             }
      87           0 :             catch (const Exception&)
      88             :             {
      89           0 :             }
      90           0 :         }
      91             :     }
      92             :     else
      93             :     {
      94           0 :         Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
      95           0 :         if(xQSupplier.is())
      96             :         {
      97           0 :             Reference<XNameAccess> xQueries = xQSupplier->getQueries();
      98             :             OSL_ENSURE(xQueries->hasByName(rTblQryName), "table not available anymore?");
      99             :             try
     100             :             {
     101           0 :                 Any aQuery = xQueries->getByName(rTblQryName);
     102           0 :                 Reference<XPropertySet> xPropSet;
     103           0 :                 aQuery >>= xPropSet;
     104           0 :                 xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
     105             :             }
     106           0 :             catch (const Exception&)
     107             :             {
     108           0 :             }
     109           0 :         }
     110             :     }
     111             : 
     112           0 :     if(xColsSupplier.is())
     113             :     {
     114           0 :         Reference <XNameAccess> xCols;
     115             :         try
     116             :         {
     117           0 :             xCols = xColsSupplier->getColumns();
     118             :         }
     119           0 :         catch (const Exception&)
     120             :         {
     121             :             OSL_FAIL("Exception in getColumns()");
     122             :         }
     123           0 :         if(xCols.is() && xCols->hasByName(rFldName))
     124             :         {
     125           0 :             Any aCol = xCols->getByName(rFldName);
     126           0 :             Reference <XPropertySet> xCol;
     127           0 :             aCol >>= xCol;
     128           0 :             Any aType = xCol->getPropertyValue(rtl::OUString("Type"));
     129           0 :             sal_Int32 eDataType = 0;
     130           0 :             aType >>= eDataType;
     131           0 :             switch(eDataType)
     132             :             {
     133             :                 case DataType::BIT:
     134             :                 case DataType::BOOLEAN:
     135             :                 case DataType::TINYINT:
     136             :                 case DataType::SMALLINT:
     137             :                 case DataType::INTEGER:
     138             :                 case DataType::BIGINT:
     139             :                 case DataType::FLOAT:
     140             :                 case DataType::REAL:
     141             :                 case DataType::DOUBLE:
     142             :                 case DataType::NUMERIC:
     143             :                 case DataType::DECIMAL:
     144             :                 case DataType::DATE:
     145             :                 case DataType::TIME:
     146             :                 case DataType::TIMESTAMP:
     147           0 :                     break;
     148             : 
     149             :                 case DataType::BINARY:
     150             :                 case DataType::VARBINARY:
     151             :                 case DataType::LONGVARBINARY:
     152             :                 case DataType::SQLNULL:
     153             :                 case DataType::OTHER:
     154             :                 case DataType::OBJECT:
     155             :                 case DataType::DISTINCT:
     156             :                 case DataType::STRUCT:
     157             :                 case DataType::ARRAY:
     158             :                 case DataType::BLOB:
     159             :                 case DataType::CLOB:
     160             :                 case DataType::REF:
     161             :                 case DataType::CHAR:
     162             :                 case DataType::VARCHAR:
     163             :                 case DataType::LONGVARCHAR:
     164             :                 default:
     165           0 :                     bNumeric = sal_False;
     166           0 :             }
     167           0 :         }
     168             :     }
     169           0 :     return bNumeric;
     170             : }
     171             : 
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10