diff options
author | Björn Milcke <bm@openoffice.org> | 2001-12-17 09:22:11 +0000 |
---|---|---|
committer | Björn Milcke <bm@openoffice.org> | 2001-12-17 09:22:11 +0000 |
commit | 219fc02285128f252f8f7e0201f9eb9925f4639b (patch) | |
tree | c657014a979b45802099c9b20c8634a00711f431 /xmloff | |
parent | 2c6c3d1d43d6aee85c4ce4d0a565b0bd0c63d182 (diff) |
#95993# export/import stock chart properties for gain, loss and the range line
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/dtd/chart.mod | 21 | ||||
-rw-r--r-- | xmloff/inc/SchXMLImport.hxx | 9 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 99 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLImport.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLPlotAreaContext.cxx | 93 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLPlotAreaContext.hxx | 33 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 8 |
7 files changed, 244 insertions, 26 deletions
diff --git a/xmloff/dtd/chart.mod b/xmloff/dtd/chart.mod index 6989f8b8d464..2f479424fec5 100644 --- a/xmloff/dtd/chart.mod +++ b/xmloff/dtd/chart.mod @@ -1,5 +1,5 @@ <!-- - $Id: chart.mod,v 1.27 2001-12-14 18:47:17 dvo Exp $ + $Id: chart.mod,v 1.28 2001-12-17 10:22:10 bm Exp $ The Contents of this file are made available subject to the terms of either of the following licenses @@ -128,6 +128,9 @@ chart:axis*, chart:categories?, chart:series*, + chart:stock-gain-marker?, + chart:stock-loss-marker?, + chart:stock-range-line?, chart:wall?, chart:floor?) > @@ -168,6 +171,20 @@ svg:width %length; #IMPLIED chart:style-name %styleName; #IMPLIED > +<!-- Stock chart elements --> + +<!ELEMENT chart:stock-gain-marker EMPTY> +<!ATTLIST chart:stock-gain-marker + chart:style-name %styleName; #IMPLIED > + +<!ELEMENT chart:stock-loss-marker EMPTY> +<!ATTLIST chart:stock-loss-marker + chart:style-name %styleName; #IMPLIED > + +<!ELEMENT chart:stock-range-line EMPTY> +<!ATTLIST chart:stock-range-line + chart:style-name %styleName; #IMPLIED > + <!-- Axis --> <!ELEMENT chart:axis (chart:title?, chart:grid*)> @@ -204,7 +221,7 @@ <!ELEMENT chart:categories EMPTY> <!ATTLIST chart:categories - table:cell-range-address %cell-range-address; #REQUIRED > + table:cell-range-address %cell-range-address; #IMPLIED > <!-- each series element must have an cell-range-address element that points diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx index 59eaf7ad770d..d36c7939fcf7 100644 --- a/xmloff/inc/SchXMLImport.hxx +++ b/xmloff/inc/SchXMLImport.hxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLImport.hxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: bm $ $Date: 2001-10-23 09:58:39 $ + * last change: $Author: bm $ $Date: 2001-12-17 10:22:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,7 +120,10 @@ enum SchXMLPlotAreaElemTokenMap XML_TOK_PA_CATEGORIES, XML_TOK_PA_WALL, XML_TOK_PA_FLOOR, - XML_TOK_PA_LIGHT_SOURCE + XML_TOK_PA_LIGHT_SOURCE, + XML_TOK_PA_STOCK_GAIN, + XML_TOK_PA_STOCK_LOSS, + XML_TOK_PA_STOCK_RANGE }; enum SchXMLSeriesElemTokenMap diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index e3516ed73cea..e60fb9b44beb 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLExport.cxx,v $ * - * $Revision: 1.62 $ + * $Revision: 1.63 $ * - * last change: $Author: dvo $ $Date: 2001-10-25 20:57:02 $ + * last change: $Author: bm $ $Date: 2001-12-17 10:22:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -158,6 +158,9 @@ #ifndef _COM_SUN_STAR_CHART_X3DDISPLAY_HPP_ #include <com/sun/star/chart/X3DDisplay.hpp> #endif +#ifndef _COM_SUN_STAR_CHART_XSTATISTICDISPLAY_HPP_ +#include <com/sun/star/chart/XStatisticDisplay.hpp> +#endif #ifndef _COM_SUN_STAR_UTIL_XSTRINGMAPPING_HPP_ #include <com/sun/star/util/XStringMapping.hpp> @@ -303,6 +306,7 @@ void SchXMLExportHelper::parseDocument( uno::Reference< chart::XChartDocument >& // determine if data is in rows sal_Bool bSwitchData = sal_False; uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + rtl::OUString sChartType ( xDiagram->getDiagramType()); if( xDiaProp.is()) { try @@ -315,7 +319,6 @@ void SchXMLExportHelper::parseDocument( uno::Reference< chart::XChartDocument >& mbRowSourceColumns = ( eRowSource == chart::ChartDataRowSource_COLUMNS ); // the chart core treats donut chart with interchanged rows/columns - rtl::OUString sChartType = xDiagram->getDiagramType(); if( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.DonutDiagram" ))) { mbRowSourceColumns = ! mbRowSourceColumns; @@ -415,16 +418,11 @@ void SchXMLExportHelper::parseDocument( uno::Reference< chart::XChartDocument >& // attributes // determine class - rtl::OUString sChartType; - if( xDiagram.is()) - { - // domain axes are also needed for auto-styles - sChartType = xDiagram->getDiagramType(); - if( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.XYDiagram" ))) - mnDomainAxes = 1; - else - mnDomainAxes = 0; - } + // domain axes are also needed for auto-styles + if( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.XYDiagram" ))) + mnDomainAxes = 1; + else + mnDomainAxes = 0; if( bExportContent ) { @@ -1522,6 +1520,81 @@ void SchXMLExportHelper::exportPlotArea( uno::Reference< chart::XDiagram > xDiag delete pSeries; } + // stock-chart elements + rtl::OUString sChartType ( xDiagram->getDiagramType()); + if( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" ))) + { + uno::Reference< chart::XStatisticDisplay > xStockPropProvider( xDiagram, uno::UNO_QUERY ); + if( xStockPropProvider.is()) + { + // stock-gain-marker + uno::Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getUpBar(); + if( xStockPropSet.is()) + { + aPropertyStates.clear(); + aPropertyStates = mxExpPropMapper->Filter( xStockPropSet ); + + if( aPropertyStates.size() > 0 ) + { + if( bExportContent ) + { + AddAutoStyleAttribute( aPropertyStates ); + + SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, sal_True, sal_True ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + } + } + + // stock-loss-marker + xStockPropSet = xStockPropProvider->getDownBar(); + if( xStockPropSet.is()) + { + aPropertyStates.clear(); + aPropertyStates = mxExpPropMapper->Filter( xStockPropSet ); + + if( aPropertyStates.size() > 0 ) + { + if( bExportContent ) + { + AddAutoStyleAttribute( aPropertyStates ); + + SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, sal_True, sal_True ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + } + } + + // stock-range-line + xStockPropSet = xStockPropProvider->getMinMaxLine(); + if( xStockPropSet.is()) + { + aPropertyStates.clear(); + aPropertyStates = mxExpPropMapper->Filter( xStockPropSet ); + + if( aPropertyStates.size() > 0 ) + { + if( bExportContent ) + { + AddAutoStyleAttribute( aPropertyStates ); + + SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, sal_True, sal_True ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + } + } + } + } + // wall and floor element // ---------------------- diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index eddaa1267646..a7a5156014e1 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLImport.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: bm $ $Date: 2001-10-23 09:58:54 $ + * last change: $Author: bm $ $Date: 2001-12-17 10:22:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -154,6 +154,9 @@ static __FAR_DATA SvXMLTokenMapEntry aPlotAreaElemTokenMap[] = { XML_NAMESPACE_CHART, XML_WALL, XML_TOK_PA_WALL }, { XML_NAMESPACE_CHART, XML_FLOOR, XML_TOK_PA_FLOOR }, { XML_NAMESPACE_DR3D, XML_LIGHT, XML_TOK_PA_LIGHT_SOURCE }, + { XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, XML_TOK_PA_STOCK_GAIN }, + { XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, XML_TOK_PA_STOCK_LOSS }, + { XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, XML_TOK_PA_STOCK_RANGE }, XML_TOKEN_MAP_END }; diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index a4cbbdace926..dbbf20d6941b 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLPlotAreaContext.cxx,v $ * - * $Revision: 1.26 $ + * $Revision: 1.27 $ * - * last change: $Author: dvo $ $Date: 2001-06-29 21:07:11 $ + * last change: $Author: bm $ $Date: 2001-12-17 10:22:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -122,6 +122,9 @@ #ifndef _COM_SUN_STAR_CHART_X3DDISPLAY_HPP_ #include <com/sun/star/chart/X3DDisplay.hpp> #endif +#ifndef _COM_SUN_STAR_CHART_XSTATISTICDISPLAY_HPP_ +#include <com/sun/star/chart/XStatisticDisplay.hpp> +#endif #ifndef _COM_SUN_STAR_AWT_POINT_HPP_ #include <com/sun/star/awt/Point.hpp> @@ -278,6 +281,20 @@ SvXMLImportContext* SchXMLPlotAreaContext::CreateChildContext( pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList ); break; + // elements for stock charts + case XML_TOK_PA_STOCK_GAIN: + pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + SchXMLStockContext::CONTEXT_TYPE_GAIN ); + break; + case XML_TOK_PA_STOCK_LOSS: + pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + SchXMLStockContext::CONTEXT_TYPE_LOSS ); + break; + case XML_TOK_PA_STOCK_RANGE: + pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + SchXMLStockContext::CONTEXT_TYPE_RANGE ); + break; + default: pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } @@ -1292,3 +1309,75 @@ void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttr } } } + +// ======================================== + +SchXMLStockContext::SchXMLStockContext( + SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const rtl::OUString& rLocalName, + uno::Reference< chart::XDiagram >& xDiagram, + ContextType eContextType ) : + SvXMLImportContext( rImport, nPrefix, rLocalName ), + mrImportHelper( rImpHelper ), + mxStockPropProvider( xDiagram, uno::UNO_QUERY ), + meContextType( eContextType ) +{ +} + +SchXMLStockContext::~SchXMLStockContext() +{ +} + +void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +{ + if( mxStockPropProvider.is()) + { + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + rtl::OUString sAutoStyleName; + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + rtl::OUString aLocalName; + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if( nPrefix == XML_NAMESPACE_CHART && + IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + { + sAutoStyleName = xAttrList->getValueByIndex( i ); + } + } + + if( sAutoStyleName.getLength()) + { + // set properties + uno::Reference< beans::XPropertySet > xProp; + switch( meContextType ) + { + case CONTEXT_TYPE_GAIN: + xProp = mxStockPropProvider->getUpBar(); + break; + case CONTEXT_TYPE_LOSS: + xProp = mxStockPropProvider->getDownBar(); + break; + case CONTEXT_TYPE_RANGE: + xProp = mxStockPropProvider->getMinMaxLine(); + break; + } + if( xProp.is()) + { + const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); + if( pStylesCtxt ) + { + const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( + mrImportHelper.GetChartFamilyID(), sAutoStyleName ); + + if( pStyle && pStyle->ISA( XMLPropStyleContext )) + (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp ); + } + } + } + } +} diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx index 6c93fa89cef7..5640578eb4cb 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLPlotAreaContext.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: bm $ $Date: 2001-05-17 15:48:47 $ + * last change: $Author: bm $ $Date: 2001-12-17 10:22:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,6 +85,7 @@ namespace com { namespace sun { namespace star { namespace chart { class XDiagram; class X3DDisplay; + class XStatisticDisplay; } namespace xml { namespace sax { class XAttributeList; @@ -289,4 +290,32 @@ public: virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); }; +// ---------------------------------------- + +class SchXMLStockContext : public SvXMLImportContext +{ +public: + enum ContextType + { + CONTEXT_TYPE_GAIN, + CONTEXT_TYPE_LOSS, + CONTEXT_TYPE_RANGE + }; + +private: + SchXMLImportHelper& mrImportHelper; + com::sun::star::uno::Reference< com::sun::star::chart::XStatisticDisplay > mxStockPropProvider; + ContextType meContextType; + +public: + SchXMLStockContext( SchXMLImportHelper& rImportHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const rtl::OUString& rLocalName, + com::sun::star::uno::Reference< com::sun::star::chart::XDiagram >& xDiagram, + ContextType eContextType ); + ~SchXMLStockContext(); + virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); +}; + #endif // _SCH_XMLPLOTAREACONTEXT_HXX_ diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 40ce2f6f6b65..80faabb9b532 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltoken.cxx,v $ * - * $Revision: 1.26 $ + * $Revision: 1.27 $ * - * last change: $Author: dvo $ $Date: 2001-11-30 17:43:01 $ + * last change: $Author: bm $ $Date: 2001-12-17 10:22:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -2083,6 +2083,10 @@ namespace xmloff { namespace token { TOKEN( "merge-last-paragraph"), // XML_MERGE_LAST_PARAGRAPH + TOKEN( "stock-loss-marker" ), // XML_STOCK_LOSS_MARKER + TOKEN( "stock-gain-marker" ), // XML_STOCK_GAIN_MARKER + TOKEN( "stock-range-line" ), // XML_STOCK_RANGE_LINE + { 0, NULL, NULL } // XML_TOKEN_END }; |