dbaccess/source/ui/inc/QueryTableView.hxx         |    1 
 dbaccess/source/ui/querydesign/QueryTableView.cxx |   71 ++++++++++++++--------
 2 files changed, 48 insertions(+), 24 deletions(-)

New commits:
commit cb6e8c46d723de33073a5fb9ca53be12412e2a27
Author: Armin Le Grand <a...@apache.org>
Date:   Tue Jul 2 08:50:18 2013 +0000

    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

diff --git a/dbaccess/source/ui/inc/QueryTableView.hxx 
b/dbaccess/source/ui/inc/QueryTableView.hxx
index f8d3243..0714cbf 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 cbf8b93..2a57381 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()
+                                                    );
+    }
 }
 
 //------------------------------------------------------------------------
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to