27#include <rtl/ustrbuf.hxx>
32#include <com/sun/star/accessibility/AccessibleScrollType.hpp>
33#include <com/sun/star/accessibility/AccessibleTextType.hpp>
34#include <com/sun/star/accessibility/XAccessible.hpp>
35#include <com/sun/star/accessibility/XAccessibleContext.hpp>
36#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
37#include <com/sun/star/accessibility/XAccessibleTextSelection.hpp>
40using namespace css::accessibility;
41using namespace css::uno;
50 return com::sun::star::accessibility::AccessibleTextType::CHARACTER;
52 return com::sun::star::accessibility::AccessibleTextType::WORD;
54 return com::sun::star::accessibility::AccessibleTextType::SENTENCE;
56 return com::sun::star::accessibility::AccessibleTextType::PARAGRAPH;
58 return com::sun::star::accessibility::AccessibleTextType::LINE;
62 &&
"No match for IA2_TEXT_BOUNDARY_ALL, handle at call site.");
68 SAL_WARN(
"iacc2",
"Unmatched text boundary type: " << boundaryType);
101 Reference<XAccessibleContext> pRContext =
pUNOInterface->getAccessibleContext();
103 Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY);
105 if( pRExtension.is() )
116 }
catch(...) {
return E_FAIL; }
127COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_attributes(
long offset,
long * startOffset,
long * endOffset, BSTR * textAttributes)
141 if( offset < 0 || offset >
GetXInterface()->getCharacterCount() )
144 OUStringBuffer strAttrs(
"Version:1;");
149 sal_Int16 numberingLevel = 0;
150 OUString numberingPrefix;
152 bool bHaveNumberingPrefixAttr =
false;
153 bool bHaveNumberingLevel =
false;
154 bool bHaveNumberingRules =
false;
158 const css::beans::PropertyValue &pValue =
pValues[
i];
159 if(pValue.Name ==
"NumberingLevel")
161 if (pValue.Value !=
Any())
162 pValue.Value >>= numberingLevel;
165 bHaveNumberingLevel =
true;
168 if(pValue.Name ==
"NumberingPrefix")
170 pValue.Value >>=numberingPrefix;
171 bHaveNumberingPrefixAttr =
true;
174 if(pValue.Name ==
"NumberingRules")
176 bHaveNumberingRules =
true;
177 anyNumRule = pValue.Value;
180 if (bHaveNumberingLevel && bHaveNumberingRules && bHaveNumberingPrefixAttr)
182 strAttrs.append(
';');
183 numberingPrefix = numberingPrefix.replaceAll(u
"\\", u
"\\\\")
184 .replaceAll(u
";", u
"\\;")
185 .replaceAll(u
"=", u
"\\=")
186 .replaceAll(u
",", u
"\\,")
187 .replaceAll(u
":", u
"\\:");
190 bHaveNumberingLevel =
false;
191 bHaveNumberingRules =
false;
193 if( (bHaveNumberingPrefixAttr && i > 1 ) ||
194 (!bHaveNumberingPrefixAttr && i > 0 ) )
196 strAttrs.append(
';');
198 strAttrs.append(pValue.Name +
":");
200 if (pValue.Name ==
"CharBackColor" ||
201 pValue.Name ==
"CharColor" ||
202 pValue.Name ==
"CharUnderlineColor" )
204 unsigned long nColor;
205 pValue.Value >>= nColor;
206 strAttrs.append(
'#');
207 OUString
const hex = OUString::number(nColor, 16).toAsciiUpperCase();
208 for (sal_Int32 j = hex.getLength(); j < 8; ++j) {
209 strAttrs.append(
'0');
211 strAttrs.append(hex);
218 strAttrs.append(
';');
222 *
textAttributes = SysAllocString(o3tl::toW(strAttrs.makeStringAndClear().getStr()));
226 TextSegment textSeg =
GetXInterface()->getTextAtIndex(
offset, AccessibleTextType::ATTRIBUTE_RUN);
238 }
catch(...) {
return E_FAIL; }
264 }
catch(...) {
return E_FAIL; }
278 if (nCharacters ==
nullptr)
290 }
catch(...) {
return E_FAIL; }
302COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_characterExtents(
long offset,
IA2CoordinateType coordType,
long * x,
long * y,
long * width,
long * height)
308 if (
x ==
nullptr ||
height ==
nullptr ||
y ==
nullptr ||
width ==
nullptr)
314 if(offset < 0 || offset >
GetXInterface()->getCharacterCount() )
321 css::awt::Point aPoint;
323 Reference<XAccessibleContext> pRContext =
pUNOInterface->getAccessibleContext();
324 if( !pRContext.is() )
328 Reference<XAccessibleComponent> pRComp(pRContext,UNO_QUERY);
333 css::awt::Point
pt = pRComp->getLocationOnScreen();
339 css::awt::Point
pt = pRComp->getLocation();
366 }
catch(...) {
return E_FAIL; }
380 if (nSelections ==
nullptr)
389 Reference<XAccessibleContext> pRContext =
pUNOInterface->getAccessibleContext();
391 Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY);
393 if( pRExtension.is() )
395 *nSelections = pRExtension->getSelectedPortionCount();
399 long iLength =
GetXInterface()->getSelectedText().getLength();
409 }
catch(...) {
return E_FAIL; }
432 css::awt::Point
point;
438 }
catch(...) {
return E_FAIL; }
464 if(selectionIndex >= nSelection || selectionIndex < 0 )
467 Reference<XAccessibleContext> pRContext =
pUNOInterface->getAccessibleContext();
469 Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY);
471 if( pRExtension.is() )
473 *
startOffset = pRExtension->getSeletedPositionStart(selectionIndex);
474 *
endOffset = pRExtension->getSeletedPositionEnd(selectionIndex);
488 }
catch(...) {
return E_FAIL; }
529 SysFreeString(*
text);
530 *
text = SysAllocString(o3tl::toW(ouStr.getStr()));
533 }
catch(...) {
return E_FAIL; }
545COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_textBeforeOffset(
long offset,
IA2TextBoundaryType boundaryType,
long * startOffset,
long * endOffset, BSTR * text)
567 const sal_Int16 nUnoBoundaryType = lcl_matchIA2TextBoundaryType(
boundaryType);
568 if (nUnoBoundaryType < 0)
572 OUString ouStr = segment.SegmentText;
573 SysFreeString(*
text);
574 *
text = SysAllocString(o3tl::toW(ouStr.getStr()));
580 }
catch(...) {
return E_FAIL; }
592COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_textAfterOffset(
long offset,
IA2TextBoundaryType boundaryType,
long * startOffset,
long * endOffset, BSTR * text)
613 const sal_Int16 nUnoBoundaryType = lcl_matchIA2TextBoundaryType(
boundaryType);
614 if (nUnoBoundaryType < 0)
618 OUString ouStr = segment.SegmentText;
619 SysFreeString(*
text);
620 *
text = SysAllocString(o3tl::toW(ouStr.getStr()));
626 }
catch(...) {
return E_FAIL; }
638COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_textAtOffset(
long offset,
IA2TextBoundaryType boundaryType,
long * startOffset,
long * endOffset, BSTR * text)
659 const sal_Int16 nUnoBoundaryType = lcl_matchIA2TextBoundaryType(
boundaryType);
660 if (nUnoBoundaryType < 0)
664 OUString ouStr = segment.SegmentText;
665 SysFreeString(*
text);
666 *
text = SysAllocString(o3tl::toW(ouStr.getStr()));
672 }
catch(...) {
return E_FAIL; }
693 Reference<XAccessibleContext> pRContext =
pUNOInterface->getAccessibleContext();
695 Reference< XAccessibleTextSelection > pRExtension(pRContext,UNO_QUERY);
697 if( pRExtension.is() )
699 pRExtension->removeSelection(selectionIndex);
708 }
catch(...) {
return E_FAIL; }
731 }
catch(...) {
return E_FAIL; }
758 }
catch(...) {
return E_FAIL; }
772 if (nCharacters ==
nullptr)
785 }
catch(...) {
return E_FAIL; }
805COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::scrollSubstringToPoint(
long,
long,
IA2CoordinateType,
long,
long )
820 AccessibleScrollType lUnoType;
825 lUnoType = AccessibleScrollType_SCROLL_TOP_LEFT;
828 lUnoType = AccessibleScrollType_SCROLL_BOTTOM_RIGHT;
831 lUnoType = AccessibleScrollType_SCROLL_TOP_EDGE;
834 lUnoType = AccessibleScrollType_SCROLL_BOTTOM_EDGE;
837 lUnoType = AccessibleScrollType_SCROLL_LEFT_EDGE;
840 lUnoType = AccessibleScrollType_SCROLL_RIGHT_EDGE;
843 lUnoType = AccessibleScrollType_SCROLL_ANYWHERE;
854 }
catch(...) {
return E_FAIL; }
872 Reference<XAccessibleContext> pRContext =
pUNOInterface->getAccessibleContext();
873 if( !pRContext.is() )
877 Reference<XAccessibleText> pRXI(pRContext,UNO_QUERY);
884 }
catch(...) {
return E_FAIL; }
const PropertyValue * pValues
STDMETHOD() get_nSelections(long *nSelections)
Get selections count.
css::accessibility::XAccessibleText * GetXInterface()
STDMETHOD() get_characterCount(long *nCharacters)
Get character count.
STDMETHOD() get_caretOffset(long *offset)
Get caret position.
long long long * endOffset
STDMETHOD() put_XInterface(hyper pXInterface) override
Put UNO interface.
STDMETHOD() setSelection(long selectionIndex, long startOffset, long endOffset)
Set special selection.
STDMETHOD() get_selection(long selectionIndex, long *startOffset, long *endOffset)
Get selection range.
STDMETHOD() get_text(long startOffset, long endOffset, BSTR *text)
Get special text.
long IA2TextBoundaryType boundaryType
long IA2CoordinateType long long long long * height
long IA2CoordinateType long long long * width
long IA2CoordinateType long * x
css::uno::Reference< css::accessibility::XAccessibleText > pRXText
STDMETHOD() setCaretOffset(long offset)
Set caret position.
STDMETHOD() get_addSelection(long startOffset, long endOffset)
Get special selection.
STDMETHOD() get_offsetAtPoint(long x, long y, IA2CoordinateType coordType, long *offset)
Get offset of some special point.
STDMETHOD() get_nCharacters(long *nCharacters)
Get characters count.
STDMETHOD() get_newText(IA2TextSegment *newText)
STDMETHOD() scrollSubstringTo(long startIndex, long endIndex, enum IA2ScrollType scrollType)
STDMETHOD() get_oldText(IA2TextSegment *oldText)
long IA2TextBoundaryType long long BSTR * text
long IA2CoordinateType coordType
STDMETHOD() removeSelection(long selectionIndex)
Remove selection.
long long long BSTR * textAttributes
long IA2CoordinateType long long * y
static OUString get_StringFromAny(css::uno::Any const &pAny)
static OUString get_String4Numbering(const css::uno::Any &pAny, sal_Int16 numberingLevel, std::u16string_view numberingPrefix)
STDMETHOD() put_XInterface(hyper pXInterface) override
css::accessibility::XAccessible * pUNOInterface
IA2ScrollType
These constants control the scrolling of an object or substring into a window.
@ IA2_SCROLL_TYPE_LEFT_EDGE
Scroll the left edge of the object or substring such that the left edge (and as much as possible of t...
@ IA2_SCROLL_TYPE_BOTTOM_EDGE
Scroll the bottom edge of the object or substring such that the bottom edge (and as much as possible ...
@ IA2_SCROLL_TYPE_ANYWHERE
Scroll the object or substring such that as much as possible of the object or substring is within the...
@ IA2_SCROLL_TYPE_TOP_EDGE
Scroll the top edge of the object or substring such that the top edge (and as much as possible of the...
@ IA2_SCROLL_TYPE_RIGHT_EDGE
Scroll the right edge of the object or substring such that the right edge (and as much as possible of...
@ IA2_SCROLL_TYPE_BOTTOM_RIGHT
Scroll the bottom right corner of the object or substring such that the bottom right corner (and as m...
@ IA2_SCROLL_TYPE_TOP_LEFT
Scroll the top left corner of the object or substring such that the top left corner (and as much as p...
IA2CoordinateType
These constants define which coordinate system a point is located in.
@ IA2_COORDTYPE_SCREEN_RELATIVE
The coordinates are relative to the screen.
@ IA2_COORDTYPE_PARENT_RELATIVE
The coordinates are relative to the upper left corner of the bounding box of the immediate parent.
IA2TextBoundaryType
This enum defines values which specify a text boundary type.
@ IA2_TEXT_BOUNDARY_LINE
Range is from start of one line to the start of another line.
@ IA2_TEXT_BOUNDARY_WORD
The range provided matches the range observed when the application processes the Ctrl + left arrow an...
@ IA2_TEXT_BOUNDARY_ALL
Using this value will cause all text to be returned.
@ IA2_TEXT_BOUNDARY_SENTENCE
Range is from start of one sentence to the start of another sentence.
@ IA2_TEXT_BOUNDARY_CHAR
Typically, a single character is returned.
@ IA2_TEXT_BOUNDARY_PARAGRAPH
Range is from start of one paragraph to the start of another paragraph.
#define SAL_WARN(area, stream)
A structure containing a substring and the start and end offsets in the enclosing string.