diff options
Diffstat (limited to 'chart2/source/controller/main/ChartController.cxx')
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 897 |
1 files changed, 510 insertions, 387 deletions
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index f81b261182fa..d49f49497f9f 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -20,69 +20,69 @@ #include <memory> #include <sal/config.h> -#include <set> - +#include <config_wasm_strip.h> #include <ChartController.hxx> +#include <ChartView.hxx> #include <servicenames.hxx> #include <ResId.hxx> #include <dlg_DataSource.hxx> #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> #include "ControllerCommandDispatch.hxx" +#include <DataSeries.hxx> +#include <Diagram.hxx> #include <strings.hrc> -#include <chartview/ExplicitValueProvider.hxx> #include <ChartViewHelper.hxx> #include <ChartWindow.hxx> #include <chartview/DrawModelWrapper.hxx> #include <DrawViewWrapper.hxx> #include <ObjectIdentifier.hxx> -#include <DiagramHelper.hxx> #include <ControllerLockGuard.hxx> #include "UndoGuard.hxx" #include "ChartDropTargetHelper.hxx" #include <dlg_ChartType.hxx> +#if !ENABLE_WASM_STRIP_ACCESSIBILITY #include <AccessibleChartView.hxx> +#endif #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" #include "UndoActions.hxx" #include <ViewElementListProvider.hxx> -#include <cppuhelper/supportsservice.hxx> +#include <comphelper/dispatchcommand.hxx> +#include <BaseCoordinateSystem.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/frame/XController2.hpp> #include <com/sun/star/util/CloseVetoException.hpp> -#include <com/sun/star/util/XModeChangeBroadcaster.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/frame/LayoutManagerEvents.hpp> #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp> -#include <com/sun/star/document/XUndoManagerSupplier.hpp> #include <com/sun/star/ui/XSidebar.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/chart2/XDataProviderAccess.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <sal/log.hxx> #include <tools/debug.hxx> #include <svx/sidebar/SelectionChangeHandler.hxx> -#include <toolkit/awt/vclxwindow.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <utility> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <osl/mutex.hxx> +#include <comphelper/lok.hxx> #include <sfx2/sidebar/SidebarController.hxx> - +#include <com/sun/star/awt/XVclWindowPeer.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> // this is needed to properly destroy the unique_ptr to the AcceleratorExecute // object in the DTOR #include <svtools/acceleratorexecute.hxx> #include <svx/ActionDescriptionProvider.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> + +#include <editeng/fontitem.hxx> // enable the following define to let the controller listen to model changes and // react on this by rebuilding the view @@ -97,16 +97,13 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -ChartController::ChartController(uno::Reference<uno::XComponentContext> const & xContext) : +ChartController::ChartController(uno::Reference<uno::XComponentContext> xContext) : m_aLifeTimeManager( nullptr ), m_bSuspended( false ), - m_xCC(xContext), //@todo is it allowed to hold this context?? - m_aModelMutex(), + m_xCC(std::move(xContext)), m_aModel( nullptr, m_aModelMutex ), - m_xViewWindow(), - m_xChartView(), - m_pDrawModelWrapper(), m_eDragMode(SdrDragMode::Move), + m_aDoubleClickTimer("chart2 ChartController m_aDoubleClickTimer"), m_bWaitingForDoubleClick(false), m_bWaitingForMouseUp(false), m_bFieldButtonDown(false), @@ -126,12 +123,10 @@ ChartController::~ChartController() stopDoubleClickWaiting(); } -ChartController::TheModel::TheModel( const uno::Reference< frame::XModel > & xModel ) : - m_xModel( xModel ), +ChartController::TheModel::TheModel( rtl::Reference<::chart::ChartModel> xModel ) : + m_xModel(std::move( xModel )), m_bOwnership( true ) { - m_xCloseable = - uno::Reference< util::XCloseable >( xModel, uno::UNO_QUERY ); } ChartController::TheModel::~TheModel() @@ -140,33 +135,22 @@ ChartController::TheModel::~TheModel() void ChartController::TheModel::addListener( ChartController* pController ) { - if(m_xCloseable.is()) + if(m_xModel) { //if you need to be able to veto against the destruction of the model // you must add as a close listener //otherwise you 'can' add as closelistener or 'must' add as dispose event listener - m_xCloseable->addCloseListener( - static_cast<util::XCloseListener*>(pController) ); - } - else if( m_xModel.is() ) - { - //we need to add as dispose event listener - m_xModel->addEventListener( + m_xModel->addCloseListener( static_cast<util::XCloseListener*>(pController) ); } - } void ChartController::TheModel::removeListener( ChartController* pController ) { - if(m_xCloseable.is()) - m_xCloseable->removeCloseListener( - static_cast<util::XCloseListener*>(pController) ); - - else if( m_xModel.is() ) - m_xModel->removeEventListener( + if(m_xModel) + m_xModel->removeCloseListener( static_cast<util::XCloseListener*>(pController) ); } @@ -177,7 +161,7 @@ void ChartController::TheModel::tryTermination() try { - if(m_xCloseable.is()) + if(m_xModel.is()) { try { @@ -185,7 +169,7 @@ void ChartController::TheModel::tryTermination() //I think yes, because there might be other CloseListeners later in the list which might be interested still //but make sure that we do not throw the CloseVetoException here ourselves //so stop listening before trying to terminate or check the source of queryclosing event - m_xCloseable->close(true); + m_xModel->close(true); m_bOwnership = false; } @@ -200,12 +184,6 @@ void ChartController::TheModel::tryTermination() } } - else if( m_xModel.is() ) - { - //@todo correct?? - m_xModel->dispose(); - return; - } } catch(const uno::Exception&) { @@ -249,26 +227,17 @@ bool ChartController::TheModelRef::is() const namespace { -css::uno::Reference<css::chart2::XChartType> getChartType( - const css::uno::Reference<css::chart2::XChartDocument>& xChartDoc) +rtl::Reference<ChartType> getChartType(const rtl::Reference<ChartModel>& xChartDoc) { - Reference <chart2::XDiagram > xDiagram = xChartDoc->getFirstDiagram(); - if (!xDiagram.is()) { - return css::uno::Reference<css::chart2::XChartType>(); - } - - Reference< chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY_THROW ); - - Sequence< Reference< chart2::XCoordinateSystem > > xCooSysSequence( xCooSysContainer->getCoordinateSystems()); - if (!xCooSysSequence.hasElements()) { - return css::uno::Reference<css::chart2::XChartType>(); - } - - Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[0], uno::UNO_QUERY_THROW ); + rtl::Reference<Diagram > xDiagram = xChartDoc->getFirstChartDiagram(); + if (!xDiagram.is()) + return nullptr; - Sequence< Reference< chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() ); + const std::vector< rtl::Reference< BaseCoordinateSystem > > xCooSysSequence( xDiagram->getBaseCoordinateSystems()); + if (xCooSysSequence.empty()) + return nullptr; - return xChartTypeSequence[0]; + return xCooSysSequence[0]->getChartTypes2()[0]; } } @@ -280,43 +249,49 @@ OUString ChartController::GetContextName() uno::Any aAny = getSelection(); if (!aAny.hasValue()) - return "Chart"; + return u"Chart"_ustr; OUString aCID; aAny >>= aCID; if (aCID.isEmpty()) - return "Chart"; + return u"Chart"_ustr; ObjectType eObjectID = ObjectIdentifier::getObjectType(aCID); switch (eObjectID) { case OBJECTTYPE_DATA_SERIES: - return "Series"; - break; + return u"Series"_ustr; case OBJECTTYPE_DATA_ERRORS_X: case OBJECTTYPE_DATA_ERRORS_Y: case OBJECTTYPE_DATA_ERRORS_Z: - return "ErrorBar"; + return u"ErrorBar"_ustr; case OBJECTTYPE_AXIS: - return "Axis"; + return u"Axis"_ustr; case OBJECTTYPE_GRID: - return "Grid"; + return u"Grid"_ustr; case OBJECTTYPE_DIAGRAM: { - css::uno::Reference<css::chart2::XChartType> xChartType = getChartType(css::uno::Reference<css::chart2::XChartDocument>(getModel(), uno::UNO_QUERY)); + rtl::Reference<ChartType> xChartType = getChartType(getChartModel()); if (xChartType.is() && xChartType->getChartType() == "com.sun.star.chart2.PieChartType") - return "ChartElements"; + return u"ChartElements"_ustr; break; } case OBJECTTYPE_DATA_CURVE: case OBJECTTYPE_DATA_AVERAGE_LINE: - return "Trendline"; + return u"Trendline"_ustr; + case OBJECTTYPE_TITLE: + return u"ChartTitle"_ustr; + case OBJECTTYPE_LEGEND: + return u"ChartLegend"_ustr; + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_LABELS: + return u"ChartLabel"_ustr; default: break; } - return "Chart"; + return u"Chart"_ustr; } // private methods @@ -334,27 +309,6 @@ bool ChartController::impl_isDisposedOrSuspended() const return false; } -// lang::XServiceInfo - -OUString SAL_CALL ChartController::getImplementationName() -{ - return CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME; -} - -sal_Bool SAL_CALL ChartController::supportsService( const OUString& rServiceName ) -{ - return cppu::supportsService(this, rServiceName); -} - -css::uno::Sequence< OUString > SAL_CALL ChartController::getSupportedServiceNames() -{ - return { - CHART_CONTROLLER_SERVICE_NAME, - "com.sun.star.frame.Controller" - //// @todo : add additional services if you support any further - }; -} - namespace { uno::Reference<ui::XSidebar> getSidebarFromModel(const uno::Reference<frame::XModel>& xModel) @@ -390,19 +344,6 @@ void SAL_CALL ChartController::attachFrame( if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended? return; //behave passive if already disposed or suspended - mpSelectionChangeHandler->Connect(); - - uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel()); - if (xSidebar.is()) - { - auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get()); - assert(pSidebar); - sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this); - pSidebar->updateModel(getModel()); - css::lang::EventObject aEvent; - mpSelectionChangeHandler->selectionChanged(aEvent); - } - if(m_xFrame.is()) //what happens, if we do have a Frame already?? { //@todo? throw exception? @@ -413,6 +354,20 @@ void SAL_CALL ChartController::attachFrame( //--attach frame m_xFrame = xFrame; //the frameloader is responsible to call xFrame->setComponent + // Only notify after setting the frame, otherwise notification will fail + mpSelectionChangeHandler->Connect(); + + uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getChartModel()); + if (xSidebar.is()) + { + auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get()); + assert(pSidebar); + pSidebar->registerSidebarForFrame(this); + pSidebar->updateModel(getChartModel()); + css::lang::EventObject aEvent; + mpSelectionChangeHandler->selectionChanged(aEvent); + } + //add as disposelistener to the frame (due to persistent reference) ??...: //the frame is considered to be owner of this controller and will live longer than we do @@ -427,13 +382,10 @@ void SAL_CALL ChartController::attachFrame( //get the window parent from the frame to use as parent for our new window if(xFrame.is()) { - uno::Reference< awt::XWindow > xContainerWindow = xFrame->getContainerWindow(); - VCLXWindow* pParentComponent = comphelper::getUnoTunnelImplementation<VCLXWindow>(xContainerWindow); - assert(pParentComponent); - if (pParentComponent) - pParentComponent->setVisible(true); - - pParent = VCLUnoHelper::GetWindow( xContainerWindow ).get(); + uno::Reference<awt::XWindow> xContainerWindow = xFrame->getContainerWindow(); + if (xContainerWindow) + xContainerWindow->setVisible(true); + pParent = VCLUnoHelper::GetWindow( xContainerWindow ); } { @@ -444,8 +396,7 @@ void SAL_CALL ChartController::attachFrame( m_xViewWindow.set( pChartWindow->GetComponentInterface(), uno::UNO_QUERY ); pChartWindow->Show(); m_apDropTargetHelper.reset( - new ChartDropTargetHelper( pChartWindow->GetDropTarget(), - uno::Reference< chart2::XChartDocument >( getModel(), uno::UNO_QUERY ))); + new ChartDropTargetHelper( pChartWindow->GetDropTarget(), getChartModel())); impl_createDrawViewController(); } @@ -458,23 +409,23 @@ void SAL_CALL ChartController::attachFrame( try { uno::Reference< css::frame::XLayoutManager > xLayoutManager; - xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager; + xPropSet->getPropertyValue( u"LayoutManager"_ustr ) >>= xLayoutManager; if ( xLayoutManager.is() ) { xLayoutManager->lock(); - xLayoutManager->requestElement( "private:resource/menubar/menubar" ); + xLayoutManager->requestElement( u"private:resource/menubar/menubar"_ustr ); //@todo: createElement should become unnecessary, remove when #i79198# is fixed - xLayoutManager->createElement( "private:resource/toolbar/standardbar" ); - xLayoutManager->requestElement( "private:resource/toolbar/standardbar" ); + xLayoutManager->createElement( u"private:resource/toolbar/standardbar"_ustr ); + xLayoutManager->requestElement( u"private:resource/toolbar/standardbar"_ustr ); //@todo: createElement should become unnecessary, remove when #i79198# is fixed - xLayoutManager->createElement( "private:resource/toolbar/toolbar" ); - xLayoutManager->requestElement( "private:resource/toolbar/toolbar" ); + xLayoutManager->createElement( u"private:resource/toolbar/toolbar"_ustr ); + xLayoutManager->requestElement( u"private:resource/toolbar/toolbar"_ustr ); // #i12587# support for shapes in chart - xLayoutManager->createElement( "private:resource/toolbar/drawbar" ); - xLayoutManager->requestElement( "private:resource/toolbar/drawbar" ); + xLayoutManager->createElement( u"private:resource/toolbar/drawbar"_ustr ); + xLayoutManager->requestElement( u"private:resource/toolbar/drawbar"_ustr ); - xLayoutManager->requestElement( "private:resource/statusbar/statusbar" ); + xLayoutManager->requestElement( u"private:resource/statusbar/statusbar"_ustr ); xLayoutManager->unlock(); // add as listener to get notified when @@ -537,14 +488,11 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent if( m_aSelection.hasSelection() ) this->impl_selectObjectAndNotiy(); else - ChartModelHelper::triggerRangeHighlighting( getModel() ); + getChartModel()->triggerRangeHighlighting(); impl_initializeAccessible(); - { - if( pChartWindow ) - pChartWindow->Invalidate(); - } + pChartWindow->Invalidate(); } m_bConnectingToView = false; @@ -565,23 +513,24 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo return false; //behave passive if already disposed or suspended aGuard.clear(); - TheModelRef aNewModelRef( new TheModel( xModel), m_aModelMutex); + ::chart::ChartModel* pChartModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pChartModel); + + TheModelRef aNewModelRef( new TheModel(pChartModel), m_aModelMutex); TheModelRef aOldModelRef(m_aModel,m_aModelMutex); m_aModel = aNewModelRef; //--handle relations to the old model if any if( aOldModelRef.is() ) { - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->removeModeChangeListener(this); + if( m_xChartView.is() ) + m_xChartView->removeModeChangeListener(this); m_pDrawModelWrapper.reset(); aOldModelRef->removeListener( this ); #ifdef TEST_ENABLE_MODIFY_LISTENER - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aOldModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->removeModifyListener( this ); + if( aOldModelRef->getModel().is()) + aOldModelRef->getModel()->removeModifyListener( this ); #endif } @@ -591,7 +540,7 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo aGuard.reset(); // lock for m_aDispatchContainer access // set new model at dispatchers m_aDispatchContainer.setModel( aNewModelRef->getModel()); - ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this, &m_aDispatchContainer ); + rtl::Reference<ControllerCommandDispatch> pDispatch = new ControllerCommandDispatch( m_xCC, this, &m_aDispatchContainer ); pDispatch->initialize(); // the dispatch container will return "this" for all commands returned by @@ -599,33 +548,30 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo // is called here at the ChartController. m_aDispatchContainer.setChartDispatch( pDispatch, impl_getAvailableCommands() ); - DrawCommandDispatch* pDrawDispatch = new DrawCommandDispatch( m_xCC, this ); + rtl::Reference<DrawCommandDispatch> pDrawDispatch = new DrawCommandDispatch( m_xCC, this ); pDrawDispatch->initialize(); - m_aDispatchContainer.setDrawCommandDispatch( pDrawDispatch ); + m_aDispatchContainer.setDrawCommandDispatch( pDrawDispatch.get() ); - ShapeController* pShapeController = new ShapeController( m_xCC, this ); + rtl::Reference<ShapeController> pShapeController = new ShapeController( m_xCC, this ); pShapeController->initialize(); - m_aDispatchContainer.setShapeController( pShapeController ); + m_aDispatchContainer.setShapeController( pShapeController.get() ); aGuard.clear(); #ifdef TEST_ENABLE_MODIFY_LISTENER - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->addModifyListener( this ); + if( aNewModelRef->getModel().is()) + aNewModelRef->getModel()->addModifyListener( this ); #endif // #i119999# Do not do this per default to allow the user to deselect the chart OLE with a single press to ESC // select chart area per default: // select( uno::Any( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ) ); - uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xFact = getChartModel(); if( xFact.is()) { - m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); + m_xChartView = xFact->createChartView(); GetDrawModelWrapper(); - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->addModeChangeListener(this); + m_xChartView->addModeChangeListener(this); } //the frameloader is responsible to call xModel->connectController @@ -636,8 +582,7 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo pChartWindow->Invalidate(); } - uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + m_xUndoManager.set( getChartModel()->getUndoManager(), uno::UNO_SET_THROW ); return true; } @@ -652,6 +597,11 @@ uno::Reference< frame::XFrame > SAL_CALL ChartController::getFrame() uno::Reference< frame::XModel > SAL_CALL ChartController::getModel() { + return getChartModel(); +} + +rtl::Reference<::chart::ChartModel> ChartController::getChartModel() +{ //provides access to currently attached model //returns the currently attached model @@ -660,7 +610,12 @@ uno::Reference< frame::XModel > SAL_CALL ChartController::getModel() if(aModelRef.is()) return aModelRef->getModel(); - return uno::Reference< frame::XModel > (); + return nullptr; +} + +rtl::Reference<::chart::Diagram> ChartController::getFirstDiagram() +{ + return getChartModel()->getFirstChartDiagram(); } uno::Any SAL_CALL ChartController::getViewData() @@ -716,6 +671,24 @@ sal_Bool SAL_CALL ChartController::suspend( sal_Bool bSuspend ) return true; } +// css::frame::XController2 + +css::uno::Reference<css::awt::XWindow> SAL_CALL ChartController::getComponentWindow() +{ + // it is a special characteristic of ChartController + // that it simultaneously provides the XWindow functionality + return this; +} + +OUString SAL_CALL ChartController::getViewControllerName() { return {}; } + +css::uno::Sequence<css::beans::PropertyValue> SAL_CALL ChartController::getCreationArguments() +{ + return {}; +} + +css::uno::Reference<css::ui::XSidebarProvider> SAL_CALL ChartController::getSidebar() { return {}; } + void ChartController::impl_createDrawViewController() { SolarMutexGuard aGuard; @@ -723,8 +696,21 @@ void ChartController::impl_createDrawViewController() { if( m_pDrawModelWrapper ) { - m_pDrawViewWrapper.reset( new DrawViewWrapper(m_pDrawModelWrapper->getSdrModel(),GetChartWindow()) ); - m_pDrawViewWrapper->attachParentReferenceDevice( getModel() ); + bool bLokCalcGlobalRTL = false; + if(comphelper::LibreOfficeKit::isActive() && AllSettings::GetLayoutRTL()) + { + rtl::Reference< ChartModel > xChartModel = getChartModel(); + if (xChartModel.is()) + { + uno::Reference<css::sheet::XSpreadsheetDocument> xSSDoc(xChartModel->getParent(), uno::UNO_QUERY); + if (xSSDoc.is()) + bLokCalcGlobalRTL = true; + } + } + + m_pDrawViewWrapper.reset( new DrawViewWrapper(m_pDrawModelWrapper->getSdrModel(),GetChartWindow()->GetOutDev()) ); + m_pDrawViewWrapper->SetNegativeX(bLokCalcGlobalRTL); + m_pDrawViewWrapper->attachParentReferenceDevice( getChartModel() ); } } } @@ -746,16 +732,17 @@ void SAL_CALL ChartController::dispose() { m_bDisposed = true; + mpSelectionChangeHandler->selectionChanged(css::lang::EventObject()); + mpSelectionChangeHandler->Disconnect(); + if (getModel().is()) { - uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel()); + uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getChartModel()); if (sfx2::sidebar::SidebarController* pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get())) { - sfx2::sidebar::SidebarController::unregisterSidebarForFrame(pSidebar, this); + pSidebar->unregisterSidebarForFrame(this); } } - mpSelectionChangeHandler->selectionChanged(css::lang::EventObject()); - mpSelectionChangeHandler->Disconnect(); try { @@ -776,7 +763,7 @@ void SAL_CALL ChartController::dispose() if( m_aModel.is()) { uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener; - uno::Reference< chart2::data::XDataReceiver > xDataReceiver( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xDataReceiver = getChartModel(); if( xDataReceiver.is() ) xSelectionChangeListener.set( xDataReceiver->getRangeHighlighter(), uno::UNO_QUERY ); if( xSelectionChangeListener.is() ) @@ -789,9 +776,8 @@ void SAL_CALL ChartController::dispose() //--release all resources and references { - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->removeModeChangeListener(this); + if( m_xChartView.is() ) + m_xChartView->removeModeChangeListener(this); impl_invalidateAccessible(); SolarMutexGuard aSolarGuard; @@ -810,7 +796,7 @@ void SAL_CALL ChartController::dispose() if( m_xLayoutManagerEventBroadcaster.is()) { m_xLayoutManagerEventBroadcaster->removeLayoutManagerEventListener( this ); - m_xLayoutManagerEventBroadcaster.set( nullptr ); + m_xLayoutManagerEventBroadcaster.clear(); } m_xFrame.clear(); @@ -821,7 +807,7 @@ void SAL_CALL ChartController::dispose() if( aModelRef.is()) { - uno::Reference< frame::XModel > xModel( aModelRef->getModel() ); + rtl::Reference< ChartModel > xModel( aModelRef->getModel() ); if(xModel.is()) xModel->disconnectController( uno::Reference< frame::XController >( this )); @@ -829,9 +815,8 @@ void SAL_CALL ChartController::dispose() #ifdef TEST_ENABLE_MODIFY_LISTENER try { - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->removeModifyListener( this ); + if( aModelRef->getModel().is()) + aModelRef->getModel()->removeModifyListener( this ); } catch( const uno::Exception & ) { @@ -857,12 +842,12 @@ void SAL_CALL ChartController::dispose() void SAL_CALL ChartController::addEventListener( const uno::Reference<lang::XEventListener>& xListener ) { - SolarMutexGuard aGuard; if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode? return; //behave passive if already disposed or suspended //--add listener - m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aEventListeners.addInterface( aGuard2, xListener ); } void SAL_CALL ChartController::removeEventListener( @@ -873,7 +858,8 @@ void SAL_CALL ChartController::removeEventListener( return; //behave passive if already disposed or suspended //--remove listener - m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aEventListeners.removeInterface( aGuard2, xListener ); } // util::XCloseListener @@ -888,7 +874,7 @@ void SAL_CALL ChartController::queryClosing( if( !aModelRef.is() ) return; - if( aModelRef->getModel() != rSource.Source ) + if( uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(aModelRef->getModel().get())) != rSource.Source ) { OSL_FAIL( "queryClosing was called on a controller from an unknown source" ); return; @@ -932,7 +918,7 @@ bool ChartController::impl_releaseThisModel( bool bReleaseModel = false; { ::osl::Guard< ::osl::Mutex > aGuard( m_aModelMutex ); - if( m_aModel.is() && m_aModel->getModel() == xModel ) + if( m_aModel.is() && uno::Reference< uno::XInterface >(static_cast<cppu::OWeakObject*>(m_aModel->getModel().get())) == xModel ) { m_aModel = nullptr; m_xUndoManager.clear(); @@ -954,7 +940,7 @@ void SAL_CALL ChartController::disposing( if( !impl_releaseThisModel( rSource.Source )) { if( rSource.Source == m_xLayoutManagerEventBroadcaster ) - m_xLayoutManagerEventBroadcaster.set( nullptr ); + m_xLayoutManagerEventBroadcaster.clear(); } } @@ -968,8 +954,8 @@ void SAL_CALL ChartController::layoutEvent( Reference< frame::XLayoutManager > xLM( aSource.Source, uno::UNO_QUERY ); if( xLM.is()) { - xLM->createElement( "private:resource/statusbar/statusbar" ); - xLM->requestElement( "private:resource/statusbar/statusbar" ); + xLM->createElement( u"private:resource/statusbar/statusbar"_ustr ); + xLM->requestElement( u"private:resource/statusbar/statusbar"_ustr ); } } } @@ -979,55 +965,55 @@ void SAL_CALL ChartController::layoutEvent( namespace { -bool lcl_isFormatObjectCommand( const OUString& aCommand ) -{ - return aCommand == "MainTitle" - || aCommand == "SubTitle" - || aCommand == "XTitle" - || aCommand == "YTitle" - || aCommand == "ZTitle" - || aCommand == "SecondaryXTitle" - || aCommand == "SecondaryYTitle" - || aCommand == "AllTitles" - || aCommand == "DiagramAxisX" - || aCommand == "DiagramAxisY" - || aCommand == "DiagramAxisZ" - || aCommand == "DiagramAxisA" - || aCommand == "DiagramAxisB" - || aCommand == "DiagramAxisAll" - || aCommand == "DiagramGridXMain" - || aCommand == "DiagramGridYMain" - || aCommand == "DiagramGridZMain" - || aCommand == "DiagramGridXHelp" - || aCommand == "DiagramGridYHelp" - || aCommand == "DiagramGridZHelp" - || aCommand == "DiagramGridAll" - - || aCommand == "DiagramWall" - || aCommand == "DiagramFloor" - || aCommand == "DiagramArea" - || aCommand == "Legend" - - || aCommand == "FormatWall" - || aCommand == "FormatFloor" - || aCommand == "FormatChartArea" - || aCommand == "FormatLegend" - - || aCommand == "FormatTitle" - || aCommand == "FormatAxis" - || aCommand == "FormatDataSeries" - || aCommand == "FormatDataPoint" - || aCommand == "FormatDataLabels" - || aCommand == "FormatDataLabel" - || aCommand == "FormatXErrorBars" - || aCommand == "FormatYErrorBars" - || aCommand == "FormatMeanValue" - || aCommand == "FormatTrendline" - || aCommand == "FormatTrendlineEquation" - || aCommand == "FormatStockLoss" - || aCommand == "FormatStockGain" - || aCommand == "FormatMajorGrid" - || aCommand == "FormatMinorGrid"; +bool lcl_isFormatObjectCommand( std::u16string_view aCommand ) +{ + return aCommand == u"MainTitle" + || aCommand == u"SubTitle" + || aCommand == u"XTitle" + || aCommand == u"YTitle" + || aCommand == u"ZTitle" + || aCommand == u"SecondaryXTitle" + || aCommand == u"SecondaryYTitle" + || aCommand == u"AllTitles" + || aCommand == u"DiagramAxisX" + || aCommand == u"DiagramAxisY" + || aCommand == u"DiagramAxisZ" + || aCommand == u"DiagramAxisA" + || aCommand == u"DiagramAxisB" + || aCommand == u"DiagramAxisAll" + || aCommand == u"DiagramGridXMain" + || aCommand == u"DiagramGridYMain" + || aCommand == u"DiagramGridZMain" + || aCommand == u"DiagramGridXHelp" + || aCommand == u"DiagramGridYHelp" + || aCommand == u"DiagramGridZHelp" + || aCommand == u"DiagramGridAll" + + || aCommand == u"DiagramWall" + || aCommand == u"DiagramFloor" + || aCommand == u"DiagramArea" + || aCommand == u"Legend" + + || aCommand == u"FormatWall" + || aCommand == u"FormatFloor" + || aCommand == u"FormatChartArea" + || aCommand == u"FormatLegend" + + || aCommand == u"FormatTitle" + || aCommand == u"FormatAxis" + || aCommand == u"FormatDataSeries" + || aCommand == u"FormatDataPoint" + || aCommand == u"FormatDataLabels" + || aCommand == u"FormatDataLabel" + || aCommand == u"FormatXErrorBars" + || aCommand == u"FormatYErrorBars" + || aCommand == u"FormatMeanValue" + || aCommand == u"FormatTrendline" + || aCommand == u"FormatTrendlineEquation" + || aCommand == u"FormatStockLoss" + || aCommand == u"FormatStockGain" + || aCommand == u"FormatMajorGrid" + || aCommand == u"FormatMinorGrid"; } } // anonymous namespace @@ -1042,7 +1028,7 @@ uno::Reference<frame::XDispatch> SAL_CALL if ( !m_aLifeTimeManager.impl_isDisposed() && getModel().is() ) { - if( !rTargetFrameName.isEmpty() && rTargetFrameName == "_self" ) + if (rTargetFrameName == "_self") return m_aDispatchContainer.getDispatchForURL( rURL ); } return uno::Reference< frame::XDispatch > (); @@ -1104,6 +1090,37 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_PositionAndSize(&rArgs); } } + else if(aCommand == "FillColor") + { + if (rArgs.getLength() > 0) + { + sal_uInt32 nColor; + if (rArgs[0].Value >>= nColor) + this->executeDispatch_FillColor(nColor); + } + } + else if(aCommand == "XLineColor") + { + if (rArgs.getLength() > 0) + { + sal_Int32 nColor = -1; + rArgs[0].Value >>= nColor; + this->executeDispatch_LineColor(nColor); + } + } + else if(aCommand == "LineWidth") + { + if (rArgs.getLength() > 0) + { + sal_Int32 nWidth = -1; + rArgs[0].Value >>= nWidth; + this->executeDispatch_LineWidth(nWidth); + } + } + else if(aCommand.startsWith("FillGradient")) + { + this->executeDispatch_FillGradient(aCommand.subView(aCommand.indexOf('=') + 1)); + } else if(aCommand == "Paste") this->executeDispatch_Paste(); else if(aCommand == "Copy" ) @@ -1114,7 +1131,7 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_SourceData(); else if(aCommand == "Update" ) //Update Chart { - ChartViewHelper::setViewToDirtyState( getModel() ); + ChartViewHelper::setViewToDirtyState( getChartModel() ); SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); if( pChartWindow ) @@ -1147,6 +1164,8 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_InsertErrorBars(false); else if( aCommand == "InsertMenuYErrorBars" ) this->executeDispatch_InsertErrorBars(true); + else if( aCommand == "InsertMenuDataTable" ) + this->executeDispatch_OpenInsertDataTableDialog(); else if( aCommand == "InsertSymbol" ) this->executeDispatch_InsertSpecialCharacter(); else if( aCommand == "InsertTrendline" ) @@ -1201,6 +1220,10 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_DeleteMajorGrid(); else if( aCommand == "DeleteMinorGrid" ) this->executeDispatch_DeleteMinorGrid(); + else if( aCommand == "InsertDataTable" ) + this->executeDispatch_InsertDataTable(); + else if( aCommand == "DeleteDataTable" ) + this->executeDispatch_DeleteDataTable(); //format objects else if( aCommand == "FormatSelection" ) this->executeDispatch_ObjectProperties(); @@ -1215,7 +1238,9 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_PositionAndSize(); } } - else if( lcl_isFormatObjectCommand(aCommand) ) + else if ( aCommand == "FontDialog" ) + this->impl_ShapeControllerDispatch(rURL, rArgs); + else if (lcl_isFormatObjectCommand(aCommand)) this->executeDispatch_FormatObject(rURL.Path); //more format else if( aCommand == "DiagramType" ) @@ -1254,6 +1279,127 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_ToggleGridVertical(); else if( aCommand == "ScaleText" ) this->executeDispatch_ScaleText(); + else if( aCommand == "Bold" || aCommand == "CharFontName" || aCommand == "FontHeight" + || aCommand == "Italic" || aCommand == "Underline" || aCommand == "Strikeout" + || aCommand == "Shadowed" || aCommand == "Color" || aCommand == "FontColor" + || aCommand == "Grow" || aCommand == "Shrink" || aCommand == "ResetAttributes" + || aCommand == "SuperScript" || aCommand == "SubScript" + || aCommand == "Spacing" + ) + { + try + { + OUString aCID(m_aSelection.getSelectedCID()); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); + if (xChartModel.is()) + { + // if the selected is title... we should get the text properties instead... + // or the selected text properties + std::vector<Reference<beans::XPropertySet>> xProperties; + xProperties.emplace(xProperties.end(), + ObjectIdentifier::getObjectPropertySet(aCID, xChartModel)); + + if (ObjectIdentifier::getObjectType(aCID) == OBJECTTYPE_TITLE) + { + Reference<chart2::XTitle> xTitle(xProperties[0], uno::UNO_QUERY); + if (xTitle.is()) + { + OutlinerView* pOutlinerView = nullptr; + if (m_pDrawViewWrapper) + { + pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + } + // if the Title is not in edit mode + if (!pOutlinerView) + { + const Sequence<Reference<chart2::XFormattedString>> aStrings( + xTitle->getText()); + xProperties.pop_back(); + for (int i = 0; i < aStrings.getLength(); i++) + { + Reference<beans::XPropertySet> xTitlePropSet(aStrings[i], + uno::UNO_QUERY); + xProperties.push_back(xTitlePropSet); + } + } + // Todo: implement the edit mode case here. + // the edited text attributes are a bit different from the properties + // SfxItemSet aItemSet = pOutlinerView->GetAttribs(); + } + } + bool bAllPropertiesExist = (xProperties.size() > 0); + for (std::size_t i = 0; i < xProperties.size(); i++) + { + if (!xProperties[i].is()) + bAllPropertiesExist = false; + } + if (bAllPropertiesExist) + { + if (aCommand == "Bold") + { + executeDispatch_FontBold(xProperties); + } + else if (aCommand == "CharFontName") + { + executeDispatch_FontName(xProperties, rArgs); + } + else if (aCommand == "FontHeight") + { + executeDispatch_FontHeight(xProperties, rArgs); + } + else if (aCommand == "Italic") + { + executeDispatch_FontItalic(xProperties); + } + else if (aCommand == "Underline") + { + executeDispatch_FontUnderline(xProperties, rArgs); + } + else if (aCommand == "Strikeout") + { + executeDispatch_FontStrikeout(xProperties); + } + else if (aCommand == "Shadowed") + { + executeDispatch_FontShadowed(xProperties); + } + else if (aCommand == "Color" || aCommand == "FontColor") + { + executeDispatch_FontColor(xProperties, rArgs); + } + else if (aCommand == "Grow") + { + executeDispatch_FontGrow(xProperties); + } + else if (aCommand == "Shrink") + { + executeDispatch_FontShrink(xProperties); + } + else if (aCommand == "ResetAttributes") + { + executeDispatch_FontReset(xProperties); + } + else if (aCommand == "Spacing") + { + executeDispatch_FontSpacing(xProperties, rArgs); + } + else if (aCommand == "SuperScript") + { + executeDispatch_FontSuperScript(xProperties); + } + else if (aCommand == "SubScript") + { + executeDispatch_FontSubScript(xProperties); + } + } + } + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + + } else if( aCommand == "StatusBarVisible" ) { // workaround: this should not be necessary. @@ -1261,24 +1407,26 @@ void SAL_CALL ChartController::dispatch( if( xPropSet.is() ) { uno::Reference< css::frame::XLayoutManager > xLayoutManager; - xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager; + xPropSet->getPropertyValue( u"LayoutManager"_ustr ) >>= xLayoutManager; if ( xLayoutManager.is() ) { - bool bIsVisible( xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" )); + bool bIsVisible( xLayoutManager->isElementVisible( u"private:resource/statusbar/statusbar"_ustr )); if( bIsVisible ) { - xLayoutManager->hideElement( "private:resource/statusbar/statusbar" ); - xLayoutManager->destroyElement( "private:resource/statusbar/statusbar" ); + xLayoutManager->hideElement( u"private:resource/statusbar/statusbar"_ustr ); + xLayoutManager->destroyElement( u"private:resource/statusbar/statusbar"_ustr ); } else { - xLayoutManager->createElement( "private:resource/statusbar/statusbar" ); - xLayoutManager->showElement( "private:resource/statusbar/statusbar" ); + xLayoutManager->createElement( u"private:resource/statusbar/statusbar"_ustr ); + xLayoutManager->showElement( u"private:resource/statusbar/statusbar"_ustr ); } // @todo: update menu state (checkmark next to "Statusbar"). } } } + else if( aCommand == "ChangeTheme" ) + comphelper::dispatchCommand(u".uno:ChangeTheme"_ustr, getFrame(), rArgs); } void SAL_CALL ChartController::addStatusListener( @@ -1313,34 +1461,36 @@ void SAL_CALL ChartController::releaseContextMenuInterceptor( void ChartController::executeDispatch_ChartType() { - UndoLiveUpdateGuard aUndoGuard( - SchResId( STR_ACTION_EDIT_CHARTTYPE ), m_xUndoManager ); + auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(SchResId(STR_ACTION_EDIT_CHARTTYPE), + m_xUndoManager); SolarMutexGuard aSolarGuard; //prepare and open dialog - ChartTypeDialog aDlg(GetChartFrame(), getModel()); - if (aDlg.run() == RET_OK) - { - impl_adaptDataSeriesAutoResize(); - aUndoGuard.commit(); - } + auto aDlg = std::make_shared<ChartTypeDialog>(GetChartFrame(), getChartModel()); + weld::DialogController::runAsync(aDlg, [this, xUndoGuard=std::move(xUndoGuard)](int nResult) { + if (nResult == RET_OK) + { + impl_adaptDataSeriesAutoResize(); + xUndoGuard->commit(); + } + }); } void ChartController::executeDispatch_SourceData() { //convert properties to ItemSet - uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + rtl::Reference< ::chart::ChartModel > xChartDoc = getChartModel(); OSL_ENSURE( xChartDoc.is(), "Invalid XChartDocument" ); if( !xChartDoc.is() ) return; // If there is a data table we should ask user if we really want to destroy it // and switch to data ranges. - ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartDoc); + ChartModel& rModel = *xChartDoc; if ( rModel.hasInternalDataProvider() ) { // Check if we will able to create data provider later - css::uno::Reference< com::sun::star::chart2::XDataProviderAccess > xCreatorDoc( + css::uno::Reference< css::chart2::XDataProviderAccess > xCreatorDoc( rModel.getParent(), uno::UNO_QUERY); if (!xCreatorDoc.is()) return; @@ -1365,27 +1515,27 @@ void ChartController::executeDispatch_SourceData() rModel.attachDataProvider(xDataProvider); } } - - UndoLiveUpdateGuard aUndoGuard( - SchResId(STR_ACTION_EDIT_DATA_RANGES), m_xUndoManager); - + auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(SchResId(STR_ACTION_EDIT_DATA_RANGES), + m_xUndoManager); SolarMutexGuard aSolarGuard; - ::chart::DataSourceDialog aDlg(GetChartFrame(), xChartDoc, m_xCC); - if (aDlg.run() == RET_OK) - { - impl_adaptDataSeriesAutoResize(); - aUndoGuard.commit(); - } + auto aDlg = std::make_shared<DataSourceDialog>(GetChartFrame(), xChartDoc); + weld::DialogController::runAsync(aDlg, [this, xUndoGuard=std::move(xUndoGuard)](int nResult) { + if (nResult == RET_OK) + { + impl_adaptDataSeriesAutoResize(); + xUndoGuard->commit(); + } + }); } void ChartController::executeDispatch_MoveSeries( bool bForward ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); //get selected series OUString aObjectCID(m_aSelection.getSelectedCID()); - uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and labels? - aObjectCID, getModel() ) ); + rtl::Reference< DataSeries > xGivenDataSeries = ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and labels? + aObjectCID, getChartModel() ); UndoGuardWithSelection aUndoGuard( ActionDescriptionProvider::createDescription( @@ -1393,7 +1543,7 @@ void ChartController::executeDispatch_MoveSeries( bool bForward ) SchResId(STR_OBJECT_DATASERIES)), m_xUndoManager ); - bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward ); + bool bChanged = getFirstDiagram()->moveSeries( xGivenDataSeries, bForward ); if( bChanged ) { m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) ); @@ -1401,33 +1551,6 @@ void ChartController::executeDispatch_MoveSeries( bool bForward ) } } -// ____ XMultiServiceFactory ____ -uno::Reference< uno::XInterface > SAL_CALL - ChartController::createInstance( const OUString& aServiceSpecifier ) -{ - uno::Reference< uno::XInterface > xResult; - - if( aServiceSpecifier == CHART_ACCESSIBLE_TEXT_SERVICE_NAME ) - xResult.set( impl_createAccessibleTextContext()); - return xResult; -} - -uno::Reference< uno::XInterface > SAL_CALL - ChartController::createInstanceWithArguments( - const OUString& ServiceSpecifier, - const uno::Sequence< uno::Any >& /* Arguments */ ) -{ - // ignore Arguments - return createInstance( ServiceSpecifier ); -} - -uno::Sequence< OUString > SAL_CALL - ChartController::getAvailableServiceNames() -{ - uno::Sequence< OUString > aServiceNames { CHART_ACCESSIBLE_TEXT_SERVICE_NAME }; - return aServiceNames; -} - // ____ XModifyListener ____ void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ ) @@ -1447,7 +1570,7 @@ void ChartController::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> pUndoA try { - const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); + rtl::Reference< ChartModel > xSuppUndo = getChartModel(); const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( std::move(pUndoAction) ) ); xUndoManager->addUndoAction( xAction ); @@ -1462,9 +1585,8 @@ DrawModelWrapper* ChartController::GetDrawModelWrapper() { if( !m_pDrawModelWrapper ) { - ExplicitValueProvider* pProvider = comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView ); - if( pProvider ) - m_pDrawModelWrapper = pProvider->getDrawModelWrapper(); + if( m_xChartView ) + m_pDrawModelWrapper = m_xChartView->getDrawModelWrapper(); if ( m_pDrawModelWrapper ) { m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl( @@ -1484,7 +1606,7 @@ DrawViewWrapper* ChartController::GetDrawViewWrapper() } -VclPtr<ChartWindow> ChartController::GetChartWindow() const +ChartWindow* ChartController::GetChartWindow() const { // clients getting the naked VCL Window from UNO should always have the // solar mutex (and keep it over the lifetime of this ptr), as VCL might @@ -1492,7 +1614,7 @@ VclPtr<ChartWindow> ChartController::GetChartWindow() const DBG_TESTSOLARMUTEX(); if(!m_xViewWindow.is()) return nullptr; - return dynamic_cast<ChartWindow*>(VCLUnoHelper::GetWindow(m_xViewWindow).get()); + return dynamic_cast<ChartWindow*>(VCLUnoHelper::GetWindow(m_xViewWindow)); } weld::Window* ChartController::GetChartFrame() @@ -1518,127 +1640,135 @@ void ChartController::SetAndApplySelection(const Reference<drawing::XShape>& rxS } } - - -uno::Reference< XAccessible > ChartController::CreateAccessible() +rtl::Reference<AccessibleChartView> ChartController::CreateAccessible() { - uno::Reference< XAccessible > xResult = new AccessibleChartView( GetDrawViewWrapper() ); - impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) ); +#if !ENABLE_WASM_STRIP_ACCESSIBILITY + rtl::Reference< AccessibleChartView > xResult = new AccessibleChartView( GetDrawViewWrapper() ); + impl_initializeAccessible( *xResult ); return xResult; +#else + return {}; +#endif } void ChartController::impl_invalidateAccessible() { +#if !ENABLE_WASM_STRIP_ACCESSIBILITY SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); if( pChartWindow ) { - Reference< lang::XInitialization > xInit( pChartWindow->GetAccessible(false), uno::UNO_QUERY ); - if(xInit.is()) + Reference<XAccessible> xAccessible = pChartWindow->GetAccessible(false); + if (xAccessible.is()) { - uno::Sequence< uno::Any > aArguments(3);//empty arguments -> invalid accessible - xInit->initialize(aArguments); + //empty arguments -> invalid accessible + dynamic_cast<AccessibleChartView&>(*xAccessible).initialize(); } } +#endif } void ChartController::impl_initializeAccessible() { +#if !ENABLE_WASM_STRIP_ACCESSIBILITY SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); - if( pChartWindow ) - this->impl_initializeAccessible( Reference< lang::XInitialization >( pChartWindow->GetAccessible(false), uno::UNO_QUERY ) ); + if( !pChartWindow ) + return; + Reference<XAccessible> xInit = pChartWindow->GetAccessible(false); + if(xInit.is()) + impl_initializeAccessible( dynamic_cast<AccessibleChartView&>(*xInit) ); +#endif } -void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit ) +#if !ENABLE_WASM_STRIP_ACCESSIBILITY +void ChartController::impl_initializeAccessible( AccessibleChartView& rAccChartView ) { - if(!xInit.is()) - return; + SolarMutexGuard aGuard; - uno::Sequence< uno::Any > aArguments(5); - aArguments[0] <<= uno::Reference<view::XSelectionSupplier>(this); - aArguments[1] <<= getModel(); - aArguments[2] <<= m_xChartView; uno::Reference< XAccessible > xParent; - { - SolarMutexGuard aGuard; - auto pChartWindow(GetChartWindow()); - if( pChartWindow ) - { - vcl::Window* pParentWin( pChartWindow->GetAccessibleParentWindow()); - if( pParentWin ) - xParent.set( pParentWin->GetAccessible()); - } - } - aArguments[3] <<= xParent; - aArguments[4] <<= m_xViewWindow; - xInit->initialize(aArguments); + ChartWindow* pChartWindow = GetChartWindow(); + if( pChartWindow ) + xParent.set(pChartWindow->GetAccessibleParent()); + + rAccChartView.initialize(*this, getChartModel(), m_xChartView, xParent, pChartWindow); } +#else +void ChartController::impl_initializeAccessible( AccessibleChartView& /* rAccChartView */) {} +#endif -const o3tl::sorted_vector< OUString >& ChartController::impl_getAvailableCommands() +const o3tl::sorted_vector< std::u16string_view >& ChartController::impl_getAvailableCommands() { - static const o3tl::sorted_vector< OUString > s_AvailableCommands { + static const o3tl::sorted_vector< std::u16string_view > s_AvailableCommands { // commands for container forward - "AddDirect", "NewDoc", "Open", - "Save", "SaveAs", "SendMail", - "EditDoc", "ExportDirectToPDF", "PrintDefault", + u"AddDirect", u"NewDoc", u"Open", + u"Save", u"SaveAs", u"SendMail", + u"EditDoc", u"ExportDirectToPDF", u"PrintDefault", // own commands - "Cut", "Copy", "Paste", - "DataRanges", "DiagramData", + u"Cut", u"Copy", u"Paste", + u"DataRanges", u"DiagramData", // insert objects - "InsertMenuTitles", "InsertTitles", - "InsertMenuLegend", "InsertLegend", "DeleteLegend", - "InsertMenuDataLabels", - "InsertMenuAxes", "InsertRemoveAxes", "InsertMenuGrids", - "InsertSymbol", - "InsertTrendlineEquation", "InsertTrendlineEquationAndR2", - "InsertR2Value", "DeleteR2Value", - "InsertMenuTrendlines", "InsertTrendline", - "InsertMenuMeanValues", "InsertMeanValue", - "InsertMenuXErrorBars", "InsertXErrorBars", - "InsertMenuYErrorBars", "InsertYErrorBars", - "InsertDataLabels", "InsertDataLabel", - "DeleteTrendline", "DeleteMeanValue", "DeleteTrendlineEquation", - "DeleteXErrorBars", "DeleteYErrorBars", - "DeleteDataLabels", "DeleteDataLabel", + u"InsertMenuTitles", u"InsertTitles", + u"InsertMenuLegend", u"InsertLegend", u"DeleteLegend", + u"InsertMenuDataLabels", + u"InsertMenuAxes", u"InsertRemoveAxes", u"InsertMenuGrids", + u"InsertSymbol", + u"InsertTrendlineEquation", u"InsertTrendlineEquationAndR2", + u"InsertR2Value", u"DeleteR2Value", + u"InsertMenuTrendlines", u"InsertTrendline", + u"InsertMenuMeanValues", u"InsertMeanValue", + u"InsertMenuXErrorBars", u"InsertXErrorBars", + u"InsertMenuYErrorBars", u"InsertYErrorBars", + u"InsertDataLabels", u"InsertDataLabel", + u"DeleteTrendline", u"DeleteMeanValue", u"DeleteTrendlineEquation", + u"DeleteXErrorBars", u"DeleteYErrorBars", + u"DeleteDataLabels", u"DeleteDataLabel", + u"InsertMenuDataTable", + u"InsertDataTable", u"DeleteDataTable", //format objects - "FormatSelection", "TransformDialog", - "DiagramType", "View3D", - "Forward", "Backward", - "MainTitle", "SubTitle", - "XTitle", "YTitle", "ZTitle", - "SecondaryXTitle", "SecondaryYTitle", - "AllTitles", "Legend", - "DiagramAxisX", "DiagramAxisY", "DiagramAxisZ", - "DiagramAxisA", "DiagramAxisB", "DiagramAxisAll", - "DiagramGridXMain", "DiagramGridYMain", "DiagramGridZMain", - "DiagramGridXHelp", "DiagramGridYHelp", "DiagramGridZHelp", - "DiagramGridAll", - "DiagramWall", "DiagramFloor", "DiagramArea", + u"FormatSelection", u"FontDialog", u"TransformDialog", + u"DiagramType", u"View3D", + u"Forward", u"Backward", + u"MainTitle", u"SubTitle", + u"XTitle", u"YTitle", u"ZTitle", + u"SecondaryXTitle", u"SecondaryYTitle", + u"AllTitles", u"Legend", + u"DiagramAxisX", u"DiagramAxisY", u"DiagramAxisZ", + u"DiagramAxisA", u"DiagramAxisB", u"DiagramAxisAll", + u"DiagramGridXMain", u"DiagramGridYMain", u"DiagramGridZMain", + u"DiagramGridXHelp", u"DiagramGridYHelp", u"DiagramGridZHelp", + u"DiagramGridAll", + u"DiagramWall", u"DiagramFloor", u"DiagramArea", //context menu - format objects entries - "FormatWall", "FormatFloor", "FormatChartArea", - "FormatLegend", + u"FormatWall", u"FormatFloor", u"FormatChartArea", + u"FormatLegend", - "FormatAxis", "FormatTitle", - "FormatDataSeries", "FormatDataPoint", - "ResetAllDataPoints", "ResetDataPoint", - "FormatDataLabels", "FormatDataLabel", - "FormatMeanValue", "FormatTrendline", "FormatTrendlineEquation", - "FormatXErrorBars", "FormatYErrorBars", - "FormatStockLoss", "FormatStockGain", + u"FormatAxis", u"FormatTitle", + u"FormatDataSeries", u"FormatDataPoint", + u"ResetAllDataPoints", u"ResetDataPoint", + u"FormatDataLabels", u"FormatDataLabel", + u"FormatMeanValue", u"FormatTrendline", u"FormatTrendlineEquation", + u"FormatXErrorBars", u"FormatYErrorBars", + u"FormatStockLoss", u"FormatStockGain", - "FormatMajorGrid", "InsertMajorGrid", "DeleteMajorGrid", - "FormatMinorGrid", "InsertMinorGrid", "DeleteMinorGrid", - "InsertAxis", "DeleteAxis", "InsertAxisTitle", + u"FormatMajorGrid", u"InsertMajorGrid", u"DeleteMajorGrid", + u"FormatMinorGrid", u"InsertMinorGrid", u"DeleteMinorGrid", + u"InsertAxis", u"DeleteAxis", u"InsertAxisTitle", // toolbar commands - "ToggleGridHorizontal", "ToggleGridVertical", "ToggleLegend", "ScaleText", - "NewArrangement", "Update", - "DefaultColors", "BarWidth", "NumberOfLines", - "ArrangeRow", - "StatusBarVisible", - "ChartElementSelector"}; + u"ToggleGridHorizontal", u"ToggleGridVertical", u"ToggleLegend", u"ScaleText", + u"NewArrangement", u"Update", + u"DefaultColors", u"BarWidth", u"NumberOfLines", + u"ArrangeRow", + u"StatusBarVisible", + u"ChartElementSelector", + + // sidebar commands + u"CharFontName" , u"FontHeight" , u"Italic", u"Underline", + u"Bold", u"Strikeout",u"Shadowed", u"Color", u"FontColor", u"ResetAttributes", + u"Grow", u"Shrink", u"Spacing", u"SuperScript", u"SubScript" + }; return s_AvailableCommands; } @@ -1649,11 +1779,4 @@ ViewElementListProvider ChartController::getViewElementListProvider() } //namespace chart -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * -com_sun_star_comp_chart2_ChartController_get_implementation(css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) -{ - return cppu::acquire(new chart::ChartController(context)); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |