LibreOffice Module connectivity (master) 1
dbconversion.hxx
Go to the documentation of this file.
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/util/Date.hpp>
25
26namespace com::sun::star::uno { template <typename > class Reference; }
27
28namespace com::sun::star
29{
30 namespace lang
31 {
32 struct Locale;
33 }
34 namespace sdb
35 {
36 class XColumn;
37 class XColumnUpdate;
38 }
39 namespace beans
40 {
41 class XPropertySet;
42 }
43 namespace util
44 {
45 class XNumberFormatter;
46 class XNumberFormatsSupplier;
47 struct Time;
48 struct DateTime;
49 }
50 namespace script
51 {
52 class XTypeConverter;
53 }
54}
55
57{
58 OOO_DLLPUBLIC_DBTOOLS css::util::Date const & getStandardDate();
60 OOO_DLLPUBLIC_DBTOOLS void setValue(const css::uno::Reference< css::sdb::XColumnUpdate>& xVariant,
61 const css::uno::Reference< css::util::XNumberFormatter>& xFormatter,
62 const css::util::Date& rNullDate,
63 const OUString& rString,
64 sal_Int32 nKey,
65 sal_Int16 nFieldType,
66 sal_Int16 nKeyType);
67
69 OOO_DLLPUBLIC_DBTOOLS void setValue(const css::uno::Reference< css::sdb::XColumnUpdate>& xVariant,
70 const css::util::Date& rNullDate,
71 const double& rValue,
72 sal_Int16 nKeyType);
73
74 OOO_DLLPUBLIC_DBTOOLS double getValue( const css::uno::Reference< css::sdb::XColumn>& xVariant, const css::util::Date& rNullDate );
75
76 // get the columnvalue as string with a default format given by the column or a default format
77 // for the type
79 const css::uno::Reference< css::beans::XPropertySet>& _xColumn,
80 const css::uno::Reference< css::util::XNumberFormatter>& xFormatter,
81 const css::lang::Locale& _rLocale,
82 const css::util::Date& rNullDate);
83
85 const css::uno::Reference< css::sdb::XColumn>& _xColumn,
86 const css::uno::Reference< css::util::XNumberFormatter>& xFormatter,
87 const css::util::Date& rNullDate,
88 sal_Int32 nKey,
89 sal_Int16 nKeyType);
90
91 OOO_DLLPUBLIC_DBTOOLS css::util::Date toDate(double dVal, const css::util::Date& _rNullDate = getStandardDate());
92 OOO_DLLPUBLIC_DBTOOLS css::util::Date toDate(std::u16string_view _sSQLDate);
93 OOO_DLLPUBLIC_DBTOOLS css::util::Time toTime(double dVal, short nDigits = 9);
94 OOO_DLLPUBLIC_DBTOOLS css::util::Time toTime(std::u16string_view _sSQLDate);
95 OOO_DLLPUBLIC_DBTOOLS css::util::DateTime toDateTime(double dVal, const css::util::Date& _rNullDate = getStandardDate());
96 OOO_DLLPUBLIC_DBTOOLS css::util::DateTime toDateTime(const OUString& _sSQLDate);
97
98 OOO_DLLPUBLIC_DBTOOLS sal_Int64 getNsFromTime(const css::util::Time& rVal);
99
100 OOO_DLLPUBLIC_DBTOOLS sal_Int32 toDays(const css::util::Date& _rVal, const css::util::Date& _rNullDate = getStandardDate());
101
102 OOO_DLLPUBLIC_DBTOOLS double toDouble(const css::util::Date& rVal, const css::util::Date& _rNullDate = getStandardDate());
103 OOO_DLLPUBLIC_DBTOOLS double toDouble(const css::util::Time& rVal);
104 OOO_DLLPUBLIC_DBTOOLS double toDouble(const css::util::DateTime& rVal, const css::util::Date& _rNullDate = getStandardDate());
105
106 OOO_DLLPUBLIC_DBTOOLS css::util::Date toDate(sal_Int32 _nVal);
107 OOO_DLLPUBLIC_DBTOOLS css::util::Time toTime(sal_Int64 _nVal);
108
112 inline double toNullDate(const css::util::Date& _rNullDate, double _rVal) { return _rVal - toDays(_rNullDate); }
113
114 // return the date from the numberformatsupplier or the STANDARD_DATE (1900,1,1)
115 OOO_DLLPUBLIC_DBTOOLS css::util::Date getNULLDate(const css::uno::Reference< css::util::XNumberFormatsSupplier > &xSupplier);
116
117 // return the date in the format %04d-%02d-%02d
118 OOO_DLLPUBLIC_DBTOOLS OUString toDateString(const css::util::Date& rDate);
119 // return the time in the format %02d:%02d:%02d
120 OOO_DLLPUBLIC_DBTOOLS OUString toTimeStringS(const css::util::Time& rTime);
121 // return the time in the format %02d:%02d:%02d.%09d
122 OOO_DLLPUBLIC_DBTOOLS OUString toTimeString(const css::util::Time& rTime);
123 // return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d.%09d
124 OOO_DLLPUBLIC_DBTOOLS OUString toDateTimeString(const css::util::DateTime& _rDateTime);
125 // return the any in an sql standard format
126 OOO_DLLPUBLIC_DBTOOLS OUString toSQLString(sal_Int32 eType, const css::uno::Any& _rVal,
127 const css::uno::Reference< css::script::XTypeConverter >& _rxTypeConverter);
128
146 const OUString& _rSource,
147 OString& _rDest,
148 rtl_TextEncoding _eEncoding
149 );
150
175 const OUString& _rSource,
176 OString& _rDest,
177 sal_Int32 _nMaxLen,
178 rtl_TextEncoding _eEncoding
179 );
180
181} // namespace dbtools::DBTypeConversion
182
183#endif // INCLUDED_CONNECTIVITY_DBCONVERSION_HXX
184
185/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 script
#define OOO_DLLPUBLIC_DBTOOLS
class SAL_NO_VTABLE XPropertySet
OOO_DLLPUBLIC_DBTOOLS sal_Int64 getNsFromTime(const css::util::Time &rVal)
OOO_DLLPUBLIC_DBTOOLS OUString toTimeStringS(const css::util::Time &rTime)
OOO_DLLPUBLIC_DBTOOLS sal_Int32 convertUnicodeStringToLength(const OUString &_rSource, OString &_rDest, sal_Int32 _nMaxLen, rtl_TextEncoding _eEncoding)
converts a Unicode string into a 8-bit string, using the given encoding
Definition: dbtools2.cxx:915
OOO_DLLPUBLIC_DBTOOLS OUString getFormattedValue(const css::uno::Reference< css::beans::XPropertySet > &_xColumn, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const css::lang::Locale &_rLocale, const css::util::Date &rNullDate)
OOO_DLLPUBLIC_DBTOOLS OUString toTimeString(const css::util::Time &rTime)
OOO_DLLPUBLIC_DBTOOLS OUString toSQLString(sal_Int32 eType, const css::uno::Any &_rVal, const css::uno::Reference< css::script::XTypeConverter > &_rxTypeConverter)
OOO_DLLPUBLIC_DBTOOLS OUString toDateString(const css::util::Date &rDate)
OOO_DLLPUBLIC_DBTOOLS css::util::Date const & getStandardDate()
OOO_DLLPUBLIC_DBTOOLS void setValue(const css::uno::Reference< css::sdb::XColumnUpdate > &xVariant, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const css::util::Date &rNullDate, const OUString &rString, sal_Int32 nKey, sal_Int16 nFieldType, sal_Int16 nKeyType)
OOO_DLLPUBLIC_DBTOOLS double toDouble(const css::util::Date &rVal, const css::util::Date &_rNullDate=getStandardDate())
OOO_DLLPUBLIC_DBTOOLS double getValue(const css::uno::Reference< css::sdb::XColumn > &xVariant, const css::util::Date &rNullDate)
OOO_DLLPUBLIC_DBTOOLS css::util::Date toDate(double dVal, const css::util::Date &_rNullDate=getStandardDate())
OOO_DLLPUBLIC_DBTOOLS sal_Int32 convertUnicodeString(const OUString &_rSource, OString &_rDest, rtl_TextEncoding _eEncoding)
converts a Unicode string into a 8-bit string, using the given encoding
Definition: dbtools2.cxx:887
OOO_DLLPUBLIC_DBTOOLS OUString toDateTimeString(const css::util::DateTime &_rDateTime)
OOO_DLLPUBLIC_DBTOOLS css::util::Date getNULLDate(const css::uno::Reference< css::util::XNumberFormatsSupplier > &xSupplier)
OOO_DLLPUBLIC_DBTOOLS sal_Int32 toDays(const css::util::Date &_rVal, const css::util::Date &_rNullDate=getStandardDate())
OOO_DLLPUBLIC_DBTOOLS css::util::Time toTime(double dVal, short nDigits=9)
OOO_DLLPUBLIC_DBTOOLS css::util::DateTime toDateTime(double dVal, const css::util::Date &_rNullDate=getStandardDate())
double toNullDate(const css::util::Date &_rNullDate, double _rVal)
convert a double which is a date value relative to the standard db null date into a date value relati...
Reference