#95993# export/import stock chart properties for gain, loss and the range line

This commit is contained in:
Björn Milcke 2001-12-17 09:22:11 +00:00
parent 2c6c3d1d43
commit 219fc02285
7 changed files with 244 additions and 26 deletions

View file

@ -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

View file

@ -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

View file

@ -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
// ----------------------

View file

@ -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
};

View file

@ -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 );
}
}
}
}
}

View file

@ -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_

View file

@ -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
};