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
117 class COMPHELPER_DLLPUBLIC OAccessibleTextHelper : public cppu::ImplInheritanceHelper<
118 OAccessibleExtendedComponentHelper,
119 css::accessibility::XAccessibleText>,
121 {
122 private:
125 void operator =(OAccessibleTextHelper const &) = delete;
126 void operator =(OAccessibleTextHelper &&) = delete;
127
128 protected:
130
131 public:
132 // XAccessibleText
133 virtual OUString SAL_CALL getSelectedText() override;
134 virtual sal_Int32 SAL_CALL getSelectionStart() override;
135 virtual sal_Int32 SAL_CALL getSelectionEnd() override;
136 virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
137 virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
138 virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
139 };
140
141
142} // namespace comphelper
143
144
145// OAccessibleTextHelper is a helper class for implementing the
146// XAccessibleText interface.
147
148// The following methods have a default implementation:
149
150// getCharacter
151// getSelectedText
152// getSelectionStart
153// getSelectionEnd
154// getTextRange
155// getTextAtIndex
156// getTextBeforeIndex
157// getTextBehindIndex
158
159// The following methods must be overridden by derived classes:
160
161// implGetText
162// implGetLocale
163// implGetSelection
164// getCaretPosition
165// setCaretPosition
166// getCharacterAttributes
167// getCharacterBounds
168// getIndexAtPoint
169// setSelection
170// copyText
171
172#endif // INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a helper class for implementing an AccessibleExtendedComponent which at the same time supports an XAc...
OAccessibleTextHelper(OAccessibleTextHelper &&)=delete
OAccessibleTextHelper(OAccessibleTextHelper const &)=delete
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_uInt16 sal_Unicode