| 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 "AxisWrapper.hxx" |
| 21 |
#include <Axis.hxx> |
| 22 |
#include <AxisHelper.hxx> |
| 23 |
#include <TitleHelper.hxx> |
| 24 |
#include "Chart2ModelContact.hxx" |
| 25 |
#include <WrappedDirectStateProperty.hxx> |
| 26 |
#include "GridWrapper.hxx" |
| 27 |
#include "TitleWrapper.hxx" |
| 28 |
#include <DisposeHelper.hxx> |
| 29 |
#include <unonames.hxx> |
| 30 |
|
| 31 |
#include <comphelper/sequence.hxx> |
| 32 |
#include <cppuhelper/supportsservice.hxx> |
| 33 |
#include <com/sun/star/beans/PropertyAttribute.hpp> |
| 34 |
#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp> |
| 35 |
#include <com/sun/star/chart/ChartAxisPosition.hpp> |
| 36 |
#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> |
| 37 |
#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> |
| 38 |
#include <com/sun/star/chart2/XAxis.hpp> |
| 39 |
|
| 40 |
#include <CharacterProperties.hxx> |
| 41 |
#include <LinePropertiesHelper.hxx> |
| 42 |
#include <UserDefinedProperties.hxx> |
| 43 |
#include "WrappedCharacterHeightProperty.hxx" |
| 44 |
#include "WrappedTextRotationProperty.hxx" |
| 45 |
#include "WrappedGapwidthProperty.hxx" |
| 46 |
#include "WrappedScaleProperty.hxx" |
| 47 |
#include "WrappedNumberFormatProperty.hxx" |
| 48 |
#include "WrappedScaleTextProperties.hxx" |
| 49 |
|
| 50 |
#include <algorithm> |
| 51 |
#include <utility> |
| 52 |
#include <comphelper/diagnose_ex.hxx> |
| 53 |
|
| 54 |
using namespace ::com::sun::star; |
| 55 |
using namespace ::com::sun::star::chart2; |
| 56 |
|
| 57 |
using ::com::sun::star::beans::Property; |
| 58 |
using ::com::sun::star::uno::Reference; |
| 59 |
using ::com::sun::star::uno::Sequence; |
| 60 |
using ::com::sun::star::uno::Any; |
| 61 |
|
| 62 |
namespace |
| 63 |
{ |
| 64 |
|
| 65 |
enum |
| 66 |
{ |
| 67 |
PROP_AXIS_MAX, |
| 68 |
PROP_AXIS_MIN, |
| 69 |
PROP_AXIS_STEPMAIN, |
| 70 |
PROP_AXIS_STEPHELP, //deprecated property use 'StepHelpCount' instead |
| 71 |
PROP_AXIS_STEPHELP_COUNT, |
| 72 |
PROP_AXIS_AUTO_MAX, |
| 73 |
PROP_AXIS_AUTO_MIN, |
| 74 |
PROP_AXIS_AUTO_STEPMAIN, |
| 75 |
PROP_AXIS_AUTO_STEPHELP, |
| 76 |
PROP_AXIS_TYPE, |
| 77 |
PROP_AXIS_TIME_INCREMENT, |
| 78 |
PROP_AXIS_EXPLICIT_TIME_INCREMENT, |
| 79 |
PROP_AXIS_LOGARITHMIC, |
| 80 |
PROP_AXIS_REVERSEDIRECTION, |
| 81 |
PROP_AXIS_VISIBLE, |
| 82 |
PROP_AXIS_CROSSOVER_POSITION, |
| 83 |
PROP_AXIS_CROSSOVER_VALUE, |
| 84 |
PROP_AXIS_ORIGIN, |
| 85 |
PROP_AXIS_AUTO_ORIGIN, |
| 86 |
PROP_AXIS_MARKS, |
| 87 |
PROP_AXIS_HELPMARKS, |
| 88 |
PROP_AXIS_MARK_POSITION, |
| 89 |
PROP_AXIS_DISPLAY_LABELS, |
| 90 |
PROP_AXIS_NUMBERFORMAT, |
| 91 |
PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, |
| 92 |
PROP_AXIS_LABEL_POSITION, |
| 93 |
PROP_AXIS_TEXT_ROTATION, |
| 94 |
PROP_AXIS_ARRANGE_ORDER, |
| 95 |
PROP_AXIS_TEXTBREAK, |
| 96 |
PROP_AXIS_CAN_OVERLAP, |
| 97 |
PROP_AXIS_STACKEDTEXT, |
| 98 |
PROP_AXIS_OVERLAP, |
| 99 |
PROP_AXIS_GAP_WIDTH, |
| 100 |
PROP_AXIS_DISPLAY_UNITS, |
| 101 |
PROP_AXIS_BUILTINUNIT, |
| 102 |
PROP_AXIS_TRY_STAGGERING_FIRST, |
| 103 |
PROP_AXIS_MAJOR_ORIGIN |
| 104 |
}; |
| 105 |
|
| 106 |
void lcl_AddPropertiesToVector( |
| 107 |
std::vector< Property > & rOutProperties ) |
| 108 |
{ |
| 109 |
//Properties for scaling: |
| 110 |
rOutProperties.emplace_back( "Max", |
| 111 |
PROP_AXIS_MAX, |
| 112 |
cppu::UnoType<double>::get(), |
| 113 |
beans::PropertyAttribute::BOUND |
| 114 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 115 |
|
| 116 |
rOutProperties.emplace_back( "Min", |
| 117 |
PROP_AXIS_MIN, |
| 118 |
cppu::UnoType<double>::get(), |
| 119 |
beans::PropertyAttribute::BOUND |
| 120 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 121 |
|
| 122 |
rOutProperties.emplace_back( "StepMain", |
| 123 |
PROP_AXIS_STEPMAIN, |
| 124 |
cppu::UnoType<double>::get(), |
| 125 |
beans::PropertyAttribute::BOUND |
| 126 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 127 |
|
| 128 |
rOutProperties.emplace_back( "StepHelpCount", |
| 129 |
PROP_AXIS_STEPHELP_COUNT, |
| 130 |
cppu::UnoType<sal_Int32>::get(), |
| 131 |
beans::PropertyAttribute::BOUND |
| 132 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 133 |
|
| 134 |
//deprecated property use 'StepHelpCount' instead |
| 135 |
rOutProperties.emplace_back( "StepHelp", |
| 136 |
PROP_AXIS_STEPHELP, |
| 137 |
cppu::UnoType<double>::get(), |
| 138 |
beans::PropertyAttribute::BOUND |
| 139 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 140 |
|
| 141 |
rOutProperties.emplace_back( "AutoMax", |
| 142 |
PROP_AXIS_AUTO_MAX, |
| 143 |
cppu::UnoType<bool>::get(), |
| 144 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 145 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 146 |
|
| 147 |
rOutProperties.emplace_back( "AutoMin", |
| 148 |
PROP_AXIS_AUTO_MIN, |
| 149 |
cppu::UnoType<bool>::get(), |
| 150 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 151 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 152 |
|
| 153 |
rOutProperties.emplace_back( "AutoStepMain", |
| 154 |
PROP_AXIS_AUTO_STEPMAIN, |
| 155 |
cppu::UnoType<bool>::get(), |
| 156 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 157 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 158 |
|
| 159 |
rOutProperties.emplace_back( "AutoStepHelp", |
| 160 |
PROP_AXIS_AUTO_STEPHELP, |
| 161 |
cppu::UnoType<bool>::get(), |
| 162 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 163 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 164 |
|
| 165 |
rOutProperties.emplace_back( "AxisType", |
| 166 |
PROP_AXIS_TYPE, |
| 167 |
cppu::UnoType<sal_Int32>::get(), //type css::chart::ChartAxisType |
| 168 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 169 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 170 |
|
| 171 |
rOutProperties.emplace_back( "TimeIncrement", |
| 172 |
PROP_AXIS_TIME_INCREMENT, |
| 173 |
cppu::UnoType<css::chart::TimeIncrement>::get(), |
| 174 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 175 |
beans::PropertyAttribute::MAYBEVOID ); |
| 176 |
|
| 177 |
rOutProperties.emplace_back( "ExplicitTimeIncrement", |
| 178 |
PROP_AXIS_EXPLICIT_TIME_INCREMENT, |
| 179 |
cppu::UnoType<css::chart::TimeIncrement>::get(), |
| 180 |
beans::PropertyAttribute::READONLY | |
| 181 |
beans::PropertyAttribute::MAYBEVOID ); |
| 182 |
|
| 183 |
rOutProperties.emplace_back( "Logarithmic", |
| 184 |
PROP_AXIS_LOGARITHMIC, |
| 185 |
cppu::UnoType<bool>::get(), |
| 186 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 187 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 188 |
|
| 189 |
rOutProperties.emplace_back( "ReverseDirection", |
| 190 |
PROP_AXIS_REVERSEDIRECTION, |
| 191 |
cppu::UnoType<bool>::get(), |
| 192 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 193 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 194 |
|
| 195 |
//todo: this property is missing in the API |
| 196 |
rOutProperties.emplace_back( "Visible", |
| 197 |
PROP_AXIS_VISIBLE, |
| 198 |
cppu::UnoType<bool>::get(), |
| 199 |
beans::PropertyAttribute::BOUND |
| 200 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 201 |
|
| 202 |
rOutProperties.emplace_back( "CrossoverPosition", |
| 203 |
PROP_AXIS_CROSSOVER_POSITION, |
| 204 |
cppu::UnoType<css::chart::ChartAxisPosition>::get(), |
| 205 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 206 |
|
| 207 |
rOutProperties.emplace_back( "CrossoverValue", |
| 208 |
PROP_AXIS_CROSSOVER_VALUE, |
| 209 |
cppu::UnoType<double>::get(), |
| 210 |
beans::PropertyAttribute::MAYBEVOID ); |
| 211 |
|
| 212 |
rOutProperties.emplace_back( "Origin", |
| 213 |
PROP_AXIS_ORIGIN, |
| 214 |
cppu::UnoType<double>::get(), |
| 215 |
beans::PropertyAttribute::BOUND |
| 216 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 217 |
|
| 218 |
rOutProperties.emplace_back( "AutoOrigin", |
| 219 |
PROP_AXIS_AUTO_ORIGIN, |
| 220 |
cppu::UnoType<bool>::get(), |
| 221 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 222 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 223 |
|
| 224 |
//Properties for interval marks: |
| 225 |
rOutProperties.emplace_back( "Marks", |
| 226 |
PROP_AXIS_MARKS, |
| 227 |
cppu::UnoType<sal_Int32>::get(), |
| 228 |
beans::PropertyAttribute::BOUND |
| 229 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 230 |
|
| 231 |
rOutProperties.emplace_back( "HelpMarks", |
| 232 |
PROP_AXIS_HELPMARKS, |
| 233 |
cppu::UnoType<sal_Int32>::get(), |
| 234 |
beans::PropertyAttribute::BOUND |
| 235 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 236 |
|
| 237 |
rOutProperties.emplace_back( "MarkPosition", |
| 238 |
PROP_AXIS_MARK_POSITION, |
| 239 |
cppu::UnoType<css::chart::ChartAxisMarkPosition>::get(), |
| 240 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 241 |
|
| 242 |
//Properties for labels: |
| 243 |
rOutProperties.emplace_back( "DisplayLabels", |
| 244 |
PROP_AXIS_DISPLAY_LABELS, |
| 245 |
cppu::UnoType<bool>::get(), |
| 246 |
beans::PropertyAttribute::BOUND |
| 247 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 248 |
|
| 249 |
rOutProperties.emplace_back( CHART_UNONAME_NUMFMT, |
| 250 |
PROP_AXIS_NUMBERFORMAT, |
| 251 |
cppu::UnoType<sal_Int32>::get(), |
| 252 |
beans::PropertyAttribute::BOUND |
| 253 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 254 |
|
| 255 |
rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT, |
| 256 |
PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, |
| 257 |
cppu::UnoType<bool>::get(), |
| 258 |
beans::PropertyAttribute::BOUND |
| 259 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 260 |
|
| 261 |
rOutProperties.emplace_back( "LabelPosition", |
| 262 |
PROP_AXIS_LABEL_POSITION, |
| 263 |
cppu::UnoType<css::chart::ChartAxisLabelPosition>::get(), |
| 264 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 265 |
|
| 266 |
rOutProperties.emplace_back( "TextRotation", |
| 267 |
PROP_AXIS_TEXT_ROTATION, |
| 268 |
cppu::UnoType<sal_Int32>::get(), |
| 269 |
beans::PropertyAttribute::BOUND |
| 270 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 271 |
|
| 272 |
rOutProperties.emplace_back( "ArrangeOrder", |
| 273 |
PROP_AXIS_ARRANGE_ORDER, |
| 274 |
cppu::UnoType<css::chart::ChartAxisArrangeOrderType>::get(), |
| 275 |
beans::PropertyAttribute::BOUND |
| 276 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 277 |
|
| 278 |
rOutProperties.emplace_back( "TextBreak", |
| 279 |
PROP_AXIS_TEXTBREAK, |
| 280 |
cppu::UnoType<bool>::get(), |
| 281 |
beans::PropertyAttribute::BOUND |
| 282 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 283 |
|
| 284 |
rOutProperties.emplace_back( "TextCanOverlap", |
| 285 |
PROP_AXIS_CAN_OVERLAP, |
| 286 |
cppu::UnoType<bool>::get(), |
| 287 |
beans::PropertyAttribute::BOUND |
| 288 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 289 |
|
| 290 |
rOutProperties.emplace_back( "StackedText", |
| 291 |
PROP_AXIS_STACKEDTEXT, |
| 292 |
cppu::UnoType<bool>::get(), |
| 293 |
beans::PropertyAttribute::BOUND |
| 294 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 295 |
|
| 296 |
// Properties related to bar charts: |
| 297 |
rOutProperties.emplace_back( "Overlap", |
| 298 |
PROP_AXIS_OVERLAP, |
| 299 |
cppu::UnoType<sal_Int32>::get(), |
| 300 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 301 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 302 |
|
| 303 |
rOutProperties.emplace_back( "GapWidth", |
| 304 |
PROP_AXIS_GAP_WIDTH, |
| 305 |
cppu::UnoType<sal_Int32>::get(), |
| 306 |
//#i111967# no PropertyChangeEvent is fired on change so far |
| 307 |
beans::PropertyAttribute::MAYBEDEFAULT ); |
| 308 |
|
| 309 |
//Properties for display units: |
| 310 |
rOutProperties.emplace_back( "DisplayUnits", |
| 311 |
PROP_AXIS_DISPLAY_UNITS, |
| 312 |
cppu::UnoType<bool>::get(), |
| 313 |
beans::PropertyAttribute::BOUND |
| 314 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 315 |
|
| 316 |
//Properties for labels: |
| 317 |
rOutProperties.emplace_back( "BuiltInUnit", |
| 318 |
PROP_AXIS_BUILTINUNIT, |
| 319 |
cppu::UnoType<OUString>::get(), |
| 320 |
beans::PropertyAttribute::BOUND |
| 321 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 322 |
|
| 323 |
// Compatibility option: starting from LibreOffice 5.1 the rotated |
| 324 |
// layout is preferred to staggering for axis labels. |
| 325 |
rOutProperties.emplace_back( "TryStaggeringFirst", |
| 326 |
PROP_AXIS_TRY_STAGGERING_FIRST, |
| 327 |
cppu::UnoType<bool>::get(), |
| 328 |
beans::PropertyAttribute::BOUND |
| 329 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 330 |
|
| 331 |
rOutProperties.emplace_back( "MajorOrigin", |
| 332 |
PROP_AXIS_MAJOR_ORIGIN, |
| 333 |
cppu::UnoType<double>::get(), |
| 334 |
beans::PropertyAttribute::BOUND |
| 335 |
| beans::PropertyAttribute::MAYBEVOID ); |
| 336 |
} |
| 337 |
|
| 338 |
const Sequence< Property >& StaticAxisWrapperPropertyArray() |
| 339 |
{ |
| 340 |
static Sequence< Property > aPropSeq = []() |
| 341 |
{ |
| 342 |
std::vector< css::beans::Property > aProperties; |
| 343 |
lcl_AddPropertiesToVector( aProperties ); |
| 344 |
::chart::CharacterProperties::AddPropertiesToVector( aProperties ); |
| 345 |
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); |
| 346 |
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); |
| 347 |
::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); |
| 348 |
|
| 349 |
std::sort( aProperties.begin(), aProperties.end(), |
| 350 |
::chart::PropertyNameLess() ); |
| 351 |
|
| 352 |
return comphelper::containerToSequence( aProperties ); |
| 353 |
}(); |
| 354 |
return aPropSeq; |
| 355 |
}; |
| 356 |
|
| 357 |
} // anonymous namespace |
| 358 |
|
| 359 |
namespace chart::wrapper |
| 360 |
{ |
| 361 |
|
| 362 |
AxisWrapper::AxisWrapper( |
| 363 |
tAxisType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : |
| 364 |
m_spChart2ModelContact(std::move( spChart2ModelContact )), |
| 365 |
m_eType( eType ) |
| 366 |
{ |
| 367 |
} |
| 368 |
|
| 369 |
AxisWrapper::~AxisWrapper() |
| 370 |
{ |
| 371 |
} |
| 372 |
|
| 373 |
// ____ chart::XAxis ____ |
| 374 |
Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle() |
| 375 |
{ |
| 376 |
if( !m_xAxisTitle.is() ) |
| 377 |
{ |
| 378 |
TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE ); |
| 379 |
switch( m_eType ) |
| 380 |
{ |
| 381 |
case X_AXIS: |
| 382 |
eTitleType = TitleHelper::X_AXIS_TITLE; |
| 383 |
break; |
| 384 |
case Y_AXIS: |
| 385 |
eTitleType = TitleHelper::Y_AXIS_TITLE; |
| 386 |
break; |
| 387 |
case Z_AXIS: |
| 388 |
eTitleType = TitleHelper::Z_AXIS_TITLE; |
| 389 |
break; |
| 390 |
case SECOND_X_AXIS: |
| 391 |
eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE; |
| 392 |
break; |
| 393 |
case SECOND_Y_AXIS: |
| 394 |
eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; |
| 395 |
break; |
| 396 |
default: |
| 397 |
return nullptr; |
| 398 |
} |
| 399 |
m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact ); |
| 400 |
} |
| 401 |
return m_xAxisTitle; |
| 402 |
} |
| 403 |
Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid() |
| 404 |
{ |
| 405 |
if( !m_xMajorGrid.is() ) |
| 406 |
{ |
| 407 |
GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID ); |
| 408 |
switch( m_eType ) |
| 409 |
{ |
| 410 |
case X_AXIS: |
| 411 |
eGridType = GridWrapper::X_MAJOR_GRID; |
| 412 |
break; |
| 413 |
case Y_AXIS: |
| 414 |
eGridType = GridWrapper::Y_MAJOR_GRID; |
| 415 |
break; |
| 416 |
case Z_AXIS: |
| 417 |
eGridType = GridWrapper::Z_MAJOR_GRID; |
| 418 |
break; |
| 419 |
default: |
| 420 |
return nullptr; |
| 421 |
} |
| 422 |
m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact ); |
| 423 |
} |
| 424 |
return m_xMajorGrid; |
| 425 |
} |
| 426 |
Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid() |
| 427 |
{ |
| 428 |
if( !m_xMinorGrid.is() ) |
| 429 |
{ |
| 430 |
GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID ); |
| 431 |
switch( m_eType ) |
| 432 |
{ |
| 433 |
case X_AXIS: |
| 434 |
eGridType = GridWrapper::X_MINOR_GRID; |
| 435 |
break; |
| 436 |
case Y_AXIS: |
| 437 |
eGridType = GridWrapper::Y_MINOR_GRID; |
| 438 |
break; |
| 439 |
case Z_AXIS: |
| 440 |
eGridType = GridWrapper::Z_MINOR_GRID; |
| 441 |
break; |
| 442 |
default: |
| 443 |
return nullptr; |
| 444 |
} |
| 445 |
m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact ); |
| 446 |
} |
| 447 |
return m_xMinorGrid; |
| 448 |
} |
| 449 |
|
| 450 |
// ____ XShape ____ |
| 451 |
awt::Point SAL_CALL AxisWrapper::getPosition() |
| 452 |
{ |
| 453 |
awt::Point aResult( m_spChart2ModelContact->GetAxisPosition( getAxis() ) ); |
| 454 |
return aResult; |
| 455 |
} |
| 456 |
|
| 457 |
void SAL_CALL AxisWrapper::setPosition( const awt::Point& /*aPosition*/ ) |
| 458 |
{ |
| 459 |
OSL_FAIL( "trying to set position of Axis" ); |
| 460 |
} |
| 461 |
|
| 462 |
awt::Size SAL_CALL AxisWrapper::getSize() |
| 463 |
{ |
| 464 |
awt::Size aSize( m_spChart2ModelContact->GetAxisSize( getAxis() ) ); |
| 465 |
return aSize; |
| 466 |
} |
| 467 |
|
| 468 |
void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ ) |
| 469 |
{ |
| 470 |
OSL_FAIL( "trying to set size of Axis" ); |
| 471 |
} |
| 472 |
|
| 473 |
// ____ XShapeDescriptor (base of XShape) ____ |
| 474 |
OUString SAL_CALL AxisWrapper::getShapeType() |
| 475 |
{ |
| 476 |
return u"com.sun.star.chart.ChartAxis"_ustr; |
| 477 |
} |
| 478 |
|
| 479 |
// ____ XNumberFormatsSupplier ____ |
| 480 |
uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings() |
| 481 |
{ |
| 482 |
rtl::Reference<ChartModel> xChartModel( m_spChart2ModelContact->getDocumentModel() ); |
| 483 |
if( xChartModel ) |
| 484 |
return xChartModel->getNumberFormatSettings(); |
| 485 |
|
| 486 |
return uno::Reference< beans::XPropertySet >(); |
| 487 |
} |
| 488 |
|
| 489 |
uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats() |
| 490 |
{ |
| 491 |
rtl::Reference<ChartModel> xChartModel( m_spChart2ModelContact->getDocumentModel() ); |
| 492 |
if( xChartModel ) |
| 493 |
return xChartModel->getNumberFormats(); |
| 494 |
|
| 495 |
return uno::Reference< util::XNumberFormats >(); |
| 496 |
} |
| 497 |
|
| 498 |
void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, bool& rbMainAxis ) |
| 499 |
{ |
| 500 |
switch( eType ) |
| 501 |
{ |
| 502 |
case X_AXIS: |
| 503 |
rnDimensionIndex = 0; rbMainAxis = true; break; |
| 504 |
case Y_AXIS: |
| 505 |
rnDimensionIndex = 1; rbMainAxis = true; break; |
| 506 |
case Z_AXIS: |
| 507 |
rnDimensionIndex = 2; rbMainAxis = true; break; |
| 508 |
case SECOND_X_AXIS: |
| 509 |
rnDimensionIndex = 0; rbMainAxis = false; break; |
| 510 |
case SECOND_Y_AXIS: |
| 511 |
rnDimensionIndex = 1; rbMainAxis = false; break; |
| 512 |
} |
| 513 |
} |
| 514 |
|
| 515 |
// ____ XComponent ____ |
| 516 |
void SAL_CALL AxisWrapper::dispose() |
| 517 |
{ |
| 518 |
std::unique_lock g(m_aMutex); |
| 519 |
Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); |
| 520 |
m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); |
| 521 |
|
| 522 |
DisposeHelper::DisposeAndClear( m_xAxisTitle ); |
| 523 |
DisposeHelper::DisposeAndClear( m_xMajorGrid ); |
| 524 |
DisposeHelper::DisposeAndClear( m_xMinorGrid ); |
| 525 |
|
| 526 |
clearWrappedPropertySet(); |
| 527 |
} |
| 528 |
|
| 529 |
void SAL_CALL AxisWrapper::addEventListener( |
| 530 |
const Reference< lang::XEventListener >& xListener ) |
| 531 |
{ |
| 532 |
std::unique_lock g(m_aMutex); |
| 533 |
m_aEventListenerContainer.addInterface( g, xListener ); |
| 534 |
} |
| 535 |
|
| 536 |
void SAL_CALL AxisWrapper::removeEventListener( |
| 537 |
const Reference< lang::XEventListener >& aListener ) |
| 538 |
{ |
| 539 |
std::unique_lock g(m_aMutex); |
| 540 |
m_aEventListenerContainer.removeInterface( g, aListener ); |
| 541 |
} |
| 542 |
|
| 543 |
//ReferenceSizePropertyProvider |
| 544 |
void AxisWrapper::updateReferenceSize() |
| 545 |
{ |
| 546 |
Reference< beans::XPropertySet > xProp( getAxis(), uno::UNO_QUERY ); |
| 547 |
if( xProp.is() ) |
| 548 |
{ |
| 549 |
if( xProp->getPropertyValue(u"ReferencePageSize"_ustr).hasValue() ) |
| 550 |
xProp->setPropertyValue(u"ReferencePageSize"_ustr, uno::Any( |
| 551 |
m_spChart2ModelContact->GetPageSize() )); |
| 552 |
} |
| 553 |
} |
| 554 |
Any AxisWrapper::getReferenceSize() |
| 555 |
{ |
| 556 |
Any aRet; |
| 557 |
Reference< beans::XPropertySet > xProp( getAxis(), uno::UNO_QUERY ); |
| 558 |
if( xProp.is() ) |
| 559 |
aRet = xProp->getPropertyValue(u"ReferencePageSize"_ustr); |
| 560 |
return aRet; |
| 561 |
} |
| 562 |
awt::Size AxisWrapper::getCurrentSizeForReference() |
| 563 |
{ |
| 564 |
return m_spChart2ModelContact->GetPageSize(); |
| 565 |
} |
| 566 |
|
| 567 |
Reference< chart2::XAxis > AxisWrapper::getAxis() |
| 568 |
{ |
| 569 |
rtl::Reference< Axis > xAxis; |
| 570 |
try |
| 571 |
{ |
| 572 |
sal_Int32 nDimensionIndex = 0; |
| 573 |
bool bMainAxis = true; |
| 574 |
AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis ); |
| 575 |
|
| 576 |
rtl::Reference< Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 577 |
xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ); |
| 578 |
if( !xAxis.is() ) |
| 579 |
{ |
| 580 |
xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext ); |
| 581 |
if( xAxis.is() ) |
| 582 |
xAxis->setPropertyValue(u"Show"_ustr, uno::Any( false ) ); |
| 583 |
} |
| 584 |
} |
| 585 |
catch( const uno::Exception & ) |
| 586 |
{ |
| 587 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 588 |
} |
| 589 |
return xAxis; |
| 590 |
} |
| 591 |
|
| 592 |
// WrappedPropertySet |
| 593 |
Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet() |
| 594 |
{ |
| 595 |
return Reference< beans::XPropertySet >( getAxis(), uno::UNO_QUERY ); |
| 596 |
} |
| 597 |
|
| 598 |
const Sequence< beans::Property >& AxisWrapper::getPropertySequence() |
| 599 |
{ |
| 600 |
return StaticAxisWrapperPropertyArray(); |
| 601 |
} |
| 602 |
|
| 603 |
std::vector< std::unique_ptr<WrappedProperty> > AxisWrapper::createWrappedProperties() |
| 604 |
{ |
| 605 |
std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; |
| 606 |
|
| 607 |
aWrappedProperties.emplace_back( new WrappedTextRotationProperty() ); |
| 608 |
aWrappedProperties.emplace_back( new WrappedProperty(u"Marks"_ustr,u"MajorTickmarks"_ustr) ); |
| 609 |
aWrappedProperties.emplace_back( new WrappedProperty(u"HelpMarks"_ustr,u"MinorTickmarks"_ustr) ); |
| 610 |
aWrappedProperties.emplace_back( new WrappedProperty(u"TextCanOverlap"_ustr,u"TextOverlap"_ustr) ); |
| 611 |
aWrappedProperties.emplace_back( new WrappedProperty(u"ArrangeOrder"_ustr,u"ArrangeOrder"_ustr) ); |
| 612 |
aWrappedProperties.emplace_back( new WrappedProperty(u"Visible"_ustr,u"Show"_ustr) ); |
| 613 |
aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"DisplayLabels"_ustr,u"DisplayLabels"_ustr) ); |
| 614 |
aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"TryStaggeringFirst"_ustr,u"TryStaggeringFirst"_ustr) ); |
| 615 |
aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"TextBreak"_ustr,u"TextBreak"_ustr) ); |
| 616 |
aWrappedProperties.emplace_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) ); |
| 617 |
aWrappedProperties.emplace_back( new WrappedLinkNumberFormatProperty ); |
| 618 |
aWrappedProperties.emplace_back( new WrappedProperty(u"StackedText"_ustr,u"StackCharacters"_ustr) ); |
| 619 |
aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"CrossoverPosition"_ustr,u"CrossoverPosition"_ustr) ); |
| 620 |
aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"MajorOrigin"_ustr,u"MajorOrigin"_ustr) ); |
| 621 |
{ |
| 622 |
WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) ); |
| 623 |
WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) ); |
| 624 |
sal_Int32 nDimensionIndex = 0; |
| 625 |
bool bMainAxis = true; |
| 626 |
sal_Int32 nAxisIndex = 0; |
| 627 |
AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis ); |
| 628 |
if( !bMainAxis ) |
| 629 |
nAxisIndex = 1; |
| 630 |
pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex ); |
| 631 |
pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex ); |
| 632 |
aWrappedProperties.emplace_back( pWrappedGapwidthProperty ); |
| 633 |
aWrappedProperties.emplace_back( pWrappedBarOverlapProperty ); |
| 634 |
} |
| 635 |
|
| 636 |
WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 637 |
|
| 638 |
WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); |
| 639 |
WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
| 640 |
|
| 641 |
return aWrappedProperties; |
| 642 |
} |
| 643 |
|
| 644 |
OUString SAL_CALL AxisWrapper::getImplementationName() |
| 645 |
{ |
| 646 |
return u"com.sun.star.comp.chart.Axis"_ustr; |
| 647 |
} |
| 648 |
|
| 649 |
sal_Bool SAL_CALL AxisWrapper::supportsService( const OUString& rServiceName ) |
| 650 |
{ |
| 651 |
return cppu::supportsService(this, rServiceName); |
| 652 |
} |
| 653 |
|
| 654 |
css::uno::Sequence< OUString > SAL_CALL AxisWrapper::getSupportedServiceNames() |
| 655 |
{ |
| 656 |
return { |
| 657 |
u"com.sun.star.chart.ChartAxis"_ustr, |
| 658 |
u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, |
| 659 |
u"com.sun.star.style.CharacterProperties"_ustr |
| 660 |
}; |
| 661 |
} |
| 662 |
|
| 663 |
} // namespace chart |
| 664 |
|
| 665 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |