summaryrefslogtreecommitdiffstats
path: root/chart2/source/model/template/LineChartTypeTemplate.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/model/template/LineChartTypeTemplate.cxx')
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.cxx222
1 files changed, 86 insertions, 136 deletions
diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx
index bbde1bebc3f1..e4d347960f18 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.cxx
@@ -18,10 +18,12 @@
*/
#include "LineChartTypeTemplate.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include "LineChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
+#include <ChartType.hxx>
#include <unonames.hxx>
#include <com/sun/star/chart2/CurveStyle.hpp>
@@ -30,8 +32,7 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -52,89 +53,58 @@ enum
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticLineChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticLineChartTypeTemplateInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE,
cppu::UnoType<chart2::CurveStyle>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-}
-
-struct StaticLineChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticLineChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeTemplateInfoHelper_Initializer >
-{
-};
-
-struct StaticLineChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
+}
-struct StaticLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeTemplateInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeTemplateInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -150,7 +120,6 @@ LineChartTypeTemplate::LineChartTypeTemplate(
bool bHasLines /* = true */,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode ),
m_bHasSymbols( bSymbols ),
m_bHasLines( bHasLines ),
@@ -166,7 +135,7 @@ LineChartTypeTemplate::~LineChartTypeTemplate()
// ____ OPropertySet ____
void LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticLineChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
rAny.clear();
@@ -176,13 +145,13 @@ void LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny )
::cppu::IPropertyArrayHelper & SAL_CALL LineChartTypeTemplate::getInfoHelper()
{
- return *StaticLineChartTypeTemplateInfoHelper::get();
+ return StaticLineChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartTypeTemplate::getPropertySetInfo()
{
- return *StaticLineChartTypeTemplateInfo::get();
+ return StaticLineChartTypeTemplateInfo();
}
sal_Int32 LineChartTypeTemplate::getDimension() const
@@ -195,12 +164,12 @@ StackMode LineChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ )
return m_eStackMode;
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
- const uno::Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+// ____ ChartTypeTemplate ____
+bool LineChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
// check symbol-style and line-style
// for a template with symbols (or with lines) it is ok, if there is at least one series
@@ -210,8 +179,8 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
bool bSymbolFound = false;
bool bLineFound = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
@@ -219,9 +188,8 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
{
chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ bool bCurrentHasSymbol = (series->getPropertyValue( "Symbol") >>= aSymbProp) &&
(aSymbProp.Style != chart2::SymbolStyle_NONE);
if( bCurrentHasSymbol )
@@ -233,7 +201,7 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
break;
}
- bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ bool bCurrentHasLine = (series->getPropertyValue( "LineStyle") >>= eLineStyle) &&
( eLineStyle != drawing::LineStyle_NONE );
if( bCurrentHasLine )
@@ -267,12 +235,10 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
{
try
{
- uno::Reference< beans::XPropertySet > xChartTypeProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ),
- uno::UNO_QUERY_THROW );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
+ rtl::Reference< ChartType > xChartType = xDiagram->getChartTypeByIndex( 0 );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartType->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartType->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartType->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
}
catch( const uno::Exception & )
{
@@ -283,27 +249,20 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > LineChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > LineChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
-
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult = new LineChartType();
+
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -313,30 +272,23 @@ Reference< chart2::XChartType > LineChartTypeTemplate::getChartTypeForIndex( sal
return xResult;
}
-Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > LineChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xResult = new LineChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -346,21 +298,19 @@ Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForN
return xResult;
}
-void SAL_CALL LineChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void LineChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
- DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
- DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 );
+ DataSeriesHelper::switchSymbolsOnOrOff( xSeries, m_bHasSymbols, nSeriesIndex );
+ DataSeriesHelper::switchLinesOnOrOff( xSeries, m_bHasLines );
+ DataSeriesHelper::makeLinesThickOrThin( xSeries, m_nDim==2 );
}
catch( const uno::Exception & )
{