summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-23 21:55:13 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-23 21:55:13 +0100
commit9e9e1181d4bda2f836cd9c23832142325d3229c1 (patch)
treedc9a559956fac6b3500e19798aff89014639bde3
parent60336fbefa1b29b0bfa8d89eec240a483b438c06 (diff)
dba34b: #i115250# DBTypeConversion::getValue: do not use the target format to determine how to obtain the column value, instead, use the column type
-rw-r--r--connectivity/inc/connectivity/dbconversion.hxx3
-rw-r--r--connectivity/inc/connectivity/virtualdbtools.hxx3
-rw-r--r--connectivity/source/commontools/DateConversion.cxx63
-rw-r--r--connectivity/source/simpledbt/staticdbtools_s.cxx4
-rw-r--r--connectivity/source/simpledbt/staticdbtools_s.hxx3
-rw-r--r--svx/source/fmcomp/gridcell.cxx4
-rw-r--r--svx/source/inc/typeconversionclient.hxx5
7 files changed, 41 insertions, 44 deletions
diff --git a/connectivity/inc/connectivity/dbconversion.hxx b/connectivity/inc/connectivity/dbconversion.hxx
index 5bf8b734e5d0..75c491e505e6 100644
--- a/connectivity/inc/connectivity/dbconversion.hxx
+++ b/connectivity/inc/connectivity/dbconversion.hxx
@@ -98,8 +98,7 @@ namespace dbtools
const double& rValue,
sal_Int16 nKeyType) throw(::com::sun::star::lang::IllegalArgumentException);
- static double getValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& xVariant, const ::com::sun::star::util::Date& rNullDate,
- sal_Int16 nKeyType);
+ static double getValue( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& xVariant, const ::com::sun::star::util::Date& rNullDate );
// get the columnvalue as string with a default format given by the column or a default format
// for the type
diff --git a/connectivity/inc/connectivity/virtualdbtools.hxx b/connectivity/inc/connectivity/virtualdbtools.hxx
index 67c3e8e07f50..1ad4c1d7d77d 100644
--- a/connectivity/inc/connectivity/virtualdbtools.hxx
+++ b/connectivity/inc/connectivity/virtualdbtools.hxx
@@ -256,8 +256,7 @@ namespace connectivity
virtual double getValue(
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
- const ::com::sun::star::util::Date& rNullDate,
- sal_Int16 nKeyType) const = 0;
+ const ::com::sun::star::util::Date& rNullDate ) const = 0;
virtual ::rtl::OUString getFormattedValue(
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx
index 3999494c3d39..a701b3b01570 100644
--- a/connectivity/source/commontools/DateConversion.cxx
+++ b/connectivity/source/commontools/DateConversion.cxx
@@ -43,6 +43,7 @@
#include "diagnose_ex.h"
#include <comphelper/numbers.hxx>
#include <rtl/ustrbuf.hxx>
+#include <tools/diagnose_ex.h>
using namespace ::connectivity;
@@ -365,46 +366,49 @@ void DBTypeConversion::setValue(const Reference<XColumnUpdate>& xVariant,
}
//------------------------------------------------------------------------------
-double DBTypeConversion::getValue(const Reference<XColumn>& xVariant,
- const Date& rNullDate,
- sal_Int16 nKeyType)
+double DBTypeConversion::getValue( const Reference< XColumn >& i_column, const Date& i_relativeToNullDate )
{
try
{
- switch (nKeyType & ~NumberFormat::DEFINED)
+ const Reference< XPropertySet > xProp( i_column, UNO_QUERY_THROW );
+
+ const sal_Int32 nColumnType = ::comphelper::getINT32( xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TYPE ) ) );
+ switch ( nColumnType )
{
- case NumberFormat::DATE:
- return toDouble( xVariant->getDate(), rNullDate);
- case NumberFormat::DATETIME:
- return toDouble(xVariant->getTimestamp(),rNullDate);
- case NumberFormat::TIME:
- return toDouble(xVariant->getTime());
- default:
+ case DataType::DATE:
+ return toDouble( i_column->getDate(), i_relativeToNullDate );
+
+ case DataType::TIME:
+ return toDouble( i_column->getTime() );
+
+ case DataType::TIMESTAMP:
+ return toDouble( i_column->getTimestamp(), i_relativeToNullDate );
+
+ default:
{
- Reference<XPropertySet> xProp(xVariant,UNO_QUERY);
- if ( xProp.is()
- && xProp->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSIGNED))
- && !::comphelper::getBOOL(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSIGNED))) )
+ sal_Bool bIsSigned = sal_True;
+ OSL_VERIFY( xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_ISSIGNED ) ) >>= bIsSigned );
+ if ( !bIsSigned )
{
- switch (::comphelper::getINT32(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ switch ( nColumnType)
{
case DataType::TINYINT:
- return static_cast<double>(static_cast<sal_uInt8>(xVariant->getByte()));
+ return static_cast<double>(static_cast<sal_uInt8>(i_column->getByte()));
case DataType::SMALLINT:
- return static_cast<double>(static_cast<sal_uInt16>(xVariant->getShort()));
+ return static_cast<double>(static_cast<sal_uInt16>(i_column->getShort()));
case DataType::INTEGER:
- return static_cast<double>(static_cast<sal_uInt32>(xVariant->getInt()));
+ return static_cast<double>(static_cast<sal_uInt32>(i_column->getInt()));
case DataType::BIGINT:
- return static_cast<double>(static_cast<sal_uInt64>(xVariant->getLong()));
+ return static_cast<double>(static_cast<sal_uInt64>(i_column->getLong()));
}
}
-
- return xVariant->getDouble();
}
+ return i_column->getDouble();
}
}
- catch(const Exception& )
+ catch( const Exception& )
{
+ DBG_UNHANDLED_EXCEPTION();
return 0.0;
}
}
@@ -462,23 +466,20 @@ double DBTypeConversion::getValue(const Reference<XColumn>& xVariant,
case NumberFormat::DATETIME:
{
// get a value which represents the given date, relative to the given null date
- double fValue = getValue(xVariant, rNullDate, nKeyType);
+ double fValue = getValue( xVariant, rNullDate );
if ( !xVariant->wasNull() )
{
// get the null date of the formatter
Date aFormatterNullDate( rNullDate );
try
{
- Reference< XPropertySet > xFormatterSettings;
- Reference< XNumberFormatsSupplier > xSupplier( xFormatter->getNumberFormatsSupplier( ) );
- if ( xSupplier.is() )
- xFormatterSettings = xSupplier->getNumberFormatSettings();
- if ( xFormatterSettings.is() )
- xFormatterSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NullDate" ) ) ) >>= aFormatterNullDate;
+ Reference< XNumberFormatsSupplier > xSupplier( xFormatter->getNumberFormatsSupplier(), UNO_SET_THROW );
+ Reference< XPropertySet > xFormatterSettings( xSupplier->getNumberFormatSettings(), UNO_SET_THROW );
+ OSL_VERIFY( xFormatterSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NullDate" ) ) ) >>= aFormatterNullDate );
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "DBTypeConversion::getFormattedValue: caught an exception while retrieving the formatter's NullDate!" );
+ DBG_UNHANDLED_EXCEPTION();
}
// get a value which represents the given date, relative to the null date of the formatter
fValue -= toDays( rNullDate, aFormatterNullDate );
diff --git a/connectivity/source/simpledbt/staticdbtools_s.cxx b/connectivity/source/simpledbt/staticdbtools_s.cxx
index 203356ce9ce2..36f9478a3312 100644
--- a/connectivity/source/simpledbt/staticdbtools_s.cxx
+++ b/connectivity/source/simpledbt/staticdbtools_s.cxx
@@ -61,9 +61,9 @@ namespace connectivity
}
//----------------------------------------------------------------
- double ODataAccessStaticTools::getValue(const Reference< XColumn>& _rxVariant, const Date& rNullDate, sal_Int16 nKeyType) const
+ double ODataAccessStaticTools::getValue(const Reference< XColumn>& _rxVariant, const Date& rNullDate ) const
{
- return ::dbtools::DBTypeConversion::getValue(_rxVariant, rNullDate, nKeyType);
+ return ::dbtools::DBTypeConversion::getValue( _rxVariant, rNullDate );
}
//----------------------------------------------------------------
diff --git a/connectivity/source/simpledbt/staticdbtools_s.hxx b/connectivity/source/simpledbt/staticdbtools_s.hxx
index 24e2109746dc..4836f6bf3d12 100644
--- a/connectivity/source/simpledbt/staticdbtools_s.hxx
+++ b/connectivity/source/simpledbt/staticdbtools_s.hxx
@@ -54,8 +54,7 @@ namespace connectivity
// ------------------------------------------------
virtual double getValue(
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
- const ::com::sun::star::util::Date& rNullDate,
- sal_Int16 nKeyType) const;
+ const ::com::sun::star::util::Date& rNullDate ) const;
// ------------------------------------------------
virtual ::rtl::OUString getFormattedValue(
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 2293e85459dc..426a860ce6db 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -1534,7 +1534,7 @@ String DbFormattedField::GetFormatText(const Reference< ::com::sun::star::sdb::X
// ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
// also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
// ich den Rest (die Formatierung) dem FormattedField ueberlassen.
- double dValue = getValue(_rxField, m_rColumn.GetParent().getNullDate(), m_nKeyType);
+ double dValue = getValue( _rxField, m_rColumn.GetParent().getNullDate() );
if (_rxField->wasNull())
return aText;
((FormattedField*)m_pPainter)->SetValue(dValue);
@@ -1578,7 +1578,7 @@ void DbFormattedField::UpdateFromField(const Reference< ::com::sun::star::sdb::X
// ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
// also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
// ich den Rest (die Formatierung) dem FormattedField ueberlassen.
- double dValue = getValue(_rxField, m_rColumn.GetParent().getNullDate(), m_nKeyType);
+ double dValue = getValue( _rxField, m_rColumn.GetParent().getNullDate() );
if (_rxField->wasNull())
m_pWindow->SetText(String());
else
diff --git a/svx/source/inc/typeconversionclient.hxx b/svx/source/inc/typeconversionclient.hxx
index 7dd3da378619..9ff7e12fe4d0 100644
--- a/svx/source/inc/typeconversionclient.hxx
+++ b/svx/source/inc/typeconversionclient.hxx
@@ -60,12 +60,11 @@ namespace svxform
// --------------------------------------------------------
inline double getValue(
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
- const ::com::sun::star::util::Date& _rNullDate,
- sal_Int16 _nKeyType) const
+ const ::com::sun::star::util::Date& _rNullDate ) const
{
double nReturn(0);
if ( ensureLoaded() )
- nReturn = m_xTypeConversion->getValue(_rxVariant, _rNullDate, _nKeyType);
+ nReturn = m_xTypeConversion->getValue( _rxVariant, _rNullDate );
return nReturn;
}