diff options
Diffstat (limited to 'chart2/source/controller/accessibility/AccessibleChartView.cxx')
-rw-r--r-- | chart2/source/controller/accessibility/AccessibleChartView.cxx | 217 |
1 files changed, 135 insertions, 82 deletions
diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx index c0dac3c22657..8f01816a6504 100644 --- a/chart2/source/controller/accessibility/AccessibleChartView.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx @@ -18,20 +18,18 @@ */ #include <AccessibleChartView.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <ObjectHierarchy.hxx> #include <ObjectIdentifier.hxx> #include <ResId.hxx> #include <strings.hrc> #include "AccessibleViewForwarder.hxx" #include <ChartModel.hxx> +#include <ChartView.hxx> +#include <ChartController.hxx> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> - -#include <comphelper/servicehelper.hxx> #include <rtl/ustring.hxx> #include <vcl/window.hxx> @@ -113,7 +111,7 @@ Reference< XAccessible > SAL_CALL AccessibleChartView::getAccessibleParent() return Reference< XAccessible >( m_xParent ); } -sal_Int32 SAL_CALL AccessibleChartView::getAccessibleIndexInParent() +sal_Int64 SAL_CALL AccessibleChartView::getAccessibleIndexInParent() { // the document is always the only child of the window return 0; @@ -158,9 +156,11 @@ awt::Point SAL_CALL AccessibleChartView::getLocationOnScreen() return aResult; } -// lang::XInitialization - -void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments ) +void AccessibleChartView::initialize( ChartController& rNewChartController, + const rtl::Reference<::chart::ChartModel>& xNewChartModel, + const rtl::Reference<::chart::ChartView>& xNewChartView, + const uno::Reference< XAccessible >& xNewParent, + const css::uno::Reference<css::awt::XWindow>& xNewWindow ) { //0: view::XSelectionSupplier offers notifications for selection changes and access to the selection itself //1: frame::XModel representing the chart model - offers access to object data @@ -171,125 +171,178 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments bool bOldInvalid = false; bool bNewInvalid = false; - Reference< view::XSelectionSupplier > xSelectionSupplier; + rtl::Reference< ::chart::ChartController > xChartController; rtl::Reference<::chart::ChartModel> xChartModel; - Reference< uno::XInterface > xChartView; + rtl::Reference<::chart::ChartView> xChartView; Reference< XAccessible > xParent; Reference< awt::XWindow > xWindow; { MutexGuard aGuard( m_aMutex); - xSelectionSupplier.set( m_xSelectionSupplier ); + xChartController = m_xChartController; xChartModel = m_xChartModel; - xChartView.set( m_xChartView ); + xChartView = m_xChartView; xParent.set( m_xParent ); xWindow.set( m_xWindow ); } - if( !xSelectionSupplier.is() || !xChartModel.is() || !xChartView.is() ) + if( !xChartController.is() || !xChartModel.is() || !xChartView.is() ) { bOldInvalid = true; } - if( rArguments.getLength() > 1 ) + if( xNewChartModel.get() != xChartModel.get() ) { - Reference< frame::XModel > xNewChartModel; - rArguments[1] >>= xNewChartModel; - assert(!xNewChartModel || dynamic_cast<::chart::ChartModel*>(xNewChartModel.get())); - ::chart::ChartModel* pNewChartModel = dynamic_cast<::chart::ChartModel*>(xNewChartModel.get()); - if( pNewChartModel != xChartModel.get() ) - { - xChartModel = pNewChartModel; - bChanged = true; - } + xChartModel = xNewChartModel; + bChanged = true; } - else if( xChartModel.is() ) + + if( xNewChartView != xChartView ) { + xChartView = xNewChartView; bChanged = true; - xChartModel = nullptr; } - if( rArguments.getLength() > 2 ) + if( xNewParent != xParent ) { - Reference< uno::XInterface > xNewChartView; - rArguments[2] >>= xNewChartView; - if( xNewChartView != xChartView ) - { - xChartView = xNewChartView; - bChanged = true; - } + xParent = xNewParent; + bChanged = true; } - else if( xChartView.is() ) + + if( xNewWindow != xWindow ) { + xWindow = xNewWindow; bChanged = true; - xChartView = nullptr; } - if( rArguments.getLength() > 3 ) + if(xChartController != &rNewChartController) { - Reference< XAccessible > xNewParent; - rArguments[3] >>= xNewParent; - if( xNewParent != xParent ) - { - xParent = xNewParent; - bChanged = true; - } + if (xChartController) + xChartController->removeSelectionChangeListener(this); + rNewChartController.addSelectionChangeListener(this); + xChartController = &rNewChartController; + bChanged = true; } - if( rArguments.getLength() > 4 ) + if( !xChartController.is() || !xChartModel.is() || !xChartView.is() ) { - Reference< awt::XWindow > xNewWindow; - rArguments[4] >>= xNewWindow; - if( xNewWindow != xWindow ) + if(xChartController.is()) { - xWindow.set( xNewWindow ); - bChanged = true; + xChartController->removeSelectionChangeListener(this); + xChartController.clear(); } + xChartModel.clear(); + xChartView.clear(); + xParent.clear(); + xWindow.clear(); + + bNewInvalid = true; } - if( rArguments.hasElements() && xChartModel.is() && xChartView.is() ) { - Reference< view::XSelectionSupplier > xNewSelectionSupplier; - rArguments[0] >>= xNewSelectionSupplier; - if(xSelectionSupplier!=xNewSelectionSupplier) - { - bChanged = true; - if(xSelectionSupplier.is()) - xSelectionSupplier->removeSelectionChangeListener(this); - if(xNewSelectionSupplier.is()) - xNewSelectionSupplier->addSelectionChangeListener(this); - xSelectionSupplier = xNewSelectionSupplier; - } + MutexGuard aGuard( m_aMutex); + m_xChartController = xChartController.get(); + m_xChartModel = xChartModel.get(); + m_xChartView = xChartView.get(); + m_xParent = xParent; + m_xWindow = xWindow; + } + + if( bOldInvalid && bNewInvalid ) + bChanged = false; + + if( !bChanged ) + return; + + { + //before notification we prepare for creation of new context + //the old context will be deleted after notification than + MutexGuard aGuard( m_aMutex); + if( xChartModel.is()) + m_spObjectHierarchy = + std::make_shared<ObjectHierarchy>( xChartModel, m_xChartView.get().get() ); + else + m_spObjectHierarchy.reset(); } - else if( xSelectionSupplier.is() ) + + { + AccessibleElementInfo aAccInfo; + aAccInfo.m_aOID = ObjectIdentifier("ROOT"); + aAccInfo.m_xChartDocument = m_xChartModel; + aAccInfo.m_xChartController = m_xChartController; + aAccInfo.m_xView = m_xChartView; + aAccInfo.m_xWindow = m_xWindow; + aAccInfo.m_pParent = nullptr; + aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; + aAccInfo.m_pSdrView = m_pSdrView; + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xWindow ); + m_pViewForwarder.reset( new AccessibleViewForwarder( this, pWindow ) ); + aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); + // broadcasts an INVALIDATE_ALL_CHILDREN event globally + SetInfo( aAccInfo ); + } +} + +void AccessibleChartView::initialize() +{ + //0: view::XSelectionSupplier offers notifications for selection changes and access to the selection itself + //1: frame::XModel representing the chart model - offers access to object data + //2: lang::XInterface representing the normal chart view - offers access to some extra object data + + //all arguments are only valid until next initialization + bool bChanged = false; + bool bOldInvalid = false; + + rtl::Reference< ::chart::ChartController > xChartController; + rtl::Reference<::chart::ChartModel> xChartModel; + rtl::Reference<::chart::ChartView> xChartView; + Reference< XAccessible > xParent; + Reference< awt::XWindow > xWindow; + { + MutexGuard aGuard( m_aMutex); + xChartController = m_xChartController; + xChartModel = m_xChartModel; + xChartView = m_xChartView; + xParent.set( m_xParent ); + xWindow.set( m_xWindow ); + } + + if( !xChartController.is() || !xChartModel.is() || !xChartView.is() ) + { + bOldInvalid = true; + } + + if( xChartModel.is() ) { bChanged = true; - xSelectionSupplier->removeSelectionChangeListener(this); - xSelectionSupplier = nullptr; + xChartModel = nullptr; } - if( !xSelectionSupplier.is() || !xChartModel.is() || !xChartView.is() ) + if( xChartView.is() ) { - if(xSelectionSupplier.is()) - xSelectionSupplier->removeSelectionChangeListener(this); - xSelectionSupplier = nullptr; - xChartModel.clear(); - xChartView.clear(); - xParent.clear(); - xWindow.clear(); + bChanged = true; + xChartView = nullptr; + } - bNewInvalid = true; + if( xChartController.is() ) + { + bChanged = true; + xChartController->removeSelectionChangeListener(this); + xChartController = nullptr; } + xParent.clear(); + xWindow.clear(); + { MutexGuard aGuard( m_aMutex); - m_xSelectionSupplier = WeakReference< view::XSelectionSupplier >(xSelectionSupplier); + m_xChartController = xChartController.get(); m_xChartModel = xChartModel.get(); - m_xChartView = WeakReference< uno::XInterface >(xChartView); + m_xChartView = xChartView.get(); m_xParent = WeakReference< XAccessible >(xParent); m_xWindow = WeakReference< awt::XWindow >(xWindow); } - if( bOldInvalid && bNewInvalid ) + if( bOldInvalid ) bChanged = false; if( !bChanged ) @@ -301,7 +354,7 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments MutexGuard aGuard( m_aMutex); if( xChartModel.is()) m_spObjectHierarchy = - std::make_shared<ObjectHierarchy>( xChartModel, comphelper::getFromUnoTunnel<ExplicitValueProvider>(m_xChartView) ); + std::make_shared<ObjectHierarchy>( xChartModel, m_xChartView.get().get() ); else m_spObjectHierarchy.reset(); } @@ -310,7 +363,7 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments AccessibleElementInfo aAccInfo; aAccInfo.m_aOID = ObjectIdentifier("ROOT"); aAccInfo.m_xChartDocument = m_xChartModel; - aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier; + aAccInfo.m_xChartController = m_xChartController; aAccInfo.m_xView = m_xChartView; aAccInfo.m_xWindow = m_xWindow; aAccInfo.m_pParent = nullptr; @@ -328,16 +381,16 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /*rEvent*/ ) { - Reference< view::XSelectionSupplier > xSelectionSupplier; + rtl::Reference< ::chart::ChartController > xChartController; { MutexGuard aGuard( m_aMutex); - xSelectionSupplier.set(m_xSelectionSupplier); + xChartController = m_xChartController.get(); } - if( !xSelectionSupplier.is() ) + if( !xChartController.is() ) return; - ObjectIdentifier aSelectedOID( xSelectionSupplier->getSelection() ); + ObjectIdentifier aSelectedOID( xChartController->getSelection() ); if ( m_aCurrentSelectionOID.isValid() ) { NotifyEvent( EventType::LOST_SELECTION, m_aCurrentSelectionOID ); |