blob: c145c7b2c85826a4f85abe50eee43a1d5534d6ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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/.
*/
#include <com/sun/star/accessibility/XAccessibleTextMarkup.hpp>
#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
#include <com/sun/star/linguistic2/XLinguServiceManager2.hpp>
#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
#include <com/sun/star/text/TextMarkupType.hpp>
#include <i18nlangtag/lang.h>
#include <vcl/scheduler.hxx>
#include <test/a11y/swaccessibletestbase.hxx>
#include <test/a11y/AccessibilityTools.hxx>
using namespace css;
/* This test only works if spell checking is available for en_US */
CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, tdf155705)
{
loadFromSrc(u"/sw/qa/extras/accessibility/testdocuments/tdf155705.fodt"_ustr);
/* we need to give it a second to fully set up the XAccessibleTextMarkup, otherwise we get a
* dysfunctional one that asserts out on m_pTextFrame */
Scheduler::ProcessEventsToIdle();
uno::Reference<linguistic2::XLinguServiceManager2> xLSM2
= linguistic2::LinguServiceManager::create(m_xContext);
uno::Reference<linguistic2::XSpellChecker1> xSpell(xLSM2->getSpellChecker(), uno::UNO_QUERY);
if (!xSpell.is() || !xSpell->hasLanguage(static_cast<sal_uInt16>(LANGUAGE_ENGLISH_US)))
return;
auto xContext = getDocumentAccessibleContext();
CPPUNIT_ASSERT(xContext.is());
auto xChildContext = getAllChildren(xContext).back();
uno::Reference<accessibility::XAccessibleTextMarkup> xMarkup(xChildContext,
uno::UNO_QUERY_THROW);
// make sure the idle spellcheck pass runs
AccessibilityTools::Await(
[&xMarkup]() { return 0 < xMarkup->getTextMarkupCount(text::TextMarkupType::SPELLCHECK); });
CPPUNIT_ASSERT_GREATER(sal_Int32(0),
xMarkup->getTextMarkupCount(text::TextMarkupType::SPELLCHECK));
auto aSegment = xMarkup->getTextMarkup(0, text::TextMarkupType::SPELLCHECK);
CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(0), aSegment.SegmentStart);
CPPUNIT_ASSERT_GREATER(aSegment.SegmentStart, aSegment.SegmentEnd);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|