diff options
Diffstat (limited to 'dbaccess/source/ui/browser')
-rw-r--r-- | dbaccess/source/ui/browser/brwctrlr.cxx | 148 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbexchange.cxx | 222 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.cxx | 25 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 15 |
4 files changed, 221 insertions, 189 deletions
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 1caae8c6bf11..0be12a01c49b 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -67,6 +67,7 @@ #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdb/SQLFilterOperator.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbc/XResultSetUpdate.hpp> #include <com/sun/star/sdbc/XRowSetListener.hpp> @@ -734,6 +735,11 @@ sal_Bool SbaXDataBrowserController::reloadForm( const Reference< XLoadable >& _r else _rxLoadable->load(); + m_xParser.clear(); + const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING))) + xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser; + Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY ); if ( xWarnings.is() ) { @@ -1205,31 +1211,31 @@ void SbaXDataBrowserController::propertyChange(const PropertyChangeEvent& evt) t // the filter or the sort criterias have changed ? -> update our parser if (evt.PropertyName.equals(PROPERTY_ACTIVECOMMAND)) { - if (m_xParser.is()) - DO_SAFE( m_xParser->setElementaryQuery(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new query to my parser !" ); + // if (m_xParser.is()) + //DO_SAFE( m_xParser->setElementaryQuery(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new query to my parser !" ); } else if (evt.PropertyName.equals(PROPERTY_FILTER)) { - if ( m_xParser.is() && m_xParser->getFilter() != ::comphelper::getString(evt.NewValue)) - { - DO_SAFE( m_xParser->setFilter(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" ); - } + // if ( m_xParser.is() && m_xParser->getFilter() != ::comphelper::getString(evt.NewValue)) + //{ + // DO_SAFE( m_xParser->setFilter(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" ); + //} InvalidateFeature(ID_BROWSER_REMOVEFILTER); } else if (evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE)) { - if ( m_xParser.is() && m_xParser->getHavingClause() != ::comphelper::getString(evt.NewValue)) - { - DO_SAFE( m_xParser->setHavingClause(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" ); - } + //if ( m_xParser.is() && m_xParser->getHavingClause() != ::comphelper::getString(evt.NewValue)) + //{ + // DO_SAFE( m_xParser->setHavingClause(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" ); + //} InvalidateFeature(ID_BROWSER_REMOVEFILTER); } else if (evt.PropertyName.equals(PROPERTY_ORDER)) { - if ( m_xParser.is() && m_xParser->getOrder() != ::comphelper::getString(evt.NewValue)) - { - DO_SAFE( m_xParser->setOrder(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new order to my parser !" ); - } + //if ( m_xParser.is() && m_xParser->getOrder() != ::comphelper::getString(evt.NewValue)) + //{ + // DO_SAFE( m_xParser->setOrder(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new order to my parser !" ); + //} InvalidateFeature(ID_BROWSER_REMOVEFILTER); } @@ -1421,14 +1427,15 @@ void SbaXDataBrowserController::disposing() OSL_ENSURE(0,"Exception thrown by dispose"); } } - try - { - ::comphelper::disposeComponent(m_xParser); - } - catch(Exception&) - { - OSL_ENSURE(0,"Exception thrown by dispose"); - } + m_xParser.clear(); + //try + //{ + // ::comphelper::disposeComponent(m_xParser); + //} + //catch(Exception&) + //{ + // OSL_ENSURE(0,"Exception thrown by dispose"); + //} } //------------------------------------------------------------------------------ void SbaXDataBrowserController::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException ) @@ -1825,7 +1832,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const } //------------------------------------------------------------------------------ -void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrder) +void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrder,const Reference< XSingleSelectQueryComposer >& _xParser) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserOrder" ); Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); @@ -1839,7 +1846,7 @@ void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrd sal_Bool bSuccess = sal_False; try { - xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(m_xParser->getOrder())); + xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_xParser->getOrder())); bSuccess = reloadForm(m_xLoadable); } catch(Exception&) @@ -1849,7 +1856,7 @@ void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrd if (!bSuccess) { xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_rOldOrder)); - DO_SAFE( m_xParser->setOrder(_rOldOrder), "SbaXDataBrowserController::applyParserOrder: could not restore the old order of my parser !" ); + //DO_SAFE( _xParser->setOrder(_rOldOrder), "SbaXDataBrowserController::applyParserOrder: could not restore the old order of my parser !" ); try { @@ -1868,7 +1875,7 @@ void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrd } //------------------------------------------------------------------------------ -void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving) +void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving,const Reference< XSingleSelectQueryComposer >& _xParser) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserFilter" ); Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); @@ -1884,8 +1891,8 @@ void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFi try { FormErrorHelper aError(this); - xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(m_xParser->getFilter())); - xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(m_xParser->getHavingClause())); + xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_xParser->getFilter())); + xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_xParser->getHavingClause())); xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True))); bSuccess = reloadForm(m_xLoadable); @@ -1915,7 +1922,26 @@ void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFi setCurrentColumnPosition(nPos); } - +//------------------------------------------------------------------------------ +Reference< XSingleSelectQueryComposer > SbaXDataBrowserController::createParser_nothrow() +{ + Reference< XSingleSelectQueryComposer > xRet; + try + { + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY_THROW); + const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY_THROW); + xRet.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY_THROW); + xRet->setElementaryQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND))); + xRet->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER))); + xRet->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE))); + xRet->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER))); + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xRet; +} //------------------------------------------------------------------------------ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) { @@ -1927,29 +1953,30 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) const ::rtl::OUString sOldVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder(); const ::rtl::OUString sOldHaving = m_xParser->getHavingClause(); + Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow(); try { Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSup = getColumnsSupplier(); Reference< XConnection> xCon(xFormSet->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY); if(bFilter) { - DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, m_xParser, xSup->getColumns() ); + DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() ); String aFilter; if(!aDlg.Execute()) { - m_xParser->setFilter(sOldVal); - m_xParser->setHavingClause(sOldHaving); + //m_xParser->setFilter(sOldVal); + //m_xParser->setHavingClause(sOldHaving); return; // if so we don't need to actualize the grid } aDlg.BuildWherePart(); } else { - DlgOrderCrit aDlg( getBrowserView(),xCon,m_xParser,xSup->getColumns() ); + DlgOrderCrit aDlg( getBrowserView(),xCon,xParser,xSup->getColumns() ); String aOrder; if(!aDlg.Execute()) { - m_xParser->setOrder(sOldVal); + //m_xParser->setOrder(sOldVal); return; // if so we don't need to actualize the grid } aDlg.BuildOrderPart(); @@ -1966,23 +1993,24 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) return; } - ::rtl::OUString sNewVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder(); + ::rtl::OUString sNewVal = bFilter ? xParser->getFilter() : xParser->getOrder(); sal_Bool bOldFilterApplied(sal_False); if (bFilter) { try { bOldFilterApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER)); } catch(Exception&) { } ; } - ::rtl::OUString sNewHaving = m_xParser->getHavingClause(); + ::rtl::OUString sNewHaving = xParser->getHavingClause(); if ( sOldVal.equals(sNewVal) && (!bFilter || sOldHaving.equals(sNewHaving)) ) // nothing to be done return; if (bFilter) - applyParserFilter(sOldVal, bOldFilterApplied,sOldHaving); + applyParserFilter(sOldVal, bOldFilterApplied,sOldHaving,xParser); else - applyParserOrder(sOldVal); + applyParserOrder(sOldVal,xParser); + ::comphelper::disposeComponent(xParser); } //------------------------------------------------------------------------------ @@ -2175,17 +2203,18 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property if (!xField.is()) break; - const ::rtl::OUString sOldSort = m_xParser->getOrder(); + Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow(); + const ::rtl::OUString sOldSort = xParser->getOrder(); sal_Bool bParserSuccess = sal_False; HANDLE_SQL_ERRORS( - m_xParser->setOrder(::rtl::OUString()); m_xParser->appendOrderByColumn(xField, bSortUp), + xParser->setOrder(::rtl::OUString()); xParser->appendOrderByColumn(xField, bSortUp), bParserSuccess, UniString(ModuleRes(SBA_BROWSER_SETTING_ORDER)), "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !" ) if (bParserSuccess) - applyParserOrder(sOldSort); + applyParserOrder(sOldSort,xParser); } break; @@ -2215,8 +2244,9 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property xProp->getPropertyValue(sAgg) >>= bHaving; } - const ::rtl::OUString sOldFilter = m_xParser->getFilter(); - const ::rtl::OUString sOldHaving = m_xParser->getHavingClause(); + Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow(); + const ::rtl::OUString sOldFilter = xParser->getFilter(); + const ::rtl::OUString sOldHaving = xParser->getHavingClause(); Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); sal_Bool bApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER)); @@ -2224,16 +2254,32 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property // -> completely overwrite it, else append one if (!bApplied) { - DO_SAFE( (bHaving ? m_xParser->setHavingClause(::rtl::OUString()) : m_xParser->setFilter(::rtl::OUString())), "SbaXDataBrowserController::Execute : caught an exception while resetting the new filter !" ); + DO_SAFE( (bHaving ? xParser->setHavingClause(::rtl::OUString()) : xParser->setFilter(::rtl::OUString())), "SbaXDataBrowserController::Execute : caught an exception while resetting the new filter !" ); } sal_Bool bParserSuccess = sal_False; + sal_Int32 nOp = SQLFilterOperator::EQUAL; + if ( xField.is() ) + { + sal_Int32 nType = 0; + xField->getPropertyValue(PROPERTY_TYPE) >>= nType; + switch(nType) + { + case DataType::VARCHAR: + case DataType::CHAR: + case DataType::LONGVARCHAR: + nOp = SQLFilterOperator::LIKE; + break; + default: + nOp = SQLFilterOperator::EQUAL; + } + } if ( bHaving ) { HANDLE_SQL_ERRORS( - m_xParser->appendHavingClauseByColumn(xField,sal_True), + xParser->appendHavingClauseByColumn(xField,sal_True,nOp), bParserSuccess, UniString(ModuleRes(SBA_BROWSER_SETTING_FILTER)), "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !" @@ -2242,7 +2288,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property else { HANDLE_SQL_ERRORS( - m_xParser->appendFilterByColumn(xField,sal_True), + xParser->appendFilterByColumn(xField,sal_True,nOp), bParserSuccess, UniString(ModuleRes(SBA_BROWSER_SETTING_FILTER)), "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !" @@ -2250,7 +2296,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property } if (bParserSuccess) - applyParserFilter(sOldFilter, bApplied,sOldHaving); + applyParserFilter(sOldFilter, bApplied,sOldHaving,xParser); InvalidateFeature(ID_BROWSER_REMOVEFILTER); InvalidateFeature(ID_BROWSER_FILTERED); @@ -2736,11 +2782,14 @@ void SbaXDataBrowserController::initializeParser() const if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING))) { // (only if the statement isn't native) // (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid) + xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser; +/* const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY); if ( xFactory.is() ) m_xParser.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); +*/ } - +/* // initialize the parser with the current sql-statement of the form if ( m_xParser.is() ) { @@ -2749,6 +2798,7 @@ void SbaXDataBrowserController::initializeParser() const m_xParser->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE))); m_xParser->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER))); } +*/ } catch(Exception&) { @@ -2783,6 +2833,7 @@ void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( R // change as a reaction on that event. as we have no chance to be notified of this change (which is // the one we're interested in) we give them time to do what they want to before invalidating our // bound-field-dependent slots .... + /* try { ::comphelper::disposeComponent(m_xParser); @@ -2791,6 +2842,7 @@ void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( R { OSL_ENSURE(0,"Exception thrown by dispose"); } + */ } //------------------------------------------------------------------------------ diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx index 70caccc10a3e..0aa4074806ec 100644 --- a/dbaccess/source/ui/browser/dbexchange.cxx +++ b/dbaccess/source/ui/browser/dbexchange.cxx @@ -31,36 +31,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBAUI_DBEXCHANGE_HXX #include "dbexchange.hxx" -#endif -#ifndef _SOT_FORMATS_HXX #include <sot/formats.hxx> -#endif -#ifndef _SOT_STORAGE_HXX #include <sot/storage.hxx> -#endif -#ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef DBAUI_TOKENWRITER_HXX +#include <com/sun/star/sdb/XResultSetAccess.hpp> #include "TokenWriter.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -//#ifndef _COMPHELPER_EXTRACT_HXX_ -//#include <comphelper/extract.hxx> -//#endif -#ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> -#endif -#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_ #include <svx/dataaccessdescriptor.hxx> -#endif #include "UITools.hxx" @@ -78,23 +58,17 @@ namespace dbaui namespace { - template<class T > void lcl_addListener(const Reference<T>& _xComponent,ODataClipboard* _pListener) + template<class T > void lcl_setListener(const Reference<T>& _xComponent, const Reference< XEventListener >& i_rListener, const bool i_bAdd ) { - if ( _xComponent.is() ) - { - Reference< XComponent> xCom(_xComponent,UNO_QUERY); - if ( xCom.is() ) - xCom->addEventListener(Reference< XEventListener>((::cppu::OWeakObject*)_pListener,UNO_QUERY)); - } - } - template<class T > void lcl_removeListener(const Reference<T>& _xComponent,ODataClipboard* _pListener) - { - if ( _xComponent.is() ) - { - Reference< XComponent> xCom(_xComponent,UNO_QUERY); - if ( xCom.is() ) - xCom->removeEventListener(Reference< XEventListener>((::cppu::OWeakObject*)_pListener,UNO_QUERY)); - } + if ( !_xComponent.is() ) + return; + + Reference< XComponent> xCom( _xComponent, UNO_QUERY ); + OSL_ENSURE( xCom.is(), "lcl_setListener: no component!" ); + if ( !xCom.is() ) + return; + + i_bAdd ? xCom->addEventListener( i_rListener ) : xCom->removeEventListener( i_rListener ); } } @@ -111,13 +85,11 @@ namespace dbaui ,m_pRtf(NULL) { osl_incrementInterlockedCount( &m_refCount ); - lcl_addListener(_rxConnection,this); + lcl_setListener( _rxConnection, this, true ); - m_pHtml = new OHTMLImportExport(getDescriptor(), _rxORB, _rxFormatter); - m_aEventListeners.push_back(m_pHtml); + m_pHtml.set( new OHTMLImportExport( getDescriptor(), _rxORB, _rxFormatter ) ); + m_pRtf.set( new ORTFImportExport( getDescriptor(), _rxORB, _rxFormatter ) ); - m_pRtf = new ORTFImportExport(getDescriptor(), _rxORB, _rxFormatter); - m_aEventListeners.push_back(m_pRtf); osl_decrementInterlockedCount( &m_refCount ); } @@ -132,47 +104,50 @@ namespace dbaui ,m_pHtml(NULL) ,m_pRtf(NULL) { - m_pHtml = new OHTMLImportExport(getDescriptor(),_rxORB, _rxFormatter); - m_aEventListeners.push_back(m_pHtml); - - m_pRtf = new ORTFImportExport(getDescriptor(),_rxORB, _rxFormatter); - m_aEventListeners.push_back(m_pRtf); + m_pHtml.set( new OHTMLImportExport( getDescriptor(),_rxORB, _rxFormatter ) ); + m_pRtf.set( new ORTFImportExport( getDescriptor(),_rxORB, _rxFormatter ) ); } // ----------------------------------------------------------------------------- - ODataClipboard::ODataClipboard( const Reference< XPropertySet >& _rxLivingForm, - const Sequence< Any >& _rSelectedRows, - const Reference< XResultSet>& _rxResultSet, - const Reference< XMultiServiceFactory >& _rxORB) - :ODataAccessObjectTransferable( _rxLivingForm ) + ODataClipboard::ODataClipboard( const Reference< XPropertySet >& i_rAliveForm, + const Sequence< Any >& i_rSelectedRows, + const sal_Bool i_bBookmarkSelection, + const Reference< XMultiServiceFactory >& i_rORB ) + :ODataAccessObjectTransferable( i_rAliveForm ) ,m_pHtml(NULL) ,m_pRtf(NULL) { + OSL_PRECOND( i_rORB.is(), "ODataClipboard::ODataClipboard: having no factory is not good ..." ); + osl_incrementInterlockedCount( &m_refCount ); Reference<XConnection> xConnection; - getDescriptor()[daConnection] >>= xConnection; - lcl_addListener(xConnection,this); - lcl_addListener(_rxResultSet,this); - - getDescriptor()[daSelection] <<= _rSelectedRows; - getDescriptor()[daBookmarkSelection]<<= sal_False; // by definition, it's the indicies - getDescriptor()[daCursor] <<= _rxResultSet; - addCompatibleSelectionDescription( _rSelectedRows ); - - if ( xConnection.is() && _rxORB.is() )
- {
- Reference< XNumberFormatter > xFormatter( getNumberFormatter( xConnection, _rxORB ) );
- if ( xFormatter.is() )
- {
- m_pHtml = new OHTMLImportExport( getDescriptor(),_rxORB, xFormatter );
- m_aEventListeners.push_back( m_pHtml );
-
- m_pRtf = new ORTFImportExport( getDescriptor(),_rxORB, xFormatter );
- m_aEventListeners.push_back( m_pRtf );
- }
- }
+ getDescriptor()[ daConnection ] >>= xConnection; + lcl_setListener( xConnection, this, true ); + + // do not pass the form itself as source result set, since the client might operate on the form, which + // might lead to undesired effects. Instead, use a clone. + Reference< XResultSet > xResultSetClone; + Reference< XResultSetAccess > xResultSetAccess( i_rAliveForm, UNO_QUERY ); + if ( xResultSetAccess.is() ) + xResultSetClone = xResultSetAccess->createResultSet(); + OSL_ENSURE( xResultSetClone.is(), "ODataClipboard::ODataClipboard: could not clone the form's result set" ); + lcl_setListener( xResultSetClone, this, true ); + getDescriptor()[daCursor] <<= xResultSetClone; + getDescriptor()[daSelection] <<= i_rSelectedRows; + getDescriptor()[daBookmarkSelection]<<= i_bBookmarkSelection; + addCompatibleSelectionDescription( i_rSelectedRows ); + + if ( xConnection.is() && i_rORB.is() ) + { + Reference< XNumberFormatter > xFormatter( getNumberFormatter( xConnection, i_rORB ) ); + if ( xFormatter.is() ) + { + m_pHtml.set( new OHTMLImportExport( getDescriptor(), i_rORB, xFormatter ) ); + m_pRtf.set( new ORTFImportExport( getDescriptor(), i_rORB, xFormatter ) ); + } + } osl_decrementInterlockedCount( &m_refCount ); } @@ -195,13 +170,11 @@ namespace dbaui // ----------------------------------------------------------------------------- void ODataClipboard::AddSupportedFormats() { - // RTF? - if (m_pRtf) - AddFormat(SOT_FORMAT_RTF); + if ( m_pRtf.is() ) + AddFormat( SOT_FORMAT_RTF ); - // HTML? - if (m_pHtml) - AddFormat(SOT_FORMATSTR_ID_HTML); + if ( m_pHtml.is() ) + AddFormat( SOT_FORMATSTR_ID_HTML ); ODataAccessObjectTransferable::AddSupportedFormats(); } @@ -213,13 +186,14 @@ namespace dbaui switch (nFormat) { case SOT_FORMAT_RTF: - if ( m_pRtf ) + if ( m_pRtf.is() ) m_pRtf->initialize(getDescriptor()); - return m_pRtf && SetObject(m_pRtf, SOT_FORMAT_RTF, rFlavor); + return m_pRtf.is() && SetObject( m_pRtf.get(), SOT_FORMAT_RTF, rFlavor ); + case SOT_FORMATSTR_ID_HTML: - if ( m_pHtml ) + if ( m_pHtml.is() ) m_pHtml->initialize(getDescriptor()); - return m_pHtml && SetObject(m_pHtml, SOT_FORMATSTR_ID_HTML, rFlavor); + return m_pHtml.is() && SetObject( m_pHtml.get(), SOT_FORMATSTR_ID_HTML, rFlavor ); } return ODataAccessObjectTransferable::GetData( rFlavor ); @@ -228,59 +202,65 @@ namespace dbaui // ----------------------------------------------------------------------------- void ODataClipboard::ObjectReleased() { - if ( m_pHtml ) + if ( m_pHtml.is() ) { m_pHtml->dispose(); - m_pHtml = NULL; - } // if ( m_pHtml ) - if ( m_pRtf ) + m_pHtml.clear(); + } + + if ( m_pRtf.is() ) { m_pRtf->dispose(); - m_pRtf = NULL; + m_pRtf.clear(); + } + + if ( getDescriptor().has( daConnection ) ) + { + Reference<XConnection> xConnection( getDescriptor()[daConnection], UNO_QUERY ); + lcl_setListener( xConnection, this, false ); + } + + if ( getDescriptor().has( daCursor ) ) + { + Reference< XResultSet > xResultSet( getDescriptor()[ daCursor ], UNO_QUERY ); + lcl_setListener( xResultSet, this, false ); } - m_aEventListeners.clear(); - Reference<XConnection> xConnection; - Reference<XResultSet> xProp; - if ( getDescriptor().has(daConnection) && (getDescriptor()[daConnection] >>= xConnection) ) - lcl_removeListener(xConnection,this); - if ( getDescriptor().has(daCursor) && (getDescriptor()[daCursor] >>= xProp) ) - lcl_removeListener(xProp,this); ODataAccessObjectTransferable::ObjectReleased( ); } + // ----------------------------------------------------------------------------- - void SAL_CALL ODataClipboard::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException) + void SAL_CALL ODataClipboard::disposing( const ::com::sun::star::lang::EventObject& i_rSource ) throw (::com::sun::star::uno::RuntimeException) { - Reference<XConnection> xConnection; - Reference<XResultSet> xProp; - if ( getDescriptor().has(daConnection) && (getDescriptor()[daConnection] >>= xConnection) ) - { - lcl_removeListener(xConnection,this); - getDescriptor().erase(daConnection); - } // if ( getDescriptor().has(daConnection) && (getDescriptor()[daConnection] >>= xConnection) ) - if ( getDescriptor().has(daCursor) && (getDescriptor()[daCursor] >>= xProp) ) - { - lcl_removeListener(xProp,this); - getDescriptor().erase(daCursor); - } // if ( getDescriptor().has(daCursor) && (getDescriptor()[daCursor] >>= xProp) ) - - if ( getDescriptor().has(daColumnObject) ) - getDescriptor().erase(daColumnObject); + ODataAccessDescriptor& rDescriptor( getDescriptor() ); - if ( getDescriptor().has(daComponent) ) - getDescriptor().erase(daComponent); + if ( rDescriptor.has( daConnection ) ) + { + Reference< XConnection > xConnection( rDescriptor[daConnection], UNO_QUERY ); + if ( xConnection == i_rSource.Source ) + { + rDescriptor.erase( daConnection ); + } + } + if ( rDescriptor.has( daCursor ) ) + { + Reference< XResultSet > xResultSet( rDescriptor[ daCursor ], UNO_QUERY ); + if ( xResultSet == i_rSource.Source ) + { + rDescriptor.erase( daCursor ); + // Selection and BookmarkSelection are meaningless without a result set + if ( rDescriptor.has( daSelection ) ) + rDescriptor.erase( daSelection ); + if ( rDescriptor.has( daBookmarkSelection ) ) + rDescriptor.erase( daBookmarkSelection ); + } + } + // no matter whether it was the source connection or the source result set which died, + // we cannot provide the data anymore. ClearFormats(); - //getDescriptor().clear(); - AddSupportedFormats(); - - /*m_pHtml = NULL; - m_pRtf = NULL; - m_aEventListeners.clear();*/ } - // ----------------------------------------------------------------------------- - IMPLEMENT_FORWARD_XINTERFACE2( ODataClipboard, ODataAccessObjectTransferable, TDataClipboard_BASE ) } diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 46f6c576c022..c3da97bfae7a 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -1443,39 +1443,30 @@ void SbaGridControl::DoRowDrag( sal_Int16 nRowPos ) // ----------------------------------------------------------------------- void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag ) { - Reference< XPropertySet > xDataSource(getDataSource(), UNO_QUERY); - DBG_ASSERT(xDataSource.is(), "SbaGridControl::implTransferSelectedRows : invalid data source !"); + Reference< XPropertySet > xForm( getDataSource(), UNO_QUERY ); + DBG_ASSERT( xForm.is(), "SbaGridControl::implTransferSelectedRows: invalid form!" ); // build the sequence of numbers of selected rows Sequence< Any > aSelectedRows; + sal_Bool bSelectionBookmarks = sal_True; // collect the affected rows if ((GetSelectRowCount() == 0) && (nRowPos >= 0)) { - aSelectedRows.realloc(1); + aSelectedRows.realloc( 1 ); aSelectedRows[0] <<= (sal_Int32)(nRowPos + 1); + bSelectionBookmarks = sal_False; } else if ( !IsAllSelected() && GetSelectRowCount() ) { - aSelectedRows.realloc(GetSelectRowCount()); - Any* pSelectedRows = aSelectedRows.getArray(); - - for (long nIdx = FirstSelectedRow(); - nIdx >= 0; - nIdx = NextSelectedRow(), ++pSelectedRows) - { - (*pSelectedRows) <<= (sal_Int32)(nIdx + 1); - } + aSelectedRows = getSelectionBookmarks(); + bSelectionBookmarks = sal_True; } Reference< XResultSet> xRowSetClone; try { - Reference< XResultSetAccess > xResultSetAccess(xDataSource,UNO_QUERY); - if ( xResultSetAccess.is() ) - xRowSetClone = xResultSetAccess->createResultSet(); - - ODataClipboard* pTransfer = new ODataClipboard(xDataSource, aSelectedRows,xRowSetClone, getServiceManager()); + ODataClipboard* pTransfer = new ODataClipboard( xForm, aSelectedRows, bSelectionBookmarks, getServiceManager() ); Reference< XTransferable > xEnsureDelete = pTransfer; if ( _bTrueIfClipboardFalseIfDrag ) diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 1e10e9421047..eda9fc01a3e4 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -650,7 +650,12 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: } aInitialValues.push_back( NamedValue( PROPERTY_CONTROLSOURCE, makeAny( *pIter ) ) ); - aInitialValues.push_back( NamedValue( PROPERTY_LABEL, makeAny( *pIter ) ) ); + ::rtl::OUString sLabel; + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + if ( sLabel.getLength() ) + aInitialValues.push_back( NamedValue( PROPERTY_LABEL, makeAny( sLabel ) ) ); + else + aInitialValues.push_back( NamedValue( PROPERTY_LABEL, makeAny( *pIter ) ) ); Reference< XPropertySet > xGridCol( xColFactory->createColumn( aCurrentModelType ), UNO_SET_THROW ); Reference< XPropertySetInfo > xGridColPSI( xGridCol->getPropertySetInfo(), UNO_SET_THROW ); @@ -681,8 +686,12 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: Any aDescription; if ( xColPSI->hasPropertyByName( PROPERTY_HELPTEXT ) ) aDescription = xColumn->getPropertyValue( PROPERTY_HELPTEXT ); - if ( !aDescription.hasValue() ) - aDescription <<= ::rtl::OUString(); + ::rtl::OUString sTemp; + aDescription >>= sTemp; + if ( !sTemp.getLength() ) + xColumn->getPropertyValue( PROPERTY_DESCRIPTION ) >>= sTemp; + + aDescription <<= sTemp; aInitialValues.push_back( NamedValue( PROPERTY_HELPTEXT, aDescription ) ); // ... horizontal justify |