23#include <com/sun/star/accessibility/XAccessible.hpp>
24#include <com/sun/star/accessibility/AccessibleStateType.hpp>
25#include <com/sun/star/accessibility/AccessibleEventId.hpp>
26#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
66 std::scoped_lock aGuard(
m_Mutex );
68 uno::Reference < XAccessible > xParent( pParent );
74 std::scoped_lock aGuard(
m_Mutex );
87 OSL_ENSURE( pVSh,
"no view shell" );
91 OSL_ENSURE( pWin,
"no window" );
101 OSL_ENSURE( pViewShell,
"no view shell" );
109 OSL_ENSURE( pViewShell,
"no view shell" );
115enum class Action {
NONE, SCROLLED, SCROLLED_WITHIN,
116 SCROLLED_IN, SCROLLED_OUT };
121 const SwRect& rOldVisArea )
128 while( aIter != aList.
end() )
139 eAction = Action::SCROLLED_WITHIN;
143 if ( bVisibleChildrenOnly &&
146 eAction = Action::SCROLLED_IN;
150 eAction = Action::SCROLLED;
154 else if( aBox.
Overlaps( rOldVisArea ) )
156 if ( bVisibleChildrenOnly &&
159 eAction = Action::SCROLLED_OUT;
163 eAction = Action::SCROLLED;
166 else if( !bVisibleChildrenOnly ||
171 eAction = Action::SCROLLED;
178 "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
186 case Action::SCROLLED:
187 xAccImpl->Scrolled( rOldVisArea );
189 case Action::SCROLLED_WITHIN:
190 xAccImpl->ScrolledWithin( rOldVisArea );
192 case Action::SCROLLED_IN:
193 xAccImpl->ScrolledIn();
195 case Action::SCROLLED_OUT:
196 xAccImpl->ScrolledOut( rOldVisArea );
210 "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
218 case Action::SCROLLED:
219 case Action::SCROLLED_WITHIN:
220 xAccImpl->ViewForwarderChanged();
222 case Action::SCROLLED_IN:
225 case Action::SCROLLED_OUT:
227 xAccImpl->ViewForwarderChanged();
245 "<SwAccessibleContext::ChildrenScrolled(..)> - not always included child not considered!" );
250 ( !bVisibleChildrenOnly ||
267 bool bIsOldShowingState;
270 std::scoped_lock aGuard(
m_Mutex );
275 if( bIsOldShowingState != bIsNewShowingState )
277 bIsNewShowingState );
295 "Visible area of child is wrong. Did it exist already?" );
300 GetMap()->GetContextImpl( pParent,
false ) );
301 uno::Reference < XAccessibleContext > xThis(
this );
302 if( !xParentImpl.is() )
307 AccessibleEventObject
aEvent;
308 aEvent.EventId = AccessibleEventId::CHILD;
309 aEvent.NewValue <<= xThis;
312 xParentImpl->FireAccessibleEvent(
aEvent );
354 while( aIter != aVisList.
end() )
364 xAccImpl->InvalidateStates( _nStates );
383 bool bCanSkipInvisible)
387 while( aIter != aVisList.
end() )
396 xAccImpl->Dispose( bRecursive );
445 SAL_INFO(
"sw.a11y",
"SwAccessibleContext::FireAccessibleEvent called for already disposed frame?");
449 if( !rEvent.Source.is() )
451 uno::Reference < XAccessibleContext > xThis(
this );
452 rEvent.Source = xThis;
461 AccessibleEventObject
aEvent;
462 aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
470 AccessibleEventObject
aEvent;
472 aEvent.EventId = AccessibleEventId::STATE_CHANGED;
487 rStateSet |= AccessibleStateType::SHOWING;
493 rStateSet |= AccessibleStateType::EDITABLE;
494 rStateSet |= AccessibleStateType::RESIZABLE;
495 rStateSet |= AccessibleStateType::MOVEABLE;
498 rStateSet |= AccessibleStateType::ENABLED;
502 rStateSet |= AccessibleStateType::OPAQUE;
508 rStateSet |= AccessibleStateType::DEFUNC;
515 std::scoped_lock aGuard(
m_Mutex );
531 throw lang::DisposedException(
"object is nonfunctional",
537 sal_Int16
const nRole,
545 , m_isDisposing( false )
546 , m_isRegisteredAtAccessibleMap( true )
547 , m_isSelectedInDoc(false)
559 std::shared_ptr<SwAccessibleMap> pMap(
m_wMap.lock());
566uno::Reference< XAccessibleContext > SAL_CALL
569 uno::Reference < XAccessibleContext > xRet(
this );
582uno::Reference< XAccessible> SAL_CALL
590 throw lang::IndexOutOfBoundsException();
595 uno::Reference < XAccessibleContext > xThis(
this );
596 lang::IndexOutOfBoundsException aExcept(
597 "index out of bounds",
602 uno::Reference< XAccessible > xChild;
607 if( xChildImpl.is() )
609 xChildImpl->SetParent(
this );
610 xChild = xChildImpl.get();
618 if( xChildImpl.is() )
619 xChild = xChildImpl.get();
629css::uno::Sequence<uno::Reference<XAccessible>> SAL_CALL
636 std::list< sw::access::SwAccessibleChild > aChildren;
639 std::vector<uno::Reference<XAccessible>> aRet;
640 aRet.reserve(aChildren.size());
641 for (
const auto & rSwChild : aChildren)
643 uno::Reference< XAccessible > xChild;
644 if( rSwChild.GetSwFrame() )
648 if( xChildImpl.is() )
650 xChildImpl->SetParent(
this );
651 xChild = xChildImpl.get();
654 else if ( rSwChild.GetDrawObject() )
657 GetMap()->GetContextImpl( rSwChild.GetDrawObject(),
659 if( xChildImpl.is() )
660 xChild = xChildImpl.get();
662 else if ( rSwChild.GetWindow() )
664 xChild = rSwChild.GetWindow()->GetAccessible();
666 aRet.push_back(xChild);
676 OSL_ENSURE( pUpper !=
nullptr ||
m_isDisposing,
"no upper found" );
678 uno::Reference< XAccessible > xAcc;
686 std::scoped_lock aWeakParentGuard(
m_Mutex );
709 OSL_ENSURE( pUpper !=
nullptr ||
m_isDisposing,
"no upper found" );
716 OSL_ENSURE( xAccImpl.is() ||
m_isDisposing,
"no parent found" );
734uno::Reference< XAccessibleRelationSet> SAL_CALL
748 sal_Int64 nStateSet = 0;
751 nStateSet |= AccessibleStateType::SELECTED;
767 const uno::Reference< XAccessibleEventListener >& xListener )
779 const uno::Reference< XAccessibleEventListener >& xListener )
786 if ( !nListenerCount )
798 const awt::Rectangle & aRect)
804 nDiffX >= 0 && nDiffX < aRect.Width && nDiffY >= 0 &&
805 nDiffY < aRect.Height;
810 const awt::Point& aPoint )
820 const awt::Point& aPoint )
826 uno::Reference< XAccessible > xAcc;
834 Point aPixPoint( aPoint.X, aPoint.Y );
885 OSL_ENSURE( pParent,
"no Parent found" );
902 OSL_ENSURE(
GetShell()->IsPreview(),
"empty page accessible?" );
906 sal_uInt16 nPageNum =
918 aPixBounds.
Move( -aParentPixPos.
getX(), -aParentPixPos.
getY() );
922 awt::Rectangle aBox( aPixBounds.
Left(), aPixBounds.
Top(),
936 awt::Point aPoint(aRect.X, aRect.Y);
945 Point aPixPos(aRect.X, aRect.Y);
954 awt::Point aPoint(aPixPos.
getX(), aPixPos.
getY());
962 awt::Size aSize( aRect.Width, aRect.Height );
997 SwPaM aPaM( aStartPos );
1025 if( !xAccImpl.is() )
1028 AccessibleEventObject
aEvent;
1029 aEvent.EventId = AccessibleEventId::CHILD;
1030 uno::Reference< XAccessible > xAcc( xAccImpl );
1031 aEvent.OldValue <<= xAcc;
1036 xAccImpl->dispose();
1041 if(
nullptr == pAccImpl)
1045 AccessibleEventObject
aEvent;
1046 aEvent.EventId = AccessibleEventId::CHILD;
1047 uno::Reference< XAccessible > xAcc( pAccImpl );
1048 aEvent.NewValue <<= xAcc;
1052 if( !pAccImpl->
GetState( AccessibleStateType::FOCUSED ) )
1058 AccessibleEventObject aStateChangedEvent;
1059 aStateChangedEvent.EventId = AccessibleEventId::STATE_CHANGED;
1060 aStateChangedEvent.NewValue <<= AccessibleStateType::FOCUSED;
1061 aStateChangedEvent.Source = xAcc;
1073 "invalid visible area for dispose" );
1083 uno::Reference < XAccessibleContext > xThis(
this );
1090 AccessibleEventObject
aEvent;
1091 aEvent.EventId = AccessibleEventId::CHILD;
1092 aEvent.OldValue <<= xThis;
1100 std::scoped_lock aDefuncStateGuard(
m_Mutex );
1120 bool bRecursive,
bool bCanSkipInvisible )
1124 if ( !bCanSkipInvisible ||
1137 xAccImpl->Dispose( bRecursive );
1148 else if ( rChildFrameOrObj.
GetWindow() )
1150 AccessibleEventObject
aEvent;
1151 aEvent.EventId = AccessibleEventId::CHILD;
1152 uno::Reference< XAccessible > xAcc =
1154 aEvent.OldValue <<= xAcc;
1159 else if( bRecursive && rChildFrameOrObj.
GetSwFrame() )
1167 OSL_ENSURE(
GetFrame() && !
GetFrame()->getFrameArea().IsEmpty(),
"context should have a size" );
1169 bool bIsOldShowingState;
1172 std::scoped_lock aShowingStateGuard(
m_Mutex );
1177 if( bIsOldShowingState != bIsNewShowingState )
1180 bIsNewShowingState );
1182 else if( bIsNewShowingState )
1191 if( !bIsNewShowingState &&
1207 const SwRect& rOldFrame )
1215 "sw.a11y",
"child context should have a size");
1224 const bool bNew = rOldFrame.
IsEmpty() ||
1225 ( rOldFrame.
Left() == 0 && rOldFrame.
Top() == 0 );
1231 if( bNew || (bVisibleChildrenOnly && !
IsShowing( rOldFrame )) )
1238 xAccImpl->ScrolledIn();
1246 if ( xAccImpl.is() )
1252 OSL_FAIL(
"<SwAccessibleContext::InvalidateChildPosOrSize(..)> - no accessible shape found." );
1255 else if ( rChildFrameOrObj.
GetWindow() )
1257 AccessibleEventObject
aEvent;
1258 aEvent.EventId = AccessibleEventId::CHILD;
1270 if( bVisibleChildrenOnly &&
1277 xAccImpl->SetParent(
this );
1278 xAccImpl->Dispose(
true );
1288 else if ( rChildFrameOrObj.
GetWindow() )
1290 OSL_FAIL(
"<SwAccessibleContext::InvalidateChildPosOrSize(..)> - not expected to handle dispose of child of type <vcl::Window>." );
1328 bool bIsOldEditableState;
1329 bool bIsNewEditableState =
IsEditable( pVSh );
1331 std::scoped_lock aGuard(
m_Mutex );
1336 if( bIsOldEditableState != bIsNewEditableState )
1338 bIsNewEditableState );
1342 bool bIsOldOpaqueState;
1343 bool bIsNewOpaqueState =
IsOpaque( pVSh );
1345 std::scoped_lock aGuard(
m_Mutex );
1350 if( bIsOldOpaqueState != bIsNewOpaqueState )
1352 bIsNewOpaqueState );
1361 AccessibleEventObject
aEvent;
1370 AccessibleEventObject
aEvent;
1371 aEvent.EventId = AccessibleEventId::TEXT_SELECTION_CHANGED;
1379 AccessibleEventObject
aEvent;
1380 aEvent.EventId = AccessibleEventId::TEXT_ATTRIBUTE_CHANGED;
1418 bool bCallShowCursor =
false;
1422 Point aPt( LONG_MIN, LONG_MIN );
1424 bCallShowCursor =
true;
1427 if( pWrtShell && pPaM->
HasMark() )
1438 if( bCallShowCursor )
1447 const OUString *pArg1,
1448 const OUString *pArg2)
1450 OUString sStr =
SwResId(pResId);
1454 sStr = sStr.replaceFirst(
"$(ARG1)", *pArg1 );
1458 sStr = sStr.replaceFirst(
"$(ARG2)", *pArg2 );
1490 vcl::Window* pAdditionalAccessibleChild(
nullptr );
1497 pAdditionalAccessibleChild =
1502 return pAdditionalAccessibleChild;
static bool lcl_PointInRectangle(const awt::Point &aPoint, const awt::Rectangle &aRect)
static const AllSettings & GetSettings()
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long getX() const
constexpr tools::Long getY() const
const_iterator end() const
const_iterator begin() const
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true)
void GetAdditionalAccessibleChildren(std::vector< vcl::Window * > *pChildren)
#i88070# - get all additional accessible children
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual ~SwAccessibleContext() override
bool HasAdditionalAccessibleChildren()
bool m_isRegisteredAtAccessibleMap
virtual css::uno::Sequence< css::uno::Reference< css::accessibility::XAccessible > > SAL_CALL getAccessibleChildren() override
void RemoveFrameFromAccessibleMap()
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
virtual css::awt::Point SAL_CALL getLocation() override
void FireStateChangedEvent(sal_Int64 nState, bool bNewState)
void FireVisibleDataEvent()
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
virtual OUString SAL_CALL getAccessibleName() override
void ChildrenScrolled(const SwFrame *pFrame, const SwRect &rOldVisArea)
css::uno::WeakReference< css::accessibility::XAccessible > m_xWeakParent
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
void DisposeShape(const SdrObject *pObj, ::accessibility::AccessibleShape *pAccImpl)
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
css::awt::Rectangle getBoundsImpl(bool bRelative)
Get bounding box.
virtual void InvalidateCursorPos_()
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame)
void FireAccessibleEvent(css::accessibility::AccessibleEventObject &rEvent)
void InvalidateRelation(sal_uInt16 nType)
void ScrolledInShape(::accessibility::AccessibleShape *pAccImpl)
vcl::Window * GetAdditionalAccessibleChild(const sal_Int32 nIndex)
#i88070# - get additional accessible child by index
virtual void GetStates(sal_Int64 &rStateSet)
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::lang::Locale SAL_CALL getLocale() override
Return the parents locale or throw exception if this object has no parent yet/anymore.
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
std::weak_ptr< SwAccessibleMap > m_wMap
note: the m_pMap is guaranteed to be valid until we hit the dtor ~SwAccessibleContext,...
void ScrolledWithin(const SwRect &rOldVisArea)
void DisposeChildren(const SwFrame *pFrame, bool bRecursive, bool bCanSkipInvisible)
vcl::Window * GetWindow()
virtual void InvalidateFocus_()
virtual sal_Int32 SAL_CALL getForeground() override
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible)
void InvalidateCursorPos()
virtual void InvalidateContent_(bool bVisibleDataFired)
virtual void SAL_CALL grabFocus() override
SwAccessibleMap * GetMap()
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
bool Select(SwPaM *pPaM, SdrObject *pObj, bool bAdd)
virtual css::awt::Rectangle SAL_CALL getBounds() override
css::uno::Reference< css::accessibility::XAccessible > GetWeakParent() const
void SetParent(SwAccessibleContext *pParent)
SwAccessibleContext(std::shared_ptr< SwAccessibleMap > const &pMap, sal_Int16 nRole, const SwFrame *pFrame)
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
SwCursorShell * GetCursorShell()
convenience method to get SwCursorShell through accessibility map
virtual css::awt::Size SAL_CALL getSize() override
void Scrolled(const SwRect &rOldVisArea)
static OUString GetResource(TranslateId pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
virtual bool SetSelectedState(bool bSelected)
void InvalidateTextSelection()
#i27301# - text selection has changed
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
void ScrolledOut(const SwRect &rOldVisArea)
void InvalidateChildrenStates(const SwFrame *_pFrame, AccessibleStates _nStates)
void InvalidateAttr()
#i88069# - attributes has changed
virtual void InvalidatePosOrSize(const SwRect &rFrame)
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nIndex) override
void InvalidateStates(AccessibleStates _nStates)
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParentImpl()
SwRect GetBounds(const SwAccessibleMap &rAccMap, const SwFrame *pFrame=nullptr)
static void GetChildren(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame &rFrame, std::list< sw::access::SwAccessibleChild > &rChildren, bool bInPagePreview)
bool IsEditable(SwViewShell const *pVSh) const
static sal_Int32 GetChildCount(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame *pFrame, bool bInPagePreviewr)
static sw::access::SwAccessibleChild GetChildAtPixel(const SwRect &rVisArea, const SwFrame &rFrame, const Point &rPos, bool bInPagePreview, SwAccessibleMap &rAccMap)
bool IsOpaque(SwViewShell const *pVSh) const
bool IsShowing(const SwAccessibleMap &rAccMap, const sw::access::SwAccessibleChild &rFrameOrObj) const
static sw::access::SwAccessibleChild GetChild(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame &rFrame, sal_Int32 &rPos, bool bInPagePreview)
const SwFrame * GetFrame() const
const SwFrame * GetParent() const
void SetVisArea(const SwRect &rNewVisArea)
const SwRect & GetVisArea() const
tools::Rectangle CoreToPixel(const SwRect &rRect) const
Size GetPreviewPageSize(sal_uInt16 _nPreviewPageNum) const
get size of a dedicated preview page
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
void RemoveContext(const SwFrame *pFrame)
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
SwViewShell * GetShell() const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
void SetSelection(const SwPaM &rCursor)
bool IsFrameSelected() const
bool FinishOLEObj()
Shutdown server.
size_t IsObjSelected() const
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position).
general base class for all free-flowing frames
const SwRect & getFrameArea() const
Base class of the Writer layout elements.
bool IsLayoutFrame() const
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
const SwPosition * GetPoint() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
A page of the document layout.
vcl::Window * GetSidebarWinForFrameByIndex(const SwFrame &rFrame, const sal_Int32 nIndex)
bool HasFrameConnectedSidebarWins(const SwFrame &rFrame)
void GetAllSidebarWinForFrame(const SwFrame &rFrame, std::vector< vcl::Window * > *pChildren)
Of course Writer needs its own rectangles.
void Top(const tools::Long nTop)
void SSize(const Size &rNew)
bool Overlaps(const SwRect &rRect) const
void Left(const tools::Long nLeft)
Represents the visualization of a paragraph.
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
TextFrameIndex GetOffset() const
SwTextNode * GetTextNodeFirst()
SwTextNode is a paragraph in the document model.
vcl::Window * GetWin() const
const SwPostItMgr * GetPostItMgr() const
Used by the UI to modify the document model.
bool GetState(sal_Int64 aState)
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)
bool IsAccessible(bool bPagePreview) const
SwRect GetBox(const SwAccessibleMap &rAccMap) const
const SwFrame * GetSwFrame() const
bool AlwaysIncludeAsChild() const
indicating, if accessible child is included even, if the corresponding object is not visible.
bool IsVisibleChildrenOnly() const
const SdrObject * GetDrawObject() const
vcl::Window * GetWindow() const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define SAL_INFO_IF(condition, area, stream)
#define SAL_INFO(area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Marks a position in the document model.
OUString SwResId(TranslateId aId)