Debian Codegraph @

chart2/source/controller/dialogs/dlg_ObjectProperties.cxx

raw
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 #include <sal/config.h>
21
22 #include <cstddef>
23
24 #include <dlg_ObjectProperties.hxx>
25 #include "tp_AxisLabel.hxx"
26 #include "tp_DataLabel.hxx"
27 #include "tp_LegendPosition.hxx"
28 #include "tp_PointGeometry.hxx"
29 #include "tp_Scale.hxx"
30 #include "tp_AxisPositions.hxx"
31 #include "tp_ErrorBars.hxx"
32 #include "tp_Trendline.hxx"
33 #include "tp_SeriesToAxis.hxx"
34 #include "tp_TitleRotation.hxx"
35 #include "tp_PolarOptions.hxx"
36 #include "tp_DataPointOption.hxx"
37 #include "tp_DataTable.hxx"
38 #include "tp_ChartColorPalette.hxx"
39 #include <ViewElementListProvider.hxx>
40 #include <ChartType.hxx>
41 #include <ChartTypeHelper.hxx>
42 #include <ObjectNameProvider.hxx>
43 #include <DataSeries.hxx>
44 #include <DiagramHelper.hxx>
45 #include <Diagram.hxx>
46 #include <NumberFormatterWrapper.hxx>
47 #include <Axis.hxx>
48 #include <AxisHelper.hxx>
49 #include <ExplicitCategoriesProvider.hxx>
50 #include <ChartModel.hxx>
51 #include <CommonConverters.hxx>
52 #include <RegressionCalculationHelper.hxx>
53 #include <BaseCoordinateSystem.hxx>
54
55 #include <com/sun/star/chart2/AxisType.hpp>
56 #include <svl/intitem.hxx>
57 #include <svl/ctloptions.hxx>
58
59 #include <svx/svxids.hrc>
60
61 #include <svx/drawitem.hxx>
62 #include <svx/ofaitem.hxx>
63 #include <svx/svxgraphicitem.hxx>
64
65 #include <svx/dialogs.hrc>
66 #include <editeng/flstitem.hxx>
67
68 #include <svx/flagsdef.hxx>
69 #include <svx/numinf.hxx>
70
71 #include <svl/cjkoptions.hxx>
72 #include <utility>
73 #include <comphelper/diagnose_ex.hxx>
74
75 #include <vcl/tabs.hrc>
76
77 namespace chart
78 {
79
80 using namespace ::com::sun::star;
81 using namespace ::com::sun::star::chart2;
82 using ::com::sun::star::uno::Reference;
83 using ::com::sun::star::uno::Sequence;
84 using ::com::sun::star::uno::Exception;
85 using ::com::sun::star::beans::XPropertySet;
86
87 ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( OUString aObjectCID )
88 : m_aObjectCID(std::move( aObjectCID ))
89 , m_eObjectType( ObjectIdentifier::getObjectType( m_aObjectCID ) )
90 , m_bAffectsMultipleObjects(false)
91 , m_bHasGeometryProperties(false)
92 , m_bHasStatisticProperties(false)
93 , m_bProvidesSecondaryYAxis(false)
94 , m_bProvidesOverlapAndGapWidth(false)
95 , m_bProvidesBarConnectors(false)
96 , m_bHasAreaProperties(false)
97 , m_bHasSymbolProperties(false)
98 , m_bHasNumberProperties(false)
99 , m_bProvidesStartingAngle(false)
100 , m_bProvidesMissingValueTreatments(false)
101 , m_bIsPieChartDataPoint(false)
102 , m_bHasScaleProperties(false)
103 , m_bCanAxisLabelsBeStaggered(false)
104 , m_bSupportingAxisPositioning(false)
105 , m_bShowAxisOrigin(false)
106 , m_bIsCrossingAxisIsCategoryAxis(false)
107 , m_bSupportingCategoryPositioning(false)
108 , m_bComplexCategoriesAxis( false )
109 , m_nNbPoints( 0 )
110 {
111 std::u16string_view aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID );
112 m_bAffectsMultipleObjects = (aParticleID == u"ALLELEMENTS");
113 }
114 ObjectPropertiesDialogParameter::~ObjectPropertiesDialogParameter()
115 {
116 }
117
118 void ObjectPropertiesDialogParameter::init( const rtl::Reference<::chart::ChartModel>& xChartModel )
119 {
120 m_xChartDocument = xChartModel;
121 rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram();
122 rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aObjectCID, xChartModel );
123 rtl::Reference< ChartType > xChartType = xChartModel->getChartTypeOfSeries( xSeries );
124 sal_Int32 nDimensionCount = 0;
125 if (xDiagram)
126 nDimensionCount = xDiagram->getDimension();
127
128 bool bHasSeriesProperties = (m_eObjectType==OBJECTTYPE_DATA_SERIES);
129 bool bHasDataPointproperties = (m_eObjectType==OBJECTTYPE_DATA_POINT);
130
131 if( bHasSeriesProperties || bHasDataPointproperties )
132 {
133 m_bHasGeometryProperties = xChartType->isSupportingGeometryProperties(nDimensionCount );
134 m_bHasAreaProperties = xChartType->isSupportingAreaProperties(nDimensionCount);
135 m_bHasSymbolProperties = xChartType->isSupportingSymbolProperties(nDimensionCount);
136 m_bIsPieChartDataPoint = bHasDataPointproperties && xChartType->isSupportingStartingAngle();
137
138 if( bHasSeriesProperties )
139 {
140 m_bHasStatisticProperties = xChartType->isSupportingStatisticProperties(nDimensionCount);
141 m_bProvidesSecondaryYAxis = xChartType->isSupportingSecondaryAxis(nDimensionCount);
142 m_bProvidesOverlapAndGapWidth = xChartType->isSupportingOverlapAndGapWidthProperties(nDimensionCount);
143 m_bProvidesBarConnectors = xChartType->isSupportingBarConnectors(nDimensionCount);
144 m_bProvidesStartingAngle = xChartType->isSupportingStartingAngle();
145
146 m_bProvidesMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType )
147 .hasElements();
148 }
149 }
150
151 if( m_eObjectType == OBJECTTYPE_DATA_ERRORS_X ||
152 m_eObjectType == OBJECTTYPE_DATA_ERRORS_Y ||
153 m_eObjectType == OBJECTTYPE_DATA_ERRORS_Z)
154 m_bHasStatisticProperties = true;
155
156 if( m_eObjectType == OBJECTTYPE_AXIS )
157 {
158 //show scale properties only for a single axis not for multiselection
159 m_bHasScaleProperties = !m_bAffectsMultipleObjects;
160
161 if( m_bHasScaleProperties )
162 {
163 rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aObjectCID, xChartModel );
164 if( xAxis.is() )
165 {
166 //no scale page for series axis
167 ScaleData aData( xAxis->getScaleData() );
168 if( aData.AxisType == chart2::AxisType::SERIES )
169 m_bHasScaleProperties = false;
170 if( aData.AxisType != chart2::AxisType::SERIES )
171 m_bHasNumberProperties = true;
172
173 //is the crossing main axis a category axes?:
174 rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, xDiagram ) );
175 rtl::Reference< Axis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ) );
176 if( xCrossingMainAxis.is() )
177 {
178 ScaleData aScale( xCrossingMainAxis->getScaleData() );
179 m_bIsCrossingAxisIsCategoryAxis = ( aScale.AxisType == chart2::AxisType::CATEGORY );
180 if( m_bIsCrossingAxisIsCategoryAxis )
181 {
182 if (xChartModel)
183 m_aCategories = DiagramHelper::getExplicitSimpleCategories( *xChartModel );
184 }
185 }
186
187 sal_Int32 nCooSysIndex=0;
188 sal_Int32 nDimensionIndex=0;
189 sal_Int32 nAxisIndex=0;
190 if( AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ) )
191 {
192 xChartType = AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( xDiagram, nAxisIndex );
193 //show positioning controls only if they make sense
194 m_bSupportingAxisPositioning = xChartType.is() ? xChartType->isSupportingAxisPositioning(nDimensionCount, nDimensionIndex) : true;
195
196 //show axis origin only for secondary y axis
197 if( nDimensionIndex==1 && nAxisIndex==1 && xChartType.is() && xChartType->isSupportingBaseValue())
198 m_bShowAxisOrigin = true;
199
200 if ( nDimensionIndex == 0 && ( aData.AxisType == chart2::AxisType::CATEGORY || aData.AxisType == chart2::AxisType::DATE ) )
201 {
202 if (xChartModel)
203 {
204 ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, *xChartModel );
205 m_bComplexCategoriesAxis = aExplicitCategoriesProvider.hasComplexCategories();
206 }
207
208 if (!m_bComplexCategoriesAxis)
209 m_bSupportingCategoryPositioning = xChartType.is() && xChartType->isSupportingCategoryPositioning(nDimensionCount);
210 }
211 }
212 }
213 }
214
215 //no staggering of labels for 3D axis
216 m_bCanAxisLabelsBeStaggered = nDimensionCount==2;
217 }
218
219 if( m_eObjectType == OBJECTTYPE_DATA_CURVE )
220 {
221 const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aDataSeqs( xSeries->getDataSequences2());
222 Sequence< double > aXValues, aYValues;
223 bool bXValuesFound = false, bYValuesFound = false;
224 m_nNbPoints = 0;
225 for( std::size_t i=0;
226 ! (bXValuesFound && bYValuesFound) && i<aDataSeqs.size();
227 ++i )
228 {
229 try
230 {
231 Reference< data::XDataSequence > xSeq( aDataSeqs[i]->getValues());
232 Reference< XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW );
233 OUString aRole;
234 if( xProp->getPropertyValue( u"Role"_ustr ) >>= aRole )
235 {
236 if( !bXValuesFound && aRole == "values-x" )
237 {
238 aXValues = DataSequenceToDoubleSequence( xSeq );
239 bXValuesFound = true;
240 }
241 else if( !bYValuesFound && aRole == "values-y" )
242 {
243 aYValues = DataSequenceToDoubleSequence( xSeq );
244 bYValuesFound = true;
245 }
246 }
247 }
248 catch( const Exception & )
249 {
250 DBG_UNHANDLED_EXCEPTION("chart2");
251 }
252 }
253 if( !bXValuesFound && bYValuesFound )
254 {
255 // initialize with 1, 2, ...
256 //first category (index 0) matches with real number 1.0
257 aXValues.realloc( aYValues.getLength() );
258 auto pXValues = aXValues.getArray();
259 for( sal_Int32 i=0; i<aXValues.getLength(); ++i )
260 pXValues[i] = i+1;
261 bXValuesFound = true;
262 }
263
264 if( bXValuesFound && bYValuesFound &&
265 aXValues.hasElements() &&
266 aYValues.hasElements() )
267 {
268 RegressionCalculationHelper::tDoubleVectorPair aValues(
269 RegressionCalculationHelper::cleanup( aXValues, aYValues, RegressionCalculationHelper::isValid()));
270 m_nNbPoints = aValues.second.size();
271 }
272 }
273
274 //create gui name for this object
275 if( !m_bAffectsMultipleObjects && m_eObjectType == OBJECTTYPE_AXIS )
276 {
277 m_aLocalizedName = ObjectNameProvider::getAxisName( m_aObjectCID, xChartModel );
278 }
279 else if( !m_bAffectsMultipleObjects && ( m_eObjectType == OBJECTTYPE_GRID || m_eObjectType == OBJECTTYPE_SUBGRID ) )
280 {
281 m_aLocalizedName = ObjectNameProvider::getGridName( m_aObjectCID, xChartModel );
282 }
283 else if( !m_bAffectsMultipleObjects && m_eObjectType == OBJECTTYPE_TITLE )
284 {
285 m_aLocalizedName = ObjectNameProvider::getTitleName( m_aObjectCID, xChartModel );
286 }
287 else
288 {
289 switch( m_eObjectType )
290 {
291 case OBJECTTYPE_DATA_POINT:
292 case OBJECTTYPE_DATA_LABEL:
293 case OBJECTTYPE_DATA_LABELS:
294 case OBJECTTYPE_DATA_ERRORS_X:
295 case OBJECTTYPE_DATA_ERRORS_Y:
296 case OBJECTTYPE_DATA_ERRORS_Z:
297 case OBJECTTYPE_DATA_AVERAGE_LINE:
298 case OBJECTTYPE_DATA_CURVE:
299 case OBJECTTYPE_DATA_CURVE_EQUATION:
300 if( m_bAffectsMultipleObjects )
301 m_aLocalizedName = ObjectNameProvider::getName_ObjectForAllSeries( m_eObjectType );
302 else
303 m_aLocalizedName = ObjectNameProvider::getName_ObjectForSeries( m_eObjectType, m_aObjectCID, m_xChartDocument );
304 break;
305 default:
306 m_aLocalizedName = ObjectNameProvider::getName(m_eObjectType,m_bAffectsMultipleObjects);
307 break;
308 }
309 }
310 }
311
312 const sal_uInt16 nNoArrowNoShadowDlg = 1101;
313
314 void SchAttribTabDlg::setSymbolInformation( SfxItemSet&& rSymbolShapeProperties,
315 std::optional<Graphic> oAutoSymbolGraphic )
316 {
317 m_oSymbolShapeProperties.emplace(std::move(rSymbolShapeProperties));
318 m_oAutoSymbolGraphic = std::move(oAutoSymbolGraphic);
319 }
320
321 void SchAttribTabDlg::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth )
322 {
323 m_fAxisMinorStepWidthForErrorBarDecimals = fMinorStepWidth;
324 }
325
326 SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent,
327 const SfxItemSet* pAttr,
328 const ObjectPropertiesDialogParameter& rDialogParameter,
329 const ViewElementListProvider* pViewElementListProvider,
330 const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier)
331 : SfxTabDialogController(pParent, u"modules/schart/ui/attributedialog.ui"_ustr, u"AttributeDialog"_ustr, pAttr)
332 , m_rParameter(rDialogParameter)
333 , m_pViewElementListProvider( pViewElementListProvider )
334 , m_pNumberFormatter(nullptr)
335 , m_fAxisMinorStepWidthForErrorBarDecimals(0.1)
336 , m_bOKPressed(false)
337 {
338 NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
339 m_pNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter();
340
341 m_xDialog->set_title(rDialogParameter.getLocalizedName());
342
343 ObjectType eType = rDialogParameter.getObjectType();
344 switch (eType)
345 {
346 case OBJECTTYPE_TITLE:
347 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
348 RID_M + RID_TAB_BORDER.sIconName);
349 AddTabPage(u"area"_ustr, TabResId(RID_TAB_AREA.aLabel), RID_SVXPAGE_AREA,
350 RID_M + RID_TAB_AREA.sIconName);
351 AddTabPage(u"transparent"_ustr, TabResId(RID_TAB_TRANSPARENCE.aLabel), RID_SVXPAGE_TRANSPARENCE,
352 RID_M + RID_TAB_TRANSPARENCE.sIconName);
353 AddTabPage(u"fontname"_ustr, TabResId(RID_TAB_FONT.aLabel), RID_SVXPAGE_CHAR_NAME,
354 RID_M + RID_TAB_FONT.sIconName);
355 AddTabPage(u"effects"_ustr, TabResId(RID_TAB_FONTEFFECTS.aLabel), RID_SVXPAGE_CHAR_EFFECTS,
356 RID_M + RID_TAB_FONTEFFECTS.sIconName);
357 AddTabPage(u"alignment"_ustr, TabResId(RID_TAB_ALIGNMENT.aLabel), SchAlignmentTabPage::Create,
358 RID_M + RID_TAB_ALIGNMENT.sIconName);
359 if( SvtCJKOptions::IsAsianTypographyEnabled() )
360 AddTabPage(u"asian"_ustr, TabResId(RID_TAB_ASIANTYPO.aLabel), RID_SVXPAGE_PARA_ASIAN,
361 RID_M + RID_TAB_ASIANTYPO.sIconName);
362 break;
363
364 case OBJECTTYPE_LEGEND:
365 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
366 RID_M + RID_TAB_BORDER.sIconName);
367 AddTabPage(u"area"_ustr, TabResId(RID_TAB_AREA.aLabel), RID_SVXPAGE_AREA,
368 RID_M + RID_TAB_AREA.sIconName);
369 AddTabPage(u"transparent"_ustr, TabResId(RID_TAB_TRANSPARENCE.aLabel), RID_SVXPAGE_TRANSPARENCE,
370 RID_M + RID_TAB_TRANSPARENCE.sIconName);
371 AddTabPage(u"colorpalette"_ustr, TabResId(RID_TAB_COLORPALETTE.aLabel), ChartColorPaletteTabPage::Create,
372 RID_M + RID_TAB_COLORPALETTE.sIconName);
373 AddTabPage(u"fontname"_ustr, TabResId(RID_TAB_FONT.aLabel), RID_SVXPAGE_CHAR_NAME,
374 RID_M + RID_TAB_FONT.sIconName);
375 AddTabPage(u"effects"_ustr, TabResId(RID_TAB_FONTEFFECTS.aLabel), RID_SVXPAGE_CHAR_EFFECTS,
376 RID_M + RID_TAB_FONTEFFECTS.sIconName);
377 AddTabPage(u"legendpos"_ustr, TabResId(RID_TAB_CHART_LEGENDPOS.aLabel), SchLegendPosTabPage::Create,
378 RID_M + RID_TAB_CHART_LEGENDPOS.sIconName);
379 if (SvtCJKOptions::IsAsianTypographyEnabled())
380 AddTabPage(u"asian"_ustr, TabResId(RID_TAB_ASIANTYPO.aLabel), RID_SVXPAGE_PARA_ASIAN,
381 RID_M + RID_TAB_ASIANTYPO.sIconName);
382 break;
383
384 case OBJECTTYPE_DATA_SERIES:
385 case OBJECTTYPE_DATA_POINT:
386 if (m_rParameter.ProvidesSecondaryYAxis() || m_rParameter.ProvidesOverlapAndGapWidth() || m_rParameter.ProvidesMissingValueTreatments())
387 AddTabPage(u"options"_ustr, TabResId(RID_TAB_CHART_OPTIONS.aLabel), SchOptionTabPage::Create,
388 RID_M + RID_TAB_CHART_OPTIONS.sIconName);
389 if (m_rParameter.ProvidesStartingAngle())
390 AddTabPage(u"polaroptions"_ustr, TabResId(RID_TAB_CHART_OPTIONS.aLabel), PolarOptionsTabPage::Create,
391 RID_M + RID_TAB_CHART_OPTIONS.sIconName);
392 if (m_rParameter.IsPieChartDataPoint())
393 AddTabPage(u"datapointoption"_ustr, TabResId(RID_TAB_CHART_OPTIONS.aLabel), DataPointOptionTabPage::Create,
394 RID_M + RID_TAB_CHART_OPTIONS.sIconName);
395
396 if (m_rParameter.HasGeometryProperties())
397 AddTabPage(u"layout"_ustr, TabResId(RID_TAB_CHART_LAYOUT.aLabel), SchLayoutTabPage::Create,
398 RID_M + RID_TAB_CHART_LAYOUT.sIconName);
399
400 if (m_rParameter.HasAreaProperties())
401 {
402 AddTabPage(u"area"_ustr, TabResId(RID_TAB_AREA.aLabel), RID_SVXPAGE_AREA,
403 RID_M + RID_TAB_AREA.sIconName);
404 AddTabPage(u"transparent"_ustr, TabResId(RID_TAB_TRANSPARENCE.aLabel), RID_SVXPAGE_TRANSPARENCE,
405 RID_M + RID_TAB_TRANSPARENCE.sIconName);
406 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
407 RID_M + RID_TAB_BORDER.sIconName);
408 }
409 else
410 AddTabPage(u"border"_ustr, TabResId(RID_TAB_LINE.aLabel), RID_SVXPAGE_LINE,
411 RID_M + RID_TAB_LINE.sIconName);
412
413 AddTabPage(u"colorpalette"_ustr, TabResId(RID_TAB_COLORPALETTE.aLabel), ChartColorPaletteTabPage::Create,
414 RID_M + RID_TAB_COLORPALETTE.sIconName);
415 break;
416
417 case OBJECTTYPE_DATA_LABEL:
418 case OBJECTTYPE_DATA_LABELS:
419 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
420 RID_M + RID_TAB_BORDER.sIconName);
421 AddTabPage(u"datalabels"_ustr, TabResId(RID_TAB_CHART_DATALABEL.aLabel), DataLabelsTabPage::Create,
422 RID_M + RID_TAB_CHART_DATALABEL.sIconName);
423 AddTabPage(u"fontname"_ustr, TabResId(RID_TAB_FONT.aLabel), RID_SVXPAGE_CHAR_NAME,
424 RID_M + RID_TAB_FONT.sIconName);
425 AddTabPage(u"effects"_ustr, TabResId(RID_TAB_FONTEFFECTS.aLabel), RID_SVXPAGE_CHAR_EFFECTS,
426 RID_M + RID_TAB_FONTEFFECTS.sIconName);
427 if( SvtCJKOptions::IsAsianTypographyEnabled() )
428 AddTabPage(u"asian"_ustr, TabResId(RID_TAB_ASIANTYPO.aLabel), RID_SVXPAGE_PARA_ASIAN,
429 RID_M + RID_TAB_ASIANTYPO.sIconName);
430
431 break;
432
433 case OBJECTTYPE_AXIS:
434 {
435 if (m_rParameter.HasScaleProperties())
436 {
437 AddTabPage(u"scale"_ustr, TabResId(RID_TAB_CHART_SCALE.aLabel), ScaleTabPage::Create,
438 RID_M + RID_TAB_CHART_SCALE.sIconName);
439 //no positioning page for z axes so far as the tickmarks are not shown so far
440 AddTabPage(u"axispos"_ustr, TabResId(RID_TAB_CHART_POSITIONING.aLabel), AxisPositionsTabPage::Create,
441 RID_M + RID_TAB_CHART_POSITIONING.sIconName);
442 }
443 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
444 RID_M + RID_TAB_BORDER.sIconName);
445 AddTabPage(u"axislabel"_ustr, TabResId(RID_TAB_CHART_AXISLABEL.aLabel), SchAxisLabelTabPage::Create,
446 RID_M + RID_TAB_CHART_AXISLABEL.sIconName);
447 if (m_rParameter.HasNumberProperties())
448 AddTabPage(u"numberformat"_ustr, TabResId(RID_TAB_NUMBERS.aLabel), RID_SVXPAGE_NUMBERFORMAT,
449 RID_M + RID_TAB_NUMBERS.sIconName);
450 AddTabPage(u"fontname"_ustr, TabResId(RID_TAB_FONT.aLabel), RID_SVXPAGE_CHAR_NAME,
451 RID_M + RID_TAB_FONT.sIconName);
452 AddTabPage(u"effects"_ustr, TabResId(RID_TAB_FONTEFFECTS.aLabel), RID_SVXPAGE_CHAR_EFFECTS,
453 RID_M + RID_TAB_FONTEFFECTS.sIconName);
454 if( SvtCJKOptions::IsAsianTypographyEnabled() )
455 AddTabPage(u"asian"_ustr, TabResId(RID_TAB_ASIANTYPO.aLabel), RID_SVXPAGE_PARA_ASIAN,
456 RID_M + RID_TAB_ASIANTYPO.sIconName);
457 break;
458 }
459
460 case OBJECTTYPE_DATA_ERRORS_X:
461 AddTabPage(u"xerrorbar"_ustr, TabResId(RID_TAB_CHART_ERROR_X.aLabel), ErrorBarsTabPage::Create,
462 RID_M + RID_TAB_CHART_ERROR_X.sIconName);
463 AddTabPage(u"border"_ustr, TabResId(RID_TAB_LINE.aLabel), RID_SVXPAGE_LINE,
464 RID_M + RID_TAB_LINE.sIconName);
465 break;
466
467 case OBJECTTYPE_DATA_ERRORS_Y:
468 AddTabPage(u"yerrorbar"_ustr, TabResId(RID_TAB_CHART_ERROR_Y.aLabel), ErrorBarsTabPage::Create,
469 RID_M + RID_TAB_CHART_ERROR_Y.sIconName);
470 AddTabPage(u"border"_ustr, TabResId(RID_TAB_LINE.aLabel), RID_SVXPAGE_LINE,
471 RID_M + RID_TAB_LINE.sIconName);
472 break;
473
474 case OBJECTTYPE_DATA_ERRORS_Z:
475 break;
476
477 case OBJECTTYPE_GRID:
478 case OBJECTTYPE_SUBGRID:
479 case OBJECTTYPE_DATA_AVERAGE_LINE:
480 case OBJECTTYPE_DATA_STOCK_RANGE:
481 AddTabPage(u"border"_ustr, TabResId(RID_TAB_LINE.aLabel), RID_SVXPAGE_LINE,
482 RID_M + RID_TAB_LINE.sIconName);
483 break;
484
485 case OBJECTTYPE_DATA_CURVE:
486 AddTabPage(u"trendline"_ustr, TabResId(RID_TAB_CHART_TREND.aLabel), TrendlineTabPage::Create,
487 RID_M + RID_TAB_CHART_TREND.sIconName);
488 AddTabPage(u"border"_ustr, TabResId(RID_TAB_LINE.aLabel), RID_SVXPAGE_LINE,
489 RID_M + RID_TAB_LINE.sIconName);
490 break;
491
492 case OBJECTTYPE_DATA_STOCK_LOSS:
493 case OBJECTTYPE_DATA_STOCK_GAIN:
494 case OBJECTTYPE_PAGE:
495 case OBJECTTYPE_DIAGRAM_FLOOR:
496 case OBJECTTYPE_DIAGRAM_WALL:
497 case OBJECTTYPE_DIAGRAM:
498 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
499 RID_M + RID_TAB_BORDER.sIconName);
500 AddTabPage(u"area"_ustr, TabResId(RID_TAB_AREA.aLabel), RID_SVXPAGE_AREA,
501 RID_M + RID_TAB_AREA.sIconName);
502 AddTabPage(u"transparent"_ustr, TabResId(RID_TAB_TRANSPARENCE.aLabel), RID_SVXPAGE_TRANSPARENCE,
503 RID_M + RID_TAB_TRANSPARENCE.sIconName);
504 if (eType != OBJECTTYPE_DATA_STOCK_LOSS && eType != OBJECTTYPE_DATA_STOCK_GAIN)
505 AddTabPage(u"colorpalette"_ustr, TabResId(RID_TAB_COLORPALETTE.aLabel), ChartColorPaletteTabPage::Create,
506 RID_M + RID_TAB_COLORPALETTE.sIconName);
507
508 break;
509
510 case OBJECTTYPE_LEGEND_ENTRY:
511 case OBJECTTYPE_AXIS_UNITLABEL:
512 case OBJECTTYPE_UNKNOWN:
513 // nothing
514 break;
515 case OBJECTTYPE_DATA_TABLE:
516 AddTabPage(u"datatable"_ustr, TabResId(RID_TAB_CHART_TABLE.aLabel), DataTableTabPage::Create,
517 RID_M + RID_TAB_CHART_TABLE.sIconName);
518 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
519 RID_M + RID_TAB_BORDER.sIconName);
520 AddTabPage(u"area"_ustr, TabResId(RID_TAB_AREA.aLabel), RID_SVXPAGE_AREA,
521 RID_M + RID_TAB_AREA.sIconName);
522 AddTabPage(u"fontname"_ustr, TabResId(RID_TAB_FONT.aLabel), RID_SVXPAGE_CHAR_NAME,
523 RID_M + RID_TAB_FONT.sIconName);
524 AddTabPage(u"effects"_ustr, TabResId(RID_TAB_FONTEFFECTS.aLabel), RID_SVXPAGE_CHAR_EFFECTS,
525 RID_M + RID_TAB_FONTEFFECTS.sIconName);
526 break;
527 case OBJECTTYPE_DATA_CURVE_EQUATION:
528 AddTabPage(u"border"_ustr, TabResId(RID_TAB_BORDER.aLabel), RID_SVXPAGE_LINE,
529 RID_M + RID_TAB_BORDER.sIconName);
530 AddTabPage(u"area"_ustr, TabResId(RID_TAB_AREA.aLabel), RID_SVXPAGE_AREA,
531 RID_M + RID_TAB_AREA.sIconName);
532 AddTabPage(u"transparent"_ustr, TabResId(RID_TAB_TRANSPARENCE.aLabel), RID_SVXPAGE_TRANSPARENCE,
533 RID_M + RID_TAB_TRANSPARENCE.sIconName);
534 AddTabPage(u"fontname"_ustr, TabResId(RID_TAB_FONT.aLabel), RID_SVXPAGE_CHAR_NAME,
535 RID_M + RID_TAB_FONT.sIconName);
536 AddTabPage(u"effects"_ustr, TabResId(RID_TAB_FONTEFFECTS.aLabel), RID_SVXPAGE_CHAR_EFFECTS,
537 RID_M + RID_TAB_FONTEFFECTS.sIconName);
538 AddTabPage(u"numberformat"_ustr, TabResId(RID_TAB_NUMBERS.aLabel), RID_SVXPAGE_NUMBERFORMAT,
539 RID_M + RID_TAB_NUMBERS.sIconName);
540 if (SvtCTLOptions::IsCTLFontEnabled())
541 {
542 /* When rotation is supported for equation text boxes, use
543 SchAlignmentTabPage::Create here. The special
544 SchAlignmentTabPage::CreateWithoutRotation can be deleted. */
545 AddTabPage(u"alignment"_ustr, TabResId(RID_TAB_ALIGNMENT.aLabel), SchAlignmentTabPage::CreateWithoutRotation,
546 RID_M + RID_TAB_ALIGNMENT.sIconName);
547 }
548 break;
549 default:
550 break;
551 }
552
553 // used to find out if user left the dialog with OK. When OK is pressed but
554 // no changes were done, Cancel is returned by the SfxTabDialog. See method
555 // DialogWasClosedWithOK.
556 GetOKButton().connect_clicked(LINK(this, SchAttribTabDlg, OKPressed));
557 }
558
559 SchAttribTabDlg::~SchAttribTabDlg()
560 {
561 }
562
563 void SchAttribTabDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
564 {
565 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
566 if (rId == "border")
567 {
568 aSet.Put (SvxColorListItem(m_pViewElementListProvider->GetColorTable(),SID_COLOR_TABLE));
569 aSet.Put (SvxDashListItem(m_pViewElementListProvider->GetDashList(),SID_DASH_LIST));
570 aSet.Put (SvxLineEndListItem(m_pViewElementListProvider->GetLineEndList(),SID_LINEEND_LIST));
571 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,0));
572 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nNoArrowNoShadowDlg));
573
574 if (m_rParameter.HasSymbolProperties())
575 {
576 aSet.Put(OfaPtrItem(SID_OBJECT_LIST,m_pViewElementListProvider->GetSymbolList()));
577 if( m_oSymbolShapeProperties )
578 aSet.Put(SfxTabDialogItem(SID_ATTR_SET, *m_oSymbolShapeProperties));
579 if( m_oAutoSymbolGraphic )
580 aSet.Put(SvxGraphicItem(*m_oAutoSymbolGraphic));
581 }
582 rPage.PageCreated(aSet);
583 }
584 else if (rId == "area")
585 {
586 aSet.Put(SvxColorListItem(m_pViewElementListProvider->GetColorTable(),SID_COLOR_TABLE));
587 aSet.Put(SvxGradientListItem(m_pViewElementListProvider->GetGradientList(),SID_GRADIENT_LIST));
588 aSet.Put(SvxHatchListItem(m_pViewElementListProvider->GetHatchList(),SID_HATCH_LIST));
589 aSet.Put(SvxBitmapListItem(m_pViewElementListProvider->GetBitmapList(),SID_BITMAP_LIST));
590 aSet.Put(SvxPatternListItem(m_pViewElementListProvider->GetPatternList(),SID_PATTERN_LIST));
591 aSet.Put(SfxUInt16Item(SID_PAGE_TYPE,0));
592 aSet.Put(SfxUInt16Item(SID_DLG_TYPE,nNoArrowNoShadowDlg));
593 rPage.PageCreated(aSet);
594 }
595 else if (rId == "transparent")
596 {
597 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,0));
598 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nNoArrowNoShadowDlg));
599 rPage.PageCreated(aSet);
600 }
601 else if (rId == "fontname")
602 {
603 aSet.Put (SvxFontListItem(m_pViewElementListProvider->getFontList(), SID_ATTR_CHAR_FONTLIST));
604 rPage.PageCreated(aSet);
605 }
606 else if (rId == "effects")
607 {
608 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
609 rPage.PageCreated(aSet);
610 }
611 else if (rId == "axislabel")
612 {
613 bool bShowStaggeringControls = m_rParameter.CanAxisLabelsBeStaggered();
614 auto & rLabelPage = static_cast<SchAxisLabelTabPage&>(rPage);
615 rLabelPage.ShowStaggeringControls( bShowStaggeringControls );
616 rLabelPage.SetComplexCategories(m_rParameter.IsComplexCategoriesAxis());
617 }
618 else if (rId == "axispos")
619 {
620 AxisPositionsTabPage* pPage = dynamic_cast< AxisPositionsTabPage* >( &rPage );
621 if(pPage)
622 {
623 pPage->SetNumFormatter( m_pNumberFormatter );
624 if (m_rParameter.IsCrossingAxisIsCategoryAxis())
625 {
626 pPage->SetCrossingAxisIsCategoryAxis(m_rParameter.IsCrossingAxisIsCategoryAxis());
627 pPage->SetCategories(m_rParameter.GetCategories());
628 }
629 pPage->SupportAxisPositioning(m_rParameter.IsSupportingAxisPositioning());
630 pPage->SupportCategoryPositioning(m_rParameter.IsSupportingCategoryPositioning());
631 }
632 }
633 else if (rId == "scale")
634 {
635 ScaleTabPage* pScaleTabPage = dynamic_cast< ScaleTabPage* >( &rPage );
636 if(pScaleTabPage)
637 {
638 pScaleTabPage->SetNumFormatter( m_pNumberFormatter );
639 pScaleTabPage->ShowAxisOrigin(m_rParameter.ShowAxisOrigin());
640 }
641 }
642 else if (rId == "datalabels")
643 {
644 DataLabelsTabPage* pLabelPage = dynamic_cast< DataLabelsTabPage* >( &rPage );
645 if( pLabelPage )
646 pLabelPage->SetNumberFormatter( m_pNumberFormatter );
647 }
648 else if (rId == "numberformat")
649 {
650 aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, SID_ATTR_NUMBERFORMAT_INFO));
651 rPage.PageCreated(aSet);
652 }
653 else if (rId == "xerrorbar")
654 {
655 ErrorBarsTabPage * pTabPage = dynamic_cast< ErrorBarsTabPage * >( &rPage );
656 OSL_ASSERT( pTabPage );
657 if( pTabPage )
658 {
659 pTabPage->SetAxisMinorStepWidthForErrorBarDecimals( m_fAxisMinorStepWidthForErrorBarDecimals );
660 pTabPage->SetErrorBarType( ErrorBarResources::ERROR_BAR_X );
661 pTabPage->SetChartDocumentForRangeChoosing(m_rParameter.getDocument());
662 }
663 }
664 else if (rId == "yerrorbar")
665 {
666 ErrorBarsTabPage * pTabPage = dynamic_cast< ErrorBarsTabPage * >( &rPage );
667 OSL_ASSERT( pTabPage );
668 if( pTabPage )
669 {
670 pTabPage->SetAxisMinorStepWidthForErrorBarDecimals( m_fAxisMinorStepWidthForErrorBarDecimals );
671 pTabPage->SetErrorBarType( ErrorBarResources::ERROR_BAR_Y );
672 pTabPage->SetChartDocumentForRangeChoosing(m_rParameter.getDocument());
673 }
674 }
675 else if (rId == "options")
676 {
677 SchOptionTabPage* pTabPage = dynamic_cast< SchOptionTabPage* >( &rPage );
678 if (pTabPage)
679 pTabPage->Init(m_rParameter.ProvidesSecondaryYAxis(),
680 m_rParameter.ProvidesOverlapAndGapWidth(),
681 m_rParameter.ProvidesBarConnectors());
682 }
683 else if (rId == "trendline")
684 {
685 TrendlineTabPage* pTrendlineTabPage = dynamic_cast< TrendlineTabPage* >( &rPage );
686 if(pTrendlineTabPage)
687 {
688 pTrendlineTabPage->SetNumFormatter( m_pNumberFormatter );
689 pTrendlineTabPage->SetNbPoints(m_rParameter.getNbPoints());
690 }
691 }
692 else if (rId == "colorpalette")
693 {
694 auto* pColorPaletteTabPage = dynamic_cast<ChartColorPaletteTabPage*>( &rPage );
695 if (pColorPaletteTabPage)
696 {
697 pColorPaletteTabPage->init(m_rParameter.getDocument());
698 }
699 }
700 }
701
702 IMPL_LINK(SchAttribTabDlg, OKPressed, weld::Button&, rButton, void)
703 {
704 m_bOKPressed = true;
705 OkHdl(rButton);
706 }
707
708 } //namespace chart
709
710 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */