chart2/source/controller/accessibility/AccessibleBase.cxx | 80 - chart2/source/controller/accessibility/AccessibleChartElement.cxx | 30 chart2/source/controller/accessibility/AccessibleChartShape.cxx | 42 chart2/source/controller/accessibility/AccessibleChartView.cxx | 80 - chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx | 26 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx | 92 - chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx | 210 +-- chart2/source/controller/chartapiwrapper/LegendWrapper.cxx | 82 - chart2/source/controller/chartapiwrapper/TitleWrapper.cxx | 26 chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx | 32 chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx | 50 chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx | 38 chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx | 38 chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx | 146 +- chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx | 40 chart2/source/controller/dialogs/ChartTypeDialogController.cxx | 38 chart2/source/controller/dialogs/DataBrowser.cxx | 134 +- chart2/source/controller/dialogs/DialogModel.cxx | 120 +- chart2/source/controller/dialogs/RangeSelectionHelper.cxx | 32 chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx | 32 chart2/source/controller/dialogs/dlg_DataSource.cxx | 22 chart2/source/controller/dialogs/res_DataLabel.cxx | 24 chart2/source/controller/dialogs/res_Trendline.cxx | 48 chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx | 78 - chart2/source/controller/dialogs/tp_ChartType.cxx | 44 chart2/source/controller/dialogs/tp_DataSource.cxx | 126 +- chart2/source/controller/dialogs/tp_RangeChooser.cxx | 76 - chart2/source/controller/dialogs/tp_Scale.cxx | 80 - chart2/source/controller/drawinglayer/DrawViewWrapper.cxx | 42 chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx | 20 chart2/source/controller/itemsetwrapper/ItemConverter.cxx | 22 chart2/source/controller/main/ChartController.cxx | 94 - chart2/source/controller/main/ChartController_Insert.cxx | 28 chart2/source/controller/main/ChartController_TextEdit.cxx | 88 - chart2/source/controller/main/ChartController_Tools.cxx | 464 +++---- chart2/source/controller/main/ChartController_Window.cxx | 104 - chart2/source/controller/main/ControllerCommandDispatch.cxx | 270 ++-- chart2/source/controller/main/DragMethod_PieSegment.cxx | 36 chart2/source/controller/main/DragMethod_RotateDiagram.cxx | 150 +- chart2/source/controller/main/DrawCommandDispatch.cxx | 378 +++--- chart2/source/controller/main/ObjectHierarchy.cxx | 154 +- chart2/source/controller/main/SelectionHelper.cxx | 222 +-- chart2/source/controller/main/ShapeController.cxx | 586 +++++----- chart2/source/controller/main/UndoCommandDispatch.cxx | 90 - chart2/source/controller/sidebar/ChartElementsPanel.cxx | 52 chart2/source/controller/sidebar/ChartTypePanel.cxx | 49 chart2/source/model/main/ChartModel.cxx | 46 chart2/source/model/main/ChartModel_Persistence.cxx | 22 chart2/source/model/template/BarChartTypeTemplate.cxx | 24 chart2/source/model/template/ChartTypeTemplate.cxx | 176 +-- chart2/source/model/template/DataInterpreter.cxx | 26 chart2/source/tools/AxisHelper.cxx | 114 - chart2/source/tools/DataSeriesHelper.cxx | 72 - chart2/source/tools/DiagramHelper.cxx | 70 - chart2/source/tools/ExplicitCategoriesProvider.cxx | 38 chart2/source/tools/InternalData.cxx | 56 chart2/source/tools/InternalDataProvider.cxx | 88 - chart2/source/tools/ModifyListenerHelper.cxx | 30 chart2/source/tools/OPropertySet.cxx | 108 - chart2/source/tools/RangeHighlighter.cxx | 222 +-- chart2/source/tools/RegressionCurveHelper.cxx | 64 - chart2/source/tools/ThreeDHelper.cxx | 28 chart2/source/view/axes/ScaleAutomatism.cxx | 60 - chart2/source/view/axes/Tickmarks_Equidistant.cxx | 28 chart2/source/view/axes/VAxisBase.cxx | 16 chart2/source/view/axes/VAxisProperties.cxx | 56 chart2/source/view/axes/VCartesianAxis.cxx | 120 +- chart2/source/view/axes/VPolarAngleAxis.cxx | 32 chart2/source/view/charttypes/BarChart.cxx | 38 chart2/source/view/charttypes/PieChart.cxx | 35 chart2/source/view/charttypes/VSeriesPlotter.cxx | 212 +-- chart2/source/view/diagram/VDiagram.cxx | 286 ++-- chart2/source/view/main/ChartView.cxx | 401 +++--- chart2/source/view/main/VButton.cxx | 22 chart2/source/view/main/VDataSeries.cxx | 108 - chart2/source/view/main/VLegend.cxx | 84 - 76 files changed, 3702 insertions(+), 3695 deletions(-)
New commits: commit 9df2821e61979dab32390d5c64dd49bee868adbb Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sat Apr 18 14:08:51 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Apr 19 11:01:18 2020 +0200 loplugin:flatten in chart2 Change-Id: Iadc4da6515a7d82e7a92b33d74d589b61fa2c64f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92480 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx b/chart2/source/controller/accessibility/AccessibleBase.cxx index 91040ee70671..6f9192eba064 100644 --- a/chart2/source/controller/accessibility/AccessibleBase.cxx +++ b/chart2/source/controller/accessibility/AccessibleBase.cxx @@ -253,24 +253,24 @@ bool AccessibleBase::ImplUpdateChildren() void AccessibleBase::AddChild( AccessibleBase * pChild ) { OSL_ENSURE( pChild != nullptr, "Invalid Child" ); - if( pChild ) - { - ClearableMutexGuard aGuard( m_aMutex ); + if( !pChild ) + return; - Reference< XAccessible > xChild( pChild ); - m_aChildList.push_back( xChild ); + ClearableMutexGuard aGuard( m_aMutex ); - m_aChildOIDMap[ pChild->GetId() ] = xChild; + Reference< XAccessible > xChild( pChild ); + m_aChildList.push_back( xChild ); - // inform listeners of new child - if( m_bChildrenInitialized ) - { - Any aEmpty, aNew; - aNew <<= xChild; + m_aChildOIDMap[ pChild->GetId() ] = xChild; - aGuard.clear(); - BroadcastAccEvent( AccessibleEventId::CHILD, aNew, aEmpty ); - } + // inform listeners of new child + if( m_bChildrenInitialized ) + { + Any aEmpty, aNew; + aNew <<= xChild; + + aGuard.clear(); + BroadcastAccEvent( AccessibleEventId::CHILD, aNew, aEmpty ); } } @@ -282,41 +282,41 @@ void AccessibleBase::RemoveChildByOId( const ObjectIdentifier& rOId ) ClearableMutexGuard aGuard( m_aMutex ); ChildOIDMap::iterator aIt( m_aChildOIDMap.find( rOId )); - if( aIt != m_aChildOIDMap.end()) - { - Reference< XAccessible > xChild( aIt->second ); + if( aIt == m_aChildOIDMap.end()) + return; - // remove from map - m_aChildOIDMap.erase( aIt ); + Reference< XAccessible > xChild( aIt->second ); - // search child in vector - ChildListVectorType::iterator aVecIter = - std::find( m_aChildList.begin(), m_aChildList.end(), xChild ); + // remove from map + m_aChildOIDMap.erase( aIt ); - OSL_ENSURE( aVecIter != m_aChildList.end(), - "Inconsistent ChildMap" ); + // search child in vector + ChildListVectorType::iterator aVecIter = + std::find( m_aChildList.begin(), m_aChildList.end(), xChild ); - // remove child from vector - m_aChildList.erase( aVecIter ); - bool bInitialized = m_bChildrenInitialized; + OSL_ENSURE( aVecIter != m_aChildList.end(), + "Inconsistent ChildMap" ); - // call listeners unguarded - aGuard.clear(); + // remove child from vector + m_aChildList.erase( aVecIter ); + bool bInitialized = m_bChildrenInitialized; - // inform listeners of removed child - if( bInitialized ) - { - Any aEmpty, aOld; - aOld <<= xChild; + // call listeners unguarded + aGuard.clear(); - BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); - } + // inform listeners of removed child + if( bInitialized ) + { + Any aEmpty, aOld; + aOld <<= xChild; - // dispose the child - Reference< lang::XComponent > xComp( xChild, UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); + BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); } + + // dispose the child + Reference< lang::XComponent > xComp( xChild, UNO_QUERY ); + if( xComp.is()) + xComp->dispose(); } awt::Point AccessibleBase::GetUpperLeftOnScreen() const diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx b/chart2/source/controller/accessibility/AccessibleChartElement.cxx index 89a5c1cd14bd..cbee2ddbb01a 100644 --- a/chart2/source/controller/accessibility/AccessibleChartElement.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx @@ -95,20 +95,22 @@ void AccessibleChartElement::InitTextEdit() } } - if( m_xTextHelper.is()) - try - { - Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); - Sequence< uno::Any > aArgs( 3 ); - aArgs[0] <<= GetInfo().m_aOID.getObjectCID(); - aArgs[1] <<= Reference< XAccessible >( this ); - aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); - xInit->initialize( aArgs ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + if( !m_xTextHelper.is()) + return; + + try + { + Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); + Sequence< uno::Any > aArgs( 3 ); + aArgs[0] <<= GetInfo().m_aOID.getObjectCID(); + aArgs[1] <<= Reference< XAccessible >( this ); + aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); + xInit->initialize( aArgs ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } // Interfaces diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.cxx b/chart2/source/controller/accessibility/AccessibleChartShape.cxx index cba557c683d7..d9c2f7071338 100644 --- a/chart2/source/controller/accessibility/AccessibleChartShape.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartShape.cxx @@ -38,27 +38,27 @@ AccessibleChartShape::AccessibleChartShape( const AccessibleElementInfo& rAccInfo ) :impl::AccessibleChartShape_Base( rAccInfo, true/*bMayHaveChildren*/, false/*bAlwaysTransparent*/ ) { - if ( rAccInfo.m_aOID.isAdditionalShape() ) - { - Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() ); - Reference< XAccessible > xParent; - if ( rAccInfo.m_pParent ) - { - xParent.set( rAccInfo.m_pParent ); - } - ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent ); - - m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView ); - m_aShapeTreeInfo.SetController( nullptr ); - m_aShapeTreeInfo.SetDevice( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) ); - m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder ); - - ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); - m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo ); - if ( m_pAccShape.is() ) - { - m_pAccShape->Init(); - } + if ( !rAccInfo.m_aOID.isAdditionalShape() ) + return; + + Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() ); + Reference< XAccessible > xParent; + if ( rAccInfo.m_pParent ) + { + xParent.set( rAccInfo.m_pParent ); + } + ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent ); + + m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView ); + m_aShapeTreeInfo.SetController( nullptr ); + m_aShapeTreeInfo.SetDevice( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) ); + m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder ); + + ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); + m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo ); + if ( m_pAccShape.is() ) + { + m_pAccShape->Init(); } } diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx index 9ce465b70613..0738f52abc36 100644 --- a/chart2/source/controller/accessibility/AccessibleChartView.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx @@ -289,37 +289,37 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments if( bOldInvalid && bNewInvalid ) bChanged = false; - if( bChanged ) + if( !bChanged ) + return; + { - { - //before notification we prepare for creation of new context - //the old context will be deleted after notification than - MutexGuard aGuard( m_aMutex); - Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); - if( xChartDoc.is()) - m_spObjectHierarchy = - std::make_shared<ObjectHierarchy>( xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(m_xChartView) ); - else - m_spObjectHierarchy.reset(); - } + //before notification we prepare for creation of new context + //the old context will be deleted after notification than + MutexGuard aGuard( m_aMutex); + Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is()) + m_spObjectHierarchy = + std::make_shared<ObjectHierarchy>( xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(m_xChartView) ); + else + m_spObjectHierarchy.reset(); + } - { - AccessibleElementInfo aAccInfo; - aAccInfo.m_aOID = ObjectIdentifier("ROOT"); - aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument >( - uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY )); - aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier; - aAccInfo.m_xView = m_xChartView; - aAccInfo.m_xWindow = m_xWindow; - aAccInfo.m_pParent = nullptr; - aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; - aAccInfo.m_pSdrView = m_pSdrView; - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xWindow ); - m_pViewForwarder.reset( new AccessibleViewForwarder( this, pWindow ) ); - aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); - // broadcasts an INVALIDATE_ALL_CHILDREN event globally - SetInfo( aAccInfo ); - } + { + AccessibleElementInfo aAccInfo; + aAccInfo.m_aOID = ObjectIdentifier("ROOT"); + aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument >( + uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY )); + aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier; + aAccInfo.m_xView = m_xChartView; + aAccInfo.m_xWindow = m_xWindow; + aAccInfo.m_pParent = nullptr; + aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; + aAccInfo.m_pSdrView = m_pSdrView; + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xWindow ); + m_pViewForwarder.reset( new AccessibleViewForwarder( this, pWindow ) ); + aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); + // broadcasts an INVALIDATE_ALL_CHILDREN event globally + SetInfo( aAccInfo ); } } @@ -333,19 +333,19 @@ void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /* xSelectionSupplier.set(m_xSelectionSupplier); } - if( xSelectionSupplier.is() ) + if( !xSelectionSupplier.is() ) + return; + + ObjectIdentifier aSelectedOID( xSelectionSupplier->getSelection() ); + if ( m_aCurrentSelectionOID.isValid() ) { - ObjectIdentifier aSelectedOID( xSelectionSupplier->getSelection() ); - if ( m_aCurrentSelectionOID.isValid() ) - { - NotifyEvent( EventType::LOST_SELECTION, m_aCurrentSelectionOID ); - } - if( aSelectedOID.isValid() ) - { - NotifyEvent( EventType::GOT_SELECTION, aSelectedOID ); - } - m_aCurrentSelectionOID = aSelectedOID; + NotifyEvent( EventType::LOST_SELECTION, m_aCurrentSelectionOID ); + } + if( aSelectedOID.isValid() ) + { + NotifyEvent( EventType::GOT_SELECTION, aSelectedOID ); } + m_aCurrentSelectionOID = aSelectedOID; } // XEventListener diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index 45b7f401550d..e0cd9e0311bb 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -57,19 +57,19 @@ void Chart2ModelContact::setModel( const css::uno::Reference< css::frame::XModel m_xChartModel = xChartModel; mpModel = dynamic_cast<ChartModel*>(xChartModel.get()); uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, uno::UNO_QUERY ); - if( xTableFactory.is() ) - { - uno::Reference< container::XNameContainer > xDashTable( xTableFactory->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xGradientTable( xTableFactory->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xHatchTable( xTableFactory->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xBitmapTable( xTableFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xTransparencyGradientTable( xTableFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY ); - m_aTableMap["LineDashName"] = xDashTable; - m_aTableMap["FillGradientName"] = xGradientTable; - m_aTableMap["FillHatchName"] = xHatchTable; - m_aTableMap["FillBitmapName"] = xBitmapTable; - m_aTableMap["FillTransparenceGradientName"] = xTransparencyGradientTable; - } + if( !xTableFactory.is() ) + return; + + uno::Reference< container::XNameContainer > xDashTable( xTableFactory->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xGradientTable( xTableFactory->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xHatchTable( xTableFactory->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xBitmapTable( xTableFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xTransparencyGradientTable( xTableFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY ); + m_aTableMap["LineDashName"] = xDashTable; + m_aTableMap["FillGradientName"] = xGradientTable; + m_aTableMap["FillHatchName"] = xHatchTable; + m_aTableMap["FillBitmapName"] = xBitmapTable; + m_aTableMap["FillTransparenceGradientName"] = xTransparencyGradientTable; } void Chart2ModelContact::clear() diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 6b48a91cb75d..f385c399c6e6 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -290,20 +290,20 @@ void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any& rOu bool bHasCategories = true; uno::Sequence< sal_Int32 > aSequenceMapping; - if( DataSourceHelper::detectRangeSegmentation( + if( !DataSourceHelper::detectRangeSegmentation( m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) + return; + + if( bUseColumns && bNewValue != bFirstCellAsLabel ) { - if( bUseColumns && bNewValue != bFirstCellAsLabel ) - { - DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns ,bNewValue, bHasCategories ); - } - else if( !bUseColumns && bNewValue != bHasCategories ) - { - DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bFirstCellAsLabel, bNewValue ); - } + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns ,bNewValue, bHasCategories ); + } + else if( !bUseColumns && bNewValue != bHasCategories ) + { + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bFirstCellAsLabel, bNewValue ); } } @@ -381,20 +381,20 @@ void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any& bool bHasCategories = true; uno::Sequence< sal_Int32 > aSequenceMapping; - if( DataSourceHelper::detectRangeSegmentation( + if( !DataSourceHelper::detectRangeSegmentation( m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) + return; + + if( bUseColumns && bNewValue != bHasCategories ) { - if( bUseColumns && bNewValue != bHasCategories ) - { - DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns, bFirstCellAsLabel, bNewValue ); - } - else if( !bUseColumns && bNewValue != bFirstCellAsLabel ) - { - DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bNewValue, bHasCategories ); - } + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns, bFirstCellAsLabel, bNewValue ); + } + else if( !bUseColumns && bNewValue != bFirstCellAsLabel ) + { + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bNewValue, bHasCategories ); } } @@ -907,35 +907,35 @@ void ChartDocumentWrapper::impl_resetAddIn() Reference< util::XRefreshable > xAddIn( m_xAddIn ); m_xAddIn.set( nullptr ); - if( xAddIn.is() ) + if( !xAddIn.is() ) + return; + + try { - try + //make sure that the add-in does not hold a references to us anymore: + Reference< lang::XComponent > xComp( xAddIn, uno::UNO_QUERY ); + if( xComp.is()) + xComp->dispose(); + else { - //make sure that the add-in does not hold a references to us anymore: - Reference< lang::XComponent > xComp( xAddIn, uno::UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); - else + uno::Reference< lang::XInitialization > xInit( xAddIn, uno::UNO_QUERY ); + if( xInit.is() ) { - uno::Reference< lang::XInitialization > xInit( xAddIn, uno::UNO_QUERY ); - if( xInit.is() ) - { - uno::Any aParam; - uno::Reference< css::chart::XChartDocument > xDoc; - aParam <<= xDoc; - uno::Sequence< uno::Any > aSeq( &aParam, 1 ); - xInit->initialize( aSeq ); - } + uno::Any aParam; + uno::Reference< css::chart::XChartDocument > xDoc; + aParam <<= xDoc; + uno::Sequence< uno::Any > aSeq( &aParam, 1 ); + xInit->initialize( aSeq ); } } - catch (const uno::RuntimeException&) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - catch (const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + } + catch (const uno::RuntimeException&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 03cea203ea26..aa12dbc27eea 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -673,24 +673,24 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) { ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); - if( xProp.is() ) - { - awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + if( !xProp.is() ) + return; - chart2::RelativePosition aRelativePosition; - aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; - aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); - aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); - if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 ) - { - OSL_FAIL("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); - uno::Any aEmpty; - xProp->setPropertyValue( "RelativePosition", aEmpty ); - return; - } - xProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); - xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) ); + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + + chart2::RelativePosition aRelativePosition; + aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; + aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); + aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); + if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 ) + { + OSL_FAIL("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( "RelativePosition", aEmpty ); + return; } + xProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); + xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) ); } awt::Size SAL_CALL DiagramWrapper::getSize() @@ -703,25 +703,25 @@ void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) { ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); - if( xProp.is() ) - { - awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + if( !xProp.is() ) + return; - chart2::RelativeSize aRelativeSize; - aRelativeSize.Primary = double(aSize.Width)/double(aPageSize.Width); - aRelativeSize.Secondary = double(aSize.Height)/double(aPageSize.Height); + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); - if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 ) - { - OSL_FAIL("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); - uno::Any aEmpty; - xProp->setPropertyValue( "RelativeSize", aEmpty ); - return; - } + chart2::RelativeSize aRelativeSize; + aRelativeSize.Primary = double(aSize.Width)/double(aPageSize.Width); + aRelativeSize.Secondary = double(aSize.Height)/double(aPageSize.Height); - xProp->setPropertyValue( "RelativeSize", uno::Any(aRelativeSize) ); - xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) ); + if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 ) + { + OSL_FAIL("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( "RelativeSize", aEmpty ); + return; } + + xProp->setPropertyValue( "RelativeSize", uno::Any(aRelativeSize) ); + xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) ); } // ____ XShapeDescriptor (base of XShape) ____ @@ -1501,58 +1501,58 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); - if( xChartDoc.is() && xDiagram.is() && nDimension == 2 ) - { - Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) ) + return; - uno::Reference< chart2::XChartTypeTemplate > xTemplate; - if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" ) - { - if( nNewValue != 0 ) - { - xTemplate.set( aTemplateAndService.first ); - try - { - sal_Int32 nOldValue = 0; - uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); - xProp->getPropertyValue( m_aOuterName ) >>= nOldValue; - if( nOldValue == nNewValue ) - return; - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - } - else - { - xTemplate.set( xFact->createInstance("com.sun.star.chart2.template.Column"), uno::UNO_QUERY ); - } - } - else if( aTemplateAndService.second == "com.sun.star.chart2.template.Column" ) - { - if( nNewValue == 0 ) - return; - xTemplate.set( xFact->createInstance( "com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY ); - } + Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); - if(xTemplate.is()) + uno::Reference< chart2::XChartTypeTemplate > xTemplate; + if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" ) + { + if( nNewValue != 0 ) { + xTemplate.set( aTemplateAndService.first ); try { - // locked controllers - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + sal_Int32 nOldValue = 0; uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); - xProp->setPropertyValue( "NumberOfLines", uno::Any(nNewValue) ); - xTemplate->changeDiagram( xDiagram ); + xProp->getPropertyValue( m_aOuterName ) >>= nOldValue; + if( nOldValue == nNewValue ) + return; } catch( const uno::Exception & ) { DBG_UNHANDLED_EXCEPTION("chart2"); } } + else + { + xTemplate.set( xFact->createInstance("com.sun.star.chart2.template.Column"), uno::UNO_QUERY ); + } + } + else if( aTemplateAndService.second == "com.sun.star.chart2.template.Column" ) + { + if( nNewValue == 0 ) + return; + xTemplate.set( xFact->createInstance( "com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY ); + } + + if(!xTemplate.is()) + return; + + try + { + // locked controllers + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); + xProp->setPropertyValue( "NumberOfLines", uno::Any(nNewValue) ); + xTemplate->changeDiagram( xDiagram ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } @@ -1611,29 +1611,29 @@ void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterVal Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); - if( xDiagram.is() && xDiaProp.is()) + if( !(xDiagram.is() && xDiaProp.is())) + return; + + std::vector< Reference< chart2::XDataSeries > > aSeriesVector( + ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + sal_Int32 i = 0; + for (auto const& series : aSeriesVector) { - std::vector< Reference< chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); - sal_Int32 i = 0; - for (auto const& series : aSeriesVector) + Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY); + if( xProp.is()) { - Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY); - if( xProp.is()) + uno::Any aVal; + if( i < aNewValue.getLength() ) + aVal <<= aNewValue[i]; + else { - uno::Any aVal; - if( i < aNewValue.getLength() ) - aVal <<= aNewValue[i]; - else - { - //set empty sequence - uno::Sequence< sal_Int32 > aSeq; - aVal <<= aSeq; - } - xProp->setPropertyValue( "AttributedDataPoints", aVal ); + //set empty sequence + uno::Sequence< sal_Int32 > aSeq; + aVal <<= aSeq; } - ++i; + xProp->setPropertyValue( "AttributedDataPoints", aVal ); } + ++i; } } @@ -1766,26 +1766,26 @@ WrappedAutomaticSizeProperty::WrappedAutomaticSizeProperty() void WrappedAutomaticSizeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( xInnerPropertySet.is() ) - { - bool bNewValue = true; - if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Property AutomaticSize requires value of type boolean", nullptr, 0 ); + if( !xInnerPropertySet.is() ) + return; - try - { - if( bNewValue ) - { - Any aRelativeSize( xInnerPropertySet->getPropertyValue( "RelativeSize" ) ); - if( aRelativeSize.hasValue() ) - xInnerPropertySet->setPropertyValue( "RelativeSize", Any() ); - } - } - catch( const uno::Exception & ) + bool bNewValue = true; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( "Property AutomaticSize requires value of type boolean", nullptr, 0 ); + + try + { + if( bNewValue ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + Any aRelativeSize( xInnerPropertySet->getPropertyValue( "RelativeSize" ) ); + if( aRelativeSize.hasValue() ) + xInnerPropertySet->setPropertyValue( "RelativeSize", Any() ); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } Any WrappedAutomaticSizeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx index cf47d80977bb..01dc74e7b7be 100644 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx @@ -93,51 +93,51 @@ Any WrappedLegendAlignmentProperty::getPropertyValue( const Reference< beans::XP void WrappedLegendAlignmentProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if(xInnerPropertySet.is()) + if(!xInnerPropertySet.is()) + return; + + bool bNewShowLegend = true; + bool bOldShowLegend = true; { - bool bNewShowLegend = true; - bool bOldShowLegend = true; - { - css::chart::ChartLegendPosition eOuterPos(css::chart::ChartLegendPosition_NONE); - if( (rOuterValue >>= eOuterPos) && eOuterPos == css::chart::ChartLegendPosition_NONE ) - bNewShowLegend = false; - xInnerPropertySet->getPropertyValue( "Show" ) >>= bOldShowLegend; - } - if(bNewShowLegend!=bOldShowLegend) - { - xInnerPropertySet->setPropertyValue( "Show", uno::Any(bNewShowLegend) ); - } - if(!bNewShowLegend) - return; + css::chart::ChartLegendPosition eOuterPos(css::chart::ChartLegendPosition_NONE); + if( (rOuterValue >>= eOuterPos) && eOuterPos == css::chart::ChartLegendPosition_NONE ) + bNewShowLegend = false; + xInnerPropertySet->getPropertyValue( "Show" ) >>= bOldShowLegend; + } + if(bNewShowLegend!=bOldShowLegend) + { + xInnerPropertySet->setPropertyValue( "Show", uno::Any(bNewShowLegend) ); + } + if(!bNewShowLegend) + return; - //set corresponding LegendPosition - Any aInnerValue = convertOuterToInnerValue( rOuterValue ); - xInnerPropertySet->setPropertyValue( m_aInnerName, aInnerValue ); + //set corresponding LegendPosition + Any aInnerValue = convertOuterToInnerValue( rOuterValue ); + xInnerPropertySet->setPropertyValue( m_aInnerName, aInnerValue ); - //correct LegendExpansion - chart2::LegendPosition eNewInnerPos(chart2::LegendPosition_LINE_END); - if( aInnerValue >>= eNewInnerPos ) - { - css::chart::ChartLegendExpansion eNewExpansion = - ( eNewInnerPos == chart2::LegendPosition_LINE_END || - eNewInnerPos == chart2::LegendPosition_LINE_START ) - ? css::chart::ChartLegendExpansion_HIGH - : css::chart::ChartLegendExpansion_WIDE; - - css::chart::ChartLegendExpansion eOldExpansion( css::chart::ChartLegendExpansion_HIGH ); - bool bExpansionWasSet( - xInnerPropertySet->getPropertyValue( "Expansion" ) >>= eOldExpansion ); - - if( !bExpansionWasSet || (eOldExpansion != eNewExpansion)) - xInnerPropertySet->setPropertyValue( "Expansion", uno::Any( eNewExpansion )); - } + //correct LegendExpansion + chart2::LegendPosition eNewInnerPos(chart2::LegendPosition_LINE_END); + if( aInnerValue >>= eNewInnerPos ) + { + css::chart::ChartLegendExpansion eNewExpansion = + ( eNewInnerPos == chart2::LegendPosition_LINE_END || + eNewInnerPos == chart2::LegendPosition_LINE_START ) + ? css::chart::ChartLegendExpansion_HIGH + : css::chart::ChartLegendExpansion_WIDE; + + css::chart::ChartLegendExpansion eOldExpansion( css::chart::ChartLegendExpansion_HIGH ); + bool bExpansionWasSet( + xInnerPropertySet->getPropertyValue( "Expansion" ) >>= eOldExpansion ); + + if( !bExpansionWasSet || (eOldExpansion != eNewExpansion)) + xInnerPropertySet->setPropertyValue( "Expansion", uno::Any( eNewExpansion )); + } - //correct RelativePosition - Any aRelativePosition( xInnerPropertySet->getPropertyValue("RelativePosition") ); - if(aRelativePosition.hasValue()) - { - xInnerPropertySet->setPropertyValue( "RelativePosition", Any() ); - } + //correct RelativePosition + Any aRelativePosition( xInnerPropertySet->getPropertyValue("RelativePosition") ); + if(aRelativePosition.hasValue()) + { + xInnerPropertySet->setPropertyValue( "RelativePosition", Any() ); } } diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index c74045752aa2..5355c72150c5 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -308,21 +308,21 @@ void TitleWrapper::setFastCharacterPropertyValue( nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); Reference< chart2::XTitle > xTitle( getTitleObject() ); - if( xTitle.is()) - { - Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); - const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); + if( !xTitle.is()) + return; - for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) - { - Reference< beans::XFastPropertySet > xFastPropertySet( aStrings[ i ], uno::UNO_QUERY ); - Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY ); + Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); + const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); - if( pWrappedProperty ) - pWrappedProperty->setPropertyValue( rValue, xPropSet ); - else if( xFastPropertySet.is() ) - xFastPropertySet->setFastPropertyValue( nHandle, rValue ); - } + for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) + { + Reference< beans::XFastPropertySet > xFastPropertySet( aStrings[ i ], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY ); + + if( pWrappedProperty ) + pWrappedProperty->setPropertyValue( rValue, xPropSet ); + else if( xFastPropertySet.is() ) + xFastPropertySet->setFastPropertyValue( nHandle, rValue ); } } diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx index 76bfe053c46f..2bfb5ed42211 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx @@ -54,26 +54,26 @@ WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty() void WrappedAutomaticPositionProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( xInnerPropertySet.is() ) - { - bool bNewValue = true; - if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", nullptr, 0 ); + if( !xInnerPropertySet.is() ) + return; - try - { - if( bNewValue ) - { - Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) ); - if( aRelativePosition.hasValue() ) - xInnerPropertySet->setPropertyValue( "RelativePosition", Any() ); - } - } - catch( const uno::Exception & ) + bool bNewValue = true; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", nullptr, 0 ); + + try + { + if( bNewValue ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) ); + if( aRelativePosition.hasValue() ) + xInnerPropertySet->setPropertyValue( "RelativePosition", Any() ); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index 90194dde22d7..044dcf28fd5b 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -68,39 +68,39 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, if( !xDiagram.is() ) return; - if( m_nDimensionIndex==1 ) + if( m_nDimensionIndex!=1 ) + return; + + Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( sal_Int32 nN = 0; nN < aChartTypeList.getLength(); nN++ ) { - Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aChartTypeList.getLength(); nN++ ) + try { - try + Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); + if( xProp.is() ) { - Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); - if( xProp.is() ) - { - Sequence< sal_Int32 > aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + Sequence< sal_Int32 > aBarPositionSequence; + xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - long nOldLength = aBarPositionSequence.getLength(); - if( nOldLength <= m_nAxisIndex ) + long nOldLength = aBarPositionSequence.getLength(); + if( nOldLength <= m_nAxisIndex ) + { + aBarPositionSequence.realloc( m_nAxisIndex+1 ); + for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) { - aBarPositionSequence.realloc( m_nAxisIndex+1 ); - for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) - { - aBarPositionSequence[i] = m_nDefaultValue; - } + aBarPositionSequence[i] = m_nDefaultValue; } - aBarPositionSequence[m_nAxisIndex] = nNewValue; - - xProp->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); } + aBarPositionSequence[m_nAxisIndex] = nNewValue; + + xProp->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); } - catch( uno::Exception& e ) - { - //the above properties are not supported by all charttypes (only by column and bar) - //in that cases this exception is ok - e.Context.is();//to have debug information without compilation warnings - } + } + catch( uno::Exception& e ) + { + //the above properties are not supported by all charttypes (only by column and bar) + //in that cases this exception is ok + e.Context.is();//to have debug information without compilation warnings } } } diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx index b0670ca02a18..373fec6c8344 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx @@ -62,29 +62,29 @@ void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const R { static const char aRefSizeName[] = "ReferencePageSize"; - if( xInnerPropertySet.is() ) + if( !xInnerPropertySet.is() ) + return; + + bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) { - bool bNewValue = false; - if( ! (rOuterValue >>= bNewValue) ) - { - if( rOuterValue.hasValue() ) - throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", nullptr, 0 ); - } + if( rOuterValue.hasValue() ) + throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", nullptr, 0 ); + } - try - { - if( bNewValue ) - { - awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() ); - xInnerPropertySet->setPropertyValue( aRefSizeName, uno::Any( aRefSize ) ); - } - else - xInnerPropertySet->setPropertyValue( aRefSizeName, Any() ); - } - catch( const uno::Exception & ) + try + { + if( bNewValue ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() ); + xInnerPropertySet->setPropertyValue( aRefSizeName, uno::Any( aRefSize ) ); } + else + xInnerPropertySet->setPropertyValue( aRefSizeName, Any() ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx index c7ac1bdcd354..ad07a98bcd15 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx @@ -108,30 +108,30 @@ public: bool bHasAmbiguousValue = false; PROPERTYTYPE aOldValue = PROPERTYTYPE(); - if( detectInnerValue( aOldValue, bHasAmbiguousValue ) ) + if( !detectInnerValue( aOldValue, bHasAmbiguousValue ) ) + return; + + if( !(bHasAmbiguousValue || aNewValue != aOldValue) ) + return; + + Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) { - if( bHasAmbiguousValue || aNewValue != aOldValue ) + try { - Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + css::uno::Reference< css::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], css::uno::UNO_QUERY ); + if( xChartTypePropertySet.is() ) { - try - { - css::uno::Reference< css::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], css::uno::UNO_QUERY ); - if( xChartTypePropertySet.is() ) - { - xChartTypePropertySet->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); - } - } - catch( uno::Exception & ex ) - { - //spline properties are not supported by all charttypes - //in that cases this exception is ok - ex.Context.is();//to have debug information without compilation warnings - } + xChartTypePropertySet->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); } } + catch( uno::Exception & ex ) + { + //spline properties are not supported by all charttypes + //in that cases this exception is ok + ex.Context.is();//to have debug information without compilation warnings + } } } diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx index 843d7efd2f8a..abcbc1f016ec 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx @@ -417,34 +417,34 @@ void WrappedErrorCategoryProperty::setValueToSeries( const Reference< beans::XPr return; uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); - if( xErrorBarProperties.is() ) + if( !xErrorBarProperties.is() ) + return; + + sal_Int32 nNewStyle = css::chart::ErrorBarStyle::NONE; + switch(aNewValue) { - sal_Int32 nNewStyle = css::chart::ErrorBarStyle::NONE; - switch(aNewValue) - { - case css::chart::ChartErrorCategory_NONE: - nNewStyle = css::chart::ErrorBarStyle::NONE; - break; - case css::chart::ChartErrorCategory_VARIANCE: - nNewStyle = css::chart::ErrorBarStyle::VARIANCE; - break; - case css::chart::ChartErrorCategory_STANDARD_DEVIATION: - nNewStyle = css::chart::ErrorBarStyle::STANDARD_DEVIATION; - break; - case css::chart::ChartErrorCategory_CONSTANT_VALUE: - nNewStyle = css::chart::ErrorBarStyle::ABSOLUTE; - break; - case css::chart::ChartErrorCategory_PERCENT: - nNewStyle = css::chart::ErrorBarStyle::RELATIVE; - break; - case css::chart::ChartErrorCategory_ERROR_MARGIN: - nNewStyle = css::chart::ErrorBarStyle::ERROR_MARGIN; - break; - default: - break; - } - xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any(nNewStyle) ); + case css::chart::ChartErrorCategory_NONE: + nNewStyle = css::chart::ErrorBarStyle::NONE; + break; + case css::chart::ChartErrorCategory_VARIANCE: + nNewStyle = css::chart::ErrorBarStyle::VARIANCE; + break; + case css::chart::ChartErrorCategory_STANDARD_DEVIATION: + nNewStyle = css::chart::ErrorBarStyle::STANDARD_DEVIATION; + break; + case css::chart::ChartErrorCategory_CONSTANT_VALUE: + nNewStyle = css::chart::ErrorBarStyle::ABSOLUTE; + break; + case css::chart::ChartErrorCategory_PERCENT: + nNewStyle = css::chart::ErrorBarStyle::RELATIVE; + break; + case css::chart::ChartErrorCategory_ERROR_MARGIN: + nNewStyle = css::chart::ErrorBarStyle::ERROR_MARGIN; + break; + default: + break; } + xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any(nNewStyle) ); } namespace { @@ -602,29 +602,29 @@ css::chart::ChartErrorIndicatorType WrappedErrorIndicatorProperty::getValueFromS void WrappedErrorIndicatorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartErrorIndicatorType& aNewValue ) const { uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); - if( xErrorBarProperties.is() ) - { - bool bPositive = false; - bool bNegative = false; - switch( aNewValue ) - { - case css::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM: - bPositive = true; - bNegative = true; - break; - case css::chart::ChartErrorIndicatorType_UPPER: - bPositive = true; - break; - case css::chart::ChartErrorIndicatorType_LOWER: - bNegative = true; - break; - default: - break; - } + if( !xErrorBarProperties.is() ) + return; - xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::Any(bPositive) ); - xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::Any(bNegative) ); + bool bPositive = false; + bool bNegative = false; + switch( aNewValue ) + { + case css::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM: + bPositive = true; + bNegative = true; + break; + case css::chart::ChartErrorIndicatorType_UPPER: + bPositive = true; + break; + case css::chart::ChartErrorIndicatorType_LOWER: + bNegative = true; + break; + default: + break; } + + xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::Any(bPositive) ); + xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::Any(bNegative) ); } namespace { @@ -721,20 +721,20 @@ OUString WrappedErrorBarRangePositiveProperty::getValueFromSeries( const Referen void WrappedErrorBarRangePositiveProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const { uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); - if( xErrorBarProperties.is() ) + if( !xErrorBarProperties.is() ) + return; + + uno::Reference< chart2::data::XDataProvider > xDataProvider( + lcl_getDataProviderFromContact( m_spChart2ModelContact )); + uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY ); + if( xDataSource.is() && xDataProvider.is()) { - uno::Reference< chart2::data::XDataProvider > xDataProvider( - lcl_getDataProviderFromContact( m_spChart2ModelContact )); - uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY ); - if( xDataSource.is() && xDataProvider.is()) - { - OUString aTmp( aNewValue ); - OUString aXMLRange( aNewValue ); - lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact ); - StatisticsHelper::setErrorDataSequence( - xDataSource, xDataProvider, aTmp, true /* positive */, true /* y-error */, &aXMLRange ); - m_aOuterValue <<= aTmp; - } + OUString aTmp( aNewValue ); + OUString aXMLRange( aNewValue ); + lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact ); + StatisticsHelper::setErrorDataSequence( + xDataSource, xDataProvider, aTmp, true /* positive */, true /* y-error */, &aXMLRange ); + m_aOuterValue <<= aTmp; } } @@ -785,20 +785,20 @@ OUString WrappedErrorBarRangeNegativeProperty::getValueFromSeries( const Referen void WrappedErrorBarRangeNegativeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const { uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); - if( xErrorBarProperties.is() ) + if( !xErrorBarProperties.is() ) + return; + + uno::Reference< chart2::data::XDataProvider > xDataProvider( + lcl_getDataProviderFromContact( m_spChart2ModelContact )); + uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY ); + if( xDataSource.is() && xDataProvider.is()) { - uno::Reference< chart2::data::XDataProvider > xDataProvider( - lcl_getDataProviderFromContact( m_spChart2ModelContact )); - uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY ); - if( xDataSource.is() && xDataProvider.is()) - { - OUString aTmp( aNewValue ); - OUString aXMLRange( aNewValue ); - lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact ); - StatisticsHelper::setErrorDataSequence( - xDataSource, xDataProvider, aTmp, false /* positive */, true /* y-error */, &aXMLRange ); - m_aOuterValue <<= aTmp; - } + OUString aTmp( aNewValue ); + OUString aXMLRange( aNewValue ); + lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact ); + StatisticsHelper::setErrorDataSequence( + xDataSource, xDataProvider, aTmp, false /* positive */, true /* y-error */, &aXMLRange ); + m_aOuterValue <<= aTmp; } } diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx index d4d262995afc..5e7a2808f832 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx @@ -79,28 +79,28 @@ void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, c Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); - if( xChartDoc.is() && xDiagram.is() && nDimension==2 ) - { - Reference< lang::XMultiServiceFactory > xFactory( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFactory ); + if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) ) + return; - uno::Reference< chart2::XChartTypeTemplate > xTemplate = - getNewTemplate( bNewValue, aTemplateAndService.second, xFactory ); + Reference< lang::XMultiServiceFactory > xFactory( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xFactory ); - if(xTemplate.is()) - { - try - { - // locked controllers - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); - xTemplate->changeDiagram( xDiagram ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - } + uno::Reference< chart2::XChartTypeTemplate > xTemplate = + getNewTemplate( bNewValue, aTemplateAndService.second, xFactory ); + + if(!xTemplate.is()) + return; + + try + { + // locked controllers + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + xTemplate->changeDiagram( xDiagram ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx index bbbd5a882f24..d9c98d2b7888 100644 --- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx +++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx @@ -305,26 +305,26 @@ void ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParame { uno::Reference< lang::XMultiServiceFactory > xTemplateManager( xChartModel->getChartTypeManager(), uno::UNO_QUERY ); uno::Reference< XChartTypeTemplate > xTemplate( getCurrentTemplate( rParameter, xTemplateManager ) ); - if(xTemplate.is()) + if(!xTemplate.is()) + return; + + // locked controllers + ControllerLockGuardUNO aCtrlLockGuard( xChartModel ); + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); + DiagramHelper::tTemplateWithServiceName aTemplateWithService( + DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager )); + if( aTemplateWithService.first.is()) + aTemplateWithService.first->resetStyles( xDiagram ); + xTemplate->changeDiagram( xDiagram ); + if( AllSettings::GetMathLayoutRTL() ) + AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) ); + if( rParameter.b3DLook ) + ThreeDHelper::setScheme( xDiagram, rParameter.eThreeDLookScheme ); + + uno::Reference<beans::XPropertySet> xDiaProp(xDiagram, uno::UNO_QUERY); + if (xDiaProp.is()) { - // locked controllers - ControllerLockGuardUNO aCtrlLockGuard( xChartModel ); - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); - DiagramHelper::tTemplateWithServiceName aTemplateWithService( - DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager )); - if( aTemplateWithService.first.is()) - aTemplateWithService.first->resetStyles( xDiagram ); - xTemplate->changeDiagram( xDiagram ); - if( AllSettings::GetMathLayoutRTL() ) - AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) ); - if( rParameter.b3DLook ) - ThreeDHelper::setScheme( xDiagram, rParameter.eThreeDLookScheme ); - - uno::Reference<beans::XPropertySet> xDiaProp(xDiagram, uno::UNO_QUERY); - if (xDiaProp.is()) - { - xDiaProp->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES, uno::Any(rParameter.bSortByXValues)); - } + xDiaProp->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES, uno::Any(rParameter.bSortByXValues)); } } void ChartTypeDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ ) diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 5702d7dae675..86571ffeea7b 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -960,88 +960,88 @@ void DataBrowser::MoveLeftColumn() { sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders ); - if( nColIdx > 0 && - m_apDataBrowserModel.get()) - { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); + if( !(nColIdx > 0 && + m_apDataBrowserModel.get())) + return; + + // save changes made to edit-field + if( IsModified() ) + SaveModified(); - m_apDataBrowserModel->swapDataSeries( nColIdx - 1 ); + m_apDataBrowserModel->swapDataSeries( nColIdx - 1 ); - // keep cursor in swapped column - if(( 0 < GetCurColumnId() ) && ( GetCurColumnId() <= ColCount() - 1 )) - { - Dispatch( BROWSER_CURSORLEFT ); - } - RenewTable(); + // keep cursor in swapped column + if(( 0 < GetCurColumnId() ) && ( GetCurColumnId() <= ColCount() - 1 )) + { + Dispatch( BROWSER_CURSORLEFT ); } + RenewTable(); } void DataBrowser::MoveRightColumn() { sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders ); - if( nColIdx >= 0 && - m_apDataBrowserModel.get()) - { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); + if( !(nColIdx >= 0 && + m_apDataBrowserModel.get())) + return; - m_apDataBrowserModel->swapDataSeries( nColIdx ); + // save changes made to edit-field + if( IsModified() ) + SaveModified(); - // keep cursor in swapped column - if( GetCurColumnId() < ColCount() - 1 ) - { - Dispatch( BROWSER_CURSORRIGHT ); - } - RenewTable(); + m_apDataBrowserModel->swapDataSeries( nColIdx ); + + // keep cursor in swapped column + if( GetCurColumnId() < ColCount() - 1 ) + { + Dispatch( BROWSER_CURSORRIGHT ); } + RenewTable(); } void DataBrowser::MoveUpRow() { - sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow()); + sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow()); - if( nRowIdx > 0 && - m_apDataBrowserModel.get()) - { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); + if( !(nRowIdx > 0 && + m_apDataBrowserModel.get())) + return; - m_apDataBrowserModel->swapDataPointForAllSeries( nRowIdx - 1 ); + // save changes made to edit-field + if( IsModified() ) + SaveModified(); - // keep cursor in swapped row - if(( 0 < GetCurRow() ) && ( GetCurRow() <= GetRowCount() - 1 )) - { - Dispatch( BROWSER_CURSORUP ); - } - RenewTable(); + m_apDataBrowserModel->swapDataPointForAllSeries( nRowIdx - 1 ); + + // keep cursor in swapped row + if(( 0 < GetCurRow() ) && ( GetCurRow() <= GetRowCount() - 1 )) + { + Dispatch( BROWSER_CURSORUP ); } + RenewTable(); } void DataBrowser::MoveDownRow() { - sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow()); + sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow()); - if( nRowIdx >= 0 && - m_apDataBrowserModel.get()) - { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); + if( !(nRowIdx >= 0 && + m_apDataBrowserModel.get())) + return; - m_apDataBrowserModel->swapDataPointForAllSeries( nRowIdx ); + // save changes made to edit-field + if( IsModified() ) + SaveModified(); - // keep cursor in swapped row - if( GetCurRow() < GetRowCount() - 1 ) - { - Dispatch( BROWSER_CURSORDOWN ); - } - RenewTable(); + m_apDataBrowserModel->swapDataPointForAllSeries( nRowIdx ); + + // keep cursor in swapped row + if( GetCurRow() < GetRowCount() - 1 ) + { + Dispatch( BROWSER_CURSORDOWN ); } + RenewTable(); } void DataBrowser::SetCursorMovedHdl( const Link<DataBrowser*,void>& rLink ) @@ -1385,21 +1385,21 @@ IMPL_LINK( DataBrowser, SeriesHeaderChanged, impl::SeriesHeaderEdit&, rEdit, voi Reference< chart2::XDataSeries > xSeries( m_apDataBrowserModel->getDataSeriesByColumn( rEdit.getStartColumn() - 1 )); Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); - if( xSource.is()) + if( !xSource.is()) + return; + + Reference< chart2::XChartType > xChartType( + m_apDataBrowserModel->getHeaderForSeries( xSeries ).m_xChartType ); + if( xChartType.is()) { - Reference< chart2::XChartType > xChartType( - m_apDataBrowserModel->getHeaderForSeries( xSeries ).m_xChartType ); - if( xChartType.is()) + Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, xChartType->getRoleOfSequenceForSeriesLabel())); + if( xLabeledSeq.is()) { - Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( - DataSeriesHelper::getDataSequenceByRole( xSource, xChartType->getRoleOfSequenceForSeriesLabel())); - if( xLabeledSeq.is()) - { - Reference< container::XIndexReplace > xIndexReplace( xLabeledSeq->getLabel(), uno::UNO_QUERY ); - if( xIndexReplace.is()) - xIndexReplace->replaceByIndex( - 0, uno::Any( rEdit.GetText())); - } + Reference< container::XIndexReplace > xIndexReplace( xLabeledSeq->getLabel(), uno::UNO_QUERY ); + if( xIndexReplace.is()) + xIndexReplace->replaceByIndex( + 0, uno::Any( rEdit.GetText())); } } } diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 29e0f92ab756..db50eab8b9ed 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -626,23 +626,23 @@ Reference< data::XLabeledDataSequence > DialogModel::getCategories() const void DialogModel::setCategories( const Reference< chart2::data::XLabeledDataSequence > & xCategories ) { - if( m_xChartDocument.is()) - { - Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); - if( xDiagram.is()) - { - // categories - bool bSupportsCategories = true; + if( !m_xChartDocument.is()) + return; - Reference< XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); - if( xFirstChartType.is() ) - { - sal_Int32 nAxisType = ChartTypeHelper::getAxisType( xFirstChartType, 0 ); // x-axis - bSupportsCategories = (nAxisType == AxisType::CATEGORY); - } - DiagramHelper::setCategoriesToDiagram( xCategories, xDiagram, true, bSupportsCategories ); - } + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); + if( !xDiagram.is()) + return; + + // categories + bool bSupportsCategories = true; + + Reference< XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + if( xFirstChartType.is() ) + { + sal_Int32 nAxisType = ChartTypeHelper::getAxisType( xFirstChartType, 0 ); // x-axis + bSupportsCategories = (nAxisType == AxisType::CATEGORY); } + DiagramHelper::setCategoriesToDiagram( xCategories, xDiagram, true, bSupportsCategories ); } OUString DialogModel::getCategoriesRange() const @@ -780,66 +780,66 @@ void DialogModel::applyInterpretedData( m_aTimerTriggeredControllerLock.startTimer(); Reference< XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); - if( xDiagram.is()) + if( !xDiagram.is()) + return; + + // styles + if( m_xTemplate.is() ) { - // styles - if( m_xTemplate.is() ) - { - sal_Int32 nGroup = 0; - sal_Int32 nSeriesCounter = 0; - sal_Int32 nNewSeriesIndex = static_cast< sal_Int32 >( rSeriesToReUse.size()); - const sal_Int32 nOuterSize=rNewData.Series.getLength(); + sal_Int32 nGroup = 0; + sal_Int32 nSeriesCounter = 0; + sal_Int32 nNewSeriesIndex = static_cast< sal_Int32 >( rSeriesToReUse.size()); + const sal_Int32 nOuterSize=rNewData.Series.getLength(); - for(; nGroup < nOuterSize; ++nGroup) + for(; nGroup < nOuterSize; ++nGroup) + { + Sequence< Reference< XDataSeries > > aSeries( rNewData.Series[ nGroup ] ); + const sal_Int32 nSeriesInGroup = aSeries.getLength(); + for( sal_Int32 nSeries=0; nSeries<nSeriesInGroup; ++nSeries, ++nSeriesCounter ) { - Sequence< Reference< XDataSeries > > aSeries( rNewData.Series[ nGroup ] ); - const sal_Int32 nSeriesInGroup = aSeries.getLength(); - for( sal_Int32 nSeries=0; nSeries<nSeriesInGroup; ++nSeries, ++nSeriesCounter ) + if( std::find( rSeriesToReUse.begin(), rSeriesToReUse.end(), aSeries[nSeries] ) + == rSeriesToReUse.end()) { - if( std::find( rSeriesToReUse.begin(), rSeriesToReUse.end(), aSeries[nSeries] ) - == rSeriesToReUse.end()) + Reference< beans::XPropertySet > xSeriesProp( aSeries[nSeries], uno::UNO_QUERY ); + if( xSeriesProp.is()) { - Reference< beans::XPropertySet > xSeriesProp( aSeries[nSeries], uno::UNO_QUERY ); - if( xSeriesProp.is()) - { - // @deprecated: correct default color should be found by view - // without setting it as hard attribute - Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme()); - if( xColorScheme.is()) - xSeriesProp->setPropertyValue( "Color" , - uno::Any( xColorScheme->getColorByIndex( nSeriesCounter ))); - } - m_xTemplate->applyStyle( aSeries[nSeries], nGroup, nNewSeriesIndex++, nSeriesInGroup ); + // @deprecated: correct default color should be found by view + // without setting it as hard attribute + Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme()); + if( xColorScheme.is()) + xSeriesProp->setPropertyValue( "Color" , + uno::Any( xColorScheme->getColorByIndex( nSeriesCounter ))); } + m_xTemplate->applyStyle( aSeries[nSeries], nGroup, nNewSeriesIndex++, nSeriesInGroup ); } } } + } - // data series - std::vector< Reference< XDataSeriesContainer > > aSeriesCnt( getAllDataSeriesContainers()); - auto aNewSeries( - comphelper::sequenceToContainer<std::vector< Sequence< Reference< XDataSeries > > >>( rNewData.Series )); + // data series + std::vector< Reference< XDataSeriesContainer > > aSeriesCnt( getAllDataSeriesContainers()); + auto aNewSeries( + comphelper::sequenceToContainer<std::vector< Sequence< Reference< XDataSeries > > >>( rNewData.Series )); - OSL_ASSERT( aSeriesCnt.size() == aNewSeries.size()); + OSL_ASSERT( aSeriesCnt.size() == aNewSeries.size()); - std::vector< Sequence< Reference< XDataSeries > > >::const_iterator aSrcIt( aNewSeries.begin()); - std::vector< Reference< XDataSeriesContainer > >::iterator aDestIt( aSeriesCnt.begin()); - for(; aSrcIt != aNewSeries.end() && aDestIt != aSeriesCnt.end(); - ++aSrcIt, ++aDestIt ) + std::vector< Sequence< Reference< XDataSeries > > >::const_iterator aSrcIt( aNewSeries.begin()); + std::vector< Reference< XDataSeriesContainer > >::iterator aDestIt( aSeriesCnt.begin()); + for(; aSrcIt != aNewSeries.end() && aDestIt != aSeriesCnt.end(); + ++aSrcIt, ++aDestIt ) + { + try { - try - { - OSL_ASSERT( (*aDestIt).is()); - (*aDestIt)->setDataSeries( *aSrcIt ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + OSL_ASSERT( (*aDestIt).is()); + (*aDestIt)->setDataSeries( *aSrcIt ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } - - DialogModel::setCategories(rNewData.Categories); } + + DialogModel::setCategories(rNewData.Categories); } sal_Int32 DialogModel::countSeries() const diff --git a/chart2/source/controller/dialogs/RangeSelectionHelper.cxx b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx index 775f80535f32..8cd8f64c8383 100644 --- a/chart2/source/controller/dialogs/RangeSelectionHelper.cxx +++ b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx @@ -70,27 +70,27 @@ Reference< sheet::XRangeSelection > const & RangeSelectionHelper::getRangeSelect void RangeSelectionHelper::raiseRangeSelectionDocument() { Reference< sheet::XRangeSelection > xRangeSel( getRangeSelection()); - if( xRangeSel.is()) + if( !xRangeSel.is()) + return; + + try { - try + // bring document to front + Reference< frame::XController > xCtrl( xRangeSel, uno::UNO_QUERY ); + if( xCtrl.is()) { - // bring document to front - Reference< frame::XController > xCtrl( xRangeSel, uno::UNO_QUERY ); - if( xCtrl.is()) + Reference< frame::XFrame > xFrame( xCtrl->getFrame()); + if( xFrame.is()) { - Reference< frame::XFrame > xFrame( xCtrl->getFrame()); - if( xFrame.is()) - { - Reference< awt::XTopWindow > xWin( xFrame->getContainerWindow(), - uno::UNO_QUERY_THROW ); - xWin->toFront(); - } + Reference< awt::XTopWindow > xWin( xFrame->getContainerWindow(), + uno::UNO_QUERY_THROW ); + xWin->toFront(); } } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx index 7735c1757e1f..40ab5f3d90ce 100644 --- a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx +++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx @@ -151,26 +151,26 @@ void SAL_CALL CreationWizardUnoDlg::setTitle( const OUString& /*rTitle*/ ) void CreationWizardUnoDlg::createDialogOnDemand() { SolarMutexGuard aSolarGuard; - if (!m_xDialog) + if (m_xDialog) + return; + + if( !m_xParentWindow.is() && m_xChartModel.is() ) { - if( !m_xParentWindow.is() && m_xChartModel.is() ) + uno::Reference< frame::XController > xController( + m_xChartModel->getCurrentController() ); + if( xController.is() ) { - uno::Reference< frame::XController > xController( - m_xChartModel->getCurrentController() ); - if( xController.is() ) - { - uno::Reference< frame::XFrame > xFrame( - xController->getFrame() ); - if(xFrame.is()) - m_xParentWindow = xFrame->getContainerWindow(); - } - } - uno::Reference< XComponent > xKeepAlive( this ); - if( m_xChartModel.is() ) - { - m_xDialog = std::make_unique<CreationWizard>(Application::GetFrameWeld(m_xParentWindow), m_xChartModel, m_xCC); + uno::Reference< frame::XFrame > xFrame( + xController->getFrame() ); + if(xFrame.is()) + m_xParentWindow = xFrame->getContainerWindow(); } } + uno::Reference< XComponent > xKeepAlive( this ); + if( m_xChartModel.is() ) + { + m_xDialog = std::make_unique<CreationWizard>(Application::GetFrameWeld(m_xParentWindow), m_xChartModel, m_xCC); + } } sal_Int16 SAL_CALL CreationWizardUnoDlg::execute( ) diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx index 46faf3b8774b..b196b24d98d8 100644 --- a/chart2/source/controller/dialogs/dlg_DataSource.cxx +++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx @@ -57,18 +57,18 @@ private: DocumentChartTypeTemplateProvider::DocumentChartTypeTemplateProvider( const Reference< chart2::XChartDocument > & xDoc ) { - if( xDoc.is()) + if( !xDoc.is()) + return; + + Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram()); + if( xDia.is()) { - Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram()); - if( xDia.is()) - { - DiagramHelper::tTemplateWithServiceName aResult( - DiagramHelper::getTemplateForDiagram( - xDia, - Reference< lang::XMultiServiceFactory >( - xDoc->getChartTypeManager(), uno::UNO_QUERY ) )); - m_xTemplate.set( aResult.first ); - } + DiagramHelper::tTemplateWithServiceName aResult( + DiagramHelper::getTemplateForDiagram( + xDia, + Reference< lang::XMultiServiceFactory >( + xDoc->getChartTypeManager(), uno::UNO_QUERY ) )); + m_xTemplate.set( aResult.first ); } } diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx index 741325178b89..ca1918c170ee 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.cxx +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -196,21 +196,21 @@ IMPL_LINK(DataLabelResources, NumberFormatDialogHdl, weld::Button&, rButton, voi NumberFormatDialog aDlg(m_pWindow, aNumberSet); if( bPercent ) aDlg.set_title(m_xFT_NumberFormatForPercent->get_label()); - if (aDlg.run() == RET_OK) + if (aDlg.run() != RET_OK) + return; + + const SfxItemSet* pResult = aDlg.GetOutputItemSet(); + if( pResult ) { - const SfxItemSet* pResult = aDlg.GetOutputItemSet(); - if( pResult ) - { - bool bOldSource = rUseSourceFormat; - sal_uLong nOldFormat = rnFormatKey; - bool bOldMixedState = rbMixedState || rbSourceMixedState; + bool bOldSource = rUseSourceFormat; + sal_uLong nOldFormat = rnFormatKey; + bool bOldMixedState = rbMixedState || rbSourceMixedState; - rbMixedState = !lcl_ReadNumberFormatFromItemSet( *pResult, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, rnFormatKey, rUseSourceFormat, rbSourceMixedState ); + rbMixedState = !lcl_ReadNumberFormatFromItemSet( *pResult, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, rnFormatKey, rUseSourceFormat, rbSourceMixedState ); - //todo this maybe can be removed when the numberformatter dialog does handle mixed state for source format correctly - if( bOldMixedState && bOldSource == rUseSourceFormat && nOldFormat == rnFormatKey ) - rbMixedState = rbSourceMixedState = true; - } + //todo this maybe can be removed when the numberformatter dialog does handle mixed state for source format correctly + if( bOldMixedState && bOldSource == rUseSourceFormat && nOldFormat == rnFormatKey ) + rbMixedState = rbSourceMixedState = true; } } diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx index a888b49f7e8f..0eaea7b4e163 100644 --- a/chart2/source/controller/dialogs/res_Trendline.cxx +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -228,31 +228,31 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) m_xCB_ShowCorrelationCoeff->set_active( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue()); } - if( m_bTrendLineUnique ) + if( !m_bTrendLineUnique ) + return; + + switch( m_eTrendLineType ) { - switch( m_eTrendLineType ) - { - case SvxChartRegress::Linear : - m_xRB_Linear->set_active(true); - break; - case SvxChartRegress::Log : - m_xRB_Logarithmic->set_active(true); - break; - case SvxChartRegress::Exp : - m_xRB_Exponential->set_active(true); - break; - case SvxChartRegress::Power : - m_xRB_Power->set_active(true); - break; - case SvxChartRegress::Polynomial : - m_xRB_Polynomial->set_active(true); - break; - case SvxChartRegress::MovingAverage : - m_xRB_MovingAverage->set_active(true); - break; - default: - break; - } + case SvxChartRegress::Linear : + m_xRB_Linear->set_active(true); + break; + case SvxChartRegress::Log : + m_xRB_Logarithmic->set_active(true); + break; + case SvxChartRegress::Exp : + m_xRB_Exponential->set_active(true); + break; + case SvxChartRegress::Power : + m_xRB_Power->set_active(true); + break; + case SvxChartRegress::Polynomial : + m_xRB_Polynomial->set_active(true); + break; + case SvxChartRegress::MovingAverage : + m_xRB_MovingAverage->set_active(true); + break; + default: + break; } } diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx index ff2f4f46b132..e656ef206499 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx @@ -131,23 +131,23 @@ namespace const ::chart::LightSource & rLightSource, sal_Int32 nIndex ) { - if( 0 <= nIndex && nIndex < 8 ) - { - OUString aIndex( OUString::number( nIndex + 1 )); + if( !(0 <= nIndex && nIndex < 8) ) + return; - try - { - xSceneProperties->setPropertyValue( "D3DSceneLightColor" + aIndex, - uno::makeAny( rLightSource.nDiffuseColor )); - xSceneProperties->setPropertyValue( "D3DSceneLightDirection" + aIndex, - uno::Any( rLightSource.aDirection )); - xSceneProperties->setPropertyValue( "D3DSceneLightOn" + aIndex, - uno::Any( rLightSource.bIsEnabled )); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + OUString aIndex( OUString::number( nIndex + 1 )); + + try + { + xSceneProperties->setPropertyValue( "D3DSceneLightColor" + aIndex, + uno::makeAny( rLightSource.nDiffuseColor )); + xSceneProperties->setPropertyValue( "D3DSceneLightDirection" + aIndex, + uno::Any( rLightSource.aDirection )); + xSceneProperties->setPropertyValue( "D3DSceneLightOn" + aIndex, + uno::Any( rLightSource.bIsEnabled )); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } @@ -353,33 +353,33 @@ IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, weld::Button&, rBut SvColorDialog aColorDlg; aColorDlg.SetColor( pListBox->GetSelectEntryColor() ); - if( aColorDlg.Execute(m_pTopLevel) == RET_OK ) + if( aColorDlg.Execute(m_pTopLevel) != RET_OK ) + return; + + Color aColor( aColorDlg.GetColor()); + lcl_selectColor( *pListBox, aColor ); + if( bIsAmbientLight ) { - Color aColor( aColorDlg.GetColor()); - lcl_selectColor( *pListBox, aColor ); - if( bIsAmbientLight ) - { - m_bInCommitToModel = true; - lcl_setAmbientColor( m_xSceneProperties, aColor ); - m_bInCommitToModel = false; - } - else + m_bInCommitToModel = true; + lcl_setAmbientColor( m_xSceneProperties, aColor ); + m_bInCommitToModel = false; + } + else + { + //get active lightsource: + LightSourceInfo* pInfo = nullptr; + sal_Int32 nL=0; + for( nL=0; nL<8; nL++) { - //get active lightsource: - LightSourceInfo* pInfo = nullptr; - sal_Int32 nL=0; - for( nL=0; nL<8; nL++) - { - pInfo = &m_pLightSourceInfoList[nL]; - if(pInfo->pButton->get_active()) - break; - pInfo = nullptr; - } - if(pInfo) - applyLightSourceToModel( nL ); + pInfo = &m_pLightSourceInfoList[nL]; + if(pInfo->pButton->get_active()) + break; + pInfo = nullptr; } - SelectColorHdl( *pListBox ); + if(pInfo) + applyLightSourceToModel( nL ); } + SelectColorHdl( *pListBox ); } IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, ColorListBox&, rBox, void ) diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index 97fbb5bf878f..ee79fc456464 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -230,32 +230,32 @@ void ChartTypeTabPage::selectMainType() } m_pCurrentMainType = getSelectedMainType(); - if( m_pCurrentMainType ) - { - showAllControls(*m_pCurrentMainType); + if( !m_pCurrentMainType ) + return; - m_pCurrentMainType->adjustParameterToMainType( aParameter ); - commitToModel( aParameter ); - //detect the new ThreeDLookScheme - aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) ); - if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Realistic ) - aParameter.eThreeDLookScheme=ThreeDLookScheme_Realistic; + showAllControls(*m_pCurrentMainType); - uno::Reference<XDiagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel); - try - { - uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); - xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; - } - catch ( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + m_pCurrentMainType->adjustParameterToMainType( aParameter ); + commitToModel( aParameter ); + //detect the new ThreeDLookScheme + aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) ); + if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Realistic ) + aParameter.eThreeDLookScheme=ThreeDLookScheme_Realistic; - fillAllControls( aParameter ); - uno::Reference< beans::XPropertySet > xTemplateProps( getCurrentTemplate(), uno::UNO_QUERY ); - m_pCurrentMainType->fillExtraControls(m_xChartModel,xTemplateProps); + uno::Reference<XDiagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel); + try + { + uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); + xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; } + catch ( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + + fillAllControls( aParameter ); + uno::Reference< beans::XPropertySet > xTemplateProps( getCurrentTemplate(), uno::UNO_QUERY ); + m_pCurrentMainType->fillExtraControls(m_xChartModel,xTemplateProps); } void ChartTypeTabPage::showAllControls( ChartTypeDialogController& rTypeController ) diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index b4cad889bb7e..eb22751a0ec3 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -390,32 +390,32 @@ void DataSourceTabPage::fillRoleListBox() bool bHasSelectedEntry = (pSeriesEntry != nullptr); int nRoleIndex = m_xLB_ROLE->get_selected_index(); - if (bHasSelectedEntry) - { - DialogModel::tRolesWithRanges aRoles( - DialogModel::getRolesWithRanges( - pSeriesEntry->m_xDataSeries, - lcl_GetSequenceNameForLabel( pSeriesEntry ), - pSeriesEntry->m_xChartType )); + if (!bHasSelectedEntry) + return; - // fill role list - m_xLB_ROLE->freeze(); - m_xLB_ROLE->clear(); + DialogModel::tRolesWithRanges aRoles( + DialogModel::getRolesWithRanges( + pSeriesEntry->m_xDataSeries, + lcl_GetSequenceNameForLabel( pSeriesEntry ), + pSeriesEntry->m_xChartType )); - for (auto const& elemRole : aRoles) - { - InsertRoleLBEntry(elemRole.first, elemRole.second); - } + // fill role list + m_xLB_ROLE->freeze(); + m_xLB_ROLE->clear(); - m_xLB_ROLE->thaw(); + for (auto const& elemRole : aRoles) + { + InsertRoleLBEntry(elemRole.first, elemRole.second); + } - // series may contain no roles, check listbox size before selecting entries - if (m_xLB_ROLE->n_children() > 0) - { - if (nRoleIndex == -1 || nRoleIndex >= m_xLB_ROLE->n_children()) - nRoleIndex = 0; - m_xLB_ROLE->select(nRoleIndex); - } + m_xLB_ROLE->thaw(); + + // series may contain no roles, check listbox size before selecting entries + if (m_xLB_ROLE->n_children() > 0) + { + if (nRoleIndex == -1 || nRoleIndex >= m_xLB_ROLE->n_children()) + nRoleIndex = 0; + m_xLB_ROLE->select(nRoleIndex); } } @@ -475,24 +475,24 @@ IMPL_LINK_NOARG(DataSourceTabPage, RoleSelectionChangedHdl, weld::TreeView&, voi { m_rDialogModel.startControllerLockTimer(); int nEntry = m_xLB_ROLE->get_selected_index(); - if (nEntry != -1) - { - OUString aSelectedRoleUI = lcl_GetSelectedRole( *m_xLB_ROLE, true ); - OUString aSelectedRange = lcl_GetSelectedRolesRange( *m_xLB_ROLE ); + if (nEntry == -1) + return; - // replace role in fixed text label - const OUString aReplacementStr( "%VALUETYPE" ); - sal_Int32 nIndex = m_aFixedTextRange.indexOf( aReplacementStr ); - if( nIndex != -1 ) - { - m_xFT_RANGE->set_label( - m_aFixedTextRange.replaceAt( - nIndex, aReplacementStr.getLength(), aSelectedRoleUI )); - } + OUString aSelectedRoleUI = lcl_GetSelectedRole( *m_xLB_ROLE, true ); + OUString aSelectedRange = lcl_GetSelectedRolesRange( *m_xLB_ROLE ); - m_xEDT_RANGE->set_text(aSelectedRange); - isValid(); + // replace role in fixed text label + const OUString aReplacementStr( "%VALUETYPE" ); + sal_Int32 nIndex = m_aFixedTextRange.indexOf( aReplacementStr ); + if( nIndex != -1 ) + { + m_xFT_RANGE->set_label( + m_aFixedTextRange.replaceAt( + nIndex, aReplacementStr.getLength(), aSelectedRoleUI )); } + + m_xEDT_RANGE->set_text(aSelectedRange); + isValid(); } IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, weld::Button&, void) @@ -594,39 +594,39 @@ IMPL_LINK_NOARG(DataSourceTabPage, RemoveButtonClickedHdl, weld::Button&, void) { m_rDialogModel.startControllerLockTimer(); int nEntry = m_xLB_SERIES->get_selected_index(); - if (nEntry != -1) - { - SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); - Reference< XDataSeries > xNewSelSeries; - SeriesEntry * pNewSelEntry = nullptr; - if (nEntry + 1 < m_xLB_SERIES->n_children()) - pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry + 1).toInt64()); - else if (nEntry > 0) - pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry - 1).toInt64()); - if (pNewSelEntry) - xNewSelSeries.set(pNewSelEntry->m_xDataSeries); - - m_rDialogModel.deleteSeries( pEntry->m_xDataSeries, pEntry->m_xChartType ); - setDirty(); + if (nEntry == -1) + return; - m_xLB_SERIES->remove(nEntry); - fillSeriesListBox(); + SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); + Reference< XDataSeries > xNewSelSeries; + SeriesEntry * pNewSelEntry = nullptr; + if (nEntry + 1 < m_xLB_SERIES->n_children()) + pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry + 1).toInt64()); + else if (nEntry > 0) + pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry - 1).toInt64()); + if (pNewSelEntry) + xNewSelSeries.set(pNewSelEntry->m_xDataSeries); + + m_rDialogModel.deleteSeries( pEntry->m_xDataSeries, pEntry->m_xChartType ); + setDirty(); + + m_xLB_SERIES->remove(nEntry); + fillSeriesListBox(); - // select previous or next series - if (xNewSelSeries.is()) + // select previous or next series + if (xNewSelSeries.is()) + { + for (int i = 0; i < m_xLB_SERIES->n_children(); ++i) { - for (int i = 0; i < m_xLB_SERIES->n_children(); ++i) + pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(i).toInt64()); + if (pEntry->m_xDataSeries == xNewSelSeries) { - pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(i).toInt64()); - if (pEntry->m_xDataSeries == xNewSelSeries) - { - m_xLB_SERIES->select(i); - break; - } + m_xLB_SERIES->select(i); + break; } } - SeriesSelectionChangedHdl(*m_xLB_SERIES); } + SeriesSelectionChangedHdl(*m_xLB_SERIES); } IMPL_LINK_NOARG(DataSourceTabPage, UpButtonClickedHdl, weld::Button&, void) diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index 29b4e179ffd9..c11c9eee8d8a 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -201,49 +201,49 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls() } } - if( m_bIsDirty ) - { - bool bFirstCellAsLabel = ( m_xCB_FirstColumnAsLabel->get_active() && !m_xRB_Columns->get_active() ) - || ( m_xCB_FirstRowAsLabel->get_active() && !m_xRB_Rows->get_active() ); - bool bHasCategories = ( m_xCB_FirstColumnAsLabel->get_active() && m_xRB_Columns->get_active() ) - || ( m_xCB_FirstRowAsLabel->get_active() && m_xRB_Rows->get_active() ); - bool bTimeBased = m_xCB_TimeBased->get_active(); + if( !m_bIsDirty ) + return; - Sequence< beans::PropertyValue > aArguments( - DataSourceHelper::createArguments( - m_xRB_Columns->get_active(), bFirstCellAsLabel, bHasCategories ) ); + bool bFirstCellAsLabel = ( m_xCB_FirstColumnAsLabel->get_active() && !m_xRB_Columns->get_active() ) + || ( m_xCB_FirstRowAsLabel->get_active() && !m_xRB_Rows->get_active() ); + bool bHasCategories = ( m_xCB_FirstColumnAsLabel->get_active() && m_xRB_Columns->get_active() ) ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits