diff options
-rw-r--r-- | connectivity/inc/connectivity/PColumn.hxx | 9 | ||||
-rw-r--r-- | connectivity/source/commontools/DateConversion.cxx | 58 | ||||
-rw-r--r-- | connectivity/source/commontools/propertyids.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/inc/propertyids.hxx | 2 | ||||
-rw-r--r-- | connectivity/source/parse/PColumn.cxx | 3 | ||||
-rw-r--r-- | svx/source/fmcomp/dbaexchange.cxx | 57 | ||||
-rw-r--r-- | svx/source/fmcomp/gridcell.cxx | 46 |
7 files changed, 91 insertions, 86 deletions
diff --git a/connectivity/inc/connectivity/PColumn.hxx b/connectivity/inc/connectivity/PColumn.hxx index 29821abf0fc7..cf41f4f08e19 100644 --- a/connectivity/inc/connectivity/PColumn.hxx +++ b/connectivity/inc/connectivity/PColumn.hxx @@ -52,6 +52,7 @@ namespace connectivity { ::rtl::OUString m_aRealName; ::rtl::OUString m_aTableName; + ::rtl::OUString m_sLabel; sal_Bool m_bFunction; sal_Bool m_bDbasePrecisionChanged; sal_Bool m_bAggregateFunction; @@ -79,15 +80,17 @@ namespace connectivity virtual void construct(); void setRealName(const ::rtl::OUString& _rName) { m_aRealName = _rName; } + void setLabel(const ::rtl::OUString& i_sLabel) { m_sLabel = i_sLabel; } void setTableName(const ::rtl::OUString& _rName) { m_aTableName = _rName; } void setFunction(sal_Bool _bFunction) { m_bFunction = _bFunction; } void setAggregateFunction(sal_Bool _bFunction) { m_bAggregateFunction = _bFunction; } void setIsSearchable( sal_Bool _bIsSearchable ) { m_bIsSearchable = _bIsSearchable; } void setDbasePrecisionChanged(sal_Bool _bDbasePrecisionChanged) { m_bDbasePrecisionChanged = _bDbasePrecisionChanged; } - ::rtl::OUString getRealName() const { return m_aRealName; } - ::rtl::OUString getTableName() const { return m_aTableName; } - sal_Bool getFunction() const { return m_bFunction; } + ::rtl::OUString getRealName() const { return m_aRealName; } + ::rtl::OUString getLabel() const { return m_sLabel; } + ::rtl::OUString getTableName() const { return m_aTableName; } + sal_Bool getFunction() const { return m_bFunction; } sal_Bool getDbasePrecisionChanged() const { return m_bDbasePrecisionChanged; } public: diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx index 010cfbcf5f34..e57820a645f3 100644 --- a/connectivity/source/commontools/DateConversion.cxx +++ b/connectivity/source/commontools/DateConversion.cxx @@ -129,9 +129,27 @@ using namespace ::com::sun::star::beans; case DataType::TIMESTAMP: { DateTime aDateTime; + bool bOk = false; + if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE) + { + double nValue = 0.0; + _rVal >>= nValue; + aDateTime = DBTypeConversion::toDateTime(nValue); + bOk = true; + } + else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING) + { + ::rtl::OUString sValue; + _rVal >>= sValue; + aDateTime = DBTypeConversion::toDateTime(sValue); + bOk = true; + } + else + bOk = _rVal >>= aDateTime; + OSL_VERIFY_RES( bOk, "DBTypeConversion::toSQLString: _rVal is not datetime!"); // check if this is really a timestamp or only a date - if ( _rVal >>= aDateTime ) + if ( bOk ) { if (bQuote) aRet.appendAscii("{TS '"); @@ -145,7 +163,24 @@ using namespace ::com::sun::star::beans; case DataType::DATE: { Date aDate; - OSL_VERIFY_RES( _rVal >>= aDate, "DBTypeConversion::toSQLString: _rVal is not date!"); + bool bOk = false; + if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE) + { + double nValue = 0.0; + _rVal >>= nValue; + aDate = DBTypeConversion::toDate(nValue); + bOk = true; + } + else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING) + { + ::rtl::OUString sValue; + _rVal >>= sValue; + aDate = DBTypeConversion::toDate(sValue); + bOk = true; + } + else + bOk = _rVal >>= aDate; + OSL_VERIFY_RES( bOk, "DBTypeConversion::toSQLString: _rVal is not date!"); if (bQuote) aRet.appendAscii("{D '"); aRet.append(DBTypeConversion::toDateString(aDate)); @@ -155,7 +190,24 @@ using namespace ::com::sun::star::beans; case DataType::TIME: { Time aTime; - OSL_VERIFY_RES( _rVal >>= aTime,"DBTypeConversion::toSQLString: _rVal is not time!"); + bool bOk = false; + if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE) + { + double nValue = 0.0; + _rVal >>= nValue; + aTime = DBTypeConversion::toTime(nValue); + bOk = true; + } + else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING) + { + ::rtl::OUString sValue; + _rVal >>= sValue; + aTime = DBTypeConversion::toTime(sValue); + bOk = true; + } + else + bOk = _rVal >>= aTime; + OSL_VERIFY_RES( bOk,"DBTypeConversion::toSQLString: _rVal is not time!"); if (bQuote) aRet.appendAscii("{T '"); aRet.append(DBTypeConversion::toTimeString(aTime)); diff --git a/connectivity/source/commontools/propertyids.cxx b/connectivity/source/commontools/propertyids.cxx index b5858652fcc8..b3074ea7fcfd 100644 --- a/connectivity/source/commontools/propertyids.cxx +++ b/connectivity/source/commontools/propertyids.cxx @@ -96,6 +96,7 @@ namespace dbtools const sal_Char* getPROPERTY_ID_FIELDTYPE() { return "FieldType"; } const sal_Char* getPROPERTY_ID_VALUE() { return "Value"; } const sal_Char* getPROPERTY_ID_ACTIVE_CONNECTION() { return "ActiveConnection"; } + const sal_Char* getPROPERTY_ID_LABEL() { return "Label"; } //============================================================ //= error messages @@ -183,6 +184,7 @@ namespace dbtools case PROPERTY_ID_HAVINGCLAUSE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_HAVINGCLAUSE() ); break; } case PROPERTY_ID_ISSIGNED: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_ISSIGNED() ); break; } case PROPERTY_ID_ISSEARCHABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_ISSEARCHABLE() ); break; } + case PROPERTY_ID_LABEL: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_LABEL() ); break; } case PROPERTY_ID_APPLYFILTER: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_APPLYFILTER() ); break; } case PROPERTY_ID_FILTER: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_FILTER() ); break; } case PROPERTY_ID_MASTERFIELDS: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_MASTERFIELDS() ); break; } diff --git a/connectivity/source/inc/propertyids.hxx b/connectivity/source/inc/propertyids.hxx index 27b2008fc7a6..ebfdbd41ea7f 100644 --- a/connectivity/source/inc/propertyids.hxx +++ b/connectivity/source/inc/propertyids.hxx @@ -136,7 +136,7 @@ pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaCon #define PROPERTY_ID_INVALID_INDEX 41 #define PROPERTY_ID_HY010 43 - // FREE +#define PROPERTY_ID_LABEL 44 #define PROPERTY_ID_DELIMITER 45 #define PROPERTY_ID_FORMATKEY 46 #define PROPERTY_ID_LOCALE 47 diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx index 0c1c357cb0d4..7c61411e7f29 100644 --- a/connectivity/source/parse/PColumn.cxx +++ b/connectivity/source/parse/PColumn.cxx @@ -155,6 +155,7 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe ) ); pColumn->setIsSearchable( _rxResMetaData->isSearchable( _nColumnPos ) ); pColumn->setRealName(_rxResMetaData->getColumnName( _nColumnPos )); + pColumn->setLabel(sLabel); return pColumn; } @@ -171,7 +172,7 @@ void OParseColumn::construct() registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME), PROPERTY_ID_REALNAME, 0, &m_aRealName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED), PROPERTY_ID_DBASEPRECISIONCHANGED, 0, &m_bDbasePrecisionChanged, ::getCppuType(reinterpret_cast<sal_Bool*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSEARCHABLE), PROPERTY_ID_ISSEARCHABLE, 0, &m_bIsSearchable, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL))); - + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_LABEL), PROPERTY_ID_LABEL, 0, &m_sLabel, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); } // ----------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper* OParseColumn::createArrayHelper() const diff --git a/svx/source/fmcomp/dbaexchange.cxx b/svx/source/fmcomp/dbaexchange.cxx index 99abbd9853f7..235cd57865ec 100644 --- a/svx/source/fmcomp/dbaexchange.cxx +++ b/svx/source/fmcomp/dbaexchange.cxx @@ -138,30 +138,19 @@ namespace svx { try { - // need a query composer for this - Reference< XSQLQueryComposerFactory > xComposerFac; - _rxForm->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xComposerFac; - Reference< XSQLQueryComposer > xComposer; - if (xComposerFac.is()) - xComposer = xComposerFac->createQueryComposer(); - - if (xComposer.is()) + Reference< XTablesSupplier > xSupTab; + _rxForm->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupTab; + + if(xSupTab.is()) { - ::rtl::OUString sActiveCommand; - _rxForm->getPropertyValue(FM_PROP_ACTIVECOMMAND) >>= sActiveCommand; - xComposer->setQuery(sActiveCommand); - Reference< XTablesSupplier > xSupTab(xComposer, UNO_QUERY); - if(xSupTab.is()) + Reference< XNameAccess > xNames = xSupTab->getTables(); + if (xNames.is()) { - Reference< XNameAccess > xNames = xSupTab->getTables(); - if (xNames.is()) + Sequence< ::rtl::OUString > aTables = xNames->getElementNames(); + if (1 == aTables.getLength()) { - Sequence< ::rtl::OUString > aTables = xNames->getElementNames(); - if (1 == aTables.getLength()) - { - sCommand = aTables[0]; - nCommandType = CommandType::TABLE; - } + sCommand = aTables[0]; + nCommandType = CommandType::TABLE; } } } @@ -460,34 +449,10 @@ namespace svx String sObjectKind = (CommandType::TABLE == nObjectType) ? String('1') : String('0'); // check if the SQL-statement is modified - sal_Bool bHasFilterOrSort(sal_False); ::rtl::OUString sCompleteStatement; try { - ::rtl::OUString sFilter, sSort; - if (::cppu::any2bool(_rxLivingForm->getPropertyValue(FM_PROP_APPLYFILTER))) - _rxLivingForm->getPropertyValue(FM_PROP_FILTER) >>= sFilter; - _rxLivingForm->getPropertyValue(FM_PROP_SORT) >>= sSort; - bHasFilterOrSort = (sFilter.getLength()>0) || (sSort.getLength()>0); - _rxLivingForm->getPropertyValue(FM_PROP_ACTIVECOMMAND) >>= sCompleteStatement; - - // create a composer - Reference< XSQLQueryComposerFactory > xFactory( xConnection, UNO_QUERY ); - Reference< XSQLQueryComposer > xComposer; - if (xFactory.is()) - xComposer = xFactory->createQueryComposer(); - - // let the composer compose - if (xComposer.is()) - { - xComposer->setQuery(sCompleteStatement); - xComposer->setFilter(sFilter); - xComposer->setOrder(sSort); - sCompleteStatement = xComposer->getComposedQuery(); - } - // Usually, I would expect the result of the composing to be the same as the ActiveCommand property - // But this code here is pretty old, and I don't know wha the side effects are if I remove it now ... } catch(Exception&) { @@ -499,7 +464,7 @@ namespace svx ,sConnectionResource ,nObjectType ,sObjectName,xConnection - ,!((CommandType::QUERY == nObjectType) && !bHasFilterOrSort) + ,!((CommandType::QUERY == nObjectType)) ,sCompleteStatement); } diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index c94a63c853f4..92e8d9aebaa1 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -48,6 +48,8 @@ #include <com/sun/star/form/XBoundComponent.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/XStatement.hpp> @@ -85,6 +87,7 @@ using namespace ::svt; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::form; @@ -3042,43 +3045,22 @@ void DbFilterField::Update() if (!xForm.is()) return; - Reference< XConnection > xConnection(getRowSetConnection(xForm)); - if (!xConnection.is()) - return; - - Reference< ::com::sun::star::sdb::XSQLQueryComposerFactory > xFactory(xConnection, UNO_QUERY); - if (!xFactory.is()) - { - DBG_ERROR("DbFilterField::Update : used the right place to request the ::com::sun::star::sdb::XSQLQueryComposerFactory interface ?"); - return; - } - - Reference< ::com::sun::star::sdb::XSQLQueryComposer > xComposer = xFactory->createQueryComposer(); - try - { - Reference< ::com::sun::star::beans::XPropertySet > xFormAsSet(xForm, UNO_QUERY); - ::rtl::OUString sStatement; - xFormAsSet->getPropertyValue(FM_PROP_ACTIVECOMMAND) >>= sStatement; - xComposer->setQuery(sStatement); - } - catch(const Exception&) - { - ::comphelper::disposeComponent(xComposer); - return; - } + Reference<XPropertySet> xFormProp(xForm,UNO_QUERY); + Reference< XTablesSupplier > xSupTab; + xFormProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupTab; - Reference< ::com::sun::star::beans::XPropertySet > xComposerAsSet(xComposer, UNO_QUERY); - if (!xComposerAsSet.is()) + Reference< XConnection > xConnection(getRowSetConnection(xForm)); + if (!xSupTab.is()) return; // search the field - Reference< ::com::sun::star::container::XNameAccess > xFieldNames; - Reference< ::com::sun::star::container::XNameAccess > xTablesNames; - Reference< ::com::sun::star::beans::XPropertySet > xComposerFieldAsSet; + Reference< XColumnsSupplier > xSupCol(xSupTab,UNO_QUERY); + Reference< ::com::sun::star::container::XNameAccess > xFieldNames = xSupCol->getColumns(); + if (!xFieldNames->hasByName(aName)) + return; - ::cppu::extractInterface(xFieldNames, xComposerAsSet->getPropertyValue(FM_PROP_SELECTED_FIELDS)); - ::cppu::extractInterface(xTablesNames, xComposerAsSet->getPropertyValue(FM_PROP_SELECTED_TABLES)); - ::cppu::extractInterface(xComposerFieldAsSet, xFieldNames->getByName(aName)); + Reference< ::com::sun::star::container::XNameAccess > xTablesNames = xSupTab->getTables(); + Reference< ::com::sun::star::beans::XPropertySet > xComposerFieldAsSet(xFieldNames->getByName(aName),UNO_QUERY); if (xComposerFieldAsSet.is() && ::comphelper::hasProperty(FM_PROP_TABLENAME, xComposerFieldAsSet) && ::comphelper::hasProperty(FM_PROP_FIELDSOURCE, xComposerFieldAsSet)) |