From 2452a8caac6dbec2cf3d140c67a59f78a0b48404 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 14 Jun 2021 17:21:55 +0100 Subject: gtk4: create separators on menu import by appending a new section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit where we have established that we always have a section in a menu to close when opening a new one Change-Id: I8af90dd89281dd0f10bcec5665d96412108cb5d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117179 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/unx/gtk4/convert3to4.cxx | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'vcl/unx/gtk4') diff --git a/vcl/unx/gtk4/convert3to4.cxx b/vcl/unx/gtk4/convert3to4.cxx index a27172b3d3b4..cbec6f838c8a 100644 --- a/vcl/unx/gtk4/convert3to4.cxx +++ b/vcl/unx/gtk4/convert3to4.cxx @@ -136,11 +136,9 @@ struct MenuEntry } }; -MenuEntry ConvertMenu(const css::uno::Reference& xOutMenu, +MenuEntry ConvertMenu(css::uno::Reference& xMenuSection, const css::uno::Reference& xNode) { - css::uno::Reference xMenu(xOutMenu); - bool bDrawAsRadio = false; css::uno::Reference xPropertyLabel; @@ -165,7 +163,7 @@ MenuEntry ConvertMenu(const css::uno::Reference& xOutMenu, auto xNextChild = xChild->getNextSibling(); - auto xCurrentMenu = xMenu; + auto xCurrentMenuSection = xMenuSection; if (xChild->getNodeName() == "object") { @@ -179,11 +177,20 @@ MenuEntry ConvertMenu(const css::uno::Reference& xOutMenu, { /* */ css::uno::Reference xItem = xDoc->createElement("item"); - xMenu->appendChild(xItem); + xMenuSection->appendChild(xItem); + } + else if (sClass == "GtkSeparatorMenuItem") + { + /*
*/ + css::uno::Reference xSection + = xDoc->createElement("section"); + xMenuSection->getParentNode()->appendChild(xSection); + xMenuSection = xSection; + xCurrentMenuSection = xMenuSection; } else if (sClass == "GtkMenu") { - xMenu->removeChild(xMenu->getLastChild()); // remove preceding + xMenuSection->removeChild(xMenuSection->getLastChild()); // remove preceding css::uno::Reference xSubMenu = xDoc->createElement("submenu"); @@ -194,13 +201,13 @@ MenuEntry ConvertMenu(const css::uno::Reference& xOutMenu, xIdAttr->setValue(sId); xSubMenu->setAttributeNode(xIdAttr); - xMenu->appendChild(xSubMenu); + xMenuSection->appendChild(xSubMenu); css::uno::Reference xSection = xDoc->createElement("section"); xSubMenu->appendChild(xSection); - xMenu = xSubMenu; + xMenuSection = xSubMenu; } } @@ -208,14 +215,14 @@ MenuEntry ConvertMenu(const css::uno::Reference& xOutMenu, css::uno::Reference xChildPropertyLabel; if (xChild->hasChildNodes()) { - MenuEntry aEntry = ConvertMenu(xMenu, xChild); + MenuEntry aEntry = ConvertMenu(xMenuSection, xChild); bChildDrawAsRadio = aEntry.m_bDrawAsRadio; xChildPropertyLabel = aEntry.m_xPropertyLabel; } if (xChild->getNodeName() == "object") { - xMenu = xCurrentMenu; + xMenuSection = xCurrentMenuSection; auto xDoc = xChild->getOwnerDocument(); @@ -233,7 +240,7 @@ MenuEntry ConvertMenu(const css::uno::Reference& xOutMenu, menu.action id */ - auto xItem = xMenu->getLastChild(); + auto xItem = xMenuSection->getLastChild(); if (xChildPropertyLabel) { @@ -874,7 +881,8 @@ ConvertResult Convert3To4(const css::uno::Reference& xNode = xDoc->createElement("section"); xMenu->appendChild(xSection); - ConvertMenu(xSection, xChild); + css::uno::Reference xMenuSection(xSection); + ConvertMenu(xMenuSection, xChild); // now remove GtkMenu contents while (true) -- cgit