summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.cxx250
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.hxx47
2 files changed, 185 insertions, 112 deletions
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
index ec51d8a69ff4..adb6a453e2d8 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: SchXMLPlotAreaContext.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: bm $ $Date: 2001-03-15 20:19:05 $
+ * last change: $Author: bm $ $Date: 2001-03-22 12:31:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -146,7 +146,9 @@ SchXMLPlotAreaContext::SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
mrImportHelper( rImpHelper ),
mrSeriesAddresses( rSeriesAddresses ),
mrCategoriesAddress( rCategoriesAddress ),
- mnDomainOffset( 0 )
+ mnDomainOffset( 0 ),
+ mnSeries( 0 ),
+ mnMaxSeriesLength( 0 )
{
// get Diagram
uno::Reference< chart::XChartDocument > xDoc( rImpHelper.GetChartDocument(), uno::UNO_QUERY );
@@ -240,12 +242,12 @@ SvXMLImportContext* SchXMLPlotAreaContext::CreateChildContext(
case XML_TOK_PA_SERIES:
{
- sal_Int32 nIndex = mrSeriesAddresses.getLength();
- mrSeriesAddresses.realloc( nIndex + 1 );
-
+ mrSeriesAddresses.realloc( mnSeries + 1 );
pContext = new SchXMLSeriesContext( mrImportHelper, GetImport(), rLocalName,
- mxDiagram, maAxes, mrSeriesAddresses[ nIndex ],
- nIndex, mnDomainOffset );
+ mxDiagram, maAxes, mrSeriesAddresses[ mnSeries ],
+ maSeriesStyleList,
+ mnSeries, mnMaxSeriesLength, mnDomainOffset );
+ mnSeries++;
}
break;
@@ -389,6 +391,103 @@ void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttri
}
}
+void SchXMLPlotAreaContext::EndElement()
+{
+ mrImportHelper.ResizeChartData( mnSeries, mnMaxSeriesLength );
+
+ uno::Reference< beans::XPropertySet > xProp;
+ sal_Int32 i;
+
+ // set autostyles for series and data points
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ const SvXMLStyleContext* pStyle = NULL;
+ ::rtl::OUString sCurrStyleName;
+
+ if( pStylesCtxt )
+ {
+ for( ::std::list< ::chartxml::DataRowPointStyle >::iterator iStyle = maSeriesStyleList.begin();
+ iStyle != maSeriesStyleList.end();
+ iStyle++ )
+ {
+ if( iStyle->mnIndex == -1 )
+ {
+ // data row style
+ for( i = 0; i < iStyle->mnRepeat; i++ )
+ {
+ try
+ {
+ xProp = mxDiagram->getDataRowProperties( iStyle->mnSeries + i );
+
+ if( xProp.is())
+ {
+ if( (iStyle->msStyleName).getLength())
+ {
+ if( ! sCurrStyleName.equals( iStyle->msStyleName ))
+ {
+ sCurrStyleName = iStyle->msStyleName;
+ pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sCurrStyleName );
+ }
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
+ }
+
+ if( iStyle->mnAttachedAxis != 1 )
+ {
+ uno::Any aAny;
+ aAny <<= chart::ChartAxisAssign::SECONDARY_Y;
+
+ xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Axis" )), aAny );
+ }
+ }
+ }
+ catch( uno::Exception aEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( aEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "PlotAreaContext:EndElement(): Exception caught: %s", aBStr.GetBuffer());
+#endif
+ }
+ }
+ }
+ else
+ {
+ // data point style
+ for( i = 0; i < iStyle->mnRepeat; i++ )
+ {
+ try
+ {
+ xProp = mxDiagram->getDataPointProperties( iStyle->mnIndex + i, iStyle->mnSeries );
+
+ if( xProp.is())
+ {
+ if( ! sCurrStyleName.equals( iStyle->msStyleName ))
+ {
+ sCurrStyleName = iStyle->msStyleName;
+ pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sCurrStyleName );
+ }
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
+ }
+ }
+ catch( uno::Exception aEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( aEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "PlotAreaContext:EndElement(): Exception caught: %s", aBStr.GetBuffer());
+#endif
+ }
+ }
+ }
+ } // styles iterator
+ }
+}
+
// ========================================
SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper,
@@ -843,16 +942,20 @@ SchXMLSeriesContext::SchXMLSeriesContext(
uno::Reference< chart::XDiagram >& xDiagram,
std::vector< SchXMLAxis >& rAxes,
com::sun::star::chart::ChartSeriesAddress& rSeriesAddress,
+ ::std::list< ::chartxml::DataRowPointStyle >& rStyleList,
sal_Int32 nSeriesIndex,
+ sal_Int32& rMaxSeriesLength,
sal_Int32& rDomainOffset ) :
SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
mxDiagram( xDiagram ),
mrAxes( rAxes ),
mrImportHelper( rImpHelper ),
mrSeriesAddress( rSeriesAddress ),
+ mrStyleList( rStyleList ),
mnSeriesIndex( nSeriesIndex ),
- mnDataPointIndex( -1 ),
+ mnDataPointIndex( 0 ),
mrDomainOffset( rDomainOffset ),
+ mrMaxSeriesLength( rMaxSeriesLength ),
mpAttachedAxis( NULL )
{
}
@@ -865,8 +968,10 @@ void SchXMLSeriesContext::StartElement( const uno::Reference< xml::sax::XAttribu
{
// parse attributes
sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
- rtl::OUString aValue;
+ ::rtl::OUString aValue;
const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetSeriesAttrTokenMap();
+ ::rtl::OUString sAutoStyleName;
+ sal_Int32 nAttachedAxis = 1;
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -897,74 +1002,37 @@ void SchXMLSeriesContext::StartElement( const uno::Reference< xml::sax::XAttribu
}
break;
case XML_TOK_SERIES_STYLE_NAME:
- msAutoStyleName = aValue;
+ sAutoStyleName = aValue;
break;
case XML_TOK_SERIES_CHART_CLASS:
// not supported yet
break;
}
}
-}
-void SchXMLSeriesContext::EndElement()
-{
- if( msAutoStyleName.getLength() &&
- mxDiagram.is())
+ if( mpAttachedAxis )
{
- uno::Reference< beans::XPropertySet > xProp;
-
- try
+ if( mpAttachedAxis->nIndexInCategory > 0 )
{
- if( mrImportHelper.GetNumberOfSeries() < mnSeriesIndex + mrDomainOffset + 1 )
- mrImportHelper.ResizeChartData( mnSeriesIndex + mrDomainOffset + 1 );
-
- xProp = mxDiagram->getDataRowProperties( mnSeriesIndex + mrDomainOffset );
+ // secondary axis => property has to be set (primary is default)
+ nAttachedAxis = 2;
}
- catch( lang::IndexOutOfBoundsException aEx )
- {
-#ifdef DBG_UTIL
- String aStr( aEx.Message );
- ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR1( "SeriesContext: Exception caught: %s", aBStr.GetBuffer());
-#endif
- }
-
- if( xProp.is())
- {
- // attach to correct axis
- if( mpAttachedAxis )
- {
- // assume attachement to primary axis
- if( mpAttachedAxis->nIndexInCategory > 0 )
- {
- // attach to secondary axis
- try
- {
- uno::Any aAny;
- aAny <<= chart::ChartAxisAssign::SECONDARY_Y;
-
- xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Axis" )), aAny );
- }
- catch( beans::UnknownPropertyException )
- {
- DBG_ERROR( "Couldn't set secondary axis property" );
- }
- }
- }
-
- const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
- if( pStylesCtxt )
- {
- const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
- mrImportHelper.GetChartFamilyID(), msAutoStyleName );
+ }
- if( pStyle && pStyle->ISA( XMLPropStyleContext ))
- (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
- }
- }
+ if( sAutoStyleName.getLength() ||
+ nAttachedAxis != 1 )
+ {
+ ::chartxml::DataRowPointStyle aStyle( mnSeriesIndex, -1, 1, sAutoStyleName, nAttachedAxis );
+ mrStyleList.push_back( aStyle );
}
}
+void SchXMLSeriesContext::EndElement()
+{
+ if( mrMaxSeriesLength < mnDataPointIndex )
+ mrMaxSeriesLength = mnDataPointIndex;
+}
+
SvXMLImportContext* SchXMLSeriesContext::CreateChildContext(
USHORT nPrefix,
const rtl::OUString& rLocalName,
@@ -987,9 +1055,8 @@ SvXMLImportContext* SchXMLSeriesContext::CreateChildContext(
}
break;
case XML_TOK_SERIES_DATA_POINT:
- mnDataPointIndex++;
pContext = new SchXMLDataPointContext( mrImportHelper, GetImport(), rLocalName, mxDiagram,
- mnSeriesIndex + mrDomainOffset, mnDataPointIndex );
+ mrStyleList, mnSeriesIndex + mrDomainOffset, mnDataPointIndex );
break;
default:
@@ -1004,10 +1071,12 @@ SvXMLImportContext* SchXMLSeriesContext::CreateChildContext(
SchXMLDataPointContext::SchXMLDataPointContext( SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName,
uno::Reference< chart::XDiagram >& xDiagram,
+ ::std::list< ::chartxml::DataRowPointStyle >& rStyleList,
sal_Int32 nSeries, sal_Int32& rIndex ) :
SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
mrImportHelper( rImpHelper ),
mxDiagram( xDiagram ),
+ mrStyleList( rStyleList ),
mnSeries( nSeries ),
mrIndex( rIndex )
{
@@ -1020,7 +1089,9 @@ SchXMLDataPointContext::~SchXMLDataPointContext()
void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
{
sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
- rtl::OUString aValue;
+ ::rtl::OUString aValue;
+ ::rtl::OUString sAutoStyleName;
+ sal_Int32 nRepeat = 1;
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -1031,51 +1102,18 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr
if( nPrefix == XML_NAMESPACE_CHART )
{
if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_style_name )))
- msAutoStyleName = xAttrList->getValueByIndex( i );
+ sAutoStyleName = xAttrList->getValueByIndex( i );
else if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_repeated )))
- mrIndex += xAttrList->getValueByIndex( i ).toInt32() - 1;
+ nRepeat = xAttrList->getValueByIndex( i ).toInt32();
}
}
-}
-void SchXMLDataPointContext::EndElement()
-{
- if( msAutoStyleName.getLength() &&
- mxDiagram.is())
+ if( sAutoStyleName.getLength())
{
- uno::Reference< beans::XPropertySet > xProp;
-
- try
- {
- if( mrImportHelper.GetNumberOfSeries() < mnSeries + 1 ||
- mrImportHelper.GetLengthOfSeries() < mrIndex + 1 )
- mrImportHelper.ResizeChartData( mnSeries + 1, mrIndex + 1 );
-
- xProp = mxDiagram->getDataPointProperties( mnSeries, mrIndex );
- }
- catch( lang::IndexOutOfBoundsException aEx )
- {
-#ifdef DBG_UTIL
- String aStr( aEx.Message );
- ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR1( "SeriesContext: Exception caught: %s", aBStr.GetBuffer());
-#endif
- }
-
- // set properties
- if( xProp.is())
- {
- const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
- if( pStylesCtxt )
- {
- const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
- mrImportHelper.GetChartFamilyID(), msAutoStyleName );
-
- if( pStyle && pStyle->ISA( XMLPropStyleContext ))
- (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
- }
- }
+ ::chartxml::DataRowPointStyle aStyle( mnSeries, mrIndex, nRepeat, sAutoStyleName );
+ mrStyleList.push_back( aStyle );
}
+ mrIndex += nRepeat;
}
// ========================================
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
index 629e52d4fecf..a43571b772d9 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: SchXMLPlotAreaContext.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: bm $ $Date: 2001-01-15 08:58:30 $
+ * last change: $Author: bm $ $Date: 2001-03-22 12:31:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,6 +72,8 @@
#include <com/sun/star/chart/ChartSeriesAddress.hpp>
#endif
+#include <list>
+
#include "transporttypes.hxx"
class SvXMLImport;
@@ -87,6 +89,32 @@ namespace com { namespace sun { namespace star {
// ----------------------------------------
+namespace chartxml
+{
+
+struct DataRowPointStyle
+{
+ sal_Int32 mnSeries;
+ sal_Int32 mnIndex;
+ sal_Int32 mnRepeat;
+ ::rtl::OUString msStyleName;
+ sal_Int32 mnAttachedAxis;
+
+ DataRowPointStyle( sal_Int32 nSeries, sal_Int32 nIndex, sal_Int32 nRepeat, ::rtl::OUString sStyleName,
+ sal_Int32 nAttachedAxis = 0 ) :
+ mnSeries( nSeries ),
+ mnIndex( nIndex ),
+ mnRepeat( nRepeat ),
+ msStyleName( sStyleName ),
+ mnAttachedAxis( nAttachedAxis )
+ {}
+};
+
+} // namespace
+
+
+// ----------------------------------------
+
class SchXMLPlotAreaContext : public SvXMLImportContext
{
private:
@@ -95,7 +123,10 @@ private:
std::vector< SchXMLAxis > maAxes;
com::sun::star::uno::Sequence< com::sun::star::chart::ChartSeriesAddress >& mrSeriesAddresses;
rtl::OUString& mrCategoriesAddress;
+ ::std::list< ::chartxml::DataRowPointStyle > maSeriesStyleList;
sal_Int32 mnDomainOffset;
+ sal_Int32 mnSeries;
+ sal_Int32 mnMaxSeriesLength;
public:
SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
@@ -110,6 +141,7 @@ public:
USHORT nPrefix,
const rtl::OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
};
// ----------------------------------------
@@ -150,9 +182,10 @@ private:
com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram;
std::vector< SchXMLAxis >& mrAxes;
com::sun::star::chart::ChartSeriesAddress& mrSeriesAddress;
- rtl::OUString msAutoStyleName;
+ ::std::list< ::chartxml::DataRowPointStyle >& mrStyleList;
sal_Int32 mnSeriesIndex;
sal_Int32 mnDataPointIndex;
+ sal_Int32& mrMaxSeriesLength;
sal_Int32& mrDomainOffset;
SchXMLAxis* mpAttachedAxis;
@@ -162,16 +195,18 @@ public:
com::sun::star::uno::Reference< com::sun::star::chart::XDiagram >& xDiagram,
std::vector< SchXMLAxis >& rAxes,
com::sun::star::chart::ChartSeriesAddress& rSeriesAddress,
+ ::std::list< ::chartxml::DataRowPointStyle >& rStyleList,
sal_Int32 nSeriesIndex,
+ sal_Int32& rMaxSeriesLength,
sal_Int32& rDomainOffset );
~SchXMLSeriesContext();
virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
- virtual void EndElement();
virtual SvXMLImportContext* CreateChildContext(
USHORT nPrefix,
const rtl::OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
};
//----------------------------------------
@@ -181,7 +216,7 @@ class SchXMLDataPointContext : public SvXMLImportContext
private:
SchXMLImportHelper& mrImportHelper;
com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram;
- rtl::OUString msAutoStyleName;
+ ::std::list< ::chartxml::DataRowPointStyle >& mrStyleList;
sal_Int32 mnSeries;
sal_Int32& mrIndex;
@@ -189,11 +224,11 @@ public:
SchXMLDataPointContext( SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName,
com::sun::star::uno::Reference< com::sun::star::chart::XDiagram >& xDiagram,
+ ::std::list< ::chartxml::DataRowPointStyle >& rStyleList,
sal_Int32 nSeries, sal_Int32& rIndex );
virtual ~SchXMLDataPointContext();
virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
- virtual void EndElement();
};
// ----------------------------------------