Commits

Anonymous committed 69017c9

CWS-TOOLING: integrate CWS fwk107_DEV300
2009-03-31 14:56:40 +0200 cd r270283 : #i100707# Correctly implement removeTab() method which destroys the embedded window

Comments (0)

Files changed (2)

framework/inc/classes/fwktabwindow.hxx

 
     void            ClearEntryList();
     TabEntry*       FindEntry( sal_Int32 nIndex ) const;
+    bool            RemoveEntry( sal_Int32 nIndex );
 
     DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * );
     DECL_DLLPRIVATE_LINK( DeactivatePageHdl, TabControl * );

framework/source/classes/fwktabwindow.cxx

 
 // -----------------------------------------------------------------------
 
+bool FwkTabWindow::RemoveEntry( sal_Int32 nIndex )
+{
+    TabEntryList::iterator pIt;
+    for (  pIt  = m_TabList.begin();
+           pIt != m_TabList.end();
+         ++pIt )
+    {
+        if ( (*pIt)->m_nIndex == nIndex )
+            break;
+    }
+
+    // remove entry from vector
+    if ( pIt != m_TabList.end())
+    {
+        m_TabList.erase(pIt);
+        return true;
+    }
+    else
+        return false;
+}
+
+// -----------------------------------------------------------------------
 TabEntry* FwkTabWindow::FindEntry( sal_Int32 nIndex ) const
 {
     TabEntry* pEntry = NULL;
         if ( pEntry )
         {
             pTabPage = new FwkTabPage( &m_aTabCtrl, pEntry->m_sPageURL, pEntry->m_xEventHdl, m_xWinProvider );
+            pEntry->m_pPage = pTabPage;
+            m_aTabCtrl.SetTabPage( nId, pTabPage );
             pTabPage->Show();
             pTabPage->ActivatePage();
-            m_aTabCtrl.SetTabPage( nId, pTabPage );
         }
     } else {
         pTabPage->ActivatePage();
 
 void FwkTabWindow::RemovePage( sal_Int32 nIndex )
 {
-    m_aTabCtrl.RemovePage( static_cast< USHORT >( nIndex ) );
+    TabEntry* pEntry = FindEntry(nIndex);
+    if ( pEntry )
+    {
+        m_aTabCtrl.RemovePage( static_cast< USHORT >( nIndex ) );
+        if (RemoveEntry(nIndex))
+            delete pEntry;
+    }
 }
 
 // -----------------------------------------------------------------------