summaryrefslogtreecommitdiffstats
path: root/chart2/source/model/template/LineChartTypeTemplate.cxx
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2007-05-22 17:49:33 +0000
committerVladimir Glazounov <vg@openoffice.org>2007-05-22 17:49:33 +0000
commit27895b78cb25f74c47374bd0ee9513261b741dc9 (patch)
tree8e81a81c354ae5fff4fc7ce2a2e5d187b63334bd /chart2/source/model/template/LineChartTypeTemplate.cxx
parentINTEGRATION: CWS chart2mst3 (1.5.4); FILE MERGED (diff)
downloadcore-27895b78cb25f74c47374bd0ee9513261b741dc9.tar.gz
core-27895b78cb25f74c47374bd0ee9513261b741dc9.zip
INTEGRATION: CWS chart2mst3 (1.11.4); FILE MERGED
2007/03/26 14:16:53 iha 1.11.4.22: #i75590# copy some aspects from old charttype during creation of new 2007/02/23 18:08:48 iha 1.11.4.21: #i74655# symbols lost when switching smooth lines 2006/10/18 17:14:13 bm 1.11.4.20: RESYNC: (1.12-1.13); FILE MERGED 2005/12/20 14:13:26 dr 1.11.4.19: API struct member names without prefixes 2005/10/30 12:42:40 iha 1.11.4.18: #125770# detect symbolstyle correctly 2005/10/07 12:03:39 bm 1.11.4.17: RESYNC: (1.11-1.12); FILE MERGED 2005/08/05 14:19:57 bm 1.11.4.16: getStackMode: per chart type (open: percent stacking works per coordinate system, how can this be synched) 2005/08/04 11:53:42 bm 1.11.4.15: set stack mode at new series. Percent stacking is now set in adaptScales 2005/08/03 16:36:23 bm 1.11.4.14: algohelper.hxx split up into CommonFunctors.hxx ContainerHelper.hxx CloneHelper.hxx 2005/04/11 09:40:57 iha 1.11.4.13: defines for servicenames for charttypes (fixed apply to 2nd axis again) 2004/09/16 15:24:26 bm 1.11.4.12: API simplification 2004/09/16 12:27:28 bm 1.11.4.11: API simplification 2004/09/15 17:32:05 bm 1.11.4.10: API simplification 2004/06/29 12:26:34 bm 1.11.4.9: XChartTypeTemplate changes 2004/05/27 17:27:12 bm 1.11.4.8: +getChartTypeForNewSeries at XChartTypeTemplate 2004/05/07 15:34:35 bm 1.11.4.7: applyStyle works for single series now 2004/04/20 19:21:34 iha 1.11.4.6: make curve style an adabtable property 2004/04/20 18:55:12 iha 1.11.4.5: enable chart type: points only on category axis; make curve style an adabtable property 2004/04/19 12:00:46 iha 1.11.4.4: set spline resolution and order to matching template 2004/04/01 10:53:10 bm 1.11.4.3: XChartType: may return a coordinate system now 2004/03/24 19:05:24 bm 1.11.4.2: XChartTypeTemplate changed: matchesTemplate may modify the template s properties if bAdaptProperties is true 2004/02/13 16:51:42 bm 1.11.4.1: join from changes on branch bm_post_chart01
Diffstat (limited to 'chart2/source/model/template/LineChartTypeTemplate.cxx')
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.cxx250
1 files changed, 125 insertions, 125 deletions
diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx
index 980028c5bd5e..d5d40d20e181 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: LineChartTypeTemplate.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: obo $ $Date: 2006-09-17 13:19:11 $
+ * last change: $Author: vg $ $Date: 2007-05-22 18:49:33 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -36,10 +36,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include "LineChartTypeTemplate.hxx"
-#include "LineChartType.hxx"
#include "macros.hxx"
-#include "algohelper.hxx"
-#include "DataSeriesTreeHelper.hxx"
+#include "DiagramHelper.hxx"
+#include "servicenames_charttypes.hxx"
+#include "ContainerHelper.hxx"
+#include "DataSeriesHelper.hxx"
#ifndef _COM_SUN_STAR_CHART2_SYMBOLSTYLE_HPP_
#include <com/sun/star/chart2/SymbolStyle.hpp>
@@ -78,6 +79,7 @@ static const OUString lcl_aServiceName(
enum
{
+ PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE,
PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER
@@ -87,6 +89,12 @@ void lcl_AddPropertiesToVector(
::std::vector< Property > & rOutProperties )
{
rOutProperties.push_back(
+ Property( C2U( "CurveStyle" ),
+ PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE,
+ ::getCppuType( reinterpret_cast< const chart2::CurveStyle * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+ rOutProperties.push_back(
Property( C2U( "CurveResolution" ),
PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
@@ -101,8 +109,12 @@ void lcl_AddPropertiesToVector(
}
void lcl_AddDefaultsToMap(
- ::chart::helper::tPropertyValueMap & rOutMap )
+ ::chart::tPropertyValueMap & rOutMap )
{
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ rOutMap[ PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ] =
+ uno::makeAny( chart2::CurveStyle_LINES );
+
OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
rOutMap[ PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ] =
uno::makeAny( sal_Int32( 20 ) );
@@ -128,10 +140,10 @@ const Sequence< Property > & lcl_GetPropertySequence()
// and sort them for access via bsearch
::std::sort( aProperties.begin(), aProperties.end(),
- ::chart::helper::PropertyNameLess() );
+ ::chart::PropertyNameLess() );
// transfer result to static Sequence
- aPropSeq = ::chart::helper::VectorToSequence( aProperties );
+ aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
}
return aPropSeq;
@@ -155,20 +167,20 @@ LineChartTypeTemplate::LineChartTypeTemplate(
uno::Reference<
uno::XComponentContext > const & xContext,
const ::rtl::OUString & rServiceName,
- chart2::StackMode eYStackMode,
- chart2::CurveStyle eCurveStyle,
+ StackMode eStackMode,
bool bSymbols,
- sal_Int32 nDim /* = 2 */,
- chart2::StackMode eZStackMode /* = NONE */ ) :
+ bool bHasLines /* = true */,
+ sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
::property::OPropertySet( m_aMutex ),
- m_eYStackMode( eYStackMode ),
- m_eCurveStyle( eCurveStyle ),
+ m_eStackMode( eStackMode ),
m_bHasSymbols( bSymbols ),
- m_bHasLines( true ),
- m_nDim( nDim ),
- m_eZStackMode( eZStackMode )
-{}
+ m_bHasLines( bHasLines ),
+ m_nDim( nDim )
+{
+ if( nDim == 3 )
+ m_bHasSymbols = false;
+}
LineChartTypeTemplate::~LineChartTypeTemplate()
{}
@@ -176,7 +188,7 @@ LineChartTypeTemplate::~LineChartTypeTemplate()
uno::Any LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
throw(beans::UnknownPropertyException)
{
- static helper::tPropertyValueMap aStaticDefaults;
+ static tPropertyValueMap aStaticDefaults;
// /--
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
@@ -186,7 +198,7 @@ uno::Any LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
lcl_AddDefaultsToMap( aStaticDefaults );
}
- helper::tPropertyValueMap::const_iterator aFound(
+ tPropertyValueMap::const_iterator aFound(
aStaticDefaults.find( nHandle ));
if( aFound == aStaticDefaults.end())
@@ -226,106 +238,69 @@ sal_Int32 LineChartTypeTemplate::getDimension() const
return m_nDim;
}
-chart2::StackMode LineChartTypeTemplate::getYStackMode() const
-{
- return m_eYStackMode;
-}
-
-chart2::StackMode LineChartTypeTemplate::getZStackMode() const
+StackMode LineChartTypeTemplate::getStackMode( sal_Int32 nChartTypeIndex ) const
{
- if( m_nDim == 2 )
- return chart2::StackMode_NONE;
-
- return m_eZStackMode;
+ return m_eStackMode;
}
-uno::Reference< chart2::XChartType > LineChartTypeTemplate::getDefaultChartType()
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
+ const uno::Reference< chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
throw (uno::RuntimeException)
{
- sal_Int32 nRes;
- sal_Int32 nOrder;
+ sal_Bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
- if( ( getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ) >>= nRes ) &&
- ( getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ) >>= nOrder ) )
+ // check symbol-style and line-style
+ // for a template with symbols (or with lines) it is ok, if there is at least one series
+ // with symbols (or with lines)
+ if( bResult )
{
- return new LineChartType( m_nDim, m_eCurveStyle, nRes, nOrder );
- }
+ ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
- return new LineChartType( m_nDim, m_eCurveStyle );
-}
-
-// ____ XChartTypeTemplate ____
-uno::Reference< chart2::XDiagram > SAL_CALL
- LineChartTypeTemplate::createDiagram(
- const uno::Sequence< uno::Reference< chart2::XDataSeries > >& aSeriesSeq )
- throw (uno::RuntimeException)
-{
- // set symbol type at data series
- chart2::SymbolStyle eStyle = m_bHasSymbols
- ? chart2::SymbolStyle_STANDARD
- : chart2::SymbolStyle_NONE;
-
- uno::Any aLineStyleToSet( uno::makeAny(
- m_bHasLines
- ? drawing::LineStyle_SOLID
- : drawing::LineStyle_NONE ));
- for( sal_Int32 i = 0; i < aSeriesSeq.getLength(); ++i )
- {
- try
+ for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aIt =
+ aSeriesVec.begin(); aIt != aSeriesVec.end(); ++aIt )
{
- chart2::Symbol aSymbProp;
- Reference< beans::XPropertySet > xProp( aSeriesSeq[i], uno::UNO_QUERY_THROW );
- if( (xProp->getPropertyValue( C2U( "Symbol" )) >>= aSymbProp ) )
- {
- aSymbProp.aStyle = eStyle;
- if( m_bHasSymbols )
- aSymbProp.nStandardSymbol = i;
- xProp->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbProp ));
- }
-
- if( m_bHasLines )
+ try
{
- // keep line-styles that are not NONE
+ chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- if( (xProp->getPropertyValue( C2U( "LineStyle" )) >>= eLineStyle ) &&
- eLineStyle == drawing::LineStyle_NONE )
+ Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY_THROW );
+
+ if( (xProp->getPropertyValue( C2U( "Symbol" )) >>= aSymbProp) &&
+ (aSymbProp.Style != chart2::SymbolStyle_NONE) &&
+ (!m_bHasSymbols) )
+ {
+ bResult = false;
+ break;
+ }
+
+ if( (xProp->getPropertyValue( C2U( "LineStyle" )) >>= eLineStyle) &&
+ (m_bHasLines != ( eLineStyle != drawing::LineStyle_NONE )) )
{
- xProp->setPropertyValue( C2U( "LineStyle" ), aLineStyleToSet );
+ bResult = false;
+ break;
}
}
- else
- xProp->setPropertyValue( C2U( "LineStyle" ), aLineStyleToSet );
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
}
}
- // todo: set symbol type at data points
-
- return ChartTypeTemplate::createDiagram( aSeriesSeq );
-}
-
-sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
- const uno::Reference< chart2::XDiagram >& xDiagram )
- throw (uno::RuntimeException)
-{
- sal_Bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram );
-
- // check curve-style
- if( bResult )
+ // adapt curve style, spline order and resolution
+ if( bResult && bAdaptProperties )
{
try
{
- uno::Reference< beans::XPropertySet > xCTProp(
- helper::DataSeriesTreeHelper::getChartTypeByIndex( xDiagram->getTree(), 0 ),
+ uno::Reference< beans::XPropertySet > xChartTypeProp(
+ DiagramHelper::getChartTypeByIndex( xDiagram, 0 ),
uno::UNO_QUERY_THROW );
- chart2::CurveStyle eCurveStyle;
- if( xCTProp->getPropertyValue( C2U( "CurveStyle" )) >>= eCurveStyle )
- {
- bResult = ( eCurveStyle == m_eCurveStyle );
- }
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(C2U("CurveStyle" )) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(C2U("CurveResolution" )) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(C2U("SplineOrder" )) );
}
catch( uno::Exception & ex )
{
@@ -333,38 +308,63 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
}
}
- // check symbol-style
- if( bResult )
+ return bResult;
+}
+
+Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+ throw (uno::RuntimeException)
+{
+ Reference< chart2::XChartType > xResult;
+
+ try
{
- uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq(
- helper::DataSeriesTreeHelper::getDataSeriesFromDiagram( xDiagram ));
- chart2::SymbolStyle eStyle = m_bHasSymbols
- ? chart2::SymbolStyle_STANDARD
- : chart2::SymbolStyle_NONE;
+ Reference< lang::XMultiServiceFactory > xFact(
+ GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
+ xResult.set( xFact->createInstance(
+ CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes, xResult );
- for( sal_Int32 i = 0; i < aSeriesSeq.getLength(); ++i )
+ Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
+ if( xCTProp.is())
{
- try
- {
- chart2::Symbol aSymbProp;
- uno::Reference< beans::XPropertySet > xProp( aSeriesSeq[i], uno::UNO_QUERY_THROW );
- if( (xProp->getPropertyValue( C2U( "Symbol" )) >>= aSymbProp ) )
- {
- if( aSymbProp.aStyle != eStyle )
- {
- bResult = false;
- break;
- }
- }
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
+ xCTProp->setPropertyValue(
+ C2U( "CurveStyle" ), getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xCTProp->setPropertyValue(
+ C2U( "CurveResolution" ), getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xCTProp->setPropertyValue(
+ C2U( "SplineOrder" ), getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
}
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
- return bResult;
+ return xResult;
+}
+
+void SAL_CALL LineChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+ throw (uno::RuntimeException)
+{
+ ChartTypeTemplate::applyStyle( 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 );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
}
// ----------------------------------------