diff options
Diffstat (limited to 'chart2/source/controller/main/ChartController_Window.cxx')
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 813 |
1 files changed, 365 insertions, 448 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index a63da0791c30..cd57689af263 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -22,13 +22,15 @@ #include <string_view> #include <ChartController.hxx> +#include <ChartView.hxx> #include <PositionAndSizeHelper.hxx> #include <ObjectIdentifier.hxx> #include <ChartWindow.hxx> #include <ResId.hxx> #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> #include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <TitleHelper.hxx> #include "UndoGuard.hxx" #include <ControllerLockGuard.hxx> @@ -37,12 +39,15 @@ #include "DragMethod_PieSegment.hxx" #include "DragMethod_RotateDiagram.hxx" #include <ObjectHierarchy.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <RelativePositionHelper.hxx> #include <chartview/DrawModelWrapper.hxx> #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> #include <StatisticsHelper.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> +#include <DataSeriesProperties.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <LegendHelper.hxx> #include <servicenames_charttypes.hxx> @@ -52,24 +57,17 @@ #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/XPopupMenuController.hpp> -#include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/awt/Rectangle.hpp> -#include <com/sun/star/qa/XDumper.hpp> #include <comphelper/lok.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/propertyvalue.hxx> -#include <comphelper/sequence.hxx> - -#include <toolkit/awt/vclxmenu.hxx> #include <sfx2/viewsh.hxx> #include <svx/ActionDescriptionProvider.hxx> @@ -83,8 +81,10 @@ #include <vcl/weld.hxx> #include <vcl/ptrstyle.hxx> #include <svtools/acceleratorexecute.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <boost/property_tree/json_parser.hpp> #include <sfx2/dispatch.hxx> @@ -94,6 +94,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; namespace chart @@ -143,13 +144,13 @@ void lcl_insertMenuCommand( const uno::Reference< awt::XPopupMenu > & xMenu, sal_Int16 nId, const OUString & rCommand ) { - xMenu->insertItem( nId, "", 0, -1 ); + xMenu->insertItem( nId, u""_ustr, 0, -1 ); xMenu->setCommand( nId, rCommand ); } -OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) +OUString lcl_getFormatCommandForObjectCID( std::u16string_view rCID ) { - OUString aDispatchCommand( ".uno:FormatSelection" ); + OUString aDispatchCommand( u".uno:FormatSelection"_ustr ); ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); @@ -172,6 +173,7 @@ OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) aDispatchCommand = ".uno:FormatTitle"; break; case OBJECTTYPE_LEGEND_ENTRY: + case OBJECTTYPE_DATA_SERIES: aDispatchCommand = ".uno:FormatDataSeries"; break; case OBJECTTYPE_AXIS: @@ -187,9 +189,6 @@ OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) case OBJECTTYPE_DATA_LABELS: aDispatchCommand = ".uno:FormatDataLabels"; break; - case OBJECTTYPE_DATA_SERIES: - aDispatchCommand = ".uno:FormatDataSeries"; - break; case OBJECTTYPE_DATA_LABEL: aDispatchCommand = ".uno:FormatDataLabel"; break; @@ -240,17 +239,16 @@ void SAL_CALL ChartController::setPosSize( sal_Int16 Flags ) { SolarMutexGuard aGuard; - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; auto pChartWindow(GetChartWindow()); - if(!(xWindow.is() && pChartWindow)) + if(!(m_xViewWindow.is() && pChartWindow)) return; Size aLogicSize = pChartWindow->PixelToLogic( Size( Width, Height ), MapMode( MapUnit::Map100thMM ) ); //todo: for standalone chart: detect whether we are standalone //change map mode to fit new size - awt::Size aModelPageSize = ChartModelHelper::getPageSize( getModel() ); + awt::Size aModelPageSize = getChartModel()->getPageSize(); sal_Int32 nScaleXNumerator = aLogicSize.Width(); sal_Int32 nScaleXDenominator = aModelPageSize.Width; sal_Int32 nScaleYNumerator = aLogicSize.Height(); @@ -264,8 +262,7 @@ void SAL_CALL ChartController::setPosSize( pChartWindow->setPosSizePixel( X, Y, Width, Height, static_cast<PosSizeFlags>(Flags) ); //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100% - uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY ); - if( xProp.is() ) + if( m_xChartView.is() ) { auto aZoomFactors(::comphelper::InitPropertySequence({ { "ScaleXNumerator", uno::Any( nScaleXNumerator ) }, @@ -273,7 +270,7 @@ void SAL_CALL ChartController::setPosSize( { "ScaleYNumerator", uno::Any( nScaleYNumerator ) }, { "ScaleYDenominator", uno::Any( nScaleYDenominator ) } })); - xProp->setPropertyValue( "ZoomFactors", uno::Any( aZoomFactors )); + m_xChartView->setPropertyValue( u"ZoomFactors"_ustr, uno::Any( aZoomFactors )); } //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area @@ -287,161 +284,114 @@ void SAL_CALL ChartController::setPosSize( awt::Rectangle SAL_CALL ChartController::getPosSize() { - //@todo awt::Rectangle aRet(0, 0, 0, 0); - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - if(xWindow.is()) - aRet = xWindow->getPosSize(); + if (m_xViewWindow.is()) + aRet = m_xViewWindow->getPosSize(); return aRet; } void SAL_CALL ChartController::setVisible( sal_Bool Visible ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->setVisible( Visible ); + if (m_xViewWindow.is()) + m_xViewWindow->setVisible(Visible); } void SAL_CALL ChartController::setEnable( sal_Bool Enable ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->setEnable( Enable ); + if (m_xViewWindow.is()) + m_xViewWindow->setEnable(Enable); } void SAL_CALL ChartController::setFocus() { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->setFocus(); + if (m_xViewWindow.is()) + m_xViewWindow->setFocus(); } void SAL_CALL ChartController::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addWindowListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addWindowListener(xListener); } void SAL_CALL ChartController::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeWindowListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeWindowListener(xListener); } void SAL_CALL ChartController::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addFocusListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addFocusListener(xListener); } void SAL_CALL ChartController::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeFocusListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeFocusListener(xListener); } void SAL_CALL ChartController::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addKeyListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addKeyListener(xListener); } void SAL_CALL ChartController::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeKeyListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeKeyListener(xListener); } void SAL_CALL ChartController::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addMouseListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addMouseListener(xListener); } void SAL_CALL ChartController::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeMouseListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeMouseListener(xListener); } void SAL_CALL ChartController::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addMouseMotionListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addMouseMotionListener(xListener); } void SAL_CALL ChartController::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeMouseMotionListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeMouseMotionListener(xListener); } void SAL_CALL ChartController::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addPaintListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addPaintListener(xListener); } void SAL_CALL ChartController::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removePaintListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removePaintListener(xListener); } // impl vcl window controller methods @@ -460,14 +410,13 @@ void ChartController::execute_Paint(vcl::RenderContext& rRenderContext, const to { try { - uno::Reference<frame::XModel> xModel(getModel()); + rtl::Reference<ChartModel> xModel(getChartModel()); //OSL_ENSURE( xModel.is(), "ChartController::execute_Paint: have no model to paint"); if (!xModel.is()) return; //better performance for big data - uno::Reference<beans::XPropertySet> xProp(m_xChartView, uno::UNO_QUERY); - if (xProp.is()) + if (m_xChartView.is()) { awt::Size aResolution(1000, 1000); { @@ -479,12 +428,11 @@ void ChartController::execute_Paint(vcl::RenderContext& rRenderContext, const to aResolution.Height = pChartWindow->GetSizePixel().Height(); } } - xProp->setPropertyValue( "Resolution", uno::Any( aResolution )); + m_xChartView->setPropertyValue( u"Resolution"_ustr, uno::Any( aResolution )); } - uno::Reference< util::XUpdatable > xUpdatable( m_xChartView, uno::UNO_QUERY ); - if (xUpdatable.is()) - xUpdatable->update(); + if (m_xChartView.is()) + m_xChartView->update(); { SolarMutexGuard aGuard; @@ -637,7 +585,7 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) } if ( !pDrawViewWrapper->IsAction() ) { - if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CAPTION ) + if ( pDrawViewWrapper->GetCurrentObjIdentifier() == SdrObjKind::Caption ) { Size aCaptionSize( 2268, 1134 ); pDrawViewWrapper->BegCreateCaptionObj( aMPos, aCaptionSize ); @@ -666,7 +614,7 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) rMEvt.IsRight(), m_bWaitingForDoubleClick ); - if( !m_aSelection.isRotateableObjectSelected( getModel() ) ) + if( !m_aSelection.isRotateableObjectSelected( getChartModel() ) ) { m_eDragMode = SdrDragMode::Move; pDrawViewWrapper->SetDragMode(m_eDragMode); @@ -699,14 +647,14 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) else if( eKind==SdrHdlKind::UpperLeft || eKind==SdrHdlKind::UpperRight || eKind==SdrHdlKind::LowerLeft || eKind==SdrHdlKind::LowerRight ) eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Z; } - pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel(), eRotationDirection ); + pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getChartModel(), eRotationDirection ); } } else { - OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) ); + std::u16string_view aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) ); if( aDragMethodServiceName == ObjectIdentifier::getPieSegmentDragMethodServiceName() ) - pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel() ); + pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getChartModel() ); } pDrawViewWrapper->SdrView::BegDragObj(aMPos, nullptr, pHitSelectionHdl, nDrgLog, pDragMethod); } @@ -739,10 +687,11 @@ void ChartController::execute_MouseMove( const MouseEvent& rMEvt ) void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); bool bMouseUpWithoutMouseDown = !m_bWaitingForMouseUp; m_bWaitingForMouseUp = false; bool bNotifySelectionChange = false; + bool bEditText = false; { SolarMutexGuard aGuard; @@ -784,9 +733,9 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) // don't want the positioning Undo action to appear in the UI impl_switchDiagramPositioningToExcludingPositioning(); } - if ( pDrawViewWrapper->AreObjectsMarked() ) + if ( pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0 ) { - if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) + if ( pDrawViewWrapper->GetCurrentObjIdentifier() == SdrObjKind::Text ) { executeDispatch_EditText(); } @@ -839,10 +788,10 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) { tools::Rectangle aObjectRect = pObj->GetSnapRect(); tools::Rectangle aOldObjectRect = pObj->GetLastBoundRect(); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( getChartModel()->getPageSize() ); tools::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); - const E3dObject* pE3dObject(dynamic_cast< const E3dObject*>(pObj)); + const E3dObject* pE3dObject(DynCastE3dObject(pObj)); if(nullptr != pE3dObject) { E3dScene* pScene(pE3dObject->getRootE3dSceneFromE3dObject()); @@ -863,17 +812,15 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) m_xUndoManager ); bool bChanged = false; - css::uno::Reference< css::frame::XModel > xModel = getModel(); - ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get()); - assert(pModel); + rtl::Reference< ChartModel > xModel = getChartModel(); if ( eObjectType == OBJECTTYPE_LEGEND ) - bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *pModel, false , true ); + bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *xModel, false , true ); bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() - , getModel() - , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) - , awt::Rectangle(aOldObjectRect.getX(), aOldObjectRect.getY(), 0, 0) - , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) ); + , xModel + , awt::Rectangle(aObjectRect.Left(),aObjectRect.Top(),aObjectRect.getOpenWidth(),aObjectRect.getOpenHeight()) + , awt::Rectangle(aOldObjectRect.Left(), aOldObjectRect.Top(), 0, 0) + , awt::Rectangle(aPageRect.Left(),aPageRect.Top(),aPageRect.getOpenWidth(),aPageRect.getOpenHeight()) ); if( bMoved || bChanged ) { @@ -893,7 +840,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( !bDraggingDone ) //mouse wasn't moved while dragging { bool bClickedTwiceOnDragableObject = SelectionHelper::isDragableObjectHitTwice( aMPos, m_aSelection.getSelectedCID(), *pDrawViewWrapper ); - bool bIsRotateable = m_aSelection.isRotateableObjectSelected( getModel() ); + bool bIsRotateable = m_aSelection.isRotateableObjectSelected( getChartModel() ); //toggle between move and rotate if( bIsRotateable && bClickedTwiceOnDragableObject && m_eDragMode==SdrDragMode::Move ) @@ -921,7 +868,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( isDoubleClick(rMEvt) && !bMouseUpWithoutMouseDown /*#i106966#*/ ) { Point aMousePixel = rMEvt.GetPosPixel(); - execute_DoubleClick( &aMousePixel ); + execute_DoubleClick( &aMousePixel, bEditText ); } if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) @@ -930,18 +877,17 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) impl_SetMousePointer( rMEvt ); - if(bNotifySelectionChange) + if(bNotifySelectionChange || bEditText) impl_notifySelectionChangeListeners(); } -void ChartController::execute_DoubleClick( const Point* pMousePixel ) +void ChartController::execute_DoubleClick( const Point* pMousePixel, bool &bEditText ) { const SfxViewShell* pViewShell = SfxViewShell::Current(); - bool isMobilePhone = pViewShell && pViewShell->isLOKMobilePhone(); - if (isMobilePhone) + bool notAllowed = pViewShell && (pViewShell->isLOKMobilePhone() || pViewShell->IsLokReadOnlyView()); + if (notAllowed) return; - bool bEditText = false; if ( m_aSelection.hasSelection() ) { OUString aCID( m_aSelection.getSelectedCID() ); @@ -957,7 +903,7 @@ void ChartController::execute_DoubleClick( const Point* pMousePixel ) { // #i12587# support for shapes in chart SdrObject* pObj = DrawViewWrapper::getSdrObject( m_aSelection.getSelectedAdditionalShape() ); - if ( dynamic_cast< const SdrTextObj* >(pObj) != nullptr ) + if ( DynCastSdrTextObj(pObj) != nullptr ) { bEditText = true; } @@ -986,33 +932,25 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) { SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); - bool bIsAction = false; - { - DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper.get(); - if(!pChartWindow || !pDrawViewWrapper) - return; - bIsAction = m_pDrawViewWrapper->IsAction(); - } + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper.get(); + if(!pChartWindow || !pDrawViewWrapper) + return; + bool bIsAction = m_pDrawViewWrapper->IsAction(); // pop-up menu if(rCEvt.GetCommand() == CommandEventId::ContextMenu && !bIsAction) { - { - if(pChartWindow) - pChartWindow->ReleaseMouse(); - } + pChartWindow->ReleaseMouse(); if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) impl_notifySelectionChangeListeners(); - css::uno::Reference< css::awt::XPopupMenu > xPopupMenu( m_xCC->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", m_xCC ), css::uno::UNO_QUERY ); + rtl::Reference< VCLXPopupMenu > xPopupMenu = new VCLXPopupMenu(); Point aPos( rCEvt.GetMousePosPixel() ); if( !rCEvt.IsMouseEvent() ) { - if(pChartWindow) - aPos = pChartWindow->GetPointerState().maPos; + aPos = pChartWindow->GetPointerState().maPos; } OUString aMenuName; @@ -1021,264 +959,260 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) aMenuName = m_pDrawViewWrapper->IsTextEdit() ? std::u16string_view( u"drawtext" ) : std::u16string_view( u"draw" ); else { + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + // todo: the context menu should be specified by an xml file in uiconfig - if( xPopupMenu.is()) + sal_Int16 nUniqueId = 1; + if (eObjectType != OBJECTTYPE_DATA_TABLE) { - sal_Int16 nUniqueId = 1; - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Cut" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Copy" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:Cut"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:Copy"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:Paste"_ustr ); xPopupMenu->insertSeparator( -1 ); + } - ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); - Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( getModel() ); + rtl::Reference< Diagram > xDiagram = getFirstDiagram(); - OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand ); + OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand ); + if (eObjectType == OBJECTTYPE_TITLE && m_pDrawViewWrapper->IsTextEdit()) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FontDialog"_ustr ); - //some commands for dataseries and points: + //some commands for dataseries and points: - if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_POINT ) + if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_POINT ) + { + bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); + rtl::Reference< RegressionCurveModel > xTrendline = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xSeries ); + bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); + rtl::Reference< RegressionCurveModel > xMeanValue = RegressionCurveHelper::getMeanValueLine( xSeries ); + bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries ); + bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false ); + bool bHasDataLabelsAtSeries = xSeries->hasDataLabelsAtSeries(); + bool bHasDataLabelsAtPoints = xSeries->hasDataLabelsAtPoints(); + bool bHasDataLabelAtPoint = false; + sal_Int32 nPointIndex = -1; + if( bIsPoint ) { - bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT ); - uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); - uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); - Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) ); - bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); - Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) ); - bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries ); - bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false ); - bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries ); - bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries ); - bool bHasDataLabelAtPoint = false; - sal_Int32 nPointIndex = -1; - if( bIsPoint ) - { - nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); - bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex ); - } - bool bSelectedPointIsFormatted = false; - bool bHasFormattedDataPointsOtherThanSelected = false; + nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); + bHasDataLabelAtPoint = xSeries->hasDataLabelAtPoint( nPointIndex ); + } + bool bSelectedPointIsFormatted = false; + bool bHasFormattedDataPointsOtherThanSelected = false; - Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); - if( xSeriesProperties.is() ) + if( xSeries.is() ) + { + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + // "AttributedDataPoints" + if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList ) { - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + if( aAttributedDataPointIndexList.hasElements() ) { - if( aAttributedDataPointIndexList.hasElements() ) + if( bIsPoint ) { - if( bIsPoint ) - { - auto aIndices( comphelper::sequenceToContainer<std::vector< sal_Int32 >>( aAttributedDataPointIndexList ) ); - std::vector< sal_Int32 >::iterator aIt = std::find( aIndices.begin(), aIndices.end(), nPointIndex ); - if( aIt != aIndices.end()) - bSelectedPointIsFormatted = true; - else - bHasFormattedDataPointsOtherThanSelected = true; - } + auto aIt = std::find( aAttributedDataPointIndexList.begin(), aAttributedDataPointIndexList.end(), nPointIndex ); + if (aIt != aAttributedDataPointIndexList.end()) + bSelectedPointIsFormatted = true; else bHasFormattedDataPointsOtherThanSelected = true; } + else + bHasFormattedDataPointsOtherThanSelected = true; } } + } - if( bIsPoint ) - { - if( bHasDataLabelAtPoint ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabel" ); - if( !bHasDataLabelAtPoint ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabel" ); - else - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabel" ); - if( bSelectedPointIsFormatted ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetDataPoint" ); + if( bIsPoint ) + { + if( bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatDataLabel"_ustr ); + if( !bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertDataLabel"_ustr ); + else + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteDataLabel"_ustr ); + if( bSelectedPointIsFormatted ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:ResetDataPoint"_ustr ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataSeries" ); - } + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatDataSeries"_ustr ); + } - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); - if( xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); + if( xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) + { + try { - try - { - Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); - if( xChartTypeProp.is() ) - { - bool bJapaneseStyle = false; - xChartTypeProp->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; - - if( bJapaneseStyle ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); - } - } - } - catch( const uno::Exception & ) + bool bJapaneseStyle = false; + xChartType->getPropertyValue( u"Japanese"_ustr ) >>= bJapaneseStyle; + + if( bJapaneseStyle ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockLoss"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockGain"_ustr ); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + } - if( bHasDataLabelsAtSeries ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabels" ); - if( bHasEquation ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); - if( xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMeanValue" ); - if( bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatXErrorBars" ); - if( bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatYErrorBars" ); + if( bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatDataLabels"_ustr ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatTrendlineEquation"_ustr ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatMeanValue"_ustr ); + if( bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatXErrorBars"_ustr ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatYErrorBars"_ustr ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - if( !bHasDataLabelsAtSeries ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabels" ); - - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendline" ); - - if( !xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMeanValue" ); - if( !bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertXErrorBars" ); - if( !bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertYErrorBars" ); - if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabels" ); - if( bHasEquation ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); - if( xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMeanValue" ); - if( bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteXErrorBars" ); - if( bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteYErrorBars" ); - - if( bHasFormattedDataPointsOtherThanSelected ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetAllDataPoints" ); + if( !bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertDataLabels"_ustr ); + + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTrendline"_ustr ); + + if( !xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertMeanValue"_ustr ); + if( !bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertXErrorBars"_ustr ); + if( !bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertYErrorBars"_ustr ); + if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteDataLabels"_ustr ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteTrendlineEquation"_ustr ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteMeanValue"_ustr ); + if( bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteXErrorBars"_ustr ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteYErrorBars"_ustr ); + + if( bHasFormattedDataPointsOtherThanSelected ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:ResetAllDataPoints"_ustr ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId, ".uno:ArrangeRow" ); - uno::Reference< awt::XPopupMenu > xArrangePopupMenu( - m_xCC->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", m_xCC ), uno::UNO_QUERY ); - if( xArrangePopupMenu.is() ) - { - sal_Int16 nSubId = nUniqueId + 1; - lcl_insertMenuCommand( xArrangePopupMenu, nSubId++, ".uno:Forward" ); - lcl_insertMenuCommand( xArrangePopupMenu, nSubId, ".uno:Backward" ); - xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); - nUniqueId = nSubId; - } - ++nUniqueId; - } - else if( eObjectType == OBJECTTYPE_DATA_CURVE ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendline" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquationAndR2" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); - } - else if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); - } + lcl_insertMenuCommand( xPopupMenu, nUniqueId, u".uno:ArrangeRow"_ustr ); + rtl::Reference< VCLXPopupMenu > xArrangePopupMenu = new VCLXPopupMenu(); + sal_Int16 nSubId = nUniqueId + 1; + lcl_insertMenuCommand( xArrangePopupMenu, nSubId++, u".uno:Forward"_ustr ); + lcl_insertMenuCommand( xArrangePopupMenu, nSubId, u".uno:Backward"_ustr ); + xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); + nUniqueId = nSubId; + ++nUniqueId; + } + else if( eObjectType == OBJECTTYPE_DATA_CURVE ) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteTrendline"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatTrendlineEquation"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTrendlineEquation"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTrendlineEquationAndR2"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertR2Value"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteTrendlineEquation"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteR2Value"_ustr ); + } + else if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertR2Value"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteR2Value"_ustr ); + } - //some commands for axes: and grids + //some commands for axes: and grids - else if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_GRID || eObjectType == OBJECTTYPE_SUBGRID ) + else if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_GRID || eObjectType == OBJECTTYPE_SUBGRID ) + { + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); + if( xAxis.is() && xDiagram.is() ) { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); - if( xAxis.is() && xDiagram.is() ) - { - sal_Int32 nDimensionIndex = -1; - sal_Int32 nCooSysIndex = -1; - sal_Int32 nAxisIndex = -1; - AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); - bool bIsSecondaryAxis = nAxisIndex!=0; - bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis ); - bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram ); - bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram ); - bool bHasTitle = false; - uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY ); - if( xTitled.is()) - bHasTitle = !TitleHelper::getCompleteString( xTitled->getTitleObject() ).isEmpty(); - - if( eObjectType != OBJECTTYPE_AXIS && bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatAxis" ); - if( eObjectType != OBJECTTYPE_GRID && bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMajorGrid" ); - if( eObjectType != OBJECTTYPE_SUBGRID && bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMinorGrid" ); - - xPopupMenu->insertSeparator( -1 ); - - if( eObjectType != OBJECTTYPE_AXIS && !bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxis" ); - if( eObjectType != OBJECTTYPE_GRID && !bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMajorGrid" ); - if( eObjectType != OBJECTTYPE_SUBGRID && !bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMinorGrid" ); - if( !bHasTitle ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxisTitle" ); - - if( bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteAxis" ); - if( bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMajorGrid" ); - if( bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMinorGrid" ); - } - } - - if( eObjectType == OBJECTTYPE_DATA_STOCK_LOSS ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); - else if( eObjectType == OBJECTTYPE_DATA_STOCK_GAIN ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); + sal_Int32 nDimensionIndex = -1; + sal_Int32 nCooSysIndex = -1; + sal_Int32 nAxisIndex = -1; + AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); + bool bIsSecondaryAxis = nAxisIndex!=0; + bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis ); + bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram ); + bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram ); + bool bHasTitle = !TitleHelper::getCompleteString( xAxis->getTitleObject2() ).isEmpty(); + + if( eObjectType != OBJECTTYPE_AXIS && bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatAxis"_ustr ); + if( eObjectType != OBJECTTYPE_GRID && bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatMajorGrid"_ustr ); + if( eObjectType != OBJECTTYPE_SUBGRID && bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatMinorGrid"_ustr ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:TransformDialog" ); + xPopupMenu->insertSeparator( -1 ); - if( eObjectType == OBJECTTYPE_PAGE || eObjectType == OBJECTTYPE_DIAGRAM - || eObjectType == OBJECTTYPE_DIAGRAM_WALL - || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR - || eObjectType == OBJECTTYPE_UNKNOWN ) - { - if( eObjectType != OBJECTTYPE_UNKNOWN ) - xPopupMenu->insertSeparator( -1 ); - bool bHasLegend = LegendHelper::hasLegend( xDiagram ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTitles" ); - if( !bHasLegend ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertLegend" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertRemoveAxes" ); - if( bHasLegend ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteLegend" ); + if( eObjectType != OBJECTTYPE_AXIS && !bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertAxis"_ustr ); + if( eObjectType != OBJECTTYPE_GRID && !bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertMajorGrid"_ustr ); + if( eObjectType != OBJECTTYPE_SUBGRID && !bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertMinorGrid"_ustr ); + if( !bHasTitle ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertAxisTitle"_ustr ); + + if( bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteAxis"_ustr ); + if( bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteMajorGrid"_ustr ); + if( bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteMinorGrid"_ustr ); + if (bIsAxisVisible) + lcl_insertMenuCommand(xPopupMenu, nUniqueId++, u".uno:InsertDataTable"_ustr); } + } + else if (eObjectType == OBJECTTYPE_DATA_TABLE) + { + lcl_insertMenuCommand(xPopupMenu, nUniqueId++, u".uno:DeleteDataTable"_ustr); + } - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramType" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DataRanges" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramData" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:View3D" ); + if( eObjectType == OBJECTTYPE_DATA_STOCK_LOSS ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockGain"_ustr ); + else if( eObjectType == OBJECTTYPE_DATA_STOCK_GAIN ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockLoss"_ustr ); + + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:TransformDialog"_ustr ); + + if( eObjectType == OBJECTTYPE_PAGE || eObjectType == OBJECTTYPE_DIAGRAM + || eObjectType == OBJECTTYPE_DIAGRAM_WALL + || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR + || eObjectType == OBJECTTYPE_UNKNOWN ) + { + if( eObjectType != OBJECTTYPE_UNKNOWN ) + xPopupMenu->insertSeparator( -1 ); + bool bHasLegend = LegendHelper::hasLegend( xDiagram ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTitles"_ustr ); + if( !bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertLegend"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertRemoveAxes"_ustr ); + if( bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteLegend"_ustr ); } + + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DiagramType"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DataRanges"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DiagramData"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:View3D"_ustr ); } - css::uno::Sequence< css::uno::Any > aArgs( 3 ); - aArgs[0] <<= comphelper::makePropertyValue( "IsContextMenu", true ); - aArgs[1] <<= comphelper::makePropertyValue( "Frame", m_xFrame ); - aArgs[2] <<= comphelper::makePropertyValue( "Value", aMenuName ); + css::uno::Sequence< css::uno::Any > aArgs{ + css::uno::Any(comphelper::makePropertyValue( u"IsContextMenu"_ustr, true )), + css::uno::Any(comphelper::makePropertyValue( u"Frame"_ustr, m_xFrame )), + css::uno::Any(comphelper::makePropertyValue( u"Value"_ustr, aMenuName )) + }; css::uno::Reference< css::frame::XPopupMenuController > xPopupController( m_xCC->getServiceManager()->createInstanceWithArgumentsAndContext( - "com.sun.star.comp.framework.ResourceMenuController", aArgs, m_xCC ), css::uno::UNO_QUERY ); + u"com.sun.star.comp.framework.ResourceMenuController"_ustr, aArgs, m_xCC ), css::uno::UNO_QUERY ); if ( !xPopupController.is() || !xPopupMenu.is() ) return; @@ -1301,14 +1235,13 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) } } - Menu* pPopupMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>(xPopupMenu)->GetMenu(); - boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pPopupMenu); + boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(xPopupMenu); boost::property_tree::ptree aRoot; aRoot.add_child("menu", aMenu); std::stringstream aStream; boost::property_tree::write_json(aStream, aRoot, true); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, aStream.str().c_str()); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, OString(aStream.str())); } } else @@ -1328,8 +1261,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) ( rCEvt.GetCommand() == CommandEventId::InputContextChange ) ) { //#i84417# enable editing with IME - if( m_pDrawViewWrapper ) - m_pDrawViewWrapper->Command( rCEvt, pChartWindow ); + m_pDrawViewWrapper->Command( rCEvt, pChartWindow ); } } @@ -1381,8 +1313,8 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if( ! bReturn ) { // Navigation (Tab/F3/Home/End) - uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); - ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView )); + rtl::Reference<::chart::ChartModel> xChartDoc( getChartModel() ); + ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, m_xChartView.get() ); awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode )); bReturn = aObjNav.handleKeyEvent( aKeyEvent ); if( bReturn ) @@ -1393,7 +1325,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { aNewSelection = aNewOID.getAny(); } - if ( m_eDragMode == SdrDragMode::Rotate && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), getModel() ) ) + if ( m_eDragMode == SdrDragMode::Rotate && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), getChartModel() ) ) { m_eDragMode = SdrDragMode::Move; } @@ -1425,7 +1357,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) nCode == KEY_DOWN ) { bDrag = true; - OUString aParameter( ObjectIdentifier::getDragParameterString( m_aSelection.getSelectedCID() )); + std::u16string_view aParameter( ObjectIdentifier::getDragParameterString( m_aSelection.getSelectedCID() )); sal_Int32 nOffsetPercentDummy( 0 ); awt::Point aMinimumPosition( 0, 0 ); awt::Point aMaximumPosition( 0, 0 ); @@ -1521,17 +1453,17 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if (pObj) { tools::Rectangle aRect = pObj->GetSnapRect(); - awt::Size aPageSize(ChartModelHelper::getPageSize(getModel())); - if ((fShiftAmountX > 0.0 && (aRect.getX() + fShiftAmountX + aRect.getWidth() > aPageSize.Width)) || - (fShiftAmountX < 0.0 && (aRect.getX() + fShiftAmountX < 0)) || - (fShiftAmountY > 0.0 && (aRect.getY() + fShiftAmountY + aRect.getHeight() > aPageSize.Height)) || - (fShiftAmountY < 0.0 && (aRect.getY() + fShiftAmountY < 0))) + awt::Size aPageSize(getChartModel()->getPageSize()); + if ((fShiftAmountX > 0.0 && (aRect.Right() + fShiftAmountX > aPageSize.Width)) || + (fShiftAmountX < 0.0 && (aRect.Left() + fShiftAmountX < 0)) || + (fShiftAmountY > 0.0 && (aRect.Bottom() + fShiftAmountY > aPageSize.Height)) || + (fShiftAmountY < 0.0 && (aRect.Top() + fShiftAmountY < 0))) bReturn = false; else bReturn = PositionAndSizeHelper::moveObject( - m_aSelection.getSelectedCID(), getModel(), - awt::Rectangle(aRect.getX() + fShiftAmountX, aRect.getY() + fShiftAmountY, aRect.getWidth(), aRect.getHeight()), - awt::Rectangle(aRect.getX(), aRect.getY(), 0, 0), + m_aSelection.getSelectedCID(), getChartModel(), + awt::Rectangle(aRect.Left() + fShiftAmountX, aRect.Top() + fShiftAmountY, aRect.getOpenWidth(), aRect.getOpenHeight()), + awt::Rectangle(aRect.Left(), aRect.Top(), 0, 0), awt::Rectangle(0, 0, aPageSize.Width, aPageSize.Height)); } } @@ -1547,7 +1479,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { awt::Point aPos( xShape->getPosition() ); awt::Size aSize( xShape->getSize() ); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( getChartModel()->getPageSize() ); aPos.X = static_cast< tools::Long >( static_cast< double >( aPos.X ) + fShiftAmountX ); aPos.Y = static_cast< tools::Long >( static_cast< double >( aPos.Y ) + fShiftAmountY ); if( aPos.X + aSize.Width > aPageSize.Width ) @@ -1570,10 +1502,10 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) // dumping the shape if( !bReturn && bCtrl && nCode == KEY_F12) { - uno::Reference< qa::XDumper > xChartModel( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xChartModel = getChartModel(); if(xChartModel.is()) { - OUString aDump = xChartModel->dump(); + OUString aDump = xChartModel->dump(u"shapes"_ustr); SAL_WARN("chart2", aDump); } } @@ -1598,8 +1530,8 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) uno::Sequence< beans::PropertyValue > aArgs; xDispatchHelper->executeDispatch( uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), - ".uno:TerminateInplaceActivation", - "_parent", + u".uno:TerminateInplaceActivation"_ustr, + u"_parent"_ustr, frame::FrameSearchFlag::PARENT, aArgs ); bReturn = true; @@ -1611,10 +1543,10 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) bReturn = executeDispatch_Delete(); if( ! bReturn ) { - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pChartWindow->GetFrameWeld(), + std::shared_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pChartWindow->GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok, SchResId(STR_ACTION_NOTPOSSIBLE))); - xInfoBox->run(); + xInfoBox->runAsync(xInfoBox, [] (int) {}); } } @@ -1627,9 +1559,9 @@ bool ChartController::requestQuickHelp( OUString & rOutQuickHelpText, awt::Rectangle & rOutEqualRect ) { - uno::Reference< frame::XModel > xChartModel; + rtl::Reference<::chart::ChartModel> xChartModel; if( m_aModel.is()) - xChartModel.set( getModel() ); + xChartModel = getChartModel(); if( !xChartModel.is()) return false; @@ -1648,10 +1580,8 @@ bool ChartController::requestQuickHelp( rOutQuickHelpText = ObjectNameProvider::getHelpText( aCID, xChartModel, bIsBalloonHelp /* bVerbose */ ); // set rectangle - ExplicitValueProvider * pValueProvider( - comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView )); - if( pValueProvider ) - rOutEqualRect = pValueProvider->getRectangleOfObject( aCID, true ); + if( m_xChartView ) + rOutEqualRect = m_xChartView->getRectangleOfObject( aCID, true ); } return bResult; @@ -1664,8 +1594,7 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) if ( rSelection.hasValue() ) { - const uno::Type& rType = rSelection.getValueType(); - if ( rType == cppu::UnoType< OUString >::get() ) + if (rSelection.getValueType() == cppu::UnoType<OUString>::get()) { OUString aNewCID; if ( ( rSelection >>= aNewCID ) && m_aSelection.setSelection( aNewCID ) ) @@ -1673,10 +1602,9 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) bSuccess = true; } } - else if ( rType == cppu::UnoType<drawing::XShape>::get() ) + else if (uno::Reference<drawing::XShape> xShape; rSelection >>= xShape) { - uno::Reference< drawing::XShape > xShape; - if ( ( rSelection >>= xShape ) && m_aSelection.setSelection( xShape ) ) + if (m_aSelection.setSelection(xShape)) { bSuccess = true; } @@ -1736,7 +1664,8 @@ void SAL_CALL ChartController::addSelectionChangeListener( const uno::Reference< return; //behave passive if already disposed or suspended //--add listener - m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<view::XSelectionChangeListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aSelectionChangeListeners.addInterface( aGuard2, xListener ); } void SAL_CALL ChartController::removeSelectionChangeListener( const uno::Reference<view::XSelectionChangeListener> & xListener ) @@ -1746,24 +1675,18 @@ void SAL_CALL ChartController::removeSelectionChangeListener( const uno::Referen return; //behave passive if already disposed or suspended //--remove listener - m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<view::XSelectionChangeListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aSelectionChangeListeners.removeInterface( aGuard2, xListener ); } void ChartController::impl_notifySelectionChangeListeners() { - ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer - .getContainer( cppu::UnoType<view::XSelectionChangeListener>::get() ); - if( pIC ) + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + if( m_aLifeTimeManager.m_aSelectionChangeListeners.getLength(aGuard) ) { uno::Reference< view::XSelectionSupplier > xSelectionSupplier(this); lang::EventObject aEvent( xSelectionSupplier ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - uno::Reference< view::XSelectionChangeListener > xListener( aIt.next(), uno::UNO_QUERY ); - if( xListener.is() ) - xListener->selectionChanged( aEvent ); - } + m_aLifeTimeManager.m_aSelectionChangeListeners.notifyEach(aGuard, &view::XSelectionChangeListener::selectionChanged, aEvent); } } @@ -1790,23 +1713,22 @@ bool ChartController::impl_moveOrResizeObject( bool bResult = false; bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT ); - uno::Reference< frame::XModel > xChartModel( getModel() ); + rtl::Reference<::chart::ChartModel> xChartModel( getChartModel() ); uno::Reference< beans::XPropertySet > xObjProp( ObjectIdentifier::getObjectPropertySet( rCID, xChartModel )); if( xObjProp.is()) { - awt::Size aRefSize = ChartModelHelper::getPageSize( xChartModel ); + awt::Size aRefSize = xChartModel->getPageSize(); chart2::RelativePosition aRelPos; chart2::RelativeSize aRelSize; - bool bDeterminePos = !(xObjProp->getPropertyValue( "RelativePosition") >>= aRelPos); - bool bDetermineSize = !bNeedResize || !(xObjProp->getPropertyValue( "RelativeSize") >>= aRelSize); + bool bDeterminePos = !(xObjProp->getPropertyValue( u"RelativePosition"_ustr) >>= aRelPos); + bool bDetermineSize = !bNeedResize || !(xObjProp->getPropertyValue( u"RelativeSize"_ustr) >>= aRelSize); if( ( bDeterminePos || bDetermineSize ) && ( aRefSize.Width > 0 && aRefSize.Height > 0 ) ) { - ExplicitValueProvider * pValueProvider( - comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView )); + ChartView * pValueProvider( m_xChartView.get() ); if( pValueProvider ) { awt::Rectangle aRect( pValueProvider->getRectangleOfObject( rCID )); @@ -1853,9 +1775,9 @@ bool ChartController::impl_moveOrResizeObject( eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager ); { ControllerLockGuardUNO aCLGuard( xChartModel ); - xObjProp->setPropertyValue( "RelativePosition", uno::Any( aRelPos )); + xObjProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any( aRelPos )); if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicit size at the diagram when an explicit position is set - xObjProp->setPropertyValue( "RelativeSize", uno::Any( aRelSize )); + xObjProp->setPropertyValue( u"RelativeSize"_ustr, uno::Any( aRelSize )); } aUndoGuard.commit(); } @@ -1863,15 +1785,15 @@ bool ChartController::impl_moveOrResizeObject( return bResult; } -bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditionalOffset ) +bool ChartController::impl_DragDataPoint( std::u16string_view rCID, double fAdditionalOffset ) { bool bResult = false; if( fAdditionalOffset < -1.0 || fAdditionalOffset > 1.0 || fAdditionalOffset == 0.0 ) return bResult; sal_Int32 nDataPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rCID ); - uno::Reference< chart2::XDataSeries > xSeries( - ObjectIdentifier::getDataSeriesForCID( rCID, getModel() )); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( rCID, getChartModel() ); if( xSeries.is()) { try @@ -1879,7 +1801,7 @@ bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditio uno::Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex( nDataPointIndex )); double fOffset = 0.0; if( xPointProp.is() && - (xPointProp->getPropertyValue( "Offset" ) >>= fOffset ) && + (xPointProp->getPropertyValue( u"Offset"_ustr ) >>= fOffset ) && (( fAdditionalOffset > 0.0 && fOffset < 1.0 ) || (fOffset > 0.0)) ) { fOffset += fAdditionalOffset; @@ -1887,7 +1809,7 @@ bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditio fOffset = 1.0; else if( fOffset < 0.0 ) fOffset = 0.0; - xPointProp->setPropertyValue( "Offset", uno::Any( fOffset )); + xPointProp->setPropertyValue( u"Offset"_ustr, uno::Any( fOffset )); bResult = true; } } @@ -1989,33 +1911,33 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) SdrObjKind eKind = m_pDrawViewWrapper->GetCurrentObjIdentifier(); switch ( eKind ) { - case OBJ_LINE: + case SdrObjKind::Line: { ePointerStyle = PointerStyle::DrawLine; } break; - case OBJ_RECT: - case OBJ_CUSTOMSHAPE: + case SdrObjKind::Rectangle: + case SdrObjKind::CustomShape: { ePointerStyle = PointerStyle::DrawRect; } break; - case OBJ_CIRC: + case SdrObjKind::CircleOrEllipse: { ePointerStyle = PointerStyle::DrawEllipse; } break; - case OBJ_FREELINE: + case SdrObjKind::FreehandLine: { ePointerStyle = PointerStyle::DrawPolygon; } break; - case OBJ_TEXT: + case SdrObjKind::Text: { ePointerStyle = PointerStyle::DrawText; } break; - case OBJ_CAPTION: + case SdrObjKind::Caption: { ePointerStyle = PointerStyle::DrawCaption; } @@ -2052,7 +1974,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { if( (m_eDragMode == SdrDragMode::Rotate) && SelectionHelper::isRotateableObject( aHitObjectCID - , getModel() ) ) + , getChartModel() ) ) pChartWindow->SetPointer( PointerStyle::Rotate ); else { @@ -2073,14 +1995,9 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) pChartWindow->SetPointer( PointerStyle::Arrow ); } -css::uno::Reference<css::uno::XInterface> const & ChartController::getChartView() const -{ - return m_xChartView; -} - -void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle) +void ChartController::sendPopupRequest(std::u16string_view rCID, tools::Rectangle aRectangle) { - ChartModel* pChartModel = dynamic_cast<ChartModel*>(m_aModel->getModel().get()); + ChartModel* pChartModel = m_aModel->getModel().get(); if (!pChartModel) return; @@ -2097,11 +2014,11 @@ void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle a return; // Get dimension index from CID - sal_Int32 nStartPos = rCID.lastIndexOf('.'); - nStartPos++; - sal_Int32 nEndPos = rCID.getLength(); - OUString sDimensionIndex = rCID.copy(nStartPos, nEndPos - nStartPos); - sal_Int32 nDimensionIndex = sDimensionIndex.toInt32(); + size_t nStartPos = rCID.rfind('.'); + nStartPos = (nStartPos == std::u16string_view::npos) ? 0 : (nStartPos + 1); + sal_Int32 nEndPos = rCID.size(); + std::u16string_view sDimensionIndex = rCID.substr(nStartPos, nEndPos - nStartPos); + sal_Int32 nDimensionIndex = o3tl::toInt32(sDimensionIndex); awt::Rectangle xRectangle { sal_Int32(aRectangle.Left()), @@ -2112,12 +2029,12 @@ void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle a uno::Sequence<beans::PropertyValue> aCallbackData = comphelper::InitPropertySequence( { - {"Rectangle", uno::makeAny<awt::Rectangle>(xRectangle)}, - {"DimensionIndex", uno::makeAny<sal_Int32>(nDimensionIndex)}, - {"PivotTableName", uno::makeAny<OUString>(sPivotTableName)}, + {"Rectangle", uno::Any(xRectangle)}, + {"DimensionIndex", uno::Any(sal_Int32(nDimensionIndex))}, + {"PivotTableName", uno::Any(sPivotTableName)}, }); - pPopupRequest->getCallback()->notify(uno::makeAny(aCallbackData)); + pPopupRequest->getCallback()->notify(uno::Any(aCallbackData)); } } //namespace chart |