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

Generated by: LCOV version 1.10