20#include <com/sun/star/accessibility/AccessibleRole.hpp>
21#include <com/sun/star/accessibility/AccessibleStateType.hpp>
22#include <com/sun/star/accessibility/AccessibleTextType.hpp>
23#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
24#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
27#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
28#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
31#include <osl/diagnose.h>
44#include <document.hxx>
55 aAccName (
SmResId(RID_DOCUMENTSTR)),
59 OSL_ENSURE(
pWin,
"SmGraphicAccessible: window missing" );
69 return pView ? pView->
GetDoc() :
nullptr;
92 const sal_Int16 nAccessibleEventId,
96 AccessibleEventObject aEvt;
97 aEvt.Source =
static_cast<XAccessible *
>(
this);
98 aEvt.EventId = nAccessibleEventId;
99 aEvt.OldValue = rOldVal;
100 aEvt.NewValue = rNewVal ;
122 return aPoint.X >= 0 && aPoint.Y >= 0 &&
127 const awt::Point& aPoint )
130 XAccessible *pRes =
nullptr;
144 css::awt::Rectangle aRet;
146 aRet.X = aOutPos.
X();
147 aRet.Y = aOutPos.
Y();
148 aRet.Width = aOutSize.
Width();
149 aRet.Height = aOutSize.
Height();
160 const css::awt::Rectangle aRect(
getBounds());
161 css::awt::Point aRet;
175 css::awt::Point aScreenLoc(0, 0);
180 css::uno::Reference<css::accessibility::XAccessibleContext> xParentContext(
181 xParent->getAccessibleContext());
182 css::uno::Reference<css::accessibility::XAccessibleComponent> xParentComponent(
183 xParentContext, css::uno::UNO_QUERY);
184 OSL_ENSURE(xParentComponent.is(),
185 "WeldEditAccessible::getLocationOnScreen: no parent component!");
186 if (xParentComponent.is())
188 css::awt::Point aParentScreenLoc(xParentComponent->getLocationOnScreen());
190 aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X;
191 aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y;
243 return static_cast<sal_Int32
>(nCol);
254 throw IndexOutOfBoundsException();
279 css::uno::Reference<css::accessibility::XAccessibleContext> xParentContext(
280 xParent->getAccessibleContext());
283 if (xParentContext.is())
285 sal_Int64 nChildCount = xParentContext->getAccessibleChildCount();
286 for (sal_Int64 nChild = 0; (nChild < nChildCount) && (-1 == nRet); ++nChild)
288 css::uno::Reference<css::accessibility::XAccessible> xChild(
289 xParentContext->getAccessibleChild(nChild));
290 if (xChild.get() ==
this)
295 catch (
const css::uno::Exception&)
305 return AccessibleRole::DOCUMENT;
312 return pDoc ? pDoc->
GetText() : OUString();
329 sal_Int64 nStateSet = 0;
332 nStateSet |= AccessibleStateType::DEFUNC;
335 nStateSet |= AccessibleStateType::ENABLED;
336 nStateSet |= AccessibleStateType::FOCUSABLE;
338 nStateSet |= AccessibleStateType::FOCUSED;
340 nStateSet |= AccessibleStateType::ACTIVE;
342 nStateSet |= AccessibleStateType::SHOWING;
344 nStateSet |= AccessibleStateType::VISIBLE;
348 nStateSet |= AccessibleStateType::OPAQUE;
386 if ( !nListenerCount )
405 if (
nIndex >= aTxt.getLength())
406 throw IndexOutOfBoundsException();
414 if (
nIndex >= aTxt.getLength())
415 throw IndexOutOfBoundsException();
421 const uno::Sequence< OUString > & )
426 throw IndexOutOfBoundsException();
445 throw IndexOutOfBoundsException();
448 bool bWasBehindText = (
nIndex == aTxt.getLength());
449 if (bWasBehindText &&
nIndex)
459 OSL_ENSURE( nAccIndex >= 0,
"invalid accessible index" );
460 OSL_ENSURE(
nIndex >= nAccIndex,
"index out of range" );
464 OUString aNodeText =
aBuf.makeStringAndClear();
465 sal_Int32 nNodeIndex =
nIndex - nAccIndex;
466 if (0 <= nNodeIndex && nNodeIndex < aNodeText.getLength())
478 rDevice.
GetTextArray( aNodeText, &aXAry, 0, aNodeText.getLength() );
479 aTLPos.
AdjustX(nNodeIndex > 0 ? aXAry[nNodeIndex - 1] : 0 );
480 aSize.
setWidth( nNodeIndex > 0 ? aXAry[nNodeIndex] - aXAry[nNodeIndex - 1] : aXAry[nNodeIndex] );
486 aRes.Width = aSize.
Width();
487 aRes.Height = aSize.
Height();
493 aRes.X += aRes.Width;
521 Point aPos( aPoint.X, aPoint.Y );
526 const SmNode *pNode =
nullptr;
534 Point aTLPos ( aOffset );
540 OSL_ENSURE( pNode->
IsVisible(),
"node is not a leaf" );
543 OUString aTxt =
aBuf.makeStringAndClear();
544 OSL_ENSURE( !aTxt.isEmpty(),
"no accessible text available" );
550 rDevice.
GetTextArray( aTxt, &aXAry, 0, aTxt.getLength() );
551 for (sal_Int32
i = 0;
i < aTxt.getLength() && nRes == -1; ++
i)
553 if (aXAry[
i] + nNodeX > aPos.
X())
556 OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(),
"index out of range" );
558 "invalid accessible index" );
583 sal_Int32 nStartIndex,
584 sal_Int32 nEndIndex )
588 if (0 > nStartIndex || nStartIndex >= nLen ||
589 0 > nEndIndex || nEndIndex >= nLen)
590 throw IndexOutOfBoundsException();
601 sal_Int32 nStartIndex,
602 sal_Int32 nEndIndex )
610 sal_Int32 nStart = std::min(nStartIndex, nEndIndex);
611 sal_Int32 nEnd = std::max(nStartIndex, nEndIndex);
612 if ((nStart > aTxt.getLength()) ||
613 (nEnd > aTxt.getLength()))
614 throw IndexOutOfBoundsException();
615 return aTxt.copy( nStart, nEnd - nStart );
623 if (
nIndex > aTxt.getLength())
624 throw IndexOutOfBoundsException();
626 css::accessibility::TextSegment aResult;
627 aResult.SegmentStart = -1;
628 aResult.SegmentEnd = -1;
629 if ( (AccessibleTextType::CHARACTER == aTextType) && (
nIndex < aTxt.getLength()) )
632 aTxt.iterateCodePoints(&nIndexEnd);
634 aResult.SegmentText = aTxt.copy(
nIndex, nIndexEnd -
nIndex);
635 aResult.SegmentStart =
nIndex;
636 aResult.SegmentEnd = nIndexEnd;
646 if (
nIndex > aTxt.getLength())
647 throw IndexOutOfBoundsException();
649 css::accessibility::TextSegment aResult;
650 aResult.SegmentStart = -1;
651 aResult.SegmentEnd = -1;
653 if ( (AccessibleTextType::CHARACTER == aTextType) &&
nIndex > 0 )
655 aTxt.iterateCodePoints(&
nIndex, -1);
657 aTxt.iterateCodePoints(&nIndexEnd);
658 aResult.SegmentText = aTxt.copy(
nIndex, nIndexEnd -
nIndex);
659 aResult.SegmentStart =
nIndex;
660 aResult.SegmentEnd = nIndexEnd;
670 if (
nIndex > aTxt.getLength())
671 throw IndexOutOfBoundsException();
673 css::accessibility::TextSegment aResult;
674 aResult.SegmentStart = -1;
675 aResult.SegmentEnd = -1;
677 if ( (AccessibleTextType::CHARACTER == aTextType) && (
nIndex + 1 < aTxt.getLength()) )
679 aTxt.iterateCodePoints(&
nIndex);
681 aTxt.iterateCodePoints(&nIndexEnd);
682 aResult.SegmentText = aTxt.copy(
nIndex, nIndexEnd -
nIndex);
683 aResult.SegmentStart =
nIndex;
684 aResult.SegmentEnd = nIndexEnd;
690 sal_Int32 nStartIndex,
691 sal_Int32 nEndIndex )
694 bool bReturn =
false;
700 if ( xClipboard.is() )
706 xClipboard->setContents( pDataObj,
nullptr );
709 if( xFlushableClipboard.is() )
710 xFlushableClipboard->flushClipboard();
726 return "SmGraphicAccessible";
730 const OUString& rServiceName )
738 "css::accessibility::Accessible",
739 "css::accessibility::AccessibleComponent",
740 "css::accessibility::AccessibleContext",
741 "css::accessibility::AccessibleText"
const LanguageTag & GetUILanguageTag() const
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
const Wallpaper & GetBackground() const
tools::Long GetTextArray(const OUString &rStr, KernArray *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, bool bCaret=false, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const Color & GetTextColor() const
constexpr tools::Long Y() const
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
constexpr tools::Long Width() const
OUString const & GetAccessibleText()
const SmTableNode * GetFormulaTree() const
const OUString & GetText() const
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual sal_Bool SAL_CALL copyText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual OUString SAL_CALL getText() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Int32 SAL_CALL getCaretPosition() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
virtual sal_Int32 SAL_CALL getForeground() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
SmDocShell * GetDoc_Impl()
virtual sal_Int32 SAL_CALL getSelectionStart() override
virtual sal_Int32 SAL_CALL getSelectionEnd() override
void LaunchEvent(const sal_Int16 nAccessibleEventId, const css::uno::Any &rOldVal, const css::uno::Any &rNewVal)
virtual sal_Int32 SAL_CALL getBackground() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual sal_Int32 SAL_CALL getIndexAtPoint(const css::awt::Point &aPoint) override
virtual void SAL_CALL grabFocus() override
virtual css::awt::Size SAL_CALL getSize() override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual css::awt::Point SAL_CALL getLocation() override
virtual css::lang::Locale SAL_CALL getLocale() override
sal_uInt32 nClientId
client id in the AccessibleEventNotifier queue
SmGraphicAccessible(const SmGraphicAccessible &)=delete
virtual css::awt::Rectangle SAL_CALL getCharacterBounds(sal_Int32 nIndex) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual css::awt::Rectangle SAL_CALL getBounds() override
virtual OUString SAL_CALL getAccessibleDescription() override
virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual OUString SAL_CALL getAccessibleName() override
virtual sal_Int32 SAL_CALL getCharacterCount() override
virtual ~SmGraphicAccessible() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual sal_Unicode SAL_CALL getCharacter(sal_Int32 nIndex) override
virtual sal_Bool SAL_CALL setSelection(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual OUString SAL_CALL getSelectedText() override
virtual sal_Bool SAL_CALL setCaretPosition(sal_Int32 nIndex) override
virtual sal_Bool SAL_CALL scrollSubstringTo(sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override
OUString GetAccessibleText_Impl()
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
sal_Int32 GetAccessibleIndex() const
Gets the node accessible index.
virtual bool IsVisible() const =0
Checks node visibility.
const SmNode * FindRectClosestTo(const Point &rPoint) const
Finds the closest rectangle in the screen.
virtual void GetAccessibleText(OUStringBuffer &rText) const =0
Appends to rText the node text.
const SmNode * FindNodeWithAccessibleIndex(sal_Int32 nAccIndex) const
Finds the node with accessible index nAccIndex.
const SmFace & GetFont() const
Gets the font.
const Point & GetTopLeft() const
tools::Long OrientedDist(const Point &rPoint) const
tools::Long GetLeft() const
const Size & GetSize() const
SmDocShell * GetDoc() const
const Color & GetWindowColor() const
const Color & GetColor() const
static sal_Int32 addEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static void addEvent(const TClientId _nClient, const css::accessibility::AccessibleEventObject &_rEvent)
static sal_Int32 removeEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static TClientId registerClient()
static void revokeClient(const TClientId _nClient)
static void revokeClientNotifyDisposing(const TClientId _nClient, const css::uno::Reference< css::uno::XInterface > &_rxEventSource)
virtual OutputDevice & get_ref_device()=0
virtual a11yref get_accessible_parent()=0
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define TOOLS_WARN_EXCEPTION(area, stream)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString SmResId(TranslateId aId)