Kaydet (Commit) 4074f6f9 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

improve chart series symbol export

Using the chart2 service allows us to export series symbols instead of
the diagram settings.

Change-Id: Ic46f067b60c972af35c0628b3ec4f7851580d725
üst 2a149037
...@@ -162,7 +162,7 @@ private: ...@@ -162,7 +162,7 @@ private:
sal_Int32 nSeriesLength ); sal_Int32 nSeriesLength );
void exportGrouping( bool isBar = false ); void exportGrouping( bool isBar = false );
void exportTrendlines( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > xSeries ); void exportTrendlines( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > xSeries );
void exportMarker(); void exportMarker( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > xSeries );
void exportSmooth(); void exportSmooth();
void exportFirstSliceAng(); void exportFirstSliceAng();
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp> #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp> #include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp> #include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart2/data/XDataSink.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp>
...@@ -1657,6 +1658,7 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_ ...@@ -1657,6 +1658,7 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
if( xSource.is()) if( xSource.is())
{ {
Reference< chart2::XDataSeries > xDataSeries( xSource, uno::UNO_QUERY );
Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt( Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
xSource->getDataSequences()); xSource->getDataSequences());
// search for main sequence and create a series element // search for main sequence and create a series element
...@@ -1727,7 +1729,7 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_ ...@@ -1727,7 +1729,7 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
{ {
case chart::TYPEID_LINE: case chart::TYPEID_LINE:
{ {
exportMarker( ); exportMarker(xDataSeries);
break; break;
} }
case chart::TYPEID_PIE: case chart::TYPEID_PIE:
...@@ -1745,12 +1747,12 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_ ...@@ -1745,12 +1747,12 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
} }
case chart::TYPEID_SCATTER: case chart::TYPEID_SCATTER:
{ {
exportMarker( ); exportMarker(xDataSeries);
break; break;
} }
case chart::TYPEID_RADARLINE: case chart::TYPEID_RADARLINE:
{ {
exportMarker( ); exportMarker(xDataSeries);
break; break;
} }
} }
...@@ -2947,48 +2949,55 @@ void ChartExport::exportTrendlines( Reference< chart2::XDataSeries > xSeries ) ...@@ -2947,48 +2949,55 @@ void ChartExport::exportTrendlines( Reference< chart2::XDataSeries > xSeries )
} }
} }
void ChartExport::exportMarker() void ChartExport::exportMarker(Reference< chart2::XDataSeries > xSeries)
{ {
Reference< XPropertySet > xPropSet( xSeries, uno::UNO_QUERY );
chart2::Symbol aSymbol;
if( GetProperty( xPropSet, "Symbol" ) )
mAny >>= aSymbol;
if(aSymbol.Style != chart2::SymbolStyle_STANDARD && aSymbol.Style != chart2::SymbolStyle_AUTO)
return;
FSHelperPtr pFS = GetFS(); FSHelperPtr pFS = GetFS();
pFS->startElement( FSNS( XML_c, XML_marker ), pFS->startElement( FSNS( XML_c, XML_marker ),
FSEND ); FSEND );
Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY );
sal_Int32 nSymbolType = ::com::sun::star::chart::ChartSymbolType::NONE;
if( GetProperty( xPropSet, "SymbolType" ) )
mAny >>= nSymbolType;
sal_Int32 nSymbol = aSymbol.StandardSymbol;
// TODO: more properties support for marker // TODO: more properties support for marker
const char* pSymbolType = NULL; const char* pSymbolType = NULL;
switch( nSymbolType ) switch( nSymbol )
{ {
case cssc::ChartSymbolType::NONE: case 0:
pSymbolType = "none";
break;
case cssc::ChartSymbolType::SYMBOL0:
pSymbolType = "square"; pSymbolType = "square";
break; break;
case cssc::ChartSymbolType::SYMBOL1: case 1:
pSymbolType = "diamond"; pSymbolType = "diamond";
break; break;
// map all triangle variants to the OOXML version case 2:
case cssc::ChartSymbolType::SYMBOL2: case 3:
case cssc::ChartSymbolType::SYMBOL3: case 4:
case cssc::ChartSymbolType::SYMBOL4: case 5:
case cssc::ChartSymbolType::SYMBOL5:
pSymbolType = "triangle"; pSymbolType = "triangle";
break; break;
case cssc::ChartSymbolType::SYMBOL6: case 8:
pSymbolType = "plus"; pSymbolType = "circle";
break; break;
case cssc::ChartSymbolType::SYMBOL7: case 9:
pSymbolType = "plus"; pSymbolType = "star";
break;
case 10:
pSymbolType = "X";
break; break;
case cssc::ChartSymbolType::AUTO: case 11:
pSymbolType = "plus";
break; break;
case cssc::ChartSymbolType::BITMAPURL: case 13:
pSymbolType = "dash";
break; break;
default: default:
SAL_WARN("oox", "unknown data series symbol"); pSymbolType = "square";
break;
} }
if( pSymbolType ) if( pSymbolType )
...@@ -2997,21 +3006,16 @@ void ChartExport::exportMarker() ...@@ -2997,21 +3006,16 @@ void ChartExport::exportMarker()
XML_val, pSymbolType, XML_val, pSymbolType,
FSEND ); FSEND );
} }
if( nSymbolType != cssc::ChartSymbolType::NONE )
{
awt::Size aSymbolSize;
if( GetProperty( xPropSet, "SymbolSize" ) )
{
mAny >>= aSymbolSize;;
sal_Int32 nSize = std::max( aSymbolSize.Width, aSymbolSize.Height );
nSize = nSize/250.0*7.0; // just guessed based on some test cases awt::Size aSymbolSize = aSymbol.Size;
nSize = std::min<sal_Int32>( 72, std::max<sal_Int32>( 2, nSize ) ); sal_Int32 nSize = std::max( aSymbolSize.Width, aSymbolSize.Height );
pFS->singleElement( FSNS( XML_c, XML_size),
XML_val, I32S(nSize), nSize = nSize/250.0*7.0; // just guessed based on some test cases
FSEND ); nSize = std::min<sal_Int32>( 72, std::max<sal_Int32>( 2, nSize ) );
} pFS->singleElement( FSNS( XML_c, XML_size),
} XML_val, I32S(nSize),
FSEND );
pFS->endElement( FSNS( XML_c, XML_marker ) ); pFS->endElement( FSNS( XML_c, XML_marker ) );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment