| 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 "DiagramWrapper.hxx" |
| 21 |
#include <servicenames_charttypes.hxx> |
| 22 |
#include "DataSeriesPointWrapper.hxx" |
| 23 |
#include <DataSeriesProperties.hxx> |
| 24 |
#include "AxisWrapper.hxx" |
| 25 |
#include "Chart2ModelContact.hxx" |
| 26 |
#include "WallFloorWrapper.hxx" |
| 27 |
#include "MinMaxLineWrapper.hxx" |
| 28 |
#include "UpDownBarWrapper.hxx" |
| 29 |
#include <Diagram.hxx> |
| 30 |
#include <DiagramHelper.hxx> |
| 31 |
#include <DataSourceHelper.hxx> |
| 32 |
#include <ChartType.hxx> |
| 33 |
#include <DataSeries.hxx> |
| 34 |
#include <WrappedIgnoreProperty.hxx> |
| 35 |
#include "WrappedAxisAndGridExistenceProperties.hxx" |
| 36 |
#include "WrappedStatisticProperties.hxx" |
| 37 |
#include "WrappedSymbolProperties.hxx" |
| 38 |
#include "WrappedDataCaptionProperties.hxx" |
| 39 |
#include "WrappedSplineProperties.hxx" |
| 40 |
#include "WrappedStockProperties.hxx" |
| 41 |
#include "WrappedSceneProperty.hxx" |
| 42 |
#include <ControllerLockGuard.hxx> |
| 43 |
#include <DisposeHelper.hxx> |
| 44 |
#include "WrappedAutomaticPositionProperties.hxx" |
| 45 |
#include <CommonConverters.hxx> |
| 46 |
#include <unonames.hxx> |
| 47 |
#include <comphelper/sequence.hxx> |
| 48 |
#include <cppuhelper/supportsservice.hxx> |
| 49 |
#include <ChartTypeManager.hxx> |
| 50 |
#include <ChartTypeTemplate.hxx> |
| 51 |
|
| 52 |
#include <com/sun/star/beans/PropertyAttribute.hpp> |
| 53 |
#include <com/sun/star/chart/ChartDataRowSource.hpp> |
| 54 |
#include <com/sun/star/chart2/RelativeSize.hpp> |
| 55 |
#include <com/sun/star/chart2/RelativePosition.hpp> |
| 56 |
#include <com/sun/star/chart2/PieChartSubType.hpp> |
| 57 |
#include <com/sun/star/chart/ChartSolidType.hpp> |
| 58 |
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> |
| 59 |
|
| 60 |
#include <LinePropertiesHelper.hxx> |
| 61 |
#include <FillProperties.hxx> |
| 62 |
#include <UserDefinedProperties.hxx> |
| 63 |
#include <SceneProperties.hxx> |
| 64 |
|
| 65 |
#include <algorithm> |
| 66 |
#include <map> |
| 67 |
#include <com/sun/star/lang/XServiceName.hpp> |
| 68 |
#include <com/sun/star/util/XRefreshable.hpp> |
| 69 |
#include <comphelper/diagnose_ex.hxx> |
| 70 |
#include <o3tl/string_view.hxx> |
| 71 |
#include <utility> |
| 72 |
|
| 73 |
using namespace ::com::sun::star; |
| 74 |
using namespace ::chart::wrapper; |
| 75 |
using namespace ::chart::DataSeriesProperties; |
| 76 |
|
| 77 |
using ::com::sun::star::uno::Reference; |
| 78 |
using ::com::sun::star::uno::Any; |
| 79 |
using ::com::sun::star::uno::Sequence; |
| 80 |
using ::com::sun::star::beans::Property; |
| 81 |
using ::com::sun::star::chart::XAxis; |
| 82 |
|
| 83 |
namespace |
| 84 |
{ |
| 85 |
|
| 86 |
enum |
| 87 |
{ |
| 88 |
PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS, |
| 89 |
PROP_DIAGRAM_PERCENT_STACKED, |
| 90 |
PROP_DIAGRAM_STACKED, |
| 91 |
PROP_DIAGRAM_THREE_D, |
| 92 |
PROP_DIAGRAM_SOLIDTYPE, |
| 93 |
PROP_DIAGRAM_DEEP, |
| 94 |
PROP_DIAGRAM_VERTICAL, |
| 95 |
PROP_DIAGRAM_NUMBER_OF_LINES, |
| 96 |
PROP_DIAGRAM_STACKED_BARS_CONNECTED, |
| 97 |
PROP_DIAGRAM_DATAROW_SOURCE, |
| 98 |
|
| 99 |
PROP_DIAGRAM_GROUP_BARS_PER_AXIS, |
| 100 |
PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, |
| 101 |
|
| 102 |
PROP_DIAGRAM_SORT_BY_X_VALUES, |
| 103 |
|
| 104 |
PROP_DIAGRAM_STARTING_ANGLE, |
| 105 |
PROP_DIAGRAM_OF_PIE_TYPE, |
| 106 |
PROP_DIAGRAM_SPLIT_POS, |
| 107 |
|
| 108 |
PROP_DIAGRAM_RIGHT_ANGLED_AXES, |
| 109 |
PROP_DIAGRAM_PERSPECTIVE, |
| 110 |
PROP_DIAGRAM_ROTATION_HORIZONTAL, |
| 111 |
PROP_DIAGRAM_ROTATION_VERTICAL, |
| 112 |
|
| 113 |
PROP_DIAGRAM_MISSING_VALUE_TREATMENT, |
| 114 |
|
| 115 |
PROP_DIAGRAM_HAS_X_AXIS, |
| 116 |
PROP_DIAGRAM_HAS_X_AXIS_DESCR, |
| 117 |
PROP_DIAGRAM_HAS_X_AXIS_TITLE, |
| 118 |
PROP_DIAGRAM_HAS_X_AXIS_GRID, |
| 119 |
PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID, |
| 120 |
|
| 121 |
PROP_DIAGRAM_HAS_Y_AXIS, |
| 122 |
PROP_DIAGRAM_HAS_Y_AXIS_DESCR, |
| 123 |
PROP_DIAGRAM_HAS_Y_AXIS_TITLE, |
| 124 |
PROP_DIAGRAM_HAS_Y_AXIS_GRID, |
| 125 |
PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID, |
| 126 |
|
| 127 |
PROP_DIAGRAM_HAS_Z_AXIS, |
| 128 |
PROP_DIAGRAM_HAS_Z_AXIS_DESCR, |
| 129 |
PROP_DIAGRAM_HAS_Z_AXIS_TITLE, |
| 130 |
PROP_DIAGRAM_HAS_Z_AXIS_GRID, |
| 131 |
PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID, |
| 132 |
|
| 133 |
PROP_DIAGRAM_HAS_SECOND_X_AXIS, |
| 134 |
PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR, |
| 135 |
|
| 136 |
PROP_DIAGRAM_HAS_SECOND_Y_AXIS, |
| 137 |
PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR, |
| 138 |
|
| 139 |
PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE, |
| 140 |
PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, |
| 141 |
|
| 142 |
PROP_DIAGRAM_AUTOMATIC_SIZE, |
| 143 |
PROP_DIAGRAM_EXTERNALDATA, |
| 144 |
PROP_DIAGRAM_STYLE_INDEX |
| 145 |
}; |
| 146 |
|
| 147 |
void lcl_AddPropertiesToVector( |
| 148 |
std::vector< Property > & rOutProperties ) |
| 149 |
{ |
| 150 |
rOutProperties.emplace_back( "AttributedDataPoints", |
| 151 |
PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS, |
| 152 |
cppu::UnoType<uno::Sequence< uno::Sequence< sal_Int32 > >>::get(), |
| 153 |
beans::PropertyAttribute::BOUND |
| 154 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 155 |
|
| 156 |
// see com.sun.star.chart.StackableDiagram |
| 157 |
rOutProperties.emplace_back( "Percent", |
| 158 |
PROP_DIAGRAM_PERCENT_STACKED, |
| 159 |
cppu::UnoType<bool>::get(), |
| 160 |
beans::PropertyAttribute::BOUND |
| 161 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 162 |
rOutProperties.emplace_back( "Stacked", |
| 163 |
PROP_DIAGRAM_STACKED, |
| 164 |
cppu::UnoType<bool>::get(), |
| 165 |
beans::PropertyAttribute::BOUND |
| 166 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 167 |
|
| 168 |
rOutProperties.emplace_back( "Dim3D", |
| 169 |
PROP_DIAGRAM_THREE_D, |
| 170 |
cppu::UnoType<bool>::get(), |
| 171 |
beans::PropertyAttribute::BOUND |
| 172 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 173 |
|
| 174 |
// see com.sun.star.chart.Chart3DBarProperties |
| 175 |
rOutProperties.emplace_back( "SolidType", |
| 176 |
PROP_DIAGRAM_SOLIDTYPE, |
| 177 |
cppu::UnoType<sal_Int32>::get(), |
| 178 |
beans::PropertyAttribute::BOUND |
| 179 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 180 |
|
| 181 |
// see com.sun.star.chart.BarDiagram |
| 182 |
rOutProperties.emplace_back( "Deep", |
| 183 |
PROP_DIAGRAM_DEEP, |
| 184 |
cppu::UnoType<bool>::get(), |
| 185 |
beans::PropertyAttribute::BOUND |
| 186 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 187 |
rOutProperties.emplace_back( "Vertical", |
| 188 |
PROP_DIAGRAM_VERTICAL, |
| 189 |
cppu::UnoType<bool>::get(), |
| 190 |
beans::PropertyAttribute::BOUND |
| 191 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 192 |
rOutProperties.emplace_back( "NumberOfLines", |
| 193 |
PROP_DIAGRAM_NUMBER_OF_LINES, |
| 194 |
cppu::UnoType<sal_Int32>::get(), |
| 195 |
beans::PropertyAttribute::BOUND |
| 196 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 197 |
rOutProperties.emplace_back( "StackedBarsConnected", |
| 198 |
PROP_DIAGRAM_STACKED_BARS_CONNECTED, |
| 199 |
cppu::UnoType<bool>::get(), |
| 200 |
beans::PropertyAttribute::BOUND |
| 201 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 202 |
|
| 203 |
rOutProperties.emplace_back( "DataRowSource", |
| 204 |
PROP_DIAGRAM_DATAROW_SOURCE, |
| 205 |
cppu::UnoType<css::chart::ChartDataRowSource>::get(), |
| 206 |
beans::PropertyAttribute::BOUND |
| 207 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 208 |
|
| 209 |
rOutProperties.emplace_back( "GroupBarsPerAxis", |
| 210 |
PROP_DIAGRAM_GROUP_BARS_PER_AXIS, |
| 211 |
cppu::UnoType<bool>::get(), |
| 212 |
beans::PropertyAttribute::BOUND |
| 213 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 214 |
|
| 215 |
rOutProperties.emplace_back( "IncludeHiddenCells", |
| 216 |
PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, |
| 217 |
cppu::UnoType<bool>::get(), |
| 218 |
beans::PropertyAttribute::BOUND |
| 219 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 220 |
|
| 221 |
//new for XY charts |
| 222 |
rOutProperties.emplace_back( CHART_UNONAME_SORT_BY_XVALUES, |
| 223 |
PROP_DIAGRAM_SORT_BY_X_VALUES, |
| 224 |
cppu::UnoType<bool>::get(), |
| 225 |
beans::PropertyAttribute::BOUND |
| 226 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 227 |
|
| 228 |
//for pie and donut charts |
| 229 |
rOutProperties.emplace_back( "StartingAngle", |
| 230 |
PROP_DIAGRAM_STARTING_ANGLE, |
| 231 |
cppu::UnoType<sal_Int32>::get(), |
| 232 |
beans::PropertyAttribute::BOUND |
| 233 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 234 |
rOutProperties.emplace_back( "SubPieType", |
| 235 |
PROP_DIAGRAM_OF_PIE_TYPE, |
| 236 |
cppu::UnoType<chart2::PieChartSubType>::get(), |
| 237 |
beans::PropertyAttribute::BOUND |
| 238 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 239 |
rOutProperties.emplace_back( "SplitPos", |
| 240 |
PROP_DIAGRAM_SPLIT_POS, |
| 241 |
cppu::UnoType<sal_Int32>::get(), |
| 242 |
beans::PropertyAttribute::BOUND |
| 243 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 244 |
|
| 245 |
//new for 3D charts |
| 246 |
rOutProperties.emplace_back( "RightAngledAxes", |
| 247 |
PROP_DIAGRAM_RIGHT_ANGLED_AXES, |
| 248 |
cppu::UnoType<bool>::get(), |
| 249 |
beans::PropertyAttribute::BOUND |
| 250 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 251 |
|
| 252 |
rOutProperties.emplace_back( "Perspective", |
| 253 |
PROP_DIAGRAM_PERSPECTIVE, |
| 254 |
cppu::UnoType<sal_Int32>::get(), |
| 255 |
beans::PropertyAttribute::MAYBEVOID ); |
| 256 |
|
| 257 |
rOutProperties.emplace_back( "RotationHorizontal", |
| 258 |
PROP_DIAGRAM_ROTATION_HORIZONTAL, |
| 259 |
cppu::UnoType<sal_Int32>::get(), |
| 260 |
beans::PropertyAttribute::MAYBEVOID ); |
| 261 |
|
| 262 |
rOutProperties.emplace_back( "RotationVertical", |
| 263 |
PROP_DIAGRAM_ROTATION_VERTICAL, |
| 264 |
cppu::UnoType<sal_Int32>::get(), |
| 265 |
beans::PropertyAttribute::MAYBEVOID ); |
| 266 |
|
| 267 |
// XAxisXSupplier |
| 268 |
rOutProperties.emplace_back( "HasXAxis", |
| 269 |
PROP_DIAGRAM_HAS_X_AXIS, |
| 270 |
cppu::UnoType<bool>::get(), |
| 271 |
beans::PropertyAttribute::BOUND |
| 272 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 273 |
rOutProperties.emplace_back( "HasXAxisDescription", |
| 274 |
PROP_DIAGRAM_HAS_X_AXIS_DESCR, |
| 275 |
cppu::UnoType<bool>::get(), |
| 276 |
beans::PropertyAttribute::BOUND |
| 277 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 278 |
rOutProperties.emplace_back( "HasXAxisTitle", |
| 279 |
PROP_DIAGRAM_HAS_X_AXIS_TITLE, |
| 280 |
cppu::UnoType<bool>::get(), |
| 281 |
beans::PropertyAttribute::BOUND |
| 282 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 283 |
rOutProperties.emplace_back( "HasXAxisGrid", |
| 284 |
PROP_DIAGRAM_HAS_X_AXIS_GRID, |
| 285 |
cppu::UnoType<bool>::get(), |
| 286 |
beans::PropertyAttribute::BOUND |
| 287 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 288 |
rOutProperties.emplace_back( "HasXAxisHelpGrid", |
| 289 |
PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID, |
| 290 |
cppu::UnoType<bool>::get(), |
| 291 |
beans::PropertyAttribute::BOUND |
| 292 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 293 |
|
| 294 |
// XAxisYSupplier |
| 295 |
rOutProperties.emplace_back( "HasYAxis", |
| 296 |
PROP_DIAGRAM_HAS_Y_AXIS, |
| 297 |
cppu::UnoType<bool>::get(), |
| 298 |
beans::PropertyAttribute::BOUND |
| 299 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 300 |
rOutProperties.emplace_back( "HasYAxisDescription", |
| 301 |
PROP_DIAGRAM_HAS_Y_AXIS_DESCR, |
| 302 |
cppu::UnoType<bool>::get(), |
| 303 |
beans::PropertyAttribute::BOUND |
| 304 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 305 |
rOutProperties.emplace_back( "HasYAxisTitle", |
| 306 |
PROP_DIAGRAM_HAS_Y_AXIS_TITLE, |
| 307 |
cppu::UnoType<bool>::get(), |
| 308 |
beans::PropertyAttribute::BOUND |
| 309 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 310 |
rOutProperties.emplace_back( "HasYAxisGrid", |
| 311 |
PROP_DIAGRAM_HAS_Y_AXIS_GRID, |
| 312 |
cppu::UnoType<bool>::get(), |
| 313 |
beans::PropertyAttribute::BOUND |
| 314 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 315 |
rOutProperties.emplace_back( "HasYAxisHelpGrid", |
| 316 |
PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID, |
| 317 |
cppu::UnoType<bool>::get(), |
| 318 |
beans::PropertyAttribute::BOUND |
| 319 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 320 |
|
| 321 |
// XAxisZSupplier |
| 322 |
rOutProperties.emplace_back( "HasZAxis", |
| 323 |
PROP_DIAGRAM_HAS_Z_AXIS, |
| 324 |
cppu::UnoType<bool>::get(), |
| 325 |
beans::PropertyAttribute::BOUND |
| 326 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 327 |
rOutProperties.emplace_back( "HasZAxisDescription", |
| 328 |
PROP_DIAGRAM_HAS_Z_AXIS_DESCR, |
| 329 |
cppu::UnoType<bool>::get(), |
| 330 |
beans::PropertyAttribute::BOUND |
| 331 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 332 |
rOutProperties.emplace_back( "HasZAxisTitle", |
| 333 |
PROP_DIAGRAM_HAS_Z_AXIS_TITLE, |
| 334 |
cppu::UnoType<bool>::get(), |
| 335 |
beans::PropertyAttribute::BOUND |
| 336 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 337 |
rOutProperties.emplace_back( "HasZAxisGrid", |
| 338 |
PROP_DIAGRAM_HAS_Z_AXIS_GRID, |
| 339 |
cppu::UnoType<bool>::get(), |
| 340 |
beans::PropertyAttribute::BOUND |
| 341 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 342 |
rOutProperties.emplace_back( "HasZAxisHelpGrid", |
| 343 |
PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID, |
| 344 |
cppu::UnoType<bool>::get(), |
| 345 |
beans::PropertyAttribute::BOUND |
| 346 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 347 |
|
| 348 |
// XTwoAxisXSupplier |
| 349 |
rOutProperties.emplace_back( "HasSecondaryXAxis", |
| 350 |
PROP_DIAGRAM_HAS_SECOND_X_AXIS, |
| 351 |
cppu::UnoType<bool>::get(), |
| 352 |
beans::PropertyAttribute::BOUND |
| 353 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 354 |
rOutProperties.emplace_back( "HasSecondaryXAxisDescription", |
| 355 |
PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR, |
| 356 |
cppu::UnoType<bool>::get(), |
| 357 |
beans::PropertyAttribute::BOUND |
| 358 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 359 |
|
| 360 |
// XTwoAxisYSupplier |
| 361 |
rOutProperties.emplace_back( "HasSecondaryYAxis", |
| 362 |
PROP_DIAGRAM_HAS_SECOND_Y_AXIS, |
| 363 |
cppu::UnoType<bool>::get(), |
| 364 |
beans::PropertyAttribute::BOUND |
| 365 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 366 |
rOutProperties.emplace_back( "HasSecondaryYAxisDescription", |
| 367 |
PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR, |
| 368 |
cppu::UnoType<bool>::get(), |
| 369 |
beans::PropertyAttribute::BOUND |
| 370 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 371 |
|
| 372 |
// XSecondAxisTitleSupplier |
| 373 |
rOutProperties.emplace_back( "HasSecondaryXAxisTitle", |
| 374 |
PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE, |
| 375 |
cppu::UnoType<bool>::get(), |
| 376 |
beans::PropertyAttribute::BOUND |
| 377 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 378 |
rOutProperties.emplace_back( "HasSecondaryYAxisTitle", |
| 379 |
PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, |
| 380 |
cppu::UnoType<bool>::get(), |
| 381 |
beans::PropertyAttribute::BOUND |
| 382 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 383 |
|
| 384 |
rOutProperties.emplace_back( "MissingValueTreatment", |
| 385 |
PROP_DIAGRAM_MISSING_VALUE_TREATMENT, |
| 386 |
cppu::UnoType<sal_Int32>::get(), |
| 387 |
beans::PropertyAttribute::BOUND |
| 388 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 389 |
|
| 390 |
rOutProperties.emplace_back( "AutomaticSize", |
| 391 |
PROP_DIAGRAM_AUTOMATIC_SIZE, |
| 392 |
cppu::UnoType<bool>::get(), |
| 393 |
beans::PropertyAttribute::BOUND |
| 394 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 395 |
|
| 396 |
// chartSpace properties |
| 397 |
rOutProperties.emplace_back( "ExternalData", |
| 398 |
PROP_DIAGRAM_EXTERNALDATA, |
| 399 |
cppu::UnoType<OUString>::get(), |
| 400 |
beans::PropertyAttribute::BOUND |
| 401 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 402 |
|
| 403 |
rOutProperties.emplace_back( "StyleIndex", |
| 404 |
PROP_DIAGRAM_STYLE_INDEX, |
| 405 |
cppu::UnoType<sal_Int32>::get(), |
| 406 |
beans::PropertyAttribute::BOUND |
| 407 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 408 |
} |
| 409 |
|
| 410 |
const Sequence< Property >& StaticDiagramWrapperPropertyArray() |
| 411 |
{ |
| 412 |
static Sequence< Property > aPropSeq = []() |
| 413 |
{ |
| 414 |
std::vector< css::beans::Property > aProperties; |
| 415 |
lcl_AddPropertiesToVector( aProperties ); |
| 416 |
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); |
| 417 |
::chart::FillProperties::AddPropertiesToVector( aProperties ); |
| 418 |
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); |
| 419 |
::chart::SceneProperties::AddPropertiesToVector( aProperties ); |
| 420 |
WrappedStatisticProperties::addProperties( aProperties ); |
| 421 |
WrappedSymbolProperties::addProperties( aProperties ); |
| 422 |
WrappedDataCaptionProperties::addProperties( aProperties ); |
| 423 |
WrappedSplineProperties::addProperties( aProperties ); |
| 424 |
WrappedStockProperties::addProperties( aProperties ); |
| 425 |
WrappedAutomaticPositionProperties::addProperties( aProperties ); |
| 426 |
|
| 427 |
std::sort( aProperties.begin(), aProperties.end(), |
| 428 |
::chart::PropertyNameLess() ); |
| 429 |
|
| 430 |
return comphelper::containerToSequence( aProperties ); |
| 431 |
}(); |
| 432 |
return aPropSeq; |
| 433 |
}; |
| 434 |
|
| 435 |
bool lcl_isXYChart( const rtl::Reference< ::chart::Diagram >& xDiagram ) |
| 436 |
{ |
| 437 |
bool bRet = false; |
| 438 |
rtl::Reference< ::chart::ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); |
| 439 |
if( xChartType.is() ) |
| 440 |
{ |
| 441 |
OUString aChartType( xChartType->getChartType() ); |
| 442 |
if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ) |
| 443 |
bRet = true; |
| 444 |
} |
| 445 |
return bRet; |
| 446 |
} |
| 447 |
|
| 448 |
sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( |
| 449 |
sal_Int32 nOldAPIIndex |
| 450 |
, const rtl::Reference< ::chart::Diagram >& xDiagram ) |
| 451 |
{ |
| 452 |
sal_Int32 nNewAPIIndex = nOldAPIIndex; |
| 453 |
|
| 454 |
if( lcl_isXYChart( xDiagram ) ) |
| 455 |
{ |
| 456 |
if( nNewAPIIndex >= 1 ) |
| 457 |
nNewAPIIndex -= 1; |
| 458 |
} |
| 459 |
|
| 460 |
std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesList = |
| 461 |
xDiagram->getDataSeries(); |
| 462 |
if( nNewAPIIndex >= static_cast<sal_Int32>(aSeriesList.size()) ) |
| 463 |
nNewAPIIndex = -1; |
| 464 |
|
| 465 |
return nNewAPIIndex; |
| 466 |
} |
| 467 |
|
| 468 |
OUString lcl_getDiagramType( std::u16string_view rTemplateServiceName ) |
| 469 |
{ |
| 470 |
static constexpr OUString aPrefix(u"com.sun.star.chart2.template."_ustr); |
| 471 |
|
| 472 |
if( o3tl::starts_with(rTemplateServiceName, aPrefix) ) |
| 473 |
{ |
| 474 |
const std::u16string_view aName( rTemplateServiceName.substr( aPrefix.getLength())); |
| 475 |
|
| 476 |
// "Area" "StackedArea" "PercentStackedArea" "ThreeDArea" |
| 477 |
// "StackedThreeDArea" "PercentStackedThreeDArea" |
| 478 |
if( aName.find( u"Area" ) != std::u16string_view::npos ) |
| 479 |
return u"com.sun.star.chart.AreaDiagram"_ustr; |
| 480 |
|
| 481 |
// Handle bar-of-pie and pie-of-pie before simple pie |
| 482 |
// "BarOfPie" |
| 483 |
if( aName.find( u"BarOfPie" ) != std::u16string_view::npos ) |
| 484 |
return u"com.sun.star.chart.BarOfPieDiagram"_ustr; |
| 485 |
|
| 486 |
// "PieOfPie" |
| 487 |
if( aName.find( u"PieOfPie" ) != std::u16string_view::npos ) |
| 488 |
return u"com.sun.star.chart.PieOfPieDiagram"_ustr; |
| 489 |
|
| 490 |
// "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded" |
| 491 |
if( aName.find( u"Pie" ) != std::u16string_view::npos ) |
| 492 |
return u"com.sun.star.chart.PieDiagram"_ustr; |
| 493 |
|
| 494 |
// "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep" |
| 495 |
// "ThreeDColumnFlat" "StackedThreeDColumnFlat" |
| 496 |
// "PercentStackedThreeDColumnFlat" "Bar" "StackedBar" |
| 497 |
// "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat" |
| 498 |
// "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine" |
| 499 |
// "StackedColumnWithLine" |
| 500 |
if( aName.find( u"Column" ) != std::u16string_view::npos || aName.find( u"Bar" ) != std::u16string_view::npos ) |
| 501 |
return u"com.sun.star.chart.BarDiagram"_ustr; |
| 502 |
|
| 503 |
// "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded" |
| 504 |
if( aName.find( u"Donut" ) != std::u16string_view::npos ) |
| 505 |
return u"com.sun.star.chart.DonutDiagram"_ustr; |
| 506 |
|
| 507 |
// "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter" |
| 508 |
if( aName.find( u"Scatter" ) != std::u16string_view::npos ) |
| 509 |
return u"com.sun.star.chart.XYDiagram"_ustr; |
| 510 |
|
| 511 |
// "FilledNet" "StackedFilledNet" "PercentStackedFilledNet" |
| 512 |
if( aName.find( u"FilledNet" ) != std::u16string_view::npos ) |
| 513 |
return u"com.sun.star.chart.FilledNetDiagram"_ustr; |
| 514 |
|
| 515 |
// "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol" |
| 516 |
// "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol" |
| 517 |
// "PercentStackedNetLine" |
| 518 |
if( aName.find( u"Net" ) != std::u16string_view::npos ) |
| 519 |
return u"com.sun.star.chart.NetDiagram"_ustr; |
| 520 |
|
| 521 |
// "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose" |
| 522 |
// "StockVolumeOpenLowHighClose" |
| 523 |
if( aName.find( u"Stock" ) != std::u16string_view::npos ) |
| 524 |
return u"com.sun.star.chart.StockDiagram"_ustr; |
| 525 |
|
| 526 |
if( aName.find( u"Bubble" ) != std::u16string_view::npos ) |
| 527 |
return u"com.sun.star.chart.BubbleDiagram"_ustr; |
| 528 |
|
| 529 |
// Note: this must be checked after Bar, Net and Scatter |
| 530 |
|
| 531 |
// "Symbol" "StackedSymbol" "PercentStackedSymbol" "Line" "StackedLine" |
| 532 |
// "PercentStackedLine" "LineSymbol" "StackedLineSymbol" |
| 533 |
// "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine" |
| 534 |
// "PercentStackedThreeDLine" "ThreeDLineDeep" |
| 535 |
if( aName.find( u"Line" ) != std::u16string_view::npos || aName.find( u"Symbol" ) != std::u16string_view::npos ) |
| 536 |
return u"com.sun.star.chart.LineDiagram"_ustr; |
| 537 |
|
| 538 |
OSL_FAIL( "unknown template" ); |
| 539 |
} |
| 540 |
|
| 541 |
return OUString(); |
| 542 |
} |
| 543 |
|
| 544 |
typedef std::map< OUString, OUString > tMakeStringStringMap; |
| 545 |
|
| 546 |
const tMakeStringStringMap& lcl_getChartTypeNameMap() |
| 547 |
{ |
| 548 |
static tMakeStringStringMap g_aChartTypeNameMap{ |
| 549 |
{"com.sun.star.chart2.LineChartType", "com.sun.star.chart.LineDiagram"}, |
| 550 |
{"com.sun.star.chart2.AreaChartType", "com.sun.star.chart.AreaDiagram"}, |
| 551 |
{"com.sun.star.chart2.ColumnChartType", "com.sun.star.chart.BarDiagram"}, |
| 552 |
{"com.sun.star.chart2.PieChartType", "com.sun.star.chart.PieDiagram"}, |
| 553 |
{"com.sun.star.chart2.DonutChartType", "com.sun.star.chart.DonutDiagram"}, |
| 554 |
{"com.sun.star.chart2.ScatterChartType", "com.sun.star.chart.XYDiagram"}, |
| 555 |
{"com.sun.star.chart2.FilledNetChartType", "com.sun.star.chart.FilledNetDiagram"}, |
| 556 |
{"com.sun.star.chart2.NetChartType", "com.sun.star.chart.NetDiagram"}, |
| 557 |
{"com.sun.star.chart2.CandleStickChartType", "com.sun.star.chart.StockDiagram"}, |
| 558 |
{"com.sun.star.chart2.BubbleChartType", "com.sun.star.chart.BubbleDiagram"} |
| 559 |
}; |
| 560 |
return g_aChartTypeNameMap; |
| 561 |
} |
| 562 |
|
| 563 |
OUString lcl_getOldChartTypeName( const OUString & rNewChartTypeName ) |
| 564 |
{ |
| 565 |
OUString aOld(rNewChartTypeName); |
| 566 |
|
| 567 |
const tMakeStringStringMap& rMap = lcl_getChartTypeNameMap(); |
| 568 |
tMakeStringStringMap::const_iterator aIt( rMap.find( rNewChartTypeName )); |
| 569 |
if( aIt != rMap.end()) |
| 570 |
{ |
| 571 |
aOld = aIt->second; |
| 572 |
} |
| 573 |
return aOld; |
| 574 |
} |
| 575 |
|
| 576 |
} // anonymous namespace |
| 577 |
|
| 578 |
namespace chart::wrapper |
| 579 |
{ |
| 580 |
|
| 581 |
DiagramWrapper::DiagramWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 582 |
: m_spChart2ModelContact(std::move(spChart2ModelContact)) |
| 583 |
{ |
| 584 |
} |
| 585 |
|
| 586 |
DiagramWrapper::~DiagramWrapper() |
| 587 |
{} |
| 588 |
|
| 589 |
// ____ XDiagram ____ |
| 590 |
OUString SAL_CALL DiagramWrapper::getDiagramType() |
| 591 |
{ |
| 592 |
OUString aRet; |
| 593 |
|
| 594 |
rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); |
| 595 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 596 |
if( xChartDoc.is() && xDiagram.is() ) |
| 597 |
{ |
| 598 |
Reference< beans::XPropertySet > xChartDocProp( static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY ); |
| 599 |
if( xChartDocProp.is() ) |
| 600 |
{ |
| 601 |
uno::Reference< util::XRefreshable > xAddIn; |
| 602 |
if( xChartDocProp->getPropertyValue( u"AddIn"_ustr ) >>= xAddIn ) |
| 603 |
{ |
| 604 |
uno::Reference< lang::XServiceName > xServiceName( xAddIn, uno::UNO_QUERY ); |
| 605 |
if( xServiceName.is()) |
| 606 |
return xServiceName->getServiceName(); |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); |
| 611 |
Diagram::tTemplateWithServiceName aTemplateAndService = |
| 612 |
xDiagram->getTemplate( xChartTypeManager ); |
| 613 |
|
| 614 |
aRet = lcl_getDiagramType( aTemplateAndService.sServiceName ); |
| 615 |
} |
| 616 |
|
| 617 |
if( !aRet.isEmpty()) |
| 618 |
return aRet; |
| 619 |
|
| 620 |
// none of the standard templates matched |
| 621 |
// use first chart type |
| 622 |
if (xDiagram) |
| 623 |
{ |
| 624 |
rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); |
| 625 |
if( xChartType.is() ) |
| 626 |
{ |
| 627 |
aRet = xChartType->getChartType(); |
| 628 |
if( !aRet.isEmpty() ) |
| 629 |
aRet = lcl_getOldChartTypeName( aRet ); |
| 630 |
} |
| 631 |
} |
| 632 |
if( aRet.isEmpty()) |
| 633 |
aRet = "com.sun.star.chart.BarDiagram"; |
| 634 |
|
| 635 |
return aRet; |
| 636 |
} |
| 637 |
|
| 638 |
Reference< |
| 639 |
beans::XPropertySet > SAL_CALL DiagramWrapper::getDataRowProperties( sal_Int32 nRow ) |
| 640 |
{ |
| 641 |
if( nRow < 0 ) |
| 642 |
throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
| 643 |
static_cast< ::cppu::OWeakObject * >( this )); |
| 644 |
|
| 645 |
sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); |
| 646 |
if( nNewAPIIndex < 0 ) |
| 647 |
throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
| 648 |
static_cast< ::cppu::OWeakObject * >( this )); |
| 649 |
|
| 650 |
Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper( |
| 651 |
DataSeriesPointWrapper::DATA_SERIES, nNewAPIIndex, 0, m_spChart2ModelContact ) ); |
| 652 |
return xRet; |
| 653 |
} |
| 654 |
|
| 655 |
Reference< |
| 656 |
beans::XPropertySet > SAL_CALL DiagramWrapper::getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow ) |
| 657 |
{ |
| 658 |
if( nCol < 0 || nRow < 0 ) |
| 659 |
throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
| 660 |
static_cast< ::cppu::OWeakObject * >( this )); |
| 661 |
|
| 662 |
sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); |
| 663 |
if( nNewAPIIndex < 0 ) |
| 664 |
throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
| 665 |
static_cast< ::cppu::OWeakObject * >( this )); |
| 666 |
|
| 667 |
//todo: check borders of point index |
| 668 |
|
| 669 |
Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper( |
| 670 |
DataSeriesPointWrapper::DATA_POINT, nNewAPIIndex, nCol, m_spChart2ModelContact ) ); |
| 671 |
|
| 672 |
return xRet; |
| 673 |
} |
| 674 |
|
| 675 |
// ____ XShape (base of XDiagram) ____ |
| 676 |
awt::Point SAL_CALL DiagramWrapper::getPosition() |
| 677 |
{ |
| 678 |
awt::Point aPosition = ToPoint( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() ); |
| 679 |
return aPosition; |
| 680 |
} |
| 681 |
|
| 682 |
void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) |
| 683 |
{ |
| 684 |
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
| 685 |
Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); |
| 686 |
if( !xProp.is() ) |
| 687 |
return; |
| 688 |
|
| 689 |
awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); |
| 690 |
|
| 691 |
chart2::RelativePosition aRelativePosition; |
| 692 |
aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; |
| 693 |
aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); |
| 694 |
aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); |
| 695 |
if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 ) |
| 696 |
{ |
| 697 |
OSL_FAIL("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); |
| 698 |
uno::Any aEmpty; |
| 699 |
xProp->setPropertyValue( u"RelativePosition"_ustr, aEmpty ); |
| 700 |
return; |
| 701 |
} |
| 702 |
xProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); |
| 703 |
xProp->setPropertyValue( u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); |
| 704 |
} |
| 705 |
|
| 706 |
awt::Size SAL_CALL DiagramWrapper::getSize() |
| 707 |
{ |
| 708 |
awt::Size aSize = ToSize( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() ); |
| 709 |
return aSize; |
| 710 |
} |
| 711 |
|
| 712 |
void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) |
| 713 |
{ |
| 714 |
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
| 715 |
Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); |
| 716 |
if( !xProp.is() ) |
| 717 |
return; |
| 718 |
|
| 719 |
awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); |
| 720 |
|
| 721 |
chart2::RelativeSize aRelativeSize; |
| 722 |
aRelativeSize.Primary = double(aSize.Width)/double(aPageSize.Width); |
| 723 |
aRelativeSize.Secondary = double(aSize.Height)/double(aPageSize.Height); |
| 724 |
|
| 725 |
if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 ) |
| 726 |
{ |
| 727 |
OSL_FAIL("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); |
| 728 |
uno::Any aEmpty; |
| 729 |
xProp->setPropertyValue( u"RelativeSize"_ustr, aEmpty ); |
| 730 |
return; |
| 731 |
} |
| 732 |
|
| 733 |
xProp->setPropertyValue( u"RelativeSize"_ustr, uno::Any(aRelativeSize) ); |
| 734 |
xProp->setPropertyValue( u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); |
| 735 |
} |
| 736 |
|
| 737 |
// ____ XShapeDescriptor (base of XShape) ____ |
| 738 |
OUString SAL_CALL DiagramWrapper::getShapeType() |
| 739 |
{ |
| 740 |
return u"com.sun.star.chart.Diagram"_ustr; |
| 741 |
} |
| 742 |
|
| 743 |
// ____ XDiagramPositioning ____ |
| 744 |
|
| 745 |
void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() |
| 746 |
{ |
| 747 |
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
| 748 |
uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
| 749 |
if( xDiaProps.is() ) |
| 750 |
{ |
| 751 |
xDiaProps->setPropertyValue( u"RelativeSize"_ustr, Any() ); |
| 752 |
xDiaProps->setPropertyValue( u"RelativePosition"_ustr, Any() ); |
| 753 |
} |
| 754 |
} |
| 755 |
sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning( ) |
| 756 |
{ |
| 757 |
uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
| 758 |
if( xDiaProps.is() ) |
| 759 |
{ |
| 760 |
Any aRelativeSize( xDiaProps->getPropertyValue( u"RelativeSize"_ustr ) ); |
| 761 |
Any aRelativePosition( xDiaProps->getPropertyValue( u"RelativePosition"_ustr ) ); |
| 762 |
if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) |
| 763 |
return false; |
| 764 |
} |
| 765 |
return true; |
| 766 |
} |
| 767 |
void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect ) |
| 768 |
{ |
| 769 |
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
| 770 |
DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getDocumentModel(), rPositionRect ); |
| 771 |
uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
| 772 |
if( xDiaProps.is() ) |
| 773 |
xDiaProps->setPropertyValue(u"PosSizeExcludeAxes"_ustr, uno::Any(true) ); |
| 774 |
} |
| 775 |
sal_Bool SAL_CALL DiagramWrapper::isExcludingDiagramPositioning() |
| 776 |
{ |
| 777 |
uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
| 778 |
if( xDiaProps.is() ) |
| 779 |
{ |
| 780 |
Any aRelativeSize( xDiaProps->getPropertyValue( u"RelativeSize"_ustr ) ); |
| 781 |
Any aRelativePosition( xDiaProps->getPropertyValue( u"RelativePosition"_ustr ) ); |
| 782 |
if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) |
| 783 |
{ |
| 784 |
bool bPosSizeExcludeAxes = false; |
| 785 |
xDiaProps->getPropertyValue( u"PosSizeExcludeAxes"_ustr ) >>= bPosSizeExcludeAxes; |
| 786 |
return bPosSizeExcludeAxes; |
| 787 |
} |
| 788 |
} |
| 789 |
return false; |
| 790 |
} |
| 791 |
awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes( ) |
| 792 |
{ |
| 793 |
return m_spChart2ModelContact->GetDiagramRectangleExcludingAxes(); |
| 794 |
} |
| 795 |
void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect ) |
| 796 |
{ |
| 797 |
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
| 798 |
DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getDocumentModel(), rPositionRect ); |
| 799 |
uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
| 800 |
if( xDiaProps.is() ) |
| 801 |
xDiaProps->setPropertyValue(u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); |
| 802 |
} |
| 803 |
awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( ) |
| 804 |
{ |
| 805 |
return m_spChart2ModelContact->GetDiagramRectangleIncludingAxes(); |
| 806 |
} |
| 807 |
void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect ) |
| 808 |
{ |
| 809 |
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
| 810 |
awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) ); |
| 811 |
DiagramWrapper::setDiagramPositionIncludingAxes( aRect ); |
| 812 |
} |
| 813 |
css::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxisTitles( ) |
| 814 |
{ |
| 815 |
return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle(); |
| 816 |
} |
| 817 |
|
| 818 |
// ____ XAxisSupplier ____ |
| 819 |
Reference< XAxis > SAL_CALL DiagramWrapper::getAxis( sal_Int32 nDimensionIndex ) |
| 820 |
{ |
| 821 |
rtl::Reference< AxisWrapper > xAxis; |
| 822 |
if(!nDimensionIndex) |
| 823 |
{ |
| 824 |
if( !m_xXAxis.is() ) |
| 825 |
m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); |
| 826 |
xAxis = m_xXAxis; |
| 827 |
} |
| 828 |
else if(nDimensionIndex==1) |
| 829 |
{ |
| 830 |
if( !m_xYAxis.is() ) |
| 831 |
m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); |
| 832 |
xAxis = m_xYAxis; |
| 833 |
} |
| 834 |
else if(nDimensionIndex==2) |
| 835 |
{ |
| 836 |
if( !m_xZAxis.is() ) |
| 837 |
m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); |
| 838 |
xAxis = m_xZAxis; |
| 839 |
} |
| 840 |
return xAxis; |
| 841 |
} |
| 842 |
|
| 843 |
Reference< XAxis > SAL_CALL DiagramWrapper::getSecondaryAxis( sal_Int32 nDimensionIndex ) |
| 844 |
{ |
| 845 |
rtl::Reference< AxisWrapper > xAxis; |
| 846 |
if(!nDimensionIndex) |
| 847 |
{ |
| 848 |
if( !m_xSecondXAxis.is() ) |
| 849 |
m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); |
| 850 |
xAxis = m_xSecondXAxis; |
| 851 |
} |
| 852 |
else if(nDimensionIndex==1) |
| 853 |
{ |
| 854 |
if( !m_xSecondYAxis.is() ) |
| 855 |
m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); |
| 856 |
xAxis = m_xSecondYAxis; |
| 857 |
} |
| 858 |
return xAxis; |
| 859 |
} |
| 860 |
|
| 861 |
// ____ XAxisZSupplier ____ |
| 862 |
Reference< drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() |
| 863 |
{ |
| 864 |
Reference< drawing::XShape > xRet; |
| 865 |
Reference< XAxis > xAxis( getAxis(2) ); |
| 866 |
if( xAxis.is() ) |
| 867 |
xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
| 868 |
return xRet; |
| 869 |
} |
| 870 |
|
| 871 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid() |
| 872 |
{ |
| 873 |
Reference< beans::XPropertySet > xRet; |
| 874 |
Reference< XAxis > xAxis( getAxis(2) ); |
| 875 |
if( xAxis.is() ) |
| 876 |
xRet = xAxis->getMajorGrid(); |
| 877 |
return xRet; |
| 878 |
} |
| 879 |
|
| 880 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid() |
| 881 |
{ |
| 882 |
Reference< beans::XPropertySet > xRet; |
| 883 |
Reference< XAxis > xAxis( getAxis(2) ); |
| 884 |
if( xAxis.is() ) |
| 885 |
xRet = xAxis->getMinorGrid(); |
| 886 |
return xRet; |
| 887 |
} |
| 888 |
|
| 889 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() |
| 890 |
{ |
| 891 |
if( ! m_xZAxis.is()) |
| 892 |
m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); |
| 893 |
return m_xZAxis; |
| 894 |
} |
| 895 |
|
| 896 |
// ____ XTwoAxisXSupplier ____ |
| 897 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() |
| 898 |
{ |
| 899 |
if( ! m_xSecondXAxis.is()) |
| 900 |
m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); |
| 901 |
return m_xSecondXAxis; |
| 902 |
} |
| 903 |
|
| 904 |
// ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____ |
| 905 |
Reference< drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle() |
| 906 |
{ |
| 907 |
Reference< drawing::XShape > xRet; |
| 908 |
Reference< XAxis > xAxis( getAxis(0) ); |
| 909 |
if( xAxis.is() ) |
| 910 |
xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
| 911 |
return xRet; |
| 912 |
} |
| 913 |
|
| 914 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() |
| 915 |
{ |
| 916 |
if( ! m_xXAxis.is()) |
| 917 |
m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); |
| 918 |
return m_xXAxis; |
| 919 |
} |
| 920 |
|
| 921 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() |
| 922 |
{ |
| 923 |
Reference< beans::XPropertySet > xRet; |
| 924 |
Reference< XAxis > xAxis( getAxis(0) ); |
| 925 |
if( xAxis.is() ) |
| 926 |
xRet = xAxis->getMajorGrid(); |
| 927 |
return xRet; |
| 928 |
} |
| 929 |
|
| 930 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid() |
| 931 |
{ |
| 932 |
Reference< beans::XPropertySet > xRet; |
| 933 |
Reference< XAxis > xAxis( getAxis(0) ); |
| 934 |
if( xAxis.is() ) |
| 935 |
xRet = xAxis->getMinorGrid(); |
| 936 |
return xRet; |
| 937 |
} |
| 938 |
|
| 939 |
// ____ XTwoAxisYSupplier ____ |
| 940 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() |
| 941 |
{ |
| 942 |
if( ! m_xSecondYAxis.is()) |
| 943 |
m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); |
| 944 |
return m_xSecondYAxis; |
| 945 |
} |
| 946 |
|
| 947 |
// ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____ |
| 948 |
Reference< drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle() |
| 949 |
{ |
| 950 |
Reference< drawing::XShape > xRet; |
| 951 |
Reference< XAxis > xAxis( getAxis(1) ); |
| 952 |
if( xAxis.is() ) |
| 953 |
xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
| 954 |
return xRet; |
| 955 |
} |
| 956 |
|
| 957 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() |
| 958 |
{ |
| 959 |
if( ! m_xYAxis.is()) |
| 960 |
m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); |
| 961 |
return m_xYAxis; |
| 962 |
} |
| 963 |
|
| 964 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() |
| 965 |
{ |
| 966 |
Reference< beans::XPropertySet > xRet; |
| 967 |
Reference< XAxis > xAxis( getAxis(1) ); |
| 968 |
if( xAxis.is() ) |
| 969 |
xRet = xAxis->getMajorGrid(); |
| 970 |
return xRet; |
| 971 |
} |
| 972 |
|
| 973 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid() |
| 974 |
{ |
| 975 |
Reference< beans::XPropertySet > xRet; |
| 976 |
Reference< XAxis > xAxis( getAxis(1) ); |
| 977 |
if( xAxis.is() ) |
| 978 |
xRet = xAxis->getMinorGrid(); |
| 979 |
return xRet; |
| 980 |
} |
| 981 |
|
| 982 |
// ____ XSecondAxisTitleSupplier ____ |
| 983 |
Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle() |
| 984 |
{ |
| 985 |
Reference< drawing::XShape > xRet; |
| 986 |
Reference< XAxis > xAxis( getSecondaryAxis(0) ); |
| 987 |
if( xAxis.is() ) |
| 988 |
xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
| 989 |
return xRet; |
| 990 |
} |
| 991 |
|
| 992 |
Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle() |
| 993 |
{ |
| 994 |
Reference< drawing::XShape > xRet; |
| 995 |
Reference< XAxis > xAxis( getSecondaryAxis(1) ); |
| 996 |
if( xAxis.is() ) |
| 997 |
xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
| 998 |
return xRet; |
| 999 |
} |
| 1000 |
|
| 1001 |
// ____ XStatisticDisplay ____ |
| 1002 |
Reference< |
| 1003 |
beans::XPropertySet > SAL_CALL DiagramWrapper::getUpBar() |
| 1004 |
{ |
| 1005 |
if( !m_xUpBarWrapper.is() ) |
| 1006 |
{ |
| 1007 |
m_xUpBarWrapper = new UpDownBarWrapper( true, m_spChart2ModelContact ); |
| 1008 |
} |
| 1009 |
return m_xUpBarWrapper; |
| 1010 |
} |
| 1011 |
|
| 1012 |
Reference< |
| 1013 |
beans::XPropertySet > SAL_CALL DiagramWrapper::getDownBar() |
| 1014 |
{ |
| 1015 |
if( !m_xDownBarWrapper.is() ) |
| 1016 |
{ |
| 1017 |
m_xDownBarWrapper = new UpDownBarWrapper( false, m_spChart2ModelContact ); |
| 1018 |
} |
| 1019 |
return m_xDownBarWrapper; |
| 1020 |
} |
| 1021 |
|
| 1022 |
Reference< |
| 1023 |
beans::XPropertySet > SAL_CALL DiagramWrapper::getMinMaxLine() |
| 1024 |
{ |
| 1025 |
if( !m_xMinMaxLineWrapper.is() ) |
| 1026 |
{ |
| 1027 |
m_xMinMaxLineWrapper = new MinMaxLineWrapper( m_spChart2ModelContact ); |
| 1028 |
} |
| 1029 |
return m_xMinMaxLineWrapper; |
| 1030 |
} |
| 1031 |
|
| 1032 |
// ____ X3DDisplay ____ |
| 1033 |
Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getWall() |
| 1034 |
{ |
| 1035 |
if( !m_xWall.is() ) |
| 1036 |
{ |
| 1037 |
m_xWall = new WallFloorWrapper( true, m_spChart2ModelContact ); |
| 1038 |
} |
| 1039 |
return m_xWall; |
| 1040 |
} |
| 1041 |
|
| 1042 |
Reference< |
| 1043 |
beans::XPropertySet > SAL_CALL DiagramWrapper::getFloor() |
| 1044 |
{ |
| 1045 |
if( !m_xFloor.is() ) |
| 1046 |
{ |
| 1047 |
m_xFloor = new WallFloorWrapper( false, m_spChart2ModelContact ); |
| 1048 |
} |
| 1049 |
return m_xFloor; |
| 1050 |
} |
| 1051 |
|
| 1052 |
// ____ X3DDefaultSetter ____ |
| 1053 |
void SAL_CALL DiagramWrapper::set3DSettingsToDefault() |
| 1054 |
{ |
| 1055 |
rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); |
| 1056 |
if( x3DDefaultSetter.is() ) |
| 1057 |
x3DDefaultSetter->set3DSettingsToDefault(); |
| 1058 |
} |
| 1059 |
|
| 1060 |
void SAL_CALL DiagramWrapper::setDefaultRotation() |
| 1061 |
{ |
| 1062 |
rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); |
| 1063 |
if( x3DDefaultSetter.is() ) |
| 1064 |
x3DDefaultSetter->setDefaultRotation(); |
| 1065 |
} |
| 1066 |
|
| 1067 |
void SAL_CALL DiagramWrapper::setDefaultIllumination() |
| 1068 |
{ |
| 1069 |
rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); |
| 1070 |
if( x3DDefaultSetter.is() ) |
| 1071 |
x3DDefaultSetter->setDefaultIllumination(); |
| 1072 |
} |
| 1073 |
|
| 1074 |
// ____ XComponent ____ |
| 1075 |
void SAL_CALL DiagramWrapper::dispose() |
| 1076 |
{ |
| 1077 |
std::unique_lock g(m_aMutex); |
| 1078 |
m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); |
| 1079 |
|
| 1080 |
DisposeHelper::DisposeAndClear( m_xXAxis ); |
| 1081 |
DisposeHelper::DisposeAndClear( m_xYAxis ); |
| 1082 |
DisposeHelper::DisposeAndClear( m_xZAxis ); |
| 1083 |
DisposeHelper::DisposeAndClear( m_xSecondXAxis ); |
| 1084 |
DisposeHelper::DisposeAndClear( m_xSecondYAxis ); |
| 1085 |
DisposeHelper::DisposeAndClear( m_xWall ); |
| 1086 |
DisposeHelper::DisposeAndClear( m_xFloor ); |
| 1087 |
DisposeHelper::DisposeAndClear( m_xMinMaxLineWrapper ); |
| 1088 |
DisposeHelper::DisposeAndClear( m_xUpBarWrapper ); |
| 1089 |
DisposeHelper::DisposeAndClear( m_xDownBarWrapper ); |
| 1090 |
|
| 1091 |
clearWrappedPropertySet(); |
| 1092 |
} |
| 1093 |
|
| 1094 |
void SAL_CALL DiagramWrapper::addEventListener( |
| 1095 |
const Reference< lang::XEventListener >& xListener ) |
| 1096 |
{ |
| 1097 |
std::unique_lock g(m_aMutex); |
| 1098 |
m_aEventListenerContainer.addInterface( g, xListener ); |
| 1099 |
} |
| 1100 |
|
| 1101 |
void SAL_CALL DiagramWrapper::removeEventListener( |
| 1102 |
const Reference< lang::XEventListener >& aListener ) |
| 1103 |
{ |
| 1104 |
std::unique_lock g(m_aMutex); |
| 1105 |
m_aEventListenerContainer.removeInterface( g, aListener ); |
| 1106 |
} |
| 1107 |
|
| 1108 |
namespace { |
| 1109 |
|
| 1110 |
//PROP_DIAGRAM_DATAROW_SOURCE |
| 1111 |
class WrappedDataRowSourceProperty : public WrappedProperty |
| 1112 |
{ |
| 1113 |
public: |
| 1114 |
explicit WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1115 |
|
| 1116 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1117 |
|
| 1118 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1119 |
|
| 1120 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1121 |
|
| 1122 |
private: //member |
| 1123 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1124 |
mutable Any m_aOuterValue; |
| 1125 |
}; |
| 1126 |
|
| 1127 |
} |
| 1128 |
|
| 1129 |
WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1130 |
: WrappedProperty(u"DataRowSource"_ustr,OUString()) |
| 1131 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1132 |
{ |
| 1133 |
m_aOuterValue = WrappedDataRowSourceProperty::getPropertyDefault( nullptr ); |
| 1134 |
} |
| 1135 |
|
| 1136 |
void WrappedDataRowSourceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1137 |
{ |
| 1138 |
css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS; |
| 1139 |
if( ! (rOuterValue >>= eChartDataRowSource) ) |
| 1140 |
{ |
| 1141 |
sal_Int32 nNew = sal_Int32(css::chart::ChartDataRowSource_ROWS); |
| 1142 |
if( !(rOuterValue >>= nNew) ) |
| 1143 |
throw lang::IllegalArgumentException( u"Property DataRowSource requires css::chart::ChartDataRowSource value"_ustr, nullptr, 0 ); |
| 1144 |
eChartDataRowSource = css::chart::ChartDataRowSource(nNew); |
| 1145 |
} |
| 1146 |
|
| 1147 |
m_aOuterValue = rOuterValue; |
| 1148 |
|
| 1149 |
bool bNewUseColumns = eChartDataRowSource == css::chart::ChartDataRowSource_COLUMNS; |
| 1150 |
|
| 1151 |
OUString aRangeString; |
| 1152 |
bool bUseColumns = true; |
| 1153 |
bool bFirstCellAsLabel = true; |
| 1154 |
bool bHasCategories = true; |
| 1155 |
uno::Sequence< sal_Int32 > aSequenceMapping; |
| 1156 |
|
| 1157 |
if( DataSourceHelper::detectRangeSegmentation( |
| 1158 |
m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns |
| 1159 |
, bFirstCellAsLabel, bHasCategories ) ) |
| 1160 |
{ |
| 1161 |
if( bUseColumns != bNewUseColumns ) |
| 1162 |
{ |
| 1163 |
aSequenceMapping.realloc(0); |
| 1164 |
DataSourceHelper::setRangeSegmentation( |
| 1165 |
m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, bNewUseColumns , bFirstCellAsLabel , bHasCategories); |
| 1166 |
} |
| 1167 |
} |
| 1168 |
} |
| 1169 |
|
| 1170 |
Any WrappedDataRowSourceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1171 |
{ |
| 1172 |
OUString aRangeString; |
| 1173 |
bool bUseColumns = true; |
| 1174 |
bool bFirstCellAsLabel = true; |
| 1175 |
bool bHasCategories = true; |
| 1176 |
uno::Sequence< sal_Int32 > aSequenceMapping; |
| 1177 |
|
| 1178 |
if( DataSourceHelper::detectRangeSegmentation( |
| 1179 |
m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns |
| 1180 |
, bFirstCellAsLabel, bHasCategories ) ) |
| 1181 |
{ |
| 1182 |
css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS; |
| 1183 |
if(bUseColumns) |
| 1184 |
eChartDataRowSource = css::chart::ChartDataRowSource_COLUMNS; |
| 1185 |
|
| 1186 |
m_aOuterValue <<= eChartDataRowSource; |
| 1187 |
} |
| 1188 |
|
| 1189 |
return m_aOuterValue; |
| 1190 |
} |
| 1191 |
|
| 1192 |
Any WrappedDataRowSourceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1193 |
{ |
| 1194 |
Any aRet; |
| 1195 |
aRet <<= css::chart::ChartDataRowSource_COLUMNS; |
| 1196 |
return aRet; |
| 1197 |
} |
| 1198 |
|
| 1199 |
namespace { |
| 1200 |
|
| 1201 |
//PROP_DIAGRAM_STACKED |
| 1202 |
//PROP_DIAGRAM_DEEP |
| 1203 |
//PROP_DIAGRAM_PERCENT_STACKED |
| 1204 |
class WrappedStackingProperty : public WrappedProperty |
| 1205 |
{ |
| 1206 |
public: |
| 1207 |
WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1208 |
|
| 1209 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1210 |
|
| 1211 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1212 |
|
| 1213 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1214 |
|
| 1215 |
protected: //methods |
| 1216 |
bool detectInnerValue( StackMode& eInnerStackMode ) const; |
| 1217 |
|
| 1218 |
private: //member |
| 1219 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1220 |
const StackMode m_eStackMode; |
| 1221 |
mutable Any m_aOuterValue; |
| 1222 |
}; |
| 1223 |
|
| 1224 |
} |
| 1225 |
|
| 1226 |
WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1227 |
: WrappedProperty(OUString(),OUString()) |
| 1228 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1229 |
, m_eStackMode( eStackMode ) |
| 1230 |
{ |
| 1231 |
switch( m_eStackMode ) |
| 1232 |
{ |
| 1233 |
case StackMode::YStacked: |
| 1234 |
m_aOuterName = "Stacked"; |
| 1235 |
break; |
| 1236 |
case StackMode::YStackedPercent: |
| 1237 |
m_aOuterName = "Percent"; |
| 1238 |
break; |
| 1239 |
case StackMode::ZStacked: |
| 1240 |
m_aOuterName = "Deep"; |
| 1241 |
break; |
| 1242 |
default: |
| 1243 |
OSL_FAIL( "unexpected stack mode" ); |
| 1244 |
break; |
| 1245 |
} |
| 1246 |
} |
| 1247 |
|
| 1248 |
bool WrappedStackingProperty::detectInnerValue( StackMode& eStackMode ) const |
| 1249 |
{ |
| 1250 |
bool bHasDetectableInnerValue = false; |
| 1251 |
bool bIsAmbiguous = false; |
| 1252 |
rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); |
| 1253 |
eStackMode = xDiagram ? xDiagram->getStackMode( bHasDetectableInnerValue, bIsAmbiguous ) : StackMode::NONE; |
| 1254 |
return bHasDetectableInnerValue; |
| 1255 |
} |
| 1256 |
|
| 1257 |
void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1258 |
{ |
| 1259 |
bool bNewValue = false; |
| 1260 |
if( ! (rOuterValue >>= bNewValue) ) |
| 1261 |
throw lang::IllegalArgumentException( u"Stacking Properties require boolean values"_ustr, nullptr, 0 ); |
| 1262 |
|
| 1263 |
StackMode eInnerStackMode; |
| 1264 |
bool bHasDetectableInnerValue = detectInnerValue( eInnerStackMode ); |
| 1265 |
|
| 1266 |
if( !bHasDetectableInnerValue ) |
| 1267 |
{ |
| 1268 |
m_aOuterValue = rOuterValue; |
| 1269 |
return; |
| 1270 |
} |
| 1271 |
|
| 1272 |
if( bNewValue && eInnerStackMode == m_eStackMode ) |
| 1273 |
return; |
| 1274 |
if( !bNewValue && eInnerStackMode != m_eStackMode ) |
| 1275 |
return; |
| 1276 |
|
| 1277 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1278 |
if( xDiagram.is() ) |
| 1279 |
{ |
| 1280 |
StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode::NONE; |
| 1281 |
xDiagram->setStackMode( eNewStackMode ); |
| 1282 |
} |
| 1283 |
} |
| 1284 |
|
| 1285 |
Any WrappedStackingProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1286 |
{ |
| 1287 |
StackMode eInnerStackMode; |
| 1288 |
if( detectInnerValue( eInnerStackMode ) ) |
| 1289 |
{ |
| 1290 |
bool bValue = (eInnerStackMode == m_eStackMode); |
| 1291 |
return Any(bValue); |
| 1292 |
} |
| 1293 |
return m_aOuterValue; |
| 1294 |
} |
| 1295 |
|
| 1296 |
Any WrappedStackingProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1297 |
{ |
| 1298 |
Any aRet; |
| 1299 |
aRet <<= false; |
| 1300 |
return aRet; |
| 1301 |
} |
| 1302 |
|
| 1303 |
namespace { |
| 1304 |
|
| 1305 |
//PROP_DIAGRAM_THREE_D |
| 1306 |
class WrappedDim3DProperty : public WrappedProperty |
| 1307 |
{ |
| 1308 |
public: |
| 1309 |
explicit WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1310 |
|
| 1311 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1312 |
|
| 1313 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1314 |
|
| 1315 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1316 |
|
| 1317 |
private: //member |
| 1318 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1319 |
mutable Any m_aOuterValue; |
| 1320 |
}; |
| 1321 |
|
| 1322 |
} |
| 1323 |
|
| 1324 |
WrappedDim3DProperty::WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1325 |
: WrappedProperty(u"Dim3D"_ustr,OUString()) |
| 1326 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1327 |
{ |
| 1328 |
m_aOuterValue = WrappedDim3DProperty::getPropertyDefault( nullptr ); |
| 1329 |
} |
| 1330 |
|
| 1331 |
void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1332 |
{ |
| 1333 |
bool bNew3D = false; |
| 1334 |
if( ! (rOuterValue >>= bNew3D) ) |
| 1335 |
throw lang::IllegalArgumentException( u"Property Dim3D requires boolean value"_ustr, nullptr, 0 ); |
| 1336 |
|
| 1337 |
m_aOuterValue = rOuterValue; |
| 1338 |
|
| 1339 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1340 |
if( !xDiagram.is() ) |
| 1341 |
return; |
| 1342 |
|
| 1343 |
bool bOld3D = xDiagram->getDimension() == 3; |
| 1344 |
if( bOld3D != bNew3D ) |
| 1345 |
xDiagram->setDimension( bNew3D ? 3 : 2 ); |
| 1346 |
} |
| 1347 |
|
| 1348 |
Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1349 |
{ |
| 1350 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1351 |
if( xDiagram.is() ) |
| 1352 |
{ |
| 1353 |
bool b3D = xDiagram->getDimension() == 3; |
| 1354 |
m_aOuterValue <<= b3D; |
| 1355 |
} |
| 1356 |
return m_aOuterValue; |
| 1357 |
} |
| 1358 |
|
| 1359 |
Any WrappedDim3DProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1360 |
{ |
| 1361 |
Any aRet; |
| 1362 |
aRet <<= false; |
| 1363 |
return aRet; |
| 1364 |
} |
| 1365 |
|
| 1366 |
namespace { |
| 1367 |
|
| 1368 |
//PROP_DIAGRAM_VERTICAL |
| 1369 |
class WrappedVerticalProperty : public WrappedProperty |
| 1370 |
{ |
| 1371 |
public: |
| 1372 |
explicit WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1373 |
|
| 1374 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1375 |
|
| 1376 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1377 |
|
| 1378 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1379 |
|
| 1380 |
private: //member |
| 1381 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1382 |
mutable Any m_aOuterValue; |
| 1383 |
}; |
| 1384 |
|
| 1385 |
} |
| 1386 |
|
| 1387 |
WrappedVerticalProperty::WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1388 |
: WrappedProperty(u"Vertical"_ustr,OUString()) |
| 1389 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1390 |
{ |
| 1391 |
m_aOuterValue = WrappedVerticalProperty::getPropertyDefault( nullptr ); |
| 1392 |
} |
| 1393 |
|
| 1394 |
void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1395 |
{ |
| 1396 |
bool bNewVertical = false; |
| 1397 |
if( ! (rOuterValue >>= bNewVertical) ) |
| 1398 |
throw lang::IllegalArgumentException( u"Property Vertical requires boolean value"_ustr, nullptr, 0 ); |
| 1399 |
|
| 1400 |
m_aOuterValue = rOuterValue; |
| 1401 |
|
| 1402 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1403 |
if( !xDiagram.is() ) |
| 1404 |
return; |
| 1405 |
|
| 1406 |
bool bFound = false; |
| 1407 |
bool bAmbiguous = false; |
| 1408 |
bool bOldVertical = xDiagram->getVertical( bFound, bAmbiguous ); |
| 1409 |
if( bFound && ( bOldVertical != bNewVertical || bAmbiguous ) ) |
| 1410 |
xDiagram->setVertical( bNewVertical ); |
| 1411 |
} |
| 1412 |
|
| 1413 |
Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1414 |
{ |
| 1415 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1416 |
if( xDiagram.is() ) |
| 1417 |
{ |
| 1418 |
bool bFound = false; |
| 1419 |
bool bAmbiguous = false; |
| 1420 |
bool bVertical = xDiagram->getVertical( bFound, bAmbiguous ); |
| 1421 |
if( bFound ) |
| 1422 |
m_aOuterValue <<= bVertical; |
| 1423 |
} |
| 1424 |
return m_aOuterValue; |
| 1425 |
} |
| 1426 |
|
| 1427 |
Any WrappedVerticalProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1428 |
{ |
| 1429 |
Any aRet; |
| 1430 |
aRet <<= false; |
| 1431 |
return aRet; |
| 1432 |
} |
| 1433 |
|
| 1434 |
namespace { |
| 1435 |
|
| 1436 |
//PROP_DIAGRAM_NUMBER_OF_LINES |
| 1437 |
class WrappedNumberOfLinesProperty : public WrappedProperty |
| 1438 |
{ |
| 1439 |
public: |
| 1440 |
explicit WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1441 |
|
| 1442 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1443 |
|
| 1444 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1445 |
|
| 1446 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1447 |
|
| 1448 |
protected: //methods |
| 1449 |
bool detectInnerValue( uno::Any& rInnerValue ) const; |
| 1450 |
|
| 1451 |
private: //member |
| 1452 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1453 |
mutable Any m_aOuterValue; |
| 1454 |
}; |
| 1455 |
|
| 1456 |
} |
| 1457 |
|
| 1458 |
WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1459 |
: WrappedProperty(u"NumberOfLines"_ustr,OUString()) |
| 1460 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1461 |
, m_aOuterValue( getPropertyDefault(nullptr) ) |
| 1462 |
{ |
| 1463 |
} |
| 1464 |
|
| 1465 |
bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) const |
| 1466 |
{ |
| 1467 |
sal_Int32 nNumberOfLines = 0; |
| 1468 |
bool bHasDetectableInnerValue = false; |
| 1469 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1470 |
rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); |
| 1471 |
if( xDiagram.is() && xChartDoc.is() ) |
| 1472 |
{ |
| 1473 |
std::vector< rtl::Reference< DataSeries > > aSeriesVector = |
| 1474 |
xDiagram->getDataSeries(); |
| 1475 |
if( !aSeriesVector.empty() ) |
| 1476 |
{ |
| 1477 |
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); |
| 1478 |
Diagram::tTemplateWithServiceName aTemplateAndService = |
| 1479 |
xDiagram->getTemplate( xChartTypeManager ); |
| 1480 |
if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) |
| 1481 |
{ |
| 1482 |
try |
| 1483 |
{ |
| 1484 |
uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(aTemplateAndService.xChartTypeTemplate.get()), uno::UNO_QUERY ); |
| 1485 |
xProp->getPropertyValue( m_aOuterName ) >>= nNumberOfLines; |
| 1486 |
bHasDetectableInnerValue = true; |
| 1487 |
} |
| 1488 |
catch( const uno::Exception & ) |
| 1489 |
{ |
| 1490 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 1491 |
} |
| 1492 |
} |
| 1493 |
} |
| 1494 |
} |
| 1495 |
if(bHasDetectableInnerValue) |
| 1496 |
rInnerValue <<= nNumberOfLines; |
| 1497 |
return bHasDetectableInnerValue; |
| 1498 |
} |
| 1499 |
|
| 1500 |
void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1501 |
{ |
| 1502 |
sal_Int32 nNewValue; |
| 1503 |
if( ! (rOuterValue >>= nNewValue) ) |
| 1504 |
throw lang::IllegalArgumentException( u"property NumberOfLines requires sal_Int32 value"_ustr, nullptr, 0 ); |
| 1505 |
|
| 1506 |
m_aOuterValue = rOuterValue; |
| 1507 |
|
| 1508 |
rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); |
| 1509 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1510 |
if( !xChartDoc || !xDiagram ) |
| 1511 |
return; |
| 1512 |
sal_Int32 nDimension = xDiagram->getDimension(); |
| 1513 |
if( nDimension != 2 ) |
| 1514 |
return; |
| 1515 |
|
| 1516 |
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); |
| 1517 |
Diagram::tTemplateWithServiceName aTemplateAndService = |
| 1518 |
xDiagram->getTemplate( xChartTypeManager ); |
| 1519 |
|
| 1520 |
rtl::Reference< ChartTypeTemplate > xTemplate; |
| 1521 |
if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) |
| 1522 |
{ |
| 1523 |
if( nNewValue != 0 ) |
| 1524 |
{ |
| 1525 |
xTemplate = aTemplateAndService.xChartTypeTemplate; |
| 1526 |
try |
| 1527 |
{ |
| 1528 |
sal_Int32 nOldValue = 0; |
| 1529 |
uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY ); |
| 1530 |
xProp->getPropertyValue( m_aOuterName ) >>= nOldValue; |
| 1531 |
if( nOldValue == nNewValue ) |
| 1532 |
return; |
| 1533 |
} |
| 1534 |
catch( const uno::Exception & ) |
| 1535 |
{ |
| 1536 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 1537 |
} |
| 1538 |
} |
| 1539 |
else |
| 1540 |
{ |
| 1541 |
xTemplate = xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Column"_ustr); |
| 1542 |
} |
| 1543 |
} |
| 1544 |
else if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.Column" ) |
| 1545 |
{ |
| 1546 |
if( nNewValue == 0 ) |
| 1547 |
return; |
| 1548 |
xTemplate = xChartTypeManager->createTemplate( u"com.sun.star.chart2.template.ColumnWithLine"_ustr ); |
| 1549 |
} |
| 1550 |
|
| 1551 |
if(!xTemplate.is()) |
| 1552 |
return; |
| 1553 |
|
| 1554 |
try |
| 1555 |
{ |
| 1556 |
// locked controllers |
| 1557 |
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
| 1558 |
uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY ); |
| 1559 |
xProp->setPropertyValue( u"NumberOfLines"_ustr, uno::Any(nNewValue) ); |
| 1560 |
xTemplate->changeDiagram( xDiagram ); |
| 1561 |
} |
| 1562 |
catch( const uno::Exception & ) |
| 1563 |
{ |
| 1564 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 1565 |
} |
| 1566 |
} |
| 1567 |
|
| 1568 |
Any WrappedNumberOfLinesProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1569 |
{ |
| 1570 |
Any aRet; |
| 1571 |
if( !detectInnerValue( aRet ) ) |
| 1572 |
aRet = m_aOuterValue; |
| 1573 |
return aRet; |
| 1574 |
} |
| 1575 |
|
| 1576 |
Any WrappedNumberOfLinesProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1577 |
{ |
| 1578 |
Any aRet; |
| 1579 |
aRet <<= sal_Int32( 0 ); |
| 1580 |
return aRet; |
| 1581 |
} |
| 1582 |
|
| 1583 |
namespace { |
| 1584 |
|
| 1585 |
//PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS |
| 1586 |
class WrappedAttributedDataPointsProperty : public WrappedProperty |
| 1587 |
{ |
| 1588 |
public: |
| 1589 |
explicit WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1590 |
|
| 1591 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1592 |
|
| 1593 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1594 |
|
| 1595 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1596 |
|
| 1597 |
private: //member |
| 1598 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1599 |
mutable Any m_aOuterValue; |
| 1600 |
}; |
| 1601 |
|
| 1602 |
} |
| 1603 |
|
| 1604 |
WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1605 |
: WrappedProperty(u"AttributedDataPoints"_ustr,OUString()) |
| 1606 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1607 |
{ |
| 1608 |
m_aOuterValue = WrappedAttributedDataPointsProperty::getPropertyDefault( nullptr ); |
| 1609 |
} |
| 1610 |
|
| 1611 |
void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1612 |
{ |
| 1613 |
uno::Sequence< uno::Sequence< sal_Int32 > > aNewValue; |
| 1614 |
if( ! (rOuterValue >>= aNewValue) ) |
| 1615 |
throw lang::IllegalArgumentException( u"Property AttributedDataPoints requires value of type uno::Sequence< uno::Sequence< sal_Int32 > >"_ustr, nullptr, 0 ); |
| 1616 |
|
| 1617 |
m_aOuterValue = rOuterValue; |
| 1618 |
|
| 1619 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1620 |
|
| 1621 |
if( !xDiagram ) |
| 1622 |
return; |
| 1623 |
|
| 1624 |
std::vector< rtl::Reference< DataSeries > > aSeriesVector = |
| 1625 |
xDiagram->getDataSeries(); |
| 1626 |
sal_Int32 i = 0; |
| 1627 |
for (auto const& series : aSeriesVector) |
| 1628 |
{ |
| 1629 |
uno::Any aVal; |
| 1630 |
if( i < aNewValue.getLength() ) |
| 1631 |
aVal <<= aNewValue[i]; |
| 1632 |
else |
| 1633 |
{ |
| 1634 |
//set empty sequence |
| 1635 |
uno::Sequence< sal_Int32 > aSeq; |
| 1636 |
aVal <<= aSeq; |
| 1637 |
} |
| 1638 |
series->setFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS, aVal ); // "AttributedDataPoints" |
| 1639 |
++i; |
| 1640 |
} |
| 1641 |
} |
| 1642 |
|
| 1643 |
Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1644 |
{ |
| 1645 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1646 |
|
| 1647 |
if( xDiagram ) |
| 1648 |
{ |
| 1649 |
std::vector< rtl::Reference< DataSeries > > aSeriesVector = |
| 1650 |
xDiagram->getDataSeries(); |
| 1651 |
|
| 1652 |
uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() ); |
| 1653 |
auto aResultRange = asNonConstRange(aResult); |
| 1654 |
sal_Int32 i = 0; |
| 1655 |
for (auto const& series : aSeriesVector) |
| 1656 |
{ |
| 1657 |
uno::Any aVal( |
| 1658 |
series->getFastPropertyValue(PROP_DATASERIES_ATTRIBUTED_DATA_POINTS)); // "AttributedDataPoints" |
| 1659 |
uno::Sequence< sal_Int32 > aSeq; |
| 1660 |
if( aVal >>= aSeq ) |
| 1661 |
aResultRange[ i ] = std::move(aSeq); |
| 1662 |
++i; |
| 1663 |
} |
| 1664 |
m_aOuterValue <<= aResult; |
| 1665 |
} |
| 1666 |
return m_aOuterValue; |
| 1667 |
} |
| 1668 |
|
| 1669 |
Any WrappedAttributedDataPointsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1670 |
{ |
| 1671 |
Any aRet; |
| 1672 |
uno::Sequence< uno::Sequence< sal_Int32 > > aSeq; |
| 1673 |
aRet <<= aSeq; |
| 1674 |
return aRet; |
| 1675 |
} |
| 1676 |
|
| 1677 |
namespace { |
| 1678 |
|
| 1679 |
//PROP_DIAGRAM_SOLIDTYPE |
| 1680 |
class WrappedSolidTypeProperty : public WrappedProperty |
| 1681 |
{ |
| 1682 |
public: |
| 1683 |
explicit WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1684 |
|
| 1685 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1686 |
|
| 1687 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1688 |
|
| 1689 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1690 |
|
| 1691 |
private: //member |
| 1692 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1693 |
mutable Any m_aOuterValue; |
| 1694 |
}; |
| 1695 |
|
| 1696 |
} |
| 1697 |
|
| 1698 |
WrappedSolidTypeProperty::WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1699 |
: WrappedProperty( u"SolidType"_ustr, OUString() ) |
| 1700 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1701 |
{ |
| 1702 |
m_aOuterValue = WrappedSolidTypeProperty::getPropertyDefault( nullptr ); |
| 1703 |
} |
| 1704 |
|
| 1705 |
void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1706 |
{ |
| 1707 |
sal_Int32 nNewSolidType = css::chart::ChartSolidType::RECTANGULAR_SOLID; |
| 1708 |
if( ! (rOuterValue >>= nNewSolidType) ) |
| 1709 |
throw lang::IllegalArgumentException( u"Property SolidType requires integer value"_ustr, nullptr, 0 ); |
| 1710 |
|
| 1711 |
m_aOuterValue = rOuterValue; |
| 1712 |
|
| 1713 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1714 |
if( !xDiagram.is() ) |
| 1715 |
return; |
| 1716 |
|
| 1717 |
bool bFound = false; |
| 1718 |
bool bAmbiguous = false; |
| 1719 |
sal_Int32 nOldSolidType = xDiagram->getGeometry3D( bFound, bAmbiguous ); |
| 1720 |
if( bFound && ( nOldSolidType != nNewSolidType || bAmbiguous ) ) |
| 1721 |
xDiagram->setGeometry3D( nNewSolidType ); |
| 1722 |
} |
| 1723 |
|
| 1724 |
Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1725 |
{ |
| 1726 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 1727 |
if( xDiagram.is() ) |
| 1728 |
{ |
| 1729 |
bool bFound = false; |
| 1730 |
bool bAmbiguous = false; |
| 1731 |
sal_Int32 nGeometry = xDiagram->getGeometry3D( bFound, bAmbiguous ); |
| 1732 |
if( bFound ) |
| 1733 |
m_aOuterValue <<= nGeometry; |
| 1734 |
} |
| 1735 |
return m_aOuterValue; |
| 1736 |
} |
| 1737 |
|
| 1738 |
Any WrappedSolidTypeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1739 |
{ |
| 1740 |
return uno::Any( css::chart::ChartSolidType::RECTANGULAR_SOLID ); |
| 1741 |
} |
| 1742 |
|
| 1743 |
namespace { |
| 1744 |
|
| 1745 |
class WrappedAutomaticSizeProperty : public WrappedProperty |
| 1746 |
{ |
| 1747 |
public: |
| 1748 |
WrappedAutomaticSizeProperty(); |
| 1749 |
|
| 1750 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1751 |
|
| 1752 |
virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1753 |
|
| 1754 |
virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
| 1755 |
}; |
| 1756 |
|
| 1757 |
} |
| 1758 |
|
| 1759 |
WrappedAutomaticSizeProperty::WrappedAutomaticSizeProperty() |
| 1760 |
: WrappedProperty( u"AutomaticSize"_ustr, OUString() ) |
| 1761 |
{ |
| 1762 |
} |
| 1763 |
|
| 1764 |
void WrappedAutomaticSizeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
| 1765 |
{ |
| 1766 |
if( !xInnerPropertySet.is() ) |
| 1767 |
return; |
| 1768 |
|
| 1769 |
bool bNewValue = true; |
| 1770 |
if( ! (rOuterValue >>= bNewValue) ) |
| 1771 |
throw lang::IllegalArgumentException( u"Property AutomaticSize requires value of type boolean"_ustr, nullptr, 0 ); |
| 1772 |
|
| 1773 |
try |
| 1774 |
{ |
| 1775 |
if( bNewValue ) |
| 1776 |
{ |
| 1777 |
Any aRelativeSize( xInnerPropertySet->getPropertyValue( u"RelativeSize"_ustr ) ); |
| 1778 |
if( aRelativeSize.hasValue() ) |
| 1779 |
xInnerPropertySet->setPropertyValue( u"RelativeSize"_ustr, Any() ); |
| 1780 |
} |
| 1781 |
} |
| 1782 |
catch( const uno::Exception & ) |
| 1783 |
{ |
| 1784 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 1785 |
} |
| 1786 |
} |
| 1787 |
|
| 1788 |
Any WrappedAutomaticSizeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
| 1789 |
{ |
| 1790 |
Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); |
| 1791 |
if( xInnerPropertySet.is() ) |
| 1792 |
{ |
| 1793 |
Any aRelativeSize( xInnerPropertySet->getPropertyValue( u"RelativeSize"_ustr ) ); |
| 1794 |
if( !aRelativeSize.hasValue() ) |
| 1795 |
aRet <<= true; |
| 1796 |
} |
| 1797 |
return aRet; |
| 1798 |
} |
| 1799 |
|
| 1800 |
Any WrappedAutomaticSizeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 1801 |
{ |
| 1802 |
Any aRet; |
| 1803 |
aRet <<= false; |
| 1804 |
return aRet; |
| 1805 |
} |
| 1806 |
|
| 1807 |
namespace { |
| 1808 |
|
| 1809 |
//PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS |
| 1810 |
class WrappedIncludeHiddenCellsProperty : public WrappedProperty |
| 1811 |
{ |
| 1812 |
public: |
| 1813 |
explicit WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
| 1814 |
|
| 1815 |
virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
| 1816 |
virtual Any getPropertyValue(const Reference<beans::XPropertySet>& xInnerPropertySet) const override; |
| 1817 |
|
| 1818 |
private: //member |
| 1819 |
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
| 1820 |
}; |
| 1821 |
|
| 1822 |
} |
| 1823 |
|
| 1824 |
WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 1825 |
: WrappedProperty(u"IncludeHiddenCells"_ustr,u"IncludeHiddenCells"_ustr) |
| 1826 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 1827 |
{ |
| 1828 |
} |
| 1829 |
|
| 1830 |
void WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1831 |
{ |
| 1832 |
bool bNewValue = false; |
| 1833 |
if( ! (rOuterValue >>= bNewValue) ) |
| 1834 |
throw lang::IllegalArgumentException( u"Property IncludeHiddenCells requires boolean value"_ustr, nullptr, 0 ); |
| 1835 |
|
| 1836 |
m_spChart2ModelContact->getDocumentModel()->setIncludeHiddenCells(bNewValue); |
| 1837 |
} |
| 1838 |
|
| 1839 |
Any WrappedIncludeHiddenCellsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
| 1840 |
{ |
| 1841 |
bool bValue = m_spChart2ModelContact->getDocumentModel()->isIncludeHiddenCells(); |
| 1842 |
return uno::Any(bValue); |
| 1843 |
} |
| 1844 |
|
| 1845 |
// ____ XDiagramProvider ____ |
| 1846 |
Reference< chart2::XDiagram > SAL_CALL DiagramWrapper::getDiagram() |
| 1847 |
{ |
| 1848 |
return m_spChart2ModelContact->getDiagram(); |
| 1849 |
} |
| 1850 |
|
| 1851 |
rtl::Reference< ::chart::Diagram > DiagramWrapper::getUnderlyingDiagram() |
| 1852 |
{ |
| 1853 |
return m_spChart2ModelContact->getDiagram(); |
| 1854 |
} |
| 1855 |
|
| 1856 |
void SAL_CALL DiagramWrapper::setDiagram( |
| 1857 |
const Reference< chart2::XDiagram >& /*xDiagram*/ ) |
| 1858 |
{ |
| 1859 |
//@todo: remove this method from interface |
| 1860 |
OSL_FAIL("DiagramWrapper::setDiagram is not implemented, should be removed and not be called" ); |
| 1861 |
} |
| 1862 |
|
| 1863 |
Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() |
| 1864 |
{ |
| 1865 |
return m_spChart2ModelContact->getDiagram(); |
| 1866 |
} |
| 1867 |
|
| 1868 |
const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() |
| 1869 |
{ |
| 1870 |
return StaticDiagramWrapperPropertyArray(); |
| 1871 |
} |
| 1872 |
|
| 1873 |
std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedProperties() |
| 1874 |
{ |
| 1875 |
std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; |
| 1876 |
|
| 1877 |
WrappedAxisAndGridExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 1878 |
WrappedAxisTitleExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 1879 |
WrappedAxisLabelExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 1880 |
WrappedSceneProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 1881 |
WrappedIgnoreProperties::addIgnoreFillProperties( aWrappedProperties ); |
| 1882 |
WrappedIgnoreProperties::addIgnoreLineProperties( aWrappedProperties ); |
| 1883 |
WrappedStatisticProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); |
| 1884 |
WrappedSymbolProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); |
| 1885 |
WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); |
| 1886 |
WrappedSplineProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 1887 |
WrappedStockProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 1888 |
WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); |
| 1889 |
|
| 1890 |
aWrappedProperties.emplace_back( new WrappedDataRowSourceProperty( m_spChart2ModelContact ) ); |
| 1891 |
aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::YStacked,m_spChart2ModelContact ) ); |
| 1892 |
aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::YStackedPercent, m_spChart2ModelContact ) ); |
| 1893 |
aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::ZStacked, m_spChart2ModelContact ) ); |
| 1894 |
aWrappedProperties.emplace_back( new WrappedDim3DProperty( m_spChart2ModelContact ) ); |
| 1895 |
aWrappedProperties.emplace_back( new WrappedVerticalProperty( m_spChart2ModelContact ) ); |
| 1896 |
aWrappedProperties.emplace_back( new WrappedNumberOfLinesProperty( m_spChart2ModelContact ) ); |
| 1897 |
aWrappedProperties.emplace_back( new WrappedAttributedDataPointsProperty( m_spChart2ModelContact ) ); |
| 1898 |
aWrappedProperties.emplace_back( new WrappedProperty( u"StackedBarsConnected"_ustr, u"ConnectBars"_ustr ) ); |
| 1899 |
aWrappedProperties.emplace_back( new WrappedSolidTypeProperty( m_spChart2ModelContact ) ); |
| 1900 |
aWrappedProperties.emplace_back( new WrappedAutomaticSizeProperty() ); |
| 1901 |
aWrappedProperties.emplace_back( new WrappedIncludeHiddenCellsProperty( m_spChart2ModelContact ) ); |
| 1902 |
|
| 1903 |
return aWrappedProperties; |
| 1904 |
} |
| 1905 |
|
| 1906 |
OUString SAL_CALL DiagramWrapper::getImplementationName() |
| 1907 |
{ |
| 1908 |
return u"com.sun.star.comp.chart.Diagram"_ustr; |
| 1909 |
} |
| 1910 |
|
| 1911 |
sal_Bool SAL_CALL DiagramWrapper::supportsService( const OUString& rServiceName ) |
| 1912 |
{ |
| 1913 |
return cppu::supportsService(this, rServiceName); |
| 1914 |
} |
| 1915 |
|
| 1916 |
css::uno::Sequence< OUString > SAL_CALL DiagramWrapper::getSupportedServiceNames() |
| 1917 |
{ |
| 1918 |
return { |
| 1919 |
u"com.sun.star.chart.Diagram"_ustr, |
| 1920 |
u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, |
| 1921 |
u"com.sun.star.chart.StackableDiagram"_ustr, |
| 1922 |
u"com.sun.star.chart.ChartAxisXSupplier"_ustr, |
| 1923 |
u"com.sun.star.chart.ChartAxisYSupplier"_ustr, |
| 1924 |
u"com.sun.star.chart.ChartAxisZSupplier"_ustr, |
| 1925 |
u"com.sun.star.chart.ChartTwoAxisXSupplier"_ustr, |
| 1926 |
u"com.sun.star.chart.ChartTwoAxisYSupplier"_ustr |
| 1927 |
}; |
| 1928 |
} |
| 1929 |
|
| 1930 |
} // namespace chart |
| 1931 |
|
| 1932 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |