[Libreoffice-commits] core.git: include/vcl vcl/source

Szymon Kłos eszkadev at gmail.com
Mon Jan 16 14:07:47 UTC 2017


 include/vcl/tabctrl.hxx        |    3 ++-
 vcl/source/control/tabctrl.cxx |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit b33715c00ea3a20e219d80845e72a2b37ba6c8cc
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Sun Jan 15 20:20:26 2017 +0100

    tdf#102139 : prevent the notebookbar from switching to empty tab
    
    Change-Id: I0b463fef98d7597c9b7f22ee84701519a0f2b575
    Reviewed-on: https://gerrit.libreoffice.org/33100
    Reviewed-by: Szymon Kłos <eszkadev at gmail.com>
    Tested-by: Szymon Kłos <eszkadev at gmail.com>

diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx
index e9a9dc8..fc7d1a8 100644
--- a/include/vcl/tabctrl.hxx
+++ b/include/vcl/tabctrl.hxx
@@ -68,7 +68,7 @@ protected:
     SAL_DLLPRIVATE Rectangle    ImplGetTabRect( sal_uInt16 nPos, long nWidth = -1, long nHeight = -1 );
     SAL_DLLPRIVATE void         ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId );
     SAL_DLLPRIVATE bool         ImplPosCurTabPage();
-    SAL_DLLPRIVATE void         ImplActivateTabPage( bool bNext );
+    virtual void                ImplActivateTabPage( bool bNext );
     SAL_DLLPRIVATE void         ImplShowFocus();
     SAL_DLLPRIVATE void         ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem* pItem,
                                              const Rectangle& rCurRect, bool bFirstInGroup,
@@ -208,6 +208,7 @@ public:
 protected:
     virtual bool ImplPlaceTabs( long nWidth ) override;
     virtual void ImplPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
+    virtual void ImplActivateTabPage( bool bNext ) override;
 
 private:
     bool bLastContextWasSupported;
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index ee31141..740628b 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2288,6 +2288,39 @@ void NotebookbarTabControl::SetCurPageId( sal_uInt16 nPageId )
         TabControl::SetCurPageId( nPageId );
 }
 
+void NotebookbarTabControl::ImplActivateTabPage( bool bNext )
+{
+    sal_uInt16 nCurPos = GetPagePos( GetCurPageId() );
+
+    if ( bNext && nCurPos + 1 < GetPageCount() )
+    {
+        sal_uInt16 nOldPos = nCurPos;
+        nCurPos++;
+
+        ImplTabItem* pItem = &mpTabCtrlData->maItemList[nCurPos];
+        while ( !pItem->mbEnabled && nCurPos + 1 < GetPageCount())
+        {
+            nCurPos++;
+            pItem = &mpTabCtrlData->maItemList[nCurPos];
+        }
+
+        if ( !pItem->mbEnabled )
+            nCurPos = nOldPos;
+    }
+    else if ( !bNext && nCurPos )
+    {
+        nCurPos--;
+        ImplTabItem* pItem = &mpTabCtrlData->maItemList[nCurPos];
+        while ( nCurPos && !pItem->mbEnabled )
+        {
+            nCurPos--;
+            pItem = &mpTabCtrlData->maItemList[nCurPos];
+        }
+    }
+
+    SelectTabPage( TabControl::GetPageId( nCurPos ) );
+}
+
 sal_uInt16 NotebookbarTabControl::GetHeaderHeight()
 {
     return m_nHeaderHeight;


More information about the Libreoffice-commits mailing list