2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
#include "ObjectNameProvider.hxx"
|
|
|
|
#include "ResId.hxx"
|
|
|
|
#include "Strings.hrc"
|
|
|
|
#include "macros.hxx"
|
|
|
|
#include "AxisHelper.hxx"
|
|
|
|
#include "ChartModelHelper.hxx"
|
|
|
|
#include "DiagramHelper.hxx"
|
|
|
|
#include "DataSeriesHelper.hxx"
|
|
|
|
#include "TitleHelper.hxx"
|
|
|
|
#include "AxisIndexDefines.hxx"
|
|
|
|
#include "ExplicitCategoriesProvider.hxx"
|
|
|
|
#include "CommonConverters.hxx"
|
2011-01-14 18:11:00 +01:00
|
|
|
#include "NumberFormatterWrapper.hxx"
|
2007-07-03 12:37:23 +00:00
|
|
|
#include "RegressionCurveHelper.hxx"
|
2007-05-22 16:28:29 +00:00
|
|
|
#include <rtl/math.hxx>
|
2013-09-23 07:19:08 +01:00
|
|
|
#include <rtl/ustring.hxx>
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/chart2/XTitle.hpp>
|
2007-07-03 12:37:23 +00:00
|
|
|
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::chart2;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString lcl_getDataSeriesName( const OUString& rObjectCID, const Reference< frame::XModel >& xChartModel )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
OUString aRet;
|
|
|
|
|
|
|
|
Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
|
|
|
|
Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY );
|
|
|
|
if( xDiagram.is() && xSeries.is() )
|
|
|
|
{
|
|
|
|
Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
|
|
|
|
if( xChartType.is() )
|
|
|
|
{
|
|
|
|
aRet = ::chart::DataSeriesHelper::getDataSeriesLabel(
|
|
|
|
xSeries, xChartType->getRoleOfSequenceForSeriesLabel() ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString lcl_getFullSeriesName( const OUString& rObjectCID, const Reference< frame::XModel >& xChartModel )
|
2009-09-11 16:06:18 +00:00
|
|
|
{
|
2013-07-27 17:01:36 +01:00
|
|
|
OUString aRet(SCH_RESSTR(STR_TIP_DATASERIES));
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aWildcard( "%SERIESNAME" );
|
2009-09-11 16:06:18 +00:00
|
|
|
sal_Int32 nIndex = aRet.indexOf( aWildcard );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) );
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:28:29 +00:00
|
|
|
void lcl_addText( OUString& rOut, const OUString& rSeparator, const OUString& rNext )
|
|
|
|
{
|
2011-12-10 22:03:11 -02:00
|
|
|
if( !(rOut.isEmpty() || rNext.isEmpty()) )
|
2007-05-22 16:28:29 +00:00
|
|
|
rOut+=rSeparator;
|
2011-12-10 22:03:11 -02:00
|
|
|
if( !rNext.isEmpty() )
|
2007-05-22 16:28:29 +00:00
|
|
|
rOut+=rNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal_Int32 nPointIndex,
|
|
|
|
const Reference< XCoordinateSystem >& xCooSys,
|
|
|
|
const Reference< frame::XModel >& xChartModel )
|
|
|
|
{
|
|
|
|
|
|
|
|
OUString aRet;
|
|
|
|
|
|
|
|
Reference<data::XDataSource> xDataSource(
|
|
|
|
uno::Reference<data::XDataSource>( xSeries, uno::UNO_QUERY ) );
|
|
|
|
if(!xDataSource.is())
|
|
|
|
return aRet;
|
|
|
|
|
|
|
|
Sequence< Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aX, aY, aY_Min, aY_Max, aY_First, aY_Last, a_Size;
|
2007-08-03 11:34:30 +00:00
|
|
|
double fValue = 0;
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY );
|
|
|
|
NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
|
|
|
|
sal_Int32 nLabelColor = 0;//dummy
|
|
|
|
bool bColorChanged;//dummy
|
|
|
|
|
|
|
|
for(sal_Int32 nN = aDataSequences.getLength();nN--;)
|
|
|
|
{
|
|
|
|
uno::Reference<data::XDataSequence> xDataSequence( aDataSequences[nN]->getValues());
|
|
|
|
if( !xDataSequence.is() )
|
|
|
|
continue;
|
|
|
|
Sequence< Any > aData( xDataSequence->getData() );
|
|
|
|
if( nPointIndex >= aData.getLength() )
|
|
|
|
continue;
|
|
|
|
uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY );
|
|
|
|
if( xProp.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
uno::Any aARole = xProp->getPropertyValue( "Role" );
|
|
|
|
OUString aRole;
|
2007-05-22 16:28:29 +00:00
|
|
|
aARole >>= aRole;
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
if( aRole == "values-x" )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
aData[nPointIndex]>>= fValue;
|
|
|
|
sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
|
|
|
|
aX = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
|
|
|
|
}
|
2012-10-06 22:23:08 -03:00
|
|
|
else if( aRole == "values-y")
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
aData[nPointIndex]>>= fValue;
|
|
|
|
sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
|
|
|
|
aY = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
|
|
|
|
}
|
2012-10-06 22:23:08 -03:00
|
|
|
else if( aRole == "values-first" )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
aData[nPointIndex]>>= fValue;
|
|
|
|
sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
|
|
|
|
aY_First = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
|
|
|
|
}
|
2012-10-06 22:23:08 -03:00
|
|
|
else if( aRole == "values-min" )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
aData[nPointIndex]>>= fValue;
|
|
|
|
sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
|
|
|
|
aY_Min = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
|
|
|
|
}
|
2012-10-06 22:23:08 -03:00
|
|
|
else if( aRole == "values-max" )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
aData[nPointIndex]>>= fValue;
|
|
|
|
sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
|
|
|
|
aY_Max = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
|
|
|
|
}
|
2012-10-06 22:23:08 -03:00
|
|
|
else if( aRole == "values-last" )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
aData[nPointIndex]>>= fValue;
|
|
|
|
sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
|
|
|
|
aY_Last = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
|
|
|
|
}
|
2012-10-06 22:23:08 -03:00
|
|
|
else if( aRole == "values-size" )
|
2009-07-02 19:17:43 +00:00
|
|
|
{
|
|
|
|
aData[nPointIndex]>>= fValue;
|
|
|
|
sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
|
|
|
|
a_Size = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
|
|
|
|
}
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
2011-11-29 02:06:57 +09:00
|
|
|
catch( const uno::Exception& e )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
ASSERT_EXCEPTION( e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-10 22:03:11 -02:00
|
|
|
if( aX.isEmpty() )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
2013-10-15 07:55:26 +02:00
|
|
|
ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get());
|
|
|
|
aRet = ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, *pModel, nPointIndex );
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aRet = aX;
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aSeparator( " " );
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
lcl_addText( aRet, aSeparator, aY );
|
|
|
|
lcl_addText( aRet, aSeparator, aY_First );
|
|
|
|
lcl_addText( aRet, aSeparator, aY_Min );
|
|
|
|
lcl_addText( aRet, aSeparator, aY_Max );
|
|
|
|
lcl_addText( aRet, aSeparator, aY_Last );
|
2009-07-02 19:17:43 +00:00
|
|
|
lcl_addText( aRet, aSeparator, a_Size );
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
} //end anonymous namespace
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aRet;
|
2007-05-22 16:28:29 +00:00
|
|
|
switch( eObjectType )
|
|
|
|
{
|
|
|
|
case OBJECTTYPE_PAGE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_PAGE);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_TITLE:
|
|
|
|
{
|
|
|
|
if(bPlural)
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLES);
|
2007-05-22 16:28:29 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE);
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OBJECTTYPE_LEGEND:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_LEGEND);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_LEGEND_ENTRY:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_LEGEND_SYMBOL);//@todo change string if we do differenciate symbol and legend entry in future
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DIAGRAM:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DIAGRAM);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DIAGRAM_WALL:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DIAGRAM_WALL);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DIAGRAM_FLOOR:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DIAGRAM_FLOOR);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_AXIS:
|
|
|
|
{
|
|
|
|
if(bPlural)
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_AXES);
|
2007-05-22 16:28:29 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_AXIS);
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OBJECTTYPE_AXIS_UNITLABEL:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_LABEL);//@todo maybe a more concrete name
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_GRID:
|
|
|
|
case OBJECTTYPE_SUBGRID: //maybe todo: different names for subgrids
|
|
|
|
{
|
|
|
|
if(bPlural)
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRIDS);
|
2007-05-22 16:28:29 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID);
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_SERIES:
|
|
|
|
{
|
|
|
|
if(bPlural)
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DATASERIES_PLURAL);
|
2007-05-22 16:28:29 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DATASERIES);
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_POINT:
|
|
|
|
{
|
|
|
|
if(bPlural)
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DATAPOINTS);
|
2007-05-22 16:28:29 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DATAPOINT);
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_LABELS:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_DATALABELS);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_LABEL:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_LABEL);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_ERRORS_X:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_ERROR_BARS_X);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_ERRORS_Y:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_ERROR_BARS_Y);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_ERRORS_Z:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_ERROR_BARS_Z);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_AVERAGE_LINE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_AVERAGE_LINE);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_CURVE:
|
2009-09-11 16:06:18 +00:00
|
|
|
{
|
|
|
|
if(bPlural)
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_CURVES);
|
2009-09-11 16:06:18 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_CURVE);
|
2009-09-11 16:06:18 +00:00
|
|
|
}
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_STOCK_RANGE:
|
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_STOCK_LOSS:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_STOCK_LOSS);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case OBJECTTYPE_DATA_STOCK_GAIN:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_STOCK_GAIN);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
2007-11-23 10:45:30 +00:00
|
|
|
case OBJECTTYPE_DATA_CURVE_EQUATION:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_CURVE_EQUATION);
|
2007-11-23 10:45:30 +00:00
|
|
|
break;
|
2007-05-22 16:28:29 +00:00
|
|
|
default: //OBJECTTYPE_UNKNOWN
|
|
|
|
;
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
2011-01-17 17:25:58 +01:00
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getAxisName( const OUString& rObjectCID
|
2007-05-22 16:28:29 +00:00
|
|
|
, const uno::Reference< frame::XModel >& xChartModel )
|
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aRet;
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
Reference< XAxis > xAxis(
|
|
|
|
ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY );
|
|
|
|
|
2009-09-11 16:06:18 +00:00
|
|
|
sal_Int32 nCooSysIndex = 0;
|
|
|
|
sal_Int32 nDimensionIndex = 0;
|
|
|
|
sal_Int32 nAxisIndex = 0;
|
|
|
|
AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ), nCooSysIndex, nDimensionIndex, nAxisIndex );
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
switch(nDimensionIndex)
|
|
|
|
{
|
|
|
|
case 0://x-axis
|
2009-09-11 16:06:18 +00:00
|
|
|
if( nAxisIndex == 0 )
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_AXIS_X);
|
2009-09-11 16:06:18 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_SECONDARY_X_AXIS);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case 1://y-axis
|
2009-09-11 16:06:18 +00:00
|
|
|
if( nAxisIndex == 0 )
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_AXIS_Y);
|
2009-09-11 16:06:18 +00:00
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_SECONDARY_Y_AXIS);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case 2://z-axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_AXIS_Z);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
default://axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_AXIS);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2009-09-11 16:06:18 +00:00
|
|
|
OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType )
|
|
|
|
{
|
|
|
|
OUString aRet;
|
|
|
|
|
|
|
|
switch(eType)
|
|
|
|
{
|
|
|
|
case TitleHelper::MAIN_TITLE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE_MAIN);
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
case TitleHelper::SUB_TITLE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE_SUB);
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
case TitleHelper::X_AXIS_TITLE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE_X_AXIS);
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
case TitleHelper::Y_AXIS_TITLE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE_Y_AXIS);
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
case TitleHelper::Z_AXIS_TITLE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE_Z_AXIS);
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
case TitleHelper::SECONDARY_X_AXIS_TITLE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE_SECONDARY_X_AXIS);
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
case TitleHelper::SECONDARY_Y_AXIS_TITLE:
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE_SECONDARY_Y_AXIS);
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("unknown title type");
|
2009-09-11 16:06:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-10 22:03:11 -02:00
|
|
|
if( aRet.isEmpty() )
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE);
|
2009-09-11 16:06:18 +00:00
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:28:29 +00:00
|
|
|
OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID
|
|
|
|
, const Reference< frame::XModel >& xChartModel )
|
|
|
|
{
|
|
|
|
OUString aRet;
|
|
|
|
|
Revert "fdo#46808, Convert chart2::Title service to new style"
This reverts commit d256dbede60533369d1aac64cca34721183f6a8a:
For one, the new css.chart2.XTitle2 looked unfinished, in that it transfered the
direct properties of the old-style css.chart2.Title service into attributes, but
left out all the properties inherited by the old-style service from
css.style.ParagraphProperties, css.drawing.FillProperties,
css.drawing.LineProperties (and that missing FIXME css.layout.LayoutElement,
whatever that is supposed to be). This needs more thought, to either make
available all propertiers as attributes, or none.
For another, this broke JunitTest_chart2_unoapi (sch.ChXChartDocument,
sch.ChartTitle), for hard-to-debug reasons.
Conflicts:
chart2/source/model/main/Title.cxx
chart2/source/model/main/Title.hxx
offapi/com/sun/star/chart2/XTitle2.idl
sc/source/filter/inc/xlchart.hxx
Change-Id: I4747208a13984904d0e409ea49a73b0f667c86c7
2013-05-23 10:11:49 +02:00
|
|
|
Reference< XTitle > xTitle(
|
2007-05-22 16:28:29 +00:00
|
|
|
ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY );
|
|
|
|
if( xTitle.is() )
|
|
|
|
{
|
|
|
|
TitleHelper::eTitleType eType;
|
|
|
|
if( TitleHelper::getTitleType( eType, xTitle, xChartModel ) )
|
2009-09-11 16:06:18 +00:00
|
|
|
aRet = ObjectNameProvider::getTitleNameByType( eType );
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
2011-12-10 22:03:11 -02:00
|
|
|
if( aRet.isEmpty() )
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_TITLE);
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getGridName( const OUString& rObjectCID
|
2007-05-22 16:28:29 +00:00
|
|
|
, const uno::Reference< frame::XModel >& xChartModel )
|
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aRet;
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
sal_Int32 nCooSysIndex = -1;
|
|
|
|
sal_Int32 nDimensionIndex = -1;
|
|
|
|
sal_Int32 nAxisIndex = -1;
|
|
|
|
Reference< XAxis > xAxis( ObjectIdentifier::getAxisForCID( rObjectCID , xChartModel ) );
|
|
|
|
AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel )
|
|
|
|
, nCooSysIndex , nDimensionIndex, nAxisIndex );
|
|
|
|
|
|
|
|
bool bMainGrid = (ObjectIdentifier::getObjectType( rObjectCID ) == OBJECTTYPE_GRID);
|
|
|
|
|
|
|
|
if( bMainGrid )
|
|
|
|
{
|
|
|
|
switch(nDimensionIndex)
|
|
|
|
{
|
|
|
|
case 0://x-axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID_MAJOR_X);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case 1://y-axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID_MAJOR_Y);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case 2://z-axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID_MAJOR_Z);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
default://axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(nDimensionIndex)
|
|
|
|
{
|
|
|
|
case 0://x-axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID_MINOR_X);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case 1://y-axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID_MINOR_Y);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
case 2://z-axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID_MINOR_Z);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
default://axis
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_OBJECT_GRID);
|
2007-05-22 16:28:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Reference< chart2::XChartDocument >& xChartDocument, bool bVerbose )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
|
|
|
return getHelpText( rObjectCID, Reference< frame::XModel >( xChartDocument, uno::UNO_QUERY ), bVerbose );
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Reference< frame::XModel >& xChartModel, bool bVerbose )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aRet;
|
2007-05-22 16:28:29 +00:00
|
|
|
ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) );
|
|
|
|
if( OBJECTTYPE_AXIS == eObjectType )
|
|
|
|
{
|
|
|
|
aRet=ObjectNameProvider::getAxisName( rObjectCID, xChartModel );
|
|
|
|
}
|
|
|
|
else if( OBJECTTYPE_GRID == eObjectType
|
|
|
|
|| OBJECTTYPE_SUBGRID == eObjectType )
|
|
|
|
{
|
|
|
|
aRet=ObjectNameProvider::getGridName( rObjectCID, xChartModel );
|
|
|
|
}
|
|
|
|
else if( OBJECTTYPE_TITLE == eObjectType )
|
|
|
|
{
|
|
|
|
aRet=ObjectNameProvider::getTitleName( rObjectCID, xChartModel );
|
|
|
|
}
|
|
|
|
else if( OBJECTTYPE_DATA_SERIES == eObjectType )
|
|
|
|
{
|
2009-09-11 16:06:18 +00:00
|
|
|
aRet = lcl_getFullSeriesName( rObjectCID, xChartModel );
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
else if( OBJECTTYPE_DATA_POINT == eObjectType )
|
|
|
|
{
|
|
|
|
if( bVerbose )
|
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aNewLine( "\n" );
|
2007-05-22 16:28:29 +00:00
|
|
|
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_TIP_DATAPOINT_INDEX);
|
2007-05-22 16:28:29 +00:00
|
|
|
aRet+=aNewLine;
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet+=SCH_RESSTR(STR_TIP_DATASERIES);
|
2007-05-22 16:28:29 +00:00
|
|
|
aRet+=aNewLine;
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet+=SCH_RESSTR(STR_TIP_DATAPOINT_VALUES);
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
else
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet=SCH_RESSTR(STR_TIP_DATAPOINT);
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
|
|
|
|
Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY );
|
|
|
|
if( xDiagram.is() && xSeries.is() )
|
|
|
|
{
|
|
|
|
sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() );
|
|
|
|
|
|
|
|
//replace data point index
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aWildcard( "%POINTNUMBER" );
|
2013-04-07 22:18:57 +02:00
|
|
|
sal_Int32 nIndex = aRet.indexOf( aWildcard );
|
2007-05-22 16:28:29 +00:00
|
|
|
if( nIndex != -1 )
|
|
|
|
{
|
2013-08-21 15:07:31 +02:00
|
|
|
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::number(nPointIndex+1) );
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//replace data series index
|
2012-10-06 22:23:08 -03:00
|
|
|
aWildcard = "%SERIESNUMBER";
|
2007-05-22 16:28:29 +00:00
|
|
|
nIndex = aRet.indexOf( aWildcard );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
{
|
|
|
|
::std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
|
|
|
|
DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
|
|
|
|
sal_Int32 nSeriesIndex = -1;
|
|
|
|
for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
|
|
|
|
{
|
|
|
|
if( aSeriesVector[nSeriesIndex] == xSeries )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString aReplacement( OUString::number(nSeriesIndex+1) );
|
2007-05-22 16:28:29 +00:00
|
|
|
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), aReplacement );
|
|
|
|
}
|
|
|
|
|
|
|
|
//replace point values
|
2012-10-06 22:23:08 -03:00
|
|
|
aWildcard = "%POINTVALUES";
|
2007-05-22 16:28:29 +00:00
|
|
|
nIndex = aRet.indexOf( aWildcard );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataPointValueText(
|
|
|
|
xSeries,nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) );
|
|
|
|
|
|
|
|
//replace series name
|
2012-10-06 22:23:08 -03:00
|
|
|
aWildcard = "%SERIESNAME";
|
2007-05-22 16:28:29 +00:00
|
|
|
nIndex = aRet.indexOf( aWildcard );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) );
|
|
|
|
}
|
|
|
|
}
|
2007-07-03 12:37:23 +00:00
|
|
|
else if( OBJECTTYPE_DATA_CURVE == eObjectType )
|
|
|
|
{
|
|
|
|
if( bVerbose )
|
|
|
|
{
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet = SCH_RESSTR( STR_OBJECT_CURVE_WITH_PARAMETERS );
|
2007-07-03 12:37:23 +00:00
|
|
|
Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
|
|
|
|
Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
|
2013-12-09 21:18:12 +01:00
|
|
|
|
2007-07-03 12:37:23 +00:00
|
|
|
if( xCurveCnt.is())
|
|
|
|
{
|
2013-12-09 21:18:12 +01:00
|
|
|
sal_Int32 nCurveIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID );
|
|
|
|
Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getRegressionCurveAtIndex(xCurveCnt, nCurveIndex) );
|
2007-07-03 12:37:23 +00:00
|
|
|
if( xCurve.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW );
|
2013-11-12 20:55:21 +01:00
|
|
|
sal_Int32 aDegree = 2;
|
|
|
|
sal_Bool aForceIntercept = false;
|
|
|
|
double aInterceptValue = 0.0;
|
|
|
|
uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
|
|
|
|
if ( xProperties.is())
|
|
|
|
{
|
|
|
|
xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
|
|
|
|
xProperties->getPropertyValue( "ForceIntercept") >>= aForceIntercept;
|
|
|
|
if (aForceIntercept)
|
|
|
|
xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue;
|
|
|
|
}
|
|
|
|
xCalculator->setRegressionProperties(aDegree, aForceIntercept, aInterceptValue, 2);
|
2007-07-03 12:37:23 +00:00
|
|
|
RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel );
|
|
|
|
|
|
|
|
// replace formula
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aWildcard( "%FORMULA" );
|
2013-04-07 22:18:57 +02:00
|
|
|
sal_Int32 nIndex = aRet.indexOf( aWildcard );
|
2007-07-03 12:37:23 +00:00
|
|
|
if( nIndex != -1 )
|
|
|
|
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), xCalculator->getRepresentation());
|
|
|
|
|
|
|
|
// replace r^2
|
2012-10-06 22:23:08 -03:00
|
|
|
aWildcard = "%RSQUARED";
|
2007-07-03 12:37:23 +00:00
|
|
|
nIndex = aRet.indexOf( aWildcard );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
{
|
|
|
|
sal_Unicode aDecimalSep( '.' );
|
|
|
|
double fR( xCalculator->getCorrelationCoefficient());
|
|
|
|
aRet = aRet.replaceAt(
|
|
|
|
nIndex, aWildcard.getLength(),
|
|
|
|
::rtl::math::doubleToUString(
|
|
|
|
fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
|
|
|
ASSERT_EXCEPTION( ex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// non-verbose
|
|
|
|
aRet = ObjectNameProvider::getName( eObjectType, false );
|
|
|
|
}
|
|
|
|
}
|
2007-10-22 15:43:10 +00:00
|
|
|
else if( OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType )
|
|
|
|
{
|
|
|
|
if( bVerbose )
|
|
|
|
{
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet = SCH_RESSTR(STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS);
|
2007-10-22 15:43:10 +00:00
|
|
|
Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
|
|
|
|
Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
|
|
|
|
if( xCurveCnt.is())
|
|
|
|
{
|
|
|
|
Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt ));
|
|
|
|
if( xCurve.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW );
|
|
|
|
RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel );
|
|
|
|
|
|
|
|
sal_Unicode aDecimalSep( '.' );
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aWildcard( "%AVERAGE_VALUE" );
|
2013-04-07 22:18:57 +02:00
|
|
|
sal_Int32 nIndex = aRet.indexOf( aWildcard );
|
2007-10-22 15:43:10 +00:00
|
|
|
// as the curve is constant, the value at any x-value is ok
|
|
|
|
if( nIndex != -1 )
|
|
|
|
{
|
|
|
|
const double fMeanValue( xCalculator->getCurveValue( 0.0 ));
|
|
|
|
aRet = aRet.replaceAt(
|
|
|
|
nIndex, aWildcard.getLength(),
|
|
|
|
::rtl::math::doubleToUString(
|
|
|
|
fMeanValue, rtl_math_StringFormat_G, 4, aDecimalSep, true ));
|
|
|
|
}
|
|
|
|
|
|
|
|
// replace standard deviation
|
2012-10-06 22:23:08 -03:00
|
|
|
aWildcard = "%STD_DEVIATION";
|
2007-10-22 15:43:10 +00:00
|
|
|
nIndex = aRet.indexOf( aWildcard );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
{
|
|
|
|
const double fStdDev( xCalculator->getCorrelationCoefficient());
|
|
|
|
aRet = aRet.replaceAt(
|
|
|
|
nIndex, aWildcard.getLength(),
|
|
|
|
::rtl::math::doubleToUString(
|
|
|
|
fStdDev, rtl_math_StringFormat_G, 4, aDecimalSep, true ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
|
|
|
ASSERT_EXCEPTION( ex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// non-verbose
|
|
|
|
aRet = ObjectNameProvider::getName( eObjectType, false );
|
|
|
|
}
|
|
|
|
}
|
2007-05-22 16:28:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
aRet = ObjectNameProvider::getName( eObjectType, false );
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getSelectedObjectText( const OUString & rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument )
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aRet;
|
2007-05-22 16:28:29 +00:00
|
|
|
ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) );
|
|
|
|
Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY );
|
|
|
|
|
|
|
|
if( OBJECTTYPE_DATA_POINT == eObjectType )
|
|
|
|
{
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet = SCH_RESSTR( STR_STATUS_DATAPOINT_MARKED );
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
|
|
|
|
Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY );
|
|
|
|
if( xDiagram.is() && xSeries.is() )
|
|
|
|
{
|
|
|
|
sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() );
|
|
|
|
|
|
|
|
// replace data point index
|
2013-08-21 15:07:31 +02:00
|
|
|
replaceParamterInString( aRet, "%POINTNUMBER", OUString::number( nPointIndex + 1 ));
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
// replace data series index
|
|
|
|
{
|
|
|
|
::std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
|
|
|
|
DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
|
|
|
|
sal_Int32 nSeriesIndex = -1;
|
|
|
|
for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
|
|
|
|
{
|
|
|
|
if( aSeriesVector[nSeriesIndex] == xSeries )
|
|
|
|
break;
|
|
|
|
}
|
2013-08-21 15:07:31 +02:00
|
|
|
replaceParamterInString( aRet, "%SERIESNUMBER", OUString::number( nSeriesIndex + 1 ) );
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// replace point value
|
2012-10-06 22:23:08 -03:00
|
|
|
replaceParamterInString( aRet, "%POINTVALUES", lcl_getDataPointValueText(
|
2007-05-22 16:28:29 +00:00
|
|
|
xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-03 12:37:23 +00:00
|
|
|
// use the verbose text including the formula for trend lines
|
2007-10-22 15:43:10 +00:00
|
|
|
const bool bVerbose( OBJECTTYPE_DATA_CURVE == eObjectType || OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType );
|
|
|
|
const OUString aHelpText( getHelpText( rObjectCID, xChartModel, bVerbose ));
|
2011-12-10 22:03:11 -02:00
|
|
|
if( !aHelpText.isEmpty())
|
2007-05-22 16:28:29 +00:00
|
|
|
{
|
2013-07-27 17:01:36 +01:00
|
|
|
aRet = SCH_RESSTR( STR_STATUS_OBJECT_MARKED );
|
2012-10-06 22:23:08 -03:00
|
|
|
replaceParamterInString( aRet, "%OBJECTNAME", aHelpText );
|
2007-05-22 16:28:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getNameForCID(
|
|
|
|
const OUString& rObjectCID,
|
2007-05-22 16:28:29 +00:00
|
|
|
const uno::Reference< chart2::XChartDocument >& xChartDocument )
|
|
|
|
{
|
|
|
|
ObjectType eType( ObjectIdentifier::getObjectType( rObjectCID ));
|
|
|
|
Reference< frame::XModel > xModel( xChartDocument, uno::UNO_QUERY );
|
|
|
|
|
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case OBJECTTYPE_AXIS:
|
|
|
|
return getAxisName( rObjectCID, xModel );
|
|
|
|
case OBJECTTYPE_TITLE:
|
|
|
|
return getTitleName( rObjectCID, xModel );
|
|
|
|
case OBJECTTYPE_GRID:
|
2009-09-11 16:06:18 +00:00
|
|
|
case OBJECTTYPE_SUBGRID:
|
2007-05-22 16:28:29 +00:00
|
|
|
return getGridName( rObjectCID, xModel );
|
2009-09-11 16:06:18 +00:00
|
|
|
case OBJECTTYPE_DATA_SERIES:
|
|
|
|
return lcl_getFullSeriesName( rObjectCID, xModel );
|
|
|
|
case OBJECTTYPE_DATA_POINT:
|
|
|
|
case OBJECTTYPE_DATA_LABELS:
|
|
|
|
case OBJECTTYPE_DATA_LABEL:
|
|
|
|
case OBJECTTYPE_DATA_ERRORS_X:
|
|
|
|
case OBJECTTYPE_DATA_ERRORS_Y:
|
|
|
|
case OBJECTTYPE_DATA_ERRORS_Z:
|
|
|
|
case OBJECTTYPE_DATA_CURVE:
|
|
|
|
case OBJECTTYPE_DATA_AVERAGE_LINE:
|
|
|
|
case OBJECTTYPE_DATA_CURVE_EQUATION:
|
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString aRet = lcl_getFullSeriesName( rObjectCID, xModel );
|
|
|
|
aRet += " ";
|
2009-09-11 16:06:18 +00:00
|
|
|
if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL )
|
|
|
|
{
|
|
|
|
aRet += getName( OBJECTTYPE_DATA_POINT );
|
|
|
|
sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID );
|
2012-10-06 22:23:08 -03:00
|
|
|
aRet += " ";
|
2013-08-21 15:07:31 +02:00
|
|
|
aRet += OUString::number(nPointIndex+1);
|
2009-09-11 16:06:18 +00:00
|
|
|
|
|
|
|
if( eType == OBJECTTYPE_DATA_LABEL )
|
|
|
|
{
|
2012-10-06 22:23:08 -03:00
|
|
|
aRet += " ";
|
2009-09-11 16:06:18 +00:00
|
|
|
aRet += getName( OBJECTTYPE_DATA_LABEL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aRet += getName( eType );
|
|
|
|
return aRet;
|
|
|
|
}
|
2007-05-22 16:28:29 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return getName( eType );
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getName_ObjectForSeries(
|
2009-09-11 16:06:18 +00:00
|
|
|
ObjectType eObjectType,
|
2012-10-06 22:23:08 -03:00
|
|
|
const OUString& rSeriesCID,
|
2009-09-11 16:06:18 +00:00
|
|
|
const uno::Reference< chart2::XChartDocument >& xChartDocument )
|
|
|
|
{
|
|
|
|
uno::Reference< frame::XModel> xChartModel( xChartDocument, uno::UNO_QUERY );
|
|
|
|
Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartModel ), uno::UNO_QUERY );
|
|
|
|
if( xSeries.is() )
|
|
|
|
{
|
2013-07-27 17:01:36 +01:00
|
|
|
OUString aRet = SCH_RESSTR(STR_OBJECT_FOR_SERIES);
|
2012-10-06 22:23:08 -03:00
|
|
|
replaceParamterInString( aRet, "%OBJECTNAME", getName( eObjectType, false /*bPlural*/ ) );
|
|
|
|
replaceParamterInString( aRet, "%SERIESNAME", lcl_getDataSeriesName( rSeriesCID, xChartModel ) );
|
2009-09-11 16:06:18 +00:00
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType );
|
|
|
|
}
|
|
|
|
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType )
|
2009-09-11 16:06:18 +00:00
|
|
|
{
|
2013-07-27 17:01:36 +01:00
|
|
|
OUString aRet = SCH_RESSTR(STR_OBJECT_FOR_ALL_SERIES);
|
2012-10-06 22:23:08 -03:00
|
|
|
replaceParamterInString( aRet, "%OBJECTNAME", getName( eObjectType, true /*bPlural*/ ) );
|
2009-09-11 16:06:18 +00:00
|
|
|
return aRet;
|
|
|
|
}
|
2007-05-22 16:28:29 +00:00
|
|
|
|
|
|
|
} //namespace chart
|
2010-10-12 15:59:00 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|