| 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 <AxisItemConverter.hxx> |
| 21 |
#include <ItemPropertyMap.hxx> |
| 22 |
#include <CharacterPropertyItemConverter.hxx> |
| 23 |
#include <GraphicPropertyItemConverter.hxx> |
| 24 |
#include <chartview/ChartSfxItemIds.hxx> |
| 25 |
#include <chartview/ExplicitScaleValues.hxx> |
| 26 |
#include "SchWhichPairs.hxx" |
| 27 |
#include <ChartModel.hxx> |
| 28 |
#include <Axis.hxx> |
| 29 |
#include <AxisHelper.hxx> |
| 30 |
#include <CommonConverters.hxx> |
| 31 |
#include <ChartType.hxx> |
| 32 |
#include <Diagram.hxx> |
| 33 |
#include <unonames.hxx> |
| 34 |
#include <BaseCoordinateSystem.hxx> |
| 35 |
#include <ChartView.hxx> |
| 36 |
#include <memory> |
| 37 |
|
| 38 |
#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> |
| 39 |
#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> |
| 40 |
#include <com/sun/star/chart/ChartAxisPosition.hpp> |
| 41 |
#include <com/sun/star/chart/TimeInterval.hpp> |
| 42 |
#include <com/sun/star/chart2/AxisOrientation.hpp> |
| 43 |
#include <com/sun/star/chart2/AxisType.hpp> |
| 44 |
|
| 45 |
#include <osl/diagnose.h> |
| 46 |
#include <o3tl/any.hxx> |
| 47 |
#include <svl/eitem.hxx> |
| 48 |
#include <svx/chrtitem.hxx> |
| 49 |
#include <svx/sdangitm.hxx> |
| 50 |
#include <svl/intitem.hxx> |
| 51 |
#include <rtl/math.hxx> |
| 52 |
|
| 53 |
using namespace ::com::sun::star; |
| 54 |
using namespace ::com::sun::star::chart2; |
| 55 |
using ::com::sun::star::uno::Reference; |
| 56 |
using ::com::sun::star::chart::TimeInterval; |
| 57 |
using ::com::sun::star::chart::TimeIncrement; |
| 58 |
|
| 59 |
namespace chart::wrapper { |
| 60 |
|
| 61 |
namespace { |
| 62 |
|
| 63 |
ItemPropertyMapType & lcl_GetAxisPropertyMap() |
| 64 |
{ |
| 65 |
static ItemPropertyMapType aAxisPropertyMap{ |
| 66 |
{SCHATTR_AXIS_SHOWDESCR, {"DisplayLabels", 0}}, |
| 67 |
{SCHATTR_AXIS_TICKS, {"MajorTickmarks", 0}}, |
| 68 |
{SCHATTR_AXIS_HELPTICKS, {"MinorTickmarks", 0}}, |
| 69 |
{SCHATTR_AXIS_LABEL_ORDER, {"ArrangeOrder", 0}}, |
| 70 |
{SCHATTR_TEXT_STACKED, {"StackCharacters", 0}}, |
| 71 |
{SCHATTR_AXIS_LABEL_BREAK, {"TextBreak", 0}}, |
| 72 |
{SCHATTR_AXIS_LABEL_OVERLAP, {"TextOverlap", 0}}}; |
| 73 |
return aAxisPropertyMap; |
| 74 |
}; |
| 75 |
|
| 76 |
} // anonymous namespace |
| 77 |
|
| 78 |
AxisItemConverter::AxisItemConverter( |
| 79 |
const Reference< beans::XPropertySet > & rPropertySet, |
| 80 |
SfxItemPool& rItemPool, |
| 81 |
SdrModel& rDrawModel, |
| 82 |
const rtl::Reference<::chart::ChartModel> & xChartDoc, |
| 83 |
::chart::ExplicitScaleData const * pScale /* = NULL */, |
| 84 |
::chart::ExplicitIncrementData const * pIncrement /* = NULL */, |
| 85 |
const std::optional<awt::Size>& pRefSize ) : |
| 86 |
ItemConverter( rPropertySet, rItemPool ), |
| 87 |
m_xChartDoc( xChartDoc ) |
| 88 |
{ |
| 89 |
if( pScale ) |
| 90 |
m_pExplicitScale.reset( new ::chart::ExplicitScaleData( *pScale ) ); |
| 91 |
if( pIncrement ) |
| 92 |
m_pExplicitIncrement.reset( new ::chart::ExplicitIncrementData( *pIncrement ) ); |
| 93 |
|
| 94 |
m_aConverters.emplace_back( new GraphicPropertyItemConverter( |
| 95 |
rPropertySet, rItemPool, rDrawModel, |
| 96 |
xChartDoc, |
| 97 |
GraphicObjectType::LineProperties )); |
| 98 |
m_aConverters.emplace_back( |
| 99 |
new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr)); |
| 100 |
|
| 101 |
m_xAxis = dynamic_cast<::chart::Axis*>(rPropertySet.get()); |
| 102 |
assert(m_xAxis); |
| 103 |
} |
| 104 |
|
| 105 |
AxisItemConverter::~AxisItemConverter() |
| 106 |
{ |
| 107 |
} |
| 108 |
|
| 109 |
void AxisItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const |
| 110 |
{ |
| 111 |
for( const auto& pConv : m_aConverters ) |
| 112 |
pConv->FillItemSet( rOutItemSet ); |
| 113 |
|
| 114 |
// own items |
| 115 |
ItemConverter::FillItemSet( rOutItemSet ); |
| 116 |
} |
| 117 |
|
| 118 |
bool AxisItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) |
| 119 |
{ |
| 120 |
bool bResult = false; |
| 121 |
|
| 122 |
for( const auto& pConv : m_aConverters ) |
| 123 |
bResult = pConv->ApplyItemSet( rItemSet ) || bResult; |
| 124 |
|
| 125 |
// own items |
| 126 |
return ItemConverter::ApplyItemSet( rItemSet ) || bResult; |
| 127 |
} |
| 128 |
|
| 129 |
const WhichRangesContainer& AxisItemConverter::GetWhichPairs() const |
| 130 |
{ |
| 131 |
// must span all used items! |
| 132 |
return nAxisWhichPairs; |
| 133 |
} |
| 134 |
|
| 135 |
bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const |
| 136 |
{ |
| 137 |
ItemPropertyMapType & rMap( lcl_GetAxisPropertyMap()); |
| 138 |
ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); |
| 139 |
|
| 140 |
if( aIt == rMap.end()) |
| 141 |
return false; |
| 142 |
|
| 143 |
rOutProperty =(*aIt).second; |
| 144 |
|
| 145 |
return true; |
| 146 |
} |
| 147 |
|
| 148 |
static bool lcl_hasTimeIntervalValue( const uno::Any& rAny ) |
| 149 |
{ |
| 150 |
bool bRet = false; |
| 151 |
TimeInterval aValue; |
| 152 |
if( rAny >>= aValue ) |
| 153 |
bRet = true; |
| 154 |
return bRet; |
| 155 |
} |
| 156 |
|
| 157 |
void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const |
| 158 |
{ |
| 159 |
if( !m_xAxis.is() ) |
| 160 |
return; |
| 161 |
|
| 162 |
const chart2::ScaleData aScale( m_xAxis->getScaleData() ); |
| 163 |
const chart2::IncrementData& rIncrement( aScale.IncrementData ); |
| 164 |
const uno::Sequence< chart2::SubIncrement >& rSubIncrements( aScale.IncrementData.SubIncrements ); |
| 165 |
const TimeIncrement& rTimeIncrement( aScale.TimeIncrement ); |
| 166 |
bool bDateAxis = (aScale.AxisType == chart2::AxisType::DATE); |
| 167 |
if( m_pExplicitScale ) |
| 168 |
bDateAxis = (m_pExplicitScale->AxisType == chart2::AxisType::DATE); |
| 169 |
|
| 170 |
switch( nWhichId ) |
| 171 |
{ |
| 172 |
case SCHATTR_AXIS_AUTO_MAX: |
| 173 |
rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Maximum) ) ); |
| 174 |
break; |
| 175 |
|
| 176 |
case SCHATTR_AXIS_MAX: |
| 177 |
{ |
| 178 |
double fMax = 10.0; |
| 179 |
if( aScale.Maximum >>= fMax ) |
| 180 |
rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) ); |
| 181 |
else |
| 182 |
{ |
| 183 |
if( m_pExplicitScale ) |
| 184 |
fMax = m_pExplicitScale->Maximum; |
| 185 |
rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) ); |
| 186 |
} |
| 187 |
} |
| 188 |
break; |
| 189 |
|
| 190 |
case SCHATTR_AXIS_AUTO_MIN: |
| 191 |
rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Minimum) ) ); |
| 192 |
break; |
| 193 |
|
| 194 |
case SCHATTR_AXIS_MIN: |
| 195 |
{ |
| 196 |
double fMin = 0.0; |
| 197 |
if( aScale.Minimum >>= fMin ) |
| 198 |
rOutItemSet.Put( SvxDoubleItem( fMin, SCHATTR_AXIS_MIN ) ); |
| 199 |
else if( m_pExplicitScale ) |
| 200 |
rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, SCHATTR_AXIS_MIN )); |
| 201 |
} |
| 202 |
break; |
| 203 |
|
| 204 |
case SCHATTR_AXIS_LOGARITHM: |
| 205 |
{ |
| 206 |
bool bValue = AxisHelper::isLogarithmic( aScale.Scaling ); |
| 207 |
rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); |
| 208 |
} |
| 209 |
break; |
| 210 |
|
| 211 |
case SCHATTR_AXIS_REVERSE: |
| 212 |
rOutItemSet.Put( SfxBoolItem( nWhichId, (aScale.Orientation == AxisOrientation_REVERSE) )); |
| 213 |
break; |
| 214 |
|
| 215 |
// Increment |
| 216 |
case SCHATTR_AXIS_AUTO_STEP_MAIN: |
| 217 |
if( bDateAxis ) |
| 218 |
rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MajorTimeInterval) ) ); |
| 219 |
else |
| 220 |
rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rIncrement.Distance) ) ); |
| 221 |
break; |
| 222 |
|
| 223 |
case SCHATTR_AXIS_MAIN_TIME_UNIT: |
| 224 |
{ |
| 225 |
TimeInterval aTimeInterval; |
| 226 |
if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) |
| 227 |
rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); |
| 228 |
else if( m_pExplicitIncrement ) |
| 229 |
rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MajorTimeInterval.TimeUnit ) ); |
| 230 |
} |
| 231 |
break; |
| 232 |
|
| 233 |
case SCHATTR_AXIS_STEP_MAIN: |
| 234 |
if( bDateAxis ) |
| 235 |
{ |
| 236 |
TimeInterval aTimeInterval; |
| 237 |
if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) |
| 238 |
rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, SCHATTR_AXIS_STEP_MAIN )); |
| 239 |
else if( m_pExplicitIncrement ) |
| 240 |
rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, SCHATTR_AXIS_STEP_MAIN )); |
| 241 |
} |
| 242 |
else |
| 243 |
{ |
| 244 |
double fDistance = 1.0; |
| 245 |
if( rIncrement.Distance >>= fDistance ) |
| 246 |
rOutItemSet.Put( SvxDoubleItem(fDistance, SCHATTR_AXIS_STEP_MAIN )); |
| 247 |
else if( m_pExplicitIncrement ) |
| 248 |
rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, SCHATTR_AXIS_STEP_MAIN )); |
| 249 |
} |
| 250 |
break; |
| 251 |
|
| 252 |
// SubIncrement |
| 253 |
case SCHATTR_AXIS_AUTO_STEP_HELP: |
| 254 |
if( bDateAxis ) |
| 255 |
rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MinorTimeInterval) ) ); |
| 256 |
else |
| 257 |
rOutItemSet.Put( SfxBoolItem( nWhichId, |
| 258 |
! ( rSubIncrements.hasElements() && rSubIncrements[0].IntervalCount.hasValue() ))); |
| 259 |
break; |
| 260 |
|
| 261 |
case SCHATTR_AXIS_HELP_TIME_UNIT: |
| 262 |
{ |
| 263 |
TimeInterval aTimeInterval; |
| 264 |
if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) |
| 265 |
rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); |
| 266 |
else if( m_pExplicitIncrement ) |
| 267 |
rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.TimeUnit ) ); |
| 268 |
} |
| 269 |
break; |
| 270 |
|
| 271 |
case SCHATTR_AXIS_STEP_HELP: |
| 272 |
if( bDateAxis ) |
| 273 |
{ |
| 274 |
TimeInterval aTimeInterval; |
| 275 |
if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) |
| 276 |
rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.Number )); |
| 277 |
else if( m_pExplicitIncrement ) |
| 278 |
rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.Number )); |
| 279 |
} |
| 280 |
else |
| 281 |
{ |
| 282 |
if( rSubIncrements.hasElements() && rSubIncrements[0].IntervalCount.hasValue()) |
| 283 |
{ |
| 284 |
rOutItemSet.Put( SfxInt32Item( nWhichId, |
| 285 |
*o3tl::doAccess<sal_Int32>( |
| 286 |
rSubIncrements[0].IntervalCount) )); |
| 287 |
} |
| 288 |
else |
| 289 |
{ |
| 290 |
if( m_pExplicitIncrement && !m_pExplicitIncrement->SubIncrements.empty() ) |
| 291 |
{ |
| 292 |
rOutItemSet.Put( SfxInt32Item( nWhichId, |
| 293 |
m_pExplicitIncrement->SubIncrements[0].IntervalCount )); |
| 294 |
} |
| 295 |
} |
| 296 |
} |
| 297 |
break; |
| 298 |
|
| 299 |
case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: |
| 300 |
{ |
| 301 |
rOutItemSet.Put( SfxBoolItem( nWhichId, |
| 302 |
!rTimeIncrement.TimeResolution.hasValue() )); |
| 303 |
} |
| 304 |
break; |
| 305 |
case SCHATTR_AXIS_TIME_RESOLUTION: |
| 306 |
{ |
| 307 |
sal_Int32 nTimeResolution=0; |
| 308 |
if( rTimeIncrement.TimeResolution >>= nTimeResolution ) |
| 309 |
rOutItemSet.Put( SfxInt32Item( nWhichId, nTimeResolution ) ); |
| 310 |
else if( m_pExplicitScale ) |
| 311 |
rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitScale->TimeResolution ) ); |
| 312 |
} |
| 313 |
break; |
| 314 |
|
| 315 |
case SCHATTR_AXIS_AUTO_ORIGIN: |
| 316 |
{ |
| 317 |
rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) ))); |
| 318 |
} |
| 319 |
break; |
| 320 |
|
| 321 |
case SCHATTR_AXIS_ORIGIN: |
| 322 |
{ |
| 323 |
double fOrigin = 0.0; |
| 324 |
if( !(aScale.Origin >>= fOrigin) ) |
| 325 |
{ |
| 326 |
if( m_pExplicitScale ) |
| 327 |
fOrigin = m_pExplicitScale->Origin; |
| 328 |
} |
| 329 |
rOutItemSet.Put( SvxDoubleItem( fOrigin, SCHATTR_AXIS_ORIGIN )); |
| 330 |
} |
| 331 |
break; |
| 332 |
|
| 333 |
case SCHATTR_AXIS_POSITION: |
| 334 |
{ |
| 335 |
css::chart::ChartAxisPosition eAxisPos( css::chart::ChartAxisPosition_ZERO ); |
| 336 |
GetPropertySet()->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eAxisPos; |
| 337 |
rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(eAxisPos) ) ); |
| 338 |
} |
| 339 |
break; |
| 340 |
|
| 341 |
case SCHATTR_AXIS_POSITION_VALUE: |
| 342 |
{ |
| 343 |
double fValue = 0.0; |
| 344 |
if( GetPropertySet()->getPropertyValue( u"CrossoverValue"_ustr ) >>= fValue ) |
| 345 |
rOutItemSet.Put( SvxDoubleItem( fValue, SCHATTR_AXIS_POSITION_VALUE ) ); |
| 346 |
} |
| 347 |
break; |
| 348 |
|
| 349 |
case SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT: |
| 350 |
{ |
| 351 |
//read only item |
| 352 |
//necessary tp display the crossing value with an appropriate format |
| 353 |
|
| 354 |
rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( |
| 355 |
m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
| 356 |
|
| 357 |
rtl::Reference< Axis > xCrossingMainAxis = AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ); |
| 358 |
|
| 359 |
sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( |
| 360 |
xCrossingMainAxis, xCooSys, m_xChartDoc); |
| 361 |
|
| 362 |
rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); |
| 363 |
} |
| 364 |
break; |
| 365 |
|
| 366 |
case SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION: |
| 367 |
rOutItemSet.Put(SfxBoolItem(nWhichId, aScale.ShiftedCategoryPosition)); |
| 368 |
break; |
| 369 |
|
| 370 |
case SCHATTR_AXIS_LABEL_POSITION: |
| 371 |
{ |
| 372 |
css::chart::ChartAxisLabelPosition ePos( css::chart::ChartAxisLabelPosition_NEAR_AXIS ); |
| 373 |
GetPropertySet()->getPropertyValue( u"LabelPosition"_ustr ) >>= ePos; |
| 374 |
rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(ePos) ) ); |
| 375 |
} |
| 376 |
break; |
| 377 |
|
| 378 |
case SCHATTR_AXIS_MARK_POSITION: |
| 379 |
{ |
| 380 |
css::chart::ChartAxisMarkPosition ePos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); |
| 381 |
GetPropertySet()->getPropertyValue( u"MarkPosition"_ustr ) >>= ePos; |
| 382 |
rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(ePos) ) ); |
| 383 |
} |
| 384 |
break; |
| 385 |
|
| 386 |
case SCHATTR_TEXT_DEGREES: |
| 387 |
{ |
| 388 |
// convert double to int (times 100) |
| 389 |
double fVal = 0; |
| 390 |
|
| 391 |
if( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fVal ) |
| 392 |
{ |
| 393 |
rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, Degree100(static_cast< sal_Int32 >( |
| 394 |
::rtl::math::round( fVal * 100.0 )) ) )); |
| 395 |
} |
| 396 |
} |
| 397 |
break; |
| 398 |
|
| 399 |
case SID_ATTR_NUMBERFORMAT_VALUE: |
| 400 |
{ |
| 401 |
if( m_pExplicitScale ) |
| 402 |
{ |
| 403 |
rtl::Reference< BaseCoordinateSystem > xCooSys( |
| 404 |
AxisHelper::getCoordinateSystemOfAxis( |
| 405 |
m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
| 406 |
|
| 407 |
sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( |
| 408 |
m_xAxis, xCooSys, m_xChartDoc); |
| 409 |
|
| 410 |
rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); |
| 411 |
} |
| 412 |
} |
| 413 |
break; |
| 414 |
|
| 415 |
case SID_ATTR_NUMBERFORMAT_SOURCE: |
| 416 |
{ |
| 417 |
bool bLinkToSource = true; |
| 418 |
GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource; |
| 419 |
rOutItemSet.Put(SfxBoolItem(nWhichId, bLinkToSource)); |
| 420 |
} |
| 421 |
break; |
| 422 |
|
| 423 |
case SCHATTR_AXISTYPE: |
| 424 |
rOutItemSet.Put( SfxInt32Item( nWhichId, aScale.AxisType )); |
| 425 |
break; |
| 426 |
|
| 427 |
case SCHATTR_AXIS_AUTO_DATEAXIS: |
| 428 |
rOutItemSet.Put( SfxBoolItem( nWhichId, aScale.AutoDateAxis )); |
| 429 |
break; |
| 430 |
|
| 431 |
case SCHATTR_AXIS_ALLOW_DATEAXIS: |
| 432 |
{ |
| 433 |
rtl::Reference< BaseCoordinateSystem > xCooSys( |
| 434 |
AxisHelper::getCoordinateSystemOfAxis( m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
| 435 |
sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; |
| 436 |
AxisHelper::getIndicesForAxis(m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ); |
| 437 |
auto xChartType = AxisHelper::getChartTypeByIndex(xCooSys, 0); |
| 438 |
bool bChartTypeAllowsDateAxis = xChartType.is() ? xChartType->isSupportingDateAxis(nDimensionIndex) : true; |
| 439 |
rOutItemSet.Put( SfxBoolItem( nWhichId, bChartTypeAllowsDateAxis )); |
| 440 |
} |
| 441 |
break; |
| 442 |
} |
| 443 |
} |
| 444 |
|
| 445 |
static bool lcl_isDateAxis( const SfxItemSet & rItemSet ) |
| 446 |
{ |
| 447 |
sal_Int32 nAxisType = rItemSet.Get( SCHATTR_AXISTYPE ).GetValue();//css::chart2::AxisType |
| 448 |
return (nAxisType == chart2::AxisType::DATE); |
| 449 |
} |
| 450 |
|
| 451 |
static bool lcl_isAutoMajor( const SfxItemSet & rItemSet ) |
| 452 |
{ |
| 453 |
bool bRet = rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN ).GetValue(); |
| 454 |
return bRet; |
| 455 |
} |
| 456 |
|
| 457 |
static bool lcl_isAutoMinor( const SfxItemSet & rItemSet ) |
| 458 |
{ |
| 459 |
bool bRet = rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP ).GetValue(); |
| 460 |
return bRet; |
| 461 |
} |
| 462 |
|
| 463 |
bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) |
| 464 |
{ |
| 465 |
if( !m_xAxis.is() ) |
| 466 |
return false; |
| 467 |
|
| 468 |
chart2::ScaleData aScale( m_xAxis->getScaleData() ); |
| 469 |
|
| 470 |
bool bSetScale = false; |
| 471 |
bool bChangedOtherwise = false; |
| 472 |
|
| 473 |
uno::Any aValue; |
| 474 |
|
| 475 |
switch( nWhichId ) |
| 476 |
{ |
| 477 |
case SCHATTR_AXIS_AUTO_MAX: |
| 478 |
if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
| 479 |
{ |
| 480 |
aScale.Maximum.clear(); |
| 481 |
bSetScale = true; |
| 482 |
} |
| 483 |
// else SCHATTR_AXIS_MAX must have some value |
| 484 |
break; |
| 485 |
|
| 486 |
case SCHATTR_AXIS_MAX: |
| 487 |
// only if auto if false |
| 488 |
if( ! (rItemSet.Get( SCHATTR_AXIS_AUTO_MAX ).GetValue() )) |
| 489 |
{ |
| 490 |
rItemSet.Get( nWhichId ).QueryValue( aValue ); |
| 491 |
|
| 492 |
if( aScale.Maximum != aValue ) |
| 493 |
{ |
| 494 |
aScale.Maximum = aValue; |
| 495 |
bSetScale = true; |
| 496 |
} |
| 497 |
} |
| 498 |
break; |
| 499 |
|
| 500 |
case SCHATTR_AXIS_AUTO_MIN: |
| 501 |
if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
| 502 |
{ |
| 503 |
aScale.Minimum.clear(); |
| 504 |
bSetScale = true; |
| 505 |
} |
| 506 |
// else SCHATTR_AXIS_MIN must have some value |
| 507 |
break; |
| 508 |
|
| 509 |
case SCHATTR_AXIS_MIN: |
| 510 |
// only if auto if false |
| 511 |
if( ! (rItemSet.Get( SCHATTR_AXIS_AUTO_MIN ).GetValue() )) |
| 512 |
{ |
| 513 |
rItemSet.Get( nWhichId ).QueryValue( aValue ); |
| 514 |
|
| 515 |
if( aScale.Minimum != aValue ) |
| 516 |
{ |
| 517 |
aScale.Minimum = aValue; |
| 518 |
bSetScale = true; |
| 519 |
} |
| 520 |
} |
| 521 |
break; |
| 522 |
|
| 523 |
case SCHATTR_AXIS_LOGARITHM: |
| 524 |
{ |
| 525 |
bool bWasLogarithm = AxisHelper::isLogarithmic( aScale.Scaling ); |
| 526 |
|
| 527 |
if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
| 528 |
{ |
| 529 |
// logarithm is true |
| 530 |
if( ! bWasLogarithm ) |
| 531 |
{ |
| 532 |
aScale.Scaling = AxisHelper::createLogarithmicScaling( 10.0 ); |
| 533 |
bSetScale = true; |
| 534 |
} |
| 535 |
} |
| 536 |
else |
| 537 |
{ |
| 538 |
// logarithm is false => linear scaling |
| 539 |
if( bWasLogarithm ) |
| 540 |
{ |
| 541 |
aScale.Scaling = AxisHelper::createLinearScaling(); |
| 542 |
bSetScale = true; |
| 543 |
} |
| 544 |
} |
| 545 |
} |
| 546 |
break; |
| 547 |
|
| 548 |
case SCHATTR_AXIS_REVERSE: |
| 549 |
{ |
| 550 |
bool bWasReverse = ( aScale.Orientation == AxisOrientation_REVERSE ); |
| 551 |
bool bNewReverse = static_cast< const SfxBoolItem & >( |
| 552 |
rItemSet.Get( nWhichId )).GetValue(); |
| 553 |
if( bWasReverse != bNewReverse ) |
| 554 |
{ |
| 555 |
aScale.Orientation = bNewReverse ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL; |
| 556 |
bSetScale = true; |
| 557 |
} |
| 558 |
} |
| 559 |
break; |
| 560 |
|
| 561 |
// Increment |
| 562 |
case SCHATTR_AXIS_AUTO_STEP_MAIN: |
| 563 |
if( lcl_isAutoMajor(rItemSet) ) |
| 564 |
{ |
| 565 |
aScale.IncrementData.Distance.clear(); |
| 566 |
aScale.TimeIncrement.MajorTimeInterval.clear(); |
| 567 |
bSetScale = true; |
| 568 |
} |
| 569 |
// else SCHATTR_AXIS_STEP_MAIN must have some value |
| 570 |
break; |
| 571 |
|
| 572 |
case SCHATTR_AXIS_MAIN_TIME_UNIT: |
| 573 |
if( !lcl_isAutoMajor(rItemSet) ) |
| 574 |
{ |
| 575 |
if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) |
| 576 |
{ |
| 577 |
TimeInterval aTimeInterval; |
| 578 |
aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; |
| 579 |
aValue >>= aTimeInterval.TimeUnit; |
| 580 |
aScale.TimeIncrement.MajorTimeInterval <<= aTimeInterval; |
| 581 |
bSetScale = true; |
| 582 |
} |
| 583 |
} |
| 584 |
break; |
| 585 |
|
| 586 |
case SCHATTR_AXIS_STEP_MAIN: |
| 587 |
// only if auto if false |
| 588 |
if( !lcl_isAutoMajor(rItemSet) ) |
| 589 |
{ |
| 590 |
rItemSet.Get( nWhichId ).QueryValue( aValue ); |
| 591 |
if( lcl_isDateAxis(rItemSet) ) |
| 592 |
{ |
| 593 |
double fValue = 1.0; |
| 594 |
if( aValue >>= fValue ) |
| 595 |
{ |
| 596 |
TimeInterval aTimeInterval; |
| 597 |
aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; |
| 598 |
aTimeInterval.Number = static_cast<sal_Int32>(fValue); |
| 599 |
aScale.TimeIncrement.MajorTimeInterval <<= aTimeInterval; |
| 600 |
bSetScale = true; |
| 601 |
} |
| 602 |
} |
| 603 |
else if( aScale.IncrementData.Distance != aValue ) |
| 604 |
{ |
| 605 |
aScale.IncrementData.Distance = aValue; |
| 606 |
bSetScale = true; |
| 607 |
} |
| 608 |
} |
| 609 |
break; |
| 610 |
|
| 611 |
// SubIncrement |
| 612 |
case SCHATTR_AXIS_AUTO_STEP_HELP: |
| 613 |
if( lcl_isAutoMinor(rItemSet) ) |
| 614 |
{ |
| 615 |
if( aScale.IncrementData.SubIncrements.hasElements() && |
| 616 |
aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) |
| 617 |
{ |
| 618 |
aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount.clear(); |
| 619 |
bSetScale = true; |
| 620 |
} |
| 621 |
if( aScale.TimeIncrement.MinorTimeInterval.hasValue() ) |
| 622 |
{ |
| 623 |
aScale.TimeIncrement.MinorTimeInterval.clear(); |
| 624 |
bSetScale = true; |
| 625 |
} |
| 626 |
} |
| 627 |
// else SCHATTR_AXIS_STEP_MAIN must have some value |
| 628 |
break; |
| 629 |
|
| 630 |
case SCHATTR_AXIS_HELP_TIME_UNIT: |
| 631 |
if( !lcl_isAutoMinor(rItemSet) ) |
| 632 |
{ |
| 633 |
if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) |
| 634 |
{ |
| 635 |
TimeInterval aTimeInterval; |
| 636 |
aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; |
| 637 |
aValue >>= aTimeInterval.TimeUnit; |
| 638 |
aScale.TimeIncrement.MinorTimeInterval <<= aTimeInterval; |
| 639 |
bSetScale = true; |
| 640 |
} |
| 641 |
} |
| 642 |
break; |
| 643 |
|
| 644 |
case SCHATTR_AXIS_STEP_HELP: |
| 645 |
// only if auto is false |
| 646 |
if( !lcl_isAutoMinor(rItemSet) ) |
| 647 |
{ |
| 648 |
rItemSet.Get( nWhichId ).QueryValue( aValue ); |
| 649 |
if( lcl_isDateAxis(rItemSet) ) |
| 650 |
{ |
| 651 |
TimeInterval aTimeInterval; |
| 652 |
aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; |
| 653 |
aValue >>= aTimeInterval.Number; |
| 654 |
aScale.TimeIncrement.MinorTimeInterval <<= aTimeInterval; |
| 655 |
bSetScale = true; |
| 656 |
} |
| 657 |
else if( aScale.IncrementData.SubIncrements.hasElements() ) |
| 658 |
{ |
| 659 |
if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || |
| 660 |
aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) |
| 661 |
{ |
| 662 |
OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); |
| 663 |
aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount = aValue; |
| 664 |
bSetScale = true; |
| 665 |
} |
| 666 |
} |
| 667 |
} |
| 668 |
break; |
| 669 |
|
| 670 |
case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: |
| 671 |
if( static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue() ) |
| 672 |
{ |
| 673 |
aScale.TimeIncrement.TimeResolution.clear(); |
| 674 |
bSetScale = true; |
| 675 |
} |
| 676 |
break; |
| 677 |
case SCHATTR_AXIS_TIME_RESOLUTION: |
| 678 |
// only if auto is false |
| 679 |
if( ! ( rItemSet.Get( SCHATTR_AXIS_AUTO_TIME_RESOLUTION ).GetValue() )) |
| 680 |
{ |
| 681 |
rItemSet.Get( nWhichId ).QueryValue( aValue ); |
| 682 |
|
| 683 |
if( aScale.TimeIncrement.TimeResolution != aValue ) |
| 684 |
{ |
| 685 |
aScale.TimeIncrement.TimeResolution = aValue; |
| 686 |
bSetScale = true; |
| 687 |
} |
| 688 |
} |
| 689 |
break; |
| 690 |
|
| 691 |
case SCHATTR_AXIS_AUTO_ORIGIN: |
| 692 |
{ |
| 693 |
if( static_cast< const SfxBoolItem & >(rItemSet.Get( nWhichId )).GetValue() ) |
| 694 |
{ |
| 695 |
aScale.Origin.clear(); |
| 696 |
bSetScale = true; |
| 697 |
} |
| 698 |
} |
| 699 |
break; |
| 700 |
|
| 701 |
case SCHATTR_AXIS_ORIGIN: |
| 702 |
{ |
| 703 |
// only if auto is false |
| 704 |
if( ! (rItemSet.Get( SCHATTR_AXIS_AUTO_ORIGIN ).GetValue() )) |
| 705 |
{ |
| 706 |
rItemSet.Get( nWhichId ).QueryValue( aValue ); |
| 707 |
|
| 708 |
if( aScale.Origin != aValue ) |
| 709 |
{ |
| 710 |
aScale.Origin = aValue; |
| 711 |
bSetScale = true; |
| 712 |
|
| 713 |
if( !AxisHelper::isAxisPositioningEnabled() ) |
| 714 |
{ |
| 715 |
//keep old and new settings for axis positioning in sync somehow |
| 716 |
rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( |
| 717 |
m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
| 718 |
|
| 719 |
sal_Int32 nDimensionIndex=0; |
| 720 |
sal_Int32 nAxisIndex=0; |
| 721 |
if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 ) |
| 722 |
{ |
| 723 |
rtl::Reference< Axis > xCrossingMainAxis = AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ); |
| 724 |
if( xCrossingMainAxis.is() ) |
| 725 |
{ |
| 726 |
double fValue = 0.0; |
| 727 |
if( aValue >>= fValue ) |
| 728 |
{ |
| 729 |
xCrossingMainAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( css::chart::ChartAxisPosition_VALUE )); |
| 730 |
xCrossingMainAxis->setPropertyValue( u"CrossoverValue"_ustr , uno::Any( fValue )); |
| 731 |
} |
| 732 |
else |
| 733 |
xCrossingMainAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( css::chart::ChartAxisPosition_START )); |
| 734 |
} |
| 735 |
} |
| 736 |
} |
| 737 |
} |
| 738 |
} |
| 739 |
} |
| 740 |
break; |
| 741 |
|
| 742 |
case SCHATTR_AXIS_POSITION: |
| 743 |
{ |
| 744 |
css::chart::ChartAxisPosition eAxisPos = |
| 745 |
static_cast<css::chart::ChartAxisPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); |
| 746 |
|
| 747 |
css::chart::ChartAxisPosition eOldAxisPos( css::chart::ChartAxisPosition_ZERO ); |
| 748 |
bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eOldAxisPos ); |
| 749 |
|
| 750 |
if( !bPropExisted || ( eOldAxisPos != eAxisPos )) |
| 751 |
{ |
| 752 |
GetPropertySet()->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( eAxisPos )); |
| 753 |
bChangedOtherwise = true; |
| 754 |
|
| 755 |
//move the parallel axes to the other side if necessary |
| 756 |
if( eAxisPos==css::chart::ChartAxisPosition_START || eAxisPos==css::chart::ChartAxisPosition_END ) |
| 757 |
{ |
| 758 |
rtl::Reference<Diagram> xDiagram = m_xChartDoc->getFirstChartDiagram(); |
| 759 |
rtl::Reference< Axis > xParallelAxis = AxisHelper::getParallelAxis( m_xAxis, xDiagram ); |
| 760 |
if( xParallelAxis.is() ) |
| 761 |
{ |
| 762 |
css::chart::ChartAxisPosition eOtherPos; |
| 763 |
if( xParallelAxis->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eOtherPos ) |
| 764 |
{ |
| 765 |
if( eOtherPos == eAxisPos ) |
| 766 |
{ |
| 767 |
css::chart::ChartAxisPosition eOppositePos = |
| 768 |
(eAxisPos==css::chart::ChartAxisPosition_START) |
| 769 |
? css::chart::ChartAxisPosition_END |
| 770 |
: css::chart::ChartAxisPosition_START; |
| 771 |
xParallelAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( eOppositePos )); |
| 772 |
} |
| 773 |
} |
| 774 |
} |
| 775 |
} |
| 776 |
} |
| 777 |
} |
| 778 |
break; |
| 779 |
|
| 780 |
case SCHATTR_AXIS_POSITION_VALUE: |
| 781 |
{ |
| 782 |
double fValue = static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue(); |
| 783 |
|
| 784 |
double fOldValue = 0.0; |
| 785 |
bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"CrossoverValue"_ustr ) >>= fOldValue ); |
| 786 |
|
| 787 |
if( !bPropExisted || ( fOldValue != fValue )) |
| 788 |
{ |
| 789 |
GetPropertySet()->setPropertyValue( u"CrossoverValue"_ustr , uno::Any( fValue )); |
| 790 |
bChangedOtherwise = true; |
| 791 |
|
| 792 |
//keep old and new settings for axis positioning in sync somehow |
| 793 |
{ |
| 794 |
rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( |
| 795 |
m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); |
| 796 |
|
| 797 |
sal_Int32 nDimensionIndex=0; |
| 798 |
sal_Int32 nAxisIndex=0; |
| 799 |
if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 ) |
| 800 |
{ |
| 801 |
rtl::Reference< Axis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) ); |
| 802 |
if( xCrossingMainAxis.is() ) |
| 803 |
{ |
| 804 |
ScaleData aCrossingScale( xCrossingMainAxis->getScaleData() ); |
| 805 |
aCrossingScale.Origin <<= fValue; |
| 806 |
xCrossingMainAxis->setScaleData(aCrossingScale); |
| 807 |
} |
| 808 |
} |
| 809 |
} |
| 810 |
} |
| 811 |
} |
| 812 |
break; |
| 813 |
|
| 814 |
case SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION: |
| 815 |
{ |
| 816 |
bool bNewValue = static_cast<const SfxBoolItem &> (rItemSet.Get(nWhichId)).GetValue(); |
| 817 |
bool bOldValue = aScale.ShiftedCategoryPosition; |
| 818 |
if (bOldValue != bNewValue) |
| 819 |
{ |
| 820 |
aScale.ShiftedCategoryPosition = bNewValue; |
| 821 |
bSetScale = true; |
| 822 |
} |
| 823 |
} |
| 824 |
break; |
| 825 |
|
| 826 |
case SCHATTR_AXIS_LABEL_POSITION: |
| 827 |
{ |
| 828 |
css::chart::ChartAxisLabelPosition ePos = |
| 829 |
static_cast<css::chart::ChartAxisLabelPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); |
| 830 |
|
| 831 |
css::chart::ChartAxisLabelPosition eOldPos( css::chart::ChartAxisLabelPosition_NEAR_AXIS ); |
| 832 |
bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"LabelPosition"_ustr ) >>= eOldPos ); |
| 833 |
|
| 834 |
if( !bPropExisted || ( eOldPos != ePos )) |
| 835 |
{ |
| 836 |
GetPropertySet()->setPropertyValue( u"LabelPosition"_ustr , uno::Any( ePos )); |
| 837 |
bChangedOtherwise = true; |
| 838 |
|
| 839 |
//move the parallel axes to the other side if necessary |
| 840 |
if( ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_START || ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_END ) |
| 841 |
{ |
| 842 |
rtl::Reference<Diagram> xDiagram = m_xChartDoc->getFirstChartDiagram(); |
| 843 |
rtl::Reference< Axis > xParallelAxis = AxisHelper::getParallelAxis( m_xAxis, xDiagram ); |
| 844 |
if( xParallelAxis.is() ) |
| 845 |
{ |
| 846 |
css::chart::ChartAxisLabelPosition eOtherPos; |
| 847 |
if( xParallelAxis->getPropertyValue( u"LabelPosition"_ustr ) >>= eOtherPos ) |
| 848 |
{ |
| 849 |
if( eOtherPos == ePos ) |
| 850 |
{ |
| 851 |
css::chart::ChartAxisLabelPosition eOppositePos = |
| 852 |
(ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_START) |
| 853 |
? css::chart::ChartAxisLabelPosition_OUTSIDE_END |
| 854 |
: css::chart::ChartAxisLabelPosition_OUTSIDE_START; |
| 855 |
xParallelAxis->setPropertyValue( u"LabelPosition"_ustr , uno::Any( eOppositePos )); |
| 856 |
} |
| 857 |
} |
| 858 |
} |
| 859 |
} |
| 860 |
} |
| 861 |
} |
| 862 |
break; |
| 863 |
|
| 864 |
case SCHATTR_AXIS_MARK_POSITION: |
| 865 |
{ |
| 866 |
css::chart::ChartAxisMarkPosition ePos = |
| 867 |
static_cast<css::chart::ChartAxisMarkPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); |
| 868 |
|
| 869 |
css::chart::ChartAxisMarkPosition eOldPos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); |
| 870 |
bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"MarkPosition"_ustr ) >>= eOldPos ); |
| 871 |
|
| 872 |
if( !bPropExisted || ( eOldPos != ePos )) |
| 873 |
{ |
| 874 |
GetPropertySet()->setPropertyValue( u"MarkPosition"_ustr , uno::Any( ePos )); |
| 875 |
bChangedOtherwise = true; |
| 876 |
} |
| 877 |
} |
| 878 |
break; |
| 879 |
|
| 880 |
case SCHATTR_TEXT_DEGREES: |
| 881 |
{ |
| 882 |
double fVal = toDegrees(rItemSet.Get(SCHATTR_TEXT_DEGREES).GetValue()); |
| 883 |
double fOldVal = 0.0; |
| 884 |
bool bPropExisted = |
| 885 |
( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fOldVal ); |
| 886 |
|
| 887 |
if( ! bPropExisted || fOldVal != fVal ) |
| 888 |
{ |
| 889 |
GetPropertySet()->setPropertyValue( u"TextRotation"_ustr , uno::Any( fVal )); |
| 890 |
bChangedOtherwise = true; |
| 891 |
} |
| 892 |
} |
| 893 |
break; |
| 894 |
|
| 895 |
case SID_ATTR_NUMBERFORMAT_VALUE: |
| 896 |
{ |
| 897 |
if( m_pExplicitScale ) |
| 898 |
{ |
| 899 |
bool bUseSourceFormat = |
| 900 |
rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE ).GetValue(); |
| 901 |
|
| 902 |
if( ! bUseSourceFormat ) |
| 903 |
{ |
| 904 |
sal_Int32 nFmt = static_cast< sal_Int32 >( |
| 905 |
static_cast< const SfxUInt32Item & >( |
| 906 |
rItemSet.Get( nWhichId )).GetValue()); |
| 907 |
|
| 908 |
aValue <<= nFmt; |
| 909 |
if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) != aValue) |
| 910 |
{ |
| 911 |
GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT , aValue); |
| 912 |
bChangedOtherwise = true; |
| 913 |
} |
| 914 |
} |
| 915 |
} |
| 916 |
} |
| 917 |
break; |
| 918 |
|
| 919 |
case SID_ATTR_NUMBERFORMAT_SOURCE: |
| 920 |
{ |
| 921 |
bool bUseSourceFormat = |
| 922 |
static_cast< const SfxBoolItem & >( |
| 923 |
rItemSet.Get( nWhichId )).GetValue(); |
| 924 |
GetPropertySet()->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(bUseSourceFormat)); |
| 925 |
|
| 926 |
bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue(); |
| 927 |
|
| 928 |
bChangedOtherwise = (bUseSourceFormat == bNumberFormatIsSet); |
| 929 |
if( bChangedOtherwise ) |
| 930 |
{ |
| 931 |
if( ! bUseSourceFormat ) |
| 932 |
{ |
| 933 |
SfxItemState aState = rItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_VALUE ); |
| 934 |
if( aState == SfxItemState::SET ) |
| 935 |
{ |
| 936 |
sal_Int32 nFormatKey = static_cast< sal_Int32 >( |
| 937 |
rItemSet.Get( SID_ATTR_NUMBERFORMAT_VALUE ).GetValue()); |
| 938 |
aValue <<= nFormatKey; |
| 939 |
} |
| 940 |
else |
| 941 |
{ |
| 942 |
rtl::Reference< BaseCoordinateSystem > xCooSys = |
| 943 |
AxisHelper::getCoordinateSystemOfAxis( |
| 944 |
m_xAxis, m_xChartDoc->getFirstChartDiagram() ); |
| 945 |
|
| 946 |
sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( |
| 947 |
m_xAxis, xCooSys, m_xChartDoc); |
| 948 |
|
| 949 |
aValue <<= nFormatKey; |
| 950 |
} |
| 951 |
} |
| 952 |
// else set a void Any |
| 953 |
GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT , aValue); |
| 954 |
} |
| 955 |
} |
| 956 |
break; |
| 957 |
|
| 958 |
case SCHATTR_AXISTYPE: |
| 959 |
{ |
| 960 |
sal_Int32 nNewAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();//css::chart2::AxisType |
| 961 |
aScale.AxisType = nNewAxisType; |
| 962 |
bSetScale = true; |
| 963 |
} |
| 964 |
break; |
| 965 |
|
| 966 |
case SCHATTR_AXIS_AUTO_DATEAXIS: |
| 967 |
{ |
| 968 |
bool bNewValue = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); |
| 969 |
bool bOldValue = aScale.AutoDateAxis; |
| 970 |
if( bOldValue != bNewValue ) |
| 971 |
{ |
| 972 |
aScale.AutoDateAxis = bNewValue; |
| 973 |
bSetScale = true; |
| 974 |
} |
| 975 |
} |
| 976 |
break; |
| 977 |
} |
| 978 |
|
| 979 |
if( bSetScale ) |
| 980 |
m_xAxis->setScaleData( aScale ); |
| 981 |
|
| 982 |
return (bSetScale || bChangedOtherwise); |
| 983 |
} |
| 984 |
|
| 985 |
} |
| 986 |
|
| 987 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |