# -*- 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 from com.sun.star.view import XSelectionChangeListener import unohelper
selectionChangedResult = 0
class XSelectionChangeListenerExtended(unohelper.Base, XSelectionChangeListener): # is invoked when a text selected, e.g. by selecting a bookmark in the Navigator
@classmethod def selectionChanged(self, event): global selectionChangedResult
selection = event.Source.getSelection() if selection.supportsService("com.sun.star.text.TextRanges"):
textRange = selection[0] if textRange.getString() == "foo":
selectionChangedResult = 1 else:
selectionChangedResult = -1
@classmethod def disposing(self, event): pass
class tdf154521(UITestCase):
def test_tdf154521(self): global selectionChangedResult with self.ui_test.create_doc_in_start_center("writer") as xDoc:
# wait for handling the selectionChanged event while selectionChangedResult == 0: pass
# This was -1 (missing selection because of early broadcasting)
self.assertEqual(selectionChangedResult, 1)
self.xUITest.executeCommand(".uno:Sidebar")
def getTitle(self, document):
xController = document.getCurrentController()
xSidebar = xController.getSidebar()
xDecks = xSidebar.getDecks()
xNavigator = xDecks['NavigatorDeck']
xPanels = xNavigator.getPanels()
xPanel = xPanels['SwNavigatorPanel']
title = xPanel.getTitle() # empty title of SwNavigatorPanel to allow to query the name of the selected bookmark
xPanel.setTitle("") return title
def test_query_selected_bookmark(self): global selectionChangedResult with self.ui_test.create_doc_in_start_center("writer") as xDoc:
# # get the title of SwNavigatorPanel with emptying it to access to the selected bookmark # self.assertEqual(self.getTitle(xDoc), "Navigator") # # title was emptied # self.assertEqual(self.getTitle(xDoc), "")
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.