17#include <sfx2/sfxsids.hrc>
20#include <com/sun/star/frame/UnknownModuleException.hpp>
21#include <com/sun/star/frame/XLayoutManager.hpp>
22#include <officecfg/Office/UI/ToolbarMode.hxx>
23#include <com/sun/star/frame/XModuleManager.hpp>
24#include <com/sun/star/frame/ModuleManager.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
35using namespace css::uno;
36using namespace css::ui;
39constexpr OUStringLiteral
MENUBAR_STR =
u"private:resource/menubar/menubar";
43bool SfxNotebookBar::m_bLock =
false;
44bool SfxNotebookBar::m_bHide =
false;
45std::map<const SfxViewShell*, std::shared_ptr<WeldedTabbedNotebookbar>> SfxNotebookBar::m_pNotebookBarWeldedWrapper;
48 std::vector<Image>& aImageValues,
49 std::vector<css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>>&
52 framework::AddonsOptions aAddonsItems;
54 for (
int nIdx = 0; nIdx < aAddonsItems.GetAddonsNotebookBarCount(); nIdx++)
56 const css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> aExtension
57 = aAddonsItems.GetAddonsNotebookBarPart(nIdx);
58 for (
const css::uno::Sequence<css::beans::PropertyValue>& rExtensionVal : aExtension)
61 bool isBigImage =
true;
62 for (
const auto& rProp : rExtensionVal)
67 rProp.Value >>= sImage;
68 aImage =
Image(aAddonsItems.GetImageFromURL(sImage, isBigImage));
71 aImageValues.push_back(aImage);
73 aExtensionValues.push_back(aExtension);
79 css::uno::Reference<css::frame::XLayoutManager> xLayoutManager;
83 Reference<css::beans::XPropertySet> xPropSet(
xFrame, UNO_QUERY);
87 Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
88 aValue >>= xLayoutManager;
92 return xLayoutManager;
116 std::shared_ptr<comphelper::ConfigurationChanges> aBatch(
121 officecfg::Office::UI::ToolbarMode::ActiveWriter::set( sFileName, aBatch );
124 officecfg::Office::UI::ToolbarMode::ActiveCalc::set( sFileName, aBatch );
127 officecfg::Office::UI::ToolbarMode::ActiveImpress::set( sFileName, aBatch );
130 officecfg::Office::UI::ToolbarMode::ActiveDraw::set( sFileName, aBatch );
143 return officecfg::Office::UI::ToolbarMode::ActiveWriter::get();
145 return officecfg::Office::UI::ToolbarMode::ActiveCalc::get();
147 return officecfg::Office::UI::ToolbarMode::ActiveImpress::get();
149 return officecfg::Office::UI::ToolbarMode::ActiveDraw::get();
160 "org.openoffice.Office.UI.ToolbarMode/",
167 if (!rNotebookbarNode.
isValid())
170 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
176 const Sequence<OUString> aModeNodeNames( aImplsNode.
getNodeNames() );
178 for (
const auto& rModeNodeName : aModeNodeNames )
186 if ( aCommandArg == aActive )
233 const Reference<frame::XFrame>&
xFrame = pViewFrm->GetFrame().GetFrameInterface();
237 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
242 catch (css::frame::UnknownModuleException& e)
244 SAL_WARN(
"sfx.appl",
"SfxNotebookBar::IsActive(): " + e.Message);
253 if (appName.isEmpty())
257 OUString aPath =
"org.openoffice.Office.UI.ToolbarMode/Applications/" + appName;
260 ::comphelper::getProcessComponentContext(),
268 if (bConsiderSingleToolbar && aActive ==
"Single")
275 const Sequence<OUString> aModeNodeNames( aModesNode.
getNodeNames() );
277 for (
const auto& rModeNodeName : aModeNodeNames )
285 if ( aCommandArg == aActive )
296 if (!rUIName.isEmpty())
300 const Reference<frame::XFrame>&
xFrame = pViewFrm->GetFrame().GetFrameInterface();
303 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
316 bool bReloadNotebookbar)
324 const Reference<css::frame::XFrame>& xFrame,
325 std::u16string_view rUIFile,
bool bReloadNotebookbar)
339 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext );
340 OUString aModuleName = xModuleManager->identify( xFrame );
345 sFile =
"notebookbar_online.ui";
349 OUString sNewFile = rUIFile + sFile;
350 OUString sCurrentFile;
353 sCurrentFile = pNotebookBar->GetUIFilePath();
355 bool bChangedFile = sNewFile != sCurrentFile;
357 if ((!sFile.isEmpty() && bChangedFile) || !pNotebookBar || !pNotebookBar->IsVisible()
364 OUString
aBuf = rUIFile + sFile;
367 std::vector<Image> aImageValues;
368 std::vector<css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > > aExtensionValues;
382 pSysWindow->
SetNotebookBar(
aBuf, xFrame, aNotebookBarAddonsItem , bReloadNotebookbar);
384 pNotebookBar->Show();
388 if ((!hasWeldedWrapper || bReloadNotebookbar) && pNotebookBar->IsWelded())
390 sal_uInt64 nWindowId =
reinterpret_cast<sal_uInt64
>(pViewShell);
393 pNotebookBar->GetUIFilePath(),
396 pNotebookBar->SetDisposeCallback(
LINK(
nullptr,
SfxNotebookBar, VclDisposeHdl), pViewShell);
399 pNotebookBar->GetParent()->Resize();
409 pNotebookBar->SetupListener(
true);
430 pNotebookBar->SetupListener(
false);
441 Reference<frame::XFrame>
xFrame;
444 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext );
461 if ( eApp == eCurrentApp )
463 const Reference<frame::XLayoutManager>& xLayoutManager =
466 if (xLayoutManager.is())
470 if (xLayoutManager->isElementVisible(
MENUBAR_STR) && !bShow)
472 else if(!xLayoutManager->isElementVisible(
MENUBAR_STR) && bShow)
495 if (xLayoutManager.is())
499 if (xLayoutManager->isElementVisible(
MENUBAR_STR) && !bShow)
501 else if (!xLayoutManager->isElementVisible(
MENUBAR_STR) && bShow)
519 const Reference<frame::XLayoutManager>& xLayoutManager =
523 if (xLayoutManager.is() && xLayoutManager->getElement(
MENUBAR_STR).is())
539 aModeNode.
setNodeValue(
"HasMenubar", toAny<bool>( bShow ) );
555 m_pNotebookBarWeldedWrapper.erase(pViewShell);
static Reference< frame::XLayoutManager > lcl_getLayoutManager(const Reference< frame::XFrame > &xFrame)
constexpr OUStringLiteral MENUBAR_STR
static utl::OConfigurationTreeRoot lcl_getCurrentImplConfigRoot()
static utl::OConfigurationNode lcl_getCurrentImplConfigNode(const Reference< css::frame::XFrame > &xFrame, utl::OConfigurationTreeRoot const &rNotebookbarNode)
IMPL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell *, pViewShell, void)
static OUString lcl_getNotebookbarFileName(vcl::EnumContext::Application eApp)
static void lcl_setNotebookbarFileName(vcl::EnumContext::Application eApp, const OUString &sFileName)
static void NotebookbarAddonValues(std::vector< Image > &aImageValues, std::vector< css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > > &aExtensionValues)
const char MERGE_NOTEBOOKBAR_URL[]
static OUString lcl_getAppName(vcl::EnumContext::Application eApp)
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
void Update(sal_uInt16 nId)
void Invalidate(sal_uInt16 nId)
SfxViewFrame * GetFrame() const
Returns a pointer to the <SfxViewFrame> instance, which belongs to this SfxDispatcher.
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SystemWindow * GetSystemWindow() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
vcl::Window & GetWindow() const
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxFrame & GetFrame() const
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
const LanguageTag & GetLOKLocale() const
Get the LibreOfficeKit locale of this view.
SfxViewFrame & GetViewFrame() const
const LanguageTag & GetLOKLanguageTag() const
Get the LibreOfficeKit language of this view.
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
void SetNotebookBar(const OUString &rUIXMLDescription, const css::uno::Reference< css::frame::XFrame > &rFrame, const NotebookBarAddonsItem &aNotebookBarAddonsItem, bool bReloadNotebookbar=false)
VclPtr< NotebookBar > const & GetNotebookBar() const
static std::shared_ptr< ConfigurationChanges > create()
Helpers for easier access to NotebookBar via the sfx2 infrastructure.
static void UnlockNotebookBar()
Method restores normal behaviour of the Notebookbar.
static void ExecMethod(SfxBindings &rBindings, const OUString &rUIName)
Function to be called from the sdi's ExecMethod.
static std::map< const SfxViewShell *, std::shared_ptr< WeldedTabbedNotebookbar > > m_pNotebookBarWeldedWrapper
static void CloseMethod(SfxBindings &rBindings)
static void ShowMenubar(bool bShow)
Show menu bar in all frames of current application.
static void LockNotebookBar()
Method temporarily blocks showing of the NotebookBar.
static bool StateMethod(SfxBindings &rBindings, std::u16string_view rUIFile, bool bReloadNotebookbar=false)
Function to be called from the sdi's StateMethod.
static void ReloadNotebookBar(std::u16string_view sUIPath)
static void ToggleMenubar()
static bool IsActive(bool bConsiderSingleToolbar=false)
static void RemoveListeners(SystemWindow const *pSysWindow)
css::uno::Sequence< OUString > getNodeNames() const noexcept
css::uno::Any getNodeValue(const OUString &_rPath) const noexcept
bool setNodeValue(const OUString &_rPath, const css::uno::Any &_rValue) const noexcept
OConfigurationNode openNode(const OUString &_rPath) const noexcept
bool commit() const noexcept
static Application GetApplicationEnum(const OUString &rsApplicationName)
SystemWindow * GetSystemWindow() const
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
void setLocale(const LanguageTag &languageTag)
void setLanguageTag(const LanguageTag &languageTag)
bool getBOOL(const Any &_rAny)
Reference< XComponentContext > getProcessComponentContext()
OUString getString(const Any &_rAny)
std::vector< Image > aImageValues
std::vector< css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > > aAddonValues
Reference< XFrame > xFrame