LCOV - code coverage report
Current view: top level - sw/source/core/uibase/fldui - xfldui.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 47 0.0 %
Date: 2014-04-11 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>
      33             : #include <view.hxx>
      34             : #include <swmodule.hxx>
      35             : 
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::container;
      38             : using namespace ::com::sun::star::lang;
      39             : using namespace ::com::sun::star::sdb;
      40             : using namespace ::com::sun::star::sdbc;
      41             : using namespace ::com::sun::star::sdbcx;
      42             : using namespace ::com::sun::star::beans;
      43             : 
      44             : // This file contains all routines of the fldui directory, which must compile
      45             : // with exceptions. So we can reduce the code of the other files, which don't
      46             : // need any exception handling.
      47             : 
      48             : /*--------------------------------------------------------------------
      49             :      Description: Is the database field numeric?
      50             :      remark: in case of error sal_True is returned
      51             :  --------------------------------------------------------------------*/
      52             : 
      53           0 : sal_Bool SwFldMgr::IsDBNumeric( const OUString& rDBName, const OUString& rTblQryName,
      54             :                             sal_Bool bIsTable, const OUString& rFldName)
      55             : {
      56           0 :     sal_Bool bNumeric = sal_True;
      57             : 
      58           0 :     SwNewDBMgr* pDBMgr = pWrtShell ? pWrtShell->GetNewDBMgr() :
      59           0 :                             ::GetActiveView()->GetWrtShell().GetNewDBMgr();
      60             : 
      61           0 :     OUString sSource(rDBName);
      62             :     Reference< XConnection> xConnection =
      63           0 :                     pDBMgr->RegisterConnection(sSource);
      64             : 
      65           0 :     if( !xConnection.is() )
      66           0 :         return bNumeric;
      67             : 
      68           0 :     Reference<XColumnsSupplier> xColsSupplier;
      69           0 :     if(bIsTable)
      70             :     {
      71           0 :         Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
      72           0 :         if(xTSupplier.is())
      73             :         {
      74           0 :             Reference<XNameAccess> xTbls = xTSupplier->getTables();
      75             :             OSL_ENSURE(xTbls->hasByName(rTblQryName), "table not available anymore?");
      76             :             try
      77             :             {
      78           0 :                 Any aTable = xTbls->getByName(rTblQryName);
      79           0 :                 Reference<XPropertySet> xPropSet;
      80           0 :                 aTable >>= xPropSet;
      81           0 :                 xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
      82             :             }
      83           0 :             catch (const Exception&)
      84             :             {
      85           0 :             }
      86           0 :         }
      87             :     }
      88             :     else
      89             :     {
      90           0 :         Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
      91           0 :         if(xQSupplier.is())
      92             :         {
      93           0 :             Reference<XNameAccess> xQueries = xQSupplier->getQueries();
      94             :             OSL_ENSURE(xQueries->hasByName(rTblQryName), "table not available anymore?");
      95             :             try
      96             :             {
      97           0 :                 Any aQuery = xQueries->getByName(rTblQryName);
      98           0 :                 Reference<XPropertySet> xPropSet;
      99           0 :                 aQuery >>= xPropSet;
     100           0 :                 xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
     101             :             }
     102           0 :             catch (const Exception&)
     103             :             {
     104           0 :             }
     105           0 :         }
     106             :     }
     107             : 
     108           0 :     if(xColsSupplier.is())
     109             :     {
     110           0 :         Reference <XNameAccess> xCols;
     111             :         try
     112             :         {
     113           0 :             xCols = xColsSupplier->getColumns();
     114             :         }
     115           0 :         catch (const Exception&)
     116             :         {
     117             :             OSL_FAIL("Exception in getColumns()");
     118             :         }
     119           0 :         if(xCols.is() && xCols->hasByName(rFldName))
     120             :         {
     121           0 :             Any aCol = xCols->getByName(rFldName);
     122           0 :             Reference <XPropertySet> xCol;
     123           0 :             aCol >>= xCol;
     124           0 :             Any aType = xCol->getPropertyValue("Type");
     125           0 :             sal_Int32 eDataType = 0;
     126           0 :             aType >>= eDataType;
     127           0 :             switch(eDataType)
     128             :             {
     129             :                 case DataType::BIT:
     130             :                 case DataType::BOOLEAN:
     131             :                 case DataType::TINYINT:
     132             :                 case DataType::SMALLINT:
     133             :                 case DataType::INTEGER:
     134             :                 case DataType::BIGINT:
     135             :                 case DataType::FLOAT:
     136             :                 case DataType::REAL:
     137             :                 case DataType::DOUBLE:
     138             :                 case DataType::NUMERIC:
     139             :                 case DataType::DECIMAL:
     140             :                 case DataType::DATE:
     141             :                 case DataType::TIME:
     142             :                 case DataType::TIMESTAMP:
     143           0 :                     break;
     144             : 
     145             :                 case DataType::BINARY:
     146             :                 case DataType::VARBINARY:
     147             :                 case DataType::LONGVARBINARY:
     148             :                 case DataType::SQLNULL:
     149             :                 case DataType::OTHER:
     150             :                 case DataType::OBJECT:
     151             :                 case DataType::DISTINCT:
     152             :                 case DataType::STRUCT:
     153             :                 case DataType::ARRAY:
     154             :                 case DataType::BLOB:
     155             :                 case DataType::CLOB:
     156             :                 case DataType::REF:
     157             :                 case DataType::CHAR:
     158             :                 case DataType::VARCHAR:
     159             :                 case DataType::LONGVARCHAR:
     160             :                 default:
     161           0 :                     bNumeric = sal_False;
     162           0 :             }
     163           0 :         }
     164             :     }
     165           0 :     return bNumeric;
     166             : }
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10