? OUT_FILE ? controller/main/.ControllerCommandDispatch.cxx.swp ? controller/main/.ControllerCommandDispatch.hxx.swp ? controller/main/svg ? tools/.DiagramHelper.cxx.swp ? tools/less Index: controller/main/CommandDispatch.cxx =================================================================== RCS file: /cvs/graphics/chart2/source/controller/main/Attic/CommandDispatch.cxx,v retrieving revision 1.1.2.4 diff -u -8 -p -r1.1.2.4 CommandDispatch.cxx --- controller/main/CommandDispatch.cxx 20 Jan 2006 16:45:34 -0000 1.1.2.4 +++ controller/main/CommandDispatch.cxx 9 Aug 2006 14:45:52 -0000 @@ -146,17 +146,17 @@ void CommandDispatch::fireAllStatusEvent const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ) { fireStatusEvent( OUString(), xSingleListener ); } void CommandDispatch::fireStatusEventForURL( const OUString & rURL, const uno::Any & rState, - sal_Bool bEnabled, + bool bEnabled, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { // prepare event to send util::URL aURL; aURL.Complete = rURL; if( !m_xURLTransformer.is()) { m_xURLTransformer.set( Index: controller/main/CommandDispatch.hxx =================================================================== RCS file: /cvs/graphics/chart2/source/controller/main/Attic/CommandDispatch.hxx,v retrieving revision 1.1.2.3 diff -u -8 -p -r1.1.2.3 CommandDispatch.hxx --- controller/main/CommandDispatch.hxx 15 Mar 2006 13:57:08 -0000 1.1.2.3 +++ controller/main/CommandDispatch.hxx 9 Aug 2006 14:45:52 -0000 @@ -116,17 +116,17 @@ protected: @param xSingleListener If set, the event is only sent to this listener rather than to all registered ones. Whenever a listener adds itself, this method is called with this parameter set to give an initial state. */ void fireStatusEventForURL( const ::rtl::OUString & rURL, const ::com::sun::star::uno::Any & rState, - sal_Bool bEnabled, + bool bEnabled, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >() ); // ____ XDispatch ____ virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& URL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException); Index: controller/main/ControllerCommandDispatch.cxx =================================================================== RCS file: /cvs/graphics/chart2/source/controller/main/Attic/ControllerCommandDispatch.cxx,v retrieving revision 1.1.2.8 diff -u -8 -p -r1.1.2.8 ControllerCommandDispatch.cxx --- controller/main/ControllerCommandDispatch.cxx 10 Apr 2006 15:03:33 -0000 1.1.2.8 +++ controller/main/ControllerCommandDispatch.cxx 9 Aug 2006 14:45:52 -0000 @@ -44,32 +44,139 @@ #include #endif #ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ #include #endif #ifndef _COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_ #include #endif +#ifndef _COM_SUN_STAR_CHART2_XDATASERIES_HPP_ +#include +#endif + using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; namespace chart { // ---------------------------------------- namespace impl { -/** Represents the current state of the model. + /** + * Declaring constants for moving the series. + * + */ + enum EnumForward{ + MOVE_SERIES_FORWARD = true, + MOVE_SERIES_BACKWARD = false + }; + + /** + * Represents the current state of the controller (needed for issue + * 63017). + * + * You can set the state by calling update(). After this call the state + * is preserved in this class until the next call to update(). + * + * This is useful, not to say necessary, for enabling and disabling of + * menu entries (format>arrangement). As the status requests are sent very + * frequently it would be impossible, from a performance point of view, to + * query the current status every time directly at the model. So this + * class serves as a cache for the state. + * + */ + struct ControllerState + { + ControllerState( const Reference< frame::XController > & xController ); + + void update( const Reference< frame::XModel > & xModel ); + + // -- State variables ------- + + bool bHasSelectedObject; + bool bIsDraggableObject; + + // May the selected series be moved forward or backward (cf + // format>arrangement). + bool bMayMoveSeriesForward; + bool bMayMoveSeriesBackward; + + private: + + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XController > m_xController; + + }; + + + ControllerState::ControllerState( + const Reference< frame::XController > & xController ) : + m_xController( xController ), + bHasSelectedObject( false ), + bIsDraggableObject( false ), + bMayMoveSeriesForward( false ), + bMayMoveSeriesBackward( false ) + { + } + + + void ControllerState::update( const Reference< frame::XModel > & xModel ) + { + + OSL_TRACE( "\nControllerState Updated -------------------------" ); + + ::com::sun::star::uno::Reference< + ::com::sun::star::view::XSelectionSupplier > + m_xSelectionSupplier( m_xController, uno::UNO_QUERY ); + + ::rtl::OUString aSelObjCID; + + // Update ControllerState variables. + if( m_xSelectionSupplier.is()) + { + uno::Any aSelObj( m_xSelectionSupplier->getSelection() ); + + bHasSelectedObject = ((aSelObj >>= aSelObjCID) && aSelObjCID.getLength() > 0); + + bIsDraggableObject = ObjectIdentifier::isDragableObject( aSelObjCID ); + + uno::Reference< ::com::sun::star::chart2::XDataSeries > xGivenDataSeries( + ObjectIdentifier::getDataSeriesForCID( + aSelObjCID, xModel ) ); + + bMayMoveSeriesForward = DiagramHelper::isSeriesMoveable( + ChartModelHelper::findDiagram( xModel ), + xGivenDataSeries, + MOVE_SERIES_FORWARD ); + + bMayMoveSeriesBackward = DiagramHelper::isSeriesMoveable( + ChartModelHelper::findDiagram( xModel ), + xGivenDataSeries, + MOVE_SERIES_BACKWARD); + + + // TODO : debug only + if ( bIsDraggableObject ) + OSL_TRACE( "Draggable Object"); + + } + + } + + + + /** Represents the current state of the model. You can set the state by calling update(). After this call the state is preserved in this class until the next call to update(). This is useful, not to say necessary, for enabling and disabling of menu entries and toolbar icons. As the status requests are sent very frequently it would be impossible, from a performance point of view, to query the current status every time directly at the model. So this class serves as a @@ -80,71 +187,72 @@ struct ModelState ModelState(); void update( const Reference< frame::XModel > & xModel ); bool HasAnyAxis() const; bool HasAnyGrid() const; bool HasAnyTitle() const; - sal_Bool bIsReadOnly; - sal_Bool bIsThreeD; - sal_Bool bHasOwnData; - - sal_Bool bHasMainTitle; - sal_Bool bHasSubTitle; - sal_Bool bHasXAxisTitle; - sal_Bool bHasYAxisTitle; - sal_Bool bHasZAxisTitle; - - sal_Bool bHasXAxis; - sal_Bool bHasYAxis; - sal_Bool bHasZAxis; - sal_Bool bHasAAxis; - sal_Bool bHasBAxis; - - sal_Bool bHasMainXGrid; - sal_Bool bHasMainYGrid; - sal_Bool bHasMainZGrid; - sal_Bool bHasHelpXGrid; - sal_Bool bHasHelpYGrid; - sal_Bool bHasHelpZGrid; + bool bIsReadOnly; + bool bIsThreeD; + bool bHasOwnData; + + bool bHasMainTitle; + bool bHasSubTitle; + bool bHasXAxisTitle; + bool bHasYAxisTitle; + bool bHasZAxisTitle; + + bool bHasXAxis; + bool bHasYAxis; + bool bHasZAxis; + bool bHasAAxis; + bool bHasBAxis; + + bool bHasMainXGrid; + bool bHasMainYGrid; + bool bHasMainZGrid; + bool bHasHelpXGrid; + bool bHasHelpYGrid; + bool bHasHelpZGrid; + + bool bHasAutoScaledText; - sal_Bool bHasAutoScaledText; }; ModelState::ModelState() : - bIsReadOnly( sal_True ), - bIsThreeD( sal_False ), - bHasOwnData( sal_False ), - bHasMainTitle( sal_False ), - bHasSubTitle( sal_False ), - bHasXAxisTitle( sal_False ), - bHasYAxisTitle( sal_False ), - bHasZAxisTitle( sal_False ), - bHasXAxis( sal_False ), - bHasYAxis( sal_False ), - bHasZAxis( sal_False ), - bHasAAxis( sal_False ), - bHasBAxis( sal_False ), - bHasMainXGrid( sal_False ), - bHasMainYGrid( sal_False ), - bHasMainZGrid( sal_False ), - bHasHelpXGrid( sal_False ), - bHasHelpYGrid( sal_False ), - bHasHelpZGrid( sal_False ), - bHasAutoScaledText( sal_False ) + bIsReadOnly( true ), + bIsThreeD( false ), + bHasOwnData( false ), + bHasMainTitle( false ), + bHasSubTitle( false ), + bHasXAxisTitle( false ), + bHasYAxisTitle( false ), + bHasZAxisTitle( false ), + bHasXAxis( false ), + bHasYAxis( false ), + bHasZAxis( false ), + bHasAAxis( false ), + bHasBAxis( false ), + bHasMainXGrid( false ), + bHasMainYGrid( false ), + bHasMainZGrid( false ), + bHasHelpXGrid( false ), + bHasHelpYGrid( false ), + bHasHelpZGrid( false ), + bHasAutoScaledText( false ) {} void ModelState::update( const Reference< frame::XModel > & xModel ) { Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); - bIsReadOnly = sal_True; + bIsReadOnly = true; Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY ); if( xStorable.is()) bIsReadOnly = xStorable->isReadonly(); bIsThreeD = (DiagramHelper::getDimension( xDiagram ) == 3); bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider()); bHasMainTitle = TitleHelper::getTitle( TitleHelper::MAIN_TITLE, xModel ).is(); @@ -164,16 +272,17 @@ void ModelState::update( const Reference bHasMainZGrid = AxisHelper::isGridShown( 2, 0, true, xDiagram ); bHasHelpXGrid = AxisHelper::isGridShown( 0, 0, false, xDiagram ); bHasHelpYGrid = AxisHelper::isGridShown( 1, 0, false, xDiagram ); bHasHelpZGrid = AxisHelper::isGridShown( 2, 0, false, xDiagram ); bHasAutoScaledText = (ReferenceSizeProvider::getAutoResizeState( xChartDoc ) == ReferenceSizeProvider::AUTO_RESIZE_YES); + } bool ModelState::HasAnyAxis() const { return bHasXAxis || bHasYAxis || bHasZAxis || bHasAAxis || bHasBAxis; } bool ModelState::HasAnyGrid() const @@ -189,97 +298,107 @@ bool ModelState::HasAnyTitle() const } // namespace impl // ---------------------------------------- ControllerCommandDispatch::ControllerCommandDispatch( const Reference< uno::XComponentContext > & xContext, const Reference< frame::XController > & xController ) : - CommandDispatch( xContext ), + impl::ControllerCommandDispatch_Base( xContext ), m_xController( xController ), m_xSelectionSupplier( xController, uno::UNO_QUERY ), m_xDispatch( xController, uno::UNO_QUERY ), - m_apModelState( new impl::ModelState()) + m_apModelState( new impl::ModelState() ), + m_apControllerState( new impl::ControllerState( xController ) ) {} ControllerCommandDispatch::~ControllerCommandDispatch() {} void ControllerCommandDispatch::initialize() { if( m_xController.is()) { Reference< frame::XModel > xModel( m_xController->getModel()); Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY ); OSL_ASSERT( xModifyBroadcaster.is()); if( xModifyBroadcaster.is()) xModifyBroadcaster->addModifyListener( this ); + + // Listen selection modifications (Arrangement feature - issue 63017). + if( m_xSelectionSupplier.is() ) + m_xSelectionSupplier->addSelectionChangeListener( this ); + if( m_apModelState.get() && xModel.is()) m_apModelState->update( xModel ); + + if( m_apControllerState.get() && xModel.is()) + m_apControllerState->update( xModel ); + } } void ControllerCommandDispatch::conditionalFireStatusEventForURL( const OUString & rCompareURL, const OUString & rURL, const uno::Any & rState, - sal_Bool bEnabled, + bool bEnabled, const Reference< frame::XStatusListener > & xSingleListener ) { if( rCompareURL.getLength() == 0 || rURL.equals( rCompareURL )) { fireStatusEventForURL( rURL, rState, bEnabled, xSingleListener ); } } void ControllerCommandDispatch::fireStatusEvent( const OUString & rURL, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { uno::Any aEmptyArg; // readonly - sal_Bool bIsWritable = ! m_apModelState->bIsReadOnly; - // selection - sal_Bool bHasSelectedObject = sal_False; - OUString aSelObjCID; - if( m_xSelectionSupplier.is()) - { - uno::Any aSelObj( m_xSelectionSupplier->getSelection()); - bHasSelectedObject = ((aSelObj >>= aSelObjCID) && aSelObjCID.getLength() > 0); - } - + bool bIsWritable = ! m_apModelState->bIsReadOnly; + + // selection + bool bHasSelectedObject = false; + + // Model and controller exist. + OSL_ASSERT( m_apModelState.get() ); + OSL_ASSERT( m_apControllerState.get() ); + + bool bModelStateIsValid = ( m_apModelState.get() != 0 ); + bool bControllerStateIsValid = ( m_apControllerState.get() != 0 ); + + // base commands (offered by all apps) conditionalFireStatusEventForURL( rURL, C2U(".uno:Save"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:SaveAs"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:SaveAll"), aEmptyArg, bIsWritable, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:Close"), aEmptyArg, sal_True, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:Close"), aEmptyArg, true, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:Cut"), aEmptyArg, bIsWritable && bHasSelectedObject, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:Copy"), aEmptyArg, bHasSelectedObject, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:Paste"), aEmptyArg, bIsWritable, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:SelectAll"), aEmptyArg, sal_True, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:SelectAll"), aEmptyArg, true, xSingleListener ); // toolbar commands conditionalFireStatusEventForURL( rURL, C2U(".uno:ToggleTitle"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:ToggleLegend"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:ToggleAxisTitle"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:ToggleAxisDescr"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:ToggleGridHorizontal"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:ToggleGridVertical"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:DataInRows"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:DataInColumns"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:ContextType"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:NewArrangement"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:Update"), aEmptyArg, bIsWritable, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:ScaleText"), - uno::makeAny( m_apModelState->bHasAutoScaledText ), - bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:DataDescriptionType"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:LegendPosition"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:DefaultColors"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:BarWidth"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:NumberOfLines"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:ArrangeRow"), aEmptyArg, bIsWritable, xSingleListener ); // insert objects @@ -291,65 +410,70 @@ void ControllerCommandDispatch::fireStat conditionalFireStatusEventForURL( rURL, C2U(".uno:InsertStatistics"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:InsertSymbol"), aEmptyArg, bIsWritable, xSingleListener ); // format objects //MENUCHANGE conditionalFireStatusEventForURL( rURL, C2U(".uno:SelectSourceRanges"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramObjects"), aEmptyArg, bIsWritable && bHasSelectedObject, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramType"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:AutoFormat"), aEmptyArg, bIsWritable, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:Forward"), aEmptyArg, bIsWritable, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:Backward"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:Legend"), aEmptyArg, bIsWritable, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramWall"), aEmptyArg, bIsWritable, xSingleListener ); conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramArea"), aEmptyArg, bIsWritable, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:TransformDialog"), aEmptyArg, bIsWritable && bHasSelectedObject && m_apControllerState->bIsDraggableObject, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:TransformDialog"), aEmptyArg, - bIsWritable && bHasSelectedObject && ObjectIdentifier::isDragableObject( aSelObjCID ), - xSingleListener ); - - OSL_ASSERT( m_apModelState.get()); - if( ! m_apModelState.get()) - bIsWritable = sal_False; - + + + // Tests requiring that the Model State is valid ("bModelStateIsValid"). + // 3d commands - conditionalFireStatusEventForURL( rURL, C2U(".uno:View3D"), aEmptyArg, bIsWritable && m_apModelState->bIsThreeD, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramFloor"), aEmptyArg, bIsWritable && m_apModelState->bIsThreeD, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:View3D"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramFloor"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD, xSingleListener ); // depending on own data - conditionalFireStatusEventForURL( rURL, C2U(".uno:DataRanges"), aEmptyArg, ! m_apModelState->bHasOwnData, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramData"), aEmptyArg, m_apModelState->bHasOwnData, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DataRanges"), aEmptyArg, bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData), xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramData"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData, xSingleListener ); // titles - conditionalFireStatusEventForURL( rURL, C2U(".uno:MainTitle"), aEmptyArg, bIsWritable && m_apModelState->bHasMainTitle, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:SubTitle"), aEmptyArg, bIsWritable && m_apModelState->bHasSubTitle, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:XTitle"), aEmptyArg, bIsWritable && m_apModelState->bHasXAxisTitle, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:YTitle"), aEmptyArg, bIsWritable && m_apModelState->bHasYAxisTitle, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:ZTitle"), aEmptyArg, bIsWritable && m_apModelState->bHasZAxisTitle, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:AllTitles"), aEmptyArg, bIsWritable && m_apModelState->HasAnyTitle(), xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:MainTitle"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:SubTitle"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasSubTitle, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:XTitle"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxisTitle, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:YTitle"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxisTitle, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:ZTitle"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxisTitle, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:AllTitles"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->HasAnyTitle(), xSingleListener ); + + // text + conditionalFireStatusEventForURL( rURL, C2U(".uno:ScaleText"), uno::makeAny( m_apModelState->bHasAutoScaledText ), bIsWritable && bModelStateIsValid , xSingleListener ); // axes - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisX"), aEmptyArg, bIsWritable && m_apModelState->bHasXAxis, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisY"), aEmptyArg, bIsWritable && m_apModelState->bHasYAxis, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisZ"), aEmptyArg, bIsWritable && m_apModelState->bHasZAxis, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisA"), aEmptyArg, bIsWritable && m_apModelState->bHasAAxis, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisB"), aEmptyArg, bIsWritable && m_apModelState->bHasBAxis, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisAll"), aEmptyArg, bIsWritable && m_apModelState->HasAnyAxis(), xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisX"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxis, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisY"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxis, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisZ"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxis, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisA"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasAAxis, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisB"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasBAxis, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramAxisAll"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->HasAnyAxis(), xSingleListener ); // grids // note: x and y are swapped in the commands! - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridYMain"), aEmptyArg, bIsWritable && m_apModelState->bHasMainXGrid, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridXMain"), aEmptyArg, bIsWritable && m_apModelState->bHasMainYGrid, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridZMain"), aEmptyArg, bIsWritable && m_apModelState->bHasMainZGrid, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridYHelp"), aEmptyArg, bIsWritable && m_apModelState->bHasHelpXGrid, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridXHelp"), aEmptyArg, bIsWritable && m_apModelState->bHasHelpYGrid, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridZHelp"), aEmptyArg, bIsWritable && m_apModelState->bHasHelpZGrid, xSingleListener ); - conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridAll"), aEmptyArg, bIsWritable && m_apModelState->HasAnyGrid(), xSingleListener ); - + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridYMain"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasMainXGrid, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridXMain"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasMainYGrid, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridZMain"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasMainZGrid, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridYHelp"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpXGrid, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridXHelp"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpYGrid, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridZHelp"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpZGrid, xSingleListener ); + conditionalFireStatusEventForURL( rURL, C2U(".uno:DiagramGridAll"), aEmptyArg, bIsWritable && bModelStateIsValid && m_apModelState->HasAnyGrid(), xSingleListener ); + + + // Tests requiring that the Model State is valid ("bModelStateIsValid") + // and that the Controller State ("bControllerStateIsValid") is valid. + + conditionalFireStatusEventForURL( rURL, C2U(".uno:Forward"), aEmptyArg, bIsWritable && bModelStateIsValid && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward, xSingleListener ); + + conditionalFireStatusEventForURL( rURL, C2U(".uno:Backward"), aEmptyArg, bIsWritable && bModelStateIsValid && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward, xSingleListener ); + } // ____ XDispatch ____ void SAL_CALL ControllerCommandDispatch::dispatch( const util::URL& URL, const Sequence< beans::PropertyValue >& Arguments ) throw (uno::RuntimeException) { @@ -373,14 +497,36 @@ void SAL_CALL ControllerCommandDispatch: m_xDispatch.clear(); m_xSelectionSupplier.clear(); } // ____ XModifyListener ____ void SAL_CALL ControllerCommandDispatch::modified( const lang::EventObject& aEvent ) throw (uno::RuntimeException) { + // Update the "ModelState" Struct. if( m_apModelState.get() && m_xController.is()) m_apModelState->update( m_xController->getModel()); + + // Update the "ControllerState" Struct. + if( m_apControllerState.get() && m_xController.is()) + m_apControllerState->update( m_xController->getModel()); + CommandDispatch::modified( aEvent ); } + +// ____ XSelectionChangeListener ____ +void SAL_CALL ControllerCommandDispatch::selectionChanged( const lang::EventObject& aEvent ) + throw (uno::RuntimeException) +{ + + // TODO : remove the comment + OSL_TRACE( "Selection Changed" ); + + // Update the "ControllerState" Struct. + if( m_apControllerState.get() && m_xController.is()) + m_apControllerState->update( m_xController->getModel()); + +} + + } // namespace chart Index: controller/main/ControllerCommandDispatch.hxx =================================================================== RCS file: /cvs/graphics/chart2/source/controller/main/Attic/ControllerCommandDispatch.hxx,v retrieving revision 1.1.2.3 diff -u -8 -p -r1.1.2.3 ControllerCommandDispatch.hxx --- controller/main/ControllerCommandDispatch.hxx 15 Mar 2006 13:57:09 -0000 1.1.2.3 +++ controller/main/ControllerCommandDispatch.hxx 9 Aug 2006 14:45:52 -0000 @@ -32,44 +32,59 @@ * MA 02111-1307 USA * ************************************************************************/ #ifndef CHART2_CONTROLLERCOMMANDDISPATCH_HXX #define CHART2_CONTROLLERCOMMANDDISPATCH_HXX #include "CommandDispatch.hxx" +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include +#endif #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ #include #endif #ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ #include #endif #ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ #include #endif +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONCHANGELISTENER_HPP_ +#include +#endif + #include namespace chart { namespace impl { -struct ModelState; + struct ControllerState; + struct ModelState; + + // issue 63017 : need to implement the XSelectionChangeListener in order + // to update the ModelState when the selected series changes. + typedef ::cppu::ImplInheritanceHelper1< + CommandDispatch, ::com::sun::star::view::XSelectionChangeListener > + ControllerCommandDispatch_Base; + } /** This class is a CommandDispatch that is responsible for all commands that the ChartController supports. This class determines which commands are currently available (via the model state) and if an available command is called forwards it to the - ChartController. + ChartController. */ -class ControllerCommandDispatch : public CommandDispatch +class ControllerCommandDispatch : public impl::ControllerCommandDispatch_Base { public: explicit ControllerCommandDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > & xController ); virtual ~ControllerCommandDispatch(); @@ -97,38 +112,49 @@ protected: const ::rtl::OUString & rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); // ____ XModifyListener ____ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); + // ____ XSelectionChangeListener ____ + // This is related to the arrangement feature (issue 63017). + virtual void SAL_CALL selectionChanged( + const ::com::sun::star::lang::EventObject& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + + + private: /** Simplification for doing a string compare between a given URL (rCompareURL) with a fixed string (rURL), and only in case of equality call the fireStatusEvent method at the base class. @param xSingleListener Same behaviour that in base class CommandDispatch: If set, the event is only sent to this listener rather than to all registered ones. */ void conditionalFireStatusEventForURL( const ::rtl::OUString & rCompareURL, const ::rtl::OUString & rURL, const ::com::sun::star::uno::Any & rState, - sal_Bool bEnabled, + bool bEnabled, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xController; ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xDispatch; ::std::auto_ptr< impl::ModelState > m_apModelState; + + ::std::auto_ptr< impl::ControllerState > m_apControllerState; + }; } // namespace chart // CHART2_CONTROLLERCOMMANDDISPATCH_HXX #endif Index: inc/DiagramHelper.hxx =================================================================== RCS file: /cvs/graphics/chart2/source/inc/DiagramHelper.hxx,v retrieving revision 1.2.4.43 diff -u -8 -p -r1.2.4.43 DiagramHelper.hxx --- inc/DiagramHelper.hxx 30 Jun 2006 22:20:19 -0000 1.2.4.43 +++ inc/DiagramHelper.hxx 9 Aug 2006 14:45:52 -0000 @@ -288,20 +288,60 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram ); static bool areChartTypesCompatible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xFirstType, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xSecondType ); - static bool moveSeries( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDiagram >& xDiagram, - const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries, bool bForward ); + + /** + * Test if the series can be moved. + * + * @param xDiagram + * Reference to the diagram that contains the selected series. + * + * @param xGivenDataSeries + * Reference to the series that needs to be moved. + * + * @param bForward + * Test to move the series forward or backward. + * + * @returns if the series can be moved. + * + */ + static bool DiagramHelper::isSeriesMoveable( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram >& xDiagram, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries, + bool bForward ); + + /** + * Move the series forward or backward. + * + * @param xDiagram + * Reference to the diagram that contains the selected series. + * + * @param xGivenDataSeries + * Reference to the series that needs to be moved. + * + * @param bForward + * Test to move the series forward or backward. + * + * @returns if the series was moved. + * + */ + static bool moveSeries( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram >& xDiagram, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries, + bool bForward ); static sal_Int32 getIndexOfSeriesWithinChartType( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& xDataSeries, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); enum BarConnectorState @@ -319,17 +359,17 @@ public: static BarConnectorState hasBarConnectors( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram ); /** Set the property "ConnectDataPoints" to true for all series that are contained in chart types that support bar connectors (see ChartTypeHelper::isSupportingBarConnectors) - @return iff the property could be set at some data series + @return if the property could be set at some data series */ static bool setBarConnectors( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram, bool bOn ); /** Returns the default camera geometry that is set in the Diagram CTOR. This is not the property default! @@ -359,14 +399,52 @@ public: static void getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance ); static bool isSupportingFloorAndWall( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram ); private: // not implemented DiagramHelper(); + + /** + * This method implements the logic of checking if a series can be moved + * forward/backward. Depending on the "bDoMove" parameter the series will + * be moved (bDoMove = true) or the function just will just test if the + * series can be moved without doing the move (bDoMove = false). + * + * Note : This function should be restructured, but is kept as is for the + * moment. + * + * @param xDiagram + * Reference to the diagram that contains the selected series. + * + * @param xGivenDataSeries + * Reference to the series that needs to be moved. + * + * @param bForward + * Move the series forward or backward. + * + * @param bDoMove + * Should this function really move the series (true) or just test if it is + * possible (false). + * + * + * @returns + * bDoMove = true + * - True : if the move was done + * - False : the move failed + * bDoMove = false + * - True : the series can be moved + * - False : the series can not be moved + * + */ + static bool lcl_moveSeriesOrCheckIfMoveIsAllowed( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram, + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries, + bool bForward, + bool bDoMove ); }; } // namespace chart // CHART2_DIAGRAMHELPER_HXX #endif Index: tools/DiagramHelper.cxx =================================================================== RCS file: /cvs/graphics/chart2/source/tools/DiagramHelper.cxx,v retrieving revision 1.5.4.58 diff -u -8 -p -r1.5.4.58 DiagramHelper.cxx --- tools/DiagramHelper.cxx 30 Jun 2006 22:20:48 -0000 1.5.4.58 +++ tools/DiagramHelper.cxx 9 Aug 2006 14:45:53 -0000 @@ -1084,144 +1084,244 @@ bool DiagramHelper::areChartTypesCompati ::std::vector< ::rtl::OUString > aFirstRoles( ContainerHelper::SequenceToVector( xFirstType->getSupportedMandatoryRoles() ) ); ::std::vector< ::rtl::OUString > aSecondRoles( ContainerHelper::SequenceToVector( xSecondType->getSupportedMandatoryRoles() ) ); ::std::sort( aFirstRoles.begin(), aFirstRoles.end() ); ::std::sort( aSecondRoles.begin(), aSecondRoles.end() ); return ( aFirstRoles == aSecondRoles ); } + + +bool DiagramHelper::isSeriesMoveable( + const Reference< XDiagram >& xDiagram, + const Reference< XDataSeries >& xGivenDataSeries, + bool bForward ) +{ + + bool bIsMoveable = false; + const bool bDoMove = false; + + bIsMoveable = lcl_moveSeriesOrCheckIfMoveIsAllowed( + xDiagram, xGivenDataSeries, bForward, bDoMove ); + + return bIsMoveable; +} + + bool DiagramHelper::moveSeries( const Reference< XDiagram >& xDiagram, const Reference< XDataSeries >& xGivenDataSeries, bool bForward ) { - bool bChanged = false; + + bool bMoved = false; + const bool bDoMove = true; + + bMoved = lcl_moveSeriesOrCheckIfMoveIsAllowed( + xDiagram, xGivenDataSeries, bForward, bDoMove ); + + return bMoved; +} + + +bool DiagramHelper::lcl_moveSeriesOrCheckIfMoveIsAllowed( + const Reference< XDiagram >& xDiagram, + const Reference< XDataSeries >& xGivenDataSeries, + bool bForward, + bool bDoMove ) +{ + + OSL_TRACE( "LOCAL_MOVE_SERIES" ); + + if( bForward ) + OSL_TRACE( "move forward" ); + else + OSL_TRACE( "move backward" ); + + + if( bDoMove ) + OSL_TRACE( "Really move" ); + else + OSL_TRACE( "DO NOT move" ); + + + bool bMovedOrMoveAllowed = false; + try { uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); - //find position of series + // Find position of series. bool bFound = false; if( xGivenDataSeries.is() && xCooSysContainer.is() ) { uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); + + // Coordinate system(s). At the moment, there is only one + // coordinate. for( sal_Int32 nCS = 0; !bFound && nCS < aCooSysList.getLength(); ++nCS ) { uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] ); //iterate through all chart types in the current coordinate system uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY ); OSL_ASSERT( xChartTypeContainer.is()); if( !xChartTypeContainer.is() ) continue; uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); uno::Reference< XChartType > xFormerChartType; + for( sal_Int32 nT = 0; !bFound && nT < aChartTypeList.getLength(); ++nT ) { uno::Reference< XChartType > xCurrentChartType( aChartTypeList[nT] ); //iterate through all series in this chart type uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xCurrentChartType, uno::UNO_QUERY ); OSL_ASSERT( xDataSeriesContainer.is()); if( !xDataSeriesContainer.is() ) continue; uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); + + for( sal_Int32 nS = 0; !bFound && nS < aSeriesList.getLength(); ++nS ) { - if( xGivenDataSeries==aSeriesList[nS] ) + + // Aim : know at which index is the series. + // We found the series we are interrested in ! + if( xGivenDataSeries==aSeriesList[nS] ) { - sal_Int32 nOldCooSysIndex=nCS; - sal_Int32 nOldChartTypeIndex=nT; - sal_Int32 nOldSeriesIndex=nS; + sal_Int32 nOldCooSysIndex = nCS; + sal_Int32 nOldChartTypeIndex = nT; + sal_Int32 nOldSeriesIndex = nS; bFound = true; try { - sal_Int32 nNewSeriesIndex=nS; - if( bForward ) + sal_Int32 nNewSeriesIndex = nS; + + // Should the series be moved forward or backward. + if( bForward ) nNewSeriesIndex--; else nNewSeriesIndex++; - if( nNewSeriesIndex >= 0 && nNewSeriesIndex < aSeriesList.getLength() ) - { - //move series in the same charttype - bChanged = true; - aSeriesList[nOldSeriesIndex]=aSeriesList[nNewSeriesIndex]; - aSeriesList[nNewSeriesIndex]=xGivenDataSeries; - xDataSeriesContainer->setDataSeries(aSeriesList); - } - else if( nNewSeriesIndex<0 ) - { - //exchange series with former charttype - if( xFormerChartType.is() && DiagramHelper::areChartTypesCompatible( xFormerChartType, xCurrentChartType ) ) - { - bChanged = true; - uno::Reference< XDataSeriesContainer > xOtherDataSeriesContainer( xFormerChartType, uno::UNO_QUERY ); - if( xOtherDataSeriesContainer.is() ) - { - uno::Sequence< uno::Reference< XDataSeries > > aOtherSeriesList( xOtherDataSeriesContainer->getDataSeries() ); - sal_Int32 nOtherSeriesIndex = aOtherSeriesList.getLength()-1; - if( nOtherSeriesIndex >= 0 && nOtherSeriesIndex < aOtherSeriesList.getLength() ) - { - uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] ); - aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries; - xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList); + + + // --- Moving in real the series ------------- + + if( bDoMove ) + { + + + if( nNewSeriesIndex >= 0 && nNewSeriesIndex < aSeriesList.getLength() ) + { + //move series in the same charttype + bMovedOrMoveAllowed = true; + aSeriesList[ nOldSeriesIndex ] = aSeriesList[ nNewSeriesIndex ]; + aSeriesList[ nNewSeriesIndex ] = xGivenDataSeries; + xDataSeriesContainer->setDataSeries( aSeriesList ); + } + else if( nNewSeriesIndex<0 ) + { + //exchange series with former charttype + if( xFormerChartType.is() && DiagramHelper::areChartTypesCompatible( xFormerChartType, xCurrentChartType ) ) + { + bMovedOrMoveAllowed = true; + uno::Reference< XDataSeriesContainer > xOtherDataSeriesContainer( xFormerChartType, uno::UNO_QUERY ); + if( xOtherDataSeriesContainer.is() ) + { + uno::Sequence< uno::Reference< XDataSeries > > aOtherSeriesList( xOtherDataSeriesContainer->getDataSeries() ); + sal_Int32 nOtherSeriesIndex = aOtherSeriesList.getLength()-1; + if( nOtherSeriesIndex >= 0 && nOtherSeriesIndex < aOtherSeriesList.getLength() ) + { + uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] ); + aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries; + xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList); aSeriesList[nOldSeriesIndex]=xExchangeSeries; xDataSeriesContainer->setDataSeries(aSeriesList); - } - } - } - } - else if( nT+1 < aChartTypeList.getLength() ) - { - //exchange series with next charttype - uno::Reference< XChartType > xOtherChartType( aChartTypeList[nT+1] ); - if( xOtherChartType.is() && DiagramHelper::areChartTypesCompatible( xOtherChartType, xCurrentChartType ) ) - { - bChanged = true; - uno::Reference< XDataSeriesContainer > xOtherDataSeriesContainer( xOtherChartType, uno::UNO_QUERY ); - if( xOtherDataSeriesContainer.is() ) - { - uno::Sequence< uno::Reference< XDataSeries > > aOtherSeriesList( xOtherDataSeriesContainer->getDataSeries() ); - sal_Int32 nOtherSeriesIndex = 0; - if( nOtherSeriesIndex >= 0 && nOtherSeriesIndex < aOtherSeriesList.getLength() ) - { - uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] ); - aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries; - xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList); + } + } + } + } + else if( nT+1 < aChartTypeList.getLength() ) + { + //exchange series with next charttype + uno::Reference< XChartType > xOtherChartType( aChartTypeList[nT+1] ); + if( xOtherChartType.is() && DiagramHelper::areChartTypesCompatible( xOtherChartType, xCurrentChartType ) ) + { + bMovedOrMoveAllowed = true; + uno::Reference< XDataSeriesContainer > xOtherDataSeriesContainer( xOtherChartType, uno::UNO_QUERY ); + if( xOtherDataSeriesContainer.is() ) + { + uno::Sequence< uno::Reference< XDataSeries > > aOtherSeriesList( xOtherDataSeriesContainer->getDataSeries() ); + sal_Int32 nOtherSeriesIndex = 0; + if( nOtherSeriesIndex >= 0 && nOtherSeriesIndex < aOtherSeriesList.getLength() ) + { + uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] ); + aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries; + xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList); aSeriesList[nOldSeriesIndex]=xExchangeSeries; xDataSeriesContainer->setDataSeries(aSeriesList); - } - } - } - } - - } - catch( util::CloseVetoException& ) - { - } - catch( uno::RuntimeException& ) - { - } - } - } - xFormerChartType = xCurrentChartType; - } - } - } - } - catch( util::CloseVetoException& ) - { - } - catch( uno::RuntimeException& ) - { - } - return bChanged; + } + } + } + } + + // --- End Moving the series -------------------- + + } + + // --- Test if the series can be moved without + // doing the move. --- + + else + { + + if( nNewSeriesIndex >= 0 && nNewSeriesIndex < aSeriesList.getLength() ) + bMovedOrMoveAllowed = true; + + else if( nNewSeriesIndex<0 ) + { + //exchange series with former charttype + if( xFormerChartType.is() && DiagramHelper::areChartTypesCompatible( xFormerChartType, xCurrentChartType ) ) + bMovedOrMoveAllowed = true; + } + else if( nT+1 < aChartTypeList.getLength() ) + { + //exchange series with next charttype + uno::Reference< XChartType > xOtherChartType( aChartTypeList[nT+1] ); + if( xOtherChartType.is() && DiagramHelper::areChartTypesCompatible( xOtherChartType, xCurrentChartType ) ) + { + bMovedOrMoveAllowed = true; + } + } + } + + } + catch( util::CloseVetoException& ) + { + } + catch( uno::RuntimeException& ) + { + } + } + } + xFormerChartType = xCurrentChartType; + } + } + } + } + catch( util::CloseVetoException& ) + { + } + catch( uno::RuntimeException& ) + { + } + return bMovedOrMoveAllowed; } sal_Int32 DiagramHelper::getIndexOfSeriesWithinChartType( const Reference< XDataSeries >& xDataSeries, const Reference< XChartType >& xChartType ) { sal_Int32 nRet = -1;