| 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 "WrappedScaleProperty.hxx" |
| 21 |
#include "Chart2ModelContact.hxx" |
| 22 |
#include <CommonConverters.hxx> |
| 23 |
#include <Axis.hxx> |
| 24 |
#include <AxisHelper.hxx> |
| 25 |
#include <com/sun/star/chart2/AxisType.hpp> |
| 26 |
#include <com/sun/star/chart2/XAxis.hpp> |
| 27 |
#include <com/sun/star/chart/ChartAxisType.hpp> |
| 28 |
#include <chartview/ExplicitScaleValues.hxx> |
| 29 |
#include <utility> |
| 30 |
#include <osl/diagnose.h> |
| 31 |
|
| 32 |
using namespace ::com::sun::star; |
| 33 |
using ::com::sun::star::uno::Any; |
| 34 |
using namespace ::com::sun::star::chart2; |
| 35 |
using ::com::sun::star::uno::Reference; |
| 36 |
using ::com::sun::star::uno::Sequence; |
| 37 |
using ::com::sun::star::chart::TimeIncrement; |
| 38 |
|
| 39 |
namespace chart::wrapper |
| 40 |
{ |
| 41 |
|
| 42 |
WrappedScaleProperty::WrappedScaleProperty(tScaleProperty eScaleProperty |
| 43 |
, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 44 |
: WrappedProperty(OUString(),OUString()) |
| 45 |
, m_spChart2ModelContact(std::move( spChart2ModelContact )) |
| 46 |
, m_eScaleProperty( eScaleProperty ) |
| 47 |
{ |
| 48 |
switch( m_eScaleProperty ) |
| 49 |
{ |
| 50 |
case SCALE_PROP_MAX: |
| 51 |
m_aOuterName = "Max"; |
| 52 |
break; |
| 53 |
case SCALE_PROP_MIN: |
| 54 |
m_aOuterName = "Min"; |
| 55 |
break; |
| 56 |
case SCALE_PROP_ORIGIN: |
| 57 |
m_aOuterName = "Origin"; |
| 58 |
break; |
| 59 |
case SCALE_PROP_STEPMAIN: |
| 60 |
m_aOuterName = "StepMain"; |
| 61 |
break; |
| 62 |
case SCALE_PROP_STEPHELP: |
| 63 |
m_aOuterName = "StepHelp"; |
| 64 |
break; |
| 65 |
case SCALE_PROP_STEPHELP_COUNT: |
| 66 |
m_aOuterName = "StepHelpCount"; |
| 67 |
break; |
| 68 |
case SCALE_PROP_AUTO_MAX: |
| 69 |
m_aOuterName = "AutoMax"; |
| 70 |
break; |
| 71 |
case SCALE_PROP_AUTO_MIN: |
| 72 |
m_aOuterName = "AutoMin"; |
| 73 |
break; |
| 74 |
case SCALE_PROP_AUTO_ORIGIN: |
| 75 |
m_aOuterName = "AutoOrigin"; |
| 76 |
break; |
| 77 |
case SCALE_PROP_AUTO_STEPMAIN: |
| 78 |
m_aOuterName = "AutoStepMain"; |
| 79 |
break; |
| 80 |
case SCALE_PROP_AUTO_STEPHELP: |
| 81 |
m_aOuterName = "AutoStepHelp"; |
| 82 |
break; |
| 83 |
case SCALE_PROP_AXIS_TYPE: |
| 84 |
m_aOuterName = "AxisType"; |
| 85 |
break; |
| 86 |
case SCALE_PROP_DATE_INCREMENT: |
| 87 |
m_aOuterName = "TimeIncrement"; |
| 88 |
break; |
| 89 |
case SCALE_PROP_EXPLICIT_DATE_INCREMENT: |
| 90 |
m_aOuterName = "ExplicitTimeIncrement"; |
| 91 |
break; |
| 92 |
case SCALE_PROP_LOGARITHMIC: |
| 93 |
m_aOuterName = "Logarithmic"; |
| 94 |
break; |
| 95 |
case SCALE_PROP_REVERSEDIRECTION: |
| 96 |
m_aOuterName = "ReverseDirection"; |
| 97 |
break; |
| 98 |
default: |
| 99 |
OSL_FAIL("unknown scale property"); |
| 100 |
break; |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
WrappedScaleProperty::~WrappedScaleProperty() |
| 105 |
{ |
| 106 |
} |
| 107 |
|
| 108 |
void WrappedScaleProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList |
| 109 |
, const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact ) |
| 110 |
{ |
| 111 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_MAX, spChart2ModelContact ) ); |
| 112 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_MIN, spChart2ModelContact ) ); |
| 113 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_ORIGIN, spChart2ModelContact ) ); |
| 114 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_STEPMAIN, spChart2ModelContact ) ); |
| 115 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP, spChart2ModelContact ) ); |
| 116 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP_COUNT, spChart2ModelContact ) ); |
| 117 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MAX, spChart2ModelContact ) ); |
| 118 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MIN, spChart2ModelContact ) ); |
| 119 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) ); |
| 120 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) ); |
| 121 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) ); |
| 122 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) ); |
| 123 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) ); |
| 124 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_EXPLICIT_DATE_INCREMENT, spChart2ModelContact ) ); |
| 125 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) ); |
| 126 |
rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) ); |
| 127 |
} |
| 128 |
|
| 129 |
void WrappedScaleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
| 130 |
{ |
| 131 |
setPropertyValue( m_eScaleProperty, rOuterValue, xInnerPropertySet ); |
| 132 |
} |
| 133 |
|
| 134 |
Any WrappedScaleProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
| 135 |
{ |
| 136 |
return getPropertyValue( m_eScaleProperty, xInnerPropertySet ); |
| 137 |
} |
| 138 |
|
| 139 |
void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
| 140 |
{ |
| 141 |
m_aOuterValue = rOuterValue; |
| 142 |
|
| 143 |
Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); |
| 144 |
OSL_ENSURE(xAxis.is(),"need an XAxis"); |
| 145 |
if(!xAxis.is()) |
| 146 |
return; |
| 147 |
|
| 148 |
bool bSetScaleData = false; |
| 149 |
|
| 150 |
chart2::ScaleData aScaleData( xAxis->getScaleData() ); |
| 151 |
|
| 152 |
bool bBool = false; |
| 153 |
switch( eScaleProperty ) |
| 154 |
{ |
| 155 |
case SCALE_PROP_MAX: |
| 156 |
{ |
| 157 |
aScaleData.Maximum = rOuterValue; |
| 158 |
bSetScaleData = true; |
| 159 |
break; |
| 160 |
} |
| 161 |
case SCALE_PROP_MIN: |
| 162 |
{ |
| 163 |
aScaleData.Minimum = rOuterValue; |
| 164 |
bSetScaleData = true; |
| 165 |
break; |
| 166 |
} |
| 167 |
case SCALE_PROP_STEPMAIN: |
| 168 |
{ |
| 169 |
aScaleData.IncrementData.Distance = rOuterValue; |
| 170 |
bSetScaleData = true; |
| 171 |
break; |
| 172 |
} |
| 173 |
case SCALE_PROP_STEPHELP: |
| 174 |
{ |
| 175 |
Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); |
| 176 |
if( !rSubIncrements.hasElements() ) |
| 177 |
rSubIncrements.realloc( 1 ); |
| 178 |
auto pSubIncrements = rSubIncrements.getArray(); |
| 179 |
|
| 180 |
double fStepHelp = 0; |
| 181 |
if( rOuterValue >>= fStepHelp ) |
| 182 |
{ |
| 183 |
double fStepMain = 0; |
| 184 |
if( AxisHelper::isLogarithmic(aScaleData.Scaling) ) |
| 185 |
{ |
| 186 |
sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepHelp); |
| 187 |
pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; |
| 188 |
} |
| 189 |
else if( (fStepHelp != 0.0) && |
| 190 |
(aScaleData.IncrementData.Distance >>= fStepMain) ) |
| 191 |
{ |
| 192 |
// approximate interval count |
| 193 |
sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);//cppcheck-suppress zerodiv |
| 194 |
pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; |
| 195 |
} |
| 196 |
} |
| 197 |
bSetScaleData = true; |
| 198 |
break; |
| 199 |
} |
| 200 |
case SCALE_PROP_STEPHELP_COUNT: |
| 201 |
{ |
| 202 |
Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); |
| 203 |
if( !rSubIncrements.hasElements() ) |
| 204 |
rSubIncrements.realloc( 1 ); |
| 205 |
auto pSubIncrements = rSubIncrements.getArray(); |
| 206 |
sal_Int32 nIntervalCount=0; |
| 207 |
if( rOuterValue>>=nIntervalCount ) |
| 208 |
pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; |
| 209 |
else |
| 210 |
pSubIncrements[ 0 ].IntervalCount = Any(); |
| 211 |
bSetScaleData = true; |
| 212 |
break; |
| 213 |
} |
| 214 |
case SCALE_PROP_AUTO_MAX: |
| 215 |
{ |
| 216 |
if( (rOuterValue >>= bBool) && bBool ) |
| 217 |
aScaleData.Maximum = Any(); |
| 218 |
else |
| 219 |
aScaleData.Maximum = getPropertyValue( SCALE_PROP_MAX, xInnerPropertySet ); |
| 220 |
bSetScaleData = true; |
| 221 |
break; |
| 222 |
} |
| 223 |
case SCALE_PROP_AUTO_MIN: |
| 224 |
{ |
| 225 |
if( (rOuterValue >>= bBool) && bBool ) |
| 226 |
aScaleData.Minimum = Any(); |
| 227 |
else |
| 228 |
aScaleData.Minimum = getPropertyValue( SCALE_PROP_MIN, xInnerPropertySet ); |
| 229 |
bSetScaleData = true; |
| 230 |
break; |
| 231 |
} |
| 232 |
case SCALE_PROP_AUTO_STEPMAIN: |
| 233 |
{ |
| 234 |
if( (rOuterValue >>= bBool) && bBool ) |
| 235 |
aScaleData.IncrementData.Distance = Any(); |
| 236 |
else |
| 237 |
aScaleData.IncrementData.Distance = getPropertyValue( SCALE_PROP_STEPMAIN, xInnerPropertySet ); |
| 238 |
bSetScaleData = true; |
| 239 |
break; |
| 240 |
} |
| 241 |
case SCALE_PROP_AUTO_STEPHELP: |
| 242 |
{ |
| 243 |
Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); |
| 244 |
if( !rSubIncrements.hasElements() ) |
| 245 |
rSubIncrements.realloc( 1 ); |
| 246 |
auto pSubIncrements = rSubIncrements.getArray(); |
| 247 |
|
| 248 |
if( (rOuterValue >>= bBool) && bBool ) |
| 249 |
pSubIncrements[ 0 ].IntervalCount = Any(); |
| 250 |
else |
| 251 |
pSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet ); |
| 252 |
bSetScaleData = true; |
| 253 |
break; |
| 254 |
} |
| 255 |
case SCALE_PROP_ORIGIN: |
| 256 |
{ |
| 257 |
aScaleData.Origin = rOuterValue; |
| 258 |
bSetScaleData = true; |
| 259 |
break; |
| 260 |
} |
| 261 |
case SCALE_PROP_AUTO_ORIGIN: |
| 262 |
{ |
| 263 |
if( (rOuterValue >>= bBool) && bBool ) |
| 264 |
aScaleData.Origin = Any(); |
| 265 |
else |
| 266 |
aScaleData.Origin = getPropertyValue( SCALE_PROP_ORIGIN, xInnerPropertySet ); |
| 267 |
bSetScaleData = true; |
| 268 |
break; |
| 269 |
} |
| 270 |
case SCALE_PROP_AXIS_TYPE: |
| 271 |
{ |
| 272 |
sal_Int32 nType = 0; |
| 273 |
if( rOuterValue >>= nType ) |
| 274 |
{ |
| 275 |
if( nType == css::chart::ChartAxisType::AUTOMATIC ) |
| 276 |
{ |
| 277 |
aScaleData.AutoDateAxis = true; |
| 278 |
if( aScaleData.AxisType == AxisType::DATE ) |
| 279 |
aScaleData.AxisType = AxisType::CATEGORY; |
| 280 |
} |
| 281 |
else if( nType == css::chart::ChartAxisType::CATEGORY ) |
| 282 |
{ |
| 283 |
aScaleData.AutoDateAxis = false; |
| 284 |
if( aScaleData.AxisType == AxisType::DATE ) |
| 285 |
aScaleData.AxisType = AxisType::CATEGORY; |
| 286 |
} |
| 287 |
else if( nType == css::chart::ChartAxisType::DATE ) |
| 288 |
{ |
| 289 |
if( aScaleData.AxisType == AxisType::CATEGORY ) |
| 290 |
aScaleData.AxisType = AxisType::DATE; |
| 291 |
} |
| 292 |
bSetScaleData = true; |
| 293 |
} |
| 294 |
break; |
| 295 |
} |
| 296 |
case SCALE_PROP_DATE_INCREMENT: |
| 297 |
{ |
| 298 |
TimeIncrement aTimeIncrement; |
| 299 |
rOuterValue >>= aTimeIncrement; |
| 300 |
aScaleData.TimeIncrement = std::move(aTimeIncrement); |
| 301 |
bSetScaleData = true; |
| 302 |
break; |
| 303 |
} |
| 304 |
case SCALE_PROP_EXPLICIT_DATE_INCREMENT: |
| 305 |
//read only property |
| 306 |
break; |
| 307 |
case SCALE_PROP_LOGARITHMIC: |
| 308 |
{ |
| 309 |
if( rOuterValue >>= bBool ) |
| 310 |
{ |
| 311 |
bool bWasLogarithm = AxisHelper::isLogarithmic( aScaleData.Scaling ); |
| 312 |
|
| 313 |
// safe comparison between sal_Bool and bool |
| 314 |
if( (!bBool) != (!bWasLogarithm) ) |
| 315 |
{ |
| 316 |
if( bBool ) |
| 317 |
aScaleData.Scaling = AxisHelper::createLogarithmicScaling( 10.0 ); |
| 318 |
else |
| 319 |
aScaleData.Scaling = nullptr; |
| 320 |
bSetScaleData = true; |
| 321 |
} |
| 322 |
} |
| 323 |
break; |
| 324 |
} |
| 325 |
case SCALE_PROP_REVERSEDIRECTION: |
| 326 |
{ |
| 327 |
if( rOuterValue >>= bBool ) |
| 328 |
{ |
| 329 |
bool bWasReverse = ( aScaleData.Orientation == AxisOrientation_REVERSE ); |
| 330 |
if( (!bBool) != (!bWasReverse) ) // safe comparison between sal_Bool and bool |
| 331 |
{ |
| 332 |
aScaleData.Orientation = bBool ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL; |
| 333 |
bSetScaleData = true; |
| 334 |
} |
| 335 |
} |
| 336 |
break; |
| 337 |
} |
| 338 |
default: |
| 339 |
{ |
| 340 |
OSL_FAIL("unknown scale property"); |
| 341 |
break; |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
if( bSetScaleData ) |
| 346 |
xAxis->setScaleData( aScaleData ); |
| 347 |
} |
| 348 |
|
| 349 |
Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
| 350 |
{ |
| 351 |
Any aRet( m_aOuterValue ); |
| 352 |
|
| 353 |
rtl::Reference< Axis > xAxis = dynamic_cast<Axis*>(xInnerPropertySet.get()); |
| 354 |
OSL_ENSURE(xAxis.is(),"need an XAxis"); |
| 355 |
if(!xAxis.is()) |
| 356 |
return aRet; |
| 357 |
|
| 358 |
chart2::ScaleData aScaleData( xAxis->getScaleData() ); |
| 359 |
|
| 360 |
ExplicitScaleData aExplicitScale; |
| 361 |
ExplicitIncrementData aExplicitIncrement; |
| 362 |
|
| 363 |
switch( eScaleProperty ) |
| 364 |
{ |
| 365 |
case SCALE_PROP_MAX: |
| 366 |
{ |
| 367 |
aRet = aScaleData.Maximum; |
| 368 |
if( !aRet.hasValue() ) |
| 369 |
{ |
| 370 |
m_spChart2ModelContact->getExplicitValuesForAxis( |
| 371 |
xAxis, aExplicitScale, aExplicitIncrement ); |
| 372 |
aRet <<= aExplicitScale.Maximum; |
| 373 |
} |
| 374 |
break; |
| 375 |
} |
| 376 |
case SCALE_PROP_MIN: |
| 377 |
{ |
| 378 |
aRet = aScaleData.Minimum; |
| 379 |
if( !aRet.hasValue() ) |
| 380 |
{ |
| 381 |
m_spChart2ModelContact->getExplicitValuesForAxis( |
| 382 |
xAxis, aExplicitScale, aExplicitIncrement ); |
| 383 |
aRet <<= aExplicitScale.Minimum; |
| 384 |
} |
| 385 |
break; |
| 386 |
} |
| 387 |
|
| 388 |
case SCALE_PROP_STEPMAIN: |
| 389 |
{ |
| 390 |
aRet = aScaleData.IncrementData.Distance; |
| 391 |
if( !aRet.hasValue() ) |
| 392 |
{ |
| 393 |
m_spChart2ModelContact->getExplicitValuesForAxis( |
| 394 |
xAxis, aExplicitScale, aExplicitIncrement ); |
| 395 |
aRet <<= aExplicitIncrement.Distance; |
| 396 |
} |
| 397 |
break; |
| 398 |
} |
| 399 |
case SCALE_PROP_STEPHELP: |
| 400 |
{ |
| 401 |
// todo: evaluate PostEquidistant |
| 402 |
bool bNeedToCalculateExplicitValues = true; |
| 403 |
|
| 404 |
bool bLogarithmic( AxisHelper::isLogarithmic(aScaleData.Scaling) ); |
| 405 |
Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); |
| 406 |
if( bLogarithmic ) |
| 407 |
{ |
| 408 |
if( rSubIncrements.hasElements() ) |
| 409 |
{ |
| 410 |
sal_Int32 nIntervalCount = 0; |
| 411 |
rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount; |
| 412 |
aRet <<= double(nIntervalCount); |
| 413 |
bNeedToCalculateExplicitValues = false; |
| 414 |
} |
| 415 |
} |
| 416 |
else if( aScaleData.IncrementData.Distance.hasValue() ) |
| 417 |
{ |
| 418 |
if( rSubIncrements.hasElements() ) |
| 419 |
{ |
| 420 |
double fStepMain = 0; |
| 421 |
sal_Int32 nIntervalCount = 0; |
| 422 |
if( (aScaleData.IncrementData.Distance >>= fStepMain) && |
| 423 |
(rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) && |
| 424 |
nIntervalCount > 0 ) |
| 425 |
{ |
| 426 |
aRet <<= fStepMain / static_cast< double >( nIntervalCount ); |
| 427 |
bNeedToCalculateExplicitValues = false; |
| 428 |
} |
| 429 |
} |
| 430 |
else |
| 431 |
{ |
| 432 |
aRet = aScaleData.IncrementData.Distance; |
| 433 |
bNeedToCalculateExplicitValues = false; |
| 434 |
} |
| 435 |
} |
| 436 |
|
| 437 |
if( bNeedToCalculateExplicitValues ) |
| 438 |
{ |
| 439 |
m_spChart2ModelContact->getExplicitValuesForAxis( |
| 440 |
xAxis, aExplicitScale, aExplicitIncrement ); |
| 441 |
|
| 442 |
if( !aExplicitIncrement.SubIncrements.empty() && |
| 443 |
aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 ) |
| 444 |
{ |
| 445 |
if( bLogarithmic ) |
| 446 |
{ |
| 447 |
if( rSubIncrements.hasElements() ) |
| 448 |
{ |
| 449 |
sal_Int32 nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount; |
| 450 |
aRet <<= double(nIntervalCount); |
| 451 |
} |
| 452 |
} |
| 453 |
else |
| 454 |
aRet <<= aExplicitIncrement.Distance / |
| 455 |
static_cast< double >( |
| 456 |
aExplicitIncrement.SubIncrements[ 0 ].IntervalCount ); |
| 457 |
} |
| 458 |
else |
| 459 |
{ |
| 460 |
if( bLogarithmic ) |
| 461 |
aRet <<= 5.0; |
| 462 |
else |
| 463 |
aRet <<= aExplicitIncrement.Distance; |
| 464 |
} |
| 465 |
} |
| 466 |
break; |
| 467 |
} |
| 468 |
case SCALE_PROP_STEPHELP_COUNT: |
| 469 |
{ |
| 470 |
sal_Int32 nIntervalCount = 0; |
| 471 |
bool bNeedToCalculateExplicitValues = true; |
| 472 |
Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); |
| 473 |
if( rSubIncrements.hasElements() ) |
| 474 |
{ |
| 475 |
if( (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) && (nIntervalCount > 0) ) |
| 476 |
bNeedToCalculateExplicitValues = false; |
| 477 |
} |
| 478 |
if( bNeedToCalculateExplicitValues ) |
| 479 |
{ |
| 480 |
m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); |
| 481 |
if( !aExplicitIncrement.SubIncrements.empty() ) |
| 482 |
nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount; |
| 483 |
} |
| 484 |
aRet <<= nIntervalCount; |
| 485 |
break; |
| 486 |
} |
| 487 |
case SCALE_PROP_AUTO_MAX: |
| 488 |
{ |
| 489 |
aRet <<= !aScaleData.Maximum.hasValue(); |
| 490 |
break; |
| 491 |
} |
| 492 |
case SCALE_PROP_AUTO_MIN: |
| 493 |
{ |
| 494 |
aRet <<= !aScaleData.Minimum.hasValue(); |
| 495 |
break; |
| 496 |
} |
| 497 |
case SCALE_PROP_AUTO_STEPMAIN: |
| 498 |
{ |
| 499 |
aRet <<= !aScaleData.IncrementData.Distance.hasValue(); |
| 500 |
break; |
| 501 |
} |
| 502 |
case SCALE_PROP_AUTO_STEPHELP: |
| 503 |
{ |
| 504 |
Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); |
| 505 |
if( rSubIncrements.hasElements() ) |
| 506 |
aRet <<= !rSubIncrements[ 0 ].IntervalCount.hasValue(); |
| 507 |
else |
| 508 |
aRet <<= true; |
| 509 |
break; |
| 510 |
} |
| 511 |
case SCALE_PROP_ORIGIN: |
| 512 |
{ |
| 513 |
aRet = aScaleData.Origin; |
| 514 |
if( !aRet.hasValue() ) |
| 515 |
{ |
| 516 |
m_spChart2ModelContact->getExplicitValuesForAxis( |
| 517 |
xAxis, aExplicitScale, aExplicitIncrement ); |
| 518 |
aRet <<= aExplicitScale.Origin; |
| 519 |
} |
| 520 |
break; |
| 521 |
} |
| 522 |
case SCALE_PROP_AUTO_ORIGIN: |
| 523 |
{ |
| 524 |
aRet <<= !hasDoubleValue(aScaleData.Origin); |
| 525 |
break; |
| 526 |
} |
| 527 |
case SCALE_PROP_AXIS_TYPE: |
| 528 |
{ |
| 529 |
sal_Int32 nType = css::chart::ChartAxisType::AUTOMATIC; |
| 530 |
if( aScaleData.AxisType == AxisType::DATE ) |
| 531 |
{ |
| 532 |
nType = css::chart::ChartAxisType::DATE; |
| 533 |
} |
| 534 |
else if( aScaleData.AxisType == AxisType::CATEGORY ) |
| 535 |
{ |
| 536 |
if( !aScaleData.AutoDateAxis ) |
| 537 |
nType = css::chart::ChartAxisType::CATEGORY; |
| 538 |
} |
| 539 |
aRet <<= nType; |
| 540 |
break; |
| 541 |
} |
| 542 |
case SCALE_PROP_DATE_INCREMENT: |
| 543 |
{ |
| 544 |
if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) |
| 545 |
aRet <<= aScaleData.TimeIncrement; |
| 546 |
break; |
| 547 |
} |
| 548 |
case SCALE_PROP_EXPLICIT_DATE_INCREMENT: |
| 549 |
{ |
| 550 |
if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) |
| 551 |
{ |
| 552 |
m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); |
| 553 |
if( aExplicitScale.AxisType == AxisType::DATE ) |
| 554 |
{ |
| 555 |
TimeIncrement aTimeIncrement; |
| 556 |
aTimeIncrement.MajorTimeInterval <<= aExplicitIncrement.MajorTimeInterval; |
| 557 |
aTimeIncrement.MinorTimeInterval <<= aExplicitIncrement.MinorTimeInterval; |
| 558 |
aTimeIncrement.TimeResolution <<= aExplicitScale.TimeResolution; |
| 559 |
aRet <<= aTimeIncrement; |
| 560 |
} |
| 561 |
else |
| 562 |
aRet <<= aScaleData.TimeIncrement; |
| 563 |
} |
| 564 |
|
| 565 |
break; |
| 566 |
} |
| 567 |
case SCALE_PROP_LOGARITHMIC: |
| 568 |
{ |
| 569 |
aRet <<= AxisHelper::isLogarithmic(aScaleData.Scaling); |
| 570 |
break; |
| 571 |
} |
| 572 |
case SCALE_PROP_REVERSEDIRECTION: |
| 573 |
{ |
| 574 |
aRet <<= aScaleData.Orientation == AxisOrientation_REVERSE; |
| 575 |
break; |
| 576 |
} |
| 577 |
default: |
| 578 |
{ |
| 579 |
OSL_FAIL("unknown scale property"); |
| 580 |
break; |
| 581 |
} |
| 582 |
} |
| 583 |
|
| 584 |
return aRet; |
| 585 |
} |
| 586 |
|
| 587 |
} // namespace chart |
| 588 |
|
| 589 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |