/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #include"vbachart.hxx" #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> #include <com/sun/star/chart/XAxisXSupplier.hpp> #include <com/sun/star/chart/XAxisYSupplier.hpp> #include <com/sun/star/chart/XAxisZSupplier.hpp> #include <com/sun/star/chart/XTwoAxisXSupplier.hpp> #include <com/sun/star/chart/XTwoAxisYSupplier.hpp> #include <com/sun/star/chart/XChartDataArray.hpp> #include <com/sun/star/chart/ChartSymbolType.hpp> #include <com/sun/star/chart/ChartSolidType.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <ooo/vba/excel/XlChartType.hpp> #include <ooo/vba/excel/XlRowCol.hpp> #include <ooo/vba/excel/XlAxisType.hpp> #include <ooo/vba/excel/XlAxisGroup.hpp>
ScVbaChart::ScVbaChart( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::lang::XComponent >& _xChartComponent, css::uno::Reference< css::table::XTableChart > _xTableChart ) : ChartImpl_BASE( _xParent, _xContext ), mxTableChart(std::move( _xTableChart ))
{
mxChartDocument.set( _xChartComponent, uno::UNO_QUERY_THROW ) ; // #TODO is it possible that the XPropertySet interface is not set // code in setPlotBy seems to indicate that this is possible? but // additionally there is no check in most of the places where it is used // ( and therefore could possibly be NULL ) // I'm going to let it throw for the moment ( npower )
mxDiagramPropertySet.set( mxChartDocument->getDiagram(), uno::UNO_QUERY_THROW );
mxChartPropertySet.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
}
void SAL_CALL
ScVbaChart::setChartType( ::sal_Int32 _nChartType )
{ try
{ switch (_nChartType)
{ case xlColumnClustered: case xlColumnStacked: case xlColumnStacked100: case xl3DColumnClustered: case xl3DColumnStacked: case xl3DColumnStacked100: case xl3DColumn: case xlBarClustered: case xlBarStacked: case xlBarStacked100: case xl3DBarClustered: case xl3DBarStacked: case xl3DBarStacked100: case xlConeColClustered: case xlConeColStacked: case xlConeColStacked100: case xlConeBarClustered: case xlConeBarStacked: case xlConeBarStacked100: case xlConeCol: case xlPyramidColClustered: case xlPyramidColStacked: case xlPyramidColStacked100: case xlPyramidBarClustered: case xlPyramidBarStacked: case xlPyramidBarStacked100: case xlPyramidCol: case xlCylinderColClustered: case xlCylinderColStacked: case xlCylinderColStacked100: case xlCylinderBarClustered: case xlCylinderBarStacked: case xlCylinderBarStacked100: case xlCylinderCol: case xlSurface: // not possible case xlSurfaceWireframe: case xlSurfaceTopView: case xlSurfaceTopViewWireframe:
setDiagram( u"com.sun.star.chart.BarDiagram"_ustr); break; case xlLine: case xl3DLine: case xlLineStacked: case xlLineStacked100: case xlLineMarkers: case xlLineMarkersStacked: case xlLineMarkersStacked100:
setDiagram( u"com.sun.star.chart.LineDiagram"_ustr); break; case xl3DArea: case xlArea: case xlAreaStacked: case xlAreaStacked100: case xl3DAreaStacked: case xl3DAreaStacked100:
setDiagram( u"com.sun.star.chart.AreaDiagram"_ustr ); break; case xlDoughnut: case xlDoughnutExploded:
setDiagram( u"com.sun.star.chart.DonutDiagram"_ustr ); break; case xlStockHLC: case xlStockOHLC: case xlStockVHLC: case xlStockVOHLC:
setDiagram( u"com.sun.star.chart.StockDiagram"_ustr);
mxDiagramPropertySet->setPropertyValue( UPDOWN, uno::Any((_nChartType == xlStockOHLC) || (_nChartType == xlStockVOHLC)));
mxDiagramPropertySet->setPropertyValue( VOLUME, uno::Any((_nChartType == xlStockVHLC) || (_nChartType == xlStockVOHLC))); break;
case xlPieOfPie: // not possible case xlPieExploded: // SegmentOffset on ChartDataPointProperties -> get from XDiagram //How does Excel do this? case xl3DPieExploded: case xl3DPie: case xlPie: case xlBarOfPie: // not possible (Zoom pie)
setDiagram( u"com.sun.star.chart.PieDiagram"_ustr); break;
case xlRadar: case xlRadarMarkers: case xlRadarFilled:
setDiagram( u"com.sun.star.chart.NetDiagram"_ustr); break; case xlXYScatter: case xlBubble: // not possible case xlBubble3DEffect: // not possible case xlXYScatterLines: case xlXYScatterLinesNoMarkers: case xlXYScatterSmooth: case xlXYScatterSmoothNoMarkers:
setDiagram( u"com.sun.star.chart.XYDiagram"_ustr); switch(_nChartType)
{ case xlXYScatter: case xlBubble: // not possible case xlBubble3DEffect: // not possible
mxDiagramPropertySet->setPropertyValue(LINES, uno::Any( false )); break; case xlXYScatterLines: case xlXYScatterLinesNoMarkers:
mxDiagramPropertySet->setPropertyValue(LINES, uno::Any( true )); break; case xlXYScatterSmooth: case xlXYScatterSmoothNoMarkers:
mxDiagramPropertySet->setPropertyValue(SPLINETYPE, uno::Any( sal_Int32(1))); break; default: break;
} break; default: throw script::BasicErrorException( OUString(), uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_CONVERSION), OUString() );
}
switch (_nChartType)
{ case xlLineMarkers: case xlLineMarkersStacked: case xlLineMarkersStacked100: case xlRadarMarkers: case xlXYScatterLines: case xlXYScatterSmooth: case xlXYScatter: case xlBubble: // not possible case xlBubble3DEffect: // not possible
mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::Any( chart::ChartSymbolType::AUTO)); break; default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SYMBOLTYPE))
{
mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::Any(chart::ChartSymbolType::NONE));
} break;
}
switch (_nChartType)
{ case xlConeCol: case xlPyramidCol: case xlCylinderCol: case xl3DColumn: case xlSurface: // not possible case xlSurfaceWireframe: case xlSurfaceTopView: case xlSurfaceTopViewWireframe:
mxDiagramPropertySet->setPropertyValue(DEEP,uno::Any( true )); break; default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DEEP))
{
mxDiagramPropertySet->setPropertyValue(DEEP, uno::Any( false));
} break;
}
switch (_nChartType)
{ case xlConeColClustered: case xlConeColStacked: case xlConeColStacked100: case xlConeBarClustered: case xlConeBarStacked: case xlConeBarStacked100: case xlConeCol:
mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::Any(chart::ChartSolidType::CONE)); break; case xlPyramidColClustered: case xlPyramidColStacked: case xlPyramidColStacked100: case xlPyramidBarClustered: case xlPyramidBarStacked: case xlPyramidBarStacked100: case xlPyramidCol:
mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::Any(chart::ChartSolidType::PYRAMID)); break; case xlCylinderColClustered: case xlCylinderColStacked: case xlCylinderColStacked100: case xlCylinderBarClustered: case xlCylinderBarStacked: case xlCylinderBarStacked100: case xlCylinderCol:
mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::Any(chart::ChartSolidType::CYLINDER)); break; default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
{
mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::Any(chart::ChartSolidType::RECTANGULAR_SOLID));
} break;
}
switch ( _nChartType)
{ case xlConeCol: case xlConeColClustered: case xlConeColStacked: case xlConeColStacked100: case xlPyramidColClustered: case xlPyramidColStacked: case xlPyramidColStacked100: case xlCylinderColClustered: case xlCylinderColStacked: case xlCylinderColStacked100: case xlColumnClustered: case xlColumnStacked: case xlColumnStacked100: case xl3DColumnClustered: case xl3DColumnStacked: case xl3DColumnStacked100: case xlSurface: // not possible case xlSurfaceWireframe: case xlSurfaceTopView: case xlSurfaceTopViewWireframe:
mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::Any( true)); break; default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(VERTICAL))
{
mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::Any(false));
} break;
}
switch (_nChartType)
{ case xlColumnStacked: case xl3DColumnStacked: case xlBarStacked: case xl3DBarStacked: case xlLineStacked: case xlLineMarkersStacked: case xlAreaStacked: case xl3DAreaStacked: case xlCylinderColStacked: case xlCylinderBarStacked: case xlConeColStacked: case xlConeBarStacked: case xlPyramidColStacked: case xlPyramidBarStacked:
mxDiagramPropertySet->setPropertyValue(PERCENT, uno::Any( false ));
mxDiagramPropertySet->setPropertyValue(STACKED, uno::Any( true )); break; case xlPyramidColStacked100: case xlPyramidBarStacked100: case xlConeColStacked100: case xlConeBarStacked100: case xlCylinderBarStacked100: case xlCylinderColStacked100: case xl3DAreaStacked100: case xlLineMarkersStacked100: case xlAreaStacked100: case xlLineStacked100: case xl3DBarStacked100: case xlBarStacked100: case xl3DColumnStacked100: case xlColumnStacked100:
mxDiagramPropertySet->setPropertyValue(STACKED, uno::Any( true));
mxDiagramPropertySet->setPropertyValue(PERCENT, uno::Any( true )); break; default:
mxDiagramPropertySet->setPropertyValue(PERCENT, uno::Any( false));
mxDiagramPropertySet->setPropertyValue(STACKED, uno::Any( false)); break;
} switch (_nChartType)
{ case xl3DArea: case xl3DAreaStacked: case xl3DAreaStacked100: case xl3DBarClustered: case xl3DBarStacked: case xl3DBarStacked100: case xl3DColumn: case xl3DColumnClustered: case xl3DColumnStacked: case xl3DColumnStacked100: case xl3DLine: case xl3DPie: case xl3DPieExploded: case xlConeColClustered: case xlConeColStacked: case xlConeColStacked100: case xlConeBarClustered: case xlConeBarStacked: case xlConeBarStacked100: case xlConeCol: case xlPyramidColClustered: case xlPyramidColStacked: case xlPyramidColStacked100: case xlPyramidBarClustered: case xlPyramidBarStacked: case xlPyramidBarStacked100: case xlPyramidCol: case xlCylinderColClustered: case xlCylinderColStacked: case xlCylinderColStacked100: case xlCylinderBarClustered: case xlCylinderBarStacked: case xlCylinderBarStacked100: case xlCylinderCol:
mxDiagramPropertySet->setPropertyValue(DIM3D, uno::Any( true)); break; default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DIM3D))
{
mxDiagramPropertySet->setPropertyValue(DIM3D, uno::Any( false));
} break;
}
} catch ( const uno::Exception& )
{ throw script::BasicErrorException( OUString(), uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
}
}
void SAL_CALL
ScVbaChart::Activate()
{ // #TODO how are Chart sheets handled ( I know we don't even consider // them in the worksheets/sheets collections ), but...??? // note: in vba for excel the parent of a Chart sheet is a workbook, // e.g. 'ThisWorkbook'
uno::Reference< XHelperInterface > xParent( getParent() );
ScVbaChartObject* pChartObj = static_cast< ScVbaChartObject* >( xParent.get() ); if ( !pChartObj ) throw script::BasicErrorException( OUString(), uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), u"no ChartObject as parent"_ustr );
// #TODO find out why we have Location/getLocation? there is afaik no // Location property, just a Location function for the Chart object
sal_Int32 SAL_CALL
ScVbaChart::Location()
{ return getLocation();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.