LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/browser - brwctrlr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1214 0.0 %
Date: 2012-12-27 Functions: 0 149 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10