diff options
-rw-r--r-- | include/svtools/tabbar.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/tabview.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/tabcont.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 3 | ||||
-rw-r--r-- | svtools/source/control/tabbar.cxx | 31 |
6 files changed, 49 insertions, 0 deletions
diff --git a/include/svtools/tabbar.hxx b/include/svtools/tabbar.hxx index 48ac6d1f679f..7c13af5b9cee 100644 --- a/include/svtools/tabbar.hxx +++ b/include/svtools/tabbar.hxx @@ -441,6 +441,7 @@ public: void SelectPage( sal_uInt16 nPageId, bool bSelect ); sal_uInt16 GetSelectPageCount() const; bool IsPageSelected( sal_uInt16 nPageId ) const; + void SetProtectionSymbol( sal_uInt16 nPageId, bool bProtection ); void SetMaxPageWidth( long nMaxWidth ); diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 9fc8d311f3e0..0424a639759c 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -500,6 +500,7 @@ public: void UpdateScrollBars(); void SetNewVisArea(); + void SetTabProtectionSymbol( SCTAB nTab, const bool bProtect ); // for protection icon of a tab on tabbar void InvalidateAttribs(); diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index 592d052167b6..1aba21d2cf9a 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -61,6 +61,10 @@ ScTabControl::ScTabControl( vcl::Window* pParent, ScViewData* pData ) InsertPage( static_cast<sal_uInt16>(i)+1, aString, TabBarPageBits::Blue); else InsertPage( static_cast<sal_uInt16>(i)+1, aString ); + + if ( pDoc->IsTabProtected(i) ) + SetProtectionSymbol(static_cast<sal_uInt16>(i)+1, true); + if ( !pDoc->IsDefaultTabBgColor(i) ) { aTabBgColor = pDoc->GetTabBgColor(i); @@ -368,6 +372,10 @@ void ScTabControl::UpdateStatus() InsertPage(static_cast<sal_uInt16>(i)+1, aString, TabBarPageBits::Blue); else InsertPage( static_cast<sal_uInt16>(i)+1, aString ); + + if ( pDoc->IsTabProtected(i) ) + SetProtectionSymbol(static_cast<sal_uInt16>(i)+1, true); + if ( !pDoc->IsDefaultTabBgColor(i) ) { aTabBgColor = pDoc->GetTabBgColor(i); diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 5ea1054821a0..84c945552677 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -460,6 +460,11 @@ void ScTabView::CellContentChanged() aViewData.GetViewShell()->UpdateInputHandler(); } +void ScTabView::SetTabProtectionSymbol( SCTAB nTab, const bool bProtect ) +{ + pTabControl->SetProtectionSymbol( static_cast<sal_uInt16>(nTab)+1, bProtect); +} + void ScTabView::SelectionChanged() { SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame(); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index b09c15316d17..591e2ef0b1c7 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2496,6 +2496,7 @@ void ScViewFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ) if (bUndo) pDocSh->GetUndoManager()->LeaveListAction(); + SetTabProtectionSymbol(nTab, true); UpdateLayerLocks(); //! broadcast to all views } @@ -2560,6 +2561,8 @@ bool ScViewFunc::Unprotect( SCTAB nTab, const OUString& rPassword ) pDocSh->GetUndoManager()->LeaveListAction(); } + SetTabProtectionSymbol(nTab, false); + if (bChanged) UpdateLayerLocks(); //! broadcast to all views diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index 70894367ba82..c25b7c07c536 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -126,6 +126,17 @@ public: mrRenderContext.DrawCtrlText(aPos, aText, 0, aText.getLength(), (DrawTextFlags::Disable | DrawTextFlags::Mnemonic)); } + void drawProtectionSymbol(const OUString &aProtectionSymbol) + { + tools::Rectangle aRect = maRect; + long nSymbolHeight = mrRenderContext.GetTextHeight(); + Point aPos = aRect.TopLeft(); + aPos.X() += 2; + aPos.Y() += (aRect.getHeight() - nSymbolHeight) / 2; + + mrRenderContext.DrawText(aPos, aProtectionSymbol); + } + void drawOverTopBorder() { Point aTopLeft = maRect.TopLeft() + Point(1, 0); @@ -205,6 +216,7 @@ struct ImplTabBarItem OString maHelpId; bool mbShort : 1; bool mbSelect : 1; + bool mbProtect : 1; Color maTabBgColor; Color maTabTextColor; @@ -215,6 +227,7 @@ struct ImplTabBarItem , mnWidth(0) , mbShort(false) , mbSelect(false) + , mbProtect(false) , maTabBgColor(Color(COL_AUTO)) , maTabTextColor(Color(COL_AUTO)) { @@ -779,6 +792,7 @@ void TabBar::ImplInitControls() mpImpl->mpAddButton->Show(); } + Link<Button*,void> aLink = LINK( this, TabBar, ImplClickHdl ); if (mnWinStyle & (WB_MINSCROLL | WB_SCROLL)) @@ -1218,6 +1232,13 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r aDrawer.drawText(aText); + if (pItem->mbProtect) + { + constexpr sal_uInt32 cLockChar = 0x1F512; + OUString aLockSymbol( &cLockChar, 1); + aDrawer.drawProtectionSymbol(aLockSymbol); + } + if (bCurrent) { rRenderContext.SetLineColor(); @@ -2038,6 +2059,16 @@ bool TabBar::IsPageSelected(sal_uInt16 nPageId) const return false; } +void TabBar::SetProtectionSymbol(sal_uInt16 nPageId, bool bProtection) +{ + sal_uInt16 nPos = GetPagePos(nPageId); + if (nPos != PAGE_NOT_FOUND) + { + mpImpl->mpItemList[nPos]->mbProtect = bProtection; + Invalidate(mpImpl->mpItemList[nPos]->maRect); + } +} + bool TabBar::StartEditMode(sal_uInt16 nPageId) { sal_uInt16 nPos = GetPagePos( nPageId ); |