From 7b0dd98941911c686c0d127810d1c333df5026c3 Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Thu, 25 Jul 2019 02:51:10 +0530 Subject: Extension support for gtkmenuItem and notebookbar.ui file added for writer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I65a07fbef7726cdaa9061ebf2227fbedd725d4db Reviewed-on: https://gerrit.libreoffice.org/76278 Tested-by: Jenkins Reviewed-by: Szymon Kłos --- extras/source/glade/libreoffice-catalog.xml.in | 6 + include/vcl/NotebookBarAddonsMerger.hxx | 11 +- sw/uiconfig/swriter/ui/notebookbar.ui | 203 ++++++++++++++++++++++++- vcl/source/window/NotebookBarAddonsMerger.cxx | 94 ++++++++---- vcl/source/window/builder.cxx | 11 +- 5 files changed, 288 insertions(+), 37 deletions(-) diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 655e5b8dbe1f..3cf70cfc456f 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -363,5 +363,11 @@ + + diff --git a/include/vcl/NotebookBarAddonsMerger.hxx b/include/vcl/NotebookBarAddonsMerger.hxx index c3b9998c7750..fde1196e4a63 100644 --- a/include/vcl/NotebookBarAddonsMerger.hxx +++ b/include/vcl/NotebookBarAddonsMerger.hxx @@ -24,12 +24,15 @@ #include #include #include +#include #include #include #include #include #include +class PopupMenu; + struct NotebookBarAddonsItem { Image aImage; @@ -59,12 +62,14 @@ struct AddonNotebookBarItem class NotebookBarAddonsMerger { public: - NotebookBarAddonsMerger(vcl::Window* pParent, - const css::uno::Reference& rFrame, - const NotebookBarAddonsItem& aNotebookBarAddonsItem); + NotebookBarAddonsMerger(); + ~NotebookBarAddonsMerger(); static void MergeNotebookBarAddons(vcl::Window* pParent, const css::uno::Reference& rFrame, const NotebookBarAddonsItem& aNotebookBarAddonsItem); + static void MergeNotebookBarMenuAddons(PopupMenu* pPopupMenu, sal_Int16 nItemId, + const OString& sItemIdName, + NotebookBarAddonsItem& aNotebookBarAddonsItem); }; #endif diff --git a/sw/uiconfig/swriter/ui/notebookbar.ui b/sw/uiconfig/swriter/ui/notebookbar.ui index f6935d190cab..c2ea3f405612 100644 --- a/sw/uiconfig/swriter/ui/notebookbar.ui +++ b/sw/uiconfig/swriter/ui/notebookbar.ui @@ -1,9 +1,33 @@ - + + + True + False + + + True + False + AddonCommand + + + + + True + False + + + + + True + False + service:com.sun.star.deployment.ui.PackageManagerDialog + + + True False @@ -17313,6 +17337,175 @@ False + + + True + False + + + True + False + end + center + True + + + True + False + center + True + vertical + + + E_xtension + True + True + False + False + end + center + True + none + True + + + False + True + 0 + + + + + True + True + end + True + both-horiz + False + 1 + + + True + False + service:com.sun.star.deployment.ui.PackageManagerDialog + + + False + True + + + + + False + True + 1 + + + + + False + True + 2 + + + + + False + False + end + 0 + + + + + True + False + end + 5 + 5 + vertical + + + False + True + 5 + end + 1 + + + + + True + False + center + True + + + True + False + center + True + + + True + False + center + True + both + False + 3 + + + True + False + AddonCommand + + + False + True + + + + + False + True + 1 + + + + + + False + True + 0 + + + + + True + True + 2 + + + + + 14 + + + + + True + False + E~xtension + True + + + 14 + False + + True @@ -17881,7 +18074,7 @@ - + True False icons @@ -18224,7 +18417,7 @@ center True - + True False 5 @@ -18363,7 +18556,7 @@ - 14 + 15 @@ -18374,7 +18567,7 @@ True - 14 + 15 False diff --git a/vcl/source/window/NotebookBarAddonsMerger.cxx b/vcl/source/window/NotebookBarAddonsMerger.cxx index d65aba9624f8..5fc0b14b8087 100644 --- a/vcl/source/window/NotebookBarAddonsMerger.cxx +++ b/vcl/source/window/NotebookBarAddonsMerger.cxx @@ -19,6 +19,7 @@ #include #include +#include #include static const char STYLE_TEXT[] = "Text"; @@ -33,13 +34,34 @@ static const char MERGE_NOTEBOOKBAR_CONTROLTYPE[] = "ControlType"; static const char MERGE_NOTEBOOKBAR_WIDTH[] = "Width"; static const char MERGE_NOTEBOOKBAR_STYLE[] = "Style"; -NotebookBarAddonsMerger::NotebookBarAddonsMerger( - vcl::Window* pParent, const css::uno::Reference& m_xFrame, - const NotebookBarAddonsItem& aNotebookBarAddonsItem) +static void GetAddonNotebookBarItem(const css::uno::Sequence& pExtension, + AddonNotebookBarItem& aAddonNotebookBarItem) { - MergeNotebookBarAddons(pParent, m_xFrame, aNotebookBarAddonsItem); + for (int nIdx = 0; nIdx < pExtension.getLength(); nIdx++) + { + if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_URL) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.sCommandURL; + else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_TITLE) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.sLabel; + else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_IMAGEID) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.sImageIdentifier; + else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_CONTEXT) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.sContext; + else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_TARGET) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.sTarget; + else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_CONTROLTYPE) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.sControlType; + else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_WIDTH) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.nWidth; + else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_STYLE) + pExtension[nIdx].Value >>= aAddonNotebookBarItem.sStyle; + } } +NotebookBarAddonsMerger::NotebookBarAddonsMerger() {} + +NotebookBarAddonsMerger::~NotebookBarAddonsMerger() {} + void NotebookBarAddonsMerger::MergeNotebookBarAddons( vcl::Window* pParent, const css::uno::Reference& m_xFrame, const NotebookBarAddonsItem& aNotebookBarAddonsItem) @@ -53,29 +75,10 @@ void NotebookBarAddonsMerger::MergeNotebookBarAddons( for (int nSecIdx = 0; nSecIdx < aExtension.getLength(); nSecIdx++) { + sal_uInt16 nItemId = 0; AddonNotebookBarItem aAddonNotebookBarItem; const css::uno::Sequence pExtension = aExtension[nSecIdx]; - for (int nRes = 0; nRes < pExtension.getLength(); nRes++) - { - if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_URL) - pExtension[nRes].Value >>= aAddonNotebookBarItem.sCommandURL; - else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_TITLE) - pExtension[nRes].Value >>= aAddonNotebookBarItem.sLabel; - else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_IMAGEID) - pExtension[nRes].Value >>= aAddonNotebookBarItem.sImageIdentifier; - else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_CONTEXT) - pExtension[nRes].Value >>= aAddonNotebookBarItem.sContext; - else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_TARGET) - pExtension[nRes].Value >>= aAddonNotebookBarItem.sTarget; - else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_CONTROLTYPE) - pExtension[nRes].Value >>= aAddonNotebookBarItem.sControlType; - else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_WIDTH) - pExtension[nRes].Value >>= aAddonNotebookBarItem.nWidth; - else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_STYLE) - pExtension[nRes].Value >>= aAddonNotebookBarItem.sStyle; - } - - sal_uInt16 nItemId = 0; + GetAddonNotebookBarItem(pExtension, aAddonNotebookBarItem); ToolBox* pToolbox = dynamic_cast(pParent); if (pToolbox) { @@ -108,7 +111,46 @@ void NotebookBarAddonsMerger::MergeNotebookBarAddons( pToolbox->SetItemImage(nItemId, sImage); } } - pToolbox->InsertSeparator(); + if (nSecIdx == aExtension.getLength() - 1) + pToolbox->InsertSeparator(); + } + } +} + +void NotebookBarAddonsMerger::MergeNotebookBarMenuAddons( + PopupMenu* pPopupMenu, sal_Int16 nItemId, const OString& sItemIdName, + NotebookBarAddonsItem& aNotebookBarAddonsItem) +{ + std::vector aImageVec = aNotebookBarAddonsItem.aImageValues; + unsigned long nIter = 0; + css::uno::Sequence> aExtension; + for (unsigned long nIdx = 0; nIdx < aNotebookBarAddonsItem.aAddonValues.size(); nIdx++) + { + aExtension = aNotebookBarAddonsItem.aAddonValues[nIdx]; + + for (int nSecIdx = 0; nSecIdx < aExtension.getLength(); nSecIdx++) + { + AddonNotebookBarItem aAddonNotebookBarItem; + Image sImage; + MenuItemBits nBits = MenuItemBits::ICON; + const css::uno::Sequence pExtension = aExtension[nSecIdx]; + + GetAddonNotebookBarItem(pExtension, aAddonNotebookBarItem); + + pPopupMenu->InsertItem(nItemId, aAddonNotebookBarItem.sLabel, nBits, sItemIdName); + pPopupMenu->SetItemCommand(nItemId, aAddonNotebookBarItem.sCommandURL); + + if (nIter < aImageVec.size()) + { + sImage = aImageVec[nIter]; + nIter++; + } + pPopupMenu->SetItemImage(nItemId, sImage); + + if (nSecIdx == aExtension.getLength() - 1) + pPopupMenu->InsertSeparator(); + + ++nItemId; } } } diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 0a4c66e0cbf1..75112c8514a4 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2170,9 +2170,9 @@ VclPtr VclBuilder::makeObject(vcl::Window *pParent, const OString & { xWindow = VclPtr::Create(pParent, WB_3DLOOK | WB_TABSTOP); } - else if (name == "NotebookBarAddonsMergePoint") + else if (name == "NotebookBarAddonsToolMergePoint") { - NotebookBarAddonsMerger aNotebookBarAddonsMerger(pParent,m_xFrame, m_pNotebookBarAddonsItem); + NotebookBarAddonsMerger::MergeNotebookBarAddons(pParent, m_xFrame, m_pNotebookBarAddonsItem); return nullptr; } else if (name == "GtkToolButton" || name == "GtkMenuToolButton" || @@ -3514,7 +3514,12 @@ void VclBuilder::insertMenuObject(PopupMenu *pParent, PopupMenu *pSubMenu, const sal_uInt16 nOldCount = pParent->GetItemCount(); sal_uInt16 nNewId = ++m_pParserState->m_nLastMenuItemId; - if (rClass == "GtkMenuItem") + if(rClass == "NotebookBarAddonsMenuMergePoint") + { + NotebookBarAddonsMerger::MergeNotebookBarMenuAddons(pParent, nNewId, rID, m_pNotebookBarAddonsItem); + m_pParserState->m_nLastMenuItemId = pParent->GetItemCount(); + } + else if (rClass == "GtkMenuItem") { OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps))); OUString aCommand(extractActionName(rProps)); -- cgit