Tag: cws_src680_dba30 User: fs Date: 2006/07/19 06:11:01 Modified: dba/dbaccess/source/ui/querydesign/JoinController.cxx
Log: RESYNC: (1.37-1.39); FILE MERGED File Changes: Directory: /dba/dbaccess/source/ui/querydesign/ =============================================== File [changed]: JoinController.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/JoinController.cxx?r1=1.35.16.3&r2=1.35.16.4 Delta lines: +142 -29 ---------------------- --- JoinController.cxx 8 May 2006 11:27:50 -0000 1.35.16.3 +++ JoinController.cxx 19 Jul 2006 13:10:59 -0000 1.35.16.4 @@ -144,6 +144,8 @@ #include "UITools.hxx" #endif +#include <boost/optional.hpp> + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; using namespace ::com::sun::star::beans; @@ -156,14 +158,99 @@ using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::ui::dialogs; using namespace ::dbtools; -using namespace ::dbaui; using namespace ::comphelper; -DBG_NAME(OJoinController); +// ............................................................................. +namespace dbaui +{ +// ............................................................................. + +// ============================================================================= +// = AddTableDialogContext +// ============================================================================= +class AddTableDialogContext : public IAddTableDialogContext +{ + OJoinController& m_rController; + +public: + AddTableDialogContext( OJoinController& _rController ) + :m_rController( _rController ) + { + } + + // IAddTableDialogContext + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + getConnection() const; + virtual bool allowViews() const; + virtual bool allowQueries() const; + virtual bool allowAddition() const; + virtual void addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ); + virtual void onWindowClosing( const Window* _pWindow ); + +private: + OJoinTableView* getTableView() const; +}; + +// ----------------------------------------------------------------------------- +Reference< XConnection > AddTableDialogContext::getConnection() const +{ + return m_rController.getConnection(); +} + +// ----------------------------------------------------------------------------- +bool AddTableDialogContext::allowViews() const +{ + return m_rController.allowViews(); +} + +// ----------------------------------------------------------------------------- +bool AddTableDialogContext::allowQueries() const +{ + return m_rController.allowQueries(); +} + +// ----------------------------------------------------------------------------- +bool AddTableDialogContext::allowAddition() const +{ + return const_cast< OJoinController& >( m_rController ).getJoinView()->getTableView()->IsAddAllowed(); +} + +// ----------------------------------------------------------------------------- +void AddTableDialogContext::addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ) +{ + getTableView()->AddTabWin( _rQualifiedTableName, _rAliasName, TRUE ); +} + +// ----------------------------------------------------------------------------- +void AddTableDialogContext::onWindowClosing( const Window* _pWindow ) +{ + if ( !m_rController.getView() ) + return; + + ::dbaui::notifySystemWindow( + m_rController.getView(), const_cast< Window* >( _pWindow ), ::comphelper::mem_fun( &TaskPaneList::RemoveWindow ) ); + + m_rController.InvalidateFeature( ID_BROWSER_ADDTABLE ); + m_rController.getView()->GrabFocus(); +} + +// ----------------------------------------------------------------------------- +OJoinTableView* AddTableDialogContext::getTableView() const +{ + if ( m_rController.getJoinView() ) + return m_rController.getJoinView()->getTableView(); + return NULL; +} + +// ============================================================================= +// = OJoinController +// ============================================================================= + +DBG_NAME(OJoinController) // ----------------------------------------------------------------------------- -OJoinController::OJoinController(const Reference< XMultiServiceFactory >& _rM) : OJoinController_BASE(_rM) - ,m_bViewsAllowed(sal_True) - ,m_pAddTabDlg(NULL) +OJoinController::OJoinController(const Reference< XMultiServiceFactory >& _rM) + :OJoinController_BASE(_rM) + ,m_pAddTableDialog(NULL) { DBG_CTOR(OJoinController,NULL); } @@ -188,9 +275,13 @@ // ----------------------------------------------------------------------------- void OJoinController::disposing() { + { + ::std::auto_ptr< Window > pEnsureDelete( m_pAddTableDialog ); + m_pAddTableDialog = NULL; + } + OJoinController_BASE::disposing(); - m_pAddTabDlg = NULL; m_pView = NULL; { @@ -207,6 +298,14 @@ } } // ----------------------------------------------------------------------------- +void OJoinController::reconnect( sal_Bool _bUI ) +{ + OJoinController_BASE::reconnect( _bUI ); + if ( isConnected() && m_pAddTableDialog ) + m_pAddTableDialog->Update(); +} + +// ----------------------------------------------------------------------------- void OJoinController::setModified(sal_Bool _bModified) { OJoinController_BASE::setModified(_bModified); @@ -237,22 +336,35 @@ switch (_nId) { case ID_BROWSER_EDITDOC: - aReturn.aState = ::cppu::bool2any(isEditable()); + aReturn.bChecked = isEditable(); break; case ID_BROWSER_SAVEDOC: aReturn.bEnabled = isConnected() && isModified(); break; case ID_BROWSER_ADDTABLE: - if (aReturn.bEnabled = getView() && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed()) - aReturn.aState = ::cppu::bool2any(m_pAddTabDlg && m_pAddTabDlg->IsVisible()); - else - aReturn.aState = ::cppu::bool2any(sal_False); + aReturn.bEnabled = ( getView() != NULL ) + && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed(); + aReturn.bChecked = aReturn.bEnabled && m_pAddTableDialog != NULL && m_pAddTableDialog->IsVisible() ; + aReturn.sTitle = OAddTableDlg::getDialogTitleForContext( impl_getDialogContext() ); break; + default: aReturn = OJoinController_BASE::GetState(_nId); } return aReturn; } + +// ----------------------------------------------------------------------------- +AddTableDialogContext& OJoinController::impl_getDialogContext() const +{ + if ( !m_pDialogContext.get() ) + { + OJoinController* pNonConstThis = const_cast< OJoinController* >( this ); + pNonConstThis->m_pDialogContext.reset( new AddTableDialogContext( *pNonConstThis ) ); + } + return *m_pDialogContext; +} + // ----------------------------------------------------------------------------- void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs) { @@ -266,7 +378,6 @@ case RET_CANCEL: // don't change anything here so return return; - break; case RET_NO: reset(); setModified(sal_False); // and we are not modified yet @@ -279,24 +390,23 @@ getJoinView()->setReadOnly(!isEditable()); InvalidateAll(); return; - break; case ID_BROWSER_ADDTABLE: - if(!m_pAddTabDlg) - m_pAddTabDlg = getJoinView()->getAddTableDialog(); - if(m_pAddTabDlg->IsVisible()) + if ( !m_pAddTableDialog ) + m_pAddTableDialog = new OAddTableDlg( getView(), impl_getDialogContext() ); + + if ( m_pAddTableDialog->IsVisible() ) { - // ::dbaui::notifySystemWindow(getView(),m_pAddTabDlg,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - m_pAddTabDlg->Show(!m_pAddTabDlg->IsVisible()); - m_pView->GrabFocus(); + m_pAddTableDialog->Show( FALSE ); + getView()->GrabFocus(); } - else if(getJoinView()->getTableView()->IsAddAllowed()) + else { { - WaitObject aWaitCursor(getView()); - m_pAddTabDlg->Update(); + WaitObject aWaitCursor( getView() ); + m_pAddTableDialog->Update(); } - m_pAddTabDlg->Show(!m_pAddTabDlg->IsVisible()); - ::dbaui::notifySystemWindow(getView(),m_pAddTabDlg,::comphelper::mem_fun(&TaskPaneList::AddWindow)); + m_pAddTableDialog->Show( TRUE ); + ::dbaui::notifySystemWindow(getView(),m_pAddTableDialog,::comphelper::mem_fun(&TaskPaneList::AddWindow)); } break; default: @@ -490,4 +600,7 @@ pViewIter->Value <<= aTables; } } -// ----------------------------------------------------------------------------- + +// ............................................................................. +} // namespace dbaui +// ............................................................................. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
