diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-02-16 15:21:07 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-02-16 15:21:07 +0100 |
commit | 155487cc3f15c1db017e260c77f2e3d9041e0bb4 (patch) | |
tree | 81ac5bb55eceb44738c735ef0c3fe3a3caffacd8 /dbaccess/source/ui/querydesign/QueryViewSwitch.cxx | |
parent | 44ce7ccd50206e7784130ee418fc6a01bb8aa0cc (diff) |
autorecovery: recover query designer settings
not yet finished:
- query designer needs to be loaded hidden, and shown when the main window is shown
- recovering table windows is not correct, yet (windows which have been added to the UI,
but do not yet add to the "latest known" statement, are not restored (probably)
- closing the recovered, and modified, query designer somehow does not ask for saving
Diffstat (limited to 'dbaccess/source/ui/querydesign/QueryViewSwitch.cxx')
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryViewSwitch.cxx | 87 |
1 files changed, 64 insertions, 23 deletions
diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx index 36b7afe6d727..90ff0685e229 100644 --- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx +++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx @@ -208,37 +208,68 @@ OQueryContainerWindow* OQueryViewSwitch::getContainer() const } // ----------------------------------------------------------------------------- -bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo ) +void OQueryViewSwitch::impl_forceSQLView() { - sal_Bool bRet = sal_True; - sal_Bool bGraphicalDesign = static_cast<OQueryController&>(m_pDesignView->getController()).isGraphicalDesign(); - OAddTableDlg* pAddTabDialog( getAddTableDialog() ); - OQueryContainerWindow* pContainer = getContainer(); + // hide the "Add Table" dialog + m_bAddTableDialogWasVisible = pAddTabDialog ? pAddTabDialog->IsVisible() : false; + if ( m_bAddTableDialogWasVisible ) + pAddTabDialog->Hide(); + + // tell the views they're in/active + m_pDesignView->stopTimer(); + m_pTextView->getSqlEdit()->startTimer(); + + // set the most recent statement at the text view + m_pTextView->clear(); + m_pTextView->setStatement(static_cast<OQueryController&>(m_pDesignView->getController()).getStatement()); +} + +// ----------------------------------------------------------------------------- +void OQueryViewSwitch::forceInitialView() +{ + OQueryController& rQueryController( static_cast< OQueryController& >( m_pDesignView->getController() ) ); + const sal_Bool bGraphicalDesign = rQueryController.isGraphicalDesign(); if ( !bGraphicalDesign ) + impl_forceSQLView(); + else { - // hide the "Add Table" dialog - m_bAddTableDialogWasVisible = pAddTabDialog ? pAddTabDialog->IsVisible() : false; - if ( m_bAddTableDialogWasVisible ) - pAddTabDialog->Hide(); + // tell the text view it's inactive now + m_pTextView->getSqlEdit()->stopTimer(); + + // update the "Add Table" dialog + OAddTableDlg* pAddTabDialog( getAddTableDialog() ); + if ( pAddTabDialog ) + pAddTabDialog->Update(); - // tell the views they're in/active - m_pDesignView->stopTimer(); - m_pTextView->getSqlEdit()->startTimer(); + // initialize the design view + m_pDesignView->initByFieldDescriptions( rQueryController.getFieldInformation() ); - // set the most recent statement at the text view - m_pTextView->clear(); - m_pTextView->setStatement(static_cast<OQueryController&>(m_pDesignView->getController()).getStatement()); + // tell the design view it's active now + m_pDesignView->startTimer(); + } + + impl_postViewSwitch( bGraphicalDesign, true ); +} + +// ----------------------------------------------------------------------------- +bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo ) +{ + sal_Bool bRet = sal_True; + sal_Bool bGraphicalDesign = static_cast<OQueryController&>(m_pDesignView->getController()).isGraphicalDesign(); + + if ( !bGraphicalDesign ) + { + impl_forceSQLView(); } else { // tell the text view it's inactive now m_pTextView->getSqlEdit()->stopTimer(); - ::rtl::OUString sOldStatement = static_cast<OQueryController&>(m_pDesignView->getController()).getStatement(); - // update the "Add Table" dialog + OAddTableDlg* pAddTabDialog( getAddTableDialog() ); if ( pAddTabDialog ) pAddTabDialog->Update(); @@ -249,24 +280,34 @@ bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo ) m_pDesignView->startTimer(); } - if ( bRet ) + return impl_postViewSwitch( bGraphicalDesign, bRet ); +} + +// ----------------------------------------------------------------------------- +bool OQueryViewSwitch::impl_postViewSwitch( const bool i_bGraphicalDesign, const bool i_bSuccess ) +{ + if ( i_bSuccess ) { - m_pTextView->Show ( !bGraphicalDesign ); - m_pDesignView->Show ( bGraphicalDesign ); - if ( bGraphicalDesign && m_bAddTableDialogWasVisible && pAddTabDialog ) - pAddTabDialog->Show(); + m_pTextView->Show ( !i_bGraphicalDesign ); + m_pDesignView->Show ( i_bGraphicalDesign ); + OAddTableDlg* pAddTabDialog( getAddTableDialog() ); + if ( pAddTabDialog ) + if ( i_bGraphicalDesign && m_bAddTableDialogWasVisible ) + pAddTabDialog->Show(); GrabFocus(); } + OQueryContainerWindow* pContainer = getContainer(); if ( pContainer ) pContainer->Resize(); m_pDesignView->getController().getUndoMgr()->Clear(); m_pDesignView->getController().InvalidateAll(); - return bRet; + return i_bSuccess; } + // ----------------------------------------------------------------------------- OAddTableDlg* OQueryViewSwitch::getAddTableDialog() { |