From 12d37f92507ab66fd519a68a2479e1cd7136cf74 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 4 Jan 2015 18:42:14 +0900 Subject: fdo#87684 option to make tabbar inline with scrollbar again This adds an option to move the tabbar back to be inline with scrollbar. The option is only available in Expert Configuration under key: /org.openoffice.Office.Calc/Layout/Other property TabbarInlineWithScrollbar Change-Id: I95491072ad1cc195f2d8b8d0fadbd5ef045767e7 --- .../registry/schema/org/openoffice/Office/Calc.xcs | 7 ++ sc/source/ui/inc/tabview.hxx | 1 + sc/source/ui/view/tabview.cxx | 83 +++++++++++++++++----- sc/source/ui/view/tabview5.cxx | 9 ++- 4 files changed, 83 insertions(+), 17 deletions(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs index 141d91a2a289..832c795a73f4 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs @@ -442,6 +442,13 @@ 9 + + + Specifies if the tabbar should be shown inline with the scrollbar. + + + false + diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 2aba44dc01e4..63573bae4bb8 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -165,6 +165,7 @@ private: bool bBlockNeg:1; // is no longer highlighted? bool bBlockCols:1; // are whole columns selected? bool bBlockRows:1; // are whole rows selected? + bool mbInlineWithScrollbar:1; // should inline with scrollbar? void Init(); diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index e734401f04cd..06367a65519f 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -59,6 +59,9 @@ #define SC_ICONSIZE 36 +#define SC_SCROLLBAR_MIN 30 +#define SC_TABBAR_MIN 6 + using namespace ::com::sun::star; // Corner-Button @@ -228,7 +231,8 @@ ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* bDragging( false ), bBlockNeg( false ), bBlockCols( false ), - bBlockRows( false ) + bBlockRows( false ), + mbInlineWithScrollbar( false ) { Init(); } @@ -377,7 +381,11 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) } if (bHScroll) { - nBarY = nScrollBarSize + nTabWidth; + nBarY = nTabWidth; + + if (!mbInlineWithScrollbar) + nBarY += nScrollBarSize; + nSizeY -= nBarY - nOverlap; } @@ -408,6 +416,8 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) } nSizeRt = nSizeX - nSizeLt - nSizeSp; + long nTabSize = 0; + if (bTabControl) { // pending relative tab bar width from extended document options @@ -416,26 +426,67 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) SetRelTabBarWidth( mfPendingTabBarWidth ); mfPendingTabBarWidth = -1.0; } - } - Point aTabPoint(nPosX - nOverlap, nPosY + nSizeY + nScrollBarSize); - Size aTabSize(nSizeX, nBarY - nScrollBarSize); - lcl_SetPosSize( *pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL ); - pTabControl->SetSheetLayoutRTL( bLayoutRTL ); + if (mbInlineWithScrollbar) + { + nTabSize = pTabControl->GetSizePixel().Width() - nOverlap; + + if ( aViewData.GetHSplitMode() != SC_SPLIT_FIX ) // left Scrollbar + { + if (nTabSize > nSizeLt-SC_SCROLLBAR_MIN) + nTabSize = nSizeLt-SC_SCROLLBAR_MIN; + if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN; + nSizeLt -= nTabSize; + } + else // right Scrollbar + { + if (nTabSize > nSizeRt-SC_SCROLLBAR_MIN) + nTabSize = nSizeRt-SC_SCROLLBAR_MIN; + if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN; + nSizeRt -= nTabSize; + } + } + } - Point aHScrollLeftPoint(nPosX - nOverlap, nPosY + nSizeY); - Size aHScrollLeftSize(nSizeLt + 2 * nOverlap, nScrollBarSize); - lcl_SetPosSize( aHScrollLeft, aHScrollLeftPoint, aHScrollLeftSize, nTotalWidth, bLayoutRTL ); + if (mbInlineWithScrollbar) + { + Point aTabPoint(nPosX - nOverlap, nPosY + nSizeY); + Size aTabSize(nTabSize + nOverlap, nBarY); + lcl_SetPosSize(*pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL); + pTabControl->SetSheetLayoutRTL(bLayoutRTL); + + Point aHScrollLeftPoint(nPosX + nTabSize - nOverlap, nPosY + nSizeY); + Size aHScrollLeftSize(nSizeLt + 2 * nOverlap, nBarY); + lcl_SetPosSize( aHScrollLeft, aHScrollLeftPoint, aHScrollLeftSize, nTotalWidth, bLayoutRTL); + + Point aHSplitterPoint(nPosX + nTabSize + nSizeLt, nPosY + nSizeY); + Size aHSplitterSize(nSizeSp, nBarY); + lcl_SetPosSize(*pHSplitter, aHSplitterPoint, aHSplitterSize, nTotalWidth, bLayoutRTL); + + Point aHScrollRightPoint(nPosX + nTabSize + nSizeLt + nSizeSp - nOverlap, nPosY + nSizeY); + Size aHScrollRightSize(nSizeRt + 2 * nOverlap, nBarY); + lcl_SetPosSize(aHScrollRight, aHScrollRightPoint, aHScrollRightSize, nTotalWidth, bLayoutRTL); + } + else + { + Point aTabPoint(nPosX - nOverlap, nPosY + nSizeY + nScrollBarSize); + Size aTabSize(nSizeX, nTabWidth); + lcl_SetPosSize( *pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL ); + pTabControl->SetSheetLayoutRTL( bLayoutRTL ); - Point aHSplitterPoint(nPosX + nSizeLt, nPosY + nSizeY); - Size aHSplitterSize(nSizeSp, nScrollBarSize); - lcl_SetPosSize( *pHSplitter, aHSplitterPoint, aHSplitterSize, nTotalWidth, bLayoutRTL ); + Point aHScrollLeftPoint(nPosX - nOverlap, nPosY + nSizeY); + Size aHScrollLeftSize(nSizeLt + 2 * nOverlap, nScrollBarSize); + lcl_SetPosSize( aHScrollLeft, aHScrollLeftPoint, aHScrollLeftSize, nTotalWidth, bLayoutRTL ); - Point aHScrollRightPoint(nPosX + nSizeLt + nSizeSp - nOverlap, nPosY + nSizeY); - Size aHScrollRightSize(nSizeRt + 2 * nOverlap, nScrollBarSize); + Point aHSplitterPoint(nPosX + nSizeLt, nPosY + nSizeY); + Size aHSplitterSize(nSizeSp, nScrollBarSize); + lcl_SetPosSize( *pHSplitter, aHSplitterPoint, aHSplitterSize, nTotalWidth, bLayoutRTL ); - lcl_SetPosSize( aHScrollRight, aHScrollRightPoint, aHScrollRightSize, nTotalWidth, bLayoutRTL ); + Point aHScrollRightPoint(nPosX + nSizeLt + nSizeSp - nOverlap, nPosY + nSizeY); + Size aHScrollRightSize(nSizeRt + 2 * nOverlap, nScrollBarSize); + lcl_SetPosSize( aHScrollRight, aHScrollRightPoint, aHScrollRightSize, nTotalWidth, bLayoutRTL ); + } // SetDragRectPixel is done below } diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 424e9bc76743..66ec1a8463e8 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -51,6 +51,8 @@ #include #include +#include + using namespace com::sun::star; // STATIC DATA ----------------------------------------------------------- @@ -65,6 +67,8 @@ void ScTabView::Init() sal_uInt16 i; + mbInlineWithScrollbar = officecfg::Office::Calc::Layout::Other::TabbarInlineWithScrollbar::get(); + aScrollTimer.SetTimeout(10); aScrollTimer.SetTimeoutHdl( LINK( this, ScTabView, TimerHdl ) ); @@ -94,7 +98,10 @@ void ScTabView::Init() pHSplitter->SetKeyboardStepSize( 1 ); pVSplitter->SetKeyboardStepSize( 1 ); - pTabControl = new ScTabControl( pFrameWin, &aViewData ); + pTabControl = new ScTabControl(pFrameWin, &aViewData); + if (mbInlineWithScrollbar) + pTabControl->SetStyle(pTabControl->GetStyle() | WB_SIZEABLE); + /* #i97900# The tab control has to remain in RTL mode if GUI is RTL, this is needed to draw the 3D effect correctly. The base TabBar implementes mirroring independent from the GUI direction. Have to set RTL mode -- cgit