LibreOffice Module editeng (master) 1
AccessibleEditableTextPara.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_EDITENG_ACCESSIBLEEDITABLETEXTPARA_HXX
21#define INCLUDED_EDITENG_ACCESSIBLEEDITABLETEXTPARA_HXX
22
23#include <config_options.h>
24#include <rtl/ref.hxx>
25#include <rtl/ustring.hxx>
26#include <tools/gen.hxx>
28
29#include <com/sun/star/uno/Reference.hxx>
30#include <com/sun/star/lang/XServiceInfo.hpp>
31#include <com/sun/star/accessibility/AccessibleScrollType.hpp>
32#include <com/sun/star/accessibility/XAccessible.hpp>
33#include <com/sun/star/accessibility/XAccessibleContext.hpp>
34#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
35#include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
36#include <com/sun/star/accessibility/XAccessibleTextAttributes.hpp>
37#include <com/sun/star/accessibility/XAccessibleHypertext.hpp>
38#include <com/sun/star/accessibility/XAccessibleMultiLineText.hpp>
39#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
40
43#include <editeng/editdata.hxx>
45
47class MapMode;
50namespace accessibility { class AccessibleImageBullet; }
51
52namespace accessibility
53{
54 typedef ::comphelper::WeakComponentImplHelper< css::accessibility::XAccessible,
55 css::accessibility::XAccessibleContext,
56 css::accessibility::XAccessibleComponent,
57 css::accessibility::XAccessibleEditableText,
58 css::accessibility::XAccessibleEventBroadcaster,
59 css::accessibility::XAccessibleTextAttributes,
60 css::accessibility::XAccessibleHypertext,
61 css::accessibility::XAccessibleMultiLineText,
62 css::lang::XServiceInfo > AccessibleTextParaInterfaceBase;
63
66 class UNLESS_MERGELIBS(EDITENG_DLLPUBLIC) AccessibleEditableTextPara final : public AccessibleTextParaInterfaceBase, private ::comphelper::OCommonAccessibleText
67 {
68
69 // override OCommonAccessibleText methods
70 virtual OUString implGetText() override;
71 virtual css::lang::Locale implGetLocale() override;
72 virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override;
73 virtual void implGetParagraphBoundary( const OUString& rtext, css::i18n::Boundary& rBoundary, sal_Int32 nIndex ) override;
74 virtual void implGetLineBoundary( const OUString& rtext, css::i18n::Boundary& rBoundary, sal_Int32 nIndex ) override;
75
76 public:
78 // #i27138#
79 // - add parameter <_pParaManager> (default value NULL)
80 // This has to be the instance of <AccessibleParaManager>, which
81 // created and manages this accessible paragraph.
82 AccessibleEditableTextPara ( css::uno::Reference< css::accessibility::XAccessible > xParent,
83 const AccessibleParaManager* _pParaManager = nullptr );
84
85 virtual ~AccessibleEditableTextPara () override;
86
87 // XInterface
88 virtual css::uno::Any SAL_CALL queryInterface (const css::uno::Type & rType) override;
89
90 // XAccessible
91 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
92
93 // XAccessibleContext
94 virtual sal_Int64 SAL_CALL getAccessibleChildCount() override;
95 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override;
96 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override;
97 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override;
98 virtual sal_Int16 SAL_CALL getAccessibleRole() override;
100 enum { MaxDescriptionLen = 40 };
101 virtual OUString SAL_CALL getAccessibleDescription() override;
102 virtual OUString SAL_CALL getAccessibleName() override;
103 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override;
104 virtual sal_Int64 SAL_CALL getAccessibleStateSet() override;
105 virtual css::lang::Locale SAL_CALL getLocale() override;
106
107 // XAccessibleEventBroadcaster
108 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
109 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
110
111 // XAccessibleComponent
112 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
113 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
114 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
115 virtual css::awt::Point SAL_CALL getLocation( ) override;
116 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
117 virtual css::awt::Size SAL_CALL getSize( ) override;
118 virtual void SAL_CALL grabFocus( ) override;
119 virtual sal_Int32 SAL_CALL getForeground( ) override;
120 virtual sal_Int32 SAL_CALL getBackground( ) override;
121
122 // XAccessibleText (this comes implicitly inherited by XAccessibleEditableText AND by XAccessibleMultiLineText)
123 virtual sal_Int32 SAL_CALL getCaretPosition() override;
124 virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override;
125 virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override;
126 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override;
127 virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override;
128 virtual sal_Int32 SAL_CALL getCharacterCount() override;
129 virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override;
130 virtual OUString SAL_CALL getSelectedText() override;
131 virtual sal_Int32 SAL_CALL getSelectionStart() override;
132 virtual sal_Int32 SAL_CALL getSelectionEnd() override;
133 virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
134 virtual OUString SAL_CALL getText() override;
135 virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
137 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;
141 virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
142 virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
143 virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override;
144
145 // XAccessibleEditableText
146 virtual sal_Bool SAL_CALL cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
147 virtual sal_Bool SAL_CALL pasteText( sal_Int32 nIndex ) override;
148 virtual sal_Bool SAL_CALL deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
149 virtual sal_Bool SAL_CALL insertText( const OUString& sText, sal_Int32 nIndex ) override;
150 virtual sal_Bool SAL_CALL replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const OUString& sReplacement ) override;
151 virtual sal_Bool SAL_CALL setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const css::uno::Sequence< css::beans::PropertyValue >& aAttributeSet ) override;
152 virtual sal_Bool SAL_CALL setText( const OUString& sText ) override;
153
154 // XAccessibleTextAttributes
155 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getDefaultAttributes( const css::uno::Sequence< OUString >& RequestedAttributes ) override;
156 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getRunAttributes( ::sal_Int32 Index, const css::uno::Sequence< OUString >& RequestedAttributes ) override;
157
158 // XAccessibleHypertext
159 virtual ::sal_Int32 SAL_CALL getHyperLinkCount( ) override;
160 virtual css::uno::Reference< css::accessibility::XAccessibleHyperlink > SAL_CALL getHyperLink( ::sal_Int32 nLinkIndex ) override;
161 virtual ::sal_Int32 SAL_CALL getHyperLinkIndex( ::sal_Int32 nCharIndex ) override;
162
163 // XAccessibleMultiLineText
164 virtual ::sal_Int32 SAL_CALL getLineNumberAtIndex( ::sal_Int32 nIndex ) override;
165 virtual css::accessibility::TextSegment SAL_CALL getTextAtLineNumber( ::sal_Int32 nLineNo ) override;
166 virtual css::accessibility::TextSegment SAL_CALL getTextAtLineWithCaret( ) override;
167 virtual ::sal_Int32 SAL_CALL getNumberOfLineWithCaret( ) override;
168
169 // XServiceInfo
170 virtual OUString SAL_CALL getImplementationName() override;
171 virtual sal_Bool SAL_CALL supportsService (const OUString& sServiceName) override;
172 virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override;
173
181 void SetIndexInParent( sal_Int32 nIndex );
182
190 sal_Int32 GetIndexInParent() const { return mnIndexInParent; }
191
199 void SetParagraphIndex( sal_Int32 nIndex );
200
208 sal_Int32 GetParagraphIndex() const { return mnParagraphIndex; }
209
217 void SetEEOffset( const Point& rOffset );
218
226 void SetEditSource( SvxEditSourceAdapter* pEditSource );
227
232 void Dispose();
233
235 void FireEvent(const sal_Int16 nEventId, const css::uno::Any& rNewValue = css::uno::Any(), const css::uno::Any& rOldValue = css::uno::Any() ) const;
236
238 void SetState( const sal_Int64 nStateId );
240 void UnSetState( const sal_Int64 nStateId );
241
242 static tools::Rectangle LogicToPixel( const tools::Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder const & rForwarder );
243
244 SvxEditSourceAdapter& GetEditSource() const;
245
253 SvxAccessibleTextAdapter& GetTextForwarder() const;
254
262 SvxViewForwarder& GetViewForwarder() const;
263
271 bool HaveEditView() const;
272
280 SvxAccessibleTextEditViewAdapter& GetEditViewForwarder( bool bCreate = false ) const;
281
288 void TextChanged();
289
290 private:
291 AccessibleEditableTextPara( const AccessibleEditableTextPara& ) = delete;
292 AccessibleEditableTextPara& operator= ( const AccessibleEditableTextPara& ) = delete;
293
307 bool GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex );
308
309 int getNotifierClientId() const { return mnNotifierClientId; }
310
312 bool HaveChildren();
313
314 const Point& GetEEOffset() const { return maEEOffset; }
315
316 // Get text from forwarder
317 OUString GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex );
318 sal_Int32 GetTextLen() const;
319
324 bool GetSelection(sal_Int32& nStartPos, sal_Int32& nEndPos );
325
329 ESelection MakeSelection( sal_Int32 nStartEEIndex, sal_Int32 nEndEEIndex );
330 ESelection MakeSelection( sal_Int32 nEEIndex );
331 ESelection MakeCursor( sal_Int32 nEEIndex );
332
333 // check whether index value is within permitted range
334
336 void CheckIndex( sal_Int32 nIndex );
338 void CheckPosition( sal_Int32 nIndex );
340 void CheckRange( sal_Int32 nStart, sal_Int32 nEnd );
341
342 void _correctValues( css::uno::Sequence< css::beans::PropertyValue >& rValues );
343 sal_Int32 SkipField(sal_Int32 nIndex, bool bForward);
344 // get overlapped field, extend return string. Only extend forward for now
345 void ExtendByField( css::accessibility::TextSegment& Segment );
346 OUString GetFieldTypeNameAtIndex(sal_Int32 nIndex);
347 // the paragraph index in the edit engine (guarded by solar mutex)
348 sal_Int32 mnParagraphIndex;
349
350 // our current index in the parent (guarded by solar mutex)
351 sal_Int32 mnIndexInParent;
352
353 // the current edit source (guarded by solar mutex)
354 SvxEditSourceAdapter* mpEditSource;
355
356 // the possible child (for image bullets, guarded by solar mutex)
358 WeakBullet maImageBullet;
359
360 // the last string used for an Accessibility::TEXT_CHANGED event (guarded by solar mutex)
361 OUString maLastTextString;
362
363 // the offset of the underlying EditEngine from the shape/cell (guarded by solar mutex)
364 Point maEEOffset;
365
366 // the current state set (updated from SetState/UnSetState and guarded by solar mutex)
367 sal_Int64 mnStateSet;
368
370 css::uno::Reference< css::accessibility::XAccessible > mxParent;
371
373 int mnNotifierClientId;
374private:
375 // Text paragraphs should provide FLOWS_TO and FLOWS_FROM relations (#i27138#)
376 // the paragraph manager, which created this instance - is NULL, if
377 // instance isn't created by AccessibleParaManager.
378 // Needed for method <getAccessibleRelationSet()> to retrieve predecessor
379 // paragraph and the successor paragraph.
380 const AccessibleParaManager* mpParaManager;
381 };
382
383} // end of namespace accessibility
384
385#endif
386
387/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
constexpr OUStringLiteral sServiceName
unotools::WeakReference< AnimationNode > mxParent
Encapsulates the document view for the purpose of unified EditEngine/Outliner access.
Definition: unoedsrc.hxx:452
Helper class for weak object references plus implementation.
sal_Int32 nIndex
static ESelection MakeSelection(sal_Int32 nStartPara, sal_Int32 nStartIndex, sal_Int32 nEndPara, sal_Int32 nEndIndex)
::comphelper::WeakComponentImplHelper< css::accessibility::XAccessible, css::accessibility::XAccessibleContext, css::accessibility::XAccessibleComponent, css::accessibility::XAccessibleEditableText, css::accessibility::XAccessibleEventBroadcaster, css::accessibility::XAccessibleTextAttributes, css::accessibility::XAccessibleHypertext, css::accessibility::XAccessibleMultiLineText, css::lang::XServiceInfo > AccessibleTextParaInterfaceBase
void Dispose(const T &xInterface)
const LanguageTag & getLocale()
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
sal_Int16 mnParagraphIndex
unsigned char sal_Bool
sal_uInt16 sal_Unicode
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
Definition: unotext.cxx:135