LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - xfldui.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 47 0.0 %
Date: 2012-08-25 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 106 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <osl/diagnose.h>
      30                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      32                 :            : #include <com/sun/star/sdbc/XDataSource.hpp>
      33                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      34                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      35                 :            : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      36                 :            : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      37                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      38                 :            : #include <comphelper/processfactory.hxx>
      39                 :            : #include <fldmgr.hxx>
      40                 :            : #include <dbmgr.hxx>
      41                 :            : #include <wrtsh.hxx>        // active window
      42                 :            : #include <view.hxx>
      43                 :            : #include <swmodule.hxx>
      44                 :            : 
      45                 :            : 
      46                 :            : using namespace ::com::sun::star::uno;
      47                 :            : using namespace ::com::sun::star::container;
      48                 :            : using namespace ::com::sun::star::lang;
      49                 :            : using namespace ::com::sun::star::sdb;
      50                 :            : using namespace ::com::sun::star::sdbc;
      51                 :            : using namespace ::com::sun::star::sdbcx;
      52                 :            : using namespace ::com::sun::star::beans;
      53                 :            : 
      54                 :            : 
      55                 :            : // ---------------------------------------------------------------------------
      56                 :            : // This file contains all routines of the fldui directory, which must compile
      57                 :            : // with exceptions. So we can reduce the code of the other files, which don't
      58                 :            : // need any exception handling.
      59                 :            : // ---------------------------------------------------------------------------
      60                 :            : 
      61                 :            : /*--------------------------------------------------------------------
      62                 :            :      Description: Is the database field numeric?
      63                 :            :      remark: in case of error sal_True is returned
      64                 :            :  --------------------------------------------------------------------*/
      65                 :            : 
      66                 :          0 : sal_Bool SwFldMgr::IsDBNumeric( const String& rDBName, const String& rTblQryName,
      67                 :            :                             sal_Bool bIsTable, const String& rFldName)
      68                 :            : {
      69                 :          0 :     sal_Bool bNumeric = sal_True;
      70                 :            : 
      71                 :          0 :     SwNewDBMgr* pDBMgr = pWrtShell ? pWrtShell->GetNewDBMgr() :
      72 [ #  # ][ #  # ]:          0 :                             ::GetActiveView()->GetWrtShell().GetNewDBMgr();
         [ #  # ][ #  # ]
      73                 :            : 
      74         [ #  # ]:          0 :     ::rtl::OUString sSource(rDBName);
      75                 :            :     Reference< XConnection> xConnection =
      76         [ #  # ]:          0 :                     pDBMgr->RegisterConnection(sSource);
      77                 :            : 
      78         [ #  # ]:          0 :     if( !xConnection.is() )
      79                 :          0 :         return bNumeric;
      80                 :            : 
      81                 :          0 :     Reference<XColumnsSupplier> xColsSupplier;
      82         [ #  # ]:          0 :     if(bIsTable)
      83                 :            :     {
      84         [ #  # ]:          0 :         Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
      85         [ #  # ]:          0 :         if(xTSupplier.is())
      86                 :            :         {
      87 [ #  # ][ #  # ]:          0 :             Reference<XNameAccess> xTbls = xTSupplier->getTables();
      88                 :            :             OSL_ENSURE(xTbls->hasByName(rTblQryName), "table not available anymore?");
      89                 :            :             try
      90                 :            :             {
      91 [ #  # ][ #  # ]:          0 :                 Any aTable = xTbls->getByName(rTblQryName);
                 [ #  # ]
      92                 :          0 :                 Reference<XPropertySet> xPropSet;
      93         [ #  # ]:          0 :                 aTable >>= xPropSet;
      94 [ #  # ][ #  # ]:          0 :                 xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
                 [ #  # ]
      95                 :            :             }
      96         [ #  # ]:          0 :             catch (const Exception&)
      97                 :            :             {
      98                 :          0 :             }
      99                 :          0 :         }
     100                 :            :     }
     101                 :            :     else
     102                 :            :     {
     103         [ #  # ]:          0 :         Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
     104         [ #  # ]:          0 :         if(xQSupplier.is())
     105                 :            :         {
     106 [ #  # ][ #  # ]:          0 :             Reference<XNameAccess> xQueries = xQSupplier->getQueries();
     107                 :            :             OSL_ENSURE(xQueries->hasByName(rTblQryName), "table not available anymore?");
     108                 :            :             try
     109                 :            :             {
     110 [ #  # ][ #  # ]:          0 :                 Any aQuery = xQueries->getByName(rTblQryName);
                 [ #  # ]
     111                 :          0 :                 Reference<XPropertySet> xPropSet;
     112         [ #  # ]:          0 :                 aQuery >>= xPropSet;
     113 [ #  # ][ #  # ]:          0 :                 xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
                 [ #  # ]
     114                 :            :             }
     115         [ #  # ]:          0 :             catch (const Exception&)
     116                 :            :             {
     117                 :          0 :             }
     118                 :          0 :         }
     119                 :            :     }
     120                 :            : 
     121         [ #  # ]:          0 :     if(xColsSupplier.is())
     122                 :            :     {
     123                 :          0 :         Reference <XNameAccess> xCols;
     124                 :            :         try
     125                 :            :         {
     126 [ #  # ][ #  # ]:          0 :             xCols = xColsSupplier->getColumns();
         [ #  # ][ #  # ]
     127                 :            :         }
     128         [ #  # ]:          0 :         catch (const Exception&)
     129                 :            :         {
     130                 :            :             OSL_FAIL("Exception in getColumns()");
     131                 :            :         }
     132 [ #  # ][ #  # ]:          0 :         if(xCols.is() && xCols->hasByName(rFldName))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     133                 :            :         {
     134 [ #  # ][ #  # ]:          0 :             Any aCol = xCols->getByName(rFldName);
                 [ #  # ]
     135                 :          0 :             Reference <XPropertySet> xCol;
     136         [ #  # ]:          0 :             aCol >>= xCol;
     137 [ #  # ][ #  # ]:          0 :             Any aType = xCol->getPropertyValue(rtl::OUString("Type"));
     138                 :          0 :             sal_Int32 eDataType = 0;
     139                 :          0 :             aType >>= eDataType;
     140         [ #  # ]:          0 :             switch(eDataType)
     141                 :            :             {
     142                 :            :                 case DataType::BIT:
     143                 :            :                 case DataType::BOOLEAN:
     144                 :            :                 case DataType::TINYINT:
     145                 :            :                 case DataType::SMALLINT:
     146                 :            :                 case DataType::INTEGER:
     147                 :            :                 case DataType::BIGINT:
     148                 :            :                 case DataType::FLOAT:
     149                 :            :                 case DataType::REAL:
     150                 :            :                 case DataType::DOUBLE:
     151                 :            :                 case DataType::NUMERIC:
     152                 :            :                 case DataType::DECIMAL:
     153                 :            :                 case DataType::DATE:
     154                 :            :                 case DataType::TIME:
     155                 :            :                 case DataType::TIMESTAMP:
     156                 :          0 :                     break;
     157                 :            : 
     158                 :            :                 case DataType::BINARY:
     159                 :            :                 case DataType::VARBINARY:
     160                 :            :                 case DataType::LONGVARBINARY:
     161                 :            :                 case DataType::SQLNULL:
     162                 :            :                 case DataType::OTHER:
     163                 :            :                 case DataType::OBJECT:
     164                 :            :                 case DataType::DISTINCT:
     165                 :            :                 case DataType::STRUCT:
     166                 :            :                 case DataType::ARRAY:
     167                 :            :                 case DataType::BLOB:
     168                 :            :                 case DataType::CLOB:
     169                 :            :                 case DataType::REF:
     170                 :            :                 case DataType::CHAR:
     171                 :            :                 case DataType::VARCHAR:
     172                 :            :                 case DataType::LONGVARCHAR:
     173                 :            :                 default:
     174                 :          0 :                     bNumeric = sal_False;
     175                 :          0 :             }
     176                 :          0 :         }
     177                 :            :     }
     178                 :          0 :     return bNumeric;
     179                 :            : }
     180                 :            : 
     181                 :            : 
     182                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10