diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2008-04-18 13:21:22 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2008-04-18 13:21:22 +0000 |
commit | 9b78e44d793bb1a7df27da2172f87d28cf1cb2b5 (patch) | |
tree | 52f0b8b8ecfe9898b156837aed35e38c8396f77a /oox/source/drawingml/chart | |
parent | 789a9b6d62dc89028134ccaf3b8086d4269f3d80 (diff) |
INTEGRATION: CWS xmlfilter04 (1.1.2); FILE ADDED
2008/04/18 12:10:48 rt 1.1.2.2: Change license header to LGPL v3.
2008/03/12 14:22:30 dr 1.1.2.1: more code finetuning
Diffstat (limited to 'oox/source/drawingml/chart')
-rw-r--r-- | oox/source/drawingml/chart/chartspaceconverter.cxx | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx new file mode 100644 index 000000000000..1efe8e9821a1 --- /dev/null +++ b/oox/source/drawingml/chart/chartspaceconverter.cxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: chartspaceconverter.cxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/drawingml/chart/chartspaceconverter.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include "oox/core/filterbase.hxx" +#include "oox/drawingml/chart/chartconverter.hxx" +#include "oox/drawingml/chart/chartspacemodel.hxx" +#include "oox/drawingml/chart/plotareaconverter.hxx" +#include "oox/drawingml/chart/titleconverter.hxx" + +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::util::XNumberFormatsSupplier; +using ::com::sun::star::chart2::XTitled; +using ::com::sun::star::chart2::data::XDataReceiver; + +namespace oox { +namespace drawingml { +namespace chart { + +// ============================================================================ + +ChartSpaceConverter::ChartSpaceConverter( const ConverterRoot& rParent, ChartSpaceModel& rModel ) : + ConverterBase< ChartSpaceModel >( rParent, rModel ) +{ +} + +ChartSpaceConverter::~ChartSpaceConverter() +{ +} + +void ChartSpaceConverter::convertModelToDocument() +{ + /* create data provider (virtual function in the ChartConverter class, + derived converters may create an external data provider) */ + getChartConverter().createDataProvider( getChartDocument() ); + + // attach number formatter of container document to data receiver + try + { + Reference< XDataReceiver > xDataRec( getChartDocument(), UNO_QUERY_THROW ); + Reference< XNumberFormatsSupplier > xNumFmtSupp( getFilter().getModel(), UNO_QUERY_THROW ); + xDataRec->attachNumberFormatsSupplier( xNumFmtSupp ); + } + catch( Exception& ) + { + } + + // convert plot area (container of all chart type groups) + PlotAreaConverter aPlotAreaConv( *this, mrModel.mxPlotArea.getOrCreate() ); + OUString aAutoTitle = aPlotAreaConv.convertModelToDocument( mrModel.mxView3D.getOrCreate() ); + + // chart title + if( !mrModel.mbAutoTitleDel ) try + { + /* If the title model is missing, but the chart shows exactly one + series, the series title is shown as chart title. */ + if( mrModel.mxTitle.is() || (aAutoTitle.getLength() > 0) ) + { + if( aAutoTitle.getLength() == 0 ) + aAutoTitle = CREATE_OUSTRING( "Chart Title" ); + Reference< XTitled > xTitled( getChartDocument(), UNO_QUERY_THROW ); + TitleConverter aTitleConv( *this, mrModel.mxTitle.getOrCreate() ); + aTitleConv.convertModelToDocument( xTitled, aAutoTitle ); + } + } + catch( Exception& ) + { + } + + // legend + if( mrModel.mxLegend.is() ) + { + LegendConverter aLegendConv( *this, *mrModel.mxLegend ); + aLegendConv.convertModelToDocument( getChartDocument()->getFirstDiagram() ); + } +} + +// ============================================================================ + +} // namespace chart +} // namespace drawingml +} // namespace oox + |