summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-09-09 16:05:12 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2022-09-21 15:04:18 +0200
commit8aafabd93d8ef61f70578967a87bb338355637d9 (patch)
treed75fd15ce11ea434e7d559ab5a6c734d38106efb
parentBump current iOS SDK to 16.0 (diff)
downloadcore-8aafabd93d8ef61f70578967a87bb338355637d9.tar.gz
core-8aafabd93d8ef61f70578967a87bb338355637d9.zip
lok: create sidebar on demand
Change-Id: I5393bba647aa4667643262e77acc6b6873afb571 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139729 Reviewed-by: Ashod Nakashian <ash@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140035 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx37
-rw-r--r--desktop/source/lib/init.cxx15
-rw-r--r--include/sfx2/sidebar/SidebarDockingWindow.hxx1
-rw-r--r--sfx2/source/sidebar/SidebarDockingWindow.cxx16
4 files changed, 49 insertions, 20 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 6cf4d2e79e6c..cebf733d4838 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -43,6 +43,8 @@
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <sfx2/sidebar/SidebarDockingWindow.hxx>
#include <unotools/datetime.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <comphelper/string.hxx>
@@ -3235,10 +3237,35 @@ void DesktopLOKTest::testMultiDocuments()
}
}
+namespace
+{
+ SfxChildWindow* lcl_initializeSidebar()
+ {
+ // in init.cxx we do setupSidebar which creaes the controller, do it here
+
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ CPPUNIT_ASSERT(pViewShell);
+
+ SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+ CPPUNIT_ASSERT(pViewFrame);
+
+ SfxChildWindow* pSideBar = pViewFrame->GetChildWindow(SID_SIDEBAR);
+ CPPUNIT_ASSERT(pSideBar);
+
+ auto pDockingWin = dynamic_cast<sfx2::sidebar::SidebarDockingWindow *>(pSideBar->GetWindow());
+ CPPUNIT_ASSERT(pDockingWin);
+
+ pDockingWin->GetOrCreateSidebarController(); // just to create the controller
+
+ return pSideBar;
+ }
+};
+
void DesktopLOKTest::testControlState()
{
LibLODocument_Impl* pDocument = loadDoc("search.ods");
pDocument->pClass->postUnoCommand(pDocument, ".uno:StarShapes", nullptr, false);
+ lcl_initializeSidebar();
Scheduler::ProcessEventsToIdle();
boost::property_tree::ptree aState;
@@ -3252,17 +3279,9 @@ void DesktopLOKTest::testMetricField()
{
LibLODocument_Impl* pDocument = loadDoc("search.ods");
pDocument->pClass->postUnoCommand(pDocument, ".uno:StarShapes", nullptr, false);
+ SfxChildWindow* pSideBar = lcl_initializeSidebar();
Scheduler::ProcessEventsToIdle();
- SfxViewShell* pViewShell = SfxViewShell::Current();
- CPPUNIT_ASSERT(pViewShell);
-
- SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
- CPPUNIT_ASSERT(pViewFrame);
-
- SfxChildWindow* pSideBar = pViewFrame->GetChildWindow(SID_SIDEBAR);
- CPPUNIT_ASSERT(pSideBar);
-
vcl::Window* pWin = pSideBar->GetWindow();
CPPUNIT_ASSERT(pWin);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f22558d6d76e..a9bf7ca19635 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -882,22 +882,21 @@ void setupSidebar(const OUString& sidebarDeckId = "")
if (!pDockingWin)
return;
- OUString currentDeckId = pDockingWin->GetSidebarController()->GetCurrentDeckId();
+ pViewFrame->ShowChildWindow( SID_SIDEBAR );
- // check if it is the chart deck id, if it is, don't switch to default deck
- bool switchToDefault = true;
+ const rtl::Reference<sfx2::sidebar::SidebarController>& xController
+ = pDockingWin->GetOrCreateSidebarController();
- if (currentDeckId == "ChartDeck")
- switchToDefault = false;
+ xController->FadeIn();
+ xController->RequestOpenDeck();
if (!sidebarDeckId.isEmpty())
{
- pDockingWin->GetSidebarController()->SwitchToDeck(sidebarDeckId);
+ xController->SwitchToDeck(sidebarDeckId);
}
else
{
- if (switchToDefault)
- pDockingWin->GetSidebarController()->SwitchToDefaultDeck();
+ xController->SwitchToDefaultDeck();
}
pDockingWin->SyncUpdate();
diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx
index 9bad1f5a8464..b22aefcb34a9 100644
--- a/include/sfx2/sidebar/SidebarDockingWindow.hxx
+++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx
@@ -46,6 +46,7 @@ public:
void SyncUpdate();
auto& GetSidebarController() const { return mpSidebarController; }
+ rtl::Reference<sfx2::sidebar::SidebarController>& GetOrCreateSidebarController();
using SfxDockingWindow::Close;
private:
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index d50aa2b3d4b0..0cc38871a8ce 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -53,13 +53,23 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChi
OSL_ASSERT(pSfxBindings!=nullptr);
OSL_ASSERT(pSfxBindings->GetDispatcher()!=nullptr);
}
- else
+ else if (!comphelper::LibreOfficeKit::isActive())
{
- const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame();
- mpSidebarController.set(sfx2::sidebar::SidebarController::create(this, pViewFrame).get());
+ GetOrCreateSidebarController();
}
}
+rtl::Reference<sfx2::sidebar::SidebarController>& SidebarDockingWindow::GetOrCreateSidebarController()
+{
+ if (!mpSidebarController)
+ {
+ const SfxViewFrame* pViewFrame = GetBindings().GetDispatcher()->GetFrame();
+ mpSidebarController = sfx2::sidebar::SidebarController::create(this, pViewFrame);
+ }
+
+ return mpSidebarController;
+}
+
SidebarDockingWindow::~SidebarDockingWindow()
{
disposeOnce();