Kaydet (Commit) dba3cd50 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#113357 cui: fix duplicate 'Formatted text [Richtext]' paste option

Prefer RTF when we have both RICHTEXT and RTF.

Change-Id: Ib4133ae4fdecc32429d89b56b0c9466dd3451522
Reviewed-on: https://gerrit.libreoffice.org/47316Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst de84816c
......@@ -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:
# -*- 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:
#
# 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:
......@@ -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) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment