1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
21 #define INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
23 #include <com/sun/star/accessibility/XAccessibleText.hpp>
24 #include <com/sun/star/accessibility/TextSegment.hpp>
25 #include <com/sun/star/i18n/XBreakIterator.hpp>
26 #include <com/sun/star/i18n/XCharacterClassification.hpp>
27 #include <comphelper/accessiblecomponenthelper.hxx>
28 #include <cppuhelper/implbase1.hxx>
29 #include <comphelper/comphelperdllapi.h>
32 //..............................................................................
35 //..............................................................................
37 //==============================================================================
38 // OCommonAccessibleText
39 //==============================================================================
40 /** base class encapsulating common functionality for the helper classes implementing
43 class COMPHELPER_DLLPUBLIC OCommonAccessibleText
46 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
> m_xBreakIter
;
47 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XCharacterClassification
> m_xCharClass
;
50 OCommonAccessibleText();
51 virtual ~OCommonAccessibleText();
53 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
> implGetBreakIterator();
54 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XCharacterClassification
> implGetCharacterClassification();
55 sal_Bool
implIsValidBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32 nLength
);
56 virtual sal_Bool
implIsValidIndex( sal_Int32 nIndex
, sal_Int32 nLength
);
57 virtual sal_Bool
implIsValidRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
, sal_Int32 nLength
);
58 virtual OUString
implGetText() = 0;
59 virtual ::com::sun::star::lang::Locale
implGetLocale() = 0;
60 virtual void implGetSelection( sal_Int32
& nStartIndex
, sal_Int32
& nEndIndex
) = 0;
61 virtual void implGetGlyphBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32 nIndex
);
62 virtual sal_Bool
implGetWordBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32 nIndex
);
63 virtual void implGetSentenceBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32 nIndex
);
64 virtual void implGetParagraphBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32 nIndex
);
65 virtual void implGetLineBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32 nIndex
);
67 /** non-virtual versions of the methods
69 sal_Unicode SAL_CALL
getCharacter( sal_Int32 nIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
70 sal_Int32 SAL_CALL
getCharacterCount() throw (::com::sun::star::uno::RuntimeException
);
71 OUString SAL_CALL
getSelectedText() throw (::com::sun::star::uno::RuntimeException
);
72 sal_Int32 SAL_CALL
getSelectionStart() throw (::com::sun::star::uno::RuntimeException
);
73 sal_Int32 SAL_CALL
getSelectionEnd() throw (::com::sun::star::uno::RuntimeException
);
74 OUString SAL_CALL
getText() throw (::com::sun::star::uno::RuntimeException
);
75 OUString SAL_CALL
getTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
76 ::com::sun::star::accessibility::TextSegment SAL_CALL
getTextAtIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
77 ::com::sun::star::accessibility::TextSegment SAL_CALL
getTextBeforeIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
78 ::com::sun::star::accessibility::TextSegment SAL_CALL
getTextBehindIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
82 /** Helper method, that detects the difference between
83 two strings and returns the deleted selection and
84 the inserted selection if available.
86 @returns true if there are differences between the
87 two strings and false if both are equal
89 @see ::com::sun::star::accessibility::AccessibleEventId
90 ::com::sun::star::accessibility::TextSegment
92 static bool implInitTextChangedEvent(
93 const OUString
& rOldString
,
94 const OUString
& rNewString
,
95 /*out*/ ::com::sun::star::uno::Any
& rDeleted
,
96 /*out*/ ::com::sun::star::uno::Any
& rInserted
); // throw()
100 //==============================================================================
101 // OAccessibleTextHelper
102 //==============================================================================
104 typedef ::cppu::ImplHelper1
< ::com::sun::star::accessibility::XAccessibleText
105 > OAccessibleTextHelper_Base
;
107 /** a helper class for implementing an AccessibleExtendedComponent which at the same time
108 supports an XAccessibleText interface
110 class COMPHELPER_DLLPUBLIC OAccessibleTextHelper
: public OAccessibleExtendedComponentHelper
,
111 public OCommonAccessibleText
,
112 public OAccessibleTextHelper_Base
115 // see the respective base class ctor for an extensive comment on this, please
116 OAccessibleTextHelper( IMutex
* _pExternalLock
);
120 DECLARE_XINTERFACE( )
123 DECLARE_XTYPEPROVIDER( )
126 virtual sal_Unicode SAL_CALL
getCharacter( sal_Int32 nIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
127 virtual sal_Int32 SAL_CALL
getCharacterCount() throw (::com::sun::star::uno::RuntimeException
);
128 virtual OUString SAL_CALL
getSelectedText() throw (::com::sun::star::uno::RuntimeException
);
129 virtual sal_Int32 SAL_CALL
getSelectionStart() throw (::com::sun::star::uno::RuntimeException
);
130 virtual sal_Int32 SAL_CALL
getSelectionEnd() throw (::com::sun::star::uno::RuntimeException
);
131 virtual OUString SAL_CALL
getText() throw (::com::sun::star::uno::RuntimeException
);
132 virtual OUString SAL_CALL
getTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
133 virtual ::com::sun::star::accessibility::TextSegment SAL_CALL
getTextAtIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
134 virtual ::com::sun::star::accessibility::TextSegment SAL_CALL
getTextBeforeIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
135 virtual ::com::sun::star::accessibility::TextSegment SAL_CALL
getTextBehindIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
138 //..............................................................................
139 } // namespace comphelper
140 //..............................................................................
142 #endif // INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
145 // -----------------------------------------------------------------------------
147 // OAccessibleTextHelper is a helper class for implementing the
148 // XAccessibleText interface.
150 // The following methods have a default implementation:
160 // getTextBeforeIndex
161 // getTextBehindIndex
163 // The following methods must be overriden by derived classes:
170 // getCharacterAttributes
171 // getCharacterBounds
176 // -----------------------------------------------------------------------------
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */