From f5531281dc390ac3e74888f078eac7a87b586095 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 11 Jan 2010 08:09:14 +0100 Subject: dba33e: svx split --- .../source/core/dataaccess/databasedocument.cxx | 2 +- .../core/dataaccess/databaseregistrations.cxx | 2 +- dbaccess/source/ui/app/AppController.cxx | 10 ++-- dbaccess/source/ui/dlg/DbAdminImpl.cxx | 10 ++-- dbaccess/source/ui/dlg/adminpages.cxx | 6 +-- dbaccess/source/ui/dlg/dbadmin.cxx | 6 +-- dbaccess/source/ui/dlg/indexdialog.cxx | 2 +- dbaccess/source/ui/dlg/indexfieldscontrol.cxx | 62 +++++++++++----------- dbaccess/source/ui/dlg/optionalboolitem.hxx | 4 +- dbaccess/source/ui/inc/indexfieldscontrol.hxx | 3 +- 10 files changed, 55 insertions(+), 52 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index ff57b3a82b06..05a697fbecb4 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -79,7 +79,7 @@ #include -#include +#include #include #include diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.cxx b/dbaccess/source/core/dataaccess/databaseregistrations.cxx index 28beb9664110..df27c73f2665 100644 --- a/dbaccess/source/core/dataaccess/databaseregistrations.cxx +++ b/dbaccess/source/core/dataaccess/databaseregistrations.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index d28799a7ce77..2f633c33410d 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -84,15 +84,15 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include #include -#include -#include +#include +#include #include #include diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 8d650ed506de..ecf6415704eb 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -64,12 +64,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include -#include +#include +#include #include #include #include diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx index 54471a0c40f9..05b88a9e1870 100644 --- a/dbaccess/source/ui/dlg/adminpages.cxx +++ b/dbaccess/source/ui/dlg/adminpages.cxx @@ -47,9 +47,9 @@ #include "sqlmessage.hxx" #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index 53b6d670b12d..96426b96a9b4 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -49,9 +49,9 @@ #include "propertysetitem.hxx" #include "stringlistitem.hxx" -#include -#include -#include +#include +#include +#include #include #include diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx index 1d9dfba5623e..0691b24440de 100644 --- a/dbaccess/source/ui/dlg/indexdialog.cxx +++ b/dbaccess/source/ui/dlg/indexdialog.cxx @@ -220,7 +220,7 @@ DBG_NAME(DbaIndexDialog) ,m_aDescription (this, ModuleRes(FT_DESCRIPTION)) ,m_aUnique (this, ModuleRes(CB_UNIQUE)) ,m_aFieldsLabel (this, ModuleRes(FT_FIELDS)) - ,m_pFields(new IndexFieldsControl (this, ModuleRes(CTR_FIELDS),_nMaxColumnsInIndex)) + ,m_pFields(new IndexFieldsControl (this, ModuleRes(CTR_FIELDS),_nMaxColumnsInIndex,::dbtools::getBooleanDataSourceSetting( m_xConnection, "AddIndexAppendix" ))) ,m_aClose (this, ModuleRes(PB_CLOSE)) ,m_aHelp (this, ModuleRes(HB_HELP)) ,m_pIndexes(NULL) diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx index 568ce0922c72..f39b562a2457 100644 --- a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx +++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx @@ -122,12 +122,13 @@ namespace dbaui //================================================================== DBG_NAME(IndexFieldsControl) //------------------------------------------------------------------ - IndexFieldsControl::IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex) + IndexFieldsControl::IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex,sal_Bool _bAddIndexAppendix) :EditBrowseBox(_pParent, _rId, EBBF_SMART_TAB_TRAVEL | EBBF_ACTIVATE_ON_BUTTONDOWN, BROWSER_STANDARD_FLAGS) ,m_aSeekRow(m_aFields.end()) ,m_pSortingCell(NULL) ,m_pFieldNameCell(NULL) ,m_nMaxColumnsInIndex(_nMaxColumnsInIndex) + ,m_bAddIndexAppendix(_bAddIndexAppendix) { DBG_CTOR(IndexFieldsControl,NULL); @@ -208,7 +209,7 @@ DBG_NAME(IndexFieldsControl) RowInserted(GetRowCount(), m_aFields.size(), sal_False); // insert an additional row for a new field for that index // if(!m_nMaxColumnsInIndex || GetRowCount() < m_nMaxColumnsInIndex ) - RowInserted(GetRowCount(), 1, sal_False); + RowInserted(GetRowCount(), 1, sal_False); SetUpdateMode(sal_True); GoToRowColumnId(0, COLUMN_ID_FIELDNAME); @@ -250,51 +251,52 @@ DBG_NAME(IndexFieldsControl) { RemoveColumns(); - m_sAscendingText = String(ModuleRes(STR_ORDER_ASCENDING)); - m_sDescendingText = String(ModuleRes(STR_ORDER_DESCENDING)); - - // the "sort order" column - String sColumnName = String(ModuleRes(STR_TAB_INDEX_SORTORDER)); - // the width of the order column is the maximum widths of the texts used - // (the title of the column) - sal_Int32 nSortOrderColumnWidth = GetTextWidth(sColumnName); - // ("ascending" + scrollbar width) - sal_Int32 nOther = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); - nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther; - // ("descending" + scrollbar width) - nOther = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); - nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther; - // (plus some additional space) - nSortOrderColumnWidth += GetTextWidth('0') * 2; - InsertDataColumn(COLUMN_ID_ORDER, sColumnName, nSortOrderColumnWidth, HIB_STDSTYLE, 1); - // for the width: both columns together should be somewhat smaller than the whole window (without the scrollbar) sal_Int32 nFieldNameWidth = GetSizePixel().Width(); - nFieldNameWidth -= nSortOrderColumnWidth; + if ( m_bAddIndexAppendix ) + { + m_sAscendingText = String(ModuleRes(STR_ORDER_ASCENDING)); + m_sDescendingText = String(ModuleRes(STR_ORDER_DESCENDING)); + + // the "sort order" column + String sColumnName = String(ModuleRes(STR_TAB_INDEX_SORTORDER)); + // the width of the order column is the maximum widths of the texts used + // (the title of the column) + sal_Int32 nSortOrderColumnWidth = GetTextWidth(sColumnName); + // ("ascending" + scrollbar width) + sal_Int32 nOther = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); + nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther; + // ("descending" + scrollbar width) + nOther = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize(); + nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther; + // (plus some additional space) + nSortOrderColumnWidth += GetTextWidth('0') * 2; + InsertDataColumn(COLUMN_ID_ORDER, sColumnName, nSortOrderColumnWidth, HIB_STDSTYLE, 1); + + m_pSortingCell = new ListBoxControl(&GetDataWindow()); + m_pSortingCell->InsertEntry(m_sAscendingText); + m_pSortingCell->InsertEntry(m_sDescendingText); + m_pSortingCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_SORTORDER ); + + nFieldNameWidth -= nSortOrderColumnWidth; + } StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); nFieldNameWidth -= aSystemStyle.GetScrollBarSize(); nFieldNameWidth -= 8; - // the "field name" column - sColumnName = String(ModuleRes(STR_TAB_INDEX_FIELD)); + String sColumnName = String(ModuleRes(STR_TAB_INDEX_FIELD)); InsertDataColumn(COLUMN_ID_FIELDNAME, sColumnName, nFieldNameWidth, HIB_STDSTYLE, 0); // create the cell controllers // for the field name cell m_pFieldNameCell = new ListBoxControl(&GetDataWindow()); m_pFieldNameCell->InsertEntry(String()); + m_pFieldNameCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_FIELD ); const ::rtl::OUString* pFields = _rAvailableFields.getConstArray(); const ::rtl::OUString* pFieldsEnd = pFields + _rAvailableFields.getLength(); for (;pFields < pFieldsEnd; ++pFields) m_pFieldNameCell->InsertEntry(*pFields); - // for the sort cell - m_pSortingCell = new ListBoxControl(&GetDataWindow()); - m_pSortingCell->InsertEntry(m_sAscendingText); - m_pSortingCell->InsertEntry(m_sDescendingText); - - m_pFieldNameCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_FIELD ); - m_pSortingCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_SORTORDER ); } //------------------------------------------------------------------ diff --git a/dbaccess/source/ui/dlg/optionalboolitem.hxx b/dbaccess/source/ui/dlg/optionalboolitem.hxx index 0a1fc397e0b6..4bc2054630eb 100644 --- a/dbaccess/source/ui/dlg/optionalboolitem.hxx +++ b/dbaccess/source/ui/dlg/optionalboolitem.hxx @@ -22,11 +22,11 @@ * * for a copy of the LGPLv3 License. ************************************************************************/ - + #ifndef DBACCESS_OPTIONALBOOLITEM_HXX #define DBACCESS_OPTIONALBOOLITEM_HXX -#include +#include #include diff --git a/dbaccess/source/ui/inc/indexfieldscontrol.hxx b/dbaccess/source/ui/inc/indexfieldscontrol.hxx index dd132206bfed..415c34b65813 100644 --- a/dbaccess/source/ui/inc/indexfieldscontrol.hxx +++ b/dbaccess/source/ui/inc/indexfieldscontrol.hxx @@ -70,9 +70,10 @@ namespace dbaui String m_sDescendingText; sal_Int32 m_nMaxColumnsInIndex; + sal_Bool m_bAddIndexAppendix; public: - IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex); + IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex,sal_Bool _bAddIndexAppendix); ~IndexFieldsControl(); void Init(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rAvailableFields); -- cgit From 0e793ea5d3e758ed431065b675a79c17a9f15ef7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 11 Jan 2010 12:15:28 +0100 Subject: dba33f: #i108038# (re-)add Selection support to the Copy Table Wizard --- dbaccess/source/ui/browser/dbexchange.cxx | 222 +++++++++++++--------------- dbaccess/source/ui/browser/sbagrid.cxx | 25 +--- dbaccess/source/ui/inc/TableCopyHelper.hxx | 31 ++-- dbaccess/source/ui/inc/TokenWriter.hxx | 50 ++----- dbaccess/source/ui/inc/dbexchange.hxx | 23 ++- dbaccess/source/ui/misc/TableCopyHelper.cxx | 122 +++++++-------- dbaccess/source/ui/misc/TokenWriter.cxx | 87 +++++++---- dbaccess/source/ui/uno/copytablewizard.cxx | 183 +++++++++++++---------- 8 files changed, 350 insertions(+), 393 deletions(-) (limited to 'dbaccess') 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 -#endif -#ifndef _SOT_STORAGE_HXX #include -#endif -#ifndef _OSL_DIAGNOSE_H_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include -#endif -#ifndef DBAUI_TOKENWRITER_HXX +#include #include "TokenWriter.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -//#ifndef _COMPHELPER_EXTRACT_HXX_ -//#include -//#endif -#ifndef _COMPHELPER_UNO3_HXX_ #include -#endif -#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_ #include -#endif #include "UITools.hxx" @@ -78,23 +58,17 @@ namespace dbaui namespace { - template void lcl_addListener(const Reference& _xComponent,ODataClipboard* _pListener) + template void lcl_setListener(const Reference& _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 void lcl_removeListener(const Reference& _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; - 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( 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; - Reference 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; - Reference 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/inc/TableCopyHelper.hxx b/dbaccess/source/ui/inc/TableCopyHelper.hxx index c0b5e77cc403..6261286b6d06 100644 --- a/dbaccess/source/ui/inc/TableCopyHelper.hxx +++ b/dbaccess/source/ui/inc/TableCopyHelper.hxx @@ -194,30 +194,17 @@ namespace dbaui ); /** insert a table into the data source. The source can eihter be a table or a query - @param _nCommandType - The command type. - @param _xSrcConnection - The connection of the source. - @param _aSelection - The selection of the rows to copy. - @param _bBookmarkSelection - If the selection is bookmark selection. - @param _sCommand - The name of the query or table. - @param _sSrcDataSourceName - The name of the source data source. - @param _sDestDataSourceName - The name of the dest data source. */ void insertTable( - sal_Int32 _nCommandType, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xSrcConnection, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _aSelection, - sal_Bool _bBookmarkSelection, - const ::rtl::OUString& _sCommand, - const ::rtl::OUString& _sSrcDataSourceName, - const ::rtl::OUString& _sDestDataSourceName, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xDestConnection + const ::rtl::OUString& i_rSourceDataSource, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rSourceConnection, + const ::rtl::OUString& i_rCommand, + const sal_Int32 i_nCommandType, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& i_rSourceRows, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelection, + const sal_Bool i_bBookmarkSelection, + const ::rtl::OUString& i_rDestDataSource, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rDestConnection ); }; diff --git a/dbaccess/source/ui/inc/TokenWriter.hxx b/dbaccess/source/ui/inc/TokenWriter.hxx index 27a103e1af8a..90bbb4c37862 100644 --- a/dbaccess/source/ui/inc/TokenWriter.hxx +++ b/dbaccess/source/ui/inc/TokenWriter.hxx @@ -30,51 +30,25 @@ #ifndef DBAUI_TOKENWRITER_HXX #define DBAUI_TOKENWRITER_HXX -#ifndef DBAUI_DATABASEEXPORT_HXX #include "DExport.hxx" -#endif -#ifndef _DBAUI_MODULE_DBU_HXX_ #include "moduledbu.hxx" -#endif -#ifndef _STREAM_HXX //autogen -#include -#endif -#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include "commontypes.hxx" + #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ #include -#endif -#ifndef _CPPUHELPER_IMPLBASE1_HXX_ -#include -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include -#endif -#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_ +#include + +#include +#include #include -#endif -#ifndef _DBAUI_COMMON_TYPES_HXX_ -#include "commontypes.hxx" -#endif + #include namespace com { namespace sun { namespace star { @@ -98,13 +72,15 @@ namespace dbaui protected: ::com::sun::star::lang::Locale m_aLocale; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSelection; + sal_Bool m_bBookmarkSelection; SvStream* m_pStream; ::com::sun::star::awt::FontDescriptor m_aFont; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xObject; // table/query - SharedConnection m_xConnection; // - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet; // - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xRow; // - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xResultSetMetaData; // + SharedConnection m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xRow; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate > m_xRowLocate; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xResultSetMetaData; ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xRowSetColumns; ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory; diff --git a/dbaccess/source/ui/inc/dbexchange.hxx b/dbaccess/source/ui/inc/dbexchange.hxx index 6627e3b2af1d..ea2fc3494221 100644 --- a/dbaccess/source/ui/inc/dbexchange.hxx +++ b/dbaccess/source/ui/inc/dbexchange.hxx @@ -56,20 +56,19 @@ #endif #include +#include + namespace dbaui { class ORTFImportExport; class OHTMLImportExport; - typedef ::cppu::ImplHelper1< ::com::sun::star::lang::XEventListener > TDataClipboard_BASE; - class ODataClipboard : public ::svx::ODataAccessObjectTransferable - , public TDataClipboard_BASE + class ODataClipboard : public ::svx::ODataAccessObjectTransferable { - ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> > m_aEventListeners; - OHTMLImportExport* m_pHtml; - ORTFImportExport* m_pRtf; + ::rtl::Reference< OHTMLImportExport > m_pHtml; + ::rtl::Reference< ORTFImportExport > m_pRtf; public: ODataClipboard( @@ -90,15 +89,15 @@ namespace dbaui ); ODataClipboard( - const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLivingForm, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rSelectedRows, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _rxResultSet, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_rAliveForm, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelectedRows, + const sal_Bool i_bBookmarkSelection, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB ); - DECLARE_XINTERFACE( ) - + // XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + protected: virtual void AddSupportedFormats(); virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); diff --git a/dbaccess/source/ui/misc/TableCopyHelper.cxx b/dbaccess/source/ui/misc/TableCopyHelper.cxx index 4b1258677037..f0ac851b58b7 100644 --- a/dbaccess/source/ui/misc/TableCopyHelper.cxx +++ b/dbaccess/source/ui/misc/TableCopyHelper.cxx @@ -163,21 +163,15 @@ using namespace ::com::sun::star::ucb; OTableCopyHelper::OTableCopyHelper(OGenericUnoController* _pControler) :m_pController(_pControler) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::OTableCopyHelper" ); } // ----------------------------------------------------------------------------- -void OTableCopyHelper::insertTable(sal_Int32 _nCommandType - ,const Reference& _xSrcConnection - ,const Sequence< Any >& _aSelection - ,sal_Bool _bBookmarkSelection - ,const ::rtl::OUString& _sCommand - ,const ::rtl::OUString& _sSrcDataSourceName - ,const ::rtl::OUString& _sDestDataSourceName - ,const Reference& _xDestConnection) +void OTableCopyHelper::insertTable( const ::rtl::OUString& i_rSourceDataSource, const Reference& i_rSourceConnection, + const ::rtl::OUString& i_rCommand, const sal_Int32 i_nCommandType, + const Reference< XResultSet >& i_rSourceRows, const Sequence< Any >& i_rSelection, const sal_Bool i_bBookmarkSelection, + const ::rtl::OUString& i_rDestDataSource, const Reference& i_rDestConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::insertTable" ); - if ( CommandType::QUERY != _nCommandType && CommandType::TABLE != _nCommandType ) + if ( CommandType::QUERY != i_nCommandType && CommandType::TABLE != i_nCommandType ) { DBG_ERROR( "OTableCopyHelper::insertTable: invalid call (no supported format found)!" ); return; @@ -185,11 +179,11 @@ void OTableCopyHelper::insertTable(sal_Int32 _nCommandType try { - Reference xSrcConnection( _xSrcConnection ); - if ( _sSrcDataSourceName == _sDestDataSourceName ) - xSrcConnection = _xDestConnection; + Reference xSrcConnection( i_rSourceConnection ); + if ( i_rSourceDataSource == i_rDestDataSource ) + xSrcConnection = i_rDestConnection; - if ( !xSrcConnection.is() || !_xDestConnection.is() ) + if ( !xSrcConnection.is() || !i_rDestConnection.is() ) { OSL_ENSURE( false, "OTableCopyHelper::insertTable: no connection/s!" ); return; @@ -200,14 +194,15 @@ void OTableCopyHelper::insertTable(sal_Int32 _nCommandType Reference< XDataAccessDescriptorFactory > xFactory( DataAccessDescriptorFactory::get( aContext.getUNOContext() ) ); Reference< XPropertySet > xSource( xFactory->createDataAccessDescriptor(), UNO_SET_THROW ); - xSource->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( _nCommandType ) ); - xSource->setPropertyValue( PROPERTY_COMMAND, makeAny( _sCommand ) ); + xSource->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( i_nCommandType ) ); + xSource->setPropertyValue( PROPERTY_COMMAND, makeAny( i_rCommand ) ); xSource->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSrcConnection ) ); - xSource->setPropertyValue( PROPERTY_SELECTION, makeAny( _aSelection ) ); - xSource->setPropertyValue( PROPERTY_BOOKMARK_SELECTION, makeAny( _bBookmarkSelection ) ); + xSource->setPropertyValue( PROPERTY_RESULT_SET, makeAny( i_rSourceRows ) ); + xSource->setPropertyValue( PROPERTY_SELECTION, makeAny( i_rSelection ) ); + xSource->setPropertyValue( PROPERTY_BOOKMARK_SELECTION, makeAny( i_bBookmarkSelection ) ); Reference< XPropertySet > xDest( xFactory->createDataAccessDescriptor(), UNO_SET_THROW ); - xDest->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( _xDestConnection ) ); + xDest->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( i_rDestConnection ) ); Reference< XCopyTableWizard > xWizard( CopyTableWizard::create( aContext.getUNOContext(), xSource, xDest ), UNO_SET_THROW ); @@ -230,72 +225,62 @@ void OTableCopyHelper::insertTable(sal_Int32 _nCommandType } // ----------------------------------------------------------------------------- -void OTableCopyHelper::pasteTable( const ::svx::ODataAccessDescriptor& _rPasteData, const ::rtl::OUString& _sDestDataSourceName, - const SharedConnection& _xDestConnection ) +void OTableCopyHelper::pasteTable( const ::svx::ODataAccessDescriptor& _rPasteData, const ::rtl::OUString& i_rDestDataSourceName, + const SharedConnection& i_rDestConnection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::pasteTable" ); - Reference xSrcConnection; - ::rtl::OUString sCommand, - sSrcDataSourceName = _rPasteData.getDataSource(); + ::rtl::OUString sSrcDataSourceName = _rPasteData.getDataSource(); + + ::rtl::OUString sCommand; + _rPasteData[ daCommand ] >>= sCommand; - _rPasteData[daCommand] >>= sCommand; + Reference xSrcConnection; if ( _rPasteData.has(daConnection) ) - _rPasteData[daConnection] >>= xSrcConnection; -#if OSL_DEBUG_LEVEL > 0 + { + OSL_VERIFY( _rPasteData[daConnection] >>= xSrcConnection ); + } + + Reference< XResultSet > xResultSet; if ( _rPasteData.has(daCursor) ) { - Reference< XResultSet > xSrcRs; - _rPasteData[daCursor] >>= xSrcRs; - OSL_ENSURE( !xSrcRs.is(), "OTableCopyHelper::pasteTable: source result set not supported anymore!" ); - // There was a time where we supported passing a result set as shortcut to the source - // object. That is, we do not need to create an own result set we already have one. - // Since we UNOized the Copy Table Wizard (#i81658#), we removed this support, since it - // contradicted the semantics of DataAccessDescriptor.ResultSet. - // - // This shouldn't be a problem, since there seems to be no client which actually - // passed a result set here. - // However, if there still is, we probably need to introduce an (undocumented?) property - // at the DataAccessDescriptor, which takes this "source result set". + OSL_VERIFY( _rPasteData[ daCursor ] >>= xResultSet ); } - if ( _rPasteData.has( daSelection ) || _rPasteData.has( daBookmarkSelection ) ) + Sequence< Any > aSelection; + if ( _rPasteData.has( daSelection ) ) { - OSL_ENSURE( false, "OTableCopyHelper::pasteTable: bookmark/selection not supported anymore!" ); - // similar notes here: Selection and BookmarkSelection are not supported in the UNOized - // copy table wizard anymore (it doesn't make sense without support for a source result set), - // and there seem to be no clients which actually use it. So, instead of implementing an - // unused case, we dropped this here. + OSL_VERIFY( _rPasteData[ daSelection ] >>= aSelection ); + OSL_ENSURE( _rPasteData.has( daBookmarkSelection ), "OTableCopyHelper::pasteTable: you should specify BookmarkSelection, too, to be on the safe side!" ); } -#endif - // paste into the tables + + sal_Bool bBookmarkSelection( sal_True ); + if ( _rPasteData.has( daBookmarkSelection ) ) + { + OSL_VERIFY( _rPasteData[ daBookmarkSelection ] >>= bBookmarkSelection ); + } + OSL_ENSURE( bBookmarkSelection, "OTableCopyHelper::pasteTable: working with selection-indicies (instead of bookmarks) is error-prone, and thus deprecated!" ); + sal_Int32 nCommandType = CommandType::COMMAND; if ( _rPasteData.has(daCommandType) ) _rPasteData[daCommandType] >>= nCommandType; - insertTable( nCommandType - ,xSrcConnection - ,Sequence< Any >() - ,sal_False - ,sCommand - ,sSrcDataSourceName - ,_sDestDataSourceName - ,_xDestConnection); + insertTable( sSrcDataSourceName, xSrcConnection, sCommand, nCommandType, + xResultSet, aSelection, bBookmarkSelection, + i_rDestDataSourceName, i_rDestConnection ); } // ----------------------------------------------------------------------------- void OTableCopyHelper::pasteTable( SotFormatStringId _nFormatId ,const TransferableDataHelper& _rTransData - ,const ::rtl::OUString& _sDestDataSourceName + ,const ::rtl::OUString& i_rDestDataSource ,const SharedConnection& _xConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::pasteTable" ); if ( _nFormatId == SOT_FORMATSTR_ID_DBACCESS_TABLE || _nFormatId == SOT_FORMATSTR_ID_DBACCESS_QUERY ) { if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(_rTransData.GetDataFlavorExVector()) ) { ::svx::ODataAccessDescriptor aPasteData = ODataAccessObjectTransferable::extractObjectDescriptor(_rTransData); - pasteTable( aPasteData,_sDestDataSourceName,_xConnection); + pasteTable( aPasteData,i_rDestDataSource,_xConnection); } } else if ( _rTransData.HasFormat(_nFormatId) ) @@ -329,22 +314,20 @@ void OTableCopyHelper::pasteTable( SotFormatStringId _nFormatId // ----------------------------------------------------------------------------- void OTableCopyHelper::pasteTable( const TransferableDataHelper& _rTransData - ,const ::rtl::OUString& _sDestDataSourceName + ,const ::rtl::OUString& i_rDestDataSource ,const SharedConnection& _xConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::pasteTable" ); if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE) || _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) ) - pasteTable( SOT_FORMATSTR_ID_DBACCESS_TABLE,_rTransData,_sDestDataSourceName,_xConnection); + pasteTable( SOT_FORMATSTR_ID_DBACCESS_TABLE,_rTransData,i_rDestDataSource,_xConnection); else if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_HTML) ) - pasteTable( SOT_FORMATSTR_ID_HTML,_rTransData,_sDestDataSourceName,_xConnection); + pasteTable( SOT_FORMATSTR_ID_HTML,_rTransData,i_rDestDataSource,_xConnection); else if ( _rTransData.HasFormat(SOT_FORMAT_RTF) ) - pasteTable( SOT_FORMAT_RTF,_rTransData,_sDestDataSourceName,_xConnection); + pasteTable( SOT_FORMAT_RTF,_rTransData,i_rDestDataSource,_xConnection); } // ----------------------------------------------------------------------------- sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc, sal_Bool _bCheck,const SharedConnection& _xConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::copyTagTable" ); Reference xEvt; ODatabaseImportExport* pImport = NULL; if ( _rDesc.bHtml ) @@ -367,7 +350,6 @@ sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc // ----------------------------------------------------------------------------- sal_Bool OTableCopyHelper::isTableFormat(const TransferableDataHelper& _rClipboard) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::isTableFormat" ); sal_Bool bTableFormat = _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE) || _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) || _rClipboard.HasFormat(SOT_FORMAT_RTF) @@ -380,7 +362,6 @@ sal_Bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& _aDroppedD ,DropDescriptor& _rAsyncDrop ,const SharedConnection& _xConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::copyTagTable" ); sal_Bool bRet = sal_False; sal_Bool bHtml = _aDroppedData.HasFormat(SOT_FORMATSTR_ID_HTML); if ( bHtml || _aDroppedData.HasFormat(SOT_FORMAT_RTF) ) @@ -413,10 +394,9 @@ sal_Bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& _aDroppedD } // ----------------------------------------------------------------------------- void OTableCopyHelper::asyncCopyTagTable( DropDescriptor& _rDesc - ,const ::rtl::OUString& _sDestDataSourceName + ,const ::rtl::OUString& i_rDestDataSource ,const SharedConnection& _xConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::asyncCopyTagTable" ); if ( _rDesc.aHtmlRtfStorage.Is() ) { copyTagTable(_rDesc,sal_False,_xConnection); @@ -427,7 +407,7 @@ void OTableCopyHelper::asyncCopyTagTable( DropDescriptor& _rDesc ::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE)); } else if ( !_rDesc.bError ) - pasteTable(_rDesc.aDroppedData,_sDestDataSourceName,_xConnection); + pasteTable(_rDesc.aDroppedData,i_rDestDataSource,_xConnection); else m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString::createFromAscii("S1000") ,0,Any())); } diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index d872590b3763..a3dc2e6e1e96 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -104,6 +104,7 @@ ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor& const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF, const String& rExchange) :m_xFormatter(_rxNumberF) + ,m_bBookmarkSelection( NULL ) ,m_xFactory(_rM) ,m_nCommandType(CommandType::TABLE) ,m_bNeedToReInitialize(sal_False) @@ -133,7 +134,8 @@ ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor& // import data ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection, const Reference< XNumberFormatter >& _rxNumberF, const Reference< XMultiServiceFactory >& _rM ) - :m_xConnection(_rxConnection) + :m_bBookmarkSelection( NULL ) + ,m_xConnection(_rxConnection) ,m_xFormatter(_rxNumberF) ,m_xFactory(_rM) ,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE) @@ -187,6 +189,7 @@ void ODatabaseImportExport::dispose() m_xResultSetMetaData.clear(); m_xResultSet.clear(); m_xRow.clear(); + m_xRowLocate.clear(); m_xFormatter.clear(); } // ----------------------------------------------------------------------------- @@ -231,20 +234,37 @@ void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor if (xComponent.is() && xEvt.is()) xComponent->addEventListener(xEvt); } - if(_aDataDescriptor.has(daSelection)) - _aDataDescriptor[daSelection] >>= m_aSelection; - sal_Bool bBookmarkSelection = sal_True; // the default if not present + if ( _aDataDescriptor.has( daSelection ) ) + _aDataDescriptor[ daSelection ] >>= m_aSelection; + if ( _aDataDescriptor.has( daBookmarkSelection ) ) + _aDataDescriptor[ daBookmarkSelection ] >>= m_bBookmarkSelection; + + if ( _aDataDescriptor.has( daCursor ) ) { - _aDataDescriptor[ daBookmarkSelection ] >>= bBookmarkSelection; - DBG_ASSERT( !bBookmarkSelection, "ODatabaseImportExport::ODatabaseImportExport: bookmarked selection not yet supported!" ); + _aDataDescriptor[ daCursor ] >>= m_xResultSet; + m_xRowLocate.set( m_xResultSet, UNO_QUERY ); } + if ( m_aSelection.getLength() != 0 ) + { + if ( !m_xResultSet.is() ) + { + OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: selection without result set is nonsense!" ); + m_aSelection.realloc( 0 ); + } + } - if(_aDataDescriptor.has(daCursor)) - _aDataDescriptor[daCursor] >>= m_xResultSet; - } // if ( !_bPlusDefaultInit ) + if ( m_aSelection.getLength() != 0 ) + { + if ( m_bBookmarkSelection && !m_xRowLocate.is() ) + { + OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: no XRowLocate -> no bookmars!" ); + m_aSelection.realloc( 0 ); + } + } + } else initialize(); @@ -314,19 +334,14 @@ void ODatabaseImportExport::initialize() // the result set may be already set with the datadescriptor if ( !m_xResultSet.is() ) { - m_xResultSet.set(m_xFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdb.RowSet")),UNO_QUERY); - Reference xProp(m_xResultSet,UNO_QUERY); - if(xProp.is()) - { - xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) ); - xProp->setPropertyValue(PROPERTY_COMMAND_TYPE,makeAny(m_nCommandType)); - xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sName)); - Reference xRowSet(xProp,UNO_QUERY); - xRowSet->execute(); - } - else - OSL_ENSURE(sal_False, "ODatabaseImportExport::initialize: could not instantiate a rowset!"); - } // if ( !m_xResultSet.is() ) + m_xResultSet.set( m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.sdb.RowSet" ) ), UNO_QUERY ); + Reference< XPropertySet > xProp( m_xResultSet, UNO_QUERY_THROW ); + xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) ); + xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( m_nCommandType ) ); + xProp->setPropertyValue( PROPERTY_COMMAND, makeAny( m_sName ) ); + Reference< XRowSet > xRowSet( xProp, UNO_QUERY ); + xRowSet->execute(); + } impl_initializeRowMember_throw(); } catch(Exception& ) @@ -375,7 +390,8 @@ void ODatabaseImportExport::impl_initializeRowMember_throw() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initializeRowMember_throw" ); if ( !m_xRow.is() && m_xResultSet.is() ) { - m_xRow.set(m_xResultSet,UNO_QUERY); + m_xRow.set( m_xResultSet, UNO_QUERY ); + m_xRowLocate.set( m_xResultSet, UNO_QUERY ); m_xResultSetMetaData = Reference(m_xRow,UNO_QUERY)->getMetaData(); Reference xSup(m_xResultSet,UNO_QUERY_THROW); m_xRowSetColumns.set(xSup->getColumns(),UNO_QUERY_THROW); @@ -570,22 +586,29 @@ BOOL ORTFImportExport::Write() Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY); sal_Int32 k=1; sal_Int32 kk=0; - if(m_aSelection.getLength()) + if ( m_aSelection.getLength() ) { const Any* pSelIter = m_aSelection.getConstArray(); const Any* pEnd = pSelIter + m_aSelection.getLength(); + sal_Bool bContinue = sal_True; - for(;pSelIter != pEnd && bContinue;++pSelIter) + for( ; pSelIter != pEnd && bContinue; ++pSelIter ) { - sal_Int32 nPos = -1; - *pSelIter >>= nPos; - OSL_ENSURE(nPos != -1,"Invalid posiotion!"); - bContinue = (m_xResultSet->absolute(nPos)); - if ( bContinue ) - appendRow(pHorzChar,nCount,k,kk); + if ( m_bBookmarkSelection ) + { + bContinue = m_xRowLocate->moveToBookmark( *pSelIter ); + } + else + { + sal_Int32 nPos = -1; + OSL_VERIFY( *pSelIter >>= nPos ); + bContinue = ( m_xResultSet->absolute( nPos ) ); + } + if ( bContinue ) + appendRow( pHorzChar, nCount, k, kk ); } - } // if(m_aSelection.getLength()) + } else { m_xResultSet->beforeFirst(); // set back before the first row diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index aa2b87fca329..8642250c45c6 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -261,6 +261,17 @@ namespace dbaui sal_Int32& _out_rCommandType ) const; + /** extracts the result set to copy records from, and the selection-related aspects, if any. + + Effectively, this method extracts m_xSourceResultSet, m_aSourceSelection, and m_bSourceSelectionBookmarks. + + If an inconsistent/insufficent sub set of those properties is present in the descriptor, and exception + is thrown. + */ + void impl_extractSourceResultSet_throw( + const Reference< XPropertySet >& i_rDescriptor + ); + /** checks whether the given copy source descriptor contains settings which are not supported (yet) @@ -302,7 +313,7 @@ namespace dbaui /** creates the INSERT INTO statement @param _xTable The destination table. */ - ::rtl::OUString impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable); + ::rtl::OUString impl_getServerSideCopyStatement_throw( const Reference< XPropertySet >& _xTable ); /** creates the statement which, when executed, will produce the source data to copy @@ -345,8 +356,9 @@ private: sal_Int32 m_nCommandType; ::std::auto_ptr< ICopyTableSourceObject > m_pSourceObject; + Reference< XResultSet > m_xSourceResultSet; Sequence< Any > m_aSourceSelection; - bool m_bSourceSelectionBookmarks; + sal_Bool m_bSourceSelectionBookmarks; // destination SharedConnection m_xDestConnection; @@ -393,13 +405,13 @@ CopyTableWizard::CopyTableWizard( const Reference< XMultiServiceFactory >& _rxOR ,m_xSourceConnection() ,m_nCommandType( CommandType::COMMAND ) ,m_pSourceObject() + ,m_xSourceResultSet() ,m_aSourceSelection() - ,m_bSourceSelectionBookmarks( true ) + ,m_bSourceSelectionBookmarks( sal_True ) ,m_xDestConnection() ,m_aCopyTableListeners( m_aMutex ) ,m_nOverrideExecutionResult( -1 ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::CopyTableWizard" ); } //------------------------------------------------------------------------- @@ -415,7 +427,7 @@ CopyTableWizard::~CopyTableWizard() // TODO: shouldn't we have explicit disposal support? If a listener is registered // at our instance, and perhaps holds this our instance by a hard ref, then we'll never - // destroyed. + // be destroyed. // However, adding XComponent support to the GenericUNODialog probably requires // some thinking - would it break existing clients which do not call a dispose, then? } @@ -462,7 +474,6 @@ Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() thr //-------------------------------------------------------------------- ::sal_Int16 SAL_CALL CopyTableWizard::getOperation() throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getOperation" ); CopyTableAccessGuard aGuard( *this ); return m_nOperation; } @@ -470,7 +481,6 @@ Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() thr //-------------------------------------------------------------------- void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (IllegalArgumentException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setOperation" ); CopyTableAccessGuard aGuard( *this ); if ( ( _operation != CopyTableOperation::CopyDefinitionAndData ) @@ -495,7 +505,6 @@ void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (Ill //-------------------------------------------------------------------- ::rtl::OUString SAL_CALL CopyTableWizard::getDestinationTableName() throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getDestinationTableName" ); CopyTableAccessGuard aGuard( *this ); return m_sDestinationTable; } @@ -503,7 +512,6 @@ void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (Ill //-------------------------------------------------------------------- void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _destinationTableName ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setDestinationTableName" ); CopyTableAccessGuard aGuard( *this ); m_sDestinationTable = _destinationTableName; } @@ -511,7 +519,6 @@ void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _ //-------------------------------------------------------------------- Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getCreatePrimaryKey" ); CopyTableAccessGuard aGuard( *this ); return m_aPrimaryKeyName; } @@ -519,7 +526,6 @@ Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() thro //-------------------------------------------------------------------- void SAL_CALL CopyTableWizard::setCreatePrimaryKey( const Optional< ::rtl::OUString >& _newPrimaryKey ) throw (IllegalArgumentException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setCreatePrimaryKey" ); CopyTableAccessGuard aGuard( *this ); if ( _newPrimaryKey.IsPresent && !OCopyTableWizard::supportsPrimaryKey( m_xDestConnection ) ) @@ -546,7 +552,6 @@ void SAL_CALL CopyTableWizard::setUseHeaderLineAsColumnNames( sal_Bool _bUseHead //-------------------------------------------------------------------- void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::addCopyTableListener" ); CopyTableAccessGuard aGuard( *this ); if ( _rxListener.is() ) m_aCopyTableListeners.addInterface( _rxListener ); @@ -555,7 +560,6 @@ void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTable //-------------------------------------------------------------------- void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::removeCopyTableListener" ); CopyTableAccessGuard aGuard( *this ); if ( _rxListener.is() ) m_aCopyTableListeners.removeInterface( _rxListener ); @@ -564,7 +568,6 @@ void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTa //-------------------------------------------------------------------- void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setTitle" ); CopyTableAccessGuard aGuard( *this ); CopyTableWizard_DialogBase::setTitle( _rTitle ); } @@ -572,7 +575,6 @@ void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw //-------------------------------------------------------------------- ::sal_Int16 SAL_CALL CopyTableWizard::execute( ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::execute" ); CopyTableAccessGuard aGuard( *this ); m_nOverrideExecutionResult = -1; @@ -586,7 +588,6 @@ void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw //------------------------------------------------------------------------- OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" ); OCopyTableWizard* pWizard = dynamic_cast< OCopyTableWizard* >( m_pDialog ); if ( !pWizard ) throw DisposedException( ::rtl::OUString(), *this ); @@ -596,7 +597,6 @@ OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() //------------------------------------------------------------------------- const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" ); const OCopyTableWizard* pWizard = dynamic_cast< const OCopyTableWizard* >( m_pDialog ); if ( !pWizard ) throw DisposedException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) ); @@ -606,7 +606,6 @@ const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const //------------------------------------------------------------------------- void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialog ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_attributesToDialog_nothrow" ); // primary key column _rDialog.setCreatePrimaryKey( m_aPrimaryKeyName.IsPresent, m_aPrimaryKeyName.Value ); _rDialog.setUseHeaderLine(m_bUseHeaderLineAsColumnNames); @@ -617,7 +616,6 @@ void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialo //------------------------------------------------------------------------- void CopyTableWizard::impl_dialogToAttributes_nothrow( const OCopyTableWizard& _rDialog ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_dialogToAttributes_nothrow" ); m_aPrimaryKeyName.IsPresent = _rDialog.shouldCreatePrimaryKey(); if ( m_aPrimaryKeyName.IsPresent ) m_aPrimaryKeyName.Value = _rDialog.getPrimaryKeyName(); @@ -692,7 +690,6 @@ Reference< XPropertySet > CopyTableWizard::impl_ensureDataAccessDescriptor_throw const Sequence< Any >& _rAllArgs, const sal_Int16 _nArgPos, SharedConnection& _out_rxConnection, InteractionHandler& _out_rxDocInteractionHandler ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_ensureDataAccessDescriptor_throw" ); Reference< XPropertySet > xDescriptor; _rAllArgs[ _nArgPos ] >>= xDescriptor; @@ -745,32 +742,19 @@ namespace //------------------------------------------------------------------------- void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< XPropertySet >& _rxSourceDescriptor ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_checkForUnsupportedSettings_throw" ); OSL_PRECOND( _rxSourceDescriptor.is(), "CopyTableWizard::impl_checkForUnsupportedSettings_throw: illegal argument!" ); Reference< XPropertySetInfo > xPSI( _rxSourceDescriptor->getPropertySetInfo(), UNO_SET_THROW ); ::rtl::OUString sUnsupportedSetting; - // in theory, we could allow to use a mere result set as copy source. However, since this is currently - // not implemented at all, we report this in the initialization phase already - if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) ) - { - Reference< XResultSet > xSource( _rxSourceDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY ); - if ( xSource.is() ) - sUnsupportedSetting = PROPERTY_RESULT_SET; - } - - if ( sUnsupportedSetting.getLength() == 0 ) + const ::rtl::OUString aSettings[] = { + PROPERTY_FILTER, PROPERTY_ORDER, PROPERTY_HAVING_CLAUSE, PROPERTY_GROUP_BY + }; + for ( size_t i=0; i < sizeof( aSettings ) / sizeof( aSettings[0] ); ++i ) { - const ::rtl::OUString aSettings[] = { - PROPERTY_FILTER, PROPERTY_ORDER, PROPERTY_HAVING_CLAUSE, PROPERTY_GROUP_BY - }; - for ( size_t i=0; i < sizeof( aSettings ) / sizeof( aSettings[0] ); ++i ) + if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) ) { - if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) ) - { - sUnsupportedSetting = aSettings[i]; - break; - } + sUnsupportedSetting = aSettings[i]; + break; } } @@ -790,17 +774,15 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X //------------------------------------------------------------------------- ::std::auto_ptr< ICopyTableSourceObject > CopyTableWizard::impl_extractSourceObject_throw( const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractSourceObject_throw" ); OSL_PRECOND( _rxDescriptor.is() && m_xSourceConnection.is(), "CopyTableWizard::impl_extractSourceObject_throw: illegal arguments!" ); - impl_checkForUnsupportedSettings_throw( _rxDescriptor ); - Reference< XPropertySetInfo > xPSI( _rxDescriptor->getPropertySetInfo(), UNO_SET_THROW ); if ( !xPSI->hasPropertyByName( PROPERTY_COMMAND ) || !xPSI->hasPropertyByName( PROPERTY_COMMAND_TYPE ) ) throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Expecting a table or query specification." ) ), + // TODO: resource *const_cast< CopyTableWizard* >( this ), 1 ); @@ -859,11 +841,49 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X return pSourceObject; } +//------------------------------------------------------------------------- +void CopyTableWizard::impl_extractSourceResultSet_throw( const Reference< XPropertySet >& i_rDescriptor ) +{ + Reference< XPropertySetInfo > xPSI( i_rDescriptor->getPropertySetInfo(), UNO_SET_THROW ); + + // extract relevant settings + if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) ) + m_xSourceResultSet.set( i_rDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY ); + + if ( xPSI->hasPropertyByName( PROPERTY_SELECTION ) ) + OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_SELECTION ) >>= m_aSourceSelection ); + + if ( xPSI->hasPropertyByName( PROPERTY_BOOKMARK_SELECTION ) ) + OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_BOOKMARK_SELECTION ) >>= m_bSourceSelectionBookmarks ); + + // sanity checks + const bool bHasResultSet = m_xSourceResultSet.is(); + const bool bHasSelection = ( m_aSourceSelection.getLength() != 0 ); + if ( bHasSelection && !bHasResultSet ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "A result set is needed when specifying a selection to copy." ) ), + // TODO: resource + *this, + 1 + ); + + if ( bHasSelection && m_bSourceSelectionBookmarks ) + { + Reference< XRowLocate > xRowLocate( m_xSourceResultSet, UNO_QUERY ); + if ( !xRowLocate.is() ) + { + ::dbtools::throwGenericSQLException( + String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ), + *this + ); + } + } +} + //------------------------------------------------------------------------- SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference< XPropertySet >& _rxDataSourceDescriptor, InteractionHandler& _out_rxDocInteractionHandler ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractConnection_throw" ); SharedConnection xConnection; OSL_PRECOND( _rxDataSourceDescriptor.is(), "CopyTableWizard::impl_extractConnection_throw: no descriptor!" ); @@ -957,7 +977,6 @@ SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference< //------------------------------------------------------------------------- ::utl::SharedUNOComponent< XPreparedStatement > CopyTableWizard::impl_createSourceStatement_throw() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_createSourceStatement_throw" ); OSL_PRECOND( m_xSourceConnection.is(), "CopyTableWizard::impl_createSourceStatement_throw: illegal call!" ); if ( !m_xSourceConnection.is() ) throw RuntimeException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) ); @@ -1062,7 +1081,6 @@ namespace //------------------------------------------------------------------------- bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _rEvent ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_processCopyError_nothrow" ); Reference< XCopyTableListener > xListener; try { @@ -1141,7 +1159,6 @@ bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _r void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSourceResultSet, const Reference< XPropertySet >& _rxDestTable ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_copyRows_throw" ); OSL_PRECOND( m_xDestConnection.is(), "CopyTableWizard::impl_copyRows_throw: illegal call!" ); if ( !m_xDestConnection.is() ) throw RuntimeException( ::rtl::OUString(), *this ); @@ -1153,16 +1170,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou bool bAutoIncrement = rWizard.shouldCreatePrimaryKey(); Reference< XRow > xRow ( _rxSourceResultSet, UNO_QUERY_THROW ); - Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY ); - - bool bSelectedRecordsOnly = m_aSourceSelection.getLength() > 0; - if ( bSelectedRecordsOnly && m_bSourceSelectionBookmarks && !xRowLocate.is() ) - { - ::dbtools::throwGenericSQLException( - String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ), - *this - ); - } + Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY_THROW ); Reference< XResultSetMetaDataSupplier > xSuppResMeta( _rxSourceResultSet, UNO_QUERY_THROW ); Reference< XResultSetMetaData> xMeta( xSuppResMeta->getMetaData() ); @@ -1180,9 +1188,11 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou Reference< XPreparedStatement > xStatement( ODatabaseExport::createPreparedStatment( xDestMetaData, _rxDestTable, aColumnMapping ), UNO_SET_THROW ); Reference< XParameters > xStatementParams( xStatement, UNO_QUERY_THROW ); + const bool bSelectedRecordsOnly = m_aSourceSelection.getLength() != 0; + const Any* pSelectedRow = m_aSourceSelection.getConstArray(); + const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength(); + sal_Int32 nRowCount = 0; - const Any* pSelectedRow = m_aSourceSelection.getConstArray(); - const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength(); bool bContinue = false; CopyTableRowEvent aCopyEvent; @@ -1198,7 +1208,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou { if ( m_bSourceSelectionBookmarks ) { - xRowLocate->moveToBookmark( *pSelectedRow ); + bContinue = xRowLocate->moveToBookmark( *pSelectedRow ); } else { @@ -1358,7 +1368,6 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou //------------------------------------------------------------------------- void CopyTableWizard::impl_doCopy_nothrow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_doCopy_nothrow" ); Any aError; try @@ -1399,26 +1408,41 @@ void CopyTableWizard::impl_doCopy_nothrow() } } - bool bServerCopy = CommandType::TABLE == m_nCommandType && m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() && !m_aSourceSelection.getLength(); - try + ::utl::SharedUNOComponent< XPreparedStatement > xSourceStatement; + ::utl::SharedUNOComponent< XResultSet > xSourceResultSet; + + if ( m_xSourceResultSet.is() ) { - if ( bServerCopy ) - { - m_xDestConnection->createStatement()->executeUpdate( impl_getSelectStatement_nothrow(xTable) ); - } + xSourceResultSet.reset( m_xSourceResultSet, ::utl::SharedUNOComponent< XResultSet >::NoTakeOwnership ); } - catch( const Exception& e ) + else { - (void)e; - bServerCopy = false; + const bool bIsSameConnection = ( m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() ); + const bool bIsTable = ( CommandType::TABLE == m_nCommandType ); + bool bDone = false; + if ( bIsSameConnection && bIsTable ) + { + // try whether the server supports copying via SQL + try + { + m_xDestConnection->createStatement()->executeUpdate( impl_getServerSideCopyStatement_throw(xTable) ); + bDone = true; + } + catch( const Exception& ) + { + // this is allowed. + } + } + + if ( !bDone ) + { + xSourceStatement.set( impl_createSourceStatement_throw(), UNO_SET_THROW ); + xSourceResultSet.set( xSourceStatement->executeQuery(), UNO_SET_THROW ); + } } - if ( !bServerCopy ) - { - ::utl::SharedUNOComponent< XPreparedStatement > xStatement( impl_createSourceStatement_throw(), UNO_SET_THROW ); - Reference< XResultSet > xSourceResultSet( xStatement->executeQuery() ); + if ( xSourceResultSet.is() ) impl_copyRows_throw( xSourceResultSet, xTable ); - } } break; @@ -1458,7 +1482,7 @@ void CopyTableWizard::impl_doCopy_nothrow() } } // ----------------------------------------------------------------------------- -::rtl::OUString CopyTableWizard::impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable) +::rtl::OUString CopyTableWizard::impl_getServerSideCopyStatement_throw(const Reference< XPropertySet >& _xTable) { const Reference xDestColsSup(_xTable,UNO_QUERY_THROW); const Sequence< ::rtl::OUString> aDestColumnNames = xDestColsSup->getColumns()->getElementNames(); @@ -1496,7 +1520,6 @@ void CopyTableWizard::impl_doCopy_nothrow() //------------------------------------------------------------------------- void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::initialize" ); ::osl::MutexGuard aGuard( m_aMutex ); if ( isInitialized() ) throw AlreadyInitializedException( ::rtl::OUString(), *this ); @@ -1525,7 +1548,9 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) InteractionHandler xSourceDocHandler; Reference< XPropertySet > xSourceDescriptor( impl_ensureDataAccessDescriptor_throw( _rArguments, 0, m_xSourceConnection, xSourceDocHandler ) ); + impl_checkForUnsupportedSettings_throw( xSourceDescriptor ); m_pSourceObject = impl_extractSourceObject_throw( xSourceDescriptor, m_nCommandType ); + impl_extractSourceResultSet_throw( xSourceDescriptor ); InteractionHandler xDestDocHandler; impl_ensureDataAccessDescriptor_throw( _rArguments, 1, m_xDestConnection, xDestDocHandler ); @@ -1549,14 +1574,12 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) //------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper& CopyTableWizard::getInfoHelper() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getInfoHelper" ); return *getArrayHelper(); } //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper* CopyTableWizard::createArrayHelper( ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createArrayHelper" ); Sequence< Property > aProps; describeProperties( aProps ); return new ::cppu::OPropertyArrayHelper( aProps ); @@ -1565,7 +1588,6 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) //------------------------------------------------------------------------------ Dialog* CopyTableWizard::createDialog( Window* _pParent ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createDialog" ); OSL_PRECOND( isInitialized(), "CopyTableWizard::createDialog: not initialized!" ); // this should have been prevented in ::execute already @@ -1588,7 +1610,6 @@ Dialog* CopyTableWizard::createDialog( Window* _pParent ) //------------------------------------------------------------------------------ void CopyTableWizard::executedDialog( sal_Int16 _nExecutionResult ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::executedDialog" ); CopyTableWizard_DialogBase::executedDialog( _nExecutionResult ); if ( _nExecutionResult == RET_OK ) -- cgit From fc5608783995783e5d4804787fab31d4fc979533 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 11 Jan 2010 13:22:04 +0100 Subject: dba33f: #i108079# travel through connection, begin with table with highest number of connections --- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 123 +++++++++++++-------- 1 file changed, 79 insertions(+), 44 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 83ed283a4836..de062c093a46 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -610,14 +610,16 @@ namespace //------------------------------------------------------------------------------ SqlParseError InsertJoinConnection( const OQueryDesignView* _pView, const ::connectivity::OSQLParseNode *pNode, - const EJoinType& _eJoinType) + const EJoinType& _eJoinType, + const ::connectivity::OSQLParseNode *pLeftTable, + const ::connectivity::OSQLParseNode *pRightTable) { SqlParseError eErrorCode = eOk; if (pNode->count() == 3 && // Ausdruck is geklammert SQL_ISPUNCTUATION(pNode->getChild(0),"(") && SQL_ISPUNCTUATION(pNode->getChild(2),")")) { - eErrorCode = InsertJoinConnection(_pView,pNode->getChild(1), _eJoinType); + eErrorCode = InsertJoinConnection(_pView,pNode->getChild(1), _eJoinType,pLeftTable,pRightTable); } else if (SQL_ISRULEOR2(pNode,search_condition,boolean_term) && // AND/OR-Verknuepfung: pNode->count() == 3) @@ -625,8 +627,8 @@ namespace // nur AND Verknüpfung zulassen if (!SQL_ISTOKEN(pNode->getChild(1),AND)) eErrorCode = eIllegalJoinCondition; - else if ( eOk == (eErrorCode = InsertJoinConnection(_pView,pNode->getChild(0), _eJoinType)) ) - eErrorCode = InsertJoinConnection(_pView,pNode->getChild(2), _eJoinType); + else if ( eOk == (eErrorCode = InsertJoinConnection(_pView,pNode->getChild(0), _eJoinType,pLeftTable,pRightTable)) ) + eErrorCode = InsertJoinConnection(_pView,pNode->getChild(2), _eJoinType,pLeftTable,pRightTable); } else if (SQL_ISRULE(pNode,comparison_predicate)) { @@ -647,7 +649,17 @@ namespace eOk != ( eErrorCode = FillDragInfo(_pView,pNode->getChild(2),aDragRight))) return eErrorCode; - insertConnection(_pView,_eJoinType,aDragLeft,aDragRight); + if ( pLeftTable ) + { + OQueryTableWindow* pLeftWindow = static_cast(_pView->getTableView())->FindTable( getTableRange(_pView,pLeftTable->getByRule(OSQLParseNode::table_ref) )); + OQueryTableWindow* pRightWindow = static_cast(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTable->getByRule(OSQLParseNode::table_ref) )); + if ( pLeftWindow == aDragLeft->GetTabWindow() ) + insertConnection(_pView,_eJoinType,aDragLeft,aDragRight); + else + insertConnection(_pView,_eJoinType,aDragRight,aDragLeft); + } + else + insertConnection(_pView,_eJoinType,aDragLeft,aDragRight); } else eErrorCode = eIllegalJoin; @@ -657,7 +669,7 @@ namespace sal_Bool GetInnerJoinCriteria( const OQueryDesignView* _pView, const ::connectivity::OSQLParseNode *pCondition) { - return InsertJoinConnection(_pView,pCondition, INNER_JOIN) != eOk; + return InsertJoinConnection(_pView,pCondition, INNER_JOIN,NULL,NULL) != eOk; } //------------------------------------------------------------------------------ ::rtl::OUString GenerateSelectList( const OQueryDesignView* _pView, @@ -1099,53 +1111,76 @@ namespace { ::std::vector::const_iterator aIter = pConnList->begin(); ::std::vector::const_iterator aEnd = pConnList->end(); + ::std::map aConnectionCount; for(;aIter != aEnd;++aIter) + { static_cast(*aIter)->SetVisited(sal_False); + if ( aConnectionCount.find((*aIter)->GetSourceWin()) == aConnectionCount.end() ) + aConnectionCount.insert(::std::map::value_type((*aIter)->GetSourceWin(),0)); + else + aConnectionCount[(*aIter)->GetSourceWin()]++; + if ( aConnectionCount.find((*aIter)->GetDestWin()) == aConnectionCount.end() ) + aConnectionCount.insert(::std::map::value_type((*aIter)->GetDestWin(),0)); + else + aConnectionCount[(*aIter)->GetDestWin()]++; + } + ::std::multimap aMulti; + ::std::map::iterator aCountIter = aConnectionCount.begin(); + ::std::map::iterator aCountEnd = aConnectionCount.end(); + for(;aCountIter != aCountEnd;++aCountIter) + { + aMulti.insert(::std::multimap::value_type(aCountIter->second,aCountIter->first)); + } - aIter = pConnList->begin(); const sal_Bool bUseEscape = ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_OUTERJOINESCAPE ); - for(;aIter != aEnd;++aIter) + ::std::multimap::reverse_iterator aRIter = aMulti.rbegin(); + ::std::multimap::reverse_iterator aREnd = aMulti.rend(); + for(;aRIter != aREnd;++aRIter) { - OQueryTableConnection* pEntryConn = static_cast(*aIter); - if(!pEntryConn->IsVisited()) + ::std::vector::const_iterator aConIter = aRIter->second->getTableView()->getTableConnections(aRIter->second); + for(;aConIter != aEnd;++aConIter) { - ::rtl::OUString aJoin; - GetNextJoin(_xConnection,pEntryConn,static_cast(pEntryConn->GetDestWin()),aJoin); - - if(aJoin.getLength()) + OQueryTableConnection* pEntryConn = static_cast(*aConIter); + if(!pEntryConn->IsVisited() && pEntryConn->GetSourceWin() == aRIter->second ) { - // insert tables into table list to avoid double entries - OQueryTableWindow* pEntryTabFrom = static_cast(pEntryConn->GetSourceWin()); - OQueryTableWindow* pEntryTabTo = static_cast(pEntryConn->GetDestWin()); - - ::rtl::OUString sTabName(BuildTable(_xConnection,pEntryTabFrom)); - if(aTableNames.find(sTabName) == aTableNames.end()) - aTableNames[sTabName] = sal_True; - sTabName = BuildTable(_xConnection,pEntryTabTo); - if(aTableNames.find(sTabName) == aTableNames.end()) - aTableNames[sTabName] = sal_True; - - ::rtl::OUString aStr; - switch(static_cast(pEntryConn->GetData().get())->GetJoinType()) + ::rtl::OUString aJoin; + GetNextJoin(_xConnection,pEntryConn,static_cast(pEntryConn->GetDestWin()),aJoin); + + if(aJoin.getLength()) { - case LEFT_JOIN: - case RIGHT_JOIN: - case FULL_JOIN: - { - // create outer join - if ( bUseEscape ) - aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("{ OJ ")); + // insert tables into table list to avoid double entries + OQueryTableWindow* pEntryTabFrom = static_cast(pEntryConn->GetSourceWin()); + OQueryTableWindow* pEntryTabTo = static_cast(pEntryConn->GetDestWin()); + + ::rtl::OUString sTabName(BuildTable(_xConnection,pEntryTabFrom)); + if(aTableNames.find(sTabName) == aTableNames.end()) + aTableNames[sTabName] = sal_True; + sTabName = BuildTable(_xConnection,pEntryTabTo); + if(aTableNames.find(sTabName) == aTableNames.end()) + aTableNames[sTabName] = sal_True; + + ::rtl::OUString aStr; + switch(static_cast(pEntryConn->GetData().get())->GetJoinType()) + { + case LEFT_JOIN: + case RIGHT_JOIN: + case FULL_JOIN: + { + // create outer join + if ( bUseEscape ) + aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("{ OJ ")); + aStr += aJoin; + if ( bUseEscape ) + aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" }")); + } + break; + default: aStr += aJoin; - if ( bUseEscape ) - aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" }")); - } - break; - default: - aStr += aJoin; - break; + break; + } + aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); + aTableListStr += aStr; } - aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); - aTableListStr += aStr; } } } @@ -1943,7 +1978,7 @@ namespace } if ( SQL_ISRULE(pNode->getChild(4),join_condition) ) { - if ( InsertJoinConnection(_pView,pNode->getChild(4)->getChild(1), eJoinType) != eOk ) + if ( InsertJoinConnection(_pView,pNode->getChild(4)->getChild(1), eJoinType,pNode->getChild(0),pRightTableRef) != eOk ) return sal_False; } } -- cgit From 9b558f5f9d7806c7a73393ee2566f676ca8b6fff Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 11 Jan 2010 14:33:57 +0100 Subject: dba33f: #i102631# --- dbaccess/qa/complex/dbaccess/DatabaseDocument.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dbaccess') diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java index 8ce063bcdb2a..abb34aa5b05f 100644 --- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java +++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java @@ -842,8 +842,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. final String otherURL = copyToTempFile(databaseDoc.getURL()); final XModel otherDoc = (XModel) UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(otherURL, _BLANK, 0, impl_getDefaultLoadArgs())); - impl_waitForEvent(m_globalEvents, "OnLoad", 5000, previousOnLoadEventPos + 1); impl_raise(otherDoc); + impl_waitForEvent(m_globalEvents, "OnLoad", 5000, previousOnLoadEventPos + 1); // ... and switch between the two impl_startObservingEvents(context); -- cgit From cf9158209265ef2bcd22dc1955e3a52170eb4a44 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Tue, 12 Jan 2010 07:20:57 +0100 Subject: dba33f: wrong order of member ini --- dbaccess/source/ui/misc/TokenWriter.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index a3dc2e6e1e96..c8c06d2b8fcb 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -103,8 +103,8 @@ ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor& const Reference< XMultiServiceFactory >& _rM, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF, const String& rExchange) - :m_xFormatter(_rxNumberF) - ,m_bBookmarkSelection( NULL ) + :m_bBookmarkSelection( NULL ) + ,m_xFormatter(_rxNumberF) ,m_xFactory(_rM) ,m_nCommandType(CommandType::TABLE) ,m_bNeedToReInitialize(sal_False) -- cgit From f950279763483bb0ca11a234ebeefe2c78580f4b Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 13 Jan 2010 08:44:34 +0100 Subject: dba33f: #i20615# new feature to allow server side column descrriptions to be visible and changeable in the table designer. --- dbaccess/inc/dbaccess_helpid.hrc | 2 +- dbaccess/source/core/dataaccess/ModelImpl.cxx | 1 + dbaccess/source/core/misc/dsntypes.cxx | 6 + dbaccess/source/inc/dsntypes.hxx | 3 + dbaccess/source/ui/browser/unodatbr.cxx | 8 +- dbaccess/source/ui/dlg/dbwizsetup.cxx | 2 +- dbaccess/source/ui/inc/FieldDescControl.hxx | 33 ++--- dbaccess/source/ui/inc/FieldDescriptions.hxx | 3 + dbaccess/source/ui/inc/dbu_tbl.hrc | 3 +- dbaccess/source/ui/misc/UITools.cxx | 1 + dbaccess/source/ui/misc/WCopyTable.cxx | 2 +- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 1 + .../source/ui/tabledesign/FieldDescriptions.cxx | 29 +++- dbaccess/source/ui/tabledesign/TEditControl.cxx | 146 +++++++++++++++------ dbaccess/source/ui/tabledesign/TEditControl.hxx | 2 + dbaccess/source/ui/tabledesign/TableController.cxx | 15 ++- dbaccess/source/ui/tabledesign/TableRow.cxx | 3 + dbaccess/source/ui/tabledesign/table.src | 6 +- dbaccess/util/hidother.src | 2 + 19 files changed, 199 insertions(+), 69 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/inc/dbaccess_helpid.hrc b/dbaccess/inc/dbaccess_helpid.hrc index ec30ff3d3d1d..9ca34ebc9eae 100644 --- a/dbaccess/inc/dbaccess_helpid.hrc +++ b/dbaccess/inc/dbaccess_helpid.hrc @@ -330,7 +330,7 @@ #define HID_APP_VIEW_PREVIEW_CB (HID_DBACCESS_START + 276) #define HID_APP_VIEW_PREVIEW_1 (HID_DBACCESS_START + 277) #define HID_APP_VIEW_PREVIEW_2 (HID_DBACCESS_START + 278) -// free +#define HID_TABDESIGN_HELPTEXT (HID_DBACCESS_START + 279) #define UID_APP_VIEW_HORZ_SPLIT (HID_DBACCESS_START + 280) #define UID_APP_VIEW_PREVIEW_1 (HID_DBACCESS_START + 281) #define HID_APP_VIEW_PREVIEW_3 (HID_DBACCESS_START + 282) diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 5abf774e1d92..e708be75cdba 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -1167,6 +1167,7 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() AsciiPropertyValue( "ImplicitCatalogRestriction", ::cppu::UnoType< ::rtl::OUString >::get() ), AsciiPropertyValue( "ImplicitSchemaRestriction", ::cppu::UnoType< ::rtl::OUString >::get() ), AsciiPropertyValue( "PrimaryKeySupport", ::cppu::UnoType< sal_Bool >::get() ), + AsciiPropertyValue( "ShowColumnDescription", makeAny( (sal_Bool)sal_False ) ), // known SDB level settings AsciiPropertyValue( "NoNameLengthLimit", makeAny( (sal_Bool)sal_False ) ), AsciiPropertyValue( "AppendTableAliasName", makeAny( (sal_Bool)sal_False ) ), diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 9793da690a2e..de6f89c24d2c 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -281,6 +281,12 @@ sal_Bool ODsnTypeCollection::supportsTableCreation(const ::rtl::OUString& _sURL) return aFeatures.getOrDefault("SupportsTableCreation",sal_False); } // ----------------------------------------------------------------------------- +sal_Bool ODsnTypeCollection::supportsColumnDescription(const ::rtl::OUString& _sURL) const +{ + const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL); + return aFeatures.getOrDefault("SupportsColumnDescription",sal_False); +} +// ----------------------------------------------------------------------------- sal_Bool ODsnTypeCollection::supportsBrowsing(const ::rtl::OUString& _sURL) const { const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL); diff --git a/dbaccess/source/inc/dsntypes.hxx b/dbaccess/source/inc/dsntypes.hxx index 4e9153a6a216..b294ef20d1a9 100644 --- a/dbaccess/source/inc/dsntypes.hxx +++ b/dbaccess/source/inc/dsntypes.hxx @@ -162,6 +162,9 @@ public: /// check if the given data source allows creation of tables sal_Bool supportsTableCreation(const ::rtl::OUString& _sURL) const; + /// check if the given data source allows to show column description. + sal_Bool supportsColumnDescription(const ::rtl::OUString& _sURL) const; + // check if a Browse button may be shown to insert connection url sal_Bool supportsBrowsing(const ::rtl::OUString& _sURL) const; diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 1e10e9421047..d6b6483f4a7f 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -681,8 +681,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 diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 9c14bfabd17a..a092109efe80 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -945,7 +945,7 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() { ::rtl::OUString sEmbeddedURL = m_pCollection->getEmbeddedDatabase(); ::connectivity::DriversConfig aDriverConfig(getORB()); - if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() || m_pImpl->getDriver(sEmbeddedURL).is() ) + if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() || !m_pImpl->getDriver(sEmbeddedURL).is() ) sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")); return sEmbeddedURL; diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx index c77942cd71c0..e7828590c53b 100644 --- a/dbaccess/source/ui/inc/FieldDescControl.hxx +++ b/dbaccess/source/ui/inc/FieldDescControl.hxx @@ -50,22 +50,23 @@ // die Spalten einer Feld-Beschreibung einer Tabelle #define FIELD_NAME 1 #define FIELD_TYPE 2 -#define FIELD_DESCR 3 - -#define FIELD_FIRST_VIRTUAL_COLUMN 4 - -#define FIELD_PROPERTY_REQUIRED 4 -#define FIELD_PROPERTY_NUMTYPE 5 -#define FIELD_PROPERTY_AUTOINC 6 -#define FIELD_PROPERTY_DEFAULT 7 -#define FIELD_PROPERTY_TEXTLEN 8 -#define FIELD_PROPERTY_LENGTH 9 -#define FIELD_PROPERTY_SCALE 10 -#define FIELD_PROPERTY_BOOL_DEFAULT 11 -#define FIELD_PROPERTY_FORMAT 12 -#define FIELD_PRPOERTY_COLUMNNAME 13 -#define FIELD_PRPOERTY_TYPE 14 -#define FIELD_PRPOERTY_AUTOINCREMENT 15 +#define HELP_TEXT 3 +#define COLUMN_DESCRIPTION 4 + +#define FIELD_FIRST_VIRTUAL_COLUMN 5 + +#define FIELD_PROPERTY_REQUIRED 5 +#define FIELD_PROPERTY_NUMTYPE 6 +#define FIELD_PROPERTY_AUTOINC 7 +#define FIELD_PROPERTY_DEFAULT 8 +#define FIELD_PROPERTY_TEXTLEN 9 +#define FIELD_PROPERTY_LENGTH 10 +#define FIELD_PROPERTY_SCALE 11 +#define FIELD_PROPERTY_BOOL_DEFAULT 12 +#define FIELD_PROPERTY_FORMAT 13 +#define FIELD_PRPOERTY_COLUMNNAME 14 +#define FIELD_PRPOERTY_TYPE 15 +#define FIELD_PRPOERTY_AUTOINCREMENT 16 class FixedText; class PushButton; diff --git a/dbaccess/source/ui/inc/FieldDescriptions.hxx b/dbaccess/source/ui/inc/FieldDescriptions.hxx index ee473b032853..4273ea9d62ff 100644 --- a/dbaccess/source/ui/inc/FieldDescriptions.hxx +++ b/dbaccess/source/ui/inc/FieldDescriptions.hxx @@ -67,6 +67,7 @@ namespace dbaui ::rtl::OUString m_sName; ::rtl::OUString m_sTypeName; ::rtl::OUString m_sDescription; + ::rtl::OUString m_sHelpText; ::rtl::OUString m_sAutoIncrementValue; sal_Int32 m_nType; // only used when m_pType is null @@ -89,6 +90,7 @@ namespace dbaui void SetName(const ::rtl::OUString& _rName); void SetDescription(const ::rtl::OUString& _rDescription); + void SetHelpText(const ::rtl::OUString& _sHelptext); void SetDefaultValue(const ::com::sun::star::uno::Any& _rDefaultValue); void SetControlDefault(const ::com::sun::star::uno::Any& _rControlDefault); void SetAutoIncrementValue(const ::rtl::OUString& _sAutoIncValue); @@ -113,6 +115,7 @@ namespace dbaui ::rtl::OUString GetName() const; ::rtl::OUString GetDescription() const; + ::rtl::OUString GetHelpText() const; ::com::sun::star::uno::Any GetControlDefault() const; ::rtl::OUString GetAutoIncrementValue() const; sal_Int32 GetType() const; diff --git a/dbaccess/source/ui/inc/dbu_tbl.hrc b/dbaccess/source/ui/inc/dbu_tbl.hrc index 4f8e99655d76..1f2ba31a0eb8 100644 --- a/dbaccess/source/ui/inc/dbu_tbl.hrc +++ b/dbaccess/source/ui/inc/dbu_tbl.hrc @@ -44,7 +44,7 @@ #define STR_TAB_FIELD_NAME RID_STR_TBL_START + 7 #define STR_TAB_FIELD_DATATYPE RID_STR_TBL_START + 8 #define STR_TAB_FIELD_LENGTH RID_STR_TBL_START + 9 -#define STR_TAB_FIELD_DESCR RID_STR_TBL_START + 10 +#define STR_TAB_HELP_TEXT RID_STR_TBL_START + 10 #define STR_TAB_FIELD_NULLABLE RID_STR_TBL_START + 11 #define STR_FIELD_AUTOINCREMENT RID_STR_TBL_START + 12 #define STR_TAB_PROPERTIES RID_STR_TBL_START + 13 @@ -89,6 +89,7 @@ #define STR_CHANGE_COLUMN_ATTRIBUTE RID_STR_TBL_START + 52 #define STR_TABLEDESIGN_SAVE_ERROR RID_STR_TBL_START + 53 #define STR_TABLEDESIGN_COULD_NOT_DROP_COL RID_STR_TBL_START + 54 +#define STR_COLUMN_DESCRIPTION RID_STR_TBL_START + 55 // please adjust checking before insert new strings diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 8d7e24e2792c..6fde27636be9 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -892,6 +892,7 @@ void setColumnProperties(const Reference& _rxColumn,const OFieldDe _rxColumn->setPropertyValue(PROPERTY_SCALE,makeAny(_pFieldDesc->GetScale())); _rxColumn->setPropertyValue(PROPERTY_ISNULLABLE, makeAny(_pFieldDesc->GetIsNullable())); _rxColumn->setPropertyValue(PROPERTY_ISAUTOINCREMENT,::cppu::bool2any(_pFieldDesc->IsAutoIncrement())); + _rxColumn->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_pFieldDesc->GetDescription())); if ( _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISCURRENCY) && _pFieldDesc->IsCurrency() ) _rxColumn->setPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(_pFieldDesc->IsCurrency())); // set autoincrement value when available diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 1cdf6156a789..fefa641d3d3f 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -371,7 +371,7 @@ void NamedTableCopySource::impl_ensureColumnInfo_throw() OFieldDescription aDesc; aDesc.SetName( xStatementMeta->getColumnName( i ) ); - aDesc.SetDescription( xStatementMeta->getColumnLabel( i ) ); + aDesc.SetHelpText( xStatementMeta->getColumnLabel( i ) ); aDesc.SetTypeValue( xStatementMeta->getColumnType( i ) ); aDesc.SetTypeName( xStatementMeta->getColumnTypeName( i ) ); aDesc.SetPrecision( xStatementMeta->getPrecision( i ) ); diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index de062c093a46..afd5124851c4 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -3157,6 +3157,7 @@ OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pE Reference xMeta = xConnection->getMetaData(); parse::OParseColumn* pColumn = new parse::OParseColumn( pEntry->GetField(), + ::rtl::OUString(), ::rtl::OUString(), ::rtl::OUString(), ColumnValue::NULLABLE_UNKNOWN, diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index 6e90ebed7e88..6e75f1e969f8 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -157,6 +157,8 @@ OFieldDescription::OFieldDescription(const Reference< XPropertySet >& xAffectedC SetName(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_NAME))); if(xPropSetInfo->hasPropertyByName(PROPERTY_DESCRIPTION)) SetDescription(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_DESCRIPTION))); + if(xPropSetInfo->hasPropertyByName(PROPERTY_HELPTEXT)) + SetHelpText(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_HELPTEXT))); if(xPropSetInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE)) SetDefaultValue( xAffectedCol->getPropertyValue(PROPERTY_DEFAULTVALUE) ); @@ -288,6 +290,21 @@ void OFieldDescription::SetName(const ::rtl::OUString& _rName) } } // ----------------------------------------------------------------------------- +void OFieldDescription::SetHelpText(const ::rtl::OUString& _sHelpText) +{ + try + { + if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_HELPTEXT) ) + m_xDest->setPropertyValue(PROPERTY_HELPTEXT,makeAny(_sHelpText)); + else + m_sHelpText = _sHelpText; + } + catch(const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} +// ----------------------------------------------------------------------------- void OFieldDescription::SetDescription(const ::rtl::OUString& _rDescription) { try @@ -504,6 +521,14 @@ void OFieldDescription::SetCurrency(sal_Bool _bIsCurrency) return m_sDescription; } // ----------------------------------------------------------------------------- +::rtl::OUString OFieldDescription::GetHelpText() const +{ + if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_HELPTEXT) ) + return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_HELPTEXT)); + else + return m_sHelpText; +} +// ----------------------------------------------------------------------------- ::com::sun::star::uno::Any OFieldDescription::GetControlDefault() const { if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) ) @@ -657,8 +682,8 @@ void OFieldDescription::copyColumnSettingsTo(const Reference< XPropertySet >& _r _rxColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(GetFormatKey())); if ( GetHorJustify() != SVX_HOR_JUSTIFY_STANDARD && xInfo->hasPropertyByName(PROPERTY_ALIGN) ) _rxColumn->setPropertyValue(PROPERTY_ALIGN,makeAny(dbaui::mapTextAllign(GetHorJustify()))); - if ( GetDescription().getLength() && xInfo->hasPropertyByName(PROPERTY_HELPTEXT) ) - _rxColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(GetDescription())); + if ( GetHelpText().getLength() && xInfo->hasPropertyByName(PROPERTY_HELPTEXT) ) + _rxColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(GetHelpText())); if ( GetControlDefault().hasValue() && xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) ) _rxColumn->setPropertyValue(PROPERTY_CONTROLDEFAULT,GetControlDefault()); diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 347a19ca60ad..8ddb588dd951 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -108,6 +108,7 @@ #ifndef DBAUI_TABLEFIELDCONTROL_HXX #include "TableFieldControl.hxx" #endif +#include "dsntypes.hxx" using namespace ::dbaui; using namespace ::comphelper; @@ -202,13 +203,21 @@ void OTableEditorCtrl::Init() ////////////////////////////////////////////////////////////////////// // Spalten einfuegen String aColumnName( ModuleRes(STR_TAB_FIELD_COLUMN_NAME) ); - InsertDataColumn( 1, aColumnName, FIELDNAME_WIDTH ); + InsertDataColumn( FIELD_NAME, aColumnName, FIELDNAME_WIDTH ); aColumnName = String( ModuleRes(STR_TAB_FIELD_COLUMN_DATATYPE) ); - InsertDataColumn( 2, aColumnName, FIELDTYPE_WIDTH ); + InsertDataColumn( FIELD_TYPE, aColumnName, FIELDTYPE_WIDTH ); - aColumnName = String( ModuleRes(STR_TAB_FIELD_DESCR) ); - InsertDataColumn( 3, aColumnName, FIELDDESCR_WIDTH ); + ::dbaccess::ODsnTypeCollection aDsnTypes(GetView()->getController().getORB()); + sal_Bool bShowColumnDescription = aDsnTypes.supportsColumnDescription(::comphelper::getString(GetView()->getController().getDataSource()->getPropertyValue(PROPERTY_URL))); + aColumnName = String( ModuleRes(STR_TAB_HELP_TEXT) ); + InsertDataColumn( HELP_TEXT, aColumnName, bShowColumnDescription ? FIELDTYPE_WIDTH : FIELDDESCR_WIDTH ); + + if ( bShowColumnDescription ) + { + aColumnName = String( ModuleRes(STR_COLUMN_DESCRIPTION) ); + InsertDataColumn( COLUMN_DESCRIPTION, aColumnName, FIELDTYPE_WIDTH ); + } InitCellController(); @@ -232,6 +241,7 @@ OTableEditorCtrl::OTableEditorCtrl(Window* pWindow) :OTableRowView(pWindow) ,pNameCell(NULL) ,pTypeCell(NULL) + ,pHelpTextCell(NULL) ,pDescrCell(NULL) ,pDescrWin(NULL) ,nIndexEvent(0) @@ -345,12 +355,16 @@ void OTableEditorCtrl::InitCellController() pDescrCell = new Edit( &GetDataWindow(), WB_LEFT ); pDescrCell->SetMaxTextLen( MAX_DESCR_LEN ); + pHelpTextCell = new Edit( &GetDataWindow(), WB_LEFT ); + pHelpTextCell->SetMaxTextLen( MAX_DESCR_LEN ); + pNameCell->SetHelpId(HID_TABDESIGN_NAMECELL); pTypeCell->SetHelpId(HID_TABDESIGN_TYPECELL); pDescrCell->SetHelpId(HID_TABDESIGN_COMMENTCELL); + pHelpTextCell->SetHelpId(HID_TABDESIGN_HELPTEXT); Size aHeight; - const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell}; + const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell,pHelpTextCell}; for(sal_Size i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i) { const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) ); @@ -368,6 +382,7 @@ void OTableEditorCtrl::ClearModified() DBG_CHKTHIS(OTableEditorCtrl,NULL); pNameCell->ClearModifyFlag(); pDescrCell->ClearModifyFlag(); + pHelpTextCell->ClearModifyFlag(); pTypeCell->SaveValue(); } @@ -399,6 +414,7 @@ OTableEditorCtrl::~OTableEditorCtrl() delete pNameCell; delete pTypeCell; delete pDescrCell; + delete pHelpTextCell; } //------------------------------------------------------------------------------ @@ -474,10 +490,16 @@ CellController* OTableEditorCtrl::GetController(long nRow, sal_uInt16 nColumnId) if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0)) return new ListBoxCellController( pTypeCell ); else return NULL; - case FIELD_DESCR: + case HELP_TEXT: + if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0)) + return new EditCellController( pHelpTextCell ); + else + return NULL; + case COLUMN_DESCRIPTION: if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0)) return new EditCellController( pDescrCell ); - else return NULL; + else + return NULL; default: return NULL; } @@ -519,7 +541,13 @@ void OTableEditorCtrl::InitController(CellControllerRef&, long nRow, sal_uInt16 } break; - case FIELD_DESCR: + case HELP_TEXT: + if( pActFieldDescr ) + aInitString = pActFieldDescr->GetHelpText(); + pHelpTextCell->SetText( aInitString ); + pHelpTextCell->SaveValue(); + break; + case COLUMN_DESCRIPTION: if( pActFieldDescr ) aInitString = pActFieldDescr->GetDescription(); pDescrCell->SetText( aInitString ); @@ -579,7 +607,8 @@ void OTableEditorCtrl::DisplayData(long nRow, sal_Bool bGrabFocus) CellControllerRef aTemp; InitController(aTemp, nRow, FIELD_NAME); InitController(aTemp, nRow, FIELD_TYPE); - InitController(aTemp, nRow, FIELD_DESCR); + InitController(aTemp, nRow, COLUMN_DESCRIPTION); + InitController(aTemp, nRow, HELP_TEXT); GoToRow(nRow); // das Description-Window aktualisieren @@ -604,7 +633,8 @@ void OTableEditorCtrl::CursorMoved() CellControllerRef aTemp; InitController(aTemp,m_nDataPos,FIELD_NAME); InitController(aTemp,m_nDataPos,FIELD_TYPE); - InitController(aTemp,m_nDataPos,FIELD_DESCR); + InitController(aTemp,m_nDataPos,COLUMN_DESCRIPTION); + InitController(aTemp,m_nDataPos,HELP_TEXT); } OTableRowView::CursorMoved(); @@ -678,7 +708,20 @@ sal_Bool OTableEditorCtrl::SaveData(long nRow, sal_uInt16 nColId) ////////////////////////////////////////////////////////////// // Speichern Inhalt DescrCell - case FIELD_DESCR: + case HELP_TEXT: + { + ////////////////////////////////////////////////////////////// + // Wenn aktuelle Feldbeschreibung NULL, Default setzen + if( !pActFieldDescr ) + { + pHelpTextCell->SetText(String()); + pHelpTextCell->ClearModifyFlag(); + } + else + pActFieldDescr->SetHelpText( pHelpTextCell->GetText() ); + break; + } + case COLUMN_DESCRIPTION: { ////////////////////////////////////////////////////////////// // Wenn aktuelle Feldbeschreibung NULL, Default setzen @@ -814,7 +857,8 @@ void OTableEditorCtrl::CellModified( long nRow, sal_uInt16 nColId ) { case FIELD_NAME: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_NAME ) ); break; case FIELD_TYPE: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_TYPE ) ); break; - case FIELD_DESCR: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_DESCRIPTION ) ); break; + case HELP_TEXT: + case COLUMN_DESCRIPTION: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_DESCRIPTION ) ); break; default: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_ATTRIBUTE ) ); break; } @@ -1179,7 +1223,7 @@ void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const ::com::s OSL_ENSURE(sal_False, "OTableEditorCtrl::SetCellData: invalid column!"); break; - case FIELD_DESCR: + case COLUMN_DESCRIPTION: pFieldDescr->SetDescription( sValue = ::comphelper::getString(_rNewData) ); break; @@ -1268,9 +1312,12 @@ Any OTableEditorCtrl::GetCellData( long nRow, sal_uInt16 nColId ) sValue = pFieldDescr->getTypeInfo()->aUIName; break; - case FIELD_DESCR: + case COLUMN_DESCRIPTION: sValue = pFieldDescr->GetDescription(); break; + case HELP_TEXT: + sValue = pFieldDescr->GetHelpText(); + break; case FIELD_PROPERTY_DEFAULT: return pFieldDescr->GetControlDefault(); @@ -1350,16 +1397,24 @@ sal_Bool OTableEditorCtrl::IsCutAllowed( long nRow ) if(bIsCutAllowed) { - if(m_eChildFocus == DESCRIPTION) - bIsCutAllowed = pDescrCell->GetSelected().Len() != 0; - else if(m_eChildFocus == NAME) - bIsCutAllowed = pNameCell->GetSelected().Len() != 0; - else if(m_eChildFocus == ROW) - // only rows are selected for cutting so we look if all rows are valid - // wwe don't waant to copy empty rows here - bIsCutAllowed = IsCopyAllowed(nRow); - else - bIsCutAllowed = sal_False; + switch(m_eChildFocus) + { + case DESCRIPTION: + bIsCutAllowed = pDescrCell->GetSelected().Len() != 0; + break; + case HELPTEXT: + bIsCutAllowed = pHelpTextCell->GetSelected().Len() != 0; + break; + case NAME: + bIsCutAllowed = pNameCell->GetSelected().Len() != 0; + break; + case ROW: + bIsCutAllowed = IsCopyAllowed(nRow); + break; + default: + bIsCutAllowed = sal_False; + break; + } } // Reference xTable = GetView()->getController().getTable(); @@ -1375,8 +1430,10 @@ sal_Bool OTableEditorCtrl::IsCopyAllowed( long /*nRow*/ ) { DBG_CHKTHIS(OTableEditorCtrl,NULL); sal_Bool bIsCopyAllowed = sal_False; - if(m_eChildFocus == DESCRIPTION) + if(m_eChildFocus == DESCRIPTION ) bIsCopyAllowed = pDescrCell->GetSelected().Len() != 0; + else if(HELPTEXT == m_eChildFocus ) + bIsCopyAllowed = pHelpTextCell->GetSelected().Len() != 0; else if(m_eChildFocus == NAME) bIsCopyAllowed = pNameCell->GetSelected().Len() != 0; else if(m_eChildFocus == ROW) @@ -1438,9 +1495,18 @@ void OTableEditorCtrl::cut() { if(GetView()->getController().isAlterAllowed()) { - SaveData(-1,FIELD_DESCR); + SaveData(-1,COLUMN_DESCRIPTION); pDescrCell->Cut(); - CellModified(-1,FIELD_DESCR); + CellModified(-1,COLUMN_DESCRIPTION); + } + } + else if(HELPTEXT == m_eChildFocus ) + { + if(GetView()->getController().isAlterAllowed()) + { + SaveData(-1,HELP_TEXT); + pHelpTextCell->Cut(); + CellModified(-1,HELP_TEXT); } } else if(m_eChildFocus == ROW) @@ -1458,7 +1524,9 @@ void OTableEditorCtrl::copy() OTableRowView::copy(); else if(m_eChildFocus == NAME) pNameCell->Copy(); - else if(m_eChildFocus == DESCRIPTION) + else if(HELPTEXT == m_eChildFocus ) + pHelpTextCell->Copy(); + else if(m_eChildFocus == DESCRIPTION ) pDescrCell->Copy(); } @@ -1480,6 +1548,14 @@ void OTableEditorCtrl::paste() CellModified(); } } + else if(HELPTEXT == m_eChildFocus ) + { + if(GetView()->getController().isAlterAllowed()) + { + pHelpTextCell->Paste(); + CellModified(); + } + } else if(m_eChildFocus == DESCRIPTION) { if(GetView()->getController().isAlterAllowed()) @@ -1496,16 +1572,6 @@ sal_Bool OTableEditorCtrl::IsDeleteAllowed( long /*nRow*/ ) DBG_CHKTHIS(OTableEditorCtrl,NULL); return GetSelectRowCount() != 0 && GetView()->getController().isDropAllowed(); -// Reference xTable = GetView()->getController().getTable(); -// if( !GetSelectRowCount() || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW"))) -// return sal_False; -// -// // Wenn nur Felder hinzugefuegt werden duerfen, Delete nur auf neuen Feldern -// Reference xCon = GetView()->getController().getConnection(); -// Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : NULL; -// -// return !(xTable.is() && xTable->getPropertySetInfo()->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY) || -// ( xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn()); } //------------------------------------------------------------------------------ @@ -1936,7 +2002,9 @@ long OTableEditorCtrl::PreNotify( NotifyEvent& rNEvt ) { if (rNEvt.GetType() == EVENT_GETFOCUS) { - if( pDescrCell && pDescrCell->HasChildPathFocus() ) + if( pHelpTextCell && pHelpTextCell->HasChildPathFocus() ) + m_eChildFocus = HELPTEXT; + else if( pDescrCell && pDescrCell->HasChildPathFocus() ) m_eChildFocus = DESCRIPTION; else if(pNameCell && pNameCell->HasChildPathFocus() ) m_eChildFocus = NAME; diff --git a/dbaccess/source/ui/tabledesign/TEditControl.hxx b/dbaccess/source/ui/tabledesign/TEditControl.hxx index c28d525d6450..120b548e8e6d 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.hxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.hxx @@ -59,6 +59,7 @@ namespace dbaui { enum ChildFocusState { + HELPTEXT, DESCRIPTION, NAME, ROW, @@ -70,6 +71,7 @@ namespace dbaui OSQLNameEdit* pNameCell; ::svt::ListBoxControl* pTypeCell; + Edit* pHelpTextCell; Edit* pDescrCell; OTableFieldDescWin* pDescrWin; // properties of one column diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 1eed02543cda..df01b15dc6cf 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -871,7 +871,7 @@ void OTableController::loadData() sal_Int32 nAlign = 0; sal_Bool bIsAutoIncrement = false, bIsCurrency = false; - ::rtl::OUString sName,sDescription,sTypeName; + ::rtl::OUString sName,sDescription,sTypeName,sHelpText; Any aControlDefault; // get the properties from the column @@ -883,10 +883,11 @@ void OTableController::loadData() xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType; xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale; xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision; - + xColumn->getPropertyValue(PROPERTY_DESCRIPTION) >>= sDescription; if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_HELPTEXT)) - xColumn->getPropertyValue(PROPERTY_HELPTEXT) >>= sDescription; + xColumn->getPropertyValue(PROPERTY_HELPTEXT) >>= sHelpText; + if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_CONTROLDEFAULT)) aControlDefault = xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT); if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_FORMATKEY)) @@ -912,6 +913,7 @@ void OTableController::loadData() pActFieldDescr->SetFormatKey(nFormatKey); // pActFieldDescr->SetPrimaryKey(pPrimary->GetValue()); pActFieldDescr->SetDescription(sDescription); + pActFieldDescr->SetHelpText(sHelpText); pActFieldDescr->SetAutoIncrement(bIsAutoIncrement); pActFieldDescr->SetHorJustify(dbaui::mapTextJustify(nAlign)); pActFieldDescr->SetCurrency(bIsCurrency); @@ -1120,13 +1122,14 @@ void OTableController::alterColumns() sal_Int32 nType=0,nPrecision=0,nScale=0,nNullable=0; sal_Bool bAutoIncrement = false; - ::rtl::OUString sTypeName; + ::rtl::OUString sTypeName,sDescription; xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType; xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision; xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale; xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable; xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAutoIncrement; + xColumn->getPropertyValue(PROPERTY_DESCRIPTION) >>= sDescription; try { xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName; } catch( const Exception& ) @@ -1145,6 +1148,7 @@ void OTableController::alterColumns() (nPrecision != pField->GetPrecision() && nPrecision ) || nScale != pField->GetScale() || nNullable != pField->GetIsNullable() || + sDescription != pField->GetDescription() || bAutoIncrement != pField->IsAutoIncrement())&& xColumnFactory.is()) { @@ -1264,7 +1268,8 @@ void OTableController::alterColumns() xColumns->getByName(pField->GetName()) >>= xColumn; Reference xInfo = xColumn->getPropertySetInfo(); if ( xInfo->hasPropertyByName(PROPERTY_HELPTEXT) ) - xColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(pField->GetDescription())); + xColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(pField->GetHelpText())); + if(xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT)) xColumn->setPropertyValue(PROPERTY_CONTROLDEFAULT,pField->GetControlDefault()); if(xInfo->hasPropertyByName(PROPERTY_FORMATKEY)) diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx index cc7ad2c4a8bf..bf45ccda6689 100644 --- a/dbaccess/source/ui/tabledesign/TableRow.cxx +++ b/dbaccess/source/ui/tabledesign/TableRow.cxx @@ -140,6 +140,7 @@ namespace dbaui _rStr << (sal_Int32)1; _rStr.WriteByteString(pFieldDesc->GetName()); _rStr.WriteByteString(pFieldDesc->GetDescription()); + _rStr.WriteByteString(pFieldDesc->GetHelpText()); double nValue = 0.0; Any aValue = pFieldDesc->GetControlDefault(); if ( aValue >>= nValue ) @@ -184,6 +185,8 @@ namespace dbaui _rStr.ReadByteString(sValue); pFieldDesc->SetDescription(sValue); + _rStr.ReadByteString(sValue); + pFieldDesc->SetHelpText(sValue); _rStr >> nValue; Any aControlDefault; diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index 9fa0b0743ef4..5616f7f4101f 100644 --- a/dbaccess/source/ui/tabledesign/table.src +++ b/dbaccess/source/ui/tabledesign/table.src @@ -106,10 +106,14 @@ String STR_TAB_FIELD_LENGTH { Text [ en-US ] = "Field length" ; }; -String STR_TAB_FIELD_DESCR +String STR_TAB_HELP_TEXT { Text [ en-US ] = "Description" ; }; +String STR_COLUMN_DESCRIPTION +{ + Text [ en-US ] = "Column Description" ; +}; String STR_TAB_FIELD_NULLABLE { Text [ en-US ] = "Input required" ; diff --git a/dbaccess/util/hidother.src b/dbaccess/util/hidother.src index 2f97d1918fd3..e564f01ded61 100644 --- a/dbaccess/util/hidother.src +++ b/dbaccess/util/hidother.src @@ -149,6 +149,8 @@ hidspecial HID_CTL_TABLEEDIT { HelpId = HID_CTL_TABLE hidspecial HID_TABDESIGN_NAMECELL { HelpId = HID_TABDESIGN_NAMECELL; }; hidspecial HID_TABDESIGN_TYPECELL { HelpId = HID_TABDESIGN_TYPECELL; }; hidspecial HID_TABDESIGN_COMMENTCELL { HelpId = HID_TABDESIGN_COMMENTCELL; }; +hidspecial HID_TABDESIGN_HELPTEXT { HelpId = HID_TABDESIGN_HELPTEXT; }; + hidspecial SID_TABLEDESIGN_INSERTROWS { HelpId = SID_TABLEDESIGN_INSERTROWS; }; hidspecial SID_TABLEDESIGN_TABED_PRIMARYKEY { HelpId = SID_TABLEDESIGN_TABED_PRIMARYKEY; }; hidspecial HID_TLB_TABLEDESIGN { HelpId = HID_TLB_TABLEDESIGN; }; -- cgit From 3bd5a7908b7c2659e1061ad479adfd60beac0436 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 13 Jan 2010 12:37:12 +0100 Subject: dba33f: #i104413# make column names unique --- dbaccess/source/core/api/RowSet.cxx | 1 + dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 3 ++- dbaccess/source/ui/tabledesign/FieldDescriptions.cxx | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index c51949e1e650..cd7d907372ab 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -1900,6 +1900,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi { xColumn = NULL; bReFetchName = sal_True; + sColumnLabel = ::rtl::OUString(); } if(!xColumn.is()) { diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index e302e38fe588..e76f31e09cdb 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -733,6 +733,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr const ::comphelper::TStringMixEqualFunctor aCaseCompareFunctor( bCase ); typedef ::std::set< size_t > SizeTSet; SizeTSet aUsedSelectColumns; + ::connectivity::parse::OParseColumn::StringMap aColumnNames; sal_Int32 nCount = xResultSetMeta->getColumnCount(); OSL_ENSURE( (size_t) nCount == aSelectColumns->get().size(), "OSingleSelectQueryComposer::getColumns: inconsistent column counts, this might result in wrong columns!" ); @@ -775,7 +776,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr if ( i > static_cast< sal_Int32>( aSelectColumns->get().size() ) ) { aSelectColumns->get().push_back( - ::connectivity::parse::OParseColumn::createColumnForResultSet( xResultSetMeta, m_xMetaData, i ) + ::connectivity::parse::OParseColumn::createColumnForResultSet( xResultSetMeta, m_xMetaData, i ,aColumnNames) ); OSL_ENSURE( aSelectColumns->get().size() == (size_t)i, "OSingleSelectQueryComposer::getColumns: inconsistency!" ); } diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index 6e75f1e969f8..ae3e3ba7a3b8 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -158,7 +158,11 @@ OFieldDescription::OFieldDescription(const Reference< XPropertySet >& xAffectedC if(xPropSetInfo->hasPropertyByName(PROPERTY_DESCRIPTION)) SetDescription(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_DESCRIPTION))); if(xPropSetInfo->hasPropertyByName(PROPERTY_HELPTEXT)) - SetHelpText(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_HELPTEXT))); + { + ::rtl::OUString sHelpText; + xAffectedCol->getPropertyValue(PROPERTY_HELPTEXT) >>= sHelpText; + SetHelpText(sHelpText); + } if(xPropSetInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE)) SetDefaultValue( xAffectedCol->getPropertyValue(PROPERTY_DEFAULTVALUE) ); -- cgit From d4d5d883ecbc6e04cd28bb49be4c85f560a1bc48 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 22 Jan 2010 08:14:22 +0100 Subject: dba33f: #i108548# extend SingleSelectQueryComposer appendFilterByColumn with additonal parameter --- .../dbaccess/SingleSelectQueryComposer.java | 2 +- dbaccess/source/core/api/BookmarkSet.cxx | 4 +- dbaccess/source/core/api/BookmarkSet.hxx | 2 +- dbaccess/source/core/api/CacheSet.cxx | 2 +- dbaccess/source/core/api/CacheSet.hxx | 2 +- dbaccess/source/core/api/KeySet.cxx | 118 +++++++++-- dbaccess/source/core/api/KeySet.hxx | 10 +- dbaccess/source/core/api/RowSet.cxx | 83 ++++---- dbaccess/source/core/api/RowSetCache.cxx | 15 +- dbaccess/source/core/api/RowSetCache.hxx | 3 +- .../source/core/api/SingleSelectQueryComposer.cxx | 225 +++++++++++++++------ dbaccess/source/core/api/definitioncolumn.cxx | 14 +- dbaccess/source/core/api/query.cxx | 24 +-- dbaccess/source/core/api/querycomposer.cxx | 19 +- .../source/core/inc/SingleSelectQueryComposer.hxx | 12 +- dbaccess/source/core/inc/definitioncolumn.hxx | 3 +- dbaccess/source/inc/stringconstants.hrc | 2 + dbaccess/source/inc/stringconstants.inc | 1 + dbaccess/source/ui/browser/brwctrlr.cxx | 148 +++++++++----- dbaccess/source/ui/inc/brwctrlr.hxx | 5 +- 20 files changed, 489 insertions(+), 205 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java index 7b0aed460dc8..40ce60699c05 100755 --- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java +++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java @@ -263,7 +263,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase filter.addProperty("Type", PropertyAttribute.MAYBEVOID, Integer.valueOf(DataType.LONGVARCHAR)); final XPropertySet column = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,filter); - m_composer.appendFilterByColumn(column, true); + m_composer.appendFilterByColumn(column, true,SQLFilterOperator.LIKE); assure("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next()); } diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx index 127ee83aaf2c..4f8a97604e57 100644 --- a/dbaccess/source/core/api/BookmarkSet.cxx +++ b/dbaccess/source/core/api/BookmarkSet.cxx @@ -62,10 +62,10 @@ using namespace ::com::sun::star::lang; // using namespace ::cppu; using namespace ::osl; -void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet) +void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::construct" ); - OCacheSet::construct(_xDriverSet); + OCacheSet::construct(_xDriverSet,i_sRowSetFilter); m_xRowLocate.set(_xDriverSet,UNO_QUERY); } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/BookmarkSet.hxx b/dbaccess/source/core/api/BookmarkSet.hxx index 4204afd59827..3433e0a5ea6b 100644 --- a/dbaccess/source/core/api/BookmarkSet.hxx +++ b/dbaccess/source/core/api/BookmarkSet.hxx @@ -54,7 +54,7 @@ namespace dbaccess m_xRowLocate = NULL; } - virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition); // ::com::sun::star::sdbcx::XRowLocate virtual ::com::sun::star::uno::Any SAL_CALL getBookmark() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index f7be322caa1a..cdff43ca52af 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -129,7 +129,7 @@ OCacheSet::OCacheSet() return sQuote; } // ------------------------------------------------------------------------- -void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet) +void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& /*i_sRowSetFilter*/) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::construct" ); OSL_ENSURE(_xDriverSet.is(),"Invalid resultSet"); diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx index 057c843fe871..e0fcf981f2ba 100644 --- a/dbaccess/source/core/api/CacheSet.hxx +++ b/dbaccess/source/core/api/CacheSet.hxx @@ -110,7 +110,7 @@ namespace dbaccess public: // late constructor - virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition); // ::com::sun::star::sdbc::XRow diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index c265944d293a..193aef7e8e77 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -162,6 +162,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, :m_aParameterValueForCache(_aParameterValueForCache) ,m_pKeyColumnNames(NULL) ,m_pColumnNames(NULL) + ,m_pParameterNames(NULL) ,m_pForeignColumnNames(NULL) ,m_xTable(_xTable) ,m_xTableKeys(_xTableKeys) @@ -191,26 +192,40 @@ OKeySet::~OKeySet() m_xComposer = NULL; delete m_pKeyColumnNames; delete m_pColumnNames; + delete m_pParameterNames; delete m_pForeignColumnNames; DBG_DTOR(OKeySet,NULL); } // ----------------------------------------------------------------------------- -void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) +void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::construct" ); - OCacheSet::construct(_xDriverSet); + OCacheSet::construct(_xDriverSet,i_sRowSetFilter); Reference xMeta = m_xConnection->getMetaData(); bool bCase = (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers()) ? true : false; - m_pKeyColumnNames = new SelectColumnsMetaData(bCase); - m_pColumnNames = new SelectColumnsMetaData(bCase); - m_pForeignColumnNames = new SelectColumnsMetaData(bCase); + m_pKeyColumnNames = new SelectColumnsMetaData(bCase); + m_pColumnNames = new SelectColumnsMetaData(bCase); + m_pParameterNames = new SelectColumnsMetaData(bCase); + m_pForeignColumnNames = new SelectColumnsMetaData(bCase); Reference xKeyColumns = getKeyColumns(); Reference xSup(m_xComposer,UNO_QUERY); Reference xSourceColumns = m_xTable->getColumns(); + // locate parameter in select columns + Reference xParaSup(m_xComposer,UNO_QUERY); + Reference xQueryParameters = xParaSup->getParameters(); + const sal_Int32 nParaCount = xQueryParameters->getCount(); + Sequence< ::rtl::OUString> aParameterColumns(nParaCount); + for(sal_Int32 i = 0; i< nParaCount;++i) + { + Reference xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW); + xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i]; + } + + ::rtl::OUString sCatalog,sSchema,sTable; Reference xTableProp(m_xTable,UNO_QUERY); @@ -238,6 +253,8 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::dbaccess::getColumnPositions(xSup->getColumns(),aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames)); ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames)); + ::dbaccess::getColumnPositions(xSup->getColumns(),aParameterColumns,m_sUpdateTableName,(*m_pParameterNames)); + SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); @@ -284,9 +301,10 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) aFilter.append(aAnd); } + Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY); Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW); Reference xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); - xAnalyzer->setQuery(m_xComposer->getQuery()); + xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery()); Reference xTabSup(xAnalyzer,uno::UNO_QUERY); Reference xSelectTables(xTabSup->getTables(),uno::UNO_QUERY); const Sequence< ::rtl::OUString> aSeq = xSelectTables->getElementNames(); @@ -323,12 +341,12 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) } } } // if ( aSeq.getLength() > 1 ) // special handling for join - const ::rtl::OUString sOldFilter = xAnalyzer->getFilter(); - if ( sOldFilter.getLength() ) + //const ::rtl::OUString sOldFilter = xAnalyzer->getFilter(); + if ( i_sRowSetFilter.getLength() ) { FilterCreator aFilterCreator; + aFilterCreator.append( i_sRowSetFilter ); aFilterCreator.append( aFilter.makeStringAndClear() ); - aFilterCreator.append( sOldFilter ); aFilter = aFilterCreator.getComposedAndClear(); } xAnalyzer->setFilter(aFilter.makeStringAndClear()); @@ -597,6 +615,7 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow sal_Int32 nPos = aIter->second.nPosition; if((_rInsertRow->get())[nPos].isModified()) { + impl_convertValue_throw(_rInsertRow,aIter->second); (_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned()); setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale); } @@ -623,10 +642,10 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow m_bUpdated = xPrep->executeUpdate() > 0; if(m_bUpdated) { - m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32((_rInsertRow->get())[0].getAny())); - OSL_ENSURE(m_aKeyIter != m_aKeyMap.end(),"New inserted row not found!"); + const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny()); + m_aKeyIter = m_aKeyMap.find(nBookmark); m_aKeyIter->second.second = 2; - copyRowValue(_rInsertRow,m_aKeyIter->second.first); + copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark); } } // ------------------------------------------------------------------------- @@ -679,6 +698,7 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind()); else { + impl_convertValue_throw(_rInsertRow,aIter->second); (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]); setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale); } @@ -786,21 +806,47 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi } if ( m_bInserted ) { - ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size()); - copyRowValue(_rInsertRow,aKeyRow); - OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end(); --aKeyIter; + ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size()); + copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1); + m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,1))).first; // now we set the bookmark for this row (_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first); } } // ----------------------------------------------------------------------------- -void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow) +void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::copyRowValue" ); connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin(); + + // check the if the parameter values have been changed + OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!"); + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1; + + bool bChanged = false; + SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin(); + SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end(); + for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i) + { + ORowSetValue aValue(*aParaValuesIter); + aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]); + if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue ) + { + ORowSetValueVector aCopy(m_aParameterValueForCache); + (aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition]; + m_aUpdatedParameter[i_nBookmark] = aCopy; + bChanged = true; + } + } + if ( !bChanged ) + { + m_aUpdatedParameter.erase(i_nBookmark); + } + + // update the key values SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); for(;aPosIter != aPosEnd;++aPosIter,++aIter) @@ -1150,9 +1196,23 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) Reference< XParameters > xParameter(m_xStatement,UNO_QUERY); OSL_ENSURE(xParameter.is(),"No Parameter interface!"); xParameter->clearParameters(); + sal_Int32 nPos=1; - connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter = m_aParameterValueForCache.get().begin(); - connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd = m_aParameterValueForCache.get().end(); + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter; + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd; + OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first); + if ( aUpdateFind == m_aUpdatedParameter.end() ) + { + + aParaIter = m_aParameterValueForCache.get().begin(); + aParaEnd = m_aParameterValueForCache.get().end(); + } + else + { + aParaIter = aUpdateFind->second.get().begin(); + aParaEnd = aUpdateFind->second.get().end(); + } + for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos) { ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() ); @@ -1463,3 +1523,25 @@ namespace dbaccess } } } +// ----------------------------------------------------------------------------- +void OKeySet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData) +{ + ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]); + switch(i_aMetaData.nType) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + { + ::rtl::OUString sValue = aValue.getString(); + sal_Int32 nIndex = sValue.indexOf('.'); + if ( nIndex != -1 ) + { + aValue = sValue.copy(0,nIndex + (i_aMetaData.nScale > 0 ? i_aMetaData.nScale + 1 : 0)); + } + } + break; + default: + break; + } +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 7a213d05b466..7db5c176e9ff 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -89,6 +89,7 @@ namespace dbaccess typedef ::std::pair OKeySetValue; typedef ::std::map OKeySetMatrix; + typedef ::std::map OUpdatedParameter; // is used when the source supports keys class OKeySet : public OCacheSet { @@ -97,9 +98,11 @@ namespace dbaccess ::std::vector< ::rtl::OUString > m_aAutoColumns; // contains all columns which are autoincrement ones + OUpdatedParameter m_aUpdatedParameter; // contains all parameter which have been updated and are needed for refetching ORowSetValueVector m_aParameterValueForCache; SelectColumnsMetaData* m_pKeyColumnNames; // contains all key column names SelectColumnsMetaData* m_pColumnNames; // contains all column names + SelectColumnsMetaData* m_pParameterNames; // contains all parameter names SelectColumnsMetaData* m_pForeignColumnNames; // contains all column names of the rest connectivity::OSQLTable m_xTable; // reference to our table ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xTableKeys; @@ -128,12 +131,15 @@ namespace dbaccess * * \param _rInsertRow the row which was inserted * \param _rKeyRow The current key row of the row set. + + \param i_nBookmark The bookmark is used to update the parameter */ - void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow); + void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark); ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getKeyColumns() const; void fillAllRows(); sal_Bool fetchRow(); + + void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData); protected: virtual ~OKeySet(); public: @@ -144,7 +150,7 @@ namespace dbaccess const ORowSetValueVector& _aParameterValueForCache); // late ctor which can throw exceptions - virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); // ::com::sun::star::sdbc::XRow virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index cd7d907372ab..01f6d7d3259b 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -201,6 +201,7 @@ ORowSet::ORowSet( const Reference< ::com::sun::star::lang::XMultiServiceFactory registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, nRT, &m_nPrivileges, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL))); registerProperty(PROPERTY_ISMODIFIED, PROPERTY_ID_ISMODIFIED, nBT, &m_bModified, ::getBooleanCppuType()); registerProperty(PROPERTY_ISNEW, PROPERTY_ID_ISNEW, nRBT, &m_bNew, ::getBooleanCppuType()); + registerProperty(PROPERTY_SINGLESELECTQUERYCOMPOSER,PROPERTY_ID_SINGLESELECTQUERYCOMPOSER, nRT, &m_xComposer, ::getCppuType(reinterpret_cast< Reference< XSingleSelectQueryComposer >* >(NULL))); // sdbcx.ResultSet Properties registerProperty(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, nRT, &m_bIsBookmarable, ::getBooleanCppuType()); @@ -993,7 +994,7 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" ); } - else // the update went rong + else if ( !m_bAfterLast ) // the update went rong { ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_UPDATE_FAILED ), SQL_INVALID_CURSOR_POSITION, *this ); } @@ -1778,7 +1779,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn: creating cache" ); - m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache ); + m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter ); if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) { m_nPrivileges = Privilege::SELECT; @@ -2226,7 +2227,8 @@ sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecu if ( !m_xComposer.is() ) m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_aContext ); - m_xComposer->setElementaryQuery( m_aActiveCommand ); + m_xComposer->setCommand( m_aCommand,m_nCommandType ); + m_aActiveCommand = m_xComposer->getQuery(); m_xComposer->setFilter( m_bApplyFilter ? m_aFilter : ::rtl::OUString() ); m_xComposer->setHavingClause( m_bApplyFilter ? m_aHavingClause : ::rtl::OUString() ); @@ -2252,6 +2254,7 @@ sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecu impl_initParametersContainer_nothrow(); _out_rCommandToExecute = m_xComposer->getQueryWithSubstitution(); + return bUseEscapeProcessing; } @@ -2274,41 +2277,52 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw() case CommandType::TABLE: { impl_resetTables_nothrow(); - - Reference< XNameAccess > xTables( impl_getTables_throw() ); - if ( xTables->hasByName(m_aCommand) ) + if ( bDoEscapeProcessing ) { - Reference< XPropertySet > xTable; - try - { - xTables->getByName( m_aCommand ) >>= xTable; - } - catch(const WrappedTargetException& e) + Reference< XNameAccess > xTables( impl_getTables_throw() ); + if ( xTables->hasByName(m_aCommand) ) { - SQLException e2; - if ( e.TargetException >>= e2 ) - throw e2; +/* + Reference< XPropertySet > xTable; + try + { + xTables->getByName( m_aCommand ) >>= xTable; + } + catch(const WrappedTargetException& e) + { + SQLException e2; + if ( e.TargetException >>= e2 ) + throw e2; + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + Reference xSup(xTable,UNO_QUERY); + if ( xSup.is() ) + m_xColumns = xSup->getColumns(); + + sCommand = rtl::OUString::createFromAscii("SELECT * FROM "); + ::rtl::OUString sCatalog, sSchema, sTable; + ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation ); + sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable ); +*/ } - catch(Exception&) + else { - DBG_UNHANDLED_EXCEPTION(); + String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) ); + sMessage.SearchAndReplaceAscii( "$table$", m_aCommand ); + throwGenericSQLException(sMessage,*this); } - - Reference xSup(xTable,UNO_QUERY); - if ( xSup.is() ) - m_xColumns = xSup->getColumns(); - + } + else + { sCommand = rtl::OUString::createFromAscii("SELECT * FROM "); ::rtl::OUString sCatalog, sSchema, sTable; ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation ); sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable ); } - else - { - String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) ); - sMessage.SearchAndReplaceAscii( "$table$", m_aCommand ); - throwGenericSQLException(sMessage,*this); - } } break; @@ -2339,10 +2353,11 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw() xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= aTable; if(aTable.getLength()) m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, sal_False, ::dbtools::eInDataManipulation ); - +/* Reference xSup(xQuery,UNO_QUERY); if(xSup.is()) m_xColumns = xSup->getColumns(); +*/ } } else @@ -2364,7 +2379,7 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw() m_aActiveCommand = sCommand; - if ( !m_aActiveCommand.getLength() ) + if ( !m_aActiveCommand.getLength() && !bDoEscapeProcessing ) ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); return bDoEscapeProcessing; @@ -2667,8 +2682,8 @@ void ORowSet::checkUpdateIterator() void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) { checkCache(); - if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex ) - ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this ); + if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this ); if ( rowDeleted() ) ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this ); @@ -2676,8 +2691,8 @@ void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) if ( m_aCurrentRow.isNull() ) ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this ); - if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) - ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this ); + if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex ) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this ); } // ----------------------------------------------------------------------------- void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException) diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 3dd4dad67441..924fd881346e 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -138,7 +138,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, const ::rtl::OUString& _rUpdateTableName, sal_Bool& _bModified, sal_Bool& _bNew, - const ORowSetValueVector& _aParameterValueForCache) + const ORowSetValueVector& _aParameterValueForCache, + const ::rtl::OUString& i_sRowSetFilter) :m_xSet(_xRs) ,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData()) ,m_aContext( _rContext ) @@ -260,7 +261,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { m_pCacheSet = new OBookmarkSet(); m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); + m_pCacheSet->construct(_xRs,i_sRowSetFilter); // check privileges m_nPrivileges = Privilege::SELECT; @@ -294,7 +295,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { m_pCacheSet = new OStaticSet(); m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); + m_pCacheSet->construct(_xRs,i_sRowSetFilter); m_nPrivileges = Privilege::SELECT; } else @@ -335,7 +336,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { m_pCacheSet = pKeySet; m_xCacheSet = m_pCacheSet; - pKeySet->construct(_xRs); + pKeySet->construct(_xRs,i_sRowSetFilter); if(Reference(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it { @@ -359,7 +360,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, m_xCacheSet = NULL; m_pCacheSet = new OStaticSet(); m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); + m_pCacheSet->construct(_xRs,i_sRowSetFilter); m_nPrivileges = Privilege::SELECT; } } @@ -1284,9 +1285,7 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) // refetch the whole row (*m_aMatrixIter) = NULL; - if ( !moveToBookmark(aBookmark) ) - m_aMatrixIter = m_pMatrix->end(); - + moveToBookmark(aBookmark); // moveToBookmark((*(*m_aInsertRow))[0].makeAny()); // if(m_pCacheSet->rowUpdated()) // *m_aMatrixIter = m_aInsertRow; diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx index 1f5be3113f8b..268c32294824 100644 --- a/dbaccess/source/core/api/RowSetCache.hxx +++ b/dbaccess/source/core/api/RowSetCache.hxx @@ -195,7 +195,8 @@ namespace dbaccess const ::rtl::OUString& _rUpdateTableName, sal_Bool& _bModified, sal_Bool& _bNew, - const ORowSetValueVector& _aParameterValueForCache); + const ORowSetValueVector& _aParameterValueForCache, + const ::rtl::OUString& i_sRowSetFilter); ~ORowSetCache(); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index e76f31e09cdb..c7dd2c130f44 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include #include #include @@ -190,6 +192,53 @@ namespace if ( _bDispose ) _rIterator.dispose(); } + void lcl_addFilterCriteria_throw(sal_Int32 i_nFilterOperator,const ::rtl::OUString& i_sValue,::rtl::OUStringBuffer& o_sRet) + { + switch( i_nFilterOperator ) + { + case SQLFilterOperator::EQUAL: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::NOT_EQUAL: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::LESS: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::GREATER: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::LESS_EQUAL: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::GREATER_EQUAL: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::LIKE: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::NOT_LIKE: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE "))); + o_sRet.append(i_sValue); + break; + case SQLFilterOperator::SQLNULL: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) ); + break; + case SQLFilterOperator::NOT_SQLNULL: + o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) ); + break; + default: + throw SQLException(); + } + } + } DBG_NAME(OSingleSelectQueryComposer) @@ -209,6 +258,7 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc ,m_aContext( _rContext ) ,m_pTables(NULL) ,m_nBoolCompareMode( BooleanComparisonMode::EQUAL_INTEGER ) + ,m_nCommandType(CommandType::COMMAND) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::OSingleSelectQueryComposer" ); DBG_CTOR(OSingleSelectQueryComposer,NULL); @@ -235,6 +285,9 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc { OSL_VERIFY( aValue >>= m_nBoolCompareMode ); } + Reference< XQueriesSupplier > xQueriesAccess(m_xConnection, UNO_QUERY); + if (xQueriesAccess.is()) + m_xConnectionQueries = xQueriesAccess->getQueries(); } catch(Exception&) { @@ -306,6 +359,7 @@ void SAL_CALL OSingleSelectQueryComposer::setQuery( const ::rtl::OUString& comma ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed); ::osl::MutexGuard aGuard( m_aMutex ); + m_nCommandType = CommandType::COMMAND; // first clear the tables and columns clearCurrentCollections(); // now set the new one @@ -319,6 +373,85 @@ void SAL_CALL OSingleSelectQueryComposer::setQuery( const ::rtl::OUString& comma for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) ) m_aElementaryParts[ eLoopParts ] = ::rtl::OUString(); } +// ------------------------------------------------------------------------- +void SAL_CALL OSingleSelectQueryComposer::setCommand( const ::rtl::OUString& Command,sal_Int32 _nCommandType ) throw(SQLException, RuntimeException) +{ + ::rtl::OUStringBuffer sSQL; + switch(_nCommandType) + { + case CommandType::COMMAND: + setElementaryQuery(Command); + return; + break; + case CommandType::TABLE: + if ( m_xConnectionTables->hasByName(Command) ) + { + sSQL.appendAscii("SELECT * FROM "); + Reference< XPropertySet > xTable; + try + { + m_xConnectionTables->getByName( Command ) >>= xTable; + } + catch(const WrappedTargetException& e) + { + SQLException e2; + if ( e.TargetException >>= e2 ) + throw e2; + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + sSQL.append(dbtools::composeTableNameForSelect(m_xConnection,xTable)); + } + else + { + String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) ); + sMessage.SearchAndReplaceAscii( "$table$", Command ); + throwGenericSQLException(sMessage,*this); + } + break; + case CommandType::QUERY: + if ( m_xConnectionQueries->hasByName(Command) ) + { + + Reference xQuery(m_xConnectionQueries->getByName(Command),UNO_QUERY); + ::rtl::OUString sCommand; + xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand; + sSQL.append(sCommand); + } + else + { + String sMessage( DBACORE_RESSTRING( RID_STR_QUERY_DOES_NOT_EXIST ) ); + sMessage.SearchAndReplaceAscii( "$table$", Command ); + throwGenericSQLException(sMessage,*this); + } + + break; + default: + break; + } + ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed); + + ::osl::MutexGuard aGuard( m_aMutex ); + m_nCommandType = _nCommandType; + m_sCommand = Command; + // first clear the tables and columns + clearCurrentCollections(); + // now set the new one + ::rtl::OUString sCommand = sSQL.makeStringAndClear(); + setElementaryQuery(sCommand); + m_sOrignal = sCommand; +/* + // reset the additive iterator to the same statement + parseAndCheck_throwError( m_aSqlParser, m_sOrignal, m_aAdditiveIterator, *this ); + + // we have no "elementary" parts anymore (means filter/groupby/having/order clauses) + for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) ) + m_aElementaryParts[ eLoopParts ] = ::rtl::OUString(); +*/ +} // ----------------------------------------------------------------------------- void OSingleSelectQueryComposer::setQuery_Impl( const ::rtl::OUString& command ) { @@ -350,18 +483,18 @@ Sequence< Sequence< PropertyValue > > SAL_CALL OSingleSelectQueryComposer::getSt return getStructuredCondition(F_tmp); } // ----------------------------------------------------------------------------- -void SAL_CALL OSingleSelectQueryComposer::appendHavingClauseByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ) throw (SQLException, RuntimeException) +void SAL_CALL OSingleSelectQueryComposer::appendHavingClauseByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendHavingClauseByColumn" ); ::std::mem_fun1_t F_tmp(&OSingleSelectQueryComposer::implSetHavingClause); - setConditionByColumn(column,andCriteria,F_tmp); + setConditionByColumn(column,andCriteria,F_tmp,filterOperator); } // ----------------------------------------------------------------------------- -void SAL_CALL OSingleSelectQueryComposer::appendFilterByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ) throw(SQLException, RuntimeException) +void SAL_CALL OSingleSelectQueryComposer::appendFilterByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendFilterByColumn" ); ::std::mem_fun1_t F_tmp(&OSingleSelectQueryComposer::implSetFilter); - setConditionByColumn(column,andCriteria,F_tmp); + setConditionByColumn(column,andCriteria,F_tmp,filterOperator); } // ----------------------------------------------------------------------------- ::rtl::OUString OSingleSelectQueryComposer::impl_getColumnName_throw(const Reference< XPropertySet >& column) @@ -659,6 +792,13 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr ::std::vector< ::rtl::OUString> aNames; ::vos::ORef< OSQLColumns> aSelectColumns; sal_Bool bCase = sal_True; + Reference< XNameAccess> xQueryColumns; + if ( m_nCommandType == CommandType::QUERY ) + { + Reference xSup(m_xConnectionQueries->getByName(m_sCommand),UNO_QUERY); + if(xSup.is()) + xQueryColumns = xSup->getColumns(); + } do { @@ -740,7 +880,14 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr for(sal_Int32 i=1;i<=nCount;++i) { ::rtl::OUString sColumnName = xResultSetMeta->getColumnName(i); - ::rtl::OUString sColumnLabel = xResultSetMeta->getColumnLabel(i); + ::rtl::OUString sColumnLabel; + if ( xQueryColumns.is() && xQueryColumns->hasByName(sColumnName) ) + { + Reference xQueryColumn(xQueryColumns->getByName(sColumnName),UNO_QUERY_THROW); + xQueryColumn->getPropertyValue(PROPERTY_LABEL) >>= sColumnLabel; + } + else + sColumnLabel = xResultSetMeta->getColumnLabel(i); sal_Bool bFound = sal_False; OSQLColumns::Vector::const_iterator aFind = ::connectivity::find(aSelectColumns->get().begin(),aSelectColumns->get().end(),sColumnLabel,aCaseCompare); size_t nFoundSelectColumnPos = aFind - aSelectColumns->get().begin(); @@ -1372,49 +1519,7 @@ namespace sRet.append(pAndIter->Name); ::rtl::OUString sValue; pAndIter->Value >>= sValue; - switch( pAndIter->Handle ) - { - case SQLFilterOperator::EQUAL: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = "))); - sRet.append(sValue); - break; - case SQLFilterOperator::NOT_EQUAL: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> "))); - sRet.append(sValue); - break; - case SQLFilterOperator::LESS: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < "))); - sRet.append(sValue); - break; - case SQLFilterOperator::GREATER: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > "))); - sRet.append(sValue); - break; - case SQLFilterOperator::LESS_EQUAL: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= "))); - sRet.append(sValue); - break; - case SQLFilterOperator::GREATER_EQUAL: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= "))); - sRet.append(sValue); - break; - case SQLFilterOperator::LIKE: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE "))); - sRet.append(sValue); - break; - case SQLFilterOperator::NOT_LIKE: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE "))); - sRet.append(sValue); - break; - case SQLFilterOperator::SQLNULL: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) ); - break; - case SQLFilterOperator::NOT_SQLNULL: - sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) ); - break; - default: - throw IllegalArgumentException(); - } + lcl_addFilterCriteria_throw(pAndIter->Handle,sValue,sRet); ++pAndIter; if ( pAndIter != pAndEnd ) sRet.append(STR_AND); @@ -1441,7 +1546,7 @@ void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Seque setHavingClause(lcl_getCondition(filter)); } // ----------------------------------------------------------------------------- -void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t& _aSetFunctor) +void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t& _aSetFunctor,sal_Int32 filterOperator) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setConditionByColumn" ); ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed); @@ -1506,18 +1611,24 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert aSQL.append( ::dbtools::quoteName( aQuote, aName ) ); } + if ( aValue.hasValue() ) { if( !m_xTypeConverter.is() ) m_aContext.createComponent( "com.sun.star.script.Converter", m_xTypeConverter ); OSL_ENSURE(m_xTypeConverter.is(),"NO typeconverter!"); + if ( nType != DataType::BOOLEAN && DataType::BIT != nType ) + { + ::rtl::OUString sEmpty; + lcl_addFilterCriteria_throw(filterOperator,sEmpty,aSQL); + } + switch(nType) { case DataType::VARCHAR: case DataType::CHAR: case DataType::LONGVARCHAR: - aSQL.append( STR_LIKE ); aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); break; case DataType::CLOB: @@ -1528,7 +1639,6 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert const ::sal_Int64 nLength = xClob->length(); if ( sal_Int64(nLength + aSQL.getLength() + STR_LIKE.getLength() ) < sal_Int64(SAL_MAX_INT32) ) { - aSQL.append( STR_LIKE ); aSQL.appendAscii("'"); aSQL.append( xClob->getSubString(1,(sal_Int32)nLength) ); aSQL.appendAscii("'"); @@ -1536,7 +1646,6 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert } else { - aSQL.append( STR_LIKE ); aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); } } @@ -1550,11 +1659,8 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert { if(nSearchable == ColumnSearch::CHAR) { - aSQL.append( STR_LIKE ); aSQL.appendAscii( "\'" ); } - else - aSQL.append( STR_EQUAL ); aSQL.appendAscii( "0x" ); const sal_Int8* pBegin = aSeq.getConstArray(); const sal_Int8* pEnd = pBegin + aSeq.getLength(); @@ -1580,13 +1686,18 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert } break; default: - aSQL.append( STR_EQUAL ); aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); break; } } else - aSQL.appendAscii( " IS NULL" ) ; + { + sal_Int32 nFilterOp = filterOperator; + if ( filterOperator != SQLFilterOperator::SQLNULL && filterOperator != SQLFilterOperator::NOT_SQLNULL ) + nFilterOp = SQLFilterOperator::SQLNULL; + ::rtl::OUString sEmpty; + lcl_addFilterCriteria_throw(nFilterOp,sEmpty,aSQL); + } // filter anhaengen // select ohne where und order by aufbauen diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx index 77a29812b105..af40ac5667d2 100644 --- a/dbaccess/source/core/api/definitioncolumn.cxx +++ b/dbaccess/source/core/api/definitioncolumn.cxx @@ -192,14 +192,16 @@ rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException) DBG_NAME( OQueryColumn ); // ------------------------------------------------------------------------- -OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection,const ::rtl::OUString& _sNewName ) +OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection,const ::rtl::OUString i_sLabel ) :OTableColumnDescriptor( false /* do not act as descriptor */ ) + ,m_sLabel(i_sLabel) { const sal_Int32 nPropAttr = PropertyAttribute::READONLY; registerProperty( PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, nPropAttr, &m_sCatalogName, ::getCppuType( &m_sCatalogName ) ); registerProperty( PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nPropAttr, &m_sSchemaName, ::getCppuType( &m_sSchemaName ) ); registerProperty( PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, nPropAttr, &m_sTableName, ::getCppuType( &m_sTableName ) ); registerProperty( PROPERTY_REALNAME, PROPERTY_ID_REALNAME, nPropAttr, &m_sRealName, ::getCppuType( &m_sRealName ) ); + registerProperty( PROPERTY_LABEL, PROPERTY_ID_LABEL, nPropAttr, &m_sLabel, ::getCppuType( &m_sLabel ) ); DBG_CTOR( OQueryColumn, NULL ); @@ -210,14 +212,8 @@ OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, co OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType ); OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement ); OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency ); - if ( _sNewName.getLength() ) - { - m_sName = _sNewName; - } - else - { - OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName ); - } + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName ); + m_bRowVersion = sal_False; Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW ); diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index 3f3ccc57db2e..4f7e9b60547c 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -237,29 +237,25 @@ void OQuery::rebuildColumns() } Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); - Sequence< ::rtl::OUString> aDefintionNames; - bool bApplyDefinitionNames = false; - //if ( xColumnDefinitions.is() ) - //{ - // aDefintionNames = xColumnDefinitions->getElementNames(); - // bApplyDefinitionNames = aDefintionNames.getLength() == aNames.getLength(); - //} - - ::rtl::OUString sEmpty; const ::rtl::OUString* pIter = aNames.getConstArray(); - const ::rtl::OUString* pEnd = pIter + aNames.getLength(); + const ::rtl::OUString* pEnd = pIter + aNames.getLength(); for ( sal_Int32 i = 0;pIter != pEnd; ++pIter,++i) { Reference xSource(xColumns->getByName( *pIter ),UNO_QUERY); - OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, bApplyDefinitionNames ? aDefintionNames[i] : sEmpty); + ::rtl::OUString sLabel = *pIter; + if ( xColumnDefinitions.is() && xColumnDefinitions->hasByName(*pIter) ) + { + Reference xCommandColumn(xColumnDefinitions->getByName( *pIter ),UNO_QUERY); + xCommandColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + } + OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, sLabel); Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW ); xChild->setParent( *this ); - ::rtl::OUString sNewName = bApplyDefinitionNames ? aDefintionNames[i] : *pIter; - implAppendColumn( sNewName, pColumn ); + implAppendColumn( *pIter, pColumn ); Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW ); if ( m_pColumnMediator.is() ) - m_pColumnMediator->notifyElementCreated( sNewName, xDest ); + m_pColumnMediator->notifyElementCreated( *pIter, xDest ); } } catch( const SQLContext& e ) diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx index 6b17ad97e12a..ce0a389407aa 100644 --- a/dbaccess/source/core/api/querycomposer.cxx +++ b/dbaccess/source/core/api/querycomposer.cxx @@ -91,6 +91,7 @@ #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include #endif +#include #ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX #include "querycomposer.hxx" #endif @@ -285,7 +286,23 @@ void SAL_CALL OQueryComposer::appendFilterByColumn( const Reference< XPropertySe m_xComposerHelper->setQuery(getQuery()); m_xComposerHelper->setFilter(::rtl::OUString()); - m_xComposerHelper->appendFilterByColumn(column,sal_True); + sal_Int32 nOp = SQLFilterOperator::EQUAL; + if ( column.is() ) + { + sal_Int32 nType = 0; + column->getPropertyValue(PROPERTY_TYPE) >>= nType; + switch(nType) + { + case DataType::VARCHAR: + case DataType::CHAR: + case DataType::LONGVARCHAR: + nOp = SQLFilterOperator::LIKE; + break; + default: + nOp = SQLFilterOperator::EQUAL; + } + } + m_xComposerHelper->appendFilterByColumn(column,sal_True,nOp); FilterCreator aFilterCreator; aFilterCreator.append(getFilter()); diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx index 88be29d9240d..3240a269bd53 100644 --- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -130,6 +130,7 @@ namespace dbaccess ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionTables; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionQueries; ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns; ::comphelper::ComponentContext m_aContext; @@ -140,8 +141,10 @@ namespace dbaccess ::rtl::OUString m_aPureSelectSQL; // the pure select statement, without filter/order/groupby/having ::rtl::OUString m_sDecimalSep; + ::rtl::OUString m_sCommand; ::com::sun::star::lang::Locale m_aLocale; sal_Int32 m_nBoolCompareMode; // how to compare bool values + sal_Int32 m_nCommandType; // ::rtl::OUString m_sOrignal; @@ -172,8 +175,8 @@ namespace dbaccess void setConditionByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column , sal_Bool andCriteria - ,::std::mem_fun1_t& _aSetFunctor); - + ,::std::mem_fun1_t& _aSetFunctor + ,sal_Int32 filterOperator); /** getStructuredCondition returns the structured condition for the where or having clause @param _aGetFunctor @@ -249,18 +252,19 @@ namespace dbaccess virtual void SAL_CALL setElementaryQuery( const ::rtl::OUString& _rElementary ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setFilter( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setStructuredFilter( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL appendGroupByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setGroup( const ::rtl::OUString& group ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHavingClause( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setStructuredHavingClause( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL appendHavingClauseByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendHavingClauseByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL appendOrderByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool ascending ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setOrder( const ::rtl::OUString& order ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); // XSingleSelectQueryAnalyzer virtual ::rtl::OUString SAL_CALL getQuery( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setQuery( const ::rtl::OUString& command ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCommand( const ::rtl::OUString& command,sal_Int32 CommandType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getFilter( ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getGroup( ) throw (::com::sun::star::uno::RuntimeException); diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx index b67b0de70c59..8d5f0d4b3f04 100644 --- a/dbaccess/source/core/inc/definitioncolumn.hxx +++ b/dbaccess/source/core/inc/definitioncolumn.hxx @@ -157,6 +157,7 @@ namespace dbaccess ::rtl::OUString m_sSchemaName; ::rtl::OUString m_sTableName; ::rtl::OUString m_sRealName; + ::rtl::OUString m_sLabel; // ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xOriginalTableColumn; @@ -168,7 +169,7 @@ namespace dbaccess OQueryColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, - const ::rtl::OUString& _sNewName + const ::rtl::OUString i_sLabel ); // XTypeProvider diff --git a/dbaccess/source/inc/stringconstants.hrc b/dbaccess/source/inc/stringconstants.hrc index 6a58ba1ddd0d..2b00a4c5af14 100644 --- a/dbaccess/source/inc/stringconstants.hrc +++ b/dbaccess/source/inc/stringconstants.hrc @@ -183,6 +183,7 @@ #define PROPERTY_ID_THOUSAND_DELIMITER 140 #define PROPERTY_ID_ENCODING 141 #define PROPERTY_ID_HELP_URL 142 +#define PROPERTY_ID_SINGLESELECTQUERYCOMPOSER 143 //============================================================ //= property names @@ -339,6 +340,7 @@ DECLARE_CONSTASCII_USTRING(PROPERTY_AS_TEMPLATE); DECLARE_CONSTASCII_USTRING(PROPERTY_HAVING_CLAUSE); DECLARE_CONSTASCII_USTRING(PROPERTY_GROUP_BY); DECLARE_CONSTASCII_USTRING(PROPERTY_EDIT_WIDTH); +DECLARE_CONSTASCII_USTRING(PROPERTY_SINGLESELECTQUERYCOMPOSER); //============================================================ //= service names diff --git a/dbaccess/source/inc/stringconstants.inc b/dbaccess/source/inc/stringconstants.inc index 8803d0e0edc7..08168f859870 100644 --- a/dbaccess/source/inc/stringconstants.inc +++ b/dbaccess/source/inc/stringconstants.inc @@ -185,6 +185,7 @@ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_AS_TEMPLATE, "AsTemplate"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_HAVING_CLAUSE, "HavingClause"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_GROUP_BY, "GroupBy"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_EDIT_WIDTH, "EditWidth"); +IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SINGLESELECTQUERYCOMPOSER,"SingleSelectQueryComposer"); //============================================================ //= service names 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 #include #include +#include #include #include #include @@ -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 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 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/inc/brwctrlr.hxx b/dbaccess/source/ui/inc/brwctrlr.hxx index d94f76b8dcc9..eab8e3ad82b0 100644 --- a/dbaccess/source/ui/inc/brwctrlr.hxx +++ b/dbaccess/source/ui/inc/brwctrlr.hxx @@ -344,14 +344,15 @@ namespace dbaui void ExecuteSearch(); void initializeParser() const; // changes the mutable member m_xParser - void applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving = ::rtl::OUString()); - void applyParserOrder(const ::rtl::OUString& _rOldOrder); + void applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving,const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xParser); + void applyParserOrder(const ::rtl::OUString& _rOldOrder,const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xParser); sal_Int16 getCurrentColumnPosition(); void setCurrentColumnPosition( sal_Int16 _nPos ); void addColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel); void impl_checkForCannotSelectUnfiltered( const ::dbtools::SQLExceptionInfo& _rError ); + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > createParser_nothrow(); // time to check the CUT/COPY/PASTE-slot-states DECL_LINK( OnInvalidateClipboard, AutoTimer* ); -- cgit From cea09e968c10682ade933a40038cb0b3eb658187 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 22 Jan 2010 10:31:43 +0100 Subject: dba33f: #i108548# handle Label property from parse column and rowsetcolumn --- dbaccess/source/core/api/CRowSetColumn.cxx | 4 ++-- dbaccess/source/core/api/CRowSetColumn.hxx | 1 + dbaccess/source/core/api/CRowSetDataColumn.cxx | 4 ++++ dbaccess/source/core/api/CRowSetDataColumn.hxx | 2 ++ dbaccess/source/core/api/RowSet.cxx | 13 +++++++++++++ dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 2 +- dbaccess/source/core/api/query.cxx | 2 +- dbaccess/source/ui/browser/unodatbr.cxx | 7 ++++++- 8 files changed, 30 insertions(+), 5 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/CRowSetColumn.cxx b/dbaccess/source/core/api/CRowSetColumn.cxx index 0974963dfd72..20e3c639eb88 100644 --- a/dbaccess/source/core/api/CRowSetColumn.cxx +++ b/dbaccess/source/core/api/CRowSetColumn.cxx @@ -53,8 +53,8 @@ namespace dbaccess //------------------------------------------------------------------------------ ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData, const Reference < XRow >& _xRow, sal_Int32 _nPos, - const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, ORowSetCacheIterator& _rColumnValue ) - :ORowSetDataColumn( _xMetaData, _xRow, NULL, _nPos, _rxDBMeta, _rDescription, _rColumnValue ) + const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, const ::rtl::OUString& i_sLabel,ORowSetCacheIterator& _rColumnValue ) + :ORowSetDataColumn( _xMetaData, _xRow, NULL, _nPos, _rxDBMeta, _rDescription, i_sLabel,_rColumnValue ) { } diff --git a/dbaccess/source/core/api/CRowSetColumn.hxx b/dbaccess/source/core/api/CRowSetColumn.hxx index 45d71d8e513a..317a28f15db1 100644 --- a/dbaccess/source/core/api/CRowSetColumn.hxx +++ b/dbaccess/source/core/api/CRowSetColumn.hxx @@ -56,6 +56,7 @@ namespace dbaccess sal_Int32 _nPos, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, + const ::rtl::OUString& i_sLabel, ORowSetCacheIterator& _rColumnValue); virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx index ae78b8af7817..036ebfae6466 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.cxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx @@ -74,10 +74,12 @@ ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& sal_Int32 _nPos, const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, + const ::rtl::OUString& i_sLabel, const ORowSetCacheIterator& _rColumnValue) :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta) ,m_aColumnValue(_rColumnValue) ,m_aDescription(_rDescription) + ,m_sLabel(i_sLabel) { DBG_CTOR(ORowSetDataColumn,NULL); OColumnSettings::registerProperties( *this ); @@ -149,6 +151,8 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny(); } } + else if ( PROPERTY_ID_LABEL == nHandle && m_sLabel.getLength() ) + rValue <<= m_sLabel; else ODataColumn::getFastPropertyValue( rValue, nHandle ); } diff --git a/dbaccess/source/core/api/CRowSetDataColumn.hxx b/dbaccess/source/core/api/CRowSetDataColumn.hxx index ceec7344737c..f6a3446755df 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.hxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.hxx @@ -51,6 +51,7 @@ namespace dbaccess ORowSetCacheIterator m_aColumnValue; ::com::sun::star::uno::Any m_aOldValue; + ::rtl::OUString m_sLabel; ::rtl::OUString m_aDescription; // description ORowSetBase* m_pRowSet; @@ -62,6 +63,7 @@ namespace dbaccess sal_Int32 _nPos, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, + const ::rtl::OUString& i_sLabel, const ORowSetCacheIterator& _rColumnValue); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 01f6d7d3259b..1531f232e5e7 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -1843,6 +1843,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi i+1, m_xActiveConnection->getMetaData(), aDescription, + ::rtl::OUString(), m_aCurrentRow); aColumnMap.insert(StringMap::value_type(sName,0)); aColumns->get().push_back(pColumn); @@ -1933,14 +1934,22 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_DESCRIPTION)) aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); + ::rtl::OUString sParseLabel; + if ( xColumn.is() ) + { + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel; + } ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(), this, this, i, m_xActiveConnection->getMetaData(), aDescription, + sParseLabel, m_aCurrentRow); aColumns->get().push_back(pColumn); + + if(!sColumnLabel.getLength()) { if(xColumn.is()) @@ -2761,11 +2770,15 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo rParent.m_pColumns->getByName(*pIter) >>= xColumn; if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION)) aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); + + ::rtl::OUString sParseLabel; + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel; ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(), this, i, rParent.m_xActiveConnection->getMetaData(), aDescription, + sParseLabel, m_aCurrentRow); aColumns->get().push_back(pColumn); pColumn->setName(*pIter); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index c7dd2c130f44..1a1f9bc1d679 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -865,7 +865,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr { // This is a valid case. If we can syntactically parse the query, but not semantically // (e.g. because it is based on a table we do not know), then there will be no SelectColumns - aSelectColumns = ::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, m_xMetaData ); + aSelectColumns = ::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, m_xMetaData ,xQueryColumns); break; } diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index 4f7e9b60547c..ad5ccbc2aee3 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -229,7 +229,7 @@ void OQuery::rebuildColumns() Reference< XDatabaseMetaData > xDBMeta( m_xConnection->getMetaData(), UNO_QUERY_THROW ); ::vos::ORef< OSQLColumns > aParseColumns( - ::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, xDBMeta ) ); + ::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, xDBMeta,xColumnDefinitions ) ); xColumns = OPrivateColumns::createWithIntrinsicNames( aParseColumns, xDBMeta->storesMixedCaseQuotedIdentifiers(), *this, m_aMutex ); if ( !xColumns.is() ) diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index d6b6483f4a7f..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 ); -- cgit From 79ea41cc2a0636a1fb0c21fd290ee9020e2fc016 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 22 Jan 2010 15:03:40 +0100 Subject: dba33f: memeber ini --- dbaccess/source/core/api/CRowSetDataColumn.cxx | 2 +- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx index 036ebfae6466..4b1c3649bf6a 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.cxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx @@ -78,8 +78,8 @@ ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& const ORowSetCacheIterator& _rColumnValue) :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta) ,m_aColumnValue(_rColumnValue) - ,m_aDescription(_rDescription) ,m_sLabel(i_sLabel) + ,m_aDescription(_rDescription) { DBG_CTOR(ORowSetDataColumn,NULL); OColumnSettings::registerProperties( *this ); diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 73263525fc93..376482bcde60 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -652,7 +652,7 @@ namespace if ( pLeftTable ) { OQueryTableWindow* pLeftWindow = static_cast(_pView->getTableView())->FindTable( getTableRange(_pView,pLeftTable->getByRule(OSQLParseNode::table_ref) )); - OQueryTableWindow* pRightWindow = static_cast(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTable->getByRule(OSQLParseNode::table_ref) )); + // OQueryTableWindow* pRightWindow = static_cast(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTable->getByRule(OSQLParseNode::table_ref) )); if ( pLeftWindow == aDragLeft->GetTabWindow() ) insertConnection(_pView,_eJoinType,aDragLeft,aDragRight); else -- cgit From 576ac52c6f7251c49fc22848cd0f7fcf083639e0 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 27 Jan 2010 15:20:45 +0100 Subject: dba33f: use a temp to gold controller --- dbaccess/source/ui/control/sqledit.cxx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx index 3889d091f737..59d5843689f1 100644 --- a/dbaccess/source/ui/control/sqledit.cxx +++ b/dbaccess/source/ui/control/sqledit.cxx @@ -87,8 +87,9 @@ OSqlEdit::~OSqlEdit() void OSqlEdit::KeyInput( const KeyEvent& rKEvt ) { DBG_CHKTHIS(OSqlEdit,NULL); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_CUT); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_COPY); + OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController(); + rController.InvalidateFeature(SID_CUT); + rController.InvalidateFeature(SID_COPY); // Ist dies ein Cut, Copy, Paste Event? KeyFuncType aKeyFunc = rKEvt.GetKeyCode().GetFunction(); @@ -127,14 +128,15 @@ IMPL_LINK(OSqlEdit, OnUndoActionTimer, void*, EMPTYARG) String aText =GetText(); if(aText != m_strOrigText) { - SfxUndoManager* pUndoMgr = m_pView->getContainerWindow()->getDesignView()->getController().getUndoMgr(); + OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController(); + SfxUndoManager* pUndoMgr = rController.getUndoMgr(); OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( this ); pUndoAct->SetOriginalText( m_strOrigText ); pUndoMgr->AddUndoAction( pUndoAct ); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_UNDO); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_REDO); + rController.InvalidateFeature(SID_UNDO); + rController.InvalidateFeature(SID_REDO); m_strOrigText =aText; } @@ -144,8 +146,9 @@ IMPL_LINK(OSqlEdit, OnUndoActionTimer, void*, EMPTYARG) //------------------------------------------------------------------------------ IMPL_LINK(OSqlEdit, OnInvalidateTimer, void*, EMPTYARG) { - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_CUT); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_COPY); + OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController(); + rController.InvalidateFeature(SID_CUT); + rController.InvalidateFeature(SID_COPY); if(!m_bStopTimer) m_timerInvalidate.Start(); return 0L; @@ -157,12 +160,13 @@ IMPL_LINK(OSqlEdit, ModifyHdl, void*, /*EMPTYTAG*/) m_timerUndoActionCreation.Stop(); m_timerUndoActionCreation.Start(); - if (!m_pView->getContainerWindow()->getDesignView()->getController().isModified()) - m_pView->getContainerWindow()->getDesignView()->getController().setModified( sal_True ); + OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController(); + if (!rController.isModified()) + rController.setModified( sal_True ); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_SBA_QRY_EXECUTE); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_CUT); - m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_COPY); + rController.InvalidateFeature(SID_SBA_QRY_EXECUTE); + rController.InvalidateFeature(SID_CUT); + rController.InvalidateFeature(SID_COPY); m_lnkTextModifyHdl.Call(NULL); return 0; -- cgit From f29cae73b29868dad9021f87d800c4d115bc7bf3 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 28 Jan 2010 08:43:23 +0100 Subject: dba33f: #i108730# impl case case and rank functions --- dbaccess/source/ui/querydesign/querycontroller.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index ca1bc56f01ef..91c30370d26a 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -1679,7 +1679,7 @@ void OQueryController::impl_reset() m_pSqlIterator->traverseAll(); if ( m_pSqlIterator->hasErrors() ) { - if ( !editingView() ) + if ( m_bGraphicalDesign && !editingView() ) { impl_showAutoSQLViewError( makeAny( m_pSqlIterator->getErrors() ) ); } -- cgit From e0288f9960b4e5f49e1fa77b3b5d6cd8c737f462 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 29 Jan 2010 10:12:25 +0100 Subject: dba33f: when re-activating an embedded object, do not reset its modified state (plus do not the other initializations which are needed for the first activation only) --- dbaccess/source/core/dataaccess/documentdefinition.cxx | 8 ++++---- dbaccess/source/core/dataaccess/documentdefinition.hxx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index f4426025c6fa..8c3ace1cd15c 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -697,7 +697,7 @@ void ODocumentDefinition::impl_removeFrameFromDesktop_throw( const ::comphelper: } // ----------------------------------------------------------------------------- -void ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow() +void ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow( const bool i_bReactivated ) { try { @@ -724,7 +724,7 @@ void ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow() LifetimeCoupler::couple( *this, xFrame.get() ); // init the edit view - if ( m_bForm && m_bOpenInDesign ) + if ( m_bForm && m_bOpenInDesign && !i_bReactivated ) impl_initFormEditView( xController ); } catch( const RuntimeException& ) @@ -1034,7 +1034,7 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons if ( _bActivate && !bOpenHidden ) { m_xEmbeddedObject->changeState( EmbedStates::ACTIVE ); - ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow(); + ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow( false ); } else { @@ -1091,7 +1091,7 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co if ( bIsActive && !bIsAliveNewStyleReport ) { - ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow(); + ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow( true ); return makeAny( getComponent() ); } } diff --git a/dbaccess/source/core/dataaccess/documentdefinition.hxx b/dbaccess/source/core/dataaccess/documentdefinition.hxx index c48d20ad58a3..cb520ab5fef8 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.hxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.hxx @@ -200,7 +200,7 @@ public: private: /** does necessary initializations after our embedded object has been switched to ACTIVE */ - void impl_onActivateEmbeddedObject_nothrow(); + void impl_onActivateEmbeddedObject_nothrow( const bool i_bReactivated ); /** initializes a newly created view/controller of a form which is displaying our embedded object -- cgit From d16fa93c41e0c55d1b8045891e69d2a9f86f8f9f Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 8 Feb 2010 14:07:46 +0100 Subject: dba33f: don't ask every driver for a tables keys and consolidate some code fragments --- dbaccess/source/ui/browser/unodatbr.cxx | 6 +++- dbaccess/source/ui/inc/RTableConnectionData.hxx | 6 ++-- dbaccess/source/ui/inc/unodatbr.hxx | 1 + dbaccess/source/ui/misc/WCopyTable.cxx | 18 ++--------- dbaccess/source/ui/querydesign/TableWindow.cxx | 28 ++-------------- .../ui/relationdesign/RTableConnectionData.cxx | 37 ++++++++++------------ .../source/ui/relationdesign/RelationTableView.cxx | 5 ++- dbaccess/source/ui/tabledesign/TableController.cxx | 34 +------------------- 8 files changed, 33 insertions(+), 102 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index eda9fc01a3e4..05c580a0aeba 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -1108,7 +1108,11 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS { // expand if required so if (_bExpandAncestors) + { + m_sToBeLoaded = _rCommand; m_pTreeView->getListBox().Expand(pCommandType); + m_sToBeLoaded = ::rtl::OUString(); + } // look for the object ::rtl::OUString sCommand = _rCommand; @@ -2057,7 +2061,7 @@ void SbaTableQueryBrowser::populateTree(const Reference& _xNameAcce const ::rtl::OUString* pEnd = pIter + aNames.getLength(); for (; pIter != pEnd; ++pIter) { - if(!m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent)) + if( (!m_sToBeLoaded.getLength() || m_sToBeLoaded == *pIter) && !m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent)) { Reference xChild(_xNameAccess->getByName(*pIter),UNO_QUERY); DBTreeListUserData* pEntryData = new DBTreeListUserData; diff --git a/dbaccess/source/ui/inc/RTableConnectionData.hxx b/dbaccess/source/ui/inc/RTableConnectionData.hxx index 1cb3c75540bd..503ee2b7d10a 100644 --- a/dbaccess/source/ui/inc/RTableConnectionData.hxx +++ b/dbaccess/source/ui/inc/RTableConnectionData.hxx @@ -64,9 +64,9 @@ namespace dbaui sal_Int32 m_nDeleteRules; sal_Int32 m_nCardinality; - BOOL checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xKeys,EConnectionSide _eEConnectionSide) const; - BOOL IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getKeys(),JTCS_FROM); } - BOOL IsDestPrimKey() const { return checkPrimaryKey(getReferencedTable()->getKeys(),JTCS_TO); } + BOOL checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const; + BOOL IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM); } + BOOL IsDestPrimKey() const { return checkPrimaryKey(getReferencedTable()->getTable(),JTCS_TO); } protected: virtual OConnectionLineDataRef CreateLineDataObj(); diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx index 3436d565367f..7a574310d82c 100644 --- a/dbaccess/source/ui/inc/unodatbr.hxx +++ b/dbaccess/source/ui/inc/unodatbr.hxx @@ -160,6 +160,7 @@ namespace dbaui OTableCopyHelper m_aTableCopyHelper; ::rtl::OUString m_sQueryCommand; // the command of the query currently loaded (if any) + ::rtl::OUString m_sToBeLoaded; // contains the element name which should be loaded if any DBTreeView* m_pTreeView; Splitter* m_pSplitter; diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 988baa48b1fd..f30f81f41d04 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -233,22 +233,10 @@ Sequence< ::rtl::OUString > ObjectCopySource::getColumnNames() const //------------------------------------------------------------------------ Sequence< ::rtl::OUString > ObjectCopySource::getPrimaryKeyColumnNames() const { - Reference xSup(m_xObject,UNO_QUERY); - Reference< XIndexAccess> xKeys; - if(xSup.is() ) - xKeys = xSup->getKeys(); - - ::std::vector< Reference< XNameAccess > > aPrimaryKeyColumns( ::dbaui::getKeyColumns( xKeys, KeyType::PRIMARY ) ); - OSL_ENSURE( ( aPrimaryKeyColumns.size() == 1 ) || aPrimaryKeyColumns.empty(), - "ObjectCopySource::getPrimaryKeyColumnNames: more than one primary key?!" ); - - Reference< XNameAccess > xKeyCols; - if ( !aPrimaryKeyColumns.empty() ) - xKeyCols = aPrimaryKeyColumns[0]; - + const Reference xPrimaryKeyColumns = getPrimaryKeyColumns_throw(m_xObject); Sequence< ::rtl::OUString > aKeyColNames; - if ( xKeyCols.is() ) - aKeyColNames = xKeyCols->getElementNames(); + if ( xPrimaryKeyColumns.is() ) + aKeyColNames = xPrimaryKeyColumns->getElementNames(); return aKeyColNames; } diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx index 46580954d02f..b4be90156303 100644 --- a/dbaccess/source/ui/querydesign/TableWindow.cxx +++ b/dbaccess/source/ui/querydesign/TableWindow.cxx @@ -62,8 +62,6 @@ #endif #include -#include -#include #include #include #include @@ -76,6 +74,7 @@ #include "UITools.hxx" #include "TableWindowAccess.hxx" #include "browserids.hxx" +#include using namespace dbaui; @@ -224,30 +223,7 @@ BOOL OTableWindow::FillListBox() Reference xPKeyColumns; try { - // first we need the keys from the table - Reference< XIndexAccess> xKeyIndex = m_pData->getKeys(); - // search the one and only primary key - if ( xKeyIndex.is() ) - { - Reference xColumnsSupplier; - for(sal_Int32 i=0;i< xKeyIndex->getCount();++i) - { - Reference xProp; - xKeyIndex->getByIndex(i) >>= xProp; - if ( xProp.is() ) - { - sal_Int32 nKeyType = 0; - xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; - if(KeyType::PRIMARY == nKeyType) - { - xColumnsSupplier.set(xProp,UNO_QUERY); - break; - } - } - } - if ( xColumnsSupplier.is() ) - xPKeyColumns = xColumnsSupplier->getColumns(); - } + xPKeyColumns = dbtools::getPrimaryKeyColumns_throw(m_pData->getTable()); } catch(Exception&) { diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index 00478a064ced..b625bd6b0f9b 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx @@ -45,6 +45,7 @@ #include "UITools.hxx" #include "moduledbu.hxx" #include +#include using namespace dbaui; using namespace ::com::sun::star::sdbc; @@ -176,35 +177,29 @@ void ORelationTableConnectionData::SetCardinality() } // ----------------------------------------------------------------------------- -BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XIndexAccess>& _xKeys,EConnectionSide _eEConnectionSide) const +BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const { // check if Table has the primary key column dependig on _eEConnectionSide USHORT nPrimKeysCount = 0, nValidLinesCount = 0; - ::std::vector > vKeyColumns = ::dbaui::getKeyColumns(_xKeys,KeyType::PRIMARY); - if ( vKeyColumns.size() == 1 ) + const Reference< XNameAccess> xKeyColumns = dbtools::getPrimaryKeyColumns_throw(i_xTable); + if ( xKeyColumns.is() ) { -// OSL_ENSURE(vKeyColumns.size()==1,"There can be only one primary key in a table!"); - Sequence< ::rtl::OUString> aKeyColumns; - Reference xKeyColumns = *vKeyColumns.begin(); - if ( xKeyColumns.is() ) - { - aKeyColumns = xKeyColumns->getElementNames(); - const ::rtl::OUString* pKeyIter = aKeyColumns.getConstArray(); - const ::rtl::OUString* pKeyEnd = pKeyIter + aKeyColumns.getLength(); + Sequence< ::rtl::OUString> aKeyColumns = xKeyColumns->getElementNames(); + const ::rtl::OUString* pKeyIter = aKeyColumns.getConstArray(); + const ::rtl::OUString* pKeyEnd = pKeyIter + aKeyColumns.getLength(); - for(;pKeyIter != pKeyEnd;++pKeyIter) + for(;pKeyIter != pKeyEnd;++pKeyIter) + { + OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin(); + OConnectionLineDataVec::const_iterator aEnd = m_vConnLineData.end(); + for(;aIter != aEnd;++aIter) { - OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin(); - OConnectionLineDataVec::const_iterator aEnd = m_vConnLineData.end(); - for(;aIter != aEnd;++aIter) + ++nValidLinesCount; + if ( (*aIter)->GetFieldName(_eEConnectionSide) == *pKeyIter ) { - ++nValidLinesCount; - if ( (*aIter)->GetFieldName(_eEConnectionSide) == *pKeyIter ) - { - ++nPrimKeysCount; - break; - } + ++nPrimKeysCount; + break; } } } diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index ca533d84062a..35aa8df11b34 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -228,9 +228,8 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const ::rtl::OUString sDestFieldName = jxdDest.pListBox->GetEntryText(jxdDest.pEntry); // die Anzahl der PKey-Felder in der Quelle - - ::std::vector< Reference< XNameAccess> > aPkeys = ::dbaui::getKeyColumns(pSourceWin->GetData()->getKeys(),KeyType::PRIMARY); - bool bAskUser = aPkeys.size() == 1 && Reference< XIndexAccess>(aPkeys[0],UNO_QUERY)->getCount() > 1; + const Reference< XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(pSourceWin->GetData()->getTable()); + bool bAskUser = xPrimaryKeyColumns.is() && Reference< XIndexAccess>(xPrimaryKeyColumns,UNO_QUERY)->getCount() > 1; pTabConnData->SetConnLine( 0, sSourceFieldName, sDestFieldName ); diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index df01b15dc6cf..1d35c5e67787 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -971,39 +971,7 @@ void OTableController::loadData() // ----------------------------------------------------------------------------- Reference OTableController::getKeyColumns() const { - // use keys and indexes for excat postioning - // first the keys - Reference xKeySup(m_xTable,UNO_QUERY); - Reference xKeys; - if(xKeySup.is()) - xKeys = xKeySup->getKeys(); - - Reference xKeyColsSup; - Reference xKeyColumns; - if(xKeys.is()) - { - Reference xProp; - sal_Int32 nCount = xKeys->getCount(); - for(sal_Int32 i=0;i< nCount;++i) - { - xKeys->getByIndex(i) >>= xProp; - OSL_ENSURE(xProp.is(),"Key is invalid: NULL!"); - if ( xProp.is() ) - { - sal_Int32 nKeyType = 0; - xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; - if(KeyType::PRIMARY == nKeyType) - { - xKeyColsSup.set(xProp,UNO_QUERY); - OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!"); - xKeyColumns = xKeyColsSup->getColumns(); - break; - } - } - } - } - - return xKeyColumns; + return getPrimaryKeyColumns_throw(m_xTable); } // ----------------------------------------------------------------------------- sal_Bool OTableController::checkColumns(sal_Bool _bNew) throw(::com::sun::star::sdbc::SQLException) -- cgit From 1baf7abd1c670cd78b54104ef93569f510bdb0fb Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 8 Feb 2010 14:09:08 +0100 Subject: dba33f: #i53377# make property IsReadOnly bound --- dbaccess/source/core/api/CRowSetColumn.cxx | 2 +- dbaccess/source/core/api/CRowSetDataColumn.cxx | 46 ++++++++++++++++++-------- dbaccess/source/core/api/CRowSetDataColumn.hxx | 1 - 3 files changed, 34 insertions(+), 15 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/CRowSetColumn.cxx b/dbaccess/source/core/api/CRowSetColumn.cxx index 20e3c639eb88..d7bb2e9f097a 100644 --- a/dbaccess/source/core/api/CRowSetColumn.cxx +++ b/dbaccess/source/core/api/CRowSetColumn.cxx @@ -73,7 +73,7 @@ ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaDa DECL_PROP1_BOOL( ISCURRENCY, READONLY ); DECL_PROP1_BOOL( ISDEFINITELYWRITABLE, READONLY ); DECL_PROP1( ISNULLABLE, sal_Int32, READONLY ); - DECL_PROP1_BOOL( ISREADONLY, READONLY ); + DECL_PROP1_BOOL( ISREADONLY, BOUND ); DECL_PROP1_BOOL( ISROWVERSION, READONLY ); DECL_PROP1_BOOL( ISSEARCHABLE, READONLY ); DECL_PROP1_BOOL( ISSIGNED, READONLY ); diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx index 036ebfae6466..40a662e0aa6d 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.cxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx @@ -107,7 +107,7 @@ ORowSetDataColumn::~ORowSetDataColumn() DECL_PROP1_BOOL( ISCURRENCY, READONLY ); DECL_PROP1_BOOL( ISDEFINITELYWRITABLE, READONLY ); DECL_PROP1( ISNULLABLE, sal_Int32, READONLY ); - DECL_PROP1_BOOL( ISREADONLY, READONLY ); + DECL_PROP1_BOOL( ISREADONLY, BOUND ); DECL_PROP1_BOOL( ISROWVERSION, READONLY ); DECL_PROP1_BOOL( ISSEARCHABLE, READONLY ); DECL_PROP1_BOOL( ISSIGNED, READONLY ); @@ -160,13 +160,21 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH // ------------------------------------------------------------------------- void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception) { - if ( PROPERTY_ID_VALUE == nHandle ) - { - updateObject(rValue); - } - else + switch( nHandle ) { - ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue ); + case PROPERTY_ID_VALUE: + updateObject(rValue); + break; + case PROPERTY_ID_ISREADONLY: + { + sal_Bool bVal = sal_False; + rValue >>= bVal; + m_isReadOnly.reset(bVal); + } + break; + default: + ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue ); + break; } } // ------------------------------------------------------------------------- @@ -176,14 +184,26 @@ sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedV const Any& rValue ) throw (IllegalArgumentException) { sal_Bool bModified = sal_False; - if ( PROPERTY_ID_VALUE == nHandle ) + switch( nHandle ) { - rConvertedValue = rValue; - getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE); - bModified = rConvertedValue != rOldValue; + case PROPERTY_ID_VALUE: + { + rConvertedValue = rValue; + getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE); + bModified = rConvertedValue != rOldValue; + } + break; + case PROPERTY_ID_ISREADONLY: + { + rConvertedValue = rValue; + getFastPropertyValue(rOldValue, PROPERTY_ID_ISREADONLY); + bModified = rConvertedValue != rOldValue; + } + break; + default: + bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue); + break; } - else - bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue); return bModified; } diff --git a/dbaccess/source/core/api/CRowSetDataColumn.hxx b/dbaccess/source/core/api/CRowSetDataColumn.hxx index f6a3446755df..056111ddf266 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.hxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.hxx @@ -83,7 +83,6 @@ namespace dbaccess virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue )throw (::com::sun::star::uno::Exception); virtual void fireValueChange(const ::connectivity::ORowSetValue& _rOldValue); - protected: using ODataColumn::getFastPropertyValue; }; -- cgit From ec5b5ea536dc706d124692bd6ebf123f5ea7a316 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 8 Feb 2010 14:11:22 +0100 Subject: dba33f: #i108730# impl case case and rank functions --- .../dbaccess/SingleSelectQueryComposer.java | 31 ++++++++++++++++++++++ .../source/core/api/SingleSelectQueryComposer.cxx | 8 +++--- 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java index 40ce60699c05..80e52c92da17 100755 --- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java +++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java @@ -55,6 +55,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase { return new String[] { + "testSetCommand", "testAttributes", "testSubQueries", "testParameters", @@ -131,6 +132,31 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase log.println(" (results in " + (String) m_composer.getQuery() + ")"); } + /** tests setCommand of the composer + */ + public void testSetCommand() + { + log.println("testing SingleSelectQueryComposer's setCommand"); + + try + { + final String table = "SELECT * FROM \"customers\""; + m_composer.setCommand("customers",CommandType.TABLE); + assure("setCommand/getQuery TABLE inconsistent", m_composer.getQuery().equals(table)); + + m_database.getDatabase().getDataSource().createQuery("set command test", "SELECT * FROM \"orders for customer\" \"a\", \"customers\" \"b\" WHERE \"a\".\"Product Name\" = \"b\".\"Name\""); + m_composer.setCommand("set command test",CommandType.QUERY); + assure("setCommand/getQuery QUERY inconsistent", m_composer.getQuery().equals(m_database.getDatabase().getDataSource().getQueryDefinition("set command test").getCommand())); + + final String sql = "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" = 'test'"; + m_composer.setCommand(sql,CommandType.COMMAND); + assure("setCommand/getQuery COMMAND inconsistent", m_composer.getQuery().equals(sql)); + } + catch (Exception e) + { + assure("Exception caught: " + e, false); + } + } /** tests accessing attributes of the composer (order, filter, group by, having) */ public void testAttributes() @@ -139,6 +165,11 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase try { + log.println("check setElementaryQuery"); + final String simpleQuery2 = "SELECT * FROM \"customers\" WHERE \"Name\" = 'oranges'"; + m_composer.setElementaryQuery(simpleQuery2); + assure("setElementaryQuery/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery2)); + log.println("check setQuery"); final String simpleQuery = "SELECT * FROM \"customers\""; m_composer.setQuery(simpleQuery); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 1a1f9bc1d679..85de0b8bc463 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1067,16 +1067,16 @@ sal_Bool OSingleSelectQueryComposer::setANDCriteria( OSQLParseNode * pCondition, aItem.Name = getColumnName(pCondition->getChild(0),_rIterator); aItem.Value <<= aValue; aItem.Handle = 0; // just to know that this is not one the known ones - if (SQL_ISRULE(pCondition,like_predicate)) + if ( SQL_ISRULE(pCondition,like_predicate) ) { - if (pCondition->count() == 5) + if ( SQL_ISTOKEN(pCondition->getChild(1)->getChild(0),NOT) ) aItem.Handle = SQLFilterOperator::NOT_LIKE; else aItem.Handle = SQLFilterOperator::LIKE; } else if (SQL_ISRULE(pCondition,test_for_null)) { - if (SQL_ISTOKEN(pCondition->getChild(2),NOT) ) + if (SQL_ISTOKEN(pCondition->getChild(1)->getChild(2),NOT) ) aItem.Handle = SQLFilterOperator::NOT_SQLNULL; else aItem.Handle = SQLFilterOperator::SQLNULL; @@ -1238,7 +1238,7 @@ sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCon aValue = aValue.copy(aColumnName.getLength()); aValue.trim(); - aItem.Name = UniString(getColumnName(pCondition->getChild(0),_rIterator)); + aItem.Name = getColumnName(pCondition->getChild(0),_rIterator); aItem.Value <<= aValue; aItem.Handle = pCondition->getNodeType(); rFilter.push_back(aItem); -- cgit From 4c43716cecb1aeab9f4713aa00e00be4f169ad7c Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 15 Feb 2010 09:53:53 +0100 Subject: dba33f: #i53377# impl join rowse helper resultset which is updateable --- dbaccess/source/core/api/CacheSet.cxx | 93 +- dbaccess/source/core/api/CacheSet.hxx | 9 +- dbaccess/source/core/api/KeySet.cxx | 64 +- dbaccess/source/core/api/KeySet.hxx | 13 +- dbaccess/source/core/api/OptimisticSet.cxx | 1689 +++++++++++++++++++++++++ dbaccess/source/core/api/OptimisticSet.hxx | 196 +++ dbaccess/source/core/api/RowSet.cxx | 197 ++- dbaccess/source/core/api/RowSet.hxx | 57 +- dbaccess/source/core/api/RowSetBase.cxx | 55 +- dbaccess/source/core/api/RowSetBase.hxx | 27 + dbaccess/source/core/api/RowSetCache.cxx | 323 +++-- dbaccess/source/core/api/RowSetCache.hxx | 33 +- dbaccess/source/core/api/WrappedResultSet.cxx | 256 ++++ dbaccess/source/core/api/WrappedResultSet.hxx | 79 ++ dbaccess/source/core/api/makefile.mk | 2 + 15 files changed, 2767 insertions(+), 326 deletions(-) create mode 100644 dbaccess/source/core/api/OptimisticSet.cxx create mode 100644 dbaccess/source/core/api/OptimisticSet.hxx create mode 100644 dbaccess/source/core/api/WrappedResultSet.cxx create mode 100644 dbaccess/source/core/api/WrappedResultSet.hxx (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index cdff43ca52af..04ee584bb38b 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -274,32 +274,8 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillParameters" ); // use keys and indexes for excat postioning // first the keys - Reference xKeySup(_xTable,UNO_QUERY); - Reference xKeys; - if(xKeySup.is()) - xKeys = xKeySup->getKeys(); - - Reference xKeyColsSup; - Reference xKeyColumns; - if(xKeys.is() && xKeys->getCount()) - { - Reference xProp; - Reference xColumnsSupplier; - // search the one and only primary key - for(sal_Int32 i=0;i< xKeys->getCount();++i) - { - ::cppu::extractInterface(xProp,xKeys->getByIndex(i)); - sal_Int32 nKeyType = 0; - xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; - if(KeyType::PRIMARY == nKeyType) - { - xKeyColsSup.set(xProp,UNO_QUERY); - break; - } - } - if(xKeyColsSup.is()) - xKeyColumns = xKeyColsSup->getColumns(); - } + Reference xSet(_xTable,UNO_QUERY); + const Reference xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet); // second the indexes Reference xIndexSup(_xTable,UNO_QUERY); Reference xIndexes; @@ -314,7 +290,7 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow { for(sal_Int32 j=0;jgetCount();++j) { - ::cppu::extractInterface(xIndexColsSup,xIndexes->getByIndex(j)); + xIndexColsSup.set(xIndexes->getByIndex(j),UNO_QUERY); if( xIndexColsSup.is() && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE)) && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX)) @@ -340,7 +316,7 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow for(; aIter != aEnd;++aIter,++nCheckCount,++i) { aColumnName = m_xSetMetaData->getColumnName(i); - if(xKeyColumns.is() && xKeyColumns->hasByName(aColumnName)) + if(xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(aColumnName)) { _sCondition.append(::dbtools::quoteName( aQuote,aColumnName)); if(aIter->isNull()) @@ -350,7 +326,7 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow _sCondition.append(aAnd); _rOrgValues.push_back(nCheckCount); - } // if(xKeyColumns.is() && xKeyColumns->hasByName(aColumnName)) + } // if(xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(aColumnName)) ::std::vector< Reference >::const_iterator aIndexEnd = aAllIndexColumns.end(); for( ::std::vector< Reference >::const_iterator aIndexIter = aAllIndexColumns.begin(); aIndexIter != aIndexEnd;++aIndexIter) @@ -439,32 +415,7 @@ void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connecti // use keys and indexes for excat postioning // first the keys - Reference xKeySup(_xTable,UNO_QUERY); - Reference xKeys; - if(xKeySup.is()) - xKeys = xKeySup->getKeys(); - - Reference xKeyColsSup; - Reference xKeyColumns; - if(xKeys.is() && xKeys->getCount()) - { - Reference xProp; - Reference xColumnsSupplier; - // search the one and only primary key - for(sal_Int32 i=0;i< xKeys->getCount();++i) - { - ::cppu::extractInterface(xProp,xKeys->getByIndex(i)); - sal_Int32 nKeyType = 0; - xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; - if(KeyType::PRIMARY == nKeyType) - { - xKeyColsSup.set(xProp,UNO_QUERY); - break; - } - } - if(xKeyColsSup.is()) - xKeyColumns = xKeyColsSup->getColumns(); - } + const Reference xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet); // second the indexes Reference xIndexSup(_xTable,UNO_QUERY); Reference xIndexes; @@ -511,7 +462,7 @@ void OCacheSet::setParameter(sal_Int32 nPos ,const Reference< XParameters >& _xParameter ,const ORowSetValue& _rValue ,sal_Int32 _nType - ,sal_Int32 _nScale) + ,sal_Int32 _nScale) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::setParameter" ); sal_Int32 nType = ( _nType != DataType::OTHER ) ? _nType : _rValue.getTypeKind(); @@ -773,3 +724,33 @@ Reference< XInterface > SAL_CALL OCacheSet::getStatement( ) throw(SQLException, return m_xDriverSet->getStatement(); } // ----------------------------------------------------------------------------- +bool OCacheSet::isResultSetChanged() const +{ + return false; +} +// ----------------------------------------------------------------------------- +void OCacheSet::reset(const Reference< XResultSet>& /*_xDriverSet*/) +{ + OSL_ENSURE(0,"Illegal call!"); +} +// ----------------------------------------------------------------------------- +void OCacheSet::mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& /*io_aInsertRow*/,ORowSetValueVector::Vector& /*io_aRow*/,::std::vector& o_aChangedColumns) +{ + o_aChangedColumns.push_back(i_nColumnIndex); +} +// ----------------------------------------------------------------------------- +bool OCacheSet::columnValuesUpdated(ORowSetValueVector::Vector& /*io_aCachedRow*/,const ORowSetValueVector::Vector& /*io_aRow*/) +{ + return false; +} +// ----------------------------------------------------------------------------- +bool OCacheSet::updateColumnValues(const ORowSetValueVector::Vector& /*io_aCachedRow*/,ORowSetValueVector::Vector& /*io_aRow*/,const ::std::vector& /*i_aChangedColumns*/) +{ + return true; +} +// ----------------------------------------------------------------------------- +void OCacheSet::fillMissingValues(ORowSetValueVector::Vector& /*io_aRow*/) const +{ +} +// ----------------------------------------------------------------------------- + diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx index e0fcf981f2ba..d206cb5815bd 100644 --- a/dbaccess/source/core/api/CacheSet.hxx +++ b/dbaccess/source/core/api/CacheSet.hxx @@ -98,7 +98,7 @@ namespace dbaccess ,const connectivity::ORowSetValue& _rValue ,sal_Int32 _nType ,sal_Int32 _nScale - ); + ) const; void fillParameters( const ORowSetRow& _rRow ,const connectivity::OSQLTable& _xTable ,::rtl::OUStringBuffer& _sCondition @@ -169,6 +169,13 @@ namespace dbaccess virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0; virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0; virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0; + + virtual bool isResultSetChanged() const; + virtual void reset(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + virtual void mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& io_aInsertRow,ORowSetValueVector::Vector& io_aRow,::std::vector& o_aChangedColumns); + virtual bool columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow); + virtual bool updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector& i_aChangedColumns); + virtual void fillMissingValues(ORowSetValueVector::Vector& io_aRow) const; }; } #endif //DBACCESS_CORE_API_CACHESET_HXX diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index c26f385a07db..bb82e06d4da3 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -225,7 +225,6 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i]; } - ::rtl::OUString sCatalog,sSchema,sTable; Reference xTableProp(m_xTable,UNO_QUERY); @@ -1004,9 +1003,9 @@ Reference OKeySet::getKeyColumns() const Reference xKeys = m_xTableKeys; if ( !xKeys.is() ) { - Reference xKeySup(m_xTable,UNO_QUERY); - if(xKeySup.is()) - xKeys = xKeySup->getKeys(); + Reference xSet(m_xTable,UNO_QUERY); + const Reference xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet); + return xPrimaryKeyColumns; } Reference xKeyColsSup; @@ -1494,49 +1493,62 @@ namespace dbaccess void getColumnPositions(const Reference& _rxQueryColumns, const Sequence< ::rtl::OUString>& _aColumnNames, const ::rtl::OUString& _rsUpdateTableName, - SelectColumnsMetaData& _rColumnNames) + SelectColumnsMetaData& o_rColumnNames, + bool i_bAppendTableName) { // get the real name of the columns Sequence< ::rtl::OUString> aSelNames(_rxQueryColumns->getElementNames()); - const ::rtl::OUString* pSelBegin = aSelNames.getConstArray(); - const ::rtl::OUString* pSelEnd = pSelBegin + aSelNames.getLength(); + const ::rtl::OUString* pSelIter = aSelNames.getConstArray(); + const ::rtl::OUString* pSelEnd = pSelIter + aSelNames.getLength(); - const ::rtl::OUString* pColumnIter = _aColumnNames.getConstArray(); - const ::rtl::OUString* pColumnEnd = pColumnIter + _aColumnNames.getLength(); + const ::rtl::OUString* pTblColumnIter = _aColumnNames.getConstArray(); + const ::rtl::OUString* pTblColumnEnd = pTblColumnIter + _aColumnNames.getLength(); - ::comphelper::UStringMixLess aTmp(_rColumnNames.key_comp()); + ::comphelper::UStringMixLess aTmp(o_rColumnNames.key_comp()); ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive()); - for(sal_Int32 nPos = 1;pSelBegin != pSelEnd;++pSelBegin,++nPos) + for(sal_Int32 nPos = 1;pSelIter != pSelEnd;++pSelIter,++nPos) { - Reference xColumnProp(_rxQueryColumns->getByName(*pSelBegin),UNO_QUERY); + Reference xQueryColumnProp(_rxQueryColumns->getByName(*pSelIter),UNO_QUERY_THROW); ::rtl::OUString sRealName,sTableName; - OSL_ENSURE(xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!"); - OSL_ENSURE(xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!"); - xColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; - xColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; + OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!"); + OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!"); + xQueryColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; + xQueryColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; - for(;pColumnIter != pColumnEnd;++pColumnIter) + for(;pTblColumnIter != pTblColumnEnd;++pTblColumnIter) { - if(bCase(sRealName,*pColumnIter) && bCase(_rsUpdateTableName,sTableName) && _rColumnNames.find(*pColumnIter) == _rColumnNames.end()) + if(bCase(sRealName,*pTblColumnIter) && bCase(_rsUpdateTableName,sTableName) && o_rColumnNames.find(*pTblColumnIter) == o_rColumnNames.end()) { sal_Int32 nType = 0; - xColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType; + xQueryColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType; sal_Int32 nScale = 0; - xColumnProp->getPropertyValue(PROPERTY_SCALE) >>= nScale; + xQueryColumnProp->getPropertyValue(PROPERTY_SCALE) >>= nScale; ::rtl::OUString sColumnDefault; - if ( xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE) ) - xColumnProp->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sColumnDefault; + if ( xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE) ) + xQueryColumnProp->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sColumnDefault; - sal_Int32 bNullable = sal_False; - xColumnProp->getPropertyValue(PROPERTY_ISNULLABLE) >>= bNullable; + sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN; + OSL_VERIFY( xQueryColumnProp->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable ); + if ( i_bAppendTableName ) + { + ::rtl::OUStringBuffer sName; + sName.append(sTableName); + sName.appendAscii("."); + sName.append(sRealName); + SelectColumnDescription aColDesc( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); + aColDesc.sRealName = sRealName; + aColDesc.sTableName = sTableName; + o_rColumnNames[sName.makeStringAndClear()] = aColDesc; + } + else + o_rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); - _rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,bNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); break; } } - pColumnIter = _aColumnNames.getConstArray(); + pTblColumnIter = _aColumnNames.getConstArray(); } } } diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 7db5c176e9ff..d0e81c1f1548 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -54,28 +54,30 @@ namespace dbaccess { struct SelectColumnDescription { + ::rtl::OUString sRealName; // may be empty + ::rtl::OUString sTableName; // may be empty + ::rtl::OUString sDefaultValue; sal_Int32 nPosition; sal_Int32 nType; sal_Int32 nScale; sal_Bool bNullable; - ::rtl::OUString sDefaultValue; + SelectColumnDescription() :nPosition( 0 ) ,nType( 0 ) ,nScale( 0 ) ,bNullable(sal_False) - ,sDefaultValue() { } SelectColumnDescription( sal_Int32 _nPosition, sal_Int32 _nType, sal_Int32 _nScale,sal_Bool _bNullable, const ::rtl::OUString& _rDefaultValue ) - :nPosition( _nPosition ) + :sDefaultValue( _rDefaultValue ) + ,nPosition( _nPosition ) ,nType( _nType ) ,nScale( _nScale ) ,bNullable(_bNullable) - ,sDefaultValue( _rDefaultValue ) { } }; @@ -85,7 +87,8 @@ namespace dbaccess void getColumnPositions(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxQueryColumns, const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aColumnNames, const ::rtl::OUString& _rsUpdateTableName, - SelectColumnsMetaData& _rColumnNames /* out */); + SelectColumnsMetaData& o_rColumnNames /* out */, + bool i_bAppendTableName = false); typedef ::std::pair OKeySetValue; typedef ::std::map OKeySetMatrix; diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx new file mode 100644 index 000000000000..71de01e4d3b6 --- /dev/null +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -0,0 +1,1689 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OptimisticSet.cxx,v $ + * $Revision: 1.73 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "OptimisticSet.hxx" +#include "core_resource.hxx" +#include "core_resource.hrc" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dbastrings.hrc" +#include "apitools.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "querycomposer.hxx" +#include "composertools.hxx" +#include +#include +#include + +using namespace dbaccess; +using namespace ::connectivity; +using namespace ::dbtools; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star; +using namespace ::cppu; +using namespace ::osl; + +DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUStringBuffer,TSQLStatements); +namespace +{ + void lcl_fillIndexColumns(const Reference& _xIndexes, ::std::vector< Reference >& _rAllIndexColumns) + { + if ( _xIndexes.is() ) + { + Reference xIndexColsSup; + sal_Int32 nCount = _xIndexes->getCount(); + for(sal_Int32 j = 0 ; j < nCount ; ++j) + { + xIndexColsSup.set(_xIndexes->getByIndex(j),UNO_QUERY); + if( xIndexColsSup.is() + && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE)) + && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX)) + ) + _rAllIndexColumns.push_back(Reference(xIndexColsSup,UNO_QUERY)->getColumns()); + } + } + } + void lcl_fillKeyCondition(const ::rtl::OUString& i_sTableName,const ::rtl::OUString& i_sQuotedColumnName,const ORowSetValue& i_aValue,TSQLStatements& io_aKeyConditions) + { + ::rtl::OUStringBuffer& rKeyCondition = io_aKeyConditions[i_sTableName]; + if ( rKeyCondition.getLength() ) + rKeyCondition.appendAscii(" AND "); + rKeyCondition.append(i_sQuotedColumnName); + if ( i_aValue.isNull() ) + rKeyCondition.appendAscii(" IS NULL"); + else + rKeyCondition.appendAscii(" = ?"); + } +} + +DBG_NAME(OptimisticSet) +// ------------------------------------------------------------------------- +OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext, + const Reference< XConnection>& i_xConnection, + const Reference< XSingleSelectQueryAnalyzer >& _xComposer, + const ORowSetValueVector& _aParameterValueForCache) + :m_aSqlParser( _rContext.getLegacyServiceFactory() ) + ,m_aSqlIterator( i_xConnection, Reference(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser, NULL ) + ,m_aParameterValueForCache(_aParameterValueForCache) + ,m_pKeyColumnNames(NULL) + ,m_pColumnNames(NULL) + ,m_pParameterNames(NULL) + ,m_xComposer(_xComposer) + ,m_bRowCountFinal(sal_False) + ,m_bResultSetChanged(false) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::OptimisticSet" ); + DBG_CTOR(OptimisticSet,NULL); +} +// ----------------------------------------------------------------------------- +OptimisticSet::~OptimisticSet() +{ + try + { + ::comphelper::disposeComponent(m_xStatement); + } + catch(Exception&) + { + m_xStatement.clear(); + } + catch(...) + { + OSL_ENSURE(0,"Unknown Exception occured"); + } + m_xComposer.clear(); + + DBG_DTOR(OptimisticSet,NULL); +} +// ----------------------------------------------------------------------------- +void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::construct" ); + OCacheSet::construct(_xDriverSet,i_sRowSetFilter); + + Reference xMeta = m_xConnection->getMetaData(); + bool bCase = (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers()) ? true : false; + + m_pKeyColumnNames.reset( new SelectColumnsMetaData(bCase) ); + m_pColumnNames.reset( new SelectColumnsMetaData(bCase) ); + m_pParameterNames.reset( new SelectColumnsMetaData(bCase) ); + + Reference xQueryColSup(m_xComposer,UNO_QUERY); + const Reference xQueryColumns = xQueryColSup->getColumns(); + const Reference xTabSup(m_xComposer,UNO_QUERY); + const Reference xTables = xTabSup->getTables(); + const Sequence< ::rtl::OUString> aTableNames = xTables->getElementNames(); + const ::rtl::OUString* pTableNameIter = aTableNames.getConstArray(); + const ::rtl::OUString* pTableNameEnd = pTableNameIter + aTableNames.getLength(); + for( ; pTableNameIter != pTableNameEnd ; ++pTableNameIter) + { + findTableColumnsMatching_throw(xTables->getByName(*pTableNameIter),xMeta,xQueryColumns); + } + + // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first + // without extra variable to be set + m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,0))); + m_aKeyIter = m_aKeyMap.begin(); + + static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + const ::rtl::OUString aQuote = getIdentifierQuoteString(); + ::rtl::OUStringBuffer aFilter; + static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM(".")); + static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); + // create the where clause + SelectColumnsMetaData::iterator aPosEnd = m_pKeyColumnNames->end(); + for(SelectColumnsMetaData::iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd;) + { + aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sTableName)); + aFilter.append(s_sDot); + aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName)); + aFilter.append(s_sParam); + ++aPosIter; + if(aPosIter != aPosEnd) + aFilter.append(aAnd); + } + + Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW); + Reference xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); + Reference xComp2(m_xComposer,UNO_QUERY_THROW); + ::rtl::OUString sQuery = xComp2->getQuery(); + xAnalyzer->setQuery(sQuery); + // check for joins + ::rtl::OUString aErrorMsg; + ::std::auto_ptr pStatementNode( m_aSqlParser.parseTree( aErrorMsg, sQuery ) ); + m_aSqlIterator.setParseTree( pStatementNode.get() ); + m_aSqlIterator.traverseAll(); + fillJoinedColumns_throw(m_aSqlIterator.getJoinConditions()); + + const ::rtl::OUString sComposerFilter = m_xComposer->getFilter(); + if ( i_sRowSetFilter.getLength() || (sComposerFilter.getLength() && sComposerFilter != i_sRowSetFilter) ) + { + FilterCreator aFilterCreator; + if ( sComposerFilter.getLength() && sComposerFilter != i_sRowSetFilter ) + aFilterCreator.append( sComposerFilter ); + aFilterCreator.append( i_sRowSetFilter ); + aFilterCreator.append( aFilter.makeStringAndClear() ); + aFilter = aFilterCreator.getComposedAndClear(); + } + xAnalyzer->setFilter(aFilter.makeStringAndClear()); + m_xStatement = m_xConnection->prepareStatement(xAnalyzer->getQueryWithSubstitution()); + ::comphelper::disposeComponent(xAnalyzer); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OptimisticSet::getBookmark() throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBookmark" ); + OSL_ENSURE(m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(), + "getBookmark is only possible when we stand on a valid row!"); + return makeAny(m_aKeyIter->first); +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveToBookmark" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark)); + return m_aKeyIter != m_aKeyMap.end(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveRelativeToBookmark" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark)); + if(m_aKeyIter != m_aKeyMap.end()) + { + relative(rows); + } + + return !isBeforeFirst() && !isAfterLast(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OptimisticSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::compareBookmarks" ); + sal_Int32 nFirst = 0, nSecond = 0; + _first >>= nFirst; + _second >>= nSecond; + + return (nFirst != nSecond) ? CompareBookmark::NOT_EQUAL : CompareBookmark::EQUAL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::hasOrderedBookmarks" ); + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OptimisticSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::hashBookmark" ); + return ::comphelper::getINT32(bookmark); +} +// ------------------------------------------------------------------------- +// ::com::sun::star::sdbcx::XDeleteRows +Sequence< sal_Int32 > SAL_CALL OptimisticSet::deleteRows( const Sequence< Any >& /*rows*/ ,const connectivity::OSQLTable& /*_xTable*/) throw(SQLException, RuntimeException) +{ + Sequence< sal_Int32 > aRet; + return aRet; +} +// ------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::updateRow" ); + if ( m_aJoinedKeyColumns.empty() ) + throw SQLException(); + // list all cloumns that should be set + static ::rtl::OUString s_sPara = ::rtl::OUString::createFromAscii(" = ?"); + ::rtl::OUString aQuote = getIdentifierQuoteString(); + static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); + + ::rtl::OUString aColumnName; + ::rtl::OUStringBuffer sKeyCondition; + ::std::map< ::rtl::OUString,bool > aResultSetChanged; + TSQLStatements aKeyConditions; + TSQLStatements aIndexConditions; + TSQLStatements aSql; + + // sal_Int32 i = 1; + // here we build the condition part for the update statement + SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(;aIter != aEnd;++aIter) + { + if ( aResultSetChanged.find( aIter->second.sTableName ) == aResultSetChanged.end() ) + aResultSetChanged[aIter->second.sTableName] = false; + const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aIter->second.sRealName); + if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() ) + { + aResultSetChanged[aIter->second.sTableName] = m_aJoinedKeyColumns.find(aIter->second.nPosition) != m_aJoinedKeyColumns.end(); + lcl_fillKeyCondition(aIter->second.sTableName,sQuotedColumnName,(_rOrginalRow->get())[aIter->second.nPosition],aKeyConditions); + } + if((_rInsertRow->get())[aIter->second.nPosition].isModified()) + { + if ( m_aJoinedKeyColumns.find(aIter->second.nPosition) != m_aJoinedKeyColumns.end() ) + throw SQLException(); + + ::std::map::const_iterator aJoinIter = m_aJoinedColumns.find(aIter->second.nPosition); + if ( aJoinIter != m_aJoinedColumns.end() ) + { + (_rInsertRow->get())[aJoinIter->second] = (_rInsertRow->get())[aIter->second.nPosition]; + } + ::rtl::OUStringBuffer& rPart = aSql[aIter->second.sTableName]; + if ( rPart.getLength() ) + rPart.appendAscii(", "); + rPart.append(sQuotedColumnName); + rPart.append(s_sPara); + } + } + + if( aSql.empty() ) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection ); + + if( aKeyConditions.empty() ) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection ); + + static const ::rtl::OUString s_sUPDATE(RTL_CONSTASCII_USTRINGPARAM("UPDATE ")); + static const ::rtl::OUString s_sSET(RTL_CONSTASCII_USTRINGPARAM(" SET ")); + + Reference xMetaData = m_xConnection->getMetaData(); + + TSQLStatements::iterator aSqlIter = aSql.begin(); + TSQLStatements::iterator aSqlEnd = aSql.end(); + for(;aSqlIter != aSqlEnd ; ++aSqlIter) + { + if ( aSqlIter->second.getLength() ) + { + m_bResultSetChanged = m_bResultSetChanged || aResultSetChanged[aSqlIter->first]; + ::rtl::OUStringBuffer sSql(s_sUPDATE); + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); + sSql.append( ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ) ); + sSql.append(s_sSET); + sSql.append(aSqlIter->second); + ::rtl::OUStringBuffer& rCondition = aKeyConditions[aSqlIter->first]; + bool bAddWhere = true; + if ( rCondition.getLength() ) + { + bAddWhere = false; + sSql.appendAscii(" WHERE "); + sSql.append( rCondition ); + } + executeUpdate(_rInsertRow ,_rOrginalRow,sSql.makeStringAndClear(),aSqlIter->first); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::insertRow" ); + TSQLStatements aSql; + TSQLStatements aParameter; + TSQLStatements aKeyConditions; + ::std::map< ::rtl::OUString,bool > aResultSetChanged; + ::rtl::OUString aQuote = getIdentifierQuoteString(); + static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); + + // here we build the condition part for the update statement + SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(;aIter != aEnd;++aIter) + { + if ( aResultSetChanged.find( aIter->second.sTableName ) == aResultSetChanged.end() ) + aResultSetChanged[aIter->second.sTableName] = false; + + const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aIter->second.sRealName); + if ( (_rInsertRow->get())[aIter->second.nPosition].isModified() ) + { + if ( m_aJoinedKeyColumns.find(aIter->second.nPosition) != m_aJoinedKeyColumns.end() ) + { + lcl_fillKeyCondition(aIter->second.sTableName,sQuotedColumnName,(_rInsertRow->get())[aIter->second.nPosition],aKeyConditions); + aResultSetChanged[aIter->second.sTableName] = true; + } + ::std::map::const_iterator aJoinIter = m_aJoinedColumns.find(aIter->second.nPosition); + if ( aJoinIter != m_aJoinedColumns.end() ) + { + (_rInsertRow->get())[aJoinIter->second] = (_rInsertRow->get())[aIter->second.nPosition]; + } + ::rtl::OUStringBuffer& rPart = aSql[aIter->second.sTableName]; + if ( rPart.getLength() ) + rPart.appendAscii(", "); + rPart.append(sQuotedColumnName); + ::rtl::OUStringBuffer& rParam = aParameter[aIter->second.sTableName]; + if ( rParam.getLength() ) + rParam.appendAscii(", "); + rParam.appendAscii("?"); + } + } + if ( aParameter.empty() ) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection ); + + Reference xMetaData = m_xConnection->getMetaData(); + static const ::rtl::OUString s_sINSERT(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO ")); + static const ::rtl::OUString s_sVALUES(RTL_CONSTASCII_USTRINGPARAM(") VALUES ( ")); + TSQLStatements::iterator aSqlIter = aSql.begin(); + TSQLStatements::iterator aSqlEnd = aSql.end(); + for(;aSqlIter != aSqlEnd ; ++aSqlIter) + { + if ( aSqlIter->second.getLength() ) + { + m_bResultSetChanged = m_bResultSetChanged || aResultSetChanged[aSqlIter->first]; + ::rtl::OUStringBuffer sSql(s_sINSERT); + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); + ::rtl::OUString sComposedTableName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); + sSql.append(sComposedTableName); + sSql.appendAscii(" ( "); + sSql.append(aSqlIter->second); + sSql.append(s_sVALUES); + sSql.append(aParameter[aSqlIter->first]); + sSql.appendAscii(" )"); + + ::rtl::OUStringBuffer& rCondition = aKeyConditions[aSqlIter->first]; + if ( rCondition.getLength() ) + { + ::rtl::OUStringBuffer sQuery; + sQuery.appendAscii("SELECT "); + sQuery.append(aSqlIter->second); + sQuery.appendAscii(" FROM "); + sQuery.append(sComposedTableName); + sQuery.appendAscii(" WHERE "); + sQuery.append(rCondition); + + try + { + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(sQuery.makeStringAndClear())); + Reference< XParameters > xParameter(xPrep,UNO_QUERY); + // and then the values of the where condition + SelectColumnsMetaData::iterator aIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::iterator aEnd = m_pKeyColumnNames->end(); + sal_Int32 i = 1; + for(;aIter != aEnd;++aIter) + { + if ( aIter->second.sTableName == aSqlIter->first ) + { + setParameter(i++,xParameter,(_rInsertRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale); + } + } + Reference xRes = xPrep->executeQuery(); + Reference xRow(xRes,UNO_QUERY); + if ( xRow.is() && xRes->next() ) + { + m_bResultSetChanged = true; + continue; + } + } + catch(const SQLException&) + { + } + } + + executeInsert(_rInsertRow,sSql.makeStringAndClear(),aSqlIter->first); + } + } +} +// ------------------------------------------------------------------------- +void OptimisticSet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName ) +{ + // now create,fill and execute the prepared statement + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL)); + Reference< XParameters > xParameter(xPrep,UNO_QUERY); + + SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(sal_Int32 i = 1;aIter != aEnd;++aIter) + { + if ( aIter->second.sTableName == i_sTableName ) + { + const sal_Int32 nPos = aIter->second.nPosition; + if((_rInsertRow->get())[nPos].isModified()) + { + if((_rInsertRow->get())[nPos].isNull()) + xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind()); + else + { + impl_convertValue_throw(_rInsertRow,aIter->second); + (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]); + setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale); + } + } + } + } + + m_bInserted = xPrep->executeUpdate() > 0; + sal_Bool bAutoValuesFetched = sal_False; + if ( m_bInserted ) + { + // first insert the default values into the insertrow + aIter = m_pColumnNames->begin(); + for(;aIter != aEnd;++aIter) + { + if ( !(_rInsertRow->get())[aIter->second.nPosition].isModified() ) + (_rInsertRow->get())[aIter->second.nPosition] = aIter->second.sDefaultValue; + } + try + { + Reference< XGeneratedResultSet > xGRes(xPrep, UNO_QUERY); + if ( xGRes.is() ) + { + Reference< XResultSet > xRes = xGRes->getGeneratedValues(); + Reference< XRow > xRow(xRes,UNO_QUERY); + if ( xRow.is() && xRes->next() ) + { + Reference< XResultSetMetaDataSupplier > xMdSup(xRes,UNO_QUERY); + Reference< XResultSetMetaData > xMd = xMdSup->getMetaData(); + sal_Int32 nColumnCount = xMd->getColumnCount(); + ::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin(); + ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end(); + for (sal_Int32 i = 1;aAutoIter != aAutoEnd && i <= nColumnCount; ++aAutoIter,++i) + { +#if OSL_DEBUG_LEVEL > 1 + ::rtl::OUString sColumnName( xMd->getColumnName(i) ); +#endif + SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter); + if ( aFind != m_pKeyColumnNames->end() ) + (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow); + } + bAutoValuesFetched = sal_True; + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Could not execute GeneratedKeys() stmt"); + } + } + + ::comphelper::disposeComponent(xPrep); +/* + if ( !bAutoValuesFetched && m_bInserted ) + { + // first check if all key column values were set + const ::rtl::OUString sMax(RTL_CONSTASCII_USTRINGPARAM(" MAX(")); + const ::rtl::OUString sMaxEnd(RTL_CONSTASCII_USTRINGPARAM("),")); + const ::rtl::OUString sQuote = getIdentifierQuoteString(); + ::rtl::OUString sMaxStmt; + aEnd = m_pKeyColumnNames->end(); + ::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin(); + ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end(); + for (;aAutoIter != aAutoEnd; ++aAutoIter) + { + // we will only fetch values which are keycolumns + if ( m_pKeyColumnNames->find(*aAutoIter) != aEnd ) + { + sMaxStmt += sMax; + sMaxStmt += ::dbtools::quoteName( sQuote,*aAutoIter); + sMaxStmt += sMaxEnd; + } + } + + if(sMaxStmt.getLength()) + { + sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1,::rtl::OUString::createFromAscii(" ")); + ::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT "); + sStmt += sMaxStmt; + sStmt += ::rtl::OUString::createFromAscii("FROM "); + sStmt += m_aSelectComposedTableName; + try + { + // now fetch the autoincrement values + Reference xStatement = m_xConnection->createStatement(); + Reference xRes = xStatement->executeQuery(sStmt); + Reference xRow(xRes,UNO_QUERY); + if(xRow.is() && xRes->next()) + { + aAutoIter = m_aAutoColumns.begin(); + for (sal_Int32 i=1;aAutoIter != aAutoEnd; ++aAutoIter,++i) + { + // we will only fetch values which are keycolumns + SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter); + if ( aFind != aEnd ) + (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow); + } + } + ::comphelper::disposeComponent(xStatement); + } + catch(SQLException&) + { + OSL_ENSURE(0,"Could not fetch with MAX() "); + } + } + } + */ + if ( m_bInserted ) + { + OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end(); + --aKeyIter; + ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size()); + copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1); + + m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,1))).first; + // now we set the bookmark for this row + (_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first); + } +} +// ----------------------------------------------------------------------------- +void OptimisticSet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::copyRowValue" ); + connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin(); + + // check the if the parameter values have been changed + OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OptimisticSet::copyRowValue: Parameter values and names differ!"); + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1; + + bool bChanged = false; + SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin(); + SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end(); + for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i) + { + ORowSetValue aValue(*aParaValuesIter); + aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]); + if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue ) + { + ORowSetValueVector aCopy(m_aParameterValueForCache); + (aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition]; + m_aUpdatedParameter[i_nBookmark] = aCopy; + bChanged = true; + } + } + if ( !bChanged ) + { + m_aUpdatedParameter.erase(i_nBookmark); + } + + // update the key values + SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); + for(;aPosIter != aPosEnd;++aPosIter,++aIter) + { + ORowSetValue aValue((_rInsertRow->get())[aPosIter->second.nPosition]); + switch(aPosIter->second.nType) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + { + ::rtl::OUString sValue = aValue.getString(); + sal_Int32 nIndex = sValue.indexOf('.'); + if ( nIndex != -1 ) + { + aValue = sValue.copy(0,nIndex + (aPosIter->second.nScale > 0 ? aPosIter->second.nScale + 1 : 0)); + } + } + break; + default: + break; + } + *aIter = aValue; + aIter->setTypeKind(aPosIter->second.nType); + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + static const ::rtl::OUString s_sAnd(RTL_CONSTASCII_USTRINGPARAM(" AND ")); + ::rtl::OUString aQuote = getIdentifierQuoteString(); + ::rtl::OUString aColumnName; + ::rtl::OUStringBuffer sKeyCondition,sIndexCondition; + ::std::vector aIndexColumnPositions; + TSQLStatements aKeyConditions; + TSQLStatements aIndexConditions; + TSQLStatements aSql; + + // sal_Int32 i = 1; + // here we build the condition part for the update statement + SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(;aIter != aEnd;++aIter) + { + if ( m_aJoinedKeyColumns.find(aIter->second.nPosition) == m_aJoinedKeyColumns.end() && m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() ) + { + // only delete rows which aren't the key in the join + const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aIter->second.sRealName); + lcl_fillKeyCondition(aIter->second.sTableName,sQuotedColumnName,(_rDeleteRow->get())[aIter->second.nPosition],aKeyConditions); + } + } + Reference xMetaData = m_xConnection->getMetaData(); + TSQLStatements::iterator aSqlIter = aKeyConditions.begin(); + TSQLStatements::iterator aSqlEnd = aKeyConditions.end(); + for(;aSqlIter != aSqlEnd ; ++aSqlIter) + { + ::rtl::OUStringBuffer& rCondition = aSqlIter->second; + if ( rCondition.getLength() ) + { + ::rtl::OUStringBuffer sSql; + sSql.appendAscii("DELETE FROM "); + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); + sSql.append( ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ) ); + sSql.appendAscii(" WHERE "); + sSql.append( rCondition ); + executeDelete(_rDeleteRow,sSql.makeStringAndClear(),aSqlIter->first); + } + } +} +// ------------------------------------------------------------------------- +void OptimisticSet::executeDelete(const ORowSetRow& _rDeleteRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::executeDelete" ); + + // now create end execute the prepared statement + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL)); + Reference< XParameters > xParameter(xPrep,UNO_QUERY); + + SelectColumnsMetaData::const_iterator aIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pKeyColumnNames->end(); + sal_Int32 i = 1; + for(;aIter != aEnd;++aIter) + { + if ( aIter->second.sTableName == i_sTableName ) + setParameter(i++,xParameter,(_rDeleteRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale); + } + m_bDeleted = xPrep->executeUpdate() > 0; + + if(m_bDeleted) + { + sal_Int32 nBookmark = ::comphelper::getINT32((_rDeleteRow->get())[0].getAny()); + if(m_aKeyIter == m_aKeyMap.find(nBookmark) && m_aKeyIter != m_aKeyMap.end()) + ++m_aKeyIter; + m_aKeyMap.erase(nBookmark); + m_bDeleted = sal_True; + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::cancelRowUpdates" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; +} +// ------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::moveToInsertRow( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveToInsertRow" ); +} +// ------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveToCurrentRow" ); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::next( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::next" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + + if(isAfterLast()) + return sal_False; + if(!m_bRowCountFinal) // not yet all records fetched + { + ++m_aKeyIter; // this is possible because we stand on begin() and this is the "beforefirst" row + if(m_aKeyIter == m_aKeyMap.end() && !fetchRow()) + m_aKeyIter = m_aKeyMap.end(); + } + else if(!isAfterLast()) + ++m_aKeyIter; + + refreshRow(); + return !isAfterLast(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isBeforeFirst" ); + return m_aKeyIter == m_aKeyMap.begin(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isAfterLast" ); + return m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::isFirst( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isFirst" ); + OKeySetMatrix::iterator aTemp = m_aKeyMap.begin(); + ++aTemp; + return m_aKeyIter == aTemp && m_aKeyIter != m_aKeyMap.end(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::isLast( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isLast" ); + if(!m_bRowCountFinal) + return sal_False; + + OKeySetMatrix::iterator aTemp = m_aKeyMap.end(); + --aTemp; + return m_aKeyIter == aTemp; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::beforeFirst" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + m_aKeyIter = m_aKeyMap.begin(); + m_xSet = NULL; + ::comphelper::disposeComponent(m_xRow); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::afterLast( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::afterLast" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + fillAllRows(); + m_aKeyIter = m_aKeyMap.end(); + m_xSet = NULL; + ::comphelper::disposeComponent(m_xRow); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::first( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::first" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + m_aKeyIter = m_aKeyMap.begin(); + ++m_aKeyIter; + if(m_aKeyIter == m_aKeyMap.end() && !fetchRow()) + m_aKeyIter = m_aKeyMap.end(); + + refreshRow(); + return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::last( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::last" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + fillAllRows(); + + m_aKeyIter = m_aKeyMap.end(); + --m_aKeyIter; + refreshRow(); + return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); +} +// ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL OptimisticSet::getRow( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getRow" ); + OSL_ENSURE(!isAfterLast(),"getRow is not allowed when afterlast record!"); + OSL_ENSURE(!isBeforeFirst(),"getRow is not allowed when beforefirst record!"); + + return ::std::distance(m_aKeyMap.begin(),m_aKeyIter); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::absolute" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + OSL_ENSURE(row,"absolute(0) isn't allowed!"); + if(row < 0) + { + if(!m_bRowCountFinal) + fillAllRows(); + + for(;row < 0 && m_aKeyIter != m_aKeyMap.begin();++row) + m_aKeyIter--; + } + else + { + if(row >= (sal_Int32)m_aKeyMap.size()) + { + if(!m_bRowCountFinal) + { + sal_Bool bNext = sal_True; + for(sal_Int32 i=m_aKeyMap.size()-1;i < row && bNext;++i) + bNext = fetchRow(); + } + else + m_aKeyIter = m_aKeyMap.end(); + } + else + { + m_aKeyIter = m_aKeyMap.begin(); + for(;row > 0 && m_aKeyIter != m_aKeyMap.end();--row) + ++m_aKeyIter; + } + } + refreshRow(); + + return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::relative" ); + if(!rows) + { + refreshRow(); + return sal_True; + } + return absolute(getRow()+rows); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::previous( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::previous" ); + m_bInserted = m_bUpdated = m_bDeleted = sal_False; + if(m_aKeyIter != m_aKeyMap.begin()) + { + --m_aKeyIter; + refreshRow(); + } + return m_aKeyIter != m_aKeyMap.begin(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OptimisticSet::refreshRow() throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::refreshRow" ); + if(isBeforeFirst() || isAfterLast() || !m_xStatement.is()) + return; + + m_xSet.clear(); + ::comphelper::disposeComponent(m_xRow); + // we just reassign the base members + Reference< XParameters > xParameter(m_xStatement,UNO_QUERY); + OSL_ENSURE(xParameter.is(),"No Parameter interface!"); + xParameter->clearParameters(); + + sal_Int32 nPos=1; + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter; + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd; + OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first); + if ( aUpdateFind == m_aUpdatedParameter.end() ) + { + aParaIter = m_aParameterValueForCache.get().begin(); + aParaEnd = m_aParameterValueForCache.get().end(); + } + else + { + aParaIter = aUpdateFind->second.get().begin(); + aParaEnd = aUpdateFind->second.get().end(); + } + + // first put the parameters set by the outer rowset + for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos) + { + ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() ); + } + + // now set the primary key column values + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin(); + SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); + for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos) + setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale); + + m_xSet = m_xStatement->executeQuery(); + OSL_ENSURE(m_xSet.is(),"No resultset form statement!"); + sal_Bool bOK = m_xSet->next(); + if ( !bOK ) + m_aKeyIter = m_aKeyMap.end(); + m_xRow.set(m_xSet,UNO_QUERY); + OSL_ENSURE(m_xRow.is(),"No row form statement!"); +} +// ----------------------------------------------------------------------------- +sal_Bool OptimisticSet::fetchRow() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::fetchRow" ); + // fetch the next row and append on the OptimisticSet + sal_Bool bRet = sal_False; + if ( !m_bRowCountFinal ) + bRet = m_xDriverSet->next(); + if ( bRet ) + { + ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size()); + connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = aKeyRow->get().begin(); + // first fetch the values needed for the key column + SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); + for(;aPosIter != aPosEnd;++aPosIter,++aIter) + { + const SelectColumnDescription& rColDesc = aPosIter->second; + aIter->fill(rColDesc.nPosition,rColDesc.nType,rColDesc.bNullable,m_xDriverRow); + } + m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(m_aKeyMap.rbegin()->first+1,OKeySetValue(aKeyRow,0))).first; + } + else + m_bRowCountFinal = sal_True; + return bRet; +} +// ------------------------------------------------------------------------- +void OptimisticSet::fillAllRows() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::fillAllRows" ); + if(!m_bRowCountFinal) + { + while(fetchRow()) + ; + } +} +// XRow +sal_Bool SAL_CALL OptimisticSet::wasNull( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::wasNull" ); + return m_xRow->wasNull(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OptimisticSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getString" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getString(columnIndex); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBoolean" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getBoolean(columnIndex); +} +// ------------------------------------------------------------------------- +sal_Int8 SAL_CALL OptimisticSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getByte" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getByte(columnIndex); +} +// ------------------------------------------------------------------------- +sal_Int16 SAL_CALL OptimisticSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getShort" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getShort(columnIndex); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OptimisticSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getInt" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getInt(columnIndex); +} +// ------------------------------------------------------------------------- +sal_Int64 SAL_CALL OptimisticSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getLong" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getLong(columnIndex); +} +// ------------------------------------------------------------------------- +float SAL_CALL OptimisticSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getFloat" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getFloat(columnIndex); +} +// ------------------------------------------------------------------------- +double SAL_CALL OptimisticSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getDouble" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getDouble(columnIndex); +} +// ------------------------------------------------------------------------- +Sequence< sal_Int8 > SAL_CALL OptimisticSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBytes" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getBytes(columnIndex); +} +// ------------------------------------------------------------------------- +::com::sun::star::util::Date SAL_CALL OptimisticSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getDate" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getDate(columnIndex); +} +// ------------------------------------------------------------------------- +::com::sun::star::util::Time SAL_CALL OptimisticSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getTime" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getTime(columnIndex); +} +// ------------------------------------------------------------------------- +::com::sun::star::util::DateTime SAL_CALL OptimisticSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getTimestamp" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getTimestamp(columnIndex); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OptimisticSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBinaryStream" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getBinaryStream(columnIndex); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OptimisticSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getCharacterStream" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getCharacterStream(columnIndex); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OptimisticSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getObject" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getObject(columnIndex,typeMap); +} +// ------------------------------------------------------------------------- +Reference< XRef > SAL_CALL OptimisticSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getRef" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getRef(columnIndex); +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL OptimisticSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBlob" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getBlob(columnIndex); +} +// ------------------------------------------------------------------------- +Reference< XClob > SAL_CALL OptimisticSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getClob" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getClob(columnIndex); +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL OptimisticSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getArray" ); + OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); + return m_xRow->getArray(columnIndex); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowUpdated" ); + return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second == 2; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::rowInserted( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowInserted" ); + return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second == 1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OptimisticSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowDeleted" ); + sal_Bool bDeleted = m_bDeleted; + m_bDeleted = sal_False; + return bDeleted; +} +// ----------------------------------------------------------------------------- +::rtl::OUString OptimisticSet::getComposedTableName(const ::rtl::OUString& /*_sCatalog*/, + const ::rtl::OUString& /*_sSchema*/, + const ::rtl::OUString& /*_sTable*/) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getComposedTableName" ); + ::rtl::OUString aComposedName; +/* + Reference xMetaData = m_xConnection->getMetaData(); + + if( xMetaData.is() && xMetaData->supportsTableCorrelationNames() ) + { + aComposedName = ::dbtools::composeTableName( xMetaData, _sCatalog, _sSchema, _sTable, sal_False, ::dbtools::eInDataManipulation ); + // first we have to check if the composed tablename is in the select clause or if an alias is used + Reference xTabSup(m_xComposer,UNO_QUERY); + Reference xSelectTables = xTabSup->getTables(); + OSL_ENSURE(xSelectTables.is(),"No Select tables!"); + if(xSelectTables.is()) + { + if(!xSelectTables->hasByName(aComposedName)) + { // the composed name isn't used in the select clause so we have to find out which name is used instead + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); + aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); + } + else + aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable ); + } + } + else + aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable ); +*/ + return aComposedName; +} +// ----------------------------------------------------------------------------- +/* +namespace dbaccess +{ + void getColumnPositions(const Reference& _rxQueryColumns, + const Sequence< ::rtl::OUString>& _aColumnNames, + const ::rtl::OUString& _rsUpdateTableName, + SelectColumnsMetaData& _rColumnNames) + { + // get the real name of the columns + Sequence< ::rtl::OUString> aSelNames(_rxQueryColumns->getElementNames()); + const ::rtl::OUString* pSelBegin = aSelNames.getConstArray(); + const ::rtl::OUString* pSelEnd = pSelBegin + aSelNames.getLength(); + + const ::rtl::OUString* pColumnIter = _aColumnNames.getConstArray(); + const ::rtl::OUString* pColumnEnd = pColumnIter + _aColumnNames.getLength(); + + ::comphelper::UStringMixLess aTmp(_rColumnNames.key_comp()); + ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive()); + + for(sal_Int32 nPos = 1;pSelBegin != pSelEnd;++pSelBegin,++nPos) + { + Reference xColumnProp(_rxQueryColumns->getByName(*pSelBegin),UNO_QUERY); + ::rtl::OUString sRealName,sTableName; + OSL_ENSURE(xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!"); + OSL_ENSURE(xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!"); + xColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; + xColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; + + for(;pColumnIter != pColumnEnd;++pColumnIter) + { + if(bCase(sRealName,*pColumnIter) && bCase(_rsUpdateTableName,sTableName) && _rColumnNames.find(*pColumnIter) == _rColumnNames.end()) + { + sal_Int32 nType = 0; + xColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType; + sal_Int32 nScale = 0; + xColumnProp->getPropertyValue(PROPERTY_SCALE) >>= nScale; + ::rtl::OUString sColumnDefault; + if ( xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE) ) + xColumnProp->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sColumnDefault; + + sal_Int32 bNullable = sal_False; + xColumnProp->getPropertyValue(PROPERTY_ISNULLABLE) >>= bNullable; + + + _rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,bNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); + break; + } + } + pColumnIter = _aColumnNames.getConstArray(); + } + } +} +*/ +// ----------------------------------------------------------------------------- +void OptimisticSet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData) +{ + ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]); + switch(i_aMetaData.nType) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + { + ::rtl::OUString sValue = aValue.getString(); + sal_Int32 nIndex = sValue.indexOf('.'); + if ( nIndex != -1 ) + { + aValue = sValue.copy(0,nIndex + (i_aMetaData.nScale > 0 ? i_aMetaData.nScale + 1 : 0)); + } + } + break; + default: + break; + } +} +// ----------------------------------------------------------------------------- +void OptimisticSet::findTableColumnsMatching_throw(const Any& i_aTable + ,const Reference& i_xMeta + ,const Reference& i_xQueryColumns) +{ + ::rtl::OUString sCatalog,sSchema,sTable; + Reference xTableProp(i_aTable,UNO_QUERY); + Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME); + aCatalog >>= sCatalog; + xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; + xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; + + // first ask the database itself for the best columns which can be used + ::std::vector< ::rtl::OUString> aBestRowColumnNames; + Reference xBestRes(i_xMeta->getBestRowIdentifier(aCatalog,sSchema,sTable,0,sal_False)); + Reference xBestRow(xBestRes,uno::UNO_QUERY); + while ( xBestRes->next() ) + { + aBestRowColumnNames.push_back(xBestRow->getString(2)); + } + + Sequence< ::rtl::OUString> aBestColumnNames; + if ( aBestRowColumnNames.empty() ) + { + Reference xKeyColumns = getPrimaryKeyColumns_throw(i_aTable); + if ( xKeyColumns.is() ) + aBestColumnNames = xKeyColumns->getElementNames(); + } + else + aBestColumnNames = Sequence< ::rtl::OUString>(&aBestRowColumnNames[0],aBestRowColumnNames.size()); + + const Reference xTblColSup(i_aTable,UNO_QUERY_THROW); + const Reference xTblColumns = xTblColSup->getColumns(); + const ::rtl::OUString sComposedUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); + ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sComposedUpdateTableName,(*m_pKeyColumnNames),true); + ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sComposedUpdateTableName,(*m_pColumnNames),true); + + // locate parameter in select columns + Reference xParaSup(m_xComposer,UNO_QUERY); + Reference xQueryParameters = xParaSup->getParameters(); + const sal_Int32 nParaCount = xQueryParameters->getCount(); + Sequence< ::rtl::OUString> aParameterColumns(nParaCount); + for(sal_Int32 i = 0; i< nParaCount;++i) + { + Reference xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW); + xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i]; + } + ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sComposedUpdateTableName,(*m_pParameterNames),true); + + SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); + for(;aPosIter != aPosEnd;++aPosIter) + { + if ( xTblColumns->hasByName(aPosIter->second.sRealName) ) + { + Reference xProp(xTblColumns->getByName(aPosIter->second.sRealName),UNO_QUERY); + sal_Bool bAuto = sal_False; + if( (xProp->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAuto) && bAuto) + m_aAutoColumns.push_back(aPosIter->first); + } + } +} +// ----------------------------------------------------------------------------- +void OptimisticSet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName) +{ + // now create end execute the prepared statement + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL)); + Reference< XParameters > xParameter(xPrep,UNO_QUERY); + + sal_Int32 i = 1; + // first the set values + SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + sal_uInt16 j = 0; + for(;aIter != aEnd;++aIter,++j) + { + if ( aIter->second.sTableName == i_sTableName ) + { + sal_Int32 nPos = aIter->second.nPosition; + if((_rInsertRow->get())[nPos].isModified()) + { + impl_convertValue_throw(_rInsertRow,aIter->second); + (_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned()); + setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale); + } + } + } + // and then the values of the where condition + aIter = m_pKeyColumnNames->begin(); + aEnd = m_pKeyColumnNames->end(); + j = 0; + for(;aIter != aEnd;++aIter,++j) + { + if ( aIter->second.sTableName == i_sTableName ) + { + setParameter(i++,xParameter,(_rOrginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale); + } + } +/* + // now we have to set the index values + ::std::vector::iterator aIdxColIter = aIndexColumnPositions.begin(); + ::std::vector::iterator aIdxColEnd = aIndexColumnPositions.end(); + j = 0; + aIter = m_pColumnNames->begin(); + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter) + { + setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); + } +*/ + const sal_Int32 nRowsUpdated = xPrep->executeUpdate(); + m_bUpdated = nRowsUpdated > 0; + if(m_bUpdated) + { + const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny()); + m_aKeyIter = m_aKeyMap.find(nBookmark); + m_aKeyIter->second.second = 2; + copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark); + } +} +// ----------------------------------------------------------------------------- +void OptimisticSet::fillJoinedColumns_throw(const ::std::vector< TNodePair >& i_aJoinColumns) +{ + ::std::vector< TNodePair >::const_iterator aIter = i_aJoinColumns.begin(); + for(;aIter != i_aJoinColumns.end();++aIter) + { + ::rtl::OUString sColumnName,sTableName; + m_aSqlIterator.getColumnRange(aIter->first,sColumnName,sTableName); + ::rtl::OUStringBuffer sLeft,sRight; + sLeft.append(sTableName); + sLeft.appendAscii("."); + sLeft.append(sColumnName); + m_aSqlIterator.getColumnRange(aIter->second,sColumnName,sTableName); + sRight.append(sTableName); + sRight.appendAscii("."); + sRight.append(sColumnName); + fillJoinedColumns_throw(sLeft.makeStringAndClear(),sRight.makeStringAndClear()); + } +} +// ----------------------------------------------------------------------------- +void OptimisticSet::fillJoinedColumns_throw(const ::rtl::OUString& i_sLeftColumn,const ::rtl::OUString& i_sRightColumn) +{ + sal_Int32 nLeft = 0,nRight = 0; + SelectColumnsMetaData::const_iterator aLeftIter = m_pKeyColumnNames->find(i_sLeftColumn); + SelectColumnsMetaData::const_iterator aRightIter = m_pKeyColumnNames->find(i_sRightColumn); + + bool bLeftKey = aLeftIter != m_pKeyColumnNames->end(); + if ( bLeftKey ) + { + nLeft = aLeftIter->second.nPosition; + } + else + { + aLeftIter = m_pColumnNames->find(i_sLeftColumn); + if ( aLeftIter != m_pColumnNames->end() ) + nLeft = aLeftIter->second.nPosition; + } + + bool bRightKey = aRightIter != m_pKeyColumnNames->end(); + if ( bRightKey ) + { + nRight = aRightIter->second.nPosition; + } + else + { + aRightIter = m_pColumnNames->find(i_sRightColumn); + if ( aRightIter != m_pColumnNames->end() ) + nRight = aRightIter->second.nPosition; + } + + if (bLeftKey) + m_aJoinedKeyColumns[nLeft] = nRight; + else + m_aJoinedColumns[nLeft] = nRight; + if (bRightKey) + m_aJoinedKeyColumns[nRight] = nLeft; + else + m_aJoinedColumns[nRight] = nLeft; +} +// ----------------------------------------------------------------------------- +bool OptimisticSet::isResultSetChanged() const +{ + bool bOld = m_bResultSetChanged; + m_bResultSetChanged = false; + return bOld; +} +// ----------------------------------------------------------------------------- +void OptimisticSet::reset(const Reference< XResultSet>& _xDriverSet) +{ + OCacheSet::construct(_xDriverSet,::rtl::OUString()); + m_bRowCountFinal = sal_False; + m_aKeyMap.clear(); + m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,0))); + m_aKeyIter = m_aKeyMap.begin(); +} +// ----------------------------------------------------------------------------- +void OptimisticSet::mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& io_aInsertRow,ORowSetValueVector::Vector& io_aRow,::std::vector& o_aChangedColumns) +{ + o_aChangedColumns.push_back(i_nColumnIndex); + ::std::map::const_iterator aJoinIter = m_aJoinedColumns.find(i_nColumnIndex); + if ( aJoinIter != m_aJoinedColumns.end() ) + { + io_aRow[aJoinIter->second] = io_aRow[i_nColumnIndex]; + io_aInsertRow[aJoinIter->second] = io_aInsertRow[i_nColumnIndex]; + io_aRow[aJoinIter->second].setModified(); + o_aChangedColumns.push_back(aJoinIter->second); + } +} +namespace +{ + struct PositionFunctor : ::std::unary_function + { + sal_Int32 m_nPos; + PositionFunctor(sal_Int32 i_nPos) + : m_nPos(i_nPos) + { + } + + inline bool operator()(const SelectColumnsMetaData::value_type& _aType) + { + return m_nPos == _aType.second.nPosition; + } + }; + struct TableNameFunctor : ::std::unary_function + { + ::rtl::OUString m_sTableName; + TableNameFunctor(const ::rtl::OUString& i_sTableName) + : m_sTableName(i_sTableName) + { + } + + inline bool operator()(const SelectColumnsMetaData::value_type& _aType) + { + return m_sTableName == _aType.second.sTableName; + } + }; +} +// ----------------------------------------------------------------------------- +bool OptimisticSet::updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector& i_aChangedColumns) +{ + bool bRet = false; + ::std::vector::const_iterator aColIdxIter = i_aChangedColumns.begin(); + for(;aColIdxIter != i_aChangedColumns.end();++aColIdxIter) + { + SelectColumnsMetaData::const_iterator aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),PositionFunctor(*aColIdxIter)); + if ( aFind != m_pKeyColumnNames->end() ) + { + const ::rtl::OUString sTableName = aFind->second.sTableName; + aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),TableNameFunctor(sTableName)); + while( aFind != m_pKeyColumnNames->end() ) + { + io_aRow[aFind->second.nPosition].setSigned(io_aCachedRow[aFind->second.nPosition].isSigned()); + if ( io_aCachedRow[aFind->second.nPosition] != io_aRow[aFind->second.nPosition] ) + break; + ++aFind; + } + if ( aFind == m_pKeyColumnNames->end() ) + { + bRet = true; + SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(sal_Int32 i = 1;aIter != aEnd;++aIter) + { + if ( aIter->second.sTableName == sTableName ) + { + io_aRow[aIter->second.nPosition] = io_aCachedRow[aIter->second.nPosition]; + io_aRow[aIter->second.nPosition].setModified(); + } + } + } + } + } + return bRet; +} +// ----------------------------------------------------------------------------- +bool OptimisticSet::columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow) +{ + bool bRet = false; + SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(;aIter != aEnd;++aIter) + { + SelectColumnsMetaData::const_iterator aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),PositionFunctor(aIter->second.nPosition)); + if ( aFind != m_pKeyColumnNames->end() ) + { + const ::rtl::OUString sTableName = aFind->second.sTableName; + aFind = ::std::find_if(m_pKeyColumnNames->begin(),m_pKeyColumnNames->end(),TableNameFunctor(sTableName)); + while( aFind != m_pKeyColumnNames->end() ) + { + o_aCachedRow[aFind->second.nPosition].setSigned(i_aRow[aFind->second.nPosition].isSigned()); + if ( o_aCachedRow[aFind->second.nPosition] != i_aRow[aFind->second.nPosition] ) + break; + ++aFind; + } + if ( aFind == m_pKeyColumnNames->end() ) + { + bRet = true; + SelectColumnsMetaData::const_iterator aIter2 = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd2 = m_pColumnNames->end(); + for(sal_Int32 i = 1;aIter2 != aEnd2;++aIter2) + { + if ( aIter2->second.sTableName == sTableName ) + { + o_aCachedRow[aIter2->second.nPosition] = i_aRow[aIter2->second.nPosition]; + o_aCachedRow[aIter2->second.nPosition].setModified(); + } + } + fillMissingValues(o_aCachedRow); + } + } + } + return bRet; +} +// ----------------------------------------------------------------------------- +void OptimisticSet::fillMissingValues(ORowSetValueVector::Vector& io_aRow) const +{ + TSQLStatements aSql; + TSQLStatements aKeyConditions; + ::std::map< ::rtl::OUString,bool > aResultSetChanged; + ::rtl::OUString aQuote = getIdentifierQuoteString(); + static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); + // here we build the condition part for the update statement + SelectColumnsMetaData::const_iterator aColIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aColEnd = m_pColumnNames->end(); + for(;aColIter != aColEnd;++aColIter) + { + const ::rtl::OUString sQuotedColumnName = ::dbtools::quoteName( aQuote,aColIter->second.sRealName); + if ( m_aJoinedKeyColumns.find(aColIter->second.nPosition) != m_aJoinedKeyColumns.end() ) + { + lcl_fillKeyCondition(aColIter->second.sTableName,sQuotedColumnName,io_aRow[aColIter->second.nPosition],aKeyConditions); + } + ::rtl::OUStringBuffer& rPart = aSql[aColIter->second.sTableName]; + if ( rPart.getLength() ) + rPart.appendAscii(", "); + rPart.append(sQuotedColumnName); + } + Reference xMetaData = m_xConnection->getMetaData(); + TSQLStatements::iterator aSqlIter = aSql.begin(); + TSQLStatements::iterator aSqlEnd = aSql.end(); + for(;aSqlIter != aSqlEnd ; ++aSqlIter) + { + if ( aSqlIter->second.getLength() ) + { + ::rtl::OUStringBuffer& rCondition = aKeyConditions[aSqlIter->first]; + if ( rCondition.getLength() ) + { + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(xMetaData,aSqlIter->first,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); + ::rtl::OUString sComposedTableName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); + ::rtl::OUStringBuffer sQuery; + sQuery.appendAscii("SELECT "); + sQuery.append(aSqlIter->second); + sQuery.appendAscii(" FROM "); + sQuery.append(sComposedTableName); + sQuery.appendAscii(" WHERE "); + sQuery.append(rCondition.makeStringAndClear()); + + try + { + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(sQuery.makeStringAndClear())); + Reference< XParameters > xParameter(xPrep,UNO_QUERY); + // and then the values of the where condition + SelectColumnsMetaData::iterator aKeyIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::iterator aKeyEnd = m_pKeyColumnNames->end(); + sal_Int32 i = 1; + for(;aKeyIter != aKeyEnd;++aKeyIter) + { + if ( aKeyIter->second.sTableName == aSqlIter->first ) + { + setParameter(i++,xParameter,io_aRow[aKeyIter->second.nPosition],aKeyIter->second.nType,aKeyIter->second.nScale); + } + } + Reference xRes = xPrep->executeQuery(); + Reference xRow(xRes,UNO_QUERY); + if ( xRow.is() && xRes->next() ) + { + i = 1; + aColIter = m_pColumnNames->begin(); + for(;aColIter != aColEnd;++aColIter) + { + if ( aColIter->second.sTableName == aSqlIter->first ) + { + io_aRow[aColIter->second.nPosition].fill(i++,aColIter->second.nType,aColIter->second.bNullable,xRow); + io_aRow[aColIter->second.nPosition].setModified(); + } + } + } + } + catch(const SQLException&) + { + } + } + } + } +} +// ----------------------------------------------------------------------------- + diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx new file mode 100644 index 000000000000..a3683aab0d12 --- /dev/null +++ b/dbaccess/source/core/api/OptimisticSet.hxx @@ -0,0 +1,196 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: KeySet.hxx,v $ + * $Revision: 1.30 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_CORE_API_OPTIMISTICSET_HXX +#define DBACCESS_CORE_API_OPTIMISTICSET_HXX + +#include "CacheSet.hxx" +#include "KeySet.hxx" +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace dbaccess +{ + // is used when the source supports keys + class OptimisticSet : public OCacheSet + { + ::connectivity::OSQLParser m_aSqlParser; + ::connectivity::OSQLParseTreeIterator m_aSqlIterator; + OKeySetMatrix m_aKeyMap; + OKeySetMatrix::iterator m_aKeyIter; + + ::std::vector< ::rtl::OUString > m_aAutoColumns; // contains all columns which are autoincrement ones + ::std::map m_aJoinedColumns; + ::std::map m_aJoinedKeyColumns; + + OUpdatedParameter m_aUpdatedParameter; // contains all parameter which have been updated and are needed for refetching + ORowSetValueVector m_aParameterValueForCache; + ::std::auto_ptr m_pKeyColumnNames; // contains all key column names + ::std::auto_ptr m_pColumnNames; // contains all column names + ::std::auto_ptr m_pParameterNames; // contains all parameter names + connectivity::OSQLTable m_xTable; // reference to our table + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement> m_xStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xSet; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xRow; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer; + + sal_Bool m_bRowCountFinal; + mutable bool m_bResultSetChanged; + + /** + getComposedTableName return the composed table name for the query + @param _sCatalog the catalogname may be empty + @param _sSchema the schemaname may be empty + @param _sTable the tablename + + @return the composed name + */ + ::rtl::OUString getComposedTableName( const ::rtl::OUString& _sCatalog, + const ::rtl::OUString& _sSchema, + const ::rtl::OUString& _sTable); + + /** copies the values from the insert row into the key row + * + * \param _rInsertRow the row which was inserted + * \param _rKeyRow The current key row of the row set. + + \param i_nBookmark The bookmark is used to update the parameter + */ + void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark); + + void fillAllRows(); + sal_Bool fetchRow(); + + void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData); + void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable + ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta + ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns); + void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName); + void executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName); + void executeDelete(const ORowSetRow& _rDeleteRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName); + void fillJoinedColumns_throw(const ::std::vector< ::connectivity::TNodePair>& i_aJoinColumns); + void fillJoinedColumns_throw(const ::rtl::OUString& i_sLeftColumn,const ::rtl::OUString& i_sRightColumn); + protected: + virtual ~OptimisticSet(); + public: + OptimisticSet(const ::comphelper::ComponentContext& _rContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_xConnection, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, + const ORowSetValueVector& _aParameterValueForCache); + + // late ctor which can throw exceptions + virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); + + // ::com::sun::star::sdbc::XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdbc::XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdbcx::XRowLocate + virtual ::com::sun::star::uno::Any SAL_CALL getBookmark() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ------------------------------------------------------------------------- + virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ------------------------------------------------------------------------- + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ------------------------------------------------------------------------- + virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ------------------------------------------------------------------------- + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ------------------------------------------------------------------------- + virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ------------------------------------------------------------------------- + // ::com::sun::star::sdbcx::XDeleteRows + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdbc::XResultSetUpdate + virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // CacheSet + virtual bool isResultSetChanged() const; + virtual void reset(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + virtual void mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& io_aInsertRow,ORowSetValueVector::Vector& io_aRow,::std::vector& o_aChangedColumns); + virtual bool columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow); + virtual bool updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector& i_aChangedColumns); + virtual void fillMissingValues(ORowSetValueVector::Vector& io_aRow) const; + + bool isReadOnly() const { return m_aJoinedKeyColumns.empty(); } + const ::std::map& getJoinedColumns() const { return m_aJoinedColumns; } + const ::std::map& getJoinedKeyColumns() const { return m_aJoinedKeyColumns; } + }; +} +#endif // DBACCESS_CORE_API_OPTIMISTICSET_HXX + diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 1531f232e5e7..a3d9d255986a 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -141,8 +141,6 @@ extern "C" void SAL_CALL createRegistryInfo_ORowSet() namespace dbaccess { //.................................................................. - - //-------------------------------------------------------------------------- Reference< XInterface > ORowSet_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory) { @@ -155,6 +153,7 @@ ORowSet::ORowSet( const Reference< ::com::sun::star::lang::XMultiServiceFactory ,m_pParameters( NULL ) ,m_aRowsetListeners(*m_pMutex) ,m_aApproveListeners(*m_pMutex) + ,m_aRowsChangeListener(*m_pMutex) ,m_pTables(NULL) ,m_nFetchDirection(FetchDirection::FORWARD) ,m_nFetchSize(50) @@ -532,6 +531,7 @@ void SAL_CALL ORowSet::disposing() aDisposeEvent.Source = static_cast< XComponent* >(this); m_aRowsetListeners.disposeAndClear( aDisposeEvent ); m_aApproveListeners.disposeAndClear( aDisposeEvent ); + m_aRowsChangeListener.disposeAndClear( aDisposeEvent ); freeResources( true ); @@ -704,12 +704,10 @@ void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) checkUpdateConditions(columnIndex); checkUpdateIterator(); - ::connectivity::ORowSetValue aOldValue(((*m_aCurrentRow)->get())[columnIndex]); - m_pCache->updateValue(columnIndex,x); - // we have to notify all listeners - ((*m_aCurrentRow)->get())[columnIndex] = x; - firePropertyChange(columnIndex-1 ,aOldValue); - fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); + ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); + ORowSetNotifier aNotify(this,rRow); + m_pCache->updateValue(columnIndex,x,rRow,aNotify.getChangedColumns()); + aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- // XRowUpdate @@ -721,12 +719,10 @@ void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, R checkUpdateConditions(columnIndex); checkUpdateIterator(); - ::connectivity::ORowSetValue aOldValue(((*m_aCurrentRow)->get())[columnIndex]); - m_pCache->updateNull(columnIndex); - // we have to notify all listeners - ((*m_aCurrentRow)->get())[columnIndex].setNull(); - firePropertyChange(columnIndex-1 ,aOldValue); - fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); + ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); + ORowSetNotifier aNotify(this,rRow); + m_pCache->updateNull(columnIndex,rRow,aNotify.getChangedColumns()); + aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) @@ -792,11 +788,8 @@ void SAL_CALL ORowSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun: void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( *m_pMutex ); - checkUpdateConditions(columnIndex); - checkUpdateIterator(); //if(((*m_aCurrentRow)->get())[columnIndex].getTypeKind() == DataType::BLOB) @@ -820,26 +813,20 @@ void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Referenc void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( *m_pMutex ); checkUpdateConditions(columnIndex); - checkUpdateIterator(); - m_pCache->updateCharacterStream(columnIndex,x,length); - - ::connectivity::ORowSetValue aOldValue(((*m_aCurrentRow)->get())[columnIndex]); - ((*m_aCurrentRow)->get())[columnIndex] = makeAny(x); - firePropertyChange(columnIndex-1 ,aOldValue); - fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); + ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); + ORowSetNotifier aNotify(this,rRow); + m_pCache->updateCharacterStream(columnIndex,x,length,rRow,aNotify.getChangedColumns()); + aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) { ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( *m_pMutex ); checkUpdateConditions(columnIndex); - checkUpdateIterator(); Any aNewValue = x; @@ -872,29 +859,23 @@ void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw if (!::dbtools::implUpdateObject(this, columnIndex, aNewValue)) { // there is no other updateXXX call which can handle the value in x - ::connectivity::ORowSetValue aOldValue(((*m_aCurrentRow)->get())[columnIndex]); - m_pCache->updateObject(columnIndex,aNewValue); - // we have to notify all listeners - ((*m_aCurrentRow)->get())[columnIndex] = aNewValue; - firePropertyChange(columnIndex-1 ,aOldValue); - fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); + ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); + ORowSetNotifier aNotify(this,rRow); + m_pCache->updateObject(columnIndex,aNewValue,rRow,aNotify.getChangedColumns()); + aNotify.firePropertyChange(); } } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException) { ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( *m_pMutex ); checkUpdateConditions(columnIndex); - checkUpdateIterator(); - ::connectivity::ORowSetValue aOldValue(((*m_aCurrentRow)->get())[columnIndex]); - m_pCache->updateNumericObject(columnIndex,x,scale); - // we have to notify all listeners - ((*m_aCurrentRow)->get())[columnIndex] = x; - firePropertyChange(columnIndex-1 ,aOldValue); - fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); + ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); + ORowSetNotifier aNotify(this,rRow); + m_pCache->updateNumericObject(columnIndex,x,scale,rRow,aNotify.getChangedColumns()); + aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- @@ -919,10 +900,12 @@ void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException) ORowSetRow aOldValues; if ( !m_aCurrentRow.isNull() ) aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() ); - RowChangeEvent aEvt(*this,RowChangeAction::INSERT,1); + Sequence aChangedBookmarks; + RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks); notifyAllListenersRowBeforeChange(aGuard,aEvt); - sal_Bool bInserted = m_pCache->insertRow(); + ::std::vector< Any > aBookmarks; + sal_Bool bInserted = m_pCache->insertRow(aBookmarks); // make sure that our row is set to the new inserted row before clearing the insert flags in the cache m_pCache->resetInsertRow(bInserted); @@ -931,9 +914,18 @@ void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException) // - column values setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here + // read-only flag restored + impl_restoreDataColumnsWriteable_throw(); + // - rowChanged notifyAllListenersRowChanged(aGuard,aEvt); + if ( !aBookmarks.empty() ) + { + RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence(&(*aBookmarks.begin()),aBookmarks.size())); + notifyAllListenersRowChanged(aGuard,aUpEvt); + } + // - IsModified if(!m_bModified) fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); @@ -972,20 +964,31 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) if ( !m_aCurrentRow.isNull() ) aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() ); - RowChangeEvent aEvt(*this,RowChangeAction::UPDATE,1); + Sequence aChangedBookmarks; + RowsChangeEvent aEvt(*this,RowChangeAction::UPDATE,1,aChangedBookmarks); notifyAllListenersRowBeforeChange(aGuard,aEvt); - m_pCache->updateRow(m_aCurrentRow.operator ->()); + ::std::vector< Any > aBookmarks; + m_pCache->updateRow(m_aCurrentRow.operator ->(),aBookmarks); + if ( !aBookmarks.empty() ) + aEvt.Bookmarks = Sequence(&(*aBookmarks.begin()),aBookmarks.size()); + aEvt.Rows += aBookmarks.size(); m_aBookmark = m_pCache->getBookmark(); m_aCurrentRow = m_pCache->m_aMatrixIter; - if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() ) + if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && (*m_pCache->m_aMatrixIter).isValid() ) { - m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody())); - - // notification order - // - column values - ORowSetBase::firePropertyChange(aOldValues); + if ( m_pCache->isResultSetChanged() ) + { + impl_rebuild_throw(aGuard); + } + else + { + m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody())); + // notification order + // - column values + ORowSetBase::firePropertyChange(aOldValues); + } // - rowChanged notifyAllListenersRowChanged(aGuard,aEvt); @@ -993,6 +996,9 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) if(!m_bModified) fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" ); + + // - RowCount/IsRowCountFinal + fireRowcount(); } else if ( !m_bAfterLast ) // the update went rong { @@ -1030,7 +1036,8 @@ void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException) if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && m_pCache->m_aMatrixIter->isValid() ) aOldValues = new ORowSetValueVector( m_pCache->m_aMatrixIter->getBody() ); - RowChangeEvent aEvt(*this,RowChangeAction::DELETE,1); + Sequence aChangedBookmarks; + RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,1,aChangedBookmarks); notifyAllListenersRowBeforeChange(aGuard,aEvt); m_pCache->deleteRow(); @@ -1129,10 +1136,11 @@ void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard _rGuard.reset(); } // ------------------------------------------------------------------------- -void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, const EventObject& aEvt) +void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, const RowsChangeEvent& aEvt) { _rGuard.clear(); - m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, aEvt ); + m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, (EventObject)aEvt ); + m_aRowsChangeListener.notifyEach( &XRowsChangeListener::rowsChanged, aEvt ); _rGuard.reset(); } // ------------------------------------------------------------------------- @@ -1167,8 +1175,8 @@ void ORowSet::fireRowcount() { sal_Int32 nHandle = PROPERTY_ID_ISROWCOUNTFINAL; Any aNew,aOld; - aNew <<= bool2any( bCurrentRowCountFinal ); - aOld <<= bool2any( m_bLastKnownRowCountFinal ); + aNew <<= bCurrentRowCountFinal; + aOld <<= m_bLastKnownRowCountFinal; fire(&nHandle,&aNew,&aOld,1,sal_False); m_bLastKnownRowCountFinal = bCurrentRowCountFinal; } @@ -1210,6 +1218,9 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) m_pCache->moveToInsertRow(); m_aCurrentRow = m_pCache->m_aInsertRow; + // set read-only flag to false + impl_setDataColumnsWriteable_throw(); + // notification order // - column values ORowSetBase::firePropertyChange(aOldValues); @@ -1230,6 +1241,33 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) } } // ------------------------------------------------------------------------- +void ORowSet::impl_setDataColumnsWriteable_throw() +{ + impl_restoreDataColumnsWriteable_throw(); + TDataColumns::iterator aIter = m_aDataColumns.begin(); + m_aReadOnlyDataColumns.resize(m_aDataColumns.size(),false); + ::std::bit_vector::iterator aReadIter = m_aReadOnlyDataColumns.begin(); + for(;aIter != m_aDataColumns.end();++aIter,++aReadIter) + { + sal_Bool bReadOnly = sal_False; + (*aIter)->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly; + *aReadIter = bReadOnly; + + (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny(sal_False)); + } +} +// ------------------------------------------------------------------------- +void ORowSet::impl_restoreDataColumnsWriteable_throw() +{ + TDataColumns::iterator aIter = m_aDataColumns.begin(); + ::std::bit_vector::iterator aReadIter = m_aReadOnlyDataColumns.begin(); + for(;aReadIter != m_aReadOnlyDataColumns.end();++aIter,++aReadIter) + { + (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny((sal_Bool)*aReadIter )); + } + m_aReadOnlyDataColumns.clear(); +} +// ------------------------------------------------------------------------- void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) { ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); @@ -1787,7 +1825,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi } m_pCache->setMaxRowSize(m_nFetchSize); m_aCurrentRow = m_pCache->createIterator(this); - m_aOldRow = m_pCache->registerOldRow(); + m_aOldRow = m_pCache->registerOldRow(); } // get the locale @@ -1807,6 +1845,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi ::rtl::OUString aDescription; sal_Int32 nFormatKey = 0; + const ::std::map& rKeyColumns = m_pCache->getKeyColumns(); if(!m_xColumns.is()) { RTL_LOGFILE_CONTEXT_AUTHOR( aColumnCreateLog, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn::creating columns" ); @@ -1851,6 +1890,8 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi aNames.push_back(sName); m_aDataColumns.push_back(pColumn); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i+1) != rKeyColumns.end())); + try { nFormatKey = 0; @@ -1949,6 +1990,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi m_aCurrentRow); aColumns->get().push_back(pColumn); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end())); if(!sColumnLabel.getLength()) { @@ -1999,6 +2041,24 @@ void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetAppr m_aApproveListeners.removeInterface(listener); } +// XRowsChangeBroadcaster +void SAL_CALL ORowSet::addRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException) +{ + ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); + + ::osl::MutexGuard aGuard( m_aColumnsMutex ); + + m_aRowsChangeListener.addInterface(listener); +} +// ------------------------------------------------------------------------- +void SAL_CALL ORowSet::removeRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException) +{ + ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); + + ::osl::MutexGuard aGuard( m_aColumnsMutex ); + + m_aRowsChangeListener.removeInterface(listener); +} // ------------------------------------------------------------------------- // XResultSetAccess @@ -2034,7 +2094,8 @@ Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows ::osl::ResettableMutexGuard aGuard( *m_pMutex ); - RowChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength()); + Sequence aChangedBookmarks; + RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength(),aChangedBookmarks); // notify the rowset listeners notifyAllListenersRowBeforeChange(aGuard,aEvt); @@ -2640,20 +2701,16 @@ void SAL_CALL ORowSet::clearWarnings( ) throw (SQLException, RuntimeException) { m_aWarnings.clearWarnings(); } - -// ------------------------------------------------------------------------- -void ORowSet::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rOldValue) -{ - OSL_ENSURE(_nPos < (sal_Int32)m_aDataColumns.size(),"nPos is invalid!"); - m_aDataColumns[_nPos]->fireValueChange(_rOldValue); -} - // ----------------------------------------------------------------------------- void ORowSet::doCancelModification( ) { //OSL_ENSURE( isModification(), "ORowSet::doCancelModification: invalid call (no cache!)!" ); if ( isModification() ) + { + // read-only flag restored + impl_restoreDataColumnsWriteable_throw(); m_pCache->cancelRowModification(); + } m_bModified = sal_False; } @@ -2721,6 +2778,14 @@ void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException) // - IsNew aNotifier.fire( ); } +// ----------------------------------------------------------------------------- +void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard) +{ + Reference< XResultSet > xResultSet( m_xStatement->executeQuery() ); + m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) ); + m_pCache->reset(xResultSet); + notifyAllListeners(_rGuard); +} // *********************************************************** // ORowSetClone // *********************************************************** diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx index 25fa3a3415f6..854df5c3252b 100644 --- a/dbaccess/source/core/api/RowSet.hxx +++ b/dbaccess/source/core/api/RowSet.hxx @@ -35,68 +35,36 @@ #include "RowSetBase.hxx" /** === begin UNO includes === **/ -#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XROWSETLISTENER_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_XROWSETAPPROVEBROADCASTER_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDELETEROWS_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDEXECUTION_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ #include -#endif +#include /** === end UNO includes === **/ -#include +#include #include #include #include namespace dbaccess { - typedef ::cppu::WeakAggComponentImplHelper11 < ::com::sun::star::sdb::XResultSetAccess + typedef ::cppu::WeakAggComponentImplHelper12 < ::com::sun::star::sdb::XResultSetAccess , ::com::sun::star::sdb::XRowSetApproveBroadcaster + , ::com::sun::star::sdb::XRowsChangeBroadcaster , ::com::sun::star::sdbcx::XDeleteRows , ::com::sun::star::sdbc::XParameters , ::com::sun::star::lang::XEventListener @@ -135,9 +103,11 @@ namespace dbaccess ORowSetValueVector m_aPrematureParamValues; ORowSetValueVector m_aParameterValueForCache; ::std::bit_vector m_aParametersSet; + ::std::bit_vector m_aReadOnlyDataColumns; ::cppu::OInterfaceContainerHelper m_aRowsetListeners; ::cppu::OInterfaceContainerHelper m_aApproveListeners; + ::cppu::OInterfaceContainerHelper m_aRowsChangeListener; ::dbtools::WarningsContainer m_aWarnings; @@ -245,10 +215,6 @@ namespace dbaccess // free clones and ParseTree. Plus, if _bComplete is , *all* other associated resources void freeResources( bool _bComplete ); - // fire a change for one column - // _nPos starts at zero - void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue); - /// informs the clones (and ourself) that we are going to delete a record with a given bookmark void notifyRowSetAndClonesRowDelete( const ::com::sun::star::uno::Any& _rBookmark ); @@ -263,6 +229,11 @@ namespace dbaccess void updateValue(sal_Int32 columnIndex,const connectivity::ORowSetValue& x); void checkUpdateConditions(sal_Int32 columnIndex); + void impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard); + // set all data columns to writeable + void impl_setDataColumnsWriteable_throw(); + // restore the old state of the data column read-only state + void impl_restoreDataColumnsWriteable_throw(); protected: virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); @@ -271,7 +242,7 @@ namespace dbaccess virtual void fireRowcount(); void notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const ::com::sun::star::sdb::RowChangeEvent &rEvt); - void notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard,const ::com::sun::star::lang::EventObject& rEvt); + void notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard,const ::com::sun::star::sdb::RowsChangeEvent& rEvt); virtual sal_Bool notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard); virtual void notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard); virtual void notifyAllListeners(::osl::ResettableMutexGuard& _rGuard); @@ -395,6 +366,10 @@ namespace dbaccess virtual void SAL_CALL addRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdb::XRowsChangeBroadcaster + virtual void SAL_CALL addRowsChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowsChangeListener >& listener ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRowsChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowsChangeListener >& listener ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdb::XResultSetAccess virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL createResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index c5811705570d..d367fb156f98 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -1297,7 +1297,12 @@ void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow) } DBG_TRACE2("DBACCESS ORowSetBase::firePropertyChange() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL)); } - +// ------------------------------------------------------------------------- +void ORowSetBase::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rOldValue) +{ + OSL_ENSURE(_nPos < (sal_Int32)m_aDataColumns.size(),"nPos is invalid!"); + m_aDataColumns[_nPos]->fireValueChange(_rOldValue); +} // ----------------------------------------------------------------------------- void ORowSetBase::fireRowcount() { @@ -1475,6 +1480,13 @@ sal_Int32 ORowSetBase::impl_getRowCount() const return nRowCount; } // ============================================================================= +struct ORowSetNotifierImpl +{ + ::std::vector aChangedColumns; + ::std::vector aChangedBookmarks; + ORowSetValueVector::Vector aRow; + +}; DBG_NAME(ORowSetNotifier) // ----------------------------------------------------------------------------- ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet ) @@ -1497,7 +1509,21 @@ ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet ) if ( m_pRowSet->isModification( ORowSetBase::GrantNotifierAccess() ) ) m_pRowSet->doCancelModification( ORowSetBase::GrantNotifierAccess() ); } +// ----------------------------------------------------------------------------- +ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet,const ORowSetValueVector::Vector& i_aRow ) + :m_pImpl(new ORowSetNotifierImpl) + ,m_pRowSet( _pRowSet ) + ,m_bWasNew( sal_False ) + ,m_bWasModified( sal_False ) +#ifdef DBG_UTIL + ,m_bNotifyCalled( sal_False ) +#endif +{ + DBG_CTOR(ORowSetNotifier,NULL); + OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." ); + m_pImpl->aRow = i_aRow; // yes, create a copy to store the old values +} // ----------------------------------------------------------------------------- ORowSetNotifier::~ORowSetNotifier( ) { @@ -1525,5 +1551,30 @@ void ORowSetNotifier::fire() m_bNotifyCalled = sal_True; #endif } - +// ----------------------------------------------------------------------------- +::std::vector& ORowSetNotifier::getChangedColumns() const +{ + OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!"); + return m_pImpl->aChangedColumns; +} +// ----------------------------------------------------------------------------- +::std::vector& ORowSetNotifier::getChangedBookmarks() const +{ + OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!"); + return m_pImpl->aChangedBookmarks; +} +// ----------------------------------------------------------------------------- +void ORowSetNotifier::firePropertyChange() +{ + OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!"); + if( m_pImpl.get() ) + { + ::std::vector::iterator aIter = m_pImpl->aChangedColumns.begin(); + for(;aIter != m_pImpl->aChangedColumns.end();++aIter) + { + m_pRowSet->firePropertyChange((*aIter)-1 ,m_pImpl->aRow[(*aIter)-1], ORowSetBase::GrantNotifierAccess()); + } + m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess()); + } +} } // namespace dbaccess diff --git a/dbaccess/source/core/api/RowSetBase.hxx b/dbaccess/source/core/api/RowSetBase.hxx index d55af88ee4d8..dc318b98bbe9 100644 --- a/dbaccess/source/core/api/RowSetBase.hxx +++ b/dbaccess/source/core/api/RowSetBase.hxx @@ -171,6 +171,9 @@ namespace dbaccess // fire a notification for all that are listening on column::VALUE property void firePropertyChange(const ORowSetRow& _rOldRow); + // fire a change for one column + // _nPos starts at zero + void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue); // fire if rowcount changed virtual void fireRowcount(); @@ -388,6 +391,10 @@ namespace dbaccess { fireProperty( _nProperty, _bNew, _bOld ); } + inline void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue, const GrantNotifierAccess& ) + { + firePropertyChange(_nPos,_rNewValue); + } using ::comphelper::OPropertyStateContainer::getFastPropertyValue; ::osl::Mutex* getMutex() const { return m_pMutex; } @@ -398,14 +405,17 @@ namespace dbaccess

