diff options
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/inc/QueryTableView.hxx | 1 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryTableView.cxx | 71 |
2 files changed, 48 insertions, 24 deletions
diff --git a/dbaccess/source/ui/inc/QueryTableView.hxx b/dbaccess/source/ui/inc/QueryTableView.hxx index f8d32438165d..0714cbfabab3 100644 --- a/dbaccess/source/ui/inc/QueryTableView.hxx +++ b/dbaccess/source/ui/inc/QueryTableView.hxx @@ -62,6 +62,7 @@ namespace dbaui /// base class overwritten: create and delete windows /// (not really delete, as it becomes an UndoAction) + bool ContainsTabWin(const OTableWindow& rTabWin); // #i122589# Allow to check if OTableWindow is registered virtual void AddTabWin( const OUString& _rTableName, const OUString& _rAliasName, sal_Bool bNewTable = sal_False ); virtual void RemoveTabWin(OTableWindow* pTabWin); diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index cbf8b93a73ac..2a57381338f8 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -763,42 +763,65 @@ sal_Bool OQueryTableView::FindTableFromField(const String& rFieldName, OTableFie } //------------------------------------------------------------------------------ +bool OQueryTableView::ContainsTabWin(const OTableWindow& rTabWin) +{ + OTableWindowMap* pTabWins = GetTabWinMap(); + OSL_ENSURE(pTabWins != NULL, "OQueryTableView::RemoveTabWin : Window should not be NULL !"); + + OTableWindowMap::iterator aIter = pTabWins->begin(); + OTableWindowMap::iterator aEnd = pTabWins->end(); + + for ( ;aIter != aEnd ; ++aIter ) + { + if ( aIter->second == &rTabWin ) + { + return true; + } + } + + return false; +} + +//------------------------------------------------------------------------------ void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin) { DBG_CHKTHIS(OQueryTableView,NULL); OSL_ENSURE(pTabWin != NULL, "OQueryTableView::RemoveTabWin : Window should not be NULL !"); - // I need my parent so it can be informed about the deletion - OQueryDesignView* pParent = static_cast<OQueryDesignView*>(getDesignView()); + if(pTabWin && ContainsTabWin(*pTabWin)) // #i122589# check if registered before deleting + { + // I need my parent so it can be informed about the deletion + OQueryDesignView* pParent = static_cast<OQueryDesignView*>(getDesignView()); - SfxUndoManager& rUndoMgr = m_pView->getController().GetUndoManager(); - rUndoMgr.EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() ); + SfxUndoManager& rUndoMgr = m_pView->getController().GetUndoManager(); + rUndoMgr.EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() ); - // add the Undo-Action - OQueryTabWinDelUndoAct* pUndoAction = new OQueryTabWinDelUndoAct(this); - pUndoAction->SetTabWin(static_cast< OQueryTableWindow*>(pTabWin)); + // add the Undo-Action + OQueryTabWinDelUndoAct* pUndoAction = new OQueryTabWinDelUndoAct(this); + pUndoAction->SetTabWin(static_cast< OQueryTableWindow*>(pTabWin)); - // and hide the window - HideTabWin(static_cast< OQueryTableWindow*>(pTabWin), pUndoAction); + // and hide the window + HideTabWin(static_cast< OQueryTableWindow*>(pTabWin), pUndoAction); - // Undo Actions and delete the fields in SelectionBrowseBox - pParent->TableDeleted( static_cast< OQueryTableWindowData*>(pTabWin->GetData().get())->GetAliasName() ); + // Undo Actions and delete the fields in SelectionBrowseBox + pParent->TableDeleted( static_cast< OQueryTableWindowData*>(pTabWin->GetData().get())->GetAliasName() ); - m_pView->getController().addUndoActionAndInvalidate( pUndoAction ); - rUndoMgr.LeaveListAction(); + m_pView->getController().addUndoActionAndInvalidate( pUndoAction ); + rUndoMgr.LeaveListAction(); - if (m_lnkTabWinsChangeHandler.IsSet()) - { - TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_REMOVED_WIN, static_cast< OQueryTableWindow*>(pTabWin)->GetAliasName()); - m_lnkTabWinsChangeHandler.Call(&aHint); - } + if (m_lnkTabWinsChangeHandler.IsSet()) + { + TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_REMOVED_WIN, static_cast< OQueryTableWindow*>(pTabWin)->GetAliasName()); + m_lnkTabWinsChangeHandler.Call(&aHint); + } - modified(); - if ( m_pAccessible ) - m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, - makeAny(pTabWin->GetAccessible()), - Any() - ); + modified(); + if ( m_pAccessible ) + m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, + makeAny(pTabWin->GetAccessible()), + Any() + ); + } } //------------------------------------------------------------------------ |