diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 14:08:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-19 11:01:18 +0200 |
commit | 9df2821e61979dab32390d5c64dd49bee868adbb (patch) | |
tree | 5b827e29e73ac2300c164b0a389a784a358956e6 /chart2/source | |
parent | 8b0a69498b025e13d9772689e9e4fa3d6b05e609 (diff) |
loplugin:flatten in chart2
Change-Id: Iadc4da6515a7d82e7a92b33d74d589b61fa2c64f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92480
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source')
76 files changed, 3702 insertions, 3695 deletions
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() ) + || ( m_xCB_FirstRowAsLabel->get_active() && m_xRB_Rows->get_active() ); + bool bTimeBased = m_xCB_TimeBased->get_active(); - if(bTimeBased) - { - aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = - beans::PropertyValue( "TimeBased", -1, uno::Any(bTimeBased), - beans::PropertyState_DIRECT_VALUE ); - } + Sequence< beans::PropertyValue > aArguments( + DataSourceHelper::createArguments( + m_xRB_Columns->get_active(), bFirstCellAsLabel, bHasCategories ) ); - // only if range is valid - if( m_aLastValidRangeString == m_xED_Range->get_text()) - { - m_rDialogModel.setTemplate( m_xCurrentChartTypeTemplate ); - aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = - beans::PropertyValue( "CellRangeRepresentation" , -1, - uno::Any( m_aLastValidRangeString ), - beans::PropertyState_DIRECT_VALUE ); - m_rDialogModel.setData( aArguments ); - m_bIsDirty = false; - - if(bTimeBased) - { - sal_Int32 nStart = m_xEd_TimeStart->get_text().toInt32(); - sal_Int32 nEnd = m_xEd_TimeEnd->get_text().toInt32(); - m_rDialogModel.setTimeBasedRange(true, nStart, nEnd); - } - } + if(bTimeBased) + { + aArguments.realloc( aArguments.getLength() + 1 ); + aArguments[aArguments.getLength() - 1] = + beans::PropertyValue( "TimeBased", -1, uno::Any(bTimeBased), + beans::PropertyState_DIRECT_VALUE ); + } - //@todo warn user that the selected range is not valid - //@todo better: disable OK-Button if range is invalid + // only if range is valid + if( m_aLastValidRangeString != m_xED_Range->get_text()) + return; + + m_rDialogModel.setTemplate( m_xCurrentChartTypeTemplate ); + aArguments.realloc( aArguments.getLength() + 1 ); + aArguments[aArguments.getLength() - 1] = + beans::PropertyValue( "CellRangeRepresentation" , -1, + uno::Any( m_aLastValidRangeString ), + beans::PropertyState_DIRECT_VALUE ); + m_rDialogModel.setData( aArguments ); + m_bIsDirty = false; + + if(bTimeBased) + { + sal_Int32 nStart = m_xEd_TimeStart->get_text().toInt32(); + sal_Int32 nEnd = m_xEd_TimeEnd->get_text().toInt32(); + m_rDialogModel.setTimeBasedRange(true, nStart, nEnd); } + + //@todo warn user that the selected range is not valid + //@todo better: disable OK-Button if range is invalid } bool RangeChooserTabPage::isValid() diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index ea47532878a4..0c626667790c 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -502,52 +502,52 @@ void ScaleTabPage::SetNumFormat() { const SfxPoolItem *pPoolItem = nullptr; - if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, true, &pPoolItem ) == SfxItemState::SET ) - { - sal_uLong nFmt = static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue(); + if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, true, &pPoolItem ) != SfxItemState::SET ) + return; - m_xFmtFldMax->set_format_key(nFmt); - m_xFmtFldMin->set_format_key(nFmt); - m_xFmtFldOrigin->set_format_key(nFmt); + sal_uLong nFmt = static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue(); - if( pNumFormatter ) - { - SvNumFormatType eType = pNumFormatter->GetType( nFmt ); - if( eType == SvNumFormatType::DATE ) - { - // for intervals use standard format for dates (so you can enter a number of days) - const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); - if( pFormat ) - nFmt = pNumFormatter->GetStandardIndex( pFormat->GetLanguage()); - else - nFmt = pNumFormatter->GetStandardIndex(); - } - else if( eType == SvNumFormatType::DATETIME ) - { - // for intervals use time format for date times - const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); - if( pFormat ) - nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME, pFormat->GetLanguage() ); - else - nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME ); - } + m_xFmtFldMax->set_format_key(nFmt); + m_xFmtFldMin->set_format_key(nFmt); + m_xFmtFldOrigin->set_format_key(nFmt); - if( m_nAxisType == chart2::AxisType::DATE && ( eType != SvNumFormatType::DATE && eType != SvNumFormatType::DATETIME) ) - { - const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); - if( pFormat ) - nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::DATE, pFormat->GetLanguage() ); - else - nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::DATE ); - - m_xFmtFldMax->set_format_key(nFmt); - m_xFmtFldMin->set_format_key(nFmt); - m_xFmtFldOrigin->set_format_key(nFmt); - } + if( pNumFormatter ) + { + SvNumFormatType eType = pNumFormatter->GetType( nFmt ); + if( eType == SvNumFormatType::DATE ) + { + // for intervals use standard format for dates (so you can enter a number of days) + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardIndex( pFormat->GetLanguage()); + else + nFmt = pNumFormatter->GetStandardIndex(); + } + else if( eType == SvNumFormatType::DATETIME ) + { + // for intervals use time format for date times + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME, pFormat->GetLanguage() ); + else + nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME ); } - m_xFmtFldStepMain->set_format_key(nFmt); + if( m_nAxisType == chart2::AxisType::DATE && ( eType != SvNumFormatType::DATE && eType != SvNumFormatType::DATETIME) ) + { + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::DATE, pFormat->GetLanguage() ); + else + nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::DATE ); + + m_xFmtFldMax->set_format_key(nFmt); + m_xFmtFldMin->set_format_key(nFmt); + m_xFmtFldOrigin->set_format_key(nFmt); + } } + + m_xFmtFldStepMain->set_format_key(nFmt); } void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx index 2141c4f76bce..303af1ceb26f 100644 --- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx +++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx @@ -336,32 +336,32 @@ void DrawViewWrapper::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) E3dView::Notify(rBC, rHint); - if( pSdrHint != nullptr ) + if( pSdrHint == nullptr ) + return; + + SdrHintKind eKind = pSdrHint->GetKind(); + if( eKind == SdrHintKind::BeginEdit ) { - SdrHintKind eKind = pSdrHint->GetKind(); - if( eKind == SdrHintKind::BeginEdit ) + // #i79965# remember map mode + OSL_ASSERT( ! m_bRestoreMapMode ); + OutputDevice* pOutDev = GetFirstOutputDevice(); + if( pOutDev ) { - // #i79965# remember map mode - OSL_ASSERT( ! m_bRestoreMapMode ); - OutputDevice* pOutDev = GetFirstOutputDevice(); - if( pOutDev ) - { - m_aMapModeToRestore = pOutDev->GetMapMode(); - m_bRestoreMapMode = true; - } + m_aMapModeToRestore = pOutDev->GetMapMode(); + m_bRestoreMapMode = true; } - else if( eKind == SdrHintKind::EndEdit ) + } + else if( eKind == SdrHintKind::EndEdit ) + { + // #i79965# scroll back view when ending text edit + OSL_ASSERT( m_bRestoreMapMode ); + if( m_bRestoreMapMode ) { - // #i79965# scroll back view when ending text edit - OSL_ASSERT( m_bRestoreMapMode ); - if( m_bRestoreMapMode ) + OutputDevice* pOutDev = GetFirstOutputDevice(); + if( pOutDev ) { - OutputDevice* pOutDev = GetFirstOutputDevice(); - if( pOutDev ) - { - pOutDev->SetMapMode( m_aMapModeToRestore ); - m_bRestoreMapMode = false; - } + pOutDev->SetMapMode( m_aMapModeToRestore ); + m_bRestoreMapMode = false; } } } diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 8502eeba1f56..38a1f4292a67 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -241,18 +241,18 @@ DataPointItemConverter::DataPointItemConverter( m_bForbidPercentValue = ChartTypeHelper::getAxisType( xChartType, 0 ) != AxisType::CATEGORY; - if (!bDataSeries) + if (bDataSeries) + return; + + uno::Reference<beans::XPropertySet> xSeriesProp(xSeries, uno::UNO_QUERY); + uno::Sequence<sal_Int32> deletedLegendEntriesSeq; + xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq; + for (auto& deletedLegendEntry : deletedLegendEntriesSeq) { - uno::Reference<beans::XPropertySet> xSeriesProp(xSeries, uno::UNO_QUERY); - uno::Sequence<sal_Int32> deletedLegendEntriesSeq; - xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq; - for (auto& deletedLegendEntry : deletedLegendEntriesSeq) + if (nPointIndex == deletedLegendEntry) { - if (nPointIndex == deletedLegendEntry) - { - m_bHideLegendEntry = true; - break; - } + m_bHideLegendEntry = true; + break; } } } diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx index c50ca18c53f4..a99d848d0c8c 100644 --- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx @@ -49,18 +49,18 @@ ItemConverter::~ItemConverter() void ItemConverter::resetPropertySet( const uno::Reference< beans::XPropertySet > & xPropSet ) { - if( xPropSet.is()) - { - stopAllComponentListening(); - m_xPropertySet = xPropSet; - m_xPropertySetInfo = m_xPropertySet->getPropertySetInfo(); + if( !xPropSet.is()) + return; - uno::Reference< lang::XComponent > xComp( m_xPropertySet, uno::UNO_QUERY ); - if( xComp.is()) - { - // method of base class ::utl::OEventListenerAdapter - startComponentListening( xComp ); - } + stopAllComponentListening(); + m_xPropertySet = xPropSet; + m_xPropertySetInfo = m_xPropertySet->getPropertySetInfo(); + + uno::Reference< lang::XComponent > xComp( m_xPropertySet, uno::UNO_QUERY ); + if( xComp.is()) + { + // method of base class ::utl::OEventListenerAdapter + startComponentListening( xComp ); } } diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 8511ad1bfcb6..ad6e94ee1f0c 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -903,25 +903,25 @@ void SAL_CALL ChartController::notifyClosing( //Listener should deregister himself and release all references to the closing object. TheModelRef aModelRef( m_aModel, m_aModelMutex); - if( impl_releaseThisModel( rSource.Source ) ) - { - //--stop listening to the closing model - aModelRef->removeListener( this ); + if( !impl_releaseThisModel( rSource.Source ) ) + return; - // #i79087# If the model using this controller is closed, the frame is - // expected to be closed as well - Reference< util::XCloseable > xFrameCloseable( m_xFrame, uno::UNO_QUERY ); - if( xFrameCloseable.is()) + //--stop listening to the closing model + aModelRef->removeListener( this ); + + // #i79087# If the model using this controller is closed, the frame is + // expected to be closed as well + Reference< util::XCloseable > xFrameCloseable( m_xFrame, uno::UNO_QUERY ); + if( xFrameCloseable.is()) + { + try { - try - { - xFrameCloseable->close( false /* DeliverOwnership */ ); - m_xFrame.clear(); - } - catch( const util::CloseVetoException & ) - { - // closing was vetoed - } + xFrameCloseable->close( false /* DeliverOwnership */ ); + m_xFrame.clear(); + } + catch( const util::CloseVetoException & ) + { + // closing was vetoed } } } @@ -1442,19 +1442,19 @@ void ChartController::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> pUndoA ENSURE_OR_RETURN_VOID( pUndoAction, "invalid Undo action" ); OUString aObjectCID = m_aSelection.getSelectedCID(); - if ( aObjectCID.isEmpty() ) + if ( !aObjectCID.isEmpty() ) + return; + + try { - try - { - const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); - const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); - const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( std::move(pUndoAction) ) ); - xUndoManager->addUndoAction( xAction ); - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); + const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( std::move(pUndoAction) ) ); + xUndoManager->addUndoAction( xAction ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } @@ -1550,28 +1550,28 @@ void ChartController::impl_initializeAccessible() } void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit ) { - if(xInit.is()) + if(!xInit.is()) + return; + + uno::Sequence< uno::Any > aArguments(5); + aArguments[0] <<= uno::Reference<view::XSelectionSupplier>(this); + aArguments[1] <<= getModel(); + aArguments[2] <<= m_xChartView; + uno::Reference< XAccessible > xParent; { - uno::Sequence< uno::Any > aArguments(5); - aArguments[0] <<= uno::Reference<view::XSelectionSupplier>(this); - aArguments[1] <<= getModel(); - aArguments[2] <<= m_xChartView; - uno::Reference< XAccessible > xParent; + SolarMutexGuard aGuard; + auto pChartWindow(GetChartWindow()); + if( pChartWindow ) { - SolarMutexGuard aGuard; - auto pChartWindow(GetChartWindow()); - if( pChartWindow ) - { - vcl::Window* pParentWin( pChartWindow->GetAccessibleParentWindow()); - if( pParentWin ) - xParent.set( pParentWin->GetAccessible()); - } + vcl::Window* pParentWin( pChartWindow->GetAccessibleParentWindow()); + if( pParentWin ) + xParent.set( pParentWin->GetAccessible()); } - aArguments[3] <<= xParent; - aArguments[4] <<= m_xViewWindow; - - xInit->initialize(aArguments); } + aArguments[3] <<= xParent; + aArguments[4] <<= m_xViewWindow; + + xInit->initialize(aArguments); } const o3tl::sorted_vector< OUString >& ChartController::impl_getAvailableCommands() diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 1e4212a428cc..611cd3dbd613 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -522,21 +522,21 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); } - if( xRegCurve.is()) + if( !xRegCurve.is()) + return; + + uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties()); + if( xEqProp.is()) { - uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties()); - if( xEqProp.is()) - { - UndoGuard aUndoGuard( - ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_CURVE_EQUATION )), - m_xUndoManager ); - xEqProp->setPropertyValue( "ShowEquation", uno::Any( true )); - xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") )); - xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x)") )); - xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( bInsertR2 )); - aUndoGuard.commit(); - } + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_CURVE_EQUATION )), + m_xUndoManager ); + xEqProp->setPropertyValue( "ShowEquation", uno::Any( true )); + xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") )); + xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x)") )); + xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( bInsertR2 )); + aUndoGuard.commit(); } } diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 57a687467fd6..ae18162d8a80 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -79,26 +79,26 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) , true //bDontDeleteOutliner , true //bOnlyOneView ); - if(bEdit) - { - m_pDrawViewWrapper->SetEditMode(); + if(!bEdit) + return; - // #i12587# support for shapes in chart - if ( pMousePixel ) + m_pDrawViewWrapper->SetEditMode(); + + // #i12587# support for shapes in chart + if ( pMousePixel ) + { + OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + if ( pOutlinerView ) { - OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); - if ( pOutlinerView ) - { - MouseEvent aEditEvt( *pMousePixel, 1, MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0 ); - pOutlinerView->MouseButtonDown( aEditEvt ); - pOutlinerView->MouseButtonUp( aEditEvt ); - } + MouseEvent aEditEvt( *pMousePixel, 1, MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0 ); + pOutlinerView->MouseButtonDown( aEditEvt ); + pOutlinerView->MouseButtonUp( aEditEvt ); } - - //we invalidate the outliner region because the outliner has some - //paint problems (some characters are painted twice a little bit shifted) - GetChartWindow()->Invalidate( m_pDrawViewWrapper->GetMarkedObjBoundRect() ); } + + //we invalidate the outliner region because the outliner has some + //paint problems (some characters are painted twice a little bit shifted) + GetChartWindow()->Invalidate( m_pDrawViewWrapper->GetMarkedObjBoundRect() ); } bool ChartController::EndTextEdit() @@ -168,42 +168,42 @@ void ChartController::executeDispatch_InsertSpecialCharacter() aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), SID_ATTR_CHAR_FONT ) ); ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetChartFrame(), aSet, nullptr)); - if( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pSet = pDlg->GetOutputItemSet(); - const SfxPoolItem* pItem=nullptr; - OUString aString; - if (pSet && pSet->GetItemState(SID_CHARMAP, true, &pItem) == SfxItemState::SET) - if (auto pStringItem = dynamic_cast<const SfxStringItem*>(pItem)) - aString = pStringItem->GetValue(); + if( pDlg->Execute() != RET_OK ) + return; - OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); - SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); + const SfxItemSet* pSet = pDlg->GetOutputItemSet(); + const SfxPoolItem* pItem=nullptr; + OUString aString; + if (pSet && pSet->GetItemState(SID_CHARMAP, true, &pItem) == SfxItemState::SET) + if (auto pStringItem = dynamic_cast<const SfxStringItem*>(pItem)) + aString = pStringItem->GetValue(); - if(!pOutliner || !pOutlinerView) - return; + OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); - // insert string to outliner + if(!pOutliner || !pOutlinerView) + return; - // prevent flicker - pOutlinerView->HideCursor(); - pOutliner->SetUpdateMode(false); + // insert string to outliner - // delete current selection by inserting empty String, so current - // attributes become unique (sel. has to be erased anyway) - pOutlinerView->InsertText(OUString()); + // prevent flicker + pOutlinerView->HideCursor(); + pOutliner->SetUpdateMode(false); - pOutlinerView->InsertText(aString, true); + // delete current selection by inserting empty String, so current + // attributes become unique (sel. has to be erased anyway) + pOutlinerView->InsertText(OUString()); - ESelection aSel = pOutlinerView->GetSelection(); - aSel.nStartPara = aSel.nEndPara; - aSel.nStartPos = aSel.nEndPos; - pOutlinerView->SetSelection(aSel); + pOutlinerView->InsertText(aString, true); - // show changes - pOutliner->SetUpdateMode(true); - pOutlinerView->ShowCursor(); - } + ESelection aSel = pOutlinerView->GetSelection(); + aSel.nStartPara = aSel.nEndPara; + aSel.nStartPos = aSel.nEndPos; + pOutlinerView->SetSelection(aSel); + + // show changes + pOutliner->SetUpdateMode(true); + pOutlinerView->ShowCursor(); } uno::Reference< css::accessibility::XAccessibleContext > diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 49214b46e8c9..c6024350430d 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -252,79 +252,79 @@ void ChartController::executeDispatch_Paste() { SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); - if( pChartWindow ) - { - Graphic aGraphic; - // paste location: center of window - Point aPos = pChartWindow->PixelToLogic( tools::Rectangle( {}, pChartWindow->GetSizePixel()).Center()); + if( !pChartWindow ) + return; - // handle different formats - TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pChartWindow )); - if( aDataHelper.GetTransferable().is()) + Graphic aGraphic; + // paste location: center of window + Point aPos = pChartWindow->PixelToLogic( tools::Rectangle( {}, pChartWindow->GetSizePixel()).Center()); + + // handle different formats + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pChartWindow )); + if( aDataHelper.GetTransferable().is()) + { + if ( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) ) { - if ( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) ) + tools::SvRef<SotStorageStream> xStm; + if ( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xStm ) ) { - tools::SvRef<SotStorageStream> xStm; - if ( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xStm ) ) - { - xStm->Seek( 0 ); - Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) ); + xStm->Seek( 0 ); + Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) ); - std::unique_ptr< SdrModel > spModel( - new SdrModel()); + std::unique_ptr< SdrModel > spModel( + new SdrModel()); - if ( SvxDrawingLayerImport( spModel.get(), xInputStream ) ) - { - impl_PasteShapes( spModel.get() ); - } + if ( SvxDrawingLayerImport( spModel.get(), xInputStream ) ) + { + impl_PasteShapes( spModel.get() ); } } - else if ( aDataHelper.HasFormat( SotClipboardFormatId::SVXB ) ) - { - // graphic exchange format (graphic manager bitmap format?) - tools::SvRef<SotStorageStream> xStm; - if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm )) - ReadGraphic( *xStm, aGraphic ); - } - else if( aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE )) - { - // meta file - GDIMetaFile aMetafile; - if( aDataHelper.GetGDIMetaFile( SotClipboardFormatId::GDIMETAFILE, aMetafile )) - aGraphic = Graphic( aMetafile ); - } - else if( aDataHelper.HasFormat( SotClipboardFormatId::BITMAP )) - { - // bitmap (non-graphic-manager) - BitmapEx aBmpEx; - if( aDataHelper.GetBitmapEx( SotClipboardFormatId::BITMAP, aBmpEx )) - aGraphic = Graphic( aBmpEx ); - } - else if( aDataHelper.HasFormat( SotClipboardFormatId::STRING )) + } + else if ( aDataHelper.HasFormat( SotClipboardFormatId::SVXB ) ) + { + // graphic exchange format (graphic manager bitmap format?) + tools::SvRef<SotStorageStream> xStm; + if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm )) + ReadGraphic( *xStm, aGraphic ); + } + else if( aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE )) + { + // meta file + GDIMetaFile aMetafile; + if( aDataHelper.GetGDIMetaFile( SotClipboardFormatId::GDIMETAFILE, aMetafile )) + aGraphic = Graphic( aMetafile ); + } + else if( aDataHelper.HasFormat( SotClipboardFormatId::BITMAP )) + { + // bitmap (non-graphic-manager) + BitmapEx aBmpEx; + if( aDataHelper.GetBitmapEx( SotClipboardFormatId::BITMAP, aBmpEx )) + aGraphic = Graphic( aBmpEx ); + } + else if( aDataHelper.HasFormat( SotClipboardFormatId::STRING )) + { + OUString aString; + if( aDataHelper.GetString( SotClipboardFormatId::STRING, aString ) && m_pDrawModelWrapper ) { - OUString aString; - if( aDataHelper.GetString( SotClipboardFormatId::STRING, aString ) && m_pDrawModelWrapper ) + if( m_pDrawViewWrapper ) { - if( m_pDrawViewWrapper ) + OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + if( pOutlinerView )//in case of edit mode insert into edited string + pOutlinerView->InsertText( aString ); + else { - OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); - if( pOutlinerView )//in case of edit mode insert into edited string - pOutlinerView->InsertText( aString ); - else - { - impl_PasteStringAsTextShape( aString, awt::Point( 0, 0 ) ); - } + impl_PasteStringAsTextShape( aString, awt::Point( 0, 0 ) ); } } } } + } - if( aGraphic.GetType() != GraphicType::NONE ) - { - Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic()); - if( xGraphic.is()) - impl_PasteGraphic( xGraphic, aPos ); - } + if( aGraphic.GetType() != GraphicType::NONE ) + { + Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic()); + if( xGraphic.is()) + impl_PasteGraphic( xGraphic, aPos ); } } @@ -345,147 +345,147 @@ void ChartController::impl_PasteGraphic( uno::Reference< drawing::XShape > xGraphicShape( xFact->createInstance( "com.sun.star.drawing.GraphicObjectShape" ), uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xGraphicShapeProp( xGraphicShape, uno::UNO_QUERY ); - if( xGraphicShapeProp.is() && xGraphicShape.is()) + if( !(xGraphicShapeProp.is() && xGraphicShape.is())) + return; + + uno::Reference< drawing::XShapes > xPage = pDrawModelWrapper->getMainDrawPage(); + if( xPage.is()) { - uno::Reference< drawing::XShapes > xPage = pDrawModelWrapper->getMainDrawPage(); - if( xPage.is()) + xPage->add( xGraphicShape ); + //need to change the model state manually { - xPage->add( xGraphicShape ); - //need to change the model state manually - { - uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY ); - if( xModifiable.is() ) - xModifiable->setModified( true ); - } - //select new shape - m_aSelection.setSelection( xGraphicShape ); - m_aSelection.applySelection( m_pDrawViewWrapper.get() ); - } - xGraphicShapeProp->setPropertyValue( "Graphic", uno::Any( xGraphic )); - uno::Reference< beans::XPropertySet > xGraphicProp( xGraphic, uno::UNO_QUERY ); - - awt::Size aGraphicSize( 1000, 1000 ); - auto pChartWindow(GetChartWindow()); - // first try size in 100th mm, then pixel size - if( ! ( xGraphicProp->getPropertyValue( "Size100thMM") >>= aGraphicSize ) && - ( ( xGraphicProp->getPropertyValue( "SizePixel") >>= aGraphicSize ) && pChartWindow )) - { - ::Size aVCLSize( pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height ))); - aGraphicSize.Width = aVCLSize.getWidth(); - aGraphicSize.Height = aVCLSize.getHeight(); + uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY ); + if( xModifiable.is() ) + xModifiable->setModified( true ); } - xGraphicShape->setSize( aGraphicSize ); - xGraphicShape->setPosition( awt::Point( 0, 0 ) ); + //select new shape + m_aSelection.setSelection( xGraphicShape ); + m_aSelection.applySelection( m_pDrawViewWrapper.get() ); + } + xGraphicShapeProp->setPropertyValue( "Graphic", uno::Any( xGraphic )); + uno::Reference< beans::XPropertySet > xGraphicProp( xGraphic, uno::UNO_QUERY ); + + awt::Size aGraphicSize( 1000, 1000 ); + auto pChartWindow(GetChartWindow()); + // first try size in 100th mm, then pixel size + if( ! ( xGraphicProp->getPropertyValue( "Size100thMM") >>= aGraphicSize ) && + ( ( xGraphicProp->getPropertyValue( "SizePixel") >>= aGraphicSize ) && pChartWindow )) + { + ::Size aVCLSize( pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height ))); + aGraphicSize.Width = aVCLSize.getWidth(); + aGraphicSize.Height = aVCLSize.getHeight(); } + xGraphicShape->setSize( aGraphicSize ); + xGraphicShape->setPosition( awt::Point( 0, 0 ) ); } void ChartController::impl_PasteShapes( SdrModel* pModel ) { DrawModelWrapper* pDrawModelWrapper( GetDrawModelWrapper() ); - if ( pDrawModelWrapper && m_pDrawViewWrapper ) + if ( !(pDrawModelWrapper && m_pDrawViewWrapper) ) + return; + + Reference< drawing::XDrawPage > xDestPage( pDrawModelWrapper->getMainDrawPage() ); + SdrPage* pDestPage = GetSdrPageFromXDrawPage( xDestPage ); + if ( !pDestPage ) + return; + + Reference< drawing::XShape > xSelShape; + m_pDrawViewWrapper->BegUndo( SvxResId( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) ); + sal_uInt16 nCount = pModel->GetPageCount(); + for ( sal_uInt16 i = 0; i < nCount; ++i ) { - Reference< drawing::XDrawPage > xDestPage( pDrawModelWrapper->getMainDrawPage() ); - SdrPage* pDestPage = GetSdrPageFromXDrawPage( xDestPage ); - if ( pDestPage ) + const SdrPage* pPage = pModel->GetPage( i ); + SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups ); + while ( aIter.IsMore() ) { - Reference< drawing::XShape > xSelShape; - m_pDrawViewWrapper->BegUndo( SvxResId( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) ); - sal_uInt16 nCount = pModel->GetPageCount(); - for ( sal_uInt16 i = 0; i < nCount; ++i ) + SdrObject* pObj(aIter.Next()); + // Clone to new SdrModel + SdrObject* pNewObj(pObj ? pObj->CloneSdrObject(pDrawModelWrapper->getSdrModel()) : nullptr); + + if ( pNewObj ) { - const SdrPage* pPage = pModel->GetPage( i ); - SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups ); - while ( aIter.IsMore() ) + // set position + Reference< drawing::XShape > xShape( pNewObj->getUnoShape(), uno::UNO_QUERY ); + if ( xShape.is() ) { - SdrObject* pObj(aIter.Next()); - // Clone to new SdrModel - SdrObject* pNewObj(pObj ? pObj->CloneSdrObject(pDrawModelWrapper->getSdrModel()) : nullptr); - - if ( pNewObj ) - { - // set position - Reference< drawing::XShape > xShape( pNewObj->getUnoShape(), uno::UNO_QUERY ); - if ( xShape.is() ) - { - xShape->setPosition( awt::Point( 0, 0 ) ); - } - - pDestPage->InsertObject( pNewObj ); - m_pDrawViewWrapper->AddUndo( std::make_unique<SdrUndoInsertObj>( *pNewObj ) ); - xSelShape = xShape; - } + xShape->setPosition( awt::Point( 0, 0 ) ); } - } - Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY ); - if ( xModifiable.is() ) - { - xModifiable->setModified( true ); + pDestPage->InsertObject( pNewObj ); + m_pDrawViewWrapper->AddUndo( std::make_unique<SdrUndoInsertObj>( *pNewObj ) ); + xSelShape = xShape; } + } + } - // select last inserted shape - m_aSelection.setSelection( xSelShape ); - m_aSelection.applySelection( m_pDrawViewWrapper.get() ); + Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY ); + if ( xModifiable.is() ) + { + xModifiable->setModified( true ); + } - m_pDrawViewWrapper->EndUndo(); + // select last inserted shape + m_aSelection.setSelection( xSelShape ); + m_aSelection.applySelection( m_pDrawViewWrapper.get() ); - impl_switchDiagramPositioningToExcludingPositioning(); - } - } + m_pDrawViewWrapper->EndUndo(); + + impl_switchDiagramPositioningToExcludingPositioning(); } void ChartController::impl_PasteStringAsTextShape( const OUString& rString, const awt::Point& rPosition ) { DrawModelWrapper* pDrawModelWrapper( GetDrawModelWrapper() ); - if ( pDrawModelWrapper && m_pDrawViewWrapper ) - { - const Reference< lang::XMultiServiceFactory >& xShapeFactory( pDrawModelWrapper->getShapeFactory() ); - const Reference< drawing::XDrawPage >& xDrawPage( pDrawModelWrapper->getMainDrawPage() ); - OSL_ASSERT( xShapeFactory.is() && xDrawPage.is() ); + if ( !(pDrawModelWrapper && m_pDrawViewWrapper) ) + return; + + const Reference< lang::XMultiServiceFactory >& xShapeFactory( pDrawModelWrapper->getShapeFactory() ); + const Reference< drawing::XDrawPage >& xDrawPage( pDrawModelWrapper->getMainDrawPage() ); + OSL_ASSERT( xShapeFactory.is() && xDrawPage.is() ); - if ( xShapeFactory.is() && xDrawPage.is() ) + if ( !(xShapeFactory.is() && xDrawPage.is()) ) + return; + + try + { + Reference< drawing::XShape > xTextShape( + xShapeFactory->createInstance( "com.sun.star.drawing.TextShape" ), uno::UNO_QUERY_THROW ); + xDrawPage->add( xTextShape ); + + Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW ); + xRange->setString( rString ); + + float fCharHeight = 10.0; + Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW ); + xProperties->setPropertyValue( "TextAutoGrowHeight", uno::Any( true ) ); + xProperties->setPropertyValue( "TextAutoGrowWidth", uno::Any( true ) ); + xProperties->setPropertyValue( "CharHeight", uno::Any( fCharHeight ) ); + xProperties->setPropertyValue( "CharHeightAsian", uno::Any( fCharHeight ) ); + xProperties->setPropertyValue( "CharHeightComplex", uno::Any( fCharHeight ) ); + xProperties->setPropertyValue( "TextVerticalAdjust", uno::Any( drawing::TextVerticalAdjust_CENTER ) ); + xProperties->setPropertyValue( "TextHorizontalAdjust", uno::Any( drawing::TextHorizontalAdjust_CENTER ) ); + xProperties->setPropertyValue( "CharFontName", uno::Any( OUString("Albany") ) ); + + xTextShape->setPosition( rPosition ); + + m_aSelection.setSelection( xTextShape ); + m_aSelection.applySelection( m_pDrawViewWrapper.get() ); + + SdrObject* pObj = DrawViewWrapper::getSdrObject( xTextShape ); + if ( pObj ) { - try - { - Reference< drawing::XShape > xTextShape( - xShapeFactory->createInstance( "com.sun.star.drawing.TextShape" ), uno::UNO_QUERY_THROW ); - xDrawPage->add( xTextShape ); - - Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW ); - xRange->setString( rString ); - - float fCharHeight = 10.0; - Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW ); - xProperties->setPropertyValue( "TextAutoGrowHeight", uno::Any( true ) ); - xProperties->setPropertyValue( "TextAutoGrowWidth", uno::Any( true ) ); - xProperties->setPropertyValue( "CharHeight", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "CharHeightAsian", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "CharHeightComplex", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "TextVerticalAdjust", uno::Any( drawing::TextVerticalAdjust_CENTER ) ); - xProperties->setPropertyValue( "TextHorizontalAdjust", uno::Any( drawing::TextHorizontalAdjust_CENTER ) ); - xProperties->setPropertyValue( "CharFontName", uno::Any( OUString("Albany") ) ); - - xTextShape->setPosition( rPosition ); - - m_aSelection.setSelection( xTextShape ); - m_aSelection.applySelection( m_pDrawViewWrapper.get() ); - - SdrObject* pObj = DrawViewWrapper::getSdrObject( xTextShape ); - if ( pObj ) - { - m_pDrawViewWrapper->BegUndo( SvxResId( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) ); - m_pDrawViewWrapper->AddUndo( std::make_unique<SdrUndoInsertObj>( *pObj ) ); - m_pDrawViewWrapper->EndUndo(); + m_pDrawViewWrapper->BegUndo( SvxResId( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) ); + m_pDrawViewWrapper->AddUndo( std::make_unique<SdrUndoInsertObj>( *pObj ) ); + m_pDrawViewWrapper->EndUndo(); - impl_switchDiagramPositioningToExcludingPositioning(); - } - } - catch ( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + impl_switchDiagramPositioningToExcludingPositioning(); } } + catch ( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } void ChartController::executeDispatch_Copy() @@ -853,32 +853,32 @@ void ChartController::executeDispatch_ToggleGridHorizontal() UndoGuard aUndoGuard( SchResId( STR_ACTION_TOGGLE_GRID_HORZ ), m_xUndoManager ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); - if( xDiagram.is()) - { - sal_Int32 nDimensionIndex = 1; - sal_Int32 nCooSysIndex = 0; + if( !xDiagram.is()) + return; + + sal_Int32 nDimensionIndex = 1; + sal_Int32 nCooSysIndex = 0; - bool bHasMajorYGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true, xDiagram ); - bool bHasMinorYGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false, xDiagram ); + bool bHasMajorYGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true, xDiagram ); + bool bHasMinorYGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false, xDiagram ); - if( bHasMajorYGrid ) + if( bHasMajorYGrid ) + { + if ( bHasMinorYGrid ) { - if ( bHasMinorYGrid ) - { - AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); - AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); - } - else - { - AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); - } + AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); + AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); } else { - AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); + AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); } - aUndoGuard.commit(); } + else + { + AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); + } + aUndoGuard.commit(); } void ChartController::executeDispatch_ToggleGridVertical() @@ -886,62 +886,62 @@ void ChartController::executeDispatch_ToggleGridVertical() UndoGuard aUndoGuard( SchResId( STR_ACTION_TOGGLE_GRID_VERTICAL ), m_xUndoManager ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); - if( xDiagram.is()) - { - sal_Int32 nDimensionIndex = 0; - sal_Int32 nCooSysIndex = 0; + if( !xDiagram.is()) + return; + + sal_Int32 nDimensionIndex = 0; + sal_Int32 nCooSysIndex = 0; - bool bHasMajorXGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true, xDiagram ); - bool bHasMinorXGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false, xDiagram ); - if( bHasMajorXGrid ) + bool bHasMajorXGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true, xDiagram ); + bool bHasMinorXGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false, xDiagram ); + if( bHasMajorXGrid ) + { + if (bHasMinorXGrid) { - if (bHasMinorXGrid) - { - AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); - AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); - } - else - { - AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); - } + AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); + AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); } else { - AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); + AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, false, xDiagram ); } - - aUndoGuard.commit(); } + else + { + AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, true, xDiagram ); + } + + aUndoGuard.commit(); } void ChartController::executeDispatch_LOKSetTextSelection(int nType, int nX, int nY) { - if (m_pDrawViewWrapper) + if (!m_pDrawViewWrapper) + return; + + if (!m_pDrawViewWrapper->IsTextEdit()) + return; + + OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + if (!pOutlinerView) + return; + + EditView& rEditView = pOutlinerView->GetEditView(); + Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY)); + switch (nType) { - if (m_pDrawViewWrapper->IsTextEdit()) - { - OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); - if (pOutlinerView) - { - EditView& rEditView = pOutlinerView->GetEditView(); - Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY)); - switch (nType) - { - case LOK_SETTEXTSELECTION_START: - rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/false, /*bClearMark=*/false); - break; - case LOK_SETTEXTSELECTION_END: - rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/false); - break; - case LOK_SETTEXTSELECTION_RESET: - rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/true); - break; - default: - assert(false); - break; - } - } - } + case LOK_SETTEXTSELECTION_START: + rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/false, /*bClearMark=*/false); + break; + case LOK_SETTEXTSELECTION_END: + rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/false); + break; + case LOK_SETTEXTSELECTION_RESET: + rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/true); + break; + default: + assert(false); + break; } } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index dcae80581d8b..45a33d61d1b0 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -241,46 +241,46 @@ void SAL_CALL ChartController::setPosSize( uno::Reference<awt::XWindow> xWindow = m_xViewWindow; auto pChartWindow(GetChartWindow()); - if(xWindow.is() && pChartWindow) + if(!(xWindow.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() ); + sal_Int32 nScaleXNumerator = aLogicSize.Width(); + sal_Int32 nScaleXDenominator = aModelPageSize.Width; + sal_Int32 nScaleYNumerator = aLogicSize.Height(); + sal_Int32 nScaleYDenominator = aModelPageSize.Height; + MapMode aNewMapMode( + MapUnit::Map100thMM, + Point(0,0), + Fraction(nScaleXNumerator, nScaleXDenominator), + Fraction(nScaleYNumerator, nScaleYDenominator) ); + pChartWindow->SetMapMode(aNewMapMode); + 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() ) { - 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() ); - sal_Int32 nScaleXNumerator = aLogicSize.Width(); - sal_Int32 nScaleXDenominator = aModelPageSize.Width; - sal_Int32 nScaleYNumerator = aLogicSize.Height(); - sal_Int32 nScaleYDenominator = aModelPageSize.Height; - MapMode aNewMapMode( - MapUnit::Map100thMM, - Point(0,0), - Fraction(nScaleXNumerator, nScaleXDenominator), - Fraction(nScaleYNumerator, nScaleYDenominator) ); - pChartWindow->SetMapMode(aNewMapMode); - 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() ) - { - auto aZoomFactors(::comphelper::InitPropertySequence({ - { "ScaleXNumerator", uno::Any( nScaleXNumerator ) }, - { "ScaleXDenominator", uno::Any( nScaleXDenominator ) }, - { "ScaleYNumerator", uno::Any( nScaleYNumerator ) }, - { "ScaleYDenominator", uno::Any( nScaleYDenominator ) } - })); - xProp->setPropertyValue( "ZoomFactors", uno::Any( aZoomFactors )); - } + auto aZoomFactors(::comphelper::InitPropertySequence({ + { "ScaleXNumerator", uno::Any( nScaleXNumerator ) }, + { "ScaleXDenominator", uno::Any( nScaleXDenominator ) }, + { "ScaleYNumerator", uno::Any( nScaleYNumerator ) }, + { "ScaleYDenominator", uno::Any( nScaleYDenominator ) } + })); + xProp->setPropertyValue( "ZoomFactors", uno::Any( aZoomFactors )); + } - //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area - if(m_pDrawViewWrapper) - { - tools::Rectangle aRect(Point(0,0), pChartWindow->GetOutputSize()); - m_pDrawViewWrapper->SetWorkArea( aRect ); - } - pChartWindow->Invalidate(); + //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area + if(m_pDrawViewWrapper) + { + tools::Rectangle aRect(Point(0,0), pChartWindow->GetOutputSize()); + m_pDrawViewWrapper->SetWorkArea( aRect ); } + pChartWindow->Invalidate(); } awt::Rectangle SAL_CALL ChartController::getPosSize() @@ -533,22 +533,22 @@ IMPL_LINK_NOARG(ChartController, DoubleClickWaitingHdl, Timer *, void) { m_bWaitingForDoubleClick = false; - if( !m_bWaitingForMouseUp && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() ) + if( !(!m_bWaitingForMouseUp && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured()) ) + return; + + impl_selectObjectAndNotiy(); + SolarMutexGuard aGuard; + auto pChartWindow(GetChartWindow()); + if( pChartWindow ) { - impl_selectObjectAndNotiy(); - SolarMutexGuard aGuard; - auto pChartWindow(GetChartWindow()); - if( pChartWindow ) - { - vcl::Window::PointerState aPointerState( pChartWindow->GetPointerState() ); - MouseEvent aMouseEvent( - aPointerState.maPos, - 1/*nClicks*/, - MouseEventModifiers::NONE, - static_cast< sal_uInt16 >( aPointerState.mnState )/*nButtons*/, - 0/*nModifier*/ ); - impl_SetMousePointer( aMouseEvent ); - } + vcl::Window::PointerState aPointerState( pChartWindow->GetPointerState() ); + MouseEvent aMouseEvent( + aPointerState.maPos, + 1/*nClicks*/, + MouseEventModifiers::NONE, + static_cast< sal_uInt16 >( aPointerState.mnState )/*nButtons*/, + 0/*nModifier*/ ); + impl_SetMousePointer( aMouseEvent ); } } diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 4508a83adb4d..4a70f339df97 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -179,134 +179,134 @@ void ControllerState::update( xController, uno::UNO_QUERY ); // Update ControllerState variables. - if( xSelectionSupplier.is()) + if( !xSelectionSupplier.is()) + return; + + uno::Any aSelObj( xSelectionSupplier->getSelection() ); + ObjectIdentifier aSelOID( aSelObj ); + OUString aSelObjCID( aSelOID.getObjectCID() ); + + bHasSelectedObject = aSelOID.isValid(); + + ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID )); + + bIsPositionableObject = (aObjectType != OBJECTTYPE_DATA_POINT) && aSelOID.isDragableObject(); + bIsTextObject = aObjectType == OBJECTTYPE_TITLE; + + uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject(); + if( aObjectType==OBJECTTYPE_DIAGRAM || aObjectType==OBJECTTYPE_DIAGRAM_WALL || aObjectType==OBJECTTYPE_DIAGRAM_FLOOR ) + bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + + uno::Reference< chart2::XDataSeries > xGivenDataSeries( + ObjectIdentifier::getDataSeriesForCID( + aSelObjCID, xModel ) ); + + bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj ); + + bMayMoveSeriesForward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( + ChartModelHelper::findDiagram( xModel ), + xGivenDataSeries, + MOVE_SERIES_FORWARD ); + + bMayMoveSeriesBackward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( + ChartModelHelper::findDiagram( xModel ), + xGivenDataSeries, + MOVE_SERIES_BACKWARD ); + + bMayAddMenuTrendline = false; + bMayAddTrendline = false; + bMayAddTrendlineEquation = false; + bMayAddR2Value = false; + bMayAddMeanValue = false; + bMayAddXErrorBars = false; + bMayAddYErrorBars = false; + bMayDeleteTrendline = false; + bMayDeleteTrendlineEquation = false; + bMayDeleteR2Value = false; + bMayDeleteMeanValue = false; + bMayDeleteXErrorBars = false; + bMayDeleteYErrorBars = false; + bMayFormatTrendline = false; + bMayFormatTrendlineEquation = false; + bMayFormatMeanValue = false; + bMayFormatXErrorBars = false; + bMayFormatYErrorBars = false; + if( !bHasSelectedObject ) + return; + + if( xGivenDataSeries.is()) { - uno::Any aSelObj( xSelectionSupplier->getSelection() ); - ObjectIdentifier aSelOID( aSelObj ); - OUString aSelObjCID( aSelOID.getObjectCID() ); - - bHasSelectedObject = aSelOID.isValid(); - - ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID )); - - bIsPositionableObject = (aObjectType != OBJECTTYPE_DATA_POINT) && aSelOID.isDragableObject(); - bIsTextObject = aObjectType == OBJECTTYPE_TITLE; - - uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); - bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject(); - if( aObjectType==OBJECTTYPE_DIAGRAM || aObjectType==OBJECTTYPE_DIAGRAM_WALL || aObjectType==OBJECTTYPE_DIAGRAM_FLOOR ) - bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram ); - - uno::Reference< chart2::XDataSeries > xGivenDataSeries( - ObjectIdentifier::getDataSeriesForCID( - aSelObjCID, xModel ) ); - - bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj ); - - bMayMoveSeriesForward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( - ChartModelHelper::findDiagram( xModel ), - xGivenDataSeries, - MOVE_SERIES_FORWARD ); - - bMayMoveSeriesBackward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( - ChartModelHelper::findDiagram( xModel ), - xGivenDataSeries, - MOVE_SERIES_BACKWARD ); - - bMayAddMenuTrendline = false; - bMayAddTrendline = false; - bMayAddTrendlineEquation = false; - bMayAddR2Value = false; - bMayAddMeanValue = false; - bMayAddXErrorBars = false; - bMayAddYErrorBars = false; - bMayDeleteTrendline = false; - bMayDeleteTrendlineEquation = false; - bMayDeleteR2Value = false; - bMayDeleteMeanValue = false; - bMayDeleteXErrorBars = false; - bMayDeleteYErrorBars = false; - bMayFormatTrendline = false; - bMayFormatTrendlineEquation = false; - bMayFormatMeanValue = false; - bMayFormatXErrorBars = false; - bMayFormatYErrorBars = false; - if( bHasSelectedObject ) + bMayAddMenuTrendline = true; + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + uno::Reference< chart2::XChartType > xFirstChartType( + DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram )); + + // trend lines/mean value line + if( (aObjectType == OBJECTTYPE_DATA_SERIES || aObjectType == OBJECTTYPE_DATA_POINT) + && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount )) { - if( xGivenDataSeries.is()) + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xGivenDataSeries, uno::UNO_QUERY ); + if( xRegCurveCnt.is()) { - bMayAddMenuTrendline = true; - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - uno::Reference< chart2::XChartType > xFirstChartType( - DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram )); - - // trend lines/mean value line - if( (aObjectType == OBJECTTYPE_DATA_SERIES || aObjectType == OBJECTTYPE_DATA_POINT) - && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount )) - { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xGivenDataSeries, uno::UNO_QUERY ); - if( xRegCurveCnt.is()) - { - // Trendline - bMayAddTrendline = true; - - // Mean Value - bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt ); - bMayAddMeanValue = ! bMayDeleteMeanValue; - } - } - - // error bars - if( (aObjectType == OBJECTTYPE_DATA_SERIES || aObjectType == OBJECTTYPE_DATA_POINT) - && ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount )) - { - bMayFormatXErrorBars = bMayDeleteXErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries, false ); - bMayAddXErrorBars = ! bMayDeleteXErrorBars; - - bMayFormatYErrorBars = bMayDeleteYErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries ); - bMayAddYErrorBars = ! bMayDeleteYErrorBars; - } + // Trendline + bMayAddTrendline = true; + + // Mean Value + bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt ); + bMayAddMeanValue = ! bMayDeleteMeanValue; } + } - if( aObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ) - bMayFormatMeanValue = true; + // error bars + if( (aObjectType == OBJECTTYPE_DATA_SERIES || aObjectType == OBJECTTYPE_DATA_POINT) + && ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount )) + { + bMayFormatXErrorBars = bMayDeleteXErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries, false ); + bMayAddXErrorBars = ! bMayDeleteXErrorBars; - if( aObjectType == OBJECTTYPE_DATA_ERRORS_X) - bMayFormatXErrorBars = true; + bMayFormatYErrorBars = bMayDeleteYErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries ); + bMayAddYErrorBars = ! bMayDeleteYErrorBars; + } + } - if( aObjectType == OBJECTTYPE_DATA_ERRORS_Y ) - bMayFormatYErrorBars = true; + if( aObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ) + bMayFormatMeanValue = true; - if( aObjectType == OBJECTTYPE_DATA_CURVE ) - { - bMayFormatTrendline = true; - bMayDeleteTrendline = true; - uno::Reference< chart2::XRegressionCurve > xRegCurve( - ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); - - // Trendline Equation - bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); - bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation; - } - else if( aObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) - { - bMayFormatTrendlineEquation = true; - bool bHasR2Value = false; - try - { - uno::Reference< beans::XPropertySet > xEquationProperties = - ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ); - if( xEquationProperties.is() ) - xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bHasR2Value; - } - catch(const uno::RuntimeException&) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } - bMayAddR2Value = !bHasR2Value; - bMayDeleteR2Value = bHasR2Value; - } + if( aObjectType == OBJECTTYPE_DATA_ERRORS_X) + bMayFormatXErrorBars = true; + + if( aObjectType == OBJECTTYPE_DATA_ERRORS_Y ) + bMayFormatYErrorBars = true; + + if( aObjectType == OBJECTTYPE_DATA_CURVE ) + { + bMayFormatTrendline = true; + bMayDeleteTrendline = true; + uno::Reference< chart2::XRegressionCurve > xRegCurve( + ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); + + // Trendline Equation + bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); + bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation; + } + else if( aObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) + { + bMayFormatTrendlineEquation = true; + bool bHasR2Value = false; + try + { + uno::Reference< beans::XPropertySet > xEquationProperties = + ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ); + if( xEquationProperties.is() ) + xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bHasR2Value; + } + catch(const uno::RuntimeException&) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } + bMayAddR2Value = !bHasR2Value; + bMayDeleteR2Value = bHasR2Value; } } @@ -488,26 +488,26 @@ ControllerCommandDispatch::~ControllerCommandDispatch() void ControllerCommandDispatch::initialize() { - if( m_xChartController.is()) - { - Reference< frame::XModel > xModel( m_xChartController->getModel()); - Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY ); - OSL_ASSERT( xModifyBroadcaster.is()); - if( xModifyBroadcaster.is()) - xModifyBroadcaster->addModifyListener( this ); + if( !m_xChartController.is()) + return; - // Listen selection modifications (Arrangement feature - issue 63017). - if( m_xSelectionSupplier.is() ) - m_xSelectionSupplier->addSelectionChangeListener( this ); + Reference< frame::XModel > xModel( m_xChartController->getModel()); + Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY ); + OSL_ASSERT( xModifyBroadcaster.is()); + if( xModifyBroadcaster.is()) + xModifyBroadcaster->addModifyListener( this ); - if( m_apModelState.get() && xModel.is()) - m_apModelState->update( xModel ); + // Listen selection modifications (Arrangement feature - issue 63017). + if( m_xSelectionSupplier.is() ) + m_xSelectionSupplier->addSelectionChangeListener( this ); - if( m_apControllerState.get() && xModel.is()) - m_apControllerState->update( m_xChartController.get(), xModel ); + if( m_apModelState.get() && xModel.is()) + m_apModelState->update( xModel ); - updateCommandAvailability(); - } + if( m_apControllerState.get() && xModel.is()) + m_apControllerState->update( m_xChartController.get(), xModel ); + + updateCommandAvailability(); } void ControllerCommandDispatch::fireStatusEventForURLImpl( diff --git a/chart2/source/controller/main/DragMethod_PieSegment.cxx b/chart2/source/controller/main/DragMethod_PieSegment.cxx index 9e8e995838f0..cb98c4e7462a 100644 --- a/chart2/source/controller/main/DragMethod_PieSegment.cxx +++ b/chart2/source/controller/main/DragMethod_PieSegment.cxx @@ -84,25 +84,25 @@ bool DragMethod_PieSegment::BeginSdrDrag() } void DragMethod_PieSegment::MoveSdrDrag(const Point& rPnt) { - if( DragStat().CheckMinMoved(rPnt) ) + if( !DragStat().CheckMinMoved(rPnt) ) + return; + + //calculate new offset + B2DVector aShiftVector( B2DVector( rPnt.X(), rPnt.Y() ) - m_aStartVector ); + m_fAdditionalOffset = m_aDragDirection.scalar( aShiftVector )/m_fDragRange; // projection + + if( m_fAdditionalOffset < -m_fInitialOffset ) + m_fAdditionalOffset = -m_fInitialOffset; + else if( m_fAdditionalOffset > (1.0-m_fInitialOffset) ) + m_fAdditionalOffset = 1.0 - m_fInitialOffset; + + B2DVector aNewPosVector = m_aStartVector + (m_aDragDirection * m_fAdditionalOffset); + Point aNewPos( static_cast<long>(aNewPosVector.getX()), static_cast<long>(aNewPosVector.getY()) ); + if( aNewPos != DragStat().GetNow() ) { - //calculate new offset - B2DVector aShiftVector( B2DVector( rPnt.X(), rPnt.Y() ) - m_aStartVector ); - m_fAdditionalOffset = m_aDragDirection.scalar( aShiftVector )/m_fDragRange; // projection - - if( m_fAdditionalOffset < -m_fInitialOffset ) - m_fAdditionalOffset = -m_fInitialOffset; - else if( m_fAdditionalOffset > (1.0-m_fInitialOffset) ) - m_fAdditionalOffset = 1.0 - m_fInitialOffset; - - B2DVector aNewPosVector = m_aStartVector + (m_aDragDirection * m_fAdditionalOffset); - Point aNewPos( static_cast<long>(aNewPosVector.getX()), static_cast<long>(aNewPosVector.getY()) ); - if( aNewPos != DragStat().GetNow() ) - { - Hide(); - DragStat().NextMove( aNewPos ); - Show(); - } + Hide(); + DragStat().NextMove( aNewPos ); + Show(); } } bool DragMethod_PieSegment::EndSdrDrag(bool /*bCopy*/) diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx index 8e29facf3cd5..6868f68a191e 100644 --- a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx @@ -65,32 +65,32 @@ DragMethod_RotateDiagram::DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWr { m_pScene = SelectionHelper::getSceneToRotate( rDrawViewWrapper.getNamedSdrObject( rObjectCID ) ); SdrObject* pObj = rDrawViewWrapper.getSelectedObject(); - if(pObj && m_pScene) - { - m_aReferenceRect = pObj->GetLogicRect(); + if(!(pObj && m_pScene)) + return; - m_aWireframePolyPolygon = m_pScene->CreateWireframe(); + m_aReferenceRect = pObj->GetLogicRect(); - uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(getChartModel()) ); - uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); - if( xDiagramProperties.is() ) - { - ThreeDHelper::getRotationFromDiagram( xDiagramProperties - , m_nInitialHorizontalAngleDegree, m_nInitialVerticalAngleDegree ); - - ThreeDHelper::getRotationAngleFromDiagram( xDiagramProperties - , m_fInitialXAngleRad, m_fInitialYAngleRad, m_fInitialZAngleRad ); - - if( ChartTypeHelper::isSupportingRightAngledAxes( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) ) - xDiagramProperties->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes; - if(m_bRightAngledAxes) - { - if( m_eRotationDirection==ROTATIONDIRECTION_Z ) - m_eRotationDirection=ROTATIONDIRECTION_FREE; - ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fInitialXAngleRad, m_fInitialYAngleRad ); - } - } + m_aWireframePolyPolygon = m_pScene->CreateWireframe(); + + uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(getChartModel()) ); + uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); + if( !xDiagramProperties.is() ) + return; + + ThreeDHelper::getRotationFromDiagram( xDiagramProperties + , m_nInitialHorizontalAngleDegree, m_nInitialVerticalAngleDegree ); + + ThreeDHelper::getRotationAngleFromDiagram( xDiagramProperties + , m_fInitialXAngleRad, m_fInitialYAngleRad, m_fInitialZAngleRad ); + + if( ChartTypeHelper::isSupportingRightAngledAxes( + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) ) + xDiagramProperties->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes; + if(m_bRightAngledAxes) + { + if( m_eRotationDirection==ROTATIONDIRECTION_Z ) + m_eRotationDirection=ROTATIONDIRECTION_FREE; + ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fInitialXAngleRad, m_fInitialYAngleRad ); } } DragMethod_RotateDiagram::~DragMethod_RotateDiagram() @@ -108,44 +108,44 @@ bool DragMethod_RotateDiagram::BeginSdrDrag() } void DragMethod_RotateDiagram::MoveSdrDrag(const Point& rPnt) { - if( DragStat().CheckMinMoved(rPnt) ) - { - Hide(); - - //calculate new angle - double fX = F_PI2 * static_cast<double>(rPnt.Y() - m_aStartPos.Y()) - / (m_aReferenceRect.GetHeight() > 0 ? static_cast<double>(m_aReferenceRect.GetHeight()) : 1.0); - double fY = F_PI * static_cast<double>(rPnt.X() - m_aStartPos.X()) - / (m_aReferenceRect.GetWidth() > 0 ? static_cast<double>(m_aReferenceRect.GetWidth()) : 1.0); - - if( m_eRotationDirection != ROTATIONDIRECTION_Y ) - m_fAdditionalYAngleRad = fY; - else - m_fAdditionalYAngleRad = 0.0; - if( m_eRotationDirection != ROTATIONDIRECTION_X ) - m_fAdditionalXAngleRad = fX; - else - m_fAdditionalXAngleRad = 0.0; - m_fAdditionalZAngleRad = 0.0; - - if( m_eRotationDirection == ROTATIONDIRECTION_Z ) - { - m_fAdditionalXAngleRad = 0.0; - m_fAdditionalYAngleRad = 0.0; + if( !DragStat().CheckMinMoved(rPnt) ) + return; - double fCx = m_aReferenceRect.Center().X(); - double fCy = m_aReferenceRect.Center().Y(); + Hide(); - m_fAdditionalZAngleRad = atan((fCx - m_aStartPos.X())/(m_aStartPos.Y()-fCy)) - + atan((fCx - rPnt.X())/(fCy-rPnt.Y())); - } + //calculate new angle + double fX = F_PI2 * static_cast<double>(rPnt.Y() - m_aStartPos.Y()) + / (m_aReferenceRect.GetHeight() > 0 ? static_cast<double>(m_aReferenceRect.GetHeight()) : 1.0); + double fY = F_PI * static_cast<double>(rPnt.X() - m_aStartPos.X()) + / (m_aReferenceRect.GetWidth() > 0 ? static_cast<double>(m_aReferenceRect.GetWidth()) : 1.0); - m_nAdditionalHorizontalAngleDegree = static_cast<sal_Int32>(basegfx::rad2deg(m_fAdditionalXAngleRad)); - m_nAdditionalVerticalAngleDegree = -static_cast<sal_Int32>(basegfx::rad2deg(m_fAdditionalYAngleRad)); + if( m_eRotationDirection != ROTATIONDIRECTION_Y ) + m_fAdditionalYAngleRad = fY; + else + m_fAdditionalYAngleRad = 0.0; + if( m_eRotationDirection != ROTATIONDIRECTION_X ) + m_fAdditionalXAngleRad = fX; + else + m_fAdditionalXAngleRad = 0.0; + m_fAdditionalZAngleRad = 0.0; + + if( m_eRotationDirection == ROTATIONDIRECTION_Z ) + { + m_fAdditionalXAngleRad = 0.0; + m_fAdditionalYAngleRad = 0.0; + + double fCx = m_aReferenceRect.Center().X(); + double fCy = m_aReferenceRect.Center().Y(); - DragStat().NextMove(rPnt); - Show(); + m_fAdditionalZAngleRad = atan((fCx - m_aStartPos.X())/(m_aStartPos.Y()-fCy)) + + atan((fCx - rPnt.X())/(fCy-rPnt.Y())); } + + m_nAdditionalHorizontalAngleDegree = static_cast<sal_Int32>(basegfx::rad2deg(m_fAdditionalXAngleRad)); + m_nAdditionalVerticalAngleDegree = -static_cast<sal_Int32>(basegfx::rad2deg(m_fAdditionalYAngleRad)); + + DragStat().NextMove(rPnt); + Show(); } bool DragMethod_RotateDiagram::EndSdrDrag(bool /*bCopy*/) { @@ -200,28 +200,28 @@ void DragMethod_RotateDiagram::CreateOverlayGeometry( aCurrentTransform.shearXY(fResultY,-fResultX); } - if(m_aWireframePolyPolygon.count() && m_pScene) - { - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(m_pScene->GetViewContact()); - const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); - const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation()); - const basegfx::B3DHomMatrix aTransform(aWorldToView * aCurrentTransform); + if(!(m_aWireframePolyPolygon.count() && m_pScene)) + return; - // transform to relative scene coordinates - basegfx::B2DPolyPolygon aPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(m_aWireframePolyPolygon, aTransform)); + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(m_pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); + const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation()); + const basegfx::B3DHomMatrix aTransform(aWorldToView * aCurrentTransform); - // transform to 2D view coordinates - aPolyPolygon.transform(rVCScene.getObjectTransformation()); + // transform to relative scene coordinates + basegfx::B2DPolyPolygon aPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(m_aWireframePolyPolygon, aTransform)); - std::unique_ptr<sdr::overlay::OverlayPolyPolygonStripedAndFilled> pNew( - new sdr::overlay::OverlayPolyPolygonStripedAndFilled( - aPolyPolygon)); + // transform to 2D view coordinates + aPolyPolygon.transform(rVCScene.getObjectTransformation()); - insertNewlyCreatedOverlayObjectForSdrDragMethod( - std::move(pNew), - rObjectContact, - rOverlayManager); - } + std::unique_ptr<sdr::overlay::OverlayPolyPolygonStripedAndFilled> pNew( + new sdr::overlay::OverlayPolyPolygonStripedAndFilled( + aPolyPolygon)); + + insertNewlyCreatedOverlayObjectForSdrDragMethod( + std::move(pNew), + rObjectContact, + rOverlayManager); } } //namespace chart diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index e8230b1d2eab..1f4e5505023b 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -97,113 +97,113 @@ static ::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel& void DrawCommandDispatch::setAttributes( SdrObject* pObj ) { - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pDrawModelWrapper && pDrawViewWrapper && pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CUSTOMSHAPE) ) + return; + + bool bAttributesAppliedFromGallery = false; + if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) { - DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pDrawModelWrapper && pDrawViewWrapper && pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CUSTOMSHAPE ) + std::vector< OUString > aObjList; + if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) { - bool bAttributesAppliedFromGallery = false; - if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) + for ( size_t i = 0; i < aObjList.size(); ++i ) { - std::vector< OUString > aObjList; - if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) + if ( aObjList[ i ].equalsIgnoreAsciiCase( m_aCustomShapeType ) ) { - for ( size_t i = 0; i < aObjList.size(); ++i ) + FmFormModel aModel; + SfxItemPool& rPool(aModel.GetItemPool()); + rPool.FreezeIdRanges(); + + if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aModel ) ) { - if ( aObjList[ i ].equalsIgnoreAsciiCase( m_aCustomShapeType ) ) + const SdrObject* pSourceObj = aModel.GetPage( 0 )->GetObj( 0 ); + if ( pSourceObj ) { - FmFormModel aModel; - SfxItemPool& rPool(aModel.GetItemPool()); - rPool.FreezeIdRanges(); - - if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aModel ) ) + const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); + SfxItemSet aDest( + pObj->getSdrModelFromSdrObject().GetItemPool(), + svl::Items< + // Ranges from SdrAttrObj: + SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, + SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, + SDRATTR_TEXTDIRECTION, + // Graphic attributes, 3D + // properties, CustomShape + // properties: + SDRATTR_GRAF_FIRST, + SDRATTR_CUSTOMSHAPE_LAST, + // Range from SdrTextObj: + EE_ITEMS_START, EE_ITEMS_END>{}); + aDest.Set( rSource ); + pObj->SetMergedItemSet( aDest ); + sal_Int32 nAngle = pSourceObj->GetRotateAngle(); + if ( nAngle ) { - const SdrObject* pSourceObj = aModel.GetPage( 0 )->GetObj( 0 ); - if ( pSourceObj ) - { - const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); - SfxItemSet aDest( - pObj->getSdrModelFromSdrObject().GetItemPool(), - svl::Items< - // Ranges from SdrAttrObj: - SDRATTR_START, SDRATTR_SHADOW_LAST, - SDRATTR_MISC_FIRST, - SDRATTR_MISC_LAST, - SDRATTR_TEXTDIRECTION, - SDRATTR_TEXTDIRECTION, - // Graphic attributes, 3D - // properties, CustomShape - // properties: - SDRATTR_GRAF_FIRST, - SDRATTR_CUSTOMSHAPE_LAST, - // Range from SdrTextObj: - EE_ITEMS_START, EE_ITEMS_END>{}); - aDest.Set( rSource ); - pObj->SetMergedItemSet( aDest ); - sal_Int32 nAngle = pSourceObj->GetRotateAngle(); - if ( nAngle ) - { - double a = nAngle * F_PI18000; - pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); - } - bAttributesAppliedFromGallery = true; - } + double a = nAngle * F_PI18000; + pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); } - break; + bAttributesAppliedFromGallery = true; } } + break; } } - if ( !bAttributesAppliedFromGallery ) - { - pObj->SetMergedItem( SvxAdjustItem( SvxAdjust::Center, 0 ) ); - pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); - pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) ); - pObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( false ) ); - - o3tl::unsafe_downcast< SdrObjCustomShape* >( pObj )->MergeDefaultAttributes( &m_aCustomShapeType ); - } } } + if ( !bAttributesAppliedFromGallery ) + { + pObj->SetMergedItem( SvxAdjustItem( SvxAdjust::Center, 0 ) ); + pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); + pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) ); + pObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( false ) ); + + o3tl::unsafe_downcast< SdrObjCustomShape* >( pObj )->MergeDefaultAttributes( &m_aCustomShapeType ); + } } void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr ) { - if ( m_nFeatureId == COMMAND_ID_LINE_ARROW_END && m_pChartController ) - { - DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pDrawModelWrapper && pDrawViewWrapper ) - { - ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDrawModelWrapper->getSdrModel() ) ); - if ( !aArrow.count() ) - { - ::basegfx::B2DPolygon aNewArrow; - aNewArrow.append( ::basegfx::B2DPoint( 10.0, 0.0 ) ); - aNewArrow.append( ::basegfx::B2DPoint( 0.0, 30.0) ); - aNewArrow.append( ::basegfx::B2DPoint( 20.0, 30.0 ) ); - aNewArrow.setClosed( true ); - aArrow.append( aNewArrow ); - } + if ( !(m_nFeatureId == COMMAND_ID_LINE_ARROW_END && m_pChartController) ) + return; - SfxItemSet aSet( pDrawViewWrapper->GetModel()->GetItemPool() ); - pDrawViewWrapper->GetAttributes( aSet ); + DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pDrawModelWrapper && pDrawViewWrapper) ) + return; - long nWidth = 300; // (1/100th mm) - if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) - { - long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue(); - if ( nValue > 0 ) - { - nWidth = nValue * 3; - } - } + ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDrawModelWrapper->getSdrModel() ) ); + if ( !aArrow.count() ) + { + ::basegfx::B2DPolygon aNewArrow; + aNewArrow.append( ::basegfx::B2DPoint( 10.0, 0.0 ) ); + aNewArrow.append( ::basegfx::B2DPoint( 0.0, 30.0) ); + aNewArrow.append( ::basegfx::B2DPoint( 20.0, 30.0 ) ); + aNewArrow.setClosed( true ); + aArrow.append( aNewArrow ); + } - rAttr.Put( XLineEndItem( SvxResId( RID_SVXSTR_ARROW ), aArrow ) ); - rAttr.Put( XLineEndWidthItem( nWidth ) ); + SfxItemSet aSet( pDrawViewWrapper->GetModel()->GetItemPool() ); + pDrawViewWrapper->GetAttributes( aSet ); + + long nWidth = 300; // (1/100th mm) + if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) + { + long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue(); + if ( nValue > 0 ) + { + nWidth = nValue * 3; } } + + rAttr.Put( XLineEndItem( SvxResId( RID_SVXSTR_ARROW ), aArrow ) ); + rAttr.Put( XLineEndWidthItem( nWidth ) ); } // WeakComponentImplHelperBase @@ -268,115 +268,115 @@ void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< bea sal_uInt16 nFeatureId = 0; OUString aBaseCommand; OUString aCustomShapeType; - if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) ) - { - bool bCreate = false; - m_nFeatureId = nFeatureId; - m_aCustomShapeType = aCustomShapeType; + if ( !parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) ) + return; - switch ( nFeatureId ) - { - case COMMAND_ID_OBJECT_SELECT: - { - eDrawMode = CHARTDRAW_SELECT; - eKind = OBJ_NONE; - } - break; - case COMMAND_ID_DRAW_LINE: - case COMMAND_ID_LINE_ARROW_END: - { - eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_LINE; - } - break; - case COMMAND_ID_DRAW_RECT: - { - eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_RECT; - } - break; - case COMMAND_ID_DRAW_ELLIPSE: - { - eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_CIRC; - } - break; - case COMMAND_ID_DRAW_FREELINE_NOFILL: - { - eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_FREELINE; - } - break; - case COMMAND_ID_DRAW_TEXT: - { - eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_TEXT; - bCreate = true; - } - break; - case COMMAND_ID_DRAW_CAPTION: - { - eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_CAPTION; - } - break; - case COMMAND_ID_DRAWTBX_CS_BASIC: - case COMMAND_ID_DRAWTBX_CS_SYMBOL: - case COMMAND_ID_DRAWTBX_CS_ARROW: - case COMMAND_ID_DRAWTBX_CS_FLOWCHART: - case COMMAND_ID_DRAWTBX_CS_CALLOUT: - case COMMAND_ID_DRAWTBX_CS_STAR: - { - eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_CUSTOMSHAPE; - } - break; - default: - { - eDrawMode = CHARTDRAW_SELECT; - eKind = OBJ_NONE; - } - break; - } + bool bCreate = false; + m_nFeatureId = nFeatureId; + m_aCustomShapeType = aCustomShapeType; - if ( m_pChartController ) - { - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pDrawViewWrapper ) + switch ( nFeatureId ) + { + case COMMAND_ID_OBJECT_SELECT: { - SolarMutexGuard aGuard; - m_pChartController->setDrawMode( eDrawMode ); - setInsertObj( sal::static_int_cast< sal_uInt16 >( eKind ) ); - if ( bCreate ) - { - pDrawViewWrapper->SetCreateMode(); - } - - const OUString sKeyModifier( "KeyModifier" ); - const beans::PropertyValue* pIter = rArgs.getConstArray(); - const beans::PropertyValue* pEnd = pIter + rArgs.getLength(); - const beans::PropertyValue* pKeyModifier = std::find_if(pIter, pEnd, - [&sKeyModifier](const beans::PropertyValue& lhs) - {return lhs.Name == sKeyModifier;} ); - sal_Int16 nKeyModifier = 0; - if ( pKeyModifier != pEnd && ( pKeyModifier->Value >>= nKeyModifier ) && nKeyModifier == KEY_MOD1 ) - { - if ( eDrawMode == CHARTDRAW_INSERT ) - { - SdrObject* pObj = createDefaultObject( nFeatureId ); - if ( pObj ) - { - SdrPageView* pPageView = pDrawViewWrapper->GetSdrPageView(); - if (pDrawViewWrapper->InsertObjectAtView(pObj, *pPageView)) - m_pChartController->SetAndApplySelection(Reference<drawing::XShape>(pObj->getUnoShape(), uno::UNO_QUERY)); - if ( nFeatureId == COMMAND_ID_DRAW_TEXT ) - { - m_pChartController->StartTextEdit(); - } - } - } - } + eDrawMode = CHARTDRAW_SELECT; + eKind = OBJ_NONE; + } + break; + case COMMAND_ID_DRAW_LINE: + case COMMAND_ID_LINE_ARROW_END: + { + eDrawMode = CHARTDRAW_INSERT; + eKind = OBJ_LINE; + } + break; + case COMMAND_ID_DRAW_RECT: + { + eDrawMode = CHARTDRAW_INSERT; + eKind = OBJ_RECT; + } + break; + case COMMAND_ID_DRAW_ELLIPSE: + { + eDrawMode = CHARTDRAW_INSERT; + eKind = OBJ_CIRC; + } + break; + case COMMAND_ID_DRAW_FREELINE_NOFILL: + { + eDrawMode = CHARTDRAW_INSERT; + eKind = OBJ_FREELINE; + } + break; + case COMMAND_ID_DRAW_TEXT: + { + eDrawMode = CHARTDRAW_INSERT; + eKind = OBJ_TEXT; + bCreate = true; + } + break; + case COMMAND_ID_DRAW_CAPTION: + { + eDrawMode = CHARTDRAW_INSERT; + eKind = OBJ_CAPTION; + } + break; + case COMMAND_ID_DRAWTBX_CS_BASIC: + case COMMAND_ID_DRAWTBX_CS_SYMBOL: + case COMMAND_ID_DRAWTBX_CS_ARROW: + case COMMAND_ID_DRAWTBX_CS_FLOWCHART: + case COMMAND_ID_DRAWTBX_CS_CALLOUT: + case COMMAND_ID_DRAWTBX_CS_STAR: + { + eDrawMode = CHARTDRAW_INSERT; + eKind = OBJ_CUSTOMSHAPE; } + break; + default: + { + eDrawMode = CHARTDRAW_SELECT; + eKind = OBJ_NONE; + } + break; + } + + if ( !m_pChartController ) + return; + + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !pDrawViewWrapper ) + return; + + SolarMutexGuard aGuard; + m_pChartController->setDrawMode( eDrawMode ); + setInsertObj( sal::static_int_cast< sal_uInt16 >( eKind ) ); + if ( bCreate ) + { + pDrawViewWrapper->SetCreateMode(); + } + + const OUString sKeyModifier( "KeyModifier" ); + const beans::PropertyValue* pIter = rArgs.getConstArray(); + const beans::PropertyValue* pEnd = pIter + rArgs.getLength(); + const beans::PropertyValue* pKeyModifier = std::find_if(pIter, pEnd, + [&sKeyModifier](const beans::PropertyValue& lhs) + {return lhs.Name == sKeyModifier;} ); + sal_Int16 nKeyModifier = 0; + if ( !(pKeyModifier != pEnd && ( pKeyModifier->Value >>= nKeyModifier ) && nKeyModifier == KEY_MOD1) ) + return; + + if ( eDrawMode != CHARTDRAW_INSERT ) + return; + + SdrObject* pObj = createDefaultObject( nFeatureId ); + if ( pObj ) + { + SdrPageView* pPageView = pDrawViewWrapper->GetSdrPageView(); + if (pDrawViewWrapper->InsertObjectAtView(pObj, *pPageView)) + m_pChartController->SetAndApplySelection(Reference<drawing::XShape>(pObj->getUnoShape(), uno::UNO_QUERY)); + if ( nFeatureId == COMMAND_ID_DRAW_TEXT ) + { + m_pChartController->StartTextEdit(); } } } diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 51339e0f4ca2..e872964a38b8 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -78,28 +78,28 @@ void lcl_getChildOIDs( ::chart::ObjectHierarchy::tChildContainer& rOutChildren, const Reference< container::XIndexAccess >& xShapes ) { - if( xShapes.is()) + if( !xShapes.is()) + return; + + sal_Int32 nCount = xShapes->getCount(); + for( sal_Int32 i=0; i<nCount; ++i) { - sal_Int32 nCount = xShapes->getCount(); - for( sal_Int32 i=0; i<nCount; ++i) + Reference< beans::XPropertySet > xShapeProp( xShapes->getByIndex( i ), uno::UNO_QUERY ); + if( xShapeProp.is()) { - Reference< beans::XPropertySet > xShapeProp( xShapes->getByIndex( i ), uno::UNO_QUERY ); - if( xShapeProp.is()) + Reference< beans::XPropertySetInfo > xInfo( xShapeProp->getPropertySetInfo()); + OUString aName; + if( xInfo.is() && + xInfo->hasPropertyByName( "Name") && + (xShapeProp->getPropertyValue( "Name") >>= aName ) && + !aName.isEmpty() && + ::chart::ObjectIdentifier::isCID( aName )) { - Reference< beans::XPropertySetInfo > xInfo( xShapeProp->getPropertySetInfo()); - OUString aName; - if( xInfo.is() && - xInfo->hasPropertyByName( "Name") && - (xShapeProp->getPropertyValue( "Name") >>= aName ) && - !aName.isEmpty() && - ::chart::ObjectIdentifier::isCID( aName )) - { - rOutChildren.emplace_back( aName ); - } - Reference< container::XIndexAccess > xNewShapes( xShapeProp, uno::UNO_QUERY ); - if( xNewShapes.is()) - lcl_getChildOIDs( rOutChildren, xNewShapes ); + rOutChildren.emplace_back( aName ); } + Reference< container::XIndexAccess > xNewShapes( xShapeProp, uno::UNO_QUERY ); + if( xNewShapes.is()) + lcl_getChildOIDs( rOutChildren, xNewShapes ); } } } @@ -278,21 +278,21 @@ void ImplObjectHierarchy::createLegendTree( const Reference< XChartDocument > & xChartDoc, const Reference< XDiagram > & xDiagram ) { - if( xDiagram.is() && LegendHelper::hasLegend( xDiagram ) ) - { - ObjectIdentifier aLegendOID( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram->getLegend(), xChartDoc ) ) ); - rContainer.push_back( aLegendOID ); + if( !(xDiagram.is() && LegendHelper::hasLegend( xDiagram )) ) + return; - // iterate over child shapes of legend and search for matching CIDs - if( m_pExplicitValueProvider ) - { - Reference< container::XIndexAccess > xLegendShapeContainer( - m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ), uno::UNO_QUERY ); - ObjectHierarchy::tChildContainer aLegendEntryOIDs; - lcl_getChildOIDs( aLegendEntryOIDs, xLegendShapeContainer ); + ObjectIdentifier aLegendOID( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram->getLegend(), xChartDoc ) ) ); + rContainer.push_back( aLegendOID ); - m_aChildMap[ aLegendOID ] = aLegendEntryOIDs; - } + // iterate over child shapes of legend and search for matching CIDs + if( m_pExplicitValueProvider ) + { + Reference< container::XIndexAccess > xLegendShapeContainer( + m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ), uno::UNO_QUERY ); + ObjectHierarchy::tChildContainer aLegendEntryOIDs; + lcl_getChildOIDs( aLegendEntryOIDs, xLegendShapeContainer ); + + m_aChildMap[ aLegendOID ] = aLegendEntryOIDs; } } @@ -305,58 +305,58 @@ void ImplObjectHierarchy::createAxesTree( sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); bool bSupportsAxesGrids = ChartTypeHelper::isSupportingMainAxis( xChartType, nDimensionCount, 0 ); - if( bSupportsAxesGrids ) + if( !bSupportsAxesGrids ) + return; + + Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ) ); + if( !m_bOrderingForElementSelector ) + std::transform( aAxes.begin(), aAxes.end(), + std::back_inserter( rContainer ), + lcl_ObjectToOID( xChartDoc )); + + // get all axes, also invisible ones + aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram ); + // Grids + Reference< frame::XModel > xChartModel = xChartDoc; + for( sal_Int32 nA=0; nA<aAxes.getLength(); ++nA ) { - Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ) ); - if( !m_bOrderingForElementSelector ) - std::transform( aAxes.begin(), aAxes.end(), - std::back_inserter( rContainer ), - lcl_ObjectToOID( xChartDoc )); - - // get all axes, also invisible ones - aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram ); - // Grids - Reference< frame::XModel > xChartModel = xChartDoc; - for( sal_Int32 nA=0; nA<aAxes.getLength(); ++nA ) + Reference< XAxis > xAxis( aAxes[nA] ); + if(!xAxis.is()) + continue; + + sal_Int32 nCooSysIndex = 0; + sal_Int32 nDimensionIndex = 0; + sal_Int32 nAxisIndex = 0; + AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); + if( nAxisIndex>0 && !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount ) ) + continue; + + if( m_bOrderingForElementSelector ) { - Reference< XAxis > xAxis( aAxes[nA] ); - if(!xAxis.is()) - continue; - - sal_Int32 nCooSysIndex = 0; - sal_Int32 nDimensionIndex = 0; - sal_Int32 nAxisIndex = 0; - AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); - if( nAxisIndex>0 && !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount ) ) - continue; - - if( m_bOrderingForElementSelector ) - { - // axis - if( AxisHelper::isAxisVisible( xAxis ) ) - rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) ); + // axis + if( AxisHelper::isAxisVisible( xAxis ) ) + rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) ); - // axis title - lcl_addAxisTitle( aAxes[nA], rContainer, xChartModel ); - } + // axis title + lcl_addAxisTitle( aAxes[nA], rContainer, xChartModel ); + } - Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() ); - if( AxisHelper::isGridVisible( xGridProperties ) ) - { - //main grid - rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ) ); - } + Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() ); + if( AxisHelper::isGridVisible( xGridProperties ) ) + { + //main grid + rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ) ); + } - Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - sal_Int32 nSubGrid = 0; - for( nSubGrid = 0; nSubGrid < aSubGrids.getLength(); ++nSubGrid ) + Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); + sal_Int32 nSubGrid = 0; + for( nSubGrid = 0; nSubGrid < aSubGrids.getLength(); ++nSubGrid ) + { + Reference< beans::XPropertySet > xSubGridProperties( aSubGrids[nSubGrid] ); + if( AxisHelper::isGridVisible( xSubGridProperties ) ) { - Reference< beans::XPropertySet > xSubGridProperties( aSubGrids[nSubGrid] ); - if( AxisHelper::isGridVisible( xSubGridProperties ) ) - { - //sub grid - rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGrid ) ); - } + //sub grid + rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGrid ) ); } } } diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx index c73bcb093a0a..5065a5768736 100644 --- a/chart2/source/controller/main/SelectionHelper.cxx +++ b/chart2/source/controller/main/SelectionHelper.cxx @@ -134,155 +134,155 @@ bool Selection::isSelectionDifferentFromBeforeMouseDown() const void Selection::applySelection( DrawViewWrapper* pDrawViewWrapper ) { - if( pDrawViewWrapper ) - { - { - SolarMutexGuard aSolarGuard; - pDrawViewWrapper->UnmarkAll(); - } - SdrObject* pObjectToSelect = nullptr; - if ( m_aSelectedOID.isAutoGeneratedObject() ) - { - pObjectToSelect = pDrawViewWrapper->getNamedSdrObject( m_aSelectedOID.getObjectCID() ); - } - else if( m_aSelectedOID.isAdditionalShape() ) - { - pObjectToSelect = DrawViewWrapper::getSdrObject( m_aSelectedOID.getAdditionalShape() ); - } + if( !pDrawViewWrapper ) + return; - impl_selectObject( pObjectToSelect, *pDrawViewWrapper ); + { + SolarMutexGuard aSolarGuard; + pDrawViewWrapper->UnmarkAll(); + } + SdrObject* pObjectToSelect = nullptr; + if ( m_aSelectedOID.isAutoGeneratedObject() ) + { + pObjectToSelect = pDrawViewWrapper->getNamedSdrObject( m_aSelectedOID.getObjectCID() ); + } + else if( m_aSelectedOID.isAdditionalShape() ) + { + pObjectToSelect = DrawViewWrapper::getSdrObject( m_aSelectedOID.getAdditionalShape() ); } + + impl_selectObject( pObjectToSelect, *pDrawViewWrapper ); } void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper const * pDrawViewWrapper , bool bIsRightMouse, bool bWaitingForDoubleClick ) { - if( pDrawViewWrapper ) - { - //do not toggle multiclick selection if right clicked on the selected object or waiting for double click - bool bAllowMultiClickSelectionChange = !bIsRightMouse && !bWaitingForDoubleClick; + if( !pDrawViewWrapper ) + return; - ObjectIdentifier aLastSelectedObject( m_aSelectedOID ); + //do not toggle multiclick selection if right clicked on the selected object or waiting for double click + bool bAllowMultiClickSelectionChange = !bIsRightMouse && !bWaitingForDoubleClick; - SolarMutexGuard aSolarGuard; + ObjectIdentifier aLastSelectedObject( m_aSelectedOID ); - //bAllowMultiClickSelectionChange==true -> a second click on the same object can lead to a changed selection (e.g. series -> single data point) + SolarMutexGuard aSolarGuard; - //get object to select: - { - m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier(); + //bAllowMultiClickSelectionChange==true -> a second click on the same object can lead to a changed selection (e.g. series -> single data point) - //the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree) - //further we travel along the grouping hierarchy from child to parent - SdrObject* pNewObj = pDrawViewWrapper->getHitObject(rMousePos); - m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) );//name of pNewObj + //get object to select: + { + m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier(); - //ignore handle only objects for hit test - while( pNewObj && m_aSelectedOID.getObjectCID().match( "HandlesOnly" ) ) - { - pNewObj->SetMarkProtect(true); - pNewObj = pDrawViewWrapper->getHitObject(rMousePos); - m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) ); - } + //the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree) + //further we travel along the grouping hierarchy from child to parent + SdrObject* pNewObj = pDrawViewWrapper->getHitObject(rMousePos); + m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) );//name of pNewObj - //accept only named objects while searching for the object to select - //this call may change m_aSelectedOID - if ( SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, true ) ) + //ignore handle only objects for hit test + while( pNewObj && m_aSelectedOID.getObjectCID().match( "HandlesOnly" ) ) + { + pNewObj->SetMarkProtect(true); + pNewObj = pDrawViewWrapper->getHitObject(rMousePos); + m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) ); + } + + //accept only named objects while searching for the object to select + //this call may change m_aSelectedOID + if ( SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, true ) ) + { + //if the so far found object is a multi click object further steps are necessary + while( ObjectIdentifier::isMultiClickObject( m_aSelectedOID.getObjectCID() ) ) { - //if the so far found object is a multi click object further steps are necessary - while( ObjectIdentifier::isMultiClickObject( m_aSelectedOID.getObjectCID() ) ) + bool bSameObjectAsLastSelected = ( aLastSelectedObject == m_aSelectedOID ); + if( bSameObjectAsLastSelected ) { - bool bSameObjectAsLastSelected = ( aLastSelectedObject == m_aSelectedOID ); - if( bSameObjectAsLastSelected ) - { - //if the same child is clicked again don't go up further - break; - } - if ( ObjectIdentifier::areSiblings( aLastSelectedObject.getObjectCID(), m_aSelectedOID.getObjectCID() ) ) - { - //if a sibling of the last selected object is clicked don't go up further - break; - } - ObjectIdentifier aLastChild = m_aSelectedOID; - if ( !SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, false ) ) - { - //take the one found so far - break; - } - //if the last selected object is found don't go up further - //but take the last child if selection change is allowed - if ( aLastSelectedObject == m_aSelectedOID ) + //if the same child is clicked again don't go up further + break; + } + if ( ObjectIdentifier::areSiblings( aLastSelectedObject.getObjectCID(), m_aSelectedOID.getObjectCID() ) ) + { + //if a sibling of the last selected object is clicked don't go up further + break; + } + ObjectIdentifier aLastChild = m_aSelectedOID; + if ( !SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, false ) ) + { + //take the one found so far + break; + } + //if the last selected object is found don't go up further + //but take the last child if selection change is allowed + if ( aLastSelectedObject == m_aSelectedOID ) + { + if( bAllowMultiClickSelectionChange ) { - if( bAllowMultiClickSelectionChange ) - { - m_aSelectedOID = aLastChild; - } - else - m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = aLastChild; - break; + m_aSelectedOID = aLastChild; } + else + m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = aLastChild; + break; } + } - OSL_ENSURE(m_aSelectedOID.isValid(), "somehow lost selected object"); + OSL_ENSURE(m_aSelectedOID.isValid(), "somehow lost selected object"); + } + else + { + //maybe an additional shape was hit + if ( pNewObj ) + { + m_aSelectedOID = ObjectIdentifier( uno::Reference< drawing::XShape >( pNewObj->getUnoShape(), uno::UNO_QUERY ) ); } else { - //maybe an additional shape was hit - if ( pNewObj ) - { - m_aSelectedOID = ObjectIdentifier( uno::Reference< drawing::XShape >( pNewObj->getUnoShape(), uno::UNO_QUERY ) ); - } - else - { - m_aSelectedOID = ObjectIdentifier(); - } + m_aSelectedOID = ObjectIdentifier(); } + } - if ( !m_aSelectedOID.isAdditionalShape() ) - { - OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );//@todo read CID from model + if ( !m_aSelectedOID.isAdditionalShape() ) + { + OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );//@todo read CID from model - if ( !m_aSelectedOID.isAutoGeneratedObject() ) - { - m_aSelectedOID = ObjectIdentifier( aPageCID ); - } + if ( !m_aSelectedOID.isAutoGeneratedObject() ) + { + m_aSelectedOID = ObjectIdentifier( aPageCID ); + } - //check whether the diagram was hit but not selected (e.g. because it has no filling): - OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ); - OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, OUString() ) );//@todo read CID from model - bool bBackGroundHit = m_aSelectedOID.getObjectCID() == aPageCID || m_aSelectedOID.getObjectCID() == aWallCID || !m_aSelectedOID.isAutoGeneratedObject(); - if( bBackGroundHit ) + //check whether the diagram was hit but not selected (e.g. because it has no filling): + OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ); + OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, OUString() ) );//@todo read CID from model + bool bBackGroundHit = m_aSelectedOID.getObjectCID() == aPageCID || m_aSelectedOID.getObjectCID() == aWallCID || !m_aSelectedOID.isAutoGeneratedObject(); + if( bBackGroundHit ) + { + //todo: if more than one diagram is available in future do check the list of all diagrams here + SdrObject* pDiagram = pDrawViewWrapper->getNamedSdrObject( aDiagramCID ); + if( pDiagram ) { - //todo: if more than one diagram is available in future do check the list of all diagrams here - SdrObject* pDiagram = pDrawViewWrapper->getNamedSdrObject( aDiagramCID ); - if( pDiagram ) + if( DrawViewWrapper::IsObjectHit( pDiagram, rMousePos ) ) { - if( DrawViewWrapper::IsObjectHit( pDiagram, rMousePos ) ) - { - m_aSelectedOID = ObjectIdentifier( aDiagramCID ); - } + m_aSelectedOID = ObjectIdentifier( aDiagramCID ); } } - //check whether the legend was hit but not selected (e.g. because it has no filling): - if( bBackGroundHit || m_aSelectedOID.getObjectCID() == aDiagramCID ) + } + //check whether the legend was hit but not selected (e.g. because it has no filling): + if( bBackGroundHit || m_aSelectedOID.getObjectCID() == aDiagramCID ) + { + OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::createParticleForLegend(nullptr) ) );//@todo read CID from model + SdrObject* pLegend = pDrawViewWrapper->getNamedSdrObject( aLegendCID ); + if( pLegend ) { - OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::createParticleForLegend(nullptr) ) );//@todo read CID from model - SdrObject* pLegend = pDrawViewWrapper->getNamedSdrObject( aLegendCID ); - if( pLegend ) + if( DrawViewWrapper::IsObjectHit( pLegend, rMousePos ) ) { - if( DrawViewWrapper::IsObjectHit( pLegend, rMousePos ) ) - { - m_aSelectedOID = ObjectIdentifier( aLegendCID ); - } + m_aSelectedOID = ObjectIdentifier( aLegendCID ); } } } } + } - if ( bIsRightMouse && m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid() ) - { - m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier(); - } + if ( bIsRightMouse && m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid() ) + { + m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier(); } } diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx index 3bb2dcb1e116..76559121c11c 100644 --- a/chart2/source/controller/main/ShapeController.cxx +++ b/chart2/source/controller/main/ShapeController.cxx @@ -140,64 +140,64 @@ FeatureState ShapeController::getState( const OUString& rCommand ) void ShapeController::execute( const OUString& rCommand, const Sequence< beans::PropertyValue>& ) { SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand ); - if ( aIter != m_aSupportedFeatures.end() ) + if ( aIter == m_aSupportedFeatures.end() ) + return; + + sal_uInt16 nFeatureId = aIter->second.nFeatureId; + switch ( nFeatureId ) { - sal_uInt16 nFeatureId = aIter->second.nFeatureId; - switch ( nFeatureId ) - { - case COMMAND_ID_FORMAT_LINE: - { - executeDispatch_FormatLine(); - } - break; - case COMMAND_ID_FORMAT_AREA: - { - executeDispatch_FormatArea(); - } - break; - case COMMAND_ID_TEXT_ATTRIBUTES: - { - executeDispatch_TextAttributes(); - } - break; - case COMMAND_ID_TRANSFORM_DIALOG: - { - executeDispatch_TransformDialog(); - } - break; - case COMMAND_ID_OBJECT_TITLE_DESCRIPTION: - { - executeDispatch_ObjectTitleDescription(); - } - break; - case COMMAND_ID_RENAME_OBJECT: - { - executeDispatch_RenameObject(); - } - break; - case COMMAND_ID_BRING_TO_FRONT: - case COMMAND_ID_FORWARD: - case COMMAND_ID_BACKWARD: - case COMMAND_ID_SEND_TO_BACK: - { - executeDispatch_ChangeZOrder( nFeatureId ); - } - break; - case COMMAND_ID_FONT_DIALOG: - { - executeDispatch_FontDialog(); - } - break; - case COMMAND_ID_PARAGRAPH_DIALOG: - { - executeDispatch_ParagraphDialog(); - } - break; - default: - { - } - break; - } + case COMMAND_ID_FORMAT_LINE: + { + executeDispatch_FormatLine(); + } + break; + case COMMAND_ID_FORMAT_AREA: + { + executeDispatch_FormatArea(); + } + break; + case COMMAND_ID_TEXT_ATTRIBUTES: + { + executeDispatch_TextAttributes(); + } + break; + case COMMAND_ID_TRANSFORM_DIALOG: + { + executeDispatch_TransformDialog(); + } + break; + case COMMAND_ID_OBJECT_TITLE_DESCRIPTION: + { + executeDispatch_ObjectTitleDescription(); + } + break; + case COMMAND_ID_RENAME_OBJECT: + { + executeDispatch_RenameObject(); + } + break; + case COMMAND_ID_BRING_TO_FRONT: + case COMMAND_ID_FORWARD: + case COMMAND_ID_BACKWARD: + case COMMAND_ID_SEND_TO_BACK: + { + executeDispatch_ChangeZOrder( nFeatureId ); + } + break; + case COMMAND_ID_FONT_DIALOG: + { + executeDispatch_FontDialog(); + } + break; + case COMMAND_ID_PARAGRAPH_DIALOG: + { + executeDispatch_ParagraphDialog(); + } + break; + default: + { + } + break; } } @@ -236,36 +236,36 @@ IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxObjectNameDialog&, rDialog, void ShapeController::executeDispatch_FormatLine() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pChartWindow && pDrawModelWrapper && pDrawViewWrapper) ) + return; + + SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); + SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); + bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + if ( bHasMarked ) { - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper ) + pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); + } + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr< SfxAbstractTabDialog > pDlg( + pFact->CreateSvxLineTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), + pSelectedObj, bHasMarked)); + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); + if ( bHasMarked ) { - SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); - SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); - if ( bHasMarked ) - { - pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); - } - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr< SfxAbstractTabDialog > pDlg( - pFact->CreateSvxLineTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), - pSelectedObj, bHasMarked)); - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); - if ( bHasMarked ) - { - pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false ); - } - else - { - pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); - } - } + pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false ); + } + else + { + pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); } } } @@ -273,34 +273,34 @@ void ShapeController::executeDispatch_FormatLine() void ShapeController::executeDispatch_FormatArea() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pChartWindow && pDrawModelWrapper && pDrawViewWrapper) ) + return; + + SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); + bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + if ( bHasMarked ) { - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper ) + pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); + } + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr< AbstractSvxAreaTabDialog > pDlg( + pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true)); + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); + if ( bHasMarked ) { - SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); - if ( bHasMarked ) - { - pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); - } - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr< AbstractSvxAreaTabDialog > pDlg( - pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true)); - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); - if ( bHasMarked ) - { - pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false ); - } - else - { - pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); - } - } + pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false ); + } + else + { + pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); } } } @@ -308,33 +308,33 @@ void ShapeController::executeDispatch_FormatArea() void ShapeController::executeDispatch_TextAttributes() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pChartWindow && pDrawViewWrapper) ) + return; + + SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); + bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + if ( bHasMarked ) { - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pChartWindow && pDrawViewWrapper ) + pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); + } + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr< SfxAbstractTabDialog > pDlg( + pFact->CreateTextTabDialog(pChartWindow, &aAttr, pDrawViewWrapper)); + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); + if ( bHasMarked ) { - SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); - if ( bHasMarked ) - { - pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); - } - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr< SfxAbstractTabDialog > pDlg( - pFact->CreateTextTabDialog(pChartWindow, &aAttr, pDrawViewWrapper)); - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); - if ( bHasMarked ) - { - pDrawViewWrapper->SetAttributes( *pOutAttr ); - } - else - { - pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); - } - } + pDrawViewWrapper->SetAttributes( *pOutAttr ); + } + else + { + pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); } } } @@ -342,47 +342,47 @@ void ShapeController::executeDispatch_TextAttributes() void ShapeController::executeDispatch_TransformDialog() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pChartWindow && pDrawViewWrapper) ) + return; + + SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); + if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == OBJ_CAPTION ) { - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pChartWindow && pDrawViewWrapper ) + // item set for caption + SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() ); + pDrawViewWrapper->GetAttributes( aAttr ); + // item set for position and size + SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr< SfxAbstractTabDialog > pDlg( + pFact->CreateCaptionDialog(pChartWindow, pDrawViewWrapper)); + const sal_uInt16* pRange = pDlg->GetInputRanges( *aAttr.GetPool() ); + SfxItemSet aCombAttr( *aAttr.GetPool(), pRange ); + aCombAttr.Put( aAttr ); + aCombAttr.Put( aGeoAttr ); + pDlg->SetInputSet( &aCombAttr ); + if ( pDlg->Execute() == RET_OK ) { - SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); - if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == OBJ_CAPTION ) - { - // item set for caption - SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() ); - pDrawViewWrapper->GetAttributes( aAttr ); - // item set for position and size - SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr< SfxAbstractTabDialog > pDlg( - pFact->CreateCaptionDialog(pChartWindow, pDrawViewWrapper)); - const sal_uInt16* pRange = pDlg->GetInputRanges( *aAttr.GetPool() ); - SfxItemSet aCombAttr( *aAttr.GetPool(), pRange ); - aCombAttr.Put( aAttr ); - aCombAttr.Put( aGeoAttr ); - pDlg->SetInputSet( &aCombAttr ); - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); - pDrawViewWrapper->SetAttributes( *pOutAttr ); - pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr ); - } - } - else - { - SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr< SfxAbstractTabDialog > pDlg( - pFact->CreateSvxTransformTabDialog(pChartWindow, &aGeoAttr, pDrawViewWrapper)); - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); - pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr ); - } - } + const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); + pDrawViewWrapper->SetAttributes( *pOutAttr ); + pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr ); + } + } + else + { + SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr< SfxAbstractTabDialog > pDlg( + pFact->CreateSvxTransformTabDialog(pChartWindow, &aGeoAttr, pDrawViewWrapper)); + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); + pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr ); } } } @@ -390,58 +390,58 @@ void ShapeController::executeDispatch_TransformDialog() void ShapeController::executeDispatch_ObjectTitleDescription() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1) ) + return; + + SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); + if ( !pSelectedObj ) + return; + + OUString aTitle( pSelectedObj->GetTitle() ); + OUString aDescription( pSelectedObj->GetDescription() ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + ScopedVclPtr< AbstractSvxObjectTitleDescDialog > pDlg( + pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription)); + if ( pDlg->Execute() == RET_OK ) { - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 ) - { - SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); - if ( pSelectedObj ) - { - OUString aTitle( pSelectedObj->GetTitle() ); - OUString aDescription( pSelectedObj->GetDescription() ); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - ScopedVclPtr< AbstractSvxObjectTitleDescDialog > pDlg( - pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription)); - if ( pDlg->Execute() == RET_OK ) - { - pDlg->GetTitle( aTitle ); - pDlg->GetDescription( aDescription ); - pSelectedObj->SetTitle( aTitle ); - pSelectedObj->SetDescription( aDescription ); - } - } - } + pDlg->GetTitle( aTitle ); + pDlg->GetDescription( aDescription ); + pSelectedObj->SetTitle( aTitle ); + pSelectedObj->SetDescription( aDescription ); } } void ShapeController::executeDispatch_RenameObject() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1) ) + return; + + SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); + if ( !pSelectedObj ) + return; + + OUString aName = pSelectedObj->GetName(); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + ScopedVclPtr< AbstractSvxObjectNameDialog > pDlg( + pFact->CreateSvxObjectNameDialog(pChartWindow, aName)); + pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) ); + if ( pDlg->Execute() == RET_OK ) { - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 ) + pDlg->GetName(aName); + if (pSelectedObj->GetName() == aName) { - SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); - if ( pSelectedObj ) - { - OUString aName = pSelectedObj->GetName(); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - ScopedVclPtr< AbstractSvxObjectNameDialog > pDlg( - pFact->CreateSvxObjectNameDialog(pChartWindow, aName)); - pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) ); - if ( pDlg->Execute() == RET_OK ) - { - pDlg->GetName(aName); - if (pSelectedObj->GetName() == aName) - { - pSelectedObj->SetName( aName ); - } - } - } + pSelectedObj->SetName( aName ); } } } @@ -450,70 +450,70 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) { SolarMutexGuard aGuard; DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr ); - if ( pDrawViewWrapper ) + if ( !pDrawViewWrapper ) + return; + + switch ( nId ) { - switch ( nId ) - { - case COMMAND_ID_BRING_TO_FRONT: - { - if ( isForwardPossible() ) - { - pDrawViewWrapper->PutMarkedToTop(); - } - } - break; - case COMMAND_ID_FORWARD: + case COMMAND_ID_BRING_TO_FRONT: + { + if ( isForwardPossible() ) { - if ( isForwardPossible() ) - { - pDrawViewWrapper->MovMarkedToTop(); - } + pDrawViewWrapper->PutMarkedToTop(); } - break; - case COMMAND_ID_BACKWARD: + } + break; + case COMMAND_ID_FORWARD: + { + if ( isForwardPossible() ) { - if ( isBackwardPossible() ) - { - pDrawViewWrapper->MovMarkedToBtm(); - } + pDrawViewWrapper->MovMarkedToTop(); } - break; - case COMMAND_ID_SEND_TO_BACK: + } + break; + case COMMAND_ID_BACKWARD: + { + if ( isBackwardPossible() ) { - if ( isBackwardPossible() ) - { - SdrObject* pFirstObj = getFirstAdditionalShape(); - pDrawViewWrapper->PutMarkedBehindObj( pFirstObj ); - } + pDrawViewWrapper->MovMarkedToBtm(); } - break; - default: + } + break; + case COMMAND_ID_SEND_TO_BACK: + { + if ( isBackwardPossible() ) { + SdrObject* pFirstObj = getFirstAdditionalShape(); + pDrawViewWrapper->PutMarkedBehindObj( pFirstObj ); } - break; - } + } + break; + default: + { + } + break; } } void ShapeController::executeDispatch_FontDialog() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper ) { - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper ) + SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() ); + pDrawViewWrapper->GetAttributes( aAttr ); + ViewElementListProvider aViewElementListProvider( pDrawModelWrapper ); + ShapeFontDialog aDlg(pChartWindow, &aAttr, &aViewElementListProvider); + if (aDlg.run() == RET_OK) { - SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() ); - pDrawViewWrapper->GetAttributes( aAttr ); - ViewElementListProvider aViewElementListProvider( pDrawModelWrapper ); - ShapeFontDialog aDlg(pChartWindow, &aAttr, &aViewElementListProvider); - if (aDlg.run() == RET_OK) - { - const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet(); - pDrawViewWrapper->SetAttributes( *pOutAttr ); - } + const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet(); + pDrawViewWrapper->SetAttributes( *pOutAttr ); } } } @@ -521,35 +521,35 @@ void ShapeController::executeDispatch_FontDialog() void ShapeController::executeDispatch_ParagraphDialog() { SolarMutexGuard aGuard; - if ( m_pChartController ) + if ( !m_pChartController ) + return; + + weld::Window* pChartWindow(m_pChartController->GetChartFrame()); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( !(pChartWindow && pDrawViewWrapper) ) + return; + + SfxItemPool& rPool = pDrawViewWrapper->GetModel()->GetItemPool(); + SfxItemSet aAttr( rPool ); + pDrawViewWrapper->GetAttributes( aAttr ); + + SfxItemSet aNewAttr( + rPool, + svl::Items< + EE_ITEMS_START, EE_ITEMS_END, + SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS>{}); + aNewAttr.Put( aAttr ); + aNewAttr.Put( SvxHyphenZoneItem( false, SID_ATTR_PARA_HYPHENZONE ) ); + aNewAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, SID_ATTR_PARA_PAGEBREAK ) ); + aNewAttr.Put( SvxFormatSplitItem( true, SID_ATTR_PARA_SPLIT) ); + aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) ); + aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) ); + + ShapeParagraphDialog aDlg(pChartWindow, &aNewAttr); + if (aDlg.run() == RET_OK) { - weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( pChartWindow && pDrawViewWrapper ) - { - SfxItemPool& rPool = pDrawViewWrapper->GetModel()->GetItemPool(); - SfxItemSet aAttr( rPool ); - pDrawViewWrapper->GetAttributes( aAttr ); - - SfxItemSet aNewAttr( - rPool, - svl::Items< - EE_ITEMS_START, EE_ITEMS_END, - SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS>{}); - aNewAttr.Put( aAttr ); - aNewAttr.Put( SvxHyphenZoneItem( false, SID_ATTR_PARA_HYPHENZONE ) ); - aNewAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, SID_ATTR_PARA_PAGEBREAK ) ); - aNewAttr.Put( SvxFormatSplitItem( true, SID_ATTR_PARA_SPLIT) ); - aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) ); - aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) ); - - ShapeParagraphDialog aDlg(pChartWindow, &aNewAttr); - if (aDlg.run() == RET_OK) - { - const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet(); - pDrawViewWrapper->SetAttributes( *pOutAttr ); - } - } + const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet(); + pDrawViewWrapper->SetAttributes( *pOutAttr ); } } diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index afa76424abd8..6cb42ff88f61 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -61,27 +61,27 @@ void UndoCommandDispatch::fireStatusEvent( const OUString & rURL, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { - if( m_xUndoManager.is() ) - { - const bool bFireAll = rURL.isEmpty(); - uno::Any aUndoState, aRedoState, aUndoStrings, aRedoStrings; - if( m_xUndoManager->isUndoPossible()) - aUndoState <<= SvtResId( STR_UNDO ) + m_xUndoManager->getCurrentUndoActionTitle(); - if( m_xUndoManager->isRedoPossible()) - aRedoState <<= SvtResId( STR_REDO ) + m_xUndoManager->getCurrentRedoActionTitle(); - - aUndoStrings <<= m_xUndoManager->getAllUndoActionTitles(); - aRedoStrings <<= m_xUndoManager->getAllRedoActionTitles(); - - if( bFireAll || rURL == ".uno:Undo" ) - fireStatusEventForURL( ".uno:Undo", aUndoState, m_xUndoManager->isUndoPossible(), xSingleListener ); - if( bFireAll || rURL == ".uno:Redo" ) - fireStatusEventForURL( ".uno:Redo", aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener ); - if( bFireAll || rURL == ".uno:GetUndoStrings" ) - fireStatusEventForURL( ".uno:GetUndoStrings", aUndoStrings, true, xSingleListener ); - if( bFireAll || rURL == ".uno:GetRedoStrings" ) - fireStatusEventForURL( ".uno:GetRedoStrings", aRedoStrings, true, xSingleListener ); - } + if( !m_xUndoManager.is() ) + return; + + const bool bFireAll = rURL.isEmpty(); + uno::Any aUndoState, aRedoState, aUndoStrings, aRedoStrings; + if( m_xUndoManager->isUndoPossible()) + aUndoState <<= SvtResId( STR_UNDO ) + m_xUndoManager->getCurrentUndoActionTitle(); + if( m_xUndoManager->isRedoPossible()) + aRedoState <<= SvtResId( STR_REDO ) + m_xUndoManager->getCurrentRedoActionTitle(); + + aUndoStrings <<= m_xUndoManager->getAllUndoActionTitles(); + aRedoStrings <<= m_xUndoManager->getAllRedoActionTitles(); + + if( bFireAll || rURL == ".uno:Undo" ) + fireStatusEventForURL( ".uno:Undo", aUndoState, m_xUndoManager->isUndoPossible(), xSingleListener ); + if( bFireAll || rURL == ".uno:Redo" ) + fireStatusEventForURL( ".uno:Redo", aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener ); + if( bFireAll || rURL == ".uno:GetUndoStrings" ) + fireStatusEventForURL( ".uno:GetUndoStrings", aUndoStrings, true, xSingleListener ); + if( bFireAll || rURL == ".uno:GetRedoStrings" ) + fireStatusEventForURL( ".uno:GetRedoStrings", aRedoStrings, true, xSingleListener ); } // ____ XDispatch ____ @@ -89,34 +89,34 @@ void SAL_CALL UndoCommandDispatch::dispatch( const util::URL& URL, const Sequence< beans::PropertyValue >& Arguments ) { - if( m_xUndoManager.is() ) + if( !m_xUndoManager.is() ) + return; + + // why is it necessary to lock the solar mutex here? + SolarMutexGuard aSolarGuard; + try { - // why is it necessary to lock the solar mutex here? - SolarMutexGuard aSolarGuard; - try - { - sal_Int16 nCount( 1 ); - if ( Arguments.hasElements() && Arguments[0].Name == URL.Path ) - Arguments[0].Value >>= nCount; - - while ( nCount-- ) - { - if ( URL.Path == "Undo" ) - m_xUndoManager->undo(); - else - m_xUndoManager->redo(); - } - } - catch( const document::UndoFailedException& ) - { - // silently ignore - } - catch( const uno::Exception& ) + sal_Int16 nCount( 1 ); + if ( Arguments.hasElements() && Arguments[0].Name == URL.Path ) + Arguments[0].Value >>= nCount; + + while ( nCount-- ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + if ( URL.Path == "Undo" ) + m_xUndoManager->undo(); + else + m_xUndoManager->redo(); } - // \-- } + catch( const document::UndoFailedException& ) + { + // silently ignore + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + // \-- } // ____ WeakComponentImplHelperBase ____ diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 63df9483b8c8..594cbf827379 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -175,21 +175,21 @@ bool isGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridTy void setGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridType eType, bool bVisible) { Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); - if(xDiagram.is()) - { - sal_Int32 nDimensionIndex = 0; - if (eType == GridType::HOR_MAJOR || eType == GridType::HOR_MINOR) - nDimensionIndex = 1; - sal_Int32 nCooSysIndex = 0; + if(!xDiagram.is()) + return; - bool bMajor = (eType == GridType::HOR_MAJOR || eType == GridType::VERT_MAJOR); + sal_Int32 nDimensionIndex = 0; + if (eType == GridType::HOR_MAJOR || eType == GridType::HOR_MINOR) + nDimensionIndex = 1; + sal_Int32 nCooSysIndex = 0; - if (bVisible) - AxisHelper::showGrid(nDimensionIndex, nCooSysIndex, bMajor, - xDiagram); - else - AxisHelper::hideGrid(nDimensionIndex, nCooSysIndex, bMajor, xDiagram); - } + bool bMajor = (eType == GridType::HOR_MAJOR || eType == GridType::VERT_MAJOR); + + if (bVisible) + AxisHelper::showGrid(nDimensionIndex, nCooSysIndex, bMajor, + xDiagram); + else + AxisHelper::hideGrid(nDimensionIndex, nCooSysIndex, bMajor, xDiagram); } bool isAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisType eType) @@ -214,21 +214,21 @@ bool isAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisTy void setAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisType eType, bool bVisible) { Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); - if(xDiagram.is()) - { - sal_Int32 nDimensionIndex = 0; - if (eType == AxisType::Y_MAIN || eType == AxisType::Y_SECOND) - nDimensionIndex = 1; - else if (eType == AxisType::Z_MAIN) - nDimensionIndex = 2; + if(!xDiagram.is()) + return; - bool bMajor = !(eType == AxisType::X_SECOND || eType == AxisType::Y_SECOND); + sal_Int32 nDimensionIndex = 0; + if (eType == AxisType::Y_MAIN || eType == AxisType::Y_SECOND) + nDimensionIndex = 1; + else if (eType == AxisType::Z_MAIN) + nDimensionIndex = 2; - if (bVisible) - AxisHelper::showAxis(nDimensionIndex, bMajor, xDiagram, comphelper::getProcessComponentContext()); - else - AxisHelper::hideAxis(nDimensionIndex, bMajor, xDiagram); - } + bool bMajor = !(eType == AxisType::X_SECOND || eType == AxisType::Y_SECOND); + + if (bVisible) + AxisHelper::showAxis(nDimensionIndex, bMajor, xDiagram, comphelper::getProcessComponentContext()); + else + AxisHelper::hideAxis(nDimensionIndex, bMajor, xDiagram); } sal_Int32 getLegendPos(const css::uno::Reference<css::frame::XModel>& xModel) diff --git a/chart2/source/controller/sidebar/ChartTypePanel.cxx b/chart2/source/controller/sidebar/ChartTypePanel.cxx index f6334864b049..da3166c74cf4 100644 --- a/chart2/source/controller/sidebar/ChartTypePanel.cxx +++ b/chart2/source/controller/sidebar/ChartTypePanel.cxx @@ -405,34 +405,33 @@ void ChartTypePanel::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; - - uno::Reference<css::chart2::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"); - } + showAllControls(*m_pCurrentMainType); - fillAllControls(aParameter); - uno::Reference<beans::XPropertySet> xTemplateProps(getCurrentTemplate(), uno::UNO_QUERY); - m_pCurrentMainType->fillExtraControls(m_xChartModel, xTemplateProps); + 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; + + uno::Reference<css::chart2::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); } } // end of namespace ::chart::sidebar diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index a7159ced9972..96c49fb56655 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -260,35 +260,35 @@ void ChartModel::impl_notifyCloseListeners() void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aVisualAreaSize ) { uno::Reference< beans::XPropertySet > xProperties( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY ); - if ( xProperties.is() ) + if ( !xProperties.is() ) + return; + + uno::Reference< drawing::XShapes > xShapes; + xProperties->getPropertyValue( "AdditionalShapes" ) >>= xShapes; + if ( !xShapes.is() ) + return; + + sal_Int32 nCount = xShapes->getCount(); + for ( sal_Int32 i = 0; i < nCount; ++i ) { - uno::Reference< drawing::XShapes > xShapes; - xProperties->getPropertyValue( "AdditionalShapes" ) >>= xShapes; - if ( xShapes.is() ) + Reference< drawing::XShape > xShape; + if ( xShapes->getByIndex( i ) >>= xShape ) { - sal_Int32 nCount = xShapes->getCount(); - for ( sal_Int32 i = 0; i < nCount; ++i ) + if ( xShape.is() ) { - Reference< drawing::XShape > xShape; - if ( xShapes->getByIndex( i ) >>= xShape ) - { - if ( xShape.is() ) - { - awt::Point aPos( xShape->getPosition() ); - awt::Size aSize( xShape->getSize() ); + awt::Point aPos( xShape->getPosition() ); + awt::Size aSize( xShape->getSize() ); - double fWidth = static_cast< double >( aVisualAreaSize.Width ) / m_aVisualAreaSize.Width; - double fHeight = static_cast< double >( aVisualAreaSize.Height ) / m_aVisualAreaSize.Height; + double fWidth = static_cast< double >( aVisualAreaSize.Width ) / m_aVisualAreaSize.Width; + double fHeight = static_cast< double >( aVisualAreaSize.Height ) / m_aVisualAreaSize.Height; - aPos.X = static_cast< long >( aPos.X * fWidth ); - aPos.Y = static_cast< long >( aPos.Y * fHeight ); - aSize.Width = static_cast< long >( aSize.Width * fWidth ); - aSize.Height = static_cast< long >( aSize.Height * fHeight ); + aPos.X = static_cast< long >( aPos.X * fWidth ); + aPos.Y = static_cast< long >( aPos.Y * fHeight ); + aSize.Width = static_cast< long >( aSize.Width * fWidth ); + aSize.Height = static_cast< long >( aSize.Height * fHeight ); - xShape->setPosition( aPos ); - xShape->setSize( aSize ); - } - } + xShape->setPosition( aPos ); + xShape->setSize( aSize ); } } } diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index 642aceb626ae..21b61c89cdbc 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -362,18 +362,18 @@ void ChartModel::impl_store( //notify parent data provider after saving thus the parent document can store //the ranges for which a load and update of the chart will be necessary Reference< beans::XPropertySet > xPropSet( m_xParent, uno::UNO_QUERY ); - if ( !hasInternalDataProvider() && xPropSet.is() ) + if ( !(!hasInternalDataProvider() && xPropSet.is()) ) + return; + + apphelper::MediaDescriptorHelper aMDHelper(rMediaDescriptor); + try + { + xPropSet->setPropertyValue( + "SavedObject", + uno::Any( aMDHelper.HierarchicalDocumentName ) ); + } + catch ( const uno::Exception& ) { - apphelper::MediaDescriptorHelper aMDHelper(rMediaDescriptor); - try - { - xPropSet->setPropertyValue( - "SavedObject", - uno::Any( aMDHelper.HierarchicalDocumentName ) ); - } - catch ( const uno::Exception& ) - { - } } } diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 48a2b53f8be4..ffc694fbd5df 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -251,19 +251,19 @@ void SAL_CALL BarChartTypeTemplate::applyStyle( { ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount ); DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) ); - if( getDimension() == 3 ) + if( getDimension() != 3 ) + return; + + try { - try - { - //apply Geometry3D - uno::Any aAGeometry3D; - getFastPropertyValue( aAGeometry3D, PROP_BAR_TEMPLATE_GEOMETRY3D ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "Geometry3D", aAGeometry3D ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + //apply Geometry3D + uno::Any aAGeometry3D; + getFastPropertyValue( aAGeometry3D, PROP_BAR_TEMPLATE_GEOMETRY3D ); + DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "Geometry3D", aAGeometry3D ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index afd9eb0f048a..646560d04adb 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -69,26 +69,26 @@ void lcl_applyDefaultStyle( void lcl_ensureCorrectLabelPlacement( const Reference< beans::XPropertySet >& xProp, const uno::Sequence < sal_Int32 >& rAvailablePlacements ) { sal_Int32 nLabelPlacement=0; - if( xProp.is() && (xProp->getPropertyValue( "LabelPlacement" ) >>= nLabelPlacement) ) + if( !(xProp.is() && (xProp->getPropertyValue( "LabelPlacement" ) >>= nLabelPlacement)) ) + return; + + bool bValid = false; + for( sal_Int32 nN = 0; nN < rAvailablePlacements.getLength(); nN++ ) { - bool bValid = false; - for( sal_Int32 nN = 0; nN < rAvailablePlacements.getLength(); nN++ ) - { - if( rAvailablePlacements[nN] == nLabelPlacement ) - { - bValid = true; - break; - } - } - if( !bValid ) + if( rAvailablePlacements[nN] == nLabelPlacement ) { - uno::Any aNewValue; - //otherwise use the first supported one - if( rAvailablePlacements.hasElements() ) - aNewValue <<=rAvailablePlacements[0]; - xProp->setPropertyValue( "LabelPlacement", aNewValue ); + bValid = true; + break; } } + if( !bValid ) + { + uno::Any aNewValue; + //otherwise use the first supported one + if( rAvailablePlacements.hasElements() ) + aNewValue <<=rAvailablePlacements[0]; + xProp->setPropertyValue( "LabelPlacement", aNewValue ); + } } void lcl_resetLabelPlacementIfDefault( const Reference< beans::XPropertySet >& xProp, sal_Int32 nDefaultPlacement ) @@ -381,37 +381,37 @@ void SAL_CALL ChartTypeTemplate::applyStyle( { // sset stacking mode Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); - if( xSeriesProp.is()) + if( !xSeriesProp.is()) + return; + + try { - try + StackMode eStackMode = getStackMode( nChartTypeIndex ); + const uno::Any aPropValue( + ( (eStackMode == StackMode::YStacked) || + (eStackMode == StackMode::YStackedPercent) ) + ? chart2::StackingDirection_Y_STACKING + : (eStackMode == StackMode::ZStacked ) + ? chart2::StackingDirection_Z_STACKING + : chart2::StackingDirection_NO_STACKING ); + xSeriesProp->setPropertyValue( "StackingDirection", aPropValue ); + + //ensure valid label placement { - StackMode eStackMode = getStackMode( nChartTypeIndex ); - const uno::Any aPropValue( - ( (eStackMode == StackMode::YStacked) || - (eStackMode == StackMode::YStackedPercent) ) - ? chart2::StackingDirection_Y_STACKING - : (eStackMode == StackMode::ZStacked ) - ? chart2::StackingDirection_Z_STACKING - : chart2::StackingDirection_NO_STACKING ); - xSeriesProp->setPropertyValue( "StackingDirection", aPropValue ); - - //ensure valid label placement - { - uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( - getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) ); - lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements ); - - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) - for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) - lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements ); - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); + uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( + getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) ); + lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements ); + + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) + lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements ); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } void ChartTypeTemplate::applyStyles( const Reference< chart2::XDiagram >& xDiagram ) @@ -685,30 +685,30 @@ void ChartTypeTemplate::createAxes( const Sequence< Reference< XCoordinateSystem > > & rCoordSys ) { //create missing axes - if( rCoordSys.hasElements() ) - { - Reference< XCoordinateSystem > xCooSys( rCoordSys[0] ); - if(!xCooSys.is()) - return; + if( !rCoordSys.hasElements() ) + return; - //create main axis in first coordinate system - sal_Int32 nDimCount = xCooSys->getDimension(); - sal_Int32 nDim=0; - for( nDim=0; nDim<nDimCount; ++nDim ) + Reference< XCoordinateSystem > xCooSys( rCoordSys[0] ); + if(!xCooSys.is()) + return; + + //create main axis in first coordinate system + sal_Int32 nDimCount = xCooSys->getDimension(); + sal_Int32 nDim=0; + for( nDim=0; nDim<nDimCount; ++nDim ) + { + sal_Int32 nAxisCount = getAxisCountByDimension( nDim ); + if( nDim == 1 && + nAxisCount < 2 && AxisHelper::isSecondaryYAxisNeeded( xCooSys )) + nAxisCount = 2; + for( sal_Int32 nAxisIndex = 0; nAxisIndex < nAxisCount; ++nAxisIndex ) { - sal_Int32 nAxisCount = getAxisCountByDimension( nDim ); - if( nDim == 1 && - nAxisCount < 2 && AxisHelper::isSecondaryYAxisNeeded( xCooSys )) - nAxisCount = 2; - for( sal_Int32 nAxisIndex = 0; nAxisIndex < nAxisCount; ++nAxisIndex ) + Reference< XAxis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ); + if( !xAxis.is()) { - Reference< XAxis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ); - if( !xAxis.is()) - { - // create and add axis - xAxis.set( AxisHelper::createAxis( - nDim, nAxisIndex, xCooSys, GetComponentContext() )); - } + // create and add axis + xAxis.set( AxisHelper::createAxis( + nDim, nAxisIndex, xCooSys, GetComponentContext() )); } } } @@ -719,36 +719,36 @@ void ChartTypeTemplate::adaptAxes( { //adapt properties of existing axes and remove superfluous axes - if( rCoordSys.hasElements() ) + if( !rCoordSys.hasElements() ) + return; + + for( sal_Int32 nCooSysIdx=0; nCooSysIdx < rCoordSys.getLength(); ++nCooSysIdx ) { - for( sal_Int32 nCooSysIdx=0; nCooSysIdx < rCoordSys.getLength(); ++nCooSysIdx ) + Reference< XCoordinateSystem > xCooSys( rCoordSys[nCooSysIdx] ); + if( !xCooSys.is() ) + continue; + sal_Int32 nDimCount = xCooSys->getDimension(); + for( sal_Int32 nDim=0; nDim<nDimCount; ++nDim ) { - Reference< XCoordinateSystem > xCooSys( rCoordSys[nCooSysIdx] ); - if( !xCooSys.is() ) - continue; - sal_Int32 nDimCount = xCooSys->getDimension(); - for( sal_Int32 nDim=0; nDim<nDimCount; ++nDim ) + sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension( nDim ); + for( sal_Int32 nAxisIndex=0; nAxisIndex<=nMaxAxisIndex; nAxisIndex++ ) { - sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension( nDim ); - for( sal_Int32 nAxisIndex=0; nAxisIndex<=nMaxAxisIndex; nAxisIndex++ ) - { - Reference< XAxis > xAxis( AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ) ); - if( !xAxis.is() ) - continue; + Reference< XAxis > xAxis( AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ) ); + if( !xAxis.is() ) + continue; - if( nAxisIndex == MAIN_AXIS_INDEX || nAxisIndex == SECONDARY_AXIS_INDEX ) + if( nAxisIndex == MAIN_AXIS_INDEX || nAxisIndex == SECONDARY_AXIS_INDEX ) + { + // adapt scales + bool bPercent = (getStackMode(0) == StackMode::YStackedPercent); + if( bPercent && nDim == 1 ) { - // adapt scales - bool bPercent = (getStackMode(0) == StackMode::YStackedPercent); - if( bPercent && nDim == 1 ) + Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY ); + if( xAxisProp.is()) { - Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY ); - if( xAxisProp.is()) - { - // set number format to source format - xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true)); - xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any()); - } + // set number format to source format + xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true)); + xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any()); } } } diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index 8fa5ea448bf1..5832612ba91d 100644 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -215,21 +215,21 @@ struct lcl_LabeledSequenceEquals m_bHasLabels ( false ), m_bHasValues ( false ) { - if( xLSeqToCmp.is()) + if( !xLSeqToCmp.is()) + return; + + Reference< data::XDataSequence > xSeq( xLSeqToCmp->getValues()); + if( xSeq.is()) { - Reference< data::XDataSequence > xSeq( xLSeqToCmp->getValues()); - if( xSeq.is()) - { - m_bHasValues = true; - m_aValuesRangeRep = xSeq->getSourceRangeRepresentation(); - } + m_bHasValues = true; + m_aValuesRangeRep = xSeq->getSourceRangeRepresentation(); + } - xSeq.set( xLSeqToCmp->getLabel()); - if( xSeq.is()) - { - m_bHasLabels = true; - m_aLabelRangeRep = xSeq->getSourceRangeRepresentation(); - } + xSeq.set( xLSeqToCmp->getLabel()); + if( xSeq.is()) + { + m_bHasLabels = true; + m_aLabelRangeRep = xSeq->getSourceRangeRepresentation(); } } diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 78c9cf5e4e28..6b5b43d0c891 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -1076,69 +1076,69 @@ Reference< XChartType > AxisHelper::getChartTypeByIndex( const Reference< XCoord void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys ) { - if( xCooSys.is() ) - { - bool bCartesian = xCooSys->getViewServiceName() == CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME; - if( bCartesian ) - { - bool bVertical = false; - Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY ); - if( xCooSysProp.is() ) - xCooSysProp->getPropertyValue( "SwapXAndYAxis" ) >>= bVertical; + if( !xCooSys.is() ) + return; - sal_Int32 nHorizontalAxisDimension = bVertical ? 1 : 0; - sal_Int32 nVerticalAxisDimension = bVertical ? 0 : 1; + bool bCartesian = xCooSys->getViewServiceName() == CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME; + if( !bCartesian ) + return; - try - { - //reverse direction for horizontal main axis - Reference< chart2::XAxis > xHorizontalMainAxis( AxisHelper::getAxis( nHorizontalAxisDimension, MAIN_AXIS_INDEX, xCooSys ) ); - if( xHorizontalMainAxis.is() ) - { - chart2::ScaleData aScale = xHorizontalMainAxis->getScaleData(); - aScale.Orientation = chart2::AxisOrientation_REVERSE; - xHorizontalMainAxis->setScaleData(aScale); - } + bool bVertical = false; + Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY ); + if( xCooSysProp.is() ) + xCooSysProp->getPropertyValue( "SwapXAndYAxis" ) >>= bVertical; - //mathematical direction for vertical main axis - Reference< chart2::XAxis > xVerticalMainAxis( AxisHelper::getAxis( nVerticalAxisDimension, MAIN_AXIS_INDEX, xCooSys ) ); - if( xVerticalMainAxis.is() ) - { - chart2::ScaleData aScale = xVerticalMainAxis->getScaleData(); - aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; - xVerticalMainAxis->setScaleData(aScale); - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2" ); - } + sal_Int32 nHorizontalAxisDimension = bVertical ? 1 : 0; + sal_Int32 nVerticalAxisDimension = bVertical ? 0 : 1; - try - { - //reverse direction for horizontal secondary axis - Reference< chart2::XAxis > xHorizontalSecondaryAxis( AxisHelper::getAxis( nHorizontalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys ) ); - if( xHorizontalSecondaryAxis.is() ) - { - chart2::ScaleData aScale = xHorizontalSecondaryAxis->getScaleData(); - aScale.Orientation = chart2::AxisOrientation_REVERSE; - xHorizontalSecondaryAxis->setScaleData(aScale); - } + try + { + //reverse direction for horizontal main axis + Reference< chart2::XAxis > xHorizontalMainAxis( AxisHelper::getAxis( nHorizontalAxisDimension, MAIN_AXIS_INDEX, xCooSys ) ); + if( xHorizontalMainAxis.is() ) + { + chart2::ScaleData aScale = xHorizontalMainAxis->getScaleData(); + aScale.Orientation = chart2::AxisOrientation_REVERSE; + xHorizontalMainAxis->setScaleData(aScale); + } - //mathematical direction for vertical secondary axis - Reference< chart2::XAxis > xVerticalSecondaryAxis( AxisHelper::getAxis( nVerticalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys ) ); - if( xVerticalSecondaryAxis.is() ) - { - chart2::ScaleData aScale = xVerticalSecondaryAxis->getScaleData(); - aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; - xVerticalSecondaryAxis->setScaleData(aScale); - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + //mathematical direction for vertical main axis + Reference< chart2::XAxis > xVerticalMainAxis( AxisHelper::getAxis( nVerticalAxisDimension, MAIN_AXIS_INDEX, xCooSys ) ); + if( xVerticalMainAxis.is() ) + { + chart2::ScaleData aScale = xVerticalMainAxis->getScaleData(); + aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; + xVerticalMainAxis->setScaleData(aScale); + } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2" ); + } + + try + { + //reverse direction for horizontal secondary axis + Reference< chart2::XAxis > xHorizontalSecondaryAxis( AxisHelper::getAxis( nHorizontalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys ) ); + if( xHorizontalSecondaryAxis.is() ) + { + chart2::ScaleData aScale = xHorizontalSecondaryAxis->getScaleData(); + aScale.Orientation = chart2::AxisOrientation_REVERSE; + xHorizontalSecondaryAxis->setScaleData(aScale); } + + //mathematical direction for vertical secondary axis + Reference< chart2::XAxis > xVerticalSecondaryAxis( AxisHelper::getAxis( nVerticalAxisDimension, SECONDARY_AXIS_INDEX, xCooSys ) ); + if( xVerticalSecondaryAxis.is() ) + { + chart2::ScaleData aScale = xVerticalSecondaryAxis->getScaleData(); + aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; + xVerticalSecondaryAxis->setScaleData(aScale); + } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index d2b0b27e04fb..3dbcd65f70a2 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -111,26 +111,26 @@ void lcl_getCooSysAndChartTypeOfSeries( Reference< chart2::XChartType > & xOutChartType ) { Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); - if( xCooSysCnt.is()) + if( !xCooSysCnt.is()) + return; + + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) { - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) + Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) { - Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nCTIdx], uno::UNO_QUERY ); + if( xSeriesCnt.is()) { - Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nCTIdx], uno::UNO_QUERY ); - if( xSeriesCnt.is()) + Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); + for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx ) { - Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); - for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx ) + if( aSeries[nSeriesIdx] == xSeries ) { - if( aSeries[nSeriesIdx] == xSeries ) - { - xOutCooSys.set( aCooSysSeq[nCooSysIdx] ); - xOutChartType.set( aChartTypes[nCTIdx] ); - } + xOutCooSys.set( aCooSysSeq[nCooSysIdx] ); + xOutChartType.set( aChartTypes[nCTIdx] ); } } } @@ -411,31 +411,31 @@ void setStackModeAtSeries( } } - if( xCorrespondingCoordinateSystem.is() && - 1 < xCorrespondingCoordinateSystem->getDimension() ) + if( !(xCorrespondingCoordinateSystem.is() && + 1 < xCorrespondingCoordinateSystem->getDimension()) ) + return; + + if( aAxisIndexSet.empty() ) { - if( aAxisIndexSet.empty() ) - { - aAxisIndexSet.insert(0); - } + aAxisIndexSet.insert(0); + } - for (auto const& axisIndex : aAxisIndexSet) + for (auto const& axisIndex : aAxisIndexSet) + { + Reference< chart2::XAxis > xAxis( + xCorrespondingCoordinateSystem->getAxisByDimension(1, axisIndex)); + if( xAxis.is()) { - Reference< chart2::XAxis > xAxis( - xCorrespondingCoordinateSystem->getAxisByDimension(1, axisIndex)); - if( xAxis.is()) - { - bool bPercent = (eStackMode == StackMode::YStackedPercent); - chart2::ScaleData aScaleData = xAxis->getScaleData(); + bool bPercent = (eStackMode == StackMode::YStackedPercent); + chart2::ScaleData aScaleData = xAxis->getScaleData(); - if( bPercent != (aScaleData.AxisType==chart2::AxisType::PERCENT) ) - { - if( bPercent ) - aScaleData.AxisType = chart2::AxisType::PERCENT; - else - aScaleData.AxisType = chart2::AxisType::REALNUMBER; - xAxis->setScaleData( aScaleData ); - } + if( bPercent != (aScaleData.AxisType==chart2::AxisType::PERCENT) ) + { + if( bPercent ) + aScaleData.AxisType = chart2::AxisType::PERCENT; + else + aScaleData.AxisType = chart2::AxisType::REALNUMBER; + xAxis->setScaleData( aScaleData ); } } } diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 0ea291db6c47..5f5abd19c191 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -531,27 +531,27 @@ void DiagramHelper::replaceCoordinateSystem( // update the coordinate-system container Reference< XCoordinateSystemContainer > xCont( xDiagram, uno::UNO_QUERY ); - if( xCont.is()) + if( !xCont.is()) + return; + + try { - try - { - Reference< chart2::data::XLabeledDataSequence > xCategories = DiagramHelper::getCategoriesFromDiagram( xDiagram ); + Reference< chart2::data::XLabeledDataSequence > xCategories = DiagramHelper::getCategoriesFromDiagram( xDiagram ); - // move chart types of xCooSysToReplace to xReplacement - Reference< XChartTypeContainer > xCTCntCooSys( xCooSysToReplace, uno::UNO_QUERY_THROW ); - Reference< XChartTypeContainer > xCTCntReplacement( xReplacement, uno::UNO_QUERY_THROW ); - xCTCntReplacement->setChartTypes( xCTCntCooSys->getChartTypes()); + // move chart types of xCooSysToReplace to xReplacement + Reference< XChartTypeContainer > xCTCntCooSys( xCooSysToReplace, uno::UNO_QUERY_THROW ); + Reference< XChartTypeContainer > xCTCntReplacement( xReplacement, uno::UNO_QUERY_THROW ); + xCTCntReplacement->setChartTypes( xCTCntCooSys->getChartTypes()); - xCont->removeCoordinateSystem( xCooSysToReplace ); - xCont->addCoordinateSystem( xReplacement ); + xCont->removeCoordinateSystem( xCooSysToReplace ); + xCont->addCoordinateSystem( xReplacement ); - if( xCategories.is() ) - DiagramHelper::setCategoriesToDiagram( xCategories, xDiagram ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + if( xCategories.is() ) + DiagramHelper::setCategoriesToDiagram( xCategories, xDiagram ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } @@ -923,25 +923,25 @@ static void lcl_generateAutomaticCategoriesFromChartType( return; OUString aMainSeq( xChartType->getRoleOfSequenceForSeriesLabel() ); Reference< XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY ); - if( xSeriesCnt.is() ) + if( !xSeriesCnt.is() ) + return; + + Sequence< Reference< XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries() ); + for( sal_Int32 nS = 0; nS < aSeriesSeq.getLength(); nS++ ) { - Sequence< Reference< XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries() ); - for( sal_Int32 nS = 0; nS < aSeriesSeq.getLength(); nS++ ) - { - Reference< data::XDataSource > xDataSource( aSeriesSeq[nS], uno::UNO_QUERY ); - if( !xDataSource.is() ) - continue; - Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( - ::chart::DataSeriesHelper::getDataSequenceByRole( xDataSource, aMainSeq )); - if( !xLabeledSeq.is() ) - continue; - Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues() ); - if( !xValueSeq.is() ) - continue; - rRet = xValueSeq->generateLabel( chart2::data::LabelOrigin_LONG_SIDE ); - if( rRet.hasElements() ) - return; - } + Reference< data::XDataSource > xDataSource( aSeriesSeq[nS], uno::UNO_QUERY ); + if( !xDataSource.is() ) + continue; + Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( + ::chart::DataSeriesHelper::getDataSequenceByRole( xDataSource, aMainSeq )); + if( !xLabeledSeq.is() ) + continue; + Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues() ); + if( !xValueSeq.is() ) + continue; + rRet = xValueSeq->generateLabel( chart2::data::LabelOrigin_LONG_SIDE ); + if( rRet.hasElements() ) + return; } } diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 401d6eaa70e1..e75fe8376a40 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -463,32 +463,32 @@ static bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& void ExplicitCategoriesProvider::init() { - if( m_bDirty ) - { - m_aComplexCats.clear();//not one per index - m_aDateCategories.clear(); + if( !m_bDirty ) + return; - if( m_xOriginalCategories.is() ) + m_aComplexCats.clear();//not one per index + m_aDateCategories.clear(); + + if( m_xOriginalCategories.is() ) + { + if( !hasComplexCategories() ) { - if( !hasComplexCategories() ) + if(m_bIsDateAxis) { - if(m_bIsDateAxis) - { - if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ), 0 ) ) - m_bIsDateAxis = lcl_fillDateCategories( m_xOriginalCategories->getValues(), m_aDateCategories, m_bIsAutoDate, mrModel ); - else - m_bIsDateAxis = false; - } - } - else - { - m_bIsDateAxis = false; + if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ), 0 ) ) + m_bIsDateAxis = lcl_fillDateCategories( m_xOriginalCategories->getValues(), m_aDateCategories, m_bIsAutoDate, mrModel ); + else + m_bIsDateAxis = false; } } else - m_bIsDateAxis=false; - m_bDirty = false; + { + m_bIsDateAxis = false; + } } + else + m_bIsDateAxis=false; + m_bDirty = false; } Sequence< OUString > const & ExplicitCategoriesProvider::getSimpleCategories() diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx index fcf3bf44c8e6..5fc4d17244a4 100644 --- a/chart2/source/tools/InternalData.cxx +++ b/chart2/source/tools/InternalData.cxx @@ -249,42 +249,42 @@ vector< uno::Any > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const void InternalData::swapRowWithNext( sal_Int32 nRowIndex ) { - if( nRowIndex < m_nRowCount - 1 ) - { - const sal_Int32 nMax = m_nColumnCount; - for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx ) - { - size_t nIndex1 = nColIdx + nRowIndex*m_nColumnCount; - size_t nIndex2 = nIndex1 + m_nColumnCount; - double fTemp = m_aData[nIndex1]; - m_aData[nIndex1] = m_aData[nIndex2]; - m_aData[nIndex2] = fTemp; - } + if( nRowIndex >= m_nRowCount - 1 ) + return; - vector< uno::Any > aTemp( m_aRowLabels[nRowIndex] ); - m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1]; - m_aRowLabels[nRowIndex + 1] = aTemp; + const sal_Int32 nMax = m_nColumnCount; + for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx ) + { + size_t nIndex1 = nColIdx + nRowIndex*m_nColumnCount; + size_t nIndex2 = nIndex1 + m_nColumnCount; + double fTemp = m_aData[nIndex1]; + m_aData[nIndex1] = m_aData[nIndex2]; + m_aData[nIndex2] = fTemp; } + + vector< uno::Any > aTemp( m_aRowLabels[nRowIndex] ); + m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1]; + m_aRowLabels[nRowIndex + 1] = aTemp; } void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex ) { - if( nColumnIndex < m_nColumnCount - 1 ) - { - const sal_Int32 nMax = m_nRowCount; - for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx ) - { - size_t nIndex1 = nColumnIndex + nRowIdx*m_nColumnCount; - size_t nIndex2 = nIndex1 + 1; - double fTemp = m_aData[nIndex1]; - m_aData[nIndex1] = m_aData[nIndex2]; - m_aData[nIndex2] = fTemp; - } + if( nColumnIndex >= m_nColumnCount - 1 ) + return; - vector< uno::Any > aTemp( m_aColumnLabels[nColumnIndex] ); - m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1]; - m_aColumnLabels[nColumnIndex + 1] = aTemp; + const sal_Int32 nMax = m_nRowCount; + for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx ) + { + size_t nIndex1 = nColumnIndex + nRowIdx*m_nColumnCount; + size_t nIndex2 = nIndex1 + 1; + double fTemp = m_aData[nIndex1]; + m_aData[nIndex1] = m_aData[nIndex2]; + m_aData[nIndex2] = fTemp; } + + vector< uno::Any > aTemp( m_aColumnLabels[nColumnIndex] ); + m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1]; + m_aColumnLabels[nColumnIndex + 1] = aTemp; } bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount ) diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 08d03b4118d1..7c826e8f6129 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -116,60 +116,60 @@ struct lcl_internalizeSeries { Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); Reference< chart2::data::XDataSink > xSink( xSeries, uno::UNO_QUERY ); - if( xSource.is() && xSink.is() ) + if( !(xSource.is() && xSink.is()) ) + return; + + Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences(); + Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() ); + for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i ) { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences(); - Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() ); - for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i ) + sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() ); + OUString aIdentifier( OUString::number( nNewIndex )); + //@todo: deal also with genericXDataSequence + Reference< chart2::data::XNumericalDataSequence > xValues( aOldSeriesData[i]->getValues(), uno::UNO_QUERY ); + Reference< chart2::data::XTextualDataSequence > xLabel( aOldSeriesData[i]->getLabel(), uno::UNO_QUERY ); + Reference< chart2::data::XDataSequence > xNewValues; + + if( xValues.is() ) { - sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() ); - OUString aIdentifier( OUString::number( nNewIndex )); - //@todo: deal also with genericXDataSequence - Reference< chart2::data::XNumericalDataSequence > xValues( aOldSeriesData[i]->getValues(), uno::UNO_QUERY ); - Reference< chart2::data::XTextualDataSequence > xLabel( aOldSeriesData[i]->getLabel(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSequence > xNewValues; - - if( xValues.is() ) + auto aValues( comphelper::sequenceToContainer<std::vector< double >>( xValues->getNumericalData())); + if( m_bDataInColumns ) + m_rInternalData.setColumnValues( nNewIndex, aValues ); + else + m_rInternalData.setRowValues( nNewIndex, aValues ); + if( m_bConnectToModel ) { - auto aValues( comphelper::sequenceToContainer<std::vector< double >>( xValues->getNumericalData())); - if( m_bDataInColumns ) - m_rInternalData.setColumnValues( nNewIndex, aValues ); - else - m_rInternalData.setRowValues( nNewIndex, aValues ); - if( m_bConnectToModel ) - { - xNewValues.set( m_rProvider.createDataSequenceByRangeRepresentation( aIdentifier )); - comphelper::copyProperties( - Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ), - Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY )); - } + xNewValues.set( m_rProvider.createDataSequenceByRangeRepresentation( aIdentifier )); + comphelper::copyProperties( + Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ), + Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY )); } + } - if( xLabel.is() ) - { - if( m_bDataInColumns ) - m_rInternalData.setComplexColumnLabel( nNewIndex, lcl_StringToAnyVector( xLabel->getTextualData() ) ); - else - m_rInternalData.setComplexRowLabel( nNewIndex, lcl_StringToAnyVector( xLabel->getTextualData() ) ); - if( m_bConnectToModel ) - { - Reference< chart2::data::XDataSequence > xNewLabel( - m_rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier )); - comphelper::copyProperties( - Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ), - Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY )); - aNewSeriesData[i].set( new LabeledDataSequence( xNewValues, xNewLabel ) ); - } - } + if( xLabel.is() ) + { + if( m_bDataInColumns ) + m_rInternalData.setComplexColumnLabel( nNewIndex, lcl_StringToAnyVector( xLabel->getTextualData() ) ); else + m_rInternalData.setComplexRowLabel( nNewIndex, lcl_StringToAnyVector( xLabel->getTextualData() ) ); + if( m_bConnectToModel ) { - if( m_bConnectToModel ) - aNewSeriesData[i].set( new LabeledDataSequence( xNewValues ) ); + Reference< chart2::data::XDataSequence > xNewLabel( + m_rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier )); + comphelper::copyProperties( + Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ), + Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY )); + aNewSeriesData[i].set( new LabeledDataSequence( xNewValues, xNewLabel ) ); } } - if( m_bConnectToModel ) - xSink->setData( aNewSeriesData ); + else + { + if( m_bConnectToModel ) + aNewSeriesData[i].set( new LabeledDataSequence( xNewValues ) ); + } } + if( m_bConnectToModel ) + xSink->setData( aNewSeriesData ); } private: diff --git a/chart2/source/tools/ModifyListenerHelper.cxx b/chart2/source/tools/ModifyListenerHelper.cxx index 7d482f3e6d8a..3266af1d037e 100644 --- a/chart2/source/tools/ModifyListenerHelper.cxx +++ b/chart2/source/tools/ModifyListenerHelper.cxx @@ -36,23 +36,23 @@ void lcl_fireModifyEvent( { ::cppu::OInterfaceContainerHelper * pCntHlp = rBroadcastHelper.getContainer( cppu::UnoType<util::XModifyListener>::get()); - if( pCntHlp ) - { - lang::EventObject aEventToSend; - if( pEvent ) - aEventToSend = *pEvent; - else - aEventToSend.Source.set( xEventSource ); - OSL_ENSURE( aEventToSend.Source.is(), "Sending event without source" ); + if( !pCntHlp ) + return; - ::cppu::OInterfaceIteratorHelper aIt( *pCntHlp ); + lang::EventObject aEventToSend; + if( pEvent ) + aEventToSend = *pEvent; + else + aEventToSend.Source.set( xEventSource ); + OSL_ENSURE( aEventToSend.Source.is(), "Sending event without source" ); - while( aIt.hasMoreElements()) - { - Reference< util::XModifyListener > xModListener( aIt.next(), uno::UNO_QUERY ); - if( xModListener.is()) - xModListener->modified( aEventToSend ); - } + ::cppu::OInterfaceIteratorHelper aIt( *pCntHlp ); + + while( aIt.hasMoreElements()) + { + Reference< util::XModifyListener > xModListener( aIt.next(), uno::UNO_QUERY ); + if( xModListener.is()) + xModListener->modified( aEventToSend ); } } diff --git a/chart2/source/tools/OPropertySet.cxx b/chart2/source/tools/OPropertySet.cxx index 859dbcfdf757..252cfb605be1 100644 --- a/chart2/source/tools/OPropertySet.cxx +++ b/chart2/source/tools/OPropertySet.cxx @@ -257,75 +257,75 @@ void SAL_CALL OPropertySet::getFastPropertyValue ( Any& rValue, sal_Int32 nHandle ) const { - if( ! m_pImplProperties->GetPropertyValueByHandle( rValue, nHandle )) + if( m_pImplProperties->GetPropertyValueByHandle( rValue, nHandle )) + return; + + // property was not set -> try style + uno::Reference< beans::XFastPropertySet > xStylePropSet( m_pImplProperties->GetStyle(), uno::UNO_QUERY ); + if( xStylePropSet.is() ) { - // property was not set -> try style - uno::Reference< beans::XFastPropertySet > xStylePropSet( m_pImplProperties->GetStyle(), uno::UNO_QUERY ); - if( xStylePropSet.is() ) - { #ifdef DBG_UTIL + { + // check if the handle of the style points to the same property + // name as the handle in this property set + uno::Reference< beans::XPropertySet > xPropSet( xStylePropSet, uno::UNO_QUERY ); + if( xPropSet.is()) { - // check if the handle of the style points to the same property - // name as the handle in this property set - uno::Reference< beans::XPropertySet > xPropSet( xStylePropSet, uno::UNO_QUERY ); - if( xPropSet.is()) + uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); + if( xInfo.is() ) { - uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); - if( xInfo.is() ) + // for some reason the virtual method getInfoHelper() is + // not const + ::cppu::IPropertyArrayHelper & rPH = + const_cast< OPropertySet * >( this )->getInfoHelper(); + + // find the Property with Handle nHandle in Style + Sequence< beans::Property > aProps( xInfo->getProperties() ); + sal_Int32 nI = aProps.getLength() - 1; + while( ( nI >= 0 ) && nHandle != aProps[ nI ].Handle ) + --nI; + + if( nI >= 0 ) // => nHandle == aProps[nI].Handle { - // for some reason the virtual method getInfoHelper() is - // not const - ::cppu::IPropertyArrayHelper & rPH = - const_cast< OPropertySet * >( this )->getInfoHelper(); - - // find the Property with Handle nHandle in Style - Sequence< beans::Property > aProps( xInfo->getProperties() ); - sal_Int32 nI = aProps.getLength() - 1; - while( ( nI >= 0 ) && nHandle != aProps[ nI ].Handle ) - --nI; - - if( nI >= 0 ) // => nHandle == aProps[nI].Handle - { - // check whether the handle in this property set is - // the same as the one in the style - beans::Property aProp( rPH.getPropertyByName( aProps[ nI ].Name ) ); - OSL_ENSURE( nHandle == aProp.Handle, - "HandleCheck: Handles for same property differ!" ); - - if( nHandle == aProp.Handle ) - { - OSL_ENSURE( aProp.Type == aProps[nI].Type, - "HandleCheck: Types differ!" ); - OSL_ENSURE( aProp.Attributes == aProps[nI].Attributes, - "HandleCheck: Attributes differ!" ); - } - } - else + // check whether the handle in this property set is + // the same as the one in the style + beans::Property aProp( rPH.getPropertyByName( aProps[ nI ].Name ) ); + OSL_ENSURE( nHandle == aProp.Handle, + "HandleCheck: Handles for same property differ!" ); + + if( nHandle == aProp.Handle ) { - OSL_FAIL( "HandleCheck: Handle not found in Style" ); + OSL_ENSURE( aProp.Type == aProps[nI].Type, + "HandleCheck: Types differ!" ); + OSL_ENSURE( aProp.Attributes == aProps[nI].Attributes, + "HandleCheck: Attributes differ!" ); } } else - OSL_FAIL( "HandleCheck: Invalid XPropertySetInfo returned" ); + { + OSL_FAIL( "HandleCheck: Handle not found in Style" ); + } } else - OSL_FAIL( "HandleCheck: XPropertySet not supported" ); + OSL_FAIL( "HandleCheck: Invalid XPropertySetInfo returned" ); } + else + OSL_FAIL( "HandleCheck: XPropertySet not supported" ); + } #endif - rValue = xStylePropSet->getFastPropertyValue( nHandle ); + rValue = xStylePropSet->getFastPropertyValue( nHandle ); + } + else + { + // there is no style (or the style does not support XFastPropertySet) + // => take the default value + try + { + rValue = GetDefaultValue( nHandle ); } - else + catch( const beans::UnknownPropertyException& ) { - // there is no style (or the style does not support XFastPropertySet) - // => take the default value - try - { - rValue = GetDefaultValue( nHandle ); - } - catch( const beans::UnknownPropertyException& ) - { - rValue.clear(); - } + rValue.clear(); } } } diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx index fe67460230a3..ea49fc64a07f 100644 --- a/chart2/source/tools/RangeHighlighter.cxx +++ b/chart2/source/tools/RangeHighlighter.cxx @@ -86,110 +86,110 @@ Sequence< chart2::data::HighlightedRange > SAL_CALL RangeHighlighter::getSelecte void RangeHighlighter::determineRanges() { m_aSelectedRanges.realloc( 0 ); - if( m_xSelectionSupplier.is()) + if( !m_xSelectionSupplier.is()) + return; + + try { - try - { - Reference< frame::XController > xController( m_xSelectionSupplier, uno::UNO_QUERY ); - Reference< frame::XModel > xChartModel; - if( xController.is()) - xChartModel.set( xController->getModel()); + Reference< frame::XController > xController( m_xSelectionSupplier, uno::UNO_QUERY ); + Reference< frame::XModel > xChartModel; + if( xController.is()) + xChartModel.set( xController->getModel()); - m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( xChartModel ); + m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( xChartModel ); - uno::Any aSelection( m_xSelectionSupplier->getSelection()); - const uno::Type& rType = aSelection.getValueType(); + uno::Any aSelection( m_xSelectionSupplier->getSelection()); + const uno::Type& rType = aSelection.getValueType(); - if ( rType == cppu::UnoType<OUString>::get() ) - { - // @todo??: maybe getSelection() should return a model object rather than a CID + if ( rType == cppu::UnoType<OUString>::get() ) + { + // @todo??: maybe getSelection() should return a model object rather than a CID - OUString aCID; - aSelection >>= aCID; - if ( !aCID.isEmpty() ) + OUString aCID; + aSelection >>= aCID; + if ( !aCID.isEmpty() ) + { + ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID ); + sal_Int32 nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aCID ); + Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, xChartModel ) ); + if( eObjectType == OBJECTTYPE_LEGEND_ENTRY ) { - ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID ); - sal_Int32 nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aCID ); - Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, xChartModel ) ); - if( eObjectType == OBJECTTYPE_LEGEND_ENTRY ) - { - OUString aParentParticel( ObjectIdentifier::getFullParentParticle( aCID ) ); - ObjectType eParentObjectType = ObjectIdentifier::getObjectType( aParentParticel ); - eObjectType = eParentObjectType; - if( eObjectType == OBJECTTYPE_DATA_POINT ) - nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aParentParticel ); - } + OUString aParentParticel( ObjectIdentifier::getFullParentParticle( aCID ) ); + ObjectType eParentObjectType = ObjectIdentifier::getObjectType( aParentParticel ); + eObjectType = eParentObjectType; + if( eObjectType == OBJECTTYPE_DATA_POINT ) + nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aParentParticel ); + } - if( eObjectType == OBJECTTYPE_DATA_POINT || eObjectType == OBJECTTYPE_DATA_LABEL ) - { - // Data Point - fillRangesForDataPoint( xDataSeries, nIndex ); - return; - } - else if( eObjectType == OBJECTTYPE_DATA_ERRORS_X || - eObjectType == OBJECTTYPE_DATA_ERRORS_Y || - eObjectType == OBJECTTYPE_DATA_ERRORS_Z ) + if( eObjectType == OBJECTTYPE_DATA_POINT || eObjectType == OBJECTTYPE_DATA_LABEL ) + { + // Data Point + fillRangesForDataPoint( xDataSeries, nIndex ); + return; + } + else if( eObjectType == OBJECTTYPE_DATA_ERRORS_X || + eObjectType == OBJECTTYPE_DATA_ERRORS_Y || + eObjectType == OBJECTTYPE_DATA_ERRORS_Z ) + { + // select error bar ranges, or data series, if the style is + // not set to FROM_DATA + fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), xDataSeries ); + return; + } + else if( xDataSeries.is() ) + { + // Data Series + fillRangesForDataSeries( xDataSeries ); + return; + } + else if( eObjectType == OBJECTTYPE_AXIS ) + { + // Axis (Categories) + Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), uno::UNO_QUERY ); + if( xAxis.is()) { - // select error bar ranges, or data series, if the style is - // not set to FROM_DATA - fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), xDataSeries ); + fillRangesForCategories( xAxis ); return; } - else if( xDataSeries.is() ) + } + else if( eObjectType == OBJECTTYPE_PAGE + || eObjectType == OBJECTTYPE_DIAGRAM + || eObjectType == OBJECTTYPE_DIAGRAM_WALL + || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR + ) + { + // Diagram + Reference< chart2::XDiagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, xChartModel ) ); + if( xDia.is()) { - // Data Series - fillRangesForDataSeries( xDataSeries ); + fillRangesForDiagram( xDia ); return; } - else if( eObjectType == OBJECTTYPE_AXIS ) - { - // Axis (Categories) - Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), uno::UNO_QUERY ); - if( xAxis.is()) - { - fillRangesForCategories( xAxis ); - return; - } - } - else if( eObjectType == OBJECTTYPE_PAGE - || eObjectType == OBJECTTYPE_DIAGRAM - || eObjectType == OBJECTTYPE_DIAGRAM_WALL - || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR - ) - { - // Diagram - Reference< chart2::XDiagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, xChartModel ) ); - if( xDia.is()) - { - fillRangesForDiagram( xDia ); - return; - } - } - } - } - else if ( rType == cppu::UnoType< drawing::XShape >::get() ) - { - // #i12587# support for shapes in chart - Reference< drawing::XShape > xShape; - aSelection >>= xShape; - if ( xShape.is() ) - { - return; } } - else + } + else if ( rType == cppu::UnoType< drawing::XShape >::get() ) + { + // #i12587# support for shapes in chart + Reference< drawing::XShape > xShape; + aSelection >>= xShape; + if ( xShape.is() ) { - //if nothing is selected select all ranges - Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY_THROW ); - fillRangesForDiagram( xChartDoc->getFirstDiagram() ); return; } } - catch( const uno::Exception & ) + else { - DBG_UNHANDLED_EXCEPTION("chart2"); + //if nothing is selected select all ranges + Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY_THROW ); + fillRangesForDiagram( xChartDoc->getFirstDiagram() ); + return; } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } void RangeHighlighter::fillRangesForDiagram( const Reference< chart2::XDiagram > & xDiagram ) @@ -264,37 +264,37 @@ void RangeHighlighter::fillRangesForCategories( const Reference< chart2::XAxis > void RangeHighlighter::fillRangesForDataPoint( const Reference< uno::XInterface > & xDataSeries, sal_Int32 nIndex ) { - if( xDataSeries.is()) + if( !xDataSeries.is()) + return; + + Reference< chart2::data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY ); + if( !xSource.is() ) + return; + + Color nPreferredColor = defaultPreferredColor; + std::vector< chart2::data::HighlightedRange > aHilightedRanges; + Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqSeq( xSource->getDataSequences()); + for( sal_Int32 i=0; i<aLSeqSeq.getLength(); ++i ) { - Reference< chart2::data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY ); - if( xSource.is() ) - { - Color nPreferredColor = defaultPreferredColor; - std::vector< chart2::data::HighlightedRange > aHilightedRanges; - Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqSeq( xSource->getDataSequences()); - for( sal_Int32 i=0; i<aLSeqSeq.getLength(); ++i ) - { - Reference< chart2::data::XDataSequence > xLabel( aLSeqSeq[i]->getLabel()); - Reference< chart2::data::XDataSequence > xValues( aLSeqSeq[i]->getValues()); - - if( xLabel.is()) - aHilightedRanges.emplace_back( - xLabel->getSourceRangeRepresentation(), - -1, - sal_Int32(nPreferredColor), - false ); - - sal_Int32 nUnhiddenIndex = DataSeriesHelper::translateIndexFromHiddenToFullSequence( nIndex, xValues, !m_bIncludeHiddenCells ); - if( xValues.is()) - aHilightedRanges.emplace_back( - xValues->getSourceRangeRepresentation(), - nUnhiddenIndex, - sal_Int32(nPreferredColor), - false ); - } - m_aSelectedRanges = comphelper::containerToSequence( aHilightedRanges ); - } + Reference< chart2::data::XDataSequence > xLabel( aLSeqSeq[i]->getLabel()); + Reference< chart2::data::XDataSequence > xValues( aLSeqSeq[i]->getValues()); + + if( xLabel.is()) + aHilightedRanges.emplace_back( + xLabel->getSourceRangeRepresentation(), + -1, + sal_Int32(nPreferredColor), + false ); + + sal_Int32 nUnhiddenIndex = DataSeriesHelper::translateIndexFromHiddenToFullSequence( nIndex, xValues, !m_bIncludeHiddenCells ); + if( xValues.is()) + aHilightedRanges.emplace_back( + xValues->getSourceRangeRepresentation(), + nUnhiddenIndex, + sal_Int32(nPreferredColor), + false ); } + m_aSelectedRanges = comphelper::containerToSequence( aHilightedRanges ); } void SAL_CALL RangeHighlighter::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& xListener ) diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 5d3d41a0a0f0..7e4a9dd17043 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -431,35 +431,35 @@ bool RegressionCurveHelper::removeAllExceptMeanValueLine( void RegressionCurveHelper::removeEquations( uno::Reference< chart2::XRegressionCurveContainer > const & xRegCnt ) { - if( xRegCnt.is()) + if( !xRegCnt.is()) + return; + + try { - try + uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( + xRegCnt->getRegressionCurves()); + for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) { - uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( - xRegCnt->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + if( !isMeanValueLine( aCurves[i] ) ) { - if( !isMeanValueLine( aCurves[i] ) ) + uno::Reference< chart2::XRegressionCurve > xRegCurve( aCurves[ i ] ); + if( xRegCurve.is() ) { - uno::Reference< chart2::XRegressionCurve > xRegCurve( aCurves[ i ] ); - if( xRegCurve.is() ) + uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties() ) ; + if( xEqProp.is()) { - uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties() ) ; - if( xEqProp.is()) - { - xEqProp->setPropertyValue( "ShowEquation", uno::Any( false )); - xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") )); - xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x) ") )); - xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( false )); - } + xEqProp->setPropertyValue( "ShowEquation", uno::Any( false )); + xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") )); + xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x) ") )); + xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( false )); } } } } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } @@ -707,19 +707,19 @@ std::vector< Reference< chart2::XRegressionCurve > > void RegressionCurveHelper::resetEquationPosition( const Reference< chart2::XRegressionCurve > & xCurve ) { - if( xCurve.is()) + if( !xCurve.is()) + return; + + try { - try - { - const OUString aPosPropertyName( "RelativePosition" ); - Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); // since m233: , uno::UNO_SET_THROW ); - if( xEqProp->getPropertyValue( aPosPropertyName ).hasValue()) - xEqProp->setPropertyValue( aPosPropertyName, uno::Any()); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2" ); - } + const OUString aPosPropertyName( "RelativePosition" ); + Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); // since m233: , uno::UNO_SET_THROW ); + if( xEqProp->getPropertyValue( aPosPropertyName ).hasValue()) + xEqProp->setPropertyValue( aPosPropertyName, uno::Any()); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2" ); } } diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx index b1c086599926..fd45dc44e257 100644 --- a/chart2/source/tools/ThreeDHelper.cxx +++ b/chart2/source/tools/ThreeDHelper.cxx @@ -69,23 +69,23 @@ void lcl_RotateLightSource( const Reference< beans::XPropertySet >& xSceneProper , const OUString& rLightSourceOn , const ::basegfx::B3DHomMatrix& rRotationMatrix ) { - if( xSceneProperties.is() ) + if( !xSceneProperties.is() ) + return; + + bool bLightOn = false; + if( !(xSceneProperties->getPropertyValue( rLightSourceOn ) >>= bLightOn) ) + return; + + if( bLightOn ) { - bool bLightOn = false; - if( xSceneProperties->getPropertyValue( rLightSourceOn ) >>= bLightOn ) + drawing::Direction3D aLight; + if( xSceneProperties->getPropertyValue( rLightSourceDirection ) >>= aLight ) { - if( bLightOn ) - { - drawing::Direction3D aLight; - if( xSceneProperties->getPropertyValue( rLightSourceDirection ) >>= aLight ) - { - ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aLight ) ); - aLightVector = rRotationMatrix*aLightVector; + ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aLight ) ); + aLightVector = rRotationMatrix*aLightVector; - xSceneProperties->setPropertyValue( rLightSourceDirection - , uno::Any( BaseGFXHelper::B3DVectorToDirection3D( aLightVector ) ) ); - } - } + xSceneProperties->setPropertyValue( rLightSourceDirection + , uno::Any( BaseGFXHelper::B3DVectorToDirection3D( aLightVector ) ) ); } } } diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 1adcfe64d652..10fc3ccd4f56 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -695,40 +695,40 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( if( nDayCount/nIntervalDayCount > nMaxMainIncrementCount ) bAutoMinor = true; } - if( bAutoMinor ) + if( !bAutoMinor ) + return; + + rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit; + rExplicitIncrement.MinorTimeInterval.Number = 1; + if( nMainIncrementCount > 100 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + else { - rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit; - rExplicitIncrement.MinorTimeInterval.Number = 1; - if( nMainIncrementCount > 100 ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + if( rExplicitIncrement.MajorTimeInterval.Number >= 2 ) + { + if( !(rExplicitIncrement.MajorTimeInterval.Number%2) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5; + else if( rExplicitIncrement.MajorTimeInterval.Number > 50 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + } else { - if( rExplicitIncrement.MajorTimeInterval.Number >= 2 ) + switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) { - if( !(rExplicitIncrement.MajorTimeInterval.Number%2) ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2; - else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3; - else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5; - else if( rExplicitIncrement.MajorTimeInterval.Number > 50 ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; - } - else - { - switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) - { - case DAY: - break; - case MONTH: - if( rExplicitScale.TimeResolution == DAY ) - rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; - break; - case YEAR: - if( rExplicitScale.TimeResolution <= MONTH ) - rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; - break; - } + case DAY: + break; + case MONTH: + if( rExplicitScale.TimeResolution == DAY ) + rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; + break; + case YEAR: + if( rExplicitScale.TimeResolution <= MONTH ) + rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; + break; } } } diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx index d678b58e56ad..60f6e63311ad 100644 --- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx @@ -105,23 +105,23 @@ EquidistantTickFactory::EquidistantTickFactory( m_fOuterMajorTickBorderMin_Scaled = m_fOuterMajorTickBorderMin; m_fOuterMajorTickBorderMax_Scaled = m_fOuterMajorTickBorderMax; - if(!m_rIncrement.PostEquidistant && m_xInverseScaling.is() ) + if(!(!m_rIncrement.PostEquidistant && m_xInverseScaling.is()) ) + return; + + m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); + m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); + + //check validity of new range: m_fOuterMajorTickBorderMin <-> m_fOuterMajorTickBorderMax + //it is assumed here, that the original range in the given Scale is valid + if( !std::isfinite(m_fOuterMajorTickBorderMin_Scaled) ) { + m_fOuterMajorTickBorderMin += m_rIncrement.Distance; m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); + } + if( !std::isfinite(m_fOuterMajorTickBorderMax_Scaled) ) + { + m_fOuterMajorTickBorderMax -= m_rIncrement.Distance; m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); - - //check validity of new range: m_fOuterMajorTickBorderMin <-> m_fOuterMajorTickBorderMax - //it is assumed here, that the original range in the given Scale is valid - if( !std::isfinite(m_fOuterMajorTickBorderMin_Scaled) ) - { - m_fOuterMajorTickBorderMin += m_rIncrement.Distance; - m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); - } - if( !std::isfinite(m_fOuterMajorTickBorderMax_Scaled) ) - { - m_fOuterMajorTickBorderMax -= m_rIncrement.Distance; - m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); - } } } diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index 16d951bdb5ad..164a9147cc4f 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -212,17 +212,17 @@ size_t VAxisBase::getIndexOfLongestLabel( const uno::Sequence<OUString>& rLabels void VAxisBase::removeTextShapesFromTicks() { - if( m_xTextTarget.is() ) + if( !m_xTextTarget.is() ) + return; + + for (auto & tickInfos : m_aAllTickInfos) { - for (auto & tickInfos : m_aAllTickInfos) + for (auto & tickInfo : tickInfos) { - for (auto & tickInfo : tickInfos) + if(tickInfo.xTextShape.is()) { - if(tickInfo.xTextShape.is()) - { - m_xTextTarget->remove(tickInfo.xTextShape); - tickInfo.xTextShape = nullptr; - } + m_xTextTarget->remove(tickInfo.xTextShape); + tickInfo.xTextShape = nullptr; } } } diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index d35bc04a0d24..27a4950a886b 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -349,38 +349,38 @@ void AxisLabelProperties::init( const uno::Reference< XAxis >& xAxisModel ) { uno::Reference< beans::XPropertySet > xProp = uno::Reference<beans::XPropertySet>::query( xAxisModel ); - if(xProp.is()) + if(!xProp.is()) + return; + + try { - try + xProp->getPropertyValue( "TextBreak" ) >>= bLineBreakAllowed; + xProp->getPropertyValue( "TextOverlap" ) >>= bOverlapAllowed; + xProp->getPropertyValue( "StackCharacters" ) >>= bStackCharacters; + xProp->getPropertyValue( "TextRotation" ) >>= fRotationAngleDegree; + + css::chart::ChartAxisArrangeOrderType eArrangeOrder; + xProp->getPropertyValue( "ArrangeOrder" ) >>= eArrangeOrder; + switch(eArrangeOrder) { - xProp->getPropertyValue( "TextBreak" ) >>= bLineBreakAllowed; - xProp->getPropertyValue( "TextOverlap" ) >>= bOverlapAllowed; - xProp->getPropertyValue( "StackCharacters" ) >>= bStackCharacters; - xProp->getPropertyValue( "TextRotation" ) >>= fRotationAngleDegree; - - css::chart::ChartAxisArrangeOrderType eArrangeOrder; - xProp->getPropertyValue( "ArrangeOrder" ) >>= eArrangeOrder; - switch(eArrangeOrder) - { - case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE: - eStaggering = AxisLabelStaggering::SideBySide; - break; - case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN: - eStaggering = AxisLabelStaggering::StaggerEven; - break; - case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD: - eStaggering = AxisLabelStaggering::StaggerOdd; - break; - default: - eStaggering = AxisLabelStaggering::StaggerAuto; - break; - } - } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); + case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE: + eStaggering = AxisLabelStaggering::SideBySide; + break; + case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN: + eStaggering = AxisLabelStaggering::StaggerEven; + break; + case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD: + eStaggering = AxisLabelStaggering::StaggerOdd; + break; + default: + eStaggering = AxisLabelStaggering::StaggerAuto; + break; } } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); + } } bool AxisLabelProperties::isStaggered() const diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index dbf360ad8ab0..d4183118cca5 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -105,18 +105,18 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( Reference< drawing::XShape > nNewLen = ( rLabel.getLength() >= sDots.getLength() ) ? sDots.getLength() : rLabel.getLength(); bool bCrop = nCharsToRemove > 0; - if( bCrop ) - { - OUString aNewLabel = rLabel.copy( 0, nNewLen ); - if( nNewLen > sDots.getLength() ) - aNewLabel += sDots; - xTextRange->setString( aNewLabel ); + if( !bCrop ) + return; - uno::Reference< beans::XPropertySet > xProp( xTextRange, uno::UNO_QUERY ); - if( xProp.is() ) - { - PropertyMapper::setMultiProperties( rPropNames, rPropValues, xProp ); - } + OUString aNewLabel = rLabel.copy( 0, nNewLen ); + if( nNewLen > sDots.getLength() ) + aNewLabel += sDots; + xTextRange->setString( aNewLabel ); + + uno::Reference< beans::XPropertySet > xProp( xTextRange, uno::UNO_QUERY ); + if( xProp.is() ) + { + PropertyMapper::setMultiProperties( rPropNames, rPropValues, xProp ); } } @@ -1448,65 +1448,65 @@ void VCartesianAxis::get2DAxisMainLine( if(m_nDimension==3 && !AxisHelper::isAxisPositioningEnabled() ) rAlignment.mfInnerTickDirection = rAlignment.mfLabelDirection;//to behave like before - if(m_nDimension==3 && AxisHelper::isAxisPositioningEnabled() ) - { - double fDeltaX = rEnd.getX() - rStart.getX(); - double fDeltaY = rEnd.getY() - rStart.getY(); - - if( m_nDimensionIndex==2 ) - { - if( m_eLeftWallPos != CuboidPlanePosition_Left ) - { - rAlignment.mfLabelDirection *= -1.0; - rAlignment.mfInnerTickDirection *= -1.0; - } + if(!(m_nDimension==3 && AxisHelper::isAxisPositioningEnabled()) ) + return; - rAlignment.meAlignment = - (rAlignment.mfLabelDirection < 0) ? - LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + double fDeltaX = rEnd.getX() - rStart.getX(); + double fDeltaY = rEnd.getY() - rStart.getY(); - if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || - ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) - rAlignment.meAlignment = - (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? - LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; - } - else if( fabs(fDeltaY) > fabs(fDeltaX) ) + if( m_nDimensionIndex==2 ) + { + if( m_eLeftWallPos != CuboidPlanePosition_Left ) { - if( m_eBackWallPos != CuboidPlanePosition_Back ) - { - rAlignment.mfLabelDirection *= -1.0; - rAlignment.mfInnerTickDirection *= -1.0; - } + rAlignment.mfLabelDirection *= -1.0; + rAlignment.mfInnerTickDirection *= -1.0; + } + rAlignment.meAlignment = + (rAlignment.mfLabelDirection < 0) ? + LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + + if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || + ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) rAlignment.meAlignment = - (rAlignment.mfLabelDirection < 0) ? + (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; - - if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || - ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) - rAlignment.meAlignment = - (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? - LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; - } - else + } + else if( fabs(fDeltaY) > fabs(fDeltaX) ) + { + if( m_eBackWallPos != CuboidPlanePosition_Back ) { - if( m_eBackWallPos != CuboidPlanePosition_Back ) - { - rAlignment.mfLabelDirection *= -1.0; - rAlignment.mfInnerTickDirection *= -1.0; - } + rAlignment.mfLabelDirection *= -1.0; + rAlignment.mfInnerTickDirection *= -1.0; + } + rAlignment.meAlignment = + (rAlignment.mfLabelDirection < 0) ? + LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + + if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || + ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) rAlignment.meAlignment = - (rAlignment.mfLabelDirection < 0) ? - LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM; - - if( ( fDeltaX>0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || - ( fDeltaX<0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) - rAlignment.meAlignment = - (rAlignment.meAlignment == LABEL_ALIGN_TOP) ? - LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP; + (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? + LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + } + else + { + if( m_eBackWallPos != CuboidPlanePosition_Back ) + { + rAlignment.mfLabelDirection *= -1.0; + rAlignment.mfInnerTickDirection *= -1.0; } + + rAlignment.meAlignment = + (rAlignment.mfLabelDirection < 0) ? + LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM; + + if( ( fDeltaX>0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || + ( fDeltaX<0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) + rAlignment.meAlignment = + (rAlignment.meAlignment == LABEL_ALIGN_TOP) ? + LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP; } } diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index cc2427a87581..f9b7399694b0 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -160,26 +160,26 @@ void VPolarAngleAxis::createLabels() double fLogicRadius = m_pPosHelper->getOuterLogicRadius(); - if( m_aAxisProperties.m_bDisplayLabels ) - { - //create tick mark text shapes - //@todo: iterate through all tick depth which should be labeled + if( !m_aAxisProperties.m_bDisplayLabels ) + return; - EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0 ); - updateUnscaledValuesAtTicks( aTickIter ); + //create tick mark text shapes + //@todo: iterate through all tick depth which should be labeled - removeTextShapesFromTicks(); + EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0 ); + updateUnscaledValuesAtTicks( aTickIter ); - AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties ); - aAxisLabelProperties.bOverlapAllowed = true; - double const fLogicZ = 1.0;//as defined - createTextShapes_ForAngleAxis( m_xTextTarget, aTickIter - , aAxisLabelProperties - , fLogicRadius, fLogicZ - ); + removeTextShapesFromTicks(); - //no staggering for polar angle axis - } + AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties ); + aAxisLabelProperties.bOverlapAllowed = true; + double const fLogicZ = 1.0;//as defined + createTextShapes_ForAngleAxis( m_xTextTarget, aTickIter + , aAxisLabelProperties + , fLogicRadius, fLogicZ + ); + + //no staggering for polar angle axis } void VPolarAngleAxis::createShapes() diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 88e8f6e4b502..3641e67b4657 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -415,27 +415,27 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis() //thus the different series use the same settings VDataSeries* pFirstSeries = getFirstSeries(); - if(pFirstSeries && !pFirstSeries->getGroupBarsPerAxis() ) + if(!(pFirstSeries && !pFirstSeries->getGroupBarsPerAxis()) ) + return; + + sal_Int32 nAxisIndex = pFirstSeries->getAttachedAxisIndex(); + sal_Int32 nN = 0; + sal_Int32 nUseThisIndex = nAxisIndex; + if( nUseThisIndex < 0 || nUseThisIndex >= m_aOverlapSequence.getLength() ) + nUseThisIndex = 0; + for( nN = 0; nN < m_aOverlapSequence.getLength(); nN++ ) { - sal_Int32 nAxisIndex = pFirstSeries->getAttachedAxisIndex(); - sal_Int32 nN = 0; - sal_Int32 nUseThisIndex = nAxisIndex; - if( nUseThisIndex < 0 || nUseThisIndex >= m_aOverlapSequence.getLength() ) - nUseThisIndex = 0; - for( nN = 0; nN < m_aOverlapSequence.getLength(); nN++ ) - { - if(nN!=nUseThisIndex) - m_aOverlapSequence[nN] = m_aOverlapSequence[nUseThisIndex]; - } + if(nN!=nUseThisIndex) + m_aOverlapSequence[nN] = m_aOverlapSequence[nUseThisIndex]; + } - nUseThisIndex = nAxisIndex; - if( nUseThisIndex < 0 || nUseThisIndex >= m_aGapwidthSequence.getLength() ) - nUseThisIndex = 0; - for( nN = 0; nN < m_aGapwidthSequence.getLength(); nN++ ) - { - if(nN!=nUseThisIndex) - m_aGapwidthSequence[nN] = m_aGapwidthSequence[nUseThisIndex]; - } + nUseThisIndex = nAxisIndex; + if( nUseThisIndex < 0 || nUseThisIndex >= m_aGapwidthSequence.getLength() ) + nUseThisIndex = 0; + for( nN = 0; nN < m_aGapwidthSequence.getLength(); nN++ ) + { + if(nN!=nUseThisIndex) + m_aGapwidthSequence[nN] = m_aGapwidthSequence[nUseThisIndex]; } } diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 0214d0f6a0eb..0e3829c00ab2 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -182,7 +182,10 @@ PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel m_pPosHelper->m_fRingDistance = 0.0; uno::Reference< beans::XPropertySet > xChartTypeProps( xChartTypeModel, uno::UNO_QUERY ); - if( xChartTypeProps.is() ) try + if( !xChartTypeProps.is() ) + return; + + try { xChartTypeProps->getPropertyValue( "UseRings") >>= m_bUseRings; if( m_bUseRings ) @@ -1573,21 +1576,21 @@ void PieChart::performLabelBestFit(ShapeParam& rShapeParam, PieLabelInfo const & if( m_bUseRings ) return; - if( !performLabelBestFitInnerPlacement(rShapeParam, rPieLabelInfo) ) - { - // If it does not fit inside, let's put it outside - PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper.get(),m_nDimension,m_xLogicTarget,m_pShapeFactory); - auto eAlignment = LABEL_ALIGN_CENTER; - awt::Point aScreenPosition2D( - aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, css::chart::DataLabelPlacement::OUTSIDE - , rShapeParam.mfUnitCircleStartAngleDegree, rShapeParam.mfUnitCircleWidthAngleDegree - , rShapeParam.mfUnitCircleInnerRadius, rShapeParam.mfUnitCircleOuterRadius, rShapeParam.mfLogicZ+0.5, 0 )); - basegfx::B2IVector aTranslationVector = rPieLabelInfo.aFirstPosition - rPieLabelInfo.aOrigin; - aTranslationVector.setLength(150); - aScreenPosition2D.X += aTranslationVector.getX(); - aScreenPosition2D.Y += aTranslationVector.getY(); - rPieLabelInfo.xLabelGroupShape->setPosition(aScreenPosition2D); - } + if( performLabelBestFitInnerPlacement(rShapeParam, rPieLabelInfo) ) + return; + + // If it does not fit inside, let's put it outside + PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper.get(),m_nDimension,m_xLogicTarget,m_pShapeFactory); + auto eAlignment = LABEL_ALIGN_CENTER; + awt::Point aScreenPosition2D( + aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, css::chart::DataLabelPlacement::OUTSIDE + , rShapeParam.mfUnitCircleStartAngleDegree, rShapeParam.mfUnitCircleWidthAngleDegree + , rShapeParam.mfUnitCircleInnerRadius, rShapeParam.mfUnitCircleOuterRadius, rShapeParam.mfLogicZ+0.5, 0 )); + basegfx::B2IVector aTranslationVector = rPieLabelInfo.aFirstPosition - rPieLabelInfo.aOrigin; + aTranslationVector.setLength(150); + aScreenPosition2D.X += aTranslationVector.getX(); + aScreenPosition2D.Y += aTranslationVector.getY(); + rPieLabelInfo.xLabelGroupShape->setPosition(aScreenPosition2D); } } //namespace chart diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 492dcc8a00da..0696efc9dcbb 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1504,129 +1504,129 @@ void VSeriesPlotter::createRegressionCurveEquationShapes( bool bShowEquation = false; bool bShowCorrCoeff = false; - if(( xEquationProperties->getPropertyValue( "ShowEquation") >>= bShowEquation ) && - ( xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient") >>= bShowCorrCoeff )) - { - if( ! (bShowEquation || bShowCorrCoeff)) - return; + if(!(( xEquationProperties->getPropertyValue( "ShowEquation") >>= bShowEquation ) && + ( xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient") >>= bShowCorrCoeff ))) + return; - OUStringBuffer aFormula; - sal_Int32 nNumberFormatKey = 0; - sal_Int32 nFormulaWidth = 0; - xEquationProperties->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey; - bool bResizeEquation = true; - sal_Int32 nMaxIteration = 2; - if ( bShowEquation ) - { - OUString aXName, aYName; - if ( !(xEquationProperties->getPropertyValue( "XName" ) >>= aXName) ) - aXName = OUString( "x" ); - if ( !(xEquationProperties->getPropertyValue( "YName" ) >>= aYName) ) - aYName = OUString( "f(x)" ); - xRegressionCurveCalculator->setXYNames( aXName, aYName ); - } + if( ! (bShowEquation || bShowCorrCoeff)) + return; - for ( sal_Int32 nCountIteration = 0; bResizeEquation && nCountIteration < nMaxIteration ; nCountIteration++ ) - { - bResizeEquation = false; - if( bShowEquation ) + OUStringBuffer aFormula; + sal_Int32 nNumberFormatKey = 0; + sal_Int32 nFormulaWidth = 0; + xEquationProperties->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey; + bool bResizeEquation = true; + sal_Int32 nMaxIteration = 2; + if ( bShowEquation ) + { + OUString aXName, aYName; + if ( !(xEquationProperties->getPropertyValue( "XName" ) >>= aXName) ) + aXName = OUString( "x" ); + if ( !(xEquationProperties->getPropertyValue( "YName" ) >>= aYName) ) + aYName = OUString( "f(x)" ); + xRegressionCurveCalculator->setXYNames( aXName, aYName ); + } + + for ( sal_Int32 nCountIteration = 0; bResizeEquation && nCountIteration < nMaxIteration ; nCountIteration++ ) + { + bResizeEquation = false; + if( bShowEquation ) + { + if (m_apNumberFormatterWrapper) + { // iteration 0: default representation (no wrap) + // iteration 1: expected width (nFormulaWidth) is calculated + aFormula = xRegressionCurveCalculator->getFormattedRepresentation( + m_apNumberFormatterWrapper->getNumberFormatsSupplier(), + nNumberFormatKey, nFormulaWidth ); + nFormulaWidth = lcl_getOUStringMaxLineLength( aFormula ); + } + else { - if (m_apNumberFormatterWrapper) - { // iteration 0: default representation (no wrap) - // iteration 1: expected width (nFormulaWidth) is calculated - aFormula = xRegressionCurveCalculator->getFormattedRepresentation( - m_apNumberFormatterWrapper->getNumberFormatsSupplier(), - nNumberFormatKey, nFormulaWidth ); - nFormulaWidth = lcl_getOUStringMaxLineLength( aFormula ); - } - else - { - aFormula = xRegressionCurveCalculator->getRepresentation(); - } - - if( bShowCorrCoeff ) - { - aFormula.append( "\n" ); - } + aFormula = xRegressionCurveCalculator->getRepresentation(); } + if( bShowCorrCoeff ) { - aFormula.append( "R" ).append( OUStringChar( aSuperscriptFigures[2] ) ).append( " = " ); - double fR( xRegressionCurveCalculator->getCorrelationCoefficient()); - if (m_apNumberFormatterWrapper) - { - Color nLabelCol; - bool bColChanged; - aFormula.append( - m_apNumberFormatterWrapper->getFormattedString( - nNumberFormatKey, fR*fR, nLabelCol, bColChanged )); - //@todo: change color of label if bColChanged is true - } - else - { - const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); - const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); - sal_Unicode aDecimalSep = aNumDecimalSep[0]; - aFormula.append( ::rtl::math::doubleToUString( - fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true )); - } + aFormula.append( "\n" ); } - - awt::Point aScreenPosition2D; - chart2::RelativePosition aRelativePosition; - if( xEquationProperties->getPropertyValue( "RelativePosition") >>= aRelativePosition ) + } + if( bShowCorrCoeff ) + { + aFormula.append( "R" ).append( OUStringChar( aSuperscriptFigures[2] ) ).append( " = " ); + double fR( xRegressionCurveCalculator->getCorrelationCoefficient()); + if (m_apNumberFormatterWrapper) { - //@todo decide whether x is primary or secondary - double fX = aRelativePosition.Primary*m_aPageReferenceSize.Width; - double fY = aRelativePosition.Secondary*m_aPageReferenceSize.Height; - aScreenPosition2D.X = static_cast< sal_Int32 >( ::rtl::math::round( fX )); - aScreenPosition2D.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY )); + Color nLabelCol; + bool bColChanged; + aFormula.append( + m_apNumberFormatterWrapper->getFormattedString( + nNumberFormatKey, fR*fR, nLabelCol, bColChanged )); + //@todo: change color of label if bColChanged is true } else - aScreenPosition2D = aDefaultPos; - - if( !aFormula.isEmpty()) { - // set fill and line properties on creation - tNameSequence aNames; - tAnySequence aValues; - PropertyMapper::getPreparedTextShapePropertyLists( xEquationProperties, aNames, aValues ); + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); + sal_Unicode aDecimalSep = aNumDecimalSep[0]; + aFormula.append( ::rtl::math::doubleToUString( + fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + } + } - uno::Reference< drawing::XShape > xTextShape = m_pShapeFactory->createText( - xEquationTarget, aFormula.makeStringAndClear(), - aNames, aValues, ShapeFactory::makeTransformation( aScreenPosition2D )); + awt::Point aScreenPosition2D; + chart2::RelativePosition aRelativePosition; + if( xEquationProperties->getPropertyValue( "RelativePosition") >>= aRelativePosition ) + { + //@todo decide whether x is primary or secondary + double fX = aRelativePosition.Primary*m_aPageReferenceSize.Width; + double fY = aRelativePosition.Secondary*m_aPageReferenceSize.Height; + aScreenPosition2D.X = static_cast< sal_Int32 >( ::rtl::math::round( fX )); + aScreenPosition2D.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY )); + } + else + aScreenPosition2D = aDefaultPos; + + if( !aFormula.isEmpty()) + { + // set fill and line properties on creation + tNameSequence aNames; + tAnySequence aValues; + PropertyMapper::getPreparedTextShapePropertyLists( xEquationProperties, aNames, aValues ); - OSL_ASSERT( xTextShape.is()); - if( xTextShape.is()) + uno::Reference< drawing::XShape > xTextShape = m_pShapeFactory->createText( + xEquationTarget, aFormula.makeStringAndClear(), + aNames, aValues, ShapeFactory::makeTransformation( aScreenPosition2D )); + + OSL_ASSERT( xTextShape.is()); + if( xTextShape.is()) + { + ShapeFactory::setShapeName( xTextShape, rEquationCID ); + awt::Size aSize( xTextShape->getSize() ); + awt::Point aPos( RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( + aScreenPosition2D, aSize, aRelativePosition.Anchor ) ); + //ensure that the equation is fully placed within the page (if possible) + if( (aPos.X + aSize.Width) > m_aPageReferenceSize.Width ) + aPos.X = m_aPageReferenceSize.Width - aSize.Width; + if( aPos.X < 0 ) { - ShapeFactory::setShapeName( xTextShape, rEquationCID ); - awt::Size aSize( xTextShape->getSize() ); - awt::Point aPos( RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( - aScreenPosition2D, aSize, aRelativePosition.Anchor ) ); - //ensure that the equation is fully placed within the page (if possible) - if( (aPos.X + aSize.Width) > m_aPageReferenceSize.Width ) - aPos.X = m_aPageReferenceSize.Width - aSize.Width; - if( aPos.X < 0 ) + aPos.X = 0; + if ( nFormulaWidth > 0 ) { - aPos.X = 0; - if ( nFormulaWidth > 0 ) - { - bResizeEquation = true; - if ( nCountIteration < nMaxIteration-1 ) - xEquationTarget->remove( xTextShape ); // remove equation - nFormulaWidth *= m_aPageReferenceSize.Width / static_cast< double >(aSize.Width); - nFormulaWidth -= nCountIteration; - if ( nFormulaWidth < 0 ) - nFormulaWidth = 0; - } + bResizeEquation = true; + if ( nCountIteration < nMaxIteration-1 ) + xEquationTarget->remove( xTextShape ); // remove equation + nFormulaWidth *= m_aPageReferenceSize.Width / static_cast< double >(aSize.Width); + nFormulaWidth -= nCountIteration; + if ( nFormulaWidth < 0 ) + nFormulaWidth = 0; } - if( (aPos.Y + aSize.Height) > m_aPageReferenceSize.Height ) - aPos.Y = m_aPageReferenceSize.Height - aSize.Height; - if( aPos.Y < 0 ) - aPos.Y = 0; - if ( !bResizeEquation || nCountIteration == nMaxIteration-1 ) - xTextShape->setPosition(aPos); // if equation was not removed } + if( (aPos.Y + aSize.Height) > m_aPageReferenceSize.Height ) + aPos.Y = m_aPageReferenceSize.Height - aSize.Height; + if( aPos.Y < 0 ) + aPos.Y = 0; + if ( !bResizeEquation || nCountIteration == nMaxIteration-1 ) + xTextShape->setPosition(aPos); // if equation was not removed } } } diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index a1fc30442898..bf9b9b70d343 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -53,20 +53,20 @@ VDiagram::VDiagram( , m_fZAnglePi(0) , m_bRightAngledAxes(false) { - if( m_nDimensionCount == 3) + if( m_nDimensionCount != 3) + return; + + uno::Reference< beans::XPropertySet > xSourceProp( m_xDiagram, uno::UNO_QUERY ); + ThreeDHelper::getRotationAngleFromDiagram( xSourceProp, m_fXAnglePi, m_fYAnglePi, m_fZAnglePi ); + if( ChartTypeHelper::isSupportingRightAngledAxes( + DiagramHelper::getChartTypeByIndex( m_xDiagram, 0 ) ) ) { - uno::Reference< beans::XPropertySet > xSourceProp( m_xDiagram, uno::UNO_QUERY ); - ThreeDHelper::getRotationAngleFromDiagram( xSourceProp, m_fXAnglePi, m_fYAnglePi, m_fZAnglePi ); - if( ChartTypeHelper::isSupportingRightAngledAxes( - DiagramHelper::getChartTypeByIndex( m_xDiagram, 0 ) ) ) + if(xSourceProp.is()) + xSourceProp->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes; + if( m_bRightAngledAxes ) { - if(xSourceProp.is()) - xSourceProp->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes; - if( m_bRightAngledAxes ) - { - ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fXAnglePi, m_fYAnglePi ); - m_fZAnglePi=0.0; - } + ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fXAnglePi, m_fYAnglePi ); + m_fZAnglePi=0.0; } } } @@ -290,150 +290,150 @@ void lcl_ensureScaleValue( double& rfScale ) void VDiagram::adjustAspectRatio3d( const awt::Size& rAvailableSize ) { OSL_PRECOND(m_xAspectRatio3D.is(), "created shape offers no XPropertySet"); - if( m_xAspectRatio3D.is()) + if( !m_xAspectRatio3D.is()) + return; + + try { - try + double fScaleX = m_aPreferredAspectRatio.DirectionX; + double fScaleY = m_aPreferredAspectRatio.DirectionY; + double fScaleZ = m_aPreferredAspectRatio.DirectionZ; + + //normalize scale factors { - double fScaleX = m_aPreferredAspectRatio.DirectionX; - double fScaleY = m_aPreferredAspectRatio.DirectionY; - double fScaleZ = m_aPreferredAspectRatio.DirectionZ; + double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); + fScaleX/=fMax; + fScaleY/=fMax; + fScaleZ/=fMax; + } - //normalize scale factors - { - double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); - fScaleX/=fMax; - fScaleY/=fMax; - fScaleZ/=fMax; - } + if( fScaleX<0 || fScaleY<0 || fScaleZ<0 ) + { + //calculate automatic 3D aspect ratio that fits good into the given 2D area + double fW = rAvailableSize.Width; + double fH = rAvailableSize.Height; - if( fScaleX<0 || fScaleY<0 || fScaleZ<0 ) - { - //calculate automatic 3D aspect ratio that fits good into the given 2D area - double fW = rAvailableSize.Width; - double fH = rAvailableSize.Height; + double sx = fabs(sin(m_fXAnglePi)); + double sy = fabs(sin(m_fYAnglePi)); + double cz = fabs(cos(m_fZAnglePi)); + double sz = fabs(sin(m_fZAnglePi)); - double sx = fabs(sin(m_fXAnglePi)); - double sy = fabs(sin(m_fYAnglePi)); - double cz = fabs(cos(m_fZAnglePi)); - double sz = fabs(sin(m_fZAnglePi)); + if(m_bRightAngledAxes) + { + //base equations: + //fH*zoomfactor == sx*fScaleZ + fScaleY; + //fW*zoomfactor == sy*fScaleZ + fScaleX; - if(m_bRightAngledAxes) + if( fScaleX>0 && fScaleZ>0 ) { - //base equations: - //fH*zoomfactor == sx*fScaleZ + fScaleY; - //fW*zoomfactor == sy*fScaleZ + fScaleX; - - if( fScaleX>0 && fScaleZ>0 ) - { - //calculate fScaleY: - if( !::basegfx::fTools::equalZero(fW) ) - { - fScaleY = (fH/fW)*(sy*fScaleZ+fScaleX)-(sx*fScaleZ); - lcl_ensureScaleValue( fScaleY ); - } - else - fScaleY = 1.0;//looking from top or bottom the height is irrelevant - } - else if( fScaleY>0 && fScaleZ>0 ) + //calculate fScaleY: + if( !::basegfx::fTools::equalZero(fW) ) { - //calculate fScaleX: - if( !::basegfx::fTools::equalZero(fH) ) - { - fScaleX = (fW/fH)*(sx*fScaleZ+fScaleY)-(sy*fScaleZ); - lcl_ensureScaleValue(fScaleX); - } - else - fScaleX = 1.0;//looking from top or bottom height is irrelevant + fScaleY = (fH/fW)*(sy*fScaleZ+fScaleX)-(sx*fScaleZ); + lcl_ensureScaleValue( fScaleY ); } else + fScaleY = 1.0;//looking from top or bottom the height is irrelevant + } + else if( fScaleY>0 && fScaleZ>0 ) + { + //calculate fScaleX: + if( !::basegfx::fTools::equalZero(fH) ) { - //todo - OSL_FAIL("not implemented yet"); - - if( fScaleX<0 ) - fScaleX = 1.0; - if( fScaleY<0 ) - fScaleY = 1.0; - if( fScaleZ<0 ) - fScaleZ = 1.0; + fScaleX = (fW/fH)*(sx*fScaleZ+fScaleY)-(sy*fScaleZ); + lcl_ensureScaleValue(fScaleX); } + else + fScaleX = 1.0;//looking from top or bottom height is irrelevant } else { - //base equations: - //fH*zoomfactor == cz*fScaleY + sz*fScaleX; - //fW*zoomfactor == cz*fScaleX + sz*fScaleY; - //==> fScaleY*(fH*sz-fW*cz) == fScaleX*(fW*sz-fH*cz); - if( fScaleX>0 && fScaleZ>0 ) - { - //calculate fScaleY: - double fDivide = fH*sz-fW*cz; - if( !::basegfx::fTools::equalZero(fDivide) ) - { - fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide; - lcl_ensureScaleValue(fScaleY); - } - else - fScaleY = 1.0;//looking from top or bottom the height is irrelevant - - } - else if( fScaleY>0 && fScaleZ>0 ) + //todo + OSL_FAIL("not implemented yet"); + + if( fScaleX<0 ) + fScaleX = 1.0; + if( fScaleY<0 ) + fScaleY = 1.0; + if( fScaleZ<0 ) + fScaleZ = 1.0; + } + } + else + { + //base equations: + //fH*zoomfactor == cz*fScaleY + sz*fScaleX; + //fW*zoomfactor == cz*fScaleX + sz*fScaleY; + //==> fScaleY*(fH*sz-fW*cz) == fScaleX*(fW*sz-fH*cz); + if( fScaleX>0 && fScaleZ>0 ) + { + //calculate fScaleY: + double fDivide = fH*sz-fW*cz; + if( !::basegfx::fTools::equalZero(fDivide) ) { - //calculate fScaleX: - double fDivide = fW*sz-fH*cz; - if( !::basegfx::fTools::equalZero(fDivide) ) - { - fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide; - lcl_ensureScaleValue(fScaleX); - } - else - fScaleX = 1.0;//looking from top or bottom height is irrelevant + fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide; + lcl_ensureScaleValue(fScaleY); } else + fScaleY = 1.0;//looking from top or bottom the height is irrelevant + + } + else if( fScaleY>0 && fScaleZ>0 ) + { + //calculate fScaleX: + double fDivide = fW*sz-fH*cz; + if( !::basegfx::fTools::equalZero(fDivide) ) { - //todo - OSL_FAIL("not implemented yet"); - - if( fScaleX<0 ) - fScaleX = 1.0; - if( fScaleY<0 ) - fScaleY = 1.0; - if( fScaleZ<0 ) - fScaleZ = 1.0; + fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide; + lcl_ensureScaleValue(fScaleX); } + else + fScaleX = 1.0;//looking from top or bottom height is irrelevant + } + else + { + //todo + OSL_FAIL("not implemented yet"); + + if( fScaleX<0 ) + fScaleX = 1.0; + if( fScaleY<0 ) + fScaleY = 1.0; + if( fScaleZ<0 ) + fScaleZ = 1.0; } } - - //normalize scale factors - { - double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); - fScaleX/=fMax; - fScaleY/=fMax; - fScaleZ/=fMax; - } - - // identity matrix - ::basegfx::B3DHomMatrix aResult; - aResult.translate( -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); - aResult.scale( fScaleX, fScaleY, fScaleZ ); - aResult.translate( FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); - - // To get the 3D aspect ratio's effect on the 2D scene size, the scene's 2D size needs to be adapted to - // 3D content changes here. The tooling class remembers the current 3D transformation stack - // and in its destructor, calculates a new 2D SnapRect for the scene and it's modified 3D geometry. - E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); - - m_xAspectRatio3D->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX - , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aResult )) ); } - catch( const uno::Exception& ) + + //normalize scale factors { - TOOLS_WARN_EXCEPTION("chart2", "" ); + double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); + fScaleX/=fMax; + fScaleY/=fMax; + fScaleZ/=fMax; } + + // identity matrix + ::basegfx::B3DHomMatrix aResult; + aResult.translate( -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); + aResult.scale( fScaleX, fScaleY, fScaleZ ); + aResult.translate( FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); + + // To get the 3D aspect ratio's effect on the 2D scene size, the scene's 2D size needs to be adapted to + // 3D content changes here. The tooling class remembers the current 3D transformation stack + // and in its destructor, calculates a new 2D SnapRect for the scene and it's modified 3D geometry. + E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); + + m_xAspectRatio3D->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX + , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aResult )) ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } } @@ -669,20 +669,20 @@ basegfx::B2IRectangle VDiagram::getCurrentRectangle() const void VDiagram::reduceToMimimumSize() { - if( m_xOuterGroupShape.is() ) - { - awt::Size aMaxSize( m_aAvailableSizeIncludingAxes ); - awt::Point aMaxPos( m_aAvailablePosIncludingAxes ); + if( !m_xOuterGroupShape.is() ) + return; - sal_Int32 nNewWidth = aMaxSize.Width/3; - sal_Int32 nNewHeight = aMaxSize.Height/3; - awt::Size aNewSize( nNewWidth, nNewHeight ); - awt::Point aNewPos( aMaxPos ); - aNewPos.X += nNewWidth; - aNewPos.Y += nNewHeight; + awt::Size aMaxSize( m_aAvailableSizeIncludingAxes ); + awt::Point aMaxPos( m_aAvailablePosIncludingAxes ); - adjustPosAndSize( aNewPos, aNewSize ); - } + sal_Int32 nNewWidth = aMaxSize.Width/3; + sal_Int32 nNewHeight = aMaxSize.Height/3; + awt::Size aNewSize( nNewWidth, nNewHeight ); + awt::Point aNewPos( aMaxPos ); + aNewPos.X += nNewWidth; + aNewPos.Y += nNewHeight; + + adjustPosAndSize( aNewPos, aNewSize ); } ::basegfx::B2IRectangle VDiagram::adjustInnerSize( const ::basegfx::B2IRectangle& rConsumedOuterRect ) diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 547295155b12..c9fa8ebd4d30 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -605,21 +605,21 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } //transport seriesnames to the coordinatesystems if needed - if( !m_aSeriesPlotterList.empty() ) + if( m_aSeriesPlotterList.empty() ) + return; + + uno::Sequence< OUString > aSeriesNames; + bool bSeriesNamesInitialized = false; + for(auto & pVCooSys : m_rVCooSysList) { - uno::Sequence< OUString > aSeriesNames; - bool bSeriesNamesInitialized = false; - for(auto & pVCooSys : m_rVCooSysList) + if( pVCooSys->needSeriesNamesForAxis() ) { - if( pVCooSys->needSeriesNamesForAxis() ) + if(!bSeriesNamesInitialized) { - if(!bSeriesNamesInitialized) - { - aSeriesNames = m_aSeriesPlotterList[0]->getSeriesNames(); - bSeriesNamesInitialized = true; - } - pVCooSys->setSeriesNamesForAxis( aSeriesNames ); + aSeriesNames = m_aSeriesPlotterList[0]->getSeriesNames(); + bSeriesNamesInitialized = true; } + pVCooSys->setSeriesNamesForAxis( aSeriesNames ); } } } @@ -914,45 +914,45 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& } } - if( AxisHelper::isAxisPositioningEnabled() ) + if( !AxisHelper::isAxisPositioningEnabled() ) + return; + + //correct origin for y main axis (the origin is where the other main axis crosses) + sal_Int32 nAxisIndex=0; + sal_Int32 nDimensionIndex=1; + for (auto & axisUsage : m_aAxisUsageList) { - //correct origin for y main axis (the origin is where the other main axis crosses) - sal_Int32 nAxisIndex=0; - sal_Int32 nDimensionIndex=1; - for (auto & axisUsage : m_aAxisUsageList) + AxisUsage& rAxisUsage = axisUsage.second; + std::vector< VCoordinateSystem* > aVCooSysList = rAxisUsage.getCoordinateSystems(nDimensionIndex,nAxisIndex); + size_t nC; + for( nC=0; nC < aVCooSysList.size(); nC++) { - AxisUsage& rAxisUsage = axisUsage.second; - std::vector< VCoordinateSystem* > aVCooSysList = rAxisUsage.getCoordinateSystems(nDimensionIndex,nAxisIndex); - size_t nC; - for( nC=0; nC < aVCooSysList.size(); nC++) - { - ExplicitScaleData aExplicitScale( aVCooSysList[nC]->getExplicitScale( nDimensionIndex, nAxisIndex ) ); - ExplicitIncrementData aExplicitIncrement( aVCooSysList[nC]->getExplicitIncrement( nDimensionIndex, nAxisIndex ) ); + ExplicitScaleData aExplicitScale( aVCooSysList[nC]->getExplicitScale( nDimensionIndex, nAxisIndex ) ); + ExplicitIncrementData aExplicitIncrement( aVCooSysList[nC]->getExplicitIncrement( nDimensionIndex, nAxisIndex ) ); - Reference< chart2::XCoordinateSystem > xCooSys( aVCooSysList[nC]->getModel() ); - Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) ); - Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ), uno::UNO_QUERY ); + Reference< chart2::XCoordinateSystem > xCooSys( aVCooSysList[nC]->getModel() ); + Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) ); + Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ), uno::UNO_QUERY ); - css::chart::ChartAxisPosition eCrossingMainAxisPos( css::chart::ChartAxisPosition_ZERO ); - if( xCrossingMainAxis.is() ) + css::chart::ChartAxisPosition eCrossingMainAxisPos( css::chart::ChartAxisPosition_ZERO ); + if( xCrossingMainAxis.is() ) + { + xCrossingMainAxis->getPropertyValue("CrossoverPosition") >>= eCrossingMainAxisPos; + if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_VALUE ) { - xCrossingMainAxis->getPropertyValue("CrossoverPosition") >>= eCrossingMainAxisPos; - if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_VALUE ) - { - double fValue = 0.0; - xCrossingMainAxis->getPropertyValue("CrossoverValue") >>= fValue; - aExplicitScale.Origin = fValue; - } - else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_ZERO ) - aExplicitScale.Origin = 0.0; - else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_START ) - aExplicitScale.Origin = aExplicitScale.Minimum; - else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_END ) - aExplicitScale.Origin = aExplicitScale.Maximum; + double fValue = 0.0; + xCrossingMainAxis->getPropertyValue("CrossoverValue") >>= fValue; + aExplicitScale.Origin = fValue; } - - aVCooSysList[nC]->setExplicitScaleAndIncrement( nDimensionIndex, nAxisIndex, aExplicitScale, aExplicitIncrement ); + else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_ZERO ) + aExplicitScale.Origin = 0.0; + else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_START ) + aExplicitScale.Origin = aExplicitScale.Minimum; + else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_END ) + aExplicitScale.Origin = aExplicitScale.Maximum; } + + aVCooSysList[nC]->setExplicitScaleAndIncrement( nDimensionIndex, nAxisIndex, aExplicitScale, aExplicitIncrement ); } } } @@ -1278,136 +1278,136 @@ bool lcl_IsPieOrDonut( const uno::Reference< XDiagram >& xDiagram ) void lcl_setDefaultWritingMode( const std::shared_ptr< DrawModelWrapper >& pDrawModelWrapper, ChartModel& rModel) { //get writing mode from parent document: - if( SvtLanguageOptions().IsCTLFontEnabled() ) + if( !SvtLanguageOptions().IsCTLFontEnabled() ) + return; + + try { - try + sal_Int16 nWritingMode=-1; + uno::Reference< beans::XPropertySet > xParentProps( rModel.getParent(), uno::UNO_QUERY ); + uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSupplier( xParentProps, uno::UNO_QUERY ); + if( xStyleFamiliesSupplier.is() ) { - sal_Int16 nWritingMode=-1; - uno::Reference< beans::XPropertySet > xParentProps( rModel.getParent(), uno::UNO_QUERY ); - uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSupplier( xParentProps, uno::UNO_QUERY ); - if( xStyleFamiliesSupplier.is() ) + uno::Reference< container::XNameAccess > xStylesFamilies( xStyleFamiliesSupplier->getStyleFamilies() ); + if( xStylesFamilies.is() ) { - uno::Reference< container::XNameAccess > xStylesFamilies( xStyleFamiliesSupplier->getStyleFamilies() ); - if( xStylesFamilies.is() ) + if( !xStylesFamilies->hasByName( "PageStyles" ) ) { - if( !xStylesFamilies->hasByName( "PageStyles" ) ) + //draw/impress is parent document + uno::Reference< lang::XMultiServiceFactory > xFatcory( xParentProps, uno::UNO_QUERY ); + if( xFatcory.is() ) { - //draw/impress is parent document - uno::Reference< lang::XMultiServiceFactory > xFatcory( xParentProps, uno::UNO_QUERY ); - if( xFatcory.is() ) - { - uno::Reference< beans::XPropertySet > xDrawDefaults( xFatcory->createInstance( "com.sun.star.drawing.Defaults" ), uno::UNO_QUERY ); - if( xDrawDefaults.is() ) - xDrawDefaults->getPropertyValue( "WritingMode" ) >>= nWritingMode; - } + uno::Reference< beans::XPropertySet > xDrawDefaults( xFatcory->createInstance( "com.sun.star.drawing.Defaults" ), uno::UNO_QUERY ); + if( xDrawDefaults.is() ) + xDrawDefaults->getPropertyValue( "WritingMode" ) >>= nWritingMode; } - else + } + else + { + uno::Reference< container::XNameAccess > xPageStyles( xStylesFamilies->getByName( "PageStyles" ), uno::UNO_QUERY ); + if( xPageStyles.is() ) { - uno::Reference< container::XNameAccess > xPageStyles( xStylesFamilies->getByName( "PageStyles" ), uno::UNO_QUERY ); - if( xPageStyles.is() ) + OUString aPageStyle; + + uno::Reference< text::XTextDocument > xTextDocument( xParentProps, uno::UNO_QUERY ); + if( xTextDocument.is() ) { - OUString aPageStyle; + //writer is parent document + //retrieve the current page style from the text cursor property PageStyleName - uno::Reference< text::XTextDocument > xTextDocument( xParentProps, uno::UNO_QUERY ); - if( xTextDocument.is() ) + uno::Reference< text::XTextEmbeddedObjectsSupplier > xTextEmbeddedObjectsSupplier( xTextDocument, uno::UNO_QUERY ); + if( xTextEmbeddedObjectsSupplier.is() ) { - //writer is parent document - //retrieve the current page style from the text cursor property PageStyleName - - uno::Reference< text::XTextEmbeddedObjectsSupplier > xTextEmbeddedObjectsSupplier( xTextDocument, uno::UNO_QUERY ); - if( xTextEmbeddedObjectsSupplier.is() ) + uno::Reference< container::XNameAccess > xEmbeddedObjects( xTextEmbeddedObjectsSupplier->getEmbeddedObjects() ); + if( xEmbeddedObjects.is() ) { - uno::Reference< container::XNameAccess > xEmbeddedObjects( xTextEmbeddedObjectsSupplier->getEmbeddedObjects() ); - if( xEmbeddedObjects.is() ) - { - uno::Sequence< OUString > aNames( xEmbeddedObjects->getElementNames() ); + uno::Sequence< OUString > aNames( xEmbeddedObjects->getElementNames() ); - sal_Int32 nCount = aNames.getLength(); - for( sal_Int32 nN=0; nN<nCount; nN++ ) + sal_Int32 nCount = aNames.getLength(); + for( sal_Int32 nN=0; nN<nCount; nN++ ) + { + uno::Reference< beans::XPropertySet > xEmbeddedProps( xEmbeddedObjects->getByName( aNames[nN] ), uno::UNO_QUERY ); + if( xEmbeddedProps.is() ) { - uno::Reference< beans::XPropertySet > xEmbeddedProps( xEmbeddedObjects->getByName( aNames[nN] ), uno::UNO_QUERY ); - if( xEmbeddedProps.is() ) + static OUString aChartCLSID = SvGlobalName( SO3_SCH_CLASSID ).GetHexName(); + OUString aCLSID; + xEmbeddedProps->getPropertyValue( "CLSID" ) >>= aCLSID; + if( aCLSID == aChartCLSID ) { - static OUString aChartCLSID = SvGlobalName( SO3_SCH_CLASSID ).GetHexName(); - OUString aCLSID; - xEmbeddedProps->getPropertyValue( "CLSID" ) >>= aCLSID; - if( aCLSID == aChartCLSID ) + uno::Reference< text::XTextContent > xEmbeddedObject( xEmbeddedProps, uno::UNO_QUERY ); + if( xEmbeddedObject.is() ) { - uno::Reference< text::XTextContent > xEmbeddedObject( xEmbeddedProps, uno::UNO_QUERY ); - if( xEmbeddedObject.is() ) + uno::Reference< text::XTextRange > xAnchor( xEmbeddedObject->getAnchor() ); + if( xAnchor.is() ) { - uno::Reference< text::XTextRange > xAnchor( xEmbeddedObject->getAnchor() ); - if( xAnchor.is() ) + uno::Reference< beans::XPropertySet > xAnchorProps( xAnchor, uno::UNO_QUERY ); + if( xAnchorProps.is() ) { - uno::Reference< beans::XPropertySet > xAnchorProps( xAnchor, uno::UNO_QUERY ); - if( xAnchorProps.is() ) - { - xAnchorProps->getPropertyValue( "WritingMode" ) >>= nWritingMode; - } - uno::Reference< text::XText > xText( xAnchor->getText() ); - if( xText.is() ) - { - uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); - if( xTextCursorProps.is() ) - xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; - } + xAnchorProps->getPropertyValue( "WritingMode" ) >>= nWritingMode; + } + uno::Reference< text::XText > xText( xAnchor->getText() ); + if( xText.is() ) + { + uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); + if( xTextCursorProps.is() ) + xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; } } - break; } + break; } } } } - if( aPageStyle.isEmpty() ) - { - uno::Reference< text::XText > xText( xTextDocument->getText() ); - if( xText.is() ) - { - uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); - if( xTextCursorProps.is() ) - xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; - } - } - if(aPageStyle.isEmpty()) - aPageStyle = "Standard"; } - else + if( aPageStyle.isEmpty() ) { - //Calc is parent document - Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xParentProps->getPropertySetInfo(); - if (xInfo->hasPropertyByName("PageStyle")) + uno::Reference< text::XText > xText( xTextDocument->getText() ); + if( xText.is() ) { - xParentProps->getPropertyValue( "PageStyle" ) >>= aPageStyle; + uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); + if( xTextCursorProps.is() ) + xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; } - if(aPageStyle.isEmpty()) - aPageStyle = "Default"; } - if( nWritingMode == -1 || nWritingMode == text::WritingMode2::PAGE ) + if(aPageStyle.isEmpty()) + aPageStyle = "Standard"; + } + else + { + //Calc is parent document + Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xParentProps->getPropertySetInfo(); + if (xInfo->hasPropertyByName("PageStyle")) { - uno::Reference< beans::XPropertySet > xPageStyle( xPageStyles->getByName( aPageStyle ), uno::UNO_QUERY ); - Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xPageStyle->getPropertySetInfo(); - if (xInfo->hasPropertyByName("WritingMode")) - { - if( xPageStyle.is() ) - xPageStyle->getPropertyValue( "WritingMode" ) >>= nWritingMode; - } + xParentProps->getPropertyValue( "PageStyle" ) >>= aPageStyle; + } + if(aPageStyle.isEmpty()) + aPageStyle = "Default"; + } + if( nWritingMode == -1 || nWritingMode == text::WritingMode2::PAGE ) + { + uno::Reference< beans::XPropertySet > xPageStyle( xPageStyles->getByName( aPageStyle ), uno::UNO_QUERY ); + Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xPageStyle->getPropertySetInfo(); + if (xInfo->hasPropertyByName("WritingMode")) + { + if( xPageStyle.is() ) + xPageStyle->getPropertyValue( "WritingMode" ) >>= nWritingMode; } } } } } - if( nWritingMode != -1 && nWritingMode != text::WritingMode2::PAGE ) - { - if( pDrawModelWrapper.get() ) - pDrawModelWrapper->GetItemPool().SetPoolDefaultItem(SvxFrameDirectionItem(static_cast<SvxFrameDirection>(nWritingMode), EE_PARA_WRITINGDIR) ); - } } - catch( const uno::Exception& ) + if( nWritingMode != -1 && nWritingMode != text::WritingMode2::PAGE ) { - DBG_UNHANDLED_EXCEPTION("chart2" ); + if( pDrawModelWrapper.get() ) + pDrawModelWrapper->GetItemPool().SetPoolDefaultItem(SvxFrameDirectionItem(static_cast<SvxFrameDirection>(nWritingMode), EE_PARA_WRITINGDIR) ); } } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2" ); + } } sal_Int16 lcl_getDefaultWritingModeFromPool( const std::shared_ptr<DrawModelWrapper>& pDrawModelWrapper ) @@ -2284,33 +2284,33 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes, aSize = awt::Size(3000, 700); // size of the button - if (xPivotTableDataProvider->getRowFields().hasElements()) + if (!xPivotTableDataProvider->getRowFields().hasElements()) + return; + + x = 200; + const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getRowFields(); + for (css::chart2::data::PivotTableFieldEntry const & rRowFieldEntry : aPivotFieldEntries) { - x = 200; - const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getRowFields(); - for (css::chart2::data::PivotTableFieldEntry const & rRowFieldEntry : aPivotFieldEntries) - { - std::unique_ptr<VButton> pButton(new VButton); - pButton->init(xPageShapes, xShapeFactory); - awt::Point aNewPosition(rRemainingSpace.X + x + 100, - rRemainingSpace.Y + rRemainingSpace.Height - aSize.Height - 100); - pButton->setLabel(rRowFieldEntry.Name); - pButton->setCID("FieldButton.Row." + OUString::number(rRowFieldEntry.DimensionIndex)); - pButton->setPosition(aNewPosition); - pButton->setSize(aSize); - if ( rRowFieldEntry.Name == "Data" ) - { - pButton->setBGColor( Color(0x00F6F6F6) ); - pButton->showArrow( false ); - } - else if (rRowFieldEntry.HasHiddenMembers) - pButton->setArrowColor(Color(0x0000FF)); - pButton->createShapes(xModelPage); - x += aSize.Width + 100; + std::unique_ptr<VButton> pButton(new VButton); + pButton->init(xPageShapes, xShapeFactory); + awt::Point aNewPosition(rRemainingSpace.X + x + 100, + rRemainingSpace.Y + rRemainingSpace.Height - aSize.Height - 100); + pButton->setLabel(rRowFieldEntry.Name); + pButton->setCID("FieldButton.Row." + OUString::number(rRowFieldEntry.DimensionIndex)); + pButton->setPosition(aNewPosition); + pButton->setSize(aSize); + if ( rRowFieldEntry.Name == "Data" ) + { + pButton->setBGColor( Color(0x00F6F6F6) ); + pButton->showArrow( false ); } - rRemainingSpace.Height -= (aSize.Height + 100 + 100); + else if (rRowFieldEntry.HasHiddenMembers) + pButton->setArrowColor(Color(0x0000FF)); + pButton->createShapes(xModelPage); + x += aSize.Width + 100; } + rRemainingSpace.Height -= (aSize.Height + 100 + 100); } void formatPage( @@ -2388,7 +2388,10 @@ void ChartView::impl_refreshAddIn() return; uno::Reference< beans::XPropertySet > xProp( static_cast< ::cppu::OWeakObject* >( &mrChartModel ), uno::UNO_QUERY ); - if( xProp.is()) try + if( !xProp.is()) + return; + + try { uno::Reference< util::XRefreshable > xAddIn; xProp->getPropertyValue( "AddIn" ) >>= xAddIn; @@ -2480,60 +2483,60 @@ void ChartView::impl_updateView( bool bCheckLockedCtrler ) if (bCheckLockedCtrler && mrChartModel.hasControllersLocked()) return; - if( m_bViewDirty && !m_bInViewUpdate ) + if( !(m_bViewDirty && !m_bInViewUpdate) ) + return; + + m_bInViewUpdate = true; + //bool bOldRefreshAddIn = m_bRefreshAddIn; + //m_bRefreshAddIn = false; + try { - m_bInViewUpdate = true; - //bool bOldRefreshAddIn = m_bRefreshAddIn; - //m_bRefreshAddIn = false; - try + impl_notifyModeChangeListener("invalid"); + + //prepare draw model { - impl_notifyModeChangeListener("invalid"); + SolarMutexGuard aSolarGuard; + m_pDrawModelWrapper->lockControllers(); + } - //prepare draw model - { - SolarMutexGuard aSolarGuard; - m_pDrawModelWrapper->lockControllers(); - } + //create chart view + { + m_bViewDirty = false; + m_bViewUpdatePending = false; + createShapes(); - //create chart view + if( m_bViewDirty ) { + //avoid recursions due to add-in + m_bRefreshAddIn = false; m_bViewDirty = false; m_bViewUpdatePending = false; + //delete old chart view createShapes(); - - if( m_bViewDirty ) - { - //avoid recursions due to add-in - m_bRefreshAddIn = false; - m_bViewDirty = false; - m_bViewUpdatePending = false; - //delete old chart view - createShapes(); - m_bRefreshAddIn = true; - } + m_bRefreshAddIn = true; } - - m_bViewDirty = m_bViewUpdatePending; - m_bViewUpdatePending = false; - m_bInViewUpdate = false; - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("chart2" ); - m_bViewDirty = m_bViewUpdatePending; - m_bViewUpdatePending = false; - m_bInViewUpdate = false; - } - - { - SolarMutexGuard aSolarGuard; - m_pDrawModelWrapper->unlockControllers(); } - impl_notifyModeChangeListener("valid"); + m_bViewDirty = m_bViewUpdatePending; + m_bViewUpdatePending = false; + m_bInViewUpdate = false; + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2" ); + m_bViewDirty = m_bViewUpdatePending; + m_bViewUpdatePending = false; + m_bInViewUpdate = false; + } - //m_bRefreshAddIn = bOldRefreshAddIn; + { + SolarMutexGuard aSolarGuard; + m_pDrawModelWrapper->unlockControllers(); } + + impl_notifyModeChangeListener("valid"); + + //m_bRefreshAddIn = bOldRefreshAddIn; } // ____ XModifyListener ____ diff --git a/chart2/source/view/main/VButton.cxx b/chart2/source/view/main/VButton.cxx index bd8c5f9749eb..088df5850416 100644 --- a/chart2/source/view/main/VButton.cxx +++ b/chart2/source/view/main/VButton.cxx @@ -134,18 +134,18 @@ void VButton::createShapes(const uno::Reference<beans::XPropertySet>& xTextProp) xEntry->setSize(m_aSize); } - if (m_bShowArrow) + if (!m_bShowArrow) + return; + + awt::Size aPolySize {280, 180}; + + uno::Reference<drawing::XShape> xPoly = createTriangle(aPolySize); + if (xPoly.is()) { - awt::Size aPolySize {280, 180}; - - uno::Reference<drawing::XShape> xPoly = createTriangle(aPolySize); - if (xPoly.is()) - { - xPoly->setSize(aPolySize); - xPoly->setPosition({ sal_Int32(m_aPosition.X + m_aSize.Width - aPolySize.Width - 100), - sal_Int32(m_aPosition.Y + (m_aSize.Height / 2.0) - (aPolySize.Height / 2.0)) }); - xContainer->add(xPoly); - } + xPoly->setSize(aPolySize); + xPoly->setPosition({ sal_Int32(m_aPosition.X + m_aSize.Width - aPolySize.Width - 100), + sal_Int32(m_aPosition.Y + (m_aSize.Height / 2.0) - (aPolySize.Height / 2.0)) }); + xContainer->add(xPoly); } } diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index b6c4adc013fa..7c7509635bf5 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -242,23 +242,23 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries ) } uno::Reference<beans::XPropertySet> xProp(xDataSeries, uno::UNO_QUERY ); - if( xProp.is()) + if( !xProp.is()) + return; + + try { - try - { - //get AttributedDataPoints - xProp->getPropertyValue("AttributedDataPoints") >>= m_aAttributedDataPointIndexList; + //get AttributedDataPoints + xProp->getPropertyValue("AttributedDataPoints") >>= m_aAttributedDataPointIndexList; - xProp->getPropertyValue("StackingDirection") >>= m_eStackingDirection; + xProp->getPropertyValue("StackingDirection") >>= m_eStackingDirection; - xProp->getPropertyValue("AttachedAxisIndex") >>= m_nAxisIndex; - if(m_nAxisIndex<0) - m_nAxisIndex=0; - } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } + xProp->getPropertyValue("AttachedAxisIndex") >>= m_nAxisIndex; + if(m_nAxisIndex<0) + m_nAxisIndex=0; + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } } @@ -268,33 +268,33 @@ VDataSeries::~VDataSeries() void VDataSeries::doSortByXValues() { - if( m_aValues_X.is() && m_aValues_X.Doubles.hasElements() ) + if( !(m_aValues_X.is() && m_aValues_X.Doubles.hasElements()) ) + return; + + //prepare a vector for sorting + std::vector< std::vector< double > > aTmp;//outer vector are points, inner vector are the different values of the point + double fNan; + ::rtl::math::setNan( & fNan ); + sal_Int32 nPointIndex = 0; + for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) { - //prepare a vector for sorting - std::vector< std::vector< double > > aTmp;//outer vector are points, inner vector are the different values of the point - double fNan; - ::rtl::math::setNan( & fNan ); - sal_Int32 nPointIndex = 0; - for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) - { - std::vector< double > aSinglePoint; - aSinglePoint.push_back( (nPointIndex < m_aValues_X.Doubles.getLength()) ? m_aValues_X.Doubles[nPointIndex] : fNan ); - aSinglePoint.push_back( (nPointIndex < m_aValues_Y.Doubles.getLength()) ? m_aValues_Y.Doubles[nPointIndex] : fNan ); - aTmp.push_back( aSinglePoint ); - } + std::vector< double > aSinglePoint; + aSinglePoint.push_back( (nPointIndex < m_aValues_X.Doubles.getLength()) ? m_aValues_X.Doubles[nPointIndex] : fNan ); + aSinglePoint.push_back( (nPointIndex < m_aValues_Y.Doubles.getLength()) ? m_aValues_Y.Doubles[nPointIndex] : fNan ); + aTmp.push_back( aSinglePoint ); + } - //do sort - std::stable_sort( aTmp.begin(), aTmp.end(), lcl_LessXOfPoint() ); + //do sort + std::stable_sort( aTmp.begin(), aTmp.end(), lcl_LessXOfPoint() ); - //fill the sorted points back to the members - m_aValues_X.Doubles.realloc( m_nPointCount ); - m_aValues_Y.Doubles.realloc( m_nPointCount ); + //fill the sorted points back to the members + m_aValues_X.Doubles.realloc( m_nPointCount ); + m_aValues_Y.Doubles.realloc( m_nPointCount ); - for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) - { - m_aValues_X.Doubles[nPointIndex]=aTmp[nPointIndex][0]; - m_aValues_Y.Doubles[nPointIndex]=aTmp[nPointIndex][1]; - } + for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) + { + m_aValues_X.Doubles[nPointIndex]=aTmp[nPointIndex][0]; + m_aValues_Y.Doubles[nPointIndex]=aTmp[nPointIndex][1]; } } @@ -498,25 +498,25 @@ void VDataSeries::getMinMaxXValue(double& fMin, double& fMax) const uno::Sequence< double > aValuesX = getAllX(); - if(aValuesX.hasElements()) - { - sal_Int32 i = 0; - while ( i < aValuesX.getLength() && std::isnan(aValuesX[i]) ) - i++; - if ( i < aValuesX.getLength() ) - fMax = fMin = aValuesX[i++]; + if(!aValuesX.hasElements()) + return; - for ( ; i < aValuesX.getLength(); i++) + sal_Int32 i = 0; + while ( i < aValuesX.getLength() && std::isnan(aValuesX[i]) ) + i++; + if ( i < aValuesX.getLength() ) + fMax = fMin = aValuesX[i++]; + + for ( ; i < aValuesX.getLength(); i++) + { + const double aValue = aValuesX[i]; + if ( aValue > fMax) { - const double aValue = aValuesX[i]; - if ( aValue > fMax) - { - fMax = aValue; - } - else if ( aValue < fMin) - { - fMin = aValue; - } + fMax = aValue; + } + else if ( aValue < fMin) + { + fMin = aValue; } } } diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 0fa0b3552d88..d7928b08e756 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -95,54 +95,54 @@ void lcl_getProperties( const awt::Size & rReferenceSize ) { // Get Line- and FillProperties from model legend - if( xLegendProp.is()) + if( !xLegendProp.is()) + return; + + // set rOutLineFillProperties + ::chart::tPropertyNameValueMap aLineFillValueMap; + ::chart::PropertyMapper::getValueMap( aLineFillValueMap, ::chart::PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xLegendProp ); + + aLineFillValueMap[ "LineJoint" ] <<= drawing::LineJoint_ROUND; + + ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( + rOutLineFillProperties.first, rOutLineFillProperties.second, aLineFillValueMap ); + + // set rOutTextProperties + ::chart::tPropertyNameValueMap aTextValueMap; + ::chart::PropertyMapper::getValueMap( aTextValueMap, ::chart::PropertyMapper::getPropertyNameMapForCharacterProperties(), xLegendProp ); + + aTextValueMap[ "TextAutoGrowHeight" ] <<= true; + aTextValueMap[ "TextAutoGrowWidth" ] <<= true; + aTextValueMap[ "TextHorizontalAdjust" ] <<= drawing::TextHorizontalAdjust_LEFT; + aTextValueMap[ "TextMaximumFrameWidth" ] <<= rReferenceSize.Width; //needs to be overwritten by actual available space in the legend + + // recalculate font size + awt::Size aPropRefSize; + float fFontHeight( 0.0 ); + if( (xLegendProp->getPropertyValue( "ReferencePageSize") >>= aPropRefSize) && + (aPropRefSize.Height > 0) && + (aTextValueMap[ "CharHeight" ] >>= fFontHeight) ) { - // set rOutLineFillProperties - ::chart::tPropertyNameValueMap aLineFillValueMap; - ::chart::PropertyMapper::getValueMap( aLineFillValueMap, ::chart::PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xLegendProp ); - - aLineFillValueMap[ "LineJoint" ] <<= drawing::LineJoint_ROUND; - - ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( - rOutLineFillProperties.first, rOutLineFillProperties.second, aLineFillValueMap ); - - // set rOutTextProperties - ::chart::tPropertyNameValueMap aTextValueMap; - ::chart::PropertyMapper::getValueMap( aTextValueMap, ::chart::PropertyMapper::getPropertyNameMapForCharacterProperties(), xLegendProp ); - - aTextValueMap[ "TextAutoGrowHeight" ] <<= true; - aTextValueMap[ "TextAutoGrowWidth" ] <<= true; - aTextValueMap[ "TextHorizontalAdjust" ] <<= drawing::TextHorizontalAdjust_LEFT; - aTextValueMap[ "TextMaximumFrameWidth" ] <<= rReferenceSize.Width; //needs to be overwritten by actual available space in the legend - - // recalculate font size - awt::Size aPropRefSize; - float fFontHeight( 0.0 ); - if( (xLegendProp->getPropertyValue( "ReferencePageSize") >>= aPropRefSize) && - (aPropRefSize.Height > 0) && - (aTextValueMap[ "CharHeight" ] >>= fFontHeight) ) + aTextValueMap[ "CharHeight" ] <<= + static_cast< float >( + ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); + + if( aTextValueMap[ "CharHeightAsian" ] >>= fFontHeight ) { - aTextValueMap[ "CharHeight" ] <<= + aTextValueMap[ "CharHeightAsian" ] <<= + static_cast< float >( + ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); + } + if( aTextValueMap[ "CharHeightComplex" ] >>= fFontHeight ) + { + aTextValueMap[ "CharHeightComplex" ] <<= static_cast< float >( ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); - - if( aTextValueMap[ "CharHeightAsian" ] >>= fFontHeight ) - { - aTextValueMap[ "CharHeightAsian" ] <<= - static_cast< float >( - ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); - } - if( aTextValueMap[ "CharHeightComplex" ] >>= fFontHeight ) - { - aTextValueMap[ "CharHeightComplex" ] <<= - static_cast< float >( - ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); - } } - - ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( - rOutTextProperties.first, rOutTextProperties.second, aTextValueMap ); } + + ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( + rOutTextProperties.first, rOutTextProperties.second, aTextValueMap ); } awt::Size lcl_createTextShapes( |