diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-19 15:02:49 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-09-03 18:25:52 +0200 |
commit | 79daf40ec696e0855d4a2894f048e44188cfbbb6 (patch) | |
tree | 96cb3ec48472c06961c1f4392ea6e1b560980555 /svx/source | |
parent | b094921089beeecb2333075e174c8b1fa6d1b812 (diff) |
weld SvxAreaTabPage
which itself has 5 sub tab pages
Change-Id: If71e91248b5771af4845ad6dba997ac4c7841b5d
Reviewed-on: https://gerrit.libreoffice.org/56112
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/accessibility/svxpixelctlaccessiblecontext.cxx | 552 | ||||
-rw-r--r-- | svx/source/accessibility/svxrectctaccessiblecontext.cxx | 3 | ||||
-rw-r--r-- | svx/source/dialog/dlgctrl.cxx | 82 | ||||
-rw-r--r-- | svx/source/inc/svxpixelctlaccessiblecontext.hxx | 191 | ||||
-rw-r--r-- | svx/source/inc/svxrectctaccessiblecontext.hxx | 19 | ||||
-rw-r--r-- | svx/source/tbxctrls/SvxPresetListBox.cxx | 78 |
6 files changed, 295 insertions, 630 deletions
diff --git a/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx b/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx index 8908e36d3bde..f5821243a743 100644 --- a/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx +++ b/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx @@ -48,21 +48,19 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; -SvxPixelCtlAccessible::SvxPixelCtlAccessible( SvxPixelCtl& rControl) : - SvxPixelCtlAccessible_BASE(m_aMutex), - mrPixelCtl(rControl), - mnClientId(0) +SvxPixelCtlAccessible::SvxPixelCtlAccessible(SvxPixelCtl* pControl) + : mpPixelCtl(pControl) { } SvxPixelCtlAccessible::~SvxPixelCtlAccessible() { - if( IsAlive() ) - { - osl_atomic_increment( &m_refCount ); - dispose(); // set mpRepr = NULL & release all children - } + ensureDisposed(); } + +IMPLEMENT_FORWARD_XINTERFACE2( SvxPixelCtlAccessible, OAccessibleSelectionHelper, OAccessibleHelper_Base ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxPixelCtlAccessible, OAccessibleSelectionHelper, OAccessibleHelper_Base ) + uno::Reference< XAccessibleContext > SvxPixelCtlAccessible::getAccessibleContext( ) { return this; @@ -78,31 +76,18 @@ uno::Reference< XAccessible > SvxPixelCtlAccessible::getAccessibleChild( sal_Int ::osl::MutexGuard aGuard( m_aMutex ); if ( i < 0 || i >= getAccessibleChildCount()) throw lang::IndexOutOfBoundsException(); - return CreateChild(i, mrPixelCtl.IndexToPoint(i)); + Reference< XAccessible > xChild; + if (mpPixelCtl) + xChild = CreateChild(i, mpPixelCtl->IndexToPoint(i)); + return xChild; } uno::Reference< XAccessible > SvxPixelCtlAccessible::getAccessibleParent( ) { ::osl::MutexGuard aGuard( m_aMutex ); - vcl::Window *pTabPage = getNonLayoutParent(&mrPixelCtl); - if (!pTabPage || WindowType::TABPAGE != pTabPage->GetType()) - return uno::Reference< XAccessible >(); - else - return pTabPage->GetAccessible(); -} - -sal_Int32 SvxPixelCtlAccessible::getAccessibleIndexInParent( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - sal_uInt16 nIdx = 0; - vcl::Window *pTabPage = getNonLayoutParent(&mrPixelCtl); - if (!pTabPage || WindowType::TABPAGE != pTabPage->GetType()) - return -1; - sal_uInt16 nChildren = pTabPage->GetChildCount(); - for(nIdx = 0; nIdx < nChildren; nIdx++) - if(pTabPage->GetChild( nIdx ) == &mrPixelCtl) - break; - return nIdx; + if (mpPixelCtl) + return mpPixelCtl->getAccessibleParent(); + return uno::Reference<css::accessibility::XAccessible>(); } sal_Int16 SvxPixelCtlAccessible::getAccessibleRole( ) @@ -114,282 +99,146 @@ OUString SvxPixelCtlAccessible::getAccessibleDescription( ) { ::osl::MutexGuard aGuard( m_aMutex ); - return mrPixelCtl.GetAccessibleDescription(); + return mpPixelCtl ? mpPixelCtl->GetAccessibleDescription() : ""; } OUString SvxPixelCtlAccessible::getAccessibleName( ) { - ::osl::MutexGuard aGuard( m_aMutex ); - return mrPixelCtl.GetAccessibleName(); + return mpPixelCtl ? mpPixelCtl->GetAccessibleName() : ""; } -uno::Reference< XAccessibleRelationSet > SvxPixelCtlAccessible::getAccessibleRelationSet( ) +Reference< XAccessibleRelationSet > SAL_CALL SvxPixelCtlAccessible::getAccessibleRelationSet() { - ::osl::MutexGuard aGuard( m_aMutex ); - utl::AccessibleRelationSetHelper* rRelationSet = new utl::AccessibleRelationSetHelper; - uno::Reference< css::accessibility::XAccessibleRelationSet > rSet = rRelationSet; - vcl::Window *pLabeledBy = mrPixelCtl.GetAccessibleRelationLabeledBy(); - if ( pLabeledBy && pLabeledBy != &mrPixelCtl ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabeledBy->GetAccessible() }; - rRelationSet->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); - } - - vcl::Window* pMemberOf = mrPixelCtl.GetAccessibleRelationMemberOf(); - if ( pMemberOf && pMemberOf != &mrPixelCtl ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() }; - rRelationSet->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); - } - return rSet; + if (mpPixelCtl) + return mpPixelCtl->get_accessible_relation_set(); + return uno::Reference<css::accessibility::XAccessibleRelationSet>(); } - uno::Reference< XAccessibleStateSet > SvxPixelCtlAccessible::getAccessibleStateSet( ) { ::osl::MutexGuard aGuard( m_aMutex ); utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; uno::Reference< XAccessibleStateSet > xRet = pStateSetHelper; - const sal_Int16 aStandardStates[] = - { - AccessibleStateType::FOCUSABLE, - AccessibleStateType::SELECTABLE, - AccessibleStateType::SHOWING, - AccessibleStateType::VISIBLE, - AccessibleStateType::OPAQUE, - 0 - }; - - sal_Int16 nState = 0; - while(aStandardStates[nState]) + if (mpPixelCtl) { - pStateSetHelper->AddState(aStandardStates[nState++]); + const sal_Int16 aStandardStates[] = + { + AccessibleStateType::FOCUSABLE, + AccessibleStateType::SELECTABLE, + AccessibleStateType::SHOWING, + AccessibleStateType::VISIBLE, + AccessibleStateType::OPAQUE, + 0 + }; + + sal_Int16 nState = 0; + while (aStandardStates[nState]) + { + pStateSetHelper->AddState(aStandardStates[nState++]); + } + if (mpPixelCtl->IsEnabled()) + pStateSetHelper->AddState(AccessibleStateType::ENABLED); + if (mpPixelCtl->HasFocus()) + pStateSetHelper->AddState(AccessibleStateType::FOCUSED); + pStateSetHelper->AddState(AccessibleStateType::MANAGES_DESCENDANTS); } - if(mrPixelCtl.IsEnabled()) - pStateSetHelper->AddState(AccessibleStateType::ENABLED); - if(mrPixelCtl.HasFocus()) - pStateSetHelper->AddState(AccessibleStateType::FOCUSED); - pStateSetHelper->AddState(AccessibleStateType::MANAGES_DESCENDANTS); return xRet; } - -css::lang::Locale SvxPixelCtlAccessible::getLocale( ) +uno::Reference<XAccessible > SAL_CALL SvxPixelCtlAccessible::getAccessibleAtPoint ( + const awt::Point& rPoint) { ::osl::MutexGuard aGuard( m_aMutex ); - if( getAccessibleParent().is() ) + + Reference< XAccessible > xRet; + + if (mpPixelCtl) { - uno::Reference< XAccessibleContext > xParentContext( getAccessibleParent()->getAccessibleContext() ); - if( xParentContext.is() ) - return xParentContext->getLocale(); + long nIndex = mpPixelCtl->PointToIndex(Point(rPoint.X, rPoint.Y)); + xRet = CreateChild(nIndex, mpPixelCtl->IndexToPoint(nIndex)); } - // No locale and no parent. Therefore throw exception to indicate this - // cluelessness. - throw IllegalAccessibleComponentStateException(); + return xRet; } - -sal_Bool SvxPixelCtlAccessible::containsPoint( const awt::Point& aPt ) +awt::Rectangle SvxPixelCtlAccessible::implGetBounds() { ::osl::MutexGuard aGuard( m_aMutex ); - Point aPoint(aPt.X, aPt.Y); - return (aPoint.X() >= 0) - && (aPoint.X() < mrPixelCtl.GetSizePixel().getWidth()) - && (aPoint.Y() >= 0) - && (aPoint.Y() < mrPixelCtl.GetSizePixel().getHeight()); -} -uno::Reference<XAccessible > SAL_CALL SvxPixelCtlAccessible::getAccessibleAtPoint ( - const awt::Point& aPoint) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if( !IsAlive() ) - throw lang::DisposedException(); - Point childPoint; - childPoint.setX( aPoint.X ); - childPoint.setY( aPoint.Y ); + awt::Rectangle aRet; - Point pt= mrPixelCtl.PixelToLogic(childPoint); - long nIndex = mrPixelCtl.PointToIndex(pt); - return CreateChild(nIndex, mrPixelCtl.IndexToPoint(nIndex)); -} + if (mpPixelCtl) + { + const Point aOutPos; + Size aOutSize(mpPixelCtl->GetOutputSizePixel()); -awt::Rectangle SvxPixelCtlAccessible::getBounds( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - awt::Rectangle aRet; - Size aSz = mrPixelCtl.GetSizePixel(); - Point aPos = mrPixelCtl.GetPosPixel(); - aRet.X = aPos.X(); - aRet.Y = aPos.Y(); - aRet.Width = aSz.Width(); - aRet.Height = aSz.Height(); - return aRet; -} + aRet.X = aOutPos.X(); + aRet.Y = aOutPos.Y(); + aRet.Width = aOutSize.Width(); + aRet.Height = aOutSize.Height(); + } -awt::Point SvxPixelCtlAccessible::getLocation( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - Point aPos; - aPos = mrPixelCtl.GetPosPixel(); - awt::Point aRet(aPos.X(), aPos.Y()); return aRet; } -awt::Point SvxPixelCtlAccessible::getLocationOnScreen( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - tools::Rectangle rect = mrPixelCtl.GetWindowExtentsRelative(nullptr); - return awt::Point(rect.Left(),rect.Top() ); -} - -awt::Size SvxPixelCtlAccessible::getSize( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - Size aSz = mrPixelCtl.GetSizePixel(); - return awt::Size(aSz.Width(),aSz.Height()); -} void SvxPixelCtlAccessible::grabFocus( ) { ::osl::MutexGuard aGuard( m_aMutex ); - mrPixelCtl.GrabFocus(); + if (mpPixelCtl) + mpPixelCtl->GrabFocus(); } sal_Int32 SvxPixelCtlAccessible::getForeground( ) { ::osl::MutexGuard aGuard( m_aMutex ); - return sal_Int32(mrPixelCtl.GetControlForeground()); + + //see SvxPixelCtl::Paint + const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); + return sal_Int32(rStyles.GetLabelTextColor()); } sal_Int32 SvxPixelCtlAccessible::getBackground( ) { ::osl::MutexGuard aGuard( m_aMutex ); - return sal_Int32(mrPixelCtl.GetControlBackground()); -} - -OUString SvxPixelCtlAccessible::getImplementationName( ) -{ - return OUString("SvxPixelCtlAccessible"); -} -sal_Bool SvxPixelCtlAccessible::supportsService( const OUString& rServiceName ) -{ - return cppu::supportsService( this, rServiceName ); -} - -uno::Sequence< OUString > SvxPixelCtlAccessible::getSupportedServiceNames( ) -{ - return uno::Sequence< OUString >{ - "Accessible", - "AccessibleContext", - "AccessibleComponent" - }; + //see SvxPixelCtl::Paint + const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); + return sal_Int32(rStyles.GetDialogColor()); } - -// XAccessibleSelection - -void SAL_CALL SvxPixelCtlAccessible::selectAccessibleChild( sal_Int32 nChildIndex ) +void SvxPixelCtlAccessible::implSelect(sal_Int32 nChildIndex, bool bSelect) { ::osl::MutexGuard aGuard( m_aMutex ); if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) throw lang::IndexOutOfBoundsException(); - long nIndex = mrPixelCtl.ShowPosition(mrPixelCtl.IndexToPoint(nChildIndex)); - NotifyChild(nIndex,true,false); -} - -sal_Bool SAL_CALL SvxPixelCtlAccessible::isAccessibleChildSelected( sal_Int32 nChildIndex ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return mrPixelCtl.GetFocusPosIndex() == nChildIndex; -} - -void SAL_CALL SvxPixelCtlAccessible::clearAccessibleSelection( ) -{ -} + if (!mpPixelCtl) + return; -void SAL_CALL SvxPixelCtlAccessible::selectAllAccessibleChildren( ) -{ + long nIndex = mpPixelCtl->ShowPosition(mpPixelCtl->IndexToPoint(nChildIndex)); + NotifyChild(nIndex, bSelect, false); } -sal_Int32 SAL_CALL SvxPixelCtlAccessible::getSelectedAccessibleChildCount( ) -{ - return 1; -} - -uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessible::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) +bool SvxPixelCtlAccessible::implIsSelected(sal_Int32 nChildIndex) { ::osl::MutexGuard aGuard( m_aMutex ); - if ( nSelectedChildIndex >= 1) - throw lang::IndexOutOfBoundsException(); - - uno::Reference< XAccessible > xChild; - if(m_xCurChild.is()) - { - xChild = m_xCurChild; - } - return xChild; -} - -void SAL_CALL SvxPixelCtlAccessible::deselectAccessibleChild( sal_Int32 ) -{ -} - -//XAccessibleEventBroadcaster -void SAL_CALL SvxPixelCtlAccessible::addAccessibleEventListener( const uno::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 SvxPixelCtlAccessible::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) -{ - if (xListener.is()) - { - ::osl::MutexGuard aGuard( m_aMutex ); - if (!mnClientId) - return; - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); - if ( !nListenerCount ) - { - comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); - mnClientId = 0; - } - } -} + if (!mpPixelCtl) + return false; -//Solution:Add the event handling method -void SvxPixelCtlAccessible::FireAccessibleEvent (short nEventId, const css::uno::Any& rOld, const css::uno::Any& rNew) -{ - const uno::Reference< XInterface > xSource( *this ); - if (mnClientId) - comphelper::AccessibleEventNotifier::addEvent( mnClientId, AccessibleEventObject( xSource, nEventId, rNew,rOld ) ); + return mpPixelCtl->GetFocusPosIndex() == nChildIndex; } void SAL_CALL SvxPixelCtlAccessible::disposing() { - if( !rBHelper.bDisposed ) - { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( mnClientId ) - { - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; - } - } + ::osl::MutexGuard aGuard(m_aMutex); + OAccessibleSelectionHelper::disposing(); + m_xCurChild.clear(); + mpPixelCtl = nullptr; } void SvxPixelCtlAccessible::NotifyChild(long nIndex,bool bSelect ,bool bCheck) @@ -410,21 +259,19 @@ void SvxPixelCtlAccessible::NotifyChild(long nIndex,bool bSelect ,bool bCheck) } if (bCheck) { - pChild->ChangePixelColorOrBG( mrPixelCtl.GetBitmapPixel(sal_uInt16(nIndex)) != 0); + pChild->ChangePixelColorOrBG(mpPixelCtl->GetBitmapPixel(sal_uInt16(nIndex)) != 0); pChild->CheckChild(); } return ; } } - uno::Reference <XAccessible> xNewChild =CreateChild(nIndex, mrPixelCtl.IndexToPoint(nIndex)); + uno::Reference <XAccessible> xNewChild =CreateChild(nIndex, mpPixelCtl->IndexToPoint(nIndex)); SvxPixelCtlAccessibleChild *pNewChild= static_cast<SvxPixelCtlAccessibleChild*>(xNewChild.get()); DBG_ASSERT(pNewChild,"Child Must be Valid"); Any aNewValue,aOldValue; aNewValue<<= xNewChild; - FireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, - aOldValue, - aNewValue ); + NotifyAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue); if (bSelect) { @@ -439,16 +286,14 @@ void SvxPixelCtlAccessible::NotifyChild(long nIndex,bool bSelect ,bool bCheck) pNewChild->CheckChild(); } m_xCurChild= xNewChild; - - } uno::Reference<XAccessible> SvxPixelCtlAccessible::CreateChild (long nIndex,Point mPoint) { - bool bPixelColorOrBG = mrPixelCtl.GetBitmapPixel(sal_uInt16(nIndex)) != 0; - Size size(mrPixelCtl.GetWidth() / SvxPixelCtl::GetLineCount(), mrPixelCtl.GetHeight() / SvxPixelCtl::GetLineCount()); + bool bPixelColorOrBG = mpPixelCtl->GetBitmapPixel(sal_uInt16(nIndex)) != 0; + Size size(mpPixelCtl->GetWidth() / SvxPixelCtl::GetLineCount(), mpPixelCtl->GetHeight() / SvxPixelCtl::GetLineCount()); uno::Reference<XAccessible> xChild; - xChild = new SvxPixelCtlAccessibleChild(mrPixelCtl, + xChild = new SvxPixelCtlAccessibleChild(*mpPixelCtl, bPixelColorOrBG, tools::Rectangle(mPoint,size), this, @@ -457,7 +302,6 @@ uno::Reference<XAccessible> SvxPixelCtlAccessible::CreateChild (long nIndex,Poin return xChild; } - void SvxPixelCtlAccessible::LoseFocus() { m_xCurChild.clear(); @@ -470,15 +314,11 @@ void SvxPixelCtlAccessibleChild::CheckChild() if (m_bPixelColorOrBG)//Current Child State { - FireAccessibleEvent( AccessibleEventId::STATE_CHANGED, - Any(), - aChecked); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(), aChecked); } else { - FireAccessibleEvent( AccessibleEventId::STATE_CHANGED, - aChecked, - Any() ); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aChecked, Any()); } } @@ -489,118 +329,58 @@ void SvxPixelCtlAccessibleChild::SelectChild( bool bSelect) if (bSelect) { - FireAccessibleEvent( AccessibleEventId::STATE_CHANGED, - Any(), - aSelected); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(), aSelected); } else { - FireAccessibleEvent( AccessibleEventId::STATE_CHANGED, - aSelected, - Any()); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aSelected, Any()); } } -void SvxPixelCtlAccessibleChild::FireAccessibleEvent ( - short nEventId, - const css::uno::Any& rOld, - const css::uno::Any& rNew) -{ - const uno::Reference< XInterface > xSource( *this ); - if (mnClientId) - comphelper::AccessibleEventNotifier::addEvent( mnClientId, AccessibleEventObject( xSource, nEventId, rNew,rOld ) ); -} -SvxPixelCtlAccessibleChild::SvxPixelCtlAccessibleChild( - SvxPixelCtl& rWindow, - bool bPixelColorOrBG, - const tools::Rectangle& rBoundingBox, - const uno::Reference<XAccessible>& rxParent, - long nIndexInParent ) : - SvxPixelCtlAccessibleChild_BASE( m_aMutex ), - mrParentWindow( rWindow ), - mxParent(rxParent), - m_bPixelColorOrBG(bPixelColorOrBG), - maBoundingBox( rBoundingBox ), - mnIndexInParent( nIndexInParent ), - mnClientId( 0 ) +SvxPixelCtlAccessibleChild::SvxPixelCtlAccessibleChild( SvxPixelCtl& rWindow, bool bPixelColorOrBG, + const tools::Rectangle& rBoundingBox, const rtl::Reference<SvxPixelCtlAccessible>& rxParent, + long nIndexInParent) + : mrParentWindow( rWindow ) + , mxParent(rxParent) + , m_bPixelColorOrBG(bPixelColorOrBG) + , maBoundingBox( rBoundingBox ) + , mnIndexInParent( nIndexInParent ) { } - SvxPixelCtlAccessibleChild::~SvxPixelCtlAccessibleChild() { - if( IsAlive() ) - { - osl_atomic_increment( &m_refCount ); - dispose(); // set mpRepr = NULL & release all children - } + ensureDisposed(); } +IMPLEMENT_FORWARD_XINTERFACE2( SvxPixelCtlAccessibleChild, OAccessibleComponentHelper, OAccessibleHelper_Base ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxPixelCtlAccessibleChild, OAccessibleComponentHelper, OAccessibleHelper_Base ) + // XAccessible uno::Reference< XAccessibleContext> SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleContext() { return this; } -// XAccessibleComponent -sal_Bool SAL_CALL SvxPixelCtlAccessibleChild::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 ) ); -} - uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleAtPoint( const awt::Point& ) { return uno::Reference< XAccessible >(); } -awt::Rectangle SAL_CALL SvxPixelCtlAccessibleChild::getBounds() -{ - // no guard -> done in getBoundingBox() - //Modified by lq, 09/26 - //return AWTRectangle( GetBoundingBox() ); - awt::Rectangle rect = AWTRectangle( GetBoundingBox() ); - rect.X = rect.X + mrParentWindow.GetClientWindowExtentsRelative().Left()-mrParentWindow.GetWindowExtentsRelative(nullptr).Left(); - rect.Y = rect.Y + mrParentWindow.GetClientWindowExtentsRelative().Top()-mrParentWindow.GetWindowExtentsRelative(nullptr).Top(); - return rect; - // End -} - -awt::Point SAL_CALL SvxPixelCtlAccessibleChild::getLocation() -{ - // no guard -> done in getBoundingBox() - return AWTPoint( GetBoundingBox().TopLeft() ); -} - -awt::Point SAL_CALL SvxPixelCtlAccessibleChild::getLocationOnScreen() -{ - // no guard -> done in getBoundingBoxOnScreen() - return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); -} - -awt::Size SAL_CALL SvxPixelCtlAccessibleChild::getSize() -{ - // no guard -> done in getBoundingBox() - return AWTSize( GetBoundingBox().GetSize() ); -} - void SAL_CALL SvxPixelCtlAccessibleChild::grabFocus() { } -sal_Int32 SvxPixelCtlAccessibleChild::getForeground( ) +sal_Int32 SvxPixelCtlAccessibleChild::getForeground() { ::osl::MutexGuard aGuard( m_aMutex ); - ThrowExceptionIfNotAlive(); - return sal_Int32(mrParentWindow.GetControlForeground()); + return mxParent.is() ? mxParent->getForeground() : -1; } -sal_Int32 SvxPixelCtlAccessibleChild::getBackground( ) + +sal_Int32 SvxPixelCtlAccessibleChild::getBackground() { ::osl::MutexGuard aGuard( m_aMutex ); - - ThrowExceptionIfNotAlive(); - return sal_Int32(mrParentWindow.GetControlBackground()); + return mxParent.is() ? mxParent->getBackground() : -1; } // XAccessibleContext @@ -616,12 +396,7 @@ uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessibleChild::getAccessible uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleParent() { - return mxParent; -} - -sal_Int32 SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleIndexInParent() -{ - return mnIndexInParent; + return mxParent.get(); } sal_Int16 SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleRole() @@ -655,7 +430,7 @@ uno::Reference< XAccessibleStateSet > SAL_CALL SvxPixelCtlAccessibleChild::getAc ::osl::MutexGuard aGuard( m_aMutex ); utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; - if( IsAlive() ) + if (!rBHelper.bDisposed) { pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); @@ -681,111 +456,16 @@ uno::Reference< XAccessibleStateSet > SAL_CALL SvxPixelCtlAccessibleChild::getAc return pStateSetHelper; } -lang::Locale SAL_CALL SvxPixelCtlAccessibleChild::getLocale() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if( mxParent.is() ) - { - uno::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 SvxPixelCtlAccessibleChild::addAccessibleEventListener( const uno::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 SvxPixelCtlAccessibleChild::removeAccessibleEventListener( const uno::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; - } - } -} - -// XServiceInfo -OUString SAL_CALL SvxPixelCtlAccessibleChild::getImplementationName() -{ - return OUString( "SvxPixelCtlAccessibleChild" ); -} - -sal_Bool SAL_CALL SvxPixelCtlAccessibleChild::supportsService( const OUString& rServiceName ) -{ - return cppu::supportsService( this, rServiceName ); -} - -Sequence< OUString > SAL_CALL SvxPixelCtlAccessibleChild::getSupportedServiceNames() -{ - uno::Sequence< OUString > aRet(3); - OUString* pArray = aRet.getArray(); - pArray[0] = "Accessible"; - pArray[1] = "AccessibleContext"; - pArray[2] = "AccessibleComponent"; - return aRet; -} - void SAL_CALL SvxPixelCtlAccessibleChild::disposing() { - if( !rBHelper.bDisposed ) - { - ::osl::MutexGuard aGuard( m_aMutex ); - - // Send a disposing to all listeners. - if ( mnClientId ) - { - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; - } - - mxParent.clear(); - } -} - -void SvxPixelCtlAccessibleChild::ThrowExceptionIfNotAlive() -{ - if( rBHelper.bDisposed || rBHelper.bInDispose ) - throw lang::DisposedException(); + OAccessibleComponentHelper::disposing(); + mxParent.clear(); } -tools::Rectangle SvxPixelCtlAccessibleChild::GetBoundingBoxOnScreen() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox() - tools::Rectangle aRect( GetBoundingBox() ); - - return tools::Rectangle( mrParentWindow.OutputToAbsoluteScreenPixel( aRect.TopLeft() ), aRect.GetSize() ); -} - -tools::Rectangle const & SvxPixelCtlAccessibleChild::GetBoundingBox() +awt::Rectangle SvxPixelCtlAccessibleChild::implGetBounds() { // no guard necessary, because no one changes maBoundingBox after creating it - ThrowExceptionIfNotAlive(); - - return maBoundingBox; + return AWTRectangle(maBoundingBox); } OUString SvxPixelCtlAccessibleChild::GetName() diff --git a/svx/source/accessibility/svxrectctaccessiblecontext.cxx b/svx/source/accessibility/svxrectctaccessiblecontext.cxx index d18fff3ad720..a92bdacbc632 100644 --- a/svx/source/accessibility/svxrectctaccessiblecontext.cxx +++ b/svx/source/accessibility/svxrectctaccessiblecontext.cxx @@ -400,6 +400,7 @@ sal_Int32 SvxRectCtlAccessibleContext::getForeground( ) return sal_Int32(mpRepr->GetControlForeground()); } + sal_Int32 SvxRectCtlAccessibleContext::getBackground( ) { ::SolarMutexGuard aSolarGuard; @@ -705,6 +706,7 @@ Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleChild( Reference< XAccessible > SAL_CALL RectCtlAccessibleContext::getAccessibleParent() { + ::osl::MutexGuard aGuard( m_aMutex ); if (mpRepr) return mpRepr->getAccessibleParent(); return uno::Reference<css::accessibility::XAccessible>(); @@ -732,6 +734,7 @@ OUString SAL_CALL RectCtlAccessibleContext::getAccessibleName() */ 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>(); diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index aee18ab17494..626debc835a8 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -103,14 +103,12 @@ void SvxRectCtl::dispose() Control::dispose(); } - void SvxRectCtl::Resize() { Resize_Impl(); Control::Resize(); } - void SvxRectCtl::Resize_Impl() { aSize = GetOutputSize(); @@ -612,7 +610,7 @@ Reference< XAccessible > SvxRectCtl::CreateAccessible() RectPoint SvxRectCtl::GetApproxRPFromPixPt( const css::awt::Point& r ) const { - return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) ); + return GetRPFromPoint(GetApproxLogPtFromPixPt(Point(r.X, r.Y ))); } BitmapEx& RectCtl::GetRectBitmap() @@ -1135,14 +1133,11 @@ void RectCtl::DoCompletelyDisable(bool bNew) css::uno::Reference< css::accessibility::XAccessible > SvxPixelCtl::CreateAccessible() { - if(!m_xAccess.is()) - { - m_xAccess = new SvxPixelCtlAccessible(*this); - } + if (!m_xAccess.is()) + m_xAccess = new SvxPixelCtlAccessible(this); return m_xAccess.get(); } -//Logic Pixel long SvxPixelCtl::PointToIndex(const Point &aPt) const { long nX = aPt.X() * nLines / aRectSize.Width(); @@ -1170,56 +1165,48 @@ long SvxPixelCtl::GetFocusPosIndex() const return aFocusPosition.getX() + aFocusPosition.getY() * nLines ; } -long SvxPixelCtl::ShowPosition( const Point &pt) +long SvxPixelCtl::ShowPosition( const Point &rPt) { - Point aPt = PixelToLogic( pt ); - - sal_Int32 nX = aPt.X() * nLines / aRectSize.Width(); - sal_Int32 nY = aPt.Y() * nLines / aRectSize.Height(); + sal_Int32 nX = rPt.X() * nLines / aRectSize.Width(); + sal_Int32 nY = rPt.Y() * nLines / aRectSize.Height(); ChangePixel( nX + nY * nLines ); //Solution:Set new focus position and repaint - //Invalidate( Rectangle( aPtTl, aPtBr ) ); aFocusPosition.setX(nX); aFocusPosition.setY(nY); Invalidate(tools::Rectangle(Point(0,0),aRectSize)); - vcl::Window *pTabPage = getNonLayoutParent(this); - if (pTabPage && WindowType::TABPAGE == pTabPage->GetType()) - static_cast<SvxTabPage*>(pTabPage)->PointChanged( this, RectPoint::MM ); // RectPoint is dummy + if (m_pPage) + m_pPage->PointChanged(GetDrawingArea(), RectPoint::MM ); // RectPoint is dummy return GetFocusPosIndex(); } -SvxPixelCtl::SvxPixelCtl(vcl::Window* pParent) - : Control(pParent, WB_BORDER) +SvxPixelCtl::SvxPixelCtl(SvxTabPage* pPage) + : m_pPage(pPage) , bPaintable(true) , aFocusPosition(0,0) { - SetPixelColor( COL_BLACK ); - SetBackgroundColor( COL_WHITE ); - SetLineColor( COL_LIGHTGRAY ); maPixelData.fill(0); } void SvxPixelCtl::Resize() { - Control::Resize(); - aRectSize = GetOutputSize(); + CustomWidgetController::Resize(); + aRectSize = GetOutputSizePixel(); } -Size SvxPixelCtl::GetOptimalSize() const +void SvxPixelCtl::SetDrawingArea(weld::DrawingArea* pDrawingArea) { - return LogicToPixel(Size(72, 72), MapMode(MapUnit::MapAppFont)); + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 25, + pDrawingArea->get_text_height() * 10); + CustomWidgetController::SetDrawingArea(pDrawingArea); } -VCL_BUILDER_FACTORY(SvxPixelCtl) - -SvxPixelCtl::~SvxPixelCtl( ) +SvxPixelCtl::~SvxPixelCtl() { - disposeOnce(); } // Changes the foreground or Background color @@ -1253,8 +1240,16 @@ void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt ) } } -// Draws the Control (Rectangle with nine circles) +tools::Rectangle SvxPixelCtl::GetFocusRect() +{ + tools::Rectangle aRet; + //Draw visual focus when has focus + if (HasFocus()) + aRet = implCalFocusRect(aFocusPosition); + return aRet; +} +// Draws the Control (Rectangle with nine circles) void SvxPixelCtl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) { if (!aRectSize.Width() || !aRectSize.Height()) @@ -1300,11 +1295,6 @@ void SvxPixelCtl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectan rRenderContext.DrawRect(tools::Rectangle(aPtTl, aPtBr)); } } - //Draw visual focus when has focus - if (HasFocus()) - { - ShowFocus(implCalFocusRect(aFocusPosition)); - } } else { @@ -1330,7 +1320,7 @@ tools::Rectangle SvxPixelCtl::implCalFocusRect( const Point& aPosition ) } //Solution:Keyboard function -void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt ) +bool SvxPixelCtl::KeyInput( const KeyEvent& rKEvt ) { vcl::KeyCode aKeyCode = rKEvt.GetKeyCode(); sal_uInt16 nCode = aKeyCode.GetCode(); @@ -1383,8 +1373,7 @@ void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt ) Invalidate( implCalFocusRect(aFocusPosition) ); break; default: - Control::KeyInput( rKEvt ); - return; + return CustomWidgetController::KeyInput( rKEvt ); } if(m_xAccess.is()) { @@ -1407,10 +1396,11 @@ void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt ) break; } } + return true; } else { - Control::KeyInput( rKEvt ); + return CustomWidgetController::KeyInput( rKEvt ); } } @@ -1419,23 +1409,15 @@ void SvxPixelCtl::GetFocus() { Invalidate(implCalFocusRect(aFocusPosition)); - if(m_xAccess.is()) + if (m_xAccess.is()) { m_xAccess->NotifyChild(GetFocusPosIndex(),true,false); } - - Control::GetFocus(); } -//Hide focus when lose focus void SvxPixelCtl::LoseFocus() { - HideFocus(); - if (m_xAccess.is()) - { - m_xAccess->LoseFocus(); - } - Control::LoseFocus(); + Invalidate(); } void SvxPixelCtl::SetXBitmap(const BitmapEx& rBitmapEx) diff --git a/svx/source/inc/svxpixelctlaccessiblecontext.hxx b/svx/source/inc/svxpixelctlaccessiblecontext.hxx index 4f399ea4a7a8..23af17a5c2ea 100644 --- a/svx/source/inc/svxpixelctlaccessiblecontext.hxx +++ b/svx/source/inc/svxpixelctlaccessiblecontext.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <comphelper/accessibleselectionhelper.hxx> #include <cppuhelper/interfacecontainer.h> #include <cppuhelper/compbase6.hxx> #include <cppuhelper/compbase5.hxx> @@ -51,197 +52,121 @@ namespace com { namespace sun { namespace star { namespace awt { class XFocusListener; } } } }; class SvxPixelCtl; +class SvxPixelCtlAccessible; +typedef ::cppu::ImplHelper1<css::accessibility::XAccessible> OAccessibleHelper_Base; -typedef ::cppu::WeakAggComponentImplHelper5< - css::accessibility::XAccessible, - css::accessibility::XAccessibleComponent, - css::accessibility::XAccessibleContext, - css::accessibility::XAccessibleEventBroadcaster, - css::lang::XServiceInfo > - SvxPixelCtlAccessibleChild_BASE; - -class SvxPixelCtlAccessibleChild : - public ::cppu::BaseMutex, - public SvxPixelCtlAccessibleChild_BASE +class SvxPixelCtlAccessibleChild final : public ::comphelper::OAccessibleComponentHelper, + public OAccessibleHelper_Base { - SvxPixelCtl& mrParentWindow; - css::uno::Reference< css::accessibility::XAccessible > mxParent; - bool m_bPixelColorOrBG;//Pixel Color Or BackGround Color - tools::Rectangle maBoundingBox; - /// index of child in parent - long mnIndexInParent; public: SvxPixelCtlAccessibleChild( SvxPixelCtl& rWindow, bool bPixelColorOrBG, const tools::Rectangle& rBounds, - const css::uno::Reference< css::accessibility::XAccessible >& xParent, + const rtl::Reference<SvxPixelCtlAccessible>& xParent, long nIndexInParent ); - virtual ~SvxPixelCtlAccessibleChild() override; - //XAccessible - virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + //XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; //XAccessibleContext virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) 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::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; - virtual css::lang::Locale SAL_CALL getLocale( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + //XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; - //XAccessibleComponent - virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) 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 sal_Int32 SAL_CALL getForeground( ) override; virtual sal_Int32 SAL_CALL getBackground( ) override; - virtual void SAL_CALL grabFocus( ) override; - - //XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) override; - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - - //Methods for XAccessibleEventBroadcaster - sal_uInt32 mnClientId; - - 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; - - //Solution: Add the event handling method - void FireAccessibleEvent (short nEventId, const css::uno::Any& rOld, const css::uno::Any& rNew); - virtual void SAL_CALL disposing() override; - - /// @throws css::uno::RuntimeException - tools::Rectangle GetBoundingBoxOnScreen(); - - /// @throws css::uno::RuntimeException - tools::Rectangle const & GetBoundingBox(); - - /// @returns true if it's disposed or in disposing - inline bool IsAlive() const; - /// @throws css::lang::DisposedException if it's not alive - void ThrowExceptionIfNotAlive(); - void CheckChild(); void SelectChild( bool bSelect); void ChangePixelColorOrBG(bool bPixelColorOrBG){ m_bPixelColorOrBG = bPixelColorOrBG ;} OUString GetName(); -}; +private: + virtual ~SvxPixelCtlAccessibleChild() override; -typedef ::cppu::WeakAggComponentImplHelper6< - css::accessibility::XAccessible, - css::accessibility::XAccessibleComponent, - css::accessibility::XAccessibleContext, - css::accessibility::XAccessibleEventBroadcaster, - css::accessibility::XAccessibleSelection, - css::lang::XServiceInfo > - SvxPixelCtlAccessible_BASE; + virtual void SAL_CALL disposing() override; -class SvxPixelCtlAccessible : - public ::cppu::BaseMutex, - public SvxPixelCtlAccessible_BASE -{ - SvxPixelCtl& mrPixelCtl; + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle + virtual css::awt::Rectangle implGetBounds( ) override; + SvxPixelCtl& mrParentWindow; + rtl::Reference<SvxPixelCtlAccessible> mxParent; + bool m_bPixelColorOrBG;//Pixel Color Or BackGround Color + tools::Rectangle maBoundingBox; + /// index of child in parent + long mnIndexInParent; +}; + +class SvxPixelCtlAccessible final : public ::comphelper::OAccessibleSelectionHelper, + public OAccessibleHelper_Base +{ public: - SvxPixelCtlAccessible(SvxPixelCtl& rWindow); - virtual ~SvxPixelCtlAccessible() override; + SvxPixelCtlAccessible(SvxPixelCtl* pPixelCtl); - //XAccessible - virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + //XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + //XAccessible //XAccessibleContext virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) 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::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; - virtual css::lang::Locale SAL_CALL getLocale( ) override; - + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; - //XAccessibleComponent - virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) 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 css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; virtual sal_Int32 SAL_CALL getForeground( ) override; virtual sal_Int32 SAL_CALL getBackground( ) override; - virtual void SAL_CALL grabFocus( ) override; - //XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) override; - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - // XAccessibleSelection - void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override; - sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override; - void SAL_CALL clearAccessibleSelection( ) override; - void SAL_CALL selectAllAccessibleChildren( ) override; - sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override; - css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override; - void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) override; - - //Methods for XAccessibleEventBroadcaster - sal_uInt32 mnClientId; - - 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; - //Solution: Add the event handling method - void FireAccessibleEvent (short nEventId, const css::uno::Any& rOld, const css::uno::Any& rNew); - virtual void SAL_CALL disposing() override; css::uno::Reference< css::accessibility::XAccessible > CreateChild (long nIndex, Point mPoint); void LoseFocus(); - /// @returns true if it's disposed or in disposing - inline bool IsAlive() const; +private: + virtual ~SvxPixelCtlAccessible() override; + + // OCommonAccessibleSelection + // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual bool implIsSelected(sal_Int32 nAccessibleChildIndex) override; + + // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual void implSelect(sal_Int32 nAccessibleChildIndex, bool bSelect) override; -protected: + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds() override; + + virtual void SAL_CALL disposing() override; + + SvxPixelCtl* mpPixelCtl; css::uno::Reference< css::accessibility::XAccessible> m_xCurChild; + public: void NotifyChild(long nIndex, bool bSelect, bool bCheck); }; -inline bool SvxPixelCtlAccessible::IsAlive() const -{ - return !rBHelper.bDisposed && !rBHelper.bInDispose; -} - -inline bool SvxPixelCtlAccessibleChild::IsAlive() const -{ - return !rBHelper.bDisposed && !rBHelper.bInDispose; -} - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/svxrectctaccessiblecontext.hxx b/svx/source/inc/svxrectctaccessiblecontext.hxx index de5df8a46ad7..6e3fb5b509bd 100644 --- a/svx/source/inc/svxrectctaccessiblecontext.hxx +++ b/svx/source/inc/svxrectctaccessiblecontext.hxx @@ -545,8 +545,8 @@ typedef ::cppu::ImplHelper3 < css::accessibility::XAccessible, css::accessibility::XAccessibleAction > OAccessibleHelper_Base_3; -class RectCtlChildAccessibleContext : public ::comphelper::OAccessibleComponentHelper, - public OAccessibleHelper_Base_3 +class RectCtlChildAccessibleContext final : public ::comphelper::OAccessibleComponentHelper, + public OAccessibleHelper_Base_3 { public: RectCtlChildAccessibleContext( @@ -554,13 +554,6 @@ public: const OUString& rName, const OUString& rDescription, const tools::Rectangle& rBoundingBox, long nIndexInParent ); -protected: - virtual ~RectCtlChildAccessibleContext() override; - - // OCommonAccessibleComponent - /// implements the calculation of the bounding rectangle - still waiting to be overwritten - virtual css::awt::Rectangle implGetBounds( ) override; -public: DECLARE_XINTERFACE( ) DECLARE_XTYPEPROVIDER( ) @@ -608,10 +601,14 @@ public: void setStateChecked(bool bChecked); void FireFocusEvent(); -protected: +private: + virtual ~RectCtlChildAccessibleContext() override; + virtual void SAL_CALL disposing() override; -private: + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle + virtual css::awt::Rectangle implGetBounds( ) override; /** Description of this object. This is not a constant because it can be set from the outside. Furthermore, it changes according to the diff --git a/svx/source/tbxctrls/SvxPresetListBox.cxx b/svx/source/tbxctrls/SvxPresetListBox.cxx index fd320d81009c..d6ee0510a15a 100644 --- a/svx/source/tbxctrls/SvxPresetListBox.cxx +++ b/svx/source/tbxctrls/SvxPresetListBox.cxx @@ -130,4 +130,82 @@ IMPL_LINK(SvxPresetListBox, OnMenuItemSelected, Menu*, pMenu, bool) return false; } +PresetListBox::PresetListBox(std::unique_ptr<weld::ScrolledWindow> pWindow) + : SvtValueSet(std::move(pWindow)) + , nColCount(3) + , aIconSize(60, 64) +{ + SetEdgeBlending(true); + SetExtraSpacing(4); +} + +void PresetListBox::Resize() +{ + DrawLayout(); + WinBits aWinBits(GetStyle()); + aWinBits |= WB_VSCROLL; + SetStyle(aWinBits); + SvtValueSet::Resize(); +} + +bool PresetListBox::ContextMenu(const Point& rPos) +{ + const sal_uInt16 nIndex = GetSelectedItemId(); + if(nIndex > 0) + { + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetDrawingArea(), "svx/ui/presetmenu.ui")); + std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu")); + OnMenuItemSelected(xMenu->popup_at_rect(GetDrawingArea(), tools::Rectangle(rPos, Size(1,1)))); + return true; + } + return false; +} + +void PresetListBox::DrawLayout() +{ + SetColCount(getColumnCount()); + SetLineCount(5); +} + +template< typename ListType, typename EntryType > +void PresetListBox::FillPresetListBoxImpl(ListType & pList, sal_uInt32 nStartIndex) +{ + const Size aSize( GetIconSize() ); + BitmapEx aBitmap; + for(long nIndex = 0; nIndex < pList.Count(); nIndex++, nStartIndex++) + { + aBitmap = pList.GetBitmapForPreview(nIndex, aSize); + EntryType* pItem = static_cast<EntryType*>( pList.Get(nIndex) ); + InsertItem(nStartIndex, Image(aBitmap), pItem->GetName()); + } +} + +void PresetListBox::FillPresetListBox(XGradientList& pList, sal_uInt32 nStartIndex) +{ + FillPresetListBoxImpl< XGradientList, XGradientEntry>( pList, nStartIndex ); +} + +void PresetListBox::FillPresetListBox(XHatchList& pList, sal_uInt32 nStartIndex) +{ + FillPresetListBoxImpl< XHatchList, XHatchEntry>( pList, nStartIndex ); +} + +void PresetListBox::FillPresetListBox(XBitmapList& pList, sal_uInt32 nStartIndex) +{ + FillPresetListBoxImpl< XBitmapList, XBitmapEntry >( pList, nStartIndex ); +} + +void PresetListBox::FillPresetListBox(XPatternList& pList, sal_uInt32 nStartIndex) +{ + FillPresetListBoxImpl< XPatternList, XBitmapEntry >( pList, nStartIndex ); +} + +void PresetListBox::OnMenuItemSelected(const OString& rIdent) +{ + if (rIdent == "rename") + maRenameHdl.Call(this); + else if (rIdent == "delete") + maDeleteHdl.Call(this); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |