diff options
author | Jim Raykowski <raykowj@gmail.com> | 2024-02-09 20:48:02 -0900 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2024-02-15 20:37:54 +0100 |
commit | 60e37a4b85226f7a4430cd98347724a4ef0bde66 (patch) | |
tree | b7d63874e8fc5c082ad4590803402025c73f6c8a /sd | |
parent | 8da681e5ef48606716219b2a4919ee90bf7a0d6b (diff) |
tdf#128787 sd: Make StyleNewByExample and StyleUpdateByExample work
when no arguments are supplied
Change-Id: I245aa0f6b212e049dce6bdf9e079495119aeadbb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163208
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/uitest/data/tdf128787.odp | bin | 0 -> 12282 bytes | |||
-rw-r--r-- | sd/qa/uitest/impress_tests2/tdf128787.py | 48 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 31 |
3 files changed, 74 insertions, 5 deletions
diff --git a/sd/qa/uitest/data/tdf128787.odp b/sd/qa/uitest/data/tdf128787.odp Binary files differnew file mode 100644 index 000000000000..d21bbbeaaefb --- /dev/null +++ b/sd/qa/uitest/data/tdf128787.odp diff --git a/sd/qa/uitest/impress_tests2/tdf128787.py b/sd/qa/uitest/impress_tests2/tdf128787.py new file mode 100644 index 000000000000..78cb03c367d4 --- /dev/null +++ b/sd/qa/uitest/impress_tests2/tdf128787.py @@ -0,0 +1,48 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, select_by_text + +class tdf128787(UITestCase): + + def test_tdf128787(self): + with self.ui_test.load_file(get_url_for_data_file("tdf128787.odp")) as document: + xImpressDoc = self.xUITest.getTopFocusWindow() + xEditWin = xImpressDoc.getChild("impress_win") + + # Without opening the StyleListPanel, executing_dialog_through_command + # .uno:StyleNewByExample doesn't work as expected in the test environment. + # Perhaps this is required so the styles are loaded. The sidebar can be closed after + # this and .uno:StyleNewByExample will work but for this test this is not wanted. + xEditWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"})) + + # wait until the template panel is available + xTemplatePanel = self.ui_test.wait_until_child_is_available('TemplatePanel') + + # select the image + xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Image 1"})) + + # New Style from Selection [uno:StyleNewByExample] + with self.ui_test.execute_dialog_through_command(".uno:StyleNewByExample") as xDialog: + # Enter a name in the Create Style dialog and press OK + stylename = xDialog.getChild("stylename") + stylename.executeAction("TYPE", mkPropertyValues({"TEXT": "New Style"})) + + # make sure filter is set "Hierarchical"' so the 'treeview' tree is used + xFilter = xTemplatePanel.getChild('filter') + select_by_text(xFilter, "Hierarchical") + + xTreeView = xTemplatePanel.getChild('treeview') + # "New Style" should be the first child of the first child in the tree + xItem = xTreeView.getChild(0).getChild(0) + self.assertEqual("New Style", get_state_as_dict(xItem)['Text']) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 04651d87fe2f..84778fd2dbf5 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -193,6 +193,8 @@ #include <ViewShellBase.hxx> #include <memory> +#include <sfx2/newstyle.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -3163,7 +3165,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) case SID_STYLE_UPDATE_BY_EXAMPLE: case SID_STYLE_NEW_BY_EXAMPLE: { - if( rReq.GetSlot() == SID_STYLE_EDIT && !rReq.GetArgs() ) + if (!rReq.GetArgs() + && (nSId == SID_STYLE_EDIT || nSId == SID_STYLE_UPDATE_BY_EXAMPLE + || nSId == SID_STYLE_NEW_BY_EXAMPLE)) { SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet(); if( pStyleSheet && pStyleSheet->GetFamily() == SfxStyleFamily::Page) @@ -3186,11 +3190,28 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SfxAllItemSet aSet(GetDoc()->GetPool()); - SfxStringItem aStyleNameItem( SID_STYLE_EDIT, pStyleSheet->GetName() ); - aSet.Put(aStyleNameItem); + aSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, + static_cast<sal_uInt16>(pStyleSheet->GetFamily()))); - SfxUInt16Item aStyleFamilyItem( SID_STYLE_FAMILY, static_cast<sal_uInt16>(pStyleSheet->GetFamily()) ); - aSet.Put(aStyleFamilyItem); + if (nSId == SID_STYLE_NEW_BY_EXAMPLE) + { + weld::Window* pWindow = GetViewFrame()->GetFrameWeld(); + SfxNewStyleDlg aDlg(pWindow, *pStyleSheet->GetPool(), pStyleSheet->GetFamily()); + auto nResult = aDlg.run(); + if (nResult == RET_OK) + { + aSet.Put(SfxStringItem(SID_STYLE_NEW_BY_EXAMPLE, aDlg.GetName())); + aSet.Put(SfxStringItem(SID_STYLE_REFERENCE, pStyleSheet->GetName())); + } + else + { + Cancel(); + rReq.Ignore(); + break; + } + } + else + aSet.Put(SfxStringItem(nSId, pStyleSheet->GetName())); rReq.SetArgs(aSet); } |