The class can only be used on the stack, within a method of ORowSetBase (or derivees)

*/ + struct ORowSetNotifierImpl; class ORowSetNotifier { private: + ::std::auto_ptr m_pImpl; ORowSetBase* m_pRowSet; // not aquired! This is not necessary because this class here is to be used on the stack within // a method of ORowSetBase (or derivees) sal_Bool m_bWasNew; sal_Bool m_bWasModified; + #ifdef DBG_UTIL sal_Bool m_bNotifyCalled; #endif @@ -417,6 +427,10 @@ namespace dbaccess */ ORowSetNotifier( ORowSetBase* m_pRowSet ); + /** use this one to consturct an vector for change value notification + */ + ORowSetNotifier( ORowSetBase* m_pRowSet,const ORowSetValueVector::Vector& i_aRow ); + // destructs the object. fire has to be called before. ~ORowSetNotifier( ); @@ -431,6 +445,19 @@ namespace dbaccess @see ORowSetBase::notifyCancelInsert */ void fire(); + + /** notifies value change events and notifies IsModified + @param i_aChangedColumns the index of the changed value columns + @param i_aRow the old values + @see ORowSetBase::notifyCancelInsert + */ + void firePropertyChange(); + + /** use this one to store the inde of the changed column values + */ + ::std::vector& getChangedColumns() const; + ::std::vector& getChangedBookmarks() const; + }; } // end of namespace diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 924fd881346e..dba67c045f9d 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -70,18 +70,11 @@ #ifndef DBACCESS_CORE_API_ROWSETBASE_HXX #include "RowSetBase.hxx" #endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include -#endif -#ifndef _CONNECTIVITY_SQLPARSE_HXX #include -#endif -#ifndef _CONNECTIVITY_SQLNODE_HXX #include -#endif -#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include #include -#endif #ifndef _COMPHELPER_PROPERTY_HXX_ #include #endif @@ -114,6 +107,8 @@ #ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" #endif +#include "WrappedResultSet.hxx" +#include "OptimisticSet.hxx" using namespace dbaccess; using namespace dbtools; @@ -162,10 +157,34 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { DBG_CTOR(ORowSetCache,NULL); + // first try if the result can be used to do inserts and updates + try + { + Reference< XResultSetUpdate> xUp(_xRs,UNO_QUERY_THROW); + xUp->moveToInsertRow(); + xUp->cancelRowUpdates(); + _xRs->beforeFirst(); + m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE; + m_pCacheSet = new WrappedResultSet(); + m_xCacheSet = m_pCacheSet; + m_pCacheSet->construct(_xRs,i_sRowSetFilter); + return; + } + catch(const Exception&) + { + } + // check if all keys of the updateable table are fetched sal_Bool bAllKeysFound = sal_False; sal_Int32 nTablesCount = 0; + Reference< XPropertySet> xProp(_xRs,UNO_QUERY); + Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo(); + sal_Bool bNeedKeySet = !(xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && + any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is() ); + bNeedKeySet = bNeedKeySet || (xPropInfo->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) && + ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY); + Reference< XIndexAccess> xUpdateTableKeys; ::rtl::OUString aUpdateTableName = _rUpdateTableName; Reference< XConnection> xConnection; @@ -186,58 +205,54 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference xTabSup(_xAnalyzer,UNO_QUERY); OSL_ENSURE(xTabSup.is(),"ORowSet::execute composer isn't a tablesupplier!"); Reference xTables = xTabSup->getTables(); - - - if(_rUpdateTableName.getLength() && xTables->hasByName(_rUpdateTableName)) - xTables->getByName(_rUpdateTableName) >>= m_aUpdateTable; - else if(xTables->getElementNames().getLength()) - { - aUpdateTableName = xTables->getElementNames()[0]; - xTables->getByName(aUpdateTableName) >>= m_aUpdateTable; + Sequence< ::rtl::OUString> aTableNames = xTables->getElementNames(); + if ( aTableNames.getLength() > 1 && !_rUpdateTableName.getLength() && bNeedKeySet ) + {// here we have a join or union and nobody told us which table to update, so we update them all + m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE; + OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache); + m_pCacheSet = pCursor; + m_xCacheSet = m_pCacheSet; + try + { + m_pCacheSet->construct(_xRs,i_sRowSetFilter); + if ( pCursor->isReadOnly() ) + m_nPrivileges = Privilege::SELECT; + m_aKeyColumns = pCursor->getJoinedKeyColumns(); + return; + } + catch(const Exception&) + { + } } - Reference xIndexAccess(xTables,UNO_QUERY); - if(xIndexAccess.is()) - nTablesCount = xIndexAccess->getCount(); else - nTablesCount = xTables->getElementNames().getLength(); - - if(m_aUpdateTable.is() && nTablesCount < 3) // for we can't handle more than 2 tables in our keyset { - Reference xKeys(m_aUpdateTable,UNO_QUERY); - if(xKeys.is()) + if(_rUpdateTableName.getLength() && xTables->hasByName(_rUpdateTableName)) + xTables->getByName(_rUpdateTableName) >>= m_aUpdateTable; + else if(xTables->getElementNames().getLength()) { - xUpdateTableKeys = xKeys->getKeys(); - if ( xUpdateTableKeys.is() ) - { - Reference xColumnsSupplier; - // search the one and only primary key - const sal_Int32 nCount = xUpdateTableKeys->getCount(); - for(sal_Int32 i = 0 ; i < nCount ; ++i) - { - Reference xProp(xUpdateTableKeys->getByIndex(i),UNO_QUERY); - sal_Int32 nKeyType = 0; - xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; - if(KeyType::PRIMARY == nKeyType) - { - xColumnsSupplier.set(xProp,UNO_QUERY); - break; - } - } + aUpdateTableName = xTables->getElementNames()[0]; + xTables->getByName(aUpdateTableName) >>= m_aUpdateTable; + } + Reference xIndexAccess(xTables,UNO_QUERY); + if(xIndexAccess.is()) + nTablesCount = xIndexAccess->getCount(); + else + nTablesCount = xTables->getElementNames().getLength(); - if(xColumnsSupplier.is()) + if(m_aUpdateTable.is() && nTablesCount < 3) // for we can't handle more than 2 tables in our keyset + { + Reference xSet(m_aUpdateTable,UNO_QUERY); + const Reference xPrimaryKeyColumns = dbtools::getPrimaryKeyColumns_throw(xSet); + if ( xPrimaryKeyColumns.is() ) + { + Reference xColSup(_xAnalyzer,UNO_QUERY); + if ( xColSup.is() ) { - - - Reference xColumns = xColumnsSupplier->getColumns(); - Reference xColSup(_xAnalyzer,UNO_QUERY); - if ( xColSup.is() ) - { - Reference xSelColumns = xColSup->getColumns(); - Reference xMeta = xConnection->getMetaData(); - SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false); - ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames); - bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xColumns->getElementNames().getLength(); - } + Reference xSelColumns = xColSup->getColumns(); + Reference xMeta = xConnection->getMetaData(); + SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false); + ::dbaccess::getColumnPositions(xSelColumns,xPrimaryKeyColumns->getElementNames(),aUpdateTableName,aColumnNames); + bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xPrimaryKeyColumns->getElementNames().getLength(); } } } @@ -247,12 +262,6 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { } } - Reference< XPropertySet> xProp(_xRs,UNO_QUERY); - - sal_Bool bNeedKeySet = !(xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && - any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is() ); - bNeedKeySet = bNeedKeySet || (xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) && - ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY); // first check if resultset is bookmarkable if(!bNeedKeySet) @@ -316,8 +325,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, const ::rtl::OUString* pEnd = pIter + aNames.getLength(); for(;pIter != pEnd;++pIter) { - Reference xColumn; - ::cppu::extractInterface(xColumn,xColumns->getByName(*pIter)); + Reference xColumn(xColumns->getByName(*pIter),UNO_QUERY); OSL_ENSURE(xColumn.is(),"Column in table is null!"); if(xColumn.is()) { @@ -473,6 +481,21 @@ Reference< XResultSetMetaData > ORowSetCache::getMetaData( ) return m_xMetaData; } // ------------------------------------------------------------------------- +Any lcl_getBookmark(ORowSetValue& i_aValue,OCacheSet* i_pCacheSet) +{ + switch ( i_aValue.getTypeKind() ) + { + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + return makeAny((sal_Int32)i_aValue); + default: + if ( i_pCacheSet && i_aValue.isNull()) + i_aValue = i_pCacheSet->getBookmark(); + return i_aValue.getAny(); + } +} +// ------------------------------------------------------------------------- // ::com::sun::star::sdbcx::XRowLocate Any ORowSetCache::getBookmark( ) { @@ -485,17 +508,7 @@ Any ORowSetCache::getBookmark( ) return Any(); // this is allowed here because the rowset knowns what it is doing } - switch(((*m_aMatrixIter)->get())[0].getTypeKind()) - { - case DataType::TINYINT: - case DataType::SMALLINT: - case DataType::INTEGER: - return makeAny((sal_Int32)((*m_aMatrixIter)->get())[0]); - default: - if(((*m_aMatrixIter)->get())[0].isNull()) - ((*m_aMatrixIter)->get())[0] = m_pCacheSet->getBookmark(); - return ((*m_aMatrixIter)->get())[0].getAny(); - } + return lcl_getBookmark(((*m_aMatrixIter)->get())[0],m_pCacheSet); } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark ) @@ -550,84 +563,106 @@ sal_Int32 ORowSetCache::compareBookmarks( const Any& _first, const Any& _second // ------------------------------------------------------------------------- sal_Bool ORowSetCache::hasOrderedBookmarks( ) { - return m_pCacheSet->hasOrderedBookmarks(); } // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark ) { - return m_pCacheSet->hashBookmark(bookmark); } -// ------------------------------------------------------------------------- // XRowUpdate // ----------------------------------------------------------------------------- -void ORowSetCache::updateNull(sal_Int32 columnIndex) +void ORowSetCache::updateNull(sal_Int32 columnIndex,ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ) { checkUpdateConditions(columnIndex); - ((*m_aInsertRow)->get())[columnIndex].setBound(sal_True); - ((*m_aInsertRow)->get())[columnIndex].setNull(); - ((*m_aInsertRow)->get())[columnIndex].setModified(); -} -// ----------------------------------------------------------------------------- -void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) -{ - checkUpdateConditions(columnIndex); + ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex].setNull(); + rInsert[columnIndex].setModified(); + io_aRow[columnIndex].setNull(); - ((*m_aInsertRow)->get())[columnIndex].setBound(sal_True); - ((*m_aInsertRow)->get())[columnIndex] = x; - ((*m_aInsertRow)->get())[columnIndex].setModified(); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); } -// ------------------------------------------------------------------------- -void ORowSetCache::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) +// ----------------------------------------------------------------------------- +void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x + ,ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ) { checkUpdateConditions(columnIndex); + ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = x; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - Sequence aSeq; - if(x.is()) - x->readBytes(aSeq,length); - updateValue(columnIndex,aSeq); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); } // ------------------------------------------------------------------------- -void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) +void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x + , sal_Int32 length,ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ) { checkUpdateConditions(columnIndex); - Sequence aSeq; if(x.is()) x->readBytes(aSeq,length); - updateValue(columnIndex,aSeq); + ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = aSeq; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = makeAny(x); + + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); } // ------------------------------------------------------------------------- -void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x ) +void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x + ,ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ) { checkUpdateConditions(columnIndex); + ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = x; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - ((*m_aInsertRow)->get())[columnIndex].setBound(sal_True); - ((*m_aInsertRow)->get())[columnIndex] = x; - ((*m_aInsertRow)->get())[columnIndex].setModified(); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); } // ------------------------------------------------------------------------- -void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) +void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ + ,ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ) { checkUpdateConditions(columnIndex); + ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = x; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - ((*m_aInsertRow)->get())[columnIndex].setBound(sal_True); - ((*m_aInsertRow)->get())[columnIndex] = x; - ((*m_aInsertRow)->get())[columnIndex].setModified(); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); } // ------------------------------------------------------------------------- // XResultSet sal_Bool ORowSetCache::next( ) { - - if(!isAfterLast()) { m_bBeforeFirst = sal_False; @@ -1226,7 +1261,7 @@ sal_Bool ORowSetCache::rowInserted( ) } // ------------------------------------------------------------------------- // XResultSetUpdate -sal_Bool ORowSetCache::insertRow( ) +sal_Bool ORowSetCache::insertRow(::std::vector< Any >& o_aBookmarks) { if ( !m_bNew || !m_aInsertRow->isValid() ) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_MOVETOINSERTROW_CALLED),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1240,7 +1275,19 @@ sal_Bool ORowSetCache::insertRow( ) Any aBookmark = ((*m_aInsertRow)->get())[0].makeAny(); m_bAfterLast = m_bBeforeFirst = sal_False; if(aBookmark.hasValue()) + { moveToBookmark(aBookmark); + // update the cached values + ORowSetValueVector::Vector& rCurrentRow = ((*m_aMatrixIter))->get(); + ORowSetMatrix::iterator aIter = m_pMatrix->begin(); + for(;aIter != m_pMatrix->end();++aIter) + { + if ( m_aMatrixIter != aIter && aIter->isValid() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) ) + { + o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet)); + } + } + } else { OSL_ENSURE(0,"There must be a bookmark after the row was inserted!"); @@ -1270,7 +1317,7 @@ void ORowSetCache::cancelRowModification() resetInsertRow(sal_False); } // ------------------------------------------------------------------------- -void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) +void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector< Any >& o_aBookmarks ) { if(isAfterLast() || isBeforeFirst()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_UPDATEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1281,16 +1328,23 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) // the row was already fetched moveToBookmark(aBookmark); m_pCacheSet->updateRow(*_rUpdateRow,*m_aMatrixIter,m_aUpdateTable); - // *(*m_aMatrixIter) = *(*_rUpdateRow); // refetch the whole row (*m_aMatrixIter) = NULL; - moveToBookmark(aBookmark); - // moveToBookmark((*(*m_aInsertRow))[0].makeAny()); -// if(m_pCacheSet->rowUpdated()) -// *m_aMatrixIter = m_aInsertRow; + if ( moveToBookmark(aBookmark) ) + { + // update the cached values + ORowSetValueVector::Vector& rCurrentRow = ((*m_aMatrixIter))->get(); + ORowSetMatrix::iterator aIter = m_pMatrix->begin(); + for(;aIter != m_pMatrix->end();++aIter) + { + if ( m_aMatrixIter != aIter && aIter->isValid() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) ) + { + o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet)); + } + } + } m_bModified = sal_False; - // refreshRow( ); } // ------------------------------------------------------------------------- bool ORowSetCache::deleteRow( ) @@ -1307,8 +1361,6 @@ bool ORowSetCache::deleteRow( ) OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!"); ORowSetMatrix::iterator aPos = calcPosition(); (*aPos) = NULL; - // (*m_pMatrix)[(m_nPosition - m_nStartPos)] = NULL; // set the deleted row to NULL - ORowSetMatrix::iterator aEnd = m_pMatrix->end(); for(++aPos;aPos != aEnd && aPos->isValid();++aPos) @@ -1625,8 +1677,39 @@ sal_Bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix: return _bCheck; } // ----------------------------------------------------------------------------- +bool ORowSetCache::isResultSetChanged() const +{ + return m_pCacheSet->isResultSetChanged(); +} +// ----------------------------------------------------------------------------- +void ORowSetCache::reset(const Reference< XResultSet>& _xDriverSet) +{ + m_xMetaData.set(Reference< XResultSetMetaDataSupplier >(_xDriverSet,UNO_QUERY)->getMetaData()); + m_pCacheSet->reset(_xDriverSet); + m_bRowCountFinal = sal_False; + m_nRowCount = 0; + reFillMatrix(m_nStartPos+1,m_nEndPos+1); +} +// ----------------------------------------------------------------------------- +void ORowSetCache::impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns) +{ + if ( o_ChangedColumns.size() > 1 ) + { + ORowSetMatrix::iterator aIter = m_pMatrix->begin(); + for(;aIter != m_pMatrix->end();++aIter) + { + if ( aIter->isValid() && m_pCacheSet->updateColumnValues((*aIter)->get(),io_aRow,o_ChangedColumns)) + { + break; + } + } - - - + if ( aIter == m_pMatrix->end() ) + { + m_pCacheSet->fillMissingValues(io_aRow); + } + } +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx index 268c32294824..851ac70149bc 100644 --- a/dbaccess/source/core/api/RowSetCache.hxx +++ b/dbaccess/source/core/api/RowSetCache.hxx @@ -122,6 +122,7 @@ namespace dbaccess typedef ::std::vector< TORowSetOldRowHelperRef > TOldRowSetRows; + ::std::map m_aKeyColumns; //the set can be static, bookmarkable or keyset ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xSet; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; // must be before m_aInsertRow @@ -169,7 +170,15 @@ namespace dbaccess void firePropertyChange(sal_Int32 _nColumnIndex,const ::connectivity::ORowSetValue& _rOldValue); void rotateCacheIterator(ORowSetMatrix::difference_type _nDist); - void updateValue(sal_Int32 columnIndex,const connectivity::ORowSetValue& x); + void updateValue(sal_Int32 columnIndex + ,const connectivity::ORowSetValue& x + ,ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ); + + void impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ); // checks and set the flags isAfterLast isLast and position when afterlast is true void checkPositionFlags(); void checkUpdateConditions(sal_Int32 columnIndex); @@ -222,11 +231,14 @@ namespace dbaccess sal_Int32 hashBookmark( const ::com::sun::star::uno::Any& bookmark ); // ::com::sun::star::sdbc::XRowUpdate - void updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ); - void updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ); - void updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ); - void updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ); - void updateNull(sal_Int32 columnIndex); + void updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length,ORowSetValueVector::Vector& io_aRow,::std::vector& o_ChangedColumns + ); + void updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x,ORowSetValueVector::Vector& io_aRow ,::std::vector& o_ChangedColumns); + void updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale,ORowSetValueVector::Vector& io_aRow ,::std::vector& o_ChangedColumns); + void updateNull(sal_Int32 columnIndex + ,ORowSetValueVector::Vector& io_aRow + ,::std::vector& o_ChangedColumns + ); // ::com::sun::star::sdbc::XResultSet sal_Bool next( ); @@ -247,14 +259,17 @@ namespace dbaccess sal_Bool rowInserted( ); // ::com::sun::star::sdbc::XResultSetUpdate - sal_Bool insertRow(); + sal_Bool insertRow(::std::vector< ::com::sun::star::uno::Any >& o_aBookmarks); void resetInsertRow(sal_Bool _bClearInsertRow); - void updateRow(); - void updateRow( ORowSetMatrix::iterator& _rUpdateRow ); + void updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector< ::com::sun::star::uno::Any >& o_aBookmarks ); bool deleteRow(); void cancelRowUpdates( ); void moveToInsertRow( ); + + const ::std::map& getKeyColumns() const { return m_aKeyColumns; } + bool isResultSetChanged() const; + void reset(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); }; } #endif diff --git a/dbaccess/source/core/api/WrappedResultSet.cxx b/dbaccess/source/core/api/WrappedResultSet.cxx new file mode 100644 index 000000000000..074da2faf46e --- /dev/null +++ b/dbaccess/source/core/api/WrappedResultSet.cxx @@ -0,0 +1,256 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: BookmarkSet.cxx,v $ + * $Revision: 1.21 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#include "WrappedResultSet.hxx" +#include "core_resource.hxx" +#include "core_resource.hrc" +#include +#include +#include + +#include + +using namespace dbaccess; +using namespace ::connectivity; +using namespace ::dbtools; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +// using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// using namespace ::cppu; +using namespace ::osl; + +void WrappedResultSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::construct" ); + OCacheSet::construct(_xDriverSet,i_sRowSetFilter); + m_xUpd.set(_xDriverSet,UNO_QUERY_THROW); + m_xRowLocate.set(_xDriverSet,UNO_QUERY_THROW); + m_xUpdRow.set(_xDriverSet,UNO_QUERY_THROW); +} +// ----------------------------------------------------------------------------- +Any SAL_CALL WrappedResultSet::getBookmark() throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::getBookmark" ); + return makeAny(m_xDriverSet->getRow()); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL WrappedResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToBookmark" ); + sal_Int32 nPos = 1; + bookmark >>= nPos; + return m_xDriverSet->absolute(nPos); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL WrappedResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveRelativeToBookmark" ); + sal_Int32 nPos = 1; + bookmark >>= nPos; + return m_xDriverSet->absolute(nPos + rows); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL WrappedResultSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::compareBookmarks" ); + return _first != _second; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL WrappedResultSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hasOrderedBookmarks" ); + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL WrappedResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hashBookmark" ); + sal_Int32 nPos = 1; + bookmark >>= nPos; + return nPos; +} +// ------------------------------------------------------------------------- +// ::com::sun::star::sdbcx::XDeleteRows +Sequence< sal_Int32 > SAL_CALL WrappedResultSet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& /*_xTable*/) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::deleteRows" ); + Reference< ::com::sun::star::sdbcx::XDeleteRows> xDeleteRow(m_xRowLocate,UNO_QUERY); + if(xDeleteRow.is()) + { + return xDeleteRow->deleteRows(rows); + } + return Sequence< sal_Int32 >(); +} +// ------------------------------------------------------------------------- +void SAL_CALL WrappedResultSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::insertRow" ); + + m_xUpd->moveToInsertRow(); + sal_Int32 i = 1; + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i) + { + aIter->setSigned(m_aSignedFlags[i-1]); + updateColumn(i,m_xUpdRow,*aIter); + } + m_xUpd->insertRow(); + (*_rInsertRow->get().begin()) = m_xDriverSet->getRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL WrappedResultSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::updateRow" ); + sal_Int32 i = 1; + connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOrginalRow->get().begin()+1; + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter) + { + aIter->setSigned(aOrgIter->isSigned()); + updateColumn(i,m_xUpdRow,*aIter); + } + m_xUpd->updateRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL WrappedResultSet::deleteRow(const ORowSetRow& /*_rDeleteRow*/ ,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::deleteRow" ); + m_xUpd->deleteRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL WrappedResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::cancelRowUpdates" ); + m_xUpd->cancelRowUpdates(); +} +// ------------------------------------------------------------------------- +void SAL_CALL WrappedResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToInsertRow" ); + m_xUpd->moveToInsertRow(); +} +// ------------------------------------------------------------------------- +void SAL_CALL WrappedResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToCurrentRow" ); +} +// ------------------------------------------------------------------------- +void WrappedResultSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::fillValueRow" ); + OCacheSet::fillValueRow(_rRow,_nPosition); +} +// ------------------------------------------------------------------------- +void WrappedResultSet::updateColumn(sal_Int32 nPos,Reference< XRowUpdate > _xParameter,const ORowSetValue& _rValue) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::updateColumn" ); + if(_rValue.isBound() && _rValue.isModified()) + { + if(_rValue.isNull()) + _xParameter->updateNull(nPos); + else + { + + switch(_rValue.getTypeKind()) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + _xParameter->updateNumericObject(nPos,_rValue.makeAny(),m_xSetMetaData->getScale(nPos)); + break; + case DataType::CHAR: + case DataType::VARCHAR: + //case DataType::DECIMAL: + //case DataType::NUMERIC: + _xParameter->updateString(nPos,_rValue); + break; + case DataType::BIGINT: + if ( _rValue.isSigned() ) + _xParameter->updateLong(nPos,_rValue); + else + _xParameter->updateString(nPos,_rValue); + break; + case DataType::BIT: + case DataType::BOOLEAN: + _xParameter->updateBoolean(nPos,_rValue); + break; + case DataType::TINYINT: + if ( _rValue.isSigned() ) + _xParameter->updateByte(nPos,_rValue); + else + _xParameter->updateShort(nPos,_rValue); + break; + case DataType::SMALLINT: + if ( _rValue.isSigned() ) + _xParameter->updateShort(nPos,_rValue); + else + _xParameter->updateInt(nPos,_rValue); + break; + case DataType::INTEGER: + if ( _rValue.isSigned() ) + _xParameter->updateInt(nPos,_rValue); + else + _xParameter->updateLong(nPos,_rValue); + break; + case DataType::FLOAT: + _xParameter->updateFloat(nPos,_rValue); + break; + case DataType::DOUBLE: + case DataType::REAL: + _xParameter->updateDouble(nPos,_rValue); + break; + case DataType::DATE: + _xParameter->updateDate(nPos,_rValue); + break; + case DataType::TIME: + _xParameter->updateTime(nPos,_rValue); + break; + case DataType::TIMESTAMP: + _xParameter->updateTimestamp(nPos,_rValue); + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + _xParameter->updateBytes(nPos,_rValue); + break; + case DataType::BLOB: + case DataType::CLOB: + _xParameter->updateObject(nPos,_rValue.getAny()); + break; + } + } + } +} + diff --git a/dbaccess/source/core/api/WrappedResultSet.hxx b/dbaccess/source/core/api/WrappedResultSet.hxx new file mode 100644 index 000000000000..082811748e6a --- /dev/null +++ b/dbaccess/source/core/api/WrappedResultSet.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: BookmarkSet.hxx,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_CORE_API_WRAPPEDRESULTSET_HXX +#define DBACCESS_CORE_API_WRAPPEDRESULTSET_HXX + +#ifndef DBACCESS_CORE_API_CACHESET_HXX +#include "CacheSet.hxx" +#endif +#include +#include + +namespace dbaccess +{ + // this set is used when we have a bookmarkable set from the driver + class WrappedResultSet : public OCacheSet + { + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate> m_xRowLocate; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate> m_xUpd; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate> m_xUpdRow; + + void updateColumn(sal_Int32 nPos,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > _xParameter,const connectivity::ORowSetValue& _rValue); + public: + WrappedResultSet() + {} + ~WrappedResultSet() + { + m_xRowLocate = NULL; + } + + virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); + virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition); + // ::com::sun::star::sdbcx::XRowLocate + virtual ::com::sun::star::uno::Any SAL_CALL getBookmark() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdbcx::XDeleteRows + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdbc::XResultSetUpdate + virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // DBACCESS_CORE_API_WRAPPEDRESULTSET_HXX + diff --git a/dbaccess/source/core/api/makefile.mk b/dbaccess/source/core/api/makefile.mk index df80f0423e14..af520ffec290 100644 --- a/dbaccess/source/core/api/makefile.mk +++ b/dbaccess/source/core/api/makefile.mk @@ -75,6 +75,8 @@ SLOFILES= \ $(SLO)$/HelperCollections.obj \ $(SLO)$/datasettings.obj \ $(SLO)$/View.obj \ + $(SLO)$/WrappedResultSet.obj \ + $(SLO)$/OptimisticSet.obj \ $(SLO)$/columnsettings.obj # --- Targets ---------------------------------- -- cgit From 6d85a9fc4837eee7f451800d5955d18387cb4bf7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 17 Feb 2010 12:45:24 +0100 Subject: dba33f: initially select complete text --- dbaccess/source/ui/dlg/dlgsave.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/dlg/dlgsave.cxx b/dbaccess/source/ui/dlg/dlgsave.cxx index 712dca576efa..24c8d9d3545d 100644 --- a/dbaccess/source/ui/dlg/dlgsave.cxx +++ b/dbaccess/source/ui/dlg/dlgsave.cxx @@ -325,6 +325,7 @@ OSaveAsDlg::OSaveAsDlg( Window * pParent, } else m_pImpl->m_aTitle.SetText(m_pImpl->m_aName); + m_pImpl->m_aTitle.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); m_pImpl->m_aPB_OK.SetPosPixel(Point(m_pImpl->m_aPB_OK.GetPosPixel().X(),aPos.Y())); m_pImpl->m_aPB_CANCEL.SetPosPixel(Point(m_pImpl->m_aPB_CANCEL.GetPosPixel().X(),aPos.Y())); -- cgit From fd8c2dd9780e8b3f4e9d26783f477452ff62a17c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 18 Feb 2010 12:17:18 +0100 Subject: dba33f: #i108311# --- dbaccess/source/core/dataaccess/documentdefinition.cxx | 2 -- 1 file changed, 2 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index 8c3ace1cd15c..b3c8e8f56620 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -1340,8 +1340,6 @@ sal_Bool ODocumentDefinition::save(sal_Bool _bApprove) aRequest.Name = DBACORE_RESSTRING( RID_STR_REPORT ); aRequest.Name = ::dbtools::createUniqueName(xName,aRequest.Name); } - else if ( xName->hasByName(aRequest.Name) ) - aRequest.Name = ::dbtools::createUniqueName(xName,aRequest.Name); aRequest.Content.set(m_xParentContainer,UNO_QUERY); OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest)); -- cgit From ceecd6235c6f1f73fa1fd41cbfa0b6029c563955 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 19 Apr 2010 14:09:15 +0200 Subject: dba33f: build problems .... --- dbaccess/source/core/api/OptimisticSet.cxx | 14 +++++++------- dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index 71de01e4d3b6..a8037df05182 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -457,14 +457,14 @@ void SAL_CALL OptimisticSet::insertRow( const ORowSetRow& _rInsertRow,const conn Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(sQuery.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); // and then the values of the where condition - SelectColumnsMetaData::iterator aIter = m_pKeyColumnNames->begin(); - SelectColumnsMetaData::iterator aEnd = m_pKeyColumnNames->end(); + SelectColumnsMetaData::iterator aKeyCol = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::iterator aKeysEnd = m_pKeyColumnNames->end(); sal_Int32 i = 1; - for(;aIter != aEnd;++aIter) + for(;aKeyCol != aKeysEnd;++aKeyCol) { - if ( aIter->second.sTableName == aSqlIter->first ) + if ( aKeyCol->second.sTableName == aSqlIter->first ) { - setParameter(i++,xParameter,(_rInsertRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale); + setParameter(i++,xParameter,(_rInsertRow->get())[aKeyCol->second.nPosition],aKeyCol->second.nType,aKeyCol->second.nScale); } } Reference xRes = xPrep->executeQuery(); @@ -1549,7 +1549,7 @@ bool OptimisticSet::updateColumnValues(const ORowSetValueVector::Vector& io_aCac bRet = true; SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); - for(sal_Int32 i = 1;aIter != aEnd;++aIter) + for ( ;aIter != aEnd;++aIter ) { if ( aIter->second.sTableName == sTableName ) { @@ -1587,7 +1587,7 @@ bool OptimisticSet::columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow bRet = true; SelectColumnsMetaData::const_iterator aIter2 = m_pColumnNames->begin(); SelectColumnsMetaData::const_iterator aEnd2 = m_pColumnNames->end(); - for(sal_Int32 i = 1;aIter2 != aEnd2;++aIter2) + for ( ;aIter2 != aEnd2;++aIter2 ) { if ( aIter2->second.sTableName == sTableName ) { diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 2ff33d126456..669ceb5ee814 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -379,7 +379,6 @@ void SAL_CALL OSingleSelectQueryComposer::setCommand( const ::rtl::OUString& Com case CommandType::COMMAND: setElementaryQuery(Command); return; - break; case CommandType::TABLE: if ( m_xConnectionTables->hasByName(Command) ) { -- cgit From 1aa7de685dde64da86c44bab9dd78641871763e4 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 22 Apr 2010 16:16:37 +0200 Subject: slidecopy: removed accelerator/*/default.xml - they're not used for a long time now ... (accelerator config is now in Accelerators.xcu in officecfg. No need to confuse people with those dead files) --- dbaccess/prj/d.lst | 38 ---------------------- dbaccess/uiconfig/dbapp/accelerator/de/default.xml | 4 --- .../uiconfig/dbapp/accelerator/en-GB/default.xml | 4 --- .../uiconfig/dbapp/accelerator/en-US/default.xml | 4 --- dbaccess/uiconfig/dbapp/accelerator/es/default.xml | 4 --- dbaccess/uiconfig/dbapp/accelerator/fr/default.xml | 4 --- .../uiconfig/dbbrowser/accelerator/de/default.xml | 4 --- .../dbbrowser/accelerator/en-GB/default.xml | 4 --- .../dbbrowser/accelerator/en-US/default.xml | 4 --- .../uiconfig/dbbrowser/accelerator/es/default.xml | 4 --- .../uiconfig/dbbrowser/accelerator/fr/default.xml | 4 --- .../uiconfig/dbquery/accelerator/de/default.xml | 6 ---- .../uiconfig/dbquery/accelerator/en-US/default.xml | 6 ---- .../uiconfig/dbtdata/accelerator/de/default.xml | 4 --- .../uiconfig/dbtdata/accelerator/en-GB/default.xml | 4 --- .../uiconfig/dbtdata/accelerator/en-US/default.xml | 4 --- .../uiconfig/dbtdata/accelerator/es/default.xml | 4 --- .../uiconfig/dbtdata/accelerator/fr/default.xml | 4 --- 18 files changed, 110 deletions(-) delete mode 100644 dbaccess/uiconfig/dbapp/accelerator/de/default.xml delete mode 100644 dbaccess/uiconfig/dbapp/accelerator/en-GB/default.xml delete mode 100644 dbaccess/uiconfig/dbapp/accelerator/en-US/default.xml delete mode 100644 dbaccess/uiconfig/dbapp/accelerator/es/default.xml delete mode 100644 dbaccess/uiconfig/dbapp/accelerator/fr/default.xml delete mode 100644 dbaccess/uiconfig/dbbrowser/accelerator/de/default.xml delete mode 100644 dbaccess/uiconfig/dbbrowser/accelerator/en-GB/default.xml delete mode 100644 dbaccess/uiconfig/dbbrowser/accelerator/en-US/default.xml delete mode 100644 dbaccess/uiconfig/dbbrowser/accelerator/es/default.xml delete mode 100644 dbaccess/uiconfig/dbbrowser/accelerator/fr/default.xml delete mode 100644 dbaccess/uiconfig/dbquery/accelerator/de/default.xml delete mode 100644 dbaccess/uiconfig/dbquery/accelerator/en-US/default.xml delete mode 100644 dbaccess/uiconfig/dbtdata/accelerator/de/default.xml delete mode 100644 dbaccess/uiconfig/dbtdata/accelerator/en-GB/default.xml delete mode 100644 dbaccess/uiconfig/dbtdata/accelerator/en-US/default.xml delete mode 100644 dbaccess/uiconfig/dbtdata/accelerator/es/default.xml delete mode 100644 dbaccess/uiconfig/dbtdata/accelerator/fr/default.xml (limited to 'dbaccess') diff --git a/dbaccess/prj/d.lst b/dbaccess/prj/d.lst index 46e8f7283477..383cc119c814 100644 --- a/dbaccess/prj/d.lst +++ b/dbaccess/prj/d.lst @@ -6,36 +6,15 @@ mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbquery mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbrelation mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtable -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\de -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\fr -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\en-US -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\en-GB -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\es mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\menubar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\toolbar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\statusbar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\menubar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\toolbar -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\de -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\fr -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\en-GB -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\en-US -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\es mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\menubar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\toolbar -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\de -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\fr -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\en-GB -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\en-US -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\es mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\menubar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\toolbar -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\accelerator -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\accelerator\de -mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\accelerator\en-US mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbrelation\menubar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbrelation\toolbar mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\dbtable\menubar @@ -57,22 +36,7 @@ mkdir: %_DEST%\inc%_EXT%\dbaccess touch: ..\%__SRC%\misc\dbaccess.hid %_DEST%\bin%_EXT%\dba.hid ..\uiconfig\dbapp\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\menubar\*.xml -..\uiconfig\dbapp\accelerator\de\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\de\*.xml -..\uiconfig\dbapp\accelerator\fr\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\fr\*.xml -..\uiconfig\dbapp\accelerator\en-US\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\en-US\*.xml -..\uiconfig\dbapp\accelerator\en-GB\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\en-GB\*.xml -..\uiconfig\dbapp\accelerator\es\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbapp\accelerator\es\*.xml -..\uiconfig\dbbrowser\accelerator\de\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\de\*.xml -..\uiconfig\dbbrowser\accelerator\fr\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\fr\*.xml -..\uiconfig\dbbrowser\accelerator\en-US\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\en-US\*.xml -..\uiconfig\dbbrowser\accelerator\en-GB\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\en-GB\*.xml -..\uiconfig\dbbrowser\accelerator\es\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\accelerator\es\*.xml ..\uiconfig\dbtdata\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\menubar\*.xml -..\uiconfig\dbtdata\accelerator\de\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\de\*.xml -..\uiconfig\dbtdata\accelerator\fr\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\fr\*.xml -..\uiconfig\dbtdata\accelerator\en-US\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\en-US\*.xml -..\uiconfig\dbtdata\accelerator\en-GB\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\en-GB\*.xml -..\uiconfig\dbtdata\accelerator\es\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\accelerator\es\*.xml ..\uiconfig\dbquery\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\menubar\*.xml ..\uiconfig\dbrelation\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbrelation\menubar\*.xml ..\uiconfig\dbtable\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtable\menubar\*.xml @@ -82,8 +46,6 @@ touch: ..\%__SRC%\misc\dbaccess.hid %_DEST%\bin%_EXT%\dba.hid ..\uiconfig\dbbrowser\toolbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbbrowser\toolbar\*.xml ..\uiconfig\dbtdata\toolbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtdata\toolbar\*.xml ..\uiconfig\dbquery\toolbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\toolbar\*.xml -..\uiconfig\dbquery\accelerator\de\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\accelerator\de\*.xml -..\uiconfig\dbquery\accelerator\en-US\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbquery\accelerator\en-US\*.xml ..\uiconfig\dbrelation\toolbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbrelation\toolbar\*.xml ..\uiconfig\dbtable\toolbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\dbtable\toolbar\*.xml ..\inc\*.hxx %_DEST%\inc%_EXT%\dbaccess\*.hxx diff --git a/dbaccess/uiconfig/dbapp/accelerator/de/default.xml b/dbaccess/uiconfig/dbapp/accelerator/de/default.xml deleted file mode 100644 index 0e778428fc18..000000000000 --- a/dbaccess/uiconfig/dbapp/accelerator/de/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbapp/accelerator/en-GB/default.xml b/dbaccess/uiconfig/dbapp/accelerator/en-GB/default.xml deleted file mode 100644 index 0e778428fc18..000000000000 --- a/dbaccess/uiconfig/dbapp/accelerator/en-GB/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbapp/accelerator/en-US/default.xml b/dbaccess/uiconfig/dbapp/accelerator/en-US/default.xml deleted file mode 100644 index 0e778428fc18..000000000000 --- a/dbaccess/uiconfig/dbapp/accelerator/en-US/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbapp/accelerator/es/default.xml b/dbaccess/uiconfig/dbapp/accelerator/es/default.xml deleted file mode 100644 index 0e778428fc18..000000000000 --- a/dbaccess/uiconfig/dbapp/accelerator/es/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbapp/accelerator/fr/default.xml b/dbaccess/uiconfig/dbapp/accelerator/fr/default.xml deleted file mode 100644 index 0e778428fc18..000000000000 --- a/dbaccess/uiconfig/dbapp/accelerator/fr/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbbrowser/accelerator/de/default.xml b/dbaccess/uiconfig/dbbrowser/accelerator/de/default.xml deleted file mode 100644 index b5c914f0ea74..000000000000 --- a/dbaccess/uiconfig/dbbrowser/accelerator/de/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbbrowser/accelerator/en-GB/default.xml b/dbaccess/uiconfig/dbbrowser/accelerator/en-GB/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbbrowser/accelerator/en-GB/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbbrowser/accelerator/en-US/default.xml b/dbaccess/uiconfig/dbbrowser/accelerator/en-US/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbbrowser/accelerator/en-US/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbbrowser/accelerator/es/default.xml b/dbaccess/uiconfig/dbbrowser/accelerator/es/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbbrowser/accelerator/es/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbbrowser/accelerator/fr/default.xml b/dbaccess/uiconfig/dbbrowser/accelerator/fr/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbbrowser/accelerator/fr/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbquery/accelerator/de/default.xml b/dbaccess/uiconfig/dbquery/accelerator/de/default.xml deleted file mode 100644 index d5d2dd7d5b28..000000000000 --- a/dbaccess/uiconfig/dbquery/accelerator/de/default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/dbaccess/uiconfig/dbquery/accelerator/en-US/default.xml b/dbaccess/uiconfig/dbquery/accelerator/en-US/default.xml deleted file mode 100644 index d5d2dd7d5b28..000000000000 --- a/dbaccess/uiconfig/dbquery/accelerator/en-US/default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/dbaccess/uiconfig/dbtdata/accelerator/de/default.xml b/dbaccess/uiconfig/dbtdata/accelerator/de/default.xml deleted file mode 100644 index b5c914f0ea74..000000000000 --- a/dbaccess/uiconfig/dbtdata/accelerator/de/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbtdata/accelerator/en-GB/default.xml b/dbaccess/uiconfig/dbtdata/accelerator/en-GB/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbtdata/accelerator/en-GB/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbtdata/accelerator/en-US/default.xml b/dbaccess/uiconfig/dbtdata/accelerator/en-US/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbtdata/accelerator/en-US/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbtdata/accelerator/es/default.xml b/dbaccess/uiconfig/dbtdata/accelerator/es/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbtdata/accelerator/es/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dbaccess/uiconfig/dbtdata/accelerator/fr/default.xml b/dbaccess/uiconfig/dbtdata/accelerator/fr/default.xml deleted file mode 100644 index 7b5b2bf22a6d..000000000000 --- a/dbaccess/uiconfig/dbtdata/accelerator/fr/default.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - -- cgit From 3f4c0ab3ae9035d3c7cb09c7258f4c8d30b4db8a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 25 May 2010 10:17:24 +0200 Subject: unoawt: completely separated the controller functionality of a wizard page from the wizard page itself, by moving the canAdvance method from OWizardPage to the IWizardPage interface, which in this course has been renamed to IWizardPageController. This will later on allow to have implementations where the TabPage is provided by an external component (e.g. as UNO Service), but the controlling of those pages is still intercepted and handled internally. --- dbaccess/source/ext/macromigration/macromigrationpages.cxx | 4 ++-- dbaccess/source/ext/macromigration/macromigrationpages.hxx | 9 ++++----- dbaccess/source/ui/dlg/ConnectionPageSetup.cxx | 2 +- dbaccess/source/ui/dlg/ConnectionPageSetup.hxx | 2 +- dbaccess/source/ui/dlg/adminpages.cxx | 7 ++++++- dbaccess/source/ui/dlg/adminpages.hxx | 8 +++++--- dbaccess/source/ui/dlg/dbwiz.cxx | 2 +- dbaccess/source/ui/dlg/dbwizsetup.cxx | 2 +- dbaccess/source/ui/inc/dbwiz.hxx | 5 +++-- dbaccess/source/ui/inc/dbwizsetup.hxx | 2 +- 10 files changed, 25 insertions(+), 18 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.cxx b/dbaccess/source/ext/macromigration/macromigrationpages.cxx index 4e35663c5a81..c2bd3986e27a 100644 --- a/dbaccess/source/ext/macromigration/macromigrationpages.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationpages.cxx @@ -188,12 +188,12 @@ namespace dbmm } //-------------------------------------------------------------------- - sal_Bool SaveDBDocPage::commitPage( CommitPageReason _eReason ) + sal_Bool SaveDBDocPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) { if ( !MacroMigrationPage::commitPage( _eReason ) ) return sal_False; - if ( eTravelBackward == _eReason ) + if ( ::svt::WizardTypes::eTravelBackward == _eReason ) return sal_True; if ( !m_aLocationController.prepareCommit() ) diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.hxx b/dbaccess/source/ext/macromigration/macromigrationpages.hxx index 550e134e6db3..8c269982999d 100644 --- a/dbaccess/source/ext/macromigration/macromigrationpages.hxx +++ b/dbaccess/source/ext/macromigration/macromigrationpages.hxx @@ -109,11 +109,10 @@ namespace dbmm m_aLocationController; protected: - // OWizardPage overridables - virtual void initializePage(); - virtual bool canAdvance() const; - // IWizardPage overridables - virtual sal_Bool commitPage( CommitPageReason _eReason ); + // IWizardPageController overridables + virtual void initializePage(); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); + virtual bool canAdvance() const; private: DECL_LINK( OnLocationModified, Edit* ); diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx index 367d95a2ed23..f53054d37339 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx @@ -289,7 +289,7 @@ namespace dbaui callModifiedHdl(); } // ----------------------------------------------------------------------- - sal_Bool OConnectionTabPageSetup::commitPage( CommitPageReason /*_eReason*/ ) + sal_Bool OConnectionTabPageSetup::commitPage( ::svt::WizardTypes::CommitPageReason /*_eReason*/ ) { return commitURL(); } diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx index 2a4380f0c70b..79a16c880c54 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx @@ -89,7 +89,7 @@ namespace dbaui virtual BOOL FillItemSet (SfxItemSet& _rCoreAttrs); virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); inline void enableConnectionURL() { m_aConnectionURL.SetReadOnly(sal_False); } diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx index bf4b691cac55..f363b5bc2fb3 100644 --- a/dbaccess/source/ui/dlg/adminpages.cxx +++ b/dbaccess/source/ui/dlg/adminpages.cxx @@ -201,11 +201,16 @@ namespace dbaui Reset(*m_pItemSetHelper->getOutputSet()); } // ----------------------------------------------------------------------- - sal_Bool OGenericAdministrationPage::commitPage( CommitPageReason ) + sal_Bool OGenericAdministrationPage::commitPage( ::svt::WizardTypes::CommitPageReason ) { return sal_True; } // ----------------------------------------------------------------------- + bool OGenericAdministrationPage::canAdvance() const + { + return true; + } + // ----------------------------------------------------------------------- void OGenericAdministrationPage::fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, USHORT _nID, sal_Bool& _bChangedSomething, bool _bRevertValue ) { if ( (_pCheckBox != NULL ) && ( _pCheckBox->GetState() != _pCheckBox->GetSavedValue() ) ) diff --git a/dbaccess/source/ui/dlg/adminpages.hxx b/dbaccess/source/ui/dlg/adminpages.hxx index 20bb0ea688cc..32ba0064a824 100644 --- a/dbaccess/source/ui/dlg/adminpages.hxx +++ b/dbaccess/source/ui/dlg/adminpages.hxx @@ -113,7 +113,8 @@ namespace dbaui //========================================================================= class IDatabaseSettingsDialog; class IItemSetHelper; - class OGenericAdministrationPage : public SfxTabPage, public svt::IWizardPage + class OGenericAdministrationPage :public SfxTabPage + ,public ::svt::IWizardPageController { private: Link m_aModifiedHandler; /// to be called if something on the page has been modified @@ -165,9 +166,10 @@ namespace dbaui */ sal_Bool getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr); - // svt::IWizardPage + // svt::IWizardPageController virtual void initializePage(); - virtual sal_Bool commitPage( CommitPageReason _eReason ); + virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ); + virtual bool canAdvance() const; void SetRoadmapStateValue( sal_Bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; } bool GetRoadmapStateValue() const { return m_abEnableRoadmap; } diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index cdecbd295df6..e6f9c2024212 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -405,7 +405,7 @@ sal_Bool ODbTypeWizDialog::saveDatasource() return sal_True; } // ----------------------------------------------------------------------------- -IWizardPage* ODbTypeWizDialog::getWizardPage(TabPage* _pCurrentPage) const +IWizardPageController* ODbTypeWizDialog::getPageController( TabPage* _pCurrentPage ) const { OGenericAdministrationPage* pPage = static_cast(_pCurrentPage); return pPage; diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 5a601bd56c92..3be4b8d663cc 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -1078,7 +1078,7 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() return aExistenceCheck.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); } // ----------------------------------------------------------------------------- - IWizardPage* ODbTypeWizDialogSetup::getWizardPage(TabPage* _pCurrentPage) const + IWizardPageController* ODbTypeWizDialogSetup::getPageController( TabPage* _pCurrentPage ) const { OGenericAdministrationPage* pPage = static_cast(_pCurrentPage); return pPage; diff --git a/dbaccess/source/ui/inc/dbwiz.hxx b/dbaccess/source/ui/inc/dbwiz.hxx index 3f36739fc08c..8b1852031776 100644 --- a/dbaccess/source/ui/inc/dbwiz.hxx +++ b/dbaccess/source/ui/inc/dbwiz.hxx @@ -111,8 +111,9 @@ protected: virtual TabPage* createPage(WizardState _nState); virtual WizardState determineNextState(WizardState _nCurrentState) const; virtual sal_Bool leaveState(WizardState _nState); - virtual ::svt::IWizardPage* getWizardPage(TabPage* _pCurrentPage) const; - virtual sal_Bool onFinish(sal_Int32 _nResult); + virtual ::svt::IWizardPageController* + getPageController( TabPage* _pCurrentPage ) const; + virtual sal_Bool onFinish(sal_Int32 _nResult); protected: inline sal_Bool isUIEnabled() const { return m_bUIEnabled; } diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx b/dbaccess/source/ui/inc/dbwizsetup.hxx index 0fcdd989a850..31ff642bf0d9 100644 --- a/dbaccess/source/ui/inc/dbwizsetup.hxx +++ b/dbaccess/source/ui/inc/dbwizsetup.hxx @@ -149,7 +149,7 @@ protected: virtual TabPage* createPage(WizardState _nState); virtual sal_Bool leaveState(WizardState _nState); virtual void enterState(WizardState _nState); - virtual ::svt::IWizardPage* getWizardPage(TabPage* _pCurrentPage) const; + virtual ::svt::IWizardPageController* getPageController( TabPage* _pCurrentPage ) const; virtual sal_Bool onFinish(sal_Int32 _nResult); protected: -- cgit From 6d599d17f761fbe7be3c84e02d8b24f0978051c8 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 25 May 2010 11:43:39 +0200 Subject: unoawt: onFinish does not need this parameter, it's always called with RET_OK --- dbaccess/source/ext/macromigration/macromigrationdialog.cxx | 4 ++-- dbaccess/source/ext/macromigration/macromigrationdialog.hxx | 2 +- dbaccess/source/ui/dlg/dbwiz.cxx | 4 ++-- dbaccess/source/ui/dlg/dbwizsetup.cxx | 8 ++++---- dbaccess/source/ui/inc/dbwiz.hxx | 2 +- dbaccess/source/ui/inc/dbwizsetup.hxx | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx index 53bcfb581d91..5ee29ff5d35f 100644 --- a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx @@ -314,9 +314,9 @@ namespace dbmm } //-------------------------------------------------------------------- - sal_Bool MacroMigrationDialog::onFinish( sal_Int32 _nResult ) + sal_Bool MacroMigrationDialog::onFinish() { - return MacroMigrationDialog_Base::onFinish( _nResult ); + return MacroMigrationDialog_Base::onFinish(); } //-------------------------------------------------------------------- diff --git a/dbaccess/source/ext/macromigration/macromigrationdialog.hxx b/dbaccess/source/ext/macromigration/macromigrationdialog.hxx index 68137db3eb80..d2af622316da 100644 --- a/dbaccess/source/ext/macromigration/macromigrationdialog.hxx +++ b/dbaccess/source/ext/macromigration/macromigrationdialog.hxx @@ -68,7 +68,7 @@ namespace dbmm virtual sal_Bool prepareLeaveCurrentState( CommitPageReason _eReason ); virtual sal_Bool leaveState( WizardState _nState ); virtual WizardState determineNextState( WizardState _nCurrentState ) const; - virtual sal_Bool onFinish( sal_Int32 _nResult ); + virtual sal_Bool onFinish(); // Dialog overridables virtual BOOL Close(); diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index e6f9c2024212..7fcf2ae8429d 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -411,10 +411,10 @@ IWizardPageController* ODbTypeWizDialog::getPageController( TabPage* _pCurrentPa return pPage; } // ----------------------------------------------------------------------------- -sal_Bool ODbTypeWizDialog::onFinish(sal_Int32 _nResult) +sal_Bool ODbTypeWizDialog::onFinish() { saveDatasource(); - return m_pImpl->saveChanges(*m_pOutSet) ? OWizardMachine::onFinish(_nResult) : sal_False; + return m_pImpl->saveChanges(*m_pOutSet) ? OWizardMachine::onFinish() : sal_False; } //......................................................................... } // namespace dbaui diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 3be4b8d663cc..b09c691864a3 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -789,7 +789,7 @@ IMPL_LINK(ODbTypeWizDialogSetup, OnRecentDocumentSelected, OGeneralPage*, /*_pGe IMPL_LINK(ODbTypeWizDialogSetup, OnSingleDocumentChosen, OGeneralPage*, /*_pGeneralPage*/) { if ( prepareLeaveCurrentState( eFinish ) ) - onFinish( RET_OK ); + onFinish(); return 0L; } @@ -1206,7 +1206,7 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() } // ----------------------------------------------------------------------------- - sal_Bool ODbTypeWizDialogSetup::onFinish(sal_Int32 _nResult) + sal_Bool ODbTypeWizDialogSetup::onFinish() { if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting ) { @@ -1214,7 +1214,7 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() // wants us to load could be a non-database document. Instead, we asynchronously // open the selected document. Thus, the wizard's return value is RET_CANCEL, // which means to not continue loading the database document - if ( !OWizardMachine::onFinish( RET_CANCEL ) ) + if ( !OWizardMachine::Finnish( RET_CANCEL ) ) return sal_False; Reference< XComponentLoader > xFrameLoader; @@ -1237,7 +1237,7 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() skipUntil(PAGE_DBSETUPWIZARD_FINAL); } if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL) - return SaveDatabaseDocument() ? OWizardMachine::onFinish( _nResult ) : sal_False; + return SaveDatabaseDocument() ? OWizardMachine::onFinish() : sal_False; else { enableButtons( WZB_FINISH, sal_False ); diff --git a/dbaccess/source/ui/inc/dbwiz.hxx b/dbaccess/source/ui/inc/dbwiz.hxx index 8b1852031776..94b3fd683336 100644 --- a/dbaccess/source/ui/inc/dbwiz.hxx +++ b/dbaccess/source/ui/inc/dbwiz.hxx @@ -113,7 +113,7 @@ protected: virtual sal_Bool leaveState(WizardState _nState); virtual ::svt::IWizardPageController* getPageController( TabPage* _pCurrentPage ) const; - virtual sal_Bool onFinish(sal_Int32 _nResult); + virtual sal_Bool onFinish(); protected: inline sal_Bool isUIEnabled() const { return m_bUIEnabled; } diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx b/dbaccess/source/ui/inc/dbwizsetup.hxx index 31ff642bf0d9..039fc64392de 100644 --- a/dbaccess/source/ui/inc/dbwizsetup.hxx +++ b/dbaccess/source/ui/inc/dbwizsetup.hxx @@ -150,7 +150,7 @@ protected: virtual sal_Bool leaveState(WizardState _nState); virtual void enterState(WizardState _nState); virtual ::svt::IWizardPageController* getPageController( TabPage* _pCurrentPage ) const; - virtual sal_Bool onFinish(sal_Int32 _nResult); + virtual sal_Bool onFinish(); protected: inline sal_Bool isUIEnabled() const { return m_bUIEnabled; } -- cgit From 4f7454a8da771afac145bb02c7682978b275c950 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Tue, 1 Jun 2010 08:19:45 +0200 Subject: dba33f: #i111949# move resultset to beforeFirst --- dbaccess/source/core/api/RowSetCache.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 82f0729500e1..cf24f563773c 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -170,6 +170,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, catch(const Exception&) { } + _xRs->beforeFirst(); // check if all keys of the updateable table are fetched sal_Bool bAllKeysFound = sal_False; -- cgit From c4bc203f2f9c639a2f7d01252d89a77efcf3db6c Mon Sep 17 00:00:00 2001 From: Release Engineering Date: Mon, 7 Jun 2010 14:10:31 +0200 Subject: masterfix: #i10000# build issue --- dbaccess/source/core/api/KeySet.cxx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 252083f2d084..9c7fdb4bbdd4 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -2,7 +2,7 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2000, 2010 Oracle andor its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * @@ -349,18 +349,6 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i]; } - - // locate parameter in select columns - Reference xParaSup(m_xComposer,UNO_QUERY); - Reference xQueryParameters = xParaSup->getParameters(); - const sal_Int32 nParaCount = xQueryParameters->getCount(); - Sequence< ::rtl::OUString> aParameterColumns(nParaCount); - for(sal_Int32 i = 0; i< nParaCount;++i) - { - Reference xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW); - xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i]; - } - ::rtl::OUString sCatalog,sSchema,sTable; Reference xTableProp(m_xTable,UNO_QUERY); -- cgit From fde2f6a6f3cb19c999846b02d5dbc4b9d392b3a1 Mon Sep 17 00:00:00 2001 From: Release Engineering Date: Mon, 7 Jun 2010 14:10:58 +0200 Subject: masterfix: #i10000# build issue --- dbaccess/source/core/api/OptimisticSet.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index a8037df05182..23a83d3df67a 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -179,7 +179,7 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const :: // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first // without extra variable to be set - m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,0))); + m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair >(0,NULL)))); m_aKeyIter = m_aKeyMap.begin(); static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); @@ -619,7 +619,7 @@ void OptimisticSet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OU ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size()); copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1); - m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,1))).first; + m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,::std::pair >(1,NULL)))).first; // now we set the bookmark for this row (_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first); } @@ -1005,7 +1005,7 @@ sal_Bool OptimisticSet::fetchRow() const SelectColumnDescription& rColDesc = aPosIter->second; aIter->fill(rColDesc.nPosition,rColDesc.nType,rColDesc.bNullable,m_xDriverRow); } - m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(m_aKeyMap.rbegin()->first+1,OKeySetValue(aKeyRow,0))).first; + m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(m_aKeyMap.rbegin()->first+1,OKeySetValue(aKeyRow,::std::pair >(0,NULL)))).first; } else m_bRowCountFinal = sal_True; @@ -1164,13 +1164,13 @@ Reference< XArray > SAL_CALL OptimisticSet::getArray( sal_Int32 columnIndex ) th sal_Bool SAL_CALL OptimisticSet::rowUpdated( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowUpdated" ); - return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second == 2; + return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 2; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OptimisticSet::rowInserted( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowInserted" ); - return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second == 1; + return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 1; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OptimisticSet::rowDeleted( ) throw(SQLException, RuntimeException) @@ -1404,7 +1404,7 @@ void OptimisticSet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRo { const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny()); m_aKeyIter = m_aKeyMap.find(nBookmark); - m_aKeyIter->second.second = 2; + m_aKeyIter->second.second.first = 2; copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark); } } @@ -1480,7 +1480,7 @@ void OptimisticSet::reset(const Reference< XResultSet>& _xDriverSet) OCacheSet::construct(_xDriverSet,::rtl::OUString()); m_bRowCountFinal = sal_False; m_aKeyMap.clear(); - m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,0))); + m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair >(0,NULL)))); m_aKeyIter = m_aKeyMap.begin(); } // ----------------------------------------------------------------------------- -- cgit