summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-01-03 13:34:46 +0100
committerMichael Stahl <mstahl@redhat.com>2018-01-04 14:45:52 +0100
commit6c19af3da928dee3287ba5dd83d32c1cdcbb1b49 (patch)
tree7aef0316178630a248cbde91a6d8fab896870daa
parent3795dfafc6b3c5ea33fe246be87fefb4fe050825 (diff)
tdf#113357 cui: fix duplicate 'Formatted text [Richtext]' paste option
Prefer RTF when we have both RICHTEXT and RTF. (cherry picked from commit dba3cd508116780cf5d115f964b7311dd61e180d) Change-Id: Ib4133ae4fdecc32429d89b56b0c9466dd3451522 Reviewed-on: https://gerrit.libreoffice.org/47339 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--cui/Module_cui.mk4
-rw-r--r--cui/UITest_cui_dialogs.mk16
-rw-r--r--cui/qa/uitest/dialogs/pastedlg.py46
-rw-r--r--cui/source/dialogs/pastedlg.cxx11
4 files changed, 77 insertions, 0 deletions
diff --git a/cui/Module_cui.mk b/cui/Module_cui.mk
index 888cd2a9f3cd..58026c6939fd 100644
--- a/cui/Module_cui.mk
+++ b/cui/Module_cui.mk
@@ -26,4 +26,8 @@ $(eval $(call gb_Module_add_screenshot_targets,cui,\
CppunitTest_cui_dialogs_test_4 \
))
+$(eval $(call gb_Module_add_uicheck_targets,cui,\
+ UITest_cui_dialogs \
+))
+
# vim: set noet sw=4 ts=4:
diff --git a/cui/UITest_cui_dialogs.mk b/cui/UITest_cui_dialogs.mk
new file mode 100644
index 000000000000..d3ad2dc64102
--- /dev/null
+++ b/cui/UITest_cui_dialogs.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_UITest_UITest,cui_dialogs))
+
+$(eval $(call gb_UITest_add_modules,cui_dialogs,$(SRCDIR)/cui/qa/uitest,\
+ dialogs/ \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/cui/qa/uitest/dialogs/pastedlg.py b/cui/qa/uitest/dialogs/pastedlg.py
new file mode 100644
index 000000000000..93973178c254
--- /dev/null
+++ b/cui/qa/uitest/dialogs/pastedlg.py
@@ -0,0 +1,46 @@
+#
+# 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 libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+
+
+# Test for SvPasteObjectDialog.
+class Test(UITestCase):
+
+ def testGetFormat(self):
+ # Copy a string in Impress.
+ self.ui_test.create_doc_in_start_center("impress")
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("cancel"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+ # Select the title shape.
+ editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+ editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
+ self.xUITest.executeCommand(".uno:SelectAll")
+ self.xUITest.executeCommand(".uno:Copy")
+
+ # Now use paste special to see what formats are offered.
+ self.ui_test.execute_dialog_through_command(".uno:PasteSpecial")
+ pasteSpecial = self.xUITest.getTopFocusWindow()
+ formats = pasteSpecial.getChild("list")
+ entryCount = int(get_state_as_dict(formats)["EntryCount"])
+ items = []
+ for index in range(entryCount):
+ formats.executeAction("SELECT", mkPropertyValues({"POS": str(index)}))
+ items.append(get_state_as_dict(formats)["SelectEntryText"])
+
+ # Make sure there is no RTF vs Richtext duplication.
+ self.assertTrue("Formatted text [RTF]" in items)
+ self.assertFalse("Formatted text [Richtext]" in items)
+
+ # Close the dialog and the document.
+ self.ui_test.close_dialog_through_button(pasteSpecial.getChild("cancel"))
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx
index 721cf06e1821..33fafa758654 100644
--- a/cui/source/dialogs/pastedlg.cxx
+++ b/cui/source/dialogs/pastedlg.cxx
@@ -161,6 +161,17 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe
else if( aName.isEmpty() )
aName = SvPasteObjectHelper::GetSotFormatUIName( nFormat );
+ // Show RICHTEXT only in case RTF is not present.
+ if (nFormat == SotClipboardFormatId::RICHTEXT)
+ {
+ auto it = std::find_if(pFormats->begin(), pFormats->end(),
+ [](const DataFlavorEx& rFlavor) {
+ return rFlavor.mnSotId == SotClipboardFormatId::RTF;
+ });
+ if (it != pFormats->end())
+ continue;
+ }
+
if( LISTBOX_ENTRY_NOTFOUND == ObjectLB().GetEntryPos( aName ) )
ObjectLB().SetEntryData(
ObjectLB().InsertEntry( aName ), reinterpret_cast<void*>(nFormat) );