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

Generated by: LCOV version 1.10