summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-06-14 17:21:55 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-06-14 20:44:10 +0200
commit2452a8caac6dbec2cf3d140c67a59f78a0b48404 (patch)
tree08740974fa1444fd031f17f7357d4409cc58ed44
parent01251c89a15116776e7f5bea93c706443b40c4da (diff)
gtk4: create separators on menu import by appending a new section
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 <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk4/convert3to4.cxx32
1 files changed, 20 insertions, 12 deletions
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<css::xml::dom::XNode>& xOutMenu,
+MenuEntry ConvertMenu(css::uno::Reference<css::xml::dom::XNode>& xMenuSection,
const css::uno::Reference<css::xml::dom::XNode>& xNode)
{
- css::uno::Reference<css::xml::dom::XNode> xMenu(xOutMenu);
-
bool bDrawAsRadio = false;
css::uno::Reference<css::xml::dom::XNode> xPropertyLabel;
@@ -165,7 +163,7 @@ MenuEntry ConvertMenu(const css::uno::Reference<css::xml::dom::XNode>& 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<css::xml::dom::XNode>& xOutMenu,
{
/* <item> */
css::uno::Reference<css::xml::dom::XElement> xItem = xDoc->createElement("item");
- xMenu->appendChild(xItem);
+ xMenuSection->appendChild(xItem);
+ }
+ else if (sClass == "GtkSeparatorMenuItem")
+ {
+ /* <section> */
+ css::uno::Reference<css::xml::dom::XElement> xSection
+ = xDoc->createElement("section");
+ xMenuSection->getParentNode()->appendChild(xSection);
+ xMenuSection = xSection;
+ xCurrentMenuSection = xMenuSection;
}
else if (sClass == "GtkMenu")
{
- xMenu->removeChild(xMenu->getLastChild()); // remove preceding <item>
+ xMenuSection->removeChild(xMenuSection->getLastChild()); // remove preceding <item>
css::uno::Reference<css::xml::dom::XElement> xSubMenu
= xDoc->createElement("submenu");
@@ -194,13 +201,13 @@ MenuEntry ConvertMenu(const css::uno::Reference<css::xml::dom::XNode>& xOutMenu,
xIdAttr->setValue(sId);
xSubMenu->setAttributeNode(xIdAttr);
- xMenu->appendChild(xSubMenu);
+ xMenuSection->appendChild(xSubMenu);
css::uno::Reference<css::xml::dom::XElement> xSection
= xDoc->createElement("section");
xSubMenu->appendChild(xSection);
- xMenu = xSubMenu;
+ xMenuSection = xSubMenu;
}
}
@@ -208,14 +215,14 @@ MenuEntry ConvertMenu(const css::uno::Reference<css::xml::dom::XNode>& xOutMenu,
css::uno::Reference<css::xml::dom::XNode> 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<css::xml::dom::XNode>& xOutMenu,
<attribute name='action'>menu.action</attribute>
<attribute name='target'>id</attribute>
*/
- auto xItem = xMenu->getLastChild();
+ auto xItem = xMenuSection->getLastChild();
if (xChildPropertyLabel)
{
@@ -874,7 +881,8 @@ ConvertResult Convert3To4(const css::uno::Reference<css::xml::dom::XNode>& xNode
= xDoc->createElement("section");
xMenu->appendChild(xSection);
- ConvertMenu(xSection, xChild);
+ css::uno::Reference<css::xml::dom::XNode> xMenuSection(xSection);
+ ConvertMenu(xMenuSection, xChild);
// now remove GtkMenu contents
while (true)