diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 3dcb94e9369e..7d3e943b92a3 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -35,6 +35,11 @@
Number Format Type
+
+
+ Current Sheet View
+
+
Flip Horizontally
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 7a4c6a34cc14..eb705ac493db 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -404,6 +404,8 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/cctrl/checklistmenu \
sc/source/ui/cctrl/dpcontrol \
sc/source/ui/cctrl/tbzoomsliderctrl \
+ sc/source/ui/cctrl/SheetViewBox \
+ sc/source/ui/cctrl/SheetViewControl \
sc/source/ui/condformat/condformatdlg \
sc/source/ui/condformat/condformatdlgentry \
sc/source/ui/condformat/condformatdlgdata \
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 6b4026af9734..e1e03bb2f099 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -239,6 +239,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/sharedfooterdialog \
sc/uiconfig/scalc/ui/sharedheaderdialog \
sc/uiconfig/scalc/ui/sharedwarningdialog \
+ sc/uiconfig/scalc/ui/sheetviewbox \
sc/uiconfig/scalc/ui/showchangesdialog \
sc/uiconfig/scalc/ui/showdetaildialog \
sc/uiconfig/scalc/ui/showsheetdialog \
diff --git a/sc/inc/SheetViewControl.hxx b/sc/inc/SheetViewControl.hxx
new file mode 100644
index 000000000000..878c10680685
--- /dev/null
+++ b/sc/inc/SheetViewControl.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include
+
+namespace sc
+{
+/** Toolbox control for showing the SheetViewBox in the toolbar / notebookbar */
+class SheetViewControl final : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SheetViewControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rToolBox);
+ virtual ~SheetViewControl() override;
+
+ virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState) override;
+ virtual VclPtr CreateItemWindow(vcl::Window* pParent) override;
+};
+
+} // end of namespace sc
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 51e78553ae2b..629289aef0bf 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -291,6 +291,8 @@ class SvxZoomSliderItem;
#define FID_SWITCH_TO_PREVIOUS_SHEET_VIEW (VIEW_MENU_START + 14)
#define FID_EXIT_SHEET_VIEW (VIEW_MENU_START + 15)
#define FID_SELECT_SHEET_VIEW (VIEW_MENU_START + 16)
+#define FID_CURRENT_SHEET_VIEW TypedWhichId(VIEW_MENU_START + 17)
+
#define FID_CHG_ACCEPT (VIEW_MENU_START + 18)// DANGER DIRTY ID
#define FID_CHG_COMMENT (VIEW_MENU_START + 19)// DANGER DIRTY ID
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index ebab09fef7fc..2ccbae38b739 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -6049,6 +6049,23 @@ SfxBoolItem ToggleFormula FID_TOGGLEFORMULA
GroupId = SfxGroupId::View
]
+SfxInt32Item CurrentSheetVIew FID_CURRENT_SHEET_VIEW
+[
+ AutoUpdate = FALSE,
+ FastCall = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = SfxGroupId::Format;
+]
+
SfxBoolItem NewSheetView FID_NEW_SHEET_VIEW
[
/* flags */
@@ -6134,8 +6151,8 @@ SfxBoolItem SelectSheetView FID_SELECT_SHEET_VIEW
/* config */
AccelConfig = TRUE,
- MenuConfig = FALSE,
- ToolBoxConfig = FALSE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
GroupId = SfxGroupId::View
]
diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi
index 753e606b8bec..cae6da0dfb4f 100644
--- a/sc/sdi/tabvwsh.sdi
+++ b/sc/sdi/tabvwsh.sdi
@@ -213,6 +213,7 @@ interface TableEditView
FID_SWITCH_TO_PREVIOUS_SHEET_VIEW [ ExecMethod = Execute; StateMethod = GetState; ]
FID_EXIT_SHEET_VIEW [ ExecMethod = Execute; StateMethod = GetState; ]
FID_SELECT_SHEET_VIEW [ ExecMethod = Execute; StateMethod = GetState; ]
+ FID_CURRENT_SHEET_VIEW [ ExecMethod = Execute; StateMethod = GetState; ]
FID_NORMALVIEWMODE [ ExecMethod = Execute; StateMethod = GetState; ]
FID_PAGEBREAKMODE [ ExecMethod = Execute; StateMethod = GetState; ]
SID_REPAINT [ ExecMethod = Execute; StateMethod = GetState; ]
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index f581ad886bfd..24980df11a36 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -72,6 +72,7 @@
#include
#include
#include
+#include
#include
// Child windows
@@ -148,6 +149,7 @@ void ScDLL::Init()
SvxClipBoardControl ::RegisterControl(SID_PASTE_UNFORMATTED, pMod );
svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
sc::ScNumberFormatControl ::RegisterControl(SID_NUMBER_TYPE_FORMAT, pMod );
+ sc::SheetViewControl::RegisterControl(FID_CURRENT_SHEET_VIEW, pMod);
SvxGrafModeToolBoxControl ::RegisterControl(SID_ATTR_GRAF_MODE, pMod);
SvxGrafRedToolBoxControl ::RegisterControl(SID_ATTR_GRAF_RED, pMod);
diff --git a/sc/source/ui/cctrl/SheetViewBox.cxx b/sc/source/ui/cctrl/SheetViewBox.cxx
new file mode 100644
index 000000000000..222d03681be1
--- /dev/null
+++ b/sc/source/ui/cctrl/SheetViewBox.cxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+SheetViewBox::SheetViewBox(vcl::Window* pParent)
+ : InterimItemWindow(pParent, u"modules/scalc/ui/sheetviewbox.ui"_ustr, u"SheetViewBox"_ustr,
+ true, reinterpret_cast(SfxViewShell::Current()))
+ , m_xWidget(m_xBuilder->weld_combo_box(u"sheetview_combobox"_ustr))
+{
+ m_xWidget->connect_changed(LINK(this, SheetViewBox, SelectHdl));
+ m_xWidget->connect_key_press(LINK(this, SheetViewBox, KeyInputHdl));
+ SetSizePixel(m_xWidget->get_preferred_size());
+}
+
+void SheetViewBox::dispose()
+{
+ m_xWidget.reset();
+ InterimItemWindow::dispose();
+}
+
+SheetViewBox::~SheetViewBox() { disposeOnce(); }
+
+void SheetViewBox::GetFocus()
+{
+ if (m_xWidget)
+ m_xWidget->grab_focus();
+ InterimItemWindow::GetFocus();
+}
+
+void SheetViewBox::Update(sc::SheetViewID nSelectedID)
+{
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ if (!pViewData)
+ return;
+
+ m_xWidget->clear();
+ m_xWidget->freeze();
+
+ OUString sActiveID = OUString::number(sc::DefaultSheetViewID);
+ m_xWidget->append(sActiveID, sc::SheetViewManager::defaultViewName());
+
+ auto pSheetManager = pViewData->GetCurrentSheetViewManager();
+
+ if (pSheetManager)
+ {
+ sc::SheetViewID nSheetViewID = 0;
+ for (auto const& pSheetView : pSheetManager->getSheetViews())
+ {
+ if (pSheetView)
+ {
+ OUString sID = OUString::number(nSheetViewID);
+ if (nSheetViewID == nSelectedID)
+ sActiveID = sID;
+ m_xWidget->append(sID, pSheetView->GetName());
+ }
+ nSheetViewID++;
+ }
+ }
+ m_xWidget->thaw();
+
+ m_xWidget->set_active_id(sActiveID);
+}
+
+IMPL_STATIC_LINK(SheetViewBox, SelectHdl, weld::ComboBox&, rComboBox, void)
+{
+ auto* pViewFrame = SfxViewFrame::Current();
+ if (!pViewFrame)
+ return;
+
+ SfxDispatcher* pDispatcher = pViewFrame->GetBindings().GetDispatcher();
+ if (!pDispatcher)
+ return;
+
+ const OUString sValue = rComboBox.get_active_id();
+ SfxInt32Item aItem(FID_CURRENT_SHEET_VIEW, sValue.toInt32());
+ pDispatcher->ExecuteList(FID_CURRENT_SHEET_VIEW, SfxCallMode::RECORD, { &aItem });
+
+ pViewFrame->GetWindow().GrabFocus();
+}
+
+IMPL_LINK(SheetViewBox, KeyInputHdl, const KeyEvent&, rKEvt, bool) { return ChildKeyInput(rKEvt); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/cctrl/SheetViewControl.cxx b/sc/source/ui/cctrl/SheetViewControl.cxx
new file mode 100644
index 000000000000..cd0a8e5e92a8
--- /dev/null
+++ b/sc/source/ui/cctrl/SheetViewControl.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include
+#include
+#include
+#include
+
+using namespace sc;
+
+SFX_IMPL_TOOLBOX_CONTROL(SheetViewControl, SfxInt32Item);
+
+SheetViewControl::SheetViewControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx)
+ : SfxToolBoxControl(nSlotId, nId, rTbx)
+{
+}
+
+SheetViewControl::~SheetViewControl() {}
+
+void SheetViewControl::StateChangedAtToolBoxControl(sal_uInt16, SfxItemState eState,
+ const SfxPoolItem* pState)
+{
+ ToolBoxItemId nId = GetId();
+ ToolBox& rToolBox = GetToolBox();
+ SheetViewBox* pSheetViewBox = static_cast(rToolBox.GetItemWindow(nId));
+
+ if (SfxItemState::DISABLED == eState)
+ pSheetViewBox->Disable();
+ else
+ pSheetViewBox->Enable();
+
+ rToolBox.EnableItem(nId, SfxItemState::DISABLED != eState);
+
+ switch (eState)
+ {
+ case SfxItemState::DEFAULT:
+ {
+ const auto* pItem = static_cast(pState);
+ sc::SheetViewID nValue = pItem->GetValue();
+ pSheetViewBox->Update(nValue);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+VclPtr SheetViewControl::CreateItemWindow(vcl::Window* pParent)
+{
+ VclPtr pControl = VclPtr::Create(pParent);
+ pControl->Show();
+
+ return pControl;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/SheetViewBox.hxx b/sc/source/ui/inc/SheetViewBox.hxx
new file mode 100644
index 000000000000..95a39c7571dc
--- /dev/null
+++ b/sc/source/ui/inc/SheetViewBox.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include
+#include
+
+/** Box / container for the combobox for showing / selecting the sheet view */
+class SheetViewBox final : public InterimItemWindow
+{
+public:
+ explicit SheetViewBox(vcl::Window* pParent);
+ virtual void dispose() override;
+ virtual ~SheetViewBox() override;
+
+ virtual void GetFocus() override;
+
+ void Update(sc::SheetViewID nID);
+
+ weld::ComboBox* getWidget() { return m_xWidget.get(); }
+
+private:
+ std::unique_ptr m_xWidget;
+
+ DECL_STATIC_LINK(SheetViewBox, SelectHdl, weld::ComboBox&, void);
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 1eaa197682ef..0aa378dc73cd 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -28,6 +28,8 @@
#include
#include
+namespace sc { class SheetViewManager; }
+
constexpr auto SC_SIZE_NONE = std::numeric_limits::max();
enum class ScFillMode
@@ -420,6 +422,8 @@ public:
sc::SheetViewID GetSheetViewIDForSheet(SCTAB nTab) const;
+ std::shared_ptr GetCurrentSheetViewManager() const;
+
SCCOL MaxCol() const { return mrDoc.MaxCol(); }
SCROW MaxRow() const { return mrDoc.MaxRow(); }
ScSplitPos GetActivePart() const { return pThisTab->eWhichActive; }
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 765acf0b715e..8fd45f493c68 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2126,6 +2126,8 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
rBindings.Invalidate( SID_STYLE_FAMILY4 ); // Designer
rBindings.Invalidate( SID_TABLES_COUNT );
+ rBindings.Invalidate(FID_CURRENT_SHEET_VIEW);
+
if (pScMod->IsRefDialogOpen())
{
sal_uInt16 nCurRefDlgId=pScMod->GetCurRefDlgId();
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 7c3b3fc6a536..8c0b51b0c8e6 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -1080,6 +1080,21 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
rReq.Done();
}
break;
+ case FID_CURRENT_SHEET_VIEW:
+ {
+ const SfxPoolItem* pItem = nullptr;
+ if (pReqArgs != nullptr && pReqArgs->HasItem(FID_CURRENT_SHEET_VIEW, &pItem))
+ {
+ const sal_Int32 nValue = static_cast(pItem)->GetValue();
+ sc::SheetViewID nID(nValue);
+ if (nID != sc::InvalidSheetViewID)
+ {
+ SelectSheetView(nID);
+ }
+ }
+ rReq.Done();
+ }
+ break;
case SID_ATTR_ZOOM: // status row
case FID_SCALE:
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 3463000eb212..8f22f8c8acf1 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -412,7 +412,11 @@ void ScTabViewShell::GetState( SfxItemSet& rSet )
}
}
break;
-
+ case FID_CURRENT_SHEET_VIEW:
+ {
+ rSet.Put(SfxInt32Item(FID_CURRENT_SHEET_VIEW, GetViewData().GetSheetViewID()));
+ }
+ break;
case FID_NORMALVIEWMODE:
case FID_PAGEBREAKMODE:
// always handle both slots - they exclude each other
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 909df42d53c2..cc625749ad04 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -4465,5 +4465,9 @@ sc::SheetViewID ScViewData::GetSheetViewIDForSheet(SCTAB nTab) const
return maTabData[nTab]->mnSheetViewID;
}
+std::shared_ptr ScViewData::GetCurrentSheetViewManager() const
+{
+ return GetDocument().GetSheetViewManager(GetTabNumber());
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index e15906bba1d9..af92ca4c2b68 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -67,7 +67,8 @@
#include
#include
#include
-
+#include
+#include
using namespace com::sun::star;
@@ -2065,8 +2066,9 @@ void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
void ScViewFunc::SheetViewChanged()
{
- ScDocShell& rDocSh = GetViewData().GetDocShell();
- ScDocument& rDocument = GetViewData().GetDocument();
+ ScViewData& rViewData = GetViewData();
+ ScDocShell& rDocSh = rViewData.GetDocShell();
+ ScDocument& rDocument = rViewData.GetDocument();
rDocSh.PostPaint(0, 0, 0, rDocument.MaxCol(), rDocument.MaxRow(), MAXTAB, PaintPartFlags::All);
if (ScTabViewShell* pViewShell = GetViewData().GetViewShell())
@@ -2074,6 +2076,8 @@ void ScViewFunc::SheetViewChanged()
ScModelObj* pModel = comphelper::getFromUnoTunnel(pViewShell->GetCurrentDocument());
SfxLokHelper::notifyViewRenderState(pViewShell, pModel);
}
+ SfxBindings& rBindings = rViewData.GetBindings();
+ rBindings.Invalidate(FID_CURRENT_SHEET_VIEW);
}
void ScViewFunc::MakeNewSheetView()
diff --git a/sc/uiconfig/scalc/ui/notebookbar_online.ui b/sc/uiconfig/scalc/ui/notebookbar_online.ui
index 34c72a531b22..3b4ce81df5dd 100644
--- a/sc/uiconfig/scalc/ui/notebookbar_online.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar_online.ui
@@ -94,7 +94,32 @@
False
True
- 0
+ 2
+
+
+
+
+
+ True
+ True
+ 3
diff --git a/sc/uiconfig/scalc/ui/sheetviewbox.ui b/sc/uiconfig/scalc/ui/sheetviewbox.ui
new file mode 100644
index 000000000000..2197a9004009
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/sheetviewbox.ui
@@ -0,0 +1,28 @@
+
+
+
+
+
+ True
+ False
+ True
+ 6
+
+
+ True
+ False
+ True
+
+
+ Sheet View
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index ab391b38f073..6cbc3e21cc8e 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -472,6 +472,7 @@ constexpr auto NavigatorList
constexpr auto NotebookbarList
= frozen::make_unordered_set({
{ u"modules/scalc/ui/numberbox.ui" },
+ { u"modules/scalc/ui/sheetviewbox.ui" },
{ u"svx/ui/fontnamebox.ui" },
{ u"svx/ui/fontsizebox.ui" },
{ u"svx/ui/stylespreview.ui" },