summaryrefslogtreecommitdiff
path: root/chart2/source/controller/accessibility/AccessibleChartView.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/accessibility/AccessibleChartView.cxx')
-rw-r--r--chart2/source/controller/accessibility/AccessibleChartView.cxx296
1 files changed, 164 insertions, 132 deletions
diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx
index 0738f52abc36..7216c6bbc665 100644
--- a/chart2/source/controller/accessibility/AccessibleChartView.cxx
+++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx
@@ -18,19 +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>
@@ -41,22 +40,19 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility;
-using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::WeakReference;
-using ::com::sun::star::uno::Any;
using osl::MutexGuard;
namespace chart
{
-AccessibleChartView::AccessibleChartView(SdrView* pView ) :
- impl::AccessibleChartView_Base(
- AccessibleElementInfo(), // empty for now
- true, // has children
- true // always transparent
- ),
- m_pSdrView( pView )
+AccessibleChartView::AccessibleChartView(SdrView* pView)
+ : ImplInheritanceHelper(AccessibleElementInfo(), // empty for now
+ true, // has children
+ true // always transparent
+ )
+ , m_pSdrView(pView)
{
AddState( AccessibleStateType::OPAQUE );
}
@@ -67,20 +63,19 @@ AccessibleChartView::~AccessibleChartView()
awt::Rectangle AccessibleChartView::GetWindowPosSize() const
{
- Reference< awt::XWindow > xWindow( GetInfo().m_xWindow );
- if( ! xWindow.is())
- return awt::Rectangle();
+ SolarMutexGuard aSolarGuard;
- awt::Rectangle aBBox( xWindow->getPosSize() );
+ VclPtr<vcl::Window> pWindow = GetInfo().m_pWindow;
+ if (!pWindow)
+ return awt::Rectangle();
- VclPtr<vcl::Window> pWindow( VCLUnoHelper::GetWindow( GetInfo().m_xWindow ));
- if( pWindow )
- {
- SolarMutexGuard aSolarGuard;
- Point aVCLPoint( pWindow->OutputToAbsoluteScreenPixel( Point( 0, 0 ) ));
- aBBox.X = aVCLPoint.getX();
- aBBox.Y = aVCLPoint.getY();
- }
+ awt::Rectangle aBBox;
+ Point aVCLPoint( pWindow->OutputToAbsoluteScreenPixel( Point( 0, 0 ) ));
+ const Size aSize = pWindow->GetSizePixel();
+ aBBox.X = aVCLPoint.getX();
+ aBBox.Y = aVCLPoint.getY();
+ aBBox.Width = aSize.Width();
+ aBBox.Height = aSize.Height();
return aBBox;
}
@@ -112,7 +107,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;
@@ -123,8 +118,7 @@ sal_Int16 SAL_CALL AccessibleChartView::getAccessibleRole()
return AccessibleRole::DOCUMENT;
}
-// ________ XAccessibleComponent ________
-awt::Rectangle SAL_CALL AccessibleChartView::getBounds()
+awt::Rectangle AccessibleChartView::implGetBounds()
{
awt::Rectangle aResult( GetWindowPosSize());
Reference< XAccessible > xParent( m_xParent );
@@ -141,25 +135,19 @@ awt::Rectangle SAL_CALL AccessibleChartView::getBounds()
return aResult;
}
-awt::Point SAL_CALL AccessibleChartView::getLocationOnScreen()
+
+void SAL_CALL AccessibleChartView::disposing()
{
- awt::Rectangle aBounds( getBounds());
- awt::Point aResult;
- Reference< XAccessible > xParent( m_xParent );
- if( xParent.is())
- {
- Reference< XAccessibleComponent > xAccComp(
- xParent->getAccessibleContext(), uno::UNO_QUERY );
- aResult = xAccComp->getLocationOnScreen();
- aResult.X += aBounds.X;
- aResult.Y += aBounds.Y;
- }
- return aResult;
-}
+ m_pChartWindow.reset();
-// lang::XInitialization
+ AccessibleBase::disposing();
+}
-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,
+ ChartWindow* pNewChartWindow)
{
//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
@@ -170,123 +158,170 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments
bool bOldInvalid = false;
bool bNewInvalid = false;
- Reference< view::XSelectionSupplier > xSelectionSupplier;
- Reference< frame::XModel > xChartModel;
- Reference< uno::XInterface > xChartView;
+ rtl::Reference< ::chart::ChartController > xChartController;
+ rtl::Reference<::chart::ChartModel> xChartModel;
+ rtl::Reference<::chart::ChartView> xChartView;
Reference< XAccessible > xParent;
- Reference< awt::XWindow > xWindow;
+ VclPtr<ChartWindow> pChartWindow;
{
MutexGuard aGuard( m_aMutex);
- xSelectionSupplier.set( m_xSelectionSupplier );
- xChartModel.set( m_xChartModel );
- xChartView.set( m_xChartView );
+ xChartController = m_xChartController;
+ xChartModel = m_xChartModel;
+ xChartView = m_xChartView;
xParent.set( m_xParent );
- xWindow.set( m_xWindow );
+ pChartWindow = m_pChartWindow;
}
- 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;
- if( xNewChartModel != xChartModel )
- {
- xChartModel = xNewChartModel;
- 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 (pNewChartWindow != pChartWindow)
{
+ pChartWindow = pNewChartWindow;
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();
+ pChartWindow.reset();
+
+ 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_pChartWindow = std::move(pChartWindow);
+ }
+
+ 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(u"ROOT"_ustr);
+ aAccInfo.m_xChartDocument = m_xChartModel;
+ aAccInfo.m_xChartController = m_xChartController;
+ aAccInfo.m_xView = m_xChartView;
+ aAccInfo.m_pWindow = m_pChartWindow;
+ aAccInfo.m_pParent = nullptr;
+ aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy;
+ aAccInfo.m_pSdrView = m_pSdrView;
+ m_pViewForwarder.reset(new AccessibleViewForwarder(this, m_pChartWindow));
+ 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;
+ {
+ MutexGuard aGuard( m_aMutex);
+ xChartController = m_xChartController;
+ xChartModel = m_xChartModel;
+ xChartView = m_xChartView;
+ }
+
+ 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;
}
{
MutexGuard aGuard( m_aMutex);
- m_xSelectionSupplier = WeakReference< view::XSelectionSupplier >(xSelectionSupplier);
- m_xChartModel = WeakReference< frame::XModel >(xChartModel);
- m_xChartView = WeakReference< uno::XInterface >(xChartView);
- m_xParent = WeakReference< XAccessible >(xParent);
- m_xWindow = WeakReference< awt::XWindow >(xWindow);
+ m_xChartController = xChartController.get();
+ m_xChartModel = xChartModel.get();
+ m_xChartView = xChartView.get();
+ m_xParent.clear();
+ m_pChartWindow.reset();
}
- if( bOldInvalid && bNewInvalid )
+ if( bOldInvalid )
bChanged = false;
if( !bChanged )
@@ -296,27 +331,24 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments
//before notification we prepare for creation of new context
//the old context will be deleted after notification than
MutexGuard aGuard( m_aMutex);
- Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY );
- if( xChartDoc.is())
+ if( xChartModel.is())
m_spObjectHierarchy =
- std::make_shared<ObjectHierarchy>( xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(m_xChartView) );
+ std::make_shared<ObjectHierarchy>( xChartModel, m_xChartView.get().get() );
else
m_spObjectHierarchy.reset();
}
{
AccessibleElementInfo aAccInfo;
- aAccInfo.m_aOID = ObjectIdentifier("ROOT");
- aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument >(
- uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY ));
- aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier;
+ aAccInfo.m_aOID = ObjectIdentifier(u"ROOT"_ustr);
+ aAccInfo.m_xChartDocument = m_xChartModel;
+ aAccInfo.m_xChartController = m_xChartController;
aAccInfo.m_xView = m_xChartView;
- aAccInfo.m_xWindow = m_xWindow;
+ aAccInfo.m_pWindow.reset();
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 ) );
+ m_pViewForwarder.reset(new AccessibleViewForwarder(this, nullptr));
aAccInfo.m_pViewForwarder = m_pViewForwarder.get();
// broadcasts an INVALIDATE_ALL_CHILDREN event globally
SetInfo( aAccInfo );
@@ -327,16 +359,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 );
@@ -345,7 +377,7 @@ void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /*
{
NotifyEvent( EventType::GOT_SELECTION, aSelectedOID );
}
- m_aCurrentSelectionOID = aSelectedOID;
+ m_aCurrentSelectionOID = std::move(aSelectedOID);
}
// XEventListener