Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include "ObjectNameProvider.hxx"
22 : : #include "ResId.hxx"
23 : : #include "Strings.hrc"
24 : : #include "macros.hxx"
25 : : #include "AxisHelper.hxx"
26 : : #include "ChartModelHelper.hxx"
27 : : #include "DiagramHelper.hxx"
28 : : #include "DataSeriesHelper.hxx"
29 : : #include "TitleHelper.hxx"
30 : : #include "AxisIndexDefines.hxx"
31 : : #include "ExplicitCategoriesProvider.hxx"
32 : : #include "CommonConverters.hxx"
33 : : #include "NumberFormatterWrapper.hxx"
34 : : #include "RegressionCurveHelper.hxx"
35 : : #include <rtl/math.hxx>
36 : : #include <tools/string.hxx>
37 : :
38 : : #include <com/sun/star/chart2/XTitle.hpp>
39 : : #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
40 : :
41 : : //.............................................................................
42 : : namespace chart
43 : : {
44 : : //.............................................................................
45 : : using namespace ::com::sun::star;
46 : : using namespace ::com::sun::star::chart2;
47 : : using ::com::sun::star::uno::Reference;
48 : : using ::com::sun::star::uno::Sequence;
49 : : using ::com::sun::star::uno::Any;
50 : : using rtl::OUString;
51 : :
52 : : namespace
53 : : {
54 : :
55 : 6712 : OUString lcl_getDataSeriesName( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel )
56 : : {
57 : 6712 : OUString aRet;
58 : :
59 [ + - ]: 6712 : Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
60 [ + - ][ + - ]: 6712 : Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY );
61 [ + - ][ + - ]: 6712 : if( xDiagram.is() && xSeries.is() )
[ + - ]
62 : : {
63 [ + - ]: 6712 : Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
64 [ + - ]: 6712 : if( xChartType.is() )
65 : : {
66 : : aRet = ::chart::DataSeriesHelper::getDataSeriesLabel(
67 [ + - ][ + - ]: 6712 : xSeries, xChartType->getRoleOfSequenceForSeriesLabel() ) ;
[ + - ]
68 : 6712 : }
69 : : }
70 : :
71 : 6712 : return aRet;
72 : : }
73 : :
74 : 6712 : OUString lcl_getFullSeriesName( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel )
75 : : {
76 [ + - ][ + - ]: 6712 : OUString aRet = String(SchResId(STR_TIP_DATASERIES));
[ + - ][ + - ]
77 [ + - ]: 6712 : OUString aWildcard( C2U("%SERIESNAME") );
78 : 6712 : sal_Int32 nIndex = aRet.indexOf( aWildcard );
79 [ + - ]: 6712 : if( nIndex != -1 )
80 [ + - ]: 6712 : aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) );
81 : 6712 : return aRet;
82 : : }
83 : :
84 : 0 : void lcl_addText( OUString& rOut, const OUString& rSeparator, const OUString& rNext )
85 : : {
86 [ # # ][ # # ]: 0 : if( !(rOut.isEmpty() || rNext.isEmpty()) )
[ # # ]
87 : 0 : rOut+=rSeparator;
88 [ # # ]: 0 : if( !rNext.isEmpty() )
89 : 0 : rOut+=rNext;
90 : 0 : }
91 : :
92 : 0 : OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal_Int32 nPointIndex,
93 : : const Reference< XCoordinateSystem >& xCooSys,
94 : : const Reference< frame::XModel >& xChartModel )
95 : : {
96 : :
97 : 0 : OUString aRet;
98 : :
99 : : Reference<data::XDataSource> xDataSource(
100 [ # # ]: 0 : uno::Reference<data::XDataSource>( xSeries, uno::UNO_QUERY ) );
101 [ # # ]: 0 : if(!xDataSource.is())
102 : : return aRet;
103 : :
104 [ # # ][ # # ]: 0 : Sequence< Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
105 : :
106 : 0 : rtl::OUString aX, aY, aY_Min, aY_Max, aY_First, aY_Last, a_Size;
107 : 0 : double fValue = 0;
108 : :
109 [ # # ]: 0 : uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY );
110 [ # # ]: 0 : NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
111 : 0 : sal_Int32 nLabelColor = 0;//dummy
112 : : bool bColorChanged;//dummy
113 : :
114 [ # # ]: 0 : for(sal_Int32 nN = aDataSequences.getLength();nN--;)
115 : : {
116 [ # # ][ # # ]: 0 : uno::Reference<data::XDataSequence> xDataSequence( aDataSequences[nN]->getValues());
[ # # ]
117 [ # # ]: 0 : if( !xDataSequence.is() )
118 : 0 : continue;
119 [ # # ][ # # ]: 0 : Sequence< Any > aData( xDataSequence->getData() );
120 [ # # ]: 0 : if( nPointIndex >= aData.getLength() )
121 : 0 : continue;
122 [ # # ]: 0 : uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY );
123 [ # # ]: 0 : if( xProp.is())
124 : : {
125 : : try
126 : : {
127 [ # # ][ # # ]: 0 : uno::Any aARole = xProp->getPropertyValue( C2U( "Role" ) );
[ # # ]
128 : 0 : rtl::OUString aRole;
129 : 0 : aARole >>= aRole;
130 : :
131 [ # # ][ # # ]: 0 : if( aRole.equals(C2U("values-x")) )
132 : : {
133 [ # # ]: 0 : aData[nPointIndex]>>= fValue;
134 [ # # ][ # # ]: 0 : sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
135 [ # # ]: 0 : aX = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
136 : : }
137 [ # # ][ # # ]: 0 : else if( aRole.equals(C2U("values-y")) )
138 : : {
139 [ # # ]: 0 : aData[nPointIndex]>>= fValue;
140 [ # # ][ # # ]: 0 : sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
141 [ # # ]: 0 : aY = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
142 : : }
143 [ # # ][ # # ]: 0 : else if( aRole.equals(C2U("values-first")) )
144 : : {
145 [ # # ]: 0 : aData[nPointIndex]>>= fValue;
146 [ # # ][ # # ]: 0 : sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
147 [ # # ]: 0 : aY_First = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
148 : : }
149 [ # # ][ # # ]: 0 : else if( aRole.equals(C2U("values-min")) )
150 : : {
151 [ # # ]: 0 : aData[nPointIndex]>>= fValue;
152 [ # # ][ # # ]: 0 : sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
153 [ # # ]: 0 : aY_Min = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
154 : : }
155 [ # # ][ # # ]: 0 : else if( aRole.equals(C2U("values-max")) )
156 : : {
157 [ # # ]: 0 : aData[nPointIndex]>>= fValue;
158 [ # # ][ # # ]: 0 : sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
159 [ # # ]: 0 : aY_Max = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
160 : : }
161 [ # # ][ # # ]: 0 : else if( aRole.equals(C2U("values-last")) )
162 : : {
163 [ # # ]: 0 : aData[nPointIndex]>>= fValue;
164 [ # # ][ # # ]: 0 : sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
165 [ # # ]: 0 : aY_Last = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
166 : : }
167 [ # # ][ # # ]: 0 : else if( aRole.equals(C2U("values-size")) )
168 : : {
169 [ # # ]: 0 : aData[nPointIndex]>>= fValue;
170 [ # # ][ # # ]: 0 : sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
171 [ # # ]: 0 : a_Size = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
172 [ # # ]: 0 : }
173 : : }
174 [ # # ]: 0 : catch( const uno::Exception& e )
175 : : {
176 : : ASSERT_EXCEPTION( e );
177 : : }
178 : : }
179 [ # # ][ # # ]: 0 : }
[ # # ]
180 : :
181 [ # # ]: 0 : if( aX.isEmpty() )
182 : : {
183 [ # # ]: 0 : aRet = ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex );
184 : : }
185 : : else
186 : : {
187 : 0 : aRet = aX;
188 : : }
189 : :
190 [ # # ]: 0 : OUString aSeparator(C2U(" "));
191 : :
192 : 0 : lcl_addText( aRet, aSeparator, aY );
193 : 0 : lcl_addText( aRet, aSeparator, aY_First );
194 : 0 : lcl_addText( aRet, aSeparator, aY_Min );
195 : 0 : lcl_addText( aRet, aSeparator, aY_Max );
196 : 0 : lcl_addText( aRet, aSeparator, aY_Last );
197 : 0 : lcl_addText( aRet, aSeparator, a_Size );
198 : :
199 [ # # ][ # # ]: 0 : return aRet;
200 : : }
201 : :
202 : : } //end anonymous namespace
203 : :
204 : 9088 : rtl::OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural )
205 : : {
206 : 9088 : rtl::OUString aRet;
207 [ + - + - : 9088 : switch( eObjectType )
+ + + - -
- - - - -
- - - + -
- - - -
+ ]
208 : : {
209 : : case OBJECTTYPE_PAGE:
210 [ + - ][ + - ]: 4543 : aRet=String(SchResId(STR_OBJECT_PAGE));
[ + - ][ + - ]
211 : 4543 : break;
212 : : case OBJECTTYPE_TITLE:
213 : : {
214 [ # # ]: 0 : if(bPlural)
215 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLES));
[ # # ][ # # ]
216 : : else
217 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE));
[ # # ][ # # ]
218 : : }
219 : 0 : break;
220 : : case OBJECTTYPE_LEGEND:
221 [ + - ][ + - ]: 2185 : aRet=String(SchResId(STR_OBJECT_LEGEND));
[ + - ][ + - ]
222 : 2185 : break;
223 : : case OBJECTTYPE_LEGEND_ENTRY:
224 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_LEGEND_SYMBOL));//@todo change string if we do differenciate symbol and legend entry in future
[ # # ][ # # ]
225 : 0 : break;
226 : : case OBJECTTYPE_DIAGRAM:
227 [ + - ][ + - ]: 2265 : aRet=String(SchResId(STR_OBJECT_DIAGRAM));
[ + - ][ + - ]
228 : 2265 : break;
229 : : case OBJECTTYPE_DIAGRAM_WALL:
230 [ + - ][ + - ]: 12 : aRet=String(SchResId(STR_OBJECT_DIAGRAM_WALL));
[ + - ][ + - ]
231 : 12 : break;
232 : : case OBJECTTYPE_DIAGRAM_FLOOR:
233 [ + - ][ + - ]: 12 : aRet=String(SchResId(STR_OBJECT_DIAGRAM_FLOOR));
[ + - ][ + - ]
234 : 12 : break;
235 : : case OBJECTTYPE_AXIS:
236 : : {
237 [ # # ]: 0 : if(bPlural)
238 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_AXES));
[ # # ][ # # ]
239 : : else
240 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_AXIS));
[ # # ][ # # ]
241 : : }
242 : 0 : break;
243 : : case OBJECTTYPE_AXIS_UNITLABEL:
244 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_LABEL));//@todo maybe a more concrete name
[ # # ][ # # ]
245 : 0 : break;
246 : : case OBJECTTYPE_GRID:
247 : : case OBJECTTYPE_SUBGRID: //maybe todo: different names for subgrids
248 : : {
249 [ # # ]: 0 : if(bPlural)
250 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRIDS));
[ # # ][ # # ]
251 : : else
252 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRID));
[ # # ][ # # ]
253 : : }
254 : 0 : break;
255 : : case OBJECTTYPE_DATA_SERIES:
256 : : {
257 [ # # ]: 0 : if(bPlural)
258 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_DATASERIES_PLURAL));
[ # # ][ # # ]
259 : : else
260 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_DATASERIES));
[ # # ][ # # ]
261 : : }
262 : 0 : break;
263 : : case OBJECTTYPE_DATA_POINT:
264 : : {
265 [ # # ]: 0 : if(bPlural)
266 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_DATAPOINTS));
[ # # ][ # # ]
267 : : else
268 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_DATAPOINT));
[ # # ][ # # ]
269 : : }
270 : 0 : break;
271 : : case OBJECTTYPE_DATA_LABELS:
272 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_DATALABELS));
[ # # ][ # # ]
273 : 0 : break;
274 : : case OBJECTTYPE_DATA_LABEL:
275 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_LABEL));
[ # # ][ # # ]
276 : 0 : break;
277 : : case OBJECTTYPE_DATA_ERRORS_X:
278 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_ERROR_BARS_X));
[ # # ][ # # ]
279 : 0 : break;
280 : : case OBJECTTYPE_DATA_ERRORS_Y:
281 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_ERROR_BARS_Y));
[ # # ][ # # ]
282 : 0 : break;
283 : : case OBJECTTYPE_DATA_ERRORS_Z:
284 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_ERROR_BARS_Z));
[ # # ][ # # ]
285 : 0 : break;
286 : : case OBJECTTYPE_DATA_AVERAGE_LINE:
287 [ + - ][ + - ]: 16 : aRet=String(SchResId(STR_OBJECT_AVERAGE_LINE));
[ + - ][ + - ]
288 : 16 : break;
289 : : case OBJECTTYPE_DATA_CURVE:
290 : : {
291 [ # # ]: 0 : if(bPlural)
292 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_CURVES));
[ # # ][ # # ]
293 : : else
294 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_CURVE));
[ # # ][ # # ]
295 : : }
296 : 0 : break;
297 : : case OBJECTTYPE_DATA_STOCK_RANGE:
298 : 0 : break;
299 : : case OBJECTTYPE_DATA_STOCK_LOSS:
300 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_STOCK_LOSS));
[ # # ][ # # ]
301 : 0 : break;
302 : : case OBJECTTYPE_DATA_STOCK_GAIN:
303 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_STOCK_GAIN));
[ # # ][ # # ]
304 : 0 : break;
305 : : case OBJECTTYPE_DATA_CURVE_EQUATION:
306 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_CURVE_EQUATION));
[ # # ][ # # ]
307 : 0 : break;
308 : : default: //OBJECTTYPE_UNKNOWN
309 : : ;
310 : : }
311 : 9088 : return aRet;
312 : : }
313 : :
314 : 3855 : rtl::OUString ObjectNameProvider::getAxisName( const rtl::OUString& rObjectCID
315 : : , const uno::Reference< frame::XModel >& xChartModel )
316 : : {
317 : 3855 : rtl::OUString aRet;
318 : :
319 : :
320 : :
321 : : Reference< XAxis > xAxis(
322 [ + - ][ + - ]: 3855 : ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY );
323 : :
324 : 3855 : sal_Int32 nCooSysIndex = 0;
325 : 3855 : sal_Int32 nDimensionIndex = 0;
326 : 3855 : sal_Int32 nAxisIndex = 0;
327 [ + - ][ + - ]: 3855 : AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ), nCooSysIndex, nDimensionIndex, nAxisIndex );
328 : :
329 [ + + + - ]: 3855 : switch(nDimensionIndex)
330 : : {
331 : : case 0://x-axis
332 [ + - ]: 2219 : if( nAxisIndex == 0 )
333 [ + - ][ + - ]: 2219 : aRet=String(SchResId(STR_OBJECT_AXIS_X));
[ + - ][ + - ]
334 : : else
335 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_SECONDARY_X_AXIS));
[ # # ][ # # ]
336 : 2219 : break;
337 : : case 1://y-axis
338 [ + - ]: 1624 : if( nAxisIndex == 0 )
339 [ + - ][ + - ]: 1624 : aRet=String(SchResId(STR_OBJECT_AXIS_Y));
[ + - ][ + - ]
340 : : else
341 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_SECONDARY_Y_AXIS));
[ # # ][ # # ]
342 : 1624 : break;
343 : : case 2://z-axis
344 [ + - ][ + - ]: 12 : aRet=String(SchResId(STR_OBJECT_AXIS_Z));
[ + - ][ + - ]
345 : 12 : break;
346 : : default://axis
347 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_AXIS));
[ # # ][ # # ]
348 : 0 : break;
349 : : }
350 : :
351 : 3855 : return aRet;
352 : : }
353 : :
354 : 2210 : OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType )
355 : : {
356 : 2210 : OUString aRet;
357 : :
358 [ + + - - : 2210 : switch(eType)
- - - - ]
359 : : {
360 : : case TitleHelper::MAIN_TITLE:
361 [ + - ][ + - ]: 1358 : aRet=String(SchResId(STR_OBJECT_TITLE_MAIN));
[ + - ][ + - ]
362 : 1358 : break;
363 : : case TitleHelper::SUB_TITLE:
364 [ + - ][ + - ]: 852 : aRet=String(SchResId(STR_OBJECT_TITLE_SUB));
[ + - ][ + - ]
365 : 852 : break;
366 : : case TitleHelper::X_AXIS_TITLE:
367 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE_X_AXIS));
[ # # ][ # # ]
368 : 0 : break;
369 : : case TitleHelper::Y_AXIS_TITLE:
370 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE_Y_AXIS));
[ # # ][ # # ]
371 : 0 : break;
372 : : case TitleHelper::Z_AXIS_TITLE:
373 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE_Z_AXIS));
[ # # ][ # # ]
374 : 0 : break;
375 : : case TitleHelper::SECONDARY_X_AXIS_TITLE:
376 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS));
[ # # ][ # # ]
377 : 0 : break;
378 : : case TitleHelper::SECONDARY_Y_AXIS_TITLE:
379 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS));
[ # # ][ # # ]
380 : 0 : break;
381 : : default:
382 : : OSL_FAIL("unknown title type");
383 : 0 : break;
384 : : }
385 : :
386 [ - + ]: 2210 : if( aRet.isEmpty() )
387 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE));
[ # # ][ # # ]
388 : :
389 : 2210 : return aRet;
390 : : }
391 : :
392 : 2210 : OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID
393 : : , const Reference< frame::XModel >& xChartModel )
394 : : {
395 : 2210 : OUString aRet;
396 : :
397 : : Reference< XTitle > xTitle(
398 [ + - ][ + - ]: 2210 : ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY );
399 [ + - ]: 2210 : if( xTitle.is() )
400 : : {
401 : : TitleHelper::eTitleType eType;
402 [ + - ][ + - ]: 2210 : if( TitleHelper::getTitleType( eType, xTitle, xChartModel ) )
403 [ + - ]: 2210 : aRet = ObjectNameProvider::getTitleNameByType( eType );
404 : : }
405 [ - + ]: 2210 : if( aRet.isEmpty() )
406 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_TITLE));
[ # # ][ # # ]
407 : :
408 : 2210 : return aRet;
409 : : }
410 : :
411 : 1812 : rtl::OUString ObjectNameProvider::getGridName( const rtl::OUString& rObjectCID
412 : : , const uno::Reference< frame::XModel >& xChartModel )
413 : : {
414 : 1812 : rtl::OUString aRet;
415 : :
416 : :
417 : 1812 : sal_Int32 nCooSysIndex = -1;
418 : 1812 : sal_Int32 nDimensionIndex = -1;
419 : 1812 : sal_Int32 nAxisIndex = -1;
420 [ + - ]: 1812 : Reference< XAxis > xAxis( ObjectIdentifier::getAxisForCID( rObjectCID , xChartModel ) );
421 : : AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel )
422 [ + - ][ + - ]: 1812 : , nCooSysIndex , nDimensionIndex, nAxisIndex );
423 : :
424 [ + - ]: 1812 : bool bMainGrid = (ObjectIdentifier::getObjectType( rObjectCID ) == OBJECTTYPE_GRID);
425 : :
426 [ + - ]: 1812 : if( bMainGrid )
427 : : {
428 [ + + - - ]: 1812 : switch(nDimensionIndex)
429 : : {
430 : : case 0://x-axis
431 [ + - ][ + - ]: 209 : aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_X));
[ + - ][ + - ]
432 : 209 : break;
433 : : case 1://y-axis
434 [ + - ][ + - ]: 1603 : aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_Y));
[ + - ][ + - ]
435 : 1603 : break;
436 : : case 2://z-axis
437 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_Z));
[ # # ][ # # ]
438 : 0 : break;
439 : : default://axis
440 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRID));
[ # # ][ # # ]
441 : 1812 : break;
442 : : }
443 : : }
444 : : else
445 : : {
446 [ # # # # ]: 0 : switch(nDimensionIndex)
447 : : {
448 : : case 0://x-axis
449 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRID_MINOR_X));
[ # # ][ # # ]
450 : 0 : break;
451 : : case 1://y-axis
452 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRID_MINOR_Y));
[ # # ][ # # ]
453 : 0 : break;
454 : : case 2://z-axis
455 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRID_MINOR_Z));
[ # # ][ # # ]
456 : 0 : break;
457 : : default://axis
458 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_OBJECT_GRID));
[ # # ][ # # ]
459 : 0 : break;
460 : : }
461 : : }
462 : 1812 : return aRet;
463 : : }
464 : :
465 : 0 : rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, const Reference< chart2::XChartDocument >& xChartDocument, bool bVerbose )
466 : : {
467 [ # # ]: 0 : return getHelpText( rObjectCID, Reference< frame::XModel >( xChartDocument, uno::UNO_QUERY ), bVerbose );
468 : : }
469 : :
470 : 2327 : rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel, bool bVerbose )
471 : : {
472 : 2327 : rtl::OUString aRet;
473 [ + - ]: 2327 : ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) );
474 [ - + ]: 2327 : if( OBJECTTYPE_AXIS == eObjectType )
475 : : {
476 [ # # ]: 0 : aRet=ObjectNameProvider::getAxisName( rObjectCID, xChartModel );
477 : : }
478 [ + - ][ - + ]: 2327 : else if( OBJECTTYPE_GRID == eObjectType
479 : : || OBJECTTYPE_SUBGRID == eObjectType )
480 : : {
481 [ # # ]: 0 : aRet=ObjectNameProvider::getGridName( rObjectCID, xChartModel );
482 : : }
483 [ - + ]: 2327 : else if( OBJECTTYPE_TITLE == eObjectType )
484 : : {
485 [ # # ]: 0 : aRet=ObjectNameProvider::getTitleName( rObjectCID, xChartModel );
486 : : }
487 [ - + ]: 2327 : else if( OBJECTTYPE_DATA_SERIES == eObjectType )
488 : : {
489 [ # # ]: 0 : aRet = lcl_getFullSeriesName( rObjectCID, xChartModel );
490 : : }
491 [ - + ]: 2327 : else if( OBJECTTYPE_DATA_POINT == eObjectType )
492 : : {
493 [ # # ]: 0 : if( bVerbose )
494 : : {
495 [ # # ]: 0 : OUString aNewLine(C2U("\n"));
496 : :
497 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_TIP_DATAPOINT_INDEX));
[ # # ][ # # ]
498 : 0 : aRet+=aNewLine;
499 [ # # ][ # # ]: 0 : aRet+=String(SchResId(STR_TIP_DATASERIES));
[ # # ][ # # ]
500 : 0 : aRet+=aNewLine;
501 [ # # ][ # # ]: 0 : aRet+=String(SchResId(STR_TIP_DATAPOINT_VALUES));
[ # # ][ # # ]
502 : : }
503 : : else
504 [ # # ][ # # ]: 0 : aRet=String(SchResId(STR_TIP_DATAPOINT));
[ # # ][ # # ]
505 : :
506 [ # # ]: 0 : Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
507 [ # # ][ # # ]: 0 : Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY );
508 [ # # ][ # # ]: 0 : if( xDiagram.is() && xSeries.is() )
[ # # ]
509 : : {
510 [ # # ]: 0 : sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() );
511 : :
512 : : //replace data point index
513 : 0 : sal_Int32 nIndex = -1;
514 [ # # ]: 0 : OUString aWildcard( C2U("%POINTNUMBER") );
515 : 0 : nIndex = aRet.indexOf( aWildcard );
516 [ # # ]: 0 : if( nIndex != -1 )
517 : : {
518 : 0 : aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::valueOf(nPointIndex+1) );
519 : : }
520 : :
521 : : //replace data series index
522 [ # # ]: 0 : aWildcard = C2U("%SERIESNUMBER");
523 : 0 : nIndex = aRet.indexOf( aWildcard );
524 [ # # ]: 0 : if( nIndex != -1 )
525 : : {
526 : : ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
527 [ # # ]: 0 : DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
528 : 0 : sal_Int32 nSeriesIndex = -1;
529 [ # # ]: 0 : for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
530 : : {
531 [ # # ][ # # ]: 0 : if( aSeriesVector[nSeriesIndex] == xSeries )
532 : : {
533 : 0 : break;
534 : : }
535 : : }
536 : :
537 : 0 : OUString aReplacement( OUString::valueOf(nSeriesIndex+1) );
538 : 0 : aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), aReplacement );
539 : : }
540 : :
541 : : //replace point values
542 [ # # ]: 0 : aWildcard = C2U("%POINTVALUES");
543 : 0 : nIndex = aRet.indexOf( aWildcard );
544 [ # # ]: 0 : if( nIndex != -1 )
545 : : aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataPointValueText(
546 [ # # ][ # # ]: 0 : xSeries,nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) );
547 : :
548 : : //replace series name
549 [ # # ]: 0 : aWildcard = C2U("%SERIESNAME");
550 : 0 : nIndex = aRet.indexOf( aWildcard );
551 [ # # ]: 0 : if( nIndex != -1 )
552 [ # # ]: 0 : aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) );
553 : 0 : }
554 : : }
555 [ - + ]: 2327 : else if( OBJECTTYPE_DATA_CURVE == eObjectType )
556 : : {
557 [ # # ]: 0 : if( bVerbose )
558 : : {
559 [ # # ][ # # ]: 0 : aRet = String( SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS ));
[ # # ][ # # ]
560 [ # # ]: 0 : Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
561 [ # # ]: 0 : Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
562 [ # # ]: 0 : if( xCurveCnt.is())
563 : : {
564 [ # # ]: 0 : Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ));
565 [ # # ]: 0 : if( xCurve.is())
566 : : {
567 : : try
568 : : {
569 [ # # ][ # # ]: 0 : Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW );
[ # # ]
570 [ # # ]: 0 : RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel );
571 : :
572 : : // replace formula
573 : 0 : sal_Int32 nIndex = -1;
574 [ # # ]: 0 : OUString aWildcard( C2U("%FORMULA") );
575 : 0 : nIndex = aRet.indexOf( aWildcard );
576 [ # # ]: 0 : if( nIndex != -1 )
577 [ # # ][ # # ]: 0 : aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), xCalculator->getRepresentation());
578 : :
579 : : // replace r^2
580 [ # # ]: 0 : aWildcard = C2U("%RSQUARED");
581 : 0 : nIndex = aRet.indexOf( aWildcard );
582 [ # # ]: 0 : if( nIndex != -1 )
583 : : {
584 : 0 : sal_Unicode aDecimalSep( '.' );
585 [ # # ][ # # ]: 0 : double fR( xCalculator->getCorrelationCoefficient());
586 : : aRet = aRet.replaceAt(
587 : : nIndex, aWildcard.getLength(),
588 : : ::rtl::math::doubleToUString(
589 : 0 : fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true ));
590 [ # # ]: 0 : }
591 : : }
592 [ # # ]: 0 : catch( const uno::Exception & ex )
593 : : {
594 : : ASSERT_EXCEPTION( ex );
595 : : }
596 : 0 : }
597 : 0 : }
598 : : }
599 : : else
600 : : {
601 : : // non-verbose
602 [ # # ]: 0 : aRet = ObjectNameProvider::getName( eObjectType, false );
603 : : }
604 : : }
605 [ - + ]: 2327 : else if( OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType )
606 : : {
607 [ # # ]: 0 : if( bVerbose )
608 : : {
609 [ # # ][ # # ]: 0 : aRet = String( SchResId( STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS ));
[ # # ][ # # ]
610 [ # # ]: 0 : Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
611 [ # # ]: 0 : Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
612 [ # # ]: 0 : if( xCurveCnt.is())
613 : : {
614 [ # # ]: 0 : Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt ));
615 [ # # ]: 0 : if( xCurve.is())
616 : : {
617 : : try
618 : : {
619 [ # # ][ # # ]: 0 : Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW );
[ # # ]
620 [ # # ]: 0 : RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel );
621 : :
622 : 0 : sal_Unicode aDecimalSep( '.' );
623 : :
624 : 0 : sal_Int32 nIndex = -1;
625 [ # # ]: 0 : OUString aWildcard( C2U("%AVERAGE_VALUE") );
626 : 0 : nIndex = aRet.indexOf( aWildcard );
627 : : // as the curve is constant, the value at any x-value is ok
628 [ # # ]: 0 : if( nIndex != -1 )
629 : : {
630 [ # # ][ # # ]: 0 : const double fMeanValue( xCalculator->getCurveValue( 0.0 ));
631 : : aRet = aRet.replaceAt(
632 : : nIndex, aWildcard.getLength(),
633 : : ::rtl::math::doubleToUString(
634 : 0 : fMeanValue, rtl_math_StringFormat_G, 4, aDecimalSep, true ));
635 : : }
636 : :
637 : : // replace standard deviation
638 [ # # ]: 0 : aWildcard = C2U("%STD_DEVIATION");
639 : 0 : nIndex = aRet.indexOf( aWildcard );
640 [ # # ]: 0 : if( nIndex != -1 )
641 : : {
642 [ # # ][ # # ]: 0 : const double fStdDev( xCalculator->getCorrelationCoefficient());
643 : : aRet = aRet.replaceAt(
644 : : nIndex, aWildcard.getLength(),
645 : : ::rtl::math::doubleToUString(
646 : 0 : fStdDev, rtl_math_StringFormat_G, 4, aDecimalSep, true ));
647 [ # # ]: 0 : }
648 : : }
649 [ # # ]: 0 : catch( const uno::Exception & ex )
650 : : {
651 : : ASSERT_EXCEPTION( ex );
652 : : }
653 : 0 : }
654 : 0 : }
655 : : }
656 : : else
657 : : {
658 : : // non-verbose
659 [ # # ]: 0 : aRet = ObjectNameProvider::getName( eObjectType, false );
660 : : }
661 : : }
662 : : else
663 : : {
664 [ + - ]: 2327 : aRet = ObjectNameProvider::getName( eObjectType, false );
665 : : }
666 : 2327 : return aRet;
667 : : }
668 : :
669 : 2327 : rtl::OUString ObjectNameProvider::getSelectedObjectText( const rtl::OUString & rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument )
670 : : {
671 : 2327 : rtl::OUString aRet;
672 [ + - ]: 2327 : ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) );
673 [ + - ]: 2327 : Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY );
674 : :
675 [ - + ]: 2327 : if( OBJECTTYPE_DATA_POINT == eObjectType )
676 : : {
677 [ # # ][ # # ]: 0 : aRet = String( SchResId( STR_STATUS_DATAPOINT_MARKED ));
[ # # ][ # # ]
678 : :
679 [ # # ]: 0 : Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
680 [ # # ][ # # ]: 0 : Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY );
681 [ # # ][ # # ]: 0 : if( xDiagram.is() && xSeries.is() )
[ # # ]
682 : : {
683 [ # # ]: 0 : sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() );
684 : :
685 : : // replace data point index
686 [ # # ][ # # ]: 0 : replaceParamterInString( aRet, C2U("%POINTNUMBER"), OUString::valueOf( nPointIndex + 1 ));
687 : :
688 : : // replace data series index
689 : : {
690 : : ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
691 [ # # ]: 0 : DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
692 : 0 : sal_Int32 nSeriesIndex = -1;
693 [ # # ]: 0 : for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
694 : : {
695 [ # # ][ # # ]: 0 : if( aSeriesVector[nSeriesIndex] == xSeries )
696 : 0 : break;
697 : : }
698 [ # # ][ # # ]: 0 : replaceParamterInString( aRet, C2U("%SERIESNUMBER"), OUString::valueOf( nSeriesIndex + 1 ) );
699 : : }
700 : :
701 : : // replace point value
702 : : replaceParamterInString( aRet, C2U("%POINTVALUES"), lcl_getDataPointValueText(
703 [ # # ][ # # ]: 0 : xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) );
[ # # ][ # # ]
704 : 0 : }
705 : : }
706 : : else
707 : : {
708 : : // use the verbose text including the formula for trend lines
709 [ + - ][ - + ]: 2327 : const bool bVerbose( OBJECTTYPE_DATA_CURVE == eObjectType || OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType );
710 [ + - ]: 2327 : const OUString aHelpText( getHelpText( rObjectCID, xChartModel, bVerbose ));
711 [ + + ]: 2327 : if( !aHelpText.isEmpty())
712 : : {
713 [ + - ][ + - ]: 2272 : aRet = String( SchResId( STR_STATUS_OBJECT_MARKED ));
[ + - ][ + - ]
714 [ + - ][ + - ]: 2272 : replaceParamterInString( aRet, C2U("%OBJECTNAME"), aHelpText );
715 : 2327 : }
716 : : }
717 : :
718 : 2327 : return aRet;
719 : : }
720 : :
721 : :
722 : 21334 : rtl::OUString ObjectNameProvider::getNameForCID(
723 : : const rtl::OUString& rObjectCID,
724 : : const uno::Reference< chart2::XChartDocument >& xChartDocument )
725 : : {
726 [ + - ]: 21334 : ObjectType eType( ObjectIdentifier::getObjectType( rObjectCID ));
727 [ + - ]: 21334 : Reference< frame::XModel > xModel( xChartDocument, uno::UNO_QUERY );
728 : :
729 [ + + + + : 21334 : switch( eType )
+ + ]
730 : : {
731 : : case OBJECTTYPE_AXIS:
732 [ + - ]: 3855 : return getAxisName( rObjectCID, xModel );
733 : : case OBJECTTYPE_TITLE:
734 [ + - ]: 2210 : return getTitleName( rObjectCID, xModel );
735 : : case OBJECTTYPE_GRID:
736 : : case OBJECTTYPE_SUBGRID:
737 [ + - ]: 1812 : return getGridName( rObjectCID, xModel );
738 : : case OBJECTTYPE_DATA_SERIES:
739 [ + - ]: 6696 : return lcl_getFullSeriesName( rObjectCID, xModel );
740 : : case OBJECTTYPE_DATA_POINT:
741 : : case OBJECTTYPE_DATA_LABELS:
742 : : case OBJECTTYPE_DATA_LABEL:
743 : : case OBJECTTYPE_DATA_ERRORS_X:
744 : : case OBJECTTYPE_DATA_ERRORS_Y:
745 : : case OBJECTTYPE_DATA_ERRORS_Z:
746 : : case OBJECTTYPE_DATA_CURVE:
747 : : case OBJECTTYPE_DATA_AVERAGE_LINE:
748 : : case OBJECTTYPE_DATA_CURVE_EQUATION:
749 : : {
750 [ + - ]: 16 : rtl::OUString aRet = lcl_getFullSeriesName( rObjectCID, xModel );
751 [ + - ]: 16 : aRet += C2U(" ");
752 [ - + ][ + - ]: 16 : if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL )
753 : : {
754 [ # # ]: 0 : aRet += getName( OBJECTTYPE_DATA_POINT );
755 [ # # ]: 0 : sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID );
756 [ # # ]: 0 : aRet += C2U(" ");
757 : 0 : aRet += OUString::valueOf(nPointIndex+1);
758 : :
759 [ # # ]: 0 : if( eType == OBJECTTYPE_DATA_LABEL )
760 : : {
761 [ # # ]: 0 : aRet += C2U(" ");
762 [ # # ]: 0 : aRet += getName( OBJECTTYPE_DATA_LABEL );
763 : 0 : }
764 : : }
765 : : else
766 [ + - ]: 16 : aRet += getName( eType );
767 : 16 : return aRet;
768 : : }
769 : : default:
770 : 6745 : break;
771 : : }
772 : :
773 [ + - ]: 21334 : return getName( eType );
774 : : }
775 : :
776 : 0 : rtl::OUString ObjectNameProvider::getName_ObjectForSeries(
777 : : ObjectType eObjectType,
778 : : const rtl::OUString& rSeriesCID,
779 : : const uno::Reference< chart2::XChartDocument >& xChartDocument )
780 : : {
781 [ # # ]: 0 : uno::Reference< frame::XModel> xChartModel( xChartDocument, uno::UNO_QUERY );
782 [ # # ][ # # ]: 0 : Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartModel ), uno::UNO_QUERY );
783 [ # # ]: 0 : if( xSeries.is() )
784 : : {
785 [ # # ][ # # ]: 0 : OUString aRet = String(SchResId(STR_OBJECT_FOR_SERIES));
[ # # ][ # # ]
786 [ # # ][ # # ]: 0 : replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, false /*bPlural*/ ) );
[ # # ]
787 [ # # ][ # # ]: 0 : replaceParamterInString( aRet, C2U("%SERIESNAME"), lcl_getDataSeriesName( rSeriesCID, xChartModel ) );
[ # # ]
788 : 0 : return aRet;
789 : : }
790 : : else
791 [ # # ]: 0 : return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType );
792 : : }
793 : :
794 : 0 : rtl::OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType )
795 : : {
796 [ # # ][ # # ]: 0 : OUString aRet = String(SchResId(STR_OBJECT_FOR_ALL_SERIES));
[ # # ]
797 [ # # ][ # # ]: 0 : replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, true /*bPlural*/ ) );
[ # # ]
798 : 0 : return aRet;
799 : : }
800 : :
801 : : //.............................................................................
802 : : } //namespace chart
803 : : //.............................................................................
804 : :
805 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|