LibreOffice Module comphelper (master) 1
accessibletexthelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
21#define INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
22
23#include <com/sun/star/accessibility/XAccessibleText.hpp>
24#include <com/sun/star/accessibility/TextSegment.hpp>
28
29namespace com::sun::star::i18n { class XBreakIterator; }
30namespace com::sun::star::i18n { class XCharacterClassification; }
31namespace com::sun::star::i18n { struct Boundary; }
32
33namespace comphelper
34{
35
36
37 // OCommonAccessibleText
38
43 {
44 private:
45 css::uno::Reference < css::i18n::XBreakIterator > m_xBreakIter;
46 css::uno::Reference < css::i18n::XCharacterClassification > m_xCharClass;
47
48 protected:
50 virtual ~OCommonAccessibleText();
51
52 css::uno::Reference < css::i18n::XBreakIterator > const & implGetBreakIterator();
53 css::uno::Reference < css::i18n::XCharacterClassification > const & implGetCharacterClassification();
54 static bool implIsValidBoundary( css::i18n::Boundary const & rBoundary, sal_Int32 nLength );
55 static bool implIsValidIndex( sal_Int32 nIndex, sal_Int32 nLength );
56 static bool implIsValidRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex, sal_Int32 nLength );
57 static sal_Unicode implGetCharacter( std::u16string_view rText, sal_Int32 nIndex );
58 static OUString implGetTextRange( std::u16string_view rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex );
59 virtual OUString implGetText() = 0;
60 virtual css::lang::Locale implGetLocale() = 0;
61 virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) = 0;
62 void implGetGlyphBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
63 bool implGetWordBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
64 void implGetSentenceBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
65 virtual void implGetParagraphBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
66 virtual void implGetLineBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
67
73 OUString getSelectedText();
75 sal_Int32 getSelectionStart();
77 sal_Int32 getSelectionEnd();
81 css::accessibility::TextSegment getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType );
85 css::accessibility::TextSegment getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType );
89 css::accessibility::TextSegment getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType );
90
91 public:
92
103 static bool implInitTextChangedEvent(
104 std::u16string_view rOldString,
105 std::u16string_view rNewString,
106 /*out*/ css::uno::Any& rDeleted,
107 /*out*/ css::uno::Any& rInserted); // throw()
108 };
109
110
111 // OAccessibleTextHelper
112
113
114 typedef ::cppu::ImplHelper1 < css::accessibility::XAccessibleText
116
123 {
124 protected:
126
127 public:
128 // XInterface
130
131 // XTypeProvider
133
134 // XAccessibleText
135 virtual OUString SAL_CALL getSelectedText() override;
136 virtual sal_Int32 SAL_CALL getSelectionStart() override;
137 virtual sal_Int32 SAL_CALL getSelectionEnd() override;
138 virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
139 virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
140 virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
141 };
142
143
144} // namespace comphelper
145
146
147// OAccessibleTextHelper is a helper class for implementing the
148// XAccessibleText interface.
149
150// The following methods have a default implementation:
151
152// getCharacter
153// getSelectedText
154// getSelectionStart
155// getSelectionEnd
156// getTextRange
157// getTextAtIndex
158// getTextBeforeIndex
159// getTextBehindIndex
160
161// The following methods must be overridden by derived classes:
162
163// implGetText
164// implGetLocale
165// implGetSelection
166// getCaretPosition
167// setCaretPosition
168// getCharacterAttributes
169// getCharacterBounds
170// getIndexAtPoint
171// setSelection
172// copyText
173
174#endif // INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
175
176/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a helper class for implementing an AccessibleContext which at the same time supports an XAccessibleEx...
a helper class for implementing an AccessibleExtendedComponent which at the same time supports an XAc...
base class encapsulating common functionality for the helper classes implementing the XAccessibleText
css::uno::Reference< css::i18n::XBreakIterator > m_xBreakIter
virtual OUString implGetText()=0
virtual void implGetSelection(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex)=0
virtual css::lang::Locale implGetLocale()=0
css::uno::Reference< css::i18n::XCharacterClassification > m_xCharClass
#define COMPHELPER_DLLPUBLIC
sal_Int32 nIndex
::cppu::ImplHelper1< css::accessibility::XAccessibleText > OAccessibleTextHelper_Base
sal_uInt16 sal_Unicode
#define DECLARE_XTYPEPROVIDER()
Definition: uno3.hxx:126
#define DECLARE_XINTERFACE()
Definition: uno3.hxx:90