1*24acc546SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24acc546SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24acc546SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24acc546SAndrew Rist  * distributed with this work for additional information
6*24acc546SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24acc546SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24acc546SAndrew Rist  * "License"); you may not use this file except in compliance
9*24acc546SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24acc546SAndrew Rist  *
11*24acc546SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24acc546SAndrew Rist  *
13*24acc546SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24acc546SAndrew Rist  * software distributed under the License is distributed on an
15*24acc546SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24acc546SAndrew Rist  * KIND, either express or implied.  See the License for the
17*24acc546SAndrew Rist  * specific language governing permissions and limitations
18*24acc546SAndrew Rist  * under the License.
19*24acc546SAndrew Rist  *
20*24acc546SAndrew Rist  *************************************************************/
21*24acc546SAndrew Rist 
22*24acc546SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_forms.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "formoperations.hxx"
28cdf0e10cSrcweir #include "frm_strings.hxx"
29cdf0e10cSrcweir #include "frm_resource.hxx"
30cdf0e10cSrcweir #include "frm_resource.hrc"
31cdf0e10cSrcweir #include "frm_module.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /** === begin UNO includes === **/
34cdf0e10cSrcweir #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
35cdf0e10cSrcweir #include <com/sun/star/util/XModifyBroadcaster.hpp>
36cdf0e10cSrcweir #include <com/sun/star/form/runtime/FormFeature.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
39cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp>
40cdf0e10cSrcweir #include <com/sun/star/form/XGrid.hpp>
41cdf0e10cSrcweir #include <com/sun/star/form/XBoundControl.hpp>
42cdf0e10cSrcweir #include <com/sun/star/form/XBoundComponent.hpp>
43cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRowLocate.hpp>
44cdf0e10cSrcweir #include <com/sun/star/form/XConfirmDeleteListener.hpp>
45cdf0e10cSrcweir #include <com/sun/star/sdb/RowChangeEvent.hpp>
46cdf0e10cSrcweir #include <com/sun/star/sdb/RowChangeAction.hpp>
47cdf0e10cSrcweir #include <com/sun/star/sdb/SQLFilterOperator.hpp>
48cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
49cdf0e10cSrcweir #include <com/sun/star/form/XReset.hpp>
50cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertySet.hpp>
51cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
52cdf0e10cSrcweir #include <com/sun/star/util/XRefreshable.hpp>
53cdf0e10cSrcweir /** === end UNO includes === **/
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
56cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
57cdf0e10cSrcweir #include <vcl/svapp.hxx>
58cdf0e10cSrcweir #include <vcl/stdtext.hxx>
59cdf0e10cSrcweir #include <vcl/msgbox.hxx>
60cdf0e10cSrcweir #include <vcl/waitobj.hxx>
61cdf0e10cSrcweir #include <tools/diagnose_ex.h>
62cdf0e10cSrcweir #include <comphelper/container.hxx>
63cdf0e10cSrcweir #include <comphelper/property.hxx>
64cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx>
65cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
66cdf0e10cSrcweir #include <vos/mutex.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir //--------------------------------------------------------------------------
createRegistryInfo_FormOperations()69cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_FormOperations()
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	static ::frm::OMultiInstanceAutoRegistration< ::frm::FormOperations > aAutoRegistration;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //........................................................................
75cdf0e10cSrcweir namespace frm
76cdf0e10cSrcweir {
77cdf0e10cSrcweir //........................................................................
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     using ::dbtools::SQLExceptionInfo;
80cdf0e10cSrcweir 	/** === begin UNO using === **/
81cdf0e10cSrcweir     using ::com::sun::star::uno::Reference;
82cdf0e10cSrcweir     using ::com::sun::star::uno::XComponentContext;
83cdf0e10cSrcweir     using ::com::sun::star::uno::RuntimeException;
84cdf0e10cSrcweir     using ::com::sun::star::uno::Sequence;
85cdf0e10cSrcweir     using ::com::sun::star::uno::Exception;
86cdf0e10cSrcweir     using ::com::sun::star::uno::Any;
87cdf0e10cSrcweir     using ::com::sun::star::uno::XInterface;
88cdf0e10cSrcweir     using ::com::sun::star::sdbc::XRowSet;
89cdf0e10cSrcweir     using ::com::sun::star::sdbc::XResultSetUpdate;
90cdf0e10cSrcweir     using ::com::sun::star::form::runtime::XFormController;
91cdf0e10cSrcweir     using ::com::sun::star::form::runtime::XFeatureInvalidation;
92cdf0e10cSrcweir     using ::com::sun::star::form::runtime::FeatureState;
93cdf0e10cSrcweir     using ::com::sun::star::lang::IllegalArgumentException;
94cdf0e10cSrcweir     using ::com::sun::star::sdbc::SQLException;
95cdf0e10cSrcweir     using namespace ::com::sun::star::sdbc;
96cdf0e10cSrcweir     using ::com::sun::star::form::XForm;
97cdf0e10cSrcweir     using ::com::sun::star::ucb::AlreadyInitializedException;
98cdf0e10cSrcweir     using ::com::sun::star::util::XModifyBroadcaster;
99cdf0e10cSrcweir     using ::com::sun::star::uno::UNO_QUERY;
100cdf0e10cSrcweir     using ::com::sun::star::lang::EventObject;
101cdf0e10cSrcweir     using ::com::sun::star::beans::PropertyChangeEvent;
102cdf0e10cSrcweir     using ::com::sun::star::lang::XMultiServiceFactory;
103cdf0e10cSrcweir     using ::com::sun::star::lang::DisposedException;
104cdf0e10cSrcweir     using ::com::sun::star::beans::XPropertySet;
105cdf0e10cSrcweir     using ::com::sun::star::awt::XControl;
106cdf0e10cSrcweir     using ::com::sun::star::form::XGrid;
107cdf0e10cSrcweir     using ::com::sun::star::container::XIndexAccess;
108cdf0e10cSrcweir     using ::com::sun::star::uno::UNO_QUERY_THROW;
109cdf0e10cSrcweir     using ::com::sun::star::form::XBoundControl;
110cdf0e10cSrcweir     using ::com::sun::star::form::XBoundComponent;
111cdf0e10cSrcweir     using ::com::sun::star::sdbcx::XRowLocate;
112cdf0e10cSrcweir     using ::com::sun::star::form::XConfirmDeleteListener;
113cdf0e10cSrcweir     using ::com::sun::star::sdb::RowChangeEvent;
114cdf0e10cSrcweir     using namespace ::com::sun::star::sdb;
115cdf0e10cSrcweir     using ::com::sun::star::form::XReset;
116cdf0e10cSrcweir     using ::com::sun::star::beans::XMultiPropertySet;
117cdf0e10cSrcweir     using ::com::sun::star::uno::makeAny;
118cdf0e10cSrcweir     using ::com::sun::star::lang::WrappedTargetException;
119cdf0e10cSrcweir     using ::com::sun::star::beans::PropertyValue;
120cdf0e10cSrcweir     using ::com::sun::star::ui::dialogs::XExecutableDialog;
121cdf0e10cSrcweir     using ::com::sun::star::beans::NamedValue;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     using ::com::sun::star::util::XRefreshable;
124cdf0e10cSrcweir     using ::com::sun::star::awt::XControlModel;
125cdf0e10cSrcweir 	/** === end UNO using === **/
126cdf0e10cSrcweir     namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
127cdf0e10cSrcweir     namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	//====================================================================
130cdf0e10cSrcweir 	//= FormOperations
131cdf0e10cSrcweir 	//====================================================================
132cdf0e10cSrcweir 	//--------------------------------------------------------------------
FormOperations(const Reference<XMultiServiceFactory> & _rxContext)133cdf0e10cSrcweir     FormOperations::FormOperations( const Reference< XMultiServiceFactory >& _rxContext )
134cdf0e10cSrcweir         :FormOperations_Base( m_aMutex )
135cdf0e10cSrcweir         ,m_aContext( _rxContext )
136cdf0e10cSrcweir         ,m_bInitializedParser( false )
137cdf0e10cSrcweir         ,m_bActiveControlModified( false )
138cdf0e10cSrcweir         ,m_bConstructed( false )
139cdf0e10cSrcweir     #ifdef DBG_UTIL
140cdf0e10cSrcweir         ,m_nMethodNestingLevel( false )
141cdf0e10cSrcweir     #endif
142cdf0e10cSrcweir     {
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	//--------------------------------------------------------------------
~FormOperations()146cdf0e10cSrcweir     FormOperations::~FormOperations()
147cdf0e10cSrcweir     {
148cdf0e10cSrcweir     }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     //--------------------------------------------------------------------
getImplementationName_Static()151cdf0e10cSrcweir     ::rtl::OUString FormOperations::getImplementationName_Static(  ) throw(RuntimeException)
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.forms.FormOperations" ) );
154cdf0e10cSrcweir     }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     //--------------------------------------------------------------------
getSupportedServiceNames_Static()157cdf0e10cSrcweir     Sequence< ::rtl::OUString > FormOperations::getSupportedServiceNames_Static(  ) throw(RuntimeException)
158cdf0e10cSrcweir     {
159cdf0e10cSrcweir         Sequence< ::rtl::OUString > aNames(1);
160cdf0e10cSrcweir         aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.runtime.FormOperations" ) );
161cdf0e10cSrcweir         return aNames;
162cdf0e10cSrcweir     }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     //--------------------------------------------------------------------
Create(const Reference<XMultiServiceFactory> & _rxFactory)165cdf0e10cSrcweir     Reference< XInterface > SAL_CALL FormOperations::Create(const Reference< XMultiServiceFactory >& _rxFactory )
166cdf0e10cSrcweir     {
167cdf0e10cSrcweir         return *new FormOperations( _rxFactory );
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     //--------------------------------------------------------------------
initialize(const Sequence<Any> & _arguments)171cdf0e10cSrcweir     void SAL_CALL FormOperations::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         if ( m_bConstructed )
174cdf0e10cSrcweir             throw AlreadyInitializedException();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         if ( _arguments.getLength() == 1 )
177cdf0e10cSrcweir         {
178cdf0e10cSrcweir             Reference< XFormController > xController;
179cdf0e10cSrcweir             Reference< XForm > xForm;
180cdf0e10cSrcweir             if ( _arguments[0] >>= xController )
181cdf0e10cSrcweir                 createWithFormController( xController );
182cdf0e10cSrcweir             else if ( _arguments[0] >>= xForm )
183cdf0e10cSrcweir                 createWithForm( xForm );
184cdf0e10cSrcweir             else
185cdf0e10cSrcweir                 throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
186cdf0e10cSrcweir             return;
187cdf0e10cSrcweir         }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir         throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
190cdf0e10cSrcweir     }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     //--------------------------------------------------------------------
getImplementationName()193cdf0e10cSrcweir     ::rtl::OUString SAL_CALL FormOperations::getImplementationName(  ) throw (RuntimeException)
194cdf0e10cSrcweir     {
195cdf0e10cSrcweir         return getImplementationName_Static();
196cdf0e10cSrcweir     }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     //--------------------------------------------------------------------
supportsService(const::rtl::OUString & _ServiceName)199cdf0e10cSrcweir     ::sal_Bool SAL_CALL FormOperations::supportsService( const ::rtl::OUString& _ServiceName ) throw (RuntimeException)
200cdf0e10cSrcweir     {
201cdf0e10cSrcweir         Sequence< ::rtl::OUString > aSupportedServiceNames( getSupportedServiceNames() );
202cdf0e10cSrcweir         const ::rtl::OUString* pBegin = aSupportedServiceNames.getConstArray();
203cdf0e10cSrcweir         const ::rtl::OUString* pEnd = aSupportedServiceNames.getConstArray() + aSupportedServiceNames.getLength();
204cdf0e10cSrcweir         return ::std::find( pBegin, pEnd, _ServiceName ) != pEnd;
205cdf0e10cSrcweir     }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     //--------------------------------------------------------------------
getSupportedServiceNames()208cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL FormOperations::getSupportedServiceNames(  ) throw (RuntimeException)
209cdf0e10cSrcweir     {
210cdf0e10cSrcweir         return getSupportedServiceNames_Static();
211cdf0e10cSrcweir     }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     //--------------------------------------------------------------------
getCursor()214cdf0e10cSrcweir     Reference< XRowSet > SAL_CALL FormOperations::getCursor() throw (RuntimeException)
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         MethodGuard aGuard( *this );
217cdf0e10cSrcweir         return m_xCursor;
218cdf0e10cSrcweir     }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     //--------------------------------------------------------------------
getUpdateCursor()221cdf0e10cSrcweir     Reference< XResultSetUpdate > SAL_CALL FormOperations::getUpdateCursor() throw (RuntimeException)
222cdf0e10cSrcweir     {
223cdf0e10cSrcweir         MethodGuard aGuard( *this );
224cdf0e10cSrcweir         return m_xUpdateCursor;
225cdf0e10cSrcweir     }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     //--------------------------------------------------------------------
getController()228cdf0e10cSrcweir     Reference< XFormController > SAL_CALL FormOperations::getController() throw (RuntimeException)
229cdf0e10cSrcweir     {
230cdf0e10cSrcweir         MethodGuard aGuard( *this );
231cdf0e10cSrcweir         return m_xController;
232cdf0e10cSrcweir     }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     //--------------------------------------------------------------------
getFeatureInvalidation()235cdf0e10cSrcweir     Reference< XFeatureInvalidation > SAL_CALL FormOperations::getFeatureInvalidation() throw (RuntimeException)
236cdf0e10cSrcweir     {
237cdf0e10cSrcweir         MethodGuard aGuard( *this );
238cdf0e10cSrcweir         return m_xFeatureInvalidation;
239cdf0e10cSrcweir     }
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     //--------------------------------------------------------------------
setFeatureInvalidation(const Reference<XFeatureInvalidation> & _rxFeatureInvalidation)242cdf0e10cSrcweir     void SAL_CALL FormOperations::setFeatureInvalidation( const Reference< XFeatureInvalidation > & _rxFeatureInvalidation ) throw (RuntimeException)
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         MethodGuard aGuard( *this );
245cdf0e10cSrcweir         m_xFeatureInvalidation = _rxFeatureInvalidation;
246cdf0e10cSrcweir     }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     //--------------------------------------------------------------------
getState(::sal_Int16 _nFeature)249cdf0e10cSrcweir     FeatureState SAL_CALL FormOperations::getState( ::sal_Int16 _nFeature ) throw (RuntimeException)
250cdf0e10cSrcweir     {
251cdf0e10cSrcweir         MethodGuard aGuard( *this );
252cdf0e10cSrcweir 
253cdf0e10cSrcweir         FeatureState aState;
254cdf0e10cSrcweir         aState.Enabled = sal_False;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         try
257cdf0e10cSrcweir         {
258cdf0e10cSrcweir             // some checks for basic pre-requisites
259cdf0e10cSrcweir             if	(	!m_xLoadableForm.is()
260cdf0e10cSrcweir                 ||  !m_xLoadableForm->isLoaded()
261cdf0e10cSrcweir 		        ||	!m_xCursorProperties.is()
262cdf0e10cSrcweir 		        )
263cdf0e10cSrcweir             {
264cdf0e10cSrcweir                 return aState;
265cdf0e10cSrcweir             }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir             switch ( _nFeature )
268cdf0e10cSrcweir             {
269cdf0e10cSrcweir             case FormFeature::MoveToFirst:
270cdf0e10cSrcweir             case FormFeature::MoveToPrevious:
271cdf0e10cSrcweir                 aState.Enabled = impl_canMoveLeft_throw( );
272cdf0e10cSrcweir                 break;
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 			case FormFeature::MoveToNext:
275cdf0e10cSrcweir 				aState.Enabled = impl_canMoveRight_throw();
276cdf0e10cSrcweir                 break;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir             case FormFeature::MoveToLast:
279cdf0e10cSrcweir 				aState.Enabled = impl_getRowCount_throw() && ( !m_xCursor->isLast() || impl_isInsertionRow_throw() );
280cdf0e10cSrcweir                 break;
281cdf0e10cSrcweir 
282cdf0e10cSrcweir             case FormFeature::DeleteRecord:
283cdf0e10cSrcweir 				// already deleted ?
284cdf0e10cSrcweir 				if ( m_xCursor->rowDeleted() )
285cdf0e10cSrcweir                     aState.Enabled = sal_False;
286cdf0e10cSrcweir                 else
287cdf0e10cSrcweir 				{
288cdf0e10cSrcweir 					// allowed to delete the row ?
289cdf0e10cSrcweir                     aState.Enabled = !impl_isInsertionRow_throw() && ::dbtools::canDelete( m_xCursorProperties );
290cdf0e10cSrcweir 				}
291cdf0e10cSrcweir                 break;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir             case FormFeature::MoveToInsertRow:
294cdf0e10cSrcweir 				// if we are inserting we can move to the next row if the current record or control is modified
295cdf0e10cSrcweir 				aState.Enabled =    impl_isInsertionRow_throw()
296cdf0e10cSrcweir                                 ?   impl_isModifiedRow_throw() || m_bActiveControlModified
297cdf0e10cSrcweir                                 :   ::dbtools::canInsert( m_xCursorProperties );
298cdf0e10cSrcweir                 break;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir             case FormFeature::ReloadForm:
301cdf0e10cSrcweir             {
302cdf0e10cSrcweir                 // there must be an active connection
303cdf0e10cSrcweir                 Reference< XRowSet > xCursorRowSet( m_xCursor, UNO_QUERY );
304cdf0e10cSrcweir                 aState.Enabled = ::dbtools::getConnection( xCursorRowSet ).is();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir                 // and an active command
307cdf0e10cSrcweir                 ::rtl::OUString sActiveCommand;
308cdf0e10cSrcweir                 m_xCursorProperties->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sActiveCommand;
309cdf0e10cSrcweir                 aState.Enabled &= sActiveCommand.getLength() > 0;
310cdf0e10cSrcweir             }
311cdf0e10cSrcweir             break;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir             case FormFeature::RefreshCurrentControl:
314cdf0e10cSrcweir             {
315cdf0e10cSrcweir                 Reference< XRefreshable > xControlModelRefresh( impl_getCurrentControlModel_throw(), UNO_QUERY );
316cdf0e10cSrcweir                 aState.Enabled = xControlModelRefresh.is();
317cdf0e10cSrcweir             }
318cdf0e10cSrcweir             break;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 			case FormFeature::SaveRecordChanges:
321cdf0e10cSrcweir 			case FormFeature::UndoRecordChanges:
322cdf0e10cSrcweir 				aState.Enabled = impl_isModifiedRow_throw() || m_bActiveControlModified;
323cdf0e10cSrcweir                 break;
324cdf0e10cSrcweir 
325cdf0e10cSrcweir 			case FormFeature::RemoveFilterAndSort:
326cdf0e10cSrcweir 				if ( impl_isParseable_throw() && impl_hasFilterOrOrder_throw() )
327cdf0e10cSrcweir                     aState.Enabled = !impl_isInsertOnlyForm_throw();
328cdf0e10cSrcweir 				break;
329cdf0e10cSrcweir 
330cdf0e10cSrcweir             case FormFeature::SortAscending:
331cdf0e10cSrcweir 			case FormFeature::SortDescending:
332cdf0e10cSrcweir 			case FormFeature::AutoFilter:
333cdf0e10cSrcweir 				if ( m_xController.is() && impl_isParseable_throw() )
334cdf0e10cSrcweir 				{
335cdf0e10cSrcweir 					sal_Bool bIsDeleted = m_xCursor->rowDeleted();
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 					if ( !bIsDeleted && !impl_isInsertOnlyForm_throw() )
338cdf0e10cSrcweir 					{
339cdf0e10cSrcweir 						Reference< XPropertySet > xBoundField = impl_getCurrentBoundField_nothrow( );
340cdf0e10cSrcweir 						if ( xBoundField.is() )
341cdf0e10cSrcweir                             xBoundField->getPropertyValue( PROPERTY_SEARCHABLE ) >>= aState.Enabled;
342cdf0e10cSrcweir 					}
343cdf0e10cSrcweir 				}
344cdf0e10cSrcweir                 break;
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 			case FormFeature::InteractiveSort:
347cdf0e10cSrcweir             case FormFeature::InteractiveFilter:
348cdf0e10cSrcweir 				if ( impl_isParseable_throw() )
349cdf0e10cSrcweir                     aState.Enabled = !impl_isInsertOnlyForm_throw();
350cdf0e10cSrcweir                 break;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 			case FormFeature::ToggleApplyFilter:
353cdf0e10cSrcweir 			{
354cdf0e10cSrcweir 				::rtl::OUString sFilter;
355cdf0e10cSrcweir                 m_xCursorProperties->getPropertyValue( PROPERTY_FILTER ) >>= sFilter;
356cdf0e10cSrcweir 				if ( sFilter.getLength() )
357cdf0e10cSrcweir 				{
358cdf0e10cSrcweir                     aState.State = m_xCursorProperties->getPropertyValue( PROPERTY_APPLYFILTER );
359cdf0e10cSrcweir                     aState.Enabled = !impl_isInsertOnlyForm_throw();
360cdf0e10cSrcweir 				}
361cdf0e10cSrcweir                 else
362cdf0e10cSrcweir                     aState.State <<= (sal_Bool)sal_False;
363cdf0e10cSrcweir 			}
364cdf0e10cSrcweir             break;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 			case FormFeature::MoveAbsolute:
367cdf0e10cSrcweir 			{
368cdf0e10cSrcweir 				sal_Int32 nPosition   = m_xCursor->getRow();
369cdf0e10cSrcweir 				sal_Bool  bIsNew      = impl_isInsertionRow_throw();
370cdf0e10cSrcweir                 sal_Int32 nCount      = impl_getRowCount_throw();
371cdf0e10cSrcweir 				sal_Bool  bFinalCount = impl_isRowCountFinal_throw();
372cdf0e10cSrcweir 
373cdf0e10cSrcweir                 if ( ( nPosition >= 0 ) || bIsNew )
374cdf0e10cSrcweir 				{
375cdf0e10cSrcweir 					if ( bFinalCount )
376cdf0e10cSrcweir 					{
377cdf0e10cSrcweir                         // special case: there are no records at all, and we
378cdf0e10cSrcweir                         // can't insert records -> disabled
379cdf0e10cSrcweir 						if ( !nCount && !::dbtools::canInsert( m_xCursorProperties ) )
380cdf0e10cSrcweir 						{
381cdf0e10cSrcweir 							aState.Enabled = sal_False;
382cdf0e10cSrcweir 						}
383cdf0e10cSrcweir 						else
384cdf0e10cSrcweir 						{
385cdf0e10cSrcweir 							if ( bIsNew )
386cdf0e10cSrcweir 								nPosition = ++nCount;
387cdf0e10cSrcweir                             aState.State <<= (sal_Int32)nPosition;
388cdf0e10cSrcweir 							aState.Enabled = sal_True;
389cdf0e10cSrcweir 						}
390cdf0e10cSrcweir 					}
391cdf0e10cSrcweir 					else
392cdf0e10cSrcweir 					{
393cdf0e10cSrcweir                         aState.State <<= (sal_Int32)nPosition;
394cdf0e10cSrcweir 						aState.Enabled = sal_True;
395cdf0e10cSrcweir 					}
396cdf0e10cSrcweir 				}
397cdf0e10cSrcweir 			}
398cdf0e10cSrcweir             break;
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 			case FormFeature::TotalRecords:
401cdf0e10cSrcweir 			{
402cdf0e10cSrcweir 				sal_Bool  bIsNew      = impl_isInsertionRow_throw();
403cdf0e10cSrcweir                 sal_Int32 nCount      = impl_getRowCount_throw();
404cdf0e10cSrcweir 				sal_Bool  bFinalCount = impl_isRowCountFinal_throw();
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 				if ( bIsNew )
407cdf0e10cSrcweir 					++nCount;
408cdf0e10cSrcweir 
409cdf0e10cSrcweir                 ::rtl::OUString sValue = ::rtl::OUString::valueOf( sal_Int32( nCount ) );
410cdf0e10cSrcweir 				if ( !bFinalCount )
411cdf0e10cSrcweir                     sValue += ::rtl::OUString::createFromAscii( " *" );
412cdf0e10cSrcweir 
413cdf0e10cSrcweir                 aState.State <<= sValue;
414cdf0e10cSrcweir                 aState.Enabled = sal_True;
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir             break;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir             default:
419cdf0e10cSrcweir                 OSL_ENSURE( sal_False, "FormOperations::getState: unknown feature id!" );
420cdf0e10cSrcweir                 break;
421cdf0e10cSrcweir             }
422cdf0e10cSrcweir         }
423cdf0e10cSrcweir         catch( const Exception& )
424cdf0e10cSrcweir         {
425cdf0e10cSrcweir             OSL_ENSURE( sal_False, "FormOperations::getState: caught an exception!" );
426cdf0e10cSrcweir         }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir         return aState;
429cdf0e10cSrcweir     }
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     //--------------------------------------------------------------------
isEnabled(::sal_Int16 _nFeature)432cdf0e10cSrcweir     ::sal_Bool SAL_CALL FormOperations::isEnabled( ::sal_Int16 _nFeature ) throw (RuntimeException)
433cdf0e10cSrcweir     {
434cdf0e10cSrcweir         MethodGuard aGuard( *this );
435cdf0e10cSrcweir 
436cdf0e10cSrcweir         FeatureState aState( getState( _nFeature ) );
437cdf0e10cSrcweir         return aState.Enabled;
438cdf0e10cSrcweir     }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     //--------------------------------------------------------------------
441cdf0e10cSrcweir     namespace
442cdf0e10cSrcweir     {
lcl_needConfirmCommit(sal_Int32 _nFeature)443cdf0e10cSrcweir         static bool lcl_needConfirmCommit( sal_Int32 _nFeature )
444cdf0e10cSrcweir         {
445cdf0e10cSrcweir             return ( ( _nFeature == FormFeature::ReloadForm )
446cdf0e10cSrcweir                   || ( _nFeature == FormFeature::RemoveFilterAndSort )
447cdf0e10cSrcweir                   || ( _nFeature == FormFeature::ToggleApplyFilter )
448cdf0e10cSrcweir                   || ( _nFeature == FormFeature::SortAscending )
449cdf0e10cSrcweir                   || ( _nFeature == FormFeature::SortDescending )
450cdf0e10cSrcweir                   || ( _nFeature == FormFeature::AutoFilter )
451cdf0e10cSrcweir                   || ( _nFeature == FormFeature::InteractiveSort )
452cdf0e10cSrcweir                   || ( _nFeature == FormFeature::InteractiveFilter )
453cdf0e10cSrcweir                    );
454cdf0e10cSrcweir         }
lcl_requiresArguments(sal_Int32 _nFeature)455cdf0e10cSrcweir         static bool lcl_requiresArguments( sal_Int32 _nFeature )
456cdf0e10cSrcweir         {
457cdf0e10cSrcweir             return ( _nFeature == FormFeature::MoveAbsolute );
458cdf0e10cSrcweir         }
lcl_isExecutableFeature(sal_Int32 _nFeature)459cdf0e10cSrcweir         static bool lcl_isExecutableFeature( sal_Int32 _nFeature )
460cdf0e10cSrcweir         {
461cdf0e10cSrcweir             return ( _nFeature != FormFeature::TotalRecords );
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir     }
464cdf0e10cSrcweir 
465cdf0e10cSrcweir     //--------------------------------------------------------------------
execute(::sal_Int16 _nFeature)466cdf0e10cSrcweir     void SAL_CALL FormOperations::execute( ::sal_Int16 _nFeature ) throw (RuntimeException, IllegalArgumentException, SQLException, WrappedTargetException)
467cdf0e10cSrcweir     {
468cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
469cdf0e10cSrcweir         MethodGuard aGuard( *this );
470cdf0e10cSrcweir 
471cdf0e10cSrcweir         if ( ( _nFeature != FormFeature::DeleteRecord ) && ( _nFeature != FormFeature::UndoRecordChanges ) )
472cdf0e10cSrcweir         {
473cdf0e10cSrcweir             // if we have a controller, commit the current control
474cdf0e10cSrcweir             if ( m_xController.is() )
475cdf0e10cSrcweir                 if ( !impl_commitCurrentControl_throw() )
476cdf0e10cSrcweir                     return;
477cdf0e10cSrcweir 
478cdf0e10cSrcweir             // commit the current record
479cdf0e10cSrcweir             bool bCommitCurrentRecord = true;
480cdf0e10cSrcweir             // (but before, let the user confirm if necessary)
481cdf0e10cSrcweir             if ( impl_isModifiedRow_throw() )
482cdf0e10cSrcweir             {
483cdf0e10cSrcweir                 if ( lcl_needConfirmCommit( _nFeature ) )
484cdf0e10cSrcweir                 {
485cdf0e10cSrcweir                     // TODO: shouldn't this be done with an interaction handler?
486cdf0e10cSrcweir 				    QueryBox aQuery( NULL, WB_YES_NO_CANCEL | WB_DEF_YES, FRM_RES_STRING( RID_STR_QUERY_SAVE_MODIFIED_ROW ) );
487cdf0e10cSrcweir                     switch ( aQuery.Execute() )
488cdf0e10cSrcweir                     {
489cdf0e10cSrcweir                     case RET_NO: bCommitCurrentRecord = false; break;
490cdf0e10cSrcweir                     case RET_CANCEL: return;
491cdf0e10cSrcweir                     }
492cdf0e10cSrcweir                 }
493cdf0e10cSrcweir             }
494cdf0e10cSrcweir 
495cdf0e10cSrcweir             if ( bCommitCurrentRecord && !impl_commitCurrentRecord_throw() )
496cdf0e10cSrcweir                 return;
497cdf0e10cSrcweir         }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir         try
500cdf0e10cSrcweir         {
501cdf0e10cSrcweir             switch ( _nFeature )
502cdf0e10cSrcweir             {
503cdf0e10cSrcweir 	        case FormFeature::MoveToFirst:
504cdf0e10cSrcweir                 m_xCursor->first();
505cdf0e10cSrcweir 		        break;
506cdf0e10cSrcweir 
507cdf0e10cSrcweir             case FormFeature::MoveToNext:
508cdf0e10cSrcweir                 impl_moveRight_throw( );
509cdf0e10cSrcweir                 break;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir             case FormFeature::MoveToPrevious:
512cdf0e10cSrcweir     		    impl_moveLeft_throw( );
513cdf0e10cSrcweir 		        break;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	        case FormFeature::MoveToLast:
516cdf0e10cSrcweir 	        {
517cdf0e10cSrcweir /*
518cdf0e10cSrcweir                 // TODO: re-implement this .....
519cdf0e10cSrcweir 		        // run in an own thread if ...
520cdf0e10cSrcweir 		        // ... the data source is thread safe ...
521cdf0e10cSrcweir 		        sal_Bool bAllowOwnThread = sal_False;
522cdf0e10cSrcweir                 if ( ::comphelper::hasProperty( PROPERTY_THREADSAFE, m_xCursorProperties ) )
523cdf0e10cSrcweir                     m_xCursorProperties->getPropertyValue( PROPERTY_THREADSAFE ) >>= bAllowOwnThread;
524cdf0e10cSrcweir 
525cdf0e10cSrcweir                 // ... the record count is unknown
526cdf0e10cSrcweir 		        sal_Bool bNeedOwnThread sal_False;
527cdf0e10cSrcweir                 if ( ::comphelper::hasProperty( PROPERTY_ROWCOUNTFINAL, m_xCursorProperties ) )
528cdf0e10cSrcweir                     m_xCursorProperties->getPropertyValue( PROPERTY_ROWCOUNTFINAL ) >>= bNeedOwnThread;
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 		        if ( bNeedOwnThread && bAllowOwnThread )
531cdf0e10cSrcweir 			        ;
532cdf0e10cSrcweir 		        else
533cdf0e10cSrcweir */
534cdf0e10cSrcweir 			        m_xCursor->last();
535cdf0e10cSrcweir 	        }
536cdf0e10cSrcweir 	        break;
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 	        case FormFeature::ReloadForm:
539cdf0e10cSrcweir                 if ( m_xLoadableForm.is() )
540cdf0e10cSrcweir                 {
541cdf0e10cSrcweir     			    WaitObject aWO( NULL );
542cdf0e10cSrcweir                     m_xLoadableForm->reload();
543cdf0e10cSrcweir 
544cdf0e10cSrcweir                     // refresh all controls in the form (and sub forms) which can be refreshed
545cdf0e10cSrcweir                     // #i90914# / 2008-07-02 / frank.schoenheit@sun.com
546cdf0e10cSrcweir                     ::comphelper::IndexAccessIterator aIter( m_xLoadableForm );
547cdf0e10cSrcweir                     Reference< XInterface > xElement( aIter.Next() );
548cdf0e10cSrcweir                     while ( xElement.is() )
549cdf0e10cSrcweir                     {
550cdf0e10cSrcweir                         Reference< XRefreshable > xRefresh( xElement, UNO_QUERY );
551cdf0e10cSrcweir                         if ( xRefresh.is() )
552cdf0e10cSrcweir                             xRefresh->refresh();
553cdf0e10cSrcweir                         xElement = aIter.Next();
554cdf0e10cSrcweir                     }
555cdf0e10cSrcweir                 }
556cdf0e10cSrcweir 	            break;
557cdf0e10cSrcweir 
558cdf0e10cSrcweir             case FormFeature::RefreshCurrentControl:
559cdf0e10cSrcweir             {
560cdf0e10cSrcweir                 Reference< XRefreshable > xControlModelRefresh( impl_getCurrentControlModel_throw(), UNO_QUERY );
561cdf0e10cSrcweir                 OSL_ENSURE( xControlModelRefresh.is(), "FormOperations::execute: how did you reach this?" );
562cdf0e10cSrcweir                 if ( xControlModelRefresh.is() )
563cdf0e10cSrcweir                     xControlModelRefresh->refresh();
564cdf0e10cSrcweir             }
565cdf0e10cSrcweir             break;
566cdf0e10cSrcweir 
567cdf0e10cSrcweir             case FormFeature::DeleteRecord:
568cdf0e10cSrcweir 	        {
569cdf0e10cSrcweir                 sal_uInt32 nCount = impl_getRowCount_throw();
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 		        // next position
572cdf0e10cSrcweir 		        sal_Bool bLeft = m_xCursor->isLast() && ( nCount > 1 );
573cdf0e10cSrcweir 		        sal_Bool bRight= !m_xCursor->isLast();
574cdf0e10cSrcweir 		        sal_Bool bSuccess = sal_False;
575cdf0e10cSrcweir 		        try
576cdf0e10cSrcweir 		        {
577cdf0e10cSrcweir 			        // ask for confirmation
578cdf0e10cSrcweir                     Reference< XConfirmDeleteListener > xConfirmDelete( m_xController, UNO_QUERY );
579cdf0e10cSrcweir 
580cdf0e10cSrcweir                     if ( xConfirmDelete.is() )
581cdf0e10cSrcweir 			        {
582cdf0e10cSrcweir 				        RowChangeEvent aEvent;
583cdf0e10cSrcweir 				        aEvent.Source = Reference< XInterface >( m_xCursor, UNO_QUERY );
584cdf0e10cSrcweir 				        aEvent.Action = RowChangeAction::DELETE;
585cdf0e10cSrcweir 				        aEvent.Rows = 1;
586cdf0e10cSrcweir 				        bSuccess = xConfirmDelete->confirmDelete( aEvent );
587cdf0e10cSrcweir 			        }
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 			        // delete it
590cdf0e10cSrcweir 			        if ( bSuccess )
591cdf0e10cSrcweir 				        m_xUpdateCursor->deleteRow();
592cdf0e10cSrcweir 		        }
593cdf0e10cSrcweir 		        catch( const Exception& )
594cdf0e10cSrcweir 		        {
595cdf0e10cSrcweir 			        bSuccess = sal_False;
596cdf0e10cSrcweir 		        }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 		        if ( bSuccess )
599cdf0e10cSrcweir 		        {
600cdf0e10cSrcweir 			        if ( bLeft || bRight )
601cdf0e10cSrcweir 				        m_xCursor->relative( bRight ? 1 : -1 );
602cdf0e10cSrcweir 			        else
603cdf0e10cSrcweir 			        {
604cdf0e10cSrcweir 				        sal_Bool bCanInsert = ::dbtools::canInsert( m_xCursorProperties );
605cdf0e10cSrcweir 				        // is it possible to insert another record?
606cdf0e10cSrcweir 					    if ( bCanInsert )
607cdf0e10cSrcweir 						    m_xUpdateCursor->moveToInsertRow();
608cdf0e10cSrcweir 					    else
609cdf0e10cSrcweir 						    // move record to update stati
610cdf0e10cSrcweir 						    m_xCursor->first();
611cdf0e10cSrcweir 			        }
612cdf0e10cSrcweir 		        }
613cdf0e10cSrcweir             }
614cdf0e10cSrcweir             break;
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 	        case FormFeature::SaveRecordChanges:
617cdf0e10cSrcweir             case FormFeature::UndoRecordChanges:
618cdf0e10cSrcweir             {
619cdf0e10cSrcweir 			    sal_Bool bInserting = impl_isInsertionRow_throw();
620cdf0e10cSrcweir 
621cdf0e10cSrcweir                 if ( FormFeature::UndoRecordChanges == _nFeature )
622cdf0e10cSrcweir                 {
623cdf0e10cSrcweir     			    if ( !bInserting )
624cdf0e10cSrcweir 	    			    m_xUpdateCursor->cancelRowUpdates();
625cdf0e10cSrcweir 
626cdf0e10cSrcweir                     // reset all controls for this form
627cdf0e10cSrcweir                     impl_resetAllControls_nothrow( );
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 			        if ( bInserting )   // back to insertion mode for this form
630cdf0e10cSrcweir 				        m_xUpdateCursor->moveToInsertRow();
631cdf0e10cSrcweir                 }
632cdf0e10cSrcweir                 else
633cdf0e10cSrcweir                 {
634cdf0e10cSrcweir 			        if  ( bInserting )
635cdf0e10cSrcweir                     {
636cdf0e10cSrcweir 				        m_xUpdateCursor->insertRow();
637cdf0e10cSrcweir                         m_xCursor->last();
638cdf0e10cSrcweir                     }
639cdf0e10cSrcweir 			        else
640cdf0e10cSrcweir 				        m_xUpdateCursor->updateRow();
641cdf0e10cSrcweir                 }
642cdf0e10cSrcweir             }
643cdf0e10cSrcweir             break;
644cdf0e10cSrcweir 
645cdf0e10cSrcweir             case FormFeature::MoveToInsertRow:
646cdf0e10cSrcweir 		        // move to the last row before moving to the insert row
647cdf0e10cSrcweir 		        // 21.01.2002 - 96480 - fs@openoffice.org
648cdf0e10cSrcweir                 m_xCursor->last();
649cdf0e10cSrcweir 		        m_xUpdateCursor->moveToInsertRow();
650cdf0e10cSrcweir     	        break;
651cdf0e10cSrcweir 
652cdf0e10cSrcweir             case FormFeature::RemoveFilterAndSort:
653cdf0e10cSrcweir             {
654cdf0e10cSrcweir 				// simultaneously reset Filter and Order property
655cdf0e10cSrcweir                 Reference< XMultiPropertySet > xProperties( m_xCursorProperties, UNO_QUERY );
656cdf0e10cSrcweir                 OSL_ENSURE( xProperties.is(), "FormOperations::execute: no multi property access!" );
657cdf0e10cSrcweir 				if ( xProperties.is() )
658cdf0e10cSrcweir 				{
659cdf0e10cSrcweir 					Sequence< ::rtl::OUString > aNames( 2 );
660cdf0e10cSrcweir                     aNames[0] = PROPERTY_FILTER;
661cdf0e10cSrcweir                     aNames[1] = PROPERTY_SORT;
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 					Sequence< Any> aValues( 2 );
664cdf0e10cSrcweir                     aValues[0] <<= ::rtl::OUString();
665cdf0e10cSrcweir                     aValues[1] <<= ::rtl::OUString();
666cdf0e10cSrcweir 
667cdf0e10cSrcweir 					WaitObject aWO( NULL );
668cdf0e10cSrcweir 					xProperties->setPropertyValues( aNames, aValues );
669cdf0e10cSrcweir 
670cdf0e10cSrcweir                     if ( m_xLoadableForm.is() )
671cdf0e10cSrcweir 					    m_xLoadableForm->reload();
672cdf0e10cSrcweir 				}
673cdf0e10cSrcweir             }
674cdf0e10cSrcweir             break;
675cdf0e10cSrcweir 
676cdf0e10cSrcweir             case FormFeature::ToggleApplyFilter:
677cdf0e10cSrcweir                 if ( impl_commitCurrentControl_throw() && impl_commitCurrentRecord_throw() )
678cdf0e10cSrcweir 			    {
679cdf0e10cSrcweir                     // simply toggle the value
680cdf0e10cSrcweir 				    sal_Bool bApplied = sal_False;
681cdf0e10cSrcweir                     m_xCursorProperties->getPropertyValue( PROPERTY_APPLYFILTER ) >>= bApplied;
682cdf0e10cSrcweir 				    m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, makeAny( (sal_Bool)!bApplied ) );
683cdf0e10cSrcweir 
684cdf0e10cSrcweir                     // and reload
685cdf0e10cSrcweir 				    WaitObject aWO( NULL );
686cdf0e10cSrcweir 				    m_xLoadableForm->reload();
687cdf0e10cSrcweir 			    }
688cdf0e10cSrcweir                 break;
689cdf0e10cSrcweir 
690cdf0e10cSrcweir             case FormFeature::SortAscending:
691cdf0e10cSrcweir                 impl_executeAutoSort_throw( true );
692cdf0e10cSrcweir                 break;
693cdf0e10cSrcweir 
694cdf0e10cSrcweir             case FormFeature::SortDescending:
695cdf0e10cSrcweir                 impl_executeAutoSort_throw( false );
696cdf0e10cSrcweir                 break;
697cdf0e10cSrcweir 
698cdf0e10cSrcweir             case FormFeature::AutoFilter:
699cdf0e10cSrcweir                 impl_executeAutoFilter_throw();
700cdf0e10cSrcweir                 break;
701cdf0e10cSrcweir 
702cdf0e10cSrcweir             case FormFeature::InteractiveSort:
703cdf0e10cSrcweir                 impl_executeFilterOrSort_throw( false );
704cdf0e10cSrcweir 		        break;
705cdf0e10cSrcweir 
706cdf0e10cSrcweir             case FormFeature::InteractiveFilter:
707cdf0e10cSrcweir                 impl_executeFilterOrSort_throw( true );
708cdf0e10cSrcweir                 break;
709cdf0e10cSrcweir 
710cdf0e10cSrcweir             default:
711cdf0e10cSrcweir             {
712cdf0e10cSrcweir                 sal_uInt16 nErrorResourceId = RID_STR_FEATURE_UNKNOWN;
713cdf0e10cSrcweir                 if ( lcl_requiresArguments( _nFeature ) )
714cdf0e10cSrcweir                     nErrorResourceId = RID_STR_FEATURE_REQUIRES_PARAMETERS;
715cdf0e10cSrcweir                 else if ( !lcl_isExecutableFeature( _nFeature ) )
716cdf0e10cSrcweir                     nErrorResourceId = RID_STR_FEATURE_NOT_EXECUTABLE;
717cdf0e10cSrcweir                 throw IllegalArgumentException( FRM_RES_STRING( nErrorResourceId ), *this, 1 );
718cdf0e10cSrcweir             }
719cdf0e10cSrcweir             }   // switch
720cdf0e10cSrcweir         }
721cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
722cdf0e10cSrcweir         catch( const SQLException& ) { throw; }
723cdf0e10cSrcweir         catch( const IllegalArgumentException& ) { throw; }
724cdf0e10cSrcweir         catch( const Exception& )
725cdf0e10cSrcweir         {
726cdf0e10cSrcweir             throw WrappedTargetException( ::rtl::OUString(), *const_cast< FormOperations* >( this ), ::cppu::getCaughtException() );
727cdf0e10cSrcweir         }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir         impl_invalidateAllSupportedFeatures_nothrow( aGuard );
730cdf0e10cSrcweir     }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     //--------------------------------------------------------------------
executeWithArguments(::sal_Int16 _nFeature,const Sequence<NamedValue> & _rArguments)733cdf0e10cSrcweir     void SAL_CALL FormOperations::executeWithArguments( ::sal_Int16 _nFeature, const Sequence< NamedValue >& _rArguments ) throw (RuntimeException, IllegalArgumentException, SQLException, WrappedTargetException)
734cdf0e10cSrcweir     {
735cdf0e10cSrcweir         if ( !lcl_requiresArguments( _nFeature ) )
736cdf0e10cSrcweir         {
737cdf0e10cSrcweir             execute( _nFeature );
738cdf0e10cSrcweir             return;
739cdf0e10cSrcweir         }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
742cdf0e10cSrcweir         MethodGuard aGuard( *this );
743cdf0e10cSrcweir 
744cdf0e10cSrcweir         // at the moment we have only one feature which supports execution parameters
745cdf0e10cSrcweir         if ( !lcl_isExecutableFeature( _nFeature ) )
746cdf0e10cSrcweir             throw IllegalArgumentException( FRM_RES_STRING( RID_STR_FEATURE_NOT_EXECUTABLE ), *this, 1 );
747cdf0e10cSrcweir 
748cdf0e10cSrcweir         switch ( _nFeature )
749cdf0e10cSrcweir         {
750cdf0e10cSrcweir         case FormFeature::MoveAbsolute:
751cdf0e10cSrcweir         {
752cdf0e10cSrcweir             sal_Int32 nPosition = -1;
753cdf0e10cSrcweir 
754cdf0e10cSrcweir             ::comphelper::NamedValueCollection aArguments( _rArguments );
755cdf0e10cSrcweir             aArguments.get_ensureType( "Position", nPosition );
756cdf0e10cSrcweir 
757cdf0e10cSrcweir             if ( nPosition < 1 )
758cdf0e10cSrcweir                 nPosition = 1;
759cdf0e10cSrcweir 
760cdf0e10cSrcweir             try
761cdf0e10cSrcweir             {
762cdf0e10cSrcweir                 // commit before doing anything else
763cdf0e10cSrcweir                 if ( m_xController.is() && !impl_commitCurrentControl_throw() )
764cdf0e10cSrcweir                     return;
765cdf0e10cSrcweir 			    if ( !impl_commitCurrentRecord_throw() )
766cdf0e10cSrcweir                     return;
767cdf0e10cSrcweir 
768cdf0e10cSrcweir                 sal_Int32 nCount      = impl_getRowCount_throw();
769cdf0e10cSrcweir 				sal_Bool  bFinalCount = impl_isRowCountFinal_throw();
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 				if ( bFinalCount && ( (sal_Int32)nPosition > nCount ) )
772cdf0e10cSrcweir 					nPosition = nCount;
773cdf0e10cSrcweir 
774cdf0e10cSrcweir                 m_xCursor->absolute( nPosition );
775cdf0e10cSrcweir             }
776cdf0e10cSrcweir             catch( const RuntimeException& ) { throw; }
777cdf0e10cSrcweir             catch( const SQLException& ) { throw; }
778cdf0e10cSrcweir             catch( const Exception& )
779cdf0e10cSrcweir             {
780cdf0e10cSrcweir                 throw WrappedTargetException( ::rtl::OUString(), *this, ::cppu::getCaughtException() );
781cdf0e10cSrcweir             }
782cdf0e10cSrcweir         }
783cdf0e10cSrcweir         break;
784cdf0e10cSrcweir         default:
785cdf0e10cSrcweir             throw IllegalArgumentException( FRM_RES_STRING( RID_STR_FEATURE_UNKNOWN ), *this, 1 );
786cdf0e10cSrcweir         }   // switch
787cdf0e10cSrcweir     }
788cdf0e10cSrcweir 
789cdf0e10cSrcweir     //--------------------------------------------------------------------
commitCurrentRecord(::sal_Bool & _out_rRecordInserted)790cdf0e10cSrcweir     ::sal_Bool SAL_CALL FormOperations::commitCurrentRecord( ::sal_Bool& _out_rRecordInserted ) throw (RuntimeException, SQLException)
791cdf0e10cSrcweir     {
792cdf0e10cSrcweir         MethodGuard aGuard( *this );
793cdf0e10cSrcweir         _out_rRecordInserted = sal_False;
794cdf0e10cSrcweir 
795cdf0e10cSrcweir         return impl_commitCurrentRecord_throw( &_out_rRecordInserted );
796cdf0e10cSrcweir     }
797cdf0e10cSrcweir 
798cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_commitCurrentRecord_throw(::sal_Bool * _pRecordInserted) const799cdf0e10cSrcweir     bool FormOperations::impl_commitCurrentRecord_throw( ::sal_Bool* _pRecordInserted ) const
800cdf0e10cSrcweir     {
801cdf0e10cSrcweir         DBG_ASSERT( m_nMethodNestingLevel, "FormOperations::impl_commitCurrentRecord_throw: to be called within a MethodGuard'ed section only!" );
802cdf0e10cSrcweir 
803cdf0e10cSrcweir         if ( !impl_hasCursor_nothrow() )
804cdf0e10cSrcweir 		    return false;
805cdf0e10cSrcweir 
806cdf0e10cSrcweir         // nothing to do if the record is not modified
807cdf0e10cSrcweir 	    sal_Bool bResult = !impl_isModifiedRow_throw();
808cdf0e10cSrcweir 	    if ( !bResult )
809cdf0e10cSrcweir 	    {
810cdf0e10cSrcweir             // insert respectively update the row
811cdf0e10cSrcweir             if ( impl_isInsertionRow_throw() )
812cdf0e10cSrcweir             {
813cdf0e10cSrcweir 				m_xUpdateCursor->insertRow();
814cdf0e10cSrcweir                 if ( _pRecordInserted )
815cdf0e10cSrcweir                     *_pRecordInserted = sal_True;
816cdf0e10cSrcweir             }
817cdf0e10cSrcweir 			else
818cdf0e10cSrcweir 				m_xUpdateCursor->updateRow();
819cdf0e10cSrcweir 			bResult = true;
820cdf0e10cSrcweir 	    }
821cdf0e10cSrcweir 	    return bResult;
822cdf0e10cSrcweir     }
823cdf0e10cSrcweir 
824cdf0e10cSrcweir     //--------------------------------------------------------------------
commitCurrentControl()825cdf0e10cSrcweir     ::sal_Bool SAL_CALL FormOperations::commitCurrentControl() throw (RuntimeException, SQLException)
826cdf0e10cSrcweir     {
827cdf0e10cSrcweir         MethodGuard aGuard( *this );
828cdf0e10cSrcweir         return impl_commitCurrentControl_throw();
829cdf0e10cSrcweir     }
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_commitCurrentControl_throw() const832cdf0e10cSrcweir     bool FormOperations::impl_commitCurrentControl_throw() const
833cdf0e10cSrcweir     {
834cdf0e10cSrcweir         DBG_ASSERT( m_nMethodNestingLevel, "FormOperations::impl_commitCurrentRecord_throw: to be called within a MethodGuard'ed section only!" );
835cdf0e10cSrcweir         OSL_PRECOND( m_xController.is(), "FormOperations::commitCurrentControl: no controller!" );
836cdf0e10cSrcweir         if ( !m_xController.is() )
837cdf0e10cSrcweir             return false;
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 	    bool bSuccess = false;
840cdf0e10cSrcweir         try
841cdf0e10cSrcweir         {
842cdf0e10cSrcweir             Reference< XControl > xCurrentControl( m_xController->getCurrentControl() );
843cdf0e10cSrcweir 
844cdf0e10cSrcweir             // check whether the control is locked
845cdf0e10cSrcweir             Reference< XBoundControl > xCheckLock( xCurrentControl, UNO_QUERY );
846cdf0e10cSrcweir 	        sal_Bool bControlIsLocked = xCheckLock.is() && xCheckLock->getLock();
847cdf0e10cSrcweir 
848cdf0e10cSrcweir             // commit if necessary
849cdf0e10cSrcweir             bSuccess = true;
850cdf0e10cSrcweir 	        if ( xCurrentControl.is() && !bControlIsLocked )
851cdf0e10cSrcweir 	        {
852cdf0e10cSrcweir 		        // both the control and it's model can be committable, so try both
853cdf0e10cSrcweir 		        Reference< XBoundComponent > xBound( xCurrentControl, UNO_QUERY );
854cdf0e10cSrcweir 		        if ( !xBound.is() )
855cdf0e10cSrcweir 			        xBound = xBound.query( xCurrentControl->getModel() );
856cdf0e10cSrcweir                 // and now really commit
857cdf0e10cSrcweir                 if ( xBound.is() )
858cdf0e10cSrcweir 			        bSuccess = xBound->commit();
859cdf0e10cSrcweir 	        }
860cdf0e10cSrcweir 
861cdf0e10cSrcweir         }
862cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
863cdf0e10cSrcweir         catch( const SQLException& ) { throw; }
864cdf0e10cSrcweir         catch( const Exception& )
865cdf0e10cSrcweir         {
866cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
867cdf0e10cSrcweir             bSuccess = false;
868cdf0e10cSrcweir         }
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 	    return bSuccess;
871cdf0e10cSrcweir     }
872cdf0e10cSrcweir 
873cdf0e10cSrcweir     //--------------------------------------------------------------------
isInsertionRow()874cdf0e10cSrcweir     ::sal_Bool SAL_CALL FormOperations::isInsertionRow() throw (RuntimeException, WrappedTargetException)
875cdf0e10cSrcweir     {
876cdf0e10cSrcweir         sal_Bool bIs = sal_False;
877cdf0e10cSrcweir         try
878cdf0e10cSrcweir         {
879cdf0e10cSrcweir             bIs = impl_isInsertionRow_throw();
880cdf0e10cSrcweir         }
881cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
882cdf0e10cSrcweir         catch( const Exception& )
883cdf0e10cSrcweir         {
884cdf0e10cSrcweir             throw WrappedTargetException( ::rtl::OUString(), *this, ::cppu::getCaughtException() );
885cdf0e10cSrcweir         }
886cdf0e10cSrcweir         return bIs;
887cdf0e10cSrcweir     }
888cdf0e10cSrcweir 
889cdf0e10cSrcweir     //--------------------------------------------------------------------
isModifiedRow()890cdf0e10cSrcweir     ::sal_Bool SAL_CALL FormOperations::isModifiedRow() throw (RuntimeException, WrappedTargetException)
891cdf0e10cSrcweir     {
892cdf0e10cSrcweir         sal_Bool bIs = sal_False;
893cdf0e10cSrcweir         try
894cdf0e10cSrcweir         {
895cdf0e10cSrcweir             bIs = impl_isModifiedRow_throw();
896cdf0e10cSrcweir         }
897cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
898cdf0e10cSrcweir         catch( const Exception& )
899cdf0e10cSrcweir         {
900cdf0e10cSrcweir             throw WrappedTargetException( ::rtl::OUString(), *this, ::cppu::getCaughtException() );
901cdf0e10cSrcweir         }
902cdf0e10cSrcweir         return bIs;
903cdf0e10cSrcweir     }
904cdf0e10cSrcweir 
905cdf0e10cSrcweir     //--------------------------------------------------------------------
cursorMoved(const EventObject &)906cdf0e10cSrcweir     void SAL_CALL FormOperations::cursorMoved( const EventObject& /*_Event*/ ) throw (RuntimeException)
907cdf0e10cSrcweir     {
908cdf0e10cSrcweir         MethodGuard aGuard( *this );
909cdf0e10cSrcweir 	    m_bActiveControlModified = sal_False;
910cdf0e10cSrcweir 
911cdf0e10cSrcweir         impl_invalidateAllSupportedFeatures_nothrow( aGuard );
912cdf0e10cSrcweir     }
913cdf0e10cSrcweir 
914cdf0e10cSrcweir     //--------------------------------------------------------------------
rowChanged(const EventObject &)915cdf0e10cSrcweir     void SAL_CALL FormOperations::rowChanged( const EventObject& /*_Event*/ ) throw (RuntimeException)
916cdf0e10cSrcweir     {
917cdf0e10cSrcweir         // not interested in
918cdf0e10cSrcweir     }
919cdf0e10cSrcweir 
920cdf0e10cSrcweir     //--------------------------------------------------------------------
rowSetChanged(const EventObject &)921cdf0e10cSrcweir     void SAL_CALL FormOperations::rowSetChanged( const EventObject& /*_Event*/ ) throw (RuntimeException)
922cdf0e10cSrcweir     {
923cdf0e10cSrcweir         // not interested in
924cdf0e10cSrcweir     }
925cdf0e10cSrcweir 
926cdf0e10cSrcweir     //--------------------------------------------------------------------
modified(const EventObject &)927cdf0e10cSrcweir     void SAL_CALL FormOperations::modified( const EventObject& /*_Source*/ ) throw( RuntimeException )
928cdf0e10cSrcweir     {
929cdf0e10cSrcweir         MethodGuard aGuard( *this );
930cdf0e10cSrcweir 
931cdf0e10cSrcweir         OSL_ENSURE( m_xCursor.is(), "FormOperations::modified: already disposed!" );
932cdf0e10cSrcweir 	    if ( !m_bActiveControlModified )
933cdf0e10cSrcweir 	    {
934cdf0e10cSrcweir 		    m_bActiveControlModified = sal_True;
935cdf0e10cSrcweir             impl_invalidateModifyDependentFeatures_nothrow( aGuard );
936cdf0e10cSrcweir 	    }
937cdf0e10cSrcweir     }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     //--------------------------------------------------------------------
propertyChange(const PropertyChangeEvent & _rEvent)940cdf0e10cSrcweir     void SAL_CALL FormOperations::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException)
941cdf0e10cSrcweir     {
942cdf0e10cSrcweir         MethodGuard aGuard( *this );
943cdf0e10cSrcweir 
944cdf0e10cSrcweir         if ( m_xCursor.is() && ( m_xCursor == _rEvent.Source ) )
945cdf0e10cSrcweir         {
946cdf0e10cSrcweir             sal_Bool bIs = sal_False;
947cdf0e10cSrcweir         	if  ( ( _rEvent.PropertyName == PROPERTY_ISMODIFIED )
948cdf0e10cSrcweir                || ( _rEvent.PropertyName == PROPERTY_ISNEW )
949cdf0e10cSrcweir                 )
950cdf0e10cSrcweir 	        {
951cdf0e10cSrcweir 		        if ( ( _rEvent.NewValue >>= bIs ) && !bIs )
952cdf0e10cSrcweir 			        m_bActiveControlModified = sal_False;
953cdf0e10cSrcweir 	        }
954cdf0e10cSrcweir             impl_invalidateAllSupportedFeatures_nothrow( aGuard );
955cdf0e10cSrcweir         }
956cdf0e10cSrcweir 
957cdf0e10cSrcweir         if ( m_xParser.is() && ( m_xCursor == _rEvent.Source ) )
958cdf0e10cSrcweir 	    {
959cdf0e10cSrcweir 		    try
960cdf0e10cSrcweir 		    {
961cdf0e10cSrcweir                 ::rtl::OUString sNewValue;
962cdf0e10cSrcweir                 _rEvent.NewValue >>= sNewValue;
963cdf0e10cSrcweir 			    if ( _rEvent.PropertyName == PROPERTY_ACTIVECOMMAND )
964cdf0e10cSrcweir                 {
965cdf0e10cSrcweir 				    m_xParser->setElementaryQuery( sNewValue );
966cdf0e10cSrcweir                 }
967cdf0e10cSrcweir 			    else if ( _rEvent.PropertyName == PROPERTY_FILTER )
968cdf0e10cSrcweir 			    {
969cdf0e10cSrcweir 				    if ( m_xParser->getFilter() != sNewValue )
970cdf0e10cSrcweir 					    m_xParser->setFilter( sNewValue );
971cdf0e10cSrcweir 			    }
972cdf0e10cSrcweir 			    else if ( _rEvent.PropertyName == PROPERTY_SORT )
973cdf0e10cSrcweir 			    {
974cdf0e10cSrcweir                     _rEvent.NewValue >>= sNewValue;
975cdf0e10cSrcweir 				    if ( m_xParser->getOrder() != sNewValue )
976cdf0e10cSrcweir 					    m_xParser->setOrder( sNewValue );
977cdf0e10cSrcweir 			    }
978cdf0e10cSrcweir 		    }
979cdf0e10cSrcweir 		    catch( Exception& )
980cdf0e10cSrcweir 		    {
981cdf0e10cSrcweir 			    OSL_ENSURE( sal_False, "FormOperations::propertyChange: caught an exception while updating the parser!" );
982cdf0e10cSrcweir 		    }
983cdf0e10cSrcweir             impl_invalidateAllSupportedFeatures_nothrow( aGuard );
984cdf0e10cSrcweir 	    }
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir 
987cdf0e10cSrcweir     //--------------------------------------------------------------------
disposing(const EventObject &)988cdf0e10cSrcweir     void SAL_CALL FormOperations::disposing( const EventObject& /*_Source*/ ) throw (RuntimeException)
989cdf0e10cSrcweir     {
990cdf0e10cSrcweir         // TODO: should we react on this? Or is this the responsibility of our owner to dispose us?
991cdf0e10cSrcweir     }
992cdf0e10cSrcweir 
993cdf0e10cSrcweir     //--------------------------------------------------------------------
disposing()994cdf0e10cSrcweir     void SAL_CALL FormOperations::disposing()
995cdf0e10cSrcweir     {
996cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
997cdf0e10cSrcweir 
998cdf0e10cSrcweir         impl_disposeParser_nothrow();
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir         try
1001cdf0e10cSrcweir         {
1002cdf0e10cSrcweir             // revoke various listeners
1003cdf0e10cSrcweir             if ( m_xCursor.is() )
1004cdf0e10cSrcweir                 m_xCursor->removeRowSetListener( this );
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 		    if ( m_xCursorProperties.is() )
1007cdf0e10cSrcweir 		    {
1008cdf0e10cSrcweir 			    m_xCursorProperties->removePropertyChangeListener( PROPERTY_ISMODIFIED,this );
1009cdf0e10cSrcweir 			    m_xCursorProperties->removePropertyChangeListener( PROPERTY_ISNEW, this );
1010cdf0e10cSrcweir 		    }
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir             Reference< XModifyBroadcaster > xBroadcaster( m_xController, UNO_QUERY );
1013cdf0e10cSrcweir 		    if ( xBroadcaster.is() )
1014cdf0e10cSrcweir 			    xBroadcaster->removeModifyListener( this );
1015cdf0e10cSrcweir         }
1016cdf0e10cSrcweir         catch( const Exception& )
1017cdf0e10cSrcweir         {
1018cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
1019cdf0e10cSrcweir         }
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir         m_xController.clear();
1022cdf0e10cSrcweir         m_xCursor.clear();
1023cdf0e10cSrcweir         m_xUpdateCursor.clear();
1024cdf0e10cSrcweir         m_xCursorProperties.clear();
1025cdf0e10cSrcweir         m_xLoadableForm.clear();
1026cdf0e10cSrcweir         m_xFeatureInvalidation.clear();
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir         m_bActiveControlModified = true;
1029cdf0e10cSrcweir     }
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_checkDisposed_throw() const1032cdf0e10cSrcweir     void FormOperations::impl_checkDisposed_throw() const
1033cdf0e10cSrcweir     {
1034cdf0e10cSrcweir         if ( impl_isDisposed_nothrow() )
1035cdf0e10cSrcweir             throw DisposedException( ::rtl::OUString(), *const_cast< FormOperations* >( this ) );
1036cdf0e10cSrcweir     }
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_initFromController_throw()1039cdf0e10cSrcweir     void FormOperations::impl_initFromController_throw()
1040cdf0e10cSrcweir     {
1041cdf0e10cSrcweir         OSL_PRECOND( m_xController.is(), "FormOperations::impl_initFromController_throw: invalid controller!" );
1042cdf0e10cSrcweir         m_xCursor = m_xCursor.query( m_xController->getModel() );
1043cdf0e10cSrcweir         if ( !m_xCursor.is() )
1044cdf0e10cSrcweir             throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir         impl_initFromForm_throw();
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir         Reference< XModifyBroadcaster > xBroadcaster( m_xController, UNO_QUERY );
1049cdf0e10cSrcweir 		if ( xBroadcaster.is() )
1050cdf0e10cSrcweir 			xBroadcaster->addModifyListener( this );
1051cdf0e10cSrcweir     }
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_initFromForm_throw()1054cdf0e10cSrcweir     void FormOperations::impl_initFromForm_throw()
1055cdf0e10cSrcweir     {
1056cdf0e10cSrcweir         OSL_PRECOND( m_xCursor.is(), "FormOperations::impl_initFromForm_throw: invalid form!" );
1057cdf0e10cSrcweir         m_xCursorProperties = m_xCursorProperties.query ( m_xCursor );
1058cdf0e10cSrcweir         m_xUpdateCursor     = m_xUpdateCursor.query     ( m_xCursor );
1059cdf0e10cSrcweir         m_xLoadableForm     = m_xLoadableForm.query     ( m_xCursor );
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir         if ( !m_xCursor.is() || !m_xCursorProperties.is() || !m_xLoadableForm.is() )
1062cdf0e10cSrcweir             throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir         m_xCursor->addRowSetListener( this );
1065cdf0e10cSrcweir 		m_xCursorProperties->addPropertyChangeListener( PROPERTY_ISMODIFIED,this );
1066cdf0e10cSrcweir 		m_xCursorProperties->addPropertyChangeListener( PROPERTY_ISNEW, this );
1067cdf0e10cSrcweir     }
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir     //--------------------------------------------------------------------
createWithFormController(const Reference<XFormController> & _rxController)1070cdf0e10cSrcweir     void FormOperations::createWithFormController( const Reference< XFormController >& _rxController )
1071cdf0e10cSrcweir     {
1072cdf0e10cSrcweir         m_xController = _rxController;
1073cdf0e10cSrcweir         if ( !m_xController.is() )
1074cdf0e10cSrcweir             throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir         impl_initFromController_throw();
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir         m_bConstructed = true;
1079cdf0e10cSrcweir     }
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir     //--------------------------------------------------------------------
createWithForm(const Reference<XForm> & _rxForm)1082cdf0e10cSrcweir     void FormOperations::createWithForm( const Reference< XForm >& _rxForm )
1083cdf0e10cSrcweir     {
1084cdf0e10cSrcweir         m_xCursor = m_xCursor.query( _rxForm );
1085cdf0e10cSrcweir         if ( !m_xCursor.is() )
1086cdf0e10cSrcweir             throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir         impl_initFromForm_throw();
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir         m_bConstructed = true;
1091cdf0e10cSrcweir     }
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_invalidateAllSupportedFeatures_nothrow(MethodGuard & _rClearForCallback) const1094cdf0e10cSrcweir     void FormOperations::impl_invalidateAllSupportedFeatures_nothrow( MethodGuard& _rClearForCallback ) const
1095cdf0e10cSrcweir     {
1096cdf0e10cSrcweir         if ( !m_xFeatureInvalidation.is() )
1097cdf0e10cSrcweir             // nobody's interested in ...
1098cdf0e10cSrcweir             return;
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir         Reference< XFeatureInvalidation > xInvalidation = m_xFeatureInvalidation;
1101cdf0e10cSrcweir         _rClearForCallback.clear();
1102cdf0e10cSrcweir         xInvalidation->invalidateAllFeatures();
1103cdf0e10cSrcweir     }
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_invalidateModifyDependentFeatures_nothrow(MethodGuard & _rClearForCallback) const1106cdf0e10cSrcweir     void FormOperations::impl_invalidateModifyDependentFeatures_nothrow( MethodGuard& _rClearForCallback ) const
1107cdf0e10cSrcweir     {
1108cdf0e10cSrcweir         if ( !m_xFeatureInvalidation.is() )
1109cdf0e10cSrcweir             // nobody's interested in ...
1110cdf0e10cSrcweir             return;
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir         static Sequence< sal_Int16 > s_aModifyDependentFeatures;
1113cdf0e10cSrcweir         if ( s_aModifyDependentFeatures.getLength() == 0 )
1114cdf0e10cSrcweir         {
1115cdf0e10cSrcweir             sal_Int16 pModifyDependentFeatures[] =
1116cdf0e10cSrcweir             {
1117cdf0e10cSrcweir 	            FormFeature::MoveToNext,
1118cdf0e10cSrcweir 	            FormFeature::MoveToInsertRow,
1119cdf0e10cSrcweir 	            FormFeature::SaveRecordChanges,
1120cdf0e10cSrcweir 	            FormFeature::UndoRecordChanges
1121cdf0e10cSrcweir             };
1122cdf0e10cSrcweir             size_t nFeatureCount = sizeof( pModifyDependentFeatures ) / sizeof( pModifyDependentFeatures[ 0 ] );
1123cdf0e10cSrcweir             s_aModifyDependentFeatures = Sequence< sal_Int16 >( pModifyDependentFeatures, nFeatureCount );
1124cdf0e10cSrcweir         }
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir         Reference< XFeatureInvalidation > xInvalidation = m_xFeatureInvalidation;
1127cdf0e10cSrcweir         _rClearForCallback.clear();
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir         xInvalidation->invalidateFeatures( s_aModifyDependentFeatures );
1130cdf0e10cSrcweir     }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_ensureInitializedParser_nothrow()1133cdf0e10cSrcweir     void FormOperations::impl_ensureInitializedParser_nothrow()
1134cdf0e10cSrcweir     {
1135cdf0e10cSrcweir         OSL_PRECOND( m_xCursorProperties.is(), "FormOperations::impl_ensureInitializedParser_nothrow: we're disposed!" );
1136cdf0e10cSrcweir         if ( m_bInitializedParser )
1137cdf0e10cSrcweir             return;
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir         try
1140cdf0e10cSrcweir         {
1141cdf0e10cSrcweir             sal_Bool bUseEscapeProcessing = sal_False;
1142cdf0e10cSrcweir             m_xCursorProperties->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bUseEscapeProcessing;
1143cdf0e10cSrcweir             if ( bUseEscapeProcessing )
1144cdf0e10cSrcweir             {
1145cdf0e10cSrcweir                 Reference< XMultiServiceFactory > xFactory( ::dbtools::getConnection( m_xCursor ), UNO_QUERY );
1146cdf0e10cSrcweir 	            if ( xFactory.is() )
1147cdf0e10cSrcweir                 {
1148cdf0e10cSrcweir 		            m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );
1149cdf0e10cSrcweir                     OSL_ENSURE( m_xParser.is(), "FormOperations::impl_ensureInitializedParser_nothrow: factory did not create a parser for us!" );
1150cdf0e10cSrcweir                 }
1151cdf0e10cSrcweir             }
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir 		    if ( m_xParser.is() )
1154cdf0e10cSrcweir 		    {
1155cdf0e10cSrcweir 			    if ( m_xLoadableForm.is() && m_xLoadableForm->isLoaded() )
1156cdf0e10cSrcweir 			    {
1157cdf0e10cSrcweir 				    ::rtl::OUString sStatement;
1158cdf0e10cSrcweir 				    ::rtl::OUString sFilter;
1159cdf0e10cSrcweir 				    ::rtl::OUString sSort;
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir                     m_xCursorProperties->getPropertyValue( PROPERTY_ACTIVECOMMAND   ) >>= sStatement;
1162cdf0e10cSrcweir 				    m_xCursorProperties->getPropertyValue( PROPERTY_FILTER          ) >>= sFilter;
1163cdf0e10cSrcweir 				    m_xCursorProperties->getPropertyValue( PROPERTY_SORT            ) >>= sSort;
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 					m_xParser->setElementaryQuery( sStatement );
1166cdf0e10cSrcweir 					m_xParser->setFilter         ( sFilter    );
1167cdf0e10cSrcweir 					m_xParser->setOrder          ( sSort      );
1168cdf0e10cSrcweir 			    }
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir                 // start listening at the order/sort properties at the form, so
1171cdf0e10cSrcweir                 // we can keep our parser in sync
1172cdf0e10cSrcweir 				m_xCursorProperties->addPropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
1173cdf0e10cSrcweir 				m_xCursorProperties->addPropertyChangeListener( PROPERTY_FILTER, this );
1174cdf0e10cSrcweir 				m_xCursorProperties->addPropertyChangeListener( PROPERTY_SORT, this );
1175cdf0e10cSrcweir 		    }
1176cdf0e10cSrcweir         }
1177cdf0e10cSrcweir         catch( const Exception& )
1178cdf0e10cSrcweir         {
1179cdf0e10cSrcweir 	        OSL_ENSURE( sal_False, "FormOperations::impl_ensureInitializedParser_nothrow: caught an exception!" );
1180cdf0e10cSrcweir         }
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir         m_bInitializedParser = true;
1183cdf0e10cSrcweir     }
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_disposeParser_nothrow()1186cdf0e10cSrcweir     void FormOperations::impl_disposeParser_nothrow()
1187cdf0e10cSrcweir     {
1188cdf0e10cSrcweir         try
1189cdf0e10cSrcweir         {
1190cdf0e10cSrcweir             // if we have a parser (and a cursor), then we're listening at the cursor's
1191cdf0e10cSrcweir             // properties to keep the parser in sync with the cursor
1192cdf0e10cSrcweir 		    if ( m_xParser.is() && m_xCursorProperties.is() )
1193cdf0e10cSrcweir 		    {
1194cdf0e10cSrcweir 			    m_xCursorProperties->removePropertyChangeListener( PROPERTY_FILTER, this );
1195cdf0e10cSrcweir 			    m_xCursorProperties->removePropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
1196cdf0e10cSrcweir 			    m_xCursorProperties->removePropertyChangeListener( PROPERTY_SORT, this );
1197cdf0e10cSrcweir 		    }
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir             Reference< XComponent > xParserComp( m_xParser, UNO_QUERY );
1200cdf0e10cSrcweir             if ( xParserComp.is() )
1201cdf0e10cSrcweir                 xParserComp->dispose();
1202cdf0e10cSrcweir             m_xParser.clear();
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir             m_bInitializedParser = false;
1205cdf0e10cSrcweir         }
1206cdf0e10cSrcweir         catch( const Exception& )
1207cdf0e10cSrcweir         {
1208cdf0e10cSrcweir             OSL_ENSURE( sal_False, "FormOperations::impl_disposeParser_nothrow: caught an exception!" );
1209cdf0e10cSrcweir         }
1210cdf0e10cSrcweir     }
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_canMoveLeft_throw() const1213cdf0e10cSrcweir     bool FormOperations::impl_canMoveLeft_throw( ) const
1214cdf0e10cSrcweir     {
1215cdf0e10cSrcweir         if ( !impl_hasCursor_nothrow() )
1216cdf0e10cSrcweir             return false;
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir         return impl_getRowCount_throw() && ( !m_xCursor->isFirst() || impl_isInsertionRow_throw() );
1219cdf0e10cSrcweir     }
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_canMoveRight_throw() const1222cdf0e10cSrcweir     bool FormOperations::impl_canMoveRight_throw( ) const
1223cdf0e10cSrcweir     {
1224cdf0e10cSrcweir         if ( !impl_hasCursor_nothrow() )
1225cdf0e10cSrcweir             return false;
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir         bool bIsNew = impl_isInsertionRow_throw();
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir         if ( impl_getRowCount_throw() && !m_xCursor->isLast() && !bIsNew )
1230cdf0e10cSrcweir             return true;
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir         if ( ::dbtools::canInsert( m_xCursorProperties ) )
1233cdf0e10cSrcweir             if ( !bIsNew || impl_isModifiedRow_throw() )
1234cdf0e10cSrcweir                 return true;
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir         if ( bIsNew && m_bActiveControlModified )
1237cdf0e10cSrcweir             return true;
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir         return false;
1240cdf0e10cSrcweir     }
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir     //--------------------------------------------------------------------
1243cdf0e10cSrcweir     namespace
1244cdf0e10cSrcweir     {
1245cdf0e10cSrcweir         template < typename TYPE >
lcl_safeGetPropertyValue_throw(const Reference<XPropertySet> & _rxProperties,const::rtl::OUString & _rPropertyName,TYPE _Default)1246cdf0e10cSrcweir         TYPE lcl_safeGetPropertyValue_throw( const Reference< XPropertySet >& _rxProperties, const ::rtl::OUString& _rPropertyName, TYPE _Default )
1247cdf0e10cSrcweir         {
1248cdf0e10cSrcweir             TYPE value( _Default );
1249cdf0e10cSrcweir             OSL_PRECOND( _rxProperties.is(), "FormOperations::<foo>: no cursor (already disposed?)!" );
1250cdf0e10cSrcweir             if ( _rxProperties.is() )
1251cdf0e10cSrcweir                 OSL_VERIFY( _rxProperties->getPropertyValue( _rPropertyName ) >>= value );
1252cdf0e10cSrcweir             return value;
1253cdf0e10cSrcweir         }
1254cdf0e10cSrcweir     }
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_isInsertionRow_throw() const1257cdf0e10cSrcweir     bool FormOperations::impl_isInsertionRow_throw() const
1258cdf0e10cSrcweir     {
1259cdf0e10cSrcweir         return lcl_safeGetPropertyValue_throw( m_xCursorProperties, PROPERTY_ISNEW, false );
1260cdf0e10cSrcweir     }
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_getRowCount_throw() const1263cdf0e10cSrcweir     sal_Int32 FormOperations::impl_getRowCount_throw() const
1264cdf0e10cSrcweir     {
1265cdf0e10cSrcweir         return lcl_safeGetPropertyValue_throw( m_xCursorProperties, PROPERTY_ROWCOUNT, (sal_Int32)0 );
1266cdf0e10cSrcweir     }
1267cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_isRowCountFinal_throw() const1268cdf0e10cSrcweir     bool FormOperations::impl_isRowCountFinal_throw() const
1269cdf0e10cSrcweir     {
1270cdf0e10cSrcweir         return lcl_safeGetPropertyValue_throw( m_xCursorProperties, PROPERTY_ROWCOUNTFINAL, false );
1271cdf0e10cSrcweir     }
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_isModifiedRow_throw() const1274cdf0e10cSrcweir     bool FormOperations::impl_isModifiedRow_throw() const
1275cdf0e10cSrcweir     {
1276cdf0e10cSrcweir         return lcl_safeGetPropertyValue_throw( m_xCursorProperties, PROPERTY_ISMODIFIED, false );
1277cdf0e10cSrcweir     }
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_isParseable_throw() const1280cdf0e10cSrcweir     bool FormOperations::impl_isParseable_throw() const
1281cdf0e10cSrcweir     {
1282cdf0e10cSrcweir         const_cast< FormOperations* >( this )->impl_ensureInitializedParser_nothrow();
1283cdf0e10cSrcweir         return m_xParser.is() && m_xParser->getQuery().getLength();
1284cdf0e10cSrcweir     }
1285cdf0e10cSrcweir 
1286cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_hasFilterOrOrder_throw() const1287cdf0e10cSrcweir 	bool FormOperations::impl_hasFilterOrOrder_throw() const
1288cdf0e10cSrcweir     {
1289cdf0e10cSrcweir         return impl_isParseable_throw() && ( m_xParser->getFilter().getLength() || m_xParser->getOrder().getLength() );
1290cdf0e10cSrcweir     }
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_isInsertOnlyForm_throw() const1293cdf0e10cSrcweir     bool FormOperations::impl_isInsertOnlyForm_throw() const
1294cdf0e10cSrcweir     {
1295cdf0e10cSrcweir         return lcl_safeGetPropertyValue_throw( m_xCursorProperties, PROPERTY_INSERTONLY, true );
1296cdf0e10cSrcweir     }
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_getCurrentControlModel_throw() const1299cdf0e10cSrcweir     Reference< XControlModel > FormOperations::impl_getCurrentControlModel_throw() const
1300cdf0e10cSrcweir     {
1301cdf0e10cSrcweir         Reference< XControl > xControl( m_xController->getCurrentControl() );
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir         // special handling for grid controls
1304cdf0e10cSrcweir         Reference< XGrid > xGrid( xControl, UNO_QUERY );
1305cdf0e10cSrcweir         Reference< XControlModel > xControlModel;
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir         if ( xGrid.is() )
1308cdf0e10cSrcweir         {
1309cdf0e10cSrcweir 	        Reference< XIndexAccess > xColumns( xControl->getModel(), UNO_QUERY_THROW );
1310cdf0e10cSrcweir 	        sal_Int16 nCurrentPos = xGrid->getCurrentColumnPosition();
1311cdf0e10cSrcweir 	        nCurrentPos = impl_gridView2ModelPos_nothrow( xColumns, nCurrentPos );
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir             if ( nCurrentPos != (sal_Int16)-1 )
1314cdf0e10cSrcweir 		        xColumns->getByIndex( nCurrentPos ) >>= xControlModel;
1315cdf0e10cSrcweir         }
1316cdf0e10cSrcweir         else if ( xControl.is() )
1317cdf0e10cSrcweir         {
1318cdf0e10cSrcweir 	        xControlModel = xControl->getModel();
1319cdf0e10cSrcweir         }
1320cdf0e10cSrcweir         return xControlModel;
1321cdf0e10cSrcweir     }
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_getCurrentBoundField_nothrow() const1324cdf0e10cSrcweir     Reference< XPropertySet > FormOperations::impl_getCurrentBoundField_nothrow( ) const
1325cdf0e10cSrcweir     {
1326cdf0e10cSrcweir         OSL_PRECOND( m_xController.is(), "FormOperations::impl_getCurrentBoundField_nothrow: no controller -> no control!" );
1327cdf0e10cSrcweir         if ( !m_xController.is() )
1328cdf0e10cSrcweir             return NULL;
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir         Reference< XPropertySet > xField;
1331cdf0e10cSrcweir         try
1332cdf0e10cSrcweir         {
1333cdf0e10cSrcweir             Reference< XPropertySet > xControlModel( impl_getCurrentControlModel_throw(), UNO_QUERY );
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir 	        if ( xControlModel.is() && ::comphelper::hasProperty( PROPERTY_BOUNDFIELD, xControlModel ) )
1336cdf0e10cSrcweir 		        xControlModel->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= xField;
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir         }
1339cdf0e10cSrcweir         catch( const Exception& )
1340cdf0e10cSrcweir         {
1341cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
1342cdf0e10cSrcweir         }
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir 	    return xField;
1345cdf0e10cSrcweir     }
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_gridView2ModelPos_nothrow(const Reference<XIndexAccess> & _rxColumns,sal_Int16 _nViewPos) const1348cdf0e10cSrcweir     sal_Int16 FormOperations::impl_gridView2ModelPos_nothrow( const Reference< XIndexAccess >& _rxColumns, sal_Int16 _nViewPos ) const
1349cdf0e10cSrcweir     {
1350cdf0e10cSrcweir         OSL_PRECOND( _rxColumns.is(), "FormOperations::impl_gridView2ModelPos_nothrow: invalid columns container!" );
1351cdf0e10cSrcweir         try
1352cdf0e10cSrcweir         {
1353cdf0e10cSrcweir             // loop through all columns
1354cdf0e10cSrcweir             sal_Int16 col = 0;
1355cdf0e10cSrcweir             Reference< XPropertySet > xCol;
1356cdf0e10cSrcweir             bool bHidden( false );
1357cdf0e10cSrcweir             for ( col = 0; col < _rxColumns->getCount(); ++col )
1358cdf0e10cSrcweir             {
1359cdf0e10cSrcweir                 _rxColumns->getByIndex( col ) >>= xCol;
1360cdf0e10cSrcweir                 OSL_VERIFY( xCol->getPropertyValue( PROPERTY_HIDDEN ) >>= bHidden );
1361cdf0e10cSrcweir                 if ( bHidden )
1362cdf0e10cSrcweir                     continue;
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir                 // for every visible col : if nViewPos is greater zero, decrement it, else we
1365cdf0e10cSrcweir                 // have found the model position
1366cdf0e10cSrcweir                 if ( !_nViewPos )
1367cdf0e10cSrcweir                     break;
1368cdf0e10cSrcweir                 else
1369cdf0e10cSrcweir                     --_nViewPos;
1370cdf0e10cSrcweir             }
1371cdf0e10cSrcweir             if ( col < _rxColumns->getCount() )
1372cdf0e10cSrcweir                 return col;
1373cdf0e10cSrcweir         }
1374cdf0e10cSrcweir         catch( const Exception& )
1375cdf0e10cSrcweir         {
1376cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
1377cdf0e10cSrcweir         }
1378cdf0e10cSrcweir         return (sal_Int16)-1;
1379cdf0e10cSrcweir     }
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_moveLeft_throw() const1382cdf0e10cSrcweir     bool FormOperations::impl_moveLeft_throw( ) const
1383cdf0e10cSrcweir     {
1384cdf0e10cSrcweir         OSL_PRECOND( impl_hasCursor_nothrow(), "FormOperations::impl_moveLeft_throw: no cursor!" );
1385cdf0e10cSrcweir 	    if ( !impl_hasCursor_nothrow() )
1386cdf0e10cSrcweir 		    return false;
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir 	    sal_Bool bRecordInserted = sal_False;
1389cdf0e10cSrcweir 	    sal_Bool bSuccess = impl_commitCurrentRecord_throw( &bRecordInserted );
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir 	    if ( !bSuccess )
1392cdf0e10cSrcweir             return false;
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir 		if ( bRecordInserted )
1395cdf0e10cSrcweir 		{
1396cdf0e10cSrcweir 			// retrieve the bookmark of the new record and move to the record preceding this bookmark
1397cdf0e10cSrcweir 			Reference< XRowLocate > xLocate( m_xCursor, UNO_QUERY );
1398cdf0e10cSrcweir             OSL_ENSURE( xLocate.is(), "FormOperations::impl_moveLeft_throw: no XRowLocate!" );
1399cdf0e10cSrcweir             if ( xLocate.is() )
1400cdf0e10cSrcweir                 xLocate->moveRelativeToBookmark( xLocate->getBookmark(), -1 );
1401cdf0e10cSrcweir 		}
1402cdf0e10cSrcweir 		else
1403cdf0e10cSrcweir         {
1404cdf0e10cSrcweir             if ( impl_isInsertionRow_throw() )
1405cdf0e10cSrcweir 			{
1406cdf0e10cSrcweir 				// we assume that the inserted record is now the last record in the
1407cdf0e10cSrcweir 				// result set
1408cdf0e10cSrcweir 				m_xCursor->last();
1409cdf0e10cSrcweir 			}
1410cdf0e10cSrcweir 			else
1411cdf0e10cSrcweir 				m_xCursor->previous();
1412cdf0e10cSrcweir         }
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir         return true;
1415cdf0e10cSrcweir     }
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_moveRight_throw() const1418cdf0e10cSrcweir     bool FormOperations::impl_moveRight_throw( ) const
1419cdf0e10cSrcweir     {
1420cdf0e10cSrcweir         OSL_PRECOND( impl_hasCursor_nothrow(), "FormOperations::impl_moveRight_throw: no cursor!" );
1421cdf0e10cSrcweir 	    if ( !impl_hasCursor_nothrow() )
1422cdf0e10cSrcweir 		    return false;
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir 	    sal_Bool bRecordInserted = sal_False;
1425cdf0e10cSrcweir 	    sal_Bool bSuccess = impl_commitCurrentRecord_throw( &bRecordInserted );
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir         if ( !bSuccess )
1428cdf0e10cSrcweir             return false;
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir 		if ( bRecordInserted )
1431cdf0e10cSrcweir 		{
1432cdf0e10cSrcweir 			// go to insert row
1433cdf0e10cSrcweir 			m_xUpdateCursor->moveToInsertRow();
1434cdf0e10cSrcweir 		}
1435cdf0e10cSrcweir 		else
1436cdf0e10cSrcweir 		{
1437cdf0e10cSrcweir 			if ( m_xCursor->isLast() )
1438cdf0e10cSrcweir 				m_xUpdateCursor->moveToInsertRow();
1439cdf0e10cSrcweir 			else
1440cdf0e10cSrcweir 				m_xCursor->next();
1441cdf0e10cSrcweir 		}
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir 	    return true;
1444cdf0e10cSrcweir     }
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_resetAllControls_nothrow() const1447cdf0e10cSrcweir     void FormOperations::impl_resetAllControls_nothrow() const
1448cdf0e10cSrcweir     {
1449cdf0e10cSrcweir 	    Reference< XIndexAccess > xContainer( m_xCursor, UNO_QUERY );
1450cdf0e10cSrcweir 		if ( !xContainer.is() )
1451cdf0e10cSrcweir             return;
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir         try
1454cdf0e10cSrcweir         {
1455cdf0e10cSrcweir             Reference< XReset > xReset;
1456cdf0e10cSrcweir             sal_Int32 nCount( xContainer->getCount() );
1457cdf0e10cSrcweir 		    for ( sal_Int32 i = 0; i < nCount; ++i )
1458cdf0e10cSrcweir 		    {
1459cdf0e10cSrcweir 			    if ( xContainer->getByIndex( i ) >>= xReset )
1460cdf0e10cSrcweir 			    {
1461cdf0e10cSrcweir                     // no resets on sub forms
1462cdf0e10cSrcweir 				    Reference< XForm > xAsForm( xReset, UNO_QUERY );
1463cdf0e10cSrcweir 				    if ( !xAsForm.is() )
1464cdf0e10cSrcweir 					    xReset->reset();
1465cdf0e10cSrcweir 			    }
1466cdf0e10cSrcweir 		    }
1467cdf0e10cSrcweir         }
1468cdf0e10cSrcweir         catch( const Exception& )
1469cdf0e10cSrcweir         {
1470cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
1471cdf0e10cSrcweir         }
1472cdf0e10cSrcweir     }
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_executeAutoSort_throw(bool _bUp) const1475cdf0e10cSrcweir     void FormOperations::impl_executeAutoSort_throw( bool _bUp ) const
1476cdf0e10cSrcweir     {
1477cdf0e10cSrcweir         OSL_PRECOND( m_xController.is(), "FormOperations::impl_executeAutoSort_throw: need a controller for this!" );
1478cdf0e10cSrcweir         OSL_PRECOND( impl_hasCursor_nothrow(), "FormOperations::impl_executeAutoSort_throw: need a cursor for this!" );
1479cdf0e10cSrcweir         OSL_PRECOND( impl_isParseable_throw(), "FormOperations::impl_executeAutoSort_throw: need a parseable statement for this!" );
1480cdf0e10cSrcweir         if ( !m_xController.is() || !impl_hasCursor_nothrow() || !impl_isParseable_throw() )
1481cdf0e10cSrcweir             return;
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir         try
1484cdf0e10cSrcweir         {
1485cdf0e10cSrcweir 		    Reference< XControl > xControl = m_xController->getCurrentControl();
1486cdf0e10cSrcweir             if ( !xControl.is() || !impl_commitCurrentControl_throw() || !impl_commitCurrentRecord_throw() )
1487cdf0e10cSrcweir                 return;
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir             Reference< XPropertySet > xBoundField( impl_getCurrentBoundField_nothrow() );
1490cdf0e10cSrcweir 			if ( !xBoundField.is() )
1491cdf0e10cSrcweir                 return;
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir             ::rtl::OUString sOriginalSort;
1494cdf0e10cSrcweir 			m_xCursorProperties->getPropertyValue( PROPERTY_SORT ) >>= sOriginalSort;
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 			// automatic sort by field is expected to always resets the previous sort order
1497cdf0e10cSrcweir     		m_xParser->setOrder( ::rtl::OUString() );
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir             param_appendOrderByColumn aParam;
1500cdf0e10cSrcweir             aParam.xField = xBoundField;
1501cdf0e10cSrcweir             aParam.bUp = _bUp;
1502cdf0e10cSrcweir 			impl_doActionInSQLContext_throw(
1503cdf0e10cSrcweir                 (Action)&FormOperations::impl_appendOrderByColumn_throw,
1504cdf0e10cSrcweir                 static_cast< const void* >( &aParam ),
1505cdf0e10cSrcweir                 (sal_uInt16)RID_STR_COULD_NOT_SET_ORDER
1506cdf0e10cSrcweir             );
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir 			WaitObject aWO( NULL );
1509cdf0e10cSrcweir 			try
1510cdf0e10cSrcweir 			{
1511cdf0e10cSrcweir 				m_xCursorProperties->setPropertyValue( PROPERTY_SORT, makeAny( m_xParser->getOrder() ) );
1512cdf0e10cSrcweir 				m_xLoadableForm->reload();
1513cdf0e10cSrcweir 			}
1514cdf0e10cSrcweir 			catch( const Exception& )
1515cdf0e10cSrcweir 			{
1516cdf0e10cSrcweir                 OSL_ENSURE( sal_False, "FormOperations::impl_executeAutoSort_throw: caught an exception while setting the parser properties!" );
1517cdf0e10cSrcweir 			}
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 			if ( !m_xLoadableForm->isLoaded() )
1521cdf0e10cSrcweir 			{	// something went wrong -> restore the original state
1522cdf0e10cSrcweir 				try
1523cdf0e10cSrcweir 				{
1524cdf0e10cSrcweir 					m_xParser->setOrder( sOriginalSort );
1525cdf0e10cSrcweir 					m_xCursorProperties->setPropertyValue( PROPERTY_SORT, makeAny( m_xParser->getOrder() ) );
1526cdf0e10cSrcweir 					m_xLoadableForm->reload();
1527cdf0e10cSrcweir 				}
1528cdf0e10cSrcweir 				catch( const Exception& )
1529cdf0e10cSrcweir 				{
1530cdf0e10cSrcweir                     OSL_ENSURE( sal_False, "FormOperations::impl_executeAutoSort_throw: could not reset the form to it's original state!" );
1531cdf0e10cSrcweir 				}
1532cdf0e10cSrcweir 
1533cdf0e10cSrcweir 			}
1534cdf0e10cSrcweir         }
1535cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
1536cdf0e10cSrcweir         catch( const SQLException& ) { throw; }
1537cdf0e10cSrcweir         catch( const Exception& )
1538cdf0e10cSrcweir         {
1539cdf0e10cSrcweir             throw WrappedTargetException( ::rtl::OUString(), *const_cast< FormOperations* >( this ), ::cppu::getCaughtException() );
1540cdf0e10cSrcweir         }
1541cdf0e10cSrcweir     }
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_executeAutoFilter_throw() const1544cdf0e10cSrcweir     void FormOperations::impl_executeAutoFilter_throw( ) const
1545cdf0e10cSrcweir     {
1546cdf0e10cSrcweir         OSL_PRECOND( m_xController.is(), "FormOperations::impl_executeAutoFilter_throw: need a controller for this!" );
1547cdf0e10cSrcweir         OSL_PRECOND( impl_hasCursor_nothrow(), "FormOperations::impl_executeAutoFilter_throw: need a cursor for this!" );
1548cdf0e10cSrcweir         OSL_PRECOND( impl_isParseable_throw(), "FormOperations::impl_executeAutoFilter_throw: need a parseable statement for this!" );
1549cdf0e10cSrcweir         if ( !m_xController.is() || !impl_hasCursor_nothrow() || !impl_isParseable_throw() )
1550cdf0e10cSrcweir             return;
1551cdf0e10cSrcweir 
1552cdf0e10cSrcweir         try
1553cdf0e10cSrcweir         {
1554cdf0e10cSrcweir 		    Reference< XControl > xControl = m_xController->getCurrentControl();
1555cdf0e10cSrcweir             if ( !xControl.is() || !impl_commitCurrentControl_throw() || !impl_commitCurrentRecord_throw() )
1556cdf0e10cSrcweir                 return;
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir             Reference< XPropertySet > xBoundField( impl_getCurrentBoundField_nothrow() );
1559cdf0e10cSrcweir 		    if ( !xBoundField.is() )
1560cdf0e10cSrcweir                 return;
1561cdf0e10cSrcweir 
1562cdf0e10cSrcweir 		    ::rtl::OUString sOriginalFilter;
1563cdf0e10cSrcweir             m_xCursorProperties->getPropertyValue( PROPERTY_FILTER ) >>= sOriginalFilter;
1564cdf0e10cSrcweir 		    sal_Bool bApplied = sal_True;
1565cdf0e10cSrcweir             m_xCursorProperties->getPropertyValue( PROPERTY_APPLYFILTER ) >>= bApplied;
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 		    // if we have a filter, but it's not applied, then we have to overwrite it, else append one
1568cdf0e10cSrcweir 		    if ( !bApplied )
1569cdf0e10cSrcweir                 m_xParser->setFilter( ::rtl::OUString() );
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir             param_appendFilterByColumn aParam;
1572cdf0e10cSrcweir             aParam.xField = xBoundField;
1573cdf0e10cSrcweir 		    impl_doActionInSQLContext_throw(
1574cdf0e10cSrcweir                 (Action)&FormOperations::impl_appendFilterByColumn_throw,
1575cdf0e10cSrcweir                 static_cast< const void* >( &aParam ),
1576cdf0e10cSrcweir                 (sal_uInt16)RID_STR_COULD_NOT_SET_FILTER
1577cdf0e10cSrcweir             );
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir             WaitObject aWO( NULL );
1580cdf0e10cSrcweir 		    try
1581cdf0e10cSrcweir 		    {
1582cdf0e10cSrcweir 			    m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, makeAny( m_xParser->getFilter() ) );
1583cdf0e10cSrcweir 			    m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, makeAny( (sal_Bool)sal_True ) );
1584cdf0e10cSrcweir 
1585cdf0e10cSrcweir 			    m_xLoadableForm->reload();
1586cdf0e10cSrcweir 		    }
1587cdf0e10cSrcweir 		    catch( const Exception& )
1588cdf0e10cSrcweir 		    {
1589cdf0e10cSrcweir                 OSL_ENSURE( sal_False, "FormOperations::impl_executeAutoFilter_throw: caught an exception while setting the parser properties!" );
1590cdf0e10cSrcweir 		    }
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir 		    if ( !m_xLoadableForm->isLoaded() )
1594cdf0e10cSrcweir 		    {	// something went wrong -> restore the original state
1595cdf0e10cSrcweir 			    try
1596cdf0e10cSrcweir 			    {
1597cdf0e10cSrcweir 				    m_xParser->setOrder( sOriginalFilter );
1598cdf0e10cSrcweir 				    m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, makeAny( (sal_Bool)bApplied ) );
1599cdf0e10cSrcweir 				    m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, makeAny( m_xParser->getFilter() ) );
1600cdf0e10cSrcweir 				    m_xLoadableForm->reload();
1601cdf0e10cSrcweir 			    }
1602cdf0e10cSrcweir 			    catch( const Exception& )
1603cdf0e10cSrcweir 			    {
1604cdf0e10cSrcweir                     OSL_ENSURE( sal_False, "FormOperations::impl_executeAutoFilter_throw: could not reset the form to it's original state!" );
1605cdf0e10cSrcweir 			    }
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir 		    }
1608cdf0e10cSrcweir         }
1609cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
1610cdf0e10cSrcweir         catch( const SQLException& ) { throw; }
1611cdf0e10cSrcweir         catch( const Exception& )
1612cdf0e10cSrcweir         {
1613cdf0e10cSrcweir             throw WrappedTargetException( ::rtl::OUString(), *const_cast< FormOperations* >( this ), ::cppu::getCaughtException() );
1614cdf0e10cSrcweir         }
1615cdf0e10cSrcweir     }
1616cdf0e10cSrcweir 
1617cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_executeFilterOrSort_throw(bool _bFilter) const1618cdf0e10cSrcweir     void FormOperations::impl_executeFilterOrSort_throw( bool _bFilter ) const
1619cdf0e10cSrcweir     {
1620cdf0e10cSrcweir         OSL_PRECOND( m_xController.is(), "FormOperations::impl_executeFilterOrSort_throw: need a controller for this!" );
1621cdf0e10cSrcweir         OSL_PRECOND( impl_hasCursor_nothrow(), "FormOperations::impl_executeFilterOrSort_throw: need a cursor for this!" );
1622cdf0e10cSrcweir         OSL_PRECOND( impl_isParseable_throw(), "FormOperations::impl_executeFilterOrSort_throw: need a parseable statement for this!" );
1623cdf0e10cSrcweir         if ( !m_xController.is() || !impl_hasCursor_nothrow() || !impl_isParseable_throw() )
1624cdf0e10cSrcweir             return;
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir         if ( !impl_commitCurrentControl_throw() || !impl_commitCurrentRecord_throw() )
1627cdf0e10cSrcweir             return;
1628cdf0e10cSrcweir 		try
1629cdf0e10cSrcweir 		{
1630cdf0e10cSrcweir 			PropertyValue aFirst;
1631cdf0e10cSrcweir 			aFirst.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "QueryComposer" ) );
1632cdf0e10cSrcweir 			aFirst.Value <<= m_xParser;
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir 			PropertyValue aSecond;
1635cdf0e10cSrcweir 			aSecond.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowSet" ) );
1636cdf0e10cSrcweir 			aSecond.Value <<= m_xCursorProperties;
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir 			Sequence<Any> aInit(2);
1639cdf0e10cSrcweir 			aInit[0] <<= aFirst;
1640cdf0e10cSrcweir 			aInit[1] <<= aSecond;
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir             ::rtl::OUString sDialogServiceName;
1643cdf0e10cSrcweir             if ( _bFilter )
1644cdf0e10cSrcweir                 sDialogServiceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.FilterDialog" ) );
1645cdf0e10cSrcweir             else
1646cdf0e10cSrcweir                 sDialogServiceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.OrderDialog" ) );
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir             Reference< XExecutableDialog> xDialog;
1649cdf0e10cSrcweir             m_aContext.createComponentWithArguments( sDialogServiceName, aInit, xDialog );
1650cdf0e10cSrcweir 
1651cdf0e10cSrcweir 			if ( !xDialog.is() )
1652cdf0e10cSrcweir             {
1653cdf0e10cSrcweir     		    ShowServiceNotAvailableError( NULL, sDialogServiceName, sal_True );
1654cdf0e10cSrcweir                 return;
1655cdf0e10cSrcweir             }
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir             if ( RET_OK == xDialog->execute() )
1658cdf0e10cSrcweir             {
1659cdf0e10cSrcweir         		WaitObject aWO( NULL );
1660cdf0e10cSrcweir                 if ( _bFilter )
1661cdf0e10cSrcweir                     m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, makeAny( m_xParser->getFilter() ) );
1662cdf0e10cSrcweir                 else
1663cdf0e10cSrcweir                     m_xCursorProperties->setPropertyValue( PROPERTY_SORT, makeAny( m_xParser->getOrder() ) );
1664cdf0e10cSrcweir 		    	m_xLoadableForm->reload();
1665cdf0e10cSrcweir             }
1666cdf0e10cSrcweir 
1667cdf0e10cSrcweir 		}
1668cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
1669cdf0e10cSrcweir         catch( const SQLException& ) { throw; }
1670cdf0e10cSrcweir 		catch( const Exception& )
1671cdf0e10cSrcweir 		{
1672cdf0e10cSrcweir             throw WrappedTargetException( ::rtl::OUString(), *const_cast< FormOperations* >( this ), ::cppu::getCaughtException() );
1673cdf0e10cSrcweir 		}
1674cdf0e10cSrcweir     }
1675cdf0e10cSrcweir 
1676cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_appendOrderByColumn_throw(const void * _pActionParam) const1677cdf0e10cSrcweir     void FormOperations::impl_appendOrderByColumn_throw( const void* _pActionParam ) const
1678cdf0e10cSrcweir     {
1679cdf0e10cSrcweir         const param_appendOrderByColumn* pParam = static_cast< const param_appendOrderByColumn* >( _pActionParam );
1680cdf0e10cSrcweir         m_xParser->appendOrderByColumn( pParam->xField, pParam->bUp );
1681cdf0e10cSrcweir     }
1682cdf0e10cSrcweir 
1683cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_appendFilterByColumn_throw(const void * _pActionParam) const1684cdf0e10cSrcweir     void FormOperations::impl_appendFilterByColumn_throw( const void* _pActionParam ) const
1685cdf0e10cSrcweir     {
1686cdf0e10cSrcweir         const param_appendFilterByColumn* pParam = static_cast< const param_appendFilterByColumn* >( _pActionParam );
1687cdf0e10cSrcweir         sal_Int32 nOp = SQLFilterOperator::EQUAL;
1688cdf0e10cSrcweir         if ( pParam->xField.is() )
1689cdf0e10cSrcweir         {
1690cdf0e10cSrcweir             sal_Int32 nType = 0;
1691cdf0e10cSrcweir             pParam->xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nType;
1692cdf0e10cSrcweir             switch(nType)
1693cdf0e10cSrcweir             {
1694cdf0e10cSrcweir                 case DataType::VARCHAR:
1695cdf0e10cSrcweir 	            case DataType::CHAR:
1696cdf0e10cSrcweir 	            case DataType::LONGVARCHAR:
1697cdf0e10cSrcweir                     nOp = SQLFilterOperator::LIKE;
1698cdf0e10cSrcweir                     break;
1699cdf0e10cSrcweir                 default:
1700cdf0e10cSrcweir                     nOp = SQLFilterOperator::EQUAL;
1701cdf0e10cSrcweir             }
1702cdf0e10cSrcweir         }
1703cdf0e10cSrcweir         m_xParser->appendFilterByColumn( pParam->xField, sal_True,nOp );
1704cdf0e10cSrcweir     }
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir     //------------------------------------------------------------------------------
impl_doActionInSQLContext_throw(Action _pAction,const void * _pParam,sal_uInt16 _nErrorResourceId) const1707cdf0e10cSrcweir     void FormOperations::impl_doActionInSQLContext_throw( Action _pAction, const void* _pParam, sal_uInt16 _nErrorResourceId ) const
1708cdf0e10cSrcweir     {
1709cdf0e10cSrcweir 	    try
1710cdf0e10cSrcweir 	    {
1711cdf0e10cSrcweir 		    (this->*_pAction)( _pParam );
1712cdf0e10cSrcweir 	    }
1713cdf0e10cSrcweir 	    catch( const SQLException& e )
1714cdf0e10cSrcweir 	    {
1715cdf0e10cSrcweir             (void)e;
1716cdf0e10cSrcweir             if ( !_nErrorResourceId )
1717cdf0e10cSrcweir                 // no information to prepend
1718cdf0e10cSrcweir                 throw;
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir             SQLExceptionInfo aInfo( ::cppu::getCaughtException() );
1721cdf0e10cSrcweir             ::rtl::OUString sAdditionalError( FRM_RES_STRING( _nErrorResourceId ) );
1722cdf0e10cSrcweir             aInfo.prepend( sAdditionalError );
1723cdf0e10cSrcweir             aInfo.doThrow();
1724cdf0e10cSrcweir 	    }
1725cdf0e10cSrcweir         catch( const RuntimeException& ) { throw; }
1726cdf0e10cSrcweir 	    catch( const Exception& )
1727cdf0e10cSrcweir 	    {
1728cdf0e10cSrcweir             ::rtl::OUString sAdditionalError( FRM_RES_STRING( _nErrorResourceId ) );
1729cdf0e10cSrcweir             throw WrappedTargetException( sAdditionalError, *const_cast< FormOperations* >( this ), ::cppu::getCaughtException() );
1730cdf0e10cSrcweir 	    }
1731cdf0e10cSrcweir     }
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir //........................................................................
1734cdf0e10cSrcweir } // namespace frm
1735cdf0e10cSrcweir //........................................................................
1736