| 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 "WrappedSymbolProperties.hxx" |
| 21 |
#include "WrappedSeriesOrDiagramProperty.hxx" |
| 22 |
#include <FastPropertyIdRanges.hxx> |
| 23 |
#include <ChartType.hxx> |
| 24 |
#include <com/sun/star/chart2/Symbol.hpp> |
| 25 |
#include <com/sun/star/chart2/SymbolStyle.hpp> |
| 26 |
#include <com/sun/star/awt/Size.hpp> |
| 27 |
#include <com/sun/star/beans/PropertyAttribute.hpp> |
| 28 |
#include <com/sun/star/beans/XPropertyState.hpp> |
| 29 |
#include <com/sun/star/chart/ChartSymbolType.hpp> |
| 30 |
#include <com/sun/star/drawing/LineStyle.hpp> |
| 31 |
#include <vcl/GraphicLoader.hxx> |
| 32 |
|
| 33 |
#include <vcl/graph.hxx> |
| 34 |
#include <comphelper/diagnose_ex.hxx> |
| 35 |
|
| 36 |
using namespace ::com::sun::star; |
| 37 |
using ::com::sun::star::uno::Any; |
| 38 |
using ::com::sun::star::uno::Reference; |
| 39 |
using ::com::sun::star::beans::Property; |
| 40 |
|
| 41 |
namespace chart::wrapper |
| 42 |
{ |
| 43 |
|
| 44 |
namespace |
| 45 |
{ |
| 46 |
|
| 47 |
class WrappedSymbolTypeProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 > |
| 48 |
{ |
| 49 |
public: |
| 50 |
virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; |
| 51 |
virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& aNewValue ) const override; |
| 52 |
|
| 53 |
virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; |
| 54 |
virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
| 55 |
|
| 56 |
explicit WrappedSymbolTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 57 |
tSeriesOrDiagramPropertyType ePropertyType); |
| 58 |
}; |
| 59 |
|
| 60 |
class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty<OUString> |
| 61 |
{ |
| 62 |
public: |
| 63 |
virtual OUString getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override; |
| 64 |
virtual void setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet, OUString const & xNewGraphicURL) const override; |
| 65 |
|
| 66 |
explicit WrappedSymbolBitmapURLProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 67 |
tSeriesOrDiagramPropertyType ePropertyType); |
| 68 |
}; |
| 69 |
|
| 70 |
class WrappedSymbolBitmapProperty : public WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>> |
| 71 |
{ |
| 72 |
public: |
| 73 |
virtual uno::Reference<graphic::XGraphic> getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override; |
| 74 |
virtual void setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet, uno::Reference<graphic::XGraphic> const & xNewGraphic) const override; |
| 75 |
|
| 76 |
explicit WrappedSymbolBitmapProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 77 |
tSeriesOrDiagramPropertyType ePropertyType); |
| 78 |
}; |
| 79 |
|
| 80 |
class WrappedSymbolSizeProperty : public WrappedSeriesOrDiagramProperty< awt::Size > |
| 81 |
{ |
| 82 |
public: |
| 83 |
virtual awt::Size getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; |
| 84 |
virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const awt::Size& aNewSize ) const override; |
| 85 |
virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
| 86 |
|
| 87 |
explicit WrappedSymbolSizeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 88 |
tSeriesOrDiagramPropertyType ePropertyType); |
| 89 |
}; |
| 90 |
|
| 91 |
class WrappedSymbolAndLinesProperty : public WrappedSeriesOrDiagramProperty< bool > |
| 92 |
{ |
| 93 |
public: |
| 94 |
virtual bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; |
| 95 |
virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const bool& bDrawLines ) const override; |
| 96 |
virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
| 97 |
|
| 98 |
explicit WrappedSymbolAndLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 99 |
tSeriesOrDiagramPropertyType ePropertyType); |
| 100 |
}; |
| 101 |
|
| 102 |
enum |
| 103 |
{ |
| 104 |
//symbol properties |
| 105 |
PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP, |
| 106 |
PROP_CHART_SYMBOL_BITMAP_URL, |
| 107 |
PROP_CHART_SYMBOL_BITMAP, |
| 108 |
PROP_CHART_SYMBOL_SIZE, |
| 109 |
PROP_CHART_SYMBOL_AND_LINES |
| 110 |
}; |
| 111 |
|
| 112 |
sal_Int32 lcl_getSymbolType( const css::chart2::Symbol& rSymbol ) |
| 113 |
{ |
| 114 |
sal_Int32 nSymbol = css::chart::ChartSymbolType::NONE; |
| 115 |
switch( rSymbol.Style ) |
| 116 |
{ |
| 117 |
case chart2::SymbolStyle_NONE: |
| 118 |
break; |
| 119 |
case chart2::SymbolStyle_AUTO: |
| 120 |
case chart2::SymbolStyle_POLYGON://new feature |
| 121 |
nSymbol = css::chart::ChartSymbolType::AUTO; |
| 122 |
break; |
| 123 |
case chart2::SymbolStyle_STANDARD: |
| 124 |
nSymbol = rSymbol.StandardSymbol%15; |
| 125 |
break; |
| 126 |
case chart2::SymbolStyle_GRAPHIC: |
| 127 |
nSymbol = css::chart::ChartSymbolType::BITMAPURL; |
| 128 |
break; |
| 129 |
default: |
| 130 |
nSymbol = css::chart::ChartSymbolType::AUTO; |
| 131 |
break; |
| 132 |
} |
| 133 |
return nSymbol; |
| 134 |
} |
| 135 |
void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol ) |
| 136 |
{ |
| 137 |
switch( nSymbolType ) |
| 138 |
{ |
| 139 |
case css::chart::ChartSymbolType::NONE: |
| 140 |
rSymbol.Style = chart2::SymbolStyle_NONE; |
| 141 |
break; |
| 142 |
case css::chart::ChartSymbolType::AUTO: |
| 143 |
rSymbol.Style = chart2::SymbolStyle_AUTO; |
| 144 |
break; |
| 145 |
case css::chart::ChartSymbolType::BITMAPURL: |
| 146 |
rSymbol.Style = chart2::SymbolStyle_GRAPHIC; |
| 147 |
break; |
| 148 |
default: |
| 149 |
rSymbol.Style = chart2::SymbolStyle_STANDARD; |
| 150 |
rSymbol.StandardSymbol = nSymbolType; |
| 151 |
break; |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
void lcl_addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList |
| 156 |
, const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact |
| 157 |
, tSeriesOrDiagramPropertyType ePropertyType ) |
| 158 |
{ |
| 159 |
rList.emplace_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) ); |
| 160 |
rList.emplace_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) ); |
| 161 |
rList.emplace_back( new WrappedSymbolBitmapProperty( spChart2ModelContact, ePropertyType ) ); |
| 162 |
rList.emplace_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) ); |
| 163 |
rList.emplace_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) ); |
| 164 |
} |
| 165 |
|
| 166 |
}//anonymous namespace |
| 167 |
|
| 168 |
void WrappedSymbolProperties::addProperties( std::vector< Property > & rOutProperties ) |
| 169 |
{ |
| 170 |
rOutProperties.emplace_back( "SymbolType", |
| 171 |
PROP_CHART_SYMBOL_TYPE, |
| 172 |
cppu::UnoType<sal_Int32>::get(), |
| 173 |
beans::PropertyAttribute::BOUND |
| 174 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 175 |
|
| 176 |
rOutProperties.emplace_back( "SymbolBitmapURL", |
| 177 |
PROP_CHART_SYMBOL_BITMAP_URL, |
| 178 |
cppu::UnoType<OUString>::get(), |
| 179 |
beans::PropertyAttribute::BOUND |
| 180 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 181 |
|
| 182 |
rOutProperties.emplace_back( "SymbolBitmap", |
| 183 |
PROP_CHART_SYMBOL_BITMAP, |
| 184 |
cppu::UnoType<graphic::XGraphic>::get(), |
| 185 |
beans::PropertyAttribute::BOUND |
| 186 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 187 |
|
| 188 |
rOutProperties.emplace_back( "SymbolSize", |
| 189 |
PROP_CHART_SYMBOL_SIZE, |
| 190 |
cppu::UnoType<awt::Size>::get(), |
| 191 |
beans::PropertyAttribute::BOUND |
| 192 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 193 |
|
| 194 |
rOutProperties.emplace_back( "Lines", |
| 195 |
PROP_CHART_SYMBOL_AND_LINES, |
| 196 |
cppu::UnoType<bool>::get(), |
| 197 |
beans::PropertyAttribute::BOUND |
| 198 |
| beans::PropertyAttribute::MAYBEDEFAULT ); |
| 199 |
} |
| 200 |
|
| 201 |
void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList |
| 202 |
, const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact ) |
| 203 |
{ |
| 204 |
lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES ); |
| 205 |
} |
| 206 |
|
| 207 |
void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList |
| 208 |
, const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact ) |
| 209 |
{ |
| 210 |
lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM ); |
| 211 |
} |
| 212 |
|
| 213 |
WrappedSymbolTypeProperty::WrappedSymbolTypeProperty( |
| 214 |
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 215 |
tSeriesOrDiagramPropertyType ePropertyType ) |
| 216 |
: WrappedSeriesOrDiagramProperty< sal_Int32 >( u"SymbolType"_ustr |
| 217 |
, uno::Any( css::chart::ChartSymbolType::NONE ) |
| 218 |
, spChart2ModelContact |
| 219 |
, ePropertyType ) |
| 220 |
{ |
| 221 |
} |
| 222 |
|
| 223 |
sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const |
| 224 |
{ |
| 225 |
sal_Int32 aRet = 0; |
| 226 |
m_aDefaultValue >>= aRet; |
| 227 |
chart2::Symbol aSymbol; |
| 228 |
if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol ) ) |
| 229 |
aRet = lcl_getSymbolType( aSymbol ); |
| 230 |
return aRet; |
| 231 |
} |
| 232 |
|
| 233 |
void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nSymbolType ) const |
| 234 |
{ |
| 235 |
if(!xSeriesPropertySet.is()) |
| 236 |
return; |
| 237 |
|
| 238 |
chart2::Symbol aSymbol; |
| 239 |
xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol; |
| 240 |
|
| 241 |
lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol ); |
| 242 |
xSeriesPropertySet->setPropertyValue( u"Symbol"_ustr, uno::Any( aSymbol ) ); |
| 243 |
} |
| 244 |
|
| 245 |
Any WrappedSymbolTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
| 246 |
{ |
| 247 |
//the old chart (< OOo 2.3) needs symbol-type="automatic" at the plot-area if any of the series should be able to have symbols |
| 248 |
if( m_ePropertyType == DIAGRAM ) |
| 249 |
{ |
| 250 |
bool bHasAmbiguousValue = false; |
| 251 |
sal_Int32 aValue = 0; |
| 252 |
if( detectInnerValue( aValue, bHasAmbiguousValue ) ) |
| 253 |
{ |
| 254 |
if(bHasAmbiguousValue) |
| 255 |
{ |
| 256 |
m_aOuterValue <<= css::chart::ChartSymbolType::AUTO; |
| 257 |
} |
| 258 |
else |
| 259 |
{ |
| 260 |
if( aValue == css::chart::ChartSymbolType::NONE ) |
| 261 |
m_aOuterValue <<= css::chart::ChartSymbolType::NONE; |
| 262 |
else |
| 263 |
m_aOuterValue <<= css::chart::ChartSymbolType::AUTO; |
| 264 |
} |
| 265 |
} |
| 266 |
return m_aOuterValue; |
| 267 |
} |
| 268 |
else |
| 269 |
{ |
| 270 |
css::uno::Any aRet( m_aDefaultValue ); |
| 271 |
aRet <<= getValueFromSeries( xInnerPropertySet ); |
| 272 |
return aRet; |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const |
| 277 |
{ |
| 278 |
//the special situation for this property here is that the diagram default can be |
| 279 |
//different from the normal default and different from all singles series values |
| 280 |
//so we need to return PropertyState_DIRECT_VALUE for more cases |
| 281 |
|
| 282 |
if( m_ePropertyType == DATA_SERIES && //single series or point |
| 283 |
m_spChart2ModelContact) |
| 284 |
{ |
| 285 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 286 |
rtl::Reference< ::chart::DataSeries > xSeries( dynamic_cast<DataSeries*>(xInnerPropertyState.get()) ); |
| 287 |
rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); |
| 288 |
if (xChartType.is() && xChartType->isSupportingSymbolProperties(2)) |
| 289 |
return beans::PropertyState_DIRECT_VALUE; |
| 290 |
} |
| 291 |
return WrappedProperty::getPropertyState( xInnerPropertyState ); |
| 292 |
} |
| 293 |
|
| 294 |
WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty( |
| 295 |
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 296 |
tSeriesOrDiagramPropertyType ePropertyType ) |
| 297 |
: WrappedSeriesOrDiagramProperty<OUString>(u"SymbolBitmapURL"_ustr, |
| 298 |
uno::Any(OUString()), spChart2ModelContact, ePropertyType) |
| 299 |
{ |
| 300 |
} |
| 301 |
|
| 302 |
OUString WrappedSymbolBitmapURLProperty::getValueFromSeries(const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/) const |
| 303 |
{ |
| 304 |
return OUString(); |
| 305 |
} |
| 306 |
|
| 307 |
void WrappedSymbolBitmapURLProperty::setValueToSeries( |
| 308 |
const Reference< beans::XPropertySet >& xSeriesPropertySet, |
| 309 |
OUString const & xNewGraphicURL) const |
| 310 |
{ |
| 311 |
if (!xSeriesPropertySet.is()) |
| 312 |
return; |
| 313 |
|
| 314 |
chart2::Symbol aSymbol; |
| 315 |
if (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) |
| 316 |
{ |
| 317 |
if (!xNewGraphicURL.isEmpty()) |
| 318 |
{ |
| 319 |
Graphic aGraphic = vcl::graphic::loadFromURL(xNewGraphicURL); |
| 320 |
aSymbol.Graphic.set(aGraphic.GetXGraphic()); |
| 321 |
xSeriesPropertySet->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); |
| 322 |
} |
| 323 |
} |
| 324 |
} |
| 325 |
|
| 326 |
WrappedSymbolBitmapProperty::WrappedSymbolBitmapProperty( |
| 327 |
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 328 |
tSeriesOrDiagramPropertyType ePropertyType ) |
| 329 |
: WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>(u"SymbolBitmap"_ustr, |
| 330 |
uno::Any(uno::Reference<graphic::XGraphic>()), spChart2ModelContact, ePropertyType) |
| 331 |
{ |
| 332 |
} |
| 333 |
|
| 334 |
uno::Reference<graphic::XGraphic> WrappedSymbolBitmapProperty::getValueFromSeries(const Reference< beans::XPropertySet >& xSeriesPropertySet) const |
| 335 |
{ |
| 336 |
uno::Reference<graphic::XGraphic> xGraphic; |
| 337 |
m_aDefaultValue >>= xGraphic; |
| 338 |
|
| 339 |
chart2::Symbol aSymbol; |
| 340 |
if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) |
| 341 |
&& aSymbol.Graphic.is()) |
| 342 |
{ |
| 343 |
xGraphic = aSymbol.Graphic; |
| 344 |
} |
| 345 |
return xGraphic; |
| 346 |
} |
| 347 |
|
| 348 |
void WrappedSymbolBitmapProperty::setValueToSeries( |
| 349 |
const Reference< beans::XPropertySet >& xSeriesPropertySet, |
| 350 |
uno::Reference<graphic::XGraphic> const & xNewGraphic) const |
| 351 |
{ |
| 352 |
if (!xSeriesPropertySet.is()) |
| 353 |
return; |
| 354 |
|
| 355 |
chart2::Symbol aSymbol; |
| 356 |
if (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) |
| 357 |
{ |
| 358 |
if (xNewGraphic.is()) |
| 359 |
{ |
| 360 |
aSymbol.Graphic.set(xNewGraphic); |
| 361 |
xSeriesPropertySet->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); |
| 362 |
} |
| 363 |
} |
| 364 |
} |
| 365 |
|
| 366 |
namespace |
| 367 |
{ |
| 368 |
|
| 369 |
void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol ) |
| 370 |
{ |
| 371 |
if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC ) |
| 372 |
return; |
| 373 |
if( rSymbol.Size.Width != -1 ) |
| 374 |
return; |
| 375 |
if( rSymbol.Size.Height != -1 ) |
| 376 |
return; |
| 377 |
|
| 378 |
//find a good automatic size |
| 379 |
try |
| 380 |
{ |
| 381 |
const awt::Size aDefaultSize(250,250); |
| 382 |
awt::Size aSize = aDefaultSize; |
| 383 |
uno::Reference< beans::XPropertySet > xProp( rSymbol.Graphic, uno::UNO_QUERY ); |
| 384 |
if( xProp.is() ) |
| 385 |
{ |
| 386 |
bool bFoundSize = false; |
| 387 |
try |
| 388 |
{ |
| 389 |
if( xProp->getPropertyValue( u"Size100thMM"_ustr ) >>= aSize ) |
| 390 |
{ |
| 391 |
if( aSize.Width == 0 && aSize.Height == 0 ) |
| 392 |
aSize = aDefaultSize; |
| 393 |
else |
| 394 |
bFoundSize = true; |
| 395 |
} |
| 396 |
} |
| 397 |
catch( const uno::Exception& ) |
| 398 |
{ |
| 399 |
TOOLS_WARN_EXCEPTION("chart2", "" ); |
| 400 |
} |
| 401 |
|
| 402 |
if(!bFoundSize) |
| 403 |
{ |
| 404 |
awt::Size aAWTPixelSize(10,10); |
| 405 |
if( xProp->getPropertyValue( u"SizePixel"_ustr ) >>= aAWTPixelSize ) |
| 406 |
{ |
| 407 |
Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height); |
| 408 |
Size aNewSize = o3tl::convert(aPixelSize, o3tl::Length::pt, o3tl::Length::mm100); |
| 409 |
|
| 410 |
aSize = awt::Size( aNewSize.Width(), aNewSize.Height() ); |
| 411 |
|
| 412 |
if( aSize.Width == 0 && aSize.Height == 0 ) |
| 413 |
aSize = aDefaultSize; |
| 414 |
} |
| 415 |
} |
| 416 |
} |
| 417 |
rSymbol.Size = aSize; |
| 418 |
} |
| 419 |
catch( const uno::Exception& ) |
| 420 |
{ |
| 421 |
TOOLS_WARN_EXCEPTION("chart2", "" ); |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
}//end anonymous namespace |
| 426 |
|
| 427 |
WrappedSymbolSizeProperty::WrappedSymbolSizeProperty( |
| 428 |
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 429 |
tSeriesOrDiagramPropertyType ePropertyType ) |
| 430 |
: WrappedSeriesOrDiagramProperty< awt::Size >( u"SymbolSize"_ustr |
| 431 |
, uno::Any( awt::Size(250,250) ), spChart2ModelContact, ePropertyType ) |
| 432 |
{ |
| 433 |
} |
| 434 |
|
| 435 |
awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const |
| 436 |
{ |
| 437 |
awt::Size aRet; |
| 438 |
m_aDefaultValue >>= aRet; |
| 439 |
chart2::Symbol aSymbol; |
| 440 |
if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol )) |
| 441 |
aRet = aSymbol.Size; |
| 442 |
return aRet; |
| 443 |
} |
| 444 |
|
| 445 |
void WrappedSymbolSizeProperty::setValueToSeries( |
| 446 |
const Reference< beans::XPropertySet >& xSeriesPropertySet, |
| 447 |
const awt::Size& aNewSize ) const |
| 448 |
{ |
| 449 |
if(!xSeriesPropertySet.is()) |
| 450 |
return; |
| 451 |
|
| 452 |
chart2::Symbol aSymbol; |
| 453 |
if( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol ) |
| 454 |
{ |
| 455 |
aSymbol.Size = aNewSize; |
| 456 |
lcl_correctSymbolSizeForBitmaps(aSymbol); |
| 457 |
xSeriesPropertySet->setPropertyValue( u"Symbol"_ustr, uno::Any( aSymbol ) ); |
| 458 |
} |
| 459 |
} |
| 460 |
|
| 461 |
beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const |
| 462 |
{ |
| 463 |
//only export symbol size if necessary |
| 464 |
if( m_ePropertyType == DIAGRAM ) |
| 465 |
return beans::PropertyState_DEFAULT_VALUE; |
| 466 |
|
| 467 |
try |
| 468 |
{ |
| 469 |
chart2::Symbol aSymbol; |
| 470 |
Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY ); |
| 471 |
if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol )) |
| 472 |
{ |
| 473 |
if( aSymbol.Style != chart2::SymbolStyle_NONE ) |
| 474 |
return beans::PropertyState_DIRECT_VALUE; |
| 475 |
} |
| 476 |
} |
| 477 |
catch( const uno::Exception & ) |
| 478 |
{ |
| 479 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 480 |
} |
| 481 |
return beans::PropertyState_DEFAULT_VALUE; |
| 482 |
} |
| 483 |
|
| 484 |
WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty( |
| 485 |
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, |
| 486 |
tSeriesOrDiagramPropertyType ePropertyType ) |
| 487 |
: WrappedSeriesOrDiagramProperty< bool >( u"Lines"_ustr |
| 488 |
, uno::Any( true ), spChart2ModelContact, ePropertyType ) |
| 489 |
{ |
| 490 |
} |
| 491 |
|
| 492 |
bool WrappedSymbolAndLinesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/ ) const |
| 493 |
{ |
| 494 |
//do not export this property anymore, instead use a linestyle none for no lines |
| 495 |
return true; |
| 496 |
} |
| 497 |
|
| 498 |
void WrappedSymbolAndLinesProperty::setValueToSeries( |
| 499 |
const Reference< beans::XPropertySet >& xSeriesPropertySet, |
| 500 |
const bool& bDrawLines ) const |
| 501 |
{ |
| 502 |
if(!xSeriesPropertySet.is()) |
| 503 |
return; |
| 504 |
|
| 505 |
drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID ); |
| 506 |
xSeriesPropertySet->getPropertyValue( u"LineStyle"_ustr ) >>= eOldLineStyle; |
| 507 |
if( bDrawLines ) |
| 508 |
{ |
| 509 |
//#i114298# don't overwrite dashed lines with solid lines here |
| 510 |
if( eOldLineStyle == drawing::LineStyle_NONE ) |
| 511 |
xSeriesPropertySet->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_SOLID ) ); |
| 512 |
} |
| 513 |
else |
| 514 |
{ |
| 515 |
if( eOldLineStyle != drawing::LineStyle_NONE ) |
| 516 |
xSeriesPropertySet->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); |
| 517 |
} |
| 518 |
} |
| 519 |
|
| 520 |
beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
| 521 |
{ |
| 522 |
//do not export this property anymore, instead use a linestyle none for no lines |
| 523 |
return beans::PropertyState_DEFAULT_VALUE; |
| 524 |
} |
| 525 |
|
| 526 |
} //namespace chart |
| 527 |
|
| 528 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |