diff options
author | Frank Schönheit <fs@openoffice.org> | 2001-07-17 12:07:48 +0000 |
---|---|---|
committer | Frank Schönheit <fs@openoffice.org> | 2001-07-17 12:07:48 +0000 |
commit | bf9d43924d5cf5e78c006878c5545b50a2b1d8e4 (patch) | |
tree | f8061ebc894783d762fa32f1ac9d27cc96ed6c84 /dbaccess/source | |
parent | f9dd048fcf8b091011c08f11e59acf9bbc5d6bda (diff) |
#87937# changes so that after unsuccessfull reloading (or setting a filter or such) a cleanup can be done
Diffstat (limited to 'dbaccess/source')
-rw-r--r-- | dbaccess/source/ui/browser/brwctrlr.cxx | 313 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/exsrcbrw.cxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 36 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/brwctrlr.hxx | 27 |
4 files changed, 189 insertions, 195 deletions
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 69fbab508bac..4542a60a05a1 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: brwctrlr.cxx,v $ * - * $Revision: 1.42 $ + * $Revision: 1.43 $ * - * last change: $Author: fs $ $Date: 2001-07-16 14:38:54 $ + * last change: $Author: fs $ $Date: 2001-07-17 13:05:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -602,6 +602,22 @@ void SAL_CALL SbaXDataBrowserController::attachFrame(const Reference< ::com::sun } // ----------------------------------------------------------------------------- +sal_Bool SbaXDataBrowserController::reloadForm(const Reference< XLoadable >& _rxLoadable) +{ + WaitObject aWO(getBrowserView()); + + m_bLoadCanceled = sal_False; + + FormErrorHelper aReportError(this); + if (_rxLoadable->isLoaded()) + _rxLoadable->reload(); + else + _rxLoadable->load(); + + return _rxLoadable->isLoaded() && !errorOccured(); +} + +// ----------------------------------------------------------------------------- void SbaXDataBrowserController::initFormatter() { // --------------------------------------------------------------- @@ -738,33 +754,20 @@ sal_Bool SbaXDataBrowserController::Construct(Window* pParent) //------------------------------------------------------------------------------ sal_Bool SbaXDataBrowserController::LoadForm() { - Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - sal_Bool bThreadSafe(sal_False); - try - { - if(xFormSet->getPropertySetInfo()->hasPropertyByName(PROPERTY_THREADSAFE)) - bThreadSafe = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_THREADSAFE)); - } - catch(Exception&) - { - } - - - m_bLoadCanceled = sal_False; - if (bThreadSafe) - { // load in an own thread so the office doesn't block meanwhile - m_pLoadThread = new LoadFormThread(getRowSet(), m_sLoadStopperCaption); - ((LoadFormThread*)m_pLoadThread)->SetTerminationHdl(LINK(this, SbaXDataBrowserController, OnOpenFinished)); - m_pLoadThread->create(); - - InvalidateAll(); - } - else - { - Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(),UNO_QUERY); - xLoadable->load(); - FormLoaded(sal_True); - } +// sal_Bool bThreadSafe(sal_False); +// if (bThreadSafe) +// { // load in an own thread so the office doesn't block meanwhile +// m_pLoadThread = new LoadFormThread(getRowSet(), m_sLoadStopperCaption); +// ((LoadFormThread*)m_pLoadThread)->SetTerminationHdl(LINK(this, SbaXDataBrowserController, OnOpenFinished)); +// m_pLoadThread->create(); +// +// InvalidateAll(); +// return sal_True; +// } + + Reference< XLoadable > xLoadable(getRowSet(),UNO_QUERY); + xLoadable->load(); + LoadFinished(sal_True); return sal_True; } //------------------------------------------------------------------------------ @@ -1541,7 +1544,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) if (!bInsertAllowedAndPossible && !bUpdateAllowedAndPossible && !bDeleteAllowedAndPossible) break; // no insert/update/delete -> no edit mode - if (!isValidCursor()) + if (!isValidCursor() || !isLoaded()) break; // no cursor -> no edit mode aReturn.bEnabled = sal_True; @@ -1586,6 +1589,92 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) } //------------------------------------------------------------------------------ +void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrder) +{ + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + Reference< XLoadable > xLoadable(getRowSet(), UNO_QUERY); + + if (!xLoadable.is()) + { + OSL_ENSURE(sal_False, "SbaXDataBrowserController::applyParserOrder: invalid row set!"); + return; + } + + sal_Bool bSuccess = sal_False; + try + { + xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(m_xParser->getOrder())); + bSuccess = reloadForm(xLoadable); + } + catch(Exception&) + { + } + + 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 !" ); + + try + { + if (m_bLoadCanceled || !reloadForm(xLoadable)) + criticalFail(); + } + catch(Exception&) + { + criticalFail(); + } + InvalidateAll(); + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied) +{ + Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); + Reference< XLoadable > xLoadable(getRowSet(), UNO_QUERY); + + if (!xLoadable.is()) + { + OSL_ENSURE(sal_False, "SbaXDataBrowserController::applyParserFilter: invalid row set!"); + return; + } + + sal_Bool bSuccess = sal_False; + try + { + FormErrorHelper aError(this); + xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(m_xParser->getFilter())); + xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True))); + + bSuccess = reloadForm(xLoadable); + } + catch(Exception&) + { + } + + if (!bSuccess) + { + xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_rOldFilter)); + xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(_bOldFilterApplied)); + DO_SAFE( m_xParser->setFilter(_rOldFilter), "SbaXDataBrowserController::applyParserFilter: could not restore the old filter of my parser !" ); + + try + { + if (m_bLoadCanceled || !reloadForm(xLoadable)) + criticalFail(); + } + catch(Exception&) + { + criticalFail(); + } + InvalidateAll(); + } + InvalidateFeature(ID_BROWSER_REMOVEFILTER); +} + +//------------------------------------------------------------------------------ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) { if (!SaveModified()) @@ -1642,7 +1731,6 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) { return; } - ; ::rtl::OUString sNewVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder(); sal_Bool bOldFilterApplied(sal_False); @@ -1655,60 +1743,10 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) // nothing to be done return; - { - WaitObject aWO(getBrowserView()); - try - { - if (bFilter) - { - xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(m_xParser->getFilter())); - xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True))); - } - else - xFormSet->setPropertyValue(PROPERTY_ORDER,makeAny( m_xParser->getOrder())); - - Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); - FormErrorHelper aReportError(this); - if (xReload->isLoaded()) - xReload->reload(); - else - xReload->load(); - } - catch(Exception&) - { - } - } - - if (errorOccured()) - { - // synchronize the parser with the form - Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - if (bFilter) - { - xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(sOldVal)); - xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(bOldFilterApplied)); - DO_SAFE( m_xParser->setFilter(sOldVal), "SbaXDataBrowserController::ExecuteFilterSortCrit : could not restore the old filter of my parser !" ); - } - else - { - xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(sOldVal)); - DO_SAFE( m_xParser->setOrder(sOldVal), "SbaXDataBrowserController::ExecuteFilterSortCrit : could not restore the old order of my parser !" ); - } - - try - { - Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); - if (xReload->isLoaded()) - xReload->reload(); - else - xReload->load(); - } - catch(Exception&) - { - } - InvalidateAll(); - } - InvalidateFeature(ID_BROWSER_REMOVEFILTER); + if (bFilter) + applyParserFilter(sOldVal, bOldFilterApplied); + else + applyParserOrder(sOldVal); } //------------------------------------------------------------------------------ @@ -1772,11 +1810,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId) Reference< XPropertySet > xActiveSet(getRowSet(), UNO_QUERY); sal_Bool bApplied = ::comphelper::getBOOL(xActiveSet->getPropertyValue(PROPERTY_APPLYFILTER)); xActiveSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(!bApplied))); - Reference< ::com::sun::star::form::XLoadable > xReload(xActiveSet, UNO_QUERY); - { - WaitObject aWO(getBrowserView()); - xReload->reload(); - } + reloadForm(Reference< XLoadable >(xActiveSet, UNO_QUERY)); } InvalidateFeature(ID_BROWSER_FILTERED); break; @@ -1860,41 +1894,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId) ) if (bParserSuccess) - { - WaitObject aWO(getBrowserView()); - try - { - Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(m_xParser->getOrder())); - - Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); - FormErrorHelper aReportError(this); - xReload->reload(); - } - catch(Exception&) - { - } - } - if (errorOccured()) - { - // synchronize the parser with the form - Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(sOldSort)); - m_xParser->setOrder(sOldSort); - - try - { - Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); - if (xReload->isLoaded()) - xReload->reload(); - else - xReload->load(); - } - catch(Exception&) - { - } - } - InvalidateFeature(ID_BROWSER_REMOVEFILTER); + applyParserOrder(sOldSort); } break; @@ -1930,41 +1930,8 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId) ) if (bParserSuccess) - { - WaitObject aWO(getBrowserView()); - try - { - Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(m_xParser->getFilter())); - xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True))); - - Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); - FormErrorHelper aReportError(this); - xReload->reload(); - } - catch(Exception&) - { - } - ; - } - if (errorOccured()) - { - // synchronize the parser with the form - Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(sOldFilter)); - xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, makeAny(bApplied)); - m_xParser->setFilter(sOldFilter); + applyParserFilter(sOldFilter, bApplied); - try - { - Reference< ::com::sun::star::form::XLoadable > xReload(xFormSet, UNO_QUERY); - xReload->reload(); - } - catch(Exception&) - { - } - ; - } InvalidateFeature(ID_BROWSER_REMOVEFILTER); InvalidateFeature(ID_BROWSER_FILTERED); } @@ -1993,13 +1960,11 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId) WaitObject aWO(getBrowserView()); try { - Reference< ::com::sun::star::form::XLoadable > xReload(getRowSet(), UNO_QUERY); - xReload->reload(); + reloadForm(Reference< XLoadable >(getRowSet(), UNO_QUERY)); } catch(Exception&) { } - ; } InvalidateFeature(ID_BROWSER_REMOVEFILTER); InvalidateFeature(ID_BROWSER_FILTERED); @@ -2008,11 +1973,8 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId) case ID_BROWSER_REFRESH: if (SaveData(sal_True, sal_False)) - { - Reference< ::com::sun::star::form::XLoadable > xReload(getRowSet(), UNO_QUERY); - WaitObject aWO(getBrowserView()); - xReload->reload(); - } + if (!reloadForm(Reference< XLoadable >(getRowSet(), UNO_QUERY))) + criticalFail(); break; case ID_BROWSER_SAVEDOC: @@ -2326,7 +2288,7 @@ IMPL_LINK(SbaXDataBrowserController, OnOpenFinishedMainThread, void*, EMPTYARG) delete m_pLoadThread; m_pLoadThread = NULL; - FormLoaded(sal_False); + LoadFinished(sal_False); return 0L; } @@ -2374,7 +2336,13 @@ IMPL_LINK(SbaXDataBrowserController, OnAsyncGetCellFocus, void*, EMPTYARG) } //------------------------------------------------------------------------------ -void SbaXDataBrowserController::FormLoaded(sal_Bool /*bWasSynch*/) +void SbaXDataBrowserController::criticalFail() +{ + InvalidateAll(); +} + +//------------------------------------------------------------------------------ +void SbaXDataBrowserController::LoadFinished(sal_Bool /*bWasSynch*/) { if (isValid() && !m_bLoadCanceled) { @@ -2478,6 +2446,13 @@ void SbaXDataBrowserController::leaveFormAction() } // ------------------------------------------------------------------------- +sal_Bool SbaXDataBrowserController::isLoaded() const +{ + Reference< XLoadable > xLoad(m_xRowSet, UNO_QUERY); + return xLoad.is() && xLoad->isLoaded(); +} + +// ------------------------------------------------------------------------- sal_Bool SbaXDataBrowserController::isValidCursor() const { Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(m_xRowSet, UNO_QUERY); diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx index a58fdc1b561e..ea43996a0b5c 100644 --- a/dbaccess/source/ui/browser/exsrcbrw.cxx +++ b/dbaccess/source/ui/browser/exsrcbrw.cxx @@ -2,9 +2,9 @@ * * $RCSfile: exsrcbrw.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: fs $ $Date: 2001-05-16 14:28:02 $ + * last change: $Author: fs $ $Date: 2001-07-17 13:07:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -259,7 +259,7 @@ void SAL_CALL SbaExternalSourceBrowser::dispatch(const ::com::sun::star::util::U { OSL_ENSURE(sal_False, ( ByteString("SbaExternalSourceBrowser::dispatch : could not set a column property (") - += ByteString(pControlProps->Name.getStr(), pControlProps->Name.getLength(), RTL_TEXTENCODING_ASCII_US) + += ByteString(pControlProps->Name.getStr(), (sal_uInt16)pControlProps->Name.getLength(), RTL_TEXTENCODING_ASCII_US) += ByteString(")!")).GetBuffer()); } } @@ -446,7 +446,7 @@ void SbaExternalSourceBrowser::Attach(const Reference< XRowSet > & xMaster) initFormatter(); // assume that the master form is already loaded, we have no chance to check this m_bLoadCanceled = sal_False; - FormLoaded(sal_True); + LoadFinished(sal_True); Reference< XResultSetUpdate > xUpdate(xMaster, UNO_QUERY); try diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 1d185d8d47d1..0991032c0f78 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unodatbr.cxx,v $ * - * $Revision: 1.90 $ + * $Revision: 1.91 $ * - * last change: $Author: oj $ $Date: 2001-07-17 11:36:27 $ + * last change: $Author: fs $ $Date: 2001-07-17 13:06:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1385,9 +1385,16 @@ void SbaTableQueryBrowser::RemoveColumnListener(const Reference< XPropertySet > } //------------------------------------------------------------------------------ -void SbaTableQueryBrowser::FormLoaded(sal_Bool _bWasSynch) +void SbaTableQueryBrowser::criticalFail() { - SbaXDataBrowserController::FormLoaded(_bWasSynch); + SbaXDataBrowserController::criticalFail(); + unloadAndCleanup(sal_False, sal_False); +} + +//------------------------------------------------------------------------------ +void SbaTableQueryBrowser::LoadFinished(sal_Bool _bWasSynch) +{ + SbaXDataBrowserController::LoadFinished(_bWasSynch); // if the form has been loaded, this means that our "selection" has changed ::com::sun::star::lang::EventObject aEvt(*this); @@ -1435,6 +1442,9 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) return aReturn; } + if (!isLoaded()) + return aReturn; + try { sal_Bool bHandled = sal_False; @@ -2160,20 +2170,13 @@ sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSou { FormErrorHelper aHelper(this); - // load the row set - m_bLoadCanceled = sal_False; - if (xLoadable->isLoaded()) - // reload does not work if not already loaded - xLoadable->reload(); - else - xLoadable->load(); + // load the form + bSuccess = reloadForm(xLoadable); // initialize the model InitializeGridModel(getFormComponent()); - FormLoaded(sal_True); - - bSuccess = xLoadable->isLoaded() && !errorOccured(); + LoadFinished(sal_True); } return bSuccess; @@ -2396,9 +2399,8 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry) // set the title of the beamer setTitle(sDataSourceName,aName); else - { - // clean up - unloadAndCleanup(sal_False, sal_False); + { // clean up + criticalFail(); } } catch(SQLException& e) diff --git a/dbaccess/source/ui/inc/brwctrlr.hxx b/dbaccess/source/ui/inc/brwctrlr.hxx index f9007f863ed0..09b3c99e32e9 100644 --- a/dbaccess/source/ui/inc/brwctrlr.hxx +++ b/dbaccess/source/ui/inc/brwctrlr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: brwctrlr.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: fs $ $Date: 2001-07-16 14:36:59 $ + * last change: $Author: fs $ $Date: 2001-07-17 13:03:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,9 @@ #ifndef _SBA_GRID_HXX #include "sbagrid.hxx" #endif +#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ +#include <com/sun/star/form/XLoadable.hpp> +#endif #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ #include <com/sun/star/container/XContainerListener.hpp> #endif @@ -212,6 +215,7 @@ namespace dbaui sal_Bool isValid() const { return m_xRowSet.is() && m_xGridModel.is(); } sal_Bool isValidCursor() const; // checks the ::com::sun::star::data::XDatabaseCursor-interface of m_xRowSet + sal_Bool isLoaded() const; protected: ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > getParser() const { return m_xParser; } @@ -356,11 +360,17 @@ namespace dbaui // load the form // the default implementation does an direct load or starts a load thread, depending on the multithread capabilities // of the data source. - // the default implementation also calls FormLoaded after a syncronous load, so be sure to do the same if you override + // the default implementation also calls LoadFinished after a syncronous load, so be sure to do the same if you override // this metod and don't call the base class' method - virtual void FormLoaded(sal_Bool bWasSynch); - // called if the loading is done (no matter if synchron or asynchron). + virtual void LoadFinished(sal_Bool bWasSynch); + // called if the loading (the _complete_ loading process) is done (no matter if synchron or asynchron). + + virtual void criticalFail(); + // called whenever a reload operation on the rowset failed + // (a "operation" is not only a simple reload: If the user sets a filter, an reloading the form + // after setting this filter fails, the filter is reset and the form is reloaded, again. Only the + // whole process (_both_ XLoadable::reload calls _together_) form the "reload operation" // -------------------- @@ -387,6 +397,10 @@ namespace dbaui // So for error recognition the above methods may be used. // init the formatter if form changes void initFormatter(); + + /// loads or reloads the form + sal_Bool reloadForm(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxLoadable); + private: // execute the filter or sort slot void ExecuteFilterSortCrit(sal_Bool bFilter); @@ -394,6 +408,9 @@ namespace dbaui // execute the search slot void ExecuteSearch(); + void applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied); + void applyParserOrder(const ::rtl::OUString& _rOldOrder); + // time to check the CUT/COPY/PASTE-slot-states DECL_LINK(OnInvalidateClipboard, void*); |