chartmultiline: cleanup

This commit is contained in:
Ingrid Halama 2009-11-24 17:45:42 +01:00
parent 8cd4824f5a
commit 139bf0fc0e
9 changed files with 73 additions and 142 deletions

View file

@ -738,8 +738,7 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
setModified( sal_True );
}
void SAL_CALL ChartModel
::setArguments( const Sequence< beans::PropertyValue >& aArguments )
void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& aArguments )
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{

View file

@ -134,7 +134,6 @@ ImplChartModel::ImplChartModel(
xContext ), uno::UNO_QUERY );
GetStyleFamilies();
CreateDefaultChartTypeTemplate();
}
ImplChartModel::ImplChartModel( const ImplChartModel & rOther, const Reference< util::XModifyListener > & xListener ) :
@ -145,7 +144,6 @@ ImplChartModel::ImplChartModel( const ImplChartModel & rOther, const Reference<
{
m_xFamilies.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xFamilies ));
m_xChartTypeManager.set( CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager ));
m_xChartTypeTemplate.set( CreateRefClone< Reference< chart2::XChartTypeTemplate > >()( rOther.m_xChartTypeTemplate ));
m_xTitle.set( CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
ModifyListenerHelper::addListener( m_xTitle, m_xModifyListener );
m_xPageBackground.set( CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground ));
@ -238,7 +236,7 @@ Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments(
bool bSetData )
throw (lang::IllegalArgumentException)
{
Reference< chart2::data::XDataSource > xResult;
Reference< chart2::data::XDataSource > xDataSource;
try
{
OSL_ASSERT( m_spChartData.get() );
@ -247,10 +245,39 @@ Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments(
m_spChartData->getDataProvider());
if( xDataProvider.is() )
{
xResult.set( xDataProvider->createDataSource( aArguments ));
xDataSource.set( xDataProvider->createDataSource( aArguments ));
if( bSetData && xResult.is())
SetNewData( xResult, aArguments );
if( bSetData && xDataSource.is())
{
// set new data
Reference< chart2::XDiagram > xDia;
if( m_aDiagrams.size() > 0 )
xDia.set( GetDiagram(0));
Reference< chart2::XChartTypeTemplate > xTemplate;
if( xDia.is())
{
// apply new data
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram(
xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY ));
xTemplate.set( aTemplateAndService.first );
}
if( !xTemplate.is())
xTemplate.set( CreateDefaultChartTypeTemplate() );
if( xTemplate.is())
{
if( xDia.is())
xTemplate->changeDiagramData( xDia, xDataSource, aArguments );
else
{
RemoveAllDiagrams();
AppendDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ));
}
}
}
}
}
catch( lang::IllegalArgumentException & )
@ -262,27 +289,7 @@ Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments(
ASSERT_EXCEPTION( ex );
}
return xResult;
}
Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetRangeRepresentation(
const OUString & rRangeRepresentation, bool bSetData )
throw (::com::sun::star::lang::IllegalArgumentException)
{
uno::Sequence< beans::PropertyValue > aArgs( 4 );
aArgs[0] = beans::PropertyValue(
::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
uno::makeAny( rRangeRepresentation ), beans::PropertyState_DIRECT_VALUE );
aArgs[1] = beans::PropertyValue(
::rtl::OUString::createFromAscii("HasCategories"), -1,
uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
aArgs[2] = beans::PropertyValue(
::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
aArgs[3] = beans::PropertyValue(
::rtl::OUString::createFromAscii("DataRowSource"), -1,
uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
return SetArguments( aArgs, bSetData );
return xDataSource;
}
void ImplChartModel::SetChartTypeManager(
@ -296,19 +303,12 @@ Reference< chart2::XChartTypeManager > ImplChartModel::GetChartTypeManager()
return m_xChartTypeManager;
}
Reference< chart2::XChartTypeTemplate > ImplChartModel::GetChartTypeTemplate()
{
return m_xChartTypeTemplate;
}
void ImplChartModel::CreateDefaultChart()
{
CreateDefaultChartTypeTemplate();
// clean up
RemoveAllDiagrams();
Reference< chart2::XChartTypeTemplate > xTemplate( GetChartTypeTemplate());
Reference< chart2::XChartTypeTemplate > xTemplate( CreateDefaultChartTypeTemplate() );
if( xTemplate.is())
{
try
@ -316,11 +316,8 @@ void ImplChartModel::CreateDefaultChart()
Reference< chart2::data::XDataSource > xDataSource( CreateDefaultData());
Sequence< beans::PropertyValue > aParam;
Sequence< OUString > aParamNames( xTemplate->getAvailableCreationParameterNames());
const OUString * pBeg = aParamNames.getConstArray();
const OUString * pEnd = pBeg + aParamNames.getLength();
const OUString * pFound( ::std::find( pBeg, pEnd, C2U("HasCategories")));
if( pFound != pEnd )
bool bSupportsCategories = xTemplate->supportsCategories();
if( bSupportsCategories )
{
aParam.realloc( 1 );
aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ),
@ -417,7 +414,6 @@ void ImplChartModel::dispose()
DisposeHelper::DisposeAndClear( m_xFamilies );
DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
DisposeHelper::DisposeAndClear( m_xChartTypeManager );
DisposeHelper::DisposeAndClear( m_xChartTypeTemplate );
DisposeHelper::DisposeAllElements( m_aDiagrams );
m_aDiagrams.clear();
DisposeHelper::DisposeAndClear( m_xTitle );
@ -446,55 +442,36 @@ Reference< chart2::XUndoManager > ImplChartModel::GetUndoManager()
return m_xUndoManager;
}
void ImplChartModel::SetNewData( const Reference< chart2::data::XDataSource > & xDataSource,
const Sequence< beans::PropertyValue > & rArgs )
{
Reference< chart2::XDiagram > xDia;
if( m_aDiagrams.size() > 0 )
xDia.set( GetDiagram(0));
Reference< chart2::XChartTypeTemplate > xTemplate;
if( xDia.is())
{
// apply new data
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram(
xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY ));
xTemplate.set( aTemplateAndService.first );
}
if( !xTemplate.is())
xTemplate.set( GetChartTypeTemplate());
if( xTemplate.is())
{
if( xDia.is())
xTemplate->changeDiagramData( xDia, xDataSource, rArgs );
else
{
RemoveAllDiagrams();
AppendDiagram( xTemplate->createDiagramByDataSource( xDataSource, rArgs ));
}
}
}
Reference< chart2::data::XDataSource > ImplChartModel::CreateDefaultData()
{
Reference< chart2::data::XDataSource > xResult;
Reference< chart2::data::XDataSource > xDataSource;
if( m_spChartData->createDefaultData())
xResult.set( SetRangeRepresentation( C2U("all"), false /* bSetData */ ));
return xResult;
{
uno::Sequence< beans::PropertyValue > aArgs( 4 );
aArgs[0] = beans::PropertyValue(
::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
uno::makeAny( C2U("all") ), beans::PropertyState_DIRECT_VALUE );
aArgs[1] = beans::PropertyValue(
::rtl::OUString::createFromAscii("HasCategories"), -1,
uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
aArgs[2] = beans::PropertyValue(
::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
aArgs[3] = beans::PropertyValue(
::rtl::OUString::createFromAscii("DataRowSource"), -1,
uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
xDataSource = SetArguments( aArgs, false /*bSetData*/ );
}
return xDataSource;
}
void ImplChartModel::CreateDefaultChartTypeTemplate()
Reference< chart2::XChartTypeTemplate > ImplChartModel::CreateDefaultChartTypeTemplate()
{
// set default chart type
Reference< chart2::XChartTypeTemplate > xTemplate;
Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
if( xFact.is() )
{
m_xChartTypeTemplate.set(
xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY );
}
xTemplate.set( xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY );
return xTemplate;
}
Reference< uno::XInterface > ImplChartModel::GetDashTable() const

View file

@ -139,10 +139,6 @@ public:
::com::sun::star::chart2::XChartTypeManager >
GetChartTypeManager();
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartTypeTemplate >
GetChartTypeTemplate();
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
GetTitle();
@ -184,16 +180,8 @@ public:
::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier );
private:
void CreateDefaultChartTypeTemplate();
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > CreateDefaultData();
void SetNewData( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > & xDataSource,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rArgs );
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > SAL_CALL SetRangeRepresentation(
const ::rtl::OUString & rRangeRepresentation, bool bSetData )
throw (::com::sun::star::lang::IllegalArgumentException);
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate > CreateDefaultChartTypeTemplate();
::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > CreateDefaultData();
// void CreateDefaultLayout();
@ -202,13 +190,6 @@ private:
::boost::shared_ptr< ChartData > m_spChartData;
// Data Access (deprecated, temporary solution)
// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > m_xChartData;
// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider;
// ::std::vector< ::com::sun::star::uno::Reference<
// ::com::sun::star::chart2::XDataSeries > > m_aInterpretedData;
::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
m_xOwnNumberFormatsSupplier;
::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
@ -216,8 +197,6 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeManager >
m_xChartTypeManager;
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate >
m_xChartTypeTemplate;
// Diagram Access
typedef ::std::vector< ::com::sun::star::uno::Reference<

View file

@ -181,12 +181,6 @@ StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */
return StackMode_NONE;
}
bool BubbleChartTypeTemplate::supportsCategories() const
{
return false;
}
void SAL_CALL BubbleChartTypeTemplate::applyStyle(
const Reference< chart2::XDataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
@ -206,10 +200,10 @@ void SAL_CALL BubbleChartTypeTemplate::applyStyle(
}
// ____ XChartTypeTemplate ____
Sequence< OUString > SAL_CALL BubbleChartTypeTemplate::getAvailableCreationParameterNames()
sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
return Sequence< OUString >();
return false;
}
sal_Bool SAL_CALL BubbleChartTypeTemplate::matchesTemplate(

View file

@ -70,7 +70,7 @@ protected:
throw (::com::sun::star::uno::RuntimeException);
// ____ XChartTypeTemplate ____
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL matchesTemplate(
const ::com::sun::star::uno::Reference<
@ -96,8 +96,6 @@ protected:
getChartTypeForIndex( sal_Int32 nChartTypeIndex );
virtual sal_Int32 getDimension() const;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const;
virtual bool supportsCategories() const;
};
} // namespace chart

View file

@ -195,11 +195,10 @@ uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource
return xDia;
}
Sequence< OUString > SAL_CALL ChartTypeTemplate::getAvailableCreationParameterNames()
sal_Bool SAL_CALL ChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
OUString aHasCat( C2U("HasCategories"));
return Sequence< OUString >( & aHasCat, 1 );
return sal_True;
}
void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >& xDiagram )
@ -561,11 +560,6 @@ bool ChartTypeTemplate::isSwapXAndY() const
return false;
}
bool ChartTypeTemplate::supportsCategories() const
{
return true;
}
// ________________________________________
void ChartTypeTemplate::createCoordinateSystems(
@ -639,7 +633,7 @@ void ChartTypeTemplate::adaptScales(
const Reference< data::XLabeledDataSequence > & xCategories //@todo: in future there may be more than one sequence of categories (e.g. charttype with categories at x and y axis )
)
{
bool bSupportsCategories( supportsCategories());
bool bSupportsCategories( supportsCategories() );
for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
{
try

View file

@ -103,7 +103,8 @@ protected:
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
/// denotes if the chart needs categories at the first scale
virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL changeDiagram(
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram )
@ -161,9 +162,6 @@ protected:
virtual bool isSwapXAndY() const;
/// denotes if the chart needs categories at the first scale
virtual bool supportsCategories() const;
// Methods for creating the diagram piecewise
// ------------------------------------------

View file

@ -222,12 +222,6 @@ StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex *
return StackMode_NONE;
}
bool ScatterChartTypeTemplate::supportsCategories() const
{
return false;
}
void SAL_CALL ScatterChartTypeTemplate::applyStyle(
const Reference< chart2::XDataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
@ -252,10 +246,10 @@ void SAL_CALL ScatterChartTypeTemplate::applyStyle(
}
// ____ XChartTypeTemplate ____
Sequence< OUString > SAL_CALL ScatterChartTypeTemplate::getAvailableCreationParameterNames()
sal_Bool SAL_CALL ScatterChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
return Sequence< OUString >();
return sal_False;
}
sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(

View file

@ -74,7 +74,7 @@ protected:
throw (::com::sun::star::uno::RuntimeException);
// ____ XChartTypeTemplate ____
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL matchesTemplate(
const ::com::sun::star::uno::Reference<
@ -101,8 +101,6 @@ protected:
virtual sal_Int32 getDimension() const;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const;
virtual bool supportsCategories() const;
private:
bool m_bHasSymbols;
bool m_bHasLines;