summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-07-02 08:50:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-07-02 14:22:30 +0100
commitcb6e8c46d723de33073a5fb9ca53be12412e2a27 (patch)
tree1e05d721018f00d7a91555af601aa9ad27d5d5ae /dbaccess
parent78c1ae17d1ee0e391279e56f2757f284a5959d51 (diff)
Resolves: #i122589# check if element is added before...
removing and deleting it (well, put it in undo) (cherry picked from commit 48558dc3e09ec442bc4caf867df4b97354b4d334) Conflicts: dbaccess/source/ui/inc/QueryTableView.hxx dbaccess/source/ui/querydesign/QueryTableView.cxx Change-Id: Id8ef54c0a223548affc007d25131a23618c5fe01
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/inc/QueryTableView.hxx1
-rw-r--r--dbaccess/source/ui/querydesign/QueryTableView.cxx71
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()
+ );
+ }
}
//------------------------------------------------------------------------