Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "browserids.hxx"
21 : : #include "brwctrlr.hxx"
22 : : #include "brwview.hxx"
23 : : #include "dbu_brw.hrc"
24 : : #include "dbustrings.hrc"
25 : : #include "queryfilter.hxx"
26 : : #include "queryorder.hxx"
27 : : #include "sqlmessage.hxx"
28 : :
29 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
30 : : #include <com/sun/star/container/XNameContainer.hpp>
31 : : #include <com/sun/star/container/XNamed.hpp>
32 : : #include <com/sun/star/form/FormButtonType.hpp>
33 : : #include <com/sun/star/form/FormSubmitEncoding.hpp>
34 : : #include <com/sun/star/form/FormSubmitMethod.hpp>
35 : : #include <com/sun/star/form/XApproveActionBroadcaster.hpp>
36 : : #include <com/sun/star/form/XBoundControl.hpp>
37 : : #include <com/sun/star/form/XChangeBroadcaster.hpp>
38 : : #include <com/sun/star/form/XChangeListener.hpp>
39 : : #include <com/sun/star/form/XDatabaseParameterBroadcaster.hpp>
40 : : #include <com/sun/star/form/XLoadable.hpp>
41 : : #include <com/sun/star/form/XReset.hpp>
42 : : #include <com/sun/star/form/XResetListener.hpp>
43 : : #include <com/sun/star/form/XSubmit.hpp>
44 : : #include <com/sun/star/form/XSubmitListener.hpp>
45 : : #include <com/sun/star/form/runtime/XFormController.hpp>
46 : : #include <com/sun/star/sdb/CommandType.hpp>
47 : : #include <com/sun/star/sdb/ErrorCondition.hpp>
48 : : #include <com/sun/star/sdb/ParametersRequest.hpp>
49 : : #include <com/sun/star/sdb/SQLContext.hpp>
50 : : #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
51 : : #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
52 : : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
53 : : #include <com/sun/star/sdb/SQLFilterOperator.hpp>
54 : : #include <com/sun/star/sdbc/XConnection.hpp>
55 : : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
56 : : #include <com/sun/star/sdbc/XRowSetListener.hpp>
57 : : #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
58 : : #include <com/sun/star/sdbcx/Privilege.hpp>
59 : : #include <com/sun/star/sdbcx/XRowLocate.hpp>
60 : : #include <com/sun/star/task/XInteractionHandler.hpp>
61 : : #include <com/sun/star/uno/TypeClass.hpp>
62 : : #include <com/sun/star/util/XCancellable.hpp>
63 : :
64 : : #include <comphelper/enumhelper.hxx>
65 : : #include <comphelper/extract.hxx>
66 : : #include <comphelper/interaction.hxx>
67 : : #include <comphelper/sequence.hxx>
68 : : #include <comphelper/string.hxx>
69 : : #include <connectivity/dbexception.hxx>
70 : : #include <connectivity/dbtools.hxx>
71 : : #include <connectivity/sqlerror.hxx>
72 : : #include <cppuhelper/exc_hlp.hxx>
73 : : #include <cppuhelper/implbase2.hxx>
74 : : #include <cppuhelper/typeprovider.hxx>
75 : : #include <osl/mutex.hxx>
76 : : #include <rtl/logfile.hxx>
77 : : #include <sfx2/app.hxx>
78 : : #include <sfx2/sfx.hrc>
79 : : #include <svx/fmsearch.hxx>
80 : : #include <svx/svxdlg.hxx>
81 : : #include <tools/diagnose_ex.h>
82 : : #include <osl/diagnose.h>
83 : : #include <vcl/msgbox.hxx>
84 : : #include <vcl/waitobj.hxx>
85 : :
86 : : using namespace ::com::sun::star::uno;
87 : : using namespace ::com::sun::star::awt;
88 : : using namespace ::com::sun::star::sdb;
89 : : using namespace ::com::sun::star::sdbc;
90 : : using namespace ::com::sun::star::sdbcx;
91 : : using namespace ::com::sun::star::task;
92 : : using namespace ::com::sun::star::beans;
93 : : using namespace ::com::sun::star::frame;
94 : : using namespace ::com::sun::star::form;
95 : : using namespace ::com::sun::star::util;
96 : : using namespace ::com::sun::star::lang;
97 : : using namespace ::com::sun::star::container;
98 : : using namespace ::dbtools;
99 : : using namespace ::comphelper;
100 : : using namespace ::svt;
101 : :
102 : : #define HANDLE_SQL_ERRORS( action, successflag, context, message ) \
103 : : try \
104 : : { \
105 : : successflag = sal_False; \
106 : : action; \
107 : : successflag = sal_True; \
108 : : } \
109 : : catch(SQLException& e) \
110 : : { \
111 : : SQLException aError = ::dbtools::prependErrorInfo(e, *this, context); \
112 : : ::com::sun::star::sdb::SQLErrorEvent aEvent; \
113 : : aEvent.Reason <<= aError; \
114 : : errorOccured(aEvent); \
115 : : } \
116 : : catch(Exception&) \
117 : : { \
118 : : DBG_UNHANDLED_EXCEPTION(); \
119 : : } \
120 : :
121 : : #define DO_SAFE( action, message ) try { action; } catch(Exception&) { OSL_FAIL(message); } ;
122 : :
123 : : //..................................................................
124 : : namespace dbaui
125 : : {
126 : : //..................................................................
127 : :
128 : : //==================================================================
129 : : // OParameterContinuation
130 : : //==================================================================
131 [ # # ][ # # ]: 0 : class OParameterContinuation : public OInteraction< XInteractionSupplyParameters >
132 : : {
133 : : Sequence< PropertyValue > m_aValues;
134 : :
135 : : public:
136 [ # # ]: 0 : OParameterContinuation() { }
137 : :
138 : 0 : Sequence< PropertyValue > getValues() const { return m_aValues; }
139 : :
140 : : // XInteractionSupplyParameters
141 : : virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException);
142 : : };
143 : :
144 : : //------------------------------------------------------------------
145 : 0 : void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException)
146 : : {
147 : 0 : m_aValues = _rValues;
148 : 0 : }
149 : :
150 : :
151 : : //==============================================================================
152 : : // a helper class implementing a runtime::XFormController, will be aggregated by SbaXDataBrowserController
153 : : // (we can't derive from XFormController as it's base class is XTabController and the XTabController::getModel collides
154 : : // with the XController::getModel implemented in our base class SbaXDataBrowserController)
155 : : class SbaXDataBrowserController::FormControllerImpl
156 : : : public ::cppu::WeakAggImplHelper2< ::com::sun::star::form::runtime::XFormController,
157 : : ::com::sun::star::frame::XFrameActionListener >
158 : : {
159 : : friend class SbaXDataBrowserController;
160 : : ::cppu::OInterfaceContainerHelper m_aActivateListeners;
161 : : SbaXDataBrowserController* m_pOwner;
162 : :
163 : : public:
164 : : FormControllerImpl(SbaXDataBrowserController* pOwner);
165 : :
166 : : // XFormController
167 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException);
168 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException );
169 : : virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( ::com::sun::star::uno::RuntimeException );
170 : : virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( ::com::sun::star::uno::RuntimeException );
171 : : virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
172 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException);
173 : : virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException);
174 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException);
175 : : virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException);
176 : :
177 : : // XChild, base of XFormController
178 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
179 : : virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
180 : :
181 : : // XComponent, base of XFormController
182 : : virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException);
183 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
184 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
185 : :
186 : : // XIndexAccess, base of XFormController
187 : : virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
188 : : virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
189 : :
190 : : // XElementAccess, base of XIndexAccess
191 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
192 : : virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
193 : :
194 : : // XEnumerationAccess, base of XElementAccess
195 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw (::com::sun::star::uno::RuntimeException);
196 : :
197 : : // XModifyBroadcaster, base of XFormController
198 : : virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
199 : : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
200 : :
201 : : // XConfirmDeleteBroadcaster, base of XFormController
202 : : virtual void SAL_CALL addConfirmDeleteListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
203 : : virtual void SAL_CALL removeConfirmDeleteListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
204 : :
205 : : // XSQLErrorBroadcaster, base of XFormController
206 : : virtual void SAL_CALL addSQLErrorListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
207 : : virtual void SAL_CALL removeSQLErrorListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
208 : :
209 : : // XRowSetApproveBroadcaster, base of XFormController
210 : : virtual void SAL_CALL addRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
211 : : virtual void SAL_CALL removeRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
212 : :
213 : : // XDatabaseParameterBroadcaster2, base of XFormController
214 : : virtual void SAL_CALL addDatabaseParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
215 : : virtual void SAL_CALL removeDatabaseParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
216 : :
217 : : // XDatabaseParameterBroadcaster, base of XDatabaseParameterBroadcaster2
218 : : virtual void SAL_CALL addParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
219 : : virtual void SAL_CALL removeParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
220 : :
221 : : // XModeSelector, base of XFormController
222 : : virtual void SAL_CALL setMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
223 : : virtual ::rtl::OUString SAL_CALL getMode( ) throw (::com::sun::star::uno::RuntimeException);
224 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes( ) throw (::com::sun::star::uno::RuntimeException);
225 : : virtual ::sal_Bool SAL_CALL supportsMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::uno::RuntimeException);
226 : :
227 : : // XTabController, base of XFormController
228 : : virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel > & Model) throw( ::com::sun::star::uno::RuntimeException );
229 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel > SAL_CALL getModel(void) throw( ::com::sun::star::uno::RuntimeException );
230 : : virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > & _Container) throw( ::com::sun::star::uno::RuntimeException );
231 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SAL_CALL getContainer(void) throw( ::com::sun::star::uno::RuntimeException );
232 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException );
233 : : virtual void SAL_CALL autoTabOrder(void) throw( ::com::sun::star::uno::RuntimeException );
234 : : virtual void SAL_CALL activateTabOrder(void) throw( ::com::sun::star::uno::RuntimeException );
235 : : virtual void SAL_CALL activateFirst(void) throw( ::com::sun::star::uno::RuntimeException );
236 : : virtual void SAL_CALL activateLast(void) throw( ::com::sun::star::uno::RuntimeException );
237 : :
238 : : // XFrameActionListener
239 : : virtual void SAL_CALL frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
240 : :
241 : : // XEventListener
242 : : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
243 : :
244 : : protected:
245 : : ~FormControllerImpl();
246 : : };
247 : :
248 : :
249 : : DBG_NAME(FormControllerImpl)
250 : : //------------------------------------------------------------------
251 : 2 : SbaXDataBrowserController::FormControllerImpl::FormControllerImpl(SbaXDataBrowserController* _pOwner)
252 [ + - ]: 2 : :m_aActivateListeners(_pOwner->getMutex())
253 [ + - ]: 4 : ,m_pOwner(_pOwner)
254 : : {
255 : : DBG_CTOR(FormControllerImpl,NULL);
256 : :
257 : : OSL_ENSURE(m_pOwner, "SbaXDataBrowserController::FormControllerImpl::FormControllerImpl : invalid Owner !");
258 : 2 : }
259 : :
260 : : //------------------------------------------------------------------
261 [ + - ]: 2 : SbaXDataBrowserController::FormControllerImpl::~FormControllerImpl()
262 : : {
263 : :
264 : : DBG_DTOR(FormControllerImpl,NULL);
265 [ - + ]: 4 : }
266 : :
267 : : //------------------------------------------------------------------
268 : 0 : Reference< runtime::XFormOperations > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getFormOperations() throw (RuntimeException)
269 : : {
270 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::getFormOperations: not supported!" );
271 : 0 : return NULL;
272 : : }
273 : :
274 : : //------------------------------------------------------------------
275 : 0 : Reference< ::com::sun::star::awt::XControl > SbaXDataBrowserController::FormControllerImpl::getCurrentControl(void) throw( RuntimeException )
276 : : {
277 [ # # ]: 0 : return m_pOwner->getBrowserView() ? m_pOwner->getBrowserView()->getGridControl() : Reference< ::com::sun::star::awt::XControl > ();
278 : : }
279 : :
280 : : //------------------------------------------------------------------
281 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addActivateListener(const Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( RuntimeException )
282 : : {
283 : 0 : m_aActivateListeners.addInterface(l);
284 : 0 : }
285 : :
286 : : //------------------------------------------------------------------
287 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeActivateListener(const Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( RuntimeException )
288 : : {
289 : 0 : m_aActivateListeners.removeInterface(l);
290 : 0 : }
291 : :
292 : : //------------------------------------------------------------------
293 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addChildController( const Reference< runtime::XFormController >& /*_ChildController*/ ) throw( RuntimeException, IllegalArgumentException )
294 : : {
295 : : // not supported
296 [ # # ][ # # ]: 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
297 : : }
298 : :
299 : : //------------------------------------------------------------------
300 : 0 : Reference< runtime::XFormControllerContext > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getContext() throw (RuntimeException)
301 : : {
302 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::getContext: no support!!" );
303 : 0 : return NULL;
304 : : }
305 : :
306 : : //------------------------------------------------------------------
307 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setContext( const Reference< runtime::XFormControllerContext >& /*_context*/ ) throw (RuntimeException)
308 : : {
309 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::setContext: no support!!" );
310 : 0 : }
311 : :
312 : : //------------------------------------------------------------------
313 : 0 : Reference< XInteractionHandler > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getInteractionHandler() throw (RuntimeException)
314 : : {
315 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::getInteractionHandler: no support!!" );
316 : 0 : return NULL;
317 : : }
318 : :
319 : : //------------------------------------------------------------------
320 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setInteractionHandler( const Reference< XInteractionHandler >& /*_interactionHandler*/ ) throw (RuntimeException)
321 : : {
322 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::setInteractionHandler: no support!!" );
323 : 0 : }
324 : :
325 : : //------------------------------------------------------------------
326 : 0 : Reference< XInterface > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getParent( ) throw (RuntimeException)
327 : : {
328 : : // don't have any parent form controllers
329 : 0 : return NULL;
330 : : }
331 : :
332 : : //------------------------------------------------------------------
333 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setParent( const Reference< XInterface >& /*Parent*/ ) throw (NoSupportException, RuntimeException)
334 : : {
335 [ # # ][ # # ]: 0 : throw NoSupportException( ::rtl::OUString(), *this );
336 : : }
337 : :
338 : : //------------------------------------------------------------------
339 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::dispose( ) throw (RuntimeException)
340 : : {
341 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::dispose: no, you do *not* want to do this!" );
342 : 0 : }
343 : :
344 : : //------------------------------------------------------------------
345 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addEventListener( const Reference< XEventListener >& /*xListener*/ ) throw (RuntimeException)
346 : : {
347 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addEventListener: no support!!" );
348 : 0 : }
349 : :
350 : : //------------------------------------------------------------------
351 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeEventListener( const Reference< XEventListener >& /*aListener*/ ) throw (RuntimeException)
352 : : {
353 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeEventListener: no support!!" );
354 : 0 : }
355 : :
356 : : //------------------------------------------------------------------
357 : 0 : ::sal_Int32 SAL_CALL SbaXDataBrowserController::FormControllerImpl::getCount( ) throw (RuntimeException)
358 : : {
359 : : // no sub controllers, never
360 : 0 : return 0;
361 : : }
362 : :
363 : : //------------------------------------------------------------------
364 : 0 : Any SAL_CALL SbaXDataBrowserController::FormControllerImpl::getByIndex( ::sal_Int32 /*Index*/ ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
365 : : {
366 : : // no sub controllers, never
367 [ # # ][ # # ]: 0 : throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
368 : : }
369 : :
370 : : //------------------------------------------------------------------
371 : 0 : Type SAL_CALL SbaXDataBrowserController::FormControllerImpl::getElementType( ) throw (RuntimeException)
372 : : {
373 : 0 : return ::cppu::UnoType< runtime::XFormController >::get();
374 : : }
375 : :
376 : : //------------------------------------------------------------------
377 : 0 : ::sal_Bool SAL_CALL SbaXDataBrowserController::FormControllerImpl::hasElements( ) throw (RuntimeException)
378 : : {
379 : : // no sub controllers, never
380 : 0 : return false;
381 : : }
382 : :
383 : : //------------------------------------------------------------------
384 : 0 : Reference< XEnumeration > SAL_CALL SbaXDataBrowserController::FormControllerImpl::createEnumeration( ) throw (RuntimeException)
385 : : {
386 [ # # ][ # # ]: 0 : return new ::comphelper::OEnumerationByIndex( this );
[ # # ]
387 : : }
388 : :
389 : : //------------------------------------------------------------------
390 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addModifyListener( const Reference< XModifyListener >& /*_Listener*/ ) throw (RuntimeException)
391 : : {
392 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addModifyListener: no support!" );
393 : 0 : }
394 : :
395 : : //------------------------------------------------------------------
396 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeModifyListener( const Reference< XModifyListener >& /*_Listener*/ ) throw (RuntimeException)
397 : : {
398 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeModifyListener: no support!" );
399 : 0 : }
400 : :
401 : : //------------------------------------------------------------------
402 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException)
403 : : {
404 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener: no support!" );
405 : 0 : }
406 : :
407 : : //------------------------------------------------------------------
408 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException)
409 : : {
410 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener: no support!" );
411 : 0 : }
412 : :
413 : : //------------------------------------------------------------------
414 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException)
415 : : {
416 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener: no support!" );
417 : 0 : }
418 : :
419 : : //------------------------------------------------------------------
420 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException)
421 : : {
422 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener: no support!" );
423 : 0 : }
424 : :
425 : : //------------------------------------------------------------------
426 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException)
427 : : {
428 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener: no support!" );
429 : 0 : }
430 : :
431 : : //------------------------------------------------------------------
432 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException)
433 : : {
434 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener: no support!" );
435 : 0 : }
436 : :
437 : : //------------------------------------------------------------------
438 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
439 : : {
440 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener: no support!" );
441 : 0 : }
442 : :
443 : : //------------------------------------------------------------------
444 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
445 : : {
446 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener: no support!" );
447 : 0 : }
448 : :
449 : : //------------------------------------------------------------------
450 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
451 : : {
452 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addParameterListener: no support!" );
453 : 0 : }
454 : :
455 : : //------------------------------------------------------------------
456 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
457 : : {
458 : : OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeParameterListener: no support!" );
459 : 0 : }
460 : :
461 : : //------------------------------------------------------------------
462 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setMode( const ::rtl::OUString& _rMode ) throw (NoSupportException, RuntimeException)
463 : : {
464 [ # # ]: 0 : if ( !supportsMode( _rMode ) )
465 [ # # ]: 0 : throw NoSupportException();
466 : 0 : }
467 : :
468 : : //------------------------------------------------------------------
469 : 0 : ::rtl::OUString SAL_CALL SbaXDataBrowserController::FormControllerImpl::getMode( ) throw (RuntimeException)
470 : : {
471 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) );
472 : : }
473 : :
474 : : //------------------------------------------------------------------
475 : 0 : Sequence< ::rtl::OUString > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getSupportedModes( ) throw (RuntimeException)
476 : : {
477 : 0 : Sequence< ::rtl::OUString > aModes(1);
478 [ # # ][ # # ]: 0 : aModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) );
479 : 0 : return aModes;
480 : : }
481 : :
482 : : //------------------------------------------------------------------
483 : 0 : ::sal_Bool SAL_CALL SbaXDataBrowserController::FormControllerImpl::supportsMode( const ::rtl::OUString& aMode ) throw (RuntimeException)
484 : : {
485 : 0 : return aMode.compareToAscii( "DataMode" ) == 0;
486 : : }
487 : :
488 : : //------------------------------------------------------------------
489 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setModel(const Reference< ::com::sun::star::awt::XTabControllerModel > & /*Model*/) throw( RuntimeException )
490 : : {
491 : : OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::setModel : invalid call, can't change my model !");
492 : 0 : }
493 : :
494 : : //------------------------------------------------------------------
495 : 0 : Reference< ::com::sun::star::awt::XTabControllerModel > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getModel(void) throw( RuntimeException )
496 : : {
497 [ # # ]: 0 : return Reference< XTabControllerModel >(m_pOwner->getRowSet(), UNO_QUERY);
498 : : }
499 : :
500 : : //------------------------------------------------------------------
501 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setContainer(const Reference< ::com::sun::star::awt::XControlContainer > & /*_Container*/) throw( RuntimeException )
502 : : {
503 : : OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::setContainer : invalid call, can't change my container !");
504 : 0 : }
505 : :
506 : : //------------------------------------------------------------------
507 : 0 : Reference< ::com::sun::star::awt::XControlContainer > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getContainer(void) throw( RuntimeException )
508 : : {
509 [ # # ]: 0 : if (m_pOwner->getBrowserView())
510 : 0 : return m_pOwner->getBrowserView()->getContainer();
511 : 0 : return Reference< ::com::sun::star::awt::XControlContainer > ();
512 : : }
513 : :
514 : : //------------------------------------------------------------------
515 : 0 : Sequence< Reference< ::com::sun::star::awt::XControl > > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getControls(void) throw( RuntimeException )
516 : : {
517 [ # # ]: 0 : if (m_pOwner->getBrowserView())
518 : : {
519 [ # # ]: 0 : Reference< ::com::sun::star::awt::XControl > xGrid = m_pOwner->getBrowserView()->getGridControl();
520 [ # # ]: 0 : return Sequence< Reference< ::com::sun::star::awt::XControl > >(&xGrid, 1);
521 : : }
522 : 0 : return Sequence< Reference< ::com::sun::star::awt::XControl > >();
523 : : }
524 : :
525 : : //------------------------------------------------------------------
526 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::autoTabOrder(void) throw( RuntimeException )
527 : : {
528 : : OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::autoTabOrder : nothing to do (always have only one control) !");
529 : 0 : }
530 : :
531 : : //------------------------------------------------------------------
532 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::activateTabOrder(void) throw( RuntimeException )
533 : : {
534 : : OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::activateTabOrder : nothing to do (always have only one control) !");
535 : 0 : }
536 : :
537 : : //------------------------------------------------------------------
538 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::activateFirst(void) throw( RuntimeException )
539 : : {
540 [ # # ]: 0 : if (m_pOwner->getBrowserView())
541 : 0 : m_pOwner->getBrowserView()->getVclControl()->ActivateCell();
542 : 0 : }
543 : :
544 : : //------------------------------------------------------------------
545 : 0 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::activateLast(void) throw( RuntimeException )
546 : : {
547 [ # # ]: 0 : if (m_pOwner->getBrowserView())
548 : 0 : m_pOwner->getBrowserView()->getVclControl()->ActivateCell();
549 : 0 : }
550 : :
551 : : //------------------------------------------------------------------
552 : 2 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::frameAction(const ::com::sun::star::frame::FrameActionEvent& /*aEvent*/) throw( RuntimeException )
553 : : {
554 : 2 : }
555 : :
556 : : //------------------------------------------------------------------
557 : 2 : void SAL_CALL SbaXDataBrowserController::FormControllerImpl::disposing(const ::com::sun::star::lang::EventObject& /*Source*/) throw( RuntimeException )
558 : : {
559 : : // nothing to do
560 : : // we don't add ourself as listener to any broadcasters, so we are not resposible for removing us
561 : 2 : }
562 : :
563 : : //==================================================================
564 : : //= SbaXDataBrowserController
565 : : //==================================================================
566 : : //------------------------------------------------------------------
567 : 0 : Sequence< Type > SAL_CALL SbaXDataBrowserController::getTypes( ) throw (RuntimeException)
568 : : {
569 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getTypes" );
570 : : return ::comphelper::concatSequences(
571 : : SbaXDataBrowserController_Base::getTypes(),
572 : 0 : m_pFormControllerImpl->getTypes()
573 [ # # ][ # # ]: 0 : );
[ # # ]
574 : : }
575 : :
576 : : //------------------------------------------------------------------
577 : 0 : Sequence< sal_Int8 > SAL_CALL SbaXDataBrowserController::getImplementationId( ) throw (RuntimeException)
578 : : {
579 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getImplementationId" );
580 : : static ::cppu::OImplementationId * pId = 0;
581 [ # # ]: 0 : if (! pId)
582 : : {
583 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
584 [ # # ]: 0 : if (! pId)
585 : : {
586 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
587 : 0 : pId = &aId;
588 [ # # ]: 0 : }
589 : : }
590 : 0 : return pId->getImplementationId();
591 : : }
592 : :
593 : : //------------------------------------------------------------------
594 : 226 : Any SAL_CALL SbaXDataBrowserController::queryInterface(const Type& _rType) throw (RuntimeException)
595 : : {
596 : : // check for our additional interfaces
597 : 226 : Any aRet = SbaXDataBrowserController_Base::queryInterface(_rType);
598 : :
599 : : // check for our aggregate (implementing the XFormController)
600 [ + + ]: 226 : if (!aRet.hasValue())
601 [ + - ][ + - ]: 20 : aRet = m_xFormControllerImpl->queryAggregation(_rType);
602 : :
603 : : // no more to offer
604 : 226 : return aRet;
605 : : }
606 : :
607 : : DBG_NAME(SbaXDataBrowserController)
608 : : //------------------------------------------------------------------------------
609 : 2 : SbaXDataBrowserController::SbaXDataBrowserController(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
610 : : :SbaXDataBrowserController_Base(_rM)
611 : : ,m_nRowSetPrivileges(0)
612 : : ,m_pClipbordNotifier( NULL )
613 : : ,m_aAsyncGetCellFocus(LINK(this, SbaXDataBrowserController, OnAsyncGetCellFocus))
614 : : ,m_aAsyncDisplayError( LINK( this, SbaXDataBrowserController, OnAsyncDisplayError ) )
615 : : ,m_sStateSaveRecord(ModuleRes(RID_STR_SAVE_CURRENT_RECORD))
616 : : ,m_sStateUndoRecord(ModuleRes(RID_STR_UNDO_MODIFY_RECORD))
617 : : ,m_sModuleIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataSourceBrowser" ) ) )
618 : : ,m_pFormControllerImpl(NULL)
619 : : ,m_nPendingLoadFinished(0)
620 : : ,m_nFormActionNestingLevel(0)
621 : : ,m_bLoadCanceled( sal_False )
622 : : ,m_bClosingKillOpen( sal_False )
623 [ + - ][ + - ]: 2 : ,m_bCannotSelectUnfiltered( true )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
624 : : {
625 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SbaXDataBrowserController" );
626 : : DBG_CTOR(SbaXDataBrowserController,NULL);
627 : :
628 : : // create the form controller aggregate
629 [ + - ]: 2 : ::comphelper::increment(m_refCount);
630 : : {
631 [ + - ]: 2 : m_pFormControllerImpl = new FormControllerImpl(this);
632 [ + - ][ + - ]: 2 : m_xFormControllerImpl = m_pFormControllerImpl;
633 [ + - ][ + - ]: 2 : m_xFormControllerImpl->setDelegator(*this);
[ + - ]
634 : : }
635 [ + - ]: 2 : ::comphelper::decrement(m_refCount);
636 : :
637 [ + - ]: 2 : m_aInvalidateClipboard.SetTimeoutHdl(LINK(this, SbaXDataBrowserController, OnInvalidateClipboard));
638 [ + - ]: 2 : m_aInvalidateClipboard.SetTimeout(300);
639 : 2 : }
640 : :
641 : : //------------------------------------------------------------------------------
642 [ + - ][ + - ]: 2 : SbaXDataBrowserController::~SbaXDataBrowserController()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
643 : : {
644 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::~SbaXDataBrowserController" );
645 : : // deleteView();
646 : : // release the aggregated form controller
647 [ + - ]: 2 : if (m_xFormControllerImpl.is())
648 : : {
649 : 2 : Reference< XInterface > xEmpty;
650 [ + - ][ + - ]: 2 : m_xFormControllerImpl->setDelegator(xEmpty);
651 : : }
652 : :
653 : : DBG_DTOR(SbaXDataBrowserController,NULL);
654 [ - + ]: 2 : }
655 : :
656 : : // -----------------------------------------------------------------------
657 : 2 : void SbaXDataBrowserController::startFrameListening( const Reference< XFrame >& _rxFrame )
658 : : {
659 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::startFrameListening" );
660 [ + - ]: 2 : SbaXDataBrowserController_Base::startFrameListening( _rxFrame );
661 : :
662 : 2 : Reference< XFrameActionListener > xAggListener;
663 [ + - ]: 2 : if ( m_xFormControllerImpl.is() )
664 [ + - ][ + - ]: 2 : m_xFormControllerImpl->queryAggregation( XFrameActionListener::static_type() ) >>= xAggListener;
[ + - ][ + - ]
665 : :
666 [ + - ][ + - ]: 2 : if ( _rxFrame.is() && xAggListener.is() )
[ + - ]
667 [ + - ][ + - ]: 2 : _rxFrame->addFrameActionListener( xAggListener );
668 : 2 : }
669 : :
670 : : // -----------------------------------------------------------------------
671 : 4 : void SbaXDataBrowserController::stopFrameListening( const Reference< XFrame >& _rxFrame )
672 : : {
673 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::stopFrameListening" );
674 [ + - ]: 4 : SbaXDataBrowserController_Base::stopFrameListening( _rxFrame );
675 : :
676 : 4 : Reference< XFrameActionListener > xAggListener;
677 [ + - ]: 4 : if ( m_xFormControllerImpl.is() )
678 [ + - ][ + - ]: 4 : m_xFormControllerImpl->queryAggregation( XFrameActionListener::static_type() ) >>= xAggListener;
[ + - ][ + - ]
679 : :
680 [ + + ][ + - ]: 4 : if ( _rxFrame.is() && xAggListener.is() )
[ + + ]
681 [ + - ][ + - ]: 4 : _rxFrame->removeFrameActionListener( xAggListener );
682 : 4 : }
683 : :
684 : : // -----------------------------------------------------------------------------
685 : 4 : void SbaXDataBrowserController::onStartLoading( const Reference< XLoadable >& _rxLoadable )
686 : : {
687 : 4 : m_bLoadCanceled = sal_False;
688 : 4 : m_bCannotSelectUnfiltered = false;
689 : :
690 [ + - ]: 4 : Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY );
691 [ + - ]: 4 : if ( xWarnings.is() )
692 [ + - ][ + - ]: 4 : xWarnings->clearWarnings();
693 : 4 : }
694 : :
695 : : // -----------------------------------------------------------------------------
696 : 0 : void SbaXDataBrowserController::impl_checkForCannotSelectUnfiltered( const SQLExceptionInfo& _rError )
697 : : {
698 [ # # ][ # # ]: 0 : ::connectivity::SQLError aError( getORB() );
[ # # ][ # # ]
699 [ # # ]: 0 : ::connectivity::ErrorCode nErrorCode( aError.getErrorCode( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED ) );
700 [ # # ][ # # ]: 0 : if ( ((const SQLException*)_rError)->ErrorCode == nErrorCode )
701 : : {
702 : 0 : m_bCannotSelectUnfiltered = true;
703 [ # # ][ # # ]: 0 : InvalidateFeature( ID_BROWSER_FILTERCRIT );
704 [ # # ]: 0 : }
705 : 0 : }
706 : :
707 : : // -----------------------------------------------------------------------------
708 : 4 : sal_Bool SbaXDataBrowserController::reloadForm( const Reference< XLoadable >& _rxLoadable )
709 : : {
710 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::reloadForm" );
711 [ + - ]: 4 : WaitObject aWO(getBrowserView());
712 : :
713 [ + - ]: 4 : onStartLoading( _rxLoadable );
714 : :
715 [ + - ]: 4 : FormErrorHelper aReportError(this);
716 [ + - ][ + - ]: 4 : if (_rxLoadable->isLoaded())
[ - + ]
717 [ # # ][ # # ]: 0 : _rxLoadable->reload();
718 : : else
719 [ + - ][ + - ]: 4 : _rxLoadable->load();
720 : :
721 : 4 : m_xParser.clear();
722 [ + - ][ + - ]: 4 : const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
723 [ + - ][ + - ]: 4 : if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)))
[ + - ][ + - ]
[ + - ]
724 [ + - ][ + - ]: 4 : xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser;
[ + - ][ + - ]
725 : : #if 0
726 : : {
727 : : const Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY );
728 : : const Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xRowSetProps->getPropertyValue( PROPERTY_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY );
729 : : if ( xAnalyzer.is() )
730 : : {
731 : : const Reference< XIndexAccess > xOrderColumns( xAnalyzer->getOrderColumns(), UNO_SET_THROW );
732 : : const sal_Int32 nOrderColumns( xOrderColumns->getCount() );
733 : : for ( sal_Int32 c=0; c<nOrderColumns; ++c )
734 : : {
735 : : const Reference< XPropertySet > xOrderColumn( xOrderColumns->getByIndex(c), UNO_QUERY_THROW );
736 : : ::rtl::OUString sColumnName;
737 : : OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName);
738 : : ::rtl::OUString sTableName;
739 : : OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName);
740 : : (void)sColumnName;
741 : : (void)sTableName;
742 : : }
743 : : }
744 : : }
745 : : #endif
746 : :
747 [ + - ]: 4 : Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY );
748 [ + - ]: 4 : if ( xWarnings.is() )
749 : : {
750 : : try
751 : : {
752 [ + - ][ + - ]: 4 : SQLExceptionInfo aInfo( xWarnings->getWarnings() );
[ + - ]
753 [ - + ]: 4 : if ( aInfo.isValid() )
754 : : {
755 [ # # ]: 0 : showError( aInfo );
756 [ # # ]: 0 : impl_checkForCannotSelectUnfiltered( aInfo );
757 [ + - ][ # # ]: 4 : }
758 : : }
759 [ # # ]: 0 : catch(const SQLException& e)
760 : : {
761 : : (void)e;
762 : : }
763 : : }
764 : :
765 [ + - ][ + - ]: 4 : return _rxLoadable->isLoaded();
[ + - ][ + - ]
766 : : }
767 : :
768 : : // -----------------------------------------------------------------------------
769 : 4 : void SbaXDataBrowserController::initFormatter()
770 : : {
771 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::initFormatter" );
772 : : // ---------------------------------------------------------------
773 : : // create a formatter working with the connections format supplier
774 [ + - ][ + - ]: 4 : Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(::dbtools::getConnection(m_xRowSet), sal_True,getORB()));
[ + - ]
775 : :
776 [ + - ]: 4 : if(xSupplier.is())
777 : : {
778 : : // create a new formatter
779 : : m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > (
780 [ + - ][ + - ]: 4 : getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
[ + - ][ + - ]
[ + - ][ + - ]
781 [ + - ]: 4 : if (m_xFormatter.is())
782 [ + - ][ + - ]: 4 : m_xFormatter->attachNumberFormatsSupplier(xSupplier);
783 : : }
784 : : else // clear the formatter
785 [ # # ]: 4 : m_xFormatter = NULL;
786 : 4 : }
787 : : // -----------------------------------------------------------------------------
788 : 2 : void SbaXDataBrowserController::describeSupportedFeatures()
789 : : {
790 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::describeSupportedFeatures" );
791 : 2 : SbaXDataBrowserController_Base::describeSupportedFeatures();
792 : 2 : implDescribeSupportedFeature( ".uno:FormSlots/undoRecord", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS );
793 : 2 : implDescribeSupportedFeature( ".uno:FormController/undoRecord", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS );
794 : 2 : implDescribeSupportedFeature( ".uno:RecUndo", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS );
795 : 2 : implDescribeSupportedFeature( ".uno:FormSlots/saveRecord", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS );
796 : 2 : implDescribeSupportedFeature( ".uno:FormController/saveRecord", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS );
797 : 2 : implDescribeSupportedFeature( ".uno:RecSave", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS );
798 : 2 : implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVERECORD, CommandGroup::DOCUMENT );
799 : 2 : implDescribeSupportedFeature( ".uno:RecSearch", SID_FM_SEARCH, CommandGroup::CONTROLS );
800 : 2 : implDescribeSupportedFeature( ".uno:AutoFilter", SID_FM_AUTOFILTER, CommandGroup::CONTROLS );
801 : 2 : implDescribeSupportedFeature( ".uno:Refresh", SID_FM_REFRESH, CommandGroup::CONTROLS );
802 : 2 : implDescribeSupportedFeature( ".uno:OrderCrit", SID_FM_ORDERCRIT, CommandGroup::CONTROLS );
803 : 2 : implDescribeSupportedFeature( ".uno:RemoveFilterSort", SID_FM_REMOVE_FILTER_SORT,CommandGroup::CONTROLS );
804 : 2 : implDescribeSupportedFeature( ".uno:FormFiltered", SID_FM_FORM_FILTERED, CommandGroup::CONTROLS );
805 : 2 : implDescribeSupportedFeature( ".uno:FilterCrit", SID_FM_FILTERCRIT, CommandGroup::CONTROLS );
806 : 2 : implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP, CommandGroup::CONTROLS );
807 : 2 : implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN, CommandGroup::CONTROLS );
808 : 2 : implDescribeSupportedFeature( ".uno:FormSlots/deleteRecord", SID_FM_DELETEROWS, CommandGroup::EDIT );
809 : 2 : implDescribeSupportedFeature( ".uno:FormSlots/insertRecord", ID_BROWSER_INSERT_ROW, CommandGroup::INSERT );
810 : 2 : }
811 : : //------------------------------------------------------------------------------
812 : 2 : sal_Bool SbaXDataBrowserController::Construct(Window* pParent)
813 : : {
814 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::Construct" );
815 : : // ---------------------------------------------
816 : : // create/initialize the form and the grid model
817 [ + - ][ + - ]: 2 : m_xRowSet = CreateForm();
818 [ - + ]: 2 : if (!m_xRowSet.is())
819 : 0 : return sal_False;
820 : :
821 [ + - ]: 2 : m_xColumnsSupplier.set(m_xRowSet,UNO_QUERY);
822 [ + - ]: 2 : m_xLoadable.set(m_xRowSet,UNO_QUERY);
823 : :
824 [ + - ]: 2 : Reference< XPropertySet > xFormProperties( m_xRowSet, UNO_QUERY );
825 [ + - ][ - + ]: 2 : if ( !InitializeForm( xFormProperties ) )
826 : 0 : return sal_False;
827 : :
828 [ + - ][ + - ]: 2 : m_xGridModel = CreateGridModel();
829 [ - + ]: 2 : if (!m_xGridModel.is())
830 : 0 : return sal_False;
831 : :
832 : : // set the formatter if available
833 [ + - ]: 2 : initFormatter();
834 : : // ---------------------------------------------------------------
835 : :
836 : : // we want to have a grid with a "flat" border
837 [ + - ]: 2 : Reference< XPropertySet > xGridSet(m_xGridModel, UNO_QUERY);
838 [ + - ]: 2 : if ( xGridSet.is() )
839 [ + - ][ + - ]: 2 : xGridSet->setPropertyValue(PROPERTY_BORDER, makeAny((sal_Int16)2));
[ + - ][ + - ]
840 : :
841 : : // ----------
842 : : // marry them
843 [ + - ]: 2 : Reference< ::com::sun::star::container::XNameContainer > xNameCont(m_xRowSet, UNO_QUERY);
844 : : {
845 [ + - ][ + - ]: 2 : String sText(ModuleRes(STR_DATASOURCE_GRIDCONTROL_NAME));
846 [ + - ][ + - ]: 2 : xNameCont->insertByName(::rtl::OUString(sText), makeAny(m_xGridModel));
[ + - ][ + - ]
[ + - ]
847 : : }
848 : :
849 : : // ---------------
850 : : // create the view
851 [ + - ][ + - ]: 2 : setView( * new UnoDataBrowserView( pParent, *this, getORB() ) );
[ + - ]
852 [ - + ]: 2 : if (!getBrowserView())
853 : 0 : return sal_False;
854 : :
855 : : // late construction
856 : 2 : sal_Bool bSuccess = sal_False;
857 : : try
858 : : {
859 [ + - ][ + - ]: 2 : getBrowserView()->Construct(getControlModel());
[ # # # ]
860 : 2 : bSuccess = sal_True;
861 : : }
862 [ # # ]: 0 : catch(SQLException&)
863 : : {
864 : : }
865 [ # # ]: 0 : catch(Exception&)
866 : : {
867 : : OSL_FAIL("SbaXDataBrowserController::Construct : the construction of UnoDataBrowserView failed !");
868 : : }
869 : :
870 [ - + ]: 2 : if (!bSuccess)
871 : : {
872 : : // deleteView();
873 : 0 : return sal_False;
874 : : }
875 : :
876 : : // now that we have a view we can create the clipboard listener
877 [ + - ][ + - ]: 2 : m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
[ + - ]
878 [ + - ]: 2 : m_aSystemClipboard.StartClipboardListening( );
879 : :
880 [ + - ][ + - ]: 2 : m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, SbaXDataBrowserController, OnClipboardChanged ) );
881 : 2 : m_pClipbordNotifier->acquire();
882 [ + - ]: 2 : m_pClipbordNotifier->AddRemoveListener( getView(), sal_True );
883 : :
884 : : // this call create the toolbox
885 [ + - ]: 2 : SbaXDataBrowserController_Base::Construct(pParent);
886 : :
887 [ + - ]: 2 : getBrowserView()->Show();
888 : :
889 : : // set the callbacks for the grid control
890 [ + - ]: 2 : SbaGridControl* pVclGrid = getBrowserView()->getVclControl();
891 : : OSL_ENSURE(pVclGrid, "SbaXDataBrowserController::Construct : have no VCL control !");
892 : 2 : pVclGrid->SetMasterListener(this);
893 : :
894 : : // --------------------------
895 : : // add listeners ...
896 : :
897 : : // ... to the form model
898 [ + - ][ + - ]: 2 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
899 [ + - ]: 2 : if (xFormSet.is())
900 : : {
901 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_ISNEW, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
902 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_ISMODIFIED, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
903 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_ROWCOUNT, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
904 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_ACTIVECOMMAND, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
905 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_ORDER, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
906 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_FILTER, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
907 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_HAVING_CLAUSE, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
908 [ + - ][ + - ]: 2 : xFormSet->addPropertyChangeListener(PROPERTY_APPLYFILTER, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
909 : : }
910 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
911 [ + - ]: 2 : if (xFormError.is())
912 [ + - ][ + - ]: 2 : xFormError->addSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
[ + - ]
913 : :
914 [ + - ]: 2 : if (m_xLoadable.is())
915 [ + - ][ + - ]: 2 : m_xLoadable->addLoadListener(this);
[ + - ]
916 : :
917 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(getRowSet(), UNO_QUERY);
918 [ + - ]: 2 : if (xFormParameter.is())
919 [ + - ][ + - ]: 2 : xFormParameter->addParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this);
[ + - ]
920 : :
921 [ + - ][ + - ]: 2 : addModelListeners(getControlModel());
922 [ + - ][ + - ]: 2 : addControlListeners(getBrowserView()->getGridControl());
923 : :
924 : : // -------------
925 : : // load the form
926 [ + - ]: 2 : return LoadForm();
927 : : }
928 : :
929 : : //------------------------------------------------------------------------------
930 : 2 : sal_Bool SbaXDataBrowserController::LoadForm()
931 : : {
932 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::LoadForm" );
933 : 2 : reloadForm( m_xLoadable );
934 : 2 : return sal_True;
935 : : }
936 : : //------------------------------------------------------------------------------
937 : 62 : void SbaXDataBrowserController::AddColumnListener(const Reference< XPropertySet > & /*xCol*/)
938 : : {
939 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::AddColumnListener" );
940 : : // we're not interested in any column properties ...
941 : 62 : }
942 : :
943 : : //------------------------------------------------------------------------------
944 : 62 : void SbaXDataBrowserController::RemoveColumnListener(const Reference< XPropertySet > & /*xCol*/)
945 : : {
946 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::RemoveColumnListener" );
947 : 62 : }
948 : : //------------------------------------------------------------------------------
949 : 2 : Reference< XRowSet > SbaXDataBrowserController::CreateForm()
950 : : {
951 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CreateForm" );
952 [ + - ][ + - ]: 2 : return Reference< XRowSet > (getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.Form"))), UNO_QUERY);
[ + - ][ + - ]
953 : : }
954 : :
955 : : //------------------------------------------------------------------------------
956 : 2 : Reference< ::com::sun::star::form::XFormComponent > SbaXDataBrowserController::CreateGridModel()
957 : : {
958 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CreateGridModel" );
959 [ + - ][ + - ]: 2 : return Reference< ::com::sun::star::form::XFormComponent > (getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.GridControl"))), UNO_QUERY);
[ + - ][ + - ]
960 : : }
961 : :
962 : : // -------------------------------------------------------------------------
963 : 2 : void SbaXDataBrowserController::addModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
964 : : {
965 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::addModelListeners" );
966 : : // ... all the grid columns
967 [ + - ]: 2 : addColumnListeners(_xGridControlModel);
968 : :
969 : : // (we are interested in all columns the grid has (and only in these) so we have to listen to the container, too)
970 [ + - ]: 2 : Reference< ::com::sun::star::container::XContainer > xColContainer(_xGridControlModel, UNO_QUERY);
971 [ + - ]: 2 : if (xColContainer.is())
972 [ + - ][ + - ]: 2 : xColContainer->addContainerListener((::com::sun::star::container::XContainerListener*)this);
[ + - ]
973 : :
974 [ + - ]: 2 : Reference< ::com::sun::star::form::XReset > xReset(_xGridControlModel, UNO_QUERY);
975 [ + - ]: 2 : if (xReset.is())
976 [ + - ][ + - ]: 2 : xReset->addResetListener((::com::sun::star::form::XResetListener*)this);
[ + - ]
977 : 2 : }
978 : :
979 : : // -------------------------------------------------------------------------
980 : 2 : void SbaXDataBrowserController::removeModelListeners(const Reference< XControlModel > & _xGridControlModel)
981 : : {
982 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::removeModelListeners" );
983 : : // every single column model
984 [ + - ]: 2 : Reference< XIndexContainer > xColumns(_xGridControlModel, UNO_QUERY);
985 [ + - ]: 2 : if (xColumns.is())
986 : : {
987 [ + - ][ + - ]: 2 : sal_Int32 nCount = xColumns->getCount();
988 [ + + ]: 64 : for (sal_uInt16 i=0; i < nCount; ++i)
989 : : {
990 [ + - ][ + - ]: 62 : Reference< XPropertySet > xCol(xColumns->getByIndex(i),UNO_QUERY);
[ + - ]
991 [ + - ]: 62 : RemoveColumnListener(xCol);
992 : 62 : }
993 : : }
994 : :
995 [ + - ]: 2 : Reference< XContainer > xColContainer(_xGridControlModel, UNO_QUERY);
996 [ + - ]: 2 : if (xColContainer.is())
997 [ + - ][ + - ]: 2 : xColContainer->removeContainerListener( this );
[ + - ]
998 : :
999 [ + - ]: 2 : Reference< XReset > xReset(_xGridControlModel, UNO_QUERY);
1000 [ + - ]: 2 : if (xReset.is())
1001 [ + - ][ + - ]: 2 : xReset->removeResetListener( this );
[ + - ]
1002 : 2 : }
1003 : :
1004 : : // -------------------------------------------------------------------------
1005 : 2 : void SbaXDataBrowserController::addControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl)
1006 : : {
1007 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::addControlListeners" );
1008 : : // to ge the 'modified' for the current cell
1009 [ + - ][ + - ]: 2 : Reference< XModifyBroadcaster > xBroadcaster(getBrowserView()->getGridControl(), UNO_QUERY);
1010 [ + - ]: 2 : if (xBroadcaster.is())
1011 [ + - ][ + - ]: 2 : xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this));
[ + - ]
1012 : :
1013 : : // introduce ourself as dispatch provider for the grid
1014 [ + - ][ + - ]: 2 : Reference< XDispatchProviderInterception > xInterception(getBrowserView()->getGridControl(), UNO_QUERY);
1015 [ + - ]: 2 : if (xInterception.is())
1016 [ + - ][ + - ]: 2 : xInterception->registerDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this));
[ + - ]
1017 : :
1018 : : // add as focus listener to the control (needed for the form controller functionality)
1019 [ + - ]: 2 : Reference< XWindow > xWindow(_xGridControl, UNO_QUERY);
1020 [ + - ]: 2 : if (xWindow.is())
1021 [ + - ][ + - ]: 2 : xWindow->addFocusListener(this);
[ + - ]
1022 : 2 : }
1023 : :
1024 : : // -------------------------------------------------------------------------
1025 : 2 : void SbaXDataBrowserController::removeControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl)
1026 : : {
1027 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::removeControlListeners" );
1028 [ + - ]: 2 : Reference< XModifyBroadcaster > xBroadcaster(_xGridControl, UNO_QUERY);
1029 [ + - ]: 2 : if (xBroadcaster.is())
1030 [ + - ][ + - ]: 2 : xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
[ + - ]
1031 : :
1032 [ + - ]: 2 : Reference< XDispatchProviderInterception > xInterception(_xGridControl, UNO_QUERY);
1033 [ + - ]: 2 : if (xInterception.is())
1034 [ + - ][ + - ]: 2 : xInterception->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this));
[ + - ]
1035 : :
1036 [ + - ]: 2 : Reference< XWindow > xWindow(_xGridControl, UNO_QUERY);
1037 [ + - ]: 2 : if (xWindow.is())
1038 [ + - ][ + - ]: 2 : xWindow->removeFocusListener(this);
[ + - ]
1039 : 2 : }
1040 : :
1041 : : //------------------------------------------------------------------
1042 : 0 : void SAL_CALL SbaXDataBrowserController::focusGained(const FocusEvent& /*e*/) throw( RuntimeException )
1043 : : {
1044 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::focusGained" );
1045 : : // notify our activate listeners (registered on the form controller aggregate)
1046 [ # # ][ # # ]: 0 : EventObject aEvt(*this);
1047 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_pFormControllerImpl->m_aActivateListeners);
1048 [ # # ]: 0 : while (aIter.hasMoreElements())
1049 [ # # ][ # # ]: 0 : static_cast<XFormControllerListener*>(aIter.next())->formActivated(aEvt);
[ # # ][ # # ]
1050 : 0 : }
1051 : :
1052 : : //------------------------------------------------------------------
1053 : 0 : void SAL_CALL SbaXDataBrowserController::focusLost(const FocusEvent& e) throw( RuntimeException )
1054 : : {
1055 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::focusLost" );
1056 : : // some general checks
1057 [ # # ][ # # ]: 0 : if (!getBrowserView() || !getBrowserView()->getGridControl().is())
[ # # ][ # # ]
[ # # # # ]
1058 : : return;
1059 [ # # ][ # # ]: 0 : Reference< XVclWindowPeer > xMyGridPeer(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY);
[ # # ][ # # ]
1060 [ # # ]: 0 : if (!xMyGridPeer.is())
1061 : : return;
1062 [ # # ]: 0 : Reference< XWindowPeer > xNextControlPeer(e.NextFocus, UNO_QUERY);
1063 [ # # ]: 0 : if (!xNextControlPeer.is())
1064 : : return;
1065 : :
1066 : : // don't do a notification if it remains in the family (i.e. a child of the grid control gets the focus)
1067 [ # # ][ # # ]: 0 : if (xMyGridPeer->isChild(xNextControlPeer))
[ # # ]
1068 : : return;
1069 : :
1070 [ # # ][ # # ]: 0 : if (xMyGridPeer == xNextControlPeer)
1071 : : return;
1072 : :
1073 : : // notify the listeners that the "form" we represent has been deactivated
1074 [ # # ][ # # ]: 0 : EventObject aEvt(*this);
1075 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter(m_pFormControllerImpl->m_aActivateListeners);
1076 [ # # ]: 0 : while (aIter.hasMoreElements())
1077 [ # # ][ # # ]: 0 : static_cast<XFormControllerListener*>(aIter.next())->formDeactivated(aEvt);
1078 : :
1079 : : // commit the changes of the grid control (as we're deactivated)
1080 [ # # ][ # # ]: 0 : Reference< XBoundComponent > xCommitable(getBrowserView()->getGridControl(), UNO_QUERY);
1081 [ # # ]: 0 : if (xCommitable.is())
1082 [ # # ][ # # ]: 0 : xCommitable->commit();
1083 : : else
1084 [ # # ][ # # ]: 0 : OSL_FAIL("SbaXDataBrowserController::focusLost : why is my control not commitable ?");
[ # # ][ # # ]
1085 : : }
1086 : :
1087 : : // -------------------------------------------------------------------------
1088 : 0 : void SbaXDataBrowserController::disposingGridControl(const ::com::sun::star::lang::EventObject& /*Source*/)
1089 : : {
1090 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingGridControl" );
1091 [ # # ]: 0 : removeControlListeners(getBrowserView()->getGridControl());
1092 : 0 : }
1093 : :
1094 : : // -------------------------------------------------------------------------
1095 : 0 : void SbaXDataBrowserController::disposingGridModel(const ::com::sun::star::lang::EventObject& /*Source*/)
1096 : : {
1097 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingGridModel" );
1098 [ # # ]: 0 : removeModelListeners(getControlModel());
1099 : 0 : }
1100 : :
1101 : : // -------------------------------------------------------------------------
1102 : 0 : void SbaXDataBrowserController::disposingFormModel(const ::com::sun::star::lang::EventObject& Source)
1103 : : {
1104 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingFormModel" );
1105 [ # # ]: 0 : Reference< XPropertySet > xSourceSet(Source.Source, UNO_QUERY);
1106 [ # # ]: 0 : if (xSourceSet.is())
1107 : : {
1108 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_ISNEW, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1109 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_ISMODIFIED, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1110 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_ROWCOUNT, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1111 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_ACTIVECOMMAND, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1112 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_ORDER, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1113 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_FILTER, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1114 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_HAVING_CLAUSE, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1115 [ # # ][ # # ]: 0 : xSourceSet->removePropertyChangeListener(PROPERTY_APPLYFILTER, static_cast<XPropertyChangeListener*>(this));
[ # # ][ # # ]
1116 : : }
1117 : :
1118 [ # # ]: 0 : Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(Source.Source, UNO_QUERY);
1119 [ # # ]: 0 : if (xFormError.is())
1120 [ # # ][ # # ]: 0 : xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
[ # # ]
1121 : :
1122 [ # # ]: 0 : if (m_xLoadable.is())
1123 [ # # ][ # # ]: 0 : m_xLoadable->removeLoadListener(this);
[ # # ]
1124 : :
1125 [ # # ]: 0 : Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(Source.Source, UNO_QUERY);
1126 [ # # ]: 0 : if (xFormParameter.is())
1127 [ # # ][ # # ]: 0 : xFormParameter->removeParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this);
[ # # ]
1128 : 0 : }
1129 : :
1130 : : // -------------------------------------------------------------------------
1131 : 0 : void SbaXDataBrowserController::disposingColumnModel(const ::com::sun::star::lang::EventObject& Source)
1132 : : {
1133 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingColumnModel" );
1134 [ # # ]: 0 : RemoveColumnListener(Reference< XPropertySet > (Source.Source, UNO_QUERY));
1135 : 0 : }
1136 : :
1137 : : // -------------------------------------------------------------------------
1138 : 2 : void SbaXDataBrowserController::disposing(const EventObject& Source) throw( RuntimeException )
1139 : : {
1140 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposing" );
1141 : : // if it's a component other than our aggregate, forward it to the aggregate
1142 [ + - ][ + - ]: 2 : if ( m_xFormControllerImpl != Source.Source )
1143 : : {
1144 : 2 : Reference< XEventListener > xAggListener;
1145 [ + - ][ + - ]: 2 : m_xFormControllerImpl->queryAggregation( ::getCppuType( &xAggListener ) ) >>= xAggListener;
[ + - ][ + - ]
1146 [ + - ]: 2 : if ( xAggListener.is( ))
1147 [ + - ][ + - ]: 2 : xAggListener->disposing( Source );
1148 : : }
1149 : :
1150 : : // is it the grid control ?
1151 [ + - ]: 2 : if (getBrowserView())
1152 : : {
1153 [ + - ]: 2 : Reference< ::com::sun::star::awt::XControl > xSourceControl(Source.Source, UNO_QUERY);
1154 [ + - ][ + - ]: 2 : if (xSourceControl == getBrowserView()->getGridControl())
[ - + ]
1155 [ # # ]: 2 : disposingGridControl(Source);
1156 : : }
1157 : :
1158 : : // it's model (the container of the columns) ?
1159 [ + - ][ + - ]: 2 : if (getControlModel() == Source.Source)
[ - + ]
1160 [ # # ]: 0 : disposingGridModel(Source);
1161 : :
1162 : : // the form's model ?
1163 [ + - ][ + - ]: 2 : if ((getRowSet() == Source.Source))
[ - + ]
1164 [ # # ]: 0 : disposingFormModel(Source);
1165 : :
1166 : : // from a single column model ?
1167 [ + - ]: 2 : Reference< XPropertySet > xSourceSet(Source.Source, UNO_QUERY);
1168 [ - + ]: 2 : if (xSourceSet.is())
1169 : : {
1170 [ # # ][ # # ]: 0 : Reference< XPropertySetInfo > xInfo = xSourceSet->getPropertySetInfo();
1171 : : // we assume that columns have a Width property and all other sets we are listening to don't have
1172 [ # # ][ # # ]: 0 : if (xInfo->hasPropertyByName(PROPERTY_WIDTH))
[ # # ][ # # ]
1173 [ # # ]: 0 : disposingColumnModel(Source);
1174 : : }
1175 [ + - ]: 2 : SbaXDataBrowserController_Base::OGenericUnoController::disposing( Source );
1176 : 2 : }
1177 : :
1178 : : // -----------------------------------------------------------------------
1179 : 0 : void SAL_CALL SbaXDataBrowserController::setIdentifier( const ::rtl::OUString& _Identifier ) throw (RuntimeException)
1180 : : {
1181 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::setIdentifier" );
1182 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( getMutex() );
1183 [ # # ]: 0 : m_sModuleIdentifier = _Identifier;
1184 : 0 : }
1185 : :
1186 : : // -----------------------------------------------------------------------
1187 : 16 : ::rtl::OUString SAL_CALL SbaXDataBrowserController::getIdentifier( ) throw (RuntimeException)
1188 : : {
1189 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getIdentifier" );
1190 [ + - ][ + - ]: 16 : ::osl::MutexGuard aGuard( getMutex() );
1191 [ + - ]: 16 : return m_sModuleIdentifier;
1192 : : }
1193 : :
1194 : : // -----------------------------------------------------------------------
1195 : 8 : void SbaXDataBrowserController::propertyChange(const PropertyChangeEvent& evt) throw ( RuntimeException )
1196 : : {
1197 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::propertyChange" );
1198 [ + - ]: 8 : Reference< XPropertySet > xSource(evt.Source, UNO_QUERY);
1199 [ - + ]: 8 : if (!xSource.is())
1200 : 8 : return;
1201 : :
1202 [ + - ]: 8 : SolarMutexGuard aGuard;
1203 : : // the IsModified changed to sal_False ?
1204 [ + - ][ - + ]: 8 : if ( (evt.PropertyName.equals(PROPERTY_ISMODIFIED))
[ # # ][ + - ]
[ - + # # ]
1205 [ # # ]: 0 : && (::comphelper::getBOOL(evt.NewValue) == sal_False)
1206 : : )
1207 : : { // -> the current field isn't modified anymore, too
1208 [ # # ]: 0 : setCurrentModified( sal_False );
1209 : : }
1210 : :
1211 : : // switching to a new record ?
1212 [ + - ][ - + ]: 8 : if ( (evt.PropertyName.equals(PROPERTY_ISNEW))
[ # # ][ + - ]
[ - + # # ]
1213 [ # # ]: 0 : && (::comphelper::getBOOL(evt.NewValue) == sal_True)
1214 : : )
1215 : : {
1216 [ # # ][ # # ]: 0 : if (::comphelper::getINT32(xSource->getPropertyValue(PROPERTY_ROWCOUNT)) == 0)
[ # # ][ # # ]
[ # # ]
1217 : : // if we're switching to a new record and didn't have any records before we need to invalidate
1218 : : // all slots (as the cursor was invalid before the mode change and so the slots were disabled)
1219 [ # # ]: 0 : InvalidateAll();
1220 : : }
1221 : :
1222 : :
1223 [ + - ][ - + ]: 8 : if (evt.PropertyName.equals(PROPERTY_FILTER))
1224 : : {
1225 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
1226 : : }
1227 [ + - ][ - + ]: 8 : else if (evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE))
1228 : : {
1229 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
1230 : : }
1231 [ + - ][ + + ]: 8 : else if (evt.PropertyName.equals(PROPERTY_ORDER))
1232 : : {
1233 [ + - ][ + - ]: 2 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
1234 : : }
1235 : :
1236 : : // a new record count ? -> may be our search availability has changed
1237 [ + - ][ + + ]: 8 : if (evt.PropertyName.equals(PROPERTY_ROWCOUNT))
1238 : : {
1239 : 2 : sal_Int32 nNewValue = 0, nOldValue = 0;
1240 : 2 : evt.NewValue >>= nNewValue;
1241 : 2 : evt.OldValue >>= nOldValue;
1242 [ - + ][ # # ]: 2 : if((nOldValue == 0 && nNewValue != 0) || (nOldValue != 0 && nNewValue == 0))
[ # # ][ + - ]
1243 [ + - ]: 2 : InvalidateAll();
1244 [ + - ][ + - ]: 8 : }
1245 : : }
1246 : :
1247 : : //------------------------------------------------------------------------
1248 : 0 : void SbaXDataBrowserController::modified(const ::com::sun::star::lang::EventObject& /*aEvent*/) throw( RuntimeException )
1249 : : {
1250 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::modified" );
1251 : 0 : setCurrentModified( sal_True );
1252 : 0 : }
1253 : :
1254 : : // -----------------------------------------------------------------------
1255 : 62 : void SbaXDataBrowserController::elementInserted(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException )
1256 : : {
1257 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::elementInserted" );
1258 : : OSL_ENSURE(Reference< XInterface >(evt.Source, UNO_QUERY).get() == Reference< XInterface >(getControlModel(), UNO_QUERY).get(),
1259 : : "SbaXDataBrowserController::elementInserted: where did this come from (not from the grid model)?!");
1260 [ + - ]: 62 : Reference< XPropertySet > xNewColumn(evt.Element,UNO_QUERY);
1261 [ + - ]: 62 : if ( xNewColumn.is() )
1262 [ + - ]: 62 : AddColumnListener(xNewColumn);
1263 : 62 : }
1264 : :
1265 : : // -----------------------------------------------------------------------
1266 : 0 : void SbaXDataBrowserController::elementRemoved(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException )
1267 : : {
1268 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::elementRemoved" );
1269 : : OSL_ENSURE(Reference< XInterface >(evt.Source, UNO_QUERY).get() == Reference< XInterface >(getControlModel(), UNO_QUERY).get(),
1270 : : "SbaXDataBrowserController::elementRemoved: where did this come from (not from the grid model)?!");
1271 [ # # ]: 0 : Reference< XPropertySet > xOldColumn(evt.Element,UNO_QUERY);
1272 [ # # ]: 0 : if ( xOldColumn.is() )
1273 [ # # ]: 0 : RemoveColumnListener(xOldColumn);
1274 : 0 : }
1275 : :
1276 : : // -----------------------------------------------------------------------
1277 : 0 : void SbaXDataBrowserController::elementReplaced(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException )
1278 : : {
1279 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::elementReplaced" );
1280 : : OSL_ENSURE(Reference< XInterface >(evt.Source, UNO_QUERY).get() == Reference< XInterface >(getControlModel(), UNO_QUERY).get(),
1281 : : "SbaXDataBrowserController::elementReplaced: where did this come from (not from the grid model)?!");
1282 [ # # ]: 0 : Reference< XPropertySet > xOldColumn(evt.ReplacedElement,UNO_QUERY);
1283 [ # # ]: 0 : if ( xOldColumn.is() )
1284 [ # # ]: 0 : RemoveColumnListener(xOldColumn);
1285 : :
1286 [ # # ]: 0 : Reference< XPropertySet > xNewColumn(evt.Element,UNO_QUERY);
1287 [ # # ]: 0 : if ( xNewColumn.is() )
1288 [ # # ]: 0 : AddColumnListener(xNewColumn);
1289 : 0 : }
1290 : :
1291 : : // -----------------------------------------------------------------------
1292 : 0 : sal_Bool SbaXDataBrowserController::suspend(sal_Bool /*bSuspend*/) throw( RuntimeException )
1293 : : {
1294 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::suspend" );
1295 : : OSL_ENSURE(m_nPendingLoadFinished == 0, "SbaXDataBrowserController::suspend : there shouldn't be a pending load !");
1296 : :
1297 : 0 : m_aAsyncGetCellFocus.CancelCall();
1298 : 0 : m_aAsyncDisplayError.CancelCall();
1299 : 0 : m_aAsyncInvalidateAll.CancelCall();
1300 : :
1301 : 0 : sal_Bool bSuccess = SaveModified();
1302 : 0 : return bSuccess;
1303 : : }
1304 : : // -----------------------------------------------------------------------
1305 : 2 : void SbaXDataBrowserController::disposing()
1306 : : {
1307 : : // the base class
1308 [ + - ]: 2 : SbaXDataBrowserController_Base::OGenericUnoController::disposing();
1309 : :
1310 : : // the data source
1311 [ + - ][ + - ]: 2 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1312 [ + - ]: 2 : if (xFormSet.is())
1313 : : {
1314 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_ISNEW, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1315 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_ISMODIFIED, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1316 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_ROWCOUNT, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1317 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_ACTIVECOMMAND, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1318 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_ORDER, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1319 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_FILTER, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1320 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_HAVING_CLAUSE, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1321 [ + - ][ + - ]: 2 : xFormSet->removePropertyChangeListener(PROPERTY_APPLYFILTER, static_cast<XPropertyChangeListener*>(this));
[ + - ][ + - ]
1322 : : }
1323 : :
1324 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
1325 [ + - ]: 2 : if (xFormError.is())
1326 [ + - ][ + - ]: 2 : xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
[ + - ]
1327 : :
1328 [ + - ]: 2 : if (m_xLoadable.is())
1329 [ + - ][ + - ]: 2 : m_xLoadable->removeLoadListener(this);
[ + - ]
1330 : :
1331 [ + - ][ + - ]: 2 : Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(getRowSet(), UNO_QUERY);
1332 [ + - ]: 2 : if (xFormParameter.is())
1333 [ + - ][ + - ]: 2 : xFormParameter->removeParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this);
[ + - ]
1334 : :
1335 [ + - ][ + - ]: 2 : removeModelListeners(getControlModel());
1336 : :
1337 [ + - ][ + - ]: 2 : if ( getView() && m_pClipbordNotifier )
[ + - ]
1338 : : {
1339 [ + - ]: 2 : m_pClipbordNotifier->ClearCallbackLink();
1340 [ + - ]: 2 : m_pClipbordNotifier->AddRemoveListener( getView(), sal_False );
1341 : 2 : m_pClipbordNotifier->release();
1342 : 2 : m_pClipbordNotifier = NULL;
1343 : : }
1344 : :
1345 [ + - ]: 2 : if (getBrowserView())
1346 : : {
1347 [ + - ][ + - ]: 2 : removeControlListeners(getBrowserView()->getGridControl());
[ # # ]
1348 : : // don't delete explicitly, this is done by the owner (and user) of this controller (me hopes ...)
1349 : 2 : clearView();
1350 : : }
1351 : :
1352 [ + - ]: 2 : if(m_aInvalidateClipboard.IsActive())
1353 [ + - ]: 2 : m_aInvalidateClipboard.Stop();
1354 : :
1355 : : // dispose the row set
1356 : : try
1357 : : {
1358 [ + - ]: 2 : ::comphelper::disposeComponent(m_xRowSet);
1359 : :
1360 [ + - ]: 2 : m_xRowSet = NULL;
1361 [ + - ]: 2 : m_xColumnsSupplier = NULL;
1362 [ + - ]: 2 : m_xLoadable = NULL;
1363 : : }
1364 [ # # ]: 0 : catch(Exception&)
1365 : : {
1366 : : DBG_UNHANDLED_EXCEPTION();
1367 : : }
1368 : 2 : m_xParser.clear();
1369 : : // don't dispose, just reset - it's owned by the RowSet
1370 : 2 : }
1371 : : //------------------------------------------------------------------------------
1372 : 2 : void SbaXDataBrowserController::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException )
1373 : : {
1374 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::frameAction" );
1375 [ + - ][ + - ]: 2 : ::osl::MutexGuard aGuard( getMutex() );
1376 : :
1377 [ + - ]: 2 : SbaXDataBrowserController_Base::frameAction( aEvent );
1378 : :
1379 [ + - ][ + - ]: 2 : if ( aEvent.Source == getFrame() )
[ + - ]
1380 [ - - + ]: 2 : switch ( aEvent.Action )
1381 : : {
1382 : : case FrameAction_FRAME_ACTIVATED:
1383 : : case FrameAction_FRAME_UI_ACTIVATED:
1384 : : // ensure that the active cell (if any) has the focus
1385 [ # # ]: 0 : m_aAsyncGetCellFocus.Call();
1386 : : // start the clipboard timer
1387 [ # # ][ # # ]: 0 : if (getBrowserView() && getBrowserView()->getVclControl() && !m_aInvalidateClipboard.IsActive())
[ # # ][ # # ]
[ # # ]
1388 : : {
1389 [ # # ]: 0 : m_aInvalidateClipboard.Start();
1390 [ # # ]: 0 : OnInvalidateClipboard( NULL );
1391 : : }
1392 : 0 : break;
1393 : : case FrameAction_FRAME_DEACTIVATING:
1394 : : case FrameAction_FRAME_UI_DEACTIVATING:
1395 : : // stop the clipboard invalidator
1396 [ # # ][ # # ]: 0 : if (getBrowserView() && getBrowserView()->getVclControl() && m_aInvalidateClipboard.IsActive())
[ # # ][ # # ]
[ # # ]
1397 : : {
1398 [ # # ]: 0 : m_aInvalidateClipboard.Stop();
1399 [ # # ]: 0 : OnInvalidateClipboard( NULL );
1400 : : }
1401 : : // remove the "get cell focus"-event
1402 [ # # ]: 0 : m_aAsyncGetCellFocus.CancelCall();
1403 : 0 : break;
1404 : : default:
1405 : 2 : break;
1406 [ + - ]: 2 : }
1407 : 2 : }
1408 : :
1409 : : //------------------------------------------------------------------------------
1410 : 0 : IMPL_LINK( SbaXDataBrowserController, OnAsyncDisplayError, void*, /* _pNotInterestedIn */ )
1411 : : {
1412 [ # # ]: 0 : if ( m_aCurrentError.isValid() )
1413 : : {
1414 [ # # ]: 0 : OSQLMessageBox aDlg( getBrowserView(), m_aCurrentError );
1415 [ # # ][ # # ]: 0 : aDlg.Execute();
1416 : : }
1417 : 0 : return 0L;
1418 : : }
1419 : :
1420 : : //------------------------------------------------------------------------------
1421 : 0 : void SbaXDataBrowserController::errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( RuntimeException )
1422 : : {
1423 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::errorOccurred" );
1424 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( getMutex() );
1425 : :
1426 [ # # ]: 0 : SQLExceptionInfo aInfo( aEvent.Reason );
1427 [ # # ]: 0 : if ( !aInfo.isValid() )
1428 : 0 : return;
1429 : :
1430 [ # # ]: 0 : if ( m_nFormActionNestingLevel )
1431 : : {
1432 : : OSL_ENSURE( !m_aCurrentError.isValid(), "SbaXDataBrowserController::errorOccurred: can handle one error per transaction only!" );
1433 [ # # ]: 0 : m_aCurrentError = aInfo;
1434 : : }
1435 : : else
1436 : : {
1437 [ # # ]: 0 : m_aCurrentError = aInfo;
1438 [ # # ]: 0 : m_aAsyncDisplayError.Call();
1439 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1440 : : }
1441 : :
1442 : : //------------------------------------------------------------------------------
1443 : 0 : sal_Bool SbaXDataBrowserController::approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( RuntimeException )
1444 : : {
1445 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::approveParameter" );
1446 [ # # ][ # # ]: 0 : if (aEvent.Source != getRowSet())
[ # # ]
1447 : : {
1448 : : // not my data source -> allow anything
1449 : : OSL_FAIL("SbaXDataBrowserController::approveParameter : invalid event source !");
1450 : 0 : return sal_True;
1451 : : }
1452 : :
1453 : 0 : Reference< ::com::sun::star::container::XIndexAccess > xParameters = aEvent.Parameters;
1454 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
1455 : :
1456 : : // default handling: instantiate an interaction handler and let it handle the parameter request
1457 : : try
1458 : : {
1459 : : // two continuations allowed: OK and Cancel
1460 [ # # ]: 0 : OParameterContinuation* pParamValues = new OParameterContinuation;
1461 [ # # ]: 0 : OInteractionAbort* pAbort = new OInteractionAbort;
1462 : : // the request
1463 [ # # ]: 0 : ParametersRequest aRequest;
1464 [ # # ]: 0 : aRequest.Parameters = xParameters;
1465 [ # # ][ # # ]: 0 : aRequest.Connection = getConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY));
[ # # ]
1466 [ # # ][ # # ]: 0 : OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest));
1467 [ # # ][ # # ]: 0 : Reference< XInteractionRequest > xParamRequest(pParamRequest);
1468 : : // some knittings
1469 [ # # ][ # # ]: 0 : pParamRequest->addContinuation(pParamValues);
[ # # ]
1470 [ # # ][ # # ]: 0 : pParamRequest->addContinuation(pAbort);
[ # # ]
1471 : :
1472 : : // create the handler, let it handle the request
1473 [ # # ][ # # ]: 0 : Reference< XInteractionHandler > xHandler(getORB()->createInstance(SERVICE_TASK_INTERACTION_HANDLER), UNO_QUERY);
[ # # ][ # # ]
[ # # ]
1474 [ # # ]: 0 : if (xHandler.is())
1475 [ # # ][ # # ]: 0 : xHandler->handle(xParamRequest);
1476 : :
1477 [ # # ]: 0 : if (!pParamValues->wasSelected())
1478 : : { // canceled
1479 : 0 : setLoadingCancelled();
1480 : 0 : return sal_False;
1481 : : }
1482 : :
1483 : : // transfer the values into the parameter supplier
1484 [ # # ]: 0 : Sequence< PropertyValue > aFinalValues = pParamValues->getValues();
1485 [ # # ][ # # ]: 0 : if (aFinalValues.getLength() != aRequest.Parameters->getCount())
[ # # ]
1486 : : {
1487 : : OSL_FAIL("SbaXDataBrowserController::approveParameter: the InteractionHandler returned nonsense!");
1488 : 0 : setLoadingCancelled();
1489 : 0 : return sal_False;
1490 : : }
1491 : 0 : const PropertyValue* pFinalValues = aFinalValues.getConstArray();
1492 [ # # ]: 0 : for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
1493 : : {
1494 : 0 : Reference< XPropertySet > xParam;
1495 [ # # ][ # # ]: 0 : ::cppu::extractInterface(xParam, aRequest.Parameters->getByIndex(i));
[ # # ]
1496 : : OSL_ENSURE(xParam.is(), "SbaXDataBrowserController::approveParameter: one of the parameters is no property set!");
1497 [ # # ]: 0 : if (xParam.is())
1498 : : {
1499 : : #ifdef DBG_UTIL
1500 : : ::rtl::OUString sName;
1501 : : xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
1502 : : OSL_ENSURE(sName.equals(pFinalValues->Name), "SbaXDataBrowserController::approveParameter: suspicious value names!");
1503 : : #endif
1504 [ # # ][ # # ]: 0 : try { xParam->setPropertyValue(PROPERTY_VALUE, pFinalValues->Value); }
[ # # ][ # # ]
1505 [ # # ]: 0 : catch(Exception&)
1506 : : {
1507 : : OSL_FAIL("SbaXDataBrowserController::approveParameter: setting one of the properties failed!");
1508 : : }
1509 : : }
1510 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1511 : : }
1512 [ # # ]: 0 : catch( const Exception& )
1513 : : {
1514 : : DBG_UNHANDLED_EXCEPTION();
1515 : : }
1516 : :
1517 [ # # ]: 0 : return sal_True;
1518 : : }
1519 : :
1520 : :
1521 : : //------------------------------------------------------------------------------
1522 : 0 : sal_Bool SbaXDataBrowserController::approveReset(const ::com::sun::star::lang::EventObject& /*rEvent*/) throw( RuntimeException )
1523 : : {
1524 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::approveReset" );
1525 : 0 : return sal_True;
1526 : : }
1527 : :
1528 : : //------------------------------------------------------------------------------
1529 : 0 : void SbaXDataBrowserController::resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( RuntimeException )
1530 : : {
1531 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::resetted" );
1532 : : OSL_ENSURE(rEvent.Source == getControlModel(), "SbaXDataBrowserController::resetted : where did this come from ?");
1533 : : (void)rEvent;
1534 : 0 : setCurrentModified( sal_False );
1535 : 0 : }
1536 : :
1537 : : //------------------------------------------------------------------------------
1538 : 0 : sal_Bool SbaXDataBrowserController::confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& /*aEvent*/) throw( RuntimeException )
1539 : : {
1540 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::confirmDelete" );
1541 [ # # ][ # # ]: 0 : if (QueryBox(getBrowserView(), ModuleRes(QUERY_BRW_DELETE_ROWS)).Execute() != RET_YES)
[ # # ][ # # ]
1542 : 0 : return sal_False;
1543 : :
1544 : 0 : return sal_True;
1545 : : }
1546 : : //------------------------------------------------------------------------------
1547 : 117 : FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const
1548 : : {
1549 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::GetState" );
1550 [ + - ]: 117 : FeatureState aReturn;
1551 : : // (disabled automatically)
1552 : :
1553 : : try
1554 : : {
1555 : : // no chance without a view
1556 [ + - ][ + - ]: 117 : if (!getBrowserView() || !getBrowserView()->getVclControl())
[ - + ][ - + ]
1557 [ # # ]: 0 : return aReturn;
1558 : :
1559 [ + + ]: 117 : switch (nId)
1560 : : {
1561 : : case ID_BROWSER_REMOVEFILTER:
1562 [ + + ]: 9 : if (!m_xParser.is())
1563 : : {
1564 : 3 : aReturn.bEnabled = false;
1565 [ + - ]: 3 : return aReturn;
1566 : : }
1567 : : // any filter or sort order set ?
1568 [ + - ][ + - ]: 6 : aReturn.bEnabled = m_xParser->getFilter().getLength() || m_xParser->getHavingClause().getLength() || m_xParser->getOrder().getLength();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # # #
# # ]
1569 [ + - ]: 6 : return aReturn;
1570 : : }
1571 : : // no chance without valid models
1572 [ + - ][ + - ]: 108 : if (isValid() && !isValidCursor())
[ - + ][ - + ]
1573 [ # # ]: 0 : return aReturn;
1574 : :
1575 [ + + + - : 108 : switch (nId)
+ + + + -
- + + +
+ ]
1576 : : {
1577 : : case ID_BROWSER_SEARCH:
1578 : : {
1579 [ + - ][ + - ]: 4 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1580 [ + - ][ + - ]: 4 : sal_Int32 nCount = ::comphelper::getINT32(xFormSet->getPropertyValue(PROPERTY_ROWCOUNT));
[ + - ][ + - ]
1581 : 4 : aReturn.bEnabled = nCount != 0;
1582 : : }
1583 : 4 : break;
1584 : : case ID_BROWSER_INSERT_ROW:
1585 : : {
1586 : : // check if it is available
1587 : 4 : sal_Bool bInsertPrivilege = ( m_nRowSetPrivileges & Privilege::INSERT) != 0;
1588 : 4 : sal_Bool bAllowInsertions = sal_True;
1589 : : try
1590 : : {
1591 [ + - ][ + - ]: 4 : Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
1592 [ + - ][ + - ]: 4 : OSL_VERIFY( xRowSetProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowInserts")) ) >>= bAllowInsertions );
[ # # ][ + - ]
1593 : : }
1594 [ # # ]: 0 : catch( const Exception& )
1595 : : {
1596 : : DBG_UNHANDLED_EXCEPTION();
1597 : : }
1598 [ + - ][ + - ]: 4 : aReturn.bEnabled = bInsertPrivilege && bAllowInsertions;
1599 : : }
1600 : 4 : break;
1601 : : case SID_FM_DELETEROWS:
1602 : : {
1603 : : // check if it is available
1604 : 4 : sal_Bool bDeletePrivilege = ( m_nRowSetPrivileges & Privilege::INSERT) != 0;
1605 : 4 : sal_Bool bAllowDeletions = sal_True;
1606 : 4 : sal_Int32 nRowCount = 0;
1607 : 4 : sal_Bool bInsertionRow = sal_False;
1608 : : try
1609 : : {
1610 [ + - ][ + - ]: 4 : Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
1611 [ + - ][ + - ]: 4 : OSL_VERIFY( xRowSetProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowDeletes")) ) >>= bAllowDeletions );
[ + - ]
1612 [ + - ][ + - ]: 4 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ROWCOUNT ) >>= nRowCount );
[ + - ]
1613 [ + - ][ + - ]: 4 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ISNEW ) >>= bInsertionRow );
[ # # ][ + - ]
1614 : : }
1615 [ # # ]: 0 : catch( const Exception& )
1616 : : {
1617 : : DBG_UNHANDLED_EXCEPTION();
1618 : : }
1619 [ + - ][ + - ]: 4 : aReturn.bEnabled = bDeletePrivilege && bAllowDeletions && ( nRowCount != 0 ) && !bInsertionRow;
[ + - ][ + - ]
1620 : : }
1621 : 4 : break;
1622 : :
1623 : : case ID_BROWSER_COPY:
1624 [ # # ][ # # ]: 0 : if ( getBrowserView()->getVclControl()->GetSelectRowCount() )
[ # # ]
1625 : : {
1626 [ # # ]: 0 : aReturn.bEnabled = m_aCurrentFrame.isActive();
1627 : 0 : break;
1628 : : }
1629 : : // run through
1630 : : case ID_BROWSER_PASTE:
1631 : : case ID_BROWSER_CUT:
1632 : : {
1633 [ + - ][ + - ]: 21 : CellControllerRef xCurrentController = getBrowserView()->getVclControl()->Controller();
1634 [ - + ][ # # ]: 21 : if (xCurrentController.Is() && xCurrentController->ISA(EditCellController))
[ # # ][ # # ]
[ - + ]
1635 : : {
1636 : 0 : Edit& rEdit = (Edit&)xCurrentController->GetWindow();
1637 [ # # ]: 0 : sal_Bool bHasLen = (rEdit.GetSelection().Len() != 0);
1638 [ # # ]: 0 : sal_Bool bIsReadOnly = rEdit.IsReadOnly();
1639 [ # # # # ]: 0 : switch (nId)
1640 : : {
1641 [ # # ][ # # ]: 0 : case ID_BROWSER_CUT: aReturn.bEnabled = m_aCurrentFrame.isActive() && bHasLen && !bIsReadOnly; break;
[ # # ][ # # ]
1642 [ # # ][ # # ]: 0 : case SID_COPY : aReturn.bEnabled = m_aCurrentFrame.isActive() && bHasLen; break;
[ # # ]
1643 : : case ID_BROWSER_PASTE:
1644 [ # # ][ # # ]: 0 : aReturn.bEnabled = m_aCurrentFrame.isActive() && !bIsReadOnly;
[ # # ]
1645 [ # # ]: 0 : if(aReturn.bEnabled)
1646 : : {
1647 [ # # ][ # # ]: 0 : aReturn.bEnabled = aReturn.bEnabled && IsFormatSupported( m_aSystemClipboard.GetDataFlavorExVector(), FORMAT_STRING );
[ # # ]
1648 : : }
1649 : 0 : break;
1650 : : }
1651 [ + - ]: 21 : }
1652 : : }
1653 : 21 : break;
1654 : :
1655 : : case ID_BROWSER_SORTUP:
1656 : : case ID_BROWSER_SORTDOWN:
1657 : : case ID_BROWSER_AUTOFILTER:
1658 : : {
1659 : : // a native statement can't be filtered or sorted
1660 [ + - ][ + - ]: 15 : const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1661 [ + - ][ + - ]: 15 : if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) || !m_xParser.is() )
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ - + ]
[ # # # # ]
[ + - ]
1662 : : break;
1663 : :
1664 [ + - ]: 15 : Reference< XPropertySet > xCurrentField = getBoundField();
1665 [ - + ]: 15 : if (!xCurrentField.is())
1666 : : break;
1667 : :
1668 [ + - ][ + - ]: 15 : aReturn.bEnabled = ::comphelper::getBOOL(xCurrentField->getPropertyValue(PROPERTY_ISSEARCHABLE));
[ + - ][ + - ]
1669 [ + - ]: 15 : const Reference< XRowSet > xRow = getRowSet();
1670 : : aReturn.bEnabled = aReturn.bEnabled
1671 : 15 : && xRow.is()
1672 [ + - ][ + - ]: 15 : && !xRow->isBeforeFirst()
1673 [ + - ][ + - ]: 15 : && !xRow->isAfterLast()
1674 [ + - ][ + - ]: 15 : && !xRow->rowDeleted()
1675 [ + - + - ]: 75 : && ( ::comphelper::getINT32( xFormSet->getPropertyValue( PROPERTY_ROWCOUNT ) ) != 0 );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + -
# # # # ]
1676 : : }
1677 : 15 : break;
1678 : :
1679 : : case ID_BROWSER_FILTERCRIT:
1680 [ - + ][ # # ]: 5 : if ( m_bCannotSelectUnfiltered && m_xParser.is() )
[ - + ]
1681 : : {
1682 : 0 : aReturn.bEnabled = sal_True;
1683 : 0 : break;
1684 : : }
1685 : : // no break
1686 : : case ID_BROWSER_ORDERCRIT:
1687 : : {
1688 [ + - ][ + - ]: 10 : const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1689 [ + - ][ + - ]: 10 : if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) || !m_xParser.is() )
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ - + ]
[ # # # # ]
[ + - ]
1690 : : break;
1691 : :
1692 [ + - ][ + - ]: 20 : aReturn.bEnabled = getRowSet().is()
[ # # ]
1693 [ + - ][ + - ]: 20 : && ( ::comphelper::getINT32( xFormSet->getPropertyValue( PROPERTY_ROWCOUNT ) ) != 0 );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + -
# # # # ]
[ + - ]
1694 : : }
1695 : 10 : break;
1696 : :
1697 : : case ID_BROWSER_REFRESH:
1698 : 0 : aReturn.bEnabled = sal_True;
1699 : 0 : break;
1700 : :
1701 : : case ID_BROWSER_REDO:
1702 : 0 : aReturn.bEnabled = sal_False; // simply forget it ;). no redo possible.
1703 : 0 : break;
1704 : :
1705 : : case ID_BROWSER_UNDORECORD:
1706 : : case ID_BROWSER_SAVERECORD:
1707 : : {
1708 [ + - ]: 34 : if (!m_bCurrentlyModified)
1709 : : {
1710 [ + - ][ + - ]: 34 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1711 [ + - ]: 34 : if (xFormSet.is())
1712 [ + - ][ + - ]: 34 : aReturn.bEnabled = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISMODIFIED));
[ + - ][ + - ]
1713 : : }
1714 : : else
1715 : 0 : aReturn.bEnabled = sal_True;
1716 : :
1717 [ + + ][ + - ]: 34 : aReturn.sTitle = (ID_BROWSER_UNDORECORD == nId) ? m_sStateUndoRecord : m_sStateSaveRecord;
[ + - ]
1718 : : }
1719 : 34 : break;
1720 : : case ID_BROWSER_EDITDOC:
1721 : : {
1722 : : // check if it is available
1723 [ + - ][ + - ]: 4 : Reference< XPropertySet > xDataSourceSet(getRowSet(), UNO_QUERY);
1724 [ - + ]: 4 : if (!xDataSourceSet.is())
1725 : : break; // no datasource -> no edit mode
1726 : :
1727 [ + - ][ + - ]: 4 : sal_Int32 nDataSourcePrivileges = ::comphelper::getINT32(xDataSourceSet->getPropertyValue(PROPERTY_PRIVILEGES));
[ + - ][ + - ]
1728 [ + - ][ + - ]: 4 : sal_Bool bInsertAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::INSERT) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowInserts"))));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
[ # # # # ]
[ + - ]
1729 [ + - ][ + - ]: 4 : sal_Bool bUpdateAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::UPDATE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowUpdates"))));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # # # ]
1730 [ + - ][ + - ]: 4 : sal_Bool bDeleteAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::DELETE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowDeletes"))));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # # # ]
1731 [ - + ][ # # ]: 4 : if (!bInsertAllowedAndPossible && !bUpdateAllowedAndPossible && !bDeleteAllowedAndPossible)
[ # # ]
1732 : : break; // no insert/update/delete -> no edit mode
1733 : :
1734 [ + - ][ + - ]: 4 : if (!isValidCursor() || !isLoaded())
[ + - ][ - + ]
[ - + ]
1735 : : break; // no cursor -> no edit mode
1736 : :
1737 : 4 : aReturn.bEnabled = sal_True;
1738 : :
1739 [ + - ]: 4 : sal_Int16 nGridMode = getBrowserView()->getVclControl()->GetOptions();
1740 [ + - ][ + - ]: 4 : aReturn.bChecked = nGridMode > DbGridControl::OPT_READONLY;
1741 : : }
1742 : 4 : break;
1743 : : case ID_BROWSER_FILTERED:
1744 : : {
1745 : 4 : aReturn.bEnabled = sal_False;
1746 [ + - ][ + - ]: 4 : Reference< XPropertySet > xActiveSet(getRowSet(), UNO_QUERY);
1747 [ + - ][ + - ]: 4 : ::rtl::OUString aFilter = ::comphelper::getString(xActiveSet->getPropertyValue(PROPERTY_FILTER));
[ + - ][ + - ]
1748 [ + - ][ + - ]: 4 : ::rtl::OUString aHaving = ::comphelper::getString(xActiveSet->getPropertyValue(PROPERTY_HAVING_CLAUSE));
[ + - ][ + - ]
1749 [ - + ][ - + ]: 4 : if ( !(aFilter.isEmpty() && aHaving.isEmpty()) )
[ + - ]
1750 : : {
1751 [ # # ][ # # ]: 0 : xActiveSet->getPropertyValue( PROPERTY_APPLYFILTER ) >>= aReturn.bChecked;
[ # # ][ # # ]
1752 : 0 : aReturn.bEnabled = sal_True;
1753 : : }
1754 : : else
1755 : : {
1756 [ + - ]: 4 : aReturn.bChecked = sal_False;
1757 : 4 : aReturn.bEnabled = sal_False;
1758 [ # # ]: 4 : }
1759 : : }
1760 : 4 : break;
1761 : : default:
1762 [ + - ]: 8 : return SbaXDataBrowserController_Base::GetState(nId);
1763 : : }
1764 : : }
1765 [ # # ]: 0 : catch(const Exception& )
1766 : : {
1767 : : DBG_UNHANDLED_EXCEPTION();
1768 : : }
1769 : :
1770 [ + - ][ + - ]: 117 : return aReturn;
1771 : : }
1772 : :
1773 : : //------------------------------------------------------------------------------
1774 : 0 : void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrder,const Reference< XSingleSelectQueryComposer >& _xParser)
1775 : : {
1776 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserOrder" );
1777 [ # # ][ # # ]: 0 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1778 [ # # ]: 0 : if (!m_xLoadable.is())
1779 : : {
1780 : : OSL_FAIL("SbaXDataBrowserController::applyParserOrder: invalid row set!");
1781 : 0 : return;
1782 : : }
1783 : :
1784 [ # # ]: 0 : sal_uInt16 nPos = getCurrentColumnPosition();
1785 : 0 : sal_Bool bSuccess = sal_False;
1786 : : try
1787 : : {
1788 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_xParser->getOrder()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1789 [ # # ]: 0 : bSuccess = reloadForm(m_xLoadable);
1790 : : }
1791 [ # # ]: 0 : catch(Exception&)
1792 : : {
1793 : : }
1794 : :
1795 [ # # ]: 0 : if (!bSuccess)
1796 : : {
1797 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_rOldOrder));
[ # # ][ # # ]
1798 : :
1799 : : try
1800 : : {
1801 [ # # ][ # # ]: 0 : if (loadingCancelled() || !reloadForm(m_xLoadable))
[ # # ][ # # ]
1802 [ # # ]: 0 : criticalFail();
1803 : : }
1804 [ # # # # ]: 0 : catch(Exception&)
1805 : : {
1806 [ # # ]: 0 : criticalFail();
1807 : : }
1808 [ # # ]: 0 : InvalidateAll();
1809 : : }
1810 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
1811 : :
1812 [ # # ][ # # ]: 0 : setCurrentColumnPosition(nPos);
1813 : : }
1814 : :
1815 : : //------------------------------------------------------------------------------
1816 : 0 : void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving,const Reference< XSingleSelectQueryComposer >& _xParser)
1817 : : {
1818 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserFilter" );
1819 [ # # ][ # # ]: 0 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1820 [ # # ]: 0 : if (!m_xLoadable.is())
1821 : : {
1822 : : OSL_FAIL("SbaXDataBrowserController::applyParserFilter: invalid row set!");
1823 : 0 : return;
1824 : : }
1825 : :
1826 [ # # ]: 0 : sal_uInt16 nPos = getCurrentColumnPosition();
1827 : :
1828 : 0 : sal_Bool bSuccess = sal_False;
1829 : : try
1830 : : {
1831 [ # # ]: 0 : FormErrorHelper aError(this);
1832 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_xParser->getFilter()));
[ # # ][ # # ]
[ # # ][ # # ]
1833 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_xParser->getHavingClause()));
[ # # ][ # # ]
[ # # ][ # # ]
1834 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True)));
[ # # ][ # # ]
1835 : :
1836 [ # # ][ # # ]: 0 : bSuccess = reloadForm(m_xLoadable);
[ # # ]
1837 : : }
1838 [ # # ]: 0 : catch(Exception&)
1839 : : {
1840 : : }
1841 : :
1842 [ # # ]: 0 : if (!bSuccess)
1843 : : {
1844 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_rOldFilter));
[ # # ][ # # ]
1845 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_sOldHaving));
[ # # ][ # # ]
1846 [ # # ][ # # ]: 0 : xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(_bOldFilterApplied));
[ # # ][ # # ]
1847 : :
1848 : : try
1849 : : {
1850 [ # # ][ # # ]: 0 : if (loadingCancelled() || !reloadForm(m_xLoadable))
[ # # ][ # # ]
1851 [ # # ]: 0 : criticalFail();
1852 : : }
1853 [ # # # # ]: 0 : catch(Exception&)
1854 : : {
1855 [ # # ]: 0 : criticalFail();
1856 : : }
1857 [ # # ]: 0 : InvalidateAll();
1858 : : }
1859 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
1860 : :
1861 [ # # ][ # # ]: 0 : setCurrentColumnPosition(nPos);
1862 : : }
1863 : :
1864 : : //------------------------------------------------------------------------------
1865 : 2 : Reference< XSingleSelectQueryComposer > SbaXDataBrowserController::createParser_nothrow()
1866 : : {
1867 : 2 : Reference< XSingleSelectQueryComposer > xComposer;
1868 : : try
1869 : : {
1870 [ + - ][ + - ]: 2 : const Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
1871 : : const Reference< XMultiServiceFactory > xFactory(
1872 [ + - ][ + - ]: 2 : xRowSetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ), UNO_QUERY_THROW );
[ + - ][ + - ]
1873 [ + - ][ + - ]: 2 : xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
[ + - ][ + - ]
1874 : :
1875 : 2 : ::rtl::OUString sActiveCommand;
1876 [ + - ][ + - ]: 2 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sActiveCommand );
[ + - ]
1877 [ - + ]: 2 : if ( !sActiveCommand.isEmpty() )
1878 : : {
1879 [ # # ][ # # ]: 0 : xComposer->setElementaryQuery( sActiveCommand );
1880 : : }
1881 : : else
1882 : : {
1883 : 2 : ::rtl::OUString sCommand;
1884 [ + - ][ + - ]: 2 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
[ + - ]
1885 : 2 : sal_Int32 nCommandType = CommandType::COMMAND;
1886 [ + - ][ + - ]: 2 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND_TYPE ) >>= nCommandType );
[ + - ]
1887 [ + - ][ + - ]: 2 : xComposer->setCommand( sCommand, nCommandType );
1888 : : }
1889 : :
1890 : 2 : ::rtl::OUString sFilter;
1891 [ + - ][ + - ]: 2 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_FILTER ) >>= sFilter );
[ + - ]
1892 [ + - ][ + - ]: 2 : xComposer->setFilter( sFilter );
1893 : :
1894 : 2 : ::rtl::OUString sHavingClause;
1895 [ + - ][ + - ]: 2 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_HAVING_CLAUSE ) >>= sHavingClause );
[ + - ]
1896 [ + - ][ + - ]: 2 : xComposer->setHavingClause( sHavingClause );
1897 : :
1898 : 2 : ::rtl::OUString sOrder;
1899 [ + - ][ + - ]: 2 : OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ORDER ) >>= sOrder );
[ + - ]
1900 [ + - ][ # # ]: 2 : xComposer->setOrder( sOrder );
[ + - ]
1901 : : }
1902 [ # # ]: 0 : catch ( const Exception& )
1903 : : {
1904 : : DBG_UNHANDLED_EXCEPTION();
1905 : : }
1906 : 2 : return xComposer;
1907 : : }
1908 : : //------------------------------------------------------------------------------
1909 : 0 : void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
1910 : : {
1911 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::ExecuteFilterSortCrit" );
1912 [ # # ][ # # ]: 0 : if (!SaveModified())
1913 : : return;
1914 : :
1915 [ # # ][ # # ]: 0 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
1916 : :
1917 [ # # ][ # # ]: 0 : const ::rtl::OUString sOldVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder();
[ # # ][ # # ]
[ # # ]
1918 [ # # ][ # # ]: 0 : const ::rtl::OUString sOldHaving = m_xParser->getHavingClause();
1919 [ # # ]: 0 : Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
1920 : : try
1921 : : {
1922 [ # # ]: 0 : Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSup = getColumnsSupplier();
1923 [ # # ][ # # ]: 0 : Reference< XConnection> xCon(xFormSet->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
[ # # ][ # # ]
1924 [ # # ]: 0 : if(bFilter)
1925 : : {
1926 [ # # ][ # # ]: 0 : DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() );
[ # # ][ # # ]
1927 [ # # ]: 0 : String aFilter;
1928 [ # # ][ # # ]: 0 : if ( !aDlg.Execute() )
1929 : : return; // if so we don't need to update the grid
1930 [ # # ][ # # ]: 0 : aDlg.BuildWherePart();
[ # # ][ # # ]
[ # # ]
1931 : : }
1932 : : else
1933 : : {
1934 [ # # ][ # # ]: 0 : DlgOrderCrit aDlg( getBrowserView(),xCon,xParser,xSup->getColumns() );
[ # # ]
1935 [ # # ]: 0 : String aOrder;
1936 [ # # ][ # # ]: 0 : if(!aDlg.Execute())
1937 : : {
1938 : : return; // if so we don't need to actualize the grid
1939 : : }
1940 [ # # ][ # # ]: 0 : aDlg.BuildOrderPart();
[ # # ][ # # ]
[ # # ]
1941 [ # # ][ # # ]: 0 : }
1942 : : }
1943 [ # # # # : 0 : catch(const SQLException& )
# ]
1944 : : {
1945 [ # # # # ]: 0 : SQLExceptionInfo aError( ::cppu::getCaughtException() );
1946 [ # # ]: 0 : showError( aError );
1947 [ # # ]: 0 : return;
1948 : : }
1949 [ # # ]: 0 : catch(Exception&)
1950 : : {
1951 : : return;
1952 : : }
1953 : :
1954 [ # # ][ # # ]: 0 : ::rtl::OUString sNewVal = bFilter ? xParser->getFilter() : xParser->getOrder();
[ # # ][ # # ]
[ # # ]
1955 : 0 : sal_Bool bOldFilterApplied(sal_False);
1956 [ # # ]: 0 : if (bFilter)
1957 : : {
1958 [ # # ][ # # ]: 0 : try { bOldFilterApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER)); } catch(Exception&) { } ;
[ # # ][ # # ]
[ # # # # ]
1959 : : }
1960 : :
1961 [ # # ][ # # ]: 0 : ::rtl::OUString sNewHaving = xParser->getHavingClause();
1962 [ # # ][ # # ]: 0 : if ( sOldVal.equals(sNewVal) && (!bFilter || sOldHaving.equals(sNewHaving)) )
[ # # ][ # # ]
1963 : : // nothing to be done
1964 : : return;
1965 : :
1966 [ # # ]: 0 : if (bFilter)
1967 [ # # ]: 0 : applyParserFilter(sOldVal, bOldFilterApplied,sOldHaving,xParser);
1968 : : else
1969 [ # # ]: 0 : applyParserOrder(sOldVal,xParser);
1970 : :
1971 [ # # ][ # # ]: 0 : ::comphelper::disposeComponent(xParser);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1972 : : }
1973 : :
1974 : : //------------------------------------------------------------------------------
1975 : 0 : void SbaXDataBrowserController::ExecuteSearch()
1976 : : {
1977 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::ExecuteSearch" );
1978 : : // calculate the control source of the active field
1979 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
1980 : : OSL_ENSURE(xGrid.is(), "SbaXDataBrowserController::ExecuteSearch : the control should have an ::com::sun::star::form::XGrid interface !");
1981 : :
1982 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::form::XGridPeer > xGridPeer(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY);
[ # # ][ # # ]
1983 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::container::XIndexContainer > xColumns = xGridPeer->getColumns();
1984 : : OSL_ENSURE(xGridPeer.is() && xColumns.is(), "SbaXDataBrowserController::ExecuteSearch : invalid peer !");
1985 : :
1986 [ # # ][ # # ]: 0 : sal_Int16 nViewCol = xGrid->getCurrentColumnPosition();
1987 [ # # ]: 0 : sal_Int16 nModelCol = getBrowserView()->View2ModelPos(nViewCol);
1988 : :
1989 [ # # ][ # # ]: 0 : Reference< XPropertySet > xCurrentCol(xColumns->getByIndex(nModelCol),UNO_QUERY);
[ # # ]
1990 [ # # ][ # # ]: 0 : String sActiveField = ::comphelper::getString(xCurrentCol->getPropertyValue(PROPERTY_CONTROLSOURCE));
[ # # ][ # # ]
[ # # ]
1991 : :
1992 : : // the text within the current cell
1993 [ # # ]: 0 : String sInitialText;
1994 [ # # ]: 0 : Reference< ::com::sun::star::container::XIndexAccess > xColControls(xGridPeer, UNO_QUERY);
1995 [ # # ][ # # ]: 0 : Reference< XInterface > xCurControl(xColControls->getByIndex(nViewCol),UNO_QUERY);
[ # # ]
1996 : 0 : ::rtl::OUString aInitialText;
1997 [ # # ][ # # ]: 0 : if (IsSearchableControl(xCurControl, &aInitialText))
1998 [ # # ]: 0 : sInitialText = aInitialText;
1999 : :
2000 : : // prohibit the synchronization of the grid's display with the cursor's position
2001 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
2002 : : OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::ExecuteSearch : no model set ?!");
2003 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_False)));
[ # # ][ # # ]
2004 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AlwaysShowCursor")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
[ # # ][ # # ]
2005 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CursorColor")), makeAny(sal_Int32(COL_LIGHTRED)));
[ # # ][ # # ]
2006 : :
2007 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::util::XNumberFormatsSupplier > xNFS(::dbtools::getNumberFormats(::dbtools::getConnection(m_xRowSet), sal_True,getORB()));
[ # # ]
2008 : :
2009 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2010 : 0 : AbstractFmSearchDialog* pDialog = NULL;
2011 [ # # ]: 0 : if ( pFact )
2012 : : {
2013 [ # # ]: 0 : ::std::vector< String > aContextNames;
2014 [ # # ][ # # ]: 0 : aContextNames.push_back( rtl::OUString("Standard") );
[ # # ]
2015 [ # # ][ # # ]: 0 : pDialog = pFact->CreateFmSearchDialog(getBrowserView(), sInitialText, aContextNames, 0, LINK(this, SbaXDataBrowserController, OnSearchContextRequest));
2016 : : }
2017 : : OSL_ENSURE( pDialog, "SbaXDataBrowserController::ExecuteSearch: could not get the search dialog!" );
2018 [ # # ]: 0 : if ( pDialog )
2019 : : {
2020 [ # # ]: 0 : pDialog->SetActiveField( sActiveField );
2021 [ # # ][ # # ]: 0 : pDialog->SetFoundHandler( LINK( this, SbaXDataBrowserController, OnFoundData ) );
2022 [ # # ][ # # ]: 0 : pDialog->SetCanceledNotFoundHdl( LINK( this, SbaXDataBrowserController, OnCanceledNotFound ) );
2023 [ # # ]: 0 : pDialog->Execute();
2024 [ # # ][ # # ]: 0 : delete pDialog;
2025 : : }
2026 : :
2027 : : // restore the grid's normal operating state
2028 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
[ # # ][ # # ]
2029 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AlwaysShowCursor")), ::comphelper::makeBoolAny(sal_Bool(sal_False)));
[ # # ][ # # ]
2030 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CursorColor")), Any());
[ # # ][ # # ]
[ # # ]
2031 : 0 : }
2032 : :
2033 : : //------------------------------------------------------------------------------
2034 : 0 : void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< PropertyValue >& _rArgs)
2035 : : {
2036 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::Execute" );
2037 : 0 : sal_Bool bSortUp = sal_True;
2038 : :
2039 [ # # # # : 0 : switch (nId)
# # # # #
# # # # #
# # # ]
2040 : : {
2041 : : default:
2042 : 0 : SbaXDataBrowserController_Base::Execute( nId, _rArgs );
2043 : 0 : return;
2044 : :
2045 : : case ID_BROWSER_INSERT_ROW:
2046 : : try
2047 : : {
2048 [ # # ][ # # ]: 0 : if (SaveModified())
2049 : : {
2050 [ # # ][ # # ]: 0 : getRowSet()->afterLast();
[ # # ]
2051 : : // check if it is available
2052 [ # # ][ # # ]: 0 : Reference< XResultSetUpdate > xUpdateCursor(getRowSet(), UNO_QUERY_THROW);
2053 [ # # ][ # # ]: 0 : xUpdateCursor->moveToInsertRow();
[ # # ]
2054 : : }
2055 : : }
2056 : 0 : catch(Exception&)
2057 : : {
2058 : : OSL_FAIL("Exception caught!");
2059 : : }
2060 : 0 : break;
2061 : : case SID_FM_DELETEROWS:
2062 : :
2063 [ # # ]: 0 : if (SaveModified())
2064 : : {
2065 : 0 : SbaGridControl* pVclGrid = getBrowserView()->getVclControl();
2066 [ # # ]: 0 : if ( pVclGrid )
2067 : : {
2068 [ # # ]: 0 : if( !pVclGrid->GetSelectRowCount() )
2069 : : {
2070 : 0 : pVclGrid->DeactivateCell();
2071 : 0 : pVclGrid->SelectRow(pVclGrid->GetCurRow());
2072 : : }
2073 : 0 : pVclGrid->DeleteSelectedRows();
2074 : : }
2075 : : }
2076 : 0 : break;
2077 : :
2078 : : case ID_BROWSER_FILTERED:
2079 [ # # ]: 0 : if (SaveModified())
2080 : : {
2081 [ # # ][ # # ]: 0 : Reference< XPropertySet > xActiveSet(getRowSet(), UNO_QUERY);
2082 [ # # ][ # # ]: 0 : sal_Bool bApplied = ::comphelper::getBOOL(xActiveSet->getPropertyValue(PROPERTY_APPLYFILTER));
[ # # ][ # # ]
2083 [ # # ][ # # ]: 0 : xActiveSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(!bApplied)));
[ # # ][ # # ]
2084 [ # # ]: 0 : reloadForm(m_xLoadable);
2085 : : }
2086 [ # # ]: 0 : InvalidateFeature(ID_BROWSER_FILTERED);
2087 : 0 : break;
2088 : : case ID_BROWSER_EDITDOC:
2089 : : {
2090 : 0 : sal_Int16 nGridMode = getBrowserView()->getVclControl()->GetOptions();
2091 [ # # ]: 0 : if (nGridMode == DbGridControl::OPT_READONLY)
2092 : 0 : getBrowserView()->getVclControl()->SetOptions(DbGridControl::OPT_UPDATE | DbGridControl::OPT_INSERT | DbGridControl::OPT_DELETE);
2093 : : // the options not supported by the data source will be removed automatically
2094 : : else
2095 : : {
2096 [ # # ]: 0 : if ( !SaveModified( ) )
2097 : : // give the user a chance to save the current record (if neccessary)
2098 : 0 : break;
2099 : :
2100 : : // maybe the user wanted to reject the modified record ?
2101 [ # # ]: 0 : if (GetState(ID_BROWSER_UNDORECORD).bEnabled)
2102 [ # # ]: 0 : Execute(ID_BROWSER_UNDORECORD,Sequence<PropertyValue>());
2103 : :
2104 : 0 : getBrowserView()->getVclControl()->SetOptions(DbGridControl::OPT_READONLY);
2105 : : }
2106 [ # # ]: 0 : InvalidateFeature(ID_BROWSER_EDITDOC);
2107 : : }
2108 : 0 : break;
2109 : :
2110 : : case ID_BROWSER_SEARCH:
2111 [ # # ]: 0 : if ( SaveModified( ) )
2112 : 0 : ExecuteSearch();
2113 : 0 : break;
2114 : :
2115 : : case ID_BROWSER_COPY:
2116 [ # # ]: 0 : if ( getBrowserView()->getVclControl()->GetSelectRowCount() > 0 )
2117 : : {
2118 : 0 : getBrowserView()->getVclControl()->CopySelectedRowsToClipboard();
2119 : 0 : break;
2120 : : }
2121 : : // run through
2122 : : case ID_BROWSER_CUT:
2123 : : case ID_BROWSER_PASTE:
2124 : : {
2125 [ # # ][ # # ]: 0 : CellControllerRef xCurrentController = getBrowserView()->getVclControl()->Controller();
2126 [ # # ]: 0 : if (!xCurrentController.Is())
2127 : : // should be intercepted by GetState. Normally.
2128 : : // Unfortunately ID_BROWSER_PASTE is a 'fast call' slot, which means it may be executed without checking if it is
2129 : : // enabled. This would be really deadly herein if the current cell has no controller ...
2130 : : return;
2131 : :
2132 : 0 : Edit& rEdit = (Edit&)xCurrentController->GetWindow();
2133 [ # # # # ]: 0 : switch (nId)
2134 : : {
2135 [ # # ]: 0 : case ID_BROWSER_CUT : rEdit.Cut(); break;
2136 [ # # ]: 0 : case SID_COPY : rEdit.Copy(); break;
2137 [ # # ]: 0 : case ID_BROWSER_PASTE : rEdit.Paste(); break;
2138 : : }
2139 [ # # ][ # # ]: 0 : if (ID_BROWSER_CUT == nId || ID_BROWSER_PASTE == nId)
2140 : : {
2141 [ # # ]: 0 : xCurrentController->SetModified();
2142 [ # # ]: 0 : rEdit.Modify();
2143 [ # # ][ # # ]: 0 : }
2144 : : }
2145 : 0 : break;
2146 : :
2147 : : case ID_BROWSER_SORTDOWN:
2148 : 0 : bSortUp = sal_False;
2149 : : // DON'T break
2150 : : case ID_BROWSER_SORTUP:
2151 : : {
2152 [ # # ][ # # ]: 0 : if (!SaveModified())
2153 : : break;
2154 : :
2155 [ # # ][ # # ]: 0 : if (!isValidCursor())
2156 : : break;
2157 : :
2158 : : // only one sort order
2159 [ # # ][ # # ]: 0 : Reference< XPropertySet > xField(getBoundField(), UNO_QUERY);
2160 [ # # ]: 0 : if (!xField.is())
2161 : : break;
2162 : :
2163 [ # # ]: 0 : Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
2164 [ # # ][ # # ]: 0 : const ::rtl::OUString sOldSort = xParser->getOrder();
2165 : 0 : sal_Bool bParserSuccess = sal_False;
2166 [ # # ][ # # ]: 0 : HANDLE_SQL_ERRORS(
[ # # ][ # # ]
[ # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
2167 : : xParser->setOrder(::rtl::OUString()); xParser->appendOrderByColumn(xField, bSortUp),
2168 : : bParserSuccess,
2169 : : ModuleRes(SBA_BROWSER_SETTING_ORDER).toString(),
2170 : : "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
2171 : : )
2172 : :
2173 [ # # ]: 0 : if (bParserSuccess)
2174 [ # # ][ # # ]: 0 : applyParserOrder(sOldSort,xParser);
2175 : : }
2176 : 0 : break;
2177 : :
2178 : : case ID_BROWSER_AUTOFILTER:
2179 : : {
2180 [ # # ][ # # ]: 0 : if (!SaveModified())
2181 : : break;
2182 : :
2183 [ # # ][ # # ]: 0 : if (!isValidCursor())
2184 : : break;
2185 : :
2186 [ # # ][ # # ]: 0 : Reference< XPropertySet > xField(getBoundField(), UNO_QUERY);
2187 [ # # ]: 0 : if (!xField.is())
2188 : : break;
2189 : :
2190 : : // check if the column is a aggregate function
2191 : 0 : sal_Bool bHaving = sal_False;
2192 : 0 : ::rtl::OUString sName;
2193 [ # # ][ # # ]: 0 : xField->getPropertyValue(PROPERTY_NAME) >>= sName;
[ # # ]
2194 [ # # ]: 0 : Reference< XColumnsSupplier > xColumnsSupplier(m_xParser, UNO_QUERY);
2195 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::container::XNameAccess > xCols = xColumnsSupplier.is() ? xColumnsSupplier->getColumns() : Reference< ::com::sun::star::container::XNameAccess > ();
[ # # ]
2196 [ # # ][ # # ]: 0 : if ( xCols.is() && xCols->hasByName(sName) )
[ # # ][ # # ]
[ # # ]
2197 : : {
2198 [ # # ][ # # ]: 0 : Reference<XPropertySet> xProp(xCols->getByName(sName),UNO_QUERY);
[ # # ]
2199 [ # # ][ # # ]: 0 : static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction"));
[ # # ][ # # ]
2200 [ # # ][ # # ]: 0 : if ( xProp->getPropertySetInfo()->hasPropertyByName(sAgg) )
[ # # ][ # # ]
[ # # ]
2201 [ # # ][ # # ]: 0 : xProp->getPropertyValue(sAgg) >>= bHaving;
2202 : : }
2203 : :
2204 [ # # ]: 0 : Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
2205 [ # # ][ # # ]: 0 : const ::rtl::OUString sOldFilter = xParser->getFilter();
2206 [ # # ][ # # ]: 0 : const ::rtl::OUString sOldHaving = xParser->getHavingClause();
2207 : :
2208 [ # # ][ # # ]: 0 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
2209 [ # # ][ # # ]: 0 : sal_Bool bApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER));
[ # # ][ # # ]
2210 : : // do we have a filter but it's not applied ?
2211 : : // -> completely overwrite it, else append one
2212 [ # # ]: 0 : if (!bApplied)
2213 : : {
2214 [ # # ][ # # ]: 0 : DO_SAFE( (bHaving ? xParser->setHavingClause(::rtl::OUString()) : xParser->setFilter(::rtl::OUString())), "SbaXDataBrowserController::Execute : caught an exception while resetting the new filter !" );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ]
2215 : : }
2216 : :
2217 : 0 : sal_Bool bParserSuccess = sal_False;
2218 : :
2219 : 0 : sal_Int32 nOp = SQLFilterOperator::EQUAL;
2220 [ # # ]: 0 : if ( xField.is() )
2221 : : {
2222 : 0 : sal_Int32 nType = 0;
2223 [ # # ][ # # ]: 0 : xField->getPropertyValue(PROPERTY_TYPE) >>= nType;
[ # # ]
2224 [ # # ]: 0 : switch(nType)
2225 : : {
2226 : : case DataType::VARCHAR:
2227 : : case DataType::CHAR:
2228 : : case DataType::LONGVARCHAR:
2229 : 0 : nOp = SQLFilterOperator::LIKE;
2230 : 0 : break;
2231 : : default:
2232 : 0 : nOp = SQLFilterOperator::EQUAL;
2233 : : }
2234 : : }
2235 : :
2236 [ # # ]: 0 : if ( bHaving )
2237 : : {
2238 [ # # ][ # # ]: 0 : HANDLE_SQL_ERRORS(
[ # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
2239 : : xParser->appendHavingClauseByColumn(xField,sal_True,nOp),
2240 : : bParserSuccess,
2241 : : ModuleRes(SBA_BROWSER_SETTING_FILTER).toString(),
2242 : : "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
2243 : : )
2244 : : }
2245 : : else
2246 : : {
2247 [ # # ][ # # ]: 0 : HANDLE_SQL_ERRORS(
[ # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
2248 : : xParser->appendFilterByColumn(xField,sal_True,nOp),
2249 : : bParserSuccess,
2250 : : ModuleRes(SBA_BROWSER_SETTING_FILTER).toString(),
2251 : : "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
2252 : : )
2253 : : }
2254 : :
2255 [ # # ]: 0 : if (bParserSuccess)
2256 [ # # ]: 0 : applyParserFilter(sOldFilter, bApplied,sOldHaving,xParser);
2257 : :
2258 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
2259 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_FILTERED);
[ # # ]
2260 : : }
2261 : 0 : break;
2262 : :
2263 : : case ID_BROWSER_ORDERCRIT:
2264 : 0 : ExecuteFilterSortCrit(sal_False);
2265 : 0 : break;
2266 : :
2267 : : case ID_BROWSER_FILTERCRIT:
2268 : 0 : ExecuteFilterSortCrit(sal_True);
2269 [ # # ]: 0 : InvalidateFeature(ID_BROWSER_FILTERED);
2270 : 0 : break;
2271 : :
2272 : : case ID_BROWSER_REMOVEFILTER:
2273 : : {
2274 [ # # ][ # # ]: 0 : if (!SaveModified())
2275 : : break;
2276 : :
2277 [ # # ]: 0 : sal_Bool bNeedPostReload = preReloadForm();
2278 : : // reset the filter and the sort property simutaneously so only _one_ new statement has to be
2279 : : // sent
2280 [ # # ][ # # ]: 0 : Reference< XPropertySet > xSet(getRowSet(), UNO_QUERY);
2281 [ # # ]: 0 : if ( xSet.is() )
2282 : : {
2283 [ # # ][ # # ]: 0 : xSet->setPropertyValue(PROPERTY_FILTER,makeAny(::rtl::OUString()));
[ # # ][ # # ]
2284 [ # # ][ # # ]: 0 : xSet->setPropertyValue(PROPERTY_HAVING_CLAUSE,makeAny(::rtl::OUString()));
[ # # ][ # # ]
2285 [ # # ][ # # ]: 0 : xSet->setPropertyValue(PROPERTY_ORDER,makeAny(::rtl::OUString()));
[ # # ][ # # ]
[ # # ]
2286 : : }
2287 : : try
2288 : : {
2289 [ # # ]: 0 : reloadForm(m_xLoadable);
2290 [ # # ]: 0 : if ( bNeedPostReload )
2291 [ # # ]: 0 : postReloadForm();
2292 : : }
2293 [ # # ]: 0 : catch(Exception&)
2294 : : {
2295 : : }
2296 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
2297 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_FILTERED);
2298 : : }
2299 : 0 : break;
2300 : :
2301 : : case ID_BROWSER_REFRESH:
2302 [ # # ]: 0 : if ( SaveModified( ) )
2303 : : {
2304 [ # # ]: 0 : if (!reloadForm(m_xLoadable))
2305 : 0 : criticalFail();
2306 : : }
2307 : 0 : break;
2308 : :
2309 : : case ID_BROWSER_SAVERECORD:
2310 [ # # ]: 0 : if ( SaveModified( sal_False ) )
2311 : 0 : setCurrentModified( sal_False );
2312 : 0 : break;
2313 : :
2314 : : case ID_BROWSER_UNDORECORD:
2315 : : {
2316 : : try
2317 : : {
2318 : : // restore the cursor state
2319 [ # # ][ # # ]: 0 : Reference< XResultSetUpdate > xCursor(getRowSet(), UNO_QUERY);
2320 [ # # ]: 0 : Reference< XPropertySet > xSet(xCursor, UNO_QUERY);
2321 [ # # ][ # # ]: 0 : Any aVal = xSet->getPropertyValue(PROPERTY_ISNEW);
[ # # ]
2322 [ # # ][ # # ]: 0 : if (aVal.hasValue() && ::comphelper::getBOOL(aVal))
[ # # ][ # # ]
2323 : : {
2324 [ # # ][ # # ]: 0 : xCursor->moveToInsertRow();
2325 : : // no need to reset the grid model after we moved to the insert row, this is done implicitly by the
2326 : : // form
2327 : : // (and in some cases it may be deadly to do the reset explicitly after the form did it implicitly,
2328 : : // cause the form's reset may be async, and this leads to some nice deadlock scenarios ....)
2329 : : }
2330 : : else
2331 : : {
2332 [ # # ][ # # ]: 0 : xCursor->cancelRowUpdates();
2333 : :
2334 : : // restore the grids state
2335 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::form::XReset > xReset(getControlModel(), UNO_QUERY);
2336 [ # # ]: 0 : if (xReset.is())
2337 [ # # ][ # # ]: 0 : xReset->reset();
2338 [ # # ]: 0 : }
2339 : : }
2340 : 0 : catch(SQLException&)
2341 : : {
2342 : : }
2343 : :
2344 : 0 : setCurrentModified( sal_False );
2345 : : }
2346 : : }
2347 : : }
2348 : :
2349 : : //------------------------------------------------------------------------------
2350 : 0 : sal_Bool SbaXDataBrowserController::SaveModified(sal_Bool bAskFor)
2351 : : {
2352 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SaveModified" );
2353 [ # # ][ # # ]: 0 : if ( bAskFor && GetState(ID_BROWSER_SAVERECORD).bEnabled )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2354 : : {
2355 [ # # ][ # # ]: 0 : getBrowserView()->getVclControl()->GrabFocus();
2356 : :
2357 [ # # ][ # # ]: 0 : QueryBox aQry(getBrowserView()->getVclControl(), ModuleRes(QUERY_BRW_SAVEMODIFIED));
[ # # ]
2358 : :
2359 [ # # ]: 0 : switch (aQry.Execute())
[ # # # ]
2360 : : {
2361 : : case RET_NO:
2362 [ # # ][ # # ]: 0 : Execute(ID_BROWSER_UNDORECORD,Sequence<PropertyValue>());
[ # # ]
2363 : 0 : return sal_True;
2364 : : case RET_CANCEL:
2365 : 0 : return sal_False;
2366 [ # # ][ # # ]: 0 : }
2367 : : }
2368 : :
2369 [ # # ][ # # ]: 0 : if ( !CommitCurrent() ) // das aktuelle Control committen lassen
2370 : 0 : return sal_False;
2371 : :
2372 [ # # ][ # # ]: 0 : Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
2373 : 0 : sal_Bool bResult = sal_False;
2374 : : try
2375 : : {
2376 [ # # ][ # # ]: 0 : if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISMODIFIED)))
[ # # ][ # # ]
[ # # ]
2377 : : {
2378 [ # # ][ # # ]: 0 : Reference< XResultSetUpdate > xCursor(getRowSet(), UNO_QUERY);
2379 [ # # ][ # # ]: 0 : if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISNEW)))
[ # # ][ # # ]
[ # # ]
2380 [ # # ][ # # ]: 0 : xCursor->insertRow();
2381 : : else
2382 [ # # ][ # # ]: 0 : xCursor->updateRow();
[ # # # ]
2383 : : }
2384 : 0 : bResult = sal_True;
2385 : : }
2386 [ # # ]: 0 : catch(SQLException&)
2387 : : {
2388 : : }
2389 [ # # ]: 0 : catch(Exception&)
2390 : : {
2391 : : OSL_FAIL("SbaXDataBrowserController::SaveModified : could not save the current record !");
2392 : 0 : bResult = sal_False;
2393 : : }
2394 : :
2395 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_SAVERECORD);
2396 [ # # ][ # # ]: 0 : InvalidateFeature(ID_BROWSER_UNDORECORD);
2397 : 0 : return bResult;
2398 : : }
2399 : :
2400 : : //------------------------------------------------------------------------------
2401 : 0 : sal_Bool SbaXDataBrowserController::CommitCurrent()
2402 : : {
2403 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CommitCurrent" );
2404 [ # # ]: 0 : if (!getBrowserView())
2405 : 0 : return sal_True;
2406 : :
2407 [ # # ]: 0 : Reference< ::com::sun::star::awt::XControl > xActiveControl(getBrowserView()->getGridControl());
2408 [ # # ]: 0 : Reference< ::com::sun::star::form::XBoundControl > xLockingTest(xActiveControl, UNO_QUERY);
2409 [ # # ][ # # ]: 0 : sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock();
[ # # ][ # # ]
2410 [ # # ][ # # ]: 0 : if (xActiveControl.is() && !bControlIsLocked)
[ # # ]
2411 : : {
2412 : : // zunaechst das Control fragen ob es das IFace unterstuetzt
2413 [ # # ]: 0 : Reference< ::com::sun::star::form::XBoundComponent > xBoundControl(xActiveControl, UNO_QUERY);
2414 [ # # ]: 0 : if (!xBoundControl.is())
2415 [ # # ][ # # ]: 0 : xBoundControl = Reference< ::com::sun::star::form::XBoundComponent > (xActiveControl->getModel(), UNO_QUERY);
[ # # ][ # # ]
2416 [ # # ][ # # ]: 0 : if (xBoundControl.is() && !xBoundControl->commit())
[ # # ][ # # ]
[ # # ]
2417 [ # # ]: 0 : return sal_False;
2418 : : }
2419 : 0 : return sal_True;
2420 : : }
2421 : :
2422 : : //------------------------------------------------------------------------------
2423 : 6 : void SbaXDataBrowserController::setCurrentModified( sal_Bool _bSet )
2424 : : {
2425 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::setCurrentModified" );
2426 : 6 : m_bCurrentlyModified = _bSet;
2427 [ + - ]: 6 : InvalidateFeature( ID_BROWSER_SAVERECORD );
2428 [ + - ]: 6 : InvalidateFeature( ID_BROWSER_UNDORECORD );
2429 : 6 : }
2430 : :
2431 : : //------------------------------------------------------------------------------
2432 : 4 : void SbaXDataBrowserController::RowChanged()
2433 : : {
2434 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::RowChanged" );
2435 : 4 : setCurrentModified( sal_False );
2436 : 4 : }
2437 : :
2438 : : //------------------------------------------------------------------------------
2439 : 2 : void SbaXDataBrowserController::ColumnChanged()
2440 : : {
2441 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::ColumnChanged" );
2442 [ + - ]: 2 : InvalidateFeature(ID_BROWSER_SORTUP);
2443 [ + - ]: 2 : InvalidateFeature(ID_BROWSER_SORTDOWN);
2444 [ + - ]: 2 : InvalidateFeature(ID_BROWSER_ORDERCRIT);
2445 [ + - ]: 2 : InvalidateFeature(ID_BROWSER_FILTERCRIT);
2446 [ + - ]: 2 : InvalidateFeature(ID_BROWSER_AUTOFILTER);
2447 [ + - ]: 2 : InvalidateFeature(ID_BROWSER_REMOVEFILTER);
2448 : :
2449 : 2 : setCurrentModified( sal_False );
2450 : 2 : }
2451 : :
2452 : : //------------------------------------------------------------------------------
2453 : 0 : void SbaXDataBrowserController::SelectionChanged()
2454 : : {
2455 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SelectionChanged" );
2456 : : // not interested in
2457 : 0 : }
2458 : :
2459 : : //------------------------------------------------------------------------------
2460 : 10 : void SbaXDataBrowserController::CellActivated()
2461 : : {
2462 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CellActivated" );
2463 : 10 : m_aInvalidateClipboard.Start();
2464 : 10 : OnInvalidateClipboard( NULL );
2465 : 10 : }
2466 : :
2467 : : //------------------------------------------------------------------------------
2468 : 4 : void SbaXDataBrowserController::CellDeactivated()
2469 : : {
2470 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CellDeactivated" );
2471 : 4 : m_aInvalidateClipboard.Stop();
2472 : 4 : OnInvalidateClipboard( NULL );
2473 : 4 : }
2474 : :
2475 : : //------------------------------------------------------------------------------
2476 : 0 : IMPL_LINK_NOARG(SbaXDataBrowserController, OnClipboardChanged)
2477 : : {
2478 [ # # ]: 0 : SolarMutexGuard aGuard;
2479 [ # # ][ # # ]: 0 : return OnInvalidateClipboard( NULL );
2480 : : }
2481 : :
2482 : : //------------------------------------------------------------------------------
2483 : 2 : IMPL_LINK(SbaXDataBrowserController, OnInvalidateClipboard, AutoTimer*, _pTimer)
2484 : : {
2485 [ + - ]: 16 : InvalidateFeature(ID_BROWSER_CUT);
2486 [ + - ]: 16 : InvalidateFeature(ID_BROWSER_COPY);
2487 : :
2488 : : // if the invalidation was triggered by the timer, we do not need to invalidate PASTE.
2489 : : // The timer is only for checking the CUT/COPY slots regulariry, which depend on the
2490 : : // selection state of the active cell
2491 : : // TODO: get a callback at the Edit which allows to be notified when the selection
2492 : : // changes. This would be much better than this cycle-eating polling mechanism here ....
2493 [ + + ]: 16 : if ( _pTimer != &m_aInvalidateClipboard )
2494 [ + - ]: 14 : InvalidateFeature(ID_BROWSER_PASTE);
2495 : :
2496 : 16 : return 0L;
2497 : : }
2498 : :
2499 : : // -------------------------------------------------------------------------
2500 : 15 : Reference< XPropertySet > SbaXDataBrowserController::getBoundField(sal_uInt16 nViewPos) const
2501 : : {
2502 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SaveData" );
2503 : 15 : Reference< XPropertySet > xEmptyReturn;
2504 : :
2505 : : // get the current column from the grid
2506 [ + - ]: 15 : if (nViewPos == (sal_uInt16)-1)
2507 : : {
2508 [ + - ][ + - ]: 15 : Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
2509 [ - + ]: 15 : if (!xGrid.is())
2510 : : return xEmptyReturn;
2511 [ + - ][ + - ]: 15 : nViewPos = xGrid->getCurrentColumnPosition();
[ + - ]
2512 : : }
2513 [ + - ]: 15 : sal_uInt16 nCurrentCol = getBrowserView()->View2ModelPos(nViewPos);
2514 [ + - ]: 15 : if (nCurrentCol == (sal_uInt16)-1)
2515 : : return xEmptyReturn;
2516 : :
2517 : : // get the according column from the model
2518 [ + - ][ + - ]: 15 : Reference< ::com::sun::star::container::XIndexContainer > xCols(getControlModel(), UNO_QUERY);
2519 [ + - ][ + - ]: 15 : Reference< XPropertySet > xCurrentCol(xCols->getByIndex(nCurrentCol),UNO_QUERY);
[ + - ]
2520 [ + - ]: 15 : if (!xCurrentCol.is())
2521 : : return xEmptyReturn;
2522 : :
2523 [ + - ][ + - ]: 15 : xEmptyReturn.set(xCurrentCol->getPropertyValue(PROPERTY_BOUNDFIELD) ,UNO_QUERY);
[ + - ][ + - ]
2524 : 15 : return xEmptyReturn;
2525 : : }
2526 : :
2527 : : //------------------------------------------------------------------------------
2528 : 0 : IMPL_LINK(SbaXDataBrowserController, OnSearchContextRequest, FmSearchContext*, pContext)
2529 : : {
2530 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::container::XIndexAccess > xPeerContainer(getBrowserView()->getGridControl(), UNO_QUERY);
2531 : :
2532 : : // check all grid columns for their control source
2533 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::container::XIndexAccess > xModelColumns(getFormComponent(), UNO_QUERY);
2534 : : OSL_ENSURE(xModelColumns.is(), "SbaXDataBrowserController::OnSearchContextRequest : there is a grid control without columns !");
2535 : : // the case 'no columns' should be indicated with an empty container, I think ...
2536 : : OSL_ENSURE(xModelColumns->getCount() >= xPeerContainer->getCount(), "SbaXDataBrowserController::OnSearchContextRequest : impossible : have more view than model columns !");
2537 : :
2538 [ # # ]: 0 : String sFieldList;
2539 [ # # ][ # # ]: 0 : for (sal_Int32 nViewPos=0; nViewPos<xPeerContainer->getCount(); ++nViewPos)
[ # # ]
2540 : : {
2541 [ # # ][ # # ]: 0 : Reference< XInterface > xCurrentColumn(xPeerContainer->getByIndex(nViewPos),UNO_QUERY);
[ # # ]
2542 [ # # ]: 0 : if (!xCurrentColumn.is())
2543 : 0 : continue;
2544 : :
2545 : : // can we use this column control for searching ?
2546 [ # # ][ # # ]: 0 : if (!IsSearchableControl(xCurrentColumn))
2547 : 0 : continue;
2548 : :
2549 [ # # ]: 0 : sal_uInt16 nModelPos = getBrowserView()->View2ModelPos((sal_uInt16)nViewPos);
2550 [ # # ][ # # ]: 0 : Reference< XPropertySet > xCurrentColModel(xModelColumns->getByIndex(nModelPos),UNO_QUERY);
[ # # ]
2551 [ # # ][ # # ]: 0 : String aName = ::comphelper::getString(xCurrentColModel->getPropertyValue(PROPERTY_CONTROLSOURCE));
[ # # ][ # # ]
[ # # ]
2552 : :
2553 [ # # ]: 0 : sFieldList += aName;
2554 [ # # ]: 0 : sFieldList += ';';
2555 : :
2556 [ # # ]: 0 : pContext->arrFields.push_back(xCurrentColumn);
2557 [ # # ][ # # ]: 0 : }
2558 [ # # ][ # # ]: 0 : sFieldList = comphelper::string::stripEnd(sFieldList, ';');
[ # # ]
2559 : :
2560 [ # # ][ # # ]: 0 : pContext->xCursor.set(getRowSet(),UNO_QUERY);
2561 [ # # ]: 0 : pContext->strUsedFields = sFieldList;
2562 : :
2563 : : // if the cursor is in a mode other than STANDARD -> reset
2564 [ # # ]: 0 : Reference< XPropertySet > xCursorSet(pContext->xCursor, UNO_QUERY);
2565 : : OSL_ENSURE(xCursorSet.is() && !::comphelper::getBOOL(xCursorSet->getPropertyValue(PROPERTY_ISMODIFIED)),
2566 : : "SbaXDataBrowserController::OnSearchContextRequest : please do not call for cursors with modified rows !");
2567 [ # # ][ # # ]: 0 : if (xCursorSet.is() && ::comphelper::getBOOL(xCursorSet->getPropertyValue(PROPERTY_ISNEW)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
2568 : : {
2569 [ # # ]: 0 : Reference< XResultSetUpdate > xUpdateCursor(pContext->xCursor, UNO_QUERY);
2570 [ # # ][ # # ]: 0 : xUpdateCursor->moveToCurrentRow();
2571 : : }
2572 [ # # ]: 0 : return pContext->arrFields.size();
2573 : : }
2574 : :
2575 : : //------------------------------------------------------------------------------
2576 : 0 : IMPL_LINK(SbaXDataBrowserController, OnFoundData, FmFoundRecordInformation*, pInfo)
2577 : : {
2578 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::sdbcx::XRowLocate > xCursor(getRowSet(), UNO_QUERY);
2579 : : OSL_ENSURE(xCursor.is(), "SbaXDataBrowserController::OnFoundData : shit happens. sometimes. but this is simply impossible !");
2580 : :
2581 : : // move the cursor
2582 [ # # ][ # # ]: 0 : xCursor->moveToBookmark(pInfo->aPosition);
2583 : :
2584 : : // let the grid snyc it's display with the cursor
2585 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
2586 : : OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::OnFoundData : no model set ?!");
2587 [ # # ][ # # ]: 0 : Any aOld = xModelSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")));
[ # # ]
2588 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
[ # # ][ # # ]
2589 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), aOld);
[ # # ]
2590 : :
2591 : : // and move to the field
2592 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::container::XIndexAccess > aColumnControls(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY);
[ # # ][ # # ]
2593 : : sal_uInt16 nViewPos;
2594 : :
2595 [ # # ][ # # ]: 0 : for ( nViewPos = 0; nViewPos < aColumnControls->getCount(); ++nViewPos )
[ # # ]
2596 : : {
2597 [ # # ][ # # ]: 0 : Reference< XInterface > xCurrent(aColumnControls->getByIndex(nViewPos),UNO_QUERY);
[ # # ]
2598 [ # # ][ # # ]: 0 : if (IsSearchableControl(xCurrent))
2599 : : {
2600 [ # # ]: 0 : if (pInfo->nFieldPos)
2601 : 0 : --pInfo->nFieldPos;
2602 : : else
2603 : : break;
2604 : : }
2605 [ # # ]: 0 : }
2606 : :
2607 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
2608 [ # # ][ # # ]: 0 : xGrid->setCurrentColumnPosition(nViewPos);
2609 : :
2610 : 0 : return 0;
2611 : : }
2612 : :
2613 : : //------------------------------------------------------------------------------
2614 : 0 : IMPL_LINK(SbaXDataBrowserController, OnCanceledNotFound, FmFoundRecordInformation*, pInfo)
2615 : : {
2616 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::sdbcx::XRowLocate > xCursor(getRowSet(), UNO_QUERY);
[ # # ]
2617 : :
2618 : : try
2619 : : {
2620 : : OSL_ENSURE(xCursor.is(), "SbaXDataBrowserController::OnCanceledNotFound : shit happens. sometimes. but this is simply impossible !");
2621 : : // move the cursor
2622 [ # # ][ # # ]: 0 : xCursor->moveToBookmark(pInfo->aPosition);
2623 : : }
2624 [ # # ]: 0 : catch( const Exception& )
2625 : : {
2626 : : DBG_UNHANDLED_EXCEPTION();
2627 : : }
2628 : :
2629 : : try
2630 : : {
2631 : : // let the grid snyc its display with the cursor
2632 [ # # ][ # # ]: 0 : Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
2633 : : OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::OnCanceledNotFound : no model set ?!");
2634 [ # # ][ # # ]: 0 : Any aOld = xModelSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")));
[ # # ]
2635 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
[ # # ][ # # ]
2636 [ # # ][ # # ]: 0 : xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), aOld);
[ # # ][ # # ]
2637 : : }
2638 [ # # ]: 0 : catch( const Exception& )
2639 : : {
2640 : : DBG_UNHANDLED_EXCEPTION();
2641 : : }
2642 : :
2643 : 0 : return 0L;
2644 : : }
2645 : :
2646 : : //------------------------------------------------------------------------------
2647 : 2 : IMPL_LINK_NOARG(SbaXDataBrowserController, OnAsyncGetCellFocus)
2648 : : {
2649 [ + + ]: 2 : SbaGridControl* pVclGrid = getBrowserView() ? getBrowserView()->getVclControl() : NULL;
2650 : : // if we have a controller, but the window for the controller doesn't have the focus, we correct this
2651 [ + + ]: 2 : if(pVclGrid)
2652 : : {
2653 [ + - ]: 1 : if (!pVclGrid->IsEditing())
2654 : 1 : return 0L;
2655 : :
2656 [ # # ]: 0 : if (pVclGrid->HasChildPathFocus())
2657 [ # # ]: 0 : pVclGrid->Controller()->GetWindow().GrabFocus();
2658 : : }
2659 : :
2660 : 2 : return 0L;
2661 : : }
2662 : :
2663 : : //------------------------------------------------------------------------------
2664 : 0 : void SbaXDataBrowserController::criticalFail()
2665 : : {
2666 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::criticalFail" );
2667 : 0 : InvalidateAll();
2668 : 0 : m_nRowSetPrivileges = 0;
2669 : 0 : }
2670 : :
2671 : : //------------------------------------------------------------------------------
2672 : 2 : void SbaXDataBrowserController::LoadFinished(sal_Bool /*bWasSynch*/)
2673 : : {
2674 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::LoadFinished" );
2675 : 2 : m_nRowSetPrivileges = 0;
2676 : :
2677 [ + - ][ + - ]: 2 : if (isValid() && !loadingCancelled())
[ + - ]
2678 : : {
2679 : : // obtain cached values
2680 : : try
2681 : : {
2682 [ + - ]: 2 : Reference< XPropertySet > xFormProps( m_xLoadable, UNO_QUERY_THROW );
2683 [ + - ][ + - ]: 2 : OSL_VERIFY( xFormProps->getPropertyValue( PROPERTY_PRIVILEGES ) >>= m_nRowSetPrivileges );
[ + - ][ # # ]
2684 : : }
2685 : 0 : catch( const Exception& )
2686 : : {
2687 : : DBG_UNHANDLED_EXCEPTION();
2688 : : }
2689 : :
2690 : : // --------------------------------
2691 : : // switch the control to alive mode
2692 [ + - ][ + - ]: 2 : getBrowserView()->getGridControl()->setDesignMode(sal_False);
2693 : :
2694 : : // -------------------------------
2695 : 2 : initializeParser();
2696 : :
2697 : : // -------------------------------
2698 : 2 : InvalidateAll();
2699 : :
2700 : 2 : m_aAsyncGetCellFocus.Call();
2701 : : }
2702 : 2 : }
2703 : : // -----------------------------------------------------------------------------
2704 : 2 : void SbaXDataBrowserController::initializeParser() const
2705 : : {
2706 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::initializeParser" );
2707 [ - + ]: 2 : if ( !m_xParser.is() )
2708 : : {
2709 : : // ----------------------------------------------
2710 : : // create a parser (needed for filtering/sorting)
2711 : : try
2712 : : {
2713 [ # # ][ # # ]: 0 : const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
2714 [ # # ][ # # ]: 0 : if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)))
[ # # ][ # # ]
[ # # ]
2715 : : { // (only if the statement isn't native)
2716 : : // (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid)
2717 [ # # ][ # # ]: 0 : xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser;
[ # # ][ # # ]
2718 : 0 : }
2719 : : }
2720 [ # # ]: 0 : catch(Exception&)
2721 : : {
2722 : : DBG_UNHANDLED_EXCEPTION();
2723 [ # # ]: 0 : m_xParser = NULL;
2724 : : // no further handling, we ignore the error
2725 : : }
2726 : : }
2727 : 2 : }
2728 : : //------------------------------------------------------------------------------
2729 : 2 : void SbaXDataBrowserController::loaded(const EventObject& /*aEvent*/) throw( RuntimeException )
2730 : : {
2731 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::loaded" );
2732 : : // not interested in
2733 : : // we're loading within an separate thread and have a handling for it's "finished event"
2734 : 2 : }
2735 : :
2736 : : //------------------------------------------------------------------------------
2737 : 0 : void SbaXDataBrowserController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
2738 : : {
2739 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::unloading" );
2740 : : // not interested in
2741 : 0 : }
2742 : :
2743 : : //------------------------------------------------------------------------------
2744 : 0 : void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
2745 : : {
2746 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::unloaded" );
2747 : 0 : m_xParser.clear();
2748 : 0 : InvalidateAll();
2749 : : // do this asynchronously, there are other listeners reacting on this message ...
2750 : : // (it's a little hack : the grid columns are listening to this event, too, and their bound field may
2751 : : // change as a reaction on that event. as we have no chance to be notified of this change (which is
2752 : : // the one we're interested in) we give them time to do what they want to before invalidating our
2753 : : // bound-field-dependent slots ....
2754 : 0 : }
2755 : :
2756 : : //------------------------------------------------------------------------------
2757 : 0 : void SbaXDataBrowserController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
2758 : : {
2759 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::reloading" );
2760 : : // not interested in
2761 : 0 : }
2762 : :
2763 : : //------------------------------------------------------------------------------
2764 : 0 : void SbaXDataBrowserController::reloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
2765 : : {
2766 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::reloaded" );
2767 : 0 : InvalidateAll();
2768 : : // do this asynchronously, there are other listeners reacting on this message ...
2769 : : // (it's a little hack : the grid columns are listening to this event, too, and their bound field may
2770 : : // change as a reaction on that event. as we have no chance to be notified of this change (which is
2771 : : // the one we're interested in) we give them time to do what they want to before invalidating our
2772 : : // bound-field-dependent slots ....
2773 : 0 : }
2774 : : //------------------------------------------------------------------------------
2775 : 6 : void SbaXDataBrowserController::enterFormAction()
2776 : : {
2777 [ + + ]: 6 : if ( !m_nFormActionNestingLevel )
2778 : : // first action -> reset
2779 : 4 : m_aCurrentError.clear();
2780 : :
2781 : 6 : ++m_nFormActionNestingLevel;
2782 : 6 : }
2783 : :
2784 : : //------------------------------------------------------------------------------
2785 : 6 : void SbaXDataBrowserController::leaveFormAction()
2786 : : {
2787 : : OSL_ENSURE( m_nFormActionNestingLevel > 0, "SbaXDataBrowserController::leaveFormAction : invalid call !" );
2788 [ + + ]: 6 : if ( --m_nFormActionNestingLevel > 0 )
2789 : 2 : return;
2790 : :
2791 [ + - ]: 4 : if ( !m_aCurrentError.isValid() )
2792 : 4 : return;
2793 : :
2794 : 6 : m_aAsyncDisplayError.Call();
2795 : : }
2796 : :
2797 : : // -------------------------------------------------------------------------
2798 : 241 : sal_Bool SbaXDataBrowserController::isLoaded() const
2799 : : {
2800 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::isLoaded" );
2801 [ + - ][ + + ]: 241 : return m_xLoadable.is() && m_xLoadable->isLoaded();
2802 : : }
2803 : :
2804 : : // -------------------------------------------------------------------------
2805 : 261 : sal_Bool SbaXDataBrowserController::isValidCursor() const
2806 : : {
2807 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::isValidCursor" );
2808 [ - + ]: 261 : if (!m_xColumnsSupplier.is())
2809 : 0 : return sal_False;
2810 [ + - ][ + - ]: 261 : Reference< ::com::sun::star::container::XNameAccess > xCols = m_xColumnsSupplier->getColumns();
2811 [ + - ][ + - ]: 261 : if (!xCols.is() || !xCols->hasElements())
[ + - ][ - + ]
[ - + ]
2812 : 0 : return sal_False;
2813 : :
2814 [ + - ][ + - ]: 261 : sal_Bool bIsValid = !(m_xRowSet->isBeforeFirst() || m_xRowSet->isAfterLast());
[ + - ][ + - ]
[ + - ][ + - ]
2815 [ - + ]: 261 : if ( !bIsValid )
2816 : : {
2817 [ # # ]: 0 : Reference<XPropertySet> xProp(m_xRowSet,UNO_QUERY);
2818 [ # # ][ # # ]: 0 : bIsValid = ::cppu::any2bool(xProp->getPropertyValue(PROPERTY_ISNEW));
[ # # ][ # # ]
2819 [ # # ]: 0 : if ( !bIsValid )
2820 : : {
2821 : 0 : bIsValid = m_xParser.is();
2822 : 0 : }
2823 : : }
2824 : 261 : return bIsValid;
2825 : : }
2826 : :
2827 : : // -----------------------------------------------------------------------------
2828 : 0 : sal_Int16 SbaXDataBrowserController::getCurrentColumnPosition()
2829 : : {
2830 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getCurrentColumnPosition" );
2831 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
[ # # ]
2832 : 0 : sal_Int16 nViewPos = -1;
2833 : : try
2834 : : {
2835 [ # # ]: 0 : if ( xGrid.is() )
2836 [ # # ][ # # ]: 0 : nViewPos = xGrid->getCurrentColumnPosition();
2837 : : }
2838 [ # # ]: 0 : catch(Exception&) {}
2839 : 0 : return nViewPos;
2840 : : }
2841 : : // -----------------------------------------------------------------------------
2842 : 0 : void SbaXDataBrowserController::setCurrentColumnPosition( sal_Int16 _nPos )
2843 : : {
2844 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::setCurrentColumnPosition" );
2845 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
[ # # ]
2846 : : try
2847 : : {
2848 [ # # ]: 0 : if ( -1 != _nPos )
2849 [ # # ][ # # ]: 0 : xGrid->setCurrentColumnPosition(_nPos);
2850 : : }
2851 [ # # ]: 0 : catch(Exception&) {}
2852 : 0 : }
2853 : : // -----------------------------------------------------------------------------
2854 : 0 : void SbaXDataBrowserController::BeforeDrop()
2855 : : {
2856 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::BeforeDrop" );
2857 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
2858 [ # # ]: 0 : if (xFormError.is())
2859 [ # # ][ # # ]: 0 : xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
[ # # ]
2860 : 0 : }
2861 : : // -----------------------------------------------------------------------------
2862 : 0 : void SbaXDataBrowserController::AfterDrop()
2863 : : {
2864 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::AfterDrop" );
2865 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
2866 [ # # ]: 0 : if (xFormError.is())
2867 [ # # ][ # # ]: 0 : xFormError->addSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
[ # # ]
2868 : 0 : }
2869 : : // -----------------------------------------------------------------------------
2870 : 2 : void SbaXDataBrowserController::addColumnListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
2871 : : {
2872 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::addColumnListeners" );
2873 : : // ... all the grid columns
2874 [ + - ]: 2 : Reference< ::com::sun::star::container::XIndexContainer > xColumns(_xGridControlModel, UNO_QUERY);
2875 [ + - ]: 2 : if (xColumns.is())
2876 : : {
2877 [ + - ][ + - ]: 2 : sal_Int32 nCount = xColumns->getCount();
2878 [ - + ]: 2 : for (sal_uInt16 i=0; i < nCount; ++i)
2879 : : {
2880 [ # # ][ # # ]: 0 : Reference< XPropertySet > xCol(xColumns->getByIndex(i),UNO_QUERY);
[ # # ]
2881 [ # # ]: 0 : AddColumnListener(xCol);
2882 : 0 : }
2883 : 2 : }
2884 : 2 : }
2885 : : // -----------------------------------------------------------------------------
2886 : 0 : sal_Bool SbaXDataBrowserController::InitializeGridModel(const Reference< ::com::sun::star::form::XFormComponent > & /*xGrid*/)
2887 : : {
2888 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::InitializeGridModel" );
2889 : 0 : return sal_True;
2890 : : }
2891 : : //..................................................................
2892 : : } // namespace dbaui
2893 : : //..................................................................
2894 : :
2895 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|