summaryrefslogtreecommitdiff
path: root/connectivity/source/commontools/DateConversion.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/commontools/DateConversion.cxx')
-rw-r--r--connectivity/source/commontools/DateConversion.cxx51
1 files changed, 21 insertions, 30 deletions
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx
index 38f20af0926c..30e9a323dc12 100644
--- a/connectivity/source/commontools/DateConversion.cxx
+++ b/connectivity/source/commontools/DateConversion.cxx
@@ -33,7 +33,7 @@
#include <comphelper/types.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::connectivity;
@@ -62,7 +62,7 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal,
case DataType::BOOLEAN:
case DataType::TINYINT:
case DataType::SMALLINT:
- if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_BOOLEAN)
+ if (_rVal.getValueTypeClass() == css::uno::TypeClass_BOOLEAN)
{
if (::cppu::any2bool(_rVal))
aRet.append("1");
@@ -83,16 +83,7 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal,
{
OUString aTemp;
_rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp;
- sal_Int32 nIndex = sal_Int32(-2);
- static const OUStringLiteral sQuot(u"\'");
- do
- {
- nIndex += 2;
- nIndex = aTemp.indexOf(sQuot,nIndex);
- if(nIndex != -1)
- aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(), u"\'\'");
- } while (nIndex != -1);
-
+ aTemp = aTemp.replaceAll(u"\'", u"\'\'");
aRet.append(aTemp);
}
aRet.append("'");
@@ -113,14 +104,14 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal,
{
DateTime aDateTime;
bool bOk = false;
- if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE)
+ if (_rVal.getValueTypeClass() == css::uno::TypeClass_DOUBLE)
{
double nValue = 0.0;
_rVal >>= nValue;
aDateTime = DBTypeConversion::toDateTime(nValue);
bOk = true;
}
- else if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_STRING)
+ else if (_rVal.getValueTypeClass() == css::uno::TypeClass_STRING)
{
OUString sValue;
_rVal >>= sValue;
@@ -134,9 +125,9 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal,
// check if this is really a timestamp or only a date
if ( bOk )
{
- aRet.append("{ts '");
- aRet.append(DBTypeConversion::toDateTimeString(aDateTime));
- aRet.append("'}");
+ aRet.append("{ts '"
+ + DBTypeConversion::toDateTimeString(aDateTime)
+ + "'}");
break;
}
break;
@@ -145,14 +136,14 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal,
{
Date aDate;
bool bOk = false;
- if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE)
+ if (_rVal.getValueTypeClass() == css::uno::TypeClass_DOUBLE)
{
double nValue = 0.0;
_rVal >>= nValue;
aDate = DBTypeConversion::toDate(nValue);
bOk = true;
}
- else if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_STRING)
+ else if (_rVal.getValueTypeClass() == css::uno::TypeClass_STRING)
{
OUString sValue;
_rVal >>= sValue;
@@ -162,22 +153,22 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal,
else
bOk = _rVal >>= aDate;
OSL_ENSURE( bOk, "DBTypeConversion::toSQLString: _rVal is not date!");
- aRet.append("{d '");
- aRet.append(DBTypeConversion::toDateString(aDate));
- aRet.append("'}");
+ aRet.append("{d '"
+ + DBTypeConversion::toDateString(aDate)
+ + "'}");
} break;
case DataType::TIME:
{
css::util::Time aTime;
bool bOk = false;
- if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE)
+ if (_rVal.getValueTypeClass() == css::uno::TypeClass_DOUBLE)
{
double nValue = 0.0;
_rVal >>= nValue;
aTime = DBTypeConversion::toTime(nValue);
bOk = true;
}
- else if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_STRING)
+ else if (_rVal.getValueTypeClass() == css::uno::TypeClass_STRING)
{
OUString sValue;
_rVal >>= sValue;
@@ -187,9 +178,9 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal,
else
bOk = _rVal >>= aTime;
OSL_ENSURE( bOk,"DBTypeConversion::toSQLString: _rVal is not time!");
- aRet.append("{t '");
- aRet.append(DBTypeConversion::toTimeString(aTime));
- aRet.append("'}");
+ aRet.append("{t '"
+ + DBTypeConversion::toTimeString(aTime)
+ + "'}");
} break;
}
}
@@ -212,7 +203,7 @@ Date DBTypeConversion::getNULLDate(const Reference< XNumberFormatsSupplier > &xS
{
// get the null date
Date aDate;
- xSupplier->getNumberFormatSettings()->getPropertyValue("NullDate") >>= aDate;
+ xSupplier->getNumberFormatSettings()->getPropertyValue(u"NullDate"_ustr) >>= aDate;
return aDate;
}
catch ( const Exception& )
@@ -252,7 +243,7 @@ void DBTypeConversion::setValue(const Reference<XColumnUpdate>& xVariant,
if (xFormatProps.is())
{
css::lang::Locale loc;
- if (xFormatProps->getPropertyValue("Locale") >>= loc)
+ if (xFormatProps->getPropertyValue(u"Locale"_ustr) >>= loc)
nStandardKey = xFormatTypes->getStandardIndex(loc);
else
{
@@ -478,7 +469,7 @@ OUString DBTypeConversion::getFormattedValue(const Reference<XColumn>& xVariant,
{
Reference< XNumberFormatsSupplier > xSupplier( xFormatter->getNumberFormatsSupplier(), UNO_SET_THROW );
Reference< XPropertySet > xFormatterSettings( xSupplier->getNumberFormatSettings(), UNO_SET_THROW );
- OSL_VERIFY( xFormatterSettings->getPropertyValue("NullDate") >>= aFormatterNullDate );
+ OSL_VERIFY( xFormatterSettings->getPropertyValue(u"NullDate"_ustr) >>= aFormatterNullDate );
}
catch( const Exception& )
{