LCOV - code coverage report
Current view: top level - include/connectivity - dbconversion.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1 0.0 %
Date: 2014-04-14 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             : #ifndef INCLUDED_CONNECTIVITY_DBCONVERSION_HXX
      21             : #define INCLUDED_CONNECTIVITY_DBCONVERSION_HXX
      22             : 
      23             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      24             : #include <com/sun/star/util/Date.hpp>
      25             : #include <com/sun/star/uno/Reference.hxx>
      26             : #include <connectivity/dbtoolsdllapi.hxx>
      27             : 
      28             : // forward declarations
      29             : namespace com
      30             : {
      31             :     namespace sun
      32             :     {
      33             :         namespace star
      34             :         {
      35             :             namespace lang
      36             :             {
      37             :                 struct Locale;
      38             :             }
      39             :             namespace sdb
      40             :             {
      41             :                 class XColumn;
      42             :                 class XColumnUpdate;
      43             :             }
      44             :             namespace sdbc
      45             :             {
      46             :                 class SQLException;
      47             :             }
      48             :             namespace beans
      49             :             {
      50             :                 class XPropertySet;
      51             :             }
      52             :             namespace util
      53             :             {
      54             :                 class XNumberFormatter;
      55             :                 class XNumberFormatsSupplier;
      56             :                 struct Time;
      57             :                 struct DateTime;
      58             :             }
      59             :             namespace script
      60             :             {
      61             :                 class XTypeConverter;
      62             :             }
      63             :         }
      64             :     }
      65             : }
      66             : 
      67             : 
      68             : namespace dbtools
      69             : {
      70             : 
      71             : 
      72             :     class OOO_DLLPUBLIC_DBTOOLS DBTypeConversion
      73             :     {
      74             :     public:
      75             :         static ::com::sun::star::util::Date getStandardDate();
      76             :         static void setValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate>& xVariant,
      77             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& xFormatter,
      78             :                                     const ::com::sun::star::util::Date& rNullDate,
      79             :                                     const OUString& rString,
      80             :                                     sal_Int32 nKey,
      81             :                                     sal_Int16 nFieldType,
      82             :                                     sal_Int16 nKeyType) throw(::com::sun::star::lang::IllegalArgumentException);
      83             : 
      84             :         static void setValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate>& xVariant,
      85             :                              const ::com::sun::star::util::Date& rNullDate,
      86             :                              const double& rValue,
      87             :                              sal_Int16 nKeyType) throw(::com::sun::star::lang::IllegalArgumentException);
      88             : 
      89             :         static double getValue( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& xVariant, const ::com::sun::star::util::Date& rNullDate );
      90             : 
      91             :         // get the columnvalue as string with a default format given by the column or a default format
      92             :         // for the type
      93             :         static OUString getFormattedValue(
      94             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
      95             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& xFormatter,
      96             :                                         const ::com::sun::star::lang::Locale& _rLocale,
      97             :                                         const ::com::sun::star::util::Date& rNullDate);
      98             : 
      99             :         static OUString getFormattedValue(
     100             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _xColumn,
     101             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& xFormatter,
     102             :                                         const ::com::sun::star::util::Date& rNullDate,
     103             :                                         sal_Int32 nKey,
     104             :                                         sal_Int16 nKeyType);
     105             : 
     106             :         static ::com::sun::star::util::Date     toDate(double dVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
     107             :         static ::com::sun::star::util::Date     toDate(const OUString& _sSQLDate);
     108             :         static ::com::sun::star::util::Time     toTime(double dVal, short nDigits = 9);
     109             :         static ::com::sun::star::util::Time     toTime(const OUString& _sSQLDate);
     110             :         static ::com::sun::star::util::DateTime toDateTime(double dVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
     111             :         static ::com::sun::star::util::DateTime toDateTime(const OUString& _sSQLDate);
     112             : 
     113             :         static sal_Int64 getNsFromTime(const ::com::sun::star::util::Time& rVal);
     114             : 
     115             :         static sal_Int32 toDays(const ::com::sun::star::util::Date& _rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
     116             : 
     117             :         static double   toDouble(const ::com::sun::star::util::Date& rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
     118             :         static double   toDouble(const ::com::sun::star::util::Time& rVal);
     119             :         static double   toDouble(const ::com::sun::star::util::DateTime& rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
     120             : 
     121             :         static ::com::sun::star::util::Date toDate(sal_Int32 _nVal);
     122             :         static ::com::sun::star::util::Time toTime(sal_Int64 _nVal);
     123             : 
     124             :         /** convert a double which is a date value relative to a given fixed date into a date value relative
     125             :             to the standard db null date.
     126             :         */
     127             :         static double toStandardDbDate(const ::com::sun::star::util::Date& _rNullDate, double _rVal) { return _rVal + toDays(_rNullDate); }
     128             :         /** convert a double which is a date value relative to the standard db null date into a date value relative
     129             :             to a given fixed date.
     130             :         */
     131           0 :         static double toNullDate(const ::com::sun::star::util::Date& _rNullDate, double _rVal) { return _rVal - toDays(_rNullDate); }
     132             : 
     133             :         // return the date from the numberformatsupplier or the STANDARD_DATE (1900,1,1)
     134             :         static ::com::sun::star::util::Date getNULLDate(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > &xSupplier);
     135             : 
     136             :         // return the date in the format %04d-%02d-%02d
     137             :         static OUString toDateString(const ::com::sun::star::util::Date& rDate);
     138             :         // return the time in the format %02d:%02d:%02d
     139             :         static OUString toTimeStringS(const ::com::sun::star::util::Time& rTime);
     140             :         // return the time in the format %02d:%02d:%02d.%09d
     141             :         static OUString toTimeString(const ::com::sun::star::util::Time& rTime);
     142             :         // return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d.%09d
     143             :         static OUString toDateTimeString(const ::com::sun::star::util::DateTime& _rDateTime);
     144             :         // return the any in an sql standard format
     145             :         static OUString toSQLString(sal_Int32 eType, const ::com::sun::star::uno::Any& _rVal, bool bQuote,
     146             :             const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >&  _rxTypeConverter);
     147             : 
     148             :         /** converts a Unicode string into a 8-bit string, using the given encoding
     149             : 
     150             :             @param _rSource
     151             :                 the source string to convert
     152             :             @param _rDest
     153             :                 the destination string
     154             :             @param _eEncoding
     155             :                 the encoding to use for the conversion
     156             : 
     157             :             @throws com::sun::star::sdbc::SQLException
     158             :                 if the given string contains characters which are not convertible using the given encoding
     159             :                 The SQLState of the exception will be set to 22018 ("Invalid character value for cast specification")
     160             : 
     161             :             @return
     162             :                 the length of the converted string
     163             :         */
     164             :         static sal_Int32 convertUnicodeString(
     165             :             const OUString& _rSource,
     166             :             OString&  _rDest,
     167             :             rtl_TextEncoding _eEncoding
     168             :         )
     169             :             SAL_THROW((::com::sun::star::sdbc::SQLException));
     170             : 
     171             :         /** converts a Unicode string into a 8-bit string, using the given encoding
     172             : 
     173             :             @param _rSource
     174             :                 the source string to convert
     175             : 
     176             :             @param _rDest
     177             :                 the destination string
     178             : 
     179             :             @param _nMaxLen
     180             :                 the maximum length of the destination string
     181             : 
     182             :             @param _eEncoding
     183             :                 the encoding to use for the conversion
     184             : 
     185             :             @throws com::sun::star::sdbc::SQLException
     186             :                 if convertUnicodeString, which is called internally, throws such an exception
     187             : 
     188             :             @throws com::sun::star::sdbc::SQLException
     189             :                 if the conversion results in a string which is longer than _nMaxLen
     190             : 
     191             :             @return
     192             :                 the length of the converted string
     193             :         */
     194             :         static sal_Int32 convertUnicodeStringToLength(
     195             :             const OUString& _rSource,
     196             :             OString&  _rDest,
     197             :             sal_Int32 _nMaxLen,
     198             :             rtl_TextEncoding _eEncoding
     199             :        )
     200             :             SAL_THROW((::com::sun::star::sdbc::SQLException));
     201             :     };
     202             : 
     203             : 
     204             : }   // namespace dbtools
     205             : 
     206             : 
     207             : #endif // INCLUDED_CONNECTIVITY_DBCONVERSION_HXX
     208             : 
     209             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10