include/svx/dlgctrl.hxx | 66 svx/source/accessibility/svxrectctaccessiblecontext.cxx | 1096 +--------------- svx/source/dialog/dlgctrl.cxx | 554 -------- svx/source/inc/svxrectctaccessiblecontext.hxx | 391 ----- 4 files changed, 88 insertions(+), 2019 deletions(-)
New commits: commit efd0a2dd23fbc069ac829167f7d9ed2e1ce88cfc Author: Caolán McNamara <[email protected]> AuthorDate: Tue Sep 18 14:52:33 2018 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Sep 19 16:59:27 2018 +0200 drop newly unused SvxRectCtl Change-Id: I41fc4f53bedb4d5504aed39bd4d3052e2084fa6d Reviewed-on: https://gerrit.libreoffice.org/60714 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index b087b97e6dcc..3d9e1cb95fd5 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -76,75 +76,9 @@ namespace o3tl template<> struct typed_flags<CTL_STATE> : is_typed_flags<CTL_STATE, 0x03> {}; } -class SvxRectCtlAccessibleContext; class RectCtlAccessibleContext; class SvxPixelCtlAccessible; -class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRectCtl : public Control -{ -private: - SVX_DLLPRIVATE void InitSettings(vcl::RenderContext& rRenderContext); - SVX_DLLPRIVATE void InitRectBitmap(); - SVX_DLLPRIVATE BitmapEx& GetRectBitmap(); - SVX_DLLPRIVATE void Resize_Impl(); - -protected: - rtl::Reference<SvxRectCtlAccessibleContext> pAccContext; - sal_uInt16 nBorderWidth; - sal_uInt16 nRadius; - Size aSize; - Point aPtLT, aPtMT, aPtRT; - Point aPtLM, aPtMM, aPtRM; - Point aPtLB, aPtMB, aPtRB; - Point aPtNew; - RectPoint eRP, eDefRP; - std::unique_ptr<BitmapEx> pBitmap; - CTL_STATE m_nState; - - bool mbUpdateForeground : 1; - bool mbUpdateBackground : 1; - - void MarkToResetSettings(bool bUpdateForeground, bool bUpdateBackground); - - RectPoint GetRPFromPoint( Point, bool bRTL = false ) const; - const Point& GetPointFromRP( RectPoint ) const; - void SetFocusRect(); - Point SetActualRPWithoutInvalidate( RectPoint eNewRP ); // returns the last point - - virtual void GetFocus() override; - virtual void LoseFocus() override; - - Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const; -public: - SvxRectCtl( vcl::Window* pParent, RectPoint eRpt = RectPoint::MM, - sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80 ); - virtual ~SvxRectCtl() override; - virtual void dispose() override; - - virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual void KeyInput( const KeyEvent& rKeyEvt ) override; - virtual void StateChanged( StateChangedType nStateChange ) override; - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; - virtual void Resize() override; - virtual Size GetOptimalSize() const override; - - void Reset(); - RectPoint GetActualRP() const { return eRP;} - void SetActualRP( RectPoint eNewRP ); - - void SetState( CTL_STATE nState ); - - static const sal_uInt8 NO_CHILDREN = 9; // returns number of usable radio buttons - - tools::Rectangle CalculateFocusRectangle() const; - tools::Rectangle CalculateFocusRectangle( RectPoint eRectPoint ) const; - - virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; - - RectPoint GetApproxRPFromPixPt( const css::awt::Point& rPixelPoint ) const; -}; - class SAL_WARN_UNUSED SVX_DLLPUBLIC RectCtl : public weld::CustomWidgetController { private: diff --git a/svx/source/accessibility/svxrectctaccessiblecontext.cxx b/svx/source/accessibility/svxrectctaccessiblecontext.cxx index a92bdacbc632..106f639a9bbf 100644 --- a/svx/source/accessibility/svxrectctaccessiblecontext.cxx +++ b/svx/source/accessibility/svxrectctaccessiblecontext.cxx @@ -98,15 +98,9 @@ static long PointToIndex( RectPoint ePoint ) return nRet; } -SvxRectCtlAccessibleContext::SvxRectCtlAccessibleContext( - const Reference< XAccessible >& rxParent, - SvxRectCtl& rRepr ) : - - SvxRectCtlAccessibleContext_Base( m_aMutex ), - mxParent( rxParent ), - mpRepr( &rRepr ), - mnClientId( 0 ), - mnSelectedChild( NOCHILDSELECTED ) +RectCtlAccessibleContext::RectCtlAccessibleContext(RectCtl* pRepr) + : mpRepr(pRepr) + , mnSelectedChild(NOCHILDSELECTED) { { ::SolarMutexGuard aSolarGuard; @@ -117,91 +111,37 @@ SvxRectCtlAccessibleContext::SvxRectCtlAccessibleContext( mvChildren.resize(MAX_NUM_OF_CHILDREN); } - -SvxRectCtlAccessibleContext::~SvxRectCtlAccessibleContext() -{ - - if( IsAlive() ) - { - osl_atomic_increment( &m_refCount ); - dispose(); // set mpRepr = NULL & release all children - } -} - -// XAccessible -Reference< XAccessibleContext > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleContext() +RectCtlAccessibleContext::~RectCtlAccessibleContext() { - return this; + ensureDisposed(); } -// XAccessibleComponent -sal_Bool SAL_CALL SvxRectCtlAccessibleContext::containsPoint( const awt::Point& rPoint ) -{ - // no guard -> done in getBounds() -// return GetBoundingBox().IsInside( VCLPoint( rPoint ) ); - return tools::Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); -} +IMPLEMENT_FORWARD_XINTERFACE2( RectCtlAccessibleContext, OAccessibleSelectionHelper, OAccessibleHelper_Base ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( RectCtlAccessibleContext, OAccessibleSelectionHelper, OAccessibleHelper_Base ) -Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) +Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) { ::osl::MutexGuard aGuard( m_aMutex ); - ThrowExceptionIfNotAlive(); - Reference< XAccessible > xRet; - long nChild = PointToIndex( mpRepr->GetApproxRPFromPixPt( rPoint ) ); + long nChild = mpRepr ? PointToIndex(mpRepr->GetApproxRPFromPixPt(rPoint)) : NOCHILDSELECTED; - if( nChild != NOCHILDSELECTED ) + if (nChild != NOCHILDSELECTED) xRet = getAccessibleChild( nChild ); return xRet; } -awt::Rectangle SAL_CALL SvxRectCtlAccessibleContext::getBounds() -{ - // no guard -> done in GetBoundingBox() - return AWTRectangle( GetBoundingBox() ); -} - -awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocation() -{ - // no guard -> done in GetBoundingBox() - return AWTPoint( GetBoundingBox().TopLeft() ); -} - -awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocationOnScreen() -{ - // no guard -> done in GetBoundingBoxOnScreen() - return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); -} - -awt::Size SAL_CALL SvxRectCtlAccessibleContext::getSize() -{ - // no guard -> done in GetBoundingBox() - return AWTSize( GetBoundingBox().GetSize() ); -} - -bool SvxRectCtlAccessibleContext::isVisible() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - ThrowExceptionIfNotAlive(); - - return mpRepr->IsVisible(); -} - // XAccessibleContext -sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChildCount() +sal_Int32 SAL_CALL RectCtlAccessibleContext::getAccessibleChildCount() { - ::osl::MutexGuard aGuard( m_aMutex ); - - ThrowExceptionIfNotAlive(); + ::osl::MutexGuard aGuard( m_aMutex ); - return SvxRectCtl::NO_CHILDREN; + return RectCtl::NO_CHILDREN; } -Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChild( sal_Int32 nIndex ) +Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleChild( sal_Int32 nIndex ) { checkChildIndex( nIndex ); @@ -212,11 +152,9 @@ Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChil ::osl::MutexGuard aGuard( m_aMutex ); - ThrowExceptionIfNotAlive(); - xChild = mvChildren[ nIndex ].get(); - if( !xChild.is() ) + if (!xChild.is() && mpRepr) { const ChildIndexToPointData* p = IndexToPoint( nIndex ); OUString aName(SvxResId(p->pResIdName)); @@ -224,8 +162,8 @@ Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChil tools::Rectangle aFocusRect( mpRepr->CalculateFocusRectangle( p->ePoint ) ); - SvxRectCtlChildAccessibleContext* pChild = new SvxRectCtlChildAccessibleContext( - this, *mpRepr, aName, aDescr, aFocusRect, nIndex ); + RectCtlChildAccessibleContext* pChild = new RectCtlChildAccessibleContext(this, aName, + aDescr, aFocusRect, nIndex ); mvChildren[ nIndex ] = pChild; xChild = pChild; @@ -238,49 +176,26 @@ Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChil return xChild; } -Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleParent() -{ - return mxParent; -} - -sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleIndexInParent() +Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleParent() { - ::osl::MutexGuard aGuard( m_aMutex ); - // Use a simple but slow solution for now. Optimize later. - - // Iterate over all the parent's children and search for this object. - if( mxParent.is() ) - { - Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); - if( xParentContext.is() ) - { - sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); - for( sal_Int32 i = 0 ; i < nChildCount ; ++i ) - { - Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) ); - if( xChild.get() == static_cast<XAccessible*>(this) ) - return i; - } - } - } - - // Return -1 to indicate that this object's parent does not know about the - // object. - return -1; + ::osl::MutexGuard aGuard( m_aMutex ); + if (mpRepr) + return mpRepr->getAccessibleParent(); + return uno::Reference<css::accessibility::XAccessible>(); } -sal_Int16 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRole() +sal_Int16 SAL_CALL RectCtlAccessibleContext::getAccessibleRole() { return AccessibleRole::PANEL; } -OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleDescription() +OUString SAL_CALL RectCtlAccessibleContext::getAccessibleDescription() { ::osl::MutexGuard aGuard( m_aMutex ); return msDescription + " Please use arrow key to selection."; } -OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleName() +OUString SAL_CALL RectCtlAccessibleContext::getAccessibleName() { ::osl::MutexGuard aGuard( m_aMutex ); return msName; @@ -289,37 +204,20 @@ OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleName() /** Return empty reference to indicate that the relation set is not supported. */ -Reference< XAccessibleRelationSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRelationSet() +Reference< XAccessibleRelationSet > SAL_CALL RectCtlAccessibleContext::getAccessibleRelationSet() { - //return Reference< XAccessibleRelationSet >(); - utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; - uno::Reference< css::accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper; - vcl::Window* pWindow = mpRepr; - if ( pWindow ) - { - // vcl::Window *pLabeledBy = pWindow->GetAccRelationLabeledBy(); - vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); - if ( pLabeledBy && pLabeledBy != pWindow ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabeledBy->GetAccessible() }; - pRelationSetHelper->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); - } - vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf(); - if ( pMemberOf && pMemberOf != pWindow ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() }; - pRelationSetHelper->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); - } - } - return xSet; + ::osl::MutexGuard aGuard( m_aMutex ); + if (mpRepr) + return mpRepr->get_accessible_relation_set(); + return uno::Reference<css::accessibility::XAccessibleRelationSet>(); } -Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleStateSet() +Reference< XAccessibleStateSet > SAL_CALL RectCtlAccessibleContext::getAccessibleStateSet() { ::osl::MutexGuard aGuard( m_aMutex ); utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; - if( IsAlive() ) + if (mpRepr) { pStateSetHelper->AddState( AccessibleStateType::ENABLED ); pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); @@ -329,7 +227,7 @@ Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccess pStateSetHelper->AddState( AccessibleStateType::SHOWING ); - if( isVisible() ) + if( mpRepr->IsVisible() ) pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); } else @@ -338,103 +236,37 @@ Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccess return pStateSetHelper; } -lang::Locale SAL_CALL SvxRectCtlAccessibleContext::getLocale() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if( mxParent.is() ) - { - Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); - if( xParentContext.is() ) - return xParentContext->getLocale(); - } - - // No parent. Therefore throw exception to indicate this cluelessness. - throw IllegalAccessibleComponentStateException(); -} - -void SAL_CALL SvxRectCtlAccessibleContext::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) -{ - if (xListener.is()) - { - ::osl::MutexGuard aGuard( m_aMutex ); - if (!mnClientId) - mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); - comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); - } -} - -void SAL_CALL SvxRectCtlAccessibleContext::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) -{ - if (xListener.is()) - { - ::osl::MutexGuard aGuard( m_aMutex ); - - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); - mnClientId = 0; - } - } -} - -void SAL_CALL SvxRectCtlAccessibleContext::grabFocus() +void SAL_CALL RectCtlAccessibleContext::grabFocus() { ::SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - ThrowExceptionIfNotAlive(); - - mpRepr->GrabFocus(); + if (mpRepr) + mpRepr->GrabFocus(); } -sal_Int32 SvxRectCtlAccessibleContext::getForeground( ) +sal_Int32 RectCtlAccessibleContext::getForeground() { ::SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - ThrowExceptionIfNotAlive(); - return sal_Int32(mpRepr->GetControlForeground()); + //see RectCtl::Paint + const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); + return sal_Int32(rStyles.GetLabelTextColor()); } -sal_Int32 SvxRectCtlAccessibleContext::getBackground( ) +sal_Int32 RectCtlAccessibleContext::getBackground( ) { ::SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - ThrowExceptionIfNotAlive(); - - return sal_Int32(mpRepr->GetControlBackground()); -} - -// XServiceInfo -OUString SAL_CALL SvxRectCtlAccessibleContext::getImplementationName() -{ - return OUString( "com.sun.star.comp.ui.SvxRectCtlAccessibleContext" ); -} -sal_Bool SAL_CALL SvxRectCtlAccessibleContext::supportsService( const OUString& sServiceName ) -{ - return cppu::supportsService(this, sServiceName); -} - -Sequence< OUString > SAL_CALL SvxRectCtlAccessibleContext::getSupportedServiceNames() -{ - const OUString sServiceName( "com.sun.star.accessibility.AccessibleContext" ); - return Sequence< OUString >( &sServiceName, 1 ); -} - -// XTypeProvider -Sequence< sal_Int8 > SAL_CALL SvxRectCtlAccessibleContext::getImplementationId() -{ - return css::uno::Sequence<sal_Int8>(); + //see RectCtl::Paint + const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); + return sal_Int32(rStyles.GetDialogColor()); } // XAccessibleSelection -void SAL_CALL SvxRectCtlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) +void RectCtlAccessibleContext::implSelect(sal_Int32 nIndex, bool bSelect) { ::SolarMutexGuard aSolarGuard; @@ -442,18 +274,25 @@ void SAL_CALL SvxRectCtlAccessibleContext::selectAccessibleChild( sal_Int32 nInd checkChildIndex( nIndex ); - ThrowExceptionIfNotAlive(); - const ChildIndexToPointData* pData = IndexToPoint( nIndex ); - DBG_ASSERT( pData, - "SvxRectCtlAccessibleContext::selectAccessibleChild(): this is an impossible state! Or at least should be..." ); + DBG_ASSERT(pData, "RectCtlAccessibleContext::selectAccessibleChild(): this is an impossible state! Or at least should be..."); - // this does all what is needed, including the change of the child's state! - mpRepr->SetActualRP( pData->ePoint ); + if (mpRepr) + { + if (bSelect) + { + // this does all what is needed, including the change of the child's state! + mpRepr->SetActualRP( pData->ePoint ); + } + else + { + SAL_WARN( "svx", "RectCtlAccessibleContext::clearAccessibleSelection() is not possible!" ); + } + } } -sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) +bool RectCtlAccessibleContext::implIsSelected( sal_Int32 nIndex ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -462,51 +301,14 @@ sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isAccessibleChildSelected( sal_In return nIndex == mnSelectedChild; } -void SAL_CALL SvxRectCtlAccessibleContext::clearAccessibleSelection() -{ - SAL_WARN( "svx", "SvxRectCtlAccessibleContext::clearAccessibleSelection() is not possible!" ); -} - -void SAL_CALL SvxRectCtlAccessibleContext::selectAllAccessibleChildren() -{ - // guard in selectAccessibleChild()! - - selectAccessibleChild( 0 ); // default per definition -} - -sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChildCount() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return mnSelectedChild == NOCHILDSELECTED? 0 : 1; -} - -Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if( nIndex || mnSelectedChild == NOCHILDSELECTED ) - // in our case only for the first (0) _selected_ child this is a valid request - throw lang::IndexOutOfBoundsException(); - - return getAccessibleChild( mnSelectedChild ); -} - -void SAL_CALL SvxRectCtlAccessibleContext::deselectAccessibleChild( sal_Int32 /*nIndex*/ ) -{ - SAL_WARN( "svx", "SvxRectCtlAccessibleContext::deselectAccessibleChild() is not possible!" ); - - throw lang::IndexOutOfBoundsException( "deselectAccessibleChild is not possible in this context", *this ); // never possible -} - // internals -void SvxRectCtlAccessibleContext::checkChildIndex( long nIndex ) +void RectCtlAccessibleContext::checkChildIndex( long nIndex ) { if( nIndex < 0 || nIndex >= getAccessibleChildCount() ) throw lang::IndexOutOfBoundsException(); } -void SvxRectCtlAccessibleContext::FireChildFocus( RectPoint eButton ) +void RectCtlAccessibleContext::FireChildFocus( RectPoint eButton ) { ::osl::MutexGuard aGuard( m_aMutex ); long nNew = PointToIndex( eButton ); @@ -522,19 +324,17 @@ void SvxRectCtlAccessibleContext::FireChildFocus( RectPoint eButton ) } else { - const Reference< XInterface > xSource( *this ); Any aOld; Any aNew; aNew <<= AccessibleStateType::FOCUSED; - if (mnClientId) - comphelper::AccessibleEventNotifier::addEvent( mnClientId, - AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) ); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aOld, aNew); } } else mnSelectedChild = NOCHILDSELECTED; } -void SvxRectCtlAccessibleContext::selectChild( long nNew ) + +void RectCtlAccessibleContext::selectChild( long nNew ) { ::osl::MutexGuard aGuard( m_aMutex ); if( nNew != mnSelectedChild ) @@ -542,7 +342,7 @@ void SvxRectCtlAccessibleContext::selectChild( long nNew ) long nNumOfChildren = getAccessibleChildCount(); if( nNew < nNumOfChildren ) { // valid index - SvxRectCtlChildAccessibleContext* pChild; + RectCtlChildAccessibleContext* pChild; if( mnSelectedChild != NOCHILDSELECTED ) { // deselect old selected child if one is selected pChild = mvChildren[ mnSelectedChild ].get(); @@ -564,770 +364,46 @@ void SvxRectCtlAccessibleContext::selectChild( long nNew ) } } -void SvxRectCtlAccessibleContext::selectChild(RectPoint eButton ) +void RectCtlAccessibleContext::selectChild(RectPoint eButton ) { // no guard -> is done in next selectChild selectChild(PointToIndex( eButton )); } -void SAL_CALL SvxRectCtlAccessibleContext::disposing() +void SAL_CALL RectCtlAccessibleContext::disposing() { - if( !rBHelper.bDisposed ) + ::osl::MutexGuard aGuard(m_aMutex); + OAccessibleSelectionHelper::disposing(); + for (auto & rxChild : mvChildren) { - { - ::osl::MutexGuard aGuard( m_aMutex ); - mpRepr = nullptr; // object dies with representation - - for (auto & rxChild : mvChildren) - if( rxChild.is() ) - rxChild->dispose(); - - mvChildren.clear(); - } - - { - ::osl::MutexGuard aGuard( m_aMutex ); - - // Send a disposing to all listeners. - if ( mnClientId ) - { - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; - } - - mxParent.clear(); - } + if( rxChild.is() ) + rxChild->dispose(); } + mvChildren.clear(); + mpRepr = nullptr; } -tools::Rectangle SvxRectCtlAccessibleContext::GetBoundingBoxOnScreen() -{ - ::SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( m_aMutex ); - - ThrowExceptionIfNotAlive(); - - return tools::Rectangle( mpRepr->GetParent()->OutputToScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() ); -} - -tools::Rectangle SvxRectCtlAccessibleContext::GetBoundingBox() +awt::Rectangle RectCtlAccessibleContext::implGetBounds() { ::SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - ThrowExceptionIfNotAlive(); - - return tools::Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() ); -} - -void SvxRectCtlAccessibleContext::ThrowExceptionIfNotAlive() -{ - if( rBHelper.bDisposed || rBHelper.bInDispose ) - throw lang::DisposedException(); -} + awt::Rectangle aRet; -RectCtlAccessibleContext::RectCtlAccessibleContext(RectCtl* pRepr) - : mpRepr(pRepr) - , mnSelectedChild(NOCHILDSELECTED) -{ + if (mpRepr) { - ::SolarMutexGuard aSolarGuard; - msName = SvxResId( RID_SVXSTR_RECTCTL_ACC_CORN_NAME ); - msDescription = SvxResId( RID_SVXSTR_RECTCTL_ACC_CORN_DESCR ); - } - - mvChildren.resize(MAX_NUM_OF_CHILDREN); -} - -RectCtlAccessibleContext::~RectCtlAccessibleContext() -{ - ensureDisposed(); -} - -IMPLEMENT_FORWARD_XINTERFACE2( RectCtlAccessibleContext, OAccessibleSelectionHelper, OAccessibleHelper_Base ) -IMPLEMENT_FORWARD_XTYPEPROVIDER2( RectCtlAccessibleContext, OAccessibleSelectionHelper, OAccessibleHelper_Base ) - -Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - Reference< XAccessible > xRet; - - long nChild = mpRepr ? PointToIndex(mpRepr->GetApproxRPFromPixPt(rPoint)) : NOCHILDSELECTED; - - if (nChild != NOCHILDSELECTED) - xRet = getAccessibleChild( nChild ); - - return xRet; -} - -// XAccessibleContext -sal_Int32 SAL_CALL RectCtlAccessibleContext::getAccessibleChildCount() -{ - ::osl::MutexGuard aGuard( m_aMutex ); + const Point aOutPos; + Size aOutSize(mpRepr->GetOutputSizePixel()); - return SvxRectCtl::NO_CHILDREN; -} + aRet.X = aOutPos.X(); + aRet.Y = aOutPos.Y(); + aRet.Width = aOutSize.Width(); + aRet.Height = aOutSize.Height(); + } -Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleChild( sal_Int32 nIndex ) -{ - checkChildIndex( nIndex ); - - Reference< XAccessible > xChild(mvChildren[ nIndex ].get()); - if( !xChild.is() ) - { - ::SolarMutexGuard aSolarGuard; - - ::osl::MutexGuard aGuard( m_aMutex ); - - xChild = mvChildren[ nIndex ].get(); - - if (!xChild.is() && mpRepr) - { - const ChildIndexToPointData* p = IndexToPoint( nIndex ); - OUString aName(SvxResId(p->pResIdName)); - OUString aDescr(SvxResId(p->pResIdDescr)); - - tools::Rectangle aFocusRect( mpRepr->CalculateFocusRectangle( p->ePoint ) ); - - RectCtlChildAccessibleContext* pChild = new RectCtlChildAccessibleContext(this, aName, - aDescr, aFocusRect, nIndex ); - mvChildren[ nIndex ] = pChild; - xChild = pChild; - - // set actual state - if( mnSelectedChild == nIndex ) - pChild->setStateChecked( true ); - } - } - - return xChild; -} - -Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleParent() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if (mpRepr) - return mpRepr->getAccessibleParent(); - return uno::Reference<css::accessibility::XAccessible>(); -} - -sal_Int16 SAL_CALL RectCtlAccessibleContext::getAccessibleRole() -{ - return AccessibleRole::PANEL; -} - -OUString SAL_CALL RectCtlAccessibleContext::getAccessibleDescription() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - return msDescription + " Please use arrow key to selection."; -} - -OUString SAL_CALL RectCtlAccessibleContext::getAccessibleName() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - return msName; -} - -/** Return empty reference to indicate that the relation set is not - supported. -*/ -Reference< XAccessibleRelationSet > SAL_CALL RectCtlAccessibleContext::getAccessibleRelationSet() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if (mpRepr) - return mpRepr->get_accessible_relation_set(); - return uno::Reference<css::accessibility::XAccessibleRelationSet>(); -} - -Reference< XAccessibleStateSet > SAL_CALL RectCtlAccessibleContext::getAccessibleStateSet() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; - - if (mpRepr) - { - pStateSetHelper->AddState( AccessibleStateType::ENABLED ); - pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); - if( mpRepr->HasFocus() ) - pStateSetHelper->AddState( AccessibleStateType::FOCUSED ); - pStateSetHelper->AddState( AccessibleStateType::OPAQUE ); - - pStateSetHelper->AddState( AccessibleStateType::SHOWING ); - - if( mpRepr->IsVisible() ) - pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); - } - else - pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); - - return pStateSetHelper; -} - -void SAL_CALL RectCtlAccessibleContext::grabFocus() -{ - ::SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( m_aMutex ); - - if (mpRepr) - mpRepr->GrabFocus(); -} - -sal_Int32 RectCtlAccessibleContext::getForeground() -{ - ::SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( m_aMutex ); - - //see SvxRectCtl::Paint - const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); - return sal_Int32(rStyles.GetLabelTextColor()); -} - -sal_Int32 RectCtlAccessibleContext::getBackground( ) -{ - ::SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( m_aMutex ); - - //see SvxRectCtl::Paint - const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); - return sal_Int32(rStyles.GetDialogColor()); -} - -// XAccessibleSelection -void RectCtlAccessibleContext::implSelect(sal_Int32 nIndex, bool bSelect) -{ - ::SolarMutexGuard aSolarGuard; - - ::osl::MutexGuard aGuard( m_aMutex ); - - checkChildIndex( nIndex ); - - const ChildIndexToPointData* pData = IndexToPoint( nIndex ); - - DBG_ASSERT(pData, "RectCtlAccessibleContext::selectAccessibleChild(): this is an impossible state! Or at least should be..."); - - if (mpRepr) - { - if (bSelect) - { - // this does all what is needed, including the change of the child's state! - mpRepr->SetActualRP( pData->ePoint ); - } - else - { - SAL_WARN( "svx", "RectCtlAccessibleContext::clearAccessibleSelection() is not possible!" ); - } - } -} - -bool RectCtlAccessibleContext::implIsSelected( sal_Int32 nIndex ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - checkChildIndex( nIndex ); - - return nIndex == mnSelectedChild; -} - -// internals -void RectCtlAccessibleContext::checkChildIndex( long nIndex ) -{ - if( nIndex < 0 || nIndex >= getAccessibleChildCount() ) - throw lang::IndexOutOfBoundsException(); -} - -void RectCtlAccessibleContext::FireChildFocus( RectPoint eButton ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - long nNew = PointToIndex( eButton ); - long nNumOfChildren = getAccessibleChildCount(); - if( nNew < nNumOfChildren ) - { - // select new child - mnSelectedChild = nNew; - if( nNew != NOCHILDSELECTED ) - { - if( mvChildren[ nNew ].is() ) - mvChildren[ nNew ]->FireFocusEvent(); - } - else - { - Any aOld; - Any aNew; - aNew <<= AccessibleStateType::FOCUSED; - NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aOld, aNew); - } - } - else - mnSelectedChild = NOCHILDSELECTED; -} - -void RectCtlAccessibleContext::selectChild( long nNew ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if( nNew != mnSelectedChild ) - { - long nNumOfChildren = getAccessibleChildCount(); - if( nNew < nNumOfChildren ) - { // valid index - RectCtlChildAccessibleContext* pChild; - if( mnSelectedChild != NOCHILDSELECTED ) - { // deselect old selected child if one is selected - pChild = mvChildren[ mnSelectedChild ].get(); - if( pChild ) - pChild->setStateChecked( false ); - } - - // select new child - mnSelectedChild = nNew; - - if( nNew != NOCHILDSELECTED ) - { - if( mvChildren[ nNew ].is() ) - mvChildren[ nNew ]->setStateChecked( true ); - } - } - else - mnSelectedChild = NOCHILDSELECTED; - } -} - -void RectCtlAccessibleContext::selectChild(RectPoint eButton ) -{ - // no guard -> is done in next selectChild - selectChild(PointToIndex( eButton )); -} - -void SAL_CALL RectCtlAccessibleContext::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - OAccessibleSelectionHelper::disposing(); - for (auto & rxChild : mvChildren) - { - if( rxChild.is() ) - rxChild->dispose(); - } - mvChildren.clear(); - mpRepr = nullptr; -} - -awt::Rectangle RectCtlAccessibleContext::implGetBounds() -{ - ::SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( m_aMutex ); - - awt::Rectangle aRet; - - if (mpRepr) - { - const Point aOutPos; - Size aOutSize(mpRepr->GetOutputSizePixel()); - - aRet.X = aOutPos.X(); - aRet.Y = aOutPos.Y(); - aRet.Width = aOutSize.Width(); - aRet.Height = aOutSize.Height(); - } - - return aRet; -} - -SvxRectCtlChildAccessibleContext::SvxRectCtlChildAccessibleContext( - const Reference<XAccessible>& rxParent, - const vcl::Window& rParentWindow, - const OUString& rName, - const OUString& rDescription, - const tools::Rectangle& rBoundingBox, - long nIndexInParent ) : - - SvxRectCtlChildAccessibleContext_Base( maMutex ), - msDescription( rDescription ), - msName( rName ), - mxParent(rxParent), - maBoundingBox( rBoundingBox ), - mrParentWindow( rParentWindow ), - mnClientId( 0 ), - mnIndexInParent( nIndexInParent ), - mbIsChecked( false ) -{ -} - - -SvxRectCtlChildAccessibleContext::~SvxRectCtlChildAccessibleContext() -{ - - if( IsAlive() ) - { - osl_atomic_increment( &m_refCount ); - dispose(); // set mpRepr = NULL & release all children - } -} - -// XAccessible -Reference< XAccessibleContext> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleContext() -{ - return this; -} - -// XAccessibleComponent -sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::containsPoint( const awt::Point& rPoint ) -{ - // no guard -> done in getBounds() - return tools::Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); -} - -Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleAtPoint( const awt::Point& /*rPoint*/ ) -{ - return Reference< XAccessible >(); -} - -awt::Rectangle SAL_CALL SvxRectCtlChildAccessibleContext::getBounds() -{ - // no guard -> done in getBoundingBox() - return AWTRectangle( GetBoundingBox() ); -} - -awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocation() -{ - // no guard -> done in getBoundingBox() - return AWTPoint( GetBoundingBox().TopLeft() ); -} - -awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocationOnScreen() -{ - // no guard -> done in getBoundingBoxOnScreen() - return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); -} - -awt::Size SAL_CALL SvxRectCtlChildAccessibleContext::getSize() -{ - // no guard -> done in getBoundingBox() - return AWTSize( GetBoundingBox().GetSize() ); -} - -void SAL_CALL SvxRectCtlChildAccessibleContext::grabFocus() -{ -} - -sal_Int32 SvxRectCtlChildAccessibleContext::getForeground( ) -{ - ::SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( maMutex ); - ThrowExceptionIfNotAlive(); - return sal_Int32(mrParentWindow.GetControlForeground()); -} -sal_Int32 SvxRectCtlChildAccessibleContext::getBackground( ) -{ - ::SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( maMutex ); - - ThrowExceptionIfNotAlive(); - return sal_Int32(mrParentWindow.GetControlBackground()); -} - -// XAccessibleContext -sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChildCount() -{ - return 0; -} - -Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChild( sal_Int32 /*nIndex*/ ) -{ - throw lang::IndexOutOfBoundsException(); -} - -Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleParent() -{ - return mxParent; -} - -sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleIndexInParent() -{ - return mnIndexInParent; -} - -sal_Int16 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRole() -{ - return AccessibleRole::RADIO_BUTTON; -} - -OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleDescription() -{ - ::osl::MutexGuard aGuard( maMutex ); - return msDescription; -} - -OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleName() -{ - ::osl::MutexGuard aGuard( maMutex ); - return msName; -} - -/** Return empty reference to indicate that the relation set is not - supported. -*/ -Reference<XAccessibleRelationSet> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRelationSet() -{ - utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; - uno::Reference< css::accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper; - if( mxParent.is() ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { mxParent }; - pRelationSetHelper->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); - - } - - return xSet; -} - -Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleStateSet() -{ - ::osl::MutexGuard aGuard( maMutex ); - utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; - - if( IsAlive() ) - { - if( mbIsChecked ) - { - pStateSetHelper->AddState( AccessibleStateType::CHECKED ); -// pStateSetHelper->AddState( AccessibleStateType::SELECTED ); - } - - pStateSetHelper->AddState( AccessibleStateType::ENABLED ); - pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); - pStateSetHelper->AddState( AccessibleStateType::OPAQUE ); - pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); - pStateSetHelper->AddState( AccessibleStateType::SHOWING ); - pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); - } - else - pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); - - return pStateSetHelper; -} - -lang::Locale SAL_CALL SvxRectCtlChildAccessibleContext::getLocale() -{ - ::osl::MutexGuard aGuard( maMutex ); - if( mxParent.is() ) - { - Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); - if( xParentContext.is() ) - return xParentContext->getLocale(); - } - - // No locale and no parent. Therefore throw exception to indicate this - // cluelessness. - throw IllegalAccessibleComponentStateException(); -} - -void SAL_CALL SvxRectCtlChildAccessibleContext::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) -{ - if (xListener.is()) - { - ::osl::MutexGuard aGuard( maMutex ); - if (!mnClientId) - mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); - comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); - } -} - - -void SAL_CALL SvxRectCtlChildAccessibleContext::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) -{ - if (xListener.is()) - { - ::osl::MutexGuard aGuard( maMutex ); - - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); - mnClientId = 0; - } - } -} - -// XAccessibleValue -Any SAL_CALL SvxRectCtlChildAccessibleContext::getCurrentValue() -{ - ThrowExceptionIfNotAlive(); - - Any aRet; - aRet <<= ( mbIsChecked? 1.0 : 0.0 ); - return aRet; -} - -sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::setCurrentValue( const Any& /*aNumber*/ ) -{ - return false; -} - -Any SAL_CALL SvxRectCtlChildAccessibleContext::getMaximumValue() -{ - Any aRet; - aRet <<= 1.0; - return aRet; -} - -Any SAL_CALL SvxRectCtlChildAccessibleContext::getMinimumValue() -{ - Any aRet; - aRet <<= 0.0; return aRet; } - -// XAccessibleAction - - -sal_Int32 SvxRectCtlChildAccessibleContext::getAccessibleActionCount( ) -{ - return 1; -} - - -sal_Bool SvxRectCtlChildAccessibleContext::doAccessibleAction ( sal_Int32 nIndex ) -{ - ::osl::MutexGuard aGuard( maMutex ); - - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) - throw IndexOutOfBoundsException(); - - Reference<XAccessibleSelection> xSelection( mxParent, UNO_QUERY); - - xSelection->selectAccessibleChild(mnIndexInParent); - - return true; -} - - -OUString SvxRectCtlChildAccessibleContext::getAccessibleActionDescription ( sal_Int32 nIndex ) -{ - ::osl::MutexGuard aGuard( maMutex ); - - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) - throw IndexOutOfBoundsException(); - - return OUString("select"); -} - - -Reference< XAccessibleKeyBinding > SvxRectCtlChildAccessibleContext::getAccessibleActionKeyBinding( sal_Int32 nIndex ) -{ - ::osl::MutexGuard aGuard( maMutex ); - - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) - throw IndexOutOfBoundsException(); - - return Reference< XAccessibleKeyBinding >(); -} - -// XServiceInfo -OUString SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationName() -{ - return OUString( "com.sun.star.comp.ui.SvxRectCtlChildAccessibleContext" ); -} - -sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::supportsService( const OUString& sServiceName ) -{ - return cppu::supportsService(this, sServiceName); -} - -Sequence< OUString > SAL_CALL SvxRectCtlChildAccessibleContext::getSupportedServiceNames() -{ - const OUString sServiceName ("com.sun.star.accessibility.AccessibleContext"); - return Sequence< OUString >( &sServiceName, 1 ); -} - -// XTypeProvider -Sequence< sal_Int8 > SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationId() -{ - return css::uno::Sequence<sal_Int8>(); -} - -void SvxRectCtlChildAccessibleContext::CommitChange( const AccessibleEventObject& rEvent ) -{ - if (mnClientId) - comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent ); -} - -void SAL_CALL SvxRectCtlChildAccessibleContext::disposing() -{ - if( !rBHelper.bDisposed ) - { - ::osl::MutexGuard aGuard( maMutex ); - - // Send a disposing to all listeners. - if ( mnClientId ) - { - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; - } - - mxParent.clear(); - } -} - -void SvxRectCtlChildAccessibleContext::ThrowExceptionIfNotAlive() -{ - if( rBHelper.bDisposed || rBHelper.bInDispose ) - throw lang::DisposedException(); -} - -tools::Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBoxOnScreen() -{ - ::osl::MutexGuard aGuard( maMutex ); - - // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox() - tools::Rectangle aRect( GetBoundingBox() ); - - return tools::Rectangle( mrParentWindow.OutputToScreenPixel( aRect.TopLeft() ), aRect.GetSize() ); -} - -tools::Rectangle const & SvxRectCtlChildAccessibleContext::GetBoundingBox() -{ - // no guard necessary, because no one changes maBoundingBox after creating it - ThrowExceptionIfNotAlive(); - - return maBoundingBox; -} - -void SvxRectCtlChildAccessibleContext::setStateChecked( bool bChecked ) -{ - if( mbIsChecked != bChecked ) - { - mbIsChecked = bChecked; - - const Reference< XInterface > xSource( *this ); - - Any aOld; - Any aNew; - Any& rMod = bChecked? aNew : aOld; - - //Send the STATE_CHANGED(Focused) event to accessible - rMod <<= AccessibleStateType::FOCUSED; - CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) ); - - rMod <<= AccessibleStateType::CHECKED; - - CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) ); - } -} - -void SvxRectCtlChildAccessibleContext::FireFocusEvent() -{ - const Reference< XInterface > xSource( *this ); - Any aOld; - Any aNew; - aNew <<= AccessibleStateType::FOCUSED; - CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) ); -} - RectCtlChildAccessibleContext::RectCtlChildAccessibleContext( const Reference<XAccessible>& rxParent, const OUString& rName, @@ -1362,7 +438,7 @@ sal_Int32 RectCtlChildAccessibleContext::getForeground( ) ::SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - //see SvxRectCtl::Paint + //see RectCtl::Paint const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); return sal_Int32(rStyles.GetLabelTextColor()); } @@ -1372,7 +448,7 @@ sal_Int32 RectCtlChildAccessibleContext::getBackground( ) ::SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - //see SvxRectCtl::Paint + //see RectCtl::Paint const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); return sal_Int32(rStyles.GetDialogColor()); } diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 85df3b8d1c1c..9c94f493ce17 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -60,556 +60,6 @@ using namespace ::com::sun::star::accessibility; // Control for display and selection of the corner points and // mid point of an object -BitmapEx& SvxRectCtl::GetRectBitmap() -{ - if( !pBitmap ) - InitRectBitmap(); - - return *pBitmap; -} - -SvxRectCtl::SvxRectCtl(vcl::Window* pParent, RectPoint eRpt, - sal_uInt16 nBorder, sal_uInt16 nCircle) - : Control(pParent, WB_BORDER | WB_TABSTOP) - , nBorderWidth(nBorder) - , nRadius(nCircle) - , eDefRP(eRpt) - , m_nState(CTL_STATE::NONE) - , mbUpdateForeground(true) - , mbUpdateBackground(true) -{ - SetMapMode(MapMode(MapUnit::Map100thMM)); - Resize_Impl(); -} - -Size SvxRectCtl::GetOptimalSize() const -{ - return LogicToPixel(Size(78, 39), MapMode(MapUnit::MapAppFont)); -} - -SvxRectCtl::~SvxRectCtl() -{ - disposeOnce(); -} - -void SvxRectCtl::dispose() -{ - pBitmap.reset(); - - pAccContext.clear(); - Control::dispose(); -} - -void SvxRectCtl::Resize() -{ - Resize_Impl(); - Control::Resize(); -} - -void SvxRectCtl::Resize_Impl() -{ - aSize = GetOutputSize(); - - aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth ); - aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth ); - aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth ); - - aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 ); - aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 ); - aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 ); - - aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth ); - aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth ); - aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth ); - - Reset(); - MarkToResetSettings(true, true); - Invalidate(); -} - -void SvxRectCtl::InitRectBitmap() -{ - pBitmap.reset(); - - const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); - svtools::ColorConfig aColorConfig; - - pBitmap.reset(new BitmapEx(RID_SVXCTRL_RECTBTNS)); - - // set bitmap-colors - Color aColorAry1[7]; - Color aColorAry2[7]; - aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray - aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow - aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white - aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray - aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black - aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green - aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue - aColorAry2[0] = rStyles.GetDialogColor(); // background - aColorAry2[1] = rStyles.GetWindowColor(); - aColorAry2[2] = rStyles.GetLightColor(); - aColorAry2[3] = rStyles.GetShadowColor(); - aColorAry2[4] = rStyles.GetDarkShadowColor(); - aColorAry2[5] = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor; - aColorAry2[6] = rStyles.GetDialogColor(); - -#ifdef DBG_UTIL - static bool bModify = false; - bool& rModify = bModify; - if( rModify ) - { - static int n = 0; - static sal_uInt8 r = 0xFF; - static sal_uInt8 g = 0x00; - static sal_uInt8 b = 0xFF; - int& rn = n; - sal_uInt8& rr = r; - sal_uInt8& rg = g; - sal_uInt8& rb = b; - aColorAry2[ rn ] = Color( rr, rg, rb ); - } -#endif - - pBitmap->Replace( aColorAry1, aColorAry2, 7 ); -} - - -void SvxRectCtl::MarkToResetSettings(bool bUpdateForeground, bool bUpdateBackground) -{ - mbUpdateForeground = bUpdateForeground; - mbUpdateBackground = bUpdateBackground; - pBitmap.reset(); // forces new creating of bitmap -} - -void SvxRectCtl::InitSettings(vcl::RenderContext& rRenderContext) -{ - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - - if (mbUpdateForeground) - { - svtools::ColorConfig aColorConfig; - Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); - - if (IsControlForeground()) - aTextColor = GetControlForeground(); - rRenderContext.SetTextColor(aTextColor); - mbUpdateForeground = false; - } - - if (mbUpdateBackground) - { - if (IsControlBackground()) - SetBackground(GetControlBackground()); - else - SetBackground(rStyleSettings.GetWindowColor()); - mbUpdateBackground = false; - } -} - -// The clicked rectangle (3 x 3) is determined and the parent (dialog) -// is notified that the item was changed -void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt ) -{ - Point aPtLast = aPtNew; - - aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() ); - - Invalidate( tools::Rectangle( aPtLast - Point( nRadius, nRadius ), - aPtLast + Point( nRadius, nRadius ) ) ); - Invalidate( tools::Rectangle( aPtNew - Point( nRadius, nRadius ), - aPtNew + Point( nRadius, nRadius ) ) ); - eRP = GetRPFromPoint( aPtNew ); - - SetActualRP( eRP ); - - vcl::Window *pTabPage = getNonLayoutParent(this); - if (pTabPage && WindowType::TABPAGE == pTabPage->GetType()) - static_cast<SvxTabPage*>(pTabPage)->PointChanged( this, eRP ); -} - -void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt ) -{ - RectPoint eNewRP = eRP; - - switch( rKeyEvt.GetKeyCode().GetCode() ) - { - case KEY_DOWN: - { - if( !(m_nState & CTL_STATE::NOVERT) ) - switch( eNewRP ) - { - case RectPoint::LT: eNewRP = RectPoint::LM; break; - case RectPoint::MT: eNewRP = RectPoint::MM; break; - case RectPoint::RT: eNewRP = RectPoint::RM; break; - case RectPoint::LM: eNewRP = RectPoint::LB; break; - case RectPoint::MM: eNewRP = RectPoint::MB; break; - case RectPoint::RM: eNewRP = RectPoint::RB; break; - default: ; //prevent warning - } - } - break; - case KEY_UP: - { - if( !(m_nState & CTL_STATE::NOVERT) ) - switch( eNewRP ) - { - case RectPoint::LM: eNewRP = RectPoint::LT; break; - case RectPoint::MM: eNewRP = RectPoint::MT; break; - case RectPoint::RM: eNewRP = RectPoint::RT; break; - case RectPoint::LB: eNewRP = RectPoint::LM; break; - case RectPoint::MB: eNewRP = RectPoint::MM; break; - case RectPoint::RB: eNewRP = RectPoint::RM; break; - default: ; //prevent warning - } - } - break; - case KEY_LEFT: - { - if( !(m_nState & CTL_STATE::NOHORZ) ) - switch( eNewRP ) - { - case RectPoint::MT: eNewRP = RectPoint::LT; break; - case RectPoint::RT: eNewRP = RectPoint::MT; break; - case RectPoint::MM: eNewRP = RectPoint::LM; break; - case RectPoint::RM: eNewRP = RectPoint::MM; break; - case RectPoint::MB: eNewRP = RectPoint::LB; break; - case RectPoint::RB: eNewRP = RectPoint::MB; break; - default: ; //prevent warning - } - } - break; - case KEY_RIGHT: - { - if( !(m_nState & CTL_STATE::NOHORZ) ) - switch( eNewRP ) - { - case RectPoint::LT: eNewRP = RectPoint::MT; break; - case RectPoint::MT: eNewRP = RectPoint::RT; break; - case RectPoint::LM: eNewRP = RectPoint::MM; break; - case RectPoint::MM: eNewRP = RectPoint::RM; break; - case RectPoint::LB: eNewRP = RectPoint::MB; break; - case RectPoint::MB: eNewRP = RectPoint::RB; break; - default: ; //prevent warning - } - } - break; - default: - Control::KeyInput( rKeyEvt ); - return; - } - if( eNewRP != eRP ) - { - SetActualRP( eNewRP ); - - vcl::Window *pTabPage = getNonLayoutParent(this); - if (pTabPage && WindowType::TABPAGE == pTabPage->GetType()) - static_cast<SvxTabPage*>(pTabPage)->PointChanged(this, eRP); - - SetFocusRect(); - } -} - - -void SvxRectCtl::StateChanged( StateChangedType nType ) -{ - if ( nType == StateChangedType::ControlForeground ) - MarkToResetSettings(true, false); - else if ( nType == StateChangedType::ControlBackground ) - MarkToResetSettings(false, true); - - Window::StateChanged( nType ); -} - - -void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt ) -{ - if ( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) ) - MarkToResetSettings(true, true); - else - Window::DataChanged( rDCEvt ); -} - -// the control (rectangle with 9 circles) -void SvxRectCtl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) -{ - InitSettings(rRenderContext); - - Point aPtDiff(PixelToLogic(Point(1, 1))); - - const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); - - rRenderContext.SetLineColor(rStyles.GetDialogColor()); - rRenderContext.SetFillColor(rStyles.GetDialogColor()); - rRenderContext.DrawRect(tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize())); - - if (IsEnabled()) - rRenderContext.SetLineColor(rStyles.GetLabelTextColor()); - else - rRenderContext.SetLineColor(rStyles.GetShadowColor()); - - rRenderContext.SetFillColor(); - - if (!IsEnabled()) - { - Color aOldCol = rRenderContext.GetLineColor(); - rRenderContext.SetLineColor(rStyles.GetLightColor()); - rRenderContext.DrawRect(tools::Rectangle(aPtLT + aPtDiff, aPtRB + aPtDiff)); - rRenderContext.SetLineColor(aOldCol); - } - rRenderContext.DrawRect(tools::Rectangle(aPtLT, aPtRB)); - - rRenderContext.SetFillColor(rRenderContext.GetBackground().GetColor()); - - Size aBtnSize(11, 11); - Size aDstBtnSize(PixelToLogic(aBtnSize)); - Point aToCenter(aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1); - Point aBtnPnt1(IsEnabled() ? 0 : 22, 0); - Point aBtnPnt2(11, 0); - Point aBtnPnt3(22, 0); - - bool bNoHorz = bool(m_nState & CTL_STATE::NOHORZ); - bool bNoVert = bool(m_nState & CTL_STATE::NOVERT); - - BitmapEx& rBitmap = GetRectBitmap(); - - rRenderContext.DrawBitmap(aPtLT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - rRenderContext.DrawBitmap(aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - rRenderContext.DrawBitmap(aPtRT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - rRenderContext.DrawBitmap(aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - - // Center for rectangle and line - rRenderContext.DrawBitmap(aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - - rRenderContext.DrawBitmap(aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - rRenderContext.DrawBitmap(aPtLB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - rRenderContext.DrawBitmap(aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - rRenderContext.DrawBitmap(aPtRB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap.GetBitmap()); - - // draw active button, avoid center pos for angle - if (IsEnabled()) - { - Point aCenterPt(aPtNew); - aCenterPt -= aToCenter; - - rRenderContext.DrawBitmap(aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap.GetBitmap()); - } -} - -// Convert RectPoint Point - -const Point& SvxRectCtl::GetPointFromRP( RectPoint _eRP) const -{ - switch( _eRP ) - { - case RectPoint::LT: return aPtLT; - case RectPoint::MT: return aPtMT; - case RectPoint::RT: return aPtRT; - case RectPoint::LM: return aPtLM; - case RectPoint::MM: return aPtMM; - case RectPoint::RM: return aPtRM; - case RectPoint::LB: return aPtLB; - case RectPoint::MB: return aPtMB; - case RectPoint::RB: return aPtRB; - } - return aPtMM; // default -} - - -void SvxRectCtl::SetFocusRect() -{ - HideFocus(); - - ShowFocus( CalculateFocusRectangle() ); -} - -Point SvxRectCtl::SetActualRPWithoutInvalidate( RectPoint eNewRP ) -{ - Point aPtLast = aPtNew; - aPtNew = GetPointFromRP( eNewRP ); - - if( m_nState & CTL_STATE::NOHORZ ) - aPtNew.setX( aPtMM.X() ); - - if( m_nState & CTL_STATE::NOVERT ) - aPtNew.setY( aPtMM.Y() ); - - // fdo#74751 this fix reverse base point on RTL UI. - bool bRTL = AllSettings::GetLayoutRTL(); - eNewRP = GetRPFromPoint( aPtNew, bRTL ); - - eDefRP = eNewRP; - eRP = eNewRP; - - return aPtLast; -} - -void SvxRectCtl::GetFocus() -{ - SetFocusRect(); - // Send the accessible focused event - Control::GetFocus(); - // Send accessibility event. - if(pAccContext.is()) - { - pAccContext->FireChildFocus(GetActualRP()); - } -} - - -void SvxRectCtl::LoseFocus() -{ - HideFocus(); -} - - -Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const -{ - Point aPt = PixelToLogic( rPt ); - long x; - long y; - - if( !( m_nState & CTL_STATE::NOHORZ ) ) - { - if( aPt.X() < aSize.Width() / 3 ) - x = aPtLT.X(); - else if( aPt.X() < aSize.Width() * 2 / 3 ) - x = aPtMM.X(); - else - x = aPtRB.X(); - } - else - x = aPtMM.X(); - - if( !( m_nState & CTL_STATE::NOVERT ) ) - { - if( aPt.Y() < aSize.Height() / 3 ) - y = aPtLT.Y(); - else if( aPt.Y() < aSize.Height() * 2 / 3 ) - y = aPtMM.Y(); - else - y = aPtRB.Y(); - } - else - y = aPtMM.Y(); - - return Point( x, y ); -} - - -// Converts Point in RectPoint - -RectPoint SvxRectCtl::GetRPFromPoint( Point aPt, bool bRTL ) const -{ - RectPoint rPoint = RectPoint::MM; // default - - if ( aPt == aPtLT) rPoint = bRTL ? RectPoint::RT : RectPoint::LT; - else if( aPt == aPtMT) rPoint = RectPoint::MT; - else if( aPt == aPtRT) rPoint = bRTL ? RectPoint::LT : RectPoint::RT; - else if( aPt == aPtLM) rPoint = bRTL ? RectPoint::RM : RectPoint::LM; - else if( aPt == aPtRM) rPoint = bRTL ? RectPoint::LM : RectPoint::RM; - else if( aPt == aPtLB) rPoint = bRTL ? RectPoint::RB : RectPoint::LB; - else if( aPt == aPtMB) rPoint = RectPoint::MB; - else if( aPt == aPtRB) rPoint = bRTL ? RectPoint::LB : RectPoint::RB; - - return rPoint; -} - -// Resets to the original state of the control - -void SvxRectCtl::Reset() -{ - aPtNew = GetPointFromRP( eDefRP ); - eRP = eDefRP; - Invalidate(); -} - -// Returns the currently selected RectPoint - - -void SvxRectCtl::SetActualRP( RectPoint eNewRP ) -{ - Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) ); - - Invalidate( tools::Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) ); - Invalidate( tools::Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) ); - - // notify accessibility object about change - if( pAccContext.is() ) - pAccContext->selectChild( eNewRP /* MT, bFireFocus */ ); -} - -void SvxRectCtl::SetState( CTL_STATE nState ) -{ - m_nState = nState; - - Point aPtLast( GetPointFromRP( eRP ) ); - Point _aPtNew( aPtLast ); - - if( m_nState & CTL_STATE::NOHORZ ) - _aPtNew.setX( aPtMM.X() ); - - if( m_nState & CTL_STATE::NOVERT) - _aPtNew.setY( aPtMM.Y() ); - - eRP = GetRPFromPoint( _aPtNew ); - Invalidate(); - - vcl::Window *pTabPage = getNonLayoutParent(this); - if (pTabPage && WindowType::TABPAGE == pTabPage->GetType()) - static_cast<SvxTabPage*>(pTabPage)->PointChanged(this, eRP); -} - -tools::Rectangle SvxRectCtl::CalculateFocusRectangle() const -{ - Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) ); - return tools::Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize ); -} - -tools::Rectangle SvxRectCtl::CalculateFocusRectangle( RectPoint eRectPoint ) const -{ - tools::Rectangle aRet; - RectPoint eOldRectPoint = GetActualRP(); - - if( eOldRectPoint == eRectPoint ) - aRet = CalculateFocusRectangle(); - else - { - SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this ); - - pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary! - aRet = CalculateFocusRectangle(); - - pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed! - } - - return aRet; -} - -Reference< XAccessible > SvxRectCtl::CreateAccessible() -{ - vcl::Window* pParent = GetAccessibleParentWindow(); - - DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" ); - - Reference< XAccessible > xAccParent = pParent->GetAccessible(); - if( xAccParent.is() ) - { - pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this ); - - SetActualRP( GetActualRP() ); - - return pAccContext.get(); - } - else - return Reference< XAccessible >(); -} - -RectPoint SvxRectCtl::GetApproxRPFromPixPt( const css::awt::Point& r ) const -{ - return GetRPFromPoint(GetApproxLogPtFromPixPt(Point(r.X, r.Y ))); -} - BitmapEx& RectCtl::GetRectBitmap() { if( !pBitmap ) @@ -877,7 +327,7 @@ void RectCtl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) BitmapEx& rBitmap = GetRectBitmap(); - // CompletelyDisabled() added to have a disabled state for SvxRectCtl + // CompletelyDisabled() added to have a disabled state for RectCtl if (IsCompletelyDisabled()) { rRenderContext.DrawBitmap(aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap.GetBitmap()); @@ -907,7 +357,7 @@ void RectCtl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) } // draw active button, avoid center pos for angle - // CompletelyDisabled() added to have a disabled state for SvxRectCtl + // CompletelyDisabled() added to have a disabled state for RectCtl if (!IsCompletelyDisabled()) { if (IsEnabled()) diff --git a/svx/source/inc/svxrectctaccessiblecontext.hxx b/svx/source/inc/svxrectctaccessiblecontext.hxx index 6e3fb5b509bd..f5648c3e319e 100644 --- a/svx/source/inc/svxrectctaccessiblecontext.hxx +++ b/svx/source/inc/svxrectctaccessiblecontext.hxx @@ -58,214 +58,9 @@ namespace com { namespace sun { namespace star { namespace awt { namespace tools { class Rectangle; } class RectCtl; -class SvxRectCtl; class RectCtlChildAccessibleContext; -class SvxRectCtlChildAccessibleContext; namespace vcl { class Window; } -typedef ::cppu::WeakAggComponentImplHelper6< - css::accessibility::XAccessible, - css::accessibility::XAccessibleComponent, - css::accessibility::XAccessibleContext, - css::accessibility::XAccessibleEventBroadcaster, - css::accessibility::XAccessibleSelection, - css::lang::XServiceInfo > - SvxRectCtlAccessibleContext_Base; - -class SvxRectCtlAccessibleContext final : public ::cppu::BaseMutex, public SvxRectCtlAccessibleContext_Base -{ -public: - // internal - SvxRectCtlAccessibleContext( - const css::uno::Reference< css::accessibility::XAccessible>& rxParent, - SvxRectCtl& rRepresentation ); - - // XAccessible - virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL - getAccessibleContext() override; - - // XAccessibleComponent - virtual sal_Bool SAL_CALL - containsPoint( const css::awt::Point& rPoint ) override; - - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL - getAccessibleAtPoint( const css::awt::Point& rPoint ) override; - - virtual css::awt::Rectangle SAL_CALL - getBounds() override; - - virtual css::awt::Point SAL_CALL - getLocation() override; - - virtual css::awt::Point SAL_CALL - getLocationOnScreen() override; - - virtual css::awt::Size SAL_CALL - getSize() override; - - /// @throws css::uno::RuntimeException - bool - isVisible(); - - virtual void SAL_CALL - grabFocus() override; - - virtual sal_Int32 SAL_CALL - getForeground( ) override; - virtual sal_Int32 SAL_CALL - getBackground( ) override; - - // XAccessibleContext - virtual sal_Int32 SAL_CALL - getAccessibleChildCount() override; - - virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL - getAccessibleChild( sal_Int32 nIndex ) override; - - virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL - getAccessibleParent() override; - - virtual sal_Int32 SAL_CALL - getAccessibleIndexInParent() override; - - virtual sal_Int16 SAL_CALL - getAccessibleRole() override; - - virtual OUString SAL_CALL - getAccessibleDescription() override; - - virtual OUString SAL_CALL - getAccessibleName() override; - - virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL - getAccessibleRelationSet() override; - - virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL - getAccessibleStateSet() override; - - virtual css::lang::Locale SAL_CALL - getLocale() override; - - // XAccessibleEventBroadcaster - virtual void SAL_CALL - addAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - - virtual void SAL_CALL - removeAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - - // XServiceInfo - virtual OUString SAL_CALL - getImplementationName() override; - - virtual sal_Bool SAL_CALL - supportsService( const OUString& sServiceName ) override; - - virtual css::uno::Sequence< OUString> SAL_CALL - getSupportedServiceNames() override; - - // XTypeProvider - virtual css::uno::Sequence<sal_Int8> SAL_CALL - getImplementationId() override; - - // XAccessibleSelection - virtual void SAL_CALL - selectAccessibleChild( sal_Int32 nChildIndex ) override; - - virtual sal_Bool SAL_CALL - isAccessibleChildSelected( sal_Int32 nChildIndex ) override; - - virtual void SAL_CALL - clearAccessibleSelection() override; - - virtual void SAL_CALL - selectAllAccessibleChildren() override; - - virtual sal_Int32 SAL_CALL - getSelectedAccessibleChildCount() override; - - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL - getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override; - - virtual void SAL_CALL - deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) override; - - /** Selects a new child by point. - - <p>If the child was not selected before, the state of the child will - be updated. If the point is not invalid, the index will internally set to NOCHILDSELECTED</p> - - @param eButton - Button which belongs to the child which should be selected. - */ - void selectChild( RectPoint ePoint ); - void FireChildFocus( RectPoint eButton ); - -private: - virtual ~SvxRectCtlAccessibleContext() override; - - // internals - /// @throws css::lang::IndexOutOfBoundsException - void checkChildIndex( long nIndexOfChild ); - - /** Selects a new child by index. - - <p>If the child was not selected before, the state of the child will - be updated. If the index is invalid, the index will internally set to NOCHILDSELECTED</p> - - @param nIndexOfChild - Index of the new child which should be selected. - */ - void selectChild( long nIndexOfChild ); - - /// @Return the object's current bounding box relative to the desktop. - /// - /// @throws css::uno::RuntimeException - tools::Rectangle GetBoundingBoxOnScreen(); - - /// @Return the object's current bounding box relative to the parent object. - /// - /// @throws css::uno::RuntimeException - tools::Rectangle GetBoundingBox(); - - virtual void SAL_CALL disposing() override; - - /// @returns true if it's disposed or in disposing - bool IsAlive() const - { - return !rBHelper.bDisposed && !rBHelper.bInDispose; - } - - /// @throws css::lang::DisposedException if it's not alive - void ThrowExceptionIfNotAlive(); - - /** Description of this object. This is not a constant because it can - be set from the outside. - */ - OUString msDescription; - - /** Name of this object. - */ - OUString msName; - - /// Reference to the parent object. - css::uno::Reference< css::accessibility::XAccessible > - mxParent; - - /// pointer to internal representation - VclPtr<SvxRectCtl> mpRepr; - - /// array for all possible children - std::vector<rtl::Reference<SvxRectCtlChildAccessibleContext>> mvChildren; - - /// client id in the AccessibleEventNotifier queue - sal_uInt32 mnClientId; - - /// actual selected child - long mnSelectedChild; -}; - typedef ::cppu::ImplHelper1<css::accessibility::XAccessible> OAccessibleHelper_Base; class RectCtlAccessibleContext final : public ::comphelper::OAccessibleSelectionHelper, @@ -354,192 +149,6 @@ private: long mnSelectedChild; }; -typedef ::cppu::WeakAggComponentImplHelper7< - css::accessibility::XAccessible, - css::accessibility::XAccessibleComponent, - css::accessibility::XAccessibleContext, - css::accessibility::XAccessibleEventBroadcaster, - css::accessibility::XAccessibleValue, - css::accessibility::XAccessibleAction, - css::lang::XServiceInfo > - SvxRectCtlChildAccessibleContext_Base; - -class SvxRectCtlChildAccessibleContext : public SvxRectCtlChildAccessibleContext_Base -{ -public: - SvxRectCtlChildAccessibleContext( - const css::uno::Reference< css::accessibility::XAccessible>& rxParent, - const vcl::Window& rParentWindow, - const OUString& rName, const OUString& rDescription, - const tools::Rectangle& rBoundingBox, - long nIndexInParent ); -protected: - virtual ~SvxRectCtlChildAccessibleContext() override; -public: - // XAccessible - virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL - getAccessibleContext() override; - - // XAccessibleComponent - virtual sal_Bool SAL_CALL - containsPoint( const css::awt::Point& rPoint ) override; - - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL - getAccessibleAtPoint( const css::awt::Point& rPoint ) override; - - virtual css::awt::Rectangle SAL_CALL - getBounds() override; - - virtual css::awt::Point SAL_CALL - getLocation() override; - - virtual css::awt::Point SAL_CALL - getLocationOnScreen() override; - - virtual css::awt::Size SAL_CALL - getSize() override; - - virtual void SAL_CALL - grabFocus() override; - - virtual sal_Int32 SAL_CALL - getForeground( ) override; - virtual sal_Int32 SAL_CALL - getBackground( ) override; - - // XAccessibleContext - virtual sal_Int32 SAL_CALL - getAccessibleChildCount() override; - - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL - getAccessibleChild( sal_Int32 nIndex ) override; - - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL - getAccessibleParent() override; - - virtual sal_Int32 SAL_CALL - getAccessibleIndexInParent() override; - - virtual sal_Int16 SAL_CALL - getAccessibleRole() override; - - virtual OUString SAL_CALL - getAccessibleDescription() override; - - virtual OUString SAL_CALL - getAccessibleName() override; - - virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL - getAccessibleRelationSet() override; - - virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL - getAccessibleStateSet() override; - - virtual css::lang::Locale SAL_CALL - getLocale() override; - - // XAccessibleEventBroadcaster - virtual void SAL_CALL - addAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - - virtual void SAL_CALL - removeAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - - // XAccessibleValue - virtual css::uno::Any SAL_CALL - getCurrentValue() override; - - virtual sal_Bool SAL_CALL - setCurrentValue( const css::uno::Any& aNumber ) override; - - virtual css::uno::Any SAL_CALL - getMaximumValue() override; - - virtual css::uno::Any SAL_CALL - getMinimumValue() override; - - // XAccessibleAction - virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; - virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; - virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; - virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; - // XServiceInfo - virtual OUString SAL_CALL - getImplementationName() override; - - virtual sal_Bool SAL_CALL - supportsService( const OUString& sServiceName ) override; - - virtual css::uno::Sequence< OUString> SAL_CALL - getSupportedServiceNames() override; - - // XTypeProvider - virtual css::uno::Sequence<sal_Int8> SAL_CALL - getImplementationId() override; - - // internal - /// Sets the checked status - void setStateChecked(bool bChecked); - void FireFocusEvent(); - -protected: - /// @throws css::uno::RuntimeException - tools::Rectangle GetBoundingBoxOnScreen(); - - /// @throws css::uno::RuntimeException - tools::Rectangle const & GetBoundingBox(); - - void CommitChange( const css::accessibility::AccessibleEventObject& rEvent ); - - virtual void SAL_CALL disposing() override; - - /// @returns true if it's disposed or in disposing - bool IsAlive() const - { - return !rBHelper.bDisposed && !rBHelper.bInDispose; - } - - /// @throws css::lang::DisposedException if it's not alive - void ThrowExceptionIfNotAlive(); - - /// Mutex guarding this object. - ::osl::Mutex maMutex; - -private: - - /** Description of this object. This is not a constant because it can - be set from the outside. Furthermore, it changes according to the - draw page's display mode. - */ - OUString msDescription; - - /** Name of this object. It changes according the draw page's - display mode. - */ - OUString msName; - - /// Reference to the parent object. - css::uno::Reference< css::accessibility::XAccessible > - mxParent; - - /// Bounding box - tools::Rectangle maBoundingBox; - - /// window of parent - const vcl::Window& mrParentWindow; - - /// client id in the AccessibleEventNotifier queue - sal_uInt32 mnClientId; - - /// index of child in parent - long mnIndexInParent; - - /// Indicates, if object is checked - bool mbIsChecked; -}; - typedef ::cppu::ImplHelper3 < css::accessibility::XAccessible, css::accessibility::XAccessibleValue, css::accessibility::XAccessibleAction _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